meshtastic 0.0.23 → 0.0.24
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 +84 -14
- 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: b24b299642029b92a222cd725fc4fcc7cc16f65456e9e7ed14a19ba961370126
|
4
|
+
data.tar.gz: f311791bced3690a4e7072cd0c71c0d7521eec9a14c93425a70a8d46f6a1e198
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 356940728257de2c144fdd3614e20b0ef7e03fba208d2e97b13822a8bf1e732bb2e338da814d06303147c756b9e60f34068723e43f774070136e123bb8dea955
|
7
|
+
data.tar.gz: eb0bd43a244d7bad3dd49ee52ecc4f07a4ecbd079781065a0fd64723e4aeb60bb1e8292f2402558c7d920ba373f0cecb5064c72dd750078668049604073162cd
|
data/lib/meshtastic/mqtt.rb
CHANGED
@@ -65,10 +65,10 @@ module Meshtastic
|
|
65
65
|
filter = opts[:filter]
|
66
66
|
|
67
67
|
# TODO: Find JSON URI for this
|
68
|
-
|
69
|
-
|
70
|
-
puts "Subscribing to: #{
|
71
|
-
mqtt_obj.subscribe(
|
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
|
-
|
100
|
-
|
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
|
-
|
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
|
143
|
-
puts
|
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
|
data/lib/meshtastic/version.rb
CHANGED