The following steps show you how to check APS ack in TI Z-Stack using ON/OFF cluster toggle command in SampleSwitch example.
1. Setup OnOffOptions and use zcl_registerClusterOptionList in zclSampleSw_Init to register receiving APS ack on ZCL_CLUSTER_ID_GEN_ON_OFF cluster command.
zclOptionRec_t OnOffOptions[] =
{
{
ZCL_CLUSTER_ID_GEN_ON_OFF, ( AF_EN_SECURITY | AF_ACK_REQUEST ),
},
};
ZStatus_t status = zcl_registerClusterOptionList ( SAMPLESW_ENDPOINT, 1,
OnOffOptions );
2. Add "case AF_DATA_CONFIRM_CMD:..." in SYS_EVENT_MSG case of zclSampleSw_event_loop
uint16 zclSampleSw_event_loop( uint8 task_id, uint16 events )
{
...
if ( events & SYS_EVENT_MSG )
{
while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclSampleSw_TaskID )) )
{
switch ( MSGpkt->hdr.event )
{
case AF_DATA_CONFIRM_CMD:
afDataConfirm_t *SWafDataConfirm;
SWafDataConfirm = (afDataConfirm_t *)MSGpkt;
rcv_aps_ack_trans_id=SWafDataConfirm->transID;
// You can use rcv_aps_ack_trans_id to check if it matches to APS_Counter when you send toggle command with zclGeneral_SendOnOff_CmdToggle
break;
...
No comments:
Post a Comment