Send telemetry from an IoT Plug and Play device to Azure IoT Hub (azure-iot-sdk-c)

fennyk 20 Reputation points
2024-04-02T02:46:25.5166667+00:00

Hello,

I try to run the demo of azure-iot-sdk-c.

The compile is OK, and the message seems have sent out,

but the monitor-events command can not see any message. Also the AZure IoT Explorer.

See the attachment picture can find the connection string.

Message Receive:

$ az iot hub monitor-events --output table --device-id mydevice --hub-name MYLINUXHUB

Message Send:

$ export IOTHUB_DEVICE_CONNECTION_STRING="HostName=MYLINUXHUB.azure-devices.net;DeviceId=mydevice;SharedAccessKey=EE5iBQTWVxS44FhZmKahYmJxRWdjISrnz6vuFkE3k14="

$ export IOTHUB_DEVICE_SECURITY_TYPE="connectionString"

$ cmake/iothub_client/samples/pnp/pnp_temperature_controller/pnp_temperature_controller

Info: Successfully created device client. Hit Control-C to exit program

Info: Sending maxTempSinceLastReboot property to IoTHub for component thermostat1

Info: Sending maxTempSinceLastReboot property to IoTHub for component thermostat2

-> 10:26:07 CONNECT | VER: 4 | KEEPALIVE: 240 | FLAGS: 192 | USERNAME: MYLINUXHUB.azure-devices.net/mydevice/?api-version=2020-09-30&DeviceClientType=iothubclient%2f1.13.0%20(native%3b%20Linux%3b%20x86_64)&model-id=dtmi%3acom%3aexample%3aTemperatureController%3b1 | PWD: XXXX | CLEAN: 0

<- 10:26:08 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0

-> 10:26:08 SUBSCRIBE | PACKET_ID: 2 | TOPIC_NAME: $iothub/twin/res/# | QOS: 0 | TOPIC_NAME: $iothub/methods/POST/# | QOS: 0

-> 10:26:08 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: devices/mydevice/messages/events/%24.ct=application%2fjson&%24.ce=utf8 | PACKET_ID: 3 | PAYLOAD_LEN: 19

Info: Publish MQTT packet. current_ms:1630, msgPublishTime:1630, msgCreationTime:1630, packet_id:3

-> 10:26:08 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: devices/mydevice/messages/events/%24.ct=application%2fjson&%24.ce=utf8&%24.sub=thermostat1 | PACKET_ID: 4 | PAYLOAD_LEN: 21

Info: Publish MQTT packet. current_ms:1631, msgPublishTime:1631, msgCreationTime:1631, packet_id:4

-> 10:26:08 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: devices/mydevice/messages/events/%24.ct=application%2fjson&%24.ce=utf8&%24.sub=thermostat2 | PACKET_ID: 5 | PAYLOAD_LEN: 21

Info: Publish MQTT packet. current_ms:1631, msgPublishTime:1631, msgCreationTime:1631, packet_id:5

<- 10:26:08 SUBACK | PACKET_ID: 2 | RETURN_CODE: 0 | RETURN_CODE: 0

-> 10:26:08 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/GET/?$rid=6

-> 10:26:08 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=7 | PAYLOAD_LEN: 36

-> 10:26:08 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=8 | PAYLOAD_LEN: 295

-> 10:26:08 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=9 | PAYLOAD_LEN: 58

-> 10:26:08 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=10 | PAYLOAD_LEN: 58

<- 10:26:09 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/200/?$rid=6 | PAYLOAD_LEN: 524

<- 10:26:09 PUBACK | PACKET_ID: 3

-> 10:26:09 SUBSCRIBE | PACKET_ID: 11 | TOPIC_NAME: $iothub/twin/PATCH/properties/desired/# | QOS: 0

<- 10:26:09 PUBACK | PACKET_ID: 4

<- 10:26:09 PUBACK | PACKET_ID: 5

<- 10:26:09 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/204/?$rid=9&$version=42 | PAYLOAD_LEN: 0

<- 10:26:09 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/204/?$rid=7&$version=39 | PAYLOAD_LEN: 0

<- 10:26:09 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/204/?$rid=8&$version=41 | PAYLOAD_LEN: 0

<- 10:26:09 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/204/?$rid=10&$version=40 | PAYLOAD_LEN: 0

<- 10:26:09 SUBACK | PACKET_ID: 11 | RETURN_CODE: 0

MyLinuxHub

IoT-sdk-C

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,120 questions
{count} votes

Accepted answer
  1. Sander van de Velde 28,546 Reputation points MVP
    2024-04-02T06:34:50.3+00:00

    Hello @fennyk,

    welcome to this moderated Azure community forum.

    I noticed the GitHub code was updated a couple of hours ago. Also, the pipeline behind it fails. So, perhaps you run into a broke version?

    Please use the latest LTS version to be sure you use an approved version.

    (and test it without any custom routes, as mentioned in the comment above).

    If it is stil not working, apply an issue to the GitHub repo so you get help from the original owners of this Azure related library.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful