@@ -50,6 +50,35 @@ SCENARIO("Test the decoding of command messages") {
50
50
}
51
51
52
52
/* ***************************************************************************/
53
+ WHEN (" Decode the ThingDetachCmd message" )
54
+ {
55
+ CommandDown command;
56
+ /*
57
+ DA 00011000 # tag(69632)
58
+ 81 # array(1)
59
+ 78 24 # text(36)
60
+ 65343439346435352D383732612D346664322D393634362D393266383739343933393463 # "e4494d55-872a-4fd2-9646-92f87949394c"
61
+ */
62
+ uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x10 , 0x00 , 0x81 , 0x78 , 0x24 ,
63
+ 0x65 , 0x34 , 0x34 , 0x39 , 0x34 , 0x64 , 0x35 , 0x35 ,
64
+ 0x2D , 0x38 , 0x37 , 0x32 , 0x61 , 0x2D , 0x34 , 0x66 ,
65
+ 0x64 , 0x32 , 0x2D , 0x39 , 0x36 , 0x34 , 0x36 , 0x2D ,
66
+ 0x39 , 0x32 , 0x66 , 0x38 , 0x37 , 0x39 , 0x34 , 0x39 ,
67
+ 0x33 , 0x39 , 0x34 , 0x63 };
68
+
69
+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
70
+ CBORMessageDecoder decoder;
71
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
72
+ const char *thingIdToMatch = " e4494d55-872a-4fd2-9646-92f87949394c" ;
73
+
74
+ THEN (" The decode is successful" ) {
75
+ REQUIRE (err == Decoder::Status::Complete);
76
+ REQUIRE (strcmp (command.thingDetachCmd .params .thing_id , thingIdToMatch) == 0 );
77
+ REQUIRE (command.c .id == ThingDetachCmdId);
78
+ }
79
+ }
80
+
81
+ /* ***********************************************************************************/
53
82
54
83
WHEN (" Decode the ThingUpdateCmdId message containing a number instead of a string" )
55
84
{
@@ -71,9 +100,30 @@ SCENARIO("Test the decoding of command messages") {
71
100
}
72
101
}
73
102
103
+ /* ***************************************************************************/
104
+ WHEN (" Decode the ThingDetachCmd message containing a number instead of a string" )
105
+ {
106
+ CommandDown command;
107
+ /*
108
+ DA 00011000 # tag(69632)
109
+ 81 # array(1)
110
+ 1A 65DCB821 # unsigned(1708963873)
111
+ */
112
+ uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x10 , 0x00 , 0x81 , 0x1A , 0x65 ,
113
+ 0xDC , 0xB8 , 0x21 };
114
+
115
+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
116
+ CBORMessageDecoder decoder;
117
+ Decoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
118
+
119
+ THEN (" The decode is successful" ) {
120
+ REQUIRE (err == Decoder::Status::Error);
121
+ }
122
+ }
123
+
74
124
/* ***************************************************************************/
75
125
76
- WHEN (" Decode the SetTimezoneCommand message" )
126
+ WHEN (" Decode the TimezoneCommandDown message" )
77
127
{
78
128
CommandDown command;
79
129
0 commit comments