interface · Browser and Node

# Link

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

Import:

```ts
import { type Link } from "@toip-tools/mesh-transport";
```

## Declaration

interface:

```ts
interface Link {
  readonly info: LinkInfo;
  readonly state: LinkState;
  open(): Promise<void>;
  close(): Promise<void>;
  /** Resolves when the frame has been transmitted. It says nothing about who received it. */
  send(frame: Uint8Array): Promise<void>;
  onFrame(fn: (f: ReceivedFrame) => void): () => void;
  onState(fn: (s: LinkState) => void): () => void;
  /** True while the radio senses a busy channel, if it can. */
  channelBusy?(): boolean;
}
```

## Properties

**`info` (required · readonly)**

`LinkInfo`

**`state` (required · readonly)**

`LinkState`

**`channelBusy` (optional)**

`(() => boolean) | undefined`

True while the radio senses a busy channel, if it can.

## Methods

### `open`

Signature:

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

No parameters.

#### Returns

`Promise<void>`

### `close`

Signature:

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

No parameters.

#### Returns

`Promise<void>`

### `send`

Resolves when the frame has been transmitted. It says nothing about who received it.

Signature:

```ts
send(frame: Uint8Array): Promise<void>;
```

#### Parameters

- **`frame` (required)**: `Uint8Array<ArrayBufferLike>`

#### Returns

`Promise<void>`

### `onFrame`

Signature:

```ts
onFrame(fn: (f: ReceivedFrame) => void): () => void;
```

#### Parameters

- **`fn` (required)**: `(f: ReceivedFrame) => void`

#### Returns

`() => void`

### `onState`

Signature:

```ts
onState(fn: (s: LinkState) => void): () => void;
```

#### Parameters

- **`fn` (required)**: `(s: LinkState) => void`

#### Returns

`() => void`

[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/)

---

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