meshtastic 0.0.120 → 0.0.121

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: 0f33af1590a9b5568820e0d0c8cfc94ec2a649ceb58b23a28de9bb95ffc27d4f
4
- data.tar.gz: '08d5ba9b1189304d9f3944f8b773f77858c72c40106f29daa6c04d34e17ae17c'
3
+ metadata.gz: 59a276ebe667397899dace2501542a43bd69484add6c2d3ea8b305ff2050b156
4
+ data.tar.gz: bac49dfeae853e2d4efae41e02668f1dc9c500044795bbc24ceb657cfffff1bd
5
5
  SHA512:
6
- metadata.gz: e7076e6d5e2ac9600dc3616455f8048e9d908e48bef63f36caa5be563f7be52150db282e90587d7e8c8ca9212f4765d332c0bfef147c47f7d7697f27f710458c
7
- data.tar.gz: b35d74b95b10e56c65542efa76a5a36efc591da98268075537c612dcc03da95770a8765f66addbe5d34c8d770fc5e14ab198519d0b719e0b41f7362a9e044044
6
+ metadata.gz: c27efa0eea1961ff43418279fb80d108256619dd46028554ae6382f11cdb4359fc8b4a22aae3ff41d2848385c39e8a2f74e1e7015d8fb372d2cbfe17c37953b1
7
+ data.tar.gz: d1b794462a3fb53b538a469e3d01050a3bb525e7496d32064aaf1314979b7a3105e6d6dfa8fcacb8760b55b277512428fa6095e01bca8521b01b3d2b9d427b2d
data/Gemfile CHANGED
@@ -6,17 +6,17 @@ source 'https://rubygems.org'
6
6
 
7
7
  gemspec
8
8
 
9
- gem 'bundler', '>=2.6.3'
9
+ gem 'bundler', '>=2.6.8'
10
10
  gem 'bundle-audit', '0.1.0'
11
11
  gem 'geocoder', '1.8.5'
12
12
  gem 'google-protobuf', '3.21.12'
13
13
  gem 'mqtt', '0.6.0'
14
14
  gem 'rake', '13.2.1'
15
- gem 'rdoc', '6.12.0'
15
+ gem 'rdoc', '6.13.1'
16
16
  gem 'rspec', '3.13.0'
17
- gem 'rubocop', '>=1.72.1'
17
+ gem 'rubocop', '>=1.75.2'
18
18
  gem 'rubocop-rake', '>=0.7.1'
19
- gem 'rubocop-rspec', '>=3.5.0'
19
+ gem 'rubocop-rspec', '>=3.6.0'
20
20
  gem 'rvm', '1.11.3.9'
21
21
  gem 'uart', '1.0.0'
22
22
  gem 'yard', '0.9.37'
@@ -37,6 +37,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
37
37
  optional :enter_dfu_mode_request, :bool, 21
38
38
  optional :delete_file_request, :string, 22
39
39
  optional :set_scale, :uint32, 23
40
+ optional :backup_preferences, :enum, 24, "meshtastic.AdminMessage.BackupLocation"
41
+ optional :restore_preferences, :enum, 25, "meshtastic.AdminMessage.BackupLocation"
42
+ optional :remove_backup_preferences, :enum, 26, "meshtastic.AdminMessage.BackupLocation"
40
43
  optional :set_owner, :message, 32, "meshtastic.User"
41
44
  optional :set_channel, :message, 33, "meshtastic.Channel"
42
45
  optional :set_config, :message, 34, "meshtastic.Config"
@@ -92,6 +95,10 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
92
95
  value :DETECTIONSENSOR_CONFIG, 11
93
96
  value :PAXCOUNTER_CONFIG, 12
94
97
  end
98
+ add_enum "meshtastic.AdminMessage.BackupLocation" do
99
+ value :FLASH, 0
100
+ value :SD, 1
101
+ end
95
102
  add_message "meshtastic.HamParameters" do
96
103
  optional :call_sign, :string, 1
97
104
  optional :tx_power, :int32, 2
@@ -108,6 +115,7 @@ module Meshtastic
108
115
  AdminMessage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.AdminMessage").msgclass
109
116
  AdminMessage::ConfigType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.AdminMessage.ConfigType").enummodule
110
117
  AdminMessage::ModuleConfigType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.AdminMessage.ModuleConfigType").enummodule
