gpt4 book ai didi

swift - Apple 蓝牙 2009 ANSI 键盘的 ProductID

转载 作者:行者123 更新时间:2023-11-28 06:18:54 24 4
gpt4 key购买 nike

我正在尝试在 Swift 中获取我连接的蓝牙设备的电池电量。在我的机器上,所有设备都被正确检测到。但是,未检测到通过蓝牙连接的 2009 Apple Wireless Bluetooth ANSI 键盘(很遗憾,我没有此键盘)。

在我的代码中,我使用了以下蓝牙产品 ID:

WIRELESS_KEYBOARD_2009_ANSI = 0x0239
WIRELESS_KEYBOARD_2009_ISO = 0x023A
WIRELESS_KEYBOARD_2009_JIS = 0x023B
WIRELESS_KEYBOARD_2011_ANSI = 0x0255
WIRELESS_KEYBOARD_2011_ISO = 0x0256
WIRELESS_KEYBOARD_2011_JIS = 0x0257
MAGIC_KEYBOARD = 0x0267
WIRELESS_ANSI = 0x022C
WIRELESS_ISO = 0x022D
WIRELESS_JIS = 0x022E

我很确定它是 0x0239,但看起来我错了。那么有没有人使用 2009 年的 Apple 蓝牙键盘并且知道该设备的产品 ID 是什么?

我正在使用 IOKit 并在“AppleBluetoothHIDKeyboard”条目中搜索。

要找到键盘,可以使用此处列出的资源管理器工具:http://mac.softpedia.com/get/System-Utilities/IORegistryExplorer.shtml

或者使用终端命令:ioreg -l | grep BatteryPercent

问候,萨沙

最佳答案

我有一个 2009 无线键盘 ( two batteries, dashboard button )。这是系统信息的输出:

Address:              00-25-BC-FB-2B-DB
Major Type: Peripheral
Minor Type: Keyboard
Services: Apple Wireless Keyboard
Paired: Yes
Configured: Yes
Connected: Yes
Manufacturer: Apple (0x3, 0x31C)
Battery Level: 41%
Firmware Version: 0x0050
Vendor ID: 0x05AC
Product ID: 0x0239
Class of Device: 0x05 0x10 0x2540
AFH: On
AFH Map: FFF7FFFFFFFFFFFFFF7F
RSSI: -62
Role: Master
Connection Mode: Sniff Mode
Interval: 11.25 ms
Host Connectable: Yes
EDR Supported: No
eSCO Supported: No
SSP Supported: No

看起来产品 ID 是 0x0239,如您所想。


这是 ioreg -i 的相关输出(没有行与 BatteryPercent 的 grep 匹配)

  +-o IOBluetoothHCIController  <class IORegistryEntry:IOService:IOBluetoothHCIController, id 0x10000035f, registered, matched, active, busy 0 (570 ms), retain 30>
