diff --git a/app/src/main/assets/web/asset-manifest.json b/app/src/main/assets/web/asset-manifest.json
index a4360cf..b439831 100644
--- a/app/src/main/assets/web/asset-manifest.json
+++ b/app/src/main/assets/web/asset-manifest.json
@@ -1,7 +1,7 @@
{
"files": {
- "main.css": "/static/css/main.1950d39d.css",
- "main.js": "/static/js/main.7cfdbd68.js",
+ "main.css": "/static/css/main.e3637504.css",
+ "main.js": "/static/js/main.eb3940a2.js",
"static/js/453.e7f11a48.chunk.js": "/static/js/453.e7f11a48.chunk.js",
"static/media/icon_leftR.svg": "/static/media/icon_leftR.76cd3e03bb846b0bacb0a84808f24c36.svg",
"static/media/icon_tab3_u.svg": "/static/media/icon_tab3_u.6d18cbd7c4dc6a54f745fdfcc7716050.svg",
@@ -26,12 +26,12 @@
"static/media/icon_bluetooth.svg": "/static/media/icon_bluetooth.a48021d03233ba0570bf3960cddf6a65.svg",
"static/media/power.svg": "/static/media/power.544f6ce9a5b3e930a515cf130f9f9551.svg",
"static/media/icon_check_s_u.svg": "/static/media/icon_check_s_u.2c5e20bec088338dc1cb2161b5cba37d.svg",
- "main.1950d39d.css.map": "/static/css/main.1950d39d.css.map",
- "main.7cfdbd68.js.map": "/static/js/main.7cfdbd68.js.map",
+ "main.e3637504.css.map": "/static/css/main.e3637504.css.map",
+ "main.eb3940a2.js.map": "/static/js/main.eb3940a2.js.map",
"453.e7f11a48.chunk.js.map": "/static/js/453.e7f11a48.chunk.js.map"
},
"entrypoints": [
- "static/css/main.1950d39d.css",
- "static/js/main.7cfdbd68.js"
+ "static/css/main.e3637504.css",
+ "static/js/main.eb3940a2.js"
]
}
\ No newline at end of file
diff --git a/app/src/main/assets/web/index.html b/app/src/main/assets/web/index.html
index 85a5e94..30487d3 100644
--- a/app/src/main/assets/web/index.html
+++ b/app/src/main/assets/web/index.html
@@ -1 +1 @@
-
廓形仪
\ No newline at end of file
+廓形仪
\ No newline at end of file
diff --git a/app/src/main/java/com/iflytop/profilometer/api/ble/BleApi.java b/app/src/main/java/com/iflytop/profilometer/api/ble/BleApi.java
index c277a37..a60acfb 100644
--- a/app/src/main/java/com/iflytop/profilometer/api/ble/BleApi.java
+++ b/app/src/main/java/com/iflytop/profilometer/api/ble/BleApi.java
@@ -10,6 +10,7 @@ import com.iflytop.profilometer.core.bluetooth.BleManager;
import com.iflytop.profilometer.core.bluetooth.BlePingManager;
import com.iflytop.profilometer.core.system.SystemService;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -67,30 +68,36 @@ public class BleApi {
public String connect(String mac) {
// 如果已经有一次连接在进行,就立刻返回
if (!isConnecting.compareAndSet(false, true)) {
- Log.w(LogTag.PROFILOMENTER, "已有连接操作进行中,忽略本次请求");
+ Log.i(LogTag.PROFILOMENTER, "已有连接操作进行中,忽略本次请求");
return Result.failed("连接中,请稍后再试");
}
- for (int i = 0; i < 2; i++) {
- try {
- boolean connect = BleManager.getInstance().connectToDeviceSync(mac);
- if (connect) {
- BleDeviceDriver bleDeviceDriver = SystemService.getInstance().getBleDeviceDriver();
- bleDeviceDriver.stopSampling();
- BlePingManager.getInstance().startPing();
- return Result.success();
- } else {
- throw new RuntimeException();
- }
- } catch (Exception e) {
+ try {
+ for (int i = 0; i < 3; i++) {
try {
- Thread.sleep(1000);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
+ boolean connect = BleManager.getInstance().connectToDeviceSync(mac);
+ if (connect) {
+ CompletableFuture.runAsync(() -> {
+ BleDeviceDriver bleDeviceDriver = SystemService.getInstance().getBleDeviceDriver();
+ bleDeviceDriver.stopSampling();
+ BlePingManager.getInstance().startPing();
+ });
+ return Result.success();
+ } else {
+ throw new RuntimeException();
+ }
+ } catch (Exception e) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
+ }
+ Log.e(LogTag.PROFILOMENTER, "链接蓝牙设备失败,第" + (i + 1) + "次", e);
}
- Log.e(LogTag.PROFILOMENTER, "链接蓝牙设备失败,第" + (i + 1) + "次", e);
}
+ return Result.failed("链接蓝牙设备失败");
+ } finally {
+ isConnecting.set(false);
}
- return Result.failed("链接蓝牙设备失败");
}
/**
diff --git a/app/src/main/java/com/iflytop/profilometer/core/bluetooth/BleManager.java b/app/src/main/java/com/iflytop/profilometer/core/bluetooth/BleManager.java
index 06b62ed..2b90c1b 100644
--- a/app/src/main/java/com/iflytop/profilometer/core/bluetooth/BleManager.java
+++ b/app/src/main/java/com/iflytop/profilometer/core/bluetooth/BleManager.java
@@ -474,9 +474,9 @@ public class BleManager {
return false;
}
- // 同步等待最大 15 秒
+ // 同步等待最大 5 秒
try {
- if (!latch.await(15, TimeUnit.SECONDS)) {
+ if (!latch.await(5, TimeUnit.SECONDS)) {
Log.e(LogTag.PROFILOMENTER, "连接超时");
disconnect();
return false;
@@ -500,8 +500,10 @@ public class BleManager {
SharedPreferences.Editor editor = prefs.edit();
editor.putString("mac_address", macAddress);
editor.apply();
+ Log.d(LogTag.PROFILOMENTER, "设备链接完毕");
return true;
} else {
+ Log.d(LogTag.PROFILOMENTER, "设备链接失败");
return false;
}
}
diff --git a/app/src/main/java/com/iflytop/profilometer/core/sync/UploadManager.java b/app/src/main/java/com/iflytop/profilometer/core/sync/UploadManager.java
index cb4184b..586f1f8 100644
--- a/app/src/main/java/com/iflytop/profilometer/core/sync/UploadManager.java
+++ b/app/src/main/java/com/iflytop/profilometer/core/sync/UploadManager.java
@@ -1,8 +1,10 @@
package com.iflytop.profilometer.core.sync;
import android.annotation.SuppressLint;
+import android.util.Log;
import com.iflytop.profilometer.ProfilometerApplication;
+import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.common.constant.SyncStatusType;
import com.iflytop.profilometer.common.constant.SystemConfigType;
import com.iflytop.profilometer.common.enums.SyncStatus;
@@ -40,7 +42,6 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
public class UploadManager {
- private static final String TAG = "UploadThread";
private final BlockingQueue uploadQueue = new LinkedBlockingQueue<>();
private volatile int fail = 0;
@@ -56,9 +57,11 @@ public class UploadManager {
try {
// 阻塞获取任务,队列为空时会一直等待
Long uploadId = uploadQueue.take();
+ Log.i(LogTag.PROFILOMENTER, "开始处理上传 : " + uploadId);
boolean result = false;
try {
result = processUpload(uploadId);
+ Log.i(LogTag.PROFILOMENTER, "上传结果 : " + result);
} catch (Exception e) {
fail++;
}
@@ -205,9 +208,21 @@ public class UploadManager {
}
}
} else {
+ fail++;
+ profileRecordDescription.setSyncStatus(SyncStatus.fail);
+ syncTask.setSyncStatus(SyncStatus.fail);
+ syncTask.setErrorMsg("网络链接错误");
+ profileRecordDao.updateProfileRecord(profileRecordDescription);
+ syncTaskDao.updateSyncTask(syncTask);
return false;
}
} catch (IOException ignored) {
+ fail++;
+ profileRecordDescription.setSyncStatus(SyncStatus.fail);
+ syncTask.setSyncStatus(SyncStatus.fail);
+ syncTask.setErrorMsg("网络链接错误");
+ profileRecordDao.updateProfileRecord(profileRecordDescription);
+ syncTaskDao.updateSyncTask(syncTask);
return false;
}
} else if (profileRecordDescription.getDataSource().equals("DCDC")) {
@@ -252,9 +267,21 @@ public class UploadManager {
}
}
} else {
+ fail++;
+ profileRecordDescription.setSyncStatus(SyncStatus.fail);
+ syncTask.setSyncStatus(SyncStatus.fail);
+ syncTask.setErrorMsg("网络链接错误");
+ profileRecordDao.updateProfileRecord(profileRecordDescription);
+ syncTaskDao.updateSyncTask(syncTask);
return false;
}
} catch (IOException ignored) {
+ fail++;
+ profileRecordDescription.setSyncStatus(SyncStatus.fail);
+ syncTask.setSyncStatus(SyncStatus.fail);
+ syncTask.setErrorMsg("网络链接错误");
+ profileRecordDao.updateProfileRecord(profileRecordDescription);
+ syncTaskDao.updateSyncTask(syncTask);
return false;
}
} else {