Setelah Anda menjalankan kode contoh untuk menghubungkan perangkat dengan IoT Platform melalui HTTPS, Setelah Anda menggunakan kode contoh untuk menghubungkan perangkat ke IoT Platform melalui Message Queuing Telemetry Transport (MQTT), Anda dapat melihat log pada perangkat.
Prasyarat
Kode contoh dalam Link SDK for C telah dikonfigurasi. Untuk informasi lebih lanjut, lihat Contoh.
Log perangkat
Anda dapat melihat hasil operasi di perangkat.
Log koneksi perangkat
Data log berikut menunjukkan perangkat telah terhubung ke IoT Platform.
core_sysdep_network_establish host iot-as-http.cn-shanghai.aliyuncs.com port 443, type 0 establish tcp connection with server(host='iot-as-http.cn-shanghai.aliyuncs.com', port=[443]) success to establish tcp, fd=3 local port: 56028 [1621563692.299][LK-1000] establish mbedtls connection with server(host='iot-as-http.cn-shanghai.aliyuncs.com', port=[443]) [1621563692.300][LK-1000] success to establish mbedtls connection, (cost 44722 bytes in total, max used 47410 bytes) [1621563692.300][LK-040B] > POST /auth?_v=sdk-c-4.1.0& HTTP/1.1 [1621563692.300][LK-040B] > Host: iot-as-http.cn-shanghai.aliyuncs.com [1621563692.300][LK-040B] > Content-Type: application/json [1621563692.300][LK-040B] > Content-Length: 192 [1621563692.300][LK-040B] > [LK-040C] > 7B 22 63 6C 69 65 6E 74 49 64 22 3A 22 61 31 77 | {"clientId":"a1w [LK-040C] > 41 66 49 55 6C 41 39 4E 2E 4C 69 67 68 74 53 77 | Af******.LightSw [LK-040C] > 69 74 63 68 22 2C 22 73 69 67 6E 6D 65 74 68 6F | itch","signmetho [LK-040C] > 64 22 3A 22 68 6D 61 63 73 68 61 32 35 36 22 2C | d":"hmacsha256", [LK-040C] > 22 64 65 76 69 63 65 4E 61 6D 65 22 3A 22 4C 69 | "deviceName":"Li [LK-040C] > 67 68 74 53 77 69 74 63 68 22 2C 22 70 72 6F 64 | ghtSwitch","prod [LK-040C] > 75 63 74 4B 65 79 22 3A 22 61 31 77 41 66 49 55 | uctKey":"a1wAf** [LK-040C] > 6C 41 39 4E 22 2C 22 73 69 67 6E 22 3A 22 41 36 | ****","sign":"A6 [LK-040C] > 43 30 32 31 32 42 44 42 33 39 45 32 36 35 38 39 | C0212BDB39E26589 [LK-040C] > 36 41 39 41 43 36 34 36 44 33 35 46 39 33 31 43 | 6A9AC646D35F931C [LK-040C] > 36 46 35 32 37 36 46 32 41 42 39 33 35 35 33 34 | 6F5276F2AB935534 [LK-040C] > 30 37 42 31 46 45 33 39 43 31 33 35 37 46 22 7D | 07B1FE39******"} [1621563692.377][LK-040D] < HTTP/1.1 200 [1621563692.377][LK-040D] < Server: nginx/1.14.2 [1621563692.377][LK-040D] < Date: Fri, 21 May 2021 02:21:32 GMT [1621563692.377][LK-040D] < Content-Type: application/json [1621563692.377][LK-040D] < Content-Length: 82 [1621563692.377][LK-040D] < Connection: keep-alive [1621563692.377][LK-040D] < [LK-040E] < 7B 22 63 6F 64 65 22 3A 30 2C 22 69 6E 66 6F 22 | {"code":0,"info" [LK-040E] < 3A 7B 22 74 6F 6B 65 6E 22 3A 22 5E 31 5E 31 36 | :{"token":"^1^16 [LK-040E] < 32 31 35 36 33 36 39 32 33 36 34 5E 66 33 35 35 | 21563692364^f355 [LK-040E] < 63 39 30 35 66 37 66 31 37 37 34 22 7D 2C 22 6D | c905f******"},"m [LK-040E] < 65 73 73 61 67 65 22 3A 22 73 75 63 63 65 73 73 | essage":"success [LK-040E] < 22 7D | "} [1621563692.377][LK-0410] {"code":0,"info":{"token":"^1^1621563692364^f355c905f******"},"message":"success"} aiot_http_auth berhasilLog pengiriman pesan
Setelah koneksi berhasil dibuat, data log berikut dicetak. Data log tersebut menunjukkan bahwa perangkat menggunakan topik, misalnya,
/a18wP******/LightSwitch/user/update, untuk mengirim pesan ke IoT Platform.[1621563692.377][LK-040B] > POST /topic/a1wAf******/LightSwitch/user/update HTTP/1.1 [1621563692.377][LK-040B] > Host: iot-as-http.cn-shanghai.aliyuncs.com [1621563692.377][LK-040B] > Content-Type: application/octet-stream [1621563692.377][LK-040B] > Password: ^1^1621563692364^f355c905f****** [1621563692.377][LK-040B] > Content-Length: 53 [1621563692.377][LK-040B] > [LK-040C] > 7B 22 69 64 22 3A 22 31 22 2C 22 76 65 72 73 69 | {"id":"1","versi [LK-040C] > 6F 6E 22 3A 22 31 2E 30 22 2C 22 70 61 72 61 6D | on":"1.0","param [LK-040C] > 73 22 3A 7B 22 4C 69 67 68 74 53 77 69 74 63 68 | s":{"LightSwitch [LK-040C] > 22 3A 30 7D 7D | ":0}}Log respons downstream
Data log berikut menunjukkan bahwa IoT Platform mengirimkan pesan respons ke perangkat.
[1621563692.477][LK-040D] < HTTP/1.1 200 [1621563692.477][LK-040D] < Server: nginx/1.14.2 [1621563692.477][LK-040D] < Date: Fri, 21 May 2021 02:21:32 GMT [1621563692.477][LK-040D] < Content-Type: application/json [1621563692.477][LK-040D] < Content-Length: 71 [1621563692.477][LK-040D] < Connection: keep-alive [1621563692.477][LK-040D] <
Log IoT Platform
Masuk ke Konsol IoT Platform untuk melihat status perangkat dan log operasi.
Status perangkat
Di panel navigasi di sebelah kiri, pilih . Kemudian, temukan perangkat dan lihat statusnya. Jika nilai di kolom State/Enabled adalah Online, perangkat terhubung ke IoT Platform.
