Class: Meshtastic::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/meshtastic/position.rb

Class Method Summary collapse

Class Method Details

.authorsObject



24
25
26
# File 'lib/meshtastic/position.rb', line 24

public_class_method def self.authors
  "AUTHOR(S):\n        0day Inc. <[email protected]>\n      "
end

.build(opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/meshtastic/position.rb', line 7

public_class_method def self.build(opts = {})
  position = new
  position.latitude_i = (opts.fetch(:lat).to_f * 10_000_000).round
  position.longitude_i = (opts.fetch(:lon).to_f * 10_000_000).round
  position.altitude = opts[:altitude].to_i if opts[:altitude]
  position.time = opts[:time].to_i if opts[:time]
  position
end

.helpObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/meshtastic/position.rb', line 28

public_class_method def self.help
  puts "        USAGE:
    # Run the build class method for this module.
    #{self}.build(
      altitude: 'optional - value for altitude passed into build',
      time: 'optional - value for time passed into build'
    )

    # Run the transmit class method for this module.
    #{self}.transmit

    # Run the authors class method for this module.
    #{self}.authors

  "
end

.transmit(opts = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/meshtastic/position.rb', line 16

public_class_method def self.transmit(opts = {})
  data = Meshtastic::Data.new(
    portnum: :POSITION_APP,
    payload: build(opts).to_proto
  )
  Meshtastic.deliver_data(opts.merge(data: data, port_num: Meshtastic::PortNum::POSITION_APP))
end