meshtastic 0.0.178 → 0.0.179

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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -175
  3. data/documentation/README.md +59 -0
  4. data/documentation/admin.md +54 -0
  5. data/documentation/apponly.md +22 -0
  6. data/documentation/atak.md +27 -0
  7. data/documentation/bluetooth-bluez.md +35 -0
  8. data/documentation/bluetooth.md +87 -0
  9. data/documentation/cannedmessages.md +25 -0
  10. data/documentation/channel.md +30 -0
  11. data/documentation/clientonly.md +21 -0
  12. data/documentation/config.md +29 -0
  13. data/documentation/connection-status.md +22 -0
  14. data/documentation/deviceonly.md +22 -0
  15. data/documentation/localonly.md +21 -0
  16. data/documentation/mesh-interface.md +52 -0
  17. data/documentation/meshtastic.md +45 -0
  18. data/documentation/module-config.md +26 -0
  19. data/documentation/mqtt.md +101 -0
  20. data/documentation/paxcount.md +25 -0
  21. data/documentation/portnums.md +67 -0
  22. data/documentation/position.md +34 -0
  23. data/documentation/protobufs.md +162 -0
  24. data/documentation/remote-hardware.md +33 -0
  25. data/documentation/rtttl.md +24 -0
  26. data/documentation/serial.md +78 -0
  27. data/documentation/storeforward.md +24 -0
  28. data/documentation/stream-interface.md +15 -0
  29. data/documentation/tcp.md +43 -0
  30. data/documentation/telemetry.md +32 -0
  31. data/documentation/traceroute.md +28 -0
  32. data/documentation/util.md +27 -0
  33. data/documentation/xmodem.md +22 -0
  34. data/lib/meshtastic/admin.rb +66 -8
  35. data/lib/meshtastic/apponly.rb +14 -8
  36. data/lib/meshtastic/atak.rb +21 -8
  37. data/lib/meshtastic/cannedmessages.rb +16 -8
  38. data/lib/meshtastic/channel.rb +13 -9
  39. data/lib/meshtastic/clientonly.rb +14 -8
  40. data/lib/meshtastic/config.rb +12 -9
  41. data/lib/meshtastic/connection_status.rb +7 -9
  42. data/lib/meshtastic/deviceonly.rb +11 -8
  43. data/lib/meshtastic/localonly.rb +11 -8
  44. data/lib/meshtastic/module_config.rb +12 -9
  45. data/lib/meshtastic/paxcount.rb +19 -9
  46. data/lib/meshtastic/portnums.rb +12 -9
  47. data/lib/meshtastic/position.rb +35 -0
  48. data/lib/meshtastic/remote_hardware.rb +34 -9
  49. data/lib/meshtastic/rtttl.rb +17 -8
  50. data/lib/meshtastic/storeforward.rb +16 -8
  51. data/lib/meshtastic/tcp.rb +102 -0
  52. data/lib/meshtastic/telemetry.rb +18 -9
  53. data/lib/meshtastic/traceroute.rb +33 -0
  54. data/lib/meshtastic/version.rb +1 -1
  55. data/lib/meshtastic/xmodem.rb +11 -9
  56. data/lib/meshtastic.rb +26 -5
  57. data/spec/lib/meshtastic/admin_pb_spec.rb +1 -1
  58. data/spec/lib/meshtastic/admin_spec.rb +39 -0
  59. data/spec/lib/meshtastic/apponly_pb_spec.rb +1 -1
  60. data/spec/lib/meshtastic/apponly_spec.rb +4 -0
  61. data/spec/lib/meshtastic/atak_pb_spec.rb +1 -1
  62. data/spec/lib/meshtastic/atak_spec.rb +22 -0
  63. data/spec/lib/meshtastic/cannedmessages_pb_spec.rb +1 -1
  64. data/spec/lib/meshtastic/cannedmessages_spec.rb +3 -0
  65. data/spec/lib/meshtastic/channel_pb_spec.rb +1 -1
  66. data/spec/lib/meshtastic/channel_spec.rb +21 -0
  67. data/spec/lib/meshtastic/clientonly_pb_spec.rb +1 -1
  68. data/spec/lib/meshtastic/clientonly_spec.rb +5 -0
  69. data/spec/lib/meshtastic/config_pb_spec.rb +1 -1
  70. data/spec/lib/meshtastic/config_spec.rb +22 -1
  71. data/spec/lib/meshtastic/connection_status_pb_spec.rb +1 -1
  72. data/spec/lib/meshtastic/connection_status_spec.rb +3 -0
  73. data/spec/lib/meshtastic/deviceonly_legacy_pb_spec.rb +1 -1
  74. data/spec/lib/meshtastic/deviceonly_pb_spec.rb +1 -1
  75. data/spec/lib/meshtastic/deviceonly_spec.rb +3 -0
  76. data/spec/lib/meshtastic/localonly_pb_spec.rb +1 -1
  77. data/spec/lib/meshtastic/localonly_spec.rb +3 -0
  78. data/spec/lib/meshtastic/mesh_beacon_pb_spec.rb +1 -1
  79. data/spec/lib/meshtastic/mesh_pb_spec.rb +1 -1
  80. data/spec/lib/meshtastic/module_config_pb_spec.rb +1 -1
  81. data/spec/lib/meshtastic/module_config_spec.rb +21 -0
  82. data/spec/lib/meshtastic/mqtt_pb_spec.rb +1 -1
  83. data/spec/lib/meshtastic/paxcount_pb_spec.rb +1 -1
  84. data/spec/lib/meshtastic/paxcount_spec.rb +23 -0
  85. data/spec/lib/meshtastic/portnums_pb_spec.rb +1 -1
  86. data/spec/lib/meshtastic/portnums_spec.rb +4 -0
  87. data/spec/lib/meshtastic/position_spec.rb +33 -0
  88. data/spec/lib/meshtastic/remote_hardware_pb_spec.rb +1 -1
  89. data/spec/lib/meshtastic/remote_hardware_spec.rb +24 -0
  90. data/spec/lib/meshtastic/rtttl_pb_spec.rb +1 -1
  91. data/spec/lib/meshtastic/rtttl_spec.rb +21 -0
  92. data/spec/lib/meshtastic/storeforward_pb_spec.rb +1 -1
  93. data/spec/lib/meshtastic/storeforward_spec.rb +21 -0
  94. data/spec/lib/meshtastic/tcp_spec.rb +48 -0
  95. data/spec/lib/meshtastic/telemetry_pb_spec.rb +1 -1
  96. data/spec/lib/meshtastic/telemetry_spec.rb +21 -0
  97. data/spec/lib/meshtastic/traceroute_spec.rb +27 -0
  98. data/spec/lib/meshtastic/xmodem_pb_spec.rb +1 -1
  99. data/spec/lib/meshtastic/xmodem_spec.rb +6 -1
  100. data/spec/lib/meshtastic_spec.rb +3 -0
  101. metadata +38 -1
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::ClientonlyPB do
5
+ describe Meshtastic::Config do
6
6
  end
