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

Auto-select LISTEN_PORT #5

Open
Ponkabonk opened this issue Oct 24, 2017 · 7 comments
Open

Auto-select LISTEN_PORT #5

Ponkabonk opened this issue Oct 24, 2017 · 7 comments

Comments

@Ponkabonk
Copy link

This is more of a feature request than an issue.

It would be great if we (well, you actually) could automatically select a LISTEN_PORT that is free/available instead of having to manually select one.

@Ponkabonk
Copy link
Author

Of course, then we'd need some way of querying what port is being used so the LISTEN_PORT could be passed along to a cloud server or somehow displayed to the user so they know what it is.

@ofekp
Copy link
Owner

ofekp commented Oct 25, 2017

I am not quite sure how to indicate the port to the user, otherwise it is not very useful.
Another problem with that feature is preventing it from choosing a different port every time, because that will be annoying as hell. You basically have to know your network and choose a static port for each of your devices. Writing them on the device can help if you have plenty.
As for the cloud, if you have a cloud service that pretty much makes this package redundant for you, if you are willing to make an architectural change. Consider that, if the ESP is connected to the cloud (you'll have to hard code the address) it can query the server for changes every few seconds or will maintain a tcp connection. When the user wants to turn on the lights he changes a bit in the server (a file or whatnot) the LED device will pick that up and perform the necessary change in the light.
I am not sure what the application is, but I see you are aiming at a zero config system.
You'll always have a config, even if you have two devices, you need to configure the server which is which.. But again, I know nothing about your system.

@Ponkabonk
Copy link
Author

You could just have a function that would return the currently-mapped port. Displaying the port to the user would be up to the UI/UX (if necessary).

I don't really have an application in mind yet. I just installed a TP-Link smart bulb and was impressed with how little the consumer needed to know in order to make the bulb work. I believe I can improve on the process though.

I'm guessing I can use printAllPortMappings to find a free port. Right? I'll need to do that before I addPortMapping though.

@Ponkabonk
Copy link
Author

If the device auto-selected the port, I would then "register" the device/IP/Port with a cloud service. The cloud service would have a UI (or I'd make an app) that would control the device so the end user wouldn't have to know (and wouldn't understand) the port number. The idea is to make the whole process plug-and-play to make it idiot-proof.

@ofekp
Copy link
Owner

ofekp commented Oct 27, 2017

So yeah, zero config.
But as I said, instead of transferring the port to the server, have the device query the server, thereby no configuration will be needed in the router, of any kind.
This is how Belkin and TP-Link and other companies do it. It is working quite well for devices such as lights switches and even cloud cameras (which take one frame every 2 or 3 seconds).
For others, 2-3 frames is not enough, in those cases the cloud is bypassed by a UPnP predefined port that is defined in the server and in the device (camera in this case) itself after connecting to it using an ethernet cable or WiFi - AdHoc process.
Please think about the process, you will need to configure the devices WiFi in any case. You will never have an absolute 0 config.
You can, however, have the device communicate with cloud and tell it what the WiFI settings are using a mobile app or web app, and while you're at it, you can get the UPnP port suggestion from the device (after using the getAll method you suggested or by using large numbers like the one you used, which is absolutely fine) then you'll set the port to be it once and for all.

@sebosfato
Copy link

I would also need this functionality… i use an app to call the user from 4g and so the app need to know the port to get it… as i want each user to get multiple devices i want the ports to be open in a sequence way first detecting the ports than open sequentially within a range..

any one know how to access the info that is printed in terminal?

because it appear that everything is there just need to make the logic to work..

i would apreciate any help or ideas..

@ofekp
Copy link
Owner

ofekp commented Mar 2, 2023

Can you elaborate on your setup a little more? Perhaps an example will help here. Like an actual scenario with port numbers and clients.
You can check out the header file to see if there is anything of use for you there, like the port rules that are currently mapped in the IGD.
It is possible to select the port automatically by avoiding the current rules in the IGD but then you need to broadcast that port to other devices somehow.

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

3 participants