求助!终端使用AF_DataRequest 发送之后,协调器怎么接收数据
终端:
ZStatus_t status = AF_DataRequest(
&dstAddr, // 目标地址
&zclSampleSwEpDesc, // 源端点
ZCL_CLUSTER_ID_CUSTOM_DATA_TRANSFER, // Cluster ID(用于绑定匹配)
frameLen, // 数据长度
sendBuf, // 数据指针(你的 AABB...CCDD 帧)
&transId, // 事务 ID(输出)
options, // 发送选项
radius // 跳数半径
);
协调器:
void zclSampleSw_Init( byte task_id )
{
zclSampleSw_TaskID = task_id;
// Set destination address to indirect
zclSampleSw_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
zclSampleSw_DstAddr.endPoint = 0;
zclSampleSw_DstAddr.addr.shortAddr = 0;
// 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 );
zclSampleSw_ResetAttributesToDefaultValues();
// Register the application's attribute list
// zcl_registerAttrList( SAMPLESW_ENDPOINT, zclSampleSw_NumAttributes, zclSampleSw_Attrs );
// Register the Application to receive the unprocessed Foundation command/response messages
zcl_registerForMsg( zclSampleSw_TaskID );
// Register for all key events - This app will handle all key events
// RegisterForKeys( zclSampleSw_TaskID );
bdb_RegisterCommissioningStatusCB( zclSampleSw_ProcessCommissioningStatus );
// Register for a test endpoint
// afRegister( &sampleSw_TestEp);
#ifdef ZCL_DIAGNOSTIC
// Register the application's callback function to read/write attribute data.
// This is only required when the attribute data format is unknown to ZCL.
zcl_registerReadWriteCB( SAMPLESW_ENDPOINT, zclDiagnostic_ReadWriteAttrCB, NULL );
if ( zclDiagnostic_InitStats() == ZSuccess )
{
// Here the user could start the timer to save Diagnostics to NV
}
#endif
#if defined (OTA_CLIENT) && (OTA_CLIENT == TRUE)
// Register for callback events from the ZCL OTA
zclOTA_Register(zclSampleSw_TaskID);
#endif
zdpExternalStateTaskID = zclSampleSw_TaskID;
#ifdef ZDO_COORDINATOR
// Init Uart
zclSampleSw_InitUart();
ZDO_RegisterForZDOMsg ( zclSampleSw_TaskID, Device_annce );
bdb_StartCommissioning( BDB_COMMISSIONING_MODE_NWK_FORMATION |
BDB_COMMISSIONING_MODE_FINDING_BINDING );
NLME_PermitJoiningRequest(255);
//change 注册自定义集群的接收回调函数
// zcl_registerPlugin( 0xFC10, 0xFC10, zclSampleSw_HdlIncomingCustomCluster );
#else
bdb_StartCommissioning( BDB_COMMISSIONING_MODE_NWK_STEERING |
BDB_COMMISSIONING_MODE_FINDING_BINDING );
osal_start_timerEx(zclSampleSw_TaskID,
SAMPLEAPP_REPORT_EVT,
SAMPLEAPP_REPORT_PERIOD);
#endif
}
if ( events & SYS_EVENT_MSG )
{
while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclSampleSw_TaskID )) )
{
switch ( MSGpkt->hdr.event )
{
case AF_INCOMING_MSG_CMD:
uint8 *rawData = MSGpkt->cmd.Data;
uint16 dataLen = MSGpkt->cmd.DataLength;
HalUARTWrite(HAL_UART_PORT_0, rawData, dataLen);
break;
...全文
相关推荐
Z-Stack协议——发送函数AF_DataRequest
zigbee协议栈说明 Z-Stack协议——发送函数AF_DataRequest 对于刚接触ZStack代码的人,通过对这个中断的编程可以对基于OSAL的编程有一定的了解,包括任务的初始化,消息的传递,等等。希望通过这篇文章对你使用ZStack有一定的帮助。
手把手教你用CC2530和Z-Stack协议栈DIY一个ZigBee环境监测器(附完整代码)
本文详细介绍了如何使用CC2530芯片和Z-Stack协议栈构建一个ZigBee环境监测系统,涵盖硬件选型、电路设计、协议栈配置、终端节点程序设计和协调器数据处理等关键步骤。通过实战指南和完整代码示例,帮助读者快速实现温湿度、空气质量等环境参数的监测,适合物联网开发者和电子爱好者参考。
Zigbee的Mac地址通信
基于Zstack栈协议写的Zigbee Mac地址综合实验。具体参考我的博客:https://blog.csdn.net/O_MMMM_O/article/details/81267913
数据传输AF层applicationframe.pdf
数据传输AF层applicationframe.pdf
Z-Stackz协议栈
详细阐述AF_DataRequest 函数的用法。


