meshcore.js
ReferenceClasses

Radio

Defined in: packages/client/src/radio/radio.ts:99

client.radio: typed wrappers around the Companion commands (appStart, deviceQuery, getContacts, sendText, …), one request in flight at a time.

Extends

Constructors

Constructor

new Radio(transport, options?): Radio;

Defined in: packages/client/src/radio/radio.ts:107

Parameters

transport

Transport

Connected or not, the radio only writes frames

options?

RadioOptions = {}

timeoutMs per request. Default 5000

Returns

Radio

Overrides

TypedEmitter.constructor

Methods

appStart()

appStart(appName): Promise<SelfInfo>;

Defined in: packages/client/src/radio/radio.ts:151

Parameters

appName

string

Name announced to the radio

Returns

Promise<SelfInfo>


deviceQuery()

deviceQuery(): Promise<DeviceInfo>;

Defined in: packages/client/src/radio/radio.ts:159

Returns

Promise<DeviceInfo>


emit()

emit<K>(event, ...args): boolean;

Defined in: packages/transports/src/typed-emitter.ts:44

Type Parameters

K

K extends string

Parameters

event

K

Event name

args

...RadioEvents[K]

Event arguments

Returns

boolean

Inherited from

TypedEmitter.emit


exportSelfContact()

exportSelfContact(): Promise<{
  packet: Uint8Array;
  uri: string;
}>;

Defined in: packages/client/src/radio/radio.ts:254

Returns

Promise<{ packet: Uint8Array; uri: string; }>


getBattAndStorage()

getBattAndStorage(): Promise<BattAndStorageFrame>;

Defined in: packages/client/src/radio/radio.ts:246

Returns

Promise<BattAndStorageFrame>


getChannel()

getChannel(index): Promise<ChannelRecord | null>;

Defined in: packages/client/src/radio/radio.ts:220

Parameters

index

number

Channel slot

Returns

Promise<ChannelRecord | null>


getContactByKey()

getContactByKey(publicKey): Promise<ContactRecord | null>;

Defined in: packages/client/src/radio/radio.ts:196

Parameters

publicKey

string

Full public key in hex

Returns

Promise<ContactRecord | null>


getContacts()

getContacts(since?): Promise<ContactRecord[]>;

Defined in: packages/client/src/radio/radio.ts:178

Parameters

since?

number

Only contacts modified after this epoch

Returns

Promise<ContactRecord[]>


listenerCount()

listenerCount<K>(event): number;

Defined in: packages/transports/src/typed-emitter.ts:49

Type Parameters

K

K extends string

Parameters

event

K

Event name

Returns

number

Inherited from

TypedEmitter.listenerCount


off()

off<K>(event, listener): this;

Defined in: packages/transports/src/typed-emitter.ts:35

Type Parameters

K

K extends string

Parameters

event

K

Event name

listener

Listener<RadioEvents[K]>

Listener to remove

Returns

this

Inherited from

TypedEmitter.off


on()

on<K>(event, listener): this;

Defined in: packages/transports/src/typed-emitter.ts:17

Type Parameters

K

K extends string

Parameters

event

K

Event name

listener

Listener<RadioEvents[K]>

Called with the event arguments

Returns

this

Inherited from

TypedEmitter.on


once()

once<K>(event, listener): this;

Defined in: packages/transports/src/typed-emitter.ts:26

Type Parameters

K

K extends string

Parameters

event

K

Event name

listener

Listener<RadioEvents[K]>

Called once with the event arguments

Returns

this

Inherited from

TypedEmitter.once


removeAllListeners()

removeAllListeners<K>(event?): this;

Defined in: packages/transports/src/typed-emitter.ts:54

Type Parameters

K

K extends string

Parameters

event?

K

Event name, or every event when omitted

Returns

this

Inherited from

TypedEmitter.removeAllListeners


removeContact()

removeContact(publicKey): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:210

Parameters

publicKey

string

Full public key in hex

Returns

Promise<void>


request()

request<T>(
   code, 
   payload?, 
   collect?
): Promise<T>;

Defined in: packages/client/src/radio/radio.ts:126

Send a Companion command that has no typed wrapper, through the same one-request-in-flight queue as the wrappers. Never write raw frames to client.transport. The three commands that transmit on the mesh are refused with GuardedCommandError.

Type Parameters

T

T = void

Parameters

code

number

Companion command code (CommandCode.*, or a byte the protocol does not know yet)

payload?

Uint8Array = ...

Command body without the code byte. Default empty

collect?

Collector<T> = ...

Turns response frames into the result. Default: expects Ok

Returns

Promise<T>


reset()

reset(error): void;

Defined in: packages/client/src/radio/radio.ts:114

Parameters

error

Error

Rejects every pending request with it

Returns

void


resetPath()

resetPath(publicKey): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:215

Parameters

publicKey

string

Full public key in hex

Returns

Promise<void>


sendSelfAdvert()

sendSelfAdvert(flood): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:270

Parameters

flood

boolean

Flood the mesh instead of a zero-hop advert; at most one flood per ADVERT_FLOOD_INTERVAL_MS (RateLimitError otherwise), the window is reserved before the request so two concurrent calls cannot both pass, and released again only when the failure proves nothing was transmitted (a RadioError, i.e. the firmware answered Err). Any other failure, notably a CommandTimeoutError, keeps the window consumed: a lost reply does not mean the flood never went out, and the reconnect loop retries login() on its own.

Returns

Promise<void>


setAdvertLatLon()

setAdvertLatLon(location): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:320

Parameters

location

Location

lat and lon in decimal degrees

Returns

Promise<void>


setAdvertName()

setAdvertName(name): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:314

Parameters

name

string

1 to 31 UTF-8 bytes

Returns

Promise<void>


setChannel()

setChannel(params): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:234

Parameters

params

SetChannelParams

Slot, name and secret

Returns

Promise<void>


setDeviceTime()

setDeviceTime(epochSeconds): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:168

Parameters

epochSeconds

number

Current time in seconds

Returns

Promise<void>


setRadioParams()

setRadioParams(params, options?): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:342

Parameters

params

RadioParams

frequency in MHz, bandwidth in kHz, spreadingFactor and codingRate

options?

repeat writes the repeater byte, firmware 9 and later

repeat?

boolean

Returns

Promise<void>


setTxPower()

setTxPower(dbm): Promise<void>;

Defined in: packages/client/src/radio/radio.ts:333

Parameters

dbm

number

9 to the radio maximum

Returns

Promise<void>


syncNextMessage()

syncNextMessage(): Promise<ContactMessageFrame | ChannelMessageFrame | null>;

Defined in: packages/client/src/radio/radio.ts:238

Returns

Promise<ContactMessageFrame | ChannelMessageFrame | null>

On this page