After you run the sample code to download an OTA update package that contains a single file over MQTT, 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/mota_basic_demo.c sample code file is configured.For more information, see 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.
    [1635150280.422][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1635150280.422][LK-032A] mqtt host: iot-******.iot-as-mqtt.unify.aliyuncs.com
    [1635150280.422][LK-0317] user name: LightSwitch&/a18wP******
    [1635150280.422][LK-0318] password: A5C6EBEFDE263E8A473C10E3F03CCAE069E56E8F6AC1081BAE628BA2D0******
    success to establish tcp, fd=3
    local port: 32826
    [1635150280.433][LK-1000] establish mbedtls connection with server(host='iot-******.iot-as-mqtt.unify.aliyuncs.com', port=[1883])
    [1635150280.499][LK-1000] success to establish mbedtls connection, (cost 45250 bytes in total, max used 47986 bytes)
    [1635150280.633][LK-0313] MQTT connect success in 210 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.
    [1635150286.199][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 35 37 | data":{"size":57
    [LK-030A] < 33 34 2C 22 73 74 72 65  61 6D 49 64 22 3A 39 30 | 34,"streamId":90
    [LK-030A] < 2C 22 73 69 67 6E 22 3A  22 63 37 38 63 65 33 33 | ,"sign":"c78ce33
    [LK-030A] < 62 62 63 64 39 30 31 35  30 36 37 65 33 61 61 38 | bbcd9015067e3aa8
    [LK-030A] < 61 64 34 64 63 31 30 39  31 22 2C 22 64 50 72 6F | ad4******","dPro
    [LK-030A] < 74 6F 63 6F 6C 22 3A 22  6D 71 74 74 22 2C 22 76 | tocol":"mqtt","v
    [LK-030A] < 65 72 73 69 6F 6E 22 3A  22 34 2E 32 2E 30 22 2C | ersion":"4.2.0",
    [LK-030A] < 22 73 69 67 6E 4D 65 74  68 6F 64 22 3A 22 4D 64 | "signMethod":"Md
    [LK-030A] < 35 22 2C 22 73 74 72 65  61 6D 46 69 6C 65 49 64 | 5","streamFileId
    [LK-030A] < 22 3A 31 2C 22 6D 64 35  22 3A 22 63 37 38 63 65 | ":1,"md5":"c78ce
    [LK-030A] < 33 33 62 62 63 64 39 30  31 35 30 36 37 65 33 61 | 33bbcd9015067e3a
    [LK-030A] < 61 38 61 64 34 64 63 31  30 39 31 22 7D 2C 22 69 | a8ad4******"},"i
    [LK-030A] < 64 22 3A 31 36 33 35 31  35 30 32 38 36 31 38 37 | d":1635150******
    [LK-030A] < 2C 22 6D 65 73 73 61 67  65 22 3A 22 73 75 63 63 | ,"message":"succ
    [LK-030A] < 65 73 73 22 7D                                   | ess"}
  • Logs generated when you send a request to obtain the update file:
    [1635150286.199][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/file/download
    
    [LK-030A] > 7B 22 69 64 22 3A 22 31  22 2C 22 76 65 72 73 69 | {"id":"1","versi
    [LK-030A] > 6F 6E 22 3A 22 31 2E 30  22 2C 22 70 61 72 61 6D | on":"1.0","param
    [LK-030A] > 73 22 3A 7B 22 66 69 6C  65 54 6F 6B 65 6E 22 3A | s":{"fileToken":
    [LK-030A] > 22 64 65 66 61 75 6C 74  22 2C 22 66 69 6C 65 49 | "default","fileI
    [LK-030A] > 6E 66 6F 22 3A 7B 22 73  74 72 65 61 6D 49 64 22 | nfo":{"streamId"
    [LK-030A] > 3A 39 30 2C 22 66 69 6C  65 49 64 22 3A 31 2C 7D | :90,"fileId":1,}
    [LK-030A] > 2C 22 66 69 6C 65 42 6C  6F 63 6B 22 3A 7B 22 73 | ,"fileBlock":{"s
    [LK-030A] > 69 7A 65 22 3A 31 30 32  34 2C 22 6F 66 66 73 65 | ize":1024,"offse
    [LK-030A] > 74 22 3A 30 7D 7D 7D                             | t":0}}}
  • Logs generated when IoT Platform returns the update file:
    [1635150287.455][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/file/download_reply
    
    [LK-030A] < 00 73 7B 22 63 6F 64 65  22 3A 32 30 30 2C 22 64 | .s{"code":200,"d
    [LK-030A] < 61 74 61 22 3A 7B 22 66  69 6C 65 54 6F 6B 65 6E | ata":{"fileToken
    [LK-030A] < 22 3A 22 64 65 66 61 75  6C 74 22 2C 22 62 4F 66 | ":"default","bOf
    [LK-030A] < 66 73 65 74 22 3A 30 2C  22 66 69 6C 65 4C 65 6E | fset":0,"fileLen
    [LK-030A] < 67 74 68 22 3A 35 37 33  34 2C 22 62 53 69 7A 65 | gth":5734,"bSize
    [LK-030A] < 22 3A 31 30 32 34 7D 2C  22 69 64 22 3A 22 31 22 | ":1024},"id":"1"
    [LK-030A] < 2C 22 6D 65 73 73 61 67  65 22 3A 22 73 75 63 63 | ,"message":"succ
    [LK-030A] < 65 73 73 22 7D 50 4B 03  04 0A 00 00 00 00 00 47 | ess"}PK........G
    [LK-030A] < 84 7A 51 00 00 00 00 00  00 00 00 00 00 00 00 0C | .zQ.............
    [LK-030A] < 00 1C 00 61 69 6F 74 5F  63 5F 64 65 6D 6F 2F 55 | ...aiot_c_demo/U
    [LK-030A] < 54 09 00 03 85 68 BF 5F  86 68 BF 5F 75 78 0B 00 | T....h._.h._ux..
    [LK-030A] < 01 04 A5 2C 14 00 04 64  00 00 00 50 4B 03 04 14 | ...,...d...PK...
    [LK-030A] < 00 00 00 08 00 56 4F 7D  4F AB 76 00 7E 7A 06 00 | .....VO}O.v.~z..
    [LK-030A] < 00 CF 0F 00 00 19 00 1C  00 61 69 6F 74 5F 63 5F | .........aiot_c_
    [LK-030A] < 64 65 6D 6F 2F 61 69 6F  74 5F 63 5F 64 65 6D 6F | demo/aiot_c_demo
    [LK-030A] < 2E 63 55 54 09 00 03 54  7B E0 5D CA 62 BF 5F 75 | .cUT...T{.].b._u
    [LK-030A] < 78 0B 00 01 04 A5 2C 14  00 04 64 00 00 00 AD 57 | x.....,...d....W
    [LK-030A] < 6D 6F D3 48 10 FE 9C FC  8A 21 A8 28 49 1D 27 01 | mo.H.....!.(I.'.
    [LK-030A] < 0A 88 52 A4 36 CD 1D 11  B4 14 1A DE C4 9D AA ED | ..R.6...........
    [LK-030A] < 7A 63 EF D5 F6 FA BC EB  A4 3D D4 FF 7E 33 BB B6 | zc.......=..~3..
    [LK-030A] < E3 94 70 A7 D3 61 A9 69  3C 33 3B AF CF CC 4E 86 | ..p..a.i<3;...N.
    [LK-030A] < FD 9F FB B4 A1 0F 13 95  DD E4 32 8C 0C 74 79 0F | ..........2..ty.
    [LK-030A] < 1E 8E C6 0F 3D FA 7C 02  B3 A3 13 64 E6 99 8F 52 | ....=.|....d...R
    [LK-030A] < 24 78 18 C7 60 05 35 E4  42 8B 7C 29 02 1F E6 91 | $x..`.5.B.|)....
    [LK-030A] < D4 90 E5 2A CC 59 02 2C  0D C0 44 02 18 E7 2A C9 | ...*.Y.,..D...*.
    [LK-030A] < 58 7A 23 D3 10 12 66 44  2E 59 AC 49 07 CB 05 12 | Xz#...fD.Y.I....
    [LK-030A] < 02 14 59 32 19 B3 CB 58  40 91 06 22 B7 C7 50 2E | ..Y2...X@.."..P.
    [LK-030A] < D1 A0 16 F6 65 CA 63 99  69 01 67 C5 65 2C 39 BC | ....e.c.i.g.e,9.
    [LK-030A] < 91 5C A4 F8 BA 1C FB 23  AB 08 4D 55 22 C7 52 9B | .\.....#..MU".R.
    [LK-030A] < 5C 5E 16 46 AA 74 43 10  56 91 E4 D1 DA 1D 54 8C | \^.F.tC.V.....T.
    [LK-030A] < DE 06 0D 71 1F CA E0 E6  3F 36 89 47 D6 DE 32 43 | ...q....?6.G..2C
    [LK-030A] < 27 00 20 32 26 7B 3E 1C  AE 56 2B 5F B8 73 BE CA | '. 2&{>..V+_.s..
    [LK-030A] < C3 61 2C 42 16 0F 45 16  0F 96 E3 91 1F 99 24 AE | .a,B..E.......$.
    [LK-030A] < BC 6D 06 B5 D5 E3 FF 64  87 FE 02 C5 8B 44 A4 46 | .m.....d.....D.F
    [LK-030A] < 0F 45 E0 EC 65 51 5D AD  89 4A 9D 09 95 EB E7 4E | .E..eQ]..J.....N
    [LK-030A] < 15 CC 58 0A 93 9C 85 A1  86 01 C8 54 1A 2C 0B F0 | ..X........T.,..
    [LK-030A] < 4A 10 7D D9 26 C7 23 96  86 02 02 11 CB 44 62 89 | J.}.&.#......Db.
    [LK-030A] < 40 65 D6 ED 45 AE 12 62  62 ED 14 50 38 69 58 1E | @e..E..bb..P8iX.
    [LK-030A] < 3F 8C E1 DC 28 7E 15 C8  38 1E 9C 30 5B DF 01 7C | ?...(~..8..0[..|
    [LK-030A] < 14 B9 A6 73 85 26 54 50  36 44 72 29 82 40 04 30 | ...s.&TP6Dr).@.0
    [LK-030A] < 01 8C 0C 03 D9 66 BE C8  02 04 10 9C BC 9B CF 27 | .....f.........'
    [LK-030A] < 56 08 16 45 CA AD 07 29  4B 04 A1 EA E7 3E C3 76 | V..E...)K....>.v
    [LK-030A] < FB BE 4C 79 5C 20 4A 5F  68 13 48 E5 47 2F 1B A4 | ..Ly\ J_h.H.G/..
    [LK-030A] < 44 24 2A BF D9 A0 75 D6  DE F9 51 E7 5F CE 6B 19 | D$*...u...Q._.k.
    [LK-030A] < A6 2C BE 43 BB D1 43 23  13 41 D4 F6 FD 40 2C 64 | .,.C..C#.A...@,d
    [LK-030A] < 8A 60 F9 7C 78 72 F6 66  7A 71 F6 FE ED F1 87 C9 | .`.|xr.fzq......
    [LK-030A] < FC E2 F5 F4 4B AB D5 EA  B0 F1 F8 5A E7 9F 92 4F | ....K......Z...O
    [LK-030A] < E3 C7 9D EF 64 8F A7 1F  67 93 E9 C5 E9 E1 C9 94 | ....d...g.......
    [LK-030A] < 64 33 16 A9 8B E4 4F 63  7E 28 79 3E 9D BC 9F CE | d3....Oc~(y>....
    [LK-030A] < C1 3D 9D 2F CF 9E 3E 3D  0A D5 B3 CF 7B 6A 15 3C | .=./..>=....{j.<
    [LK-030A] < 8A F9 D1 DE EA D3 F1 1F  F9 CD E9 99 3A FA 10 C8 | ............:...
    [LK-030A] < 57 18 DB B0 8F 50 E0 31  35 B2 AD E1 35 42 02 E3 | W....P.15...5B..
    [LK-030A] < 59 57 85 49 65 4E D0 E4  39 C6 D9 ED 01 E6 D3 C9 | YW.IeN..9.......
    [LK-030A] < 20 E0 CC 26 13 91 A7 8D  83 50 1F 47 48 50 70 F3 |  ..&.....P.GHPp.
    [LK-030A] < 5A DC 78 D0 A4 07 62 89  ED 71 8A 95 DE 46 3F 17 | Z.x...b..q...F?.
    [LK-030A] < 3C 17 C6 C3 56 D9 F6 B4  AC A8 83 D6 2C F8 3A DE | <...V.......,.:.
    [LK-030A] < 1B FD EE B9 E3 85 26 A7  13 F1 F5 C9 5E 45 CA 98 | ......&.....^E..
    [LK-030A] < D6 2B 95 07 44 EA ED B7  DB 4B 15 33 23 B1 13 C9 | .+..D....K.3#...
    [LK-030A] < 6D A3 10 D0 19 1C C0 C8  72 64 00 1C 93 29 75 D4 | m.......rd...)u.
    [LK-030A] < 25 2E 56 B4 D7 FE D6 6E  B9 CA 76 CF 67 BF CE 4E | %.V....n..v.g..N
    [LK-030A] < E7 1E 9C 7E 78 F3 06 35  B5 EA C3 E3 FD F6 6D 79 | ...~x..5......my
    [LK-030A] < 1C 81 AB 59 28 0E F3 5C  E2 18 ED 9E B8 D7 63 66 | ...Y(..\......cf
    [LK-030A] < 58 1F 92 C0 6A 23 4C 95  F4 7E 25 8F 4A 92 60 F0 | X...j#L..~%.J.`.
    [LK-030A] < B2 7C 43 5F 5A 19 F6 9D  59 74 3B 3B 7E 5F FF 66 | .|C_Z...Yt;;~_.f
    [LK-030A] < 3A 9E E5 A3 39 C9 29 67  83 97 31 8E 16 DB 9B 3E | :...9.)g..1....>
    [LK-030A] < 7E FB 07 2E 36 19 23 67  37 F4 A5 A8 8F 22 EC 95 | ~...6.#g7...."..
    [LK-030A] < 06 07 2F 33 76 13 2B 16  58 5D 5D CA 5B FF 3B 5E | ../3v.+.X]].[.;^
    [LK-030A] < CF 46 89 30 49 98 4C D7  B0 40 1C 50 AE 88 68 93 | .F.0I.L..@.P..h.
    [LK-030A] < C6 F2 90 BB D4 F7 E9 5A  08 97 36 68 E2 E4 BC 4C | .......Z..6h...L
    [LK-030A] < 74 0B 95 68 61 8A CC 22  ED B2 58 2C 44 EE 81 44 | t..ha.."..X,D..D
    [LK-030A] < 25 05 E2 E0 52 86 20 52  55 84 11 2C 54 0E 2C 96 | %...R. RU..,T.,.
    [LK-030A] < 37 45 0A 33 35 79 56                             | 7E.35yV
    
    [1635150287.455][LK-0000] header : {"code":200,"data":{"fileToken":"default","bOffset":0,"fileLength":5734,"bSize":1024},"id":"1","message":"success"}PK
    download 017% done, +1024 bytes
  • Logs generated when the update file is downloaded:
    [1635150288.688][LK-0901] digest matched
    [1635150293.688][LK-0309] pub: /ota/device/progress/a18wP******/LightSwitch
    
    [LK-030A] > 7B 22 69 64 22 3A 37 2C  20 22 70 61 72 61 6D 73 | {"id":7, "params
    [LK-030A] > 22 3A 7B 22 73 74 65 70  22 3A 22 31 30 30 22 2C | ":{"step":"100",
    [LK-030A] > 22 64 65 73 63 22 3A 22  22 7D 7D                | "desc":""}}

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.