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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbd76d5eb5caa289b389949f752dcdcbe9185dd55db794ceeaa7aeff86342eb9
4
- data.tar.gz: 9a941303697050de11c04c2fbcc64ef6cffebd16b1959a3b1e5359b904c7628d
3
+ metadata.gz: 92ee92f4c1356fc60440b101723abac1c35e33ef757bb74266e8d32a982df2b5
4
+ data.tar.gz: 3917587b0080996105d5f0c73fee9208f2c89ddf067a13a661d95f58a5fb5f43
5
5
  SHA512:
6
- metadata.gz: 3af0be5f4930d87b7a4f536417de6429302bd65da11f19ccf843241de0d32b1c72077ab6a4ce2231f237b75669514ee4a237b618e65534884da6f0db619f5f0a
7
- data.tar.gz: d560584669d17490e6da18e4169164dce4077f2cbcb8619bca0f5d816b46e4526d2334acaeaeba3cd32b4a5e0494250dbd34fe6994a0baf4e2b066d60289722e
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( mqtt_obj: mqtt_obj) do |message|
44
+ Meshtastic::MQTT.subscribe(mqtt_obj: mqtt_obj) do |message|
44
45
  puts message[:from]
45
46
  end
46
47
  ```
@@ -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
- root_topic = "msh/#{region}/2/json" if json
67
- root_topic = "msh/#{region}/2/c" unless json
68
- mqtt_obj.subscribe("#{root_topic}/#{channel}/#", qos)
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
- puts "\n"
135
- puts '-' * 80
136
- puts "*** DEBUGGING ***"
137
- puts "MSG:\n#{message.inspect}"
138
- # puts "\nMap Report: #{map_report.inspect}"
139
- puts "\nRaw Packet: #{raw_packet.inspect}"
140
- puts "Length: #{raw_packet_len}"
141
- puts '-' * 80
142
- puts "\n\n\n"
143
- yield message if block_given?
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==)',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meshtastic
4
- VERSION = '0.0.22'
4
+ VERSION = '0.0.23'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meshtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.