meshtastic 0.0.169 → 0.0.172
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 +2 -2
- data/README.md +115 -5
- data/lib/meshtastic/config_pb.rb +1 -1
- data/lib/meshtastic/interdevice_pb.rb +12 -3
- data/lib/meshtastic/mesh_interface.rb +30 -11
- data/lib/meshtastic/serial_interface.rb +496 -279
- data/lib/meshtastic/version.rb +1 -1
- data/spec/lib/meshtastic/serial_interface_spec.rb +72 -0
- metadata +6 -6
data/lib/meshtastic/version.rb
CHANGED
|
@@ -3,4 +3,76 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
describe Meshtastic::SerialInterface do
|
|
6
|
+
def fake_serial_obj
|
|
7
|
+
written = +''.b
|
|
8
|
+
serial_conn = Object.new
|
|
9
|
+
serial_conn.define_singleton_method(:write) do |b|
|
|
10
|
+
written << b
|
|
11
|
+
b.bytesize
|
|
12
|
+
end
|
|
13
|
+
serial_conn.define_singleton_method(:flush) { true }
|
|
14
|
+
serial_conn.define_singleton_method(:closed?) { false }
|
|
15
|
+
serial_conn.define_singleton_method(:close) { true }
|
|
16
|
+
serial_conn.define_singleton_method(:written) { written }
|
|
17
|
+
{ serial_conn: serial_conn, written: written, my_node_num: 0xb0b }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '.send_to_radio' do
|
|
21
|
+
it 'frames a ToRadio with START1/START2 and big-endian length' do
|
|
22
|
+
serial_obj = fake_serial_obj
|
|
23
|
+
to_radio = Meshtastic::ToRadio.new
|
|
24
|
+
to_radio.want_config_id = 42
|
|
25
|
+
body = to_radio.to_proto
|
|
26
|
+
|
|
27
|
+
described_class.send_to_radio(serial_obj: serial_obj, to_radio: to_radio)
|
|
28
|
+
frame = serial_obj[:serial_conn].written
|
|
29
|
+
|
|
30
|
+
expect(frame.getbyte(0)).to eq(Meshtastic::START1)
|
|
31
|
+
expect(frame.getbyte(1)).to eq(Meshtastic::START2)
|
|
32
|
+
expect((frame.getbyte(2) << 8) + frame.getbyte(3)).to eq(body.bytesize)
|
|
33
|
+
expect(frame.byteslice(4, body.bytesize)).to eq(body)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'accepts a pre-serialized String body' do
|
|
37
|
+
serial_obj = fake_serial_obj
|
|
38
|
+
body = Meshtastic::ToRadio.new.tap { |t| t.want_config_id = 7 }.to_proto
|
|
39
|
+
described_class.send_to_radio(serial_obj: serial_obj, to_radio: body)
|
|
40
|
+
frame = serial_obj[:serial_conn].written
|
|
41
|
+
expect(frame.bytesize).to eq(4 + body.bytesize)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '.send_text' do
|
|
46
|
+
it 'writes a decoded ToRadio mesh packet for the radio to encrypt' do
|
|
47
|
+
serial_obj = fake_serial_obj
|
|
48
|
+
described_class.send_text(
|
|
49
|
+
serial_obj: serial_obj,
|
|
50
|
+
text: 'ping',
|
|
51
|
+
to: '!ffffffff',
|
|
52
|
+
channel: 0
|
|
53
|
+
)
|
|
54
|
+
frame = serial_obj[:serial_conn].written
|
|
55
|
+
body_len = (frame.getbyte(2) << 8) + frame.getbyte(3)
|
|
56
|
+
tr = Meshtastic::ToRadio.decode(frame.byteslice(4, body_len))
|
|
57
|
+
|
|
58
|
+
expect(tr.packet).not_to be_nil
|
|
59
|
+
expect(tr.packet.decoded).not_to be_nil
|
|
60
|
+
expect(tr.packet.decoded.payload).to eq('ping')
|
|
61
|
+
expect(tr.packet.encrypted.to_s).to eq('')
|
|
62
|
+
expect(tr.packet.from).to eq(0xb0b)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe '.disconnect' do
|
|
67
|
+
it 'returns nil and closes the serial connection' do
|
|
68
|
+
serial_obj = fake_serial_obj
|
|
69
|
+
expect(described_class.disconnect(serial_obj: serial_obj)).to be_nil
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe '.help' do
|
|
74
|
+
it 'prints usage without raising' do
|
|
75
|
+
expect { described_class.help }.to output(/USAGE/).to_stdout
|
|
76
|
+
end
|
|
77
|
+
end
|
|
6
78
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.172
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 0day Inc.
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 4.0.
|
|
18
|
+
version: 4.0.16
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 4.0.
|
|
25
|
+
version: 4.0.16
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: bundler-audit
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -239,14 +239,14 @@ dependencies:
|
|
|
239
239
|
requirements:
|
|
240
240
|
- - '='
|
|
241
241
|
- !ruby/object:Gem::Version
|
|
242
|
-
version: 0.9.
|
|
242
|
+
version: 0.9.45
|
|
243
243
|
type: :runtime
|
|
244
244
|
prerelease: false
|
|
245
245
|
version_requirements: !ruby/object:Gem::Requirement
|
|
246
246
|
requirements:
|
|
247
247
|
- - '='
|
|
248
248
|
- !ruby/object:Gem::Version
|
|
249
|
-
version: 0.9.
|
|
249
|
+
version: 0.9.45
|
|
250
250
|
description: https://github.com/0dayinc/meshtastic/README.md
|
|
251
251
|
email:
|
|
252
252
|
- support@0dayinc.com
|
|
@@ -402,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
402
402
|
- !ruby/object:Gem::Version
|
|
403
403
|
version: '0'
|
|
404
404
|
requirements: []
|
|
405
|
-
rubygems_version: 4.0.
|
|
405
|
+
rubygems_version: 4.0.16
|
|
406
406
|
specification_version: 4
|
|
407
407
|
summary: Ruby gem for Meshtastic
|
|
408
408
|
test_files: []
|