Yeah, it is supposed to be an array of pointers. This is because the
only way you're supposed to get a OCRepPayload object is via the
OCRepPayloadCreate. I've unfortunately not documented that well enough,
and one of the things on my "TODO" list is to move the definition of all
of the OCPayloads to an implementation only file, which would prevent
this confusion.
-Erich
On Tue, 2015-09-15 at 06:16 +0000, ??? wrote:
>
> Hi Erich.
>
>
> I looked up my samples why it makes fault with the original code and find out
> OCRepPayload array values should be pointer of OCRepPayload like
>
> OCRepPayload* c1;
> OCRepPayload* c2;
> const OCRepPayload* arr[] = {c1,c2};
> OCRepPayloadSetPropObjectArray(root, "temp", arr, dimensions);
>
> However I did the test with the following format. so I think it brings to
> jump around while increasing i;
> OCRepPayload c1;
> OCRepPayload c2;
> OCRepPayload arr[2] = {c1,c2};
> OCRepPayloadSetPropObjectArray(root, "temp", arr, dimensions);
>
> if your original intention is pointer of pointers, there is no reason not to
> follow.
> I make this submission abandoned to keep the original code and thank you for
> everything.
>
> Best Regards,
> Rami Jung
>
> ------- Original Message -------
> Sender : ???<rami.jung at samsung.com> S6(??)/??/IoT Solution Lab(S/W??)/????
> Date : 2015-09-14 13:15 (GMT+09:00)
> Title : Re: Re: [dev] Nested sequence type of AttributeValue(OCRepPayload )
> in C
>
> Hi Erich.
>
> I've sumitted "https://gerrit.iotivity.org/gerrit/#/c/2495/" to avoid the
> incorrect working.
> Please review it then get it merged until you find out the better method.
>
> Thanks
> Rami
>
> ------- Original Message -------
> Sender : Keane, Erich<erich.keane at intel.com>
> Date : 2015-09-12 01:16 (GMT+09:00)
> Title : Re: [dev] Nested sequence type of AttributeValue(OCRepPayload ) in C
>
> Reading again... I'm not so convinced... Sorry for the tons of emails, I
> keep second guessing myself on this one. I'll look into it later today
> if I get a chance.
>
>
> On Fri, 2015-09-11 at 16:12 +0000, Keane, Erich wrote:
> > AH! I see the bug now!
> >
> > array is of type OCRepPayload**!
> >
> > The array[i] should REALLY be (*array)[i];
> >
> > Thats why it looks like it is jumping around. Good catch! If you'd
> > like to submit a patch, I'm sure it wouldn't have a problem getting
> > accepted.
> >
> > On Fri, 2015-09-11 at 16:05 +0000, Keane, Erich wrote:
> > > I'm not sure I'm getting what you mean? Are you attempting to alter
> > > behavior, or did you find a bug? If you found a bug, feel free to
> > > submit a patch and add Jon A. Cruz to the review.
> > >
> > > As far as:
> > > array[i] -> *array+i, I definitely prefer the previous, and I'm not
> > > sure how they would be different...
> > >
> > >
> > >
> > > On Fri, 2015-09-11 at 13:11 +0000, ??? wrote:
> > > > Currently, Samsung implements the sequence type of
> > > > AttributeValue(OCRepPayload ) in C like C++
> > > > I wrote the sequence type of AttributeValue(OCRepPayload ) because C
> > > > doesn't support vector.
> > > >
> > > > when I am using *.c from resoruce/csdk/stack/src because we cannot
> > > > use OCpresentation.cpp for the thin project ,I have problem to
> > > > exchaange "OCRepPayload array (OCRepPayload[] )" as a value.
> > > >
> > > > ie . the following format cannot be sent.
> > > > . { "key1" : {
> > > > {
> > > > "nested key" : "key_01"
> > > > value" : 100
> > > > },
> > > > {
> > > > "nested key" : "key_02"
> > > > "value" : 200
> > > > }
> > > > }
> > > > }
> > > >
> > > > The based file i tested was
> > > > resource/scdk/stack/smaples/linux/SimpleClientServer/ocserver.cpp,
> > > > occlient.cpp.
> > > > Even though they are .cpp, they call c functions intread of c++
> > > > functions..
> > > >
> > > >
> > > > while testing and debuging this issue, I found out that
> > > > OCRepPayloadSetPropObjectArray of ocpayload.c has a pointer issue
> > > > line 953 ; increasing i of array[i] in OCRepPayloadClone(array[i])
> > > > jumps too much , so it cannot find the next OCRepPayload correct.
> > > >
> > > > If newArray[i] = OCRepPayloadClone(array[i]) is changed to
> > > > newArray[i] = OCRepPayloadClone((*array +i) ) ;,it seems it works
> > > > well as intended
> > > >
> > > >
> > > > =============
> > > >
> > > > typedef struct LIGHTRESOURCE
> > > > {
> > > > OCResourceHandle handle;
> > > > bool state;
> > > > int power;
> > > > char strArray[STRARRAYNUMBER][STRARRAYLENTH]; //
> > > > array string
> > > > int64_t intArray[INTARRAYNUMBER]; //
> > > > array int
> > > > OCRepPayload rcsArray[2];
> > > > } LightResource;
> > > >
> > > > -----------------
> > > >
> > > > {
> > > > ......
> > > > OCRepPayload dupobj[2];
> > > > dimensions[0]=2; dimensions[1]=dimensions[2]=0;
> > > > if(OCRepPayloadGetPropObjectArray(input, "rcsarray",
> > > > (OCRepPayload ***)dupobj, dimensions)) {
> > > >
> > > > memcpy(currLightResource->rcsArray, dupobj,
> > > > RCSTARRAYNUMBER*sizeof(OCRepPayload));
> > > > }
> > > >
> > > > }
> > > > // when I check currLightResource->rcsArray,, it has teh correct
> > > > value.
> > > > return getPayload(gResourceUri, currLightResource->power,
> > > > currLightResource->state,
> > > > currLightResource->strArray, currLightResource->intArray,
> > > > currLightResource->rcsArray);
> > > > }
> > > >
> > > >
> > > >
> > > > OCRepPayload* getPayload(const char* uri, int64_t power, bool state,
> > > > char strArray[][STRARRAYLENTH],
> > > > int64_t* intArray, OCRepPayload* rcsArray)
> > > > {
> > > > ....
> > > > size_t dimensions[MAX_REP_ARRAY_DEPTH]={2,0,0}; ;; just 2 times.
> > > > OCRepPayloadSetPropObjectArray(payload, "rcsarray",( const
> > > > OCRepPayload**) &rcsArray, dimensions ); ///
> > > > ....
> > > > }
> > > >
> > > >
> > > > Given that OCRepresentation.cpp doesn't use
> > > > OCRepPayloadSetPropObjectArray and nobody uses OCRepPayload array
> > > > (OCRepPayload[] ) yet, I think it is possble that it would rather be
> > > > changed. however I am still believeing my testing way may need to get
> > > > fixed..
> > > >
> > > >
> > > > If you don't mind . Can I submit ocpayload.c directly? otherwise
> > > > please find out the better way or make me correct..
> > > >
> > > >
> > > > thank you
> > > > Rami
> > > > _______________________________________________
> > > > iotivity-dev mailing list
> > > > iotivity-dev at lists.iotivity.org
> > > > https://lists.iotivity.org/mailman/listinfo/iotivity-dev
> > >
> > > _______________________________________________
> > > iotivity-dev mailing list
> > > iotivity-dev at lists.iotivity.org
> > > https://lists.iotivity.org/mailman/listinfo/iotivity-dev
> >
> > _______________________________________________
> > iotivity-dev mailing list
> > iotivity-dev at lists.iotivity.org
> > https://lists.iotivity.org/mailman/listinfo/iotivity-dev
>