Indoor positioning. Central unit.

Dependencies:   aconno_SEGGER_RTT

tasks/tasks.cpp

Committer:
jurica238814
Date:
2018-03-06
Revision:
0:07a75b2fae14
Child:
1:2bdc506d8baa

File content as of revision 0:07a75b2fae14:

/*
 *
 *
 */

#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);
    }    
}