Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
LEDService.h@0:7d1cfe8dd01c, 2017-02-17 (annotated)
- Committer:
- jacampora
- Date:
- Fri Feb 17 07:21:40 2017 +0000
- Revision:
- 0:7d1cfe8dd01c
First commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jacampora | 0:7d1cfe8dd01c | 1 | /* mbed Microcontroller Library |
| jacampora | 0:7d1cfe8dd01c | 2 | * Copyright (c) 2006-2013 ARM Limited |
| jacampora | 0:7d1cfe8dd01c | 3 | * |
| jacampora | 0:7d1cfe8dd01c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| jacampora | 0:7d1cfe8dd01c | 5 | * you may not use this file except in compliance with the License. |
| jacampora | 0:7d1cfe8dd01c | 6 | * You may obtain a copy of the License at |
| jacampora | 0:7d1cfe8dd01c | 7 | * |
| jacampora | 0:7d1cfe8dd01c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| jacampora | 0:7d1cfe8dd01c | 9 | * |
| jacampora | 0:7d1cfe8dd01c | 10 | * Unless required by applicable law or agreed to in writing, software |
| jacampora | 0:7d1cfe8dd01c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| jacampora | 0:7d1cfe8dd01c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| jacampora | 0:7d1cfe8dd01c | 13 | * See the License for the specific language governing permissions and |
| jacampora | 0:7d1cfe8dd01c | 14 | * limitations under the License. |
| jacampora | 0:7d1cfe8dd01c | 15 | */ |
| jacampora | 0:7d1cfe8dd01c | 16 | |
| jacampora | 0:7d1cfe8dd01c | 17 | #ifndef __BLE_LED_SERVICE_H__ |
| jacampora | 0:7d1cfe8dd01c | 18 | #define __BLE_LED_SERVICE_H__ |
| jacampora | 0:7d1cfe8dd01c | 19 | |
| jacampora | 0:7d1cfe8dd01c | 20 | class LEDService { |
| jacampora | 0:7d1cfe8dd01c | 21 | public: |
| jacampora | 0:7d1cfe8dd01c | 22 | const static uint16_t LED_SERVICE_UUID = 0xA000; |
| jacampora | 0:7d1cfe8dd01c | 23 | const static uint16_t LED_STATE_CHARACTERISTIC_UUID = 0xA001; |
| jacampora | 0:7d1cfe8dd01c | 24 | |
| jacampora | 0:7d1cfe8dd01c | 25 | LEDService(BLEDevice &_ble, bool initialValueForLEDCharacteristic) : |
| jacampora | 0:7d1cfe8dd01c | 26 | ble(_ble), ledState(LED_STATE_CHARACTERISTIC_UUID, &initialValueForLEDCharacteristic) |
| jacampora | 0:7d1cfe8dd01c | 27 | { |
| jacampora | 0:7d1cfe8dd01c | 28 | GattCharacteristic *charTable[] = {&ledState}; |
| jacampora | 0:7d1cfe8dd01c | 29 | GattService ledService(LED_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); |
| jacampora | 0:7d1cfe8dd01c | 30 | ble.addService(ledService); |
| jacampora | 0:7d1cfe8dd01c | 31 | } |
| jacampora | 0:7d1cfe8dd01c | 32 | |
| jacampora | 0:7d1cfe8dd01c | 33 | GattAttribute::Handle_t getValueHandle() const { |
| jacampora | 0:7d1cfe8dd01c | 34 | return ledState.getValueHandle(); |
| jacampora | 0:7d1cfe8dd01c | 35 | } |
| jacampora | 0:7d1cfe8dd01c | 36 | |
| jacampora | 0:7d1cfe8dd01c | 37 | private: |
| jacampora | 0:7d1cfe8dd01c | 38 | BLEDevice &ble; |
| jacampora | 0:7d1cfe8dd01c | 39 | ReadWriteGattCharacteristic<bool> ledState; |
| jacampora | 0:7d1cfe8dd01c | 40 | }; |
| jacampora | 0:7d1cfe8dd01c | 41 | |
| jacampora | 0:7d1cfe8dd01c | 42 | #endif /* #ifndef __BLE_LED_SERVICE_H__ */ |