Commit 6f9e0638 authored by David Mondou's avatar David Mondou
Browse files

Merge branch 'feature/move_demo_url' into 'master'

Feature/move demo url

See merge request !5
parents b86b4940 8dd1f6f1
<!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 <font color="#800000">Node-RED</font> web interface here:
<a href="http://params_node_red_url">http://params_node_red_url</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,30 +246,59 @@ 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);
//html response
var res_str;
if ( {
hostname = ssid =;
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'})
//error handling for host_url
if(!node_red_url) {
node_red_url = "unknown.local";
} else {
node_red_url = node_red_url + ".local";
//append the port if not port 80
if(NODE_RED_PORT !== 80) {
node_red_url = node_red_url + ":" + NODE_RED_PORT.toString().trim();
//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);
//send the html response
commands.push({cmd: BIN_DIR+"/configure_gateway", args: ["--disableOneTimeSetup", "--persist"]});
//wait 5s before sending the configure command so the exit page can be loaded
setTimeout( function() {
commands.push({cmd: BIN_DIR+"/configure_gateway", args: ["--disableOneTimeSetup", "--persist"]});
// Now execute the commands serially
runCmd(0, commands);
}, 5000);
// Now execute the commands serially
runCmd(0, commands);
......@@ -340,21 +369,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