void EddystoneService::manageRadio(void) { FrameType frameType; uint32_t startTimeManageRadio = timeSinceBootTimer.read_ms(); /* Signal that there is currently no callback posted */ radioManagerCallbackHandle = NULL; if (advFrameQueue.pop(frameType)) { /* We have something to advertise */ if (ble.gap().getState().advertising) { ble.gap().stopAdvertising(); } swapAdvertisedFrame(frameType); ble.gap().startAdvertising(); /* Increase the advertised packet count in TLM frame */ tlmFrame.updatePduCount(); /* Post a callback to itself to stop the advertisement or pop the next * frame from the queue. However, take into account the time taken to * swap in this frame. */ radioManagerCallbackHandle = minar::Scheduler::postCallback( this, &EddystoneService::manageRadio ).delay( minar::milliseconds(ble.gap().getMinNonConnectableAdvertisingInterval() - (timeSinceBootTimer.read_ms() - startTimeManageRadio)) ).tolerance(0).getHandle(); } else if (ble.gap().getState().advertising) { /* Nothing else to advertise, stop advertising and do not schedule any callbacks */ ble.gap().stopAdvertising(); } }
void EddystoneService::manageRadio(void) { FrameType frameType; if (advFrameQueue.pop(frameType)) { /* We have something to advertise */ if (ble.gap().getState().advertising) { ble.gap().stopAdvertising(); } swapAdvertisedFrame(frameType); ble.gap().startAdvertising(); /* Increase the advertised packet count in TLM frame */ tlmFrame.updatePduCount(); } else if (ble.gap().getState().advertising) { /* Nothing else to advertise, stop advertising and do not schedule any callbacks */ ble.gap().stopAdvertising(); } }