Friendly LWM2M client
WppTypes.h
Go to the documentation of this file.
1 #ifndef WPP_TYPES_T
2 #define WPP_TYPES_T
3 
4 #include <vector>
5 #include <string>
6 #include <functional>
7 #include <variant>
8 
9 #include "liblwm2m.h"
10 
11 namespace wpp {
12 
13 #define SINGLE_INSTANCE_ID 0
14 
15 using ID_T = uint16_t;
16 #define ID_T_MAX_VAL (LWM2M_MAX_ID)
17 
18 using EVENT_ID_T = uint8_t;
19 
23 enum class TYPE_ID: uint8_t {
24  BOOL, // bool
25  INT, // int64_t
26  UINT, // uint64_t
27  FLOAT, // double
28  OBJ_LINK, // {object ID, instance ID}
29  TIME, // Derived from INT
30  OPAQUE, // vector<uint8_t>
31  STRING, // string
32  CORE_LINK, // Derived from STRING
33  EXECUTE, // Type of executable resources
34  UNDEFINED // Undefined type
35 };
36 
40 using BOOL_T = bool;
41 using INT_T = int64_t;
42 using UINT_T = uint64_t;
43 using FLOAT_T = double;
44 using TIME_T = INT_T;
45 using STRING_T = std::string;
49 using OPAQUE_T = std::vector<uint8_t>;
54 struct OBJ_LINK_T {
57 };
62 using CORE_LINK_T = std::string;
71 class Instance;
72 using EXECUTE_T = std::function<bool(Instance&, ID_T, const OPAQUE_T&)>;
73 
77 template<typename T>
79  TYPE_ID typeID = TYPE_ID::UNDEFINED;
80  if constexpr (std::is_same<T, BOOL_T>::value) typeID = TYPE_ID::BOOL;
81  else if constexpr (std::is_same<T, INT_T>::value) typeID = TYPE_ID::INT;
82  else if constexpr (std::is_same<T, UINT_T>::value) typeID = TYPE_ID::UINT;
83  else if constexpr (std::is_same<T, FLOAT_T>::value) typeID = TYPE_ID::FLOAT;
84  else if constexpr (std::is_same<T, OPAQUE_T>::value) typeID = TYPE_ID::OPAQUE;
85  else if constexpr (std::is_same<T, OBJ_LINK_T>::value) typeID = TYPE_ID::OBJ_LINK;
86  else if constexpr (std::is_same<T, STRING_T>::value) typeID = TYPE_ID::STRING;
87  else if constexpr (std::is_same<T, EXECUTE_T>::value) typeID = TYPE_ID::EXECUTE;
88  return typeID;
89 }
90 
94 using VERIFY_INT_T = std::function<bool(const INT_T&)>;
95 using VERIFY_UINT_T = std::function<bool(const UINT_T&)>;
96 using VERIFY_FLOAT_T = std::function<bool(const FLOAT_T&)>;
97 using VERIFY_OPAQUE_T = std::function<bool(const OPAQUE_T&)>;
98 using VERIFY_BOOL_T = std::function<bool(const BOOL_T&)>;
99 using VERIFY_OBJ_LINK_T = std::function<bool(const OBJ_LINK_T&)>;
100 using VERIFY_STRING_T = std::function<bool(const STRING_T&)>;
101 using VERIFY_EXECUTE_T = std::function<bool(const EXECUTE_T &)>;
102 using VERIFY_CORE_LINK_T = std::function<bool(const CORE_LINK_T &)>;
103 
104 enum class PRIORITY: uint8_t {
105  HIGH,
106  MEDIUM,
107  LOW,
108  DEFAULT = LOW
109 };
110 
111 enum class IS_SINGLE: uint8_t {
112  SINGLE,
113  MULTIPLE
114 };
115 
116 enum class IS_MANDATORY: uint8_t {
117  MANDATORY,
118  OPTIONAL
119 };
120 
121 
122 struct Version {
123  uint8_t major;
124  uint8_t minor;
125 };
126 
127 struct ResLink {
130 };
131 
132 struct DataLink {
135 };
136 
137 } // namespace wpp
138 
139 #endif // WPP_TYPES_T
#define ID_T_MAX_VAL
Definition: WppTypes.h:16
Instance is interface class that implements manipulation with derived class resources....
Definition: Instance.h:40
The WppConnection class represents a connection interface for the Wpp library.
Definition: WppClient.cpp:14
std::string CORE_LINK_T
CoreLink - </3/0> or </1/0/>;ssid=101 or </5>,</4>,</55>;ver=1.9,</55/0>. Represent as string in lwm2...
Definition: WppTypes.h:62
IS_MANDATORY
Definition: WppTypes.h:116
bool BOOL_T
Wpp data types bindings.
Definition: WppTypes.h:40
std::function< bool(const EXECUTE_T &)> VERIFY_EXECUTE_T
Definition: WppTypes.h:101
std::function< bool(Instance &, ID_T, const OPAQUE_T &)> EXECUTE_T
Definition: WppTypes.h:72
PRIORITY
Definition: WppTypes.h:104
std::function< bool(const BOOL_T &)> VERIFY_BOOL_T
Definition: WppTypes.h:98
int64_t INT_T
Definition: WppTypes.h:41
uint16_t ID_T
Definition: WppTypes.h:15
std::function< bool(const STRING_T &)> VERIFY_STRING_T
Definition: WppTypes.h:100
uint8_t EVENT_ID_T
Definition: WppTypes.h:18
std::function< bool(const INT_T &)> VERIFY_INT_T
Data validation function types.
Definition: WppTypes.h:94
uint64_t UINT_T
Definition: WppTypes.h:42
std::function< bool(const OBJ_LINK_T &)> VERIFY_OBJ_LINK_T
Definition: WppTypes.h:99
std::function< bool(const CORE_LINK_T &)> VERIFY_CORE_LINK_T
Definition: WppTypes.h:102
std::string STRING_T
Definition: WppTypes.h:45
INT_T TIME_T
Definition: WppTypes.h:44
std::function< bool(const UINT_T &)> VERIFY_UINT_T
Definition: WppTypes.h:95
std::vector< uint8_t > OPAQUE_T
Opaque - represent buffer or string as lwm2m_data_t.value.asBuffer.
Definition: WppTypes.h:49
std::function< bool(const FLOAT_T &)> VERIFY_FLOAT_T
Definition: WppTypes.h:96
TYPE_ID dataTypeToID()
Determining type ID by real type.
Definition: WppTypes.h:78
std::function< bool(const OPAQUE_T &)> VERIFY_OPAQUE_T
Definition: WppTypes.h:97
double FLOAT_T
Definition: WppTypes.h:43
IS_SINGLE
Definition: WppTypes.h:111
TYPE_ID
Wpp data types ID.
Definition: WppTypes.h:23
uint8_t major
Definition: WppTypes.h:123
uint8_t minor
Definition: WppTypes.h:124