This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Azure IoT Hub - MQTT
#21
(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

Is there a typo in the filename or is the package removed from your downloads? 

libmosquitto_1.4.15-1_imx6.ipk
Reply


Messages In This Thread
Azure IoT Hub - MQTT - by FatMax - 17.12.2018, 23:00
RE: Azure IoT Hub - MQTT - by FatMax - 21.12.2018, 07:52
RE: Azure IoT Hub - MQTT - by admin - 21.12.2018, 08:26
RE: Azure IoT Hub - MQTT - by FatMax - 10.01.2019, 08:26
RE: Azure IoT Hub - MQTT - by admin - 10.01.2019, 09:55
RE: Azure IoT Hub - MQTT - by Sandstrand - 21.05.2019, 09:15
RE: Azure IoT Hub - MQTT - by FatMax - 03.07.2019, 11:47
RE: Azure IoT Hub - MQTT - by FatMax - 10.01.2019, 11:01
RE: Azure IoT Hub - MQTT - by FatMax - 11.01.2019, 18:26
RE: Azure IoT Hub - MQTT - by Duvan2127 - 04.02.2019, 14:10
RE: Azure IoT Hub - MQTT - by admin - 04.02.2019, 14:50
RE: Azure IoT Hub - MQTT - by Duvan2127 - 04.02.2019, 16:00
RE: Azure IoT Hub - MQTT - by admin - 05.02.2019, 07:38
RE: Azure IoT Hub - MQTT - by Duvan2127 - 05.02.2019, 14:35
RE: Azure IoT Hub - MQTT - by admin - 07.02.2019, 09:04
RE: Azure IoT Hub - MQTT - by Duvan2127 - 15.02.2019, 22:20
RE: Azure IoT Hub - MQTT - by admin - 16.02.2019, 07:21
RE: Azure IoT Hub - MQTT - by edgars - 26.02.2019, 09:18
RE: Azure IoT Hub - MQTT - by FatMax - 01.05.2019, 21:26
RE: Azure IoT Hub - MQTT - by admin - 02.05.2019, 06:46
RE: Azure IoT Hub - MQTT - by FatMax - 02.05.2019, 07:22
RE: Azure IoT Hub - MQTT - by admin - 21.05.2019, 09:27
RE: Azure IoT Hub - MQTT - by admin - 03.07.2019, 12:33
RE: Azure IoT Hub - MQTT - by FatMax - 03.07.2019, 13:06
RE: Azure IoT Hub - MQTT - by admin - 03.07.2019, 13:18
RE: Azure IoT Hub - MQTT - by FatMax - 03.07.2019, 17:48
RE: Azure IoT Hub - MQTT - by admin - 04.07.2019, 06:04
RE: Azure IoT Hub - MQTT - by admin - 04.07.2019, 15:17

Forum Jump: