After you run the sample code to download an OTA update package that contains a single file over HTTPS, After you use the sample code to connect a device to IoT Platform over Message Queuing Telemetry Transport (MQTT), you can view logs on the device.

Prerequisites

The ./demos/fota_posix_demo.c sample code file is configured. Sample code.

Device logs

You can view the running result on the device.
  • Device connection logs

    The following log data indicates that the device is connected to IoT Platform.
    [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
  • Logs generated when version numbers are submitted

    The following log data indicates that the device submits the initial version number 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"}}
  • Logs generated when OTA update commands are received

    The following log data indicates that the device receives a command after you create an OTA update task in IoT Platform and add an update package that contains a single file.
    [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"}
                                
  • Logs generated when you download the update package

    The following log data indicates that the device downloads the update package and obtains the progress until the download is completed.

    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

IoT Platform logs

Log on to the IoT Platform console to view the device status and operation logs.

  • Information about the OTA update package

    In the left-side navigation pane, choose Maintenance > OTA Update. On the Update Packages tab, view the information about the update package. For more information, see View update status.
  • Device status

    In the left-side navigation pane, choose Devices > Devices. Then, find the device and view the device status. If the value in the State/Enabled column is Online, the device is connected to IoT Platform. View the device status
  • Update logs

    In the left-side navigation pane, choose Maintenance > Device Log. Select a product to view the logs that are generated when the device goes online, the device submits the version number, and IoT Platform pushes the OTA update package.