如下代码,终端A(client)想要取得终端B(server)的属性:
tmpDstAddr.addrMode = (afAddrMode_t)Addr16Bit;
tmpDstAddr.endPoint = 0x01;
tmpDstAddr.addr.shortAddr = 0xC859;
BasicAttrsList.numAttr = 1;
BasicAttrsList.attrID[0] = ATTRID_BASIC_MANUFACTURER_NAME;
status = zcl_SendRead( SAMPLESW_ENDPOINT, &tmpDstAddr,
ZCL_CLUSTER_ID_GEN_BASIC, &BasicAttrsList,
ZCL_FRAME_CLIENT_SERVER_DIR, FALSE, bdb_getZCLFrameCounter() );
发送成功,却没有接受到Read Response。通过抓包来看,代码中指定了终端B的地址(0xC859),但是这帧的目的地址显示却是0x0000,请教大神,是什么原因,如何解决?
补充说明:因为是测试代码,通过抓包,已经确定了目的地址等信息,所以hard coding了,在zcl_SendRead之前,调用zclGeneral_SendOnOff_CmdOn对终端B(0xC859)操作就没有问题。
zhaoqqq:
仔细确认了下抓的包,发现:
MAC Header里的Destination Address是0x0000,NWK Header里的Destination Address是0x0004
这是怎么回事啊?
YiKai Chen:
請附上抓包檔分析問題
zhaoqqq:
回复 YiKai Chen:
YK Chen,
这是zcl_SendRead的包,麻烦看看是什么原因,谢谢!Basic: Read Attributes 61-88-A9-4B-90-00-00-BD-F9-48-22-04-00-BD-F9-1E-09-28-0F-00-00-00-07-7F-75-0F-00-4B-12-00-00-00-01-00-00-04-01-08-18-00-04-00-04-00-3F-7D-62-FF-FF-FF
Frame Information: (50 bytes)Packet ID: 181Protocol: ZigBeeTimestamp: 09/17/2019 07:56:11Channel: 20Length: 50RSSI: -42 dBmSource Id: -1431132140Status: Encrypted
MAC Header: (9 bytes)Frame Control: 0x8861・・・・ ・・・・ ・・・・ ・001 = Frame Type: [0x1] Data・・・・ ・・・・ ・・・・ 0・・・ = Security Enabled: [0x0] No・・・・ ・・・・ ・・・0 ・・・・ = Frame Pending: [0x0] No・・・・ ・・・・ ・・1・ ・・・・ = Acknowledgement Request: [0x1] Yes・・・・ ・・・・ ・1・・ ・・・・ = Intra-PAN: [0x1] Yes・・・・ ・・00 0・・・ ・・・・ = Reserved: 0x0・・・・ 10・・ ・・・・ ・・・・ = Destination Addr Mode: [0x2] 16-bit Short Address・・00 ・・・・ ・・・・ ・・・・ = Reserved: 0x010・・ ・・・・ ・・・・ ・・・・ = Source Addr Mode: [0x2] 16-bit Short AddressSequence Number: 169Destination PAN ID: 0x904BDestination Address: 0x0000Source Address: 0xF9BD
MAC Payload: (39 bytes)NWK Header: 0x091EF9BD00042248Frame Control: 0x2248・・・・ ・・・・ ・・・・ ・・00 = Frame Type: [0x0] Data・・・・ ・・・・ ・・00 10・・ = Protocol Version: [0x2] ZigBee Pro・・・・ ・・・・ 01・・ ・・・・ = Route Discovery: [0x1] Enabled・・・・ ・・・0 ・・・・ ・・・・ = Multicast Flag: [0x0] Unicast or Broadcast・・・・ ・・1・ ・・・・ ・・・・ = Security Enabled: [0x1] Yes・・・・ ・0・・ ・・・・ ・・・・ = Source Route Included: [0x0] No・・・・ 0・・・ ・・・・ ・・・・ = Destination IEEE Address Included: [0x0] No・・・0 ・・・・ ・・・・ ・・・・ = Source IEEE Address Included: [0x0] No・・1・ ・・・・ ・・・・ ・・・・ = End Device Initiator: [0x1] Yes00・・ ・・・・ ・・・・ ・・・・ = Reserved: 0x0Destination Address: 0x0004Source Address: 0xF9BDRadius: 0x1ESequence Number: 9NWK Aux Header: (14 bytes)Network Security Control: 0x28・・・・ ・000 = Network Security Level: [0x0] None・・・0 1・・・ = Key NWK ID: [0x1] Network Key・・1・ ・・・・ = Extended Nonce: [0x1] Yes00・・ ・・・・ = Reserved: 0x0NWK Frame Counter: 15Source Address: 00:12:4B:00:0F:75:7F:07NWK Key Sequence Number: 0NWK Payload: (13 bytes)APS Header: 0x1808010400000100Frame Control: 0x00・・・・ ・・00 = Frame Type: [0x0] Data・・・・ 00・・ = Delivery Mode: [0x0] Normal Unicast Delivery・・・0 ・・・・ = Acknowledgement Format: 0x0Format: [0x0] Data Frame・・0・ ・・・・ = Security Enabled: [0x0] No・0・・ ・・・・ = Acknowledgement Request: 0x0Request: [0x0] No0・・・ ・・・・ = Extended Header Present: [0x0] NoDestination Endpoint: 0x01Cluster ID: [0x0000] General: BasicProfile ID: [0x0104] ZigBee Home AutomationSource Endpoint: 0x08APS Counter: 24APS Payload: 0x0004000400ZCL Header: 0x000400Frame Control: 0x00・・・・ ・・00 = Frame Type: [0x0] Command Acts Across the Entire Profile・・・・ ・0・・ = Manufacturer Specific: [0x0] Manufacturer Code Not Included in the ZCL Frame・・・・ 0・・・ = Direction: [0x0] From Client to Server・・・0 ・・・・ = Disable Default Response: [0x0] No000・ ・・・・ = Reserved: 0x0Transaction Sequence Number: 4General Command Frame: [0x00] Read AttributesZCL Payload: 0x0004Attribute ID: [0x0004] Manufacturer NameNWK MIC: 0x3F7D62FF
MAC Footer: 0xFFFFFrame Check Sequence: 0xFFFF
YiKai Chen:
回复 zhaoqqq:
請附上完整的抓包檔
zhaoqqq:
回复 YiKai Chen:
YK Chen,
请参考,谢谢!0917_181.txt
YiKai Chen:
回复 zhaoqqq:
你是用什麼工具抓包的,為什麼抓包檔是txt格式?
zhaoqqq:
回复 YiKai Chen:
YK Chen,
Ubiqua,附上cubx文档,谢谢!0917_181.zip
YiKai Chen:
你的抓包檔裡面完全沒有看到發給0xC859這個設備的封包啊,你確定"在zcl_SendRead之前,调用zclGeneral_SendOnOff_CmdOn对终端B(0xC859)操作就没有问题"? 可否指出你抓包檔哪裡有送給0xC859的On Command?
zhaoqqq:
回复 YiKai Chen:
YK Chen,
zcl_SendRead和zclGeneral_SendOnOff_CmdOn在代码中是if-else,所以刚才的抓包档里没有zclGeneral_SendOnOff_CmdOn。
这次这个抓包档里有zcl_SendRead(Packet ID: 11)和zclGeneral_SendOnOff_CmdOn(Packet ID: 77)。0917_read_on.zip
请参考,谢谢!
zhaoqqq:
回复 zhaoqqq:
另,附上zclGeneral_SendOnOff_CmdOn的代码,对目标地址的处理和zcl_SendRead是一样的:tmpDstAddr.addrMode = (afAddrMode_t)Addr16Bit;tmpDstAddr.endPoint = 0x01;tmpDstAddr.addr.shortAddr = 0xC859;status = zclGeneral_SendOnOff_CmdOn( SAMPLESW_ENDPOINT, &tmpDstAddr, FALSE, bdb_getZCLFrameCounter() );