求助!终端使用AF_DataRequest 发送之后,协调器怎么接收数据

波风亭 2025-10-13 22:31:38

终端:

  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;

 

...全文
102 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
善学坊 导师 10-27
  • 打赏
  • 举报
回复

亲,由于论坛系统除了问题,很抱歉延迟回复

675

社区成员

发帖
与我相关
我的任务
社区描述
ZigBee技术交流社区
物联网 技术论坛(原bbs)
社区管理员
  • 大可 Ducker
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

ZigBee技术交流社区说明

  • ZigBee技术学习官网:www.sxf-iot.com
  • 关注微信公众号了解更多IoT行业资讯:shanxuefang-iot
  • 如何提问技术问题:点击了解

试试用AI创作助手写篇文章吧