fetchUuidsWithSdp 中奇怪的 UUID 反转

Cob*_*les 4 python uuid android bluetooth endianness

我有一个在树莓派上运行的 python 蓝牙服务器(使用 PyBluez)。我在服务器中使用的 uuid 是:

8f86d132-4ab8-4c15-b8df-0b70cf10ea56

device.fetchUuidsWithSdp()在我的 Android 应用程序中调用蓝牙服务器。当它最终获取 uuid 时,它们以两个为一组反转(似乎字节序已更改)。

在广播接收器中:

Parcelable[] uuids = intent.getParcelableArrayExtra(BluetoothDevice.EXTRA_UUID);
if (uuids != null) {
    if (uuids.length > 0) {
         for (Parcelable uuid : uuids) {
              Utilities.err(uuid.toString());
         }
    } else {
         Utilities.err("no uuids");
    }
} 
Run Code Online (Sandbox Code Playgroud)

例如:

8f86d132-4ab8-4c15-b8df-0b70cf10ea56 -> 56ea10cf-700b-dfb8-154c-b84a32d1868f

看前两个字符8f,它们是反向uuid的最后两个字符。

看后两个字符86,它们是反向uuid的倒数第二个字符

这是什么原因造成的?

这与 UUID 是小端还是大端有什么关系吗?

小智 5

您是否有机会在 android 版本 6.0.1 上遇到此问题?可悲的是,android 中似乎有一个错误导致了这一点。 https://code.google.com/p/android/issues/detail?id=197341