資料壓縮的常式運行後,您可以在裝置端和物聯網平台查看日誌資訊。
前提條件
已配置C Link SDK的資料壓縮常式,詳細資料,請參見使用樣本。
裝置端日誌
您可以在裝置端查看運行結果。
串連日誌。
出現如下日誌,表示裝置與物聯網平台串連成功。
[1673252439.000][LK-0313] MQTT user calls aiot_mqtt_connect api, connect [1673252439.000][LK-032A] mqtt host: xxxxxx.xxxxx.xxxxxx.xxxxxxx.com [1673252439.000][LK-0317] user name: compress_xxxxxxx [1673252439.000][LK-0318] password: 570D5xxxxxxxxx success to establish tcp, fd=3 local port: 47622 [1673252439.100][LK-1000] establish mbedtls connection with server(host='xxxxx.xxxxxx.unify.aliyuncs.com', port=[443]) [1673252439.288][LK-1000] success to establish mbedtls connection, (cost 45326 bytes in total, max used 48294 bytes) [1673252440.111][LK-0313] MQTT connect success in 1109 ms AIOT_MQTTEVT_CONNECT
裝置訂閱上報結果回複的Topic。
[1673252440.111][LK-0309] sub: /sys/a1xxxxxx/compress_test_001/codec/topic/update_reply suback, res: -0x0000, packet id: 1, max qos: 1
裝置上報Topic列表。
[1673252440.611][LK-0309] pub: /sys/a1xxxxxxx/compress_test_001/codec/topic/update [LK-030A] > 7B 22 70 61 72 61 6D 73 22 3A 5B 7B 22 74 6F 70 | {"params":[{"top [LK-030A] > 69 63 22 3A 20 22 2F 61 31 68 45 39 36 7A 66 38 | ic": "/a1xxxxxx [LK-030A] > 73 34 2F 63 6F 6D 70 72 65 73 73 5F 74 65 73 74 | /compress_test [LK-030A] > 5F 30 30 31 2F 75 73 65 72 2F 75 70 64 61 74 65 | _001/user/update [LK-030A] > 22 2C 22 6F 70 65 72 61 74 69 6F 6E 22 3A 20 22 | ","operation": " [LK-030A] > 64 65 63 6F 6D 70 72 65 73 73 22 2C 22 66 6F 72 | decompress","for [LK-030A] > 6D 61 74 22 3A 20 22 67 7A 69 70 22 7D 2C 7B 22 | mat": "gzip"},{" [LK-030A] > 74 6F 70 69 63 22 3A 20 22 2F 73 79 73 2F 61 31 | topic": "/sys/a1 [LK-030A] > 68 45 39 36 7A 66 38 73 34 2F 63 6F 6D 70 72 65 | xxxxxx/compre [LK-030A] > 73 73 5F 74 65 73 74 5F 30 30 31 2F 74 68 69 6E | ss_test_001/thin [LK-030A] > 67 2F 65 76 65 6E 74 2F 70 72 6F 70 65 72 74 79 | g/event/property [LK-030A] > 2F 70 6F 73 74 22 2C 22 6F 70 65 72 61 74 69 6F | /post","operatio [LK-030A] > 6E 22 3A 20 22 64 65 63 6F 6D 70 72 65 73 73 22 | n": "decompress" [LK-030A] > 2C 22 66 6F 72 6D 61 74 22 3A 20 22 67 7A 69 70 | ,"format": "gzip [LK-030A] > 22 7D 2C 7B 22 74 6F 70 69 63 22 3A 20 22 2F 61 | "},{"topic": "/a [LK-030A] > 31 68 45 39 36 7A 66 38 73 34 2F 63 6F 6D 70 72 | 1xxxxxxx/compr [LK-030A] > 65 73 73 5F 74 65 73 74 5F 30 30 31 2F 75 73 65 | ess_test_001/use [LK-030A] > 72 2F 75 70 64 61 74 65 5F 72 65 70 6C 79 22 2C | r/update_reply", [LK-030A] > 22 6F 70 65 72 61 74 69 6F 6E 22 3A 20 22 63 6F | "operation": "co [LK-030A] > 6D 70 72 65 73 73 22 2C 22 66 6F 72 6D 61 74 22 | mpress","format" [LK-030A] > 3A 20 22 67 7A 69 70 22 7D 2C 7B 22 74 6F 70 69 | : "gzip"},{"topi [LK-030A] > 63 22 3A 20 22 2F 73 79 73 2F 61 31 68 45 39 36 | c": "/sys/a1xxxxx [LK-030A] > 7A 66 38 73 34 2F 63 6F 6D 70 72 65 73 73 5F 74 | /compress_t [LK-030A] > 65 73 74 5F 30 30 31 2F 74 68 69 6E 67 2F 65 76 | est_001/thing/ev [LK-030A] > 65 6E 74 2F 70 72 6F 70 65 72 74 79 2F 70 6F 73 | ent/property/pos [LK-030A] > 74 5F 72 65 70 6C 79 22 2C 22 6F 70 65 72 61 74 | t_reply","operat [LK-030A] > 69 6F 6E 22 3A 20 22 63 6F 6D 70 72 65 73 73 22 | ion": "compress" [LK-030A] > 2C 22 66 6F 72 6D 61 74 22 3A 20 22 67 7A 69 70 | ,"format": "gzip [LK-030A] > 22 7D 5D 7D | "}]}
物聯網平台返回上報結果。
[1673252441.266][LK-0309] pub: /sys/a1xxxxxxx/compress_test_001/codec/topic/update_reply [LK-030A] < 7B 22 63 6F 64 65 22 3A 32 30 30 2C 22 6D 65 73 | {"code":200,"mes [LK-030A] < 73 61 67 65 22 3A 22 73 75 63 63 65 73 73 22 7D | sage":"success"} compress update reply code 200, message success
裝置上報壓縮訊息。
日誌輸出是壓縮前的報文,日誌中有
compressed
表示已完成壓縮。[1673252442.611][LK-0309] pub: /sys/a1xxxxxx/compress_test_001/thing/event/property/post [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 4C 69 67 68 74 53 77 69 74 63 68 | s":{"LightSwitch [LK-030A] > 22 3A 30 2C 20 22 6D 65 73 73 61 67 65 22 3A 22 | ":0, "message":" [LK-030A] > 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D | this is a test m [LK-030A] > 65 73 73 61 67 65 2C 20 74 68 69 73 20 69 73 20 | essage, this is [LK-030A] > 61 20 74 65 73 74 20 6D 65 73 73 61 67 65 2C 20 | a test message, [LK-030A] > 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 6D | this is a test m [LK-030A] > 65 73 73 61 67 65 22 7D 7D | essage"}} [1673252442.611][LK-2200] compressed [137] --> [103]
物聯網平台下發壓縮訊息。
日誌輸出是解壓後的報文,日誌中有
decompressed
表示報文已完成解壓縮。[1673252442.966][LK-2200] decompressed [105] --> [104] [1673252442.966][LK-0309] pub: /sys/a1xxxxxxxx/compress_test_001/thing/event/property/post_reply [LK-030A] < 7B 22 63 6F 64 65 22 3A 32 30 30 2C 22 64 61 74 | {"code":200,"dat [LK-030A] < 61 22 3A 7B 7D 2C 22 69 64 22 3A 22 31 22 2C 22 | a":{},"id":"1"," [LK-030A] < 6D 65 73 73 61 67 65 22 3A 22 73 75 63 63 65 73 | message":"succes [LK-030A] < 73 22 2C 22 6D 65 74 68 6F 64 22 3A 22 74 68 69 | s","method":"thi [LK-030A] < 6E 67 2E 65 76 65 6E 74 2E 70 72 6F 70 65 72 74 | ng.event.propert [LK-030A] < 79 2E 70 6F 73 74 22 2C 22 76 65 72 73 69 6F 6E | y.post","version [LK-030A] < 22 3A 22 31 2E 30 22 7D | ":"1.0"}
物聯網平台日誌
您可以在,查看常式運行後的日誌資訊。
在左側導覽列,選擇監控營運 > Log Service,選擇產品後,查看裝置上報訊息日誌。
說明
日誌中展示的訊息為亂碼,是因為物聯網平台儲存的是壓縮後的訊息內容。
後續步驟
作業記錄中出現的錯誤資訊,請參見aiot_compress_api.h中的狀態代碼描述,根據提示解決問題。