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

Cannot detect NOTIFY packets #64

Open
uddhavdave opened this issue Apr 24, 2020 · 3 comments
Open

Cannot detect NOTIFY packets #64

uddhavdave opened this issue Apr 24, 2020 · 3 comments

Comments

@uddhavdave
Copy link

Hi, I am using your library to discover a gateway. Facing an issue when the MSEARCH packet is sent out to [239.255.255.250] Port [1900], it only proceeds further on MSEARCH response packet and waits till it gets it (Precisely this function waitForUnicastResponseToMSearch()) However, I need it to also listen for NOTIFY packets in the function which is sent out by the gateway at regular intervals.

I can see the notify packets from the gateway over other SSDP listeners. How can you enable listening to not only Msearch response packets but also notify packets in this library?

@ofekp
Copy link
Owner

ofekp commented Apr 24, 2020

Hey there, currently there is no support for that.
The reason is that with the current API you will have to listen constantly to the UDP packets each time checking the size and and if > 0 you check if it is a NOTIFY packet.
Instead we will need to use something like this:
https://github.com/espressif/arduino-esp32/tree/master/libraries/AsyncUDP
which will work with interrupts.

I believe it will be a good idea to implement this since this will be good for both M-SEARCH and NOTIFY, but a thought needs to be given on what happens if there are too many NOTIFY messages, that might congest the device. If it is running a server, it might slow it down in extreme situations, so there should be a flag to disable it.

This will require some work, not seeing that I can get to it soon, if you can start a PR I can join and help as best I can. The link I provided is a good start.

@uddhavdave
Copy link
Author

Okay, so you mean that the _udpclient object does not give NOTIFY packets as a response when we call int packetSize = _udpClient.parsePacket(); is that right?

If so the link you shared is definitely a good start in order to implement this. I have tried using async calls before in my program and not a big fan of them as they might trigger watchdog timeouts. However, I will try implementing this and get back.

In the case where we get too many NOTIFY messages, we can use a cyclic buffer which will avoid stack overflows. I think that will be a good start. And yes, a flag to disable the service is also needed.

Thanks for the reply and guidance.

@ofekp
Copy link
Owner

ofekp commented Apr 29, 2020

Okay, so you mean that the _udpclient object does not give NOTIFY packets as a response when we call int packetSize = _udpClient.parsePacket(); is that right?

not exactly, what I mean is that you would have to constantly listen to NOTIFY messages which is not feasible if you also have a server running on the same core. The async package should take care of this in the sense that you can be interrupting the server thread when NOTIFY messages are available. I think the link I shared is a package that will allow that. _udpclient can pick up NOTIFY messages but it will need to have a thread that is constantly active and checking if there are new packets. I think we can still make it work with _udpclient if we add a periodic check in the main loop but perhaps the interrupt will be better, since it will only interrupt the main loop if there are actually NOTIFY packets. Does that make sense? I hope I explained it well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants