This is a small CLI tool to run an express based HTTP server for connecting and controlling Sphero toys via HTTP requests. It uses Sphero Connector Core, a tiny wrapper around the unofficial Sphero V2 API for communicating with Sphero toys.
Install Sphero-Connector-HTTP via npm:
npm install --save sphero-connector-http
Add npm run script to your package.json
:
{
"scripts": {
"sphero-connector-http": "sphero-connector-http"
}
}
Add the following section to your package.json
:
{
"sphero-connector": {
"type": "http"
}
}
Finally, run npm run sphero-connector-http
and sphero-connector-http will start its express server listening on port 3000.
By default, sphero-connector-http will listen on port 3000 for incoming HTTP requests.
You can change the port number (range from 3.000 to 40.000) in the sphero-connector
section of your package.json as follows:
{
"sphero-connector": {
"type": "http",
"port": 7331
}
}
To auto-connect with a Sphero toy on start, you can specify the toy type and name in your package.json.
{
"sphero-connector": {
"type": "http",
"connectOnStart": {
"toyType": "SpheroMini",
"toyName": "SM-0815"
}
}
}
Valid values for toyType
are: SpheroMini
, LightningMcQueen
, R2D2
, R2Q5
, BB9E
.
The toyName
option is currently only supported for toyType: "SpheroMini"
.
POST /connect
(body:{ type: 'SpheroMini' }, name: 'SM-0815' }
)POST /wake
POST /sleep
POST /main-led-color/random
POST /main-led-color/hex
(body:{ color: '#ACADDB' }
)
Please be aware of the licenses of the components used in this project. Everything else that has been developed by the contributions to this project is under MIT License.