@@ -2,5 +2,26 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::Clientonly do
5
+ describe Meshtastic::Config 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'requests LoRa config via Admin' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.get(serial_obj: serial_obj, config_type: :LORA_CONFIG)
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ admin = Meshtastic::AdminMessage.decode(packet.decoded.payload)
25
+ expect(admin.get_config_request).to eq(:LORA_CONFIG)
26
+ end
6
27
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::ConnectionStatusPB do
5
+ describe Meshtastic::DeviceConnectionStatus do
6
6
  end
@@ -3,4 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::ConnectionStatus do
6
+ it 'decodes DeviceConnectionStatus bytes' do
7
+ expect(described_class.decode(Meshtastic::DeviceConnectionStatus.new.to_proto)).to be_a(Meshtastic::DeviceConnectionStatus)
8
+ end
6
9
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::DeviceonlyLegacyPB do
5
+ describe Meshtastic::NodeDatabase_Legacy do
6
6
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::DeviceonlyPB do
5
+ describe Meshtastic::DeviceState do
6
6
  end
@@ -3,4 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::Deviceonly do
6
+ it 'decodes an empty DeviceState' do
7
+ expect(described_class.decode_state(Meshtastic::DeviceState.new.to_proto)).to be_a(Meshtastic::DeviceState)
8
+ end
6
9
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::LocalonlyPB do
5
+ describe Meshtastic::LocalConfig do
6
6
  end
