Library for controlling toio™Core Cube using Node.js
const { NearestScanner } = require('@toio/scanner')
async function main() {
// start a scanner to find the nearest cube
const cube = await new NearestScanner().start()
// connect to the cube
await cube.connect()
// move cube
cube.move(100, 100, 1000)
// | | `--- duration [ms]
// | `--------- right motor speed
// `------------- left motor speed
}
main()- Node.js >= 8
- This library depends on noble, so follow noble's prerequisites please.
- Windows : needs Bluetooth 4.0 USB adapter. This video is good for beginners - Bluetooth LE with Node.js and Noble on Windows
On Windows, we need additional settings (C++, python and special driver for BLE adapter). Please see noble's setup guide mentioned above.
We recommend 10.13 (High Sierra) and 10.14 (Mojave). On 10.12 (Sierra), the frequency of BLE notify event is slower than 10.13, 10.14 or Windows. This affects position correction logic (like used in chase sample).
Not verified yet, we are waiting for your report.
| Package name | Readme | Description |
|---|---|---|
| @toio/scanner | packages/scanner | Cube scanner |
| @toio/cube | packages/cube | Cube BLE API wrapper |
git clone https://github.com/toio/toio.js.git # clone repository
cd toio.js # move to repository root
yarn install # install dependencies
yarn build # build @toio/* packages
yarn example:<name of example> # start sample application (see below)If yarn command is not existed, type npm install -g yarn to install.
| Name & Source | Command | #cubes | Mat | Description |
|---|---|---|---|---|
| id-reader | yarn example:id-reader |
1 | Yes | read & show toio ID information |
| keyboard-control | yarn example:keyboard-control |
1 | No | move a cube with ↑↓←→ |
| chase | yarn example:chase |
2 | Yes | a cube chase another one |