Wednesday, August 26, 2015

How to create a periodic event in TI Z-Stack or BLE-Stack

The following codes are example to start PERIODIC_EVT every second and you can do any periodic processing in PERIODIC_EVT.

//Put where you want to start PERIODIC_EVT
osal_start_timerEx( XXX_TaskID, SENSOR_READ_EVT, 1000 );

//For Z-Stack, create PERIODIC_EVT processing in zcl_XXX_event_loop
//For BLE-Stack, create PERIODIC_EVT processing in xxx_ProcessEvent
  if( events & PERIODIC_EVT )
  {
    //Do things that need periodic processing here!
    ...
    osal_start_timerEx( XXX_TaskID, PERIODIC_EVT, 1000 );
    return (events ^ PERIODIC_EVT);
  }

No comments:

Post a Comment