@@ -3,4 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::Localonly do
6
+ it 'decodes an empty LocalConfig' do
7
+ expect(described_class.decode_config(Meshtastic::LocalConfig.new.to_proto)).to be_a(Meshtastic::LocalConfig)
8
+ end
6
9
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::MeshBeaconPB do
5
+ describe Meshtastic::MeshBeacon do
6
6
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::MeshPB do
5
+ describe Meshtastic::MeshPacket do
6
6
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::ModuleConfigPB do
5
+ describe Meshtastic::ModuleConfig do
6
6
  end
@@ -3,4 +3,25 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::ModuleConfig 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'requests MQTT module config via Admin' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.get(serial_obj: serial_obj, module_config_type: :MQTT_CONFIG)
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ admin = Meshtastic::AdminMessage.decode(packet.decoded.payload)
25
+ expect(admin.get_module_config_request).to eq(:MQTT_CONFIG)
26
+ end
6
27
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::MQTTPB do
5
+ describe Meshtastic::ServiceEnvelope do
6
6
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::PaxcountPB do
5
+ describe Meshtastic::Paxcount do
6
6
  end
@@ -3,4 +3,27 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::Paxcount 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'transmits PAXCOUNTER_APP counts' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.transmit(serial_obj: serial_obj, wifi: 3, ble: 2)
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ expect(packet.decoded.portnum).to eq(:PAXCOUNTER_APP)
25
+ count = Meshtastic::Paxcount.decode(packet.decoded.payload)
26
+ expect(count.wifi).to eq(3)
27
+ expect(count.ble).to eq(2)
28
+ end
6
29
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::PortnumsPB do
5
+ describe Meshtastic::PortNum do
6
6
  end
@@ -3,4 +3,8 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::Portnums do
6
+ it 'resolves names and numbers' do
7
+ expect(described_class.lookup(:TEXT_MESSAGE_APP)).to eq(1)
8
+ expect(described_class.lookup(1)).to eq(:TEXT_MESSAGE_APP)
9
+ end
6
10
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Meshtastic::Position 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'sends a POSITION_APP packet with scaled lat/lon' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.transmit(serial_obj: serial_obj, lat: 37.7749, lon: -122.4194)
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ expect(packet.decoded.portnum).to eq(:POSITION_APP)
25
+ position = Meshtastic::Position.decode(packet.decoded.payload)
26
+ expect(position.latitude_i).to eq(377_749_000)
27
+ expect(position.longitude_i).to eq(-1_224_194_000)
28
+ end
29
+
30
+ it 'prints usage without raising' do
31
+ expect { described_class.help }.to output(/USAGE/).to_stdout
32
+ end
33
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::RemoteHardwarePB do
5
+ describe Meshtastic::HardwareMessage do
6
6
  end
@@ -3,4 +3,28 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::RemoteHardware 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'writes GPIO bits on REMOTE_HARDWARE_APP' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.write_gpios(serial_obj: serial_obj, gpio_mask: 0x01, gpio_value: 0x01)
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ expect(packet.decoded.portnum).to eq(:REMOTE_HARDWARE_APP)
25
+ hw = Meshtastic::HardwareMessage.decode(packet.decoded.payload)
26
+ expect(hw.type).to eq(:WRITE_GPIOS)
27
+ expect(hw.gpio_mask).to eq(1)
28
+ expect(hw.gpio_value).to eq(1)
29
+ end
6
30
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::RTTTLPB do
5
+ describe Meshtastic::RTTTLConfig do
6
6
  end
@@ -3,4 +3,25 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::RTTTL 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'sets a ringtone via Admin' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.set(serial_obj: serial_obj, ringtone: 'beep:d=4,o=5,b=120:16c6')
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ admin = Meshtastic::AdminMessage.decode(packet.decoded.payload)
25
+ expect(admin.set_ringtone_message).to eq('beep:d=4,o=5,b=120:16c6')
26
+ end
6
27
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::StoreforwardPB do
5
+ describe Meshtastic::StoreAndForward do
6
6
  end
