https://github.com/meshcore-dev/meshcore.js
https://github.com/meshcore-dev/meshcore.js
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/meshcore-dev/meshcore.js
- Owner: meshcore-dev
- License: mit
- Created: 2025-02-10T18:28:05.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-20T04:23:59.000Z (12 months ago)
- Last Synced: 2025-08-06T10:43:43.707Z (10 months ago)
- Language: JavaScript
- Size: 266 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MeshCore.js
A Javascript library for interacting with a [MeshCore](https://github.com/ripplebiz/MeshCore) device running the [Companion Radio Firmware](https://github.com/ripplebiz/MeshCore/blob/main/examples/companion_radio/main.cpp).
This library can be used in a Web Browser to connect to MeshCore Companion devices over BLE or USB Serial.
It can also be used in NodeJS to connect to MeshCore Companion devices over TCP/WiFi or USB Serial.
## Supported Connection Methods
- Web Browser
- BLE: [WebBleConnection()](./src/connection/web_ble_connection.js)
- USB/Serial: [WebSerialConnection()](./src/connection/web_serial_connection.js)
- NodeJS
- TCP/WiFi: [TCPConnection("host", "port")](./src/connection/tcp_connection.js)
- USB/Serial: [NodeJSSerialConnection("/dev/ttyUSB0")](./src/connection/nodejs_serial_connection.js)
## Install
```
npm install @liamcottle/meshcore.js
```
## Simple Example
```
import { TCPConnection, NodeJSSerialConnection } from "@liamcottle/meshcore.js";
// serial connections are supported by "companion_radio_usb" firmware
const connection = new NodeJSSerialConnection("/dev/cu.usbmodem14401");
// tcp connections are supported by "companion_radio_wifi" firmware
// const connection = new TCPConnection("10.1.0.226", 5000);
// wait until connected
connection.on("connected", async () => {
// we are now connected
console.log("connected!");
// log contacts
const contacts = await connection.getContacts();
for(const contact of contacts) {
console.log(`Contact: ${contact.advName}`);
}
// disconnect
connection.close();
});
// connect to meshcore device
await connection.connect();
```
## Examples
There's a few other examples scripts in the [examples](./examples) folder.
## License
MIT