@meshtastic/meshtasticjs
Advanced tools
Comparing version 2.0.13-4 to 2.0.13-5
@@ -65,5 +65,3 @@ import { Types } from "../index.js"; | ||
/** Set device state to connecting */ | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTING | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTING); | ||
/** Set device if specified, else request. */ | ||
@@ -74,5 +72,3 @@ this.device = device ?? (await this.getDevice(deviceFilter)); | ||
this.log.info(Types.Emitter[Types.Emitter.connect], "Device disconnected"); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_DISCONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_DISCONNECTED); | ||
this.complete(); | ||
@@ -123,5 +119,3 @@ }); | ||
}); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTED); | ||
void this.configure().catch(() => { | ||
@@ -135,5 +129,3 @@ // TODO: FIX, workaround for `wantConfigId` not getting acks. | ||
this.device?.gatt?.disconnect(); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_DISCONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_DISCONNECTED); | ||
this.complete(); | ||
@@ -162,9 +154,5 @@ } | ||
if (value.byteLength > 0) { | ||
this.handleFromRadio({ | ||
fromRadio: new Uint8Array(readBuffer, 0) | ||
}); | ||
this.handleFromRadio(new Uint8Array(readBuffer)); | ||
} | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTED); | ||
}) | ||
@@ -171,0 +159,0 @@ .catch((e) => { |
@@ -30,5 +30,3 @@ import { Types } from "../index.js"; | ||
async connect({ address, fetchInterval = 3000, receiveBatchRequests = false, tls = false }) { | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTING | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTING); | ||
this.receiveBatchRequests = receiveBatchRequests; | ||
@@ -64,5 +62,3 @@ this.url = `${tls ? "https://" : "http://"}${address}`; | ||
this.abortController.abort(); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_DISCONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_DISCONNECTED); | ||
if (this.readLoop) { | ||
@@ -81,5 +77,3 @@ clearInterval(this.readLoop); | ||
pingSuccessful = true; | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTED); | ||
}) | ||
@@ -89,5 +83,3 @@ .catch((e) => { | ||
this.log.error(Types.Emitter[Types.Emitter.ping], `❌ ${e.message}`); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_RECONNECTING | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_RECONNECTING); | ||
}); | ||
@@ -114,10 +106,6 @@ return pingSuccessful; | ||
this.peningRequest = false; | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTED); | ||
readBuffer = await response.arrayBuffer(); | ||
if (readBuffer.byteLength > 0) { | ||
this.handleFromRadio({ | ||
fromRadio: new Uint8Array(readBuffer, 0) | ||
}); | ||
this.handleFromRadio(new Uint8Array(readBuffer)); | ||
} | ||
@@ -128,5 +116,3 @@ }) | ||
this.log.error(Types.Emitter[Types.Emitter.readFromRadio], `❌ ${e.message}`); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_RECONNECTING | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_RECONNECTING); | ||
}); | ||
@@ -149,5 +135,3 @@ } | ||
.then(async () => { | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTED); | ||
await this.readFromRadio().catch((e) => { | ||
@@ -159,5 +143,3 @@ this.log.error(Types.Emitter[Types.Emitter.writeToRadio], `❌ ${e.message}`); | ||
this.log.error(Types.Emitter[Types.Emitter.writeToRadio], `❌ ${e.message}`); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_RECONNECTING | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_RECONNECTING); | ||
}); | ||
@@ -164,0 +146,0 @@ } |
@@ -47,3 +47,3 @@ import { SubEvent } from "sub-events"; | ||
if (value) { | ||
this.handleFromRadio({ fromRadio: value }); | ||
this.handleFromRadio(value); | ||
} | ||
@@ -71,5 +71,3 @@ }) | ||
/** Set device state to connecting */ | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTING | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTING); | ||
/** Set device if specified, else request. */ | ||
@@ -80,5 +78,3 @@ this.port = port ?? (await this.getPort()); | ||
this.log.info(Types.Emitter[Types.Emitter.connect], "Device disconnected"); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_DISCONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_DISCONNECTED); | ||
this.complete(); | ||
@@ -96,5 +92,3 @@ }); | ||
void this.readFromRadio(reader.getReader()); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONNECTED); | ||
void this.configure().catch(() => { | ||
@@ -122,5 +116,3 @@ // TODO: FIX, workaround for `wantConfigId` not getting acks. | ||
this.onReleaseEvent.emit(true); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_DISCONNECTED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_DISCONNECTED); | ||
this.complete(); | ||
@@ -127,0 +119,0 @@ return Promise.resolve(); |
import { Logger } from "tslog"; | ||
import { Types } from "./index.js"; | ||
import { clearChannelProps, getChannelProps, getConfigProps, getMetadataProps, getModuleConfigProps, handleFromRadioProps, rebootOTAProps, rebootProps, requestPositionProps, sendPacketProps, sendRawProps, sendTextProps, setChannelProps, setConfigProps, setModuleConfigProps, setOwnerProps, setPositionProps, shutdownProps, traceRouteProps, updateDeviceStatusProps } from "./types.js"; | ||
import { Protobuf, Types } from "./index.js"; | ||
import { EventSystem } from "./utils/eventSystem.js"; | ||
@@ -40,36 +39,36 @@ import { Queue } from "./utils/queue.js"; | ||
*/ | ||
sendText({ text, destination, wantAck, channel }: sendTextProps): Promise<number>; | ||
sendText(text: string, destination?: Types.Destination, wantAck?: boolean, channel?: Types.ChannelNumber): Promise<number>; | ||
/** | ||
* Sends a text over the radio | ||
*/ | ||
sendWaypoint({ waypoint, destination, channel }: Types.sendWaypointProps): Promise<number>; | ||
sendWaypoint(waypoint: Protobuf.Waypoint, destination: Types.Destination, channel?: Types.ChannelNumber): Promise<number>; | ||
/** | ||
* Sends packet over the radio | ||
*/ | ||
sendPacket({ byteData, portNum, destination, wantAck, channel, wantResponse, echoResponse, emoji, replyId }: sendPacketProps): Promise<number>; | ||
sendPacket(byteData: Uint8Array, portNum: Protobuf.PortNum, destination: Types.Destination, channel?: Types.ChannelNumber, wantAck?: boolean, wantResponse?: boolean, echoResponse?: boolean, replyId?: number, emoji?: number): Promise<number>; | ||
/** | ||
* Sends raw packet over the radio | ||
*/ | ||
sendRaw({ id, toRadio }: sendRawProps): Promise<number>; | ||
sendRaw(toRadio: Uint8Array, id?: number): Promise<number>; | ||
/** | ||
* Writes config to device | ||
*/ | ||
setConfig({ config }: setConfigProps): Promise<number>; | ||
setConfig(config: Protobuf.Config): Promise<number>; | ||
/** | ||
* Writes module config to device | ||
*/ | ||
setModuleConfig({ moduleConfig }: setModuleConfigProps): Promise<number>; | ||
setModuleConfig(moduleConfig: Protobuf.ModuleConfig): Promise<number>; | ||
/** | ||
* Sets devices owner data | ||
*/ | ||
setOwner({ owner }: setOwnerProps): Promise<number>; | ||
setOwner(owner: Protobuf.User): Promise<number>; | ||
/** | ||
* Sets devices ChannelSettings | ||
*/ | ||
setChannel({ channel }: setChannelProps): Promise<number>; | ||
setPosition({ position }: setPositionProps): Promise<number>; | ||
setChannel(channel: Protobuf.Channel): Promise<number>; | ||
setPosition(position: Protobuf.Position): Promise<number>; | ||
/** | ||
* Gets specified channel information from the radio | ||
*/ | ||
getChannel({ index }: getChannelProps): Promise<number>; | ||
getChannel(index: number): Promise<number>; | ||
/** | ||
@@ -79,7 +78,7 @@ * Gets devices config | ||
*/ | ||
getConfig({ configType }: getConfigProps): Promise<number>; | ||
getConfig(configType: Protobuf.AdminMessage_ConfigType): Promise<number>; | ||
/** | ||
* Gets Module config | ||
*/ | ||
getModuleConfig({ moduleConfigType }: getModuleConfigProps): Promise<number>; | ||
getModuleConfig(moduleConfigType: Protobuf.AdminMessage_ModuleConfigType): Promise<number>; | ||
/** Gets devices Owner */ | ||
@@ -90,7 +89,7 @@ getOwner(): Promise<number>; | ||
*/ | ||
getMetadata({ nodeNum }: getMetadataProps): Promise<number>; | ||
getMetadata(nodeNum: number): Promise<number>; | ||
/** | ||
* Clears specific channel with the designated index | ||
*/ | ||
clearChannel({ index }: clearChannelProps): Promise<number>; | ||
clearChannel(index: number): Promise<number>; | ||
/** | ||
@@ -114,5 +113,5 @@ * Confirms the currently set channels, and prevents changes from reverting | ||
/** Shuts down the current node after the specified amount of time has elapsed. */ | ||
shutdown({ time }: shutdownProps): Promise<number>; | ||
shutdown(time: number): Promise<number>; | ||
/** Reboots the current node after the specified amount of time has elapsed. */ | ||
reboot({ time }: rebootProps): Promise<number>; | ||
reboot(time: number): Promise<number>; | ||
/** | ||
@@ -122,3 +121,3 @@ * Reboots the current node into OTA mode after the specified amount of time | ||
*/ | ||
rebootOTA({ time }: rebootOTAProps): Promise<number>; | ||
rebootOTA(time: number): Promise<number>; | ||
/** Factory resets the current node */ | ||
@@ -129,9 +128,9 @@ factoryReset(): Promise<number>; | ||
/** Sends a trace route packet to the designated node */ | ||
traceRoute({ destination }: traceRouteProps): Promise<number>; | ||
traceRoute(destination: number): Promise<number>; | ||
/** Requests position from the designated node */ | ||
requestPosition({ destination }: requestPositionProps): Promise<number>; | ||
requestPosition(destination: number): Promise<number>; | ||
/** | ||
* Updates the device status eliminating duplicate status events | ||
*/ | ||
updateDeviceStatus({ status }: updateDeviceStatusProps): void; | ||
updateDeviceStatus(status: Types.DeviceStatusEnum): void; | ||
/** | ||
@@ -147,3 +146,3 @@ * Generates random packet identifier | ||
*/ | ||
protected handleFromRadio({ fromRadio }: handleFromRadioProps): void; | ||
protected handleFromRadio(fromRadio: Uint8Array): void; | ||
/** Completes all SubEvents */ | ||
@@ -150,0 +149,0 @@ complete(): void; |
import { Logger } from "tslog"; | ||
import { broadCastNum, minFwVer } from "./constants.js"; | ||
import { Protobuf, Types } from "./index.js"; | ||
import { ChannelNumber } from "./types.js"; | ||
import { EventSystem } from "./utils/eventSystem.js"; | ||
@@ -56,13 +55,6 @@ import { Queue } from "./utils/queue.js"; | ||
*/ | ||
async sendText({ text, destination, wantAck, channel }) { | ||
async sendText(text, destination, wantAck, channel) { | ||
this.log.debug(Types.Emitter[Types.Emitter.sendText], `📤 Sending message to ${destination ?? "broadcast"} on channel ${channel?.toString() ?? 0}`); | ||
const enc = new TextEncoder(); | ||
return this.sendPacket({ | ||
byteData: enc.encode(text), | ||
portNum: Protobuf.PortNum.TEXT_MESSAGE_APP, | ||
destination: destination ?? "broadcast", | ||
wantAck, | ||
channel, | ||
echoResponse: true | ||
}); | ||
return this.sendPacket(enc.encode(text), Protobuf.PortNum.TEXT_MESSAGE_APP, destination ?? "broadcast", channel, wantAck, true, true); | ||
} | ||
@@ -72,12 +64,5 @@ /** | ||
*/ | ||
sendWaypoint({ waypoint, destination, channel }) { | ||
sendWaypoint(waypoint, destination, channel) { | ||
this.log.debug(Types.Emitter[Types.Emitter.sendWaypoint], `📤 Sending waypoint to ${destination} on channel ${channel?.toString() ?? 0}`); | ||
return this.sendPacket({ | ||
byteData: waypoint.toBinary(), | ||
portNum: Protobuf.PortNum.WAYPOINT_APP, | ||
destination, | ||
wantAck: true, | ||
channel, | ||
echoResponse: true | ||
}); | ||
return this.sendPacket(waypoint.toBinary(), Protobuf.PortNum.WAYPOINT_APP, destination, channel); | ||
} | ||
@@ -87,3 +72,3 @@ /** | ||
*/ | ||
async sendPacket({ byteData, portNum, destination, wantAck = false, channel = Types.ChannelNumber.PRIMARY, wantResponse = false, echoResponse = false, emoji = 0, replyId = 0 }) { | ||
async sendPacket(byteData, portNum, destination, channel = Types.ChannelNumber.PRIMARY, wantAck = true, wantResponse = true, echoResponse = false, replyId, emoji) { | ||
this.log.trace(Types.Emitter[Types.Emitter.sendPacket], `📤 Sending ${Protobuf.PortNum[portNum]} to ${destination}`); | ||
@@ -124,3 +109,3 @@ const meshPacket = new Protobuf.MeshPacket({ | ||
} | ||
return this.sendRaw({ id: meshPacket.id, toRadio: toRadio.toBinary() }); | ||
return this.sendRaw(toRadio.toBinary(), meshPacket.id); | ||
} | ||
@@ -130,3 +115,3 @@ /** | ||
*/ | ||
async sendRaw({ id = this.generateRandId(), toRadio }) { | ||
async sendRaw(toRadio, id = this.generateRandId()) { | ||
if (toRadio.length > 512) { | ||
@@ -149,3 +134,3 @@ throw new Error("Message longer than 512 bytes, it will not be sent!"); | ||
*/ | ||
async setConfig({ config }) { | ||
async setConfig(config) { | ||
this.log.debug(Types.Emitter[Types.Emitter.setConfig], `Setting config`); | ||
@@ -158,9 +143,3 @@ const setRadio = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: setRadio.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(setRadio.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -170,3 +149,3 @@ /** | ||
*/ | ||
async setModuleConfig({ moduleConfig }) { | ||
async setModuleConfig(moduleConfig) { | ||
this.log.debug(Types.Emitter[Types.Emitter.setModuleConfig], `Setting module config`); | ||
@@ -179,9 +158,3 @@ const setRadio = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: setRadio.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(setRadio.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -191,3 +164,3 @@ /** | ||
*/ | ||
async setOwner({ owner }) { | ||
async setOwner(owner) { | ||
this.log.debug(Types.Emitter[Types.Emitter.setOwner], `Setting owner`); | ||
@@ -200,9 +173,3 @@ const setOwner = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: setOwner.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(setOwner.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -212,3 +179,3 @@ /** | ||
*/ | ||
async setChannel({ channel }) { | ||
async setChannel(channel) { | ||
this.log.debug(Types.Emitter[Types.Emitter.setChannel], `📻 Setting Channel: ${channel.index}`); | ||
@@ -221,18 +188,6 @@ const setChannel = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: setChannel.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(setChannel.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
async setPosition({ position }) { | ||
return this.sendPacket({ | ||
byteData: position.toBinary(), | ||
portNum: Protobuf.PortNum.POSITION_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
async setPosition(position) { | ||
return this.sendPacket(position.toBinary(), Protobuf.PortNum.POSITION_APP, "self"); | ||
} | ||
@@ -242,3 +197,3 @@ /** | ||
*/ | ||
async getChannel({ index }) { | ||
async getChannel(index) { | ||
this.log.debug(Types.Emitter[Types.Emitter.getChannel], `📻 Requesting Channel: ${index}`); | ||
@@ -251,9 +206,3 @@ const getChannelRequest = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: getChannelRequest.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(getChannelRequest.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -264,3 +213,3 @@ /** | ||
*/ | ||
async getConfig({ configType }) { | ||
async getConfig(configType) { | ||
this.log.debug(Types.Emitter[Types.Emitter.getConfig], `Requesting config`); | ||
@@ -273,9 +222,3 @@ const getRadioRequest = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: getRadioRequest.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(getRadioRequest.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -285,3 +228,3 @@ /** | ||
*/ | ||
async getModuleConfig({ moduleConfigType }) { | ||
async getModuleConfig(moduleConfigType) { | ||
this.log.debug(Types.Emitter[Types.Emitter.getModuleConfig], `Requesting module config`); | ||
@@ -294,9 +237,3 @@ const getRadioRequest = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: getRadioRequest.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(getRadioRequest.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -312,9 +249,3 @@ /** Gets devices Owner */ | ||
}); | ||
return this.sendPacket({ | ||
byteData: getOwnerRequest.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(getOwnerRequest.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -324,3 +255,3 @@ /** | ||
*/ | ||
async getMetadata({ nodeNum }) { | ||
async getMetadata(nodeNum) { | ||
this.log.debug(Types.Emitter[Types.Emitter.getMetadata], `Requesting metadata from ${nodeNum}`); | ||
@@ -333,10 +264,3 @@ const getDeviceMetricsRequest = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: getDeviceMetricsRequest.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: nodeNum, | ||
wantAck: true, | ||
channel: Types.ChannelNumber.ADMIN, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(getDeviceMetricsRequest.toBinary(), Protobuf.PortNum.ADMIN_APP, nodeNum, Types.ChannelNumber.ADMIN); | ||
} | ||
@@ -346,3 +270,3 @@ /** | ||
*/ | ||
async clearChannel({ index }) { | ||
async clearChannel(index) { | ||
this.log.debug(Types.Emitter[Types.Emitter.clearChannel], `📻 Clearing Channel ${index}`); | ||
@@ -359,9 +283,3 @@ const channel = new Protobuf.Channel({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: setChannel.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(setChannel.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -380,9 +298,3 @@ /** | ||
}); | ||
return this.sendPacket({ | ||
byteData: confirmSetChannel.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(confirmSetChannel.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -397,7 +309,3 @@ async beginEditSettings() { | ||
}); | ||
return this.sendPacket({ | ||
byteData: beginEditSettings.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self" | ||
}); | ||
return this.sendPacket(beginEditSettings.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -412,7 +320,3 @@ async commitEditSettings() { | ||
}); | ||
return this.sendPacket({ | ||
byteData: commitEditSettings.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self" | ||
}); | ||
return this.sendPacket(commitEditSettings.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -434,9 +338,3 @@ /** | ||
}); | ||
return this.sendPacket({ | ||
byteData: confirmSetRadio.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(confirmSetRadio.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -455,12 +353,6 @@ /** | ||
}); | ||
return this.sendPacket({ | ||
byteData: resetPeers.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(resetPeers.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
/** Shuts down the current node after the specified amount of time has elapsed. */ | ||
async shutdown({ time }) { | ||
async shutdown(time) { | ||
this.log.debug(Types.Emitter[Types.Emitter.shutdown], `🔌 Shutting down ${time > 2 ? "now" : `in ${time} seconds`}`); | ||
@@ -473,12 +365,6 @@ const shutdown = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: shutdown.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(shutdown.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
/** Reboots the current node after the specified amount of time has elapsed. */ | ||
async reboot({ time }) { | ||
async reboot(time) { | ||
this.log.debug(Types.Emitter[Types.Emitter.reboot], `🔌 Rebooting node ${time > 0 ? "now" : `in ${time} seconds`}`); | ||
@@ -491,9 +377,3 @@ const reboot = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: reboot.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(reboot.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -504,3 +384,3 @@ /** | ||
*/ | ||
async rebootOTA({ time }) { | ||
async rebootOTA(time) { | ||
this.log.debug(Types.Emitter[Types.Emitter.rebootOTA], `🔌 Rebooting into OTA mode ${time > 0 ? "now" : `in ${time} seconds`}`); | ||
@@ -513,9 +393,3 @@ const rebootOTA = new Protobuf.AdminMessage({ | ||
}); | ||
return this.sendPacket({ | ||
byteData: rebootOTA.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(rebootOTA.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -531,9 +405,3 @@ /** Factory resets the current node */ | ||
}); | ||
return this.sendPacket({ | ||
byteData: factoryReset.toBinary(), | ||
portNum: Protobuf.PortNum.ADMIN_APP, | ||
destination: "self", | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(factoryReset.toBinary(), Protobuf.PortNum.ADMIN_APP, "self"); | ||
} | ||
@@ -543,5 +411,3 @@ /** Triggers the device configure process */ | ||
this.log.debug(Types.Emitter[Types.Emitter.configure], `⚙️ Requesting device configuration`); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONFIGURING | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONFIGURING); | ||
const toRadio = new Protobuf.ToRadio({ | ||
@@ -553,29 +419,14 @@ payloadVariant: { | ||
}); | ||
return this.sendRaw({ | ||
id: this.generateRandId(), | ||
toRadio: toRadio.toBinary() | ||
}); | ||
return this.sendRaw(toRadio.toBinary()); | ||
} | ||
/** Sends a trace route packet to the designated node */ | ||
async traceRoute({ destination }) { | ||
async traceRoute(destination) { | ||
const routeDiscovery = new Protobuf.RouteDiscovery({ | ||
route: [] | ||
}); | ||
return this.sendPacket({ | ||
byteData: routeDiscovery.toBinary(), | ||
portNum: Protobuf.PortNum.ROUTING_APP, | ||
destination: destination, | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
return this.sendPacket(routeDiscovery.toBinary(), Protobuf.PortNum.ROUTING_APP, destination); | ||
} | ||
/** Requests position from the designated node */ | ||
async requestPosition({ destination }) { | ||
return this.sendPacket({ | ||
byteData: new Uint8Array(), | ||
portNum: Protobuf.PortNum.POSITION_APP, | ||
destination: destination, | ||
wantAck: true, | ||
wantResponse: true | ||
}); | ||
async requestPosition(destination) { | ||
return this.sendPacket(new Uint8Array(), Protobuf.PortNum.POSITION_APP, destination); | ||
} | ||
@@ -585,3 +436,3 @@ /** | ||
*/ | ||
updateDeviceStatus({ status }) { | ||
updateDeviceStatus(status) { | ||
if (status !== this.deviceStatus) { | ||
@@ -607,3 +458,3 @@ this.events.onDeviceStatus.emit(status); | ||
*/ | ||
handleFromRadio({ fromRadio }) { | ||
handleFromRadio(fromRadio) { | ||
const decodedMessage = Protobuf.FromRadio.fromBinary(fromRadio); | ||
@@ -633,3 +484,3 @@ this.events.onFromRadio.emit(decodedMessage); | ||
from: decodedMessage.payloadVariant.value.num, | ||
channel: ChannelNumber.PRIMARY, | ||
channel: Types.ChannelNumber.PRIMARY, | ||
data: decodedMessage.payloadVariant.value.position | ||
@@ -644,3 +495,3 @@ }); | ||
from: decodedMessage.payloadVariant.value.num, | ||
channel: ChannelNumber.PRIMARY, | ||
channel: Types.ChannelNumber.PRIMARY, | ||
data: decodedMessage.payloadVariant.value.user | ||
@@ -668,5 +519,3 @@ }); | ||
this.log.info(Types.Emitter[Types.Emitter.handleFromRadio], `⚙️ Valid config id reveived from device: ${this.configId}`); | ||
this.updateDeviceStatus({ | ||
status: Types.DeviceStatusEnum.DEVICE_CONFIGURED | ||
}); | ||
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_CONFIGURED); | ||
break; | ||
@@ -735,6 +584,3 @@ case "rebooted": | ||
case "decoded": | ||
this.handleDecodedPacket({ | ||
dataPacket: meshPacket.payloadVariant.value, | ||
meshPacket | ||
}); | ||
this.handleDecodedPacket(meshPacket.payloadVariant.value, meshPacket); | ||
break; | ||
@@ -746,3 +592,3 @@ case "encrypted": | ||
} | ||
handleDecodedPacket({ dataPacket, meshPacket }) { | ||
handleDecodedPacket(dataPacket, meshPacket) { | ||
let adminMessage = undefined; | ||
@@ -749,0 +595,0 @@ let routingPacket = undefined; |
@@ -110,3 +110,3 @@ /// <reference types="web-bluetooth" /> | ||
export type ConnectionType = IBLEConnection | IHTTPConnection | ISerialConnection; | ||
export type destination = number | "self" | "broadcast"; | ||
export type Destination = number | "self" | "broadcast"; | ||
export interface PacketError { | ||
@@ -116,82 +116,1 @@ id: number; | ||
} | ||
export interface sendTextProps { | ||
text: string; | ||
destination?: destination; | ||
wantAck?: boolean; | ||
channel?: ChannelNumber; | ||
} | ||
export interface sendWaypointProps { | ||
waypoint: Protobuf.Waypoint; | ||
destination: destination; | ||
channel?: ChannelNumber; | ||
} | ||
export interface sendPacketProps { | ||
byteData: Uint8Array; | ||
portNum: Protobuf.PortNum; | ||
destination: destination; | ||
wantAck?: boolean; | ||
channel?: ChannelNumber; | ||
wantResponse?: boolean; | ||
echoResponse?: boolean; | ||
emoji?: number; | ||
replyId?: number; | ||
} | ||
export interface sendRawProps { | ||
id?: number; | ||
toRadio: Uint8Array; | ||
} | ||
export interface setConfigProps { | ||
config: Protobuf.Config; | ||
} | ||
export interface setModuleConfigProps { | ||
moduleConfig: Protobuf.ModuleConfig; | ||
} | ||
export interface setOwnerProps { | ||
owner: Protobuf.User; | ||
} | ||
export interface setChannelProps { | ||
channel: Protobuf.Channel; | ||
} | ||
export interface setPositionProps { | ||
position: Protobuf.Position; | ||
} | ||
export interface getChannelProps { | ||
index: number; | ||
} | ||
export interface getConfigProps { | ||
configType: Protobuf.AdminMessage_ConfigType; | ||
} | ||
export interface getModuleConfigProps { | ||
moduleConfigType: Protobuf.AdminMessage_ModuleConfigType; | ||
} | ||
export interface getMetadataProps { | ||
nodeNum: number; | ||
} | ||
export interface clearChannelProps { | ||
index: number; | ||
} | ||
export interface traceRouteProps { | ||
destination: number; | ||
} | ||
export interface requestPositionProps { | ||
destination: number; | ||
} | ||
export interface shutdownProps { | ||
time: number; | ||
} | ||
export interface rebootProps { | ||
time: number; | ||
} | ||
export interface rebootOTAProps { | ||
time: number; | ||
} | ||
export interface updateDeviceStatusProps { | ||
status: DeviceStatusEnum; | ||
} | ||
export interface handleFromRadioProps { | ||
fromRadio: Uint8Array; | ||
} | ||
export interface handleDataPacketProps { | ||
dataPacket: Protobuf.Data; | ||
meshPacket: Protobuf.MeshPacket; | ||
} |
{ | ||
"name": "@meshtastic/meshtasticjs", | ||
"version": "2.0.13-4", | ||
"version": "2.0.13-5", | ||
"description": "Browser library for interfacing with meshtastic devices", | ||
@@ -5,0 +5,0 @@ "license": "GPL-3.0-only", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
179793
2320