Thursday, October 27, 2016

How to create a periodic event for CC253x/CC254x Z-Stack and BLE Stack.

The following codes show example to create a periodic event that is triggered every 5 seconds for CC253x in Z-Stack and you can do it accordingly for CC254x in BLE Stack.

1. Add "#define PERIODIC_EVT 0x0001"in your code. Please note that event define has to be an unused bit mask of uint16.

2. Put  the following line at where you want to start PERIODIC_EVT

osal_start_timerEx( zcl_XXX_TaskID, PERIODIC_EVT, 10 );

2. Create PERIODIC_EVT processing in zcl_XXX_event_loop
if( events & PERIODIC_EVT )
  //Do things that need periodic processing here!
  osal_start_timerEx( zcl_XXX_TaskID, PERIODIC_EVT, 5000 );
  return (events ^ PERIODIC_EVT);