NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
NimBLE2904.h
1/*
2 * Copyright 2020-2024 Ryan Powell <ryan@nable-embedded.io> and
3 * esp-nimble-cpp, NimBLE-Arduino contributors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NIMBLE_CPP_2904_H_
19#define NIMBLE_CPP_2904_H_
20
21#include "nimconfig.h"
22#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
23
24# include "NimBLEDescriptor.h"
25
26struct NimBLE2904Data {
27 uint8_t m_format{0};
28 int8_t m_exponent{0};
29 uint16_t m_unit{0x2700}; // Unitless; See https://www.bluetooth.com/specifications/assigned-numbers/units
30 uint8_t m_namespace{1}; // 1 = Bluetooth SIG Assigned Numbers
31 uint16_t m_description{0}; // unknown description
32} __attribute__((packed));
33
40 public:
41 NimBLE2904(NimBLECharacteristic* pChr = nullptr);
42 static const uint8_t FORMAT_BOOLEAN = 1;
43 static const uint8_t FORMAT_UINT2 = 2;
44 static const uint8_t FORMAT_UINT4 = 3;
45 static const uint8_t FORMAT_UINT8 = 4;
46 static const uint8_t FORMAT_UINT12 = 5;
47 static const uint8_t FORMAT_UINT16 = 6;
48 static const uint8_t FORMAT_UINT24 = 7;
49 static const uint8_t FORMAT_UINT32 = 8;
50 static const uint8_t FORMAT_UINT48 = 9;
51 static const uint8_t FORMAT_UINT64 = 10;
52 static const uint8_t FORMAT_UINT128 = 11;
53 static const uint8_t FORMAT_SINT8 = 12;
54 static const uint8_t FORMAT_SINT12 = 13;
55 static const uint8_t FORMAT_SINT16 = 14;
56 static const uint8_t FORMAT_SINT24 = 15;
57 static const uint8_t FORMAT_SINT32 = 16;
58 static const uint8_t FORMAT_SINT48 = 17;
59 static const uint8_t FORMAT_SINT64 = 18;
60 static const uint8_t FORMAT_SINT128 = 19;
61 static const uint8_t FORMAT_FLOAT32 = 20;
62 static const uint8_t FORMAT_FLOAT64 = 21;
63 static const uint8_t FORMAT_SFLOAT16 = 22;
64 static const uint8_t FORMAT_SFLOAT32 = 23;
65 static const uint8_t FORMAT_IEEE20601 = 24;
66 static const uint8_t FORMAT_UTF8 = 25;
67 static const uint8_t FORMAT_UTF16 = 26;
68 static const uint8_t FORMAT_OPAQUE = 27;
69 static const uint8_t FORMAT_MEDASN1 = 28;
70
71 void setDescription(uint16_t);
72 void setExponent(int8_t exponent);
73 void setFormat(uint8_t format);
74 void setNamespace(uint8_t namespace_value);
75 void setUnit(uint16_t unit);
76
77 private:
78 friend class NimBLECharacteristic;
79 NimBLE2904Data m_data{};
80}; // NimBLE2904
81
82#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
83#endif // NIMBLE_CPP_2904_H_
Descriptor for Characteristic Presentation Format.
Definition NimBLE2904.h:39
void setNamespace(uint8_t namespace_value)
Set the namespace.
Definition NimBLE2904.cpp:59
void setDescription(uint16_t)
Set the description.
Definition NimBLE2904.cpp:32
void setExponent(int8_t exponent)
Set the exponent.
Definition NimBLE2904.cpp:41
void setFormat(uint8_t format)
Set the format.
Definition NimBLE2904.cpp:50
void setUnit(uint16_t unit)
Set the units for this value.
Definition NimBLE2904.cpp:69
The model of a BLE Characteristic.
Definition NimBLECharacteristic.h:40
A model of a BLE descriptor.
Definition NimBLEDescriptor.h:33