118
+ AdminMessage::BackupLocation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.AdminMessage.BackupLocation").enummodule
111
119
  HamParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.HamParameters").msgclass
112
120
  NodeRemoteHardwarePinsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeRemoteHardwarePinsResponse").msgclass
113
121
  end
@@ -156,6 +156,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
156
156
  value :OLED_SSD1306, 1
157
157
  value :OLED_SH1106, 2
158
158
  value :OLED_SH1107, 3
159
+ value :OLED_SH1107_128_64, 4
159
160
  end
160
161
  add_enum "meshtastic.Config.DisplayConfig.DisplayMode" do
161
162
  value :DEFAULT, 0
@@ -20,6 +20,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
20
20
  optional :node_filter, :message, 12, "meshtastic.NodeFilter"
21
21
  optional :node_highlight, :message, 13, "meshtastic.NodeHighlight"
22
22
  optional :calibration_data, :bytes, 14
23
+ optional :map_data, :message, 15, "meshtastic.Map"
23
24
  end
24
25
  add_message "meshtastic.NodeFilter" do
25
26
  optional :unknown_switch, :bool, 1
@@ -37,6 +38,16 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
37
38
  optional :iaq_switch, :bool, 4
38
39
  optional :node_name, :string, 5
39
40
  end
41
+ add_message "meshtastic.GeoPoint" do
42
+ optional :zoom, :int32, 1
43
+ optional :latitude, :int32, 2
44
+ optional :longitude, :int32, 3
45
+ end
46
+ add_message "meshtastic.Map" do
47
+ optional :home, :message, 1, "meshtastic.GeoPoint"
48
+ optional :style, :string, 2
49
+ optional :follow_gps, :bool, 3
50
+ end
40
51
  add_enum "meshtastic.Theme" do
41
52
  value :DARK, 0
42
53
  value :LIGHT, 1
@@ -59,6 +70,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
59
70
  value :GREEK, 13
60
71
  value :NORWEGIAN, 14
61
72
  value :SLOVENIAN, 15
73
+ value :UKRAINIAN, 16
62
74
  value :SIMPLIFIED_CHINESE, 30
63
75
  value :TRADITIONAL_CHINESE, 31
64
76
  end
@@ -69,6 +81,8 @@ module Meshtastic
69
81
  DeviceUIConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.DeviceUIConfig").msgclass
70
82
  NodeFilter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeFilter").msgclass
71
83
  NodeHighlight = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeHighlight").msgclass
84
+ GeoPoint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.GeoPoint").msgclass
85
+ Map = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Map").msgclass
72
86
  Theme = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Theme").enummodule
73
87
  Language = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Language").enummodule
74
88
  end
@@ -7,6 +7,7 @@ require 'meshtastic/channel_pb'
7
7
  require 'meshtastic/mesh_pb'
8
8
  require 'meshtastic/telemetry_pb'
9
9
  require 'meshtastic/config_pb'
10
+ require 'meshtastic/localonly_pb'
10
11
  require 'nanopb_pb'
11
12
 
12
13
  Google::Protobuf::DescriptorPool.generated_pool.build do
@@ -51,12 +52,23 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
51
52
  optional :did_gps_reset, :bool, 11
52
53
  optional :rx_waypoint, :message, 12, "meshtastic.MeshPacket"
53
54
  repeated :node_remote_hardware_pins, :message, 13, "meshtastic.NodeRemoteHardwarePin"
54
- repeated :node_db_lite, :message, 14, "meshtastic.NodeInfoLite"
55
+ end
56
+ add_message "meshtastic.NodeDatabase" do
57
+ optional :version, :uint32, 1
58
+ repeated :nodes, :message, 2, "meshtastic.NodeInfoLite"
55
59
  end
56
60
  add_message "meshtastic.ChannelFile" do
57
61
  repeated :channels, :message, 1, "meshtastic.Channel"
58
62
  optional :version, :uint32, 2
59
63
  end
64
+ add_message "meshtastic.BackupPreferences" do
65
+ optional :version, :uint32, 1
66
+ optional :timestamp, :fixed32, 2
67
+ optional :config, :message, 3, "meshtastic.LocalConfig"
68
+ optional :module_config, :message, 4, "meshtastic.LocalModuleConfig"
69
+ optional :channels, :message, 5, "meshtastic.ChannelFile"
70
+ optional :owner, :message, 6, "meshtastic.User"
71
+ end
60
72
  end
