meshtastic 0.0.23 → 0.0.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92ee92f4c1356fc60440b101723abac1c35e33ef757bb74266e8d32a982df2b5
4
- data.tar.gz: 3917587b0080996105d5f0c73fee9208f2c89ddf067a13a661d95f58a5fb5f43
3
+ metadata.gz: b24b299642029b92a222cd725fc4fcc7cc16f65456e9e7ed14a19ba961370126
4
+ data.tar.gz: f311791bced3690a4e7072cd0c71c0d7521eec9a14c93425a70a8d46f6a1e198
5
5
  SHA512:
6
- metadata.gz: 678c08feb284f83a56bdc43824074621b1a0835de6ecf56757f2129f5ac26277940b4c1cc48b636947dbd8974bc94f872f7169429872c86c9f04f33161cc47c4
7
- data.tar.gz: d581f878f32669d5a93a57dc849468669c21939d98b20915cce1c432bb76f1984b6bf9005690c9d581741fbe40a068bd06c5d3e0c7c9356853b6e5808eeccdef
6
+ metadata.gz: 356940728257de2c144fdd3614e20b0ef7e03fba208d2e97b13822a8bf1e732bb2e338da814d06303147c756b9e60f34068723e43f774070136e123bb8dea955
7
+ data.tar.gz: eb0bd43a244d7bad3dd49ee52ecc4f07a4ecbd079781065a0fd64723e4aeb60bb1e8292f2402558c7d920ba373f0cecb5064c72dd750078668049604073162cd
@@ -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.24'
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.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.