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
WatchTimeService.h@3:a4b8d67de1b1, 2015-07-27 (annotated)
- Committer:
- Bobty
- Date:
- Mon Jul 27 15:25:59 2015 +0000
- Revision:
- 3:a4b8d67de1b1
- Child:
- 5:2682353a8c32
Basic functionality of setting the time is working but no RTC is enabled
Who changed what in which revision?
User | Revision | Line number | New 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 | 3:a4b8d67de1b1 | 7 | class WatchTimeService { |
Bobty | 3:a4b8d67de1b1 | 8 | public: |
Bobty | 3:a4b8d67de1b1 | 9 | |
Bobty | 3:a4b8d67de1b1 | 10 | static const int WatchTime_BlockSize = 7; |
Bobty | 3:a4b8d67de1b1 | 11 | const static uint16_t WATCHTIME_SERVICE_UUID = 0xFE32; |
Bobty | 3:a4b8d67de1b1 | 12 | const static uint16_t WATCHTIME_STATE_CHARACTERISTIC_UUID = 0xFE33; |
Bobty | 3:a4b8d67de1b1 | 13 | |
Bobty | 3:a4b8d67de1b1 | 14 | WatchTimeService(BLE &_ble, uint8_t* pInitialWatchTime) : |
Bobty | 3:a4b8d67de1b1 | 15 | ble(_ble), watchTimeVal(WATCHTIME_STATE_CHARACTERISTIC_UUID, pInitialWatchTime, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) |
Bobty | 3:a4b8d67de1b1 | 16 | { |
Bobty | 3:a4b8d67de1b1 | 17 | GattCharacteristic *charTable[] = {&watchTimeVal}; |
Bobty | 3:a4b8d67de1b1 | 18 | GattService watchTimeService(WatchTimeService::WATCHTIME_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); |
Bobty | 3:a4b8d67de1b1 | 19 | ble.gattServer().addService(watchTimeService); |
Bobty | 3:a4b8d67de1b1 | 20 | } |
Bobty | 3:a4b8d67de1b1 | 21 | |
Bobty | 3:a4b8d67de1b1 | 22 | void sendWatchTime(uint8_t* pWatchTime) { |
Bobty | 3:a4b8d67de1b1 | 23 | ble.gattServer().write(watchTimeVal.getValueHandle(), pWatchTime, WatchTime_BlockSize); |
Bobty | 3:a4b8d67de1b1 | 24 | } |
Bobty | 3:a4b8d67de1b1 | 25 | |
Bobty | 3:a4b8d67de1b1 | 26 | GattAttribute::Handle_t getValueHandle() |
Bobty | 3:a4b8d67de1b1 | 27 | { |
Bobty | 3:a4b8d67de1b1 | 28 | return watchTimeVal.getValueHandle(); |
Bobty | 3:a4b8d67de1b1 | 29 | } |
Bobty | 3:a4b8d67de1b1 | 30 | |
Bobty | 3:a4b8d67de1b1 | 31 | private: |
Bobty | 3:a4b8d67de1b1 | 32 | BLE &ble; |
Bobty | 3:a4b8d67de1b1 | 33 | ReadWriteArrayGattCharacteristic<uint8_t, WatchTime_BlockSize> watchTimeVal; |
Bobty | 3:a4b8d67de1b1 | 34 | }; |
Bobty | 3:a4b8d67de1b1 | 35 | |
Bobty | 3:a4b8d67de1b1 | 36 | #endif /* #ifndef __BLE_WATCHTIME_SERVICE_H__ */ |