Lizzy project

Dependencies:   aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT

Committer:
jurica238814
Date:
Thu Sep 13 15:14:14 2018 +0200
Branch:
SimpleGATTExample
Revision:
22:7dae8496b97c
Parent:
19:2681edc2f2b9
LAUT example program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jurica238814 19:2681edc2f2b9 1 /**
jurica238814 19:2681edc2f2b9 2 * Aconno.de
jurica238814 19:2681edc2f2b9 3 */
jurica238814 19:2681edc2f2b9 4
jurica238814 19:2681edc2f2b9 5 #include "bspLed.h"
dbartolovic 8:7ba4f82de9b6 6 #include "aconno_ble.h"
dbartolovic 8:7ba4f82de9b6 7 #include "tasks.h"
dbartolovic 8:7ba4f82de9b6 8 #include "GapAdvertisingData.h"
jurica238814 19:2681edc2f2b9 9 #include "aconnoConfig.h"
jurica238814 19:2681edc2f2b9 10 #include "bsp.h"
dbartolovic 8:7ba4f82de9b6 11
jurica238814 22:7dae8496b97c 12 #define SHORT_DELAY_MS (75)
dbartolovic 8:7ba4f82de9b6 13
dbartolovic 8:7ba4f82de9b6 14 static advertising_packet advertisementPacket;
dbartolovic 8:7ba4f82de9b6 15 static GapAdvertisingData adv_data = GapAdvertisingData();
dbartolovic 8:7ba4f82de9b6 16
jurica238814 22:7dae8496b97c 17 void updateBuzzLedsF()
dbartolovic 8:7ba4f82de9b6 18 {
jurica238814 19:2681edc2f2b9 19
jurica238814 22:7dae8496b97c 20 while (true)
dbartolovic 8:7ba4f82de9b6 21 {
dbartolovic 8:7ba4f82de9b6 22 Thread::signal_wait(UPDATE_BUZZ_LEDS);
dbartolovic 8:7ba4f82de9b6 23 updateBuzzLedsT.signal_clr(UPDATE_BUZZ_LEDS);
jurica238814 19:2681edc2f2b9 24
jurica238814 22:7dae8496b97c 25 if (lizzy_service->get_red_state())
dbartolovic 8:7ba4f82de9b6 26 {
jurica238814 22:7dae8496b97c 27 redLed = LED_ON;
jurica238814 22:7dae8496b97c 28 wait_ms(SHORT_DELAY_MS);
jurica238814 22:7dae8496b97c 29 redLed = LED_OFF;
jurica238814 22:7dae8496b97c 30 lizzy_service->set_red_state(LED_OFF);
dbartolovic 8:7ba4f82de9b6 31 }
jurica238814 22:7dae8496b97c 32 if (lizzy_service->get_green_state())
dbartolovic 8:7ba4f82de9b6 33 {
jurica238814 22:7dae8496b97c 34 greenLed = LED_ON;
jurica238814 22:7dae8496b97c 35 wait_ms(SHORT_DELAY_MS);
jurica238814 22:7dae8496b97c 36 greenLed = LED_OFF;
jurica238814 22:7dae8496b97c 37 lizzy_service->set_green_state(LED_OFF);
dbartolovic 8:7ba4f82de9b6 38 }
dbartolovic 8:7ba4f82de9b6 39 }
dbartolovic 8:7ba4f82de9b6 40 }
dbartolovic 8:7ba4f82de9b6 41
dbartolovic 8:7ba4f82de9b6 42 void bleF(BLE *ble)
dbartolovic 8:7ba4f82de9b6 43 {
dbartolovic 8:7ba4f82de9b6 44 while(true)
dbartolovic 8:7ba4f82de9b6 45 {
dbartolovic 8:7ba4f82de9b6 46 Thread::signal_wait(MEAS_DONE);
dbartolovic 8:7ba4f82de9b6 47 bleT.signal_clr(MEAS_DONE);
jurica238814 19:2681edc2f2b9 48
dbartolovic 8:7ba4f82de9b6 49 adv_data = ble->getAdvertisingData();
jurica238814 22:7dae8496b97c 50 adv_data.updateData(adv_data.MANUFACTURER_SPECIFIC_DATA,
jurica238814 22:7dae8496b97c 51 (uint8_t *)&advertisementPacket, sizeof(advertisementPacket));
dbartolovic 8:7ba4f82de9b6 52 ble->setAdvertisingData(adv_data);
dbartolovic 8:7ba4f82de9b6 53 }
jurica238814 19:2681edc2f2b9 54 }