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
- Committer:
- Bobty
- Date:
- 2015-12-14
- Revision:
- 5:2682353a8c32
- Parent:
- 3:a4b8d67de1b1
- Child:
- 6:4a12e0f03381
File content as of revision 5:2682353a8c32:
// 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__
//typedef void (*GetCurTimeCallbackFn)(uint8_t* curWatchTime)
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 writeWatchTime(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;
// GetCurTimeCallbackFn _pGetCurTimeCallback;
};
#endif /* #ifndef __BLE_WATCHTIME_SERVICE_H__ */