<p>还有另外一个版本,特别适用于mac osx 10.8<a href="https://github.com/0-1-0/lightblue-0.4" rel="nofollow">https://github.com/0-1-0/lightblue-0.4</a>。我也可以在OSX10.10Yosemite下运行这个版本。</p>
<p>我只需要按照setup.py文件中的以下行进行更改:</p>
<pre><code>os.system("xcodebuild install -arch 'x86_64' -target LightAquaBlue -configuration Release DSTROOT=/ INSTALL_PATH=/Library/Frameworks DEPLOYMENT_LOCATION=YES")
</code></pre>
<p>然后我在/Library/Python/2.7/site-packages/lightblue//u lightblue.py中插入了以下两个方法:</p>
<p>def deviceinquiredevicenameupdated_devices_devices remaining_u(自身、发送方、设备、设备remaining):
通过</p>
<p>def deviceInquiryUpdatingDeviceNamesStarted_devicesRemaining_u(self,sender,devicesRemaining):开始设备剩余:
通过</p>
<p>建造人之后:</p>
<pre><code>_AsyncDeviceInquiry(Foundation.NSObject):
</code></pre>
<p>完整的代码是:</p>
<pre><code>class _AsyncDeviceInquiry(Foundation.NSObject):
# NSObject init, not python __init__
def init(self):
try:
attr = _IOBluetooth.IOBluetoothDeviceInquiry
except AttributeError:
raise ImportError("Cannot find IOBluetoothDeviceInquiry class " +\
"to perform device discovery. This class was introduced in " +\
"Mac OS X 10.4, are you running an earlier version?")
self = super(_AsyncDeviceInquiry, self).init()
self._inquiry = \
_IOBluetooth.IOBluetoothDeviceInquiry.inquiryWithDelegate_(self)
# callbacks
self.cb_started = None
self.cb_completed = None
self.cb_founddevice = None
return self
def deviceInquiryDeviceNameUpdated_device_devicesRemaining_(self, sender, device, devicesRemaining):
pass
def deviceInquiryUpdatingDeviceNamesStarted_devicesRemaining_(self, sender, devicesRemaining):
pass
</code></pre>
<p>最后一步是更改同一文件中的这一行:</p>
<pre><code>deviceInquiryComplete_error_aborted_, signature="v@:@iB")
</code></pre>
<p>到</p>
<pre><code>deviceInquiryComplete_error_aborted_, signature="v@:@iZ")
</code></pre>
<p>对我来说那很好!</p>
<p>希望这是一个有用的帖子。</p>