Browse Source

feta:增加手动扫描功能

develop
白凤吉 2 months ago
parent
commit
ecd49a6eea
  1. 4
      app/build.gradle
  2. 12
      app/src/main/assets/web/asset-manifest.json
  3. 2
      app/src/main/assets/web/index.html
  4. 5
      app/src/main/java/com/iflytop/profilometer/api/ble/BleApi.java
  5. 22
      app/src/main/java/com/iflytop/profilometer/api/ws/BleWebsocketManager.java

4
app/build.gradle

@ -14,9 +14,9 @@ android {
minSdk 26 minSdk 26
targetSdk 35 targetSdk 35
// //
versionCode 27
versionCode 30
// //
versionName "1.1.27"
versionName "1.1.30"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

12
app/src/main/assets/web/asset-manifest.json

@ -1,7 +1,7 @@
{ {
"files": { "files": {
"main.css": "/static/css/main.85138b91.css",
"main.js": "/static/js/main.deeffa60.js",
"main.css": "/static/css/main.1950d39d.css",
"main.js": "/static/js/main.7cfdbd68.js",
"static/js/453.e7f11a48.chunk.js": "/static/js/453.e7f11a48.chunk.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_leftR.svg": "/static/media/icon_leftR.76cd3e03bb846b0bacb0a84808f24c36.svg",
"static/media/icon_tab3_u.svg": "/static/media/icon_tab3_u.6d18cbd7c4dc6a54f745fdfcc7716050.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/icon_bluetooth.svg": "/static/media/icon_bluetooth.a48021d03233ba0570bf3960cddf6a65.svg",
"static/media/power.svg": "/static/media/power.544f6ce9a5b3e930a515cf130f9f9551.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", "static/media/icon_check_s_u.svg": "/static/media/icon_check_s_u.2c5e20bec088338dc1cb2161b5cba37d.svg",
"main.85138b91.css.map": "/static/css/main.85138b91.css.map",
"main.deeffa60.js.map": "/static/js/main.deeffa60.js.map",
"main.1950d39d.css.map": "/static/css/main.1950d39d.css.map",
"main.7cfdbd68.js.map": "/static/js/main.7cfdbd68.js.map",
"453.e7f11a48.chunk.js.map": "/static/js/453.e7f11a48.chunk.js.map" "453.e7f11a48.chunk.js.map": "/static/js/453.e7f11a48.chunk.js.map"
}, },
"entrypoints": [ "entrypoints": [
"static/css/main.85138b91.css",
"static/js/main.deeffa60.js"
"static/css/main.1950d39d.css",
"static/js/main.7cfdbd68.js"
] ]
} }

2
app/src/main/assets/web/index.html

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><title>廓形仪</title><script defer="defer" src="/static/js/main.deeffa60.js"></script><link href="/static/css/main.85138b91.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>function setupWebViewJavascriptBridge(e){if(window.WebViewJavascriptBridge)return e(WebViewJavascriptBridge);if(/android/i.test(navigator.userAgent))document.addEventListener("WebViewJavascriptBridgeReady",(function(){e(WebViewJavascriptBridge)}),!1);else{if(window.WVJBCallbacks)return window.WVJBCallbacks.push(e);window.WVJBCallbacks=[e];var i=document.createElement("iframe");i.style.display="none",i.src="https://__bridge_loaded__",document.documentElement.appendChild(i),setTimeout((function(){document.documentElement.removeChild(i)}),0)}}setupWebViewJavascriptBridge((function(e){window.bridge=e}));var SyncBridgeJS={call:function(e,i){return prompt("sync/syncBridge/"+e,i)}}</script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><title>廓形仪</title><script defer="defer" src="/static/js/main.7cfdbd68.js"></script><link href="/static/css/main.1950d39d.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>function setupWebViewJavascriptBridge(e){if(window.WebViewJavascriptBridge)return e(WebViewJavascriptBridge);if(/android/i.test(navigator.userAgent))document.addEventListener("WebViewJavascriptBridgeReady",(function(){e(WebViewJavascriptBridge)}),!1);else{if(window.WVJBCallbacks)return window.WVJBCallbacks.push(e);window.WVJBCallbacks=[e];var i=document.createElement("iframe");i.style.display="none",i.src="https://__bridge_loaded__",document.documentElement.appendChild(i),setTimeout((function(){document.documentElement.removeChild(i)}),0)}}setupWebViewJavascriptBridge((function(e){window.bridge=e}));var SyncBridgeJS={call:function(e,i){return prompt("sync/syncBridge/"+e,i)}}</script></body></html>

5
app/src/main/java/com/iflytop/profilometer/api/ble/BleApi.java

@ -28,10 +28,7 @@ public class BleApi {
*/ */
public String start() { public String start() {
try { try {
BluetoothGatt bluetoothGatt = BleManager.getInstance().getBluetoothGatt();
if (bluetoothGatt == null) {
BleManager.getInstance().startScan();
}
BleManager.getInstance().startScan();
BleWebsocketManager.getInstance().startWsPush(); BleWebsocketManager.getInstance().startWsPush();
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {

22
app/src/main/java/com/iflytop/profilometer/api/ws/BleWebsocketManager.java

@ -3,7 +3,6 @@ package com.iflytop.profilometer.api.ws;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGatt;
import android.util.Log;
import com.iflytop.profilometer.core.bluetooth.BleManager; import com.iflytop.profilometer.core.bluetooth.BleManager;
import com.iflytop.profilometer.core.websocket.WebSocketManager; import com.iflytop.profilometer.core.websocket.WebSocketManager;
@ -56,17 +55,16 @@ public class BleWebsocketManager {
bleMap.put("name", gattDevice.getName()); bleMap.put("name", gattDevice.getName());
bleMap.put("linked", true); bleMap.put("linked", true);
bleList.add(bleMap); bleList.add(bleMap);
}else{
for (BluetoothDevice bluetoothDevice : scannedDevices) {
String mac = bluetoothDevice.getAddress();
boolean exists = bleList.stream() .anyMatch(map -> mac.equals(map.get("mac")));
if(! exists){
Map<String, Object> bleMap = new HashMap<>();
bleMap.put("mac", mac);
bleMap.put("name", bluetoothDevice.getName() == null ? "未命名" : bluetoothDevice.getName());
bleMap.put("linked", false);
bleList.add(bleMap);
}
}
for (BluetoothDevice bluetoothDevice : scannedDevices) {
String mac = bluetoothDevice.getAddress();
boolean exists = bleList.stream().anyMatch(map -> mac.equals(map.get("mac")));
if (!exists) {
Map<String, Object> bleMap = new HashMap<>();
bleMap.put("mac", mac);
bleMap.put("name", bluetoothDevice.getName() == null ? "未命名" : bluetoothDevice.getName());
bleMap.put("linked", false);
bleList.add(bleMap);
} }
} }
bleList.sort(Comparator.comparing(map -> (String) map.get("mac"))); bleList.sort(Comparator.comparing(map -> (String) map.get("mac")));

Loading…
Cancel
Save