jimu-decompiled/sources/com/afunx/ble/blelitelib/operation/BleWriteCharacteristicNoResponseOperation.java
2025-05-13 19:24:51 +02:00

55 lines
2.1 KiB
Java

package com.afunx.ble.blelitelib.operation;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import com.afunx.ble.blelitelib.log.BleLiteLog;
/* loaded from: classes.dex */
public class BleWriteCharacteristicNoResponseOperation extends BleOperationAbs {
private static final String TAG = "BleWriteCharacteristicNoResponseOperation";
private final BluetoothGatt mBluetoothGatt;
private final BluetoothGattCharacteristic mCharacteristic;
private final byte[] mMsg;
private BleWriteCharacteristicNoResponseOperation(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic bluetoothGattCharacteristic, byte[] bArr) {
this.mBluetoothGatt = bluetoothGatt;
this.mCharacteristic = bluetoothGattCharacteristic;
this.mMsg = bArr;
}
public static BleWriteCharacteristicNoResponseOperation createInstance(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic bluetoothGattCharacteristic, byte[] bArr) {
return new BleWriteCharacteristicNoResponseOperation(bluetoothGatt, bluetoothGattCharacteristic, bArr);
}
@Override // com.afunx.ble.blelitelib.operation.BleOperationAbs
protected void clearConcurrentOperation() {
}
@Override // com.afunx.ble.blelitelib.operation.BleOperation
public int getOperatcionCode() {
return 8;
}
@Override // com.afunx.ble.blelitelib.operation.BleOperation, java.lang.Runnable
public void run() {
this.mCharacteristic.setValue(this.mMsg);
this.mCharacteristic.setWriteType(1);
boolean z = false;
for (int i = 0; !z && i < 3; i++) {
if (i > 0) {
try {
Thread.sleep(50L);
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
z = this.mBluetoothGatt.writeCharacteristic(this.mCharacteristic);
}
if (z) {
return;
}
BleLiteLog.e(TAG, "writeCharacteristic() fail");
}
}