Class: TiltHydrometer::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/tilt_hydrometer/core.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Core

Returns a new instance of Core.



7
8
9
# File 'lib/tilt_hydrometer/core.rb', line 7

def initialize(options = {})
  @options = options
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tilt_hydrometer/core.rb', line 11

def run
  Open3.popen3 'hcidump -R' do |_stdin, stdout, _stderr, _thread|
    buffer = []
    while line = stdout.gets
      if line.start_with?('>') || line.start_with?('<')
        process_advertisement(buffer.join.gsub(/\s+/, ''))

        buffer = []
      end

      buffer << line[2..-2]
    end
  end
end