@@ -3,4 +3,25 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::Storeforward 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'sends STORE_FORWARD_APP history request' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.send(serial_obj: serial_obj, rr: :CLIENT_HISTORY)
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ expect(packet.decoded.portnum).to eq(:STORE_FORWARD_APP)
25
+ expect(Meshtastic::StoreAndForward.decode(packet.decoded.payload).rr).to eq(:CLIENT_HISTORY)
26
+ end
6
27
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'socket'
5
+
6
+ describe Meshtastic::TCP do
7
+ def with_tcp_link(opts = {})
8
+ local, remote = UNIXSocket.pair
9
+ tcp_obj = described_class.connect({ socket: local, host: '127.0.0.1', port: 4403, want_config: false }.merge(opts))
10
+ begin
11
+ yield tcp_obj, remote
12
+ ensure
13
+ described_class.disconnect(tcp_obj: tcp_obj)
14
+ remote.close unless remote.closed?
15
+ end
16
+ end
17
+
18
+ def radio_frame(message)
19
+ body = message.to_proto
20
+ [Meshtastic::START1, Meshtastic::START2, body.bytesize].pack('CCn') + body
21
+ end
22
+
23
+ it 'writes a decoded ToRadio mesh packet over TCP without MQTT encryption' do
24
+ with_tcp_link do |tcp_obj, remote|
25
+ described_class.send_text(tcp_obj: tcp_obj, text: 'ping', to: '!ffffffff', channel: 0)
26
+ expect(remote.read(32)).to eq(([Meshtastic::START2] * 32).pack('C*'))
27
+ header = remote.read(4)
28
+ packet = Meshtastic::ToRadio.decode(remote.read(header.unpack('CCn').last)).packet
29
+ expect(packet.decoded.payload).to eq('ping')
30
+ expect(packet.encrypted.to_s).to eq('')
31
+ end
32
+ end
33
+
34
+ it 'receives a framed FromRadio over TCP' do
35
+ with_tcp_link do |tcp_obj, remote|
36
+ remote.read(32)
37
+ message = Meshtastic::FromRadio.new(packet: Meshtastic::MeshPacket.new(
38
+ from: 123, decoded: Meshtastic::Data.new(portnum: :TEXT_MESSAGE_APP, payload: 'hello')
39
+ ))
40
+ remote.write(radio_frame(message))
41
+ expect(described_class.recv_from_radio(tcp_obj: tcp_obj, timeout: 1)).to eq(message)
42
+ end
43
+ end
44
+
45
+ it 'prints usage without raising' do
46
+ expect { described_class.help }.to output(/USAGE/).to_stdout
47
+ end
48
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::TelemetryPB do
5
+ describe Meshtastic::Telemetry do
6
6
  end
@@ -3,4 +3,25 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic::Telemetry 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'requests TELEMETRY_APP with want_response' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.request(serial_obj: serial_obj, to: '!aabbccdd')
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ expect(packet.decoded.portnum).to eq(:TELEMETRY_APP)
25
+ expect(packet.decoded.want_response).to be true
26
+ end
6
27
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Meshtastic::Traceroute 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: serial_conn, written: written, my_node_num: 0xb0b }
17
+ end
18
+
19
+ it 'sends an empty RouteDiscovery on TRACEROUTE_APP' do
20
+ serial_obj = fake_serial_obj
21
+ described_class.send(serial_obj: serial_obj, to: '!aabbccdd')
22
+ frame = serial_obj[:written]
23
+ packet = Meshtastic::ToRadio.decode(frame.byteslice(4, (frame.getbyte(2) << 8) + frame.getbyte(3))).packet
24
+ expect(packet.decoded.portnum).to eq(:TRACEROUTE_APP)
25
+ expect(Meshtastic::RouteDiscovery.decode(packet.decoded.payload)).to be_a(Meshtastic::RouteDiscovery)
26
+ end
27
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::XModemPB do
5
+ describe Meshtastic::XModem do
6
6
  end
@@ -2,5 +2,10 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::XModem do
5
+ describe Meshtastic::Xmodem do
6
+ it 'encodes an XModem SOH packet' do
7
+ packet = described_class.encode(control: :SOH, seq: 1, buffer: 'A')
8
+ expect(packet.control).to eq(:SOH)
9
+ expect(packet.seq).to eq(1)
10
+ end
6
11
  end
