Auto updating alarm watch - accepts alarm settings from a BLE device like a Raspberry Pi and buzzes at the appropriate time - also displays binary time
Dependencies: BLE_API mbed-src nRF51822 nrf51_rtc
Diff: WatchTimeService.h
- Revision:
- 3:a4b8d67de1b1
- Child:
- 5:2682353a8c32
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/WatchTimeService.h Mon Jul 27 15:25:59 2015 +0000
@@ -0,0 +1,36 @@
+// BLE Service for Watch Time
+// To allow a watch device to be told the current time
+
+#ifndef __BLE_WATCHTIME_SERVICE_H__
+#define __BLE_WATCHTIME_SERVICE_H__
+
+class WatchTimeService {
+public:
+
+ static const int WatchTime_BlockSize = 7;
+ const static uint16_t WATCHTIME_SERVICE_UUID = 0xFE32;
+ const static uint16_t WATCHTIME_STATE_CHARACTERISTIC_UUID = 0xFE33;
+
+ WatchTimeService(BLE &_ble, uint8_t* pInitialWatchTime) :
+ ble(_ble), watchTimeVal(WATCHTIME_STATE_CHARACTERISTIC_UUID, pInitialWatchTime, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
+ {
+ GattCharacteristic *charTable[] = {&watchTimeVal};
+ GattService watchTimeService(WatchTimeService::WATCHTIME_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
+ ble.gattServer().addService(watchTimeService);
+ }
+
+ void sendWatchTime(uint8_t* pWatchTime) {
+ ble.gattServer().write(watchTimeVal.getValueHandle(), pWatchTime, WatchTime_BlockSize);
+ }
+
+ GattAttribute::Handle_t getValueHandle()
+ {
+ return watchTimeVal.getValueHandle();
+ }
+
+private:
+ BLE &ble;
+ ReadWriteArrayGattCharacteristic<uint8_t, WatchTime_BlockSize> watchTimeVal;
+};
+
+#endif /* #ifndef __BLE_WATCHTIME_SERVICE_H__ */