toip.tools

class · Node only

GwmpServer

@toip-tools/mesh-transport/gwmpView source
TypeScriptImport
import { GwmpServer } from "@toip-tools/mesh-transport/gwmp";

Constructor

TypeScriptConstructor
new (opts?: {
    port?: number;
    host?: string;
    allow?: {
        eui: string;
        address?: string;
    }[];
    log?: (s: string) => void;
    plan?: ChannelPlan;
    staleMs?: number;
    txAckTimeoutMs?: number;
}): GwmpServer;

Parameters

optsoptional
{ port?: number; host?: string; allow?: { eui: string; address?: string; }[]; log?: (s: string) => void; plan?: ChannelPlan; staleMs?: number; txAckTimeoutMs?: number; }

Default: {}

Fields of opts
portoptional
number | undefined
hostoptional
string | undefined
allowoptional
{ eui: string; address?: string; }[] | undefined

Only these gateways (and, if given, only from this address).

logoptional
((s: string) => void) | undefined
planoptional
ChannelPlan | undefined

The channel plan for every gateway's link. Default us915-b-gateway.

staleMsoptional
number | undefined

A gateway is "failed" after this long without PULL_DATA. Default 30 s.

txAckTimeoutMsoptional
number | undefined

Returns

Properties

staleMsrequired · readonly
number
txAckTimeoutMsrequired · readonly
number
portrequired
number

The bound UDP port (useful with port 0).

Methods

start

TypeScriptSignature
start(): Promise<void>;

No parameters.

Returns

Promise<void>

stop

TypeScriptSignature
stop(): Promise<void>;

No parameters.

Returns

Promise<void>

onGateway

TypeScriptSignature
onGateway(fn: (link: GwmpLink) => void): () => void;

Parameters

fnrequired
(link: GwmpLink) => void

Returns

() => void

transmit

Sends one txpk to a gateway and waits for its TX_ACK. Resolves with the error string ("NONE" on success).

TypeScriptSignature
transmit(eui: string, txpk: Record<string, unknown>): Promise<string>;

Parameters

euirequired
string
txpkrequired
Record<string, unknown>

Returns

Promise<string>