裝置分發功能的常式運行後,您可以在裝置端和物聯網平台查看日誌資訊。
背景資訊
已配置C Link SDK的裝置分發功能常式,詳細資料,請參見使用樣本。
裝置端日誌
您可以在裝置端查看運行結果。請求日誌:
裝置向物聯網平台發起裝置分發請求的日誌如下。
core_sysdep_network_establish host iot-auth-global.aliyuncs.com port 443, type 0 establish tcp connection with server(host='iot-auth-global.aliyuncs.com', port=[443]) success to establish tcp, fd=3 local port: 37124 [1626074474.366][LK-1000] establish mbedtls connection with server(host='iot-auth-global.aliyuncs.com', port=[443]) [1626074474.466][LK-1000] success to establish mbedtls connection, (cost 45366 bytes in total, max used 48070 bytes) [1626074474.466][LK-040B] > POST /auth/bootstrap HTTP/1.1 [1626074474.466][LK-040B] > Host: iot-auth-global.aliyuncs.com [1626074474.466][LK-040B] > Accept: text/xml,text/javascript,text/html,application/json [1626074474.466][LK-040B] > Content-Type: application/x-www-form-urlencoded;charset=utf-8 [1626074474.466][LK-040B] > Content-Length: 111 [1626074474.466][LK-040B] > [LK-040C] > 70 72 6F 64 75 63 74 4B 65 79 3D 67 37 68 30 67 | productKey=a18** [LK-040C] > 35 77 72 79 34 51 26 64 65 76 69 63 65 4E 61 6D | ******&deviceNam [LK-040C] > 65 3D 4C 69 67 68 74 53 77 69 74 63 68 42 6F 6F | e=LightSwitch&cl [LK-040C] > 74 73 74 72 61 70 26 63 6C 69 65 6E 74 49 64 3D | ientId=a18****** [LK-040C] > 67 37 68 30 67 35 77 72 79 34 51 2E 4C 69 67 68 | **.LightSwitch&r [LK-040C] > 74 53 77 69 74 63 68 42 6F 6F 74 73 74 72 61 70 | esources=mqtt [LK-040C] > 26 72 65 73 6F 75 72 63 65 73 3D 6D 71 74 74 |
- 應答日誌:
物聯網平台收到裝置分發請求後,向裝置端返回接入網域名稱和連接埠號碼,日誌如下。
[1626074474.566][LK-040D] < HTTP/1.1 200 OK [1626074474.566][LK-040D] < Server: Tengine [1626074474.566][LK-040D] < Date: Mon, 12 Jul 2021 07:21:14 GMT [1626074474.566][LK-040D] < Content-Type: text/xml [1626074474.566][LK-040D] < Content-Length: 174 [1626074474.566][LK-040D] < Connection: keep-alive [1626074474.566][LK-040D] < X-Application-Context: iotx-base:oxs-shanghai-global-dns:7001 [1626074474.566][LK-040D] < [LK-040E] < 7B 22 63 6F 64 65 22 3A 32 30 30 2C 22 64 61 74 | {"code":200,"dat [LK-040E] < 61 22 3A 7B 22 69 6E 73 74 61 6E 63 65 49 64 22 | a":{"instanceId" [LK-040E] < 3A 22 69 6F 74 2D 30 36 30 61 30 35 66 63 22 2C | :"iot-06******", [LK-040E] < 22 72 65 73 6F 75 72 63 65 73 22 3A 7B 22 6D 71 | "resources":{"mq [LK-040E] < 74 74 22 3A 7B 22 68 6F 73 74 22 3A 22 69 6F 74 | tt":{"host":"iot [LK-040E] < 2D 30 36 30 61 30 35 66 63 2E 6D 71 74 74 2E 69 | -06******.mqtt.i [LK-040E] < 6F 74 68 75 62 2E 61 6C 69 79 75 6E 63 73 2E 63 | othub.aliyuncs.c [LK-040E] < 6F 6D 22 2C 22 69 70 22 3A 22 31 30 31 2E 31 33 | om","ip":"101.13 [LK-040E] < 33 2E 31 36 36 2E 31 37 32 22 2C 22 70 6F 72 74 | 3.***.***","port [LK-040E] < 22 3A 31 38 38 33 7D 7D 7D 2C 22 6D 65 73 73 61 | ":1883}}},"messa [LK-040E] < 67 65 22 3A 22 73 75 63 63 65 73 73 22 7D | ge":"success"} status code: 200 host: iot-06******.mqtt.iothub.aliyuncs.com, port: 1883
串連日誌:
通過返回的接入網域名稱和連接埠號碼,裝置與物聯網平台建立串連,日誌如下。
[1626074474.566][LK-0313] MQTT user calls aiot_mqtt_connect api, connect [1626074474.566][LK-0317] LightSwitch&a18******** [1626074474.566][LK-0318] 7E8240C1708B26EEF60062B1CAF756DE2016FA5D7A780B0FC334702A37****** [1626074474.566][LK-031D] 101.133.***.*** core_sysdep_network_establish host iot-06******.mqtt.iothub.aliyuncs.com port 1883, type 0 establish tcp connection with server(host='iot-06******.mqtt.iothub.aliyuncs.com', port=[1883]) success to establish tcp, fd=4 local port: 60686 [1626074474.611][LK-1000] establish mbedtls connection with server(host='iot-06******.mqtt.iothub.aliyuncs.com', port=[1883]) [1626074474.677][LK-1000] success to establish mbedtls connection, (cost 44947 bytes in total, max used 47859 bytes) [1626074474.677][LK-0319] a18********.LightSwitch|timestamp=2524608000000,_ss=1,_v=sdk-c-4.1.0,securemode=2,signmethod=hmacsha256,ext=3,_conn=tls_72| [1626074474.733][LK-0313] MQTT connect success in 170 ms AIOT_MQTTEVT_CONNECT
物聯網平台下發的通知日誌:
裝置接入後,如果您在物聯網平台,再次執行裝置分發操作後,裝置端收到如下日誌,表示裝置已分發,裝置原來串連的地區已刪除該裝置。
重要 僅當您在物聯網平台發起裝置分發操作後,裝置才會收到以下日誌。[1626163769.222][LK-0309] pub: /sys/a1wP******/LightSwitch/thing/bootstrap/notify [LK-030A] < 7B 22 6D 65 74 68 6F 64 22 3A 22 74 68 69 6E 67 | {"method":"thing [LK-030A] < 2E 62 6F 6F 74 73 74 72 61 70 2E 6E 6F 74 69 66 | .bootstrap.notif [LK-030A] < 79 22 2C 22 69 64 22 3A 22 31 30 33 39 31 37 35 | y","id":"1039175 [LK-030A] < 33 38 31 22 2C 22 70 61 72 61 6D 73 22 3A 7B 22 | 381","params":{" [LK-030A] < 63 6D 64 22 3A 30 7D 2C 22 76 65 72 73 69 6F 6E | cmd":0},"version [LK-030A] < 22 3A 22 31 2E 30 2E 30 22 7D | ":"1.0.0"} AIOT_BOOTSTRAPRECV_NOTIFY, cmd: 0 [1626163769.222][LK-0309] pub: /sys/a1wP******/LightSwitch/thing/bootstrap/notify_reply [LK-030A] > 7B 22 69 64 22 3A 22 31 30 33 39 31 37 35 33 38 | {"id":"103917538 [LK-030A] > 31 22 2C 22 63 6F 64 65 22 3A 32 30 30 2C 22 64 | 1","code":200,"d [LK-030A] > 61 74 61 22 3A 7B 7D 7D | ata":{}} [1626163769.311][LK-0309] pub: /ext/notify [LK-030A] < 7B 22 74 69 74 6C 65 22 3A 22 6B 69 63 6B 22 2C | {"title":"kick", [LK-030A] < 22 63 6F 6E 74 65 6E 74 22 3A 22 4B 69 63 6B 65 | "content":"Kicke [LK-030A] < 64 20 64 75 65 20 74 6F 20 64 65 76 69 63 65 20 | d due to device [LK-030A] < 64 65 6C 65 74 65 64 22 7D | deleted"} pub, qos: 0, topic: /ext/notify pub, payload: {"title":"kick","content":"Kicked due to device deleted"}
物聯網平台日誌
您可以在物聯網平台控制台,查看裝置的狀態和作業記錄。
線上狀態:
在左側導覽列,選擇
,找到裝置,查看裝置狀態。裝置狀態顯示為線上,則表示裝置與物聯網平台成功串連。作業記錄:
裝置上線後,會自動訂閱系統Topic。
在左側導覽列,選擇
,選擇產品後,查看相關日誌。
後續步驟
作業記錄中出現的錯誤資訊,請參見aiot_bootstrap_api.h中的狀態代碼描述,根據提示解決問題。