Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of SenseAirLP8 by
Diff: LP8_Service.h
- Revision:
- 0:ee3787c8e209
- Child:
- 2:d02255d8c36f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LP8_Service.h Fri Apr 21 13:26:06 2017 +0000
@@ -0,0 +1,35 @@
+#ifndef LP8_SERVICE_H
+#define LP8_SERVICE_H
+
+/* LP8 Gatt Service Class */
+
+class LP8_Service
+{
+public:
+
+ const static uint16_t LP8_SERVICE_UUID = 0xA000; //set custom UUID´s
+ const static uint16_t LP8_STATE_CHARACTERISTIC_UUID = 0xA001; //
+
+ //constructor setup for Gatt Service
+ LP8_Service(BLE &_ble, int co2ValueInitial): /* Passes a refrence to ble stack object and the lp8State copy to the private members */
+ ble(_ble),
+ lp8State(LP8_STATE_CHARACTERISTIC_UUID, &co2ValueInitial, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
+ {
+ GattCharacteristic *charTable[] = {&lp8State }; //create an 1 element array with lp8 Gatt characteristic
+ GattService lp8Service(LP8_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); //create an LP8 GattService
+ ble.addService(lp8Service); //add gatt service to the ble stack
+ };
+
+ void updateCo2Value(int co2Value)
+ {
+ ble.gattServer().write(lp8State.getValueAttribute().getHandle(),(uint8_t *) &co2Value, sizeof(co2Value)); //update the Gatt Server with new CO2 value
+ };
+
+private:
+
+ BLE &ble; //reference to ble object
+ ReadOnlyGattCharacteristic<int> lp8State; //
+
+
+};
+#endif
\ No newline at end of file
