获取配对设备的电量百分比

问题描述 投票:0回答:0

当我尝试为配对设备的电池充电时显示错误和警告。 我写了一个脚本,通过地址检测蓝牙设备的电池。 之前我从 IOBluetooth 框架加载了 IOBluetoothDevice 类。

import objc
import CoreBluetooth 

objc.loadBundleFunctions(
objc.loadBundle("IOBluetooth", globals(),
bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework')),
globals(),
[('IOBluetoothPreferenceGetControllerPowerState', b'oI'),
 ('IOBluetoothPreferenceSetControllerPowerState', b'Vi'),
 ('IOBluetoothDevice', b'B')]
 )
print(IOBluetoothDevice.alloc().batteryLevel_(u'2C-A0-42-84-9F-64'))

平台信息

• 3.10 蟒蛇

• python.org

• 11.7.4 Mac 操作系统版本

预期行为

应该返回配对设备的电池百分比,或者尽管有。波纹管,错误。

Traceback (most recent call last):
  File "/Users/admin/PycharmProjects/pythonProject3/BluetoothObjC.py", line 16, in <module>
    battery = IOBluetoothDevice.alloc().init().batteryLevel_(0x7f88e9cfa810)
TypeError: Argument 2 is a block, but no signature available

附加上下文 我使用了

IOBluetooth.arm64efile.bridgesupport
文件。在那里我必须 使用类
IOBluetoothDevice
.

<class name='IOBluetoothDevice'>
<method selector='isConnected'>
<retval type64='B'/>
</method>

怎么了?

python bluetooth pyobjc
© www.soinside.com 2019 - 2024. All rights reserved.