Update de grbl avec un plus grand buffer et un peu de doc en plus

This commit is contained in:
Geekoid
2019-12-18 21:26:27 +01:00
parent c24dd1bb34
commit dd41d3358a
159 changed files with 38922 additions and 18 deletions

View File

@ -0,0 +1,49 @@
<html>
<head>
<script>
var connection = new WebSocket('ws://10.11.2.1:81/', ['arduino']);
connection.onopen = function () {
connection.send('Message from Browser to ESP8266 yay its Working!! ' + new Date());
connection.send('ping');
/* setInterval(function() {
connection.send('Time: ' + new Date());
}, 20);
*/
connection.send('Time: ' + new Date());
};
connection.onerror = function (error) {
console.log('WebSocket Error ', error);
};
connection.onmessage = function (e) {
console.log('Server: ', e.data);
connection.send('Time: ' + new Date());
};
function sendRGB() {
var r = parseInt(document.getElementById('r').value).toString(16);
var g = parseInt(document.getElementById('g').value).toString(16);
var b = parseInt(document.getElementById('b').value).toString(16);
if(r.length < 2) { r = '0' + r; }
if(g.length < 2) { g = '0' + g; }
if(b.length < 2) { b = '0' + b; }
var rgb = '#'+r+g+b;
console.log('RGB: ' + rgb);
connection.send(rgb);
}
</script>
</head>
<body>
LED Control:<br/>
<br/>
R: <input id="r" type="range" min="0" max="255" step="1" onchange="sendRGB();" /><br/>
G: <input id="g" type="range" min="0" max="255" step="1" onchange="sendRGB();" /><br/>
B: <input id="b" type="range" min="0" max="255" step="1" onchange="sendRGB();" /><br/>
</body>
</html>

View File

@ -0,0 +1,57 @@
#!/usr/bin/env node
var WebSocketServer = require('websocket').server;
var http = require('http');
var server = http.createServer(function(request, response) {
console.log((new Date()) + ' Received request for ' + request.url);
response.writeHead(404);
response.end();
});
server.listen(8011, function() {
console.log((new Date()) + ' Server is listening on port 8011');
});
wsServer = new WebSocketServer({
httpServer: server,
// You should not use autoAcceptConnections for production
// applications, as it defeats all standard cross-origin protection
// facilities built into the protocol and the browser. You should
// *always* verify the connection's origin and decide whether or not
// to accept it.
autoAcceptConnections: false
});
function originIsAllowed(origin) {
// put logic here to detect whether the specified origin is allowed.
return true;
}
wsServer.on('request', function(request) {
if (!originIsAllowed(request.origin)) {
// Make sure we only accept requests from an allowed origin
request.reject();
console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');
return;
}
var connection = request.accept('arduino', request.origin);
console.log((new Date()) + ' Connection accepted.');
connection.on('message', function(message) {
if (message.type === 'utf8') {
console.log('Received Message: ' + message.utf8Data);
// connection.sendUTF(message.utf8Data);
}
else if (message.type === 'binary') {
console.log('Received Binary Message of ' + message.binaryData.length + ' bytes');
//connection.sendBytes(message.binaryData);
}
});
connection.on('close', function(reasonCode, description) {
console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');
});
connection.sendUTF("Hallo Client!");
});

View File

@ -0,0 +1,27 @@
{
"name": "webSocketServer",
"version": "1.0.0",
"description": "WebSocketServer for testing",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/Links2004/arduinoWebSockets"
},
"keywords": [
"esp8266",
"websocket",
"arduino"
],
"author": "Markus Sattler",
"license": "LGPLv2",
"bugs": {
"url": "https://github.com/Links2004/arduinoWebSockets/issues"
},
"homepage": "https://github.com/Links2004/arduinoWebSockets",
"dependencies": {
"websocket": "^1.0.18"
}
}