meshtastic 0.0.34 → 0.0.36
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 +4 -4
- data/lib/meshtastic/mqtt.rb +30 -15
- 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: a1557d6c023667935647acdf7bb90c4d1613bf048a1907b522849fb9f3a3c5d1
|
4
|
+
data.tar.gz: a26600a5afd502eeb0a7efe99c9df4cddf8f41635d1d53414f8d4a7d59c036f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38f3941863fb6a984f0ea93e170435fdf9d6c9ff648b7b779cb476daf7c4d3e6fdae2c17ac1b28207a5e7a36088cf3eb9630478304059350a6edc9163538eb19
|
7
|
+
data.tar.gz: 356331a1d7daf23a56359108cf469e059fb5671660a8cea817b21ada22253e400e8879cc74cc0ff4197a0240c47f5416783d84cadba37374c7f4c823e947340d
|
data/lib/meshtastic/mqtt.rb
CHANGED
@@ -86,21 +86,24 @@ module Meshtastic
|
|
86
86
|
cipher = OpenSSL::Cipher.new('AES-128-CTR')
|
87
87
|
filter_arr = filter.to_s.split(',').map(&:strip)
|
88
88
|
mqtt_obj.get_packet do |packet_bytes|
|
89
|
-
raw_packet = packet_bytes.to_s.b
|
89
|
+
# raw_packet = packet_bytes.to_s.b
|
90
90
|
raw_topic = packet_bytes.topic ||= ''
|
91
|
-
|
91
|
+
raw_payload = packet_bytes.payload
|
92
92
|
|
93
93
|
begin
|
94
94
|
disp = false
|
95
|
+
decoded_payload_hash = {}
|
95
96
|
message = {}
|
96
97
|
stdout_message = ''
|
97
98
|
|
98
99
|
if json
|
99
|
-
|
100
|
+
decoded_payload_hash = JSON.parse(raw_payload, symbolize_names: true)
|
100
101
|
else
|
101
|
-
|
102
|
-
|
102
|
+
decoded_payload = Meshtastic::ServiceEnvelope.decode(raw_payload)
|
103
|
+
decoded_payload_hash = decoded_payload.to_h
|
103
104
|
end
|
105
|
+
|
106
|
+
message = decoded_payload_hash[:packet] if decoded_payload_hash.keys.include?(:packet)
|
104
107
|
message[:topic] = raw_topic
|
105
108
|
message[:node_id_from] = "!#{message[:from].to_i.to_s(16)}"
|
106
109
|
message[:node_id_to] = "!#{message[:to].to_i.to_s(16)}"
|
@@ -123,6 +126,8 @@ module Meshtastic
|
|
123
126
|
|
124
127
|
decrypted = cipher.update(encrypted_message) + cipher.final
|
125
128
|
message[:decrypted] = decrypted
|
129
|
+
# decoded_packet = Meshtastic::ServiceEnvelope.decode(decrypted)
|
130
|
+
# puts "Decoded Decrypted Packet: #{decoded_packet.display.to_h}"
|
126
131
|
# Vvv Decode the decrypted message vvV
|
127
132
|
end
|
128
133
|
|
@@ -175,7 +180,8 @@ module Meshtastic
|
|
175
180
|
pb_obj = Meshtastic::StoreAndForward.decode(payload)
|
176
181
|
when :TEXT_MESSAGE_APP
|
177
182
|
# Unsure if this is the correct protobuf object
|
178
|
-
pb_obj = Meshtastic::MqttClientProxyMessage.decode(payload)
|
183
|
+
# pb_obj = Meshtastic::MqttClientProxyMessage.decode(payload)
|
184
|
+
pb_obj = Meshtastic::Data.decode(payload)
|
179
185
|
when :TELEMETRY_APP
|
180
186
|
pb_obj = Meshtastic::Telemetry.decode(payload)
|
181
187
|
when :TRACEROUTE_APP
|
@@ -214,23 +220,32 @@ module Meshtastic
|
|
214
220
|
# message[:decoded][:pb_obj] = pb_obj
|
215
221
|
end
|
216
222
|
|
223
|
+
# message[:raw_packet] = raw_packet if block_given?
|
224
|
+
decoded_payload_hash[:packet] = message
|
225
|
+
unless block_given?
|
226
|
+
message[:stdout] = 'pretty'
|
227
|
+
stdout_message = JSON.pretty_generate(decoded_payload_hash)
|
228
|
+
end
|
229
|
+
rescue Google::Protobuf::ParseError,
|
230
|
+
JSON::GeneratorError
|
231
|
+
|
232
|
+
decoded_payload_hash[:packet] = message
|
233
|
+
unless block_given?
|
234
|
+
message[:stdout] = 'inspect'
|
235
|
+
stdout_message = decoded_payload_hash.inspect
|
236
|
+
end
|
237
|
+
|
238
|
+
next
|
239
|
+
ensure
|
217
240
|
filter_arr = [message[:id].to_s] if filter.nil?
|
218
241
|
flat_message = message.values.join(' ')
|
219
242
|
|
220
243
|
disp = true if filter_arr.first == message[:id] ||
|
221
244
|
filter_arr.all? { |filter| flat_message.include?(filter) }
|
222
245
|
|
223
|
-
message[:raw_packet] = raw_packet if block_given?
|
224
|
-
stdout_message = JSON.pretty_generate(message) unless block_given?
|
225
|
-
rescue Google::Protobuf::ParseError,
|
226
|
-
JSON::GeneratorError
|
227
|
-
|
228
|
-
stdout_message = message.inspect unless block_given?
|
229
|
-
next
|
230
|
-
ensure
|
231
246
|
if disp
|
232
247
|
if block_given?
|
233
|
-
yield
|
248
|
+
yield decoded_payload_hash
|
234
249
|
else
|
235
250
|
puts "\n"
|
236
251
|
puts '-' * 80
|
data/lib/meshtastic/version.rb
CHANGED