-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup appRaspi.js, and startH264player.sh
Update node_modules (again) for FRC 2020.
- Loading branch information
Raspi Config
committed
Jan 31, 2020
1 parent
654f27a
commit 34db3d1
Showing
53 changed files
with
572 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,62 @@ | ||
"use strict"; | ||
|
||
/** | ||
* Run this on a raspberry pi | ||
* then browse (using google chrome/firefox) to http://[pi ip]:5085/ | ||
*/ | ||
const port = 5805; // legal port for competition FMS | ||
const os = require('os'); | ||
const ifaces = os.networkInterfaces(); | ||
const http = require('http'); | ||
const express = require('express'); | ||
const os = require('os'); | ||
const ifaces = os.networkInterfaces(); | ||
const WebStreamerServer = require('./serverRaspi'); | ||
const app = express(); | ||
let ip = undefined; | ||
const os = require('os'); | ||
|
||
//public website | ||
app.use(express.static(__dirname + '/www')); | ||
const server = http.createServer(app); | ||
const silence = new WebStreamerServer(server); | ||
const ip = undefined; | ||
doit(); | ||
|
||
// find our IPv4 address | ||
Object.keys(ifaces).forEach(function (ifname) { | ||
ifaces[ifname].foreach(function(iface) { | ||
if(iface.family == "IPv4" && iface.internal == false) | ||
{ | ||
if(ip == undefined) | ||
{ | ||
ip = iface.address; | ||
return; | ||
} | ||
else | ||
{ | ||
console.log("multiple ip addresses, ignoring: " + | ||
iface.address); | ||
} | ||
} | ||
}); | ||
}); | ||
function doit() | ||
{ | ||
let ip = getIP(); | ||
|
||
const app = express(); | ||
const server = http.createServer(app); | ||
const silence = new WebStreamerServer(server); | ||
app.use(express.static(__dirname + '/www')); // public website | ||
|
||
// start the server on a single interface | ||
try | ||
{ | ||
console.log(`appRaspi listening on ${ip}:${port}`); | ||
server.listen(port, ip); // | ||
} | ||
|
||
// find our IPv4 address | ||
console.log("interfaces:\n"); | ||
for(let ifname of Object.keys(ifaces)) | ||
catch(err) | ||
{ | ||
console.log("appRaspi error: " + err.message); | ||
} | ||
} | ||
|
||
function getIP() | ||
{ | ||
for(let iface of ifaces[ifname]) | ||
// find our IPv4 address | ||
const ifaces = os.networkInterfaces(); | ||
let ip = undefined; | ||
|
||
console.log("host interfaces discovered:"); | ||
for(let ifname of Object.keys(ifaces)) | ||
{ | ||
console.log(`${ifname} ${iface.family} ip:${iface.address}`); | ||
if(iface.family == "IPv4" && iface.internal == false) | ||
for(let iface of ifaces[ifname]) | ||
{ | ||
if(ip == undefined) | ||
{ | ||
ip = iface.address; | ||
} | ||
else | ||
console.log(` ${ifname} ${iface.family} ip:${iface.address}`); | ||
if(iface.family == "IPv4" && iface.internal == false) | ||
{ | ||
console.log("multiple ip addresses, ignoring: " + | ||
iface.address); | ||
if(ip == undefined) | ||
{ | ||
ip = iface.address; | ||
} | ||
else | ||
{ | ||
console.log(" Multiple IPv4 addresses, ignoring: " + | ||
iface.address); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
try | ||
{ | ||
console.log(`appRaspi listening on ${ip}:${port}`); | ||
server.listen(port, ip); // | ||
} | ||
|
||
catch(err) | ||
{ | ||
console.log("appRaspi error: " + err.message); | ||
return ip; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.