meshtastic 0.0.59 → 0.0.61

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bee0bc9cf63a72bf400763d93004424baa89bf5c6252a53d594cd472a09ee0a
4
- data.tar.gz: 4bfa4ff0b53b434da3624a55d5dc26934b1edb641a5a6c32101dc5029cf6df58
3
+ metadata.gz: dceeac29deeac96282b54784e35f07c58b94eefa80d90e52c99fa13d34abe359
4
+ data.tar.gz: 8a30e46f08215d9c681506e9e138856b442f97af1f9bdcb28b3a2c3defd02a14
5
5
  SHA512:
6
- metadata.gz: 5abc75249f2f677b1bfdc96f21a1a3ce76b5ab0b6ee38968f1f20cc436c45423702e5445fd89e2f6aa2a64ea8b1a6f5eddf71dca03e5808eddf33b87d19bed2e
7
- data.tar.gz: 0610bbc1cd020aa4dcf01fae92430006eb3c2150c0b9971b3270ab1e67133bbcbd1488348ffce1260960270c61219a1a7c93365a61ebce3c4682ef41e545ccb6
6
+ metadata.gz: ac41b52aa5c8069b6da7b8ce6e27f09643604c0b2978230dde661612e50a1656e6740d7ede4f4c8bf27a0230b807e4b98f305897e293053f0450d5f8a793aa52
7
+ data.tar.gz: 760a90c99e4618a3b1448e13d5a2fd0434a5c169d7235629c8c18a128bc8761bd81135a131e6aa4cce84f823dd27eb15aa77a077a1b3ed4fd761e2cf3a54e6e8
@@ -167,7 +167,8 @@ module Meshtastic
167
167
  end
168
168
 
169
169
  payload
170
- rescue Google::Protobuf::ParseError
170
+ rescue Encoding::CompatibilityError,
171
+ Google::Protobuf::ParseError
171
172
  payload
172
173
  rescue StandardError => e
173
174
  raise e
@@ -291,18 +292,21 @@ module Meshtastic
291
292
  message[:stdout] = 'pretty'
292
293
  stdout_message = JSON.pretty_generate(decoded_payload_hash)
293
294
  end
294
- rescue Google::Protobuf::ParseError,
295
+ rescue Encoding::CompatibilityError,
296
+ Google::Protobuf::ParseError,
295
297
  JSON::GeneratorError,
296
298
  ArgumentError => e
297
299
 
298
- message[:decrypted] = e.message if e.message.include?('key must be')
299
- message[:decrypted] = 'unable to decrypt - psk?' if e.message.include?('occurred during parsing')
300
- decoded_payload_hash[:packet] = message
301
- unless block_given?
302
- puts "WARNING: #{e.inspect} - MSG IS >>>"
303
- # puts e.backtrace
304
- message[:stdout] = 'inspect'
305
- stdout_message = decoded_payload_hash.inspect
300
+ unless e.is_a?(Encoding::CompatibilityError)
301
+ message[:decrypted] = e.message if e.message.include?('key must be')
302
+ message[:decrypted] = 'unable to decrypt - psk?' if e.message.include?('occurred during parsing')
303
+ decoded_payload_hash[:packet] = message
304
+ unless block_given?
305
+ puts "WARNING: #{e.inspect} - MSG IS >>>"
306
+ # puts e.backtrace
307
+ message[:stdout] = 'inspect'
308
+ stdout_message = decoded_payload_hash.inspect
309
+ end
306
310
  end
307
311
 
308
312
  next
@@ -339,6 +343,32 @@ module Meshtastic
339
343
  mqtt_obj.disconnect if mqtt_obj
340
344
  end
341
345
 
346
+ # Supported Method Parameters::
347
+ # Meshtastic.send_text(
348
+ # mqtt_obj: 'required - mqtt_obj returned from #connect method',
349
+ # from: ' required - From ID (String or Integer)',
350
+ # to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
351
+ # topic: 'optional - topic to publish to (default: "msh/US/2/e/LongFast/1")',
352
+ # channel: 'optional - channel ID (Default: 6)',
353
+ # text: 'optional - Text Message (Default: SYN)',
354
+ # want_ack: 'optional - Want Acknowledgement (Default: false)',
355
+ # want_response: 'optional - Want Response (Default: false)',
356
+ # hop_limit: 'optional - Hop Limit (Default: 3)',
357
+ # on_response: 'optional - Callback on Response',
358
+ # psks: 'optional - hash of :channel => psk key value pairs (default: { LongFast: "AQ==" })'
359
+ # )
360
+ public_class_method def self.send_text(opts = {})
361
+ mqtt_obj = opts[:mqtt_obj]
362
+ topic = opts[:topic] ||= 'msh/US/2/e/LongFast/#'
363
+ opts[:via] = :mqtt
364
+
365
+ protobuf_text = Meshtastic.send_text(opts)
366
+
367
+ mqtt_obj.publish(topic, protobuf_text)
368
+ rescue StandardError => e
369
+ raise e
370
+ end
371
+
342
372
  # Supported Method Parameters::
343
373
  # mqtt_obj = Meshtastic.gps_search(
344
374
  # lat: 'required - latitude float (e.g. 37.7749)',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meshtastic
4
- VERSION = '0.0.59'
4
+ VERSION = '0.0.61'
5
5
  end
data/lib/meshtastic.rb CHANGED
@@ -55,7 +55,7 @@ module Meshtastic
55
55
  # to: 'optional - Destination ID (Default: 0xFFFFFFFF)',
56
56
  # last_packet_id: 'optional - Last Packet ID (Default: 0)',
57
57
  # via: 'optional - :radio || :mqtt (Default: :radio)',
58
- # channel: 'optional - Channel ID (Default: 0)',
58
+ # channel: 'optional - Channel ID (Default: 6)',
59
59
  # text: 'optional - Text Message (Default: SYN)',
60
60
  # want_ack: 'optional - Want Acknowledgement (Default: false)',
61
61
  # want_response: 'optional - Want Response (Default: false)',
@@ -76,7 +76,7 @@ module Meshtastic
76
76
 
77
77
  last_packet_id = opts[:last_packet_id] ||= 0
78
78
  via = opts[:via] ||= :radio
79
- channel = opts[:channel] ||= 0
79
+ channel = opts[:channel] ||= 6
80
80
  text = opts[:text] ||= 'SYN'
81
81
  want_ack = opts[:want_ack] ||= false
82
82
  want_response = opts[:want_response] ||= false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meshtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.59
4
+ version: 0.0.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-10 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler