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

Committer:
Bobty
Date:
Mon Dec 14 22:58:31 2015 +0000
Revision:
5:2682353a8c32
Parent:
3:a4b8d67de1b1
Child:
6:4a12e0f03381
Works reliably - time only (no alarm functions) - doesn't display on binary digits as yet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bobty 3:a4b8d67de1b1 1 // BLE Service for Watch Time
Bobty 3:a4b8d67de1b1 2 // To allow a watch device to be told the current time
Bobty 3:a4b8d67de1b1 3
Bobty 3:a4b8d67de1b1 4 #ifndef __BLE_WATCHTIME_SERVICE_H__
Bobty 3:a4b8d67de1b1 5 #define __BLE_WATCHTIME_SERVICE_H__
Bobty 3:a4b8d67de1b1 6
Bobty 5:2682353a8c32 7 //typedef void (*GetCurTimeCallbackFn)(uint8_t* curWatchTime)
Bobty 5:2682353a8c32 8
Bobty 3:a4b8d67de1b1 9 class WatchTimeService {
Bobty 3:a4b8d67de1b1 10 public:
Bobty 3:a4b8d67de1b1 11
Bobty 3:a4b8d67de1b1 12 static const int WatchTime_BlockSize = 7;
Bobty 3:a4b8d67de1b1 13 const static uint16_t WATCHTIME_SERVICE_UUID = 0xFE32;
Bobty 3:a4b8d67de1b1 14 const static uint16_t WATCHTIME_STATE_CHARACTERISTIC_UUID = 0xFE33;
Bobty 3:a4b8d67de1b1 15
Bobty 5:2682353a8c32 16 WatchTimeService(BLE &ble, uint8_t* pInitialWatchTime) :
Bobty 5:2682353a8c32 17 _ble(ble),
Bobty 5:2682353a8c32 18 _watchTimeVal(WATCHTIME_STATE_CHARACTERISTIC_UUID, pInitialWatchTime, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
Bobty 3:a4b8d67de1b1 19 {
Bobty 5:2682353a8c32 20 GattCharacteristic *charTable[] = {&_watchTimeVal};
Bobty 3:a4b8d67de1b1 21 GattService watchTimeService(WatchTimeService::WATCHTIME_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
Bobty 5:2682353a8c32 22 _ble.gattServer().addService(watchTimeService);
Bobty 3:a4b8d67de1b1 23 }
Bobty 3:a4b8d67de1b1 24
Bobty 5:2682353a8c32 25 void writeWatchTime(uint8_t* pWatchTime)
Bobty 5:2682353a8c32 26 {
Bobty 5:2682353a8c32 27 _ble.gattServer().write(_watchTimeVal.getValueHandle(), pWatchTime, WatchTime_BlockSize);
Bobty 3:a4b8d67de1b1 28 }
Bobty 3:a4b8d67de1b1 29
Bobty 3:a4b8d67de1b1 30 GattAttribute::Handle_t getValueHandle()
Bobty 3:a4b8d67de1b1 31 {
Bobty 5:2682353a8c32 32 return _watchTimeVal.getValueHandle();
Bobty 3:a4b8d67de1b1 33 }
Bobty 3:a4b8d67de1b1 34
Bobty 3:a4b8d67de1b1 35 private:
Bobty 5:2682353a8c32 36 BLE &_ble;
Bobty 5:2682353a8c32 37 ReadWriteArrayGattCharacteristic<uint8_t, WatchTime_BlockSize> _watchTimeVal;
Bobty 5:2682353a8c32 38 // GetCurTimeCallbackFn _pGetCurTimeCallback;
Bobty 3:a4b8d67de1b1 39 };
Bobty 3:a4b8d67de1b1 40
Bobty 3:a4b8d67de1b1 41 #endif /* #ifndef __BLE_WATCHTIME_SERVICE_H__ */