Lizzy project

Dependencies:   aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT

Branch:
master
Revision:
26:6101bb09f70d
Parent:
16:482d8f81d6f3
Child:
28:0cc8a58195cb
--- a/aconno_ble/aconno_ble.cpp	Thu Sep 20 07:41:02 2018 +0000
+++ b/aconno_ble/aconno_ble.cpp	Thu Sep 20 13:20:13 2018 +0000
@@ -8,6 +8,7 @@
 #include "aconno_ble.h"
 #include "tasks.h"
 #include "lizzy_service.h"
+#include "proj_config.h"
 
 
 /* BLE event queue size */
@@ -53,15 +54,18 @@
 
 void onDataWrittenCallback(const GattWriteCallbackParams *params) 
 {
-    if ((params->handle == lizzy_service->get_buzz_handle()) &&
-        (params->len == 1))
+    if ((params->handle == lizzy_service->getBuzzHandle()))
     {
+#if VODAFONE_COMPATIBILITY == 1
+#else
         if ((uint8_t)true < *(params->data))
-            lizzy_service->set_buzz_state(true);
-            
+            lizzy_service->setBuzzState(true);
+#endif
         updateBuzzLedsT.signal_set(UPDATE_BUZZ_LEDS);
     }
-    else if ((params->handle == lizzy_service->get_red_handle()) &&
+#if VODAFONE_COMPATIBILITY == 1
+#else
+    else if ((params->handle == lizzy_service->getRedHandle()) &&
         (params->len == 1))
     {
         if ((uint8_t)true < *(params->data))
@@ -69,6 +73,7 @@
             
         updateBuzzLedsT.signal_set(UPDATE_BUZZ_LEDS);
     }
+#endif
     else if ((params->handle == lizzy_service->get_green_handle()) &&
         (params->len == 1))
     {
@@ -107,12 +112,18 @@
         return;
     }
     
-    
     lizzy_service = new LizzyService(ble, &init_lizzy);
     ble.gap().onDisconnection(disconnectionCallback);
     ble.gap().onConnection(onConnectionCallback);         
     ble.gattServer().onDataWritten(onDataWrittenCallback);
     
+#if VODAFONE_COMPATIBILITY == 1
+    uint8_t myMacAddress[6];
+    BLEProtocol::AddressType_t temp_address_type;
+    ble.gap().getAddress(&temp_address_type, myMacAddress);
+    lizzy_service->setMac(myMacAddress);    // Update MAC address
+#endif
+    
     // Setup event handling. This is needed only with services.
     ble.onEventsToProcess(scheduleBleEventsProcessing);
     
@@ -129,8 +140,12 @@
     advertisementPacket.magnetometer[2] = (int16_t)0;
     
     /* setup advertising */
+#if VODAFONE_COMPATIBILITY == 1
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::INCOMPLETE_LIST_128BIT_SERVICE_IDS  , (uint8_t*)UUID, sizeof(UUID));
+#else
     ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
-    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, (uint8_t *)&advertisementPacket, sizeof(uint8_t)*11);
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, (uint8_t *)&advertisementPacket, sizeof(advertisementPacket));
+#endif
     ble.gap().setAdvertisingInterval(ADV_INTERVAL_MS);
     //ble.gap().startAdvertising();
 }