Library for controlling toio™Core Cube using Node.js
- Node.js >= 10
- 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
Install toio.js using yarn
:
yarn add @toio/scanner
Or npm
:
npm install @toio/scanner
Here is a quick example to get you started.
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 the cube
cube.move(100, 100, 1000)
// | | `--- duration [ms]
// | `--------- right motor speed
// `-------------- left motor speed
}
main()
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), 10.14 (Mojave) and 10.15(Catalina). On 10.12 (Sierra), the frequency of BLE notify event is slower than others. 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 |