lwm2m observable resource
Antwort
05.12.16 13:22

Hey,

I have trouble notifying the lwm2m (leshan) server which observes a resource (16677/0/0) about it changing. The function I've written finds the change in the variable which is dynamically used as a resource and then it runs the following code:

 

Lwm2m_URI_Path_T stateUriPath = { STATE_OBJECT_INDEX_VALUE, STATE_OBJECT_INSTANCE_INDEX_VALUE, STATE_OBJECT_RESOURCE_NUMBER };
rc = Lwm2mReporting_resourceChanged(&stateUriPath);

 

Where:

#define STATE_OBJECT_INDEX_VALUE                   INT32_C(16677)
#define STATE_OBJECT_INSTANCE_INDEX_VALUE          INT32_C(0)
#define STATE_OBJECT_RESOURCE_NUMBER               INT32_C(0)

 

The server doesn't get the changed value. What should I change?

Thanks!

0 (0 Stimmen)
RE: lwm2m observable resource
Antwort
05.12.16 17:46 als Antwort auf Jason Athanasoglou.

Hello Jason,

from the first look should your code work as intended.

To make any suggestions I would ask you to go more into detail about your implementation. Are you using an existing example from the XDK workbench to adapt it to your use case.

Additionally, did you checked the error code returned after calling Lwm2mReporting_resourceChanged()?

Kind regards,
Franjo

0 (0 Stimmen)
RE: lwm2m observable resource
Antwort
06.12.16 16:02 als Antwort auf Franjo Stjepandic.

Hello Franjo, thanks for the reply,

 

I am using the Lwm2mExampleClient example. I have added a struct for my resources in AppLwm2mObjects.h, which I use in a .c file I have created (where I have all my dynamic/functions etc). I am registering these resources with the following:

 

Lwm2mObjectInstance_T objectInstances[] =
{
		{ LWM2M_OBJECTID_DEVICE, LWM2M_SINGLE_INSTANCE, LWM2M_RESOURCES(deviceResources), .permissions = {LWM2M_ACCESS_CONTROL_OWNER, 0x0, 0x0, 0x0} },
		{ SILO_OBJECTID, LWM2M_SINGLE_INSTANCE, LWM2M_RESOURCES(silo1), .permissions = {LWM2M_ACCESS_CONTROL_OWNER, 0x0, 0x0, 0x0} },
};

Lwm2mReporting_resourceChanged() returns RC_OK

 

Thanks in advance

0 (0 Stimmen)
RE: lwm2m observable resource
Antwort
07.12.16 14:09 als Antwort auf Jason Athanasoglou.

Hello Jason,

thank you for the information you provided. I believe I have found a solution for your issue. To be sure, we have to clarify some things first. The resource you are trying to observe is declared in your second device instance SILO_OBJECTID. Am I right here?

I assume you use the following code just as it is to wrap objectInstances into deviceResourceInfo?

Lwm2mDevice_T deviceResourceInfo =
{
        .name = NULL,
        .binding = UDP,
        .sms = NULL,
        .numberOfObjectInstances =    LWM2M_OBJECT_INSTANCE_COUNT(objectInstances),
        .objectInstances = objectInstances,
};

If this is in both cases true, then you have to delete the first declaration in objectInstances:

{ LWM2M_OBJECTID_DEVICE, LWM2M_SINGLE_INSTANCE, LWM2M_RESOURCES(deviceResources), .permissions = {LWM2M_ACCESS_CONTROL_OWNER, 0x0, 0x0, 0x0} }

This is necessary because you use here two device instances which collides with the lwm2m interface of the XDK. The interface only supports the declaration of one device instance which represents the XDK. Therefore you have to delete one device instance as suggested or merge the lwm2m objects of both device instances into one device instance. One way or another, only one device instance can remain.

Please tell me if this solves your issue.

Kind regards,
Franjo

0 (0 Stimmen)
RE: lwm2m observable resource
Antwort
08.12.16 19:25 als Antwort auf Franjo Stjepandic.

Hello Franjo and thanks for your suggestion, it helped me find the solution :)

First of all I was registering only one device instance but I deleted what you suggested as a test. I noticed that observing worked as intended (I used 0, 0, 0 as parameters for the Lwm2m_URI_Path_T). Then, I brought back the first declaration in objectInstances, but this time I used 1, 1, 0 as parameters for the URI path. Observation worked again, and I also had the device object registered!

So, here are the paratemeters I used for the URI path:

#define STATE_OBJECT_INDEX_VALUE                   INT32_C(1)
#define STATE_OBJECT_INSTANCE_INDEX_VALUE          INT32_C(1)
#define STATE_OBJECT_RESOURCE_NUMBER               INT32_C(0)

I had tried using 1, 0, 0 in the past but it didn't work. I guess the problem was that the instance index is used based on the total number of instances, and not for the specific object. Am I right on this one?

Either way, my code works now and I can proceed with my project. Thanks a lot for your time and your suggestions!

0 (0 Stimmen)
RE: lwm2m observable resource
Antwort
09.12.16 17:53 als Antwort auf Jason Athanasoglou.

Hello Jason,

I glad to hear that you manage to solve the issue by yourself. I would like to reproduce your issues depending on the instance index, but unfortunately the leshan sandbox I use to test the lwm2m applications is currently offline.
Therefore I cannot make any funded conclusion about the instance index. I will come back to this topic on monday when the sandbox hopefully works again.

The only thing I can do for now is ask you for patience.

Kind regards,
Franjo

+1 (1 Stimme)
RE: lwm2m observable resource
Antwort
13.12.16 15:23 als Antwort auf Franjo Stjepandic.

Hello Jason,

sorry for the late reply. Unfortunately the leshan sandbox is still not working. Therefore I can't draw any conclusion on the instance index.

I will reply to you as soon as the sandbox is working again, thus I have to ask you for patience.

Kind regards,
Franjo

0 (0 Stimmen)
RE: lwm2m observable resource
Antwort
13.12.16 16:51 als Antwort auf Franjo Stjepandic.

Hello Franjo,

 

Thanks again for your time. Since my project is working fine, I am in no rush. I will be waiting for an answer when it's available.

 

All the best,

Jason

0 (0 Stimmen)
RE: lwm2m observable resource
Antwort
03.01.17 14:53 als Antwort auf Jason Athanasoglou.

Hello Jason,

happy new year to you and everybody else in the community. I am now able to answer your question about the instance index.
As it is always set manually, you can of course chose random entries.
Note that object ID and the resource index can only be chosen randomly within certain restrictions.

The limitation comes in with the used object ID, because the object ID is classified in certain category labels. A category label defines a range of possible object IDs. For example the Lwm2mExampleClient uses the oma-label category which defines the used object ID 3. This object ID represents the device itself. The resources of this device ID are also predefined. On the other hand, if the object ID is defined within the ext-label or x-label, then you are able to chose the object ID, instance ID and resource complete randomly.

For more information about the category labels please refer to table 1 in the lwm2m guide you can find here.

Please don't hesitate to ask if you have further questions.

Kind regards,
Franjo

+1 (1 Stimme)