diff --git a/public/exit.html b/public/exit.html index ba431c6232451fd959350fdd0f673f242817562a..c150731051aed5ede51b204d1d1a7c1ad116ff01 100755 --- a/public/exit.html +++ b/public/exit.html @@ -25,7 +25,7 @@ <h1>Finishing Setup...</h1> <div class='section'> <div class="content" style="padding: 30px; padding-bottom: 0px"> - Your gateway is rebooting and joining the selected WiFi network. Once complete, the LED on the top of the gateway will turn solid green. To connect to your gateway make sure your computer is on the same network. You can navigate to the Node-RED web interface here: + Your gateway is rebooting and joining the selected WiFi network. Once complete, the LED on the top of the gateway will turn solid green. To connect to your gateway make sure your computer is on the same network. You can navigate to the <font color="#800000"><b>Node-RED</b></font> web interface here: <a href="http://params_node_red_url:params_node_red_http_port">http://params_node_red_url:params_node_red_http_port</a> <br><br> </div> diff --git a/server.js b/server.js index 208efcbdf36968a874a7faeb9af79a4b82c5ad45..d64dfeacd48e224cfa9fb28cb56b43ad32e6ef7f 100755 --- a/server.js +++ b/server.js @@ -260,7 +260,8 @@ function submitForm(params, res, req) { hostname = ssid = params.name; } - if (params.newwifi) { // WiFi is being configured + // WiFi is being configured + if (params.newwifi) { res_str = fs.readFileSync(site + '/exit.html', {encoding: 'utf8'}) } else { res_str = fs.readFileSync(site + '/exiting-without-wifi.html', {encoding: 'utf8'}) @@ -273,25 +274,27 @@ function submitForm(params, res, req) { node_red_url = node_red_url + ".local"; } + //replace params res_str = res_str.replace(/params_new_wifi/g, params.newwifi ? params.newwifi : ""); res_str = res_str.replace(/params_hostname/g, hostname + ".local"); res_str = res_str.replace(/params_ssid/g, ssid); res_str = res_str.replace(/params_curr_ssid/g, nameobj.ssid); res_str = res_str.replace(/params_curr_hostname/g, nameobj.hostname + ".local"); + //replace node-red params res_str = res_str.replace(/params_node_red_url/g, node_red_url); res_str = res_str.replace(/params_node_red_http_port/g, node_red_port); + //send the html response res.end(res_str); //wait 5s before sending the configure command so the exit page can be loaded setTimeout( function() { - console.log("configuring gateway wifi now!"); - commands.push({cmd: BIN_DIR+"/configure_gateway", args: ["--disableOneTimeSetup", "--persist"]}); - // Now execute the commands serially - runCmd(0, commands); - }, 5000); - + commands.push({cmd: BIN_DIR+"/configure_gateway", args: ["--disableOneTimeSetup", "--persist"]}); + // Now execute the commands serially + runCmd(0, commands); + }, 5000); + }); }