@seeed-studio/meshtastic 0.1.1 → 0.2.1

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.
package/src/send.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
+
3
+ import { stripMarkdown } from "openclaw/plugin-sdk/text-runtime";
4
+
2
5
  import { resolveMeshtasticAccount } from "./accounts.js";
3
6
  import { hexToNodeNum, normalizeMeshtasticMessagingTarget } from "./normalize.js";
4
7
  import { getMeshtasticRuntime } from "./runtime.js";
@@ -50,13 +53,15 @@ export async function sendMessageMeshtastic(
50
53
  if (!account.configured) {
51
54
  throw new Error(
52
55
  `Meshtastic is not configured for account "${account.accountId}". ` +
53
- `Set channels.meshtastic.transport and connection details.`,
56
+ `Run 'openclaw onboard' or set channels.meshtastic.transport and connection details in config.`,
54
57
  );
55
58
  }
56
59
 
57
60
  const target = normalizeMeshtasticMessagingTarget(to);
58
61
  if (!target) {
59
- throw new Error(`Invalid Meshtastic target: ${to}`);
62
+ throw new Error(
63
+ `Invalid Meshtastic target: "${to}". Use a node ID like "!aabbccdd" or a channel name like "channel:LongFast".`,
64
+ );
60
65
  }
61
66
 
62
67
  const tableMode = runtime.channel.text.resolveMarkdownTableMode({
@@ -65,7 +70,8 @@ export async function sendMessageMeshtastic(
65
70
  accountId: account.accountId,
66
71
  });
67
72
  const prepared = runtime.channel.text.convertMarkdownTables(text.trim(), tableMode);
68
- if (!prepared.trim()) {
73
+ const stripped = stripMarkdown(prepared);
74
+ if (!stripped.trim()) {
69
75
  throw new Error("Message must be non-empty for Meshtastic sends");
70
76
  }
71
77
 
@@ -73,17 +79,17 @@ export async function sendMessageMeshtastic(
73
79
 
74
80
  if (transport === "mqtt") {
75
81
  if (activeMqttSend) {
76
- await activeMqttSend(prepared, target, opts.channelName);
82
+ await activeMqttSend(stripped, target, opts.channelName);
77
83
  } else {
78
- throw new Error("No active MQTT connection. Start the gateway first.");
84
+ throw new Error("No active MQTT connection. Run 'openclaw gateway start' to connect.");
79
85
  }
80
86
  } else {
81
87
  // Serial or HTTP: use active transport if available.
82
88
  if (activeSerialSend) {
83
89
  const destination = target.startsWith("!") ? hexToNodeNum(target) : undefined;
84
- await activeSerialSend(prepared, destination, opts.channelIndex);
90
+ await activeSerialSend(stripped, destination, opts.channelIndex);
85
91
  } else {
86
- throw new Error(`No active ${transport} connection. Start the gateway first.`);
92
+ throw new Error(`No active ${transport} connection. Run 'openclaw gateway start' to connect.`);
87
93
  }
88
94
  }
89
95
 
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { BaseProbeResult } from "openclaw/plugin-sdk";
2
1
  import type {
2
+ BaseProbeResult,
3
3
  BlockStreamingCoalesceConfig,
4
4
  DmConfig,
5
5
  DmPolicy,
@@ -8,7 +8,7 @@ import type {
8
8
  GroupToolPolicyConfig,
9
9
  MarkdownConfig,
10
10
  OpenClawConfig,
11
- } from "openclaw/plugin-sdk";
11
+ } from "openclaw/plugin-sdk/irc";
12
12
 
13
13
  export type MeshtasticChannelConfig = {
14
14
  requireMention?: boolean;
@@ -28,6 +28,8 @@ export type MeshtasticMqttConfig = {
28
28
  topic?: string;
29
29
  publishTopic?: string;
30
30
  tls?: boolean;
31
+ /** Own node ID in !hex format — required for DM detection over MQTT. */
32
+ myNodeId?: string;
31
33
  };
32
34
 
33
35
  export type MeshtasticTransport = "serial" | "http" | "mqtt";