After running the broadcast communication sample code, you can view logs on the device and in IoT Platform.
Prerequisites
Configure the C Link SDK broadcast communication sample code. For more information, see Usage Examples.
Device logs
The following logs are generated on the device.
-
Connection logs:
The following log confirms a successful device connection to IoT Platform.
[1583135792.733][LK-0313] MQTT user calls aiot_mqtt_connect api, connect [1583135792.733][LK-0317] LightSwitch&a18wP****** [1583135792.733][LK-0318] 3FC4A3DED5AC5F31C4969CBB1868758B17FAB2E5070FC51C9880910472****** [1583135792.733][LK-0319] a18wP******.LightSwitch|timestamp=2524608000000,_ss=1,_v=sdk-c-4.0.0,securemode=2,signmethod=hmacsha256,ext=1,| establish mbedtls connection with server(host='a18wP******.iot-as-mqtt.cn-shanghai.aliyuncs.com', port=[443]) success to establish mbedtls connection, fd = 6(cost 44763 bytes in total, max used 47675 bytes) [1583135792.888][LK-0313] MQTT connect success in 147 ms AIOT_MQTTEVT_CONNECT -
Topic subscription logs:
To broadcast to all devices of a product, each device must subscribe to the topic. For example, when a device subscribes to
/broadcast/a18wP******/test, it returns the following log.[1624933980.266][LK-0309] sub: /broadcast/a18wP******/test suback, res: -0x0000, packet id: 1, max qos: 1 -
Broadcast message logs
-
Broadcast to a specific topic
Call PubBroadcast to send a message with payload
helloworldto topic/broadcast/a18wP******/test. The device receives the following log.[1624934078.899][LK-0309] pub: /broadcast/a18wP******/test [LK-030A] < 68 65 6C 6C 6F 77 6F 72 6C 64 | helloworld pub, qos: 0, topic: /broadcast/a18wP******/test pub, payload: helloworld -
Broadcast to multiple devices
Call PubBroadcast to send a message with payload
helloworldto all online devices of a product. The device receives the following log.-
Log information
[1624934109.099][LK-0309] pub: /sys/a18wP******/LightSwitch/broadcast/request/1409701944049****** [LK-030A] < 68 65 6C 6C 6F 77 6F 72 6C 64 | helloworld pub, qos: 1, topic: /sys/a18wP******/LightSwitch/broadcast/request/1409701944049****** pub, payload: helloworld -
Log description
In the log,
/sys/a18wP******/LightSwitch/broadcast/request/1409701944049******is the topic for the broadcast message request, and1409701944049******is the message ID. This topic format is defined in broadcast communication.
-
-
IoT Platform logs
Log in to the IoT Platform console. In the left-side navigation pane, choose , and then select a product to view the communication logs for your device.
The Log Service page has four tabs: cloud-side run log, local device log, message trace, and log ingestion. On the cloud-side run log tab, filter by DeviceName, TraceID, Keywords/message ID, Status, or Time Range. The log list shows Time, TraceID, Message Content, DeviceName, Business Type, Operation, Content, and Status.
Next steps
To resolve errors in the run logs, see Common error codes for solutions.