Class: ScanBeacon::BlueZScanner
- Inherits:
-
GenericScanner
- Object
- GenericScanner
- ScanBeacon::BlueZScanner
- Defined in:
- lib/scan_beacon/bluez_scanner.rb
Instance Attribute Summary
Attributes inherited from GenericScanner
Instance Method Summary collapse
- #each_advertisement ⇒ Object
-
#initialize(opts = {}) ⇒ BlueZScanner
constructor
A new instance of BlueZScanner.
Methods inherited from GenericScanner
#add_beacon, #add_parser, #detect_beacon, #scan
Constructor Details
#initialize(opts = {}) ⇒ BlueZScanner
4 5 6 7 8 |
# File 'lib/scan_beacon/bluez_scanner.rb', line 4 def initialize(opts = {}) super @device_id = opts[:device_id] || BlueZ.devices[0][:device_id] BlueZ.device_up @device_id end |
Instance Method Details
#each_advertisement ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/scan_beacon/bluez_scanner.rb', line 10 def each_advertisement ScanBeacon::BlueZ.scan(@device_id) do |mac, ad_data, rssi| if ad_data.nil? yield(nil) elsif ad_data.size > 4 ad_type = ad_data[4].unpack("C")[0] if ad_type == 0xff yield(ad_data[5..-1], mac, rssi, ad_type) else yield(ad_data[9..-1], mac, rssi, ad_type) end end end end |