@@ -152,6 +152,124 @@ SCENARIO("Test the decoding of command messages") {
152152 }
153153 }
154154
155+ WHEN (" Decode the TimezoneCommandDown message, but until is not present" )
156+ {
157+ CommandDown command;
158+
159+ /*
160+ DA 00010764 # tag(67840)
161+ 81 # array(1)
162+ 1A 65DCB821 # unsigned(1708963873)
163+ */
164+
165+ uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x09 , 0x00 , 0x81 , 0x1A , 0x65 ,
166+ 0xDC , 0xB8 , 0x21 };
167+
168+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
169+ CBORMessageDecoder decoder;
170+ MessageDecoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
171+
172+ THEN (" The decode is unsuccessful" ) {
173+ REQUIRE (err == MessageDecoder::Status::Error);
174+ }
175+ }
176+
177+ WHEN (" Decode the TimezoneCommandDown message, but offset is incorrectly encoded" )
178+ {
179+ CommandDown command;
180+
181+ /*
182+ DA 00010764 # tag(67840)
183+ 81 # array(1)
184+ 1A 65DC # unsigned(26076)
185+ */
186+
187+ uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x09 , 0x00 , 0x81 , 0x1A ,};
188+
189+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
190+ CBORMessageDecoder decoder;
191+ MessageDecoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
192+
193+ THEN (" The decode is unsuccessful" ) {
194+ REQUIRE (err == MessageDecoder::Status::Error);
195+ }
196+ }
197+
198+ WHEN (" Decode the TimezoneCommandDown message, but offset is a byte array instead of an integer" )
199+ {
200+ CommandDown command;
201+
202+ /*
203+ DA 00010764 # tag(67840)
204+ 81 # array(2)
205+ 4D # bytes(13)
206+ 00010203040506070809101112 # "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\u0010\u0011\u0012"
207+ 1A 65DCB821 # unsigned(1708963873)
208+ */
209+
210+ uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x09 , 0x00 , 0x81 , 0x21 , 0x4D ,
211+ 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 ,
212+ 0x08 , 0x09 , 0x10 , 0x11 , 0x12 , 0x1A , 0x65 , 0xDC ,
213+ 0xB8 ,};
214+
215+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
216+ CBORMessageDecoder decoder;
217+ MessageDecoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
218+
219+ THEN (" The decode is unsuccessful" ) {
220+ REQUIRE (err == MessageDecoder::Status::Error);
221+ }
222+ }
223+
224+ WHEN (" Decode the TimezoneCommandDown message, but until is a byte array instead of an integer" )
225+ {
226+ CommandDown command;
227+
228+ /*
229+ DA 00010764 # tag(67840)
230+ 82 # array(2)
231+ 1A 65DCB821 # unsigned(1708963873)
232+ 4D # bytes(13)
233+ 00010203040506070809101112 # "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\u0010\u0011\u0012"
234+ */
235+
236+ uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x09 , 0x00 , 0x82 , 0x1A , 0x65 ,
237+ 0xDC , 0xB8 , 0x21 , 0x4D , 0x00 , 0x01 , 0x02 , 0x03 ,
238+ 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x10 , 0x11 ,
239+ 0x12 };
240+
241+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
242+ CBORMessageDecoder decoder;
243+ MessageDecoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
244+
245+ THEN (" The decode is unsuccessful" ) {
246+ REQUIRE (err == MessageDecoder::Status::Error);
247+ }
248+ }
249+
250+ WHEN (" Decode the TimezoneCommandDown message, but until is incorrectly encoded" )
251+ {
252+ CommandDown command;
253+
254+ /*
255+ DA 00010764 # tag(67840)
256+ 82 # array(2)
257+ 1A 65DCB821 # unsigned(1708963873)
258+ 1A 78AC # unsigned(30892)
259+ */
260+
261+ uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x09 , 0x00 , 0x82 , 0x1A , 0x65 ,
262+ 0xDC , 0xB8 , 0x21 , 0x1A , 0x78 , 0xAC };
263+
264+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
265+ CBORMessageDecoder decoder;
266+ MessageDecoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
267+
268+ THEN (" The decode is unsuccessful" ) {
269+ REQUIRE (err == MessageDecoder::Status::Error);
270+ }
271+ }
272+
155273 /* ***************************************************************************/
156274
157275 WHEN (" Decode the LastValuesUpdateCmd message" )
@@ -190,6 +308,29 @@ SCENARIO("Test the decoding of command messages") {
190308 free (command.lastValuesUpdateCmd .params .last_values );
191309 }
192310
311+ WHEN (" Decode the LastValuesUpdateCmd message, but lastvalues is an integer" )
312+ {
313+ CommandDown command;
314+
315+ /*
316+ DA 00010600 # tag(67072)
317+ 81 # array(1)
318+ 1A 65DCB821 # unsigned(1708963873)
319+
320+ */
321+
322+ uint8_t const payload[] = {0xDA , 0x00 , 0x01 , 0x06 , 0x00 , 0x81 , 0x1A , 0x65 ,
323+ 0xDC , 0xB8 , 0x21 };
324+
325+ size_t payload_length = sizeof (payload) / sizeof (uint8_t );
326+ CBORMessageDecoder decoder;
327+ MessageDecoder::Status err = decoder.decode ((Message*)&command, payload, payload_length);
328+
329+ THEN (" The decode is unsuccessful" ) {
330+ REQUIRE (err == MessageDecoder::Status::Error);
331+ }
332+ }
333+
193334 /* ***************************************************************************/
194335
195336 WHEN (" Decode the OtaUpdateCmdDown message" )
0 commit comments