Skip to content

Instantly share code, notes, and snippets.

@WayneKeenan
Last active November 26, 2017 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WayneKeenan/f71525f1fd3839c485946590ae3ef81d to your computer and use it in GitHub Desktop.
Save WayneKeenan/f71525f1fd3839c485946590ae3ef81d to your computer and use it in GitHub Desktop.
# python3 -m venv my-venv
# source my-venv/bin/activate
# pip3 install --upgrade pip setuptools wheel
# hg clone https://bitbucket.org/ronaldoussoren/pyobjc pyobjc # e.g. homebrew install mercurial
# cd pyobj
# python3 install.py # You will need XCode installed in order to compile the native extensions.
# python3 ../test_4.1.py
# deactivate
import objc
import libdispatch
from PyObjCTools import AppHelper
import CoreBluetooth
class DispatchTest():
def __init__(self):
try:
with objc.autorelease_pool():
dispatch_queue = libdispatch.dispatch_queue_create(None, None)
print(dispatch_queue)
manager = CoreBluetooth.CBCentralManager.alloc()
manager.initWithDelegate_queue_options_(self, dispatch_queue, None)
manager.scanForPeripheralsWithServices_options_(None, None)
AppHelper.runConsoleEventLoop(installInterrupt=True)
except Exception as e:
print(e)
# CoreBluetooth CentralManager Protocol
def centralManagerDidUpdateState_(self, manager):
print(manager.state())
def centralManager_didDiscoverPeripheral_advertisementData_RSSI_(self, manager, peripheral, data, rssi):
print(peripheral)
DispatchTest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment