meshtastic 0.0.35 → 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 +16 -9
- 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
|
|
|
@@ -215,17 +220,19 @@ module Meshtastic
|
|
|
215
220
|
# message[:decoded][:pb_obj] = pb_obj
|
|
216
221
|
end
|
|
217
222
|
|
|
218
|
-
message[:raw_packet] = raw_packet if block_given?
|
|
223
|
+
# message[:raw_packet] = raw_packet if block_given?
|
|
224
|
+
decoded_payload_hash[:packet] = message
|
|
219
225
|
unless block_given?
|
|
220
226
|
message[:stdout] = 'pretty'
|
|
221
|
-
stdout_message = JSON.pretty_generate(
|
|
227
|
+
stdout_message = JSON.pretty_generate(decoded_payload_hash)
|
|
222
228
|
end
|
|
223
229
|
rescue Google::Protobuf::ParseError,
|
|
224
230
|
JSON::GeneratorError
|
|
225
231
|
|
|
232
|
+
decoded_payload_hash[:packet] = message
|
|
226
233
|
unless block_given?
|
|
227
234
|
message[:stdout] = 'inspect'
|
|
228
|
-
stdout_message =
|
|
235
|
+
stdout_message = decoded_payload_hash.inspect
|
|
229
236
|
end
|
|
230
237
|
|
|
231
238
|
next
|
|
@@ -238,7 +245,7 @@ module Meshtastic
|
|
|
238
245
|
|
|
239
246
|
if disp
|
|
240
247
|
if block_given?
|
|
241
|
-
yield
|
|
248
|
+
yield decoded_payload_hash
|
|
242
249
|
else
|
|
243
250
|
puts "\n"
|
|
244
251
|
puts '-' * 80
|
data/lib/meshtastic/version.rb
CHANGED