Code Monkey home page Code Monkey logo

Comments (12)

szysas avatar szysas commented on May 22, 2024

There are two things:

  1. Make a resource to be observable (for example https://github.com/ARMmbed/java-coap/blob/master/coap-core/src/test/java/com/mbed/coap/observe/SimpleObservableResourceTest.java#L52)

  2. Subscribe to a resource from RestAPI: https://docs.mbed.com/docs/mbed-device-connector-web-interfaces/en/latest/api-reference/

from java-coap.

Karandev avatar Karandev commented on May 22, 2024

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.

from java-coap.

szysas avatar szysas commented on May 22, 2024

What kind of problems do you get?

from java-coap.

Karandev avatar Karandev commented on May 22, 2024

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

from java-coap.

szysas avatar szysas commented on May 22, 2024

Logs please.

from java-coap.

szysas avatar szysas commented on May 22, 2024

Note also that I added observable resource to example-client: https://github.com/ARMmbed/java-coap/blob/dev/example-client/example-client/src/main/java/com/mbed/coap/example/DeviceEmulator.java#L85

from java-coap.

Karandev avatar Karandev commented on May 22, 2024

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?

from java-coap.

szysas avatar szysas commented on May 22, 2024

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

from java-coap.

Karandev avatar Karandev commented on May 22, 2024

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?

from java-coap.

szysas avatar szysas commented on May 22, 2024

Could you attached device logs?

from java-coap.

Karandev avatar Karandev commented on May 22, 2024

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.

from java-coap.

szysas avatar szysas commented on May 22, 2024

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?

from java-coap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.