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 - npm Package Compare versions

Comparing version 0.6.35 to 0.6.36

10

dist/iMeshDevice.d.ts

@@ -33,3 +33,3 @@ import { SubEvent } from "sub-events";

/**
* @TODO desc
* Keeps track of all requests sent to the radio that have callbacks
*/

@@ -233,5 +233,11 @@ private responseQueue;

* Gets devices RadioConfig
* @param callback If wantAck is true, callback is called when the ack is received
*/
getPreferences(): Promise<void>;
getPreferences(callback?: (id: number) => Promise<void>): Promise<void>;
/**
* Gets devices Owner
* @param callback If wantAck is true, callback is called when the ack is received
*/
getOwner(callback?: (id: number) => Promise<void>): Promise<void>;
/**
* Triggers the device configure process

@@ -238,0 +244,0 @@ */

69

dist/iMeshDevice.js

@@ -35,3 +35,3 @@ import { SubEvent } from "sub-events";

/**
* @TODO desc
* Keeps track of all requests sent to the radio that have callbacks
*/

@@ -53,5 +53,4 @@ responseQueue;

});
this.onMyNodeInfo.subscribe(async (myNodeInfo) => {
this.onMyNodeInfo.subscribe((myNodeInfo) => {
this.myNodeInfo = myNodeInfo;
await this.getAllChannels();
});

@@ -185,2 +184,3 @@ this.onAdminPacket.subscribe((adminPacket) => {

sendText(text, destinationNum, wantAck = false, channel = 0, callback) {
log(`IMeshDevice.sendText`, `Sending message to ${destinationNum} with text ${text}`, LogRecord_Level.DEBUG);
const enc = new TextEncoder();

@@ -200,2 +200,3 @@ return this.sendPacket(enc.encode(text), PortNum.TEXT_MESSAGE_APP, destinationNum, wantAck, channel, undefined, true, callback);

async sendPacket(byteData, portNum, destinationNum, wantAck = false, channel = 0, wantResponse = false, echoResponse = false, callback) {
log(`IMeshDevice.sendPacket`, `Sending ${Protobuf.PortNum[portNum]} to ${destinationNum}`, LogRecord_Level.TRACE);
const meshPacket = MeshPacket.create({

@@ -247,3 +248,3 @@ payloadVariant: {

if (toRadio.length > 512) {
log(`IMeshDevice.sendPacket`, `Message longer than 512 bytes, it will not be sent!`, LogRecord_Level.WARNING);
log(`IMeshDevice.sendRaw`, `Message longer than 512 bytes, it will not be sent!`, LogRecord_Level.WARNING);
}

@@ -260,2 +261,3 @@ else {

async setPreferences(preferences, callback) {
log(`IMeshDevice.setPreferences`, `Setting preferences ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const setRadio = AdminMessage.toBinary(AdminMessage.create({

@@ -279,2 +281,3 @@ variant: {

async confirmSetPreferences(callback) {
log(`IMeshDevice.confirmSetPreferences`, `Confirming preferences ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const confirmSetRadio = AdminMessage.toBinary(AdminMessage.create({

@@ -294,2 +297,3 @@ variant: {

async setOwner(owner, callback) {
log(`IMeshDevice.setOwner`, `Setting owner ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const setOwner = AdminMessage.toBinary(AdminMessage.create({

@@ -302,4 +306,3 @@ variant: {

await this.sendPacket(setOwner, PortNum.ADMIN_APP, this.myNodeInfo.myNodeNum, true, 0, true, false, async (id) => {
// @todo call getOwner once implemented
await Promise.resolve();
await this.getOwner();
callback && callback(id);

@@ -314,2 +317,3 @@ });

async setChannel(channel, callback) {
log(`IMeshDevice.setChannel`, `Setting Channel: ${channel.index} ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const setChannel = AdminMessage.toBinary(AdminMessage.create({

@@ -331,2 +335,3 @@ variant: {

async confirmSetChannel(callback) {
log(`IMeshDevice.confirmSetChannel`, `Confirming Channel config ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const confirmSetChannel = AdminMessage.toBinary(AdminMessage.create({

@@ -346,2 +351,3 @@ variant: {

async deleteChannel(index, callback) {
log(`IMeshDevice.deleteChannel`, `Deleting Channel ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const channel = Protobuf.Channel.create({

@@ -351,3 +357,3 @@ index,

});
const deleteChannel = AdminMessage.toBinary(AdminMessage.create({
const setChannel = AdminMessage.toBinary(AdminMessage.create({
variant: {

@@ -358,3 +364,3 @@ setChannel: channel,

}));
await this.sendPacket(deleteChannel, PortNum.ADMIN_APP, this.myNodeInfo.myNodeNum, true, 0, true, false, async (id) => {
await this.sendPacket(setChannel, PortNum.ADMIN_APP, this.myNodeInfo.myNodeNum, true, 0, true, false, async (id) => {
await this.getChannel(channel.index);

@@ -370,3 +376,4 @@ callback && callback(id);

async getChannel(index, callback) {
await this.sendPacket(AdminMessage.toBinary(AdminMessage.create({
log(`IMeshDevice.getChannel`, `Requesting Channel: ${index} ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const getChannelRequest = AdminMessage.toBinary(AdminMessage.create({
variant: {

@@ -376,3 +383,4 @@ getChannelRequest: index + 1,

}
})), PortNum.ADMIN_APP, this.myNodeInfo.myNodeNum, true, 0, true, false, callback);
}));
await this.sendPacket(getChannelRequest, PortNum.ADMIN_APP, this.myNodeInfo.myNodeNum, true, 0, true, false, callback);
}

@@ -384,2 +392,3 @@ /**

async getAllChannels(callback) {
log(`IMeshDevice.getAllChannels`, `Requesting all Channels ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const queue = [];

@@ -397,5 +406,7 @@ for (let i = 0; i <= this.myNodeInfo.maxChannels; i++) {

* Gets devices RadioConfig
* @param callback If wantAck is true, callback is called when the ack is received
*/
async getPreferences() {
await this.sendPacket(AdminMessage.toBinary(AdminMessage.create({
async getPreferences(callback) {
log(`IMeshDevice.getPreferences`, `Requesting preferences ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const getRadioRequest = AdminMessage.toBinary(AdminMessage.create({
variant: {

@@ -405,5 +416,20 @@ getRadioRequest: true,

}
})), PortNum.ADMIN_APP, this.myNodeInfo.myNodeNum, true, 0, true);
}));
await this.sendPacket(getRadioRequest, PortNum.ADMIN_APP, this.myNodeInfo.myNodeNum, true, 0, true, false, callback);
}
/**
* Gets devices Owner
* @param callback If wantAck is true, callback is called when the ack is received
*/
async getOwner(callback) {
log(`IMeshDevice.getOwner`, `Requesting owner ${callback ? "with" : "without"} callback`, LogRecord_Level.DEBUG);
const getOwnerRequest = AdminMessage.toBinary(AdminMessage.create({
variant: {
getOwnerRequest: true,
oneofKind: "getOwnerRequest"
}
}));
await this.sendPacket(getOwnerRequest, PortNum.ADMIN_APP, this.myNodeInfo.myNodeNum, true, 0, true, false, callback);
}
/**
* Triggers the device configure process

@@ -420,4 +446,2 @@ */

})));
await this.getPreferences();
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONFIGURED);
}

@@ -496,2 +520,17 @@ /**

}
await this.writeToRadio(ToRadio.toBinary(ToRadio.create({
payloadVariant: {
peerInfo: {
appVersion: 1,
mqttGateway: false
},
oneofKind: "peerInfo"
}
})));
await this.getPreferences(async () => {
await this.getAllChannels(async () => {
await Promise.resolve();
});
});
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONFIGURED);
break;

@@ -498,0 +537,0 @@ case "rebooted":

@@ -49,3 +49,5 @@ import { Types } from "./index.js";

await this.disconnect();
// TODO: Handle non-fatal read error.
/**
* @todo, Handle non-fatal read error.
*/
}

@@ -108,2 +110,3 @@ }

async disconnect() {
await this.reader.cancel();
await this.port?.close();

@@ -123,2 +126,5 @@ this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_DISCONNECTED);

async writeToRadio(data) {
while (this.writer.locked) {
await new Promise((resolve) => setTimeout(resolve, 100));
}
const writer = this.writer.getWriter();

@@ -125,0 +131,0 @@ await writer.write(new Uint8Array([0x94, 0xc3, 0x00, data.length, ...data]));

{
"name": "@meshtastic/meshtasticjs",
"version": "0.6.35",
"version": "0.6.36",
"description": "Browser library for interfacing with meshtastic devices",

@@ -31,8 +31,8 @@ "license": "GPL-3.0-only",

"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/core": "^7.16.5",
"@protobuf-ts/plugin": "2.1.0",
"@types/w3c-web-serial": "^1.0.2",
"@types/web-bluetooth": "^0.0.11",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"@types/web-bluetooth": "^0.0.12",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"@verypossible/eslint-config": "^1.6.1",

@@ -53,3 +53,3 @@ "babel-plugin-module-resolver": "^4.1.0",

"typedoc": "^0.22.10",
"typescript": "^4.5.3"
"typescript": "^4.5.4"
},

@@ -56,0 +56,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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