Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifying LWM2M server periodically with data from client #6

Closed
Karandev opened this issue May 30, 2017 · 12 comments
Closed

Notifying LWM2M server periodically with data from client #6

Karandev opened this issue May 30, 2017 · 12 comments

Comments

@Karandev
Copy link

How do we update the LWM2M server about a change in some sensor value, for example temperature value obtained from device sensors, in the form of endpoints and resources?

@szysas
Copy link
Contributor

szysas commented May 30, 2017

@Karandev
Copy link
Author

If the value of an observable resource changed from client and then we need to push that new value to mbed server what should be done? This we are trying to do once we receive sensor data after a period of every 15 seconds.
We are using like this:
if(startedCoapServer != null && registrationManager != null) { SimpleObservableResource obsResourceX = new SimpleObservableResource("/AndroidDevice/Gravity/X", startedCoapServer); try { obsResourceX.setBody(gravityData[0] + ""); } catch (CoapException e) { e.printStackTrace(); } SimpleObservableResource obsResourceY = new SimpleObservableResource("/AndroidDevice/Gravity/Y", startedCoapServer); try { obsResourceY.setBody(gravityData[1] + ""); } catch (CoapException e) { e.printStackTrace(); } SimpleObservableResource obsResourceZ = new SimpleObservableResource("/AndroidDevice/Gravity/Z", startedCoapServer); try { obsResourceZ.setBody(gravityData[2] + ""); } catch (CoapException e) { e.printStackTrace(); } startedCoapServer.addRequestHandler("/AndroidDevice/Gravity/X", obsResourceX); startedCoapServer.addRequestHandler("/AndroidDevice/Gravity/Y", obsResourceY); startedCoapServer.addRequestHandler("/AndroidDevice/Gravity/Z", obsResourceZ); registrationManager.register(); }
This don't seems to be correct. Please help.

@szysas
Copy link
Contributor

szysas commented May 30, 2017

What kind of problems do you get?

@Karandev
Copy link
Author

Karandev commented May 30, 2017

After some time keeping the application idle, a 502 error is received, even though de-registration is not done.

@szysas
Copy link
Contributor

szysas commented May 30, 2017

Logs please.

@szysas
Copy link
Contributor

szysas commented May 30, 2017

@Karandev
Copy link
Author

We are able to send data continously every 15 seconds. Is there any parameter we need to set so that this happens for atleast, let's say, 30 minutes or one hour, without any interruption?

@szysas
Copy link
Contributor

szysas commented May 31, 2017

Well, just set your scheduler to send notification as often as you need.

@Karandev
Copy link
Author

Karandev commented May 31, 2017

We keep on sending the data every 15 sec. After about 10 minutes or so testing in the mbed server console, clicking the Test Api button keeps on trying to fetch the data for get resources, but with no result.
What could be wrong?
When does the onNoObservers method get called?

@szysas
Copy link
Contributor

szysas commented May 31, 2017

Could you attached device logs?

@Karandev
Copy link
Author

Now we are using the endpoint name, server key etc. from the security.h file from mbed portal. Is there a way to programmatically create the security.h file or the required keys?
We found that same endpoint name and keystore cannot be used for multiple android devices.
Please help.

@szysas
Copy link
Contributor

szysas commented May 31, 2017

I'm sure there is a way to make a (bash) script that would do the job automatically. Any collaboration is more than welcome :).
Is original issue solved? If so could we close this ticket?

@Karandev Karandev closed this as completed Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants