The uriP I was talking about is the one you pass as parameter to lwm2m_resource_value_changed().
BTW, Achim code sample has a small typo. It should be:
lwm2m_uri_t uri;
if (lwm2m_stringToUri("/3/0/9", 6, &uri))
{
lwm2m_resource_value_changed(lwm2mH,
&uri);
}
You can see this code working in the test client using the command “change”. See
https://github.com/eclipse/wakaama/blob/master/tests/client/lwm2mclient.c#L312
Regards,
David Navarro
From: wakaama-dev-bounces@xxxxxxxxxxx [mailto:wakaama-dev-bounces@xxxxxxxxxxx]
On Behalf Of Ugur Kirbac
Sent: Thursday, 23 July, 2015 15:07
To: Wakaama developer discussions
Subject: Re: [wakaama-dev] Observe Method Problem
Do you have any idea why uriP can be null considering I’m using the context iniitialized in the main?
"Another possibility is that contextP does not point to an actual lwm2m_context_t.”
What is the actual lwm2m_context_t,
where can I pass it from?
Do you know if Observe method was tested with some dynamic data? If yes, any clue how?
Alternatively, I use OMA Mozilla addon and it works pretty well for notifying the resource updates. I
wanted to experiment with Wakaama with Raspberry PI2 but apparently Observe method doesn’t work for me. I will give it a try for awhile before I give up on Wakaama.
Cheers
From:
<Navarro>, David
Reply-To: Wakaama developer discussions
Date: Thursday 23 July 2015 15:53
To: Wakaama developer discussions
Subject: Re: [wakaama-dev] Observe Method Problem
Even if targetP is null, a segfault can not occur as tests are performed. Maybe it is the uriP with is null ? This one is not tested.
Another possibility is that contextP does not point to an actual lwm2m_context_t.
Regards,
David Navarro
Actually my update() method is invoked when server sends an Observe or Read request to the client inside
static uint8_t prv_accelerometer_read.
In addition to that, I have debugged the code and contextP is not actually null inside prv_getObservedList()
if(contextP =! NULL)fprintf(stderr, "contextP is not null\n");
else fprintf(stderr, "contextP is null\n”);
However, as I mentioned eariler, targetP
returns NULL so targetP->uri.objectId
gives segmentation fault
targetP = contextP->observedList;
fprintf(stderr, “targetP is not NULL: %s \n",targetP->uri.objectId);
else fprintf(stderr, "targetP is NULL\n");
fprintf(stderr, "%s ObjectID: \n",targetP->uri.objectId);
Has anybody got Observe method working for any object?
Thanks
From:
<Navarro>, David
Reply-To: Wakaama developer discussions
Date: Thursday 23 July 2015 12:01
To: Wakaama developer discussions
Subject: Re: [wakaama-dev] Observe Method Problem
Hi Ugur,
maybe your update() function is called before the lwm2m_context_t is initialized ?
The only to have a segfault in
prv_getObservedList() is by having a null contextP.
Regards,
David Navarro
I have done already exactly what you suggested but the problem is that when I create the lwm2m_context_t
* after initialization and pass it to lwm2m_resource_value_changed through a global variable, the segmentation fault occurs in the method below. targetP
= contextP->observedList; is basically NULL.
static obs_list_t * prv_getObservedList(lwm2m_context_t * contextP,
lwm2m_observed_t * targetP;
targetP = contextP->observedList;
fprintf(stderr, “targetP is not NULL: %s \n",targetP->uri.objectId);
else fprintf(stderr, "targetP is NULL\n");
fprintf(stderr, "%s ObjectID: \n",targetP->uri.objectId);
From:
"Kraus Achim (INST/ESY4)"
Reply-To: Wakaama developer discussions
Date: Wednesday 22 July 2015 17:09
To: Wakaama developer discussions
Subject: Re: [wakaama-dev] Observe Method Problem
Hi,
to call
void lwm2m_resource_value_changed(lwm2m_context_t * contextP,
lwm2m_uri_t * uriP)
you need a "lwm2m_context_t *", which is the result of the initial call of
lwm2m_context_t * lwm2m_init(lwm2m_connect_server_callback_t connectCallback,
lwm2m_buffer_send_callback_t bufferSendCallback,
void * userData)
This is usually called during initialization (see „lwm2mclient/main.c“) and may be shared
via a global variable or set by calling specific user defined function into the different
modules after the lwm2m_init call.
Mit freundlichen Grüßen / Best regards
Achim Kraus
Bosch Software Innovations GmbH
Communications (INST/ESY4)
Stuttgarter Straße 130
71332 Waiblingen
GERMANY
www.bosch-si.de
www.blog.bosch-si.com
achim.kraus@xxxxxxxxxxxx
Registered office: Berlin, Register court: Amtsgericht Charlottenburg, HRB 148411 B
Executives: Dr.-Ing. Rainer Kallenbach; Michael Hahn
Thanks for the quick reply,
Where should I use “lwm2m_resource_value_changed”? When I try to use it in
object_temperature.c, I get a segmentation fault. I’m not sure how to get the context pointer “lwm2mH” inside object_temperature.c.
From:
"Kraus Achim (INST/ESY4)"
Reply-To: Wakaama developer discussions
Date: Wednesday 22 July 2015 13:53
To: Wakaama developer discussions
Subject: Re: [wakaama-dev] Observe Method Problem
Hi,
only changing the „float temperature“ is not detected by the wakaama core.
If you change a resource, you must call „lwm2m_resource_value_changed“
with the associated uri.
e.g.
lwm2m_uri_t uri;
if (lwm2m_stringToUri("/3/0/9", 6, &uri))
{
lwm2m_resource_value_changed(lwm2mH, uri);
}
to inform the core about a battery level change (uri „/3/0/9“).
Mit freundlichen Grüßen / Best regards
Achim Kraus
Bosch Software Innovations GmbH
Communications (INST/ESY4)
Stuttgarter Straße 130
71332 Waiblingen
GERMANY
www.bosch-si.de
www.blog.bosch-si.com
achim.kraus@xxxxxxxxxxxx
Registered office: Berlin, Register court: Amtsgericht Charlottenburg, HRB 148411 B
Executives: Dr.-Ing. Rainer Kallenbach; Michael Hahn
I’m currently experimenting a Leshan server and Wakaama client. I have been trying to get Observe method working for Wakaama client however I couldn’t
manage it so far. First, I tried to observe the device object and I haven’t seen any notification from Wakaama client to Leshan server. After that, I created two IPSO Objects and update the values using a timer because right now I don’t have any real sensor
connected to the client so I’m kinda faking the resources.
The code I used for updating is the below.
temperature = rand() % 10 + 20;
//fake accelerometer data producer starts//
#define INTERVAL 5000 /* number of milliseconds to go off */
struct itimerval it_val; /* for setting itimer */
/* Upon SIGALRM, call DoStuff().
* Set interval timer. We want frequency in ms,
* but the setitimer call needs seconds and useconds. */
if (signal(SIGALRM, (void (*)(int)) randomTemp) == SIG_ERR) {
perror("Unable to catch SIGALRM");
it_val.it_value.tv_sec = INTERVAL/1000;
it_val.it_value.tv_usec = (INTERVAL*1000) % 1000000;
it_val.it_interval = it_val.it_value;
if (setitimer(ITIMER_REAL, &it_val, NULL) == -1) {
perror("error calling setitimer()");
Is there any problem with Observe method in Wakaama client? Any suggestion?
I have also attached an image showing the CoAP Messages logs for Leshan server on the browser.
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
|