Compare commits
No commits in common. "6b354fed02e3fb8bd72ce7fc595e75496c13d5af" and "0f45c368e7c06909727bbeba4c62ee743e6d89d4" have entirely different histories.
6b354fed02
...
0f45c368e7
8 changed files with 25 additions and 99 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
node_modules/
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
20
index.js
20
index.js
|
@ -1,15 +1,11 @@
|
||||||
import * as server from './server.js';
|
import * as server from './server.js';
|
||||||
import * as lights from './lights.js';
|
|
||||||
|
|
||||||
const cfg = require('./config.json');
|
console.log(server)
|
||||||
|
server.default(
|
||||||
global.cfg = cfg;
|
(res) => {
|
||||||
|
console.log(`callback: ${res}`);
|
||||||
server.recv(
|
},
|
||||||
(res) => {
|
(res) => {
|
||||||
lights.parse_pattern(JSON.parse(res));
|
console.log(`error callback: ${res}`);
|
||||||
},
|
}
|
||||||
(res) => {
|
|
||||||
console.log(`error callback: ${res}`);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
import * from 'rpi-ws281x-native'
|
|
||||||
|
|
||||||
const fade_ticks = 10;
|
|
||||||
|
|
||||||
export function parse_pattern(pattern) {
|
|
||||||
console.log(pattern)
|
|
||||||
}
|
|
|
@ -13,8 +13,5 @@
|
||||||
"url": "git@ssh.gitdab.com:jane/leds"
|
"url": "git@ssh.gitdab.com:jane/leds"
|
||||||
},
|
},
|
||||||
"author": "jane@j4.pm",
|
"author": "jane@j4.pm",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED"
|
||||||
"dependencies": {
|
|
||||||
"rpi-ws281x-native": "^1.0.3"
|
|
||||||
}
|
|
||||||
}
|
}
|
41
pnpm-lock.yaml
generated
41
pnpm-lock.yaml
generated
|
@ -1,41 +0,0 @@
|
||||||
dependencies:
|
|
||||||
eris: 0.15.1
|
|
||||||
lockfileVersion: 5.2
|
|
||||||
packages:
|
|
||||||
/eris/0.15.1:
|
|
||||||
dependencies:
|
|
||||||
ws: 7.4.6
|
|
||||||
dev: false
|
|
||||||
engines:
|
|
||||||
node: '>=10.4.0'
|
|
||||||
optionalDependencies:
|
|
||||||
opusscript: 0.0.8
|
|
||||||
tweetnacl: 1.0.3
|
|
||||||
resolution:
|
|
||||||
integrity: sha512-IQ3BPW6OjgFoqjdh+irPOa1jFlkotk+WNu2GQQ7QAQfbzQEPZgn+F+hpOxfMUXPHOZMX4sPKLkVDkMHAssBYhw==
|
|
||||||
/opusscript/0.0.8:
|
|
||||||
dev: false
|
|
||||||
optional: true
|
|
||||||
resolution:
|
|
||||||
integrity: sha512-VSTi1aWFuCkRCVq+tx/BQ5q9fMnQ9pVZ3JU4UHKqTkf0ED3fKEPdr+gKAAl3IA2hj9rrP6iyq3hlcJq3HELtNQ==
|
|
||||||
/tweetnacl/1.0.3:
|
|
||||||
dev: false
|
|
||||||
optional: true
|
|
||||||
resolution:
|
|
||||||
integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==
|
|
||||||
/ws/7.4.6:
|
|
||||||
dev: false
|
|
||||||
engines:
|
|
||||||
node: '>=8.3.0'
|
|
||||||
peerDependencies:
|
|
||||||
bufferutil: ^4.0.1
|
|
||||||
utf-8-validate: ^5.0.2
|
|
||||||
peerDependenciesMeta:
|
|
||||||
bufferutil:
|
|
||||||
optional: true
|
|
||||||
utf-8-validate:
|
|
||||||
optional: true
|
|
||||||
resolution:
|
|
||||||
integrity: sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==
|
|
||||||
specifiers:
|
|
||||||
eris: ^0.15.1
|
|
2
run.sh
2
run.sh
|
@ -1,2 +1,2 @@
|
||||||
git pull
|
git pull
|
||||||
node index.js
|
python ./leds.py
|
43
server.js
43
server.js
|
@ -1,36 +1,21 @@
|
||||||
import * as net from 'net';
|
import * as net from 'net';
|
||||||
|
|
||||||
const hostname = '0.0.0.0';
|
const hostname = '0.0.0.0';
|
||||||
const port = 29999;
|
const port = 29997;
|
||||||
|
|
||||||
export function recv(callback, errorCallback) {
|
export default function recv(callback, errorCallback) {
|
||||||
let server = new net.Server();
|
let server = new net.Server();
|
||||||
server.listen(port, hostname, () => {
|
server.listen(port, hostname, () => {
|
||||||
server.on('connection', (con) => {
|
server.on('connect', ()=>{
|
||||||
console.log('connection recieved: ' +
|
console.log('connection recieved')
|
||||||
con.remoteAddress + ":" + con.remotePort);
|
|
||||||
con.on('data', (data) => {
|
|
||||||
callback(data);
|
|
||||||
});
|
|
||||||
con.on('close', () => {
|
|
||||||
console.log('recieved close for ' +
|
|
||||||
con.remoteAddress + ":" + con.remotePort);
|
|
||||||
con.destroy();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.getConnections((err, cons) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`connections: ${cons}`);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
server.on('data', (data) => {
|
||||||
|
callback(data)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
server.on('error', (e) => {
|
server.on('error', (e) => {
|
||||||
server.close();
|
server.close();
|
||||||
errorCallback(e);
|
errorCallback(e);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue