meshtastic 0.0.132 → 0.0.133

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: 55a43435391e779611e5b054b48922b801ede63b8e2a1475ca6231bee6fea0dc
4
- data.tar.gz: a174043a34c15e67ac5d3633b2f3e7cb4e8043103f1ec772511dfe07ab4e25e1
3
+ metadata.gz: dd7da546fac5be533cc4420c830da4514bf10c5dd48577abfd54cf912d0af58e
4
+ data.tar.gz: 583508248f892029b83b21663e3666dff7bae1a034c085eaa67616c6834d4ef1
5
5
  SHA512:
6
- metadata.gz: 56e964f576c853715ba6991d86e4136f40e2c7aca7a33ab51cc0d395c826738bcc97556b05d3556a611b131520d714a016a9a8fe49235dc8dff0c63cdf3cff16
7
- data.tar.gz: 9ceb1c0ba1b34b56d44cfdc9c382c2cbee879607555f61671ed4d1d21961ccdb2057b1ce702c74223712191b76382414375ff1a54a63688ff54ba2e6af7fe631
6
+ metadata.gz: e689b2141774914914ef4895867a5cc7e197cdf63ee0f282fbbcf5b1fcabf917167de1a81fccbbb865e4c35082f154dd4b3957769d0d601dd8388925f4b85ea7
7
+ data.tar.gz: af9a806f6fdf54668c1391ad46865a8590bfe4d8bb47829fafc7232eae7413dd470f506c1deffd25f4f08fa9dede9cd298d97a9a963c3e76cc5e031c6ca1c309
@@ -278,10 +278,34 @@ module Meshtastic
278
278
  opts[:via] = :mqtt
279
279
 
280
280
  # TODO: Implement chunked message to deal with large messages
281
+ raw_text = opts[:text].to_s
282
+ max_bytes = 233
281
283
  mui = Meshtastic::MeshInterface.new
282
- protobuf_text = mui.send_text(opts)
283
284
 
284
- mqtt_obj.publish(absolute_topic, protobuf_text)
285
+ if raw_text.bytesize > max_bytes
286
+ chunks = []
287
+ current_chunk = ''
288
+ raw_text.each_char do |char|
289
+ if (current_chunk + char).bytesize > max_bytes
290
+ chunks.push(current_chunk)
291
+ current_chunk = char
292
+ else
293
+ current_chunk += char
294
+ end
295
+ end
296
+ chunks.push(current_chunk) unless current_chunk.empty?
297
+
298
+ total_chunks = chunks.length
299
+ chunks.each_with_index do |chunk, index|
300
+ opts[:text] = chunk
301
+ opts[:text] = "[#{index + 1}/#{total_chunks}] #{chunk}"
302
+ protobuf_chunk = mui.send_text(opts)
303
+ push(mqtt_obj.publish(absolute_topic, protobuf_chunk))
304
+ end
305
+ else
306
+ protobuf_text = mui.send_text(opts)
307
+ mqtt_obj.publish(absolute_topic, protobuf_text)
308
+ end
285
309
  rescue StandardError => e
286
310
  raise e
287
311
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meshtastic
4
- VERSION = '0.0.132'
4
+ VERSION = '0.0.133'
5
5
  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.132
4
+ version: 0.0.133
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.