Lizzy project
Dependencies: aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT
Diff: aconno_ble/lizzy_service.h
- Branch:
- master
- Revision:
- 26:6101bb09f70d
- Parent:
- 8:7ba4f82de9b6
--- a/aconno_ble/lizzy_service.h Thu Sep 20 07:41:02 2018 +0000 +++ b/aconno_ble/lizzy_service.h Thu Sep 20 13:20:13 2018 +0000 @@ -3,6 +3,8 @@ #include "mbed.h" #include "ble/BLE.h" +#include "service_macros.h" +#include "proj_config.h" #define NUM_LEDS (3) #define NUM_AXIS (3) @@ -21,7 +23,7 @@ public: const static uint16_t LIZZY_SERVICE_UUID = 0xA000; const static uint16_t BUZZ_UUID = 0xA001; - const static uint16_t RED_UUID = 0xA002; + const static uint16_t MAC_RED_UUID = 0xA002; const static uint16_t GREEN_UUID = 0xA003; const static uint16_t BLUE_UUID = 0xA004; const static uint16_t ACC_LSB_UUID = 0xA005; @@ -29,14 +31,25 @@ LizzyService(BLEDevice &_ble, init_lizzy_t *init) : ble(_ble), +#if VODAFONE_COMPATIBILITY == 1 + buzz(BUZZ_UUID, (uint8_t*)&(init->buzz)), + mac(MAC_RED_UUID, (uint8_t*)&(init->leds[0]), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), +#else buzz(BUZZ_UUID, &(init->buzz), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), - red_led(RED_UUID, &(init->leds[0]), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), + redLed(MAC_RED_UUID, &(init->leds[0]), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), +#endif green_led(GREEN_UUID, &(init->leds[1]), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), blue_led(BLUE_UUID, &(init->leds[2]), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), acc_lsb(ACC_LSB_UUID, &(init->acc_lsb), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), acc_data(ACC_DATA_UUID, init->acc_data, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) { - GattCharacteristic *charTable[] = {&buzz, &red_led, &green_led, &blue_led, &acc_lsb, &acc_data}; // Add characteristick in table + GattCharacteristic *charTable[] = { +#if VODAFONE_COMPATIBILITY == 1 + &buzz, &mac, +#else + &buzz, &redLed, +#endif + &green_led, &blue_led, &acc_lsb, &acc_data}; // Add characteristick in table GattService AckService(LIZZY_SERVICE_UUID, charTable, sizeof(charTable)/sizeof(GattCharacteristic *)); ble.gattServer().addService(AckService); // Add service in the BLE } @@ -46,12 +59,13 @@ } // Characteristic setters. +/* inline void set_buzz_state(bool new_state){ ble.gattServer().write(buzz.getValueHandle(), (uint8_t*)&new_state, sizeof(new_state)); } inline void set_red_state(bool new_state){ ble.gattServer().write(red_led.getValueHandle(), (uint8_t*)&new_state, sizeof(new_state)); - } + }*/ inline void set_green_state(bool new_state){ ble.gattServer().write(green_led.getValueHandle(), (uint8_t*)&new_state, sizeof(new_state)); } @@ -67,6 +81,7 @@ } // Characteristic getters. +/* inline bool get_buzz_state(){ bool tmp; uint16_t size = sizeof(tmp); @@ -78,7 +93,7 @@ uint16_t size = sizeof(tmp); ble.gattServer().read(red_led.getValueHandle(), (uint8_t*)&tmp, &size); return tmp; - } + }*/ inline bool get_green_state(){ bool tmp; uint16_t size = sizeof(tmp); @@ -91,13 +106,14 @@ ble.gattServer().read(blue_led.getValueHandle(), (uint8_t*)&tmp, &size); return tmp; } - + +/* inline GattAttribute::Handle_t get_buzz_handle(){ return buzz.getValueHandle(); } inline GattAttribute::Handle_t get_red_handle(){ return red_led.getValueHandle(); - } + }*/ inline GattAttribute::Handle_t get_green_handle(){ return green_led.getValueHandle(); } @@ -110,12 +126,21 @@ }inline GattAttribute::Handle_t get_acc_data_handle(){ return acc_data.getValueHandle(); } + +#if VODAFONE_COMPATIBILITY == 1 + CHARACTERISTIC_A(WriteOnly, uint8_t, 4, buzz, Buzz); + CHARACTERISTIC_A(ReadOnly, uint8_t, 6, mac, Mac); +#else + CHARACTERISTIC_W(ReadWrite, bool, buzz, Buzz); + CHARACTERISTIC_W(ReadWrite, bool, redLed, RedLed); +#endif private: BLEDevice &ble; // Create new characteristics +/* ReadWriteGattCharacteristic<bool> buzz; - ReadWriteGattCharacteristic<bool> red_led; + ReadWriteGattCharacteristic<bool> red_led;*/ ReadWriteGattCharacteristic<bool> green_led; ReadWriteGattCharacteristic<bool> blue_led;