InertiaSDK

Loading...
Searching...
No Matches
ServiceCommands.h
1#pragma once
2
3#include "data/command/InertiaCommand.h"
4#include "data/Sample.h"
5
6 namespace inertia
7{
8
10 enum ServiceCommands : uint8_t {
11 ServiceSetRTC = 1,
12 ServiceGetRTC,
13 ServiceGetUptime,
14 ServiceStoreConfig,
15 ServiceRestoreConfig,
16 ServiceSendEvent,
17 ServiceRadio,
18 ServiceStatus,
19 ServicePowerDown,
20 ServiceReboot,
21 ServiceSetOperatingMode,
22 ServiceGetOperatingMode,
23 ServiceGetOperatingModeLevels,
24 ServiceSetTimeZone,
25 ServiceStatusV2,
26 ServiceSendWOR,
27 ServiceLast
28};
29
30
31 enum ServiceOperatingMode : uint8_t {
32 ServiceOperatingModeActive = 0,
33 ServiceOperatingModeStandby = 1,
34 ServiceOperatingModeSleep = 2,
35 ServiceOperatingModeDeepSleep = 3,
36 ServiceOperatingModeTEDS = 4,
37};
38
39
40 struct INERTIA_API ServiceCommand
41 : InertiaCommand
42{
43 protected:
44 ServiceCommand();
45 ServiceCommand(const uint8_t* packet, const unsigned max_size);
46 ServiceCommand(std::wstring const& argString);
47
48 public:
49 InertiaCommandGroups GetGroup() const override;
50 static std::wstring GetName(ServiceCommands const command);
51
52 static InertiaCommandPtr Parse(const uint8_t* in, unsigned const packetSize);
53 static InertiaCommandPtr Parse(std::wstring const& argString);
54};
55
56
57 struct INERTIA_API RTCValue
58{
59 protected:
60 RTCValue();
61 RTCValue(const uint8_t* packet, const unsigned max_size);
62 RTCValue(std::wstring const& argString);
63
64 virtual void GetBytes(std::vector<uint8_t>& out) const;
65 const std::wstring ToString() const;
66
67#ifdef WITH_BOOST_PROGRAM_OPTIONS
68 static const po::options_description GetOptionDescription();
69#endif
70
71 public:
72 uint32_t timestamp;
73};
74
75
76 struct INERTIA_API ServiceSetRTCRequest
77 : ServiceCommand
78 , RTCValue
79{
80 ServiceSetRTCRequest();
81 ServiceSetRTCRequest(const uint8_t* packet, const unsigned max_size);
82 ServiceSetRTCRequest(std::wstring const& argString);
83
84 void GetBytes(std::vector<uint8_t>& out) const override;
85 const std::wstring ToString() const override;
86
87#ifdef WITH_BOOST_PROGRAM_OPTIONS
88 static const po::options_description GetOptionDescription();
89#endif
90
91 uint8_t GetType() const override;
92 bool IsResponse() const override;
93};
94
95
96 struct INERTIA_API ServiceSetRTCResponse
97 : ServiceCommand
98 , BoolValue
99{
100 ServiceSetRTCResponse(const uint8_t* packet, const unsigned max_size);
101 ServiceSetRTCResponse(std::wstring const& argString);
102
103 void GetBytes(std::vector<uint8_t>& out) const override;
104 const std::wstring ToString() const override;
105
106#ifdef WITH_BOOST_PROGRAM_OPTIONS
107 static const po::options_description GetOptionDescription();
108#endif
109
110 uint8_t GetType() const override;
111 bool IsResponse() const override;
112};
113
114
115 struct INERTIA_API ServiceGetRTCRequest
116 : ServiceCommand
117{
118 ServiceGetRTCRequest();
119 ServiceGetRTCRequest(const uint8_t* packet, const unsigned max_size);
120 ServiceGetRTCRequest(std::wstring const& argString);
121
122 void GetBytes(std::vector<uint8_t>& out) const override;
123 const std::wstring ToString() const override;
124
125#ifdef WITH_BOOST_PROGRAM_OPTIONS
126 static const po::options_description GetOptionDescription();
127#endif
128
129 uint8_t GetType() const override;
130 bool IsResponse() const override;
131};
132
133
134 struct INERTIA_API ServiceGetRTCResponse
135 : ServiceCommand
136 , RTCValue
137{
138 ServiceGetRTCResponse(const uint8_t* packet, const unsigned max_size);
139 ServiceGetRTCResponse(std::wstring const& argString);
140
141 void GetBytes(std::vector<uint8_t>& out) const override;
142 const std::wstring ToString() const override;
143
144#ifdef WITH_BOOST_PROGRAM_OPTIONS
145 static const po::options_description GetOptionDescription();
146#endif
147
148 uint8_t GetType() const override;
149 bool IsResponse() const override;
150};
151
152
153 struct INERTIA_API ServiceGetUptimeRequest
154 : ServiceCommand
155{
156 ServiceGetUptimeRequest();
157 ServiceGetUptimeRequest(const uint8_t* packet, const unsigned max_size);
158 ServiceGetUptimeRequest(std::wstring const& argString);
159
160 void GetBytes(std::vector<uint8_t>& out) const override;
161 const std::wstring ToString() const override;
162
163#ifdef WITH_BOOST_PROGRAM_OPTIONS
164 static const po::options_description GetOptionDescription();
165#endif
166
167 uint8_t GetType() const override;
168 bool IsResponse() const override;
169};
170
171
172 struct INERTIA_API ServiceGetUptimeResponse
173 : ServiceCommand
174 , RTCValue
175{
176 ServiceGetUptimeResponse(const uint8_t* packet, const unsigned max_size);
177 ServiceGetUptimeResponse(std::wstring const& argString);
178
179 void GetBytes(std::vector<uint8_t>& out) const override;
180 const std::wstring ToString() const override;
181
182#ifdef WITH_BOOST_PROGRAM_OPTIONS
183 static const po::options_description GetOptionDescription();
184#endif
185
186 uint8_t GetType() const override;
187 bool IsResponse() const override;
188};
189
190
191 struct INERTIA_API ServiceStoreConfigRequest
192 : ServiceCommand
193{
194 ServiceStoreConfigRequest();
195 ServiceStoreConfigRequest(const uint8_t* packet, const unsigned max_size);
196 ServiceStoreConfigRequest(std::wstring const& argString);
197
198 void GetBytes(std::vector<uint8_t>& out) const override;
199 const std::wstring ToString() const override;
200
201#ifdef WITH_BOOST_PROGRAM_OPTIONS
202 static const po::options_description GetOptionDescription();
203#endif
204
205 uint8_t GetType() const override;
206 bool IsResponse() const override;
207};
208
209
210 struct INERTIA_API ServiceStoreConfigResponse
211 : ServiceCommand
212 , BoolValue
213{
214 ServiceStoreConfigResponse(const uint8_t* packet, const unsigned max_size);
215 ServiceStoreConfigResponse(std::wstring const& argString);
216
217 void GetBytes(std::vector<uint8_t>& out) const override;
218 const std::wstring ToString() const override;
219
220#ifdef WITH_BOOST_PROGRAM_OPTIONS
221 static const po::options_description GetOptionDescription();
222#endif
223
224 uint8_t GetType() const override;
225 bool IsResponse() const override;
226};
227
228
229 struct INERTIA_API ServiceRestoreConfigRequest
230 : ServiceCommand
231{
232 ServiceRestoreConfigRequest();
233 ServiceRestoreConfigRequest(const uint8_t* packet, const unsigned max_size);
234 ServiceRestoreConfigRequest(std::wstring const& argString);
235
236 void GetBytes(std::vector<uint8_t>& out) const override;
237 const std::wstring ToString() const override;
238
239#ifdef WITH_BOOST_PROGRAM_OPTIONS
240 static const po::options_description GetOptionDescription();
241#endif
242
243 uint8_t GetType() const override;
244 bool IsResponse() const override;
245};
246
247
248 struct INERTIA_API ServiceRestoreConfigResponse
249 : ServiceCommand
250 , BoolValue
251{
252 ServiceRestoreConfigResponse(const uint8_t* packet, const unsigned max_size);
253 ServiceRestoreConfigResponse(std::wstring const& argString);
254
255 void GetBytes(std::vector<uint8_t>& out) const override;
256 const std::wstring ToString() const override;
257
258#ifdef WITH_BOOST_PROGRAM_OPTIONS
259 static const po::options_description GetOptionDescription();
260#endif
261
262 uint8_t GetType() const override;
263 bool IsResponse() const override;
264};
265
266
267 struct INERTIA_API ServiceSendEventRequest
268 : ServiceCommand
269{
270 uint8_t sampler, event;
271 int16_t param1, param2;
272
273 ServiceSendEventRequest();
274 ServiceSendEventRequest(const uint8_t* packet, const unsigned max_size);
275 ServiceSendEventRequest(std::wstring const& argString);
276
277 void GetBytes(std::vector<uint8_t>& out) const override;
278 const std::wstring ToString() const override;
279
280#ifdef WITH_BOOST_PROGRAM_OPTIONS
281 static const po::options_description GetOptionDescription();
282#endif
283
284 uint8_t GetType() const override;
285 bool IsResponse() const override;
286};
287
288
289 struct INERTIA_API ServiceSendEventResponse
290 : ServiceCommand
291 , BoolValue
292{
293 ServiceSendEventResponse(const uint8_t* packet, const unsigned max_size);
294 ServiceSendEventResponse(std::wstring const& argString);
295
296 void GetBytes(std::vector<uint8_t>& out) const override;
297 const std::wstring ToString() const override;
298
299#ifdef WITH_BOOST_PROGRAM_OPTIONS
300 static const po::options_description GetOptionDescription();
301#endif
302
303 uint8_t GetType() const override;
304 bool IsResponse() const override;
305};
306
307
308 struct INERTIA_API ServiceRadioRequest
309 : ServiceCommand
310{
311 uint8_t setting;
312
313 ServiceRadioRequest();
314 ServiceRadioRequest(const uint8_t* packet, const unsigned max_size);
315 ServiceRadioRequest(std::wstring const& argString);
316
317 void GetBytes(std::vector<uint8_t>& out) const override;
318 const std::wstring ToString() const override;
319
320#ifdef WITH_BOOST_PROGRAM_OPTIONS
321 static const po::options_description GetOptionDescription();
322#endif
323
324 uint8_t GetType() const override;
325 bool IsResponse() const override;
326};
327
328
329 struct INERTIA_API ServiceRadioResponse
330 : ServiceCommand
331 , BoolValue
332{
333 ServiceRadioResponse(const uint8_t* packet, const unsigned max_size);
334 ServiceRadioResponse(std::wstring const& argString);
335
336 void GetBytes(std::vector<uint8_t>& out) const override;
337 const std::wstring ToString() const override;
338
339#ifdef WITH_BOOST_PROGRAM_OPTIONS
340 static const po::options_description GetOptionDescription();
341#endif
342
343 uint8_t GetType() const override;
344 bool IsResponse() const override;
345};
346
347
348 struct INERTIA_API ServiceStatusRequest
349 : ServiceCommand
350{
351 private:
352 ServiceCommands type; // ServiceStatus, ServiceStatusV2
353
354 public:
355 ServiceStatusRequest(ServiceCommands const cmdType = ServiceStatus);
356 ServiceStatusRequest(const uint8_t* packet, const unsigned max_size, ServiceCommands const cmdType = ServiceStatus);
357 ServiceStatusRequest(std::wstring const& argString, ServiceCommands const cmdType = ServiceStatus);
358
359 void GetBytes(std::vector<uint8_t>& out) const override;
360 const std::wstring ToString() const override;
361
362#ifdef WITH_BOOST_PROGRAM_OPTIONS
363 static const po::options_description GetOptionDescription();
364#endif
365
366 uint8_t GetType() const override;
367 bool IsResponse() const override;
368};
369
370
371 struct INERTIA_API ServiceStatusResponse
372 : ServiceCommand
373{
374 private:
375 ServiceCommands type; // ServiceStatus, ServiceStatusV2
376
377 public:
378 std::map<StatusMeasurementID, StatusValue> status;
379
380 bool IsValid() const;
381
382 ServiceStatusResponse(const uint8_t* packet, const unsigned max_size, ServiceCommands const cmdType = ServiceStatus);
383 ServiceStatusResponse(std::wstring const& argString, ServiceCommands const cmdType = ServiceStatus);
384
385 void GetBytes(std::vector<uint8_t>& out) const override;
386 const std::wstring ToString() const override;
387
388#ifdef WITH_BOOST_PROGRAM_OPTIONS
389 static const po::options_description GetOptionDescription();
390#endif
391
392 uint8_t GetType() const override;
393 bool IsResponse() const override;
394};
395
396
397 struct INERTIA_API ServicePowerDownRequest
398 : ServiceCommand
399{
400 ServicePowerDownRequest();
401 ServicePowerDownRequest(const uint8_t* packet, const unsigned max_size);
402 ServicePowerDownRequest(std::wstring const& argString);
403
404 void GetBytes(std::vector<uint8_t>& out) const override;
405 const std::wstring ToString() const override;
406
407#ifdef WITH_BOOST_PROGRAM_OPTIONS
408 static const po::options_description GetOptionDescription();
409#endif
410
411 uint8_t GetType() const override;
412 bool IsResponse() const override;
413};
414
415
416 struct INERTIA_API ServicePowerDownResponse
417 : ServiceCommand
418 , BoolValue
419{
420 ServicePowerDownResponse(const uint8_t* packet, const unsigned max_size);
421 ServicePowerDownResponse(std::wstring const& argString);
422
423 void GetBytes(std::vector<uint8_t>& out) const override;
424 const std::wstring ToString() const override;
425
426#ifdef WITH_BOOST_PROGRAM_OPTIONS
427 static const po::options_description GetOptionDescription();
428#endif
429
430 uint8_t GetType() const override;
431 bool IsResponse() const override;
432};
433
434
435 struct INERTIA_API ServiceRebootRequest
436 : ServiceCommand
437{
438 ServiceRebootRequest();
439 ServiceRebootRequest(const uint8_t* packet, const unsigned max_size);
440 ServiceRebootRequest(std::wstring const& argString);
441
442 void GetBytes(std::vector<uint8_t>& out) const override;
443 const std::wstring ToString() const override;
444
445#ifdef WITH_BOOST_PROGRAM_OPTIONS
446 static const po::options_description GetOptionDescription();
447#endif
448
449 uint8_t GetType() const override;
450 bool IsResponse() const override;
451};
452
453
454 struct INERTIA_API ServiceRebootResponse
455 : ServiceCommand
456 , BoolValue
457{
458 ServiceRebootResponse(const uint8_t* packet, const unsigned max_size);
459 ServiceRebootResponse(std::wstring const& argString);
460
461 void GetBytes(std::vector<uint8_t>& out) const override;
462 const std::wstring ToString() const override;
463
464#ifdef WITH_BOOST_PROGRAM_OPTIONS
465 static const po::options_description GetOptionDescription();
466#endif
467
468 uint8_t GetType() const override;
469 bool IsResponse() const override;
470};
471
472
473 struct INERTIA_API ServiceSetOperatingModeRequest
474 : ServiceCommand
475{
476 ServiceOperatingMode operatingMode;
477
478 ServiceSetOperatingModeRequest(ServiceOperatingMode const& operatingMode = ServiceOperatingModeActive);
479 ServiceSetOperatingModeRequest(const uint8_t* packet, const unsigned max_size);
480 ServiceSetOperatingModeRequest(std::wstring const& argString);
481
482 void GetBytes(std::vector<uint8_t>& out) const override;
483 const std::wstring ToString() const override;
484
485#ifdef WITH_BOOST_PROGRAM_OPTIONS
486 static const po::options_description GetOptionDescription();
487#endif
488
489 uint8_t GetType() const override;
490 bool IsResponse() const override;
491};
492
493
494 struct INERTIA_API ServiceSetOperatingModeResponse
495 : ServiceCommand
496 , BoolValue
497{
498 ServiceSetOperatingModeResponse(const uint8_t* packet, const unsigned max_size);
499 ServiceSetOperatingModeResponse(std::wstring const& argString);
500
501 void GetBytes(std::vector<uint8_t>& out) const override;
502 const std::wstring ToString() const override;
503
504#ifdef WITH_BOOST_PROGRAM_OPTIONS
505 static const po::options_description GetOptionDescription();
506#endif
507
508 uint8_t GetType() const override;
509 bool IsResponse() const override;
510};
511
512
513 struct INERTIA_API ServiceGetOperatingModeRequest
514 : ServiceCommand
515{
516 ServiceGetOperatingModeRequest();
517 ServiceGetOperatingModeRequest(const uint8_t* packet, const unsigned max_size);
518 ServiceGetOperatingModeRequest(std::wstring const& argString);
519
520 void GetBytes(std::vector<uint8_t>& out) const override;
521 const std::wstring ToString() const override;
522
523#ifdef WITH_BOOST_PROGRAM_OPTIONS
524 static const po::options_description GetOptionDescription();
525#endif
526
527 uint8_t GetType() const override;
528 bool IsResponse() const override;
529};
530
531
532 struct INERTIA_API ServiceGetOperatingModeResponse
533 : ServiceCommand
534{
535 ServiceOperatingMode operatingMode;
536
537 ServiceGetOperatingModeResponse(const uint8_t* packet, const unsigned max_size);
538 ServiceGetOperatingModeResponse(std::wstring const& argString);
539
540 void GetBytes(std::vector<uint8_t>& out) const override;
541 const std::wstring ToString() const override;
542
543#ifdef WITH_BOOST_PROGRAM_OPTIONS
544 static const po::options_description GetOptionDescription();
545#endif
546
547 uint8_t GetType() const override;
548 bool IsResponse() const override;
549};
550
551
552 struct INERTIA_API ServiceGetOperatingModeLevelsRequest
553 : ServiceCommand
554{
555 ServiceGetOperatingModeLevelsRequest();
556 ServiceGetOperatingModeLevelsRequest(const uint8_t* packet, const unsigned max_size);
557 ServiceGetOperatingModeLevelsRequest(std::wstring const& argString);
558
559 void GetBytes(std::vector<uint8_t>& out) const override;
560 const std::wstring ToString() const override;
561
562#ifdef WITH_BOOST_PROGRAM_OPTIONS
563 static const po::options_description GetOptionDescription();
564#endif
565
566 uint8_t GetType() const override;
567 bool IsResponse() const override;
568};
569
570
571 struct INERTIA_API ServiceGetOperatingModeLevelsResponse
572 : ServiceCommand
573{
574 std::vector<ServiceOperatingMode> operatingModes;
575
576 ServiceGetOperatingModeLevelsResponse(const uint8_t* packet, const unsigned max_size);
577 ServiceGetOperatingModeLevelsResponse(std::wstring const& argString);
578
579 void GetBytes(std::vector<uint8_t>& out) const override;
580 const std::wstring ToString() const override;
581
582#ifdef WITH_BOOST_PROGRAM_OPTIONS
583 static const po::options_description GetOptionDescription();
584#endif
585
586 uint8_t GetType() const override;
587 bool IsResponse() const override;
588};
589
590
591 struct INERTIA_API ServiceSetTimeZoneRequest
592 : ServiceCommand
593{
594 std::wstring timezone;
595
596 ServiceSetTimeZoneRequest();
597 ServiceSetTimeZoneRequest(const uint8_t* packet, const unsigned max_size);
598 ServiceSetTimeZoneRequest(std::wstring const& argString);
599
600 void GetBytes(std::vector<uint8_t>& out) const override;
601 const std::wstring ToString() const override;
602
603#ifdef WITH_BOOST_PROGRAM_OPTIONS
604 static const po::options_description GetOptionDescription();
605#endif
606
607 uint8_t GetType() const override;
608 bool IsResponse() const override;
609};
610
611
612 struct INERTIA_API ServiceSetTimeZoneResponse
613 : ServiceCommand
614 , BoolValue
615{
616 ServiceSetTimeZoneResponse(const uint8_t* packet, const unsigned max_size);
617 ServiceSetTimeZoneResponse(std::wstring const& argString);
618
619 void GetBytes(std::vector<uint8_t>& out) const override;
620 const std::wstring ToString() const override;
621
622#ifdef WITH_BOOST_PROGRAM_OPTIONS
623 static const po::options_description GetOptionDescription();
624#endif
625
626 uint8_t GetType() const override;
627 bool IsResponse() const override;
628};
629
630
631 struct INERTIA_API ServiceWakeOnRadioRequest
632 : ServiceCommand
633{
634 uint8_t slot;
635
636 ServiceWakeOnRadioRequest();
637 ServiceWakeOnRadioRequest(const uint8_t* packet, const unsigned max_size);
638 ServiceWakeOnRadioRequest(std::wstring const& argString);
639
640 void GetBytes(std::vector<uint8_t>& out) const override;
641 const std::wstring ToString() const override;
642
643#ifdef WITH_BOOST_PROGRAM_OPTIONS
644 static const po::options_description GetOptionDescription();
645#endif
646
647 uint8_t GetType() const override;
648 bool IsResponse() const override;
649};
650
651
652 struct INERTIA_API ServiceWakeOnRadioResponse
653 : ServiceCommand
654 , BoolValue
655{
656 ServiceWakeOnRadioResponse(const uint8_t* packet, const unsigned max_size);
657 ServiceWakeOnRadioResponse(std::wstring const& argString);
658
659 void GetBytes(std::vector<uint8_t>& out) const override;
660 const std::wstring ToString() const override;
661
662#ifdef WITH_BOOST_PROGRAM_OPTIONS
663 static const po::options_description GetOptionDescription();
664#endif
665
666 uint8_t GetType() const override;
667 bool IsResponse() const override;
668};
669
670}
inertia
Definition FlashCommands.h:6
inertia::ServiceCommands
ServiceCommands
Definition ServiceCommands.h:10
inertia::InertiaCommandPtr
std::shared_ptr< InertiaCommand > InertiaCommandPtr
Pointer to an InertiaCommand.
Definition platform.h:52
inertia::ServiceRadio
ServiceRadio
Definition InertiaService.h:104
inertia::InertiaCommandGroups
InertiaCommandGroups
Definition InertiaCommand.h:7