Class: SensoroBeaconManagerListener

Inherits:
Object
  • Object
show all
Defined in:
lib/ios/sensoro_beacon_manager.rb,
lib/android/sensoro_beacon_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(callback) ⇒ SensoroBeaconManagerListener

Returns a new instance of SensoroBeaconManagerListener.



2
3
4
5
# File 'lib/ios/sensoro_beacon_manager.rb', line 2

def initialize(callback)
  @callback = callback
  @cache = {}
end

Instance Method Details

#_beacon(beacon) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ios/sensoro_beacon_manager.rb', line 19

def _beacon(beacon)
  @cache[beacon.serialNumber] ||= begin
    obj = SensoroBeacon.new
    obj.uuid = beacon.beaconID.proximityUUID
    obj.major = beacon.beaconID.major
    obj.minor = beacon.beaconID.minor
    obj.serial_number = beacon.serialNumber
    obj.battery_level = beacon.batteryLevel
    obj.firmware_version = beacon.firmwareVersion
    obj.temperature = beacon.temperature
    obj.light = beacon.light
    obj.accelerometer_count = beacon.accelerometerCount
    obj.accuracy = beacon.accuracy
    obj.rssi = beacon.rssi
    obj.model_name = beacon.hardwareModelName
    obj
  end
end

#beaconManager(manager, scanDidFinishWithBeacons: beacons) ⇒ Object



7
8
9
# File 'lib/ios/sensoro_beacon_manager.rb', line 7

def beaconManager(manager, didRangeNewBeacon:beacon)
  @callback.call :beacon_found, _beacon(beacon)
end

#onGoneBeacon(beacon) ⇒ Object



11
12
13
# File 'lib/android/sensoro_beacon_manager.rb', line 11

def onGoneBeacon(beacon)
  @callback.call :beacon_lost, _beacon(beacon)
end

#onNewBeacon(beacon) ⇒ Object



7
8
9
# File 'lib/android/sensoro_beacon_manager.rb', line 7

def onNewBeacon(beacon)
  @callback.call :beacon_found, _beacon(beacon)
end

#onUpdateBeacon(beacons) ⇒ Object



15
16
17
# File 'lib/android/sensoro_beacon_manager.rb', line 15

def onUpdateBeacon(beacons)
  # TODO: refresh beacon sensors info
end