Class SerialConnection

Allows to connect to a Meshtastic device over WebSerial

Hierarchy (view full)

Constructors

Properties

configId: number

Randomly generated number to ensure confiuration lockstep

Defines the connection type as serial

deviceStatus: DeviceStatusEnum

Describes the current state of the device

events: EventSystem
isConfigured: boolean

Describes the current state of the device

log: Logger<unknown>

Logs to the console and the logging event emitter

pendingSettingsChanges: boolean

Are there any settings that have yet to be applied?

pipePromise?: Promise<void>

Unfortunately, this is currently the only way to release the lock on a stream after piping it through a transform stream (https://stackoverflow.com/questions/71262432)

port: undefined | SerialPort

Serial port used to communicate with device.

portId: string
preventLock?: boolean

Should locks be prevented

queue: Queue

Packert queue, to space out transmissions and routing handle errors and acks

readerHack: undefined | ReadableStreamDefaultReader<Uint8Array>
transformer?: TransformStream<Uint8Array, Uint8Array>

Transform stream for parsing raw serial data

xModem: Xmodem

Methods

  • Clears specific channel with the designated index

    Parameters

    • index: number

    Returns Promise<number>

  • Completes all Events

    Returns void

  • Triggers the device configure process

    Returns Promise<number>

  • Initiates the connect process to a Meshtastic device via Web Serial

    Parameters

    Returns Promise<void>

  • Disconnects from the serial port

    Returns Promise<undefined | SerialPort>

  • Factory resets the current config

    Returns Promise<number>

  • Factory resets the current device

    Returns Promise<number>

  • Gets specified channel information from the radio

    Parameters

    • index: number

    Returns Promise<number>

  • Returns undefined | SerialPort

  • Gets devices metadata

    Parameters

    • nodeNum: number

    Returns Promise<number>

  • Gets devices Owner

    Returns Promise<number>

  • Opens browsers connection dialogue to select a serial port

    Parameters

    • Optional filter: SerialPortRequestOptions

    Returns Promise<SerialPort>

  • Gets list of serial ports that can be passed to connect

    Returns Promise<SerialPort[]>

  • Gets called whenever a fromRadio message is received from device, returns fromRadio data

    Parameters

    • fromRadio: Uint8Array

    Returns void

  • Pings device to check if it is avaliable

    Returns Promise<boolean>

  • Reads packets from transformed serial port steam and processes them.

    Parameters

    • reader: ReadableStreamDefaultReader<Uint8Array>

    Returns Promise<void>

  • Reboots the current node after the specified amount of time has elapsed.

    Parameters

    • time: number

    Returns Promise<number>

  • Reboots the current node into OTA mode after the specified amount of time has elapsed.

    Parameters

    • time: number

    Returns Promise<number>

  • Disconnects from the serial port

    Returns Promise<void>

  • Removes a node from the internal NodeDB of the radio by node number

    Parameters

    • nodeNum: number

    Returns Promise<number>

  • Requests position from the designated node

    Parameters

    • destination: number

    Returns Promise<number>

  • Resets the internal NodeDB of the radio, usefull for removing old nodes that no longer exist.

    Returns Promise<number>

  • Sends packet over the radio

    Parameters

    • byteData: Uint8Array
    • portNum: PortNum
    • destination: Destination
    • channel: ChannelNumber = Types.ChannelNumber.Primary
    • wantAck: boolean = true
    • wantResponse: boolean = true
    • echoResponse: boolean = false
    • Optional replyId: number
    • Optional emoji: number

    Returns Promise<number>

  • Sends raw packet over the radio

    Parameters

    • toRadio: Uint8Array
    • id: number = ...

    Returns Promise<number>

  • Sends a text over the radio

    Parameters

    Returns Promise<number>

  • Sends a text over the radio

    Parameters

    Returns Promise<number>

  • Sets devices ChannelSettings

    Parameters

    Returns Promise<number>

  • Writes config to device

    Parameters

    Returns Promise<number>

  • Writes module config to device

    Parameters

    Returns Promise<number>

  • Sets devices owner data

    Parameters

    Returns Promise<number>

  • Parameters

    Returns Promise<number>

  • Shuts down the current node after the specified amount of time has elapsed.

    Parameters

    • time: number

    Returns Promise<number>

  • Sends a trace route packet to the designated node

    Parameters

    • destination: number

    Returns Promise<number>

  • Sends supplied protobuf message to the radio

    Parameters

    • data: Uint8Array

    Returns Promise<void>

Events

onReleaseEvent: SimpleEventDispatcher<boolean>

Fires when disconnect() is called, used to instruct serial port and readers to release there locks

onReleaseEvent

Generated using TypeDoc