Class: ScanBeacon::BLE112Device::BLE112Response
- Inherits:
-
Object
- Object
- ScanBeacon::BLE112Device::BLE112Response
- Defined in:
- lib/scan_beacon/ble112_device.rb
Instance Method Summary collapse
- #advertisement? ⇒ Boolean
- #advertisement_data ⇒ Object
- #advertisement_type ⇒ Object
- #event? ⇒ Boolean
- #gap_scan? ⇒ Boolean
-
#initialize(data) ⇒ BLE112Response
constructor
A new instance of BLE112Response.
- #mac ⇒ Object
- #manufacturer_ad? ⇒ Boolean
- #rssi ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(data) ⇒ BLE112Response
73 74 75 |
# File 'lib/scan_beacon/ble112_device.rb', line 73 def initialize(data) @data = data end |
Instance Method Details
#advertisement? ⇒ Boolean
93 94 95 |
# File 'lib/scan_beacon/ble112_device.rb', line 93 def advertisement? event? && gap_scan? && manufacturer_ad? end |
#advertisement_data ⇒ Object
101 102 103 |
# File 'lib/scan_beacon/ble112_device.rb', line 101 def advertisement_data @advertisement_data ||= @data[20..-1] end |
#advertisement_type ⇒ Object
97 98 99 |
# File 'lib/scan_beacon/ble112_device.rb', line 97 def advertisement_type @data[19].unpack('C')[0] end |
#event? ⇒ Boolean
81 82 83 |
# File 'lib/scan_beacon/ble112_device.rb', line 81 def event? @data[0].unpack('C')[0] == BG_EVENT end |
#gap_scan? ⇒ Boolean
85 86 87 |
# File 'lib/scan_beacon/ble112_device.rb', line 85 def gap_scan? @data[2..3].unpack('CC') == [BG_MSG_CLASS_GAP, 0] end |
#mac ⇒ Object
105 106 107 |
# File 'lib/scan_beacon/ble112_device.rb', line 105 def mac @data[6..11].unpack('H2 H2 H2 H2 H2 H2').join(":") end |
#manufacturer_ad? ⇒ Boolean
89 90 91 |
# File 'lib/scan_beacon/ble112_device.rb', line 89 def manufacturer_ad? size > 20 && advertisement_type == 0xFF end |
#rssi ⇒ Object
109 110 111 |
# File 'lib/scan_beacon/ble112_device.rb', line 109 def rssi @data[4].unpack('c')[0] end |
#size ⇒ Object
77 78 79 |
# File 'lib/scan_beacon/ble112_device.rb', line 77 def size @data.size end |