meshtastic 0.0.23 → 0.0.25

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: 92ee92f4c1356fc60440b101723abac1c35e33ef757bb74266e8d32a982df2b5
4
- data.tar.gz: 3917587b0080996105d5f0c73fee9208f2c89ddf067a13a661d95f58a5fb5f43
3
+ metadata.gz: 9aaeb1f3c75edb7a08e4f090d34ebbdae6d2bee25ff9b6cde3191967b425412d
4
+ data.tar.gz: 8ea1b16b5e6e50cb5557f3bf188c6ee1ae76dd98a9c8f88ca46b7913eb42790b
5
5
  SHA512:
6
- metadata.gz: 678c08feb284f83a56bdc43824074621b1a0835de6ecf56757f2129f5ac26277940b4c1cc48b636947dbd8974bc94f872f7169429872c86c9f04f33161cc47c4
7
- data.tar.gz: d581f878f32669d5a93a57dc849468669c21939d98b20915cce1c432bb76f1984b6bf9005690c9d581741fbe40a068bd06c5d3e0c7c9356853b6e5808eeccdef
6
+ metadata.gz: 47fae55292b03c5993c4ecd1123e337fd7fc205c9aca093a4762ce1208d7e3c8ae33f950d8c036ea3aaf2396043430f2779988d28fd625bae983c5fe7221c432
7
+ data.tar.gz: 259fad6dbe769bb3d427ab6e5583f85fca1db5d6ebd14d0637f4edc8344cb09f8f34e31d592c72101e0a381faa270942dd2722bd2ccb924a28e961b5bc57e066
data/Gemfile CHANGED
@@ -23,3 +23,4 @@ gem 'rubocop', '1.63.4'
23
23
  gem 'rubocop-rake', '0.6.0'
24
24
  gem 'rubocop-rspec', '2.29.1'
25
25
  gem 'rvm', '1.11.3.9'
26
+ gem 'yard', '0.9.36'
data/README.md CHANGED
@@ -24,7 +24,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
24
24
 
25
25
  ## Usage
26
26
 
27
- At the moment the only module available is `Meshtastic::MQTT`. To view MQTT messages, run the following:
27
+ At the moment the only module available is `Meshtastic::MQTT`. To view MQTT messages, and filter for all messages containing `_APP` _and_ `LongFast` strings, use the following code:
28
28
 
29
29
  ```ruby
30
30
  require 'meshtastic'
@@ -32,17 +32,17 @@ Meshtastic::MQTT.help
32
32
  mqtt_obj = Meshastic::MQTT.connect
33
33
  Meshtastic::MQTT.subscribe(
34
34
  mqtt_obj: mqtt_obj,
35
- filter: 'NODEINFO_APP, LongFast'
35
+ filter: '_APP, LongFast'
36
36
  )
37
37
  ```
38
38
 
39
- This code will print the `from` value of each message received:
39
+ This code will dump the contents of every message:
40
40
 
41
41
  ```ruby
42
42
  require 'meshtastic'
43
43
  mqtt_obj = Meshastic::MQTT.connect
44
44
  Meshtastic::MQTT.subscribe(mqtt_obj: mqtt_obj) do |message|
45
- puts message[:from]
45
+ puts message.inspect
46
46
  end
47
47
  ```
48
48
 
@@ -65,10 +65,10 @@ module Meshtastic
65
65
  filter = opts[:filter]
66
66
 
67
67
  # TODO: Find JSON URI for this
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)
68
+ full_topic = "#{root_topic}/#{region}/2/json/#{channel}/#" if json
69
+ full_topic = "#{root_topic}/#{region}/2/c/#{channel}/#" unless json
70
+ puts "Subscribing to: #{full_topic}"
71
+ mqtt_obj.subscribe(full_topic, qos)
72
72
 
73
73
  # Decrypt the message
74
74
  # Our AES key is 128 or 256 bits, shared as part of the 'Channel' specification.
@@ -85,20 +85,19 @@ module Meshtastic
85
85
  filter_arr = filter.to_s.split(',').map(&:strip)
86
86
  mqtt_obj.get_packet do |packet_bytes|
87
87
  raw_packet = packet_bytes.to_s.b
88
- raw_packet_len = raw_packet.to_s.b.length
89
88
  raw_topic = packet_bytes.topic ||= ''
90
89
  raw_message = packet_bytes.payload
91
90
 
92
91
  begin
93
92
  disp = false
94
93
  message = {}
94
+ stdout_message = ''
95
95
 
96
96
  if json
97
97
  message = JSON.parse(raw_message, symbolize_names: true)
98
98
  else
99
- svc_envl = Meshtastic::ServiceEnvelope.decode(raw_message)
100
- # map_report = Meshtastic::MapReport.decode(raw_message)
101
- message = svc_envl.to_h[:packet]
99
+ decoded_packet = Meshtastic::ServiceEnvelope.decode(raw_message)
100
+ message = decoded_packet.to_h[:packet]
102
101
  end
103
102
  message[:topic] = raw_topic
104
103
  message[:node_id_from] = "!#{message[:from].to_i.to_s(16)}"
@@ -122,6 +121,75 @@ module Meshtastic
122
121
 
123
122
  decrypted = cipher.update(encrypted_message) + cipher.final
