全部產品
Search
文件中心

:作業記錄

更新時間:Jun 30, 2024

物模型功能的常式運行後,您可以在裝置端和物聯網平台查看日誌資訊

前提條件

已配置C Link SDK的物模型功能常式,詳細資料,請參見使用樣本

裝置端日誌

您可以在裝置端查看運行結果。

  • 串連日誌:

    出現如下日誌,表示裝置與物聯網平台串連成功。

    [1624012656.944][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1624012656.944][LK-0317] LightSwitch&a18wP******
    [1624012656.944][LK-0318] ADE0BBAA0DFAC1CA3440DAB1D8B555EFD6E0AA0546A2312D0E1E1A60A******
    [1581401572.800][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 tcp, fd=3
    local port: 43014
    [1624012657.133][LK-0313] MQTT connect success in 184 ms
    AIOT_MQTTEVT_CONNECT
  • 訂閱Topic日誌:

    如果您配置了訂閱Topic相關代碼,裝置端列印如下日誌。該日誌表示裝置已訂閱Topic,例如/sys/a18wP******/LightSwitch/thing/event/property/batch/post_reply

    [1624012657.133][LK-0309] sub: /sys/a18wP******/LightSwitch/thing/event/property/batch/post_reply
  • 上報訊息日誌:

    • 裝置通過物模型預設模組,發送屬性訊息的日誌如下:

      [1624012657.133][LK-0309] pub: /sys/a18wP******/LightSwitch/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 20 30 7D 2C 22 73  79 73 22 3A 7B 22 61 63 | ": 0},"sys":{"ac
      [LK-030A] > 6B 22 3A 31 7D 7D                                | k":1}}
    • 裝置通過物模型預設模組,發送事件訊息的日誌如下:

      [1624012657.133][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/Error/post
      
      [LK-030A] > 7B 22 69 64 22 3A 22 32  22 2C 22 76 65 72 73 69 | {"id":"2","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 45 72 72  6F 72 43 6F 64 65 22 3A | s":{"ErrorCode":
      [LK-030A] > 20 30 7D 2C 22 73 79 73  22 3A 7B 22 61 63 6B 22 |  0},"sys":{"ack"
      [LK-030A] > 3A 31 7D 7D                                      | :1}}
    • 裝置通過自訂模組,例如demo_extra_block,發送事件訊息的日誌如下:

      [1624012657.133][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/property/post
      
      [LK-030A] > 7B 22 69 64 22 3A 22 33  22 2C 22 76 65 72 73 69 | {"id":"3","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 64 65 6D  6F 5F 65 78 74 72 61 5F | s":{"demo_extra_
      [LK-030A] > 62 6C 6F 63 6B 3A 4E 69  67 68 74 4C 69 67 68 74 | block:NightLight
      [LK-030A] > 53 77 69 74 63 68 22 3A  20 31 7D 2C 22 73 79 73 | Switch": 1},"sys
      [LK-030A] > 22 3A 7B 22 61 63 6B 22  3A 31 7D 7D             | ":{"ack":1}}
    • 裝置通過物模型預設模組,批量發送屬性訊息的日誌如下:

      [1624012657.133][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/property/batch/post
      
      [LK-030A] > 7B 22 69 64 22 3A 22 34  22 2C 22 76 65 72 73 69 | {"id":"4","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 70 72 6F  70 65 72 74 69 65 73 22 | s":{"properties"
      [LK-030A] > 3A 7B 22 50 6F 77 65 72  22 3A 20 5B 20 7B 22 76 | :{"Power": [ {"v
      [LK-030A] > 61 6C 75 65 22 3A 22 6F  6E 22 2C 22 74 69 6D 65 | alue":"on","time
      [LK-030A] > 22 3A 31 36 31 32 36 38  34 35 31 38 7D 5D 2C 22 | ":1612684518}],"
      [LK-030A] > 57 46 22 3A 20 5B 7B 22  76 61 6C 75 65 22 3A 20 | WF": [{"value":
      [LK-030A] > 33 2C 22 74 69 6D 65 22  3A 31 36 31 32 36 38 34 | 3,"time":1612684
      [LK-030A] > 35 31 38 7D 5D 7D 7D 2C  22 73 79 73 22 3A 7B 22 | 518}]}},"sys":{"
      [LK-030A] > 61 63 6B 22 3A 31 7D 7D                          | ack":1}}
  • 響應日誌:

    裝置向物聯網平台發送訊息後,物聯網平台會做出響應,以下日誌為響應報文:

    [1624012657.188][LK-0309] pub: /sys/a18wP******/LightSwitch/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"}
    
    [1624012657.188][LK-0A08] DM recv generic reply
    demo_dm_recv_handler, type = 0
    msg_id = 1, code = 200, data = {}, message = success
    [1624012657.199][LK-0309] pub: /sys/a18wP******/LightSwitch/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 33 22 2C 22 | a":{},"id":"3","
    [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"}
    
    [1624012657.199][LK-0A08] DM recv generic reply
    demo_dm_recv_handler, type = 0
    msg_id = 3, code = 200, data = {}, message = success
    [1624012657.200][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/event/Error/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 32 22 2C 22 | a":{},"id":"2","
    [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 45 72 72 6F 72 2E 70 | ng.event.Error.p
    [LK-030A] < 6F 73 74 22 2C 22 76 65  72 73 69 6F 6E 22 3A 22 | ost","version":"
    [LK-030A] < 31 2E 30 22 7D                                   | 1.0"}
  • 處理設定屬性的日誌:

    裝置串連物聯網平台後,您可以通過以下方式,向裝置發送指令。

    裝置端接收物聯網平台下發的指令後,執行回呼函數的處理,樣本僅做列印處理,日誌如下:

    [1624246230.777][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/service/property/set
    
    [LK-030A] < 7B 22 6D 65 74 68 6F 64  22 3A 22 74 68 69 6E 67 | {"method":"thing
    [LK-030A] < 2E 73 65 72 76 69 63 65  2E 70 72 6F 70 65 72 74 | .service.propert
    [LK-030A] < 79 2E 73 65 74 22 2C 22  69 64 22 3A 22 31 34 30 | y.set","id":"140
    [LK-030A] < 37 31 32 32 37 39 32 22  2C 22 70 61 72 61 6D 73 | 7122792","params
    [LK-030A] < 22 3A 7B 22 4C 69 67 68  74 53 77 69 74 63 68 22 | ":{"LightSwitch"
    [LK-030A] < 3A 30 7D 2C 22 76 65 72  73 69 6F 6E 22 3A 22 31 | :0},"version":"1
    [LK-030A] < 2E 30 2E 30 22 7D                                | .0.0"}
    
    [1624246230.777][LK-0A08] DM recv property set
    demo_dm_recv_handler, type = 1
    msg_id = 1407122792, params = {"LightSwitch":0}
    [1624246230.777][LK-0309] pub: /sys/a18wP******/LightSwitch/thing/service/property/set_reply
    
    [LK-030A] > 7B 22 69 64 22 3A 22 31  34 30 37 31 32 32 37 39 | {"id":"140712279
    [LK-030A] > 32 22 2C 22 63 6F 64 65  22 3A 32 30 30 2C 22 64 | 2","code":200,"d
    [LK-030A] > 61 74 61 22 3A 7B 7D 7D                          | ata":{}}

物聯網平台日誌

您可以在物聯網平台控制台查看裝置的狀態和作業記錄。

  • 線上狀態:

    在左側導覽列,選擇裝置管理 > 裝置,找到裝置,查看裝置狀態。裝置狀態顯示為線上,則表示裝置與物聯網平台成功串連。查看裝置狀態

  • 物模型資料:

    裝置詳情頁面的物模型資料頁簽下,查看上報的物模型資料。物模型資料

  • 作業記錄:

    在左側導覽列,選擇監控營運 > Log Service,選擇產品後,查看裝置上線、訂閱Topic和上報訊息的日誌。

    物模型日誌

後續步驟

作業記錄中出現的錯誤資訊,請參見常見錯誤碼aiot_dm_api.h中的狀態代碼描述根據提示解決問題。