Skip to content

Instantly share code, notes, and snippets.

@nanki
Last active December 10, 2016 14:21
Show Gist options
  • Save nanki/5c34ad8f6b3bda481bc9 to your computer and use it in GitHub Desktop.
Save nanki/5c34ad8f6b3bda481bc9 to your computer and use it in GitHub Desktop.
framework 'IOBluetooth'
class A
def initialize
@c = CBCentralManager.alloc.initWithDelegate(self, queue:nil)
end
def centralManagerDidUpdateState(central)
if central.state == CBCentralManagerStatePoweredOn
@c.scanForPeripheralsWithServices(nil, options:nil)
end
end
def centralManager(central, didDiscoverPeripheral:peripheral, advertisementData:data, RSSI:rssi)
puts NSString.stringWithFormat("peripheral: %@\nadvertisementData: %@\nrssi: %@", peripheral, data, rssi)
end
end
A.new
NSRunLoop.currentRunLoop.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment