Code Monkey home page Code Monkey logo

Comments (3)

ofekp avatar ofekp commented on June 19, 2024 1

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.

from tinyupnp.

ofekp avatar ofekp commented on June 19, 2024 1

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.

from tinyupnp.

uddhavdave avatar uddhavdave commented on June 19, 2024

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.

from tinyupnp.

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.