| +-o AppleBroadcomBluetoothHostController <class IORegistryEntry:IOService:IOBluetoothHostController:BroadcomBluetoothHostController:AppleBroadcomBluetoothHostController, id 0x100000366, registered, matched, active, busy 0 (566 ms), retain 8>
| | +-o IOBluetoothDevice <class IORegistryEntry:IOService:IOBluetoothObject:IOBluetoothDevice, id 0x100000f27, registered, matched, active, busy 0 (45 ms), retain 12>
| | | +-o IOBluetoothL2CAPSignalChannel <class IORegistryEntry:IOService:IOBluetoothObject:IOBluetoothL2CAPChannel:IOBluetoothL2CAPSignalChannel, id 0x100000f28, registered, matched, active, busy 0 (1 ms), retain 8>
| | | | +-o IOBluetoothL2CAPChannelUserClient <class IORegistryEntry:IOService:IOUserClient:IOBluetoothL2CAPChannelUserClient, id 0x100000f29, !registered, !matched, active, busy 0, retain 6>
| | | +-o IOBluetoothL2CAPChannel <class IORegistryEntry:IOService:IOBluetoothObject:IOBluetoothL2CAPChannel, id 0x100000f2e, registered, matched, active, busy 0 (44 ms), retain 8>
| | | | +-o AppleBluetoothHIDKeyboard <class IORegistryEntry:IOService:IOHIDDevice:IOBluetoothHIDDriver:IOAppleBluetoothHIDDriver:AppleBluetoothHIDKeyboard, id 0x100000f2f, registered, matched, active, busy 0 (8 ms), retain 9>
| | | | +-o IOHIDInterface <class IORegistryEntry:IOService:IOHIDInterface, id 0x100000f34, registered, matched, active, busy 0 (7 ms), retain 7>
| | | | | +-o AppleEmbeddedKeyboard <class IORegistryEntry:IOService:IOHIDEventService:IOHIDEventDriver:AppleEmbeddedKeyboard, id 0x100000f36, registered, matched, active, busy 0 (0 ms), retain 8>
| | | | | +-o IOHIDEventServiceUserClient <class IORegistryEntry:IOService:IOUserClient:IOHIDEventServiceUserClient, id 0x100000f3a, !registered, !matched, active, busy 0, retain 6>
| | | | +-o IOHIDLibUserClient <class IORegistryEntry:IOService:IOUserClient:IOHIDLibUserClient, id 0x100000f35, !registered, !matched, active, busy 0, retain 6>
| | | +-o IOBluetoothL2CAPChannel <class IORegistryEntry:IOService:IOBluetoothObject:IOBluetoothL2CAPChannel, id 0x100000f32, registered, matched, active, busy 0 (0 ms), retain 7>

ioreg -l:

  | | | | +-o AppleBluetoothHIDKeyboard  <class AppleBluetoothHIDKeyboard, id 0x100000f2f, registered, matched, active, busy 0 (8 ms), retain 9>
