This question relates to using zcbor.
Basically I have the following.
void smp_req_image_state() { uint8_t payload[128]; ZCBOR_STATE_E(encoding_state, 0, payload, sizeof(payload), 0); // int err; bool r = true; smp_frm_t smp_msg = {0}; smp_msg.hdr.smp_cmd_id = GRP_IMG_STATE; smp_msg.hdr.smp_grp = ntohs(MGMT_GRP_ID_IMAGE); smp_msg.hdr.smp_op = SMP_OP_RD; smp_msg.hdr.smp_seq = 1; // because...why not. r = r && zcbor_map_start_encode(encoding_state, 1); r = r && zcbor_map_end_encode(encoding_state, 1); // smp_msg.hdr.smp_len = ntohs(512); smp_msg.hdr.smp_len = ntohs(encoding_state->payload - payload); uint8_t encoded_lenth = encoding_state->payload - payload; printf("Encoded length is %i\n", encoded_lenth); smp_msg.data = malloc(/*sizeof(uint8_t) * */ encoded_lenth); memcpy(smp_msg.data, payload, encoded_lenth); uint8_t total_size = sizeof(smp_msg.hdr) + encoded_lenth; uint8_t *my_ptr = (uint8_t *)&smp_msg; printf("Size of smp 'FRAME' = %i\n", total_size); printf("The contents of FRAME - "); for (int i = 0; i < total_size; i++) { printf("%.2x, ", my_ptr[i]); } printf("\n"); }
I got
The contents of FRAME - 00, 00, 00, 02, 00, 01, 01, 00, b0, 06,
But I was expecting 00, 00, 00, 01, 00, 01, 01, 00, a0.
I've played arround with -DZCBOR_CANONICAL, but that just fails with if (!zcbor_new_backup(state, 0)).
I'm basing the expected on what I've seen come out of mcumgr and smpmgr when i had debug handles on the cli scripts.
The reason I'm using and wraping my messages is because I'm using a zync fpga with FREERTOS app to control the mcuboot on a nordic device.