npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bleskomat/web-serial

v1.4.0

Published

JavaScript library to interact with Bleskomat hardware devices in the browser - flash firmware, listen to serial monitor, execute JSON-RPC commands.

Downloads

7

Readme

BleskomatWebSerial

JavaScript library to interact with Bleskomat hardware devices in the browser. The WebSerial API is used to open a serial connection to a hardware device enabling the following:

  • Upload (flash) firmware to the device
  • Verify md5 checksum of flash memory
  • Listen to serial output from the device
  • Use the JSON-RPC over serial API of a device running Bleskomat firmware

Please note that this library requires the WebSerial browser API. As of the time this library was released, only Chrome/Chromium-based browsers have this API available.

This document's table of contents:

Installation

Use npm to install this library in a nodejs project:

npm install @bleskomat/web-serial

Or use the pre-built distribution files found in the dist directory.

Usage

Connect to a Bleskomat hardware device:

const bleskomat = new BleskomatWebSerial();
// This will open a browser dialog which prompts the user to select a serial device.
// If no device is selected, then the promise rejects with an error.
bleskomat.connect().then(() => {
	// Connected!
	console.log('Connected!');
}).catch(error => {
	// Something went wrong...
	console.log({ error });
});

Listen to serial monitor:

// `bleskomat` is an instance of nodejs' EventEmitter class.
// It is possible to listen for messages sent by the device via the serial connection.
bleskomat.on('message', message => {
	console.log({ message });
});

Flash new firmware on the device:

// `firmware` can be a base64-encoded string, instance of Buffer, or instance of Uint8Array.
const firmware = Buffer.from('').toString('base64');
// All the required partitions are uploaded to the device along with the app.
// e.g. bootloader, ota slot, and partitions table.
bleskomat.flash(firmware).then(() => {
	// Finished flashing firmware to device.
	console.log('Finished flashing firmware!');
}).catch(error => {
	// Something went wrong...
	console.log({ error });
});

Pre-built firmware binaries for Bleskomat hardware devices can be found in their source code repositories:

Execute JSON-RPC commands:

// 'echo' sends text to the device which then responds with the same text.
bleskomat.cmd('echo', ['hello!']).then(result => {
	console.log({ result });
}).catch(error => {
	// Something went wrong...
	console.log({ error });
});

// The response from 'getinfo' includes details about installed firmware and other info about the device.
bleskomat.cmd('getinfo').then(result => {
	console.log({ result });
}).catch(error => {
	// Something went wrong...
	console.log({ error });
});

// The response from 'getconfig' is an object containing the device's current configuration.
// e.g. "apiKey.id", "logLevel", etc.
bleskomat.cmd('getconfig').then(result => {
	console.log({ result });
}).catch(error => {
	// Something went wrong...
	console.log({ error });
});

// Use 'setconfig' to change device configurations.
bleskomat.cmd('setconfig', { 'apiKey.id': 'XXX' }).then(result => {
	// `result` will equal true if successful.
	console.log({ result });
}).catch(error => {
	// Something went wrong...
	console.log({ error });
});

Build Distribution Files

Node.js (w/ npm) and make are required to build the library's distribution files.

Download or clone this repository, then install all module dependencies as follows:

npm ci

Now run the build:

npm run build

The distribution files are located in the ./dist directory.

Tests

Both automated and manual tests require a Bleskomat-combatible hardware device connected via USB - e.g. an ESP32 devkit, Lilygo T-Display kit, or Bleskomat PCB.

Automated Tests

The automated tests use Puppeteer to run an instance of Chromium/Chrome browser. Manual selection of the USB device is required. To run the automated tests:

npm test

Manual Testing

Run the following command to prepare manual testing web files and start a local web server:

npm run test:manual

Then open your browser to localhost:8080.

Changelog

See CHANGELOG.md

Support

Need some help? Join us in the official Telegram group or send us an email at [email protected] and we will try our best to respond in a reasonable time. If you have a feature request or bug to report, please open an issue in this project repository.

License

The project is licensed under the GNU General Public License v3 (GPL-3):

You may copy, distribute and modify the software as long as you track changes/dates in source files. Any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions.

Trademark

"Bleskomat" is a registered trademark. You are welcome to hack, fork, build, and use the source code and instructions found in this repository. However, the right to use the name "Bleskomat" with any commercial products or services is withheld and reserved for the trademark owner.