@@ -3,4 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Meshtastic do
6
+ it 'requires a transport for deliver_data' do
7
+ expect { described_class.deliver_data(data: Meshtastic::Data.new) }.to raise_error(ArgumentError, /serial_obj/)
8
+ end
6
9
  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.178
4
+ version: 0.0.179
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
@@ -284,6 +284,37 @@ files:
284
284
  - Rakefile
285
285
  - bin/meshtastic_autoinc_version
286
286
  - build_gem.sh
287
+ - documentation/README.md
288
+ - documentation/admin.md
289
+ - documentation/apponly.md
290
+ - documentation/atak.md
291
+ - documentation/bluetooth-bluez.md
292
+ - documentation/bluetooth.md
293
+ - documentation/cannedmessages.md
294
+ - documentation/channel.md
295
+ - documentation/clientonly.md
296
+ - documentation/config.md
297
+ - documentation/connection-status.md
298
+ - documentation/deviceonly.md
299
+ - documentation/localonly.md
300
+ - documentation/mesh-interface.md
301
+ - documentation/meshtastic.md
302
+ - documentation/module-config.md
303
+ - documentation/mqtt.md
304
+ - documentation/paxcount.md
305
+ - documentation/portnums.md
306
+ - documentation/position.md
307
+ - documentation/protobufs.md
308
+ - documentation/remote-hardware.md
309
+ - documentation/rtttl.md
310
+ - documentation/serial.md
311
+ - documentation/storeforward.md
312
+ - documentation/stream-interface.md
313
+ - documentation/tcp.md
314
+ - documentation/telemetry.md
315
+ - documentation/traceroute.md
316
+ - documentation/util.md
317
+ - documentation/xmodem.md
287
318
  - git_commit.sh
288
319
  - lib/meshtastic.rb
289
320
  - lib/meshtastic/admin.rb
@@ -323,6 +354,7 @@ files:
323
354
  - lib/meshtastic/paxcount_pb.rb
324
355
  - lib/meshtastic/portnums.rb
325
356
  - lib/meshtastic/portnums_pb.rb
357
+ - lib/meshtastic/position.rb
326
358
  - lib/meshtastic/powermon_pb.rb
327
359
  - lib/meshtastic/remote_hardware.rb
328
360
  - lib/meshtastic/remote_hardware_pb.rb
@@ -333,8 +365,10 @@ files:
333
365
  - lib/meshtastic/storeforward.rb
334
366
  - lib/meshtastic/storeforward_pb.rb
335
367
  - lib/meshtastic/stream_interface.rb
368
+ - lib/meshtastic/tcp.rb
336
369
  - lib/meshtastic/telemetry.rb
337
370
  - lib/meshtastic/telemetry_pb.rb
371
+ - lib/meshtastic/traceroute.rb
338
372
  - lib/meshtastic/util.rb
339
373
  - lib/meshtastic/version.rb
340
374
  - lib/meshtastic/xmodem.rb
@@ -380,6 +414,7 @@ files:
380
414
  - spec/lib/meshtastic/paxcount_spec.rb
381
415
  - spec/lib/meshtastic/portnums_pb_spec.rb
382
416
  - spec/lib/meshtastic/portnums_spec.rb
417
+ - spec/lib/meshtastic/position_spec.rb
383
418
  - spec/lib/meshtastic/powermon_pb_spec.rb
384
419
  - spec/lib/meshtastic/remote_hardware_pb_spec.rb
385
420
  - spec/lib/meshtastic/remote_hardware_spec.rb
@@ -390,8 +425,10 @@ files:
390
425
  - spec/lib/meshtastic/storeforward_pb_spec.rb
391
426
  - spec/lib/meshtastic/storeforward_spec.rb
392
427
  - spec/lib/meshtastic/stream_interface_spec.rb
428
+ - spec/lib/meshtastic/tcp_spec.rb
393
429
  - spec/lib/meshtastic/telemetry_pb_spec.rb
394
430
  - spec/lib/meshtastic/telemetry_spec.rb
431
+ - spec/lib/meshtastic/traceroute_spec.rb
395
432
  - spec/lib/meshtastic/util_spec.rb
396
433
  - spec/lib/meshtastic/version_spec.rb
397
434
  - spec/lib/meshtastic/xmodem_pb_spec.rb