Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@meshtastic/meshtasticjs

Package Overview
Dependencies
Maintainers
1
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meshtastic/meshtasticjs

Browser library for interfacing with meshtastic devices

  • 0.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-75.86%
Maintainers
1
Weekly downloads
 
Created
Source

Meshtastic.js

Overview

Meshtastic.js is a JavaScript library that provides an interface to Meshtastic devices. It can be used to build applications to interface with a Meshtastic network. Currently HTTP(S) and Bluetooth connections are supported.

Documentation/API Reference

Installation & Usage

The library is available from NPM and can be installed with:

yarn add @meshtastic/meshtasticjs
npm install @meshtastic/meshtasticjs
Usage

The library has a built in connection manager that will handle multiple devices of different connection types.

import {
  Client,
  Types,
  SettingsManager,
} from "meshtasticjs";

/**
 * Instantiate a new device manager
 */
const client = new Client();

/**
 * Optional: Set the logging level
 */
SettingsManager.setDebugMode(Protobuf.LogLevelEnum.DEBUG);

/**
 * Create the connection type of your choice
 */
const httpConnection = client.createHTTPConnection();
const bleConnection = client.createBLEConnection();

/**
 * Connect to the device with the desired paramaters
 */
httpConnection.connect(...connectionParams);
bleConnection.connect(...connectionParams);

/**
 * Device can now be accessed individually or via `deviceInterfaces`
 */
client.deviceInterfaces.forEach(connection => {
  ...
});

All events can be handled via any of the inbuilt onxEvent methods.

httpConnection.onFromRadioEvent.subscribe(event => {
    ...
});

Sending data

Data in multiple formats can be send over the radio

/**
 * Plaintext message
 */
bleConnection.sendText("Message");

/**
 * With recipient
 */
bleConnection.sendText("Message", 1234);

/**
 * Arbitrary data
 */
bleConnection.sendPacket(
  new Uint8Array([...data]),
  Protobuf.PortNumEnum.PRIVATE_APP
);

/**
 * Send custom location
 */
bleConnection.sendPosition(lat, lng, alt, time);

Compatibility

The Bluetooth connection option relies on the availability of the Web Bluetooth API, which is represented in the compatibility matrix below.

Keywords

FAQs

Package last updated on 21 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc