bfs-backend-example
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

bfs-backend-example package

This package has been specifically designed and implemented for use in bits-fusion workshops. It is intended to be utilized in a Node.js environment with TypeScript. The package serves as a wrapper for two dependencies, namely serialport and express, and offers straightforward APIs to facilitate rapid development.

Install dependencies

Go to project directory and install dependencies

npm install bfs-backend-example

Examples

Example 1 - Serial Port

/**
 * Example 1 - Serial Port
 * What is your port name?
 * - Windows: Open device manager
 * - Mac: Run `ls /dev/tty.*` in terminal
 */
import { McuSerial } from 'bfs-backend-example';
const PORT_NAME = "COM1"; //!! <-- DEPENDED ON YOUR SYSTEM
new McuSerial(PORT_NAME, {
    onOpen: (link: McuSerial) => {
        link.send("pwmd/3/0.99");
    },
    onData: (data) => {
        console.log(data);
    },
});

Example 2 - Simple Web Server

/**
 * Example 2 - Simple Web Server
 */
import { WebServer } from 'bfs-backend-example';
new WebServer();

Example 3 - Simple Web Server with MCU

/**
 * Example 5 - Simple Web Server with MCU
 * Note:
 *  - Check and set serial port name.
 *  - Goto `http://localhost:3000/mcu` to get MCU message.
 */
import { McuSerial, WebServer } from 'bfs-backend-example';
new WebServer(new McuSerial("COMx"));//!! <-- DEPENDED ON YOUR SYSTEM

Readme

Keywords

none

Package Sidebar

Install

npm i bfs-backend-example

Weekly Downloads

2

Version

0.0.3

License

ISC

Unpacked Size

7.3 kB

Total Files

7

Last publish

Collaborators

  • drsanti