Pull request for i.a. sensor buffer template

Dependencies:   BLE_API MPU6050 mbed nRF51822

Revision:
9:e9d6a9758cf7
Parent:
8:d1f5c8801d59
--- a/AccelerationService.h	Tue Oct 16 22:01:14 2018 +0200
+++ b/AccelerationService.h	Tue Oct 16 22:29:07 2018 +0200
@@ -3,7 +3,9 @@
 
 #include "ble/BLE.h"
 
-#define UUID_ACCELERATION_CHAR    "5D34E2F0-3DD2-07AC-38F2-BBAD120EF853"
+#define UUID_ACCELERATION_X_CHAR  "5D34E2F0-3DD2-07AC-38F2-BBAD120EF853"
+#define UUID_ACCELERATION_Y_CHAR  "5D34E2F0-3DD2-07AC-38F3-BBAD120EF853"
+#define UUID_ACCELERATION_Z_CHAR  "5D34E2F0-3DD2-07AC-38F4-BBAD120EF853"
 #define UUID_ACCELERATION_SERVICE "5D34E2F0-3DD2-07AC-38F1-BBAD120EF853"
       
 /**
@@ -19,10 +21,11 @@
     AccelerationService(BLE &_ble) :
         ble(_ble),
         accelerationIndex(0),
-        accelerationCharacteristic(UUID(UUID_ACCELERATION_CHAR), &temp, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
-        //accelerationCharacteristic(0x1234, &temp, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
+        accelerationXCharacteristic(UUID(UUID_ACCELERATION_X_CHAR), &temp, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
+        accelerationYCharacteristic(UUID(UUID_ACCELERATION_Y_CHAR), &temp, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
+        accelerationZCharacteristic(UUID(UUID_ACCELERATION_Z_CHAR), &temp, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
 
-        GattCharacteristic *charTable[] = {&accelerationCharacteristic};
+        GattCharacteristic *charTable[] = {&accelerationXCharacteristic, &accelerationYCharacteristic, &accelerationZCharacteristic};
         GattService         AccelerationService(UUID(UUID_ACCELERATION_SERVICE), charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
 
         ble.addService(AccelerationService);
@@ -35,11 +38,12 @@
      *              Update to temperature.
      */
     void addAcceleration(int16_t *newAccel) {
-        /*
-        temperature = newTemp;
-        uint16_t temp = (uint16_t)temperature;
-        ble.gattServer().write(accelerationCharacteristic.getValueHandle(), (const uint8_t*)&temp, sizeof(temperature));
-        */
+        temp = newAccel[0];
+        ble.gattServer().write(accelerationXCharacteristic.getValueHandle(), (const uint8_t*)&temp, sizeof(temp));
+        temp = newAccel[1];
+        ble.gattServer().write(accelerationYCharacteristic.getValueHandle(), (const uint8_t*)&temp, sizeof(temp));
+        temp = newAccel[2];
+        ble.gattServer().write(accelerationZCharacteristic.getValueHandle(), (const uint8_t*)&temp, sizeof(temp));
     }
 
 
@@ -61,7 +65,9 @@
      * A ReadOnlyGattCharacteristic that allows access to the peer device to the
      * temperature value through BLE.
      */
-    ReadOnlyGattCharacteristic<int16_t> accelerationCharacteristic;
+    ReadOnlyGattCharacteristic<int16_t> accelerationXCharacteristic;
+    ReadOnlyGattCharacteristic<int16_t> accelerationYCharacteristic;
+    ReadOnlyGattCharacteristic<int16_t> accelerationZCharacteristic;
 };
 
 #endif /* #ifndef __ACCELERATION_SERVICE_H__*/