我在 BLE 4.2 设备上运行具有自定义特征的自定义服务。我正在开发一个 android 应用程序来读取/写入特性等。我尝试的第一件事是读取特性。
我定义了一个 UUID 列表: List chars = new ArrayList<>();
我使用我知道的服务 UUID 创建一个服务: mCustomService = mBluetoothGatt.getService(MY_SERVICE_UUID);
我从我的服务中加载了 4 个已知 UUID 的列表:
chars.clear();
chars.add(UUID1);
chars.add(UUID2);
chars.add(UUID3);
chars.add(UUID4);
I read the first characteristic from the end of my list:
BluetoothGattCharacteristic mReadCharacteristic = mCustomService.getCharacteristic(chars.get(chars.size() - 1));
if(mReadCharacteristic != null)
mBluetoothGatt.readCharacteristic(mReadCharacteristic);
mReadCharacteristic 始终返回 null,服务不包含我的特征。
如果我使用 BLE“嗅探器”应用程序,那么我确实看到了所有特征。
谢谢
富有的
PS我无法弄清楚这里的格式!