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.

Z-satack3.0.1数据收发问题

用SampleSwitch例子做了个route 和coord  。route定时向coord发送数据。

从dongle看来coord是收到数据,但是coord并没有进入zclSampleSw_ProcessIncomingMsg( zclIncomingMsg_t *pInMsg )

请问是哪里没有配置好吗?

Switch_coord.rar

  • 如果你用的是zcl并且注册回调会直接进入zcl回调。

  • 请问zcl的回调函数是哪一个?
  • 看了一下你的code, 你用的是AF_DataRequest发送的。建议你直接参考GenericApp.
  • GenericApp还是从这个函数 zclGenericApp_ProcessIncomingMsg( (zclIncomingMsg_t *)MSGpkt ); 吗
  • 按ZCL回调,coord并没有进入
    if ( *msgPtr == AF_INCOMING_MSG_CMD )
    {
    zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );
    }

    请问有解决的方法吗?
    或是分享一个能通讯的code例子给我,谢谢
  • 是这样的,给你打个比方,绝对让你明白zigbee这鸟玩意到底是怎么通讯一回事:

    假如节点0x1234要发送信息给0x5678,怎么做呢?

    我们知道,首先0x1234和0x5678两边都要注册endpoint,不注册是不行的,用的是afRegister这个函数注册的,假如0x1234这边注册的endpoint是14,0x5678那边注册的是18

    我们就实现给0x5678发送一个开灯的指令,并问候一句"你是猪吗":

     

    uint8 srcEndpoint=14;		//指定我们(0x1234)的endpoint
    uint8 dstEndpoint=18;		//指定对方(0x5678)的endpoint
    
    uint8 pBuf[]={"Are you pig?"};
    uint8 msgLen=sizeof(pBuf);
    uint8 seqNum=0;
    
    afAddrType_t dstAddr;
    dstAddr.addrMode = Addr16Bit;
    dstAddr.addr.shortAddr = 0x5678;
    dstAddr.endPoint=dstEndpoint;
    zcl_SendCommand( srcEndpoint, &dstAddr, ZCL_CLUSTER_ID_GEN_ON_OFF,
    				  COMMAND_ON, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
    				  TRUE, 0, seqNum, msgLen, pBuf);
    

     

  • 在init里面有注册过endpoint的 

    void zclSampleSw_Init( byte task_id )
    {
    zclSampleSw_TaskID = task_id;
    P1DIR |= 0x03;
    // Set destination address to indirect
    zclSampleSw_DstAddr.addrMode = (afAddrMode_t)Addr16Bit; //AddrNotPresent;
    zclSampleSw_DstAddr.endPoint = 18;
    zclSampleSw_DstAddr.addr.shortAddr = 0x0000;

    zclSampleSw_epDesc.endPoint = 10;
    zclSampleSw_epDesc.task_id = &zclSampleSw_TaskID;
    zclSampleSw_epDesc.simpleDesc
    = (SimpleDescriptionFormat_t *)&zclSampleSw_SimpleDesc;
    // Register the Simple Descriptor for this application
    bdb_RegisterSimpleDescriptor( &zclSampleSw_SimpleDesc );

    // Register the ZCL General Cluster Library callback functions
    zclGeneral_RegisterCmdCallbacks( SAMPLESW_ENDPOINT, &zclSampleSw_CmdCallbacks );

    现在的问题是coord收到了router发过来的  {"Are you pig?"};

    coord收到了,但不知道放在哪里了。

  • 你调用了bdb_RegisterSimpleDescriptor,注册的Endpoint就在ZCL_TaskID上了,数据放在zcl_event_loop的if ( *msgPtr == AF_INCOMING_MSG_CMD )里面。这个地方交给ZCL处理,你用zclGeneral_RegisterCmdCallbacks注册了每条ZCL控制指令,ZCL会自动把你收到的控制指令对应到你注册的执行函数上。“你是猪吗”不是正确指令,所以ZCL给你滤掉了。

  • 你的zclSampleSw_epDesc是多此一举,bdb_RegisterSimpleDescriptor已经给你分配了一个epDesc了
  • 这个不怪Juson,这个是TI SampleLight代码的问题,一言以蔽之:脱裤子放屁---多此一举。

    的确是在bdb_RegisterSimpleDescriptor里面已经调用afRegister注册了endpoint,后面又接着调用afRegister注册同一个endpoint,不是多此一举是什么?

    的确是要检查一下AF_INCOMING_MSG_CMD消息的处理,一般很多时候都是在这里根据clusterId和command以及client-server方向等等来判断,给滤除了。
  • (void)task_id; // Intentionally unreferenced parameter
    P0_0 = ~P0_0;
    if ( events & SYS_EVENT_MSG )
    {
    msgPtr = osal_msg_receive( zcl_TaskID );
    while ( msgPtr != NULL )
    {
    uint8 dealloc = TRUE;

    if ( *msgPtr == AF_INCOMING_MSG_CMD )
    {
    zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );
    }
    else
    ………………
    我在打过断点, zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr ); 跟本没到这里来。

    zclGeneral_SendOnOff_CmdToggle和AF_DataRequest 两种方式都试过。

  • ZCL里面也有问题,zcl_getExternalFoundationHandler函数入口居然是afIncomingMSGPacket_t,传递给ZCL Task的message都是afIncomingMSGPacket_t格式么?显然不是。

  • 终于解决了。

    用AF_DataRequest发送的消息。
    coord收到消息会到zclSampleSw_event_loop里的AF_INCOMING_MSG_CMD里进行处理。
    但官方的例子里没有AF_INCOMING_MSG_CMD这个case。需要自行添加。

    zcl_SendCommand发送方式,需要将收发双方进行绑定,绑定后也能正常通讯了。


    这个问题 哎~~~~

  • 早都说了要注册endpoint,另外没有绑定这个说法,不是ble,绑啥绑,开发这么长时间,ti代码里面的glitch早已习以为常了,遇到后自己就悄悄修复了,别给他们说,不然说了也白说
  • zcl_SendCommand在没有绑定的情况下还是不行。
    定义了zclSampleSw_OnOffCB, 没反应。

    协调器收到。知道从哪取出数据。
    请帮帮忙

  • 上ubiqua抓包文件,确定一下是否的确是收到了。
  • 麻烦帮我看下,谢谢!

    zcl_SendCommand_flase.psd

  • 找到问题了。
    我修改过SimpleDesc里面的内容,改回原来的就OK了。