test1

Dependencies:   BLE_API mbed nRF51822

Committer:
bbman30
Date:
Fri May 20 02:36:33 2016 +0000
Revision:
0:91ab5e95f6b0
hkh

Who changed what in which revision?

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