0
从蓝牙android API获取android辅助蓝牙gatt服务。获取辅助蓝牙gatt服务android
目前下面是我们获取BLE服务代码:
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
List<BluetoothGattService> gattServices = mBluetoothGatt.getServices();
Log.e("onServicesDiscovered", "Services count: "+gattServices.size());
BluetoothGattService bleServ = mBluetoothGatt.getService(UUID.fromString("22222222-0000-0000-0000-000000000000"));
for (BluetoothGattService gattService : gattServices) {
String serviceUUID = gattService.getUuid().toString();
Log.e("onServicesDiscovered", "Service uuid "+serviceUUID);
}
} else {
Log.w(TAG, "onServicesDiscovered received: " + status);
}
}
即使试图获取独占次要业务,但它返回null对象:
BluetoothGattService bleServ = mBluetoothGatt.getService(UUID.fromString("22222222-0000-0000-0000-000000000000"));
有人能指出任何指针如何搜索Android中的二次可用服务。
感谢Emil的回应。即使我和我们的蓝牙堆栈开发者也有同样的讨论。您能否提供输入如何使辅助服务成为可连接外围设备上主要服务的一部分?我们的ble团队正在使用BlueZ堆栈,并且以下是他们所指的用于在设备上创建服务的链接https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt- api.txt – ASH
似乎它没有在BlueZ中实现“array {object} Includes [只读]:未实现”。你真的需要辅助服务吗?你不能使用主要服务吗? – Emil
有一个要求,不要将某些服务暴露给所有设备进行连接。只有允许连接可充电外围设备的设备才能够与其他辅助服务进行通信。 – ASH