A library for accessing Particle USB devices
npm install particle-usb!CI
A library for accessing Particle USB devices.
Note: This library requires Particle firmware 0.8.0 or later.
Installation | Usage | API Reference | Development | Testing | Releasing | License
Using npm:
``sh`
$ npm install particle-usb @particle/device-constants
_NOTE: particle-usb declares @particle/device-constants as a peerDependency - this ensures your app only ever has one copy of that dependency_
In Node.js:
`js`
import * as usb from 'particle-usb';
`js`
const devices = await usb.getDevices();
for (let device of devices) {
console.log(device.type); // Prints device type, e.g. "Photon"
}
Most of the device methods, such as reset(), require the device to be open:
`js`
const devices = await usb.getDevices();
if (devices.length == 0) {
throw new Error('No devices found');
}
const device = devices[0];
await device.open();
await device.reset(); // Resets the device
It is possible to open a device by ID:
`js`
const device = await usb.openDeviceById('0123456789abcdef01234567');
await device.reset();
The device should be closed when it is no longer needed:
`js`
await device.close();
For more information, read the API reference on GitHub.
1. Install Node.js [node@12.x and npm@8.x are required]$ git clone git@github.com:particle-iot/particle-usb.git && cd ./particle-usb
1. Clone this repository $ npm install
1. Install dependencies $ npm run
1. View available commands $ npm test
1. Run the tests
1. Start Hacking!
Particle USB has a number of automated test suites and related commands. The most important are:
* npm test - run all testsnpm run test:e2e
* - run all end-to-end tests _NOTE: Requires additional setup_npm run test:ci
* - run all tests excluding device-dependent end-to-end tests as CI doesnpm run lint
* - run the linter and print any errors to your terminalnpm run coverage` - report code coverage stats
*
All tests use mocha, chai, and sinon with coverage handled by nyc.
We recommend running locally if you can as it greatly shortens your feedback loop. However, CI also runs against every PR and error reporting is publicly available.
For release instructions, see RELEASE.md
This library is released under the Apache 2.0 license. See LICENSE for details.