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:
Sun Jul 26 15:38:59 2015 +0000
Revision:
2:9090120e2656
Child:
3:a4b8d67de1b1
Replaced code with RedBear sample BLE code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bobty 2:9090120e2656 1 /* mbed Microcontroller Library
Bobty 2:9090120e2656 2 * Copyright (c) 2006-2013 ARM Limited
Bobty 2:9090120e2656 3 *
Bobty 2:9090120e2656 4 * Licensed under the Apache License, Version 2.0 (the "License");
Bobty 2:9090120e2656 5 * you may not use this file except in compliance with the License.
Bobty 2:9090120e2656 6 * You may obtain a copy of the License at
Bobty 2:9090120e2656 7 *
Bobty 2:9090120e2656 8 * http://www.apache.org/licenses/LICENSE-2.0
Bobty 2:9090120e2656 9 *
Bobty 2:9090120e2656 10 * Unless required by applicable law or agreed to in writing, software
Bobty 2:9090120e2656 11 * distributed under the License is distributed on an "AS IS" BASIS,
Bobty 2:9090120e2656 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Bobty 2:9090120e2656 13 * See the License for the specific language governing permissions and
Bobty 2:9090120e2656 14 * limitations under the License.
Bobty 2:9090120e2656 15 */
Bobty 2:9090120e2656 16
Bobty 2:9090120e2656 17 #ifndef __BLE_BUTTON_SERVICE_H__
Bobty 2:9090120e2656 18 #define __BLE_BUTTON_SERVICE_H__
Bobty 2:9090120e2656 19
Bobty 2:9090120e2656 20 class ButtonService {
Bobty 2:9090120e2656 21 public:
Bobty 2:9090120e2656 22 const static uint16_t BUTTON_SERVICE_UUID = 0xA000;
Bobty 2:9090120e2656 23 const static uint16_t BUTTON_STATE_CHARACTERISTIC_UUID = 0xA001;
Bobty 2:9090120e2656 24
Bobty 2:9090120e2656 25 ButtonService(BLE &_ble, bool buttonPressedInitial) :
Bobty 2:9090120e2656 26 ble(_ble), buttonState(BUTTON_STATE_CHARACTERISTIC_UUID, &buttonPressedInitial, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
Bobty 2:9090120e2656 27 {
Bobty 2:9090120e2656 28 GattCharacteristic *charTable[] = {&buttonState};
Bobty 2:9090120e2656 29 GattService buttonService(ButtonService::BUTTON_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
Bobty 2:9090120e2656 30 ble.gattServer().addService(buttonService);
Bobty 2:9090120e2656 31 }
Bobty 2:9090120e2656 32
Bobty 2:9090120e2656 33 void updateButtonState(bool newState) {
Bobty 2:9090120e2656 34 ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)&newState, sizeof(bool));
Bobty 2:9090120e2656 35 }
Bobty 2:9090120e2656 36
Bobty 2:9090120e2656 37 private:
Bobty 2:9090120e2656 38 BLE &ble;
Bobty 2:9090120e2656 39 ReadOnlyGattCharacteristic<bool> buttonState;
Bobty 2:9090120e2656 40 };
Bobty 2:9090120e2656 41
Bobty 2:9090120e2656 42 #endif /* #ifndef __BLE_BUTTON_SERVICE_H__ */