https://github.com/hlfshell/serial-synapse-socket
Given a synapse object, create a socket server for the device
https://github.com/hlfshell/serial-synapse-socket
Last synced: 12 months ago
JSON representation
Given a synapse object, create a socket server for the device
- Host: GitHub
- URL: https://github.com/hlfshell/serial-synapse-socket
- Owner: hlfshell
- Created: 2016-06-19T19:28:19.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-20T00:44:46.000Z (about 10 years ago)
- Last Synced: 2025-04-04T05:42:58.338Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# synapse-serial-socket
Given a synapse object, create a socket server for the device. This is an accessory module for [Serial Synapse](https://github.com/hlfshell/serial-synapse).
#Install
```
npm install serial-synapse-socket
```
#Example
```
//Assuming you created a synapse object called synapse
var SynapseServer = require('serial-synapse-socket');
var server = new SynapseServer({
port: 8080,
synapse: synapse
});
```
...That's it!
#Command syntax
synapse-serial-socket is expecting incoming messages to always be a JSON formatted message. It requires a command attribute, and and args attribute. If it is a single argument, you can just send it alone. Multiple arguments can be sent in an array in the order they are to be sent.
For example:
```
{
"command": "drive",
"args": 255
}
//OR
{
"command": "stepDistance",
"args": [1, 217]
}
```
#Example
I've put together [a quick example](https://github.com/hlfshell/redbot-synapse-example) using a sub $100 robot you can buy off of Sparkfun.
#TODO
1 - There is no authentication yet
2 - Your update functions (*then*) are overridden in this version with one that broadcasts the data to all connected clients.