61
73
  end
62
74
 
@@ -65,5 +77,7 @@ module Meshtastic
65
77
  UserLite = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.UserLite").msgclass
66
78
  NodeInfoLite = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeInfoLite").msgclass
67
79
  DeviceState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.DeviceState").msgclass
80
+ NodeDatabase = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeDatabase").msgclass
68
81
  ChannelFile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ChannelFile").msgclass
82
+ BackupPreferences = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.BackupPreferences").msgclass
69
83
  end
@@ -386,6 +386,16 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
386
386
  value :ROUTASTIC, 85
387
387
  value :MESH_TAB, 86
388
388
  value :MESHLINK, 87
389
+ value :XIAO_NRF52_KIT, 88
390
+ value :THINKNODE_M1, 89
391
+ value :THINKNODE_M2, 90
392
+ value :T_ETH_ELITE, 91
393
+ value :HELTEC_SENSOR_HUB, 92
394
+ value :RESERVED_FRIED_CHICKEN, 93
395
+ value :HELTEC_MESH_POCKET, 94
396
+ value :SEEED_SOLAR_NODE, 95
397
+ value :NOMADSTAR_METEOR_PRO, 96
398
+ value :CROWPANEL, 97
389
399
  value :PRIVATE_HW, 255
390
400
  end
391
401
  add_enum "meshtastic.Constants" do
@@ -423,6 +433,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
423
433
  value :AMBIENTLIGHTING_CONFIG, 1024
424
434
  value :DETECTIONSENSOR_CONFIG, 2048
425
435
  value :PAXCOUNTER_CONFIG, 4096
436
+ value :BLUETOOTH_CONFIG, 8192
437
+ value :NETWORK_CONFIG, 16384
426
438
  end
427
439
  end
428
440
  end
@@ -32,6 +32,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
32
32
  value :ATAK_PLUGIN, 72
33
33
  value :MAP_REPORT_APP, 73
34
34
  value :POWERSTRESS_APP, 74
35
+ value :RETICULUM_TUNNEL_APP, 76
35
36
  value :PRIVATE_APP, 256
36
37
  value :ATAK_FORWARDER, 257
37
38
  value :MAX, 511
@@ -10,46 +10,21 @@ require 'uart'
10
10
 
11
11
  # Plugin used to interact with Meshtastic nodes
12
12
  module Meshtastic
13
- module Serial
13
+ module SerialInterface
14
14
  @console_data = []
15
15
  @proto_data = []
16
16
 
17
17
  # Supported Method Parameters::
18
- # console_thread = init_console_thread(
19
- # serial_conn: 'required - SerialPort.new object'
18
+ # proto_thread = init_stdout_thread(
19
+ # serial_conn: 'required - serial_conn object returned from UART.open method',
20
+ # type: 'required - :proto or :console'
20
21
  # )
21
22
 
22
- private_class_method def self.init_console_thread(opts = {})
23
- serial_conn = opts[:serial_conn]
24
-
25
- # Spin up a serial_obj console_thread
26
- Thread.new do
27
- # serial_conn.read_timeout = -1
28
- serial_conn.flush
29
-
30
- loop do
31
- serial_conn.wait_readable
32
- # Read raw chars into @console_data,
33
- # convert to readable bytes if need-be
34
- # later.
35
- @console_data << serial_conn.readchar.force_encoding('UTF-8')
36
- end
37
- end
38
- rescue StandardError => e
39
- console_thread&.terminate
40
- serial_conn&.close
41
- serial_conn = nil
42
-
43
- raise e
44
- end
45
-
46
- # Supported Method Parameters::
47
- # proto_thread = init_proto_thread(
48
- # serial_conn: 'required - SerialPort.new object'
49
- # )
50
-
51
- private_class_method def self.init_proto_thread(opts = {})
23
+ private_class_method def self.init_stdout_thread(opts = {})
52
24
  serial_conn = opts[:serial_conn]
25
+ type = opts[:type]
26
+ valid_types = %i[proto console]
27
+ raise "ERROR: Invalid type: #{type}. Supported types are :proto or :console" unless valid_types.include?(type)
53
28
 
54
29
  # Spin up a serial_obj console_thread
