Class: ScanBeacon::BLE112Advertiser

Inherits:
GenericIndividualAdvertiser show all
Defined in:
lib/scan_beacon/ble112_advertiser.rb

Instance Attribute Summary

Attributes inherited from GenericAdvertiser

#ad, #advertising, #beacon, #parser

Instance Method Summary collapse

Methods inherited from GenericIndividualAdvertiser

#ad=, #beacon=, #parser=, #update_ad

Constructor Details

#initialize(opts = {}) ⇒ BLE112Advertiser

Returns a new instance of BLE112Advertiser.



4
5
6
7
# File 'lib/scan_beacon/ble112_advertiser.rb', line 4

def initialize(opts = {})
  @device = BLE112Device.new opts[:port]
  super(opts)
end

Instance Method Details

#inspectObject



23
24
25
# File 'lib/scan_beacon/ble112_advertiser.rb', line 23

def inspect
  "<BLE112Advertiser ad=#{@ad.inspect}>"
end

#rotate_addrObject



27
28
29
30
31
# File 'lib/scan_beacon/ble112_advertiser.rb', line 27

def rotate_addr
  @device.open do
    @device.rotate_addr
  end
end

#rotate_addr_and_update_adObject



33
34
35
36
# File 'lib/scan_beacon/ble112_advertiser.rb', line 33

def rotate_addr_and_update_ad
  self.update_ad
  self.start(true)
end

#start(with_rotation = false) ⇒ Object



9
10
11
12
13
14
# File 'lib/scan_beacon/ble112_advertiser.rb', line 9

def start(with_rotation = false)
  @device.open do
    @device.start_advertising(@ad, with_rotation)
    @advertising = true
  end
end

#stopObject



16
17
18
19
20
21
# File 'lib/scan_beacon/ble112_advertiser.rb', line 16

def stop
  @device.open do
    @device.stop_advertising
    @advertising = false
  end
end