Open tablatronix opened 6 years ago
Is there a way you could provide an example on how to run a shared webserver.
Sure, when I figure out how
Ok, i see it's something everybody would like ^^ What about a way to link the dnsserver to a specific page of the web server, not the "/" , something like "/captivePortail", is it possible ?
dnsserver? dns server resolves domains
Hi I see As you can see I'm not a specialist ^^ You understand the idea : captive portal point to a "/captiveportal" page not to the "/" default page
An other idea could be to check if the client is connected to AP or from network , and link to different pages, if it is connected on AP the page as only few button which link to other specific pages, so the difference is only on the first page Do you see what I mean ? Maybe it's already what you do
Yeah the idea is to share the webserver instance so you can access in your own code, you can do this now by just making it public, but I have not decided if that is the final route. It might be better to makde it a shared pointer so that memory gets cleaned up better.
A shared pointer allow you to keep the same webserver but the configuration of this webserver (.on(..) , etc.) is erase when captive portal is open, isn't it ? Do I understand well or I'm wrong ? Let me know if it's not the good place to have this discussion
I wouldn't think so, not sure what you mean. webportal is always on when configportal is on
Does the setupConfigPortal erase the setup of the server done in the setup() of the sketch ?
Ah I see what you are saying, yes that resets the webserver. hmm you have to setup yours after that, wm would have to be setup to allow that to be skipped, it also gets torn down on closeconfigportal
Good point
For my project, I'm not saying it's the best solution for everyone, pass a pointer of web server to WM and just assign handlers looks good.
Is there a way to know if the client is connected to AP or through network ?
Curious , Did you add a new constructor to pass the webserver in , or use a setter?
I guess you could check by client ip, or get the clients attached to ap and check them for that ip request. There is a function in esp to get stas that are connected, I forget it
Not in WM, it was a test in a personal library
Ok i will look for this function :)
If you remember the name, let me know ^^ Thanks
Ok thanks, I just test it, it works well, as expected only for client connected to AP. So it's possible to compare IP to know if it connected to AP or through network, and send a different first web page
I just test something, with my iPhone, I don't know if it's true with android and I didn't get captive portal on my computer, but the captive portal seems to request the "/hotspot-detect.html" Is it a standard ?...
no there is no standard for captive portals, I always get captive portal on iphone and osx, if you have connected before you might have to "forget" the access point or else it auto joins and doesnt do captive portals. Also if you are on 2 networks sometimes it will not launch the captive portal, but my iphone almost always works. There is an open issue in esp lib about android captive portals not working with certain IPs
for now I am testing this out
setWebServerCallback
that fires after webserver is setup and before route events are setup ( this allows user to override routes eg. /info )testing added to DEV example
I am testing this already, but I am using a getter and a shared_ptr, not sure which way will be final. Ill post my branch later, I was adding some callbacks and testing what kind of parameters and callouts we would want to plan for templating and sharing webserver control.
There are several options, make server public, add getter with shared_pointer, and a few others. I am unsure which is the best design pattern for this, or how we want to control ownership.
Thoughts welcome.