class · Node only

# GwmpServer

`@toip-tools/mesh-transport/gwmp` · [View source](https://github.com/yourbuddyconner/toip-tools/blob/main/packages/mesh-transport/src/gwmp.ts#L56)

Import:

```ts
import { GwmpServer } from "@toip-tools/mesh-transport/gwmp";
```

## Constructor

Constructor:

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

### Parameters

**`opts` (optional)**

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

Default: `{}`

**Fields of `opts`**

**`port` (optional)**

`number | undefined`

**`host` (optional)**

`string | undefined`

**`allow` (optional)**

`{ eui: string; address?: string; }[] | undefined`

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

**`log` (optional)**

`((s: string) => void) | undefined`

**`plan` (optional)**

`ChannelPlan | undefined`

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

**`staleMs` (optional)**

`number | undefined`

A gateway is "failed" after this long without PULL\_DATA. Default 30 s.

**`txAckTimeoutMs` (optional)**

`number | undefined`

### Returns

`GwmpServer`

## Properties

**`staleMs` (required · readonly)**

`number`

**`txAckTimeoutMs` (required · readonly)**

`number`

**`port` (required)**

`number`

The bound UDP port (useful with port 0).

## Methods

### `start`

Signature:

```ts
start(): Promise<void>;
```

No parameters.

#### Returns

`Promise<void>`

### `stop`

Signature:

```ts
stop(): Promise<void>;
```

No parameters.

#### Returns

`Promise<void>`

### `onGateway`

Signature:

```ts
onGateway(fn: (link: GwmpLink) => void): () => void;
```

#### Parameters

- **`fn` (required)**: `(link: GwmpLink) => void`

#### Returns

`() => void`

### `link`

Signature:

```ts
link(eui: string): GwmpLink | undefined;
```

#### Parameters

- **`eui` (required)**: `string`

#### Returns

`GwmpLink | undefined`

### `transmit`

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

Signature:

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

#### Parameters

- **`eui` (required)**: `string`
- **`txpk` (required)**: `Record<string, unknown>`

#### Returns

`Promise<string>`

[Usage guide](https://toip.tools/toolkit/mesh-transport/#usage) · [Error handling](https://toip.tools/toolkit/mesh-transport/#errors) · [All exports](https://toip.tools/toolkit/mesh-transport/api/gwmp/)

---

This is the Markdown version of https://toip.tools/toolkit/mesh-transport/api/gwmp/GwmpServer/. An index of the documentation for AI assistants is at https://toip.tools/llms.txt.
