meshtastic 0.0.131 → 0.0.133
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.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/meshtastic/mqtt.rb +31 -5
- data/lib/meshtastic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd7da546fac5be533cc4420c830da4514bf10c5dd48577abfd54cf912d0af58e
|
|
4
|
+
data.tar.gz: 583508248f892029b83b21663e3666dff7bae1a034c085eaa67616c6834d4ef1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e689b2141774914914ef4895867a5cc7e197cdf63ee0f282fbbcf5b1fcabf917167de1a81fccbbb865e4c35082f154dd4b3957769d0d601dd8388925f4b85ea7
|
|
7
|
+
data.tar.gz: af9a806f6fdf54668c1391ad46865a8590bfe4d8bb47829fafc7232eae7413dd470f506c1deffd25f4f08fa9dede9cd298d97a9a963c3e76cc5e031c6ca1c309
|
data/README.md
CHANGED
|
@@ -30,6 +30,7 @@ At the moment the only module available is `Meshtastic::MQTT`. To view MQTT mes
|
|
|
30
30
|
require 'meshtastic'
|
|
31
31
|
Meshtastic::MQTT.help
|
|
32
32
|
mqtt_obj = Meshastic::MQTT.connect
|
|
33
|
+
puts mqtt_obj.inspect
|
|
33
34
|
Meshtastic::MQTT.subscribe(
|
|
34
35
|
mqtt_obj: mqtt_obj,
|
|
35
36
|
include: '_APP, LongFast'
|
|
@@ -43,6 +44,7 @@ require 'meshtastic'
|
|
|
43
44
|
mqtt_obj = Meshastic::MQTT.connect
|
|
44
45
|
Meshtastic::MQTT.subscribe(
|
|
45
46
|
mqtt_obj: mqtt_obj,
|
|
47
|
+
root_topic: 'msh',
|
|
46
48
|
region: 'US',
|
|
47
49
|
topic: '2/e/LongFast/#',
|
|
48
50
|
psks: { LongFast: 'AQ==' }
|
|
@@ -61,7 +63,9 @@ Meshtastic::MQTT.send_text(
|
|
|
61
63
|
mqtt_obj: mqtt_obj,
|
|
62
64
|
from: client_id,
|
|
63
65
|
to: '!ffffffff',
|
|
64
|
-
|
|
66
|
+
root_topic: 'msh',
|
|
67
|
+
region: 'US',
|
|
68
|
+
topic: '2/e/LongFast/#',
|
|
65
69
|
channel: 93,
|
|
66
70
|
text: 'Hello, World!',
|
|
67
71
|
psks: { LongFast: 'AQ==' }
|
|
@@ -75,6 +79,7 @@ require 'meshtastic'
|
|
|
75
79
|
mqtt_obj = Meshastic::MQTT.connect
|
|
76
80
|
Meshtastic::MQTT.subscribe(
|
|
77
81
|
mqtt_obj: mqtt_obj,
|
|
82
|
+
root_topic: 'msh',
|
|
78
83
|
region: 'US',
|
|
79
84
|
topic: '2/e/LongFast/#',
|
|
80
85
|
psks: { LongFast: 'AQ==' },
|
data/lib/meshtastic/mqtt.rb
CHANGED
|
@@ -255,7 +255,7 @@ module Meshtastic
|
|
|
255
255
|
# to: 'optional - Destination ID (Default: "!ffffffff")',
|
|
256
256
|
# root_topic: 'optional - root topic (default: msh)',
|
|
257
257
|
# region: 'optional - region e.g. "US/VA", etc (default: US)',
|
|
258
|
-
# topic: 'optional - topic to publish to (default: "2/e/LongFast")',
|
|
258
|
+
# topic: 'optional - topic to publish to (default: "2/e/LongFast/#")',
|
|
259
259
|
# channel: 'optional - channel (Default: 6)',
|
|
260
260
|
# text: 'optional - Text Message (Default: SYN)',
|
|
261
261
|
# want_ack: 'optional - Want Acknowledgement (Default: false)',
|
|
@@ -270,16 +270,42 @@ module Meshtastic
|
|
|
270
270
|
opts[:to] ||= '!ffffffff'
|
|
271
271
|
opts[:root_topic] ||= 'msh'
|
|
272
272
|
opts[:region] ||= 'US'
|
|
273
|
-
opts[:topic] ||= '2/e/LongFast'
|
|
273
|
+
opts[:topic] ||= '2/e/LongFast/#'
|
|
274
|
+
opts[:topic] = opts[:topic].to_s.gsub('/#', '')
|
|
274
275
|
opts[:channel] ||= 6
|
|
275
276
|
absolute_topic = "#{opts[:root_topic]}/#{opts[:region]}/#{opts[:topic]}/#{opts[:from]}"
|
|
277
|
+
opts[:topic] = absolute_topic
|
|
276
278
|
opts[:via] = :mqtt
|
|
277
279
|
|
|
278
280
|
# TODO: Implement chunked message to deal with large messages
|
|
281
|
+
raw_text = opts[:text].to_s
|
|
282
|
+
max_bytes = 233
|
|
279
283
|
mui = Meshtastic::MeshInterface.new
|
|
280
|
-
protobuf_text = mui.send_text(opts)
|
|
281
284
|
|
|
282
|
-
|
|
285
|
+
if raw_text.bytesize > max_bytes
|
|
286
|
+
chunks = []
|
|
287
|
+
current_chunk = ''
|
|
288
|
+
raw_text.each_char do |char|
|
|
289
|
+
if (current_chunk + char).bytesize > max_bytes
|
|
290
|
+
chunks.push(current_chunk)
|
|
291
|
+
current_chunk = char
|
|
292
|
+
else
|
|
293
|
+
current_chunk += char
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
chunks.push(current_chunk) unless current_chunk.empty?
|
|
297
|
+
|
|
298
|
+
total_chunks = chunks.length
|
|
299
|
+
chunks.each_with_index do |chunk, index|
|
|
300
|
+
opts[:text] = chunk
|
|
301
|
+
opts[:text] = "[#{index + 1}/#{total_chunks}] #{chunk}"
|
|
302
|
+
protobuf_chunk = mui.send_text(opts)
|
|
303
|
+
push(mqtt_obj.publish(absolute_topic, protobuf_chunk))
|
|
304
|
+
end
|
|
305
|
+
else
|
|
306
|
+
protobuf_text = mui.send_text(opts)
|
|
307
|
+
mqtt_obj.publish(absolute_topic, protobuf_text)
|
|
308
|
+
end
|
|
283
309
|
rescue StandardError => e
|
|
284
310
|
raise e
|
|
285
311
|
end
|
|
@@ -339,7 +365,7 @@ module Meshtastic
|
|
|
339
365
|
to: 'optional - Destination ID (Default: \"!ffffffff\")',
|
|
340
366
|
root_topic: 'optional - root topic (default: msh)',
|
|
341
367
|
region: 'optional - region e.g. 'US/VA', etc (default: US)',
|
|
342
|
-
topic: 'optional - topic to publish to (default: '2/e/LongFast')',
|
|
368
|
+
topic: 'optional - topic to publish to (default: '2/e/LongFast/#')',
|
|
343
369
|
channel: 'optional - channel (Default: 6)',
|
|
344
370
|
text: 'optional - Text Message (Default: SYN)',
|
|
345
371
|
want_ack: 'optional - Want Acknowledgement (Default: false)',
|
data/lib/meshtastic/version.rb
CHANGED