55
30
  Thread.new do
@@ -62,27 +37,24 @@ module Meshtastic
62
37
  # Read raw chars into @console_data,
63
38
  # convert to readable bytes if need-be
64
39
  # later.
65
- @proto_data << from_radio.to_h
40
+ @proto_data << from_radio.to_h if type == :proto
41
+ @console_data << serial_conn.readchar.force_encoding('UTF-8') if type == :console
66
42
  end
67
43
  end
68
44
  rescue StandardError => e
69
- proto_thread&.terminate
70
- serial_conn&.close
71
- serial_conn = nil
72
-
73
45
  raise e
74
46
  end
75
47
 
76
48
  # Supported Method Parameters::
77
- # Meshtastic::Serial.request(
49
+ # Meshtastic::SerialInterface.request(
78
50
  # serial_obj: 'required serial_obj returned from #connect method',
79
- # payload: 'required - array of bytes OR string to write to serial device (e.g. [0x00, 0x41, 0x90, 0x00] OR "ATDT+15555555\r\n"'
51
+ # payload: 'required - array of bytes OR string to write to serial device (e.g. [0x00, 0x41, 0x90, 0x00] OR "\x00\x41\c90\x00\r\n"'
80
52
  # )
81
53
 
82
54
  public_class_method def self.request(opts = {})
83
55
  serial_obj = opts[:serial_obj]
84
- payload = opts[:payload]
85
56
  serial_conn = serial_obj[:serial_conn]
57
+ payload = opts[:payload]
86
58
 
87
59
  byte_arr = nil
88
60
  byte_arr = payload if payload.instance_of?(Array)
@@ -101,7 +73,7 @@ module Meshtastic
101
73
  end
102
74
 
103
75
  # Supported Method Parameters::
104
- # serial_obj = Meshtastic::Serial.connect(
76
+ # serial_obj = Meshtastic::SerialInterface.connect(
105
77
  # block_dev: 'optional - serial block device path (defaults to /dev/ttyUSB0)',
106
78
  # baud: 'optional - (defaults to 115200)',
107
79
  # data_bits: 'optional - (defaults to 8)',
@@ -138,16 +110,16 @@ module Meshtastic
138
110
 
139
111
  serial_obj = {}
140
112
  serial_obj[:serial_conn] = serial_conn
