asdf

Dependencies:   BLE_API mbed nRF51822

Committer:
amithy
Date:
Fri Nov 10 02:28:21 2017 +0000
Revision:
0:503f6a4871e6
asdf

Who changed what in which revision?

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