设备分发功能的例程运行后,您可以在设备端和物联网平台查看日志信息

背景信息

已配置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中的状态码描述根据提示解决问题。