esp-nimble-cpp / NimBLE-Arduino  1.3.1
NimBLE2904.h
1 /*
2  * NimBLE2904.h
3  *
4  * Created: on March 13, 2020
5  * Author H2zero
6  *
7  * Originally:
8  *
9  * BLE2904.h
10  *
11  * Created on: Dec 23, 2017
12  * Author: kolban
13  */
14 
15 #ifndef MAIN_NIMBLE2904_H_
16 #define MAIN_NIMBLE2904_H_
17 #include "sdkconfig.h"
18 #if defined(CONFIG_BT_ENABLED)
19 
20 #include "nimconfig.h"
21 #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
22 
23 #include "NimBLEDescriptor.h"
24 
25 struct BLE2904_Data {
26  uint8_t m_format;
27  int8_t m_exponent;
28  uint16_t m_unit; // See https://www.bluetooth.com/specifications/assigned-numbers/units
29  uint8_t m_namespace;
30  uint16_t m_description;
31 
32 } __attribute__((packed));
33 
34 
44 public:
45  NimBLE2904(NimBLECharacteristic* pCharacterisitic = nullptr);
46  static const uint8_t FORMAT_BOOLEAN = 1;
47  static const uint8_t FORMAT_UINT2 = 2;
48  static const uint8_t FORMAT_UINT4 = 3;
49  static const uint8_t FORMAT_UINT8 = 4;
50  static const uint8_t FORMAT_UINT12 = 5;
51  static const uint8_t FORMAT_UINT16 = 6;
52  static const uint8_t FORMAT_UINT24 = 7;
53  static const uint8_t FORMAT_UINT32 = 8;
54  static const uint8_t FORMAT_UINT48 = 9;
55  static const uint8_t FORMAT_UINT64 = 10;
56  static const uint8_t FORMAT_UINT128 = 11;
57  static const uint8_t FORMAT_SINT8 = 12;
58  static const uint8_t FORMAT_SINT12 = 13;
59  static const uint8_t FORMAT_SINT16 = 14;
60  static const uint8_t FORMAT_SINT24 = 15;
61  static const uint8_t FORMAT_SINT32 = 16;
62  static const uint8_t FORMAT_SINT48 = 17;
63  static const uint8_t FORMAT_SINT64 = 18;
64  static const uint8_t FORMAT_SINT128 = 19;
65  static const uint8_t FORMAT_FLOAT32 = 20;
66  static const uint8_t FORMAT_FLOAT64 = 21;
67  static const uint8_t FORMAT_SFLOAT16 = 22;
68  static const uint8_t FORMAT_SFLOAT32 = 23;
69  static const uint8_t FORMAT_IEEE20601 = 24;
70  static const uint8_t FORMAT_UTF8 = 25;
71  static const uint8_t FORMAT_UTF16 = 26;
72  static const uint8_t FORMAT_OPAQUE = 27;
73 
74  void setDescription(uint16_t);
75  void setExponent(int8_t exponent);
76  void setFormat(uint8_t format);
77  void setNamespace(uint8_t namespace_value);
78  void setUnit(uint16_t unit);
79 
80 private:
81  friend class NimBLECharacteristic;
82  BLE2904_Data m_data;
83 }; // BLE2904
84 
85 #endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
86 #endif /* CONFIG_BT_ENABLED */
87 #endif /* MAIN_NIMBLE2904_H_ */
Descriptor for Characteristic Presentation Format.
Definition: NimBLE2904.h:43
void setNamespace(uint8_t namespace_value)
Set the namespace.
Definition: NimBLE2904.cpp:73
void setDescription(uint16_t)
Set the description.
Definition: NimBLE2904.cpp:46
void setExponent(int8_t exponent)
Set the exponent.
Definition: NimBLE2904.cpp:55
void setFormat(uint8_t format)
Set the format.
Definition: NimBLE2904.cpp:64
void setUnit(uint16_t unit)
Set the units for this value. It should be one of the encoded values defined here: https://www....
Definition: NimBLE2904.cpp:84
The model of a BLE Characteristic.
Definition: NimBLECharacteristic.h:60
A model of a BLE descriptor.
Definition: NimBLEDescriptor.h:44