Indoor positioning. Central unit.
Dependencies: aconno_SEGGER_RTT
Diff: tasks/tasks.cpp
- Revision:
- 0:07a75b2fae14
- Child:
- 1:2bdc506d8baa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tasks/tasks.cpp Tue Mar 06 09:52:46 2018 +0000 @@ -0,0 +1,58 @@ +/* + * + * + */ + +#include "tasks.h" +#include "aconno_ble.h" + +#if DEBUG_LED + extern DigitalOut advLed; + extern DigitalOut scanLed; + extern DigitalOut periodicLed; +#endif + +void periodicCallback(BLE *ble) +{ + while(true) + { + ble->waitForEvent(); + #if DEBUG_LED + periodicLed = !periodicLed; + #endif + wait(PERIODIC_CALLBACK_S); + } +} + +void bleStartAdvertising(BLE *ble) +{ + while(true) + { + ble->gap().startAdvertising(); + printf("Advertisement started.\r\n"); + #if DEBUG_LED + advLed = 0; + #endif + wait(ADVERTISING_DURATION_S); + wait_ms(1000); + ble->gap().stopAdvertising(); + printf("Advertisement stopped.\r\n"); + #if DEBUG_LED + advLed = 1; + #endif + wait(BLE_SLEEP_DURATION_S); + wait_ms(1000); + } +} + +void bleStartScanning(BLE *ble) +{ + while(true) + { + ble->gap().setScanParams(1500, 400); + ble->gap().startScan(advertisementCallback); + Thread::signal_wait(0x00023456); + //Thread::signal_clr(ACC_INT_SIG); + //bleT.signal_set(DISABLE_BLE_SIG); + } +}