meshtastic 0.0.94 → 0.0.95
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 +11 -3
- data/lib/meshtastic/mqtt.rb +10 -10
- data/lib/meshtastic/version.rb +1 -1
- data/lib/meshtastic.rb +4 -3
- 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: 97d144971ff7a74ca7623e32e95afca4d2436bb40dc8fec7c9d31d4570627752
|
4
|
+
data.tar.gz: a00eeb6ed18164c2c3f2da207d01dd5e7dc76515b6e314fc38914e8b4e847748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a66fc870f5878bdc0e4602cedaae60de5692c131dcfbc3460c462c6907bfe11f099c84799d8f25957db6ba8a285b95c154ab5548c9195f2dcfd002cbd1f98ae1
|
7
|
+
data.tar.gz: 1d3523d5f2ba4af1fefc6a5818cc3db7b8110dfa7de352b44581d88aac688162a72440793b2e97977ac634bc35585b783350ac88c3836521516f8100de43c0ca
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ mqtt_obj = Meshastic::MQTT.connect
|
|
44
44
|
Meshtastic::MQTT.subscribe(
|
45
45
|
mqtt_obj: mqtt_obj,
|
46
46
|
region: 'US',
|
47
|
-
|
47
|
+
channel_id_path: '2/e/LongFast/#',
|
48
48
|
psks: { LongFast: 'AQ==' }
|
49
49
|
) do |message|
|
50
50
|
puts message.inspect
|
@@ -68,7 +68,7 @@ Meshtastic::MQTT.send_text(
|
|
68
68
|
)
|
69
69
|
```
|
70
70
|
|
71
|
-
One of the "gotchas" when sending messages is ensuring you're sending over the proper channel. The best way to determine
|
71
|
+
One of the "gotchas" when sending messages is ensuring you're sending over the proper integer for the `channel` parameter. The best way to determine the proper `channel` value is by sending a test message from within the meshtastic app and then viewing the MQTT message similar to the following:
|
72
72
|
|
73
73
|
```ruby
|
74
74
|
require 'meshtastic'
|
@@ -76,7 +76,7 @@ mqtt_obj = Meshastic::MQTT.connect
|
|
76
76
|
Meshtastic::MQTT.subscribe(
|
77
77
|
mqtt_obj: mqtt_obj,
|
78
78
|
region: 'US',
|
79
|
-
|
79
|
+
channel_id_path: '2/e/LongFast/#',
|
80
80
|
psks: { LongFast: 'AQ==' },
|
81
81
|
filter: '!YOUR_CLIENT_ID'
|
82
82
|
) do |message|
|
@@ -84,6 +84,14 @@ Meshtastic::MQTT.subscribe(
|
|
84
84
|
end
|
85
85
|
```
|
86
86
|
|
87
|
+
You should see something like this:
|
88
|
+
|
89
|
+
```
|
90
|
+
{packet: {from: 4080917205, to: 4294967295, channel: 93, id: 1198634591, rx_time: 1738614021, rx_snr: 0.0, hop_limit: 3, want_ack: false, priority: :HIGH, rx_rssi: 0, delayed: :NO_DELAY, via_mqtt: false, hop_start: 3, public_key: "", pki_encrypted: false, next_hop: 0, relay_node: 0, tx_after: 0, decoded: {portnum: :TEXT_MESSAGE_APP, payload: "WHAT IS MY channel VALUE?", want_response: false, dest: 0, source: 0, request_id: 0, reply_id: 0, emoji: 0, bitfield: 0}, encrypted: :decrypted, topic: "msh/US/2/e/LongFast/!f33ddad5", node_id_from: "!f33ddad5", node_id_to: "!ffffffff", rx_time_utc: "2025-01-01 07:00:00 UTC"}, channel_id: "LongFast", gateway_id: "!f33ddad5"}
|
91
|
+
```
|
92
|
+
|
93
|
+
Note where is says `channel: 93`. This is the `channel` value required to send messages in this particular example.
|
94
|
+
|
87
95
|
## Contributing
|
88
96
|
|
89
97
|
Bug reports and pull requests are welcome on GitHub at https://github.com/0dayinc/meshtastic. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/0dayinc/meshtastic/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/meshtastic/mqtt.rb
CHANGED
@@ -48,8 +48,8 @@ module Meshtastic
|
|
48
48
|
# mqtt_obj: 'required - mqtt_obj returned from #connect method'
|
49
49
|
# root_topic: 'optional - root topic (default: msh)',
|
50
50
|
# region: 'optional - region e.g. 'US/VA', etc (default: US)',
|
51
|
-
#
|
52
|
-
# psks: 'optional - hash of :
|
51
|
+
# channel_id_path: 'optional - channel ID path e.g. "2/stat/#" (default: "2/e/LongFast/#")',
|
52
|
+
# psks: 'optional - hash of :channel_id => psk key value pairs (default: { LongFast: "AQ==" })',
|
53
53
|
# qos: 'optional - quality of service (default: 0)',
|
54
54
|
# filter: 'optional - comma-delimited string(s) to filter on in message (default: nil)',
|
55
55
|
# gps_metadata: 'optional - include GPS metadata in output (default: false)',
|
@@ -60,12 +60,12 @@ module Meshtastic
|
|
60
60
|
mqtt_obj = opts[:mqtt_obj]
|
61
61
|
root_topic = opts[:root_topic] ||= 'msh'
|
62
62
|
region = opts[:region] ||= 'US'
|
63
|
-
|
63
|
+
channel_id_path = opts[:channel_id_path] ||= '2/e/LongFast/#'
|
64
64
|
# TODO: Support Array of PSKs and attempt each until decrypted
|
65
65
|
|
66
66
|
public_psk = '1PG7OiApB1nwvP+rz05pAQ=='
|
67
67
|
psks = opts[:psks] ||= { LongFast: public_psk }
|
68
|
-
raise 'ERROR: psks parameter must be a hash of :
|
68
|
+
raise 'ERROR: psks parameter must be a hash of :channel_id => psk key value pairs' unless psks.is_a?(Hash)
|
69
69
|
|
70
70
|
psks[:LongFast] = public_psk if psks[:LongFast] == 'AQ=='
|
71
71
|
psks = Meshtastic.get_cipher_keys(psks: psks)
|
@@ -77,7 +77,7 @@ module Meshtastic
|
|
77
77
|
include_raw = opts[:include_raw] ||= false
|
78
78
|
|
79
79
|
# NOTE: Use MQTT Explorer for topic discovery
|
80
|
-
full_topic = "#{root_topic}/#{region}/#{
|
80
|
+
full_topic = "#{root_topic}/#{region}/#{channel_id_path}"
|
81
81
|
full_topic = "#{root_topic}/#{region}" if region == '#'
|
82
82
|
puts "Subscribing to: #{full_topic}"
|
83
83
|
mqtt_obj.subscribe(full_topic, qos)
|
@@ -218,13 +218,13 @@ module Meshtastic
|
|
218
218
|
# from: ' required - From ID (String or Integer)',
|
219
219
|
# to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
|
220
220
|
# topic: 'optional - topic to publish to (default: "msh/US/2/e/LongFast/1")',
|
221
|
-
# channel: 'optional - channel
|
221
|
+
# channel: 'optional - channel (Default: 6)',
|
222
222
|
# text: 'optional - Text Message (Default: SYN)',
|
223
223
|
# want_ack: 'optional - Want Acknowledgement (Default: false)',
|
224
224
|
# want_response: 'optional - Want Response (Default: false)',
|
225
225
|
# hop_limit: 'optional - Hop Limit (Default: 3)',
|
226
226
|
# on_response: 'optional - Callback on Response',
|
227
|
-
# psks: 'optional - hash of :
|
227
|
+
# psks: 'optional - hash of :channel_id => psk key value pairs (default: { LongFast: "AQ==" })'
|
228
228
|
# )
|
229
229
|
public_class_method def self.send_text(opts = {})
|
230
230
|
mqtt_obj = opts[:mqtt_obj]
|
@@ -276,8 +276,8 @@ module Meshtastic
|
|
276
276
|
mqtt_obj: 'required - mqtt_obj object returned from #connect method',
|
277
277
|
root_topic: 'optional - root topic (default: msh)',
|
278
278
|
region: 'optional - region e.g. 'US/VA', etc (default: US)',
|
279
|
-
|
280
|
-
psks: 'optional - hash of :
|
279
|
+
channel_id_path: 'optional - channel ID path e.g. '2/stat/#' (default: '2/e/LongFast/#')',
|
280
|
+
psks: 'optional - hash of :channel_id => psk key value pairs (default: { LongFast: 'AQ==' })',
|
281
281
|
qos: 'optional - quality of service (default: 0)',
|
282
282
|
json: 'optional - JSON output (default: false)',
|
283
283
|
filter: 'optional - comma-delimited string(s) to filter on in message (default: nil)',
|
@@ -289,7 +289,7 @@ module Meshtastic
|
|
289
289
|
from: ' required - From ID (String or Integer)',
|
290
290
|
to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
|
291
291
|
topic: 'optional - topic to publish to (default: 'msh/US/2/e/LongFast/1')',
|
292
|
-
channel: 'optional - channel
|
292
|
+
channel: 'optional - channel (Default: 6)',
|
293
293
|
text: 'optional - Text Message (Default: SYN)',
|
294
294
|
want_ack: 'optional - Want Acknowledgement (Default: false)',
|
295
295
|
want_response: 'optional - Want Response (Default: false)',
|
data/lib/meshtastic/version.rb
CHANGED
data/lib/meshtastic.rb
CHANGED
@@ -55,7 +55,7 @@ module Meshtastic
|
|
55
55
|
# to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
|
56
56
|
# last_packet_id: 'optional - Last Packet ID (Default: 0)',
|
57
57
|
# via: 'optional - :radio || :mqtt (Default: :radio)',
|
58
|
-
# channel: 'optional - Channel
|
58
|
+
# channel: 'optional - Channel (Default: 6)',
|
59
59
|
# text: 'optional - Text Message (Default: SYN)',
|
60
60
|
# want_ack: 'optional - Want Acknowledgement (Default: false)',
|
61
61
|
# want_response: 'optional - Want Response (Default: false)',
|
@@ -127,7 +127,7 @@ module Meshtastic
|
|
127
127
|
# to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
|
128
128
|
# last_packet_id: 'optional - Last Packet ID (Default: 0)',
|
129
129
|
# via: 'optional - :radio || :mqtt (Default: :radio)',
|
130
|
-
# channel: 'optional - Channel
|
130
|
+
# channel: 'optional - Channel (Default: 0)',
|
131
131
|
# data: 'required - Data to Send',
|
132
132
|
# want_ack: 'optional - Want Acknowledgement (Default: false)',
|
133
133
|
# hop_limit: 'optional - Hop Limit (Default: 3)',
|
@@ -192,7 +192,7 @@ module Meshtastic
|
|
192
192
|
# to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
|
193
193
|
# last_packet_id: 'optional - Last Packet ID (Default: 0)',
|
194
194
|
# via: 'optional - :radio || :mqtt (Default: :radio)',
|
195
|
-
# channel: 'optional - Channel
|
195
|
+
# channel: 'optional - Channel (Default: 0)',
|
196
196
|
# want_ack: 'optional - Want Acknowledgement (Default: false)',
|
197
197
|
# hop_limit: 'optional - Hop Limit (Default: 3)',
|
198
198
|
# psks: 'optional - hash of :channel => psk key value pairs (default: { LongFast: "AQ==" })'
|
@@ -264,6 +264,7 @@ module Meshtastic
|
|
264
264
|
when :mqtt
|
265
265
|
service_envelope = Meshtastic::ServiceEnvelope.new
|
266
266
|
service_envelope.packet = mesh_packet
|
267
|
+
# TODO: Add support for multiple PSKs by accepting channel_id
|
267
268
|
service_envelope.channel_id = psks.keys.first
|
268
269
|
service_envelope.gateway_id = "!#{from.to_s(16).downcase}"
|
269
270
|
send_to_mqtt(service_envelope: service_envelope)
|