Class: Radbeacon::Scanner

Inherits:
LeScanner show all
Defined in:
lib/radbeacon/scanner.rb

Constant Summary collapse

C_DEVICE_NAME =
"0x0003"
RADBEACON_USB =
"52 61 64 42 65 61 63 6f 6e 20 55 53 42"

Instance Attribute Summary

Attributes inherited from LeScanner

#duration, #options

Instance Method Summary collapse

Methods inherited from LeScanner

#initialize, #passive_scan, #scan_command, #scan_command_duration

Constructor Details

This class inherits a constructor from Radbeacon::LeScanner

Instance Method Details

#fetch(mac_address) ⇒ Object



13
14
15
16
# File 'lib/radbeacon/scanner.rb', line 13

def fetch(mac_address)
  dev = BluetoothLeDevice.new(mac_address, nil)
  radbeacon_check(dev) if dev.fetch_characteristics
end

#radbeacon_check(device) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/radbeacon/scanner.rb', line 18

def radbeacon_check(device)
  radbeacon = nil
  case device.values[C_DEVICE_NAME]
  when RADBEACON_USB
    radbeacon = Usb.create_if_valid(device)
  end
  radbeacon
end

#scanObject



7
8
9
10
11
# File 'lib/radbeacon/scanner.rb', line 7

def scan
  devices = super
  radbeacons = devices.map { |dev| radbeacon_check(dev) }
  radbeacons.compact
end