![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Project aiming to do a Bluetooth Low Energy IoT devices, which measure temperature and humidity. Bluetooth achieved with the IDB05A1 shield. Temperature/humidity achieved with a DHT11 sensor. Project working, tested on an STM32 L476 board.
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
LEDService.h@1:023e1eae2048, 2017-04-18 (annotated)
- Committer:
- ledonger
- Date:
- Tue Apr 18 14:08:50 2017 +0000
- Revision:
- 1:023e1eae2048
Be careful to use mbed revision 125
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ledonger | 1:023e1eae2048 | 1 | /* mbed Microcontroller Library |
ledonger | 1:023e1eae2048 | 2 | * Copyright (c) 2006-2013 ARM Limited |
ledonger | 1:023e1eae2048 | 3 | * |
ledonger | 1:023e1eae2048 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ledonger | 1:023e1eae2048 | 5 | * you may not use this file except in compliance with the License. |
ledonger | 1:023e1eae2048 | 6 | * You may obtain a copy of the License at |
ledonger | 1:023e1eae2048 | 7 | * |
ledonger | 1:023e1eae2048 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
ledonger | 1:023e1eae2048 | 9 | * |
ledonger | 1:023e1eae2048 | 10 | * Unless required by applicable law or agreed to in writing, software |
ledonger | 1:023e1eae2048 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
ledonger | 1:023e1eae2048 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ledonger | 1:023e1eae2048 | 13 | * See the License for the specific language governing permissions and |
ledonger | 1:023e1eae2048 | 14 | * limitations under the License. |
ledonger | 1:023e1eae2048 | 15 | */ |
ledonger | 1:023e1eae2048 | 16 | |
ledonger | 1:023e1eae2048 | 17 | #ifndef __BLE_LED_SERVICE_H__ |
ledonger | 1:023e1eae2048 | 18 | #define __BLE_LED_SERVICE_H__ |
ledonger | 1:023e1eae2048 | 19 | |
ledonger | 1:023e1eae2048 | 20 | class LEDService { |
ledonger | 1:023e1eae2048 | 21 | public: |
ledonger | 1:023e1eae2048 | 22 | const static uint16_t LED_SERVICE_UUID = 0xA000; |
ledonger | 1:023e1eae2048 | 23 | const static uint16_t LED_STATE_CHARACTERISTIC_UUID = 0xA001; |
ledonger | 1:023e1eae2048 | 24 | |
ledonger | 1:023e1eae2048 | 25 | LEDService(BLEDevice &_ble, bool initialValueForLEDCharacteristic) : |
ledonger | 1:023e1eae2048 | 26 | ble(_ble), ledState(LED_STATE_CHARACTERISTIC_UUID, &initialValueForLEDCharacteristic) |
ledonger | 1:023e1eae2048 | 27 | { |
ledonger | 1:023e1eae2048 | 28 | GattCharacteristic *charTable[] = {&ledState}; |
ledonger | 1:023e1eae2048 | 29 | GattService ledService(LED_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); |
ledonger | 1:023e1eae2048 | 30 | ble.addService(ledService); |
ledonger | 1:023e1eae2048 | 31 | } |
ledonger | 1:023e1eae2048 | 32 | |
ledonger | 1:023e1eae2048 | 33 | GattAttribute::Handle_t getValueHandle() const { |
ledonger | 1:023e1eae2048 | 34 | return ledState.getValueHandle(); |
ledonger | 1:023e1eae2048 | 35 | } |
ledonger | 1:023e1eae2048 | 36 | |
ledonger | 1:023e1eae2048 | 37 | private: |
ledonger | 1:023e1eae2048 | 38 | BLEDevice &ble; |
ledonger | 1:023e1eae2048 | 39 | ReadWriteGattCharacteristic<bool> ledState; |
ledonger | 1:023e1eae2048 | 40 | }; |
ledonger | 1:023e1eae2048 | 41 | |
ledonger | 1:023e1eae2048 | 42 | #endif /* #ifndef __BLE_LED_SERVICE_H__ */ |