Hi,
sorry, I missed to answer in time.
// “This is where i want to Access content variable”
The question will be, which version of the “content”?
Notifications are intended to change the content over time, therefore the example uses a “CoapHandler”, which get’s called, when your client receives a notification
of such a content change. How would you reflect that using a “variable”?
One solution maybe to use a “queue” (of content), so push the received content in onLoad to the queue, and pop it, where you want to receive the content. But though
I don’t know, what you want to do there, what you can’t do in the onLoad callback of the CoapHandler.
Mit freundlichen Grüßen / Best regards
Achim Kraus
(INST/ECS4)
Bosch Software Innovations GmbH | Stuttgarter Straße 130 | 71332 Waiblingen |
GERMANY |
www.bosch-si.com
Sitz: Berlin, Registergericht: Amtsgericht Charlottenburg; HRB 148411 B
Aufsichtsratsvorsitzender: Dr.-Ing. Thorsten Lücke; Geschäftsführung: Dr. Stefan Ferber, Michael Hahn
From: cf-dev-bounces@xxxxxxxxxxx <cf-dev-bounces@xxxxxxxxxxx>
On Behalf Of Sedat Bilgili
Sent: Montag, 2. April 2018 15:21
To: cf-dev@xxxxxxxxxxx
Subject: [cf-dev] How to get observe response as variable
Hello,
Currently i am trying to get some observe data from my CoAP server nodes. I am using the code in CoapClientExample.java “\demo-apps\api-demo\src\org\eclipse\californium\examples\”. It Works perfectly and prints values
on screen. However i want to access content variable.
*************************************
CoapObserveRelation relation = client.observe(
new CoapHandler() {
@Override public void onLoad(CoapResponse response) {
String content = response.getResponseText();
System.out.println("NOTIFICATION: " + content);
}
@Override public void onError() {
System.err.println("OBSERVING FAILED (press enter to exit)");
}
});
// “This is where i want to Access content variable”
// i.e. :
System.out.println(content);
*************************************
I have little experience with java. There’s no global variables or pointers like C/C++. How can i make it work ?
Thank you, Sedat Bilgili.