Lizzy project
Dependencies: aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT
Diff: aconno_ble/aconno_ble.cpp
- Branch:
- mbedOsUpdate
- Revision:
- 19:2681edc2f2b9
- Parent:
- 8:7ba4f82de9b6
- Child:
- 22:7dae8496b97c
diff -r d1f73bb9275a -r 2681edc2f2b9 aconno_ble/aconno_ble.cpp --- a/aconno_ble/aconno_ble.cpp Wed Sep 12 16:21:36 2018 +0200 +++ b/aconno_ble/aconno_ble.cpp Thu Sep 13 12:20:35 2018 +0200 @@ -4,10 +4,10 @@ * */ -#include "main.h" #include "aconno_ble.h" #include "tasks.h" #include "lizzy_service.h" +#include "aconnoConfig.h" init_lizzy_t init_lizzy = { .buzz = false, @@ -23,18 +23,18 @@ (lizzy_service->get_ble())->gap().startAdvertising(); } -void onConnectionCallback(const Gap::ConnectionCallbackParams_t *params){ - +void onConnectionCallback(const Gap::ConnectionCallbackParams_t *params){ + } -void onDataWrittenCallback(const GattWriteCallbackParams *params) +void onDataWrittenCallback(const GattWriteCallbackParams *params) { if ((params->handle == lizzy_service->get_buzz_handle()) && (params->len == 1)) { if ((uint8_t)true < *(params->data)) lizzy_service->set_buzz_state(true); - + updateBuzzLedsT.signal_set(UPDATE_BUZZ_LEDS); } else if ((params->handle == lizzy_service->get_red_handle()) && @@ -42,7 +42,7 @@ { if ((uint8_t)true < *(params->data)) lizzy_service->set_red_state(true); - + updateBuzzLedsT.signal_set(UPDATE_BUZZ_LEDS); } else if ((params->handle == lizzy_service->get_green_handle()) && @@ -50,7 +50,7 @@ { if ((uint8_t)true < *(params->data)) lizzy_service->set_green_state(true); - + updateBuzzLedsT.signal_set(UPDATE_BUZZ_LEDS); } else if ((params->handle == lizzy_service->get_blue_handle()) && @@ -58,7 +58,7 @@ { if ((uint8_t)true < *(params->data)) lizzy_service->set_blue_state(true); - + updateBuzzLedsT.signal_set(UPDATE_BUZZ_LEDS); } } @@ -82,13 +82,13 @@ if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { return; } - - + + lizzy_service = new LizzyService(ble, &init_lizzy); ble.gap().onDisconnection(disconnectionCallback); - //ble.gap().onConnection(onConnectionCallback); + //ble.gap().onConnection(onConnectionCallback); ble.gattServer().onDataWritten(onDataWrittenCallback); - + advertisementPacket.header = APPLICATION_ID; advertisementPacket.type = 0x00; advertisementPacket.gyroscope[0] = (int16_t)0; @@ -100,7 +100,7 @@ advertisementPacket.magnetometer[0] = (int16_t)0; advertisementPacket.magnetometer[1] = (int16_t)0; advertisementPacket.magnetometer[2] = (int16_t)0; - + /* setup advertising */ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, (uint8_t *)&advertisementPacket, sizeof(uint8_t)*11);