Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wakaama-dev] Wakaama Client with Multiple Resource Instances

gps_read might work if *numDataP is 0, but it probably won’t work any other way. The arrays for the children should be allocated in the do loop. You are also hardcoding the indices instead of using the current index. Here is an example of what I think one case it should look like:

            case RES_M_GEOFENCING_LAT:

            {

                //lwm2m_data_encode_float(data->geofencing_lat, *dataArrayP + i);

                lwm2m_data_t *instances = lwm2m_data_new(2);

                lwm2m_data_encode_float(data->geofencing_lat[0], &instances[0]);

                lwm2m_data_encode_float(data->geofencing_lat[1], &instances[1]);

                lwm2m_data_encode_instances( instances, 2, *dataArrayP + i);

                result = COAP_205_CONTENT;

                break;

            }

 

You probably have problems with the hardcoded indices in gps_write also. It should look more like this:

            case RES_M_GEOFENCING_LAT: 

                 //if (lwm2m_data_decode_float(&dataArray[i], &data->geofencing_lat) == 1)

                 If ( dataArray[i].type == LWM2M_TYPE_MULTIPLE_RESOURCE && dataArray[i].value.asChildren.count == 2)

                 {

                     if ( lwm2m_data_decode_float( &(dataArray[i].value.asChildren.array[0]), &(data->geofencing_lat[0])) == 1 &&

                          lwm2m_data_decode_float( &(dataArray[i].value.asChildren.array[1]), &(data->geofencing_lat[1])) == 1 ) 

                         result = COAP_204_CHANGED;

                 }

                break;

 

Regards,

Scott

 

From: wakaama-dev-bounces@xxxxxxxxxxx <wakaama-dev-bounces@xxxxxxxxxxx> On Behalf Of Zsófia Papp
Sent: Thursday, July 26, 2018 7:27 AM
To: wakaama-dev@xxxxxxxxxxx
Subject: [wakaama-dev] Wakaama Client with Multiple Resource Instances

 

Hi all,

I'm currently developing an LwM2M client using Wakaama library, and it would be nice to use Multiple Resource Instances in one of my Smart Object - an object what implemets a GeoFencing function. The .xml and .cpp files of this Object are attached to see what I'm talking about.

For the GPS functionality I use  the "Sodaq_UBlox_GPS" library.

I've tried with Single Resources already, and it works fine - but with Multiple Resources I get this error message: "Invalid Response: Unable to decode response payload of request".

I'm trying to find the problem, but couldn't find it yet. I also couln't find any examples on the Internet, where Muliple Resources are used with Wakaama.

Do you have any experience with this topic? I would be grateful for every help!

Thanks for reading,
Regards,

 

Zsofi Papp


Back to the top