Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wakaama-dev] Observe Method Problem

Hello David,
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;

    if (targetP!=NULL)

    {

fprintf(stderr, “targetP is not NULL: %s \n",targetP->uri.objectId);

        /* code */

    }

    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

 

From: wakaama-dev-bounces@xxxxxxxxxxx [mailto:wakaama-dev-bounces@xxxxxxxxxxx] On Behalf Of Ugur Kirbac
Sent: Thursday, 23 July, 2015 10:15
To: Wakaama developer discussions
Subject: Re: [wakaama-dev] Observe Method Problem

 

 

Thanks again Achim,

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_uri_t * uriP)

{

    obs_list_t * resultP;

    lwm2m_observed_t * targetP;

 

    resultP = NULL;

 

    targetP = contextP->observedList;

    if (targetP!=NULL)

    {

fprintf(stderr, “targetP is not NULL: %s \n",targetP->uri.objectId);

        /* code */

    }

    else fprintf(stderr, "targetP is NULL\n");

    

    fprintf(stderr, "%s ObjectID: \n",targetP->uri.objectId);

 

 

 

Any suggestion about it? 

 

Thanks

 

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

 

 

Von:wakaama-dev-bounces@xxxxxxxxxxx [mailto:wakaama-dev-bounces@xxxxxxxxxxx] Im Auftrag von Ugur Kirbac
Gesendet: Mittwoch, 22. Juli 2015 15:09
An: Wakaama developer discussions
Betreff: Re: [wakaama-dev] Observe Method Problem

 

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.

Any idea?

Thanks

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

 

 

Von:wakaama-dev-bounces@xxxxxxxxxxx [mailto:wakaama-dev-bounces@xxxxxxxxxxx] Im Auftrag von Ugur Kirbac
Gesendet: Mittwoch, 22. Juli 2015 12:07
An: wakaama-dev@xxxxxxxxxxx
Betreff: [wakaama-dev] Observe Method Problem

 

Hello,

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. 

 

 float temperature;

 

 void randomTemp(void){

    temperature = rand() % 10 + 20;

    

}

//fake accelerometer data producer starts//

#define INTERVAL 5000        /* number of milliseconds to go off */

 

void update(void) {

 

  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");

    exit(1);

  }

  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()");

    exit(1);

  }

 

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. 

 

Cheers

 

---------------------------------------------------------------------
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.


Back to the top