meshtastic 0.0.57 → 0.0.59
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/version.rb +1 -1
- data/lib/meshtastic.rb +16 -11
- 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: 4bee0bc9cf63a72bf400763d93004424baa89bf5c6252a53d594cd472a09ee0a
|
4
|
+
data.tar.gz: 4bfa4ff0b53b434da3624a55d5dc26934b1edb641a5a6c32101dc5029cf6df58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5abc75249f2f677b1bfdc96f21a1a3ce76b5ab0b6ee38968f1f20cc436c45423702e5445fd89e2f6aa2a64ea8b1a6f5eddf71dca03e5808eddf33b87d19bed2e
|
7
|
+
data.tar.gz: 0610bbc1cd020aa4dcf01fae92430006eb3c2150c0b9971b3270ab1e67133bbcbd1488348ffce1260960270c61219a1a7c93365a61ebce3c4682ef41e545ccb6
|
data/lib/meshtastic/version.rb
CHANGED
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)
|
@@ -273,8 +276,10 @@ module Meshtastic
|
|
273
276
|
last_packet_id = opts[:last_packet_id] ||= 0
|
274
277
|
last_packet_id = 0 if last_packet_id.negative?
|
275
278
|
|
276
|
-
Random.rand(0xffffffff) if last_packet_id.zero?
|
277
|
-
(last_packet_id + 1) & 0xffffffff if last_packet_id.positive?
|
279
|
+
packet_id = Random.rand(0xffffffff) if last_packet_id.zero?
|
280
|
+
packet_id = (last_packet_id + 1) & 0xffffffff if last_packet_id.positive?
|
281
|
+
|
282
|
+
packet_id
|
278
283
|
end
|
279
284
|
|
280
285
|
# Supported Method Parameters::
|