Version 1

Committer:
d4rth_j0k3r
Date:
Fri Aug 07 07:10:58 2020 +0000
Revision:
0:ad26a5d97cd7
Version 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
d4rth_j0k3r 0:ad26a5d97cd7 1 /* mbed Microcontroller Library
d4rth_j0k3r 0:ad26a5d97cd7 2 * Copyright (c) 2006-2013 ARM Limited
d4rth_j0k3r 0:ad26a5d97cd7 3 *
d4rth_j0k3r 0:ad26a5d97cd7 4 * Licensed under the Apache License, Version 2.0 (the "License");
d4rth_j0k3r 0:ad26a5d97cd7 5 * you may not use this file except in compliance with the License.
d4rth_j0k3r 0:ad26a5d97cd7 6 * You may obtain a copy of the License at
d4rth_j0k3r 0:ad26a5d97cd7 7 *
d4rth_j0k3r 0:ad26a5d97cd7 8 * http://www.apache.org/licenses/LICENSE-2.0
d4rth_j0k3r 0:ad26a5d97cd7 9 *
d4rth_j0k3r 0:ad26a5d97cd7 10 * Unless required by applicable law or agreed to in writing, software
d4rth_j0k3r 0:ad26a5d97cd7 11 * distributed under the License is distributed on an "AS IS" BASIS,
d4rth_j0k3r 0:ad26a5d97cd7 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d4rth_j0k3r 0:ad26a5d97cd7 13 * See the License for the specific language governing permissions and
d4rth_j0k3r 0:ad26a5d97cd7 14 * limitations under the License.
d4rth_j0k3r 0:ad26a5d97cd7 15 */
d4rth_j0k3r 0:ad26a5d97cd7 16
d4rth_j0k3r 0:ad26a5d97cd7 17 #ifndef __BLE_LED_SERVICE_H__
d4rth_j0k3r 0:ad26a5d97cd7 18 #define __BLE_LED_SERVICE_H__
d4rth_j0k3r 0:ad26a5d97cd7 19
d4rth_j0k3r 0:ad26a5d97cd7 20 class LEDService {
d4rth_j0k3r 0:ad26a5d97cd7 21 public:
d4rth_j0k3r 0:ad26a5d97cd7 22 const static uint16_t LED_SERVICE_UUID = 0xA000;
d4rth_j0k3r 0:ad26a5d97cd7 23 const static uint16_t LED_STATE_CHARACTERISTIC_UUID = 0xA001;
d4rth_j0k3r 0:ad26a5d97cd7 24
d4rth_j0k3r 0:ad26a5d97cd7 25 LEDService(BLEDevice &_ble, bool initialValueForLEDCharacteristic) :
d4rth_j0k3r 0:ad26a5d97cd7 26 ble(_ble), ledState(LED_STATE_CHARACTERISTIC_UUID, &initialValueForLEDCharacteristic)
d4rth_j0k3r 0:ad26a5d97cd7 27 {
d4rth_j0k3r 0:ad26a5d97cd7 28 GattCharacteristic *charTable[] = {&ledState};
d4rth_j0k3r 0:ad26a5d97cd7 29 GattService ledService(LED_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
d4rth_j0k3r 0:ad26a5d97cd7 30
d4rth_j0k3r 0:ad26a5d97cd7 31 ble.gattServer().addService(ledService);
d4rth_j0k3r 0:ad26a5d97cd7 32 }
d4rth_j0k3r 0:ad26a5d97cd7 33
d4rth_j0k3r 0:ad26a5d97cd7 34 GattAttribute::Handle_t getValueHandle() const
d4rth_j0k3r 0:ad26a5d97cd7 35 {
d4rth_j0k3r 0:ad26a5d97cd7 36 return ledState.getValueHandle();
d4rth_j0k3r 0:ad26a5d97cd7 37 }
d4rth_j0k3r 0:ad26a5d97cd7 38
d4rth_j0k3r 0:ad26a5d97cd7 39 private:
d4rth_j0k3r 0:ad26a5d97cd7 40 BLEDevice &ble;
d4rth_j0k3r 0:ad26a5d97cd7 41 ReadWriteGattCharacteristic<bool> ledState;
d4rth_j0k3r 0:ad26a5d97cd7 42 };
d4rth_j0k3r 0:ad26a5d97cd7 43
d4rth_j0k3r 0:ad26a5d97cd7 44 #endif /* #ifndef __BLE_LED_SERVICE_H__ */