diff --git a/public/exit.html b/public/exit.html index d417328976be4f7e3dfdf491ebd3fab0e2bef19e..ba431c6232451fd959350fdd0f673f242817562a 100755 --- a/public/exit.html +++ b/public/exit.html @@ -1,7 +1,7 @@ <!DOCTYPE html> <html> <head> - <title>Leaving Setup</title> + <title>Finishing Setup</title> <link rel="stylesheet" type="text/css" href="main.css" media="screen"/> <script src="feedbacklib.js"></script> <script type="text/javascript"> @@ -22,11 +22,11 @@ </noscript> </head> <body> -<h1>Leaving Setup</h1> +<h1>Finishing Setup...</h1> <div class='section'> <div class="content" style="padding: 30px; padding-bottom: 0px"> - Please wait while we setup your device. Once the setup is complete the user LED on the Rigado Gateway will turn solid green. <b> When that happens, you can connect to the Rigado Gateway by joining <i>this</i> machine to the 'params_new_wifi' - network</b> + 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: + <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> </div> diff --git a/public/index.html b/public/index.html index dca7bd09ae93f2276f595f474c3142f73cff6b46..55e79fa6e8a4a62a03250316c018b6c578acb184 100755 --- a/public/index.html +++ b/public/index.html @@ -252,15 +252,7 @@ <div class="submit_section"> <input class="submit_button" type="submit" value="Submit"> </div> - - <div class="section" align="center"> - This IoT Gateway includes Node-RED, a web-based tool for building Node.js applications. - <br> - The Node-RED web application is accessible at: - <a href="http://params_hostname:params_node_red_http_port">http://params_hostname:params_node_red_http_port</a> - </div> - - <div class="warning"> + <div class="warning"> <body> This application does not require or manage Passwords and you are responsible for securing your Gateway. <br> diff --git a/server.js b/server.js index 3f0ec5377693ed3d316637786b72c862d63f4e2e..208efcbdf36968a874a7faeb9af79a4b82c5ad45 100755 --- a/server.js +++ b/server.js @@ -246,7 +246,14 @@ function submitForm(params, res, req) { console.log(ex); } - var hostname = nameobj.hostname, ssid = nameobj.ssid; + var hostname = nameobj.hostname + var ssid = nameobj.ssid; + + //hostname is in format: [serial_num].rigadogateway.com, we just want [serial_num]. + var node_red_url = hostname.split(".", 1); + var node_red_port = NODE_RED_PORT.toString().trim(); + + //html response var res_str; if (params.name) { @@ -259,17 +266,32 @@ function submitForm(params, res, req) { res_str = fs.readFileSync(site + '/exiting-without-wifi.html', {encoding: 'utf8'}) } + //error handling for host_url + if(!node_red_url) { + node_red_url = "unknown.local"; + } else { + node_red_url = node_red_url + ".local"; + } + 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"); - res.end(res_str); + + 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); - commands.push({cmd: BIN_DIR+"/configure_gateway", args: ["--disableOneTimeSetup", "--persist"]}); + res.end(res_str); - // Now execute the commands serially - runCmd(0, commands); + //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); + }); } @@ -340,21 +362,7 @@ function requestHandler(req, res) { } }); } else { - exec ('/usr/bin/unit_serial_number', function (error, stdout, stderr) { - var sn = stdout.trim(); - if(error || !sn ) { - console.log("error getting serial number!", error); - sn = "unknown" - } - - var res_str = getStateBasedIndexPage(); - var host_url = sn + ".local"; - var host_port = NODE_RED_PORT.toString().trim(); - - res_str = res_str.replace(/params_hostname/g, host_url); - res_str = res_str.replace(/params_node_red_http_port/g, host_port); - res.end(res_str); - }); + res.end(getStateBasedIndexPage()); } } else if (urlobj.pathname === '/wifiNetworks') { if (fs.existsSync(NETWORKS_FILE)) {