No changes

Dependencies:   BLE_API mbed nRF51822

Fork of SDP_Version3_Abdul by Michael Galis

Revision:
4:caab577334f0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ReedSwitchService.h	Sun Feb 26 02:33:32 2017 +0000
@@ -0,0 +1,34 @@
+/* Senior Project Bluetooth bicycle speedometer
+Author: Michael Galis
+This header file describes the Reed Switch Service that I created to be able
+to send the state of the reed switch as a magnet passes by.
+*/
+
+#ifndef __BLE_BUTTON_SERVICE_H__
+#define __BLE_BUTTON_SERVICE_H__
+
+class ReedSwitchService {
+public:
+    const static uint16_t REED_SWITCH_SERVICE_UUID              = 0xA006;
+    const static uint16_t REED_SWITCH_STATE_CHARACTERISTIC_UUID = 0xA007;
+
+    ReedSwitchService(BLE &_ble, uint8_t reedSwitchPressedInitial) :
+        ble(_ble), 
+        reedSwitchState(REED_SWITCH_STATE_CHARACTERISTIC_UUID, &reedSwitchPressedInitial, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
+    {
+        GattCharacteristic *charTable[] = {&reedSwitchState};
+        GattService         reedSwitchService(ReedSwitchService::REED_SWITCH_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
+        ble.gattServer().addService(reedSwitchService);
+    }
+
+    void updateReedSwitchState(uint8_t newState) 
+    {
+        ble.gattServer().write(reedSwitchState.getValueHandle(), (uint8_t *)&newState, sizeof(uint8_t));
+    }
+
+private:
+    BLE                              &ble;
+    ReadOnlyGattCharacteristic<uint8_t>  reedSwitchState;
+};
+
+#endif /* #ifndef __BLE_BUTTON_SERVICE_H__ */