Commit e48aa94c authored by Donald Chen's avatar Donald Chen
Browse files

move node-red url from index.html to exit.html, added 5s delay before...

move node-red url from index.html to exit.html, added 5s delay before configuring wifi so the browser can have a chance to load the whole page before tearing down the wlan interface.
parent b86b4940
<!DOCTYPE html>
<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 @@
<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'
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>
......@@ -252,15 +252,7 @@
<div class="submit_section">
<input class="submit_button" type="submit" value="Submit">
<div class="section" align="center">
This IoT Gateway includes Node-RED, a web-based tool for building Node.js applications.
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 class="warning">
<div class="warning">
This application does not require or manage Passwords and you are responsible for securing your Gateway.
......@@ -246,7 +246,14 @@ function submitForm(params, res, req) {
var hostname = nameobj.hostname, ssid = nameobj.ssid;
var hostname = nameobj.hostname
var ssid = nameobj.ssid;
//hostname is in format: [serial_num], 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 ( {
......@@ -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_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"]});
// 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);
} else if (urlobj.pathname === '/wifiNetworks') {
if (fs.existsSync(NETWORKS_FILE)) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment