meshtastic 0.0.36 → 0.0.37
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/lib/meshtastic/mqtt.rb +8 -8
- 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: 41d11712815ee1680ff3929084cbe63bc0500d400bbdf7d2f087709a9ded258f
|
4
|
+
data.tar.gz: 817138fd986e7a7f7267e69861f866dedad4ac95de8194e7a6e3edcdd6b028ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31ce0114b3ad6e1a03ad185b2706f44ee303c7d8ed1f5fa258ad96b5b6422bdde6d62352fcb7ea71005aa242d99a50eaa2917ef94c063c4a4d6c5f2f04a129e2
|
7
|
+
data.tar.gz: 2caacc5276cb34442c07af78fd8539620b613a3021b84893be243299c0ebd2bdbbdd303a2c65edd3286128c26792fa8e02b2d2be8e51e250b11323307817d6cb
|
data/lib/meshtastic/mqtt.rb
CHANGED
@@ -46,11 +46,10 @@ module Meshtastic
|
|
46
46
|
# Meshtastic::MQQT.subscribe(
|
47
47
|
# mqtt_obj: 'required - mqtt_obj returned from #connect method'
|
48
48
|
# root_topic: 'optional - root topic (default: msh)',
|
49
|
-
# region: 'optional - region (default: US)',
|
50
|
-
# channel: 'optional - channel name (default: LongFast)',
|
49
|
+
# region: 'optional - region e.g. 'US/VA', etc (default: US)',
|
50
|
+
# channel: 'optional - channel name (default: "2/c/LongFast/#")',
|
51
51
|
# psk: 'optional - channel pre-shared key (default: AQ==)',
|
52
52
|
# qos: 'optional - quality of service (default: 0)',
|
53
|
-
# json: 'optional - JSON output (default: false)',
|
54
53
|
# filter: 'optional - comma-delimited string(s) to filter on in message (default: nil)',
|
55
54
|
# gps_metadata: 'optional - include GPS metadata in output (default: false)'
|
56
55
|
# )
|
@@ -59,7 +58,7 @@ module Meshtastic
|
|
59
58
|
mqtt_obj = opts[:mqtt_obj]
|
60
59
|
root_topic = opts[:root_topic] ||= 'msh'
|
61
60
|
region = opts[:region] ||= 'US'
|
62
|
-
channel = opts[:channel] ||= 'LongFast'
|
61
|
+
channel = opts[:channel] ||= '2/e/LongFast/#'
|
63
62
|
psk = opts[:psk] ||= 'AQ=='
|
64
63
|
qos = opts[:qos] ||= 0
|
65
64
|
json = opts[:json] ||= false
|
@@ -67,8 +66,7 @@ module Meshtastic
|
|
67
66
|
gps_metadata = opts[:gps_metadata] ||= false
|
68
67
|
|
69
68
|
# TODO: Find JSON URI for this
|
70
|
-
full_topic = "#{root_topic}/#{region}
|
71
|
-
full_topic = "#{root_topic}/#{region}/2/c/#{channel}/#" unless json
|
69
|
+
full_topic = "#{root_topic}/#{region}/#{channel}"
|
72
70
|
puts "Subscribing to: #{full_topic}"
|
73
71
|
mqtt_obj.subscribe(full_topic, qos)
|
74
72
|
|
@@ -76,7 +74,7 @@ module Meshtastic
|
|
76
74
|
# Our AES key is 128 or 256 bits, shared as part of the 'Channel' specification.
|
77
75
|
|
78
76
|
# Actual pre-shared key for LongFast channel
|
79
|
-
psk = '1PG7OiApB1nwvP+rz05pAQ==' if channel
|
77
|
+
psk = '1PG7OiApB1nwvP+rz05pAQ==' if channel.include?('LongFast')
|
80
78
|
padded_psk = psk.ljust(psk.length + ((4 - (psk.length % 4)) % 4), '=')
|
81
79
|
replaced_psk = padded_psk.gsub('-', '+').gsub('_', '/')
|
82
80
|
psk = replaced_psk
|
@@ -227,8 +225,10 @@ module Meshtastic
|
|
227
225
|
stdout_message = JSON.pretty_generate(decoded_payload_hash)
|
228
226
|
end
|
229
227
|
rescue Google::Protobuf::ParseError,
|
230
|
-
JSON::GeneratorError
|
228
|
+
JSON::GeneratorError,
|
229
|
+
ArgumentError => e
|
231
230
|
|
231
|
+
message[:decrypted] = e.message if ArgumentError
|
232
232
|
decoded_payload_hash[:packet] = message
|
233
233
|
unless block_given?
|
234
234
|
message[:stdout] = 'inspect'
|
data/lib/meshtastic/version.rb
CHANGED