用SampleSwitch例子做了个route 和coord 。route定时向coord发送数据。
从dongle看来coord是收到数据,但是coord并没有进入zclSampleSw_ProcessIncomingMsg( zclIncomingMsg_t *pInMsg )
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.
用SampleSwitch例子做了个route 和coord 。route定时向coord发送数据。
从dongle看来coord是收到数据,但是coord并没有进入zclSampleSw_ProcessIncomingMsg( zclIncomingMsg_t *pInMsg )
是这样的,给你打个比方,绝对让你明白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给你滤掉了。
(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格式么?显然不是。