03.07.2019, 11:47
(10.01.2019, 09:55)admin Wrote: Thanks!
First, you need to update MQTT library packages:
New CPU:
https://dl.openrb.com/pkg/libmosquitto_1...1_imx6.ipk
https://dl.openrb.com/pkg/luamosquitto_0.3-2_imx6.ipk
Old CPU:
https://dl.openrb.com/pkg/libmosquitto_1.4.15-1_mxs.ipk
https://dl.openrb.com/pkg/luamosquitto_0.3-2_mxs.ipk
Here's a minimal example that you can use, don't forget to change device_id, broker, username and password parameters. You also need to upload azure.crt via FTP (using ftp username, upload to root directory). Certificate file contents: https://gist.github.com/jsopenrb/5873b20...d6b950151f
Code:device_id = 'DEV_TEST'
broker = 'DEV.azure-devices.net'
port = 8883
username = 'DEV.azure-devices.net/DEV_TEST'
password = 'SharedAccessSignature ...'
mqtt = require('mosquitto')
client = mqtt.new(device_id)
client.ON_CONNECT = function(...)
log('ON_CONNECT', ...)
client:publish('devices/' .. device_id .. '/messages/events/', '{id=456}')
end
client.ON_PUBLISH = function(...)
log('ON_PUBLISH', ...)
end
client.ON_LOG = function(...)
log('ON_LOG', ...)
end
client.ON_DISCONNECT = function(...)
log('ON_DISCONNECT', ...)
end
client:version_set(mqtt.PROTOCOL_V311)
client:tls_set('/home/ftp/azure.crt')
client:login_set(username, password)
client:connect(broker, port)
while true do
res, err, code = client:loop()
if not res then
log('loop error', res, err, code)
os.sleep(1)
end
end
HELLO!
You seem to have removed one of the mosquitto lib files from your server!! Thats a bit of an issue as we have software that downloads and installs those libs automatically. Can you please upload them again?