Options
All
  • Public
  • Public/Protected
  • All
Menu

Allows to connect to a Meshtastic device over WebSerial

Hierarchy

Index

Constructors

constructor

Events

Readonly onAdminPacket

onAdminPacket: SubEvent<AdminPacket> = ...

Fires when a new MeshPacket message containing an AdminMessage packet has been received from device

Readonly onAtakPacket

onAtakPacket: SubEvent<AtakPacket> = ...

Fires when a new MeshPacket message containing a ATAK packet has been received from device

Readonly onDeviceStatus

onDeviceStatus: SubEvent<DeviceStatusEnum> = ...

Fires when the devices connection or configuration status changes

Readonly onEnvironmentPacket

onEnvironmentPacket: SubEvent<EnvironmentPacket> = ...

Fires when a new MeshPacket message containing a Environmental Meassurement packet has been received from device

Readonly onFromRadio

onFromRadio: SubEvent<Protobuf.FromRadio> = ...

Fires when a new FromRadio message has been received from the device

Readonly onIpTunnelPacket

onIpTunnelPacket: SubEvent<IpTunnelPacket> = ...

Fires when a new MeshPacket message containing a IP Tunnel packet has been received from device

Readonly onLogRecord

onLogRecord: SubEvent<Protobuf.LogRecord> = ...

Fires when a new FromRadio message containing a Text packet has been received from device

Readonly onMeshHeartbeat

onMeshHeartbeat: SubEvent<Date> = ...

Fires when the device receives a meshPacket, returns a timestamp

Readonly onMeshPacket

onMeshPacket: SubEvent<Protobuf.MeshPacket> = ...

Fires when a new FromRadio message containing a Data packet has been received from the device

Readonly onNodeInfoPacket

onNodeInfoPacket: SubEvent<NodeInfoPacket> = ...

Fires when a new MeshPacket message containing a NodeInfo packet has been received from device

Readonly onPingPacket

onPingPacket: SubEvent<PingPacket> = ...

Fires when a new MeshPacket message containing a Ping packet has been received from device

Readonly onPositionPacket

onPositionPacket: SubEvent<PositionPacket> = ...

Fires when a new MeshPacket message containing a Position packet has been received from device

Readonly onPrivatePacket

onPrivatePacket: SubEvent<PrivatePacket> = ...

Fires when a new MeshPacket message containing a Private packet has been received from device

Readonly onRangeTestPacket

onRangeTestPacket: SubEvent<RangeTestPacket> = ...

Fires when a new MeshPacket message containing a Store and Forward packet has been received from device

Readonly onRemoteHardwarePacket

onRemoteHardwarePacket: SubEvent<RemoteHardwarePacket> = ...

Fires when a new MeshPacket message containing a Remote Hardware packet has been received from device

Readonly onRoutingPacket

onRoutingPacket: SubEvent<RoutingPacket> = ...

Fires when a new MeshPacket message containing a Routing packet has been received from device

Readonly onSerialPacket

onSerialPacket: SubEvent<SerialPacket> = ...

Fires when a new MeshPacket message containing a Serial packet has been received from device

Readonly onStoreForwardPacket

onStoreForwardPacket: SubEvent<StoreForwardPacket> = ...

Fires when a new MeshPacket message containing a Store and Forward packet has been received from device

Readonly onTextPacket

onTextPacket: SubEvent<TextPacket> = ...

Fires when a new MeshPacket message containing a Text packet has been received from device

Readonly onUserPacket

onUserPacket: SubEvent<UserPacket> = ...

Fires when a new MeshPacket message containing a User packet has been received from device

Properties

Protected deviceStatus

deviceStatus: DeviceStatusEnum

Describes the current state of the device

Protected isConfigured

isConfigured: boolean

Describes the current state of the device

Readonly onMyNodeInfo

onMyNodeInfo: SubEvent<Protobuf.MyNodeInfo> = ...

Fires when a new MyNodeInfo message has been received from the device

Readonly onRadioConfig

onRadioConfig: SubEvent<Protobuf.RadioConfig> = ...

Fires when a new RadioConfig message has been received from the device

Private port

port: undefined | SerialPort

Serial port used to communicate with device.

Private reader

reader: ReadableStreamDefaultReader<Uint8Array>

Readable stream from serial port.

Private writer

writer: WritableStream<ArrayBuffer>

Writable stream to serial port.

Methods

complete

  • complete(): void
  • Completes all SubEvents

    Returns void

configure

  • configure(): Promise<void>
  • Triggers the device configure process

    Returns Promise<void>

