HTTPS协议下载单个文件升级包的OTA升级功能例程运行后,您可以在设备端和物联网平台查看日志信息

前提条件

已配置OTA升级例程./demos/fota_posix_demo.c详细信息,请参见示例代码说明

设备端日志

您可以在设备端查看运行结果。
  • 连接日志:

    出现如下日志,表示设备与物联网平台连接成功。
    [1579511737.377][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1579511737.377][LK-0317] LightSwitch&a18wP******
    [1579511737.377][LK-0318] 779ACA0181ED1C0BD4B1BA7A347C9B172E27EAAB4AA18FC1F9FAD4CED1*******
    [1579511737.377][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 = 3(cost 44763 bytes in total, max used 47675 bytes)
    [1579511737.522][LK-0313] MQTT connect success in 152 ms
    AIOT_MQTTEVT_CONNECT
  • 上报版本号日志:

    以下日志显示设备上报了初始的设备版本号1.0.0
    [1579511737.522][LK-0309] pub: /ota/device/inform/a18wP******/LightSwitch
    
    [LK-030A] > 7B 22 69 64 22 3A 30 2C  20 22 70 61 72 61 6D 73 | {"id":0, "params
    [LK-030A] > 22 3A 7B 22 76 65 72 73  69 6F 6E 22 3A 22 31 2E | ":{"version":"1.
    [LK-030A] > 30 2E 30 22 7D 7D                                | 0.0"}}
  • 接收OTA升级指令的日志:

    在物联网平台创建OTA升级任务,并添加仅含单个文件的升级包后,设备接收以下OTA指令消息。
    [1579511826.577][LK-0309] pub: /ota/device/upgrade/a18wP******/LightSwitch
    
    [LK-030A] < 7B 22 63 6F 64 65 22 3A  22 31 30 30 30 22 2C 22 | {"code":"1000","
    [LK-030A] < 64 61 74 61 22 3A 7B 22  73 69 7A 65 22 3A 31 32 | data":{"size":12
    [LK-030A] < 34 38 33 30 36 2C 22 73  69 67 6E 22 3A 22 34 62 | 48306,"sign":"4b
    [LK-030A] < 66 61 63 65 66 35 63 62  61 30 61 35 36 64 63 32 | facef5cba0a56dc2
    [LK-030A] < 62 65 62 38 65 65 30 33  65 32 62 65 30 61 37 61 | beb8ee03e2be0a7a
    [LK-030A] < 65 64 65 65 65 31 38 38  35 61 63 65 30 66 62 35 | edeee1885ace0fb5
    [LK-030A] < 35 65 61 38 62 62 66 64  39 38 64 61 64 63 22 2C | 5ea8bbfd******",
    [LK-030A] < 22 76 65 72 73 69 6F 6E  22 3A 22 31 2E 31 2E 30 | "version":"1.1.0
    [LK-030A] < 22 2C 22 75 72 6C 22 3A  22 68 74 74 70 73 3A 2F | ","url":"https:/
    [LK-030A] < 2F 6F 74 61 2E 69 6F 74  2D 74 68 69 6E 67 2E 63 | /ota.iot-thing.c
    [LK-030A] < 6E 2D 73 68 61 6E 67 68  61 69 2E 61 6C 69 79 75 | n-shanghai.aliyu
    [LK-030A] < 6E 63 73 2E 63 6F 6D 2F  6F 74 61 2F 36 35 64 66 | ncs.com/ota/65df
    [LK-030A] < 63 64 61 30 34 37 33 62  65 32 39 38 33 36 64 66 | cda0473be29836df
    [LK-030A] < 64 65 35 38 35 34 37 32  37 65 31 32 2F 63 6B 35 | de5854******/ck5
    [LK-030A] < 32 6E 79 6F 31 7A 30 30  30 30 33 39 37 69 69 79 | 2nyo1z0000397iiy
    [LK-030A] < 76 68 6E 72 32 69 2E 62  69 6E 3F 45 78 70 69 72 | ******.bin?Expir
    [LK-030A] < 65 73 3D 31 35 37 39 35  39 38 32 32 36 26 4F 53 | es=1579598226&OS
    [LK-030A] < 53 41 63 63 65 73 73 4B  65 79 49 64 3D 63 53 38 | SAccessKeyId=cS8
    [LK-030A] < 75 52 52 79 35 34 52 73  7A 59 57 6E 61 26 53 69 | uRRy54R******&Si
    [LK-030A] < 67 6E 61 74 75 72 65 3D  42 4F 55 46 51 65 34 68 | gnature=BOUFQe4h
    [LK-030A] < 39 6E 36 41 64 5A 57 46  42 45 49 7A 33 5A 6A 70 | 9n6AdZWFBEIz3Zjp
    [LK-030A] < 42 70 59 25 33 44 22 2C  22 73 69 67 6E 4D 65 74 | ******","signMet
    [LK-030A] < 68 6F 64 22 3A 22 53 48  41 32 35 36 22 7D 2C 22 | hod":"SHA256"},"
    [LK-030A] < 69 64 22 3A 31 35 37 39  35 31 31 38 32 36 35 32 | id":157951182652
    [LK-030A] < 30 2C 22 6D 65 73 73 61  67 65 22 3A 22 73 75 63 | 0,"message":"suc
    [LK-030A] < 63 65 73 73 22 7D                                | cess"}
                                
  • 升级包下载过程日志:

    以下日志显示设备开始下载升级包,并获取下载进度,直至下载完成。

    OTA target firmware version: 1.1.0, size: 1248306 Bytes
    starting download thread in 2 seconds ......
    establish mbedtls connection with server(host='ota.iot-thing.cn-shanghai.aliyuncs.com', port=[443])
    success to establish mbedtls connection, fd = 4(cost 44868 bytes in total, max used 47604 bytes)
    [1579511828.699][LK-040B] > GET /ota/65dfcda0473be29836dfde5854******/ck52nyo1z0000397iiy******.bin?Expires=1579598226&OSSAccessKeyId=cS8uRRy54R******&Signature
    [1579511828.699][LK-040B] > Host: ota.iot-thing.cn-shanghai.aliyuncs.com
    [1579511828.699][LK-040B] > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [1579511828.699][LK-040B] > Range: bytes=0-
    [1579511828.699][LK-040B] > Content-Length: 0
    [1579511828.699][LK-040B] >
    [1579511828.699][LK-0309] pub: /ota/device/progress/a18wP******/LightSwitch
    
    [LK-030A] > 7B 22 69 64 22 3A 31 2C  20 22 70 61 72 61 6D 73 | {"id":1, "params
    [LK-030A] > 22 3A 7B 22 73 74 65 70  22 3A 22 30 22 2C 22 64 | ":{"step":"0","d
    [LK-030A] > 65 73 63 22 3A 22 22 7D  7D                      | esc":""}}
    
    [1579511828.755][LK-040D] < HTTP/1.1 206 Partial Content
    [1579511828.755][LK-040D] < Date: Mon, 20 Jan 2020 09:17:08 GMT
    [1579511828.755][LK-040D] < Content-Type: application/octet-stream
    [1579511828.755][LK-040D] < Content-Length: 1248306
    [1579511828.755][LK-040D] < Connection: keep-alive
    [1579511828.755][LK-040D] < x-oss-request-id: 5E2570140838A33233******
    [1579511828.755][LK-040D] < Content-Range: bytes 0-1248305/1248306
    [1579511828.755][LK-040D] < Accept-Ranges: bytes
    [1579511828.755][LK-040D] < ETag: "4818CE191A4E2A93EE2DF17938******"
    [1579511828.755][LK-040D] < Last-Modified: Mon, 06 Jan 2020 16:32:55 GMT
    [1579511828.755][LK-040D] < x-oss-object-type: Normal
    [1579511828.755][LK-040D] < x-oss-hash-crc64ecma: 14290028752135******
    [1579511828.755][LK-040D] < x-oss-storage-class: Standard
    [1579511828.755][LK-040D] < Content-MD5: SBjOGRpOKpPuLfF5OC******
    [1579511828.755][LK-040D] < x-oss-server-time: 47
    [1579511828.755][LK-040D] <
    download 005% done, +8192 bytes
    [1579511828.777][LK-0309] pub: /ota/device/progress/a18wP******/LightSwitch
    
    [LK-030A] > 7B 22 69 64 22 3A 32 2C  20 22 70 61 72 61 6D 73 | {"id":2, "params
    [LK-030A] > 22 3A 7B 22 73 74 65 70  22 3A 22 35 22 2C 22 64 | ":{"step":"5","d
    [LK-030A] > 65 73 63 22 3A 22 22 7D  7D                      | esc":""}}
    
    download 010% done, +8192 bytes
    [1579511828.788][LK-0309] pub: /ota/device/progress/a18wP******/LightSwitch
    
    [LK-030A] > 7B 22 69 64 22 3A 33 2C  20 22 70 61 72 61 6D 73 | {"id":3, "params
    [LK-030A] > 22 3A 7B 22 73 74 65 70  22 3A 22 31 30 22 2C 22 | ":{"step":"10","
    [LK-030A] > 64 65 73 63 22 3A 22 22  7D 7D                   | desc":""}}
    
     ……
     ……
    
    [LK-030A] > 7B 22 69 64 22 3A 32 30  2C 20 22 70 61 72 61 6D | {"id":20, "param
    [LK-030A] > 73 22 3A 7B 22 73 74 65  70 22 3A 22 39 35 22 2C | s":{"step":"95",
    [LK-030A] > 22 64 65 73 63 22 3A 22  22 7D 7D                | "desc":""}}
    
    [1579511828.833][LK-0901] digest matched
    download 100% done, +3122 bytes
    [1579511828.833][LK-0309] pub: /ota/device/progress/a18wP******/LightSwitch
    
    [LK-030A] > 7B 22 69 64 22 3A 32 31  2C 20 22 70 61 72 61 6D | {"id":21, "param
    [LK-030A] > 73 22 3A 7B 22 73 74 65  70 22 3A 22 31 30 30 22 | s":{"step":"100"
    [LK-030A] > 2C 22 64 65 73 63 22 3A  22 22 7D 7D             | ,"desc":""}}
    
    download completed
    download thread exit

物联网平台日志

您可以在物联网平台控制台查看例程运行后的日志信息。

  • OTA升级包情况:

    在左侧导航栏,选择监控运维 > OTA升级,在升级包列表查看升级包,了解升级情况。更多信息,请参见查看升级情况
  • 在线状态:

    在左侧导航栏,选择设备管理 > 设备,找到设备,查看设备状态。设备状态显示为在线,则表示设备与物联网平台成功连接。查看设备状态
  • 升级日志:

    在左侧导航栏,选择监控运维 > 日志服务,选择产品后,查看设备的上线、设备上报设备版本、物联网平台推送OTA升级包等日志。日志

后续步骤

运行日志中出现的错误信息,请参见aiot_ota_api.h中的状态码描述根据提示解决问题。