佩戴状态有变化才触发回调

This commit is contained in:
peng 2025-07-08 11:45:27 +08:00
parent be97ea91d8
commit 53e8df1683

View File

@ -41,6 +41,7 @@ public class SerialPortHelper {
private GH3220MeasureCallback gh3220MeasureCallback;
private AlgoResultCallback algoResultCallback;
private boolean isSimulationMode = false;
private Boolean lastWearStatus = null;
private final ByteBuffer frameBuffer = ByteBuffer.allocate(1024);
public interface SendCallback {
@ -322,6 +323,7 @@ public class SerialPortHelper {
sendData(data, null);
}
public boolean open() {
try {
LogManager.d(TAG, "Opening serial port: " + mPortName + " with baud rate: " + mBaudRate);
@ -648,7 +650,10 @@ public class SerialPortHelper {
case ASR5515Protocol.Commands.CMD_WEAR_DETECTION_RESP:
ASR5515Protocol.WearDetectionResponse wearDetectionResponse = ASR5515Protocol.parseWearDetectionResponse(frame);
if (wearDetectionResponse != null && wearDetectionCallback != null) {
wearDetectionCallback.onWearDetectionResponse(wearDetectionResponse);
if (lastWearStatus == null || lastWearStatus != wearDetectionResponse.isWearing) {
wearDetectionCallback.onWearDetectionResponse(wearDetectionResponse);
lastWearStatus = wearDetectionResponse.isWearing;
}
}
break;