Indoor positioning. Central unit.
Dependencies: aconno_SEGGER_RTT
Diff: tasks/tasks.cpp
- Revision:
- 2:1b85a28b1e68
- Parent:
- 1:2bdc506d8baa
--- a/tasks/tasks.cpp Tue Mar 06 15:45:34 2018 +0000 +++ b/tasks/tasks.cpp Wed Mar 07 11:43:39 2018 +0000 @@ -15,6 +15,7 @@ // BLE global data GapAdvertisingData adv_data = GapAdvertisingData(); +uint16_t adv_cntr = 0; void periodicCallback(BLE *ble) @@ -29,23 +30,42 @@ } } +void bleUpdateData(BLE *ble) +{ + while (true) + { + Thread::signal_wait(UPDATE_DATA_SIG); + Thread::signal_clr(UPDATE_DATA_SIG); + + while (rssi_buff.cntr != 0) + { + memcpy(MSD, uuid, sizeof(uuid)); + memcpy(MSD + sizeof(uuid), &(rssi_buff.pairs[rssi_buff.cntr-1]), sizeof(rssi_buff.pairs[0])); + + rssi_buff.cntr--; + + adv_data = ble->getAdvertisingData(); + adv_data.updateData(adv_data.MANUFACTURER_SPECIFIC_DATA, (uint8_t*)MSD, MSD_SIZE_b); + ble->setAdvertisingData(adv_data); + + wait_ms(ADV_INTERVAL_MS*2); + } + } +} + void bleStartAdvertising(BLE *ble) { while(true) { - adv_data = ble->getAdvertisingData(); - adv_data.updateData(adv_data.MANUFACTURER_SPECIFIC_DATA, (uint8_t*)MSD, MSD_SIZE_b); - ble->setAdvertisingData(adv_data); - - ble->gap().startAdvertising(); - printf("Advertisement started.\r\n"); + //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"); + //ble->gap().stopAdvertising(); + //printf("Advertisement stopped.\r\n"); #if DEBUG_LED advLed = 1; #endif @@ -58,7 +78,7 @@ { while(true) { - ble->gap().setScanParams(1500, 400); + ble->gap().setScanParams(300, 250); ble->gap().startScan(advertisementCallback); Thread::signal_wait(0x00023456); //Thread::signal_clr(ACC_INT_SIG);