网关与子设备的功能例程运行后,您可以在设备端和物联网平台查看日志信息

前提条件

已配置C Link SDK的网关与子设备的功能例程,详细信息,请参见使用示例

设备端日志

您可以在网关设备查看运行日志。

  1. 以下日志显示网关设备与物联网平台连接成功。
    [1625220273.644][LK-0313] MQTT user calls aiot_mqtt_connect api, connect
    [1625220273.644][LK-0317] LightSwitchGW&a18wP******
    [1625220273.644][LK-0318] 29F9969F10F1AE9728977EA79D31DAC85981B101761E8887548CD4685D******
    core_sysdep_network_establish host iot-06******.mqtt.iothub.aliyuncs.com port 443, type 0
    establish tcp connection with server(host='a18wP******.iot-as-mqtt.cn-shanghai.aliyuncs.com', port=[443])
    success to establish tcp, fd=3
    local port: 41574
    [1625220273.677][LK-1000] establish mbedtls connection with server(host='a18wP******.iot-as-mqtt.cn-shanghai.aliyuncs.com', port=[443])
    [1625220273.744][LK-1000] success to establish mbedtls connection, (cost 44947 bytes in total, max used 47859 bytes)
    [1625220273.744][LK-0319] a18wP******.LightSwitchGW|timestamp=2524608000000,_ss=1,_v=sdk-c-4.1.0,securemode=2,signmethod=hmacsha256,ext=3,_conn=tls_66|
    [1625220273.811][LK-0313] MQTT connect success in 168 ms
    [1625220273.811][LK-0317] cid[10] connected, online channel 10
  2. 如果选择自动添加拓扑关系,网关设备连接后,无需添加拓扑关系,直接通过网关的Topic /ext/session/a18wP******/LightSwitchGW/combine/batch_login,向物联网平台发送批量登录请求。
    [1625466501.399][LK-0309] pub[2]: /ext/session/a18wP******/LightSwitchGW/combine/batch_login
    
    [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 73 69 67  6E 4D 65 74 68 6F 64 22 | s":{"signMethod"
    [LK-030A] > 3A 22 68 6D 61 63 53 68  61 32 35 36 22 2C 22 64 | :"hmacSha256","d
    [LK-030A] > 65 76 69 63 65 4C 69 73  74 22 3A 5B 7B 22 70 72 | eviceList":[{"pr
    [LK-030A] > 6F 64 75 63 74 4B 65 79  22 3A 22 67 37 68 30 69 | oductKey":"a13FN
    [LK-030A] > 75 38 54 74 31 61 22 2C  22 64 65 76 69 63 65 4E | ******","deviceN
    [LK-030A] > 61 6D 65 22 3A 22 4C 69  67 68 74 53 77 69 74 63 | ame":"LightSwitc
    [LK-030A] > 68 5F 53 75 62 44 65 76  5F 30 31 22 2C 22 63 6C | h_SubDev_01","cl
    [LK-030A] > 69 65 6E 74 49 64 22 3A  22 67 37 68 30 69 75 38 | ientId":"a13FN**
    [LK-030A] > 54 74 31 61 2E 4C 69 67  68 74 53 77 69 74 63 68 | ****.LightSwitch
    [LK-030A] > 5F 53 75 62 44 65 76 5F  30 31 22 2C 22 74 69 6D | _SubDev_01","tim
    [LK-030A] > 65 73 74 61 6D 70 22 3A  22 31 36 32 35 34 36 36 | estamp":"1625466
    [LK-030A] > 35 30 31 33 39 36 22 2C  22 63 6C 65 61 6E 53 65 | 501396","cleanSe
    [LK-030A] > 73 73 69 6F 6E 22 3A 22  66 61 6C 73 65 22 2C 22 | ssion":"false","
    [LK-030A] > 73 69 67 6E 22 3A 22 30  46 41 45 38 43 33 43 33 | sign":"0FAE8C3C3
    [LK-030A] > 34 38 44 35 30 37 38 38  43 41 42 38 38 42 36 44 | 48D50788CAB88B6D
    [LK-030A] > 39 44 34 34 43 35 44 35  36 46 45 46 44 42 33 45 | 9D44C5D56FEFDB3E
    [LK-030A] > 43 46 41 30 30 35 38 37  32 30 41 43 34 45 37 43 | CFA0058720AC4E7C
    [LK-030A] > 46 36 44 36 34 44 36 22  7D 2C 7B 22 70 72 6F 64 | F******"},{"prod
    [LK-030A] > 75 63 74 4B 65 79 22 3A  22 67 37 68 30 69 75 38 | uctKey":"a13FN**
    [LK-030A] > 54 74 31 61 22 2C 22 64  65 76 69 63 65 4E 61 6D | ****","deviceNam
    [LK-030A] > 65 22 3A 22 4C 69 67 68  74 53 77 69 74 63 68 5F | e":"LightSwitch_
    [LK-030A] > 53 75 62 44 65 76 5F 30  32 22 2C 22 63 6C 69 65 | SubDev_02","clie
    [LK-030A] > 6E 74 49 64 22 3A 22 67  37 68 30 69 75 38 54 74 | ntId":"a13FN****
    [LK-030A] > 31 61 2E 4C 69 67 68 74  53 77 69 74 63 68 5F 53 | **.LightSwitch_S
    [LK-030A] > 75 62 44 65 76 5F 30 32  22 2C 22 74 69 6D 65 73 | ubDev_02","times
    [LK-030A] > 74 61 6D 70 22 3A 22 31  36 32 35 34 36 36 35 30 | tamp":"162546650
    [LK-030A] > 31 33 39 36 22 2C 22 63  6C 65 61 6E 53 65 73 73 | 1396","cleanSess
    [LK-030A] > 69 6F 6E 22 3A 22 66 61  6C 73 65 22 2C 22 73 69 | ion":"false","si
    [LK-030A] > 67 6E 22 3A 22 33 31 36  45 45 36 35 37 33 46 31 | gn":"316EE6573F1
    [LK-030A] > 35 37 33 38 36 32 41 34  42 37 35 39 45 32 35 42 | 573862A4B759E25B
    [LK-030A] > 43 32 34 41 32 30 33 44  35 30 31 43 41 30 42 35 | C24A203D501CA0B5
    [LK-030A] > 31 44 30 35 30 30 41 32  32 45 34 39 46 42 38 38 | 1D0500A22E49FB88
    [LK-030A] > 39 46 32 42 35 22 7D 2C  7B 22 70 72 6F 64 75 63 | *****"},{"produc
    [LK-030A] > 74 4B 65 79 22 3A 22 67  37 68 30 69 75 38 54 74 | tKey":"g7h0i****
    [LK-030A] > 31 61 22 2C 22 64 65 76  69 63 65 4E 61 6D 65 22 | **","deviceName"
    [LK-030A] > 3A 22 4C 69 67 68 74 53  77 69 74 63 68 5F 53 75 | :"LightSwitch_Su
    [LK-030A] > 62 44 65 76 5F 30 33 22  2C 22 63 6C 69 65 6E 74 | bDev_03","client
    [LK-030A] > 49 64 22 3A 22 67 37 68  30 69 75 38 54 74 31 61 | Id":"a13FN******
    [LK-030A] > 2E 4C 69 67 68 74 53 77  69 74 63 68 5F 53 75 62 | .LightSwitch_Sub
    [LK-030A] > 44 65 76 5F 30 33 22 2C  22 74 69 6D 65 73 74 61 | Dev_03","timesta
    [LK-030A] > 6D 70 22 3A 22 31 36 32  35 34 36 36 35 30 31 33 | mp":"16254665013
    [LK-030A] > 39 36 22 2C 22 63 6C 65  61 6E 53 65 73 73 69 6F | 96","cleanSessio
    [LK-030A] > 6E 22 3A 22 66 61 6C 73  65 22 2C 22 73 69 67 6E | n":"false","sign
    [LK-030A] > 22 3A 22 37 31 30 43 44  43 37 31 36 34 34 35 36 | ":"710CDC7164456
    [LK-030A] > 43 39 43 45 41 36 44 39  43 33 30 41 35 44 38 30 | C9CEA6D9C30A5D80
    [LK-030A] > 32 33 42 41 32 46 46 45  42 30 32 41 33 46 36 37 | 23BA2FFEB02A3F67
    [LK-030A] > 35 41 37 41 34 39 32 34  33 45 33 33 41 32 31 45 | 5A7A49243E33A21E
    [LK-030A] > 36 36 44 22 7D 2C 7B 22  70 72 6F 64 75 63 74 4B | ***"},{"productK
    [LK-030A] > 65 79 22 3A 22 67 37 68  30 69 75 38 54 74 31 61 | ey":"a13FN******
    [LK-030A] > 22 2C 22 64 65 76 69 63  65 4E 61 6D 65 22 3A 22 | ","deviceName":"
    [LK-030A] > 4C 69 67 68 74 53 77 69  74 63 68 5F 53 75 62 44 | LightSwitch_SubD
    [LK-030A] > 65 76 5F 30 34 22 2C 22  63 6C 69 65 6E 74 49 64 | ev_04","clientId
    [LK-030A] > 22 3A 22 67 37 68 30 69  75 38 54 74 31 61 2E 4C | ":"a13FN******.L
    [LK-030A] > 69 67 68 74 53 77 69 74  63 68 5F 53 75 62 44 65 | ightSwitch_SubDe
    [LK-030A] > 76 5F 30 34 22 2C 22 74  69 6D 65 73 74 61 6D 70 | v_04","timestamp
    [LK-030A] > 22 3A 22 31 36 32 35 34  36 36 35 30 31 33 39 36 | ":"1625466501396
    [LK-030A] > 22 2C 22 63 6C 65 61 6E  53 65 73 73 69 6F 6E 22 | ","cleanSession"
    [LK-030A] > 3A 22 66 61 6C 73 65 22  2C 22 73 69 67 6E 22 3A | :"false","sign":
    [LK-030A] > 22 38 42 35 39 39 34 44  32 39 37 32 45 43 37 46 | "8B5994D2972EC7F
    [LK-030A] > 42 36 46 42 31 39 39 32  30 39 36 39 43 39 37 31 | B6FB19920969C971
    [LK-030A] > 31 44 38 34 45 36 45 42  32 42 36 37 46 41 39 35 | 1D84E6EB2B67FA95
    [LK-030A] > 31 43 33 42 34 35 31 41  38 31 39 41 30 44 32 44 | 1C3B451A819*****
    [LK-030A] > 45 22 7D 5D 7D 7D                                | *"}]}}
  3. 如果未选择自动添加拓扑关系,日志如下。
    1. 网关设备连接后,通过网关的Topic /sys/a18wP******/LightSwitchGW/thing/topo/add,向物联网平台发送添加拓扑关系的请求,日志如下:
      [1625466499.399][LK-0309] pub: /sys/a18wP******/LightSwitchGW/thing/topo/add
      
      [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 5B 7B 22 70 72  6F 64 75 63 74 4B 65 79 | s":[{"productKey
      [LK-030A] > 22 3A 22 67 37 68 30 69  75 38 54 74 31 61 22 2C | ":"a13FN******",
      [LK-030A] > 22 64 65 76 69 63 65 4E  61 6D 65 22 3A 22 4C 69 | "deviceName":"Li
      [LK-030A] > 67 68 74 53 77 69 74 63  68 5F 53 75 62 44 65 76 | ghtSwitch_SubDev
      [LK-030A] > 5F 30 31 22 2C 22 63 6C  69 65 6E 74 49 64 22 3A | _01","clientId":
      [LK-030A] > 22 67 37 68 30 69 75 38  54 74 31 61 2E 4C 69 67 | "a13FN******.Lig
      [LK-030A] > 68 74 53 77 69 74 63 68  5F 53 75 62 44 65 76 5F | htSwitch_SubDev_
      [LK-030A] > 30 31 22 2C 22 74 69 6D  65 73 74 61 6D 70 22 3A | 01","timestamp":
      [LK-030A] > 22 31 36 32 35 34 36 36  34 39 39 33 39 36 22 2C | "1625466499396",
      [LK-030A] > 22 73 69 67 6E 6D 65 74  68 6F 64 22 3A 22 68 6D | "signmethod":"hm
      [LK-030A] > 61 63 53 68 61 32 35 36  22 2C 22 73 69 67 6E 22 | acSha256","sign"
      [LK-030A] > 3A 22 33 44 44 32 38 36  39 45 30 45 37 46 35 43 | :"3DD2869E0E7F5C
      [LK-030A] > 41 37 46 43 35 46 30 30  36 37 30 36 44 38 33 45 | A7FC5F006706D83E
      [LK-030A] > 44 36 46 46 39 35 38 39  46 43 35 43 32 33 45 45 | D6FF9589FC5C23EE
      [LK-030A] > 32 44 33 41 46 39 33 39  31 44 46 42 46 32 31 30 | 2D3AF9391DFB****
      [LK-030A] > 37 34 22 7D 2C 7B 22 70  72 6F 64 75 63 74 4B 65 | **"},{"productKe
      [LK-030A] > 79 22 3A 22 67 37 68 30  69 75 38 54 74 31 61 22 | y":"a13FN******"
      [LK-030A] > 2C 22 64 65 76 69 63 65  4E 61 6D 65 22 3A 22 4C | ,"deviceName":"L
      [LK-030A] > 69 67 68 74 53 77 69 74  63 68 5F 53 75 62 44 65 | ightSwitch_SubDe
      [LK-030A] > 76 5F 30 32 22 2C 22 63  6C 69 65 6E 74 49 64 22 | v_02","clientId"
      [LK-030A] > 3A 22 67 37 68 30 69 75  38 54 74 31 61 2E 4C 69 | :"a13FN******.Li
      [LK-030A] > 67 68 74 53 77 69 74 63  68 5F 53 75 62 44 65 76 | ghtSwitch_SubDev
      [LK-030A] > 5F 30 32 22 2C 22 74 69  6D 65 73 74 61 6D 70 22 | _02","timestamp"
      [LK-030A] > 3A 22 31 36 32 35 34 36  36 34 39 39 33 39 36 22 | :"1625466499396"
      [LK-030A] > 2C 22 73 69 67 6E 6D 65  74 68 6F 64 22 3A 22 68 | ,"signmethod":"h
      [LK-030A] > 6D 61 63 53 68 61 32 35  36 22 2C 22 73 69 67 6E | macSha256","sign
      [LK-030A] > 22 3A 22 34 39 44 38 31  43 44 43 44 41 39 31 30 | ":"49D81CDCDA910
      [LK-030A] > 37 36 34 45 32 43 39 42  43 39 44 35 46 31 33 30 | 764E2C9BC9D5F130
      [LK-030A] > 31 30 35 44 34 38 37 42  34 43 34 33 33 41 31 39 | 105D487B4C433A19
      [LK-030A] > 36 35 32 35 46 33 46 41  38 38 39 31 37 37 30 38 | 6525F3FA88917***
      [LK-030A] > 36 31 35 22 7D 2C 7B 22  70 72 6F 64 75 63 74 4B | ***"},{"productK
      [LK-030A] > 65 79 22 3A 22 67 37 68  30 69 75 38 54 74 31 61 | ey":"a13FN******
      [LK-030A] > 22 2C 22 64 65 76 69 63  65 4E 61 6D 65 22 3A 22 | ","deviceName":"
      [LK-030A] > 4C 69 67 68 74 53 77 69  74 63 68 5F 53 75 62 44 | LightSwitch_SubD
      [LK-030A] > 65 76 5F 30 33 22 2C 22  63 6C 69 65 6E 74 49 64 | ev_03","clientId
      [LK-030A] > 22 3A 22 67 37 68 30 69  75 38 54 74 31 61 2E 4C | ":"a13FN******.L
      [LK-030A] > 69 67 68 74 53 77 69 74  63 68 5F 53 75 62 44 65 | ightSwitch_SubDe
      [LK-030A] > 76 5F 30 33 22 2C 22 74  69 6D 65 73 74 61 6D 70 | v_03","timestamp
      [LK-030A] > 22 3A 22 31 36 32 35 34  36 36 34 39 39 33 39 36 | ":"1625466499396
      [LK-030A] > 22 2C 22 73 69 67 6E 6D  65 74 68 6F 64 22 3A 22 | ","signmethod":"
      [LK-030A] > 68 6D 61 63 53 68 61 32  35 36 22 2C 22 73 69 67 | hmacSha256","sig
      [LK-030A] > 6E 22 3A 22 44 33 30 31  46 30 33 31 42 45 37 38 | n":"D301F031BE78
      [LK-030A] > 33 44 42 41 35 42 33 33  42 39 44 43 45 30 32 39 | 3DBA5B33B9DCE029
      [LK-030A] > 38 33 42 41 30 31 42 46  39 37 46 34 34 32 32 43 | 83BA01BF97F4422C
      [LK-030A] > 33 39 45 30 31 44 34 32  41 39 34 41 41 37 45 45 | 39E01D42A94AA***
      [LK-030A] > 41 33 43 42 22 7D 2C 7B  22 70 72 6F 64 75 63 74 | A***"},{"product
      [LK-030A] > 4B 65 79 22 3A 22 67 37  68 30 69 75 38 54 74 31 | Key":"a13FN*****
      [LK-030A] > 61 22 2C 22 64 65 76 69  63 65 4E 61 6D 65 22 3A | *","deviceName":
      [LK-030A] > 22 4C 69 67 68 74 53 77  69 74 63 68 5F 53 75 62 | "LightSwitch_Sub
      [LK-030A] > 44 65 76 5F 30 34 22 2C  22 63 6C 69 65 6E 74 49 | Dev_04","clientI
      [LK-030A] > 64 22 3A 22 67 37 68 30  69 75 38 54 74 31 61 2E | d":"a13FN******.
      [LK-030A] > 4C 69 67 68 74 53 77 69  74 63 68 5F 53 75 62 44 | LightSwitch_SubD
      [LK-030A] > 65 76 5F 30 34 22 2C 22  74 69 6D 65 73 74 61 6D | ev_04","timestam
      [LK-030A] > 70 22 3A 22 31 36 32 35  34 36 36 34 39 39 33 39 | p":"162546649939
      [LK-030A] > 36 22 2C 22 73 69 67 6E  6D 65 74 68 6F 64 22 3A | 6","signmethod":
      [LK-030A] > 22 68 6D 61 63 53 68 61  32 35 36 22 2C 22 73 69 | "hmacSha256","si
      [LK-030A] > 67 6E 22 3A 22 43 41 36  46 35 37 38 34 45 37 45 | gn":"CA6F5784E7E
      [LK-030A] > 45 31 32 32 46 33 35 45  37 41 36 44 36 43 30 31 | E122F35E7A6D6C01
      [LK-030A] > 46 42 35 37 42 30 42 32  44 41 43 39 46 45 38 41 | FB57B0B2DAC9FE8A
      [LK-030A] > 31 44 35 41 44 36 46 38  34 46 32 35 46 39 45 38 | 1D5AD6F84F25F9E*
      [LK-030A] > 30 31 34 38 45 22 7D 5D  7D                      | *****"}]}
    2. 物联网平台收到上述请求后,通过网关的Topic /sys/a18wP******/LightSwitchGW/thing/topo/add_reply,向网关返回应答报文,日志如下:
      [1625466499.500][LK-0309] pub: /sys/a18wP******/LightSwitchGW/thing/topo/add_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 5B 7B 22 70 72  6F 64 75 63 74 4B 65 79 | a":[{"productKey
      [LK-030A] < 22 3A 22 67 37 68 30 69  75 38 54 74 31 61 22 2C | ":"a13FN******",
      [LK-030A] < 22 64 65 76 69 63 65 4E  61 6D 65 22 3A 22 4C 69 | "deviceName":"Li
      [LK-030A] < 67 68 74 53 77 69 74 63  68 5F 53 75 62 44 65 76 | ghtSwitch_SubDev
      [LK-030A] < 5F 30 34 22 7D 2C 7B 22  70 72 6F 64 75 63 74 4B | _04"},{"productK
      [LK-030A] < 65 79 22 3A 22 67 37 68  30 69 75 38 54 74 31 61 | ey":"a13FN******
      [LK-030A] < 22 2C 22 64 65 76 69 63  65 4E 61 6D 65 22 3A 22 | ","deviceName":"
      [LK-030A] < 4C 69 67 68 74 53 77 69  74 63 68 5F 53 75 62 44 | LightSwitch_SubD
      [LK-030A] < 65 76 5F 30 33 22 7D 2C  7B 22 70 72 6F 64 75 63 | ev_03"},{"produc
      [LK-030A] < 74 4B 65 79 22 3A 22 67  37 68 30 69 75 38 54 74 | tKey":"a13FN****
      [LK-030A] < 31 61 22 2C 22 64 65 76  69 63 65 4E 61 6D 65 22 | **","deviceName"
      [LK-030A] < 3A 22 4C 69 67 68 74 53  77 69 74 63 68 5F 53 75 | :"LightSwitch_Su
      [LK-030A] < 62 44 65 76 5F 30 32 22  7D 2C 7B 22 70 72 6F 64 | bDev_02"},{"prod
      [LK-030A] < 75 63 74 4B 65 79 22 3A  22 67 37 68 30 69 75 38 | uctKey":"a13FN**
      [LK-030A] < 54 74 31 61 22 2C 22 64  65 76 69 63 65 4E 61 6D | ****","deviceNam
      [LK-030A] < 65 22 3A 22 4C 69 67 68  74 53 77 69 74 63 68 5F | e":"LightSwitch_
      [LK-030A] < 53 75 62 44 65 76 5F 30  31 22 7D 5D 2C 22 69 64 | SubDev_01"}],"id
      [LK-030A] < 22 3A 22 31 22 2C 22 6D  65 73 73 61 67 65 22 3A | ":"1","message":
      [LK-030A] < 22 73 75 63 63 65 73 73  22 2C 22 6D 65 74 68 6F | "success","metho
      [LK-030A] < 64 22 3A 22 74 68 69 6E  67 2E 74 6F 70 6F 2E 61 | d":"thing.topo.a
      [LK-030A] < 64 64 22 2C 22 76 65 72  73 69 6F 6E 22 3A 22 31 | dd","version":"1
      [LK-030A] < 2E 30 22 7D                                      | .0"}
      
      msgid        : 1
      code         : 200
      product key  : a18wP******
      device name  : LightSwitchGW
      message      : success
      data         : [{"productKey":"a13FN******","deviceName":"LightSwitch_SubDev_04"},{"productKey":"a13FN******","deviceName":"LightSwitch_SubDev_03"},{"productKey":"a13FN******","deviceName":"LightSwitch_SubDev_02"},{"productKey":"a13FN******","deviceName":"LightSwitch_SubDev_01"}]
    3. 物联网平台为网关和子设备添加拓扑关系后,通过网关的Topic /sys/a18wP******/LightSwitchGW/thing/topo/change,向网关返回拓扑关系变更通知,日志如下:
      [1625466499.533][LK-0309] pub: /sys/a18wP******/LightSwitchGW/thing/topo/change
      
      [LK-030A] < 7B 22 6D 65 74 68 6F 64  22 3A 22 74 68 69 6E 67 | {"method":"thing
      [LK-030A] < 2E 74 6F 70 6F 2E 63 68  61 6E 67 65 22 2C 22 69 | .topo.change","i
      [LK-030A] < 64 22 3A 22 31 33 31 32  34 35 35 31 37 30 22 2C | d":"1312455170",
      [LK-030A] < 22 70 61 72 61 6D 73 22  3A 7B 22 73 75 62 4C 69 | "params":{"subLi
      [LK-030A] < 73 74 22 3A 5B 7B 22 64  65 76 69 63 65 4E 61 6D | st":[{"deviceNam
      [LK-030A] < 65 22 3A 22 4C 69 67 68  74 53 77 69 74 63 68 5F | e":"LightSwitch_
      [LK-030A] < 53 75 62 44 65 76 5F 30  31 22 2C 22 70 72 6F 64 | SubDev_01","prod
      [LK-030A] < 75 63 74 4B 65 79 22 3A  22 67 37 68 30 69 75 38 | uctKey":"a13FN**
      [LK-030A] < 54 74 31 61 22 7D 2C 7B  22 64 65 76 69 63 65 4E | ****"},{"deviceN
      [LK-030A] < 61 6D 65 22 3A 22 4C 69  67 68 74 53 77 69 74 63 | ame":"LightSwitc
      [LK-030A] < 68 5F 53 75 62 44 65 76  5F 30 32 22 2C 22 70 72 | h_SubDev_02","pr
      [LK-030A] < 6F 64 75 63 74 4B 65 79  22 3A 22 67 37 68 30 69 | oductKey":"a13FN
      [LK-030A] < 75 38 54 74 31 61 22 7D  2C 7B 22 64 65 76 69 63 | ******"},{"devic
      [LK-030A] < 65 4E 61 6D 65 22 3A 22  4C 69 67 68 74 53 77 69 | eName":"LightSwi
      [LK-030A] < 74 63 68 5F 53 75 62 44  65 76 5F 30 33 22 2C 22 | tch_SubDev_03","
      [LK-030A] < 70 72 6F 64 75 63 74 4B  65 79 22 3A 22 67 37 68 | productKey":"a13
      [LK-030A] < 30 69 75 38 54 74 31 61  22 7D 2C 7B 22 64 65 76 | FN******"},{"dev
      [LK-030A] < 69 63 65 4E 61 6D 65 22  3A 22 4C 69 67 68 74 53 | iceName":"LightS
      [LK-030A] < 77 69 74 63 68 5F 53 75  62 44 65 76 5F 30 34 22 | witch_SubDev_04"
      [LK-030A] < 2C 22 70 72 6F 64 75 63  74 4B 65 79 22 3A 22 67 | ,"productKey":"a
      [LK-030A] < 37 68 30 69 75 38 54 74  31 61 22 7D 5D 2C 22 73 | 13FN******"}],"s
      [LK-030A] < 74 61 74 75 73 22 3A 30  7D 2C 22 76 65 72 73 69 | tatus":0},"versi
      [LK-030A] < 6F 6E 22 3A 22 31 2E 30  2E 30 22 7D             | on":"1.0.0"}
      
      msgid        : 1312455170
      product key  : a18wP******
      device name  : LightSwitchGW
      params       : {"subList":[{"deviceName":"LightSwitch_SubDev_01","productKey":"a13FN******"},{"deviceName":"LightSwitch_SubDev_02","productKey":"a13FN******"},{"deviceName":"LightSwitch_SubDev_03","productKey":"a13FN******"},{"deviceName":"LightSwitch_SubDev_04","productKey":"a13FN******"}],"status":0}
    4. 添加拓扑关系后,向物联网平台发送登录子设备的请求,日志如下:
      [1625466501.399][LK-0309] pub: /ext/session/a18wP******/LightSwitchGW/combine/batch_login
      
      [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 73 69 67  6E 4D 65 74 68 6F 64 22 | s":{"signMethod"
      [LK-030A] > 3A 22 68 6D 61 63 53 68  61 32 35 36 22 2C 22 64 | :"hmacSha256","d
      [LK-030A] > 65 76 69 63 65 4C 69 73  74 22 3A 5B 7B 22 70 72 | eviceList":[{"pr
      [LK-030A] > 6F 64 75 63 74 4B 65 79  22 3A 22 67 37 68 30 69 | oductKey":"a13FN
      [LK-030A] > 75 38 54 74 31 61 22 2C  22 64 65 76 69 63 65 4E | ******","deviceN
      [LK-030A] > 61 6D 65 22 3A 22 4C 69  67 68 74 53 77 69 74 63 | ame":"LightSwitc
      [LK-030A] > 68 5F 53 75 62 44 65 76  5F 30 31 22 2C 22 63 6C | h_SubDev_01","cl
      [LK-030A] > 69 65 6E 74 49 64 22 3A  22 67 37 68 30 69 75 38 | ientId":"a13FN**
      [LK-030A] > 54 74 31 61 2E 4C 69 67  68 74 53 77 69 74 63 68 | ****.LightSwitch
      [LK-030A] > 5F 53 75 62 44 65 76 5F  30 31 22 2C 22 74 69 6D | _SubDev_01","tim
      [LK-030A] > 65 73 74 61 6D 70 22 3A  22 31 36 32 35 34 36 36 | estamp":"1625466
      [LK-030A] > 35 30 31 33 39 36 22 2C  22 63 6C 65 61 6E 53 65 | 501396","cleanSe
      [LK-030A] > 73 73 69 6F 6E 22 3A 22  66 61 6C 73 65 22 2C 22 | ssion":"false","
      [LK-030A] > 73 69 67 6E 22 3A 22 30  46 41 45 38 43 33 43 33 | sign":"0FAE8C3C3
      [LK-030A] > 34 38 44 35 30 37 38 38  43 41 42 38 38 42 36 44 | 48D50788CAB88B6D
      [LK-030A] > 39 44 34 34 43 35 44 35  36 46 45 46 44 42 33 45 | 9D44C5D56FEFDB3E
      [LK-030A] > 43 46 41 30 30 35 38 37  32 30 41 43 34 45 37 43 | CFA0058720AC4E7C
      [LK-030A] > 46 36 44 36 34 44 36 22  7D 2C 7B 22 70 72 6F 64 | F******"},{"prod
      [LK-030A] > 75 63 74 4B 65 79 22 3A  22 67 37 68 30 69 75 38 | uctKey":"a13FN**
      [LK-030A] > 54 74 31 61 22 2C 22 64  65 76 69 63 65 4E 61 6D | ****","deviceNam
      [LK-030A] > 65 22 3A 22 4C 69 67 68  74 53 77 69 74 63 68 5F | e":"LightSwitch_
      [LK-030A] > 53 75 62 44 65 76 5F 30  32 22 2C 22 63 6C 69 65 | SubDev_02","clie
      [LK-030A] > 6E 74 49 64 22 3A 22 67  37 68 30 69 75 38 54 74 | ntId":"a13FN****
      [LK-030A] > 31 61 2E 4C 69 67 68 74  53 77 69 74 63 68 5F 53 | **.LightSwitch_S
      [LK-030A] > 75 62 44 65 76 5F 30 32  22 2C 22 74 69 6D 65 73 | ubDev_02","times
      [LK-030A] > 74 61 6D 70 22 3A 22 31  36 32 35 34 36 36 35 30 | tamp":"162546650
      [LK-030A] > 31 33 39 36 22 2C 22 63  6C 65 61 6E 53 65 73 73 | 1396","cleanSess
      [LK-030A] > 69 6F 6E 22 3A 22 66 61  6C 73 65 22 2C 22 73 69 | ion":"false","si
      [LK-030A] > 67 6E 22 3A 22 33 31 36  45 45 36 35 37 33 46 31 | gn":"316EE6573F1
      [LK-030A] > 35 37 33 38 36 32 41 34  42 37 35 39 45 32 35 42 | 573862A4B759E25B
      [LK-030A] > 43 32 34 41 32 30 33 44  35 30 31 43 41 30 42 35 | C24A203D501CA0B5
      [LK-030A] > 31 44 30 35 30 30 41 32  32 45 34 39 46 42 38 38 | 1D0500A22E49FB88
      [LK-030A] > 39 46 32 42 35 22 7D 2C  7B 22 70 72 6F 64 75 63 | *****"},{"produc
      [LK-030A] > 74 4B 65 79 22 3A 22 67  37 68 30 69 75 38 54 74 | tKey":"g7h0i****
      [LK-030A] > 31 61 22 2C 22 64 65 76  69 63 65 4E 61 6D 65 22 | **","deviceName"
      [LK-030A] > 3A 22 4C 69 67 68 74 53  77 69 74 63 68 5F 53 75 | :"LightSwitch_Su
      [LK-030A] > 62 44 65 76 5F 30 33 22  2C 22 63 6C 69 65 6E 74 | bDev_03","client
      [LK-030A] > 49 64 22 3A 22 67 37 68  30 69 75 38 54 74 31 61 | Id":"a13FN******
      [LK-030A] > 2E 4C 69 67 68 74 53 77  69 74 63 68 5F 53 75 62 | .LightSwitch_Sub
      [LK-030A] > 44 65 76 5F 30 33 22 2C  22 74 69 6D 65 73 74 61 | Dev_03","timesta
      [LK-030A] > 6D 70 22 3A 22 31 36 32  35 34 36 36 35 30 31 33 | mp":"16254665013
      [LK-030A] > 39 36 22 2C 22 63 6C 65  61 6E 53 65 73 73 69 6F | 96","cleanSessio
      [LK-030A] > 6E 22 3A 22 66 61 6C 73  65 22 2C 22 73 69 67 6E | n":"false","sign
      [LK-030A] > 22 3A 22 37 31 30 43 44  43 37 31 36 34 34 35 36 | ":"710CDC7164456
      [LK-030A] > 43 39 43 45 41 36 44 39  43 33 30 41 35 44 38 30 | C9CEA6D9C30A5D80
      [LK-030A] > 32 33 42 41 32 46 46 45  42 30 32 41 33 46 36 37 | 23BA2FFEB02A3F67
      [LK-030A] > 35 41 37 41 34 39 32 34  33 45 33 33 41 32 31 45 | 5A7A49243E33A21E
      [LK-030A] > 36 36 44 22 7D 2C 7B 22  70 72 6F 64 75 63 74 4B | ***"},{"productK
      [LK-030A] > 65 79 22 3A 22 67 37 68  30 69 75 38 54 74 31 61 | ey":"a13FN******
      [LK-030A] > 22 2C 22 64 65 76 69 63  65 4E 61 6D 65 22 3A 22 | ","deviceName":"
      [LK-030A] > 4C 69 67 68 74 53 77 69  74 63 68 5F 53 75 62 44 | LightSwitch_SubD
      [LK-030A] > 65 76 5F 30 34 22 2C 22  63 6C 69 65 6E 74 49 64 | ev_04","clientId
      [LK-030A] > 22 3A 22 67 37 68 30 69  75 38 54 74 31 61 2E 4C | ":"a13FN******.L
      [LK-030A] > 69 67 68 74 53 77 69 74  63 68 5F 53 75 62 44 65 | ightSwitch_SubDe
      [LK-030A] > 76 5F 30 34 22 2C 22 74  69 6D 65 73 74 61 6D 70 | v_04","timestamp
      [LK-030A] > 22 3A 22 31 36 32 35 34  36 36 35 30 31 33 39 36 | ":"1625466501396
      [LK-030A] > 22 2C 22 63 6C 65 61 6E  53 65 73 73 69 6F 6E 22 | ","cleanSession"
      [LK-030A] > 3A 22 66 61 6C 73 65 22  2C 22 73 69 67 6E 22 3A | :"false","sign":
      [LK-030A] > 22 38 42 35 39 39 34 44  32 39 37 32 45 43 37 46 | "8B5994D2972EC7F
      [LK-030A] > 42 36 46 42 31 39 39 32  30 39 36 39 43 39 37 31 | B6FB19920969C971
      [LK-030A] > 31 44 38 34 45 36 45 42  32 42 36 37 46 41 39 35 | 1D84E6EB2B67FA95
      [LK-030A] > 31 43 33 42 34 35 31 41  38 31 39 41 30 44 32 44 | 1C3B451A819*****
      [LK-030A] > 45 22 7D 5D 7D 7D                                | *"}]}}
  4. 子设备登录成功后,物联网平台向网关返回响应报文,日志如下:
    [1625466501.500][LK-0309] pub: /ext/session/a18wP******/LightSwitchGW/combine/batch_login_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 5B 7B 22 70 72  6F 64 75 63 74 4B 65 79 | a":[{"productKey
    [LK-030A] < 22 3A 22 67 37 68 30 69  75 38 54 74 31 61 22 2C | ":"a13FN******",
    [LK-030A] < 22 64 65 76 69 63 65 4E  61 6D 65 22 3A 22 4C 69 | "deviceName":"Li
    [LK-030A] < 67 68 74 53 77 69 74 63  68 5F 53 75 62 44 65 76 | ghtSwitch_SubDev
    [LK-030A] < 5F 30 31 22 7D 2C 7B 22  70 72 6F 64 75 63 74 4B | _01"},{"productK
    [LK-030A] < 65 79 22 3A 22 67 37 68  30 69 75 38 54 74 31 61 | ey":"a13FN******
    [LK-030A] < 22 2C 22 64 65 76 69 63  65 4E 61 6D 65 22 3A 22 | ","deviceName":"
    [LK-030A] < 4C 69 67 68 74 53 77 69  74 63 68 5F 53 75 62 44 | LightSwitch_SubD
    [LK-030A] < 65 76 5F 30 32 22 7D 2C  7B 22 70 72 6F 64 75 63 | ev_02"},{"produc
    [LK-030A] < 74 4B 65 79 22 3A 22 67  37 68 30 69 75 38 54 74 | tKey":"a13FN****
    [LK-030A] < 31 61 22 2C 22 64 65 76  69 63 65 4E 61 6D 65 22 | 1a","deviceName"
    [LK-030A] < 3A 22 4C 69 67 68 74 53  77 69 74 63 68 5F 53 75 | :"LightSwitch_Su
    [LK-030A] < 62 44 65 76 5F 30 33 22  7D 2C 7B 22 70 72 6F 64 | bDev_03"},{"prod
    [LK-030A] < 75 63 74 4B 65 79 22 3A  22 67 37 68 30 69 75 38 | uctKey":"a13FN**
    [LK-030A] < 54 74 31 61 22 2C 22 64  65 76 69 63 65 4E 61 6D | ****","deviceNam
    [LK-030A] < 65 22 3A 22 4C 69 67 68  74 53 77 69 74 63 68 5F | e":"LightSwitch_
    [LK-030A] < 53 75 62 44 65 76 5F 30  34 22 7D 5D 2C 22 69 64 | SubDev_04"}],"id
    [LK-030A] < 22 3A 22 32 22 2C 22 6D  65 73 73 61 67 65 22 3A | ":"2","message":
    [LK-030A] < 22 73 75 63 63 65 73 73  22 7D                   | "success"}
    
    msgid        : 2
    code         : 200
    product key  : a18wP******
    device name  : LightSwitchGW
    message      : success
    data         : [{"productKey":"a13FN******","deviceName":"LightSwitch_SubDev_01"},{"productKey":"a13FN******","deviceName":"LightSwitch_SubDev_02"},{"productKey":"a13FN******","deviceName":"LightSwitch_SubDev_03"},{"productKey":"a13FN******","deviceName":"LightSwitch_SubDev_04"}]
  5. 可选:如果您配置子设备订阅Topic相关代码,网关设备将收到如下日志。该日志表示子设备已订阅Topic /a13FN******/LightSwitch_SubDev_01/user/get
    [1625470230.077][LK-0309] sub: /a13FN******/LightSwitch_SubDev_01/user/get

    Topic订阅成功后,您可以登录物联网平台控制台,在设备详情页面的Topic列表页签,单击订阅的Topic操作栏的发布消息,然后在发布消息对话框的消息输入栏中,输入一条消息(例如:This is a test message from Alibaba Iot Platform.),模拟从物联网平台向子设备发送信息。

    向子设备发送消息
    网关设备收到消息后,打印如下日志。
    重要 您需自行编写代码逻辑,将网关设备接收到的消息转发到设备。
    [1625472952.433][LK-0309] pub: /a13FN******/LightSwitch_SubDev_01/user/get
    
    [LK-030A] < 54 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 20 66  72 6F 6D 20 41 6C 69 62 | essage from Alib
    [LK-030A] < 61 62 61 20 49 6F 74 20  50 6C 61 74 66 6F 72 6D | aba Iot Platform
    [LK-030A] < 2E                                               | .
    
    pub, qos: 0, topic: /a13FN******/LightSwitch_SubDev_01/user/get
    pub, payload: This is a test message from Alibaba Iot Platform.
  6. 批量上报子设备消息的日子如下。
    [1629707578.833][LK-0309] pub[4]: /sys/a18Wp******/LightSwitchGW/proxy/batch_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 5B 7B 22 74 6F  70 69 63 22 3A 22 2F 73 | s":[{"topic":"/s
    [LK-030A] > 79 73 2F 61 31 58 48 53  67 64 4B 42 37 4F 2F 73 | ys/a13FN******/s
    [LK-030A] > 75 62 5F 64 65 76 69 63  65 5F 74 65 73 74 5F 30 | ub_device_test_0
    [LK-030A] > 30 30 31 2F 74 68 69 6E  67 2F 65 76 65 6E 74 2F | 001/thing/event/
    [LK-030A] > 70 72 6F 70 65 72 74 79  2F 70 6F 73 74 22 2C 22 | property/post","
    [LK-030A] > 70 61 79 6C 6F 61 64 22  3A 22 65 79 4A 70 5A 43 | payload":"eyJpZC
    [LK-030A] > 49 36 49 6A 45 69 4C 43  4A 32 5A 58 4A 7A 61 57 | I6IjEiLCJ2ZXJzaW
    [LK-030A] > 39 75 49 6A 6F 69 4D 53  34 77 49 69 77 69 63 47 | 9uIjoiMS4wIiwicG
    [LK-030A] > 46 79 59 57 31 7A 49 6A  70 37 49 6E 42 49 49 6A | FyYW1zIjp7InBIIj
    [LK-030A] > 6F 31 66 58 30 41 22 7D  2C 7B 22 74 6F 70 69 63 | o1fX0A"},{"topic
    [LK-030A] > 22 3A 22 2F 73 79 73 2F  61 31 58 48 53 67 64 4B | ":"/sys/a13FNgdK
    [LK-030A] > 42 37 4F 2F 73 75 62 5F  64 65 76 69 63 65 5F 74 | B7O/sub_device_t
    [LK-030A] > 65 73 74 5F 30 30 30 32  2F 74 68 69 6E 67 2F 65 | est_0002/thing/e
    [LK-030A] > 76 65 6E 74 2F 70 72 6F  70 65 72 74 79 2F 70 6F | vent/property/po
    [LK-030A] > 73 74 22 2C 22 70 61 79  6C 6F 61 64 22 3A 22 65 | st","payload":"e
    [LK-030A] > 79 4A 70 5A 43 49 36 49  6A 45 69 4C 43 4A 32 5A | yJpZCI6IjEiLCJ2Z
    [LK-030A] > 58 4A 7A 61 57 39 75 49  6A 6F 69 4D 53 34 77 49 | XJzaW9uIjoiMS4wI
    [LK-030A] > 69 77 69 63 47 46 79 59  57 31 7A 49 6A 70 37 49 | iwicGFyYW1zIjp7I
    [LK-030A] > 6E 42 49 49 6A 6F 31 66  58 30 41 22 7D 2C 7B 22 | nBIIjo1fX0A"},{"
    [LK-030A] > 74 6F 70 69 63 22 3A 22  2F 73 79 73 2F 61 31 58 | topic":"/sys/a1X
    [LK-030A] > 48 53 67 64 4B 42 37 4F  2F 73 75 62 5F 64 65 76 | HS******/sub_dev
    [LK-030A] > 69 63 65 5F 74 65 73 74  5F 30 30 30 33 2F 74 68 | ice_test_0003/th
    [LK-030A] > 69 6E 67 2F 65 76 65 6E  74 2F 70 72 6F 70 65 72 | ing/event/proper
    [LK-030A] > 74 79 2F 70 6F 73 74 22  2C 22 70 61 79 6C 6F 61 | ty/post","payload"
    [LK-030A] > 64 22 3A 22 65 79 4A 70  5A 43 49 36 49 6A 45 69 | :"eyJpZCI6IjEi
    [LK-030A] > 4C 43 4A 32 5A 58 4A 7A  61 57 39 75 49 6A 6F 69 | LCJ2ZXJzaW9uIjoi
    [LK-030A] > 4D 53 34 77 49 69 77 69  63 47 46 79 59 57 31 7A | MS4wIiwicGFyYW1z
    [LK-030A] > 49 6A 70 37 49 6E 42 49  49 6A 6F 31 66 58 30 41 | Ijp7InBIIjo1fX0A
    [LK-030A] > 22 7D 2C 7B 22 74 6F 70  69 63 22 3A 22 2F 73 79 | "},{"topic":"/sy
    [LK-030A] > 73 2F 61 31 58 48 53 67  64 4B 42 37 4F 2F 73 75 | s/a13FN******/su
    [LK-030A] > 62 5F 64 65 76 69 63 65  5F 74 65 73 74 5F 30 30 | b_device_test_00
    [LK-030A] > 30 34 2F 74 68 69 6E 67  2F 65 76 65 6E 74 2F 70 | 04/thing/event/p
    [LK-030A] > 72 6F 70 65 72 74 79 2F  70 6F 73 74 22 2C 22 70 | roperty/post","p
    [LK-030A] > 61 79 6C 6F 61 64 22 3A  22 65 79 4A 70 5A 43 49 | ayload":"eyJpZCI
    [LK-030A] > 36 49 6A 45 69 4C 43 4A  32 5A 58 4A 7A 61 57 39 | 6IjEiLCJ2ZXJzaW9
    [LK-030A] > 75 49 6A 6F 69 4D 53 34  77 49 69 77 69 63 47 46 | uIjoiMS4wIiwicGF
    [LK-030A] > 79 59 57 31 7A 49 6A 70  37 49 6E 42 49 49 6A 6F | yYW1zIjp7InBIIjo
    [LK-030A] > 31 66 58 30 41 22 7D 2C  7B 22 74 6F 70 69 63 22 | 1fX0A"},{"topic"
    [LK-030A] > 3A 22 2F 73 79 73 2F 61  31 58 48 53 67 64 4B 42 | :"/sys/a13FNgdKB
    [LK-030A] > 37 4F 2F 73 75 62 5F 64  65 76 69 63 65 5F 74 65 | 7O/sub_device_te
    [LK-030A] > 73 74 5F 30 30 30 31 2F  74 68 69 6E 67 2F 65 76 | st_0001/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 22 2C 22 70 61 79 6C  6F 61 64 22 3A 22 65 79 | t","payload":"ey
    [LK-030A] > 4A 70 5A 43 49 36 49 6A  45 69 4C 43 4A 32 5A 58 | JpZCI6IjEiLCJ2ZX
    [LK-030A] > 4A 7A 61 57 39 75 49 6A  6F 69 4D 53 34 77 49 69 | JzaW9uIjoiMS4wIi
    [LK-030A] > 77 69 63 47 46 79 59 57  31 7A 49 6A 70 37 49 6E | wicGFyYW1zIjp7In
    [LK-030A] > 42 49 49 6A 6F 31 66 58  30 41 22 7D 2C 7B 22 74 | BIIjo1fX0A"},{"t
    [LK-030A] > 6F 70 69 63 22 3A 22 2F  73 79 73 2F 61 31 58 48 | opic":"/sys/a1XH
    [LK-030A] > 53 67 64 4B 42 37 4F 2F  73 75 62 5F 64 65 76 69 | S******/sub_devi
    [LK-030A] > 63 65 5F 74 65 73 74 5F  30 30 30 32 2F 74 68 69 | ce_test_0002/thi
    [LK-030A] > 6E 67 2F 65 76 65 6E 74  2F 70 72 6F 70 65 72 74 | ng/event/propert
    [LK-030A] > 79 2F 70 6F 73 74 22 2C  22 70 61 79 6C 6F 61 64 | y/post","payload
    [LK-030A] > 22 3A 22 65 79 4A 70 5A  43 49 36 49 6A 45 69 4C | ":"eyJpZCI6IjEiL
    [LK-030A] > 43 4A 32 5A 58 4A 7A 61  57 39 75 49 6A 6F 69 4D | CJ2ZXJzaW9uIjoiM
    [LK-030A] > 53 34 77 49 69 77 69 63  47 46 79 59 57 31 7A 49 | S4wIiwicGFyYW1zI
    [LK-030A] > 6A 70 37 49 6E 42 49 49  6A 6F 31 66 58 30 41 22 | jp7InBIIjo1fX0A"
    [LK-030A] > 7D 2C 7B 22 74 6F 70 69  63 22 3A 22 2F 73 79 73 | },{"topic":"/sys
    [LK-030A] > 2F 61 31 58 48 53 67 64  4B 42 37 4F 2F 73 75 62 | /a13FN******/sub
    [LK-030A] > 5F 64 65 76 69 63 65 5F  74 65 73 74 5F 30 30 30 | _device_test_000
    [LK-030A] > 33 2F 74 68 69 6E 67 2F  65 76 65 6E 74 2F 70 72 | 3/thing/event/pr
    [LK-030A] > 6F 70 65 72 74 79 2F 70  6F 73 74 22 2C 22 70 61 | operty/post","pa
    [LK-030A] > 79 6C 6F 61 64 22 3A 22  65 79 4A 70 5A 43 49 36 | yload":"eyJpZCI6
    [LK-030A] > 49 6A 45 69 4C 43 4A 32  5A 58 4A 7A 61 57 39 75 | IjEiLCJ2ZXJzaW9u
    [LK-030A] > 49 6A 6F 69 4D 53 34 77  49 69 77 69 63 47 46 79 | IjoiMS4wIiwicGFy
    [LK-030A] > 59 57 31 7A 49 6A 70 37  49 6E 42 49 49 6A 6F 31 | YW1zIjp7InBIIjo1
    [LK-030A] > 66 58 30 41 22 7D 5D 7D                          | fX0A"}]}   
    
    [1629707578.955][LK-0309] pub: /sys/a18Wp******/LightSwitchGW/proxy/batch_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 5B 7B 22 63 6F  64 65 22 3A 32 30 30 2C | a":[{"code":200,
    [LK-030A] < 22 74 6F 70 69 63 22 3A  22 2F 73 79 73 2F 61 31 | "topic":"/sys/a1
    [LK-030A] < 58 48 53 67 64 4B 42 37  4F 2F 73 75 62 5F 64 65 | XHS******/sub_de
    [LK-030A] < 76 69 63 65 5F 74 65 73  74 5F 30 30 30 31 2F 74 | vice_test_0001/t
    [LK-030A] < 68 69 6E 67 2F 65 76 65  6E 74 2F 70 72 6F 70 65 | hing/event/prope
    [LK-030A] < 72 74 79 2F 70 6F 73 74  22 7D 2C 7B 22 63 6F 64 | rty/post"},{"cod
    [LK-030A] < 65 22 3A 32 30 30 2C 22  74 6F 70 69 63 22 3A 22 | e":200,"topic":"
    [LK-030A] < 2F 73 79 73 2F 61 31 58  48 53 67 64 4B 42 37 4F | /sys/a13FN******
    [LK-030A] < 2F 73 75 62 5F 64 65 76  69 63 65 5F 74 65 73 74 | /sub_device_test
    [LK-030A] < 5F 30 30 30 32 2F 74 68  69 6E 67 2F 65 76 65 6E | _0002/thing/even
    [LK-030A] < 74 2F 70 72 6F 70 65 72  74 79 2F 70 6F 73 74 22 | t/property/post"
    [LK-030A] < 7D 2C 7B 22 63 6F 64 65  22 3A 32 30 30 2C 22 74 | },{"code":200,"t
    [LK-030A] < 6F 70 69 63 22 3A 22 2F  73 79 73 2F 61 31 58 48 | opic":"/sys/a1XH
    [LK-030A] < 53 67 64 4B 42 37 4F 2F  73 75 62 5F 64 65 76 69 | S******/sub_devi
    [LK-030A] < 63 65 5F 74 65 73 74 5F  30 30 30 33 2F 74 68 69 | ce_test_0003/thi
    [LK-030A] < 6E 67 2F 65 76 65 6E 74  2F 70 72 6F 70 65 72 74 | ng/event/propert
    [LK-030A] < 79 2F 70 6F 73 74 22 7D  2C 7B 22 63 6F 64 65 22 | y/post"},{"code"
    [LK-030A] < 3A 32 30 30 2C 22 74 6F  70 69 63 22 3A 22 2F 73 | :200,"topic":"/s
    [LK-030A] < 79 73 2F 61 31 58 48 53  67 64 4B 42 37 4F 2F 73 | ys/a13FN******/s
    [LK-030A] < 75 62 5F 64 65 76 69 63  65 5F 74 65 73 74 5F 30 | ub_device_test_0
    [LK-030A] < 30 30 34 2F 74 68 69 6E  67 2F 65 76 65 6E 74 2F | 004/thing/event/
    [LK-030A] < 70 72 6F 70 65 72 74 79  2F 70 6F 73 74 22 7D 2C | property/post"},
    [LK-030A] < 7B 22 63 6F 64 65 22 3A  32 30 30 2C 22 74 6F 70 | {"code":200,"top
    [LK-030A] < 69 63 22 3A 22 2F 73 79  73 2F 61 31 58 48 53 67 | ic":"/sys/a13FNg
    [LK-030A] < 64 4B 42 37 4F 2F 73 75  62 5F 64 65 76 69 63 65 | dKB7O/sub_device
    [LK-030A] < 5F 74 65 73 74 5F 30 30  30 31 2F 74 68 69 6E 67 | _test_0001/thing
    [LK-030A] < 2F 65 76 65 6E 74 2F 70  72 6F 70 65 72 74 79 2F | /event/property/
    [LK-030A] < 70 6F 73 74 22 7D 2C 7B  22 63 6F 64 65 22 3A 32 | post"},{"code":2
    [LK-030A] < 30 30 2C 22 74 6F 70 69  63 22 3A 22 2F 73 79 73 | 00,"topic":"/sys
    [LK-030A] < 2F 61 31 58 48 53 67 64  4B 42 37 4F 2F 73 75 62 | /a13FN******/sub
    [LK-030A] < 5F 64 65 76 69 63 65 5F  74 65 73 74 5F 30 30 30 | _device_test_000
    [LK-030A] < 32 2F 74 68 69 6E 67 2F  65 76 65 6E 74 2F 70 72 | 2/thing/event/pr
    [LK-030A] < 6F 70 65 72 74 79 2F 70  6F 73 74 22 7D 2C 7B 22 | operty/post"},{"
    [LK-030A] < 63 6F 64 65 22 3A 32 30  30 2C 22 74 6F 70 69 63 | code":200,"topic
    [LK-030A] < 22 3A 22 2F 73 79 73 2F  61 31 58 48 53 67 64 4B | ":"/sys/a13FNgdK
    [LK-030A] < 42 37 4F 2F 73 75 62 5F  64 65 76 69 63 65 5F 74 | B7O/sub_device_t
    [LK-030A] < 65 73 74 5F 30 30 30 33  2F 74 68 69 6E 67 2F 65 | est_0003/thing/e
    [LK-030A] < 76 65 6E 74 2F 70 72 6F  70 65 72 74 79 2F 70 6F | vent/property/po
    [LK-030A] < 73 74 22 7D 5D 7D                                | st"}]}  
  7. 可选:如果您配置了子设备发送消息的相关代码,设备端打印以下日志,说明子设备通过Topic /a13FN******/LightSwitch_SubDev_01/user/update,向物联网平台上报了一条消息。
    [1625470230.077][LK-0309] pub: /a13FN******/LightSwitch_SubDev_01/user/update
    
    [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 7D 7D                                   | ":0}}

物联网平台日志

您可以在物联网平台控制台查看设备的状态和运行日志。

  • 在左侧导航栏,选择设备管理 > 设备,找到网关设备和子设备,查看设备状态。设备状态显示为在线,则表示设备与物联网平台成功连接。网关设备和子设备的在线状态
  • 在左侧导航栏,选择监控运维 > 日志服务,选择产品后,查看设备上线、订阅Topic和上报消息的日志。

    • 选择网关对应的产品后,日志如下图所示。您可以查看网关与子设备建立拓扑关系的过程。

      单击查看按钮,您可查看每一条日志消息的内容。

      网关设备日志
    • 选择子设备对应的产品后,日志如下图所示。子设备LightSwitch_SubDev_01登录后,订阅了Topic,并接收了来自物联网平台的消息。子设备日志

后续步骤

运行日志中出现的错误信息,请参见aiot_subdev_api.h中的状态码描述,根据提示解决问题。