我无法与Android中的Mi Band 2保持连接。当我尝试从Mi频段获取心率时,它会断开连接。连接仅停留几秒钟。
这就是我授权Mi乐队的方式。
info.plist
这就是我在GetHeartRate按钮上所做的。令人遗憾的是,当我按下此按钮时,它断开了连接。除此之外,它不会获得HeartRate。
private void authoriseMiBand() {
BluetoothGattService service = gatt.getService(UUIDs.CUSTOM_SERVICE_FEE1);
BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUIDs.CUSTOM_SERVICE_AUTH_CHARACTERISTIC);
gatt.setCharacteristicNotification(characteristic, true);
for (BluetoothGattDescriptor descriptor : characteristic.getDescriptors()) {
if (descriptor.getUuid().equals(UUIDs.CUSTOM_SERVICE_AUTH_DESCRIPTOR)) {
Log.d("INFO", "Found NOTIFICATION BluetoothGattDescriptor: " + descriptor.getUuid().toString());
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
}
}
characteristic.setValue(new byte[]{0x01, 0x8, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45});
gatt.writeCharacteristic(characteristic);
}