| | | | | {
| | | | | "PrimaryUsagePage" = 1
| | | | | "MaxInputReportSize" = 9
| | | | | "IOUserClientClass" = "IOHIDLibUserClient"
| | | | | "BatteryPanic" = No
| | | | | "ReportDescriptor" = <05010906a1018501050719e029e71500250175019508810275089501810175019505050819012905910275039501910175089506150026ff00050719002aff008100c0050c0901a101854705010906a10205060920150026ff00750895018102c0c0050c0901a10185111500250175019503810175019501050c09b8810206ff0009038102750195038101050c8512150025017501950109cd810209b3810209b$
| | | | | "VendorID" = 1452
| | | | | "VersionNumber" = 80
| | | | | "DeviceAddress" = "00-25-bc-fb-2b-db"
| | | | | "SuspendSupported" = Yes
| | | | | "HIDVirtualDevice" = No
| | | | | "ExtendedFeatures" = {"FullFactoryDefault"={"id"=68,"type"=2},"RecantConnection"={"id"=65,"type"=2},"DeviceNameChange"={"id"=80,"type"=2},"DeviceName1"={"id"=81,"size"=8,"type"=2},"DeviceName2"={"id"=82,"size"=8,"type"=2},"DeviceName3"={"id"=83,"size"=8,"type"=2},"LongDeviceName"={"id"=85,"size"=64,"type"=2},"DeviceName4"={"id"=84,"size"=8,"$
| | | | | "MaxFeatureReportSize" = 4
| | | | | "Product" = "(my name)'s keyboard"
| | | | | "SerialNumber" = "00-25-bc-fb-2b-db"
| | | | | "PSM" = 17
| | | | | "BatteryLow" = No
| | | | | "Transport" = "Bluetooth"
| | | | | "Elements" = ({"ReportID"=0,"ElementCookie"=1,"CollectionType"=1,"Type"=513,"Elements"=({"UnitExponent"=0,"IsRelative"=No,"UsagePage"=7,"Max"=1,"IsArray"=No,"Min"=0,"Type"=2,"Size"=1,"Flags"=2,"ReportID"=1,"Usage"=224,"ReportCount"=1,"Unit"=0,"HasNullState"=No,"IsNonLinear"=No,"HasPreferredState"=Yes,"ReportSize"=1,"ScaledMin"=0,"IsWrapping"$
| | | | | "SetReportTimeoutMS" = 3500
| | | | | "BatteryLowNotificationType" = "LowBattery"
| | | | | "Manufacturer" = "Apple"
| | | | | "ConnectionNotificationType" = "Connected"
| | | | | "ProductID" = 569
| | | | | "PoweredOffNotificationType" = "KeyboardOff"
| | | | | "IOPowerManagement" = {"CapabilityFlags"=32768,"MaxPowerState"=1,"CurrentPowerState"=1}
| | | | | "BatteryDangerouslyLowNotificationType" = "CriticallyLowBattery"
| | | | | "BD_ADDR" = <0025bcfb2bdb>
| | | | | "DeviceUsagePairs" = ({"DeviceUsagePage"=1,"DeviceUsage"=6},{"DeviceUsagePage"=12,"DeviceUsage"=1})
| | | | | "BatteryPercent" = 29
| | | | | "ClassOfDevice" = 9536
| | | | | "BTHIDObjectID" = 1378462720
| | | | | "InputReportElements" = ({"ReportID"=1,"ElementCookie"=292,"Size"=72,"ReportCount"=1,"Type"=1,"UsagePage"=0,"ReportSize"=72,"Usage"=0},{"ReportID"=71,"ElementCookie"=293,"Size"=16,"ReportCount"=1,"Type"=1,"UsagePage"=0,"ReportSize"=16,"Usage"=0},{"ReportID"=17,"ElementCookie"=294,"Size"=16,"ReportCount"=1,"Type"=1,"UsagePage"=0,"ReportSize"=$
| | | | | "ReportInterval" = 11250
| | | | | "VendorIDSource" = 2
| | | | | "CFBundleIdentifier" = "com.apple.driver.AppleBluetoothHIDKeyboard"
| | | | | "MaxOutputReportSize" = 2
| | | | | "IOCFPlugInTypes" = {"7DDEECA8-A7B4-11DA-8A0E-0014519758EF"="IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin","FA12FA38-6F1A-11D4-BA0C-0005028F18D5"="IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin"}
| | | | | "IOProviderClass" = "IOBluetoothL2CAPChannel"
| | | | | "LocationID" = 1023093723
| | | | | "IOClass" = "AppleBluetoothHIDKeyboard"
| | | | | "DisconnectionNotificationType" = "Disconnected"
| | | | | "PrimaryUsage" = 6
| | | | | "HIDDefaultBehavior" = ""
| | | | | "CountryCode" = 33
| | | | | "IOGeneralInterest" = "IOCommand is not serializable"
| | | | | "IOMatchCategory" = "IODefaultMatchCategory"
| | | | | "DeviceOpenedByEventSystem" = Yes
| | | | | "IOProbeScore" = 2100
| | | | | "GetReportTimeoutMS" = 3500
| | | | | "DebuggingOn" = No
| | | | | "BatteryState" = 0
| | | | | }

和ioreg -c AppleBluetoothHIDKeyboard | grep 电池`:

$ ioreg -c AppleBluetoothHIDKeyboard | grep Battery
| | | | | "BatteryPanic" = No
| | | | | "ExtendedFeatures" = {"FullFactoryDefault"={"id"=68,"type"=2},"RecantConnection"={"id"=65,"type"=2},"DeviceNameChange"={"id"=80,"type"=2},"DeviceName1"={"id"=81,"size"=8,"type"=2},"DeviceName2"={"id"=82,"size"=8,"type"=2},"DeviceName3"={"id"=83,"size"=8,"type"=2},"LongDeviceName"={"id"=85,"size"=64,"type"=2},"DeviceName4"={"id"=84,"size"=8,"type"=2},"BatteryState"={"size"=1,"id"=48,"min"=0,"max"=2,"type"=0},"BatteryPercent"={"size"=1,"id"=71,"min"=0,"max"=100,"type"=2},"WillShutdown"={"id"=64,"type"=2},"UserMode"={"size"=1,"id"=67,"min"=1,"max"=3,"type"=2},"FactoryDefault"={"id"=69,"type"=2}}
| | | | | "BatteryLow" = No
| | | | | "BatteryLowNotificationType" = "LowBattery"
| | | | | "BatteryDangerouslyLowNotificationType" = "CriticallyLowBattery"
| | | | | "BatteryPercent" = 29
| | | | | "BatteryState" = 0

关于swift - Apple 蓝牙 2009 ANSI 键盘的 ProductID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44275413/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com