You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Regarding the code:

    I do not understand lines 18..23... it also looks syntactically weird to me... may be something got lost in copy-paste... I'm also curious about the big indentation... must be some context.

    Regarding the text:

    open a Web server to get SSID and password

    Does that mean that something is 'polling/trying to connect to that Web server to come up and then requests a page to post the SSID and password to connect to a different network? ...because servers do not request things, they serve requests, they also do not send pages by themselves, the respond to requests with a page.

    stop listening on a Web server

    Do you mean stop listening to requests?

    Milling over my own question I guess I see what event you are locking for:

    The even of having sent the response in its entirety and only then you want to shut down the server. You can setup the response with streaming... then you get an event when all data is sent only the close - response.end()with no data anymore is needed... and with a short timeout you can then shut down what ever you need (in correct sequence).

    Are you thinking of the remote device operating in two modes:

    First mode - for setup / boot: it is an access point with 'static/fix' ssid, pw and web server that allows to be connect to and can receive a post with and other ssid and password for Second mode.
    Second mode - for regula operation: Connect as station to the network with ssid and password received in the first mode.

    Another comment I want to make is: when you are already connected to a wifi network w/ a particular SSID and password - I do not know if you can can create an access point, because an access point means defining a new network with its own, different SSID and password, and I do not know if you can operate on two networks simultaneously. But:

    If you have a Wifi connection, yes you can open a server and listen to requests and then shut it down after serving the pages / posts you needed to serve (to either provide data or get data, and use the gotten data to continue on the connection with something else (such as create a http request - to get a 'command' for execution, polling).

About

Avatar for allObjects @allObjects started