|
12 | 12 | #include <Encoder.h>
|
13 | 13 | #include <cbor/MessageEncoder.h>
|
14 | 14 | #include "../../src/ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor/CBOR.h"
|
| 15 | + #include "../../src/ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor/CBORInstances.h" |
15 | 16 |
|
16 | 17 | /******************************************************************************
|
17 | 18 | TEST CODE
|
|
233 | 234 | REQUIRE(memcmp(buffer, expected_result, sizeof(expected_result)) == 0);
|
234 | 235 | }
|
235 | 236 | }
|
| 237 | + |
| 238 | + WHEN("Encode a message with provisioning sketch version ") |
| 239 | + { |
| 240 | + ProvSketchVersionProvisioningMessage command; |
| 241 | + command.c.id = ProvisioningMessageId::ProvSketchVersionProvisioningMessageId; |
| 242 | + command.provSketchVersion = "1.6.0"; |
| 243 | + uint8_t buffer[512]; |
| 244 | + size_t bytes_encoded = sizeof(buffer); |
| 245 | + |
| 246 | + CBORMessageEncoder encoder; |
| 247 | + MessageEncoder::Status err = encoder.encode((Message*)&command, buffer, bytes_encoded); |
| 248 | + |
| 249 | + uint8_t expected_result[] = { |
| 250 | + 0xda, 0x00, 0x01, 0x20, 0x15, 0x81, 0x65, 0x31, 0x2E, 0x36, 0x2E, 0x30 |
| 251 | + }; |
| 252 | + |
| 253 | + // Test the encoding is |
| 254 | + // DA 00012015 # tag(73749) |
| 255 | + // 81 # array(1) |
| 256 | + // 65 # text(5) |
| 257 | + // 312E362E30 # "1.6.0" |
| 258 | + THEN("The encoding is successful") { |
| 259 | + REQUIRE(err == MessageEncoder::Status::Complete); |
| 260 | + REQUIRE(bytes_encoded == sizeof(expected_result)); |
| 261 | + REQUIRE(memcmp(buffer, expected_result, sizeof(expected_result)) == 0); |
| 262 | + } |
| 263 | + } |
| 264 | + |
| 265 | + WHEN("Encode a message with provisioning Network Configurator lib version ") |
| 266 | + { |
| 267 | + NetConfigLibVersionProvisioningMessage command; |
| 268 | + command.c.id = ProvisioningMessageId::NetConfigLibVersProvisioningMessageId; |
| 269 | + command.netConfigLibVersion = "1.6.0"; |
| 270 | + uint8_t buffer[512]; |
| 271 | + size_t bytes_encoded = sizeof(buffer); |
| 272 | + |
| 273 | + CBORMessageEncoder encoder; |
| 274 | + MessageEncoder::Status err = encoder.encode((Message*)&command, buffer, bytes_encoded); |
| 275 | + |
| 276 | + uint8_t expected_result[] = { |
| 277 | + 0xda, 0x00, 0x01, 0x20, 0x16, 0x81, 0x65, 0x31, 0x2E, 0x36, 0x2E, 0x30 |
| 278 | + }; |
| 279 | + |
| 280 | + // Test the encoding is |
| 281 | + // DA 00012016 # tag(73750) |
| 282 | + // 81 # array(1) |
| 283 | + // 65 # text(5) |
| 284 | + // 312E362E30 # "1.6.0" |
| 285 | + printf("res %d\n", (int)err); |
| 286 | + THEN("The encoding is successful") { |
| 287 | + REQUIRE(err == MessageEncoder::Status::Complete); |
| 288 | + REQUIRE(bytes_encoded == sizeof(expected_result)); |
| 289 | + REQUIRE(memcmp(buffer, expected_result, sizeof(expected_result)) == 0); |
| 290 | + } |
| 291 | + } |
236 | 292 | }
|
0 commit comments