rajarajan elango
/
mbed-os-example-ble-LED
Testing of Onboard Led using nRF control panel app in Android device.
source/LEDService.h@79:4c62b7c6081a, 2019-08-15 (annotated)
- Committer:
- mbed_official
- Date:
- Thu Aug 15 17:01:56 2019 +0100
- Revision:
- 79:4c62b7c6081a
- Parent:
- 74:51fde11a771f
Merge pull request #252 from donatieng/mbed_os_update
Update Master branch to use Mbed OS 5.13.1
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 2:864ddfb70a9c | 1 | /* mbed Microcontroller Library |
mbed_official | 2:864ddfb70a9c | 2 | * Copyright (c) 2006-2013 ARM Limited |
mbed_official | 2:864ddfb70a9c | 3 | * |
mbed_official | 2:864ddfb70a9c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 2:864ddfb70a9c | 5 | * you may not use this file except in compliance with the License. |
mbed_official | 2:864ddfb70a9c | 6 | * You may obtain a copy of the License at |
mbed_official | 2:864ddfb70a9c | 7 | * |
mbed_official | 2:864ddfb70a9c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 2:864ddfb70a9c | 9 | * |
mbed_official | 2:864ddfb70a9c | 10 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 2:864ddfb70a9c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 2:864ddfb70a9c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 2:864ddfb70a9c | 13 | * See the License for the specific language governing permissions and |
mbed_official | 2:864ddfb70a9c | 14 | * limitations under the License. |
mbed_official | 2:864ddfb70a9c | 15 | */ |
mbed_official | 2:864ddfb70a9c | 16 | |
mbed_official | 2:864ddfb70a9c | 17 | #ifndef __BLE_LED_SERVICE_H__ |
mbed_official | 2:864ddfb70a9c | 18 | #define __BLE_LED_SERVICE_H__ |
mbed_official | 2:864ddfb70a9c | 19 | |
mbed_official | 2:864ddfb70a9c | 20 | class LEDService { |
mbed_official | 2:864ddfb70a9c | 21 | public: |
mbed_official | 2:864ddfb70a9c | 22 | const static uint16_t LED_SERVICE_UUID = 0xA000; |
mbed_official | 2:864ddfb70a9c | 23 | const static uint16_t LED_STATE_CHARACTERISTIC_UUID = 0xA001; |
mbed_official | 2:864ddfb70a9c | 24 | |
mbed_official | 2:864ddfb70a9c | 25 | LEDService(BLEDevice &_ble, bool initialValueForLEDCharacteristic) : |
mbed_official | 2:864ddfb70a9c | 26 | ble(_ble), ledState(LED_STATE_CHARACTERISTIC_UUID, &initialValueForLEDCharacteristic) |
mbed_official | 2:864ddfb70a9c | 27 | { |
mbed_official | 2:864ddfb70a9c | 28 | GattCharacteristic *charTable[] = {&ledState}; |
mbed_official | 2:864ddfb70a9c | 29 | GattService ledService(LED_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); |
mbed_official | 74:51fde11a771f | 30 | |
mbed_official | 74:51fde11a771f | 31 | ble.gattServer().addService(ledService); |
mbed_official | 2:864ddfb70a9c | 32 | } |
mbed_official | 2:864ddfb70a9c | 33 | |
mbed_official | 2:864ddfb70a9c | 34 | GattAttribute::Handle_t getValueHandle() const |
mbed_official | 2:864ddfb70a9c | 35 | { |
mbed_official | 2:864ddfb70a9c | 36 | return ledState.getValueHandle(); |
mbed_official | 2:864ddfb70a9c | 37 | } |
mbed_official | 2:864ddfb70a9c | 38 | |
mbed_official | 2:864ddfb70a9c | 39 | private: |
mbed_official | 2:864ddfb70a9c | 40 | BLEDevice &ble; |
mbed_official | 2:864ddfb70a9c | 41 | ReadWriteGattCharacteristic<bool> ledState; |
mbed_official | 2:864ddfb70a9c | 42 | }; |
mbed_official | 2:864ddfb70a9c | 43 | |
mbed_official | 2:864ddfb70a9c | 44 | #endif /* #ifndef __BLE_LED_SERVICE_H__ */ |