apache / apache/mynewt-core

CBOR Decoding of Array of Arrays not working

Open
#1,330 0 comments 0 reactions 1 assignee Claimed by @mkiiskila View on GitHub
Dominant language
C
Stars
891
Forks
381
Avg merge
2d 7h
Merged PRs (30d)
14

Description

Hi,
CBOR Decoding for an Array of Int Array for e.g.
the following structure :-
{a:[1,2,3,4], b:[ {c:[1,2,3,4,5]}, {c:[1,2,3,4,5]}]}

Tried decoding using the following structure.

uint64_t a[5];
Int a_count = 0;

struct c_object{
int c[6];
}c_arr_objs[5];
int c_obj_count = 0;

struct cbor_attr_t c_attrs[] = {
{
.attribute = “c",
.type = CborAttrObjectType,
CBORATTR_STRUCT_OBJECT(struct c_object, c),
.dflt.integer = 0
},
{
.attribute = NULL
}
};
// Tried CborAttrObjectType, CborAttrIntegerType and CborAttrArrayType.

struct cbor_attr_t root_attrs[] = {
{
.attribute = “a",
.type = CborAttrArrayType,
.addr.array.element_type = CborAttrUnsignedIntegerType,
.addr.array.arr.uintegers.store = a,
.addr.array.count = &a_count,
.addr.array.maxlen = sizeof(a) / sizeof(a[0]),
.nodefault = true
},
{
.attribute = “b",
.type = CborAttrArrayType,
CBORATTR_STRUCT_ARRAY(c_arr_objs, c_attrs, &c_obj_count),
.nodefault = true
},
{
.attribute = NULL
}
};

This method doesn't work. The method is very similar to the example given in the following test case :-
cborattr/test/src/testcases/cborattr_decode_int_array.c

Please let me know if there is a mistake on my end.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.