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