141
- serial_obj[:console_thread] = init_console_thread(
142
- serial_conn: serial_conn
113
+ serial_obj[:console_thread] = init_stdout_thread(
114
+ serial_conn: serial_conn,
115
+ type: :console
143
116
  )
144
- serial_obj[:proto_thread] = init_proto_thread(
145
- serial_conn: serial_conn
117
+ serial_obj[:proto_thread] = init_stdout_thread(
118
+ serial_conn: serial_conn,
119
+ type: :proto
146
120
  )
147
121
 
148
- # 32 bytes of start2_byte in a byte array
149
- start2_byte_arr = [START2].pack('C') * 32
150
- request(serial_obj: serial_obj, payload: start2_byte_arr)
122
+ wake_up_device(serial_obj: serial_obj)
151
123
 
152
124
  mui = Meshtastic::MeshInterface.new
153
125
  mui.start_config
@@ -157,91 +129,73 @@ module Meshtastic
157
129
  disconnect(serial_obj: serial_obj) unless serial_obj.nil?
158
130
  raise e
159
131
  end
160
-
132
+ #
161
133
  # Supported Method Parameters::
162
- # console_data = Meshtastic::Serial.dump_console_data
134
+ # wake_up_device(
135
+ # serial_obj: 'required - serial_obj returned from #connect method'
136
+ # )
137
+ public_class_method def self.wake_up_device(opts = {})
138
+ serial_obj = opts[:serial_obj]
163
139
 
164
- public_class_method def self.dump_console_data
165
- if block_given?
166
- @console_data.join.split("\n").each { |data| yield data }
167
- else
168
- @console_data.join
169
- end
140
+ start2_byte_arr = [START2].pack('C') * 32
141
+ request(serial_obj: serial_obj, payload: start2_byte_arr)
170
142
  rescue StandardError => e
143
+ disconnect(serial_obj: serial_obj) unless serial_obj.nil?
171
144
  raise e
172
145
  end
173
146
 
174
147
  # Supported Method Parameters::
175
- # console_data = Meshtastic::Serial.dump_proto_data
148
+ # stdout_data = Meshtastic::SerialInterface.dump_stdout_data(
149
+ # type: 'required - :proto or :console'
150
+ # )
151
+
152
+ public_class_method def self.dump_stdout_data(opts = {})
153
+ type = opts[:type]
154
+ valid_types = %i[proto console]
155
+ raise "ERROR: Invalid type: #{type}. Supported types are :proto or :console" unless valid_types.include?(type)
176
156
 
177
- public_class_method def self.dump_proto_data
178
157
  if block_given?
179
- @proto_data.each { |proto_hash| yield proto_hash }
158
+ @proto_data.each { |proto_hash| yield proto_hash } if type == :proto
159
+ @console_data.join.split("\n").each{ |line| yield line.force_encoding('UTF-8') } if type == :console
180
160
  else
181
- @proto_data
182
- end
183
- rescue StandardError => e
184
- raise e
185
- end
186
-
187
- # Supported Method Parameters::
188
- # console_data = Meshtastic::Serial.flush_data(opts = {})
161
+ stdout_data = @proto_data if type == :proto
162
+ stdout_data = @console_data.join if type == :console
189
163
 
190
- public_class_method def self.flush_data(opts = {})
191
- target = opts[:target]
192
- case target
193
- when :console
194
- @console_data.clear
195
- when :proto
196
- @proto_data.clear
197
- else
198
- raise "ERROR: supported targets are :console or :proto"
164
+ stdout_data
199
165
  end
200
166
  rescue StandardError => e
201
167
  raise e
202
168
  end
203
169
 
204
170
  # Supported Method Parameters::
205
- # console_data = Meshtastic::Serial.monitor_console(
206
- # refresh: 'optional - refresh interval (default: 3)',
207
- # include: 'optional - comma-delimited string(s) to include in message (default: nil)',
208
- # exclude: 'optional - comma-delimited string(s) to exclude in message (default: nil)'
209
- # )
171
+ # console_data = Meshtastic::SerialInterface.flush_data(opts = {})
210
172
 
211
- public_class_method def self.monitor_console(opts = {})
212
- refresh = opts[:refresh] ||= 3
213
- include = opts[:include]
214
- exclude = opts[:exclude]
215
-
216
- loop do
217
- exclude_arr = exclude.to_s.split(',').map(&:strip)
218
- include_arr = include.to_s.split(',').map(&:strip)
173
+ public_class_method def self.flush_data(opts = {})
174
+ type = opts[:type]
175
+ valid_types = %i[proto console]
176
+ raise "ERROR: Invalid type: #{type}. Supported types are :proto or :console" unless valid_types.include?(type)
219
177
 
220
- dump_console_data do |data|
221
- disp = false
222
- disp = true if exclude_arr.none? { |exclude| data.include?(exclude) } && (
223
- include_arr.empty? ||
224
- include_arr.all? { |include| data.include?(include) }
225
- )
226
- puts data if disp
227
- flush_data(target: :console)
228
- end
229
- sleep refresh
230
- end
231
- rescue Interrupt
232
- puts "\nCTRL+C detected. Breaking out of console mode..."
178
+ @console_data.clear if type == :console
179
+ @proto_data.clear if type == :proto
233
180
  rescue StandardError => e
234
181
  raise e
235
182
  end
236
183
 
237
184
  # Supported Method Parameters::
238
- # console_data = Meshtastic::Serial.monitor_proto(
185
+ # console_data = Meshtastic::SerialInterface.monitor_stdout(
186
+ # serial_obj: 'required - serial_obj returned from #connect method',
187
+ # type: 'required - :proto or :console',
239
188
  # refresh: 'optional - refresh interval (default: 3)',
240
189
  # include: 'optional - comma-delimited string(s) to include in message (default: nil)',
241
190
  # exclude: 'optional - comma-delimited string(s) to exclude in message (default: nil)'
242
191
  # )
243
192
 
244
- public_class_method def self.monitor_proto(opts = {})
193
+ public_class_method def self.monitor_stdout(opts = {})
194
+ serial_obj = opts[:serial_obj]
195
+ type = opts[:type]
196
+ valid_types = %i[proto console]
197
+ raise "ERROR: Invalid type: #{type}. Supported types are :proto or :console" unless valid_types.include?(type)
198
+
245
199
  refresh = opts[:refresh] ||= 3
246
200
  include = opts[:include]
247
201
  exclude = opts[:exclude]
@@ -250,25 +204,27 @@ module Meshtastic
250
204
  exclude_arr = exclude.to_s.split(',').map(&:strip)
251
205
  include_arr = include.to_s.split(',').map(&:strip)
252
206
 
253
- dump_proto_data do |data|
207
+ dump_stdout_data(type: type) do |data|
254
208
  disp = false
255
209
  disp = true if exclude_arr.none? { |exclude| data.include?(exclude) } && (
256
210
  include_arr.empty? ||
257
211
  include_arr.all? { |include| data.include?(include) }
258
212
  )
259
213
  puts data if disp
260
- flush_data(target: :proto)
214
+ flush_data(type: type)
261
215
  end
262
216
  sleep refresh
263
217
  end
264
218
  rescue Interrupt
265
- puts "\nCTRL+C detected. Breaking out of proto mode..."
219
+ puts "\nCTRL+C detected. Breaking out of console mode..."
220
+ disconnect(serial_obj: serial_obj) unless serial_obj.nil?
266
221
  rescue StandardError => e
222
+ disconnect(serial_obj: serial_obj) unless serial_obj.nil?
267
223
  raise e
268
224
  end
269
225
 
270
226
  # Supported Method Parameters::
271
- # Meshtastic::Serial.subscribe(
227
+ # Meshtastic::SerialInterface.subscribe(
272
228
  # serial_obj: 'required - serial_obj returned from #connect method'
273
229
  # root_topic: 'optional - root topic (default: msh)',
274
230
  # region: 'optional - region e.g. 'US/VA', etc (default: US)',
@@ -451,14 +407,14 @@ module Meshtastic
451
407
  end
452
408
  rescue Interrupt
453
409
  puts "\nCTRL+C detected. Exiting..."
410
+ serial_obj = disconnect(serial_obj: serial_obj) unless serial_obj.nil?
454
411
  rescue StandardError => e
412
+ serial_obj = disconnect(serial_obj: serial_obj) unless serial_obj.nil?
455
413
  raise e
456
- ensure
457
- serial_obj.disconnect if serial_obj
458
414
  end
459
415
 
460
416
  # Supported Method Parameters::
461
- # Meshtastic::Serial.send_text(
417
+ # Meshtastic::SerialInterface.send_text(
462
418
  # serial_obj: 'required - serial_obj returned from #connect method',
463
419
  # from: 'required - From ID (String or Integer) (Default: "!00000b0b")',
464
420
  # to: 'optional - Destination ID (Default: "!ffffffff")',
@@ -472,17 +428,18 @@ module Meshtastic
472
428
  # psks: 'optional - hash of :channel_id => psk key value pairs (default: { LongFast: "AQ==" })'
473
429
  # )
474
430
  public_class_method def self.send_text(opts = {})
475
- serial_obj = opts[:serial_obj]
476
- topic = opts[:topic] ||= 'msh/US/2/e/LongFast/#'
431
+ # serial_obj = opts[:serial_obj]
432
+ # topic = opts[:topic] ||= 'msh/US/2/e/LongFast/#'
477
433
  opts[:via] = :radio
478
434
 
479
435
  # TODO: Implement chunked message to deal with large messages
480
436
  mui = Meshtastic::MeshInterface.new
481
- protobuf_text = mui.send_text(opts)
437
+ mui.send_text(opts)
482
438
 
483
439
  # TODO: serial equivalent of publish
484
440
  # serial_obj.publish(topic, protobuf_text)
485
441
  rescue StandardError => e
442
+ serial_obj = disconnect(serial_obj: serial_obj) unless serial_obj.nil?
486
443
  raise e
487
444
  end
488
445
 
@@ -493,7 +450,16 @@ module Meshtastic
493
450
  public_class_method def self.disconnect(opts = {})
494
451
  serial_obj = opts[:serial_obj]
495
452
 
496
- serial_obj.disconnect if serial_obj
453
+ if serial_obj
454
+ console_thread = serial_obj[:console_thread]
455
+ proto_thread = serial_obj[:proto_thread]
456
+ serial_conn = serial_obj[:serial_conn]
457
+
458
+ console_thread&.terminate
459
+ proto_thread&.terminate
460
+ serial_conn&.close
461
+ end
462
+
497
463
  nil
498
464
  rescue StandardError => e
499
465
  raise e
@@ -522,16 +488,28 @@ module Meshtastic
522
488
  ack_timeout: 'optional - acknowledgement timeout (default: 30)'
523
489
  )
524
490
 
525
- #{self}.monitor_console(
526
- refresh: 'optional - refresh interval (default: 3)',
527
- include: 'optional - comma-delimited string(s) to include in message (default: nil)',
528
- exclude: 'optional - comma-delimited string(s) to exclude in message (default: nil)'
491
+ #{self}.wake_up_device(
492
+ serial_obj: 'required - serial_obj returned from #connect method'
493
+ )
494
+
495
+ #{self}.request(
496
+ serial_obj: 'required serial_obj returned from #connect method',
497
+ payload: 'required - array of bytes OR string to write to serial device (e.g. [0x00, 0x41, 0x90, 0x00] OR \"\\x00\\x41\\c90\\x00\\r\\n\"'
529
498
  )
