meshtastic 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/meshtastic/mqtt.rb +20 -13
- 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: 92ee92f4c1356fc60440b101723abac1c35e33ef757bb74266e8d32a982df2b5
|
4
|
+
data.tar.gz: 3917587b0080996105d5f0c73fee9208f2c89ddf067a13a661d95f58a5fb5f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 678c08feb284f83a56bdc43824074621b1a0835de6ecf56757f2129f5ac26277940b4c1cc48b636947dbd8974bc94f872f7169429872c86c9f04f33161cc47c4
|
7
|
+
data.tar.gz: d581f878f32669d5a93a57dc849468669c21939d98b20915cce1c432bb76f1984b6bf9005690c9d581741fbe40a068bd06c5d3e0c7c9356853b6e5808eeccdef
|
data/README.md
CHANGED
@@ -37,10 +37,11 @@ Meshtastic::MQTT.subscribe(
|
|
37
37
|
```
|
38
38
|
|
39
39
|
This code will print the `from` value of each message received:
|
40
|
+
|
40
41
|
```ruby
|
41
42
|
require 'meshtastic'
|
42
43
|
mqtt_obj = Meshastic::MQTT.connect
|
43
|
-
Meshtastic::MQTT.subscribe(
|
44
|
+
Meshtastic::MQTT.subscribe(mqtt_obj: mqtt_obj) do |message|
|
44
45
|
puts message[:from]
|
45
46
|
end
|
46
47
|
```
|
data/lib/meshtastic/mqtt.rb
CHANGED
@@ -45,6 +45,7 @@ module Meshtastic
|
|
45
45
|
# Supported Method Parameters::
|
46
46
|
# Meshtastic::MQQT.subscribe(
|
47
47
|
# mqtt_obj: 'required - mqtt_obj returned from #connect method'
|
48
|
+
# root_topic: 'optional - root topic (default: msh)',
|
48
49
|
# region: 'optional - region (default: US)',
|
49
50
|
# channel: 'optional - channel name (default: LongFast)',
|
50
51
|
# psk: 'optional - channel pre-shared key (default: AQ==)',
|
@@ -55,6 +56,7 @@ module Meshtastic
|
|
55
56
|
|
56
57
|
public_class_method def self.subscribe(opts = {})
|
57
58
|
mqtt_obj = opts[:mqtt_obj]
|
59
|
+
root_topic = opts[:root_topic] ||= 'msh'
|
58
60
|
region = opts[:region] ||= 'US'
|
59
61
|
channel = opts[:channel] ||= 'LongFast'
|
60
62
|
psk = opts[:psk] ||= 'AQ=='
|
@@ -63,9 +65,10 @@ module Meshtastic
|
|
63
65
|
filter = opts[:filter]
|
64
66
|
|
65
67
|
# TODO: Find JSON URI for this
|
66
|
-
|
67
|
-
|
68
|
-
|
68
|
+
mqtt_path = "#{root_topic}/#{region}/2/json/#{channel}/#" if json
|
69
|
+
mqtt_path = "#{root_topic}/#{region}/2/c/#{channel}/#" unless json
|
70
|
+
puts "Subscribing to: #{mqtt_path}"
|
71
|
+
mqtt_obj.subscribe(mqtt_path, qos)
|
69
72
|
|
70
73
|
# Decrypt the message
|
71
74
|
# Our AES key is 128 or 256 bits, shared as part of the 'Channel' specification.
|
@@ -131,16 +134,19 @@ module Meshtastic
|
|
131
134
|
next
|
132
135
|
ensure
|
133
136
|
if disp
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
137
|
+
if block_given?
|
138
|
+
yield message
|
139
|
+
else
|
140
|
+
puts "\n"
|
141
|
+
puts '-' * 80
|
142
|
+
puts "*** DEBUGGING ***"
|
143
|
+
puts "MSG:\n#{message.inspect}"
|
144
|
+
# puts "\nMap Report: #{map_report.inspect}"
|
145
|
+
puts "\nRaw Packet: #{raw_packet.inspect}"
|
146
|
+
puts "Length: #{raw_packet_len}"
|
147
|
+
puts '-' * 80
|
148
|
+
puts "\n\n\n"
|
149
|
+
end
|
144
150
|
else
|
145
151
|
print '.'
|
146
152
|
end
|
@@ -206,6 +212,7 @@ module Meshtastic
|
|
206
212
|
|
207
213
|
#{self}.subscribe(
|
208
214
|
mqtt_obj: 'required - mqtt_obj object returned from #connect method',
|
215
|
+
root_topic: 'optional - root topic (default: msh)',
|
209
216
|
region: 'optional - region (default: US)',
|
210
217
|
channel: 'optional - channel name (default: LongFast)',
|
211
218
|
psk: 'optional - channel pre-shared key (default: AQ==)',
|
data/lib/meshtastic/version.rb
CHANGED