meshtastic 0.0.58 → 0.0.60

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a264d9893fbd8e3aa81eee241844cdf976374859a1e43c8bbca68e6b8e906781
4
- data.tar.gz: 77849c92d27e23c9aabc8ac69c4b56add82a6204207622c3383ab15cdef48c19
3
+ metadata.gz: eeece01e7acf9c7a1da3ce75b799d101ad6b4a543203e220c8d8ef67c66980ae
4
+ data.tar.gz: 0ca6e337660d31a51421aab3f1fcf62fda73f8e9178b4b1bcb165c3d5eebce3c
5
5
  SHA512:
6
- metadata.gz: a12dc68ece20d389402fe79492ec2ebcf109ac30eecc2d0d4e1ed228b2b3292a355bed10ddf0397f7589a41780765599e0a88fabc5944ccb4d979e14d87cbb1b
7
- data.tar.gz: 61f56c89bca4d7fee23336a1502b196b711f39190b31acc0667e672456ed5194fb20122bbdc323d22491dfec25d7e6d9c2315b63de4961e90871819d0c4cbad8
6
+ metadata.gz: 002f3c6cb87c0ae8174986a3b0b834c71e04b26d5ecc5553ea45a453b8ffb2e18fe0990819088153fdf72fae6638042696d8b4c95a3612c6070f15bf0b72dc9c
7
+ data.tar.gz: 6015c2daf7cccdd2fc1d2e109de4d1379ba13916b3d9431d14d279499fea56e7dd861b9867ca87d1e02879511be2fc915399cdeefcbd2461fe2022eba8b079b0
@@ -291,18 +291,21 @@ module Meshtastic
291
291
  message[:stdout] = 'pretty'
292
292
  stdout_message = JSON.pretty_generate(decoded_payload_hash)
293
293
  end
294
- rescue Google::Protobuf::ParseError,
294
+ rescue Encoding::CompatibilityError,
295
+ Google::Protobuf::ParseError,
295
296
  JSON::GeneratorError,
296
297
  ArgumentError => e
297
298
 
298
- message[:decrypted] = e.message if e.message.include?('key must be')
299
- message[:decrypted] = 'unable to decrypt - psk?' if e.message.include?('occurred during parsing')
300
- decoded_payload_hash[:packet] = message
301
- unless block_given?
302
- puts "WARNING: #{e.inspect} - MSG IS >>>"
303
- # puts e.backtrace
304
- message[:stdout] = 'inspect'
305
- stdout_message = decoded_payload_hash.inspect
299
+ unless e.is_a?(Encoding::CompatibilityError)
300
+ message[:decrypted] = e.message if e.message.include?('key must be')
301
+ message[:decrypted] = 'unable to decrypt - psk?' if e.message.include?('occurred during parsing')
302
+ decoded_payload_hash[:packet] = message
303
+ unless block_given?
304
+ puts "WARNING: #{e.inspect} - MSG IS >>>"
305
+ # puts e.backtrace
306
+ message[:stdout] = 'inspect'
307
+ stdout_message = decoded_payload_hash.inspect
308
+ end
306
309
  end
307
310
 
308
311
  next
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meshtastic
4
- VERSION = '0.0.58'
4
+ VERSION = '0.0.60'
5
5
  end
data/lib/meshtastic.rb CHANGED
@@ -53,6 +53,7 @@ module Meshtastic
53
53
  # Meshtastic.send_text(
54
54
  # from: 'required - From ID (String or Integer)',
55
55
  # to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
56
+ # last_packet_id: 'optional - Last Packet ID (Default: 0)',
56
57
  # via: 'optional - :radio || :mqtt (Default: :radio)',
57
58
  # channel: 'optional - Channel ID (Default: 0)',
58
59
  # text: 'optional - Text Message (Default: SYN)',
@@ -73,6 +74,7 @@ module Meshtastic
73
74
  to_hex = to.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if to.is_a?(String)
74
75
  to = to_hex.to_i(16) if to_hex
75
76
 
