Friendly LWM2M client
Device.h
Go to the documentation of this file.
1 /*
2  * Device
3  * Generated on: 2023-11-02 16:38:01
4  * Created by: Sinai RnD
5  */
6 
7 #ifndef WPP_M_3_DEVICE_H
8 #define WPP_M_3_DEVICE_H
9 
10 #include "DeviceConfig.h"
11 #include "DeviceInfo.h"
12 #include "Instance.h"
13 #include "InstSubject.h"
14 
15 /* --------------- Сode_h block 0 start --------------- */
16 #include "WppTaskQueue.h"
17 #include "WppBindings.h"
18 /* --------------- Сode_h block 0 end --------------- */
19 
20 namespace wpp {
21 
22 class WppClient;
23 class Object;
24 
25 /* --------------- Сode_h block 1 start --------------- */
26 /* --------------- Сode_h block 1 end --------------- */
27 
28 class Device : public Instance {
29 public:
30  enum ID: ID_T {
31  #if RES_3_0
33  #endif
34  #if RES_3_1
36  #endif
37  #if RES_3_2
39  #endif
40  #if RES_3_3
42  #endif
43  REBOOT_4 = 4,
44  #if RES_3_5
45  FACTORY_RESET_5 = 5,
46  #endif
47  #if RES_3_6
48  AVAILABLE_POWER_SOURCES_6 = 6,
49  #endif
50  #if RES_3_7
51  POWER_SOURCE_VOLTAGE_7 = 7,
52  #endif
53  #if RES_3_8
54  POWER_SOURCE_CURRENT_8 = 8,
55  #endif
56  #if RES_3_9
57  BATTERY_LEVEL_9 = 9,
58  #endif
59  #if RES_3_10
60  MEMORY_FREE_10 = 10,
61  #endif
63  #if RES_3_12
64  RESET_ERROR_CODE_12 = 12,
65  #endif
66  #if RES_3_13
68  #endif
69  #if RES_3_14
70  UTC_OFFSET_14 = 14,
71  #endif
72  #if RES_3_15
73  TIMEZONE_15 = 15,
74  #endif
76  #if RES_3_17
77  DEVICE_TYPE_17 = 17,
78  #endif
79  #if RES_3_18
80  HARDWARE_VERSION_18 = 18,
81  #endif
82  #if RES_3_19
83  SOFTWARE_VERSION_19 = 19,
84  #endif
85  #if RES_3_20
86  BATTERY_STATUS_20 = 20,
87  #endif
88  #if RES_3_21
89  MEMORY_TOTAL_21 = 21,
90  #endif
91  #if RES_3_22
92  EXTDEVINFO_22 = 22,
93  #endif
94  };
95 
96  /* --------------- Code_h block 2 start --------------- */
97  #if RES_3_6
98  enum PwrSrcs: uint8_t {
99  DC = 0,
100  INTERN_BAT = 1,
101  EXTERN_BAT = 2,
102  FUEL_CELL = 3,
103  PWR_OVER_ETHERNET = 4,
104  USB = 5,
105  AC = 6,
106  SOLAR = 7,
107  PWR_SRC_MAX
108  };
109  #endif
110 
111  enum ErrCode: uint8_t {
112  NO_ERROR = 0,
113  LOW_BAT = 1,
115  GPS_FAIL = 3,
118  SMS_FAIL = 6,
122  };
123 
124  #if RES_3_20
125  enum BatStatus {
126  NORMAL = 0,
127  CHARGING = 1,
128  CHARGED = 2,
129  DAMAGED = 3,
130  LOW_BATTERY = 4,
131  NOT_INSTALLED = 5,
132  UNKNOWN = 6,
133  BAT_STATUS_MAX
134  };
135  #endif
136  /* --------------- Code_h block 2 end --------------- */
137 
138 public:
139  Device(lwm2m_context_t &context, const OBJ_LINK_T &id);
140  ~Device();
141 
142  /* --------------- Helpful methods --------------- */
148  static Object & object(WppClient &ctx);
149 
156  static Device * instance(WppClient &ctx, ID_T instId = ID_T_MAX_VAL);
157 
164  static Device * createInst(WppClient &ctx, ID_T instId = ID_T_MAX_VAL);
165 
172  static bool removeInst(WppClient &ctx, ID_T instId);
173 
174  /* --------------- Code_h block 3 start --------------- */
175  /* --------------- Code_h block 3 end --------------- */
176 
177 protected:
178  /* --------------- Instance implementation part --------------- */
179  /*
180  * Handles information about resource operation that made server
181  */
182  void serverOperationNotifier(Instance *securityInst, ItemOp::TYPE type, const ResLink &resLink) override;
183  /*
184  * Handles information about resource operation that made user
185  */
186  void userOperationNotifier(ItemOp::TYPE type, const ResLink &resLink) override;
187 
188  /* --------------- Code_h block 4 start --------------- */
189  /* --------------- Code_h block 4 end --------------- */
190 
191 private:
192  /* --------------- Class private methods --------------- */
193  /*
194  * Creates resources without initializing.
195  */
196  void resourcesCreate();
197  /*
198  * Initialize resources with default values
199  * SINGLE resource always must have at least one instance.
200  */
201  void resourcesInit();
202 
203  /* --------------- Code_h block 5 start --------------- */
204  /* --------------- Code_h block 5 end --------------- */
205 
206 private:
207  /* --------------- Class private properties --------------- */
208  /* --------------- Code_h block 6 start --------------- */
209  #if RES_3_13
210  WppTaskQueue::task_id_t _currentTimeTaskId;
211  #endif
212  /* --------------- Code_h block 6 end --------------- */
213 };
214 
215 } /* namespace wpp */
216 
217 #endif /* WPP_M_3_DEVICE_H */
#define ID_T_MAX_VAL
Definition: WppTypes.h:16
static Device * instance(WppClient &ctx, ID_T instId=ID_T_MAX_VAL)
Gets an instance of the object.
Definition: Device.cpp:53
static bool removeInst(WppClient &ctx, ID_T instId)
Removes an instance of the object.
Definition: Device.cpp:65
void userOperationNotifier(ItemOp::TYPE type, const ResLink &resLink) override
This method must be implemented by the derived class, and handle information about resource operation...
Definition: Device.cpp:79
void serverOperationNotifier(Instance *securityInst, ItemOp::TYPE type, const ResLink &resLink) override
This method must be implemented by the derived class, and handle information about resource operation...
Definition: Device.cpp:69
@ SUPPORTED_BINDING_AND_MODES_16
Definition: Device.h:75
@ CURRENT_TIME_13
Definition: Device.h:67
@ SERIAL_NUMBER_2
Definition: Device.h:38
@ MODEL_NUMBER_1
Definition: Device.h:35
@ REBOOT_4
Definition: Device.h:43
@ MANUFACTURER_0
Definition: Device.h:32
@ ERROR_CODE_11
Definition: Device.h:62
@ FIRMWARE_VERSION_3
Definition: Device.h:41
static Object & object(WppClient &ctx)
Gets the Object reference.
Definition: Device.cpp:49
@ PERIPH_FAIL
Definition: Device.h:120
@ LOW_SIG_STRENGTH
Definition: Device.h:116
@ NO_ERROR
Definition: Device.h:112
@ ERR_CODE_MAX
Definition: Device.h:121
@ SMS_FAIL
Definition: Device.h:118
@ OUT_OF_MEM
Definition: Device.h:117
@ EXT_PWR_SUPP_OFF
Definition: Device.h:114
@ IP_CONN_FAIL
Definition: Device.h:119
@ GPS_FAIL
Definition: Device.h:115
static Device * createInst(WppClient &ctx, ID_T instId=ID_T_MAX_VAL)
Creates an instance of the object.
Definition: Device.cpp:59
Device(lwm2m_context_t &context, const OBJ_LINK_T &id)
Definition: Device.cpp:26
Instance is interface class that implements manipulation with derived class resources....
Definition: Instance.h:40
Instance(lwm2m_context_t &context, const OBJ_LINK_T &id)
Definition: Instance.h:42
uint32_t task_id_t
Definition: WppTaskQueue.h:52
The WppConnection class represents a connection interface for the Wpp library.
Definition: WppClient.cpp:14
uint16_t ID_T
Definition: WppTypes.h:15
TYPE
Enum representing the different types of operations.
Definition: ItemOp.h:29