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

How to get uri.path from observed packets arriving from 8266 CoAp Server? #22

Open
pcbtborges opened this issue Jul 11, 2019 · 0 comments

Comments

@pcbtborges
Copy link

Dear friend, I set an experiment to see the workings of CoAp and for that I used your code at Github.

I set a 8266 Coap Server running one /led resource
The second is an ESP12 running CoAp Client and it is set to observe the resource /led in the 8266 CoAp Server.

When /led changes at the CoAp Server ( I am using a browser with CoAp for that) the ESP12 is notified. It works ok.

The problem is that, in case I am observing more than one resource at the server I must find a way to identify what resource is generating the packet when it arrives at the following function:

`// coap client response callback
void callback_response(coapPacket &packet, IPAddress ip, int port) {
char p[packet.payloadlen + 1];
memcpy(p, packet.payload, packet.payloadlen);
p[packet.payloadlen] = NULL;

char t[packet.tokenlen + 1];
memcpy(t, packet.token, packet.tokenlen);
t[packet.tokenlen] = NULL;    

//response from coap server
if(packet.type==3 && packet.code==0){
  Serial.println("ping ok");
}

Serial.print("type: ");
Serial.print(packet.type);
Serial.print(" - code: ");
Serial.print(packet.code);
Serial.print(" - messageid: ");
Serial.print(packet.messageid);    
Serial.print(" - optionnum: ");
Serial.print(packet.optionnum); 
Serial.print(" - token: ");
Serial.println(t);     

Serial.println(p);

}`

I tried to print all variables I could find but had no success with uri.path.

So, my question is:
How to get the "/led" resource name so I can patch the payload value to the correct variable?

Thanks in advance for your time.
And Congrats for the excellent work!

Paulo Borges

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

1 participant