@@ -26,8 +26,8 @@ SCENARIO("Test the decoding of command messages") {
26
26
CommandDown command;
27
27
/*
28
28
DA 00010400 # tag(66560)
29
- 81 # array(1)
30
- 78 24 # text(36)
29
+ 81 # array(1)
30
+ 78 24 # text(36)
31
31
65343439346435352D383732612D346664322D393634362D393266383739343933393463 # "e4494d55-872a-4fd2-9646-92f87949394c"
32
32
*/
33
33
uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x04 , 0x00 , 0x81 , 0x78 , 0x24 ,
@@ -38,7 +38,7 @@ SCENARIO("Test the decoding of command messages") {
38
38
0x33 , 0x39 , 0x34 , 0x63 };
39
39
size_t payload_length = sizeof (payload) / sizeof (uint8_t );
40
40
CBORMessageDecoder decoder;
41
- Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
41
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
42
42
const char *thingIdToMatch = " e4494d55-872a-4fd2-9646-92f87949394c" ;
43
43
44
44
THEN (" The decode is successful" ) {
@@ -56,7 +56,7 @@ SCENARIO("Test the decoding of command messages") {
56
56
57
57
/*
58
58
DA 00010764 # tag(67840)
59
- 82 # array(2)
59
+ 82 # array(2)
60
60
1A 65DCB821 # unsigned(1708963873)
61
61
1A 78ACA191 # unsigned(2024579473)
62
62
*/
@@ -83,9 +83,9 @@ SCENARIO("Test the decoding of command messages") {
83
83
CommandDown command;
84
84
85
85
/*
86
- DA 00010600 # tag(67072)
86
+ DA 00010600 # tag(67072)
87
87
81 # array(1)
88
- 4D # bytes(13)
88
+ 4D # bytes(13)
89
89
00010203040506070809101112 # "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\u0010\u0011\u0012"
90
90
91
91
*/
@@ -256,4 +256,145 @@ SCENARIO("Test the decoding of command messages") {
256
256
REQUIRE (command.c .id == OtaUpdateCmdDownId);
257
257
}
258
258
}
259
+
260
+ /* ***************************************************************************/
261
+
262
+ WHEN (" Decode the OtaBeginUp message" )
263
+ {
264
+ CommandDown command;
265
+ /*
266
+ DA 00010000 # tag(65536)
267
+ 81 # array(1)
268
+ 58 20 # bytes(32)
269
+ 01020304
270
+ */
271
+ uint8_t const payload[] = {0xda , 0x00 , 0x01 , 0x00 , 0x00 , 0x81 , 0x58 , 0x20 ,
272
+ 0x01 , 0x02 , 0x03 , 0x04 , 0x00 , 0x00 , 0x00 , 0x00 ,
273
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
274
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
275
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
276
+
277
+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
278
+ CBORMessageDecoder decoder;
279
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
280
+
281
+ THEN (" The decode is unsuccessful - OtaBeginUp is not supported" ) {
282
+ REQUIRE (err == Decoder::Status::Error);
283
+ }
284
+ }
285
+
286
+ /* ***************************************************************************/
287
+
288
+ WHEN (" Decode the ThingBeginCmd message" )
289
+ {
290
+ CommandDown command;
291
+ /*
292
+ DA 00010300 # tag(66304)
293
+ 81 # array(1)
294
+ 68 # text(8)
295
+ 7468696E675F6964 # "thing_id"
296
+ */
297
+ uint8_t const payload[] = {0xda , 0x00 , 0x01 , 0x03 , 0x00 , 0x81 , 0x68 , 0x74 ,
298
+ 0x68 , 0x69 , 0x6e , 0x67 , 0x5f , 0x69 , 0x64 };
299
+
300
+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
301
+ CBORMessageDecoder decoder;
302
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
303
+
304
+ THEN (" The decode is unsuccessful - ThingBeginCmd is not supported" ) {
305
+ REQUIRE (err == Decoder::Status::Error);
306
+ }
307
+ }
308
+
309
+ /* ***************************************************************************/
310
+
311
+ WHEN (" Decode the LastValuesBeginCmd message" )
312
+ {
313
+ CommandDown command;
314
+ /*
315
+ DA 00010500 # tag(66816)
316
+ 80 # array(0)
317
+ */
318
+ uint8_t const payload[] = {0xda , 0x00 , 0x01 , 0x05 , 0x00 , 0x80 };
319
+
320
+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
321
+ CBORMessageDecoder decoder;
322
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
323
+
324
+ THEN (" The decode is unsuccessful - LastValuesBeginCmd is not supported" ) {
325
+ REQUIRE (err == Decoder::Status::Error);
326
+ }
327
+ }
328
+
329
+ /* ***************************************************************************/
330
+
331
+ WHEN (" Decode the DeviceBeginCmd message" )
332
+ {
333
+ CommandDown command;
334
+ /*
335
+ DA 00010700 # tag(67328)
336
+ 81 # array(1)
337
+ 65 # text(5)
338
+ 322E302E30 # "2.0.0"
339
+ */
340
+ uint8_t const payload[] = {0xda , 0x00 , 0x01 , 0x07 , 0x00 , 0x81 , 0x65 , 0x32 ,
341
+ 0x2e , 0x30 , 0x2e , 0x30 };
342
+
343
+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
344
+ CBORMessageDecoder decoder;
345
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
346
+
347
+ THEN (" The decode is unsuccessful - DeviceBeginCmd is not supported" ) {
348
+ REQUIRE (err == Decoder::Status::Error);
349
+ }
350
+ }
351
+
352
+ /* ***************************************************************************/
353
+
354
+ WHEN (" Decode the OtaProgressCmdUp message" )
355
+ {
356
+ CommandDown command;
357
+ /*
358
+ DA 00010200 # tag(66048)
359
+ 84 # array(4)
360
+ 50 # bytes(16)
361
+ 000102030405060708090A0B0C0D0E0F # "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f"
362
+ E1 # primitive(1)
363
+ 20 # negative(0)
364
+ 18 64 # unsigned(100)
365
+ */
366
+ uint8_t const payload[] = {0xda , 0x00 , 0x01 , 0x02 , 0x00 , 0x84 , 0x50 , 0x00 ,
367
+ 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 ,
368
+ 0x09 , 0x0a , 0x0b , 0x0c , 0x0d , 0x0e , 0x0f , 0xe1 ,
369
+ 0x20 , 0x18 , 0x64 };
370
+
371
+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
372
+ CBORMessageDecoder decoder;
373
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
374
+
375
+ THEN (" The decode is unsuccessful - OtaProgressCmdUp is not supported" ) {
376
+ REQUIRE (err == Decoder::Status::Error);
377
+ }
378
+ }
379
+
380
+ /* ***************************************************************************/
381
+
382
+ WHEN (" Decode the TimezoneCommandUp message" )
383
+ {
384
+ CommandDown command;
385
+ /*
386
+ DA 00010800 # tag(67584)
387
+ 80 # array(0)
388
+ */
389
+ uint8_t const payload[] = {0xda , 0x00 , 0x01 , 0x08 , 0x00 , 0x80 };
390
+
391
+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
392
+ CBORMessageDecoder decoder;
393
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
394
+
395
+ THEN (" The decode is unsuccessful - TimezoneCommandUp is not supported" ) {
396
+ REQUIRE (err == Decoder::Status::Error);
397
+ }
398
+ }
399
+
259
400
}
0 commit comments