gpt4 book ai didi

Android 到 Linux 蓝牙找不到所有 UUID

转载 作者:太空宇宙 更新时间:2023-11-04 09:16:02 29 4
gpt4 key购买 nike

我正在尝试通过蓝牙在 Android 设备和 Linux 设备之间进行通信。使用此代码通过 DBUS 通过 bluez 注册配置文件后:

bus = dbus.SystemBus()
bluezObj = bus.get_object(BUS_NAME, "/org/bluez")

profilePath = "/test/profile"
profile = Profile(bus, profilePath)

profileManager = dbus.Interface(bluezObj, "org.bluez.ProfileManager1")
profileManager.RegisterProfile(profile, uuid, dbus.Dictionary({
"name": "EntireData Hardware Interface",
"Service": uuid,
"Role": "server"
}, signature="sv"))

loop = GLib.MainLoop()
loop.run()

在此之后,我可以通过运行 bluetoothctl 并输入 show 来查看配置文件的 uuid:

[bluetooth]# show
Controller B8:27:EB:6C:B7:E5
Class: 0x000100
Modalias: usb:v1D6Bp0246d052B
...
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: Vendor specific (94f39d29-7d6d-437d-973b-fba39e49d4ee)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)

但是尝试从 Android 设备查询 UUID,并不是所有的都显示出来:

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
final Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
for(BluetoothDevice device : pairedDevices) {
ParcelUuid[] uuids = device.getUuids();
for(ParcelUuid uuid : uuids) {
Log.d(TAG, "Found UUID: "+uuid);
}
}

只在日志中显示:

Found UUID: 0000110e-0000-1000-8000-00805f9b34fb
Found UUID: 00000000-0000-1000-8000-00805f9b34fb
Found UUID: eed4499e-a3fb-3b97-7d43-6d7d299df394

但不显示我添加的自定义项,如果我尝试连接到它会出错。如何连接到自定义配置文件/服务?

最佳答案

您在日志中看到的第三个 UUID 是您添加的。它面临字节序问题并以相反的顺序显示 UUID。

关于Android 到 Linux 蓝牙找不到所有 UUID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47700977/

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