TI中文支持网
TI专业的中文技术问题搜集分享网站

Zstack 3.0.2中,怎么读取空中发来的数据数据内容?ZCL_INCOMING_MSG

 case ZCL_INCOMING_MSG:
          // Incoming ZCL Foundation command/response messages
          zclMyApp_ProcessIncomingMsg( (zclIncomingMsg_t *)MSGpkt );
          break;

static void zclMyApp_ProcessIncomingMsg( zclIncomingMsg_t *pInMsg )
{
  uint8 databuf[50]={0};  //用来接收AF数据的数组  uint8 Info_temp[80]={0};
   osal_memset(databuf,0,50);
  osal_memset(Info_temp,0,80);   osal_memcpy(databuf,pInMsg->cmd.Data,pInMsg->cmd.DataLength);   switch ( pInMsg->zclHdr.commandID )
  {

……

}

}

这个函数中参数为zclIncomingMsg_t *pInMsg,没有数据内容,是要用某个解析语句么?刚从旧协议栈转过来,有点不适应

YiKai Chen:

可以參考SampleLight程內zclSampleLight_ProcessIncomingMsg的作法

user4711142:

回复 YiKai Chen:

协调器已经可以建立网络了,但是终端下载程序后,却没有现象。
初始化程序如下:是终端没有加入网络,还是协调器禁止入网了?zstack 3.0 如何让协调器一直可以入网。
void zclMyApp_Init( byte task_id )
{static uint8 addr_temp[2]={0xFF,0xFE};zclMyApp_TaskID = task_id;
// This app is part of the Home Automation Profile //注册使能家居描述符bdb_RegisterSimpleDescriptor( &zclMyApp_SimpleDesc ); //注册简单描述符
// Register the ZCL General Cluster Library callback functionszclGeneral_RegisterCmdCallbacks( MYAPP_ENDPOINT, &zclMyApp_CmdCallbacks );// MYAPP_TODO: Register other cluster command callbacks here
// Register the application's attribute listzcl_registerAttrList( MYAPP_ENDPOINT, zclMyApp_NumAttributes, zclMyApp_Attrs );
// Register the Application to receive the unprocessed Foundation command/response messageszcl_registerForMsg( zclMyApp_TaskID );

#ifdef ZCL_DISCOVER// Register the application's command listzcl_registerCmdList( MYAPP_ENDPOINT, zclCmdsArraySize, zclMyApp_Cmds );
#endif
// Register low voltage NV memory protection application callbackRegisterVoltageWarningCB( zclSampleApp_BatteryWarningCB );
// Register for all key events – This app will handle all key eventsRegisterForKeys( zclMyApp_TaskID );
bdb_RegisterCommissioningStatusCB( zclMyApp_ProcessCommissioningStatus );bdb_RegisterIdentifyTimeChangeCB( zclMyApp_ProcessIdentifyTimeChange );bdb_RegisterBindNotificationCB( zclMyApp_BindNotification );

//=============================add by user=================================//串口初始化,并打印信息MyApp_UartInit();HalUARTWrite(0,"—USRT_DTU_TEST—\r\n",strlen("—USRT_DTU_TEST—\r\n"));//建立、加入网络bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_FORMATION | BDB_COMMISSIONING_MODE_NWK_STEERING | BDB_COMMISSIONING_MODE_FINDING_BINDING | BDB_COMMISSIONING_MODE_INITIATOR_TL);
ChangePA(20);
}

user4711142:

回复 user4711142:

串口打印都不显示HalUARTWrite(0,"—USRT_DTU_TEST—\r\n",strlen("—USRT_DTU_TEST—\r\n"));

YiKai Chen:

回复 user4711142:

zstack 3.0 無法让协调器一直允許入网、最多只能開放254秒、有沒有抓包看看設備為什麼無法入网

user4711142:

回复 YiKai Chen:

怎么跟更改协议栈,可以实现?

user4711142:

回复 YiKai Chen:

解决了,现在又有一个问题:终端发送给协调器的无线数据。提示终端发送成功,但是协调却没有按预期的显示。
经查看有一个CONST zclAttrRec_t zclSampleTemperatureSensor_Attrs[] =;
我没有做任何更改,是需要把自定的MYAPP_SENDADDR_CLUSTERID放在这个里面进行初始化么?

YiKai Chen:

回复 user4711142:

不大懂你的問題、你可以貼出你终端发送给协调器数据的代碼?

