High level Bluetooth Low Energy API and radio abstraction layer

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate BLE_ANCS_SDAPI_IRC ... more

Overview

The BLE_API is a high level abstraction for using Bluetooth Low Energy on multiple platforms. For details and examples using the BLE_API please see the BLE_API Summary Page. Or click on the API Documentation tab above.

Supported Services

Supported services can be found in the BLE_API/services folder.

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Mon Nov 02 09:09:08 2015 +0000
Parent:
865:0f44d2aaf201
Child:
867:b099c28e8e28
Commit message:
Synchronized with git rev be09e516
Author: Rohit Grover
use types like ReadOnlyGattCharacteristic<TemperatureType_t>

Changed in this revision

ble/services/EnvironmentalService.h Show annotated file Show diff for this revision Revisions of this file
--- a/ble/services/EnvironmentalService.h	Mon Nov 02 09:09:07 2015 +0000
+++ b/ble/services/EnvironmentalService.h	Mon Nov 02 09:09:08 2015 +0000
@@ -40,26 +40,11 @@
      * @param   humidity_en Enable this characteristic.
      * @param   pressure_en Enable this characteristic.
      */
-    EnvironmentalService(BLE &_ble,
-                         bool temperature_en = false,
-                         bool humidity_en = false,
-                         bool pressure_en = false) :
+    EnvironmentalService(BLE& _ble) :
         ble(_ble),
-        temperatureCharacteristic(GattCharacteristic::UUID_TEMPERATURE_CHAR,
-                                  (uint8_t *) &temperature,
-                                  (temperature_en) ? 2 : 0, // minLength
-                                  (temperature_en) ? 2 : 0, // maxLength
-                                  GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
-        humidityCharacteristic(GattCharacteristic::UUID_HUMIDITY_CHAR,
-                               (uint8_t *) &humidity,
-                               (humidity_en) ? 2 : 0, // minLength
-                               (humidity_en) ? 2 : 0, // maxLength
-                               GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
-        pressureCharacteristic(GattCharacteristic::UUID_PRESSURE_CHAR,
-                               (uint8_t *) &pressure,
-                               (pressure_en) ? 4 : 0, // minLength
-                               (pressure_en) ? 4 : 0, // maxLength
-                               GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ)
+        temperatureCharacteristic(GattCharacteristic::UUID_TEMPERATURE_CHAR, &temperature),
+        humidityCharacteristic(GattCharacteristic::UUID_HUMIDITY_CHAR, &humidity),
+        pressureCharacteristic(GattCharacteristic::UUID_PRESSURE_CHAR, &pressure)
     {
         static bool serviceAdded = false; /* We should only ever need to add the information service once. */
         if (serviceAdded) {
@@ -70,8 +55,7 @@
                                             &pressureCharacteristic,
                                             &temperatureCharacteristic };
 
-        GattService         environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable,
-                                                 sizeof(charTable) / sizeof(GattCharacteristic *));
+        GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
 
         ble.gattServer().addService(environmentalService);
         serviceAdded = true;
@@ -108,14 +92,15 @@
     }
 
 private:
-    BLE &              ble;
+    BLE& ble;
 
-    int16_t            temperature;
-    GattCharacteristic temperatureCharacteristic;
-    uint16_t           humidity;
-    GattCharacteristic humidityCharacteristic;
-    uint32_t           pressure;
-    GattCharacteristic pressureCharacteristic;
+    TemperatureType_t temperature;
+    HumidityType_t    humidity;
+    PressureType_t    pressure;
+
+    ReadOnlyGattCharacteristic<TemperatureType_t> temperatureCharacteristic;
+    ReadOnlyGattCharacteristic<HumidityType_t>    humidityCharacteristic;
+    ReadOnlyGattCharacteristic<PressureType_t>    pressureCharacteristic;
 };
 
 #endif /* #ifndef __BLE_ENVIRONMENTAL_SERVICE_H__*/
\ No newline at end of file