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