It is possible it might not work right off the bat. At least, I have not built 
such objects myself.
We do accept contributions ;)

You can also build code using the tinycbor decoder. This is what cborattr 
itself uses, if you
don’t have time to augment cborattr.

> On Aug 13, 2018, at 10:28 AM, Aditya Xavier <[email protected]> 
> wrote:
> 
> Thanks for replying !
> 
> Yeah, but If I do that, I won’t have an Array of Arrays right ?
> 
> i.e. I want to have {a:[1,2,3,4], b:[ {c:[1,2,3,4,5]}, {c:[1,2,3,4,5]}]} 
> structure..
> 
> Which means, I need multiple instances of C object. Hence the struct c_object 
> creation.. If I make CborAttrArrayType
> 
> Am not sure that will work.
> 
> Please correct me if am wrong.
> 
> Thanks,
> Aditya Xavier.
> 
> 
> 
>> On 13-Aug-2018, at 12:53 PM, marko kiiskila <[email protected]> wrote:
>> 
>> “c" looks like an int array instead of an object. Hope that helps
>> 
>>> On Aug 10, 2018, at 10:06 AM, Aditya Xavier <[email protected]> 
>>> wrote:
>>> 
>>> Hello !
>>> 
>>> 
>>> Require some guidance on how to write a CBOR parsing implementation for the 
>>> following structure.
>>> 
>>> {a:[1,2,3,4], b:[ {c:[1,2,3,4,5]}, {c:[1,2,3,4,5]}]}
>>> 
>>> I tried the following implementation.
>>> ———————————————————————————————————————————————————————
>>> 
>>> 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
>>>  }
>>> };
>>> 
>>> 
>>> 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
>>>  }
>>> };
>>> 
>>> ———————————————————————————————————————————————————————
>>> 
>>> 
>>> I assumed this to work as I have been using the same albeit without ‘c’ 
>>> being a int Array. It works when I use ‘c’ as a Int etc, but not as a int 
>>> Array, 
>>> 
>>> The example :- 
>>> https://github.com/apache/mynewt-core/blob/master/encoding/cborattr/test/src/testcases/cborattr_decode_object_array.c
>>>  
>>> <https://github.com/apache/mynewt-core/blob/master/encoding/cborattr/test/src/testcases/cborattr_decode_object_array.c>
>>> 
>>> Has a similar implementation for Text String instead of Int Array.
>>> 
>>> Thanks,
>>> Aditya Xavier.
>>> 
>>> 
>>> 
>> 
> 

Reply via email to