user4711142:

回复 YiKai Chen:

终端中定义:
const cId_t zclMyApp_InClusterList[] =
{ZCL_CLUSTER_ID_GEN_BASIC,ZCL_CLUSTER_ID_GEN_IDENTIFY,// MYAPP_TODO: Add MyApp specific Input Clusters Here. //See zcl.h for Cluster ID definitions
};
协调器中定义:
const cId_t zclMyApp_OutClusterList[] =
{ZCL_CLUSTER_ID_GEN_BASIC,MYAPP_CLUSTERID_SENDADDR,// MYAPP_TODO: Add MyApp specific Output Clusters Here. //See zcl.h for Cluster ID definitions
};
————————————————————————————————————————————————–

终端发送的代码:
void MyApp_SendShortaddrToCoor(uint8 DeviceType)
{
//设置发送目的地址MyApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;MyApp_DstAddr.addr.shortAddr = 0x0000;MyApp_DstAddr.endPoint = MYAPP_ENDPOINT;//HalUARTWrite(0,buf,7);//发送出去if(AF_DataRequest(&MyApp_DstAddr,//目的地址&MyApp_epDesc,//设备描述符MYAPP_CLUSTERID_SENDADDR, //簇ID14,//长度buf,//要发送的数组&MyApp_TransID,//传输序列号AF_ACK_REQUEST,//发送选项AF_DEFAULT_RADIUS)==afStatus_SUCCESS){//成功;HalUARTWrite(0,"MyApp_SendShortaddrToCoor Success\r\n",strlen("MyApp_SendShortaddrToCoor Success\r\n")); }else {//如果不成功,就再发送一次HalUARTWrite(0,"MyApp_SendShortaddrToCoor Error\r\n",strlen("MyApp_SendShortaddrToCoor Error\r\n")); }
}
协调器接收代码:
static void zclMyApp_ProcessIncomingMsg( zclIncomingMsg_t *pInMsg )
{uint8 databuf[50]={0};//用来接收AF数据的数组 osal_memset(databuf,0,50);
osal_memcpy(databuf,((afIncomingMSGPacket_t *)pInMsg)->cmd.Data,((afIncomingMSGPacket_t *)pInMsg)->cmd.DataLength); switch ( pInMsg->zclHdr.commandID ){……
case MYAPP_CLUSTERID_SENDADDR:HalUARTWrite(0,"MYAPP_CLUSTERID_SENDADDR\r\n",strlen("MYAPP_CLUSTERID_SENDADDR\r\n")); //接收到打印break;default:break;}
if ( pInMsg->attrCmd )osal_mem_free( pInMsg->attrCmd );
}

协调器接收数据应该会打印,结果根本没有打印

user4711142:

回复 user4711142:

协议栈中这个是做什么用的?我对这个没有做任何更改:
/********************************************************************** ATTRIBUTE DEFINITIONS – Uses REAL cluster IDs*/
CONST zclAttrRec_t zclMyApp_Attrs[] =
{// *** General Basic Cluster Attributes ***{ZCL_CLUSTER_ID_GEN_BASIC,// Cluster IDs – defined in the foundation (ie. zcl.h){// Attribute recordATTRID_BASIC_HW_VERSION,// Attribute ID – Found in Cluster Library header (ie. zcl_general.h)ZCL_DATATYPE_UINT8,// Data Type – found in zcl.hACCESS_CONTROL_READ,// Variable access control – found in zcl.h(void *)&zclMyApp_HWRevision// Pointer to attribute variable}},{ZCL_CLUSTER_ID_GEN_BASIC,{ // Attribute recordATTRID_BASIC_ZCL_VERSION,ZCL_DATATYPE_UINT8,ACCESS_CONTROL_READ,(void *)&zclMyApp_ZCLVersion}},……
};

Alvin Chen:

回复 user4711142:

你发送的不是ZCL命令,你转化后肯定是无法识别的,

你需要在:

case AF_INCOMING_MSG_CMD: GenericApp_MessageMSGCB( MSGpkt );

static void GenericApp_MessageMSGCB( afIncomingMSGPacket_t *pkt ){ switch ( pkt->clusterId ) {

}}

赞(0)
未经允许不得转载:TI中文支持网 » Zstack 3.0.2中,怎么读取空中发来的数据数据内容?ZCL_INCOMING_MSG
分享到: 更多 (0)