meshtastic 0.0.36 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/meshtastic/mqtt.rb +10 -10
- 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: ac577c0153e4ad5a0113ad1e2329a1225787406d712974c45b98d438e51c17e3
|
4
|
+
data.tar.gz: e0364940c63d6a242c031170a6258bcabcf93354554d1d84c624d04d624afd02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b520548467c045ecacd7aa41ffd2e0b08cd0bccaa777a5f6a93af8b7c3335e5c003b452e984f3b5b617403579b1a8bae31b914f7ae04d8c9f4d0bb9889979b92
|
7
|
+
data.tar.gz: a5a22a3c7909cf349fd250a5ef289a7d210b284b0eb7bae7d045b2e68a184cd8798497bcade3f86f7d3ecf645edb33385465042ccdb0db5a5977ae07117f883e
|
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 e.g. "2/stat/#" (default: "2/e/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'
|
@@ -320,8 +320,8 @@ module Meshtastic
|
|
320
320
|
#{self}.subscribe(
|
321
321
|
mqtt_obj: 'required - mqtt_obj object returned from #connect method',
|
322
322
|
root_topic: 'optional - root topic (default: msh)',
|
323
|
-
region: 'optional - region (default: US)',
|
324
|
-
channel: 'optional - channel name (default: LongFast)',
|
323
|
+
region: 'optional - region e.g. 'US/VA', etc (default: US)',
|
324
|
+
channel: 'optional - channel name e.g. '2/stat/#' (default: '2/e/LongFast/#')',
|
325
325
|
psk: 'optional - channel pre-shared key (default: AQ==)',
|
326
326
|
qos: 'optional - quality of service (default: 0)',
|
327
327
|
json: 'optional - JSON output (default: false)',
|
data/lib/meshtastic/version.rb
CHANGED