124
123
  message[:decrypted] = decrypted
124
+ # Vvv Decode the decrypted message vvV
125
+ end
126
+
127
+ if message[:decoded]
128
+ payload = message[:decoded][:payload]
129
+
130
+ msg_type = message[:decoded][:portnum]
131
+ case msg_type
132
+ when :ADMIN_APP
133
+ pb_obj = Meshtastic::Admin.decode(payload)
134
+ when :ATAK_FORWARDER
135
+ pb_obj = Meshtastic::AtakForwarder.decode(payload)
136
+ when :ATAK_PLUGIN
137
+ pb_obj = Meshtastic::AtakPlugin.decode(payload)
138
+ when :AUDIO_APP
139
+ pb_obj = Meshtastic::Audio.decode(payload)
140
+ when :DETECTION_SENSOR_APP
141
+ pb_obj = Meshtastic::DetectionSensor.decode(payload)
142
+ when :IP_TUNNEL_APP
143
+ pb_obj = Meshtastic::IpTunnel.decode(payload)
144
+ when :MAP_REPORT_APP
145
+ pb_obj = Meshtastic::MapReport.decode(payload)
146
+ when :MAX
147
+ pb_obj = Meshtastic::Max.decode(payload)
148
+ when :NEIGHBORINFO_APP
149
+ pb_obj = Meshtastic::NeighborInfo.decode(payload)
150
+ when :NODEINFO_APP
151
+ pb_obj = Meshtastic::NodeInfo.decode(payload)
152
+ when :PAXCOUNTER_APP
153
+ pb_obj = Meshtastic::Paxcounter.decode(payload)
154
+ when :POSITION_APP
155
+ pb_obj = Meshtastic::Position.decode(payload)
156
+ when :PRIVATE_APP
157
+ pb_obj = Meshtastic::Private.decode(payload)
158
+ when :RANGE_TEST_APP
159
+ pb_obj = Meshtastic::RangeTest.decode(payload)
160
+ when :REMOTE_HARDWARE_APP
161
+ pb_obj = Meshtastic::RemoteHardware.decode(payload)
162
+ when :REPLY_APP
163
+ pb_obj = Meshtastic::Reply.decode(payload)
164
+ when :ROUTING_APP
165
+ pb_obj = Meshtastic::Routing.decode(payload)
166
+ when :SERIAL_APP
167
+ pb_obj = Meshtastic::Serial.decode(payload)
168
+ when :SIMULATOR_APP
169
+ pb_obj = Meshtastic::Simulator.decode(payload)
170
+ when :STORE_FORWARD_APP
171
+ pb_obj = Meshtastic::StoreForward.decode(payload)
172
+ when :TEXT_MESSAGE_APP
173
+ pb_obj = Meshtastic::TextMessage.decode(payload)
174
+ when :TEXT_MESSAGE_COMPRESSED_APP
175
+ pb_obj = Meshtastic::TextMessageCompressed.decode(payload)
176
+ when :TELEMETRY_APP
177
+ pb_obj = Meshtastic::Telemetry.decode(payload)
178
+ when :TRACEROUTE_APP
179
+ pb_obj = Meshtastic::Traceroute.decode(payload)
180
+ when :UNKNOWN_APP
181
+ pb_obj = Meshtastic.Unknown.decode(payload)
182
+ when :WAYPOINT_APP
183
+ pb_obj = Meshtastic::Waypoint.decode(payload)
184
+ when :ZPS_APP
185
+ pb_obj = Meshtastic::Zps.decode(payload)
186
+ else
187
+ puts "WARNING: Unknown message type: #{msg_type}"
188
+ end
189
+ # Overwrite the payload with the decoded protobuf object
190
+ message[:decoded][:payload] = pb_obj.to_h
191
+ # puts pb_obj.public_methods
192
+ # message[:decoded][:pb_obj] = pb_obj
125
193
  end
126
194
 
127
195
  filter_arr = [message[:id].to_s] if filter.nil?
@@ -130,7 +198,12 @@ module Meshtastic
130
198
  disp = true if filter_arr.first == message[:id] ||
131
199
  filter_arr.all? { |filter| flat_message.include?(filter) }
132
200
 
133
- rescue Google::Protobuf::ParseError
201
+ message[:raw_packet] = raw_packet if block_given?
202
+ stdout_message = JSON.pretty_generate(message) unless block_given?
203
+ rescue Google::Protobuf::ParseError,
204
+ JSON::GeneratorError
205
+
206
+ stdout_message = message.to_s.b.inspect unless block_given?
134
207
  next
135
208
  ensure
136
209
  if disp
@@ -139,11 +212,8 @@ module Meshtastic
139
212
  else
140
213
  puts "\n"
141
214
  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}"
215
+ puts 'MSG:'
216
+ puts stdout_message
147
217
  puts '-' * 80
148
218
  puts "\n\n\n"
149
219
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meshtastic
4
- VERSION = '0.0.23'
4
+ VERSION = '0.0.25'
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.23
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
180
  version: 1.11.3.9
181
+ - !ruby/object:Gem::Dependency
182
+ name: yard
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 0.9.36
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 0.9.36
181
195
  description: https://github.com/0dayinc/meshtastic/README.md
182
196
  email:
183
197
  - support@0dayinc.com