confirmSetChannel

  • confirmSetChannel(callback?: (id: number) => Promise<void>): Promise<void>
  • Confirms the currently set channels, and prevents changes from reverting after 10 minutes.

    Parameters

    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

confirmSetPreferences

  • confirmSetPreferences(callback?: (id: number) => Promise<void>): Promise<void>
  • Confirms the currently set preferences, and prevents changes from reverting after 10 minutes.

    Parameters

    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

connect

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

    Parameters

    Returns Promise<void>

deleteChannel

  • deleteChannel(index: number, callback?: (id: number) => Promise<void>): Promise<void>
  • Deletes specific channel via index

    Parameters

    • index: number

      Channel index to be deleted

    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

disconnect

  • disconnect(): Promise<void>
  • Disconnects from the serial port

    Returns Promise<void>

getAllChannels

  • getAllChannels(callback?: () => Promise<void>): Promise<void>
  • Gets all of the devices channels

    Parameters

    • Optional callback: () => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (): Promise<void>
        • Returns Promise<void>

    Returns Promise<void>

getChannel

  • getChannel(index: number, callback?: (id: number) => Promise<void>): Promise<void>
  • Gets specified channel information from the radio

    Parameters

    • index: number

      Channel index to be retrieved

    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

getPort

  • getPort(filter?: SerialPortRequestOptions): Promise<SerialPort>
  • Gets list of serial ports that can be passed to connect

    Parameters

    • Optional filter: SerialPortRequestOptions

    Returns Promise<SerialPort>

getPorts

  • getPorts(): Promise<SerialPort[]>
  • Gets list of serial ports that can be passed to connect

    Returns Promise<SerialPort[]>

getPreferences

  • getPreferences(): Promise<void>

Protected handleFromRadio

  • handleFromRadio(fromRadio: Uint8Array): Promise<void>
  • Gets called whenever a fromRadio message is received from device, returns fromRadio data

    Parameters

    • fromRadio: Uint8Array

      Uint8Array containing raw radio data

    Returns Promise<void>

ping

  • ping(): Promise<boolean>
  • Pings device to check if it is avaliable

    Returns Promise<boolean>

Private readFromRadio

  • readFromRadio(): Promise<void>
  • Reads packets from transformed serial port steam and processes them.

    Returns Promise<void>

sendPacket

  • sendPacket(byteData: Uint8Array, portNum: PortNum, destinationNum?: number, wantAck?: boolean, channel?: number, wantResponse?: boolean, echoResponse?: boolean, callback?: (id: number) => Promise<void>): Promise<void>
  • Sends packet over the radio

    Parameters

    • byteData: Uint8Array
    • portNum: PortNum

      dataType Enum of protobuf data type

    • Optional destinationNum: number

      Node number of the destination node

    • wantAck: boolean = false

      Whether or not acknowledgement is wanted

    • channel: number = 0
    • wantResponse: boolean = false

      Used for testing, requests recpipient to respond in kind with the same type of request

    • echoResponse: boolean = false

      Sends event back to client

    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

sendRaw

  • sendRaw(toRadio: Uint8Array): Promise<void>
  • Sends raw packet over the radio

    Parameters

    • toRadio: Uint8Array

      binary data to send

    Returns Promise<void>

sendText

  • sendText(text: string, destinationNum?: number, wantAck?: boolean, channel?: number, callback?: (id: number) => Promise<void>): Promise<void>
  • Sends a text over the radio

    Parameters

    • text: string
    • Optional destinationNum: number

      Node number of the destination node

    • wantAck: boolean = false

      Whether or not acknowledgement is wanted

    • channel: number = 0
    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

setChannel

  • setChannel(channel: Protobuf.Channel, callback?: (id: number) => Promise<void>): Promise<void>
  • Sets devices ChannelSettings

    Parameters

    • channel: Protobuf.Channel

      Channel data to be set

    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

setOwner

  • setOwner(owner: Protobuf.User, callback?: (id: number) => Promise<void>): Promise<void>
  • Sets devices owner data

    Parameters

    • owner: Protobuf.User

      Owner data to apply to the device

    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

setPreferences

  • Writes radio config to device

    Parameters

    • preferences: Partial<Protobuf.RadioConfig_UserPreferences>

      Radio UserPreferences

    • Optional callback: (id: number) => Promise<void>

      If wantAck is true, callback is called when the ack is received

        • (id: number): Promise<void>
        • Parameters

          • id: number

          Returns Promise<void>

    Returns Promise<void>

updateDeviceStatus

Protected writeToRadio

  • writeToRadio(data: Uint8Array): Promise<void>
  • Sends supplied protobuf message to the radio

    Parameters

    • data: Uint8Array

    Returns Promise<void>

Generated using TypeDoc