@seeed-studio/meshtastic 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+ environment: NPM_KEY
15
+ steps:
16
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
17
+
18
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
19
+ with:
20
+ node-version: "24"
21
+ registry-url: "https://registry.npmjs.org"
22
+
23
+ - run: npm install
24
+
25
+ - run: npm publish --provenance --access public
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Seeed Solution
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,136 +1,219 @@
1
- # openclaw-meshtastic
1
+ # OpenClaw Meshtastic Plugin
2
2
 
3
- OpenClaw channel plugin for [Meshtastic](https://meshtastic.org/) LoRa mesh networks.
3
+ [![npm version](https://img.shields.io/npm/v/@seeed-studio/meshtastic.svg)](https://www.npmjs.com/package/@seeed-studio/meshtastic)
4
+ [![license](https://img.shields.io/npm/l/@seeed-studio/meshtastic.svg)](https://www.npmjs.com/package/@seeed-studio/meshtastic)
4
5
 
5
- Lets your OpenClaw gateway send and receive messages over Meshtastic devices — via USB serial, HTTP (WiFi), or MQTT broker.
6
+ **[English](README.md)** | [中文](README.zh-CN.md)
6
7
 
7
- <p align="center">
8
- <img src="media/hardware.jpg" width="400" alt="Meshtastic LoRa hardware with Seeed WM1302 module" />
9
- </p>
8
+ [OpenClaw](https://github.com/openclaw/openclaw) channel plugin for [Meshtastic](https://meshtastic.org/) LoRa mesh networks. Connect your AI gateway to the mesh over USB serial, HTTP, or MQTT — no cloud required.
10
9
 
11
- ## Demo
10
+ > [!IMPORTANT]
11
+ > This is a **channel plugin** for the [OpenClaw](https://github.com/openclaw/openclaw) AI gateway — not a standalone application. You need a running OpenClaw instance (Node.js 22+) to use it.
12
12
 
13
- https://github.com/user-attachments/assets/demo.mp4
13
+ [Documentation][docs] · [Hardware Guide](#recommended-hardware) · [Report Bug][issues] · [Request Feature][issues]
14
14
 
15
- > The video above shows OpenClaw communicating over a Meshtastic LoRa mesh network. If it doesn't load, see [media/demo.mp4](media/demo.mp4).
15
+ <p align="center">
16
+ <img src="media/hardware.jpg" width="420" alt="Meshtastic LoRa hardware" />
17
+ </p>
16
18
 
17
- ## Features
19
+ ## Table of Contents
18
20
 
19
- - **Three transport modes**
20
- - **Serial** connect a Meshtastic device via USB (e.g. `/dev/ttyUSB0`)
21
- - **HTTP** — connect over WiFi to a device's HTTP API (e.g. `meshtastic.local`)
22
- - **MQTT** — connect through an MQTT broker (e.g. `mqtt.meshtastic.org`), no local hardware needed
23
- - **Direct messages and group channels** — supports both DM and mesh channel conversations
24
- - **Access control** — DM policy (open / pairing / allowlist), per-channel allowlists, mention-gating for group channels
25
- - **Multi-account** — run multiple Meshtastic connections with independent configs
26
- - **LoRa region selection** — configure device region on connect (US, EU_868, CN, JP, etc.)
27
- - **Device display name** — set node longName, also used as @mention trigger in channels
28
- - **Interactive onboarding** — guided setup wizard via `openclaw setup`
29
- - **Auto-reconnect** — resilient connection handling with configurable retry
21
+ - [Quick Start](#quick-start)
22
+ - [How It Works](#how-it-works)
23
+ - [Recommended Hardware](#recommended-hardware)
24
+ - [Demo](#demo)
25
+ - [Features](#features)
26
+ - [Setup Wizard](#setup-wizard)
27
+ - [Configuration](#configuration)
28
+ - [Troubleshooting](#troubleshooting)
29
+ - [Development](#development)
30
+ - [Contributing](#contributing)
30
31
 
31
- ## Requirements
32
+ ## Quick Start
32
33
 
33
- - [OpenClaw](https://github.com/openclaw/openclaw) installed and running
34
- - Node.js 22+
35
- - For serial transport: a Meshtastic device connected via USB
36
- - For HTTP transport: a Meshtastic device on the same network
37
- - For MQTT transport: access to an MQTT broker (public `mqtt.meshtastic.org` works out of the box)
34
+ ```bash
35
+ # 1. Install plugin
36
+ openclaw plugins install @seeed-studio/meshtastic
38
37
 
39
- ## Install
38
+ # 2. Guided setup — walks you through transport, region, and access policy
39
+ openclaw setup
40
40
 
41
- ```bash
42
- openclaw plugins install @seeed-studio/openclaw-meshtastic
41
+ # 3. Verify
42
+ openclaw channels status --probe
43
43
  ```
44
44
 
45
- Or install from a local directory during development:
45
+ <p align="center">
46
+ <img src="media/setup-screenshot.png" width="700" alt="OpenClaw setup wizard" />
47
+ </p>
46
48
 
47
- ```bash
48
- git clone https://github.com/suharvest/openclaw-meshtastic.git
49
- openclaw plugins install -l ./openclaw-meshtastic
49
+ ## How It Works
50
+
51
+ ```mermaid
52
+ flowchart LR
53
+ subgraph mesh ["📻 LoRa Mesh Network"]
54
+ N["Meshtastic Nodes"]
55
+ end
56
+ subgraph gw ["⚙️ OpenClaw Gateway"]
57
+ P["Meshtastic Plugin"]
58
+ AI["AI Agent"]
59
+ end
60
+ N -- "Serial (USB)" --> P
61
+ N -- "HTTP (WiFi)" --> P
62
+ N -. "MQTT (Broker)" .-> P
63
+ P <--> AI
50
64
  ```
51
65
 
52
- ## Configuration
66
+ The plugin bridges Meshtastic LoRa devices and the OpenClaw AI agent. It supports three transport modes:
53
67
 
54
- ### Interactive setup
68
+ - **Serial** — direct USB connection to a local Meshtastic device
69
+ - **HTTP** — connects to a device over WiFi / local network
70
+ - **MQTT** — subscribes to a Meshtastic MQTT broker, no local hardware needed
55
71
 
56
- ```bash
57
- openclaw setup
58
- # Select "Meshtastic" when prompted for channel
59
- ```
72
+ Inbound messages go through access control (DM policy, group policy, mention gating) before reaching the AI. Outbound replies are stripped of markdown formatting (LoRa devices can't render it) and chunked to fit radio packet size limits.
60
73
 
61
- The wizard walks you through transport selection, connection details, region, access policy, and channel config.
74
+ ## Recommended Hardware
62
75
 
63
76
  <p align="center">
64
- <img src="media/setup-screenshot.png" width="600" alt="OpenClaw setup wizard with Meshtastic channel configured" />
77
+ <img src="media/XIAOclaw.png" width="760" alt="Meshtastic device with Seeed XIAO module" />
65
78
  </p>
66
79
 
67
- ### Manual configuration
80
+ | Device | Best for | Link |
81
+ |---|---|---|
82
+ | XIAO ESP32S3 + Wio-SX1262 kit | Budget off-grid node | [Buy][hw-xiao] |
83
+ | Wio Tracker L1 Pro | Ready-to-deploy gateway | [Buy][hw-wio] |
84
+ | SenseCAP Card Tracker T1000-E | Compact field tracker | [Buy][hw-sensecap] |
85
+
86
+ Any Meshtastic-compatible device works. Serial and HTTP transports connect directly; MQTT requires no local hardware at all.
87
+
88
+ ## Demo
89
+
90
+ https://github.com/user-attachments/assets/a3e46e9d-cf5a-4743-9830-f671a1998ca0
91
+
92
+ Fallback: [media/demo.mp4](media/demo.mp4)
93
+
94
+ ## Features
95
+
96
+ - **Direct messages and mesh channels** with per-channel rules
97
+ - **Access control** — DM policy (`open` / `pairing` / `allowlist`), group policy (`open` / `allowlist` / `disabled`), mention-gating, per-channel allowlists
98
+ - **Multi-account** — run independent serial, HTTP, and MQTT connections side by side
99
+ - **Region-aware** — sets device region on connect and derives MQTT topic defaults
100
+ - **Auto-reconnect** with resilient retry handling
101
+
102
+ ## Setup Wizard
103
+
104
+ Running `openclaw setup` launches an interactive wizard that walks you through each configuration step. Below is what each step means and how to choose.
105
+
106
+ ### 1. Transport
107
+
108
+ How the gateway connects to the Meshtastic mesh:
109
+
110
+ | Option | Description | Requires |
111
+ |---|---|---|
112
+ | **Serial** (USB) | Direct USB connection to a local device. Auto-detects available ports. | Meshtastic device plugged in via USB |
113
+ | **HTTP** (WiFi) | Connects to a device over the local network. | Device IP or hostname (e.g. `meshtastic.local`) |
114
+ | **MQTT** (broker) | Connects to the mesh via an MQTT broker — no local hardware needed. | Broker address, credentials, and subscribe topic |
115
+
116
+ ### 2. LoRa Region
68
117
 
69
- Add to your OpenClaw config (`openclaw config edit`):
118
+ > Serial and HTTP only. MQTT derives the region from the subscribe topic.
70
119
 
71
- **Serial (USB device):**
120
+ Sets the radio frequency region on the device. Must match your local regulations and other nodes on the mesh. Common choices:
121
+
122
+ | Region | Frequency |
123
+ |---|---|
124
+ | `US` | 902–928 MHz |
125
+ | `EU_868` | 869 MHz |
126
+ | `CN` | 470–510 MHz |
127
+ | `JP` | 920 MHz |
128
+ | `UNSET` | Keep device default |
129
+
130
+ See [Meshtastic region docs](https://meshtastic.org/docs/getting-started/initial-config/#lora) for the full list.
131
+
132
+ ### 3. Node Name
133
+
134
+ The device's display name on the mesh. Also used as the **@mention trigger** in group channels — other users send `@OpenClaw` to talk to your bot.
135
+
136
+ - **Serial / HTTP**: optional — auto-detects from the connected device if left empty.
137
+ - **MQTT**: required — there is no physical device to read the name from.
138
+
139
+ ### 4. Channel Access (`groupPolicy`)
140
+
141
+ Controls whether and how the bot responds in **mesh group channels** (e.g. LongFast, Emergency):
142
+
143
+ | Policy | Behavior |
144
+ |---|---|
145
+ | `disabled` (default) | Ignores all group channel messages. Only DMs are processed. |
146
+ | `open` | Responds in **every** channel on the mesh. |
147
+ | `allowlist` | Responds only in **listed** channels. You will be prompted to enter channel names (comma-separated, e.g. `LongFast, Emergency`). Use `*` as a wildcard to match all. |
148
+
149
+ ### 5. Require Mention
150
+
151
+ > Only appears when channel access is enabled (not `disabled`).
152
+
153
+ When enabled (default: **yes**), the bot only responds in group channels when someone mentions its node name (e.g. `@OpenClaw how's the weather?`). This prevents the bot from replying to every single message in the channel.
154
+
155
+ When disabled, the bot responds to **all** messages in allowed channels.
156
+
157
+ ### 6. DM Access Policy (`dmPolicy`)
158
+
159
+ Controls who can send **direct messages** to the bot:
160
+
161
+ | Policy | Behavior |
162
+ |---|---|
163
+ | `pairing` (default) | New senders trigger a pairing request that must be approved before they can chat. |
164
+ | `open` | Anyone on the mesh can DM the bot freely. |
165
+ | `allowlist` | Only nodes listed in `allowFrom` can DM. All others are ignored. |
166
+
167
+ ### 7. DM Allowlist (`allowFrom`)
168
+
169
+ > Only appears when `dmPolicy` is `allowlist`, or when the wizard determines one is needed.
170
+
171
+ A list of Meshtastic node IDs allowed to send direct messages. Format: `!aabbccdd` (hex node ID). Multiple entries are comma-separated.
172
+
173
+ ### 8. Account Display Names
174
+
175
+ > Only appears for multi-account setups. Optional.
176
+
177
+ Assigns human-readable display names to your accounts. For example, an account with ID `home` could be displayed as "Home Station". If skipped, the raw account ID is used as-is. This is purely cosmetic and does not affect functionality.
178
+
179
+ ## Configuration
180
+
181
+ The guided setup (`openclaw setup`) covers everything below. See [Setup Wizard](#setup-wizard) for a step-by-step walkthrough. For manual config, edit with `openclaw config edit`.
182
+
183
+ ### Serial (USB)
72
184
 
73
185
  ```yaml
74
186
  channels:
75
187
  meshtastic:
76
- enabled: true
77
188
  transport: serial
78
189
  serialPort: /dev/ttyUSB0
79
190
  nodeName: OpenClaw
80
- dmPolicy: pairing
81
191
  ```
82
192
 
83
- **HTTP (WiFi device):**
193
+ ### HTTP (WiFi)
84
194
 
85
195
  ```yaml
86
196
  channels:
87
197
  meshtastic:
88
- enabled: true
89
198
  transport: http
90
199
  httpAddress: meshtastic.local
91
- httpTls: false
92
200
  nodeName: OpenClaw
93
- dmPolicy: pairing
94
201
  ```
95
202
 
96
- **MQTT (broker):**
203
+ ### MQTT (broker)
97
204
 
98
205
  ```yaml
99
206
  channels:
100
207
  meshtastic:
101
- enabled: true
102
208
  transport: mqtt
209
+ nodeName: OpenClaw
103
210
  mqtt:
104
211
  broker: mqtt.meshtastic.org
105
- port: 1883
106
212
  username: meshdev
107
213
  password: large4cats
108
214
  topic: "msh/US/2/json/#"
109
- tls: false
110
- dmPolicy: pairing
111
215
  ```
112
216
 
113
- ### Configuration reference
114
-
115
- | Key | Type | Default | Description |
116
- |-----|------|---------|-------------|
117
- | `transport` | `serial` \| `http` \| `mqtt` | `serial` | Connection method |
118
- | `serialPort` | string | — | Serial device path |
119
- | `httpAddress` | string | `meshtastic.local` | Device IP or hostname |
120
- | `httpTls` | boolean | `false` | Use HTTPS for HTTP transport |
121
- | `mqtt.broker` | string | `mqtt.meshtastic.org` | MQTT broker hostname |
122
- | `mqtt.port` | number | `1883` | MQTT broker port |
123
- | `mqtt.username` | string | `meshdev` | MQTT username |
124
- | `mqtt.password` | string | `large4cats` | MQTT password |
125
- | `mqtt.topic` | string | `msh/US/2/json/#` | MQTT subscribe topic |
126
- | `mqtt.tls` | boolean | `false` | Use TLS for MQTT |
127
- | `region` | string | `UNSET` | LoRa region (serial/HTTP only) |
128
- | `nodeName` | string | — | Device display name and @mention trigger |
129
- | `dmPolicy` | `open` \| `pairing` \| `allowlist` | `pairing` | DM access policy |
130
- | `allowFrom` | string[] | — | Allowed node IDs (e.g. `["!aabbccdd"]`) |
131
- | `groupPolicy` | `open` \| `allowlist` \| `disabled` | `disabled` | Group channel policy |
132
- | `channels` | object | — | Per-channel config (requireMention, tools, allowFrom) |
133
-
134
217
  ### Multi-account
135
218
 
136
219
  ```yaml
@@ -144,27 +227,80 @@ channels:
144
227
  transport: mqtt
145
228
  mqtt:
146
229
  broker: mqtt.meshtastic.org
230
+ topic: "msh/US/2/json/#"
147
231
  ```
148
232
 
149
- ## Verify
233
+ <details>
234
+ <summary><b>All Options Reference</b></summary>
235
+
236
+ | Key | Type | Default | Notes |
237
+ |---|---|---|---|
238
+ | `transport` | `serial \| http \| mqtt` | `serial` | |
239
+ | `serialPort` | `string` | — | Required for serial |
240
+ | `httpAddress` | `string` | `meshtastic.local` | Required for HTTP |
241
+ | `httpTls` | `boolean` | `false` | |
242
+ | `mqtt.broker` | `string` | `mqtt.meshtastic.org` | |
243
+ | `mqtt.port` | `number` | `1883` | |
244
+ | `mqtt.username` | `string` | `meshdev` | |
245
+ | `mqtt.password` | `string` | `large4cats` | |
246
+ | `mqtt.topic` | `string` | `msh/US/2/json/#` | Subscribe topic |
247
+ | `mqtt.publishTopic` | `string` | derived | |
248
+ | `mqtt.tls` | `boolean` | `false` | |
249
+ | `region` | enum | `UNSET` | `US`, `EU_868`, `CN`, `JP`, `ANZ`, `KR`, `TW`, `RU`, `IN`, `NZ_865`, `TH`, `EU_433`, `UA_433`, `UA_868`, `MY_433`, `MY_919`, `SG_923`, `LORA_24`. Serial/HTTP only. |
250
+ | `nodeName` | `string` | auto-detect | Display name and @mention trigger. Required for MQTT. |
251
+ | `dmPolicy` | `open \| pairing \| allowlist` | `pairing` | Who can send direct messages. See [DM Access Policy](#6-dm-access-policy-dmpolicy). |
252
+ | `allowFrom` | `string[]` | — | Node IDs for DM allowlist, e.g. `["!aabbccdd"]` |
253
+ | `groupPolicy` | `open \| allowlist \| disabled` | `disabled` | Group channel response policy. See [Channel Access](#4-channel-access-grouppolicy). |
254
+ | `channels` | `Record<string, object>` | — | Per-channel overrides: `requireMention`, `allowFrom`, `tools` |
255
+
256
+ </details>
257
+
258
+ <details>
259
+ <summary><b>Environment Variable Overrides</b></summary>
260
+
261
+ These override the default account's config (YAML takes precedence for named accounts):
262
+
263
+ | Variable | Equivalent config key |
264
+ |---|---|
265
+ | `MESHTASTIC_TRANSPORT` | `transport` |
266
+ | `MESHTASTIC_SERIAL_PORT` | `serialPort` |
267
+ | `MESHTASTIC_HTTP_ADDRESS` | `httpAddress` |
268
+ | `MESHTASTIC_MQTT_BROKER` | `mqtt.broker` |
269
+ | `MESHTASTIC_MQTT_TOPIC` | `mqtt.topic` |
270
+
271
+ </details>
272
+
273
+ ## Troubleshooting
274
+
275
+ | Symptom | Check |
276
+ |---|---|
277
+ | Serial won't connect | Device path correct? Host has permission? |
278
+ | HTTP won't connect | `httpAddress` reachable? `httpTls` matches device? |
279
+ | MQTT receives nothing | Region in `mqtt.topic` correct? Broker credentials valid? |
280
+ | No DM responses | `dmPolicy` and `allowFrom` configured? See [DM Access Policy](#6-dm-access-policy-dmpolicy). |
281
+ | No group replies | `groupPolicy` enabled? Channel in allowlist? Mention required? See [Channel Access](#4-channel-access-grouppolicy). |
282
+
283
+ Found a bug? [Open an issue][issues] with transport type, config (redact secrets), and `openclaw channels status --probe` output.
284
+
285
+ ## Development
150
286
 
151
287
  ```bash
152
- openclaw channels status --probe
288
+ git clone https://github.com/Seeed-Solution/openclaw-meshtastic.git
289
+ cd openclaw-meshtastic
290
+ npm install
291
+ openclaw plugins install -l ./openclaw-meshtastic
153
292
  ```
154
293
 
155
- ## Environment variables
156
-
157
- These can be used as alternatives to config file settings:
158
-
159
- - `MESHTASTIC_TRANSPORT` — `serial`, `http`, or `mqtt`
160
- - `MESHTASTIC_SERIAL_PORT` — serial device path
161
- - `MESHTASTIC_HTTP_ADDRESS` — device IP or hostname
162
- - `MESHTASTIC_MQTT_BROKER` — MQTT broker hostname
163
-
164
- ## Supported LoRa regions
294
+ No build step — OpenClaw loads TypeScript source directly. Use `openclaw channels status --probe` to verify.
165
295
 
166
- US, EU_433, EU_868, CN, JP, ANZ, KR, TW, RU, IN, NZ_865, TH, UA_433, UA_868, MY_433, MY_919, SG_923, LORA_24
296
+ ## Contributing
167
297
 
168
- ## License
298
+ - [Open an issue][issues] for bugs or feature requests
299
+ - Pull requests welcome — keep code aligned with existing TypeScript conventions
169
300
 
170
- MIT
301
+ <!-- Reference-style links -->
302
+ [docs]: https://meshtastic.org/docs/
303
+ [issues]: https://github.com/Seeed-Solution/openclaw-meshtastic/issues
304
+ [hw-xiao]: https://www.seeedstudio.com/Wio-SX1262-with-XIAO-ESP32S3-p-5982.html
305
+ [hw-wio]: https://www.seeedstudio.com/Wio-Tracker-L1-Pro-p-6454.html
306
+ [hw-sensecap]: https://www.seeedstudio.com/SenseCAP-Card-Tracker-T1000-E-for-Meshtastic-p-5913.html