- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I recently started my baby steps into the IoT universe and I have faced an issue with the MQTT library in WICED SDK 3.5.2.
I am trying to connect my device to Azure's IoT Hub, which supports MQTT's Last Will and Testament (LWT) feature. However the LWT functionality does not seem to be exposed through mqtt_api.h.
Looking into the wiced_mqtt_connect() function, I can see that some boilerplate code is present, but the feature is switched off. So, I was wondering if there are there any plans to provide proper support for LWT in the MQTT library?
Thanks,
Stavros.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Is there any documentation for connecting WICED to Azure's IoT Hub using MQTT?
Thanks,
Axel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Haven't seen any. However, the MQTT examples that come with WICED 3.5.2 work fairly easily.
The only thing you need to do is to configure the CA of the SSL certificate in your device so that it accepts the connection from Azure IoT. The cert I am referring to is the "Baltimore CyberTrust Root" and should be already in your certificate store.
Just export it as .pem format and pass it in as the ca_cert in the security argument of the mqtt_conn_open() function.
Good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm referencing below doc:
It needs below settings to make mqtt connection.
* ClientID
* Username
* Password
The description seems different from yours.
Do you have a example settings using mosquitto tool to test Azure IoT?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi axel.lin,
My description is complementary to the document you linked. I just describe a step that is not covered in the WICED SDK for Azure-specific connections through MQTT.
Indeed, ClientID, Username and Password must be defined as that document describes. But you also need to make sure that you use the secure MQTT (port 8883) because Azure will accept no other.
Here is an example connection profile that I would have imported in MQTT.fx if I was to use the Azure IoT Hub that is described in the document you pointed at:
{
"connectionProfiles" : [ {
"recentSubscriptionTopics" : [ ],
"recentPublishTopics" : [ ],
"preDefinedMessages" : [ ],
"brokerAddress" : "contoso.azure-devices.net",
"brokerPort" : "8883",
"lastPublishTopic" : null,
"lastSubscriptionTopic" : null,
"profileName" : "MyDevice01@Contoso",
"scriptsPath" : "",
"connectionOptions" : {
"clientId" : "paho398791429784759",
"connectionTimeout" : 30,
"keepAliveInterval" : 60,
"mqttVersionUseDefault" : true,
"mqttVersion" : "3.1.1",
"cleanSession" : true,
"userName" : "contoso.azure-devices.net/MyDevice01",
"password" : "SharedAccessSignature sr={your hub name}.azure-devices.net%2fdevices%2fyDevice01&sig=vSgHBMUG.....Ntg%3d&se=1456481802g%3d&se=1456481802",
"lwtQos" : 1,
"lwtRetained" : false,
"lastWillDestination" : "devices/MyDevice01/messages/events/dead",
"testament" : "",
"useProxy" : false,
"useHttpsProxy" : false,
"httpsProxyHost" : "",
"httpsProxyPort" : "",
"httpProxyHost" : "",
"httpProxyPort" : "",
"httpProxyUser" : "",
"httpProxyPassword" : "",
"enableSSLTLS" : true,
"sslTlsProtocol" : "TLSv1.2",
"certificateFilesPemFormat" : false,
"selfCreatedCaFile" : "",
"caFile" : "",
"clientCertificateFile" : "",
"clientKeyFile" : "",
"clientKeyPassword" : "",
"useSelfCreatedCA" : false,
"useServerSignedCertificate" : true,
"useTrustedKeystoreFile" : false,
"useCertificateFiles" : false,
"useKeystoreFiles" : false,
"clientKeystoreFilesPemFormat" : false,
"trustedKeystoreOnlyFile" : "",
"trustedKeystoreOnlyPassword" : "",
"trustedKeystoreFile" : "",
"trustedKeystoreAlias" : "",
"trustedKeystorePassword" : "",
"clientKeystoreFile" : "",
"clientKeystorePassword" : "",
"clientKeyPairAlias" : "",
"clientKeyPairPassword" : ""
},
"notificatonsEnabled" : false,
"showLastestMessagesOnly" : false
} ]
}
I hope this helps.
Also, I hope that someone has an insight into my original question.
Cheers,
Stavros.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is LWT supported in v3.7.0?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
suchitra.hullur wrote:
Is LWT supported in v3.7.0?
No.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Axel.lin, is LWT support added in SDK v4.0.1?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
suchitra.hullur wrote:
Hi Axel.lin, is LWT support added in SDK v4.0.1?
No. ( But it's easy to implement supporting LWT by yourself).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Truth is that it LWT is not exposed in WICED SDK's API, but the guts seem to be in place.
With a few modifications you could make LWT work even in 3.5.2. This is what we have done and we have been utilizing LWT against Azure's IoT Hub service.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
kafouros wrote:
Hi axel.lin_1746341,
My description is complementary to the document you linked. I just describe a step that is not covered in the WICED SDK for Azure-specific connections through MQTT.
Indeed, ClientID, Username and Password must be defined as that document describes. But you also need to make sure that you use the secure MQTT (port 8883) because Azure will accept no other.
Here is an example connection profile that I would have imported in MQTT.fx if I was to use the Azure IoT Hub that is described in the document you pointed at:
{
"connectionProfiles" : [ {
"recentSubscriptionTopics" : [ ],
"recentPublishTopics" : [ ],
"preDefinedMessages" : [ ],
"brokerAddress" : "contoso.azure-devices.net",
"brokerPort" : "8883",
"lastPublishTopic" : null,
"lastSubscriptionTopic" : null,
"profileName" : "MyDevice01@Contoso",
"scriptsPath" : "",
"connectionOptions" : {
"clientId" : "paho398791429784759",
"connectionTimeout" : 30,
"keepAliveInterval" : 60,
"mqttVersionUseDefault" : true,
"mqttVersion" : "3.1.1",
"cleanSession" : true,
"userName" : "contoso.azure-devices.net/MyDevice01",
"password" : "SharedAccessSignature sr={your hub name}.azure-devices.net%2fdevices%2fyDevice01&sig=vSgHBMUG.....Ntg%3d&se=1456481802g%3d&se=1456481802",
"lwtQos" : 1,
"lwtRetained" : false,
"lastWillDestination" : "devices/MyDevice01/messages/events/dead",
"testament" : "",
"useProxy" : false,
"useHttpsProxy" : false,
"httpsProxyHost" : "",
"httpsProxyPort" : "",
"httpProxyHost" : "",
"httpProxyPort" : "",
"httpProxyUser" : "",
"httpProxyPassword" : "",
"enableSSLTLS" : true,
"sslTlsProtocol" : "TLSv1.2",
"certificateFilesPemFormat" : false,
"selfCreatedCaFile" : "",
"caFile" : "",
Hi kafouros,
When I test using mosquitto, I must set --capath /etc/ssl/certs/ otherwise the connection fails.
I'm wondering how you connect with "caFile":""?