530
499
 
531
- #{self}.monitor_proto(
500
+ stdout_data = #{self}.dump_stdout_data(
501
+ type: 'required - :proto or :console'
502
+ )
503
+
504
+ #{self}.flush_data(
505
+ type: 'optional - :console or :proto (default: nil)'
506
+ )
507
+
508
+ #{self}.monitor_stdout(
509
+ type: 'required - :proto or :console',
532
510
  refresh: 'optional - refresh interval (default: 3)',
533
511
  include: 'optional - comma-delimited string(s) to include in message (default: nil)',
534
- exclude: 'optional - comma-delimited string(s) to exclude in message (default: nil)'
512
+ exclude: 'optional - comma-delimited string(s) to exclude in message (default: nil)',
535
513
  )
536
514
 
537
515
  #{self}.subscribe(
@@ -58,7 +58,7 @@ module Meshtastic
58
58
  sleep(0.1) # wait 100ms to give device time to start running
59
59
 
60
60
  @rx_thread.start
61
- mui = Meshtastic::MeshInfoUser.new
61
+ mui = Meshtastic::MeshInterface.new
62
62
  mui.start_config
63
63
  rescue StandardError => e
64
64
  raise e
@@ -67,10 +67,50 @@ module Meshtastic
67
67
  # Supported Method Parameters::
