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