藍牙廣播中對服務 UUID 格式定義都有三種 16 bit UUID、32 bit UUID、128 bit UUID。
但是熟悉安卓開發的小伙伴都知道接口都 UUID 格式,fromString 時候 16bit 的 UUID 該咋辦呢?
16bit 和 32bit 的 UUID 與 128bit 的值之間轉換關系:
128_bit_UUID = 16_bit_UUID * 2^96 + Bluetooth_Base_UUID
128_bit_UUID = 32_bit_UUID * 2^96 + Bluetooth_Base_UUID
其中 Bluetooth_Base_UUID 定義為 00000000-0000-1000-8000-00805F9B34FB
如果你想說這是啥呀,那我這樣說你應該可以明白點:
若 16 bit UUID為xxxx,那么 128 bit UUID 為 0000xxxx-0000-1000-8000-00805F9B34FB
若 32 bit UUID為xxxxxxxx,那么 128 bit UUID 為 xxxxxxxx-0000-1000-8000-00805F9B34FB