Class: ScanBeacon::BLE112Scanner
- Inherits:
-
GenericScanner
- Object
- GenericScanner
- ScanBeacon::BLE112Scanner
- Defined in:
- lib/scan_beacon/ble112_scanner.rb
Instance Attribute Summary
Attributes inherited from GenericScanner
Instance Method Summary collapse
- #each_advertisement ⇒ Object
-
#initialize(opts = {}) ⇒ BLE112Scanner
constructor
A new instance of BLE112Scanner.
Methods inherited from GenericScanner
#add_beacon, #add_parser, #detect_beacon, #scan
Constructor Details
#initialize(opts = {}) ⇒ BLE112Scanner
Returns a new instance of BLE112Scanner.
4 5 6 7 |
# File 'lib/scan_beacon/ble112_scanner.rb', line 4 def initialize(opts = {}) super @device = BLE112Device.new opts[:port] end |
Instance Method Details
#each_advertisement ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/scan_beacon/ble112_scanner.rb', line 9 def each_advertisement @device.open do |device| device.start_scan begin keep_scanning = true while keep_scanning do response = device.read if response.advertisement? if response.manufacturer_ad? keep_scanning = false if yield(response.advertisement_data, response.mac, response.rssi) == false else keep_scanning = false if yield(response.advertisement_data[4..-1], response.mac, response.rssi, 0x03) == false end end end ensure device.stop_scan end end end |