meshtastic 0.0.184 → 0.0.185
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/.rubocop_todo.yml +1 -0
- data/Gemfile +2 -1
- data/documentation/README.md +5 -0
- data/documentation/forwarder.md +149 -0
- data/documentation/mesh-interface.md +157 -1
- data/documentation/payload-formats.md +187 -0
- data/documentation/reticulum.md +89 -0
- data/lib/meshtastic/atak.rb +98 -13
- data/lib/meshtastic/atak_pb.rb +3 -1
- data/lib/meshtastic/config_pb.rb +1 -1
- data/lib/meshtastic/field_metadata_pb.rb +1 -1
- data/lib/meshtastic/forwarder.rb +190 -0
- data/lib/meshtastic/forwarder_pb.rb +77 -0
- data/lib/meshtastic/mesh_beacon_pb.rb +1 -1
- data/lib/meshtastic/mesh_interface.rb +115 -65
- data/lib/meshtastic/mesh_pb.rb +2 -1
- data/lib/meshtastic/module_config_pb.rb +1 -1
- data/lib/meshtastic/mqtt.rb +4 -34
- data/lib/meshtastic/payload_compression.rb +90 -0
- data/lib/meshtastic/payload_formats.rb +248 -0
- data/lib/meshtastic/reticulum.rb +71 -0
- data/lib/meshtastic/serial.rb +1 -19
- data/lib/meshtastic/telemetry_pb.rb +2 -2
- data/lib/meshtastic/unishox2.rb +467 -0
- data/lib/meshtastic/version.rb +1 -1
- data/lib/meshtastic.rb +4 -0
- data/meshtastic.gemspec +2 -0
- data/spec/lib/meshtastic/atak_spec.rb +50 -0
- data/spec/lib/meshtastic/bluetooth_spec.rb +14 -0
- data/spec/lib/meshtastic/forwarder_pb_spec.rb +11 -0
- data/spec/lib/meshtastic/forwarder_spec.rb +97 -0
- data/spec/lib/meshtastic/mesh_interface_spec.rb +169 -0
- data/spec/lib/meshtastic/mqtt_spec.rb +56 -0
- data/spec/lib/meshtastic/payload_compression_spec.rb +43 -0
- data/spec/lib/meshtastic/payload_formats_spec.rb +160 -0
- data/spec/lib/meshtastic/reticulum_spec.rb +91 -0
- data/spec/lib/meshtastic/serial_spec.rb +46 -0
- data/spec/lib/meshtastic/tcp_spec.rb +15 -0
- data/spec/lib/meshtastic/unishox2_spec.rb +34 -0
- data/spec/support/payload_fixtures.rb +124 -0
- data/spec/support/reticulum_fixtures.json +12 -0
- data/spec/support/tak_codec_fixtures.rb +4 -0
- data/spec/support/unishox_fixtures.rb +4 -0
- metadata +36 -3
data/lib/meshtastic/mqtt.rb
CHANGED
|
@@ -137,40 +137,10 @@ module Meshtastic
|
|
|
137
137
|
message[:public_key] = Base64.strict_encode64(raw_public_key)
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
message[:topic]
|
|
145
|
-
|
|
146
|
-
# if message[:pki_encrypted]
|
|
147
|
-
# # TODO: Display Decrypted PKI Message
|
|
148
|
-
# public_key = message[:public_key]
|
|
149
|
-
# dec_public_key = Base64.strict_decode64(public_key)
|
|
150
|
-
# else
|
|
151
|
-
packet_id = message[:id]
|
|
152
|
-
packet_from = message[:from]
|
|
153
|
-
|
|
154
|
-
nonce_packet_id = [packet_id].pack('V').ljust(8, "\x00")
|
|
155
|
-
nonce_from_node = [packet_from].pack('V').ljust(8, "\x00")
|
|
156
|
-
nonce = "#{nonce_packet_id}#{nonce_from_node}"
|
|
157
|
-
|
|
158
|
-
psk = psks[:LongFast]
|
|
159
|
-
target_channel = message[:topic].split('/')[-2].to_sym
|
|
160
|
-
psk = psks[target_channel] if psks.keys.include?(target_channel)
|
|
161
|
-
dec_psk = Base64.strict_decode64(psk)
|
|
162
|
-
|
|
163
|
-
cipher = OpenSSL::Cipher.new('AES-128-CTR')
|
|
164
|
-
cipher = OpenSSL::Cipher.new('AES-256-CTR') if dec_psk.length == 32
|
|
165
|
-
cipher.decrypt
|
|
166
|
-
cipher.key = dec_psk
|
|
167
|
-
cipher.iv = nonce
|
|
168
|
-
|
|
169
|
-
decrypted = cipher.update(encrypted_message) + cipher.final
|
|
170
|
-
# end
|
|
171
|
-
message[:decoded] = Meshtastic::Data.decode(decrypted).to_h
|
|
172
|
-
message[:encrypted] = :decrypted
|
|
173
|
-
end
|
|
140
|
+
mui.decrypt_packet(
|
|
141
|
+
message: message, psks: psks,
|
|
142
|
+
channel: decoded_payload_hash[:channel_id].to_s.empty? ? raw_topic.split('/')[-2].to_s : decoded_payload_hash[:channel_id]
|
|
143
|
+
)
|
|
174
144
|
|
|
175
145
|
if message[:decoded]
|
|
176
146
|
# payload = Meshtastic::Data.decode(message[:decoded][:payload]).to_h
|