Last active
November 26, 2017 07:52
-
-
Save WayneKeenan/f71525f1fd3839c485946590ae3ef81d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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