|
| 1 | +/* |
| 2 | + * Mbed-OS Microcontroller Library |
| 3 | + * Copyright (c) 2020 Embedded Planet |
| 4 | + * Copyright (c) 2020 ARM Limited |
| 5 | + * SPDX-License-Identifier: Apache-2.0 |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License |
| 18 | + */ |
| 19 | + |
| 20 | +#ifndef MBED_OS_EXPERIMENTAL_BLE_SERVICES_DESCRIPTORS_CHARACTERISTICUSERDESCRIPTIONDESCRIPTOR_H_ |
| 21 | +#define MBED_OS_EXPERIMENTAL_BLE_SERVICES_DESCRIPTORS_CHARACTERISTICUSERDESCRIPTIONDESCRIPTOR_H_ |
| 22 | + |
| 23 | +#include "ble/gatt/GattCharacteristic.h" |
| 24 | +#include "ble/gatt/GattAttribute.h" |
| 25 | + |
| 26 | +/** |
| 27 | + * Class encapsulating a Characteristic User Description Descriptor (CUDD) |
| 28 | + * |
| 29 | + * See Bluetooth Core Specification 5.2, Volume 3, Part G, Section 3.3.3.2 |
| 30 | + * |
| 31 | + * TODO extend this in the future to support client-writable CUDD (set Writable Auxiliary bit) |
| 32 | + */ |
| 33 | +class CharacteristicUserDescriptionDescriptor : public GattAttribute |
| 34 | +{ |
| 35 | +public: |
| 36 | + |
| 37 | + CharacteristicUserDescriptionDescriptor(const char* user_description) : |
| 38 | + _user_description(user_description), |
| 39 | + GattAttribute((const UUID&) UUID(BLE_UUID_DESCRIPTOR_CHAR_USER_DESC), |
| 40 | + (uint8_t*) user_description, strlen(user_description), strlen(user_description), false) |
| 41 | + { } |
| 42 | + |
| 43 | + const char* get_user_description() const { |
| 44 | + return _user_description; |
| 45 | + } |
| 46 | + |
| 47 | +private: |
| 48 | + |
| 49 | + const char* _user_description; |
| 50 | + |
| 51 | + |
| 52 | +}; |
| 53 | + |
| 54 | +#endif /* MBED_OS_EXPERIMENTAL_BLE_SERVICES_DESCRIPTORS_CHARACTERISTICUSERDESCRIPTIONDESCRIPTOR_H_ */ |
0 commit comments