68
68
  # Meshtastic::StreamInterface.reader
69
69
  def reader
70
+ loop do
71
+ break if @want_exit
72
+ # Read from stream and handle data
73
+ # This should be implemented based on how you handle reading from @stream
74
+ data = @stream.read(1) # Example: read one byte at a time
75
+ @rx_buf << data if data
76
+
77
+ # Here you would parse the data according to your protocol
78
+ # This is just a placeholder for the actual reading logic
79
+
80
+ # Yield for other threads
81
+ sleep(0.01)
82
+ end
70
83
  rescue StandardError => e
71
84
  raise e
72
85
  end
73
86
 
87
+ def write_bytes(opts = {})
88
+ bytes = opts[:bytes]
89
+ @stream.write(bytes) if @stream
90
+ @stream.flush if @stream
91
+ end
92
+
93
+ def read_bytes(opts = {})
94
+ length = opts[:length]
95
+ @stream.read(length) if @stream
96
+ end
97
+
98
+ def send_to_radio_impl(opts = {})
99
+ to_radio = opts[:to_radio]
100
+ # Convert to_radio to bytes, assuming it's a proto message in Ruby
101
+ # This example assumes `to_radio` has a method to serialize to string
102
+ b = to_radio.to_s
103
+ buf_len = b.length
104
+ header = [0x94, 0xC3, (buf_len >> 8) & 0xFF, buf_len & 0xFF].pack('C*')
105
+ write_bytes(header + b)
106
+ end
107
+
108
+ def close
109
+ @want_exit = true
110
+ @rx_thread.join if @rx_thread && @rx_thread != Thread.current
111
+ @stream&.close
112
+ end
113
+
74
114
  # Author(s):: 0day Inc. <support@0dayinc.com>
75
115
 
76
116
  def authors
@@ -33,6 +33,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
33
33
  proto3_optional :radiation, :float, 18
