Skip to content

Commit

Permalink
INITIAL COMMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
acien101 committed Jul 3, 2018
1 parent 6fb53f9 commit ffd1ea7
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
copytoproduction.sh
utils/log.txt
bower_components/
config.json
**/.DS_Store
.idea/

# Logs
logs
utils/*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages
/bower_components
bower_components/**

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
12 changes: 12 additions & 0 deletions configsample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"database_user": "",
"database_password": "",
"web_host": "0.0.0.0",
"web_port": 8002,
"aprsfi_apikey": "",
"serial_rotors": "/dev/ttyUSB0",
"serial_transceiver_keenwoodts2000": "/dev/ttyS0",
"serial_transceiver_icom9100": "/dev/ttyUSB1",
"log_file": "utils/log.txt",
"log_size_sent": "10000"
}
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "cosmos-tcpserver",
"version": "1.0.0",
"description": "GranaSAT Dashboard",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/granasat/GranaSatDashboard.git"
},
"author": "Granasat",
"license": "ISC",
"bugs": {
"url": "https://github.com/granasat/GranaSatDashboard/issues"
},
"homepage": "https://github.com/granasat/GranaSatDashboard#readme",
"dependencies": {
"colors": "^1.1.2",
"dateformat": "^1.0.12",
"mysql": "^2.11.1"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-wiredep": "^3.0.1"
}
}
33 changes: 33 additions & 0 deletions tcpServerTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
SOURCE: https://gist.github.com/tedmiston/5935757
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it.
And connect with a tcp client from the command line using netcat, the *nix
utility for reading and writing across tcp/udp network connections. I've only
used it for debugging myself.
$ netcat 127.0.0.1 1337
MODIFIED FOR SAVING INPUT DATA TO A FILE
*/

//Log
var log = require('./utils/logger.js').Logger;

//Config
var config = require('./config.json');

var net = require('net');

var server = net.createServer(function(socket) {
socket.on('data', function (input) {
log("Received data: " + input.toString('utf8'), "info");
});
});

server.listen(config.web_port, config.web_host);
console.log("Listening on port " + config.web_port + " on " + config.web_host);


36 changes: 36 additions & 0 deletions utils/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var config = require('../config.json')
var colors = require('colors')
var dateFormat = require('dateformat')
var fs = require('fs')


exports.Logger = function(msg, type) {

var d = dateFormat(new Date(), "dd/mm/yyyy HH:MM:ss");
var s = d + " -> " + msg + "\n";

fs.appendFile(config.log_file, s, function (err) {
if (err){
console.log(d.grey + " Log file Error: ".red + err.red);
}
});

if (type == "warn") {
console.log(d.grey + " Warn: ".yellow + msg.yellow.italic);
} else if (type == "error") {
console.log(d.grey + " Error: ".red + msg.red);
} else {
console.log(d.grey + " Info: ".green + msg.green);
}
}

exports.APRSLogger = function(msg) {

var d = dateFormat(new Date(), "dd/mm/yyyy HH:MM:ss");
var s = d + " -> " + msg + "\n";

fs.appendFile(config.aprs_log_file, s, function (err) {
if (err) throw err;
});

}

0 comments on commit ffd1ea7

Please sign in to comment.