meshtastic 0.0.21 → 0.0.22
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/Gemfile +1 -1
- data/README.md +9 -0
- data/lib/meshtastic/mqtt.rb +30 -36
- data/lib/meshtastic/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd76d5eb5caa289b389949f752dcdcbe9185dd55db794ceeaa7aeff86342eb9
|
4
|
+
data.tar.gz: 9a941303697050de11c04c2fbcc64ef6cffebd16b1959a3b1e5359b904c7628d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3af0be5f4930d87b7a4f536417de6429302bd65da11f19ccf843241de0d32b1c72077ab6a4ce2231f237b75669514ee4a237b618e65534884da6f0db619f5f0a
|
7
|
+
data.tar.gz: d560584669d17490e6da18e4169164dce4077f2cbcb8619bca0f5d816b46e4526d2334acaeaeba3cd32b4a5e0494250dbd34fe6994a0baf4e2b066d60289722e
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,15 @@ Meshtastic::MQTT.subscribe(
|
|
36
36
|
)
|
37
37
|
```
|
38
38
|
|
39
|
+
This code will print the `from` value of each message received:
|
40
|
+
```ruby
|
41
|
+
require 'meshtastic'
|
42
|
+
mqtt_obj = Meshastic::MQTT.connect
|
43
|
+
Meshtastic::MQTT.subscribe( mqtt_obj: mqtt_obj) do |message|
|
44
|
+
puts message[:from]
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
39
48
|
## Contributing
|
40
49
|
|
41
50
|
Bug reports and pull requests are welcome on GitHub at https://github.com/0dayinc/meshtastic. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/0dayinc/meshtastic/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/meshtastic/mqtt.rb
CHANGED
@@ -50,7 +50,7 @@ module Meshtastic
|
|
50
50
|
# psk: 'optional - channel pre-shared key (default: AQ==)',
|
51
51
|
# qos: 'optional - quality of service (default: 0)',
|
52
52
|
# json: 'optional - JSON output (default: false)',
|
53
|
-
# filter: 'optional - comma-delimited string(s) to filter on in
|
53
|
+
# filter: 'optional - comma-delimited string(s) to filter on in message (default: nil)'
|
54
54
|
# )
|
55
55
|
|
56
56
|
public_class_method def self.subscribe(opts = {})
|
@@ -84,26 +84,28 @@ module Meshtastic
|
|
84
84
|
raw_packet = packet_bytes.to_s.b
|
85
85
|
raw_packet_len = raw_packet.to_s.b.length
|
86
86
|
raw_topic = packet_bytes.topic ||= ''
|
87
|
-
|
87
|
+
raw_message = packet_bytes.payload
|
88
88
|
|
89
89
|
begin
|
90
|
-
|
90
|
+
disp = false
|
91
|
+
message = {}
|
92
|
+
|
91
93
|
if json
|
92
|
-
|
94
|
+
message = JSON.parse(raw_message, symbolize_names: true)
|
93
95
|
else
|
94
|
-
svc_envl = Meshtastic::ServiceEnvelope.decode(
|
95
|
-
# map_report = Meshtastic::MapReport.decode(
|
96
|
-
|
96
|
+
svc_envl = Meshtastic::ServiceEnvelope.decode(raw_message)
|
97
|
+
# map_report = Meshtastic::MapReport.decode(raw_message)
|
98
|
+
message = svc_envl.to_h[:packet]
|
97
99
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
# If
|
104
|
-
if
|
105
|
-
packet_id =
|
106
|
-
packet_from =
|
100
|
+
message[:topic] = raw_topic
|
101
|
+
message[:node_id_from] = "!#{message[:from].to_i.to_s(16)}"
|
102
|
+
message[:node_id_to] = "!#{message[:to].to_i.to_s(16)}"
|
103
|
+
|
104
|
+
encrypted_message = message[:encrypted]
|
105
|
+
# If encrypted_message is not nil, then decrypt the message
|
106
|
+
if encrypted_message.to_s.length.positive?
|
107
|
+
packet_id = message[:id]
|
108
|
+
packet_from = message[:from]
|
107
109
|
nonce_packet_id = [packet_id].pack('V').ljust(8, "\x00")
|
108
110
|
nonce_from_node = [packet_from].pack('V').ljust(8, "\x00")
|
109
111
|
nonce = "#{nonce_packet_id}#{nonce_from_node}".b
|
@@ -115,41 +117,33 @@ module Meshtastic
|
|
115
117
|
cipher.key = dec_psk
|
116
118
|
cipher.iv = nonce
|
117
119
|
|
118
|
-
decrypted = cipher.update(
|
119
|
-
|
120
|
+
decrypted = cipher.update(encrypted_message) + cipher.final
|
121
|
+
message[:decrypted] = decrypted
|
120
122
|
end
|
121
123
|
|
122
|
-
filter_arr = [
|
123
|
-
|
124
|
-
flat_payload = payload.values.join(' ')
|
124
|
+
filter_arr = [message[:id].to_s] if filter.nil?
|
125
|
+
flat_message = message.values.join(' ')
|
125
126
|
|
126
|
-
disp = true if filter_arr.first ==
|
127
|
-
filter_arr.all? { |filter|
|
127
|
+
disp = true if filter_arr.first == message[:id] ||
|
128
|
+
filter_arr.all? { |filter| flat_message.include?(filter) }
|
128
129
|
|
130
|
+
rescue Google::Protobuf::ParseError
|
131
|
+
next
|
132
|
+
ensure
|
129
133
|
if disp
|
130
134
|
puts "\n"
|
131
135
|
puts '-' * 80
|
132
136
|
puts "*** DEBUGGING ***"
|
133
|
-
puts "
|
137
|
+
puts "MSG:\n#{message.inspect}"
|
134
138
|
# puts "\nMap Report: #{map_report.inspect}"
|
135
139
|
puts "\nRaw Packet: #{raw_packet.inspect}"
|
136
140
|
puts "Length: #{raw_packet_len}"
|
137
141
|
puts '-' * 80
|
138
142
|
puts "\n\n\n"
|
143
|
+
yield message if block_given?
|
139
144
|
else
|
140
145
|
print '.'
|
141
146
|
end
|
142
|
-
rescue Google::Protobuf::ParseError
|
143
|
-
puts "\n"
|
144
|
-
puts '-' * 80
|
145
|
-
puts "*** DEBUGGING ***"
|
146
|
-
puts "Payload:\n#{payload}"
|
147
|
-
# puts "\nMap Report: #{map_report.inspect}"
|
148
|
-
puts "\nRaw Packet: #{raw_packet.inspect}"
|
149
|
-
puts "Length: #{raw_packet_len}"
|
150
|
-
puts '-' * 80
|
151
|
-
puts "\n\n\n"
|
152
|
-
next
|
153
147
|
end
|
154
148
|
end
|
155
149
|
rescue Interrupt
|
@@ -217,7 +211,7 @@ module Meshtastic
|
|
217
211
|
psk: 'optional - channel pre-shared key (default: AQ==)',
|
218
212
|
qos: 'optional - quality of service (default: 0)',
|
219
213
|
json: 'optional - JSON output (default: false)',
|
220
|
-
filter: 'optional - comma-delimited string(s) to filter on in
|
214
|
+
filter: 'optional - comma-delimited string(s) to filter on in message (default: nil)'
|
221
215
|
)
|
222
216
|
|
223
217
|
#{self}.gps_search(
|
data/lib/meshtastic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meshtastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.63.
|
131
|
+
version: 1.63.4
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.63.
|
138
|
+
version: 1.63.4
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubocop-rake
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|