34
34
  proto3_optional :rainfall_1h, :float, 19
35
35
  proto3_optional :rainfall_24h, :float, 20
36
+ proto3_optional :soil_moisture, :uint32, 21
37
+ proto3_optional :soil_temperature, :float, 22
36
38
  end
37
39
  add_message "meshtastic.PowerMetrics" do
38
40
  proto3_optional :ch1_voltage, :float, 1
@@ -127,6 +129,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
127
129
  value :RADSENS, 33
128
130
  value :INA226, 34
129
131
  value :DFROBOT_RAIN, 35
132
+ value :DPS310, 36
133
+ value :RAK12035, 37
130
134
  end
131
135
  end
132
136
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meshtastic
4
- VERSION = '0.0.120'
4
+ VERSION = '0.0.121'
5
5
  end
data/lib/meshtastic.rb CHANGED
@@ -45,7 +45,7 @@ module Meshtastic
45
45
  autoload :Portnums, 'meshtastic/portnums'
46
46
  autoload :RemoteHardware, 'meshtastic/remote_hardware'
47
47
  autoload :RTTTL, 'meshtastic/rtttl'
48
- autoload :Serial, 'meshtastic/serial'
48
+ autoload :SerialInterface, 'meshtastic/serial_interface'
49
49
  autoload :Storeforward, 'meshtastic/storeforward'
50
50
  autoload :StreamInterface, 'meshtastic/stream_interface'
51
51
  autoload :Telemetry, 'meshtastic/telemetry'
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Meshtastic::Serial do
5
+ describe Meshtastic::SerialInterface do
6
6
  end
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.120
4
+ version: 0.0.121
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-17 00:00:00.000000000 Z
10
+ date: 2025-04-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 2.6.3
18
+ version: 2.6.8
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: 2.6.3
25
+ version: 2.6.8
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundle-audit
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -99,14 +99,14 @@ dependencies:
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 6.12.0
102
+ version: 6.13.1
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 6.12.0
109
+ version: 6.13.1
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: rspec
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +127,14 @@ dependencies:
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: 1.72.1
130
+ version: 1.75.2
131
131
  type: :runtime
132
132
  prerelease: false
133
133
  version_requirements: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: 1.72.1
137
+ version: 1.75.2
138
138
  - !ruby/object:Gem::Dependency
139
139
  name: rubocop-rake
140
140
  requirement: !ruby/object:Gem::Requirement
@@ -155,14 +155,14 @@ dependencies:
155
155
  requirements:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
- version: 3.5.0
158
+ version: 3.6.0
159
159
  type: :runtime
160
160
  prerelease: false
161
161
  version_requirements: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: 3.5.0
165
+ version: 3.6.0
166
166
  - !ruby/object:Gem::Dependency
167
167
  name: rvm
168
168
  requirement: !ruby/object:Gem::Requirement
@@ -267,7 +267,7 @@ files:
267
267
  - lib/meshtastic/remote_hardware_pb.rb
268
268
  - lib/meshtastic/rtttl.rb
269
269
  - lib/meshtastic/rtttl_pb.rb
270
- - lib/meshtastic/serial.rb
270
+ - lib/meshtastic/serial_interface.rb
271
271
  - lib/meshtastic/storeforward.rb
272
272
  - lib/meshtastic/storeforward_pb.rb
273
273
  - lib/meshtastic/stream_interface.rb
@@ -317,7 +317,7 @@ files:
317
317
  - spec/lib/meshtastic/remote_hardware_spec.rb
318
318
  - spec/lib/meshtastic/rtttl_pb_spec.rb
319
319
  - spec/lib/meshtastic/rtttl_spec.rb
320
- - spec/lib/meshtastic/serial_spec.rb
320
+ - spec/lib/meshtastic/serial_interface_spec.rb
321
321
  - spec/lib/meshtastic/storeforward_pb_spec.rb
322
322
  - spec/lib/meshtastic/storeforward_spec.rb
323
323
  - spec/lib/meshtastic/stream_interface_spec.rb
@@ -353,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
353
353
  - !ruby/object:Gem::Version
354
354
  version: '0'
355
355
  requirements: []
356
- rubygems_version: 3.6.3
356
+ rubygems_version: 3.6.6
357
357
  specification_version: 4
358
358
  summary: Ruby gem for Meshtastic
359
359
  test_files: []