@magicred-1/react-native-lxmf 0.2.6 → 0.2.16

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.
@@ -66,8 +66,9 @@ class LxmfModule : Module() {
66
66
 
67
67
  AsyncFunction("start") { identityHex: String, lxmfAddressHex: String, mode: Int,
68
68
  announceIntervalMs: Double, bleMtuHint: Int,
69
- tcpInterfaces: List<Map<String, Any>>, displayName: String ->
70
- Log.d(TAG, "start() mode=$mode interfaces=$tcpInterfaces name=$displayName")
69
+ tcpInterfaces: List<Map<String, Any>>, displayName: String,
70
+ isBeacon: Boolean ->
71
+ Log.d(TAG, "start() mode=$mode interfaces=$tcpInterfaces name=$displayName beacon=$isBeacon")
71
72
  val interfacesJson = org.json.JSONArray(tcpInterfaces.map { iface ->
72
73
  org.json.JSONObject().apply {
73
74
  put("host", iface["host"] ?: "")
@@ -75,7 +76,7 @@ class LxmfModule : Module() {
75
76
  }
76
77
  }).toString()
77
78
  val rc = nativeStart(identityHex, lxmfAddressHex, mode, announceIntervalMs.toLong(),
78
- bleMtuHint.toShort(), interfacesJson, displayName)
79
+ bleMtuHint.toShort(), interfacesJson, displayName, isBeacon)
79
80
  if (rc != 0) throw RuntimeException("nativeStart returned $rc")
80
81
  true
81
82
  }
@@ -195,7 +196,8 @@ class LxmfModule : Module() {
195
196
  announceIntervalMs: Long,
196
197
  bleMtuHint: Short,
197
198
  tcpInterfacesJson: String,
198
- displayName: String
199
+ displayName: String,
200
+ isBeacon: Boolean
199
201
  ): Int
200
202
  private external fun nativeStop(): Int
201
203
  private external fun nativeIsRunning(): Boolean
@@ -3,7 +3,7 @@ export type NativeModuleType = {
3
3
  start(identityHex: string, lxmfAddressHex: string, mode: number, announceIntervalMs: number, bleMtuHint: number, tcpInterfaces: {
4
4
  host: string;
5
5
  port: number;
6
- }[], displayName: string): Promise<boolean>;
6
+ }[], displayName: string, isBeacon: boolean): Promise<boolean>;
7
7
  stop(): Promise<boolean>;
8
8
  isRunning(): boolean;
9
9
  send(destHex: string, bodyBase64: string): Promise<number>;
@@ -55,6 +55,8 @@ export interface UseLxmfOptions {
55
55
  bleMtuHint?: number;
56
56
  /** Display name broadcast in LXMF announces. Default: "lxmf-mobile" */
57
57
  displayName?: string;
58
+ /** Advertise this node as an anonmesh beacon (app_data = "anonmesh::beacon::v1\0<name>"). Default: false */
59
+ isBeacon?: boolean;
58
60
  }
59
61
  export declare function useLxmf(options?: UseLxmfOptions): {
60
62
  status: LxmfNodeStatus | null;
@@ -69,6 +71,7 @@ export declare function useLxmf(options?: UseLxmfOptions): {
69
71
  mode?: LxmfNodeMode;
70
72
  tcpInterfaces?: TcpInterface[];
71
73
  displayName?: string;
74
+ isBeacon?: boolean;
72
75
  }) => Promise<boolean>;
73
76
  stop: () => Promise<void>;
74
77
  send: (destHex: string, bodyBase64: string) => Promise<number>;
package/build/useLxmf.js CHANGED
@@ -131,11 +131,12 @@ function useLxmf(options = {}) {
131
131
  const announceMs = options.announceIntervalMs ?? 5000;
132
132
  const bleMtu = options.bleMtuHint ?? 255;
133
133
  const displayName = overrides?.displayName ?? options.displayName ?? '';
134
+ const isBeacon = overrides?.isBeacon ?? options.isBeacon ?? false;
134
135
  if (mode !== LxmfNodeMode.BleOnly && tcpInterfaces.length === 0) {
135
136
  setError(`Mode ${mode} requires at least one TCP interface.`);
136
137
  return false;
137
138
  }
138
- await LxmfModule_1.LxmfModule.start(resolvedIdentityHex, resolvedLxmfAddressHex, mode, announceMs, bleMtu, tcpInterfaces, displayName);
139
+ await LxmfModule_1.LxmfModule.start(resolvedIdentityHex, resolvedLxmfAddressHex, mode, announceMs, bleMtu, tcpInterfaces, displayName, isBeacon);
139
140
  setRunning(true);
140
141
  syncStatus();
141
142
  setError(null);
@@ -153,6 +154,7 @@ function useLxmf(options = {}) {
153
154
  options.announceIntervalMs,
154
155
  options.bleMtuHint,
155
156
  options.displayName,
157
+ options.isBeacon,
156
158
  syncStatus,
157
159
  ]);
158
160
  (0, react_1.useEffect)(() => {
@@ -13,7 +13,8 @@ func lxmf_start(
13
13
  _ announceIntervalMs: UInt64,
14
14
  _ bleMtuHint: UInt16,
15
15
  _ tcpInterfacesJson: UnsafePointer<CChar>?,
16
- _ displayName: UnsafePointer<CChar>?
16
+ _ displayName: UnsafePointer<CChar>?,
17
+ _ isBeacon: UInt8
17
18
  ) -> Int32
18
19
 
19
20
  @_silgen_name("lxmf_stop")
@@ -182,7 +183,8 @@ public class LxmfModule: Module {
182
183
  announceIntervalMs: Double,
183
184
  bleMtuHint: Int,
184
185
  tcpInterfaces: [[String: Any]],
185
- displayName: String
186
+ displayName: String,
187
+ isBeacon: Bool
186
188
  ) -> Bool in
187
189
  // Serialize TCP interfaces to JSON (matches Android pattern)
188
190
  let interfacesJson: String
@@ -200,7 +202,8 @@ public class LxmfModule: Module {
200
202
  lxmf_start(
201
203
  idPtr, addrPtr,
202
204
  UInt32(mode), UInt64(announceIntervalMs),
203
- UInt16(bleMtuHint), ifacesPtr, namePtr
205
+ UInt16(bleMtuHint), ifacesPtr, namePtr,
206
+ isBeacon ? 1 : 0
204
207
  )
205
208
  }
206
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicred-1/react-native-lxmf",
3
- "version": "0.2.6",
3
+ "version": "0.2.16",
4
4
  "description": "LXMF Reticulum mesh networking for React Native + Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",