This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

zcl_SendRead发送的目的地址不对

如下代码,终端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)操作就没有问题。

  • 仔细确认了下抓的包,发现:
    MAC Header里的Destination Address是0x0000,NWK Header里的Destination Address是0x0004
    这是怎么回事啊?
  • 請附上抓包檔分析問題
  • 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: 181
    Protocol: ZigBee
    Timestamp: 09/17/2019 07:56:11
    Channel: 20
    Length: 50
    RSSI: -42 dBm
    Source Id: -1431132140
    Status: 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: 0x0
    10・・ ・・・・ ・・・・ ・・・・ = Source Addr Mode: [0x2] 16-bit Short Address
    Sequence Number: 169
    Destination PAN ID: 0x904B
    Destination Address: 0x0000
    Source Address: 0xF9BD
    MAC Payload: (39 bytes)
    NWK Header: 0x091EF9BD00042248
    Frame 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] Yes
    00・・ ・・・・ ・・・・ ・・・・ = Reserved: 0x0
    Destination Address: 0x0004
    Source Address: 0xF9BD
    Radius: 0x1E
    Sequence Number: 9
    NWK 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] Yes
    00・・ ・・・・ = Reserved: 0x0
    NWK Frame Counter: 15
    Source Address: 00:12:4B:00:0F:75:7F:07
    NWK Key Sequence Number: 0
    NWK Payload: (13 bytes)
    APS Header: 0x1808010400000100
    Frame Control: 0x00
    ・・・・ ・・00 = Frame Type: [0x0] Data
    ・・・・ 00・・ = Delivery Mode: [0x0] Normal Unicast Delivery
    ・・・0 ・・・・ = Acknowledgement Format: 0x0
    Format: [0x0] Data Frame
    ・・0・ ・・・・ = Security Enabled: [0x0] No
    ・0・・ ・・・・ = Acknowledgement Request: 0x0
    Request: [0x0] No
    0・・・ ・・・・ = Extended Header Present: [0x0] No
    Destination Endpoint: 0x01
    Cluster ID: [0x0000] General: Basic
    Profile ID: [0x0104] ZigBee Home Automation
    Source Endpoint: 0x08
    APS Counter: 24
    APS Payload: 0x0004000400
    ZCL Header: 0x000400
    Frame 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] No
    000・ ・・・・ = Reserved: 0x0
    Transaction Sequence Number: 4
    General Command Frame: [0x00] Read Attributes
    ZCL Payload: 0x0004
    Attribute ID: [0x0004] Manufacturer Name
    NWK MIC: 0x3F7D62FF
    MAC Footer: 0xFFFF
    Frame Check Sequence: 0xFFFF
  • 請附上完整的抓包檔
  • YK Chen,

    请参考,谢谢!0917_181.txt

  • 你是用什麼工具抓包的,為什麼抓包檔是txt格式?
  • YK Chen,

    Ubiqua,附上cubx文档,谢谢!0917_181.zip

  • 你的抓包檔裡面完全沒有看到發給0xC859這個設備的封包啊,你確定"在zcl_SendRead之前,调用zclGeneral_SendOnOff_CmdOn对终端B(0xC859)操作就没有问题"? 可否指出你抓包檔哪裡有送給0xC859的On Command?
  • 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

    请参考,谢谢!

  • 另,附上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() );
  • 另,附上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() );
  • zcl_SendRead(Packet ID: 11)看起來destination address是0x0004啊,你要不要調試你的程序看看怎麼回事
  • YK Chen,
    调试看不到什么错误,传入的地址都是对的,zcl_SendRead也成功返回了。
    你能不能说明下在client端,为了通过zcl_SendRead取得server端的属性,都需要做哪些处理?
    我目前做了以下处理,还有没有什么遗漏?
    1.在OutClusterList中定义ZCL_CLUSTER_ID_GEN_BASIC,在SimpleDesc中定义OutClusterList
    2. zcl_SendRead发送请求
    3.zcl_registerForMsg注册zcl消息
    4.在ZCL_INCOMING_MSG中处理response
  • 你現在是抓包根本沒看到read attribute發出來,還沒到接收的階段吧,你調試看看執行zcl_SendRead後,抓包上看到的是什麼封包
  • YK Chen,
    执行zcl_SendRead后,read attribute发出来了,上次的抓包档里,Packet ID: 11就是read attribute。
  • 之前已經回复zcl_SendRead(Packet ID: 11)看起來destination address是0x0004

  • zcl_SendRead发送的目的地址不对的原因找到了,是因为保存目的地址的变量的值被修改了。
    但为什么被修改,原因不明。
  • 你看一下你的保存的地址有没有在其他地方被修改,debug 查看一下
  • 一定是你的應用程序改到了,還是建議你仔細調試你的程序找出問題