77
+ last_packet_id = opts[:last_packet_id] ||= 0
76
78
  via = opts[:via] ||= :radio
77
79
  channel = opts[:channel] ||= 0
78
80
  text = opts[:text] ||= 'SYN'
@@ -102,6 +104,7 @@ module Meshtastic
102
104
  send_data(
103
105
  from: from,
104
106
  to: to,
107
+ last_packet_id: last_packet_id,
105
108
  via: via,
106
109
  channel: channel,
107
110
  data: data,
@@ -120,6 +123,7 @@ module Meshtastic
120
123
  # Meshtastic.send_data(
121
124
  # from: 'required - From ID (String or Integer)',
122
125
  # to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
126
+ # last_packet_id: 'optional - Last Packet ID (Default: 0)',
123
127
  # via: 'optional - :radio || :mqtt (Default: :radio)',
124
128
  # channel: 'optional - Channel ID (Default: 0)',
125
129
  # data: 'required - Data to Send',
@@ -139,6 +143,7 @@ module Meshtastic
139
143
  to_hex = to.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if to.is_a?(String)
140
144
  to = to_hex.to_i(16) if to_hex
141
145
 
146
+ last_packet_id = opts[:last_packet_id] ||= 0
142
147
  via = opts[:via] ||= :radio
143
148
  channel = opts[:channel] ||= 0
144
149
  data = opts[:data]
@@ -165,6 +170,7 @@ module Meshtastic
165
170
  mesh_packet: mesh_packet,
166
171
  from: from,
167
172
  to: to,
173
+ last_packet_id: last_packet_id,
168
174
  via: via,
169
175
  channel: channel,
170
176
  want_ack: want_ack,
@@ -180,6 +186,7 @@ module Meshtastic
180
186
  # mesh_packet: 'required - Mesh Packet to Send',
181
187
  # from: 'required - From ID (String or Integer)',
182
188
  # to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
189
+ # last_packet_id: 'optional - Last Packet ID (Default: 0)',
183
190
  # via: 'optional - :radio || :mqtt (Default: :radio)',
184
191
  # channel: 'optional - Channel ID (Default: 0)',
185
192
  # want_ack: 'optional - Want Acknowledgement (Default: false)',
@@ -197,6 +204,7 @@ module Meshtastic
197
204
  to_hex = to.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if to.is_a?(String)
198
205
  to = to_hex.to_i(16) if to_hex
199
206
 
207
+ last_packet_id = opts[:last_packet_id] ||= 0
200
208
  via = opts[:via] ||= :radio
201
209
  channel = opts[:channel] ||= 0
202
210
  want_ack = opts[:want_ack] ||= false
@@ -216,15 +224,7 @@ module Meshtastic
216
224
  mesh_packet.channel = channel
217
225
  mesh_packet.want_ack = want_ack
218
226
  mesh_packet.hop_limit = hop_limit
219
-
220
- # TODO: Implement strategy for obtaining last packet id
221
- packet_id = 0
222
- if mesh_packet.id.zero?
223
- packet_id = generate_packet_id(
224
- last_packet_id: mesh_packet.id
225
- )
226
- end
227
- mesh_packet.id = packet_id
227
+ mesh_packet.id = generate_packet_id(last_packet_id: last_packet_id)
228
228
 
229
229
  if psks
230
230
  nonce_packet_id = [mesh_packet.id].pack('V').ljust(8, "\x00")
@@ -249,6 +249,9 @@ module Meshtastic
249
249
  # puts "Sending Packet via: #{via}"
250
250
  case via
251
251
  when :radio
252
+ # Sending a to_radio message over mqtt
253
+ # causes unpredictable behavior
254
+ # (e.g. disconnecting node(s) from bluetooth)
252
255
  to_radio = Meshtastic::ToRadio.new
253
256
  to_radio.packet = mesh_packet
254
257
  send_to_radio(to_radio: to_radio)
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.58
4
+ version: 0.0.60
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-05-10 00:00:00.000000000 Z
11
+ date: 2024-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler