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.

应用层如何接收ZCL_CMD_WRITE命令?

Genius 3030 points

如果想解析ZCL_CMD_WRITE命令,需要在下面的函数添加?

static void zclSampleThermostat_ProcessIncomingMsg( zclIncomingMsg_t *pInMsg)
{
  switch ( pInMsg->zclHdr.commandID )
  {
#ifdef ZCL_READ
    case ZCL_CMD_READ_RSP:
      zclSampleThermostat_ProcessInReadRspCmd( pInMsg );
      break;
#endif
#ifdef ZCL_WRITE
    case ZCL_CMD_WRITE_RSP:
      zclSampleThermostat_ProcessInWriteRspCmd( pInMsg );
      break;
#endif
#ifdef ZCL_REPORT
    case ZCL_CMD_CONFIG_REPORT:
      //zclSampleThermostat_ProcessInConfigReportCmd( pInMsg );
      break;

    case ZCL_CMD_CONFIG_REPORT_RSP:
      //zclSampleThermostat_ProcessInConfigReportRspCmd( pInMsg );
      break;

    case ZCL_CMD_READ_REPORT_CFG:
      //zclSampleThermostat_ProcessInReadReportCfgCmd( pInMsg );
      break;

    case ZCL_CMD_READ_REPORT_CFG_RSP:
      //zclSampleThermostat_ProcessInReadReportCfgRspCmd( pInMsg );
      break;
#endif
#ifdef ZCL_REPORT_DESTINATION_DEVICE
    case ZCL_CMD_REPORT:
      zclSampleThermostat_ProcessInReportCmd( pInMsg );
      break;
#endif
    case ZCL_CMD_DEFAULT_RSP:
      zclSampleThermostat_ProcessInDefaultRspCmd( pInMsg );
      break;

    default:
      break;
  }

  if ( pInMsg->attrCmd )
  {
    osal_mem_free( pInMsg->attrCmd );
  }
}

  • 如果你没有注册回调函数,则会进入这个处理。
    举个例之你使用zcl_SendWrite()去发送WRITE CMD,
    然后会在case ZCL_CMD_WRITE 下面去处理。
  • 那怎样注册回调函数?
  • 你看genericapp例子的

    // Register the ZCL General Cluster Library callback functions
    zclGeneral_RegisterCmdCallbacks( GENERICAPP_ENDPOINT, &zclGenericApp_CmdCallbacks );

    static zclGeneral_AppCallbacks_t zclGenericApp_CmdCallbacks =
    {
    zclGenericApp_BasicResetCB, // Basic Cluster Reset command
    NULL, // Identify Trigger Effect command
    NULL, // On/Off cluster commands
    NULL, // On/Off cluster enhanced command Off with Effect
    NULL, // On/Off cluster enhanced command On with Recall Global Scene
    NULL, // On/Off cluster enhanced command On with Timed Off
    #ifdef ZCL_LEVEL_CTRL
    NULL, // Level Control Move to Level command
    NULL, // Level Control Move command
    NULL, // Level Control Step command
    NULL, // Level Control Stop command
    #endif
    #ifdef ZCL_GROUPS
    NULL, // Group Response commands
    #endif
    #ifdef ZCL_SCENES
    NULL, // Scene Store Request command
    NULL, // Scene Recall Request command
    NULL, // Scene Response command
    #endif
    #ifdef ZCL_ALARMS
    NULL, // Alarm (Response) commands
    #endif
    #ifdef SE_UK_EXT
    NULL, // Get Event Log command
    NULL, // Publish Event Log command
    #endif
    NULL, // RSSI Location command
    NULL // RSSI Location Response command
    };
  • 这个CallBack只是针对Command的啊,我现在要用Coordinator向Router发送ZCL_CMD_WRITE命令进行写属性,Router在哪里可以解析收到的数据呢?
  • 跟我第一个所说的一样的,都是command处理,你看一下支持的case:


    /*** Foundation Command IDs ***/
    #define ZCL_CMD_READ 0x00
    #define ZCL_CMD_READ_RSP 0x01
    #define ZCL_CMD_WRITE 0x02
    #define ZCL_CMD_WRITE_UNDIVIDED 0x03
    #define ZCL_CMD_WRITE_RSP 0x04
    #define ZCL_CMD_WRITE_NO_RSP 0x05
    #define ZCL_CMD_CONFIG_REPORT 0x06
    #define ZCL_CMD_CONFIG_REPORT_RSP 0x07
    #define ZCL_CMD_READ_REPORT_CFG 0x08
    #define ZCL_CMD_READ_REPORT_CFG_RSP 0x09
    #define ZCL_CMD_REPORT 0x0a
    #define ZCL_CMD_DEFAULT_RSP 0x0b
    #define ZCL_CMD_DISCOVER_ATTRS 0x0c
    #define ZCL_CMD_DISCOVER_ATTRS_RSP 0x0d
    #define ZCL_CMD_DISCOVER_CMDS_RECEIVED 0x11
    #define ZCL_CMD_DISCOVER_CMDS_RECEIVED_RSP 0x12
    #define ZCL_CMD_DISCOVER_CMDS_GEN 0x13
    #define ZCL_CMD_DISCOVER_CMDS_GEN_RSP 0x14
    #define ZCL_CMD_DISCOVER_ATTRS_EXT 0x15
    #define ZCL_CMD_DISCOVER_ATTRS_EXT_RSP 0x16