meshtastic 0.0.119 → 0.0.120
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/mqtt.rb +1 -1
- data/lib/meshtastic/stream_interface.rb +92 -0
- data/lib/meshtastic/version.rb +1 -1
- data/lib/meshtastic.rb +1 -0
- data/spec/lib/meshtastic/stream_interface_spec.rb +6 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f33af1590a9b5568820e0d0c8cfc94ec2a649ceb58b23a28de9bb95ffc27d4f
|
4
|
+
data.tar.gz: '08d5ba9b1189304d9f3944f8b773f77858c72c40106f29daa6c04d34e17ae17c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7076e6d5e2ac9600dc3616455f8048e9d908e48bef63f36caa5be563f7be52150db282e90587d7e8c8ca9212f4765d332c0bfef147c47f7d7697f27f710458c
|
7
|
+
data.tar.gz: b35d74b95b10e56c65542efa76a5a36efc591da98268075537c612dcc03da95770a8765f66addbe5d34c8d770fc5e14ab198519d0b719e0b41f7362a9e044044
|
data/lib/meshtastic/mqtt.rb
CHANGED
@@ -268,7 +268,7 @@ module Meshtastic
|
|
268
268
|
opts[:via] = :mqtt
|
269
269
|
|
270
270
|
# TODO: Implement chunked message to deal with large messages
|
271
|
-
mui = Meshtastic::
|
271
|
+
mui = Meshtastic::MeshInterface.new
|
272
272
|
protobuf_text = mui.send_text(opts)
|
273
273
|
|
274
274
|
mqtt_obj.publish(topic, protobuf_text)
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'meshtastic/mesh_pb'
|
4
|
+
|
5
|
+
# Plugin used to interact with Meshtastic nodes
|
6
|
+
module Meshtastic
|
7
|
+
class StreamInterface
|
8
|
+
attr_accessor :cur_log_line,
|
9
|
+
:is_windows11,
|
10
|
+
:rx_buf,
|
11
|
+
:stream,
|
12
|
+
:want_exit
|
13
|
+
|
14
|
+
def initialize(opts = {})
|
15
|
+
debug_out = opts[:debug_out]
|
16
|
+
no_proto = false if opts[:no_proto].nil?
|
17
|
+
no_proto = true if opts[:no_proto]
|
18
|
+
|
19
|
+
connect_now = true if opts[:connect_now].nil?
|
20
|
+
connect_now = false if opts[:connect_now]
|
21
|
+
|
22
|
+
no_nodes = false if opts[:no_nodes].nil?
|
23
|
+
no_nodes = true if opts[:no_nodes]
|
24
|
+
# Note: In Ruby, we don't need to explicitly define a type hint for self.
|
25
|
+
raise Exception("StreamInterface is now abstract (to update existing code create SerialInterface instead)") if !defined?(@stream) && !no_proto
|
26
|
+
|
27
|
+
@stream = nil
|
28
|
+
@rx_buf = []
|
29
|
+
@want_exit = false
|
30
|
+
@is_windows11 = RUBY_PLATFORM =~ /win32/
|
31
|
+
@cur_log_line = ""
|
32
|
+
|
33
|
+
# Note: Ruby's threading API is different from Python. We use the Thread class instead of threading.Thread.
|
34
|
+
rx_thread = Thread.new do
|
35
|
+
reader
|
36
|
+
end
|
37
|
+
|
38
|
+
if connect_now
|
39
|
+
connect
|
40
|
+
unless no_proto
|
41
|
+
wait_for_config
|
42
|
+
end
|
43
|
+
end
|
44
|
+
rescue StandardError => e
|
45
|
+
raise e
|
46
|
+
end
|
47
|
+
|
48
|
+
# Supported Method Parameters::
|
49
|
+
# packet_id = Meshtastic.generate_packet_id(
|
50
|
+
# last_packet_id: 'optional - Last Packet ID (Default: 0)'
|
51
|
+
# )
|
52
|
+
def connect(opts = {})
|
53
|
+
# Send some bogus UART characters to force a sleeping device to wake, and
|
54
|
+
# if the reading statemachine was parsing a bad packet make sure we write enough start bytes to force it to resync (we don't use START1 because we want to ensure it is looking for START1)
|
55
|
+
p = [START2] * 32
|
56
|
+
self._write_bytes(p)
|
57
|
+
|
58
|
+
sleep(0.1) # wait 100ms to give device time to start running
|
59
|
+
|
60
|
+
@rx_thread.start
|
61
|
+
mui = Meshtastic::MeshInfoUser.new
|
62
|
+
mui.start_config
|
63
|
+
rescue StandardError => e
|
64
|
+
raise e
|
65
|
+
end
|
66
|
+
|
67
|
+
# Supported Method Parameters::
|
68
|
+
# Meshtastic::StreamInterface.reader
|
69
|
+
def reader
|
70
|
+
rescue StandardError => e
|
71
|
+
raise e
|
72
|
+
end
|
73
|
+
|
74
|
+
# Author(s):: 0day Inc. <support@0dayinc.com>
|
75
|
+
|
76
|
+
def authors
|
77
|
+
"AUTHOR(S):
|
78
|
+
0day Inc. <support@0dayinc.com>
|
79
|
+
"
|
80
|
+
end
|
81
|
+
|
82
|
+
# Display Usage for this Module
|
83
|
+
|
84
|
+
def help
|
85
|
+
puts "USAGE:
|
86
|
+
#{self}.connect
|
87
|
+
|
88
|
+
#{self}.authors
|
89
|
+
"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/meshtastic/version.rb
CHANGED
data/lib/meshtastic.rb
CHANGED
@@ -47,6 +47,7 @@ module Meshtastic
|
|
47
47
|
autoload :RTTTL, 'meshtastic/rtttl'
|
48
48
|
autoload :Serial, 'meshtastic/serial'
|
49
49
|
autoload :Storeforward, 'meshtastic/storeforward'
|
50
|
+
autoload :StreamInterface, 'meshtastic/stream_interface'
|
50
51
|
autoload :Telemetry, 'meshtastic/telemetry'
|
51
52
|
autoload :Util, 'meshtastic/util'
|
52
53
|
autoload :Xmodem, 'meshtastic/xmodem'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
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.120
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-17 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bundler
|
@@ -270,6 +270,7 @@ files:
|
|
270
270
|
- lib/meshtastic/serial.rb
|
271
271
|
- lib/meshtastic/storeforward.rb
|
272
272
|
- lib/meshtastic/storeforward_pb.rb
|
273
|
+
- lib/meshtastic/stream_interface.rb
|
273
274
|
- lib/meshtastic/telemetry.rb
|
274
275
|
- lib/meshtastic/telemetry_pb.rb
|
275
276
|
- lib/meshtastic/util.rb
|
@@ -319,6 +320,7 @@ files:
|
|
319
320
|
- spec/lib/meshtastic/serial_spec.rb
|
320
321
|
- spec/lib/meshtastic/storeforward_pb_spec.rb
|
321
322
|
- spec/lib/meshtastic/storeforward_spec.rb
|
323
|
+
- spec/lib/meshtastic/stream_interface_spec.rb
|
322
324
|
- spec/lib/meshtastic/telemetry_pb_spec.rb
|
323
325
|
- spec/lib/meshtastic/telemetry_spec.rb
|
324
326
|
- spec/lib/meshtastic/util_spec.rb
|