zhunk 9 月之前
父節點
當前提交
8e485798de

+ 19 - 9
q6_felgo_iot/CMakeLists.txt

@@ -1,5 +1,4 @@
 cmake_minimum_required(VERSION 3.16)
-
 project(q6_felgo_iot VERSION 0.1 LANGUAGES CXX)
 
 set(CMAKE_AUTOMOC ON)
@@ -25,7 +24,7 @@ set(OPENCV_LIB_3RDPATHS
 
 set(SPDLOG_LIB_PATHS
     ##第三方库的绝对路径/
-    ${PROJECT_SOURCE_DIR}/../Lib/Spdlog/Android/felgo
+    ${PROJECT_SOURCE_DIR}/../Lib/Spdlog/Android/arm64-v8a
 )
 
 set(CURL_LIB_PATHS
@@ -149,6 +148,7 @@ set(QRC_FILES
     resources.qrc
 )
 
+
 qt_add_resources(QRC_SOURCES ${QRC_FILES})
 
 qt_add_shaders(q6_felgo_iot "shaders"
@@ -162,7 +162,9 @@ qt_add_shaders(q6_felgo_iot "shaders"
         "shaders/mandelbrot.frag"
 )
 
-
+file(GLOB MARKDOWN_FILES "*.md" "docs/*.md")  # 根据你的目录结构调整
+# 创建一个虚拟目标,仅用于在 IDE 中显示文件
+add_custom_target(docs SOURCES ${MARKDOWN_FILES})
 ## 链接路径
 if(WIN32)
     message(STATUS ${PROJECT_SOURCE_DIR})
@@ -214,14 +216,22 @@ if (ANDROID)
 target_link_libraries(q6_felgo_iot
   PRIVATE ${CURL_LIB_PATHS}/libcurl.so)
 target_link_libraries(q6_felgo_iot PRIVATE ${SPDLOG_LIB_PATHS}/libspdlog.a)
-target_link_libraries(q6_felgo_iot
-  PRIVATE libz.so)
+
+
+# 使用 CMake 的 FindZLIB 模块
+find_package(ZLIB)
+if(ZLIB_FOUND)
+    message(STATUS "Found zlib: ${ZLIB_LIBRARIES}")
+    target_link_libraries(q6_felgo_iot PRIVATE ${ZLIB_LIBRARIES})
+    target_include_directories(q6_felgo_iot PRIVATE ${ZLIB_INCLUDE_DIRS})
+else()
+    message(WARNING "ZLIB not found, trying alternative methods")
+endif()
+
 
 target_link_libraries(q6_felgo_iot
   PRIVATE ${LWJSON_PATH}/liblwjson.a)
 
-target_link_libraries(q6_felgo_iot
-  PRIVATE ${RGA_PATH}/librga.a)
 
 # target_link_libraries(q6_felgo_iot
 #     PRIVATE  ${LIBUVC_PATH}/libusb1.0.so  ${LIBUVC_PATH}/libuvc.so)
@@ -303,5 +313,5 @@ else()
 endif()
 # uncomment this line to add the Live Client Module and use live reloading with your custom C++ code
 # for the remaining steps to build a custom Live Code Reload app see here: https://felgo.com/custom-code-reload-app/
-#find_package(FelgoLive REQUIRED)
-#target_link_libraries(appq6_felgo_iot PRIVATE FelgoLive)
+# find_package(FelgoLive REQUIRED)
+# target_link_libraries(appq6_felgo_iot PRIVATE FelgoLive)

+ 83 - 34
q6_felgo_iot/CMakeLists.txt.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 14.0.1, 2026-01-17T09:42:38. -->
+<!-- Written by QtCreator 17.0.1, 2026-02-09T14:15:17. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
@@ -13,8 +13,8 @@
  <data>
   <variable>ProjectExplorer.Project.EditorSettings</variable>
   <valuemap type="QVariantMap">
+   <value type="bool" key="EditorConfiguration.AutoDetect">true</value>
    <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
-   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
    <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
    <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
     <value type="QString" key="language">Cpp</value>
@@ -33,6 +33,7 @@
    <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
    <value type="int" key="EditorConfiguration.IndentSize">4</value>
    <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
+   <value type="int" key="EditorConfiguration.LineEndingBehavior">0</value>
    <value type="int" key="EditorConfiguration.MarginColumn">80</value>
    <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
    <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
@@ -41,7 +42,7 @@
    <value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
    <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
    <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
-   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
+   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
    <value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
    <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
    <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
@@ -79,7 +80,7 @@
     <value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
     <value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
     <value type="int" key="ClangTools.ParallelJobs">6</value>
-    <value type="bool" key="ClangTools.PreferConfigFile">false</value>
+    <value type="bool" key="ClangTools.PreferConfigFile">true</value>
     <valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
     <valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
     <valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
@@ -91,9 +92,10 @@
   <variable>ProjectExplorer.Project.Target.0</variable>
   <valuemap type="QVariantMap">
    <value type="QString" key="DeviceType">Android.Device.Type</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">安卓 Qt 6.4.1 (android_arm64_v8a) Clang arm64-v8a</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">安卓 Qt 6.4.1 (android_arm64_v8a) Clang arm64-v8a</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{289dcc12-6f96-4fbb-9e60-49a727cf7110}</value>
+   <value type="bool" key="HasPerBcDcs">true</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">安卓 Qt 6.8.3 (android_arm64_v8a) Clang arm64-v8a</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">安卓 Qt 6.8.3 (android_arm64_v8a) Clang arm64-v8a</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e189f30a-a10f-4d05-a2ec-de17da0b4fec}</value>
    <value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
    <value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
    <value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
@@ -102,25 +104,28 @@
     <value type="int" key="CMake.Configure.BaseEnvironment">2</value>
     <value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
     <valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
-    <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+    <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DANDROID_ABI:STRING=arm64-v8a
+-DCMAKE_TOOLCHAIN_FILE:FILEPATH=F:/Android_Env/android_sdk/ndk/27.2.12479018/build/cmake/android.toolchain.cmake
+-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON
+-DCMAKE_FIND_ROOT_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DANDROID_STL:STRING=c++_shared
+-DCMAKE_GENERATOR:STRING=Ninja
+-DQT_USE_TARGET_ANDROID_BUILD_DIR:BOOL=ON
 -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DQT_HOST_PATH:PATH=%{Qt:QT_HOST_PREFIX}
--DQT_NO_GLOBAL_APK_TARGET_PART_OF_ALL:BOOL=ON
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DANDROID_NDK:PATH=F:/Android_Env/android-ndk-r23c
 -DANDROID_USE_LEGACY_TOOLCHAIN_FILE:BOOL=OFF
--DCMAKE_FIND_ROOT_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_TOOLCHAIN_FILE:FILEPATH=F:/Android_Env/android-ndk-r23c/build/cmake/android.toolchain.cmake
--DANDROID_SDK_ROOT:PATH=F:/Android_Env/android_sdk
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DANDROID_NATIVE_API_LEVEL:STRING=23
--DANDROID_ABI:STRING=arm64-v8a
--DCMAKE_BUILD_TYPE:STRING=Release
+-DQT_MAINTENANCE_TOOL:FILEPATH=D:/Qt/Felgo/MaintenanceTool.exe
+-DANDROID_PLATFORM:STRING=android-23
 -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DANDROID_NDK:PATH=F:/Android_Env/android_sdk/ndk/27.2.12479018
 -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DANDROID_STL:STRING=c++_shared
--DCMAKE_GENERATOR:STRING=Ninja</value>
-    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:\QT_WorkSpace\qt6_iot_all\build-q6_felgo_iot-Qt_6_4_1_android_arm64_v8a_Clang_arm64_v8a-Release</value>
+-DQT_HOST_PATH:PATH=%{Qt:QT_HOST_PREFIX}
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DANDROID_SDK_ROOT:PATH=F:/Android_Env/android_sdk
+-DQT_NO_GLOBAL_APK_TARGET_PART_OF_ALL:BOOL=ON
+-DCMAKE_BUILD_TYPE:STRING=Release</value>
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:\QT_WorkSpace\qt6_iot_all\q6_felgo_iot\build\Qt_6_8_3_android_arm64_v8a_Clang_arm64_v8a-Release</value>
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
       <value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
@@ -135,12 +140,11 @@
      </valuemap>
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
       <value type="QString" key="BuildTargetSdk">android-36</value>
-      <value type="QString" key="BuildToolsVersion">36.1.0</value>
+      <value type="QString" key="BuildToolsVersion"></value>
       <value type="QString" key="KeystoreLocation">F:/QT_WorkSpace/qt6_iot_all/key/android_release.keystore</value>
       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建安卓 APK</value>
       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QmakeProjectManager.AndroidBuildApkStep</value>
-      <value type="bool" key="VerboseOutput">true</value>
      </valuemap>
      <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
@@ -171,6 +175,59 @@
     <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
+    <value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
+    <value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidDeployQtStep</value>
+      </valuemap>
+      <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
+     <valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
+     <value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidDeployConfiguration2</value>
+    </valuemap>
+    <value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings">
+     <valuelist type="QVariantList" key="AndroidDeviceAbis">
+      <value type="QString">arm64-v8a</value>
+      <value type="QString">armeabi-v7a</value>
+      <value type="QString">armeabi</value>
+     </valuelist>
+     <value type="QString" key="AndroidDeviceSerialNumber">6fd587f33738dc9f</value>
+     <value type="int" key="AndroidVersion.ApiLevel">32</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
+     <value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
+     <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
+     <value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
+     <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
+     <value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
+     <valuelist type="QVariantList" key="Android.PostStartShellCmdListKey">
+      <value type="QString"></value>
+     </valuelist>
+     <valuelist type="QVariantList" key="Android.PreStartShellCmdListKey">
+      <value type="QString"></value>
+     </valuelist>
+     <valuelist type="QVariantList" key="CustomOutputParsers"/>
+     <value type="int" key="PE.EnvironmentAspect.Base">0</value>
+     <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
+     <value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
+     <value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">q6_felgo_iot</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:</value>
+     <value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">q6_felgo_iot</value>
+     <value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
+     <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
+     <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
+    </valuemap>
+    <value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
    </valuemap>
    <value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
@@ -190,18 +247,10 @@
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidDeployConfiguration2</value>
    </valuemap>
    <value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
-   <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings">
-    <valuelist type="QVariantList" key="AndroidDeviceAbis">
-     <value type="QString">arm64-v8a</value>
-     <value type="QString">armeabi-v7a</value>
-     <value type="QString">armeabi</value>
-    </valuelist>
-    <value type="QString" key="AndroidDeviceSerialNumber">6fd587f33738dc9f</value>
-    <value type="int" key="AndroidVersion.ApiLevel">32</value>
-   </valuemap>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
     <value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
     <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
+    <value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
     <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
     <value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
     <valuelist type="QVariantList" key="Android.PostStartShellCmdListKey">
@@ -216,7 +265,7 @@
     <value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
     <value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">q6_felgo_iot</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:q6_felgo_iot</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:</value>
     <value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">q6_felgo_iot</value>
     <value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
     <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>

+ 0 - 36
q6_felgo_iot/Readme.md

@@ -1,36 +0,0 @@
-## 20251206
-    #define APP_VERSION "1.3.21"
-    更新说明:
-        串口解析使用lwjson
-        取图接口调整
-        增加Y轴坐标校准
-## 20251113
-    #define APP_VERSION "1.3.20"
-    更新说明:
-        自动对焦:闪退问题解决,自动对焦过程中退出程序,再次启动APP后执行对焦拍照会触发闪退;
-        原因:GPS定位成功后释放时机,延迟释放即可解决;
-## 20251110
-    #define APP_VERSION "1.3.18"
-    更新说明:
-        修复主函数数据库逻辑问题;
-## 20251104
-    #define APP_VERSION "1.3.18"
-    更新说明:
-        修复mqtt不停上报最新数据问题;
-## 20251103
-    #define APP_VERSION "1.3.17"
-    更新说明:
-        修复读取/设置主板参数/数据后  mqtt不上报最新数据问题;
-
-#### 20251101
-    #define APP_VERSION "1.3.16"
-    更新说明:
-        修复FTP上传图片失败问题,构建curl时还未读取到IMEI
-## 20251101
-    #define APP_VERSION "1.3.15"
-    更新说明:
-        增加设置IMEI功能
-## 20250829
-    #define APP_VERSION "1.2.10"
-    更新说明:
-        增加每隔24小时系统重启;

+ 0 - 54
q6_felgo_iot/android/src/com/yfkj/cb/Q6iot/GetUsbPermission.java

@@ -20,9 +20,6 @@ import android.os.PowerManager;
 
 public class GetUsbPermission extends QtNative
 {
-
-    protected static UsbManager usbManager;
-    private static UsbDevice camdev = null;
     private static PowerManager.WakeLock wakeLock = null;
 
 //    public GetPermission()
@@ -60,57 +57,6 @@ public class GetUsbPermission extends QtNative
         return 1;
     }
 
-    public static int requestDevicePermission(UsbManager m_usbManager, int vid, int pid)
-    {
-        usbManager = m_usbManager;
-        Activity currentActivity = QtNative.activity();
-        HashMap<String, UsbDevice> deviceList = m_usbManager.getDeviceList();
-        Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
-        while(deviceIterator.hasNext())
-        {
-            UsbDevice device = deviceIterator.next();
-            if (device.getVendorId()== vid && device.getProductId()== pid)
-            {
-                Log.e("GetPermission/requestDevicePermission", "Find the device: " + device.getDeviceName());
-                camdev = device;
-                boolean permissionCheck = m_usbManager.hasPermission(camdev);
-                PendingIntent mPermissionIntent = PendingIntent.getActivity(QtNative.activity(),0,QtNative.activity().getIntent(),0);
-                if(!permissionCheck)m_usbManager.requestPermission(device, mPermissionIntent);
-                break;
-            }
-        }
-        if(camdev == null){
-            return 0;
-        }
-        return 1;
-    }
-
-    public static int checkPermission(){
-        boolean checkResult = usbManager.hasPermission(camdev);
-        Log.d("GetPermission/checkPermission", checkResult?"yes":"no");
-        int ret = 0;
-        if(checkResult)
-            ret = openDevice();
-        return ret;
-    }
-
-    private static int openDevice()
-    {
-
-        try {
-            UsbDeviceConnection devConn = usbManager.openDevice(camdev);
-            int fd = devConn.getFileDescriptor();
-            //devConn.close();
-            Log.e("GetPermission/openDevice","USB device FileDescriptor = " + fd);
-            return fd;
-        }
-        catch (Exception e) {
-            Log.wtf("GetPermission/openDevice","Exception catched when open device");
-            e.printStackTrace();
-            return 0;
-        }
-
-    }
     /**
      * 执行shell命令(需要root权限)
      */

+ 28 - 31
q6_felgo_iot/android/src/com/yfkj/cb/Q6iot/StatusBarCtr.java

@@ -9,9 +9,11 @@ import android.telephony.SignalStrength;
 import android.telephony.CellInfo;
 import android.telephony.CellInfoLte;
 
+
 import android.Manifest;
 import org.qtproject.qt.android.QtNative;
 import java.io.File;
+import android.content.pm.PackageManager;
 import android.content.ComponentName;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
@@ -43,6 +45,7 @@ import com.hjq.permissions.XXPermissions;   //申请权限的第三方框架
 //这是额外引入的android.support.v4的tar包;
 //因为自Android7.0起,直接通过Uri去parsePath的方式因为安全问题被禁用,改成FileProvider的方式
 import androidx.core.content.FileProvider;
+import androidx.core.app.ActivityCompat;
 
 public class StatusBarCtr {
     //private Context context; // 添加一个成员变量保存上下文
@@ -92,8 +95,8 @@ public class StatusBarCtr {
             e.printStackTrace();
         }
 
-        if (QtNative.activity() == null){
-            Log.e("QtNative.activity() == null","Error");
+        if (context == null){
+            Log.e("context == null","Error");
             return;
         }
         try {
@@ -154,6 +157,7 @@ public class StatusBarCtr {
         }
     }
 
+
     /**
      * 判断是否包含SIM卡
      *
@@ -173,42 +177,35 @@ public class StatusBarCtr {
         return result;
     }
 
-    public void getMobileNetworkSignal(Context mcontext) {
-        TelephonyManager telephonyManager = (TelephonyManager) mcontext.getSystemService(Context.TELEPHONY_SERVICE);
-        PhoneStateListener phoneStateListener = new PhoneStateListener() {
-            @Override
-            public void onSignalStrengthsChanged(SignalStrength signalStrength) {
-                super.onSignalStrengthsChanged(signalStrength);
-                int lteCsq = getLTECSQ(signalStrength);
-                // 这里的 lteCsq 就是 LTE 的 CSQ 值
-                // 可以在这里对 CSQ 值进行处理
-                Log.d("lteCsq" , String.valueOf(lteCsq));
 
-            }
-        };
-        telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
-    }
+    public static int getRsrp(Context context) {
+        TelephonyManager tm =
+                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
 
+        if (tm == null) return -999;
 
-    private int getLTECSQ(SignalStrength signalStrength) {
-            if (signalStrength != null) {
-                if (signalStrength.isGsm()) {
-                    return signalStrength.getGsmSignalStrength();
-                } else {
-                    try {
-                        // 通过反射获取 LTE 的信号强度
-                        // 该方法在不同的设备上可能会有所不同,请根据实际情况进行调整
-                        return (int) signalStrength.getClass().getMethod("getLteSignalStrength").invoke(signalStrength);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                }
+        if (ActivityCompat.checkSelfPermission(
+                context, Manifest.permission.ACCESS_FINE_LOCATION)
+                != PackageManager.PERMISSION_GRANTED) {
+            return -998;
+        }
+
+        List<CellInfo> infos = tm.getAllCellInfo();
+        if (infos == null) return -997;
+
+        for (CellInfo info : infos) {
+            if (info instanceof CellInfoLte) {
+                CellSignalStrengthLte lte =
+                        ((CellInfoLte) info).getCellSignalStrength();
+                return lte.getRsrp();   // ⭐ LTE 核心指标
             }
-            return 0;
+        }
+        return -996;
     }
+
     public String getICCID(Context context) {
         String iccid = "-1";
-        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);;
+        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
         if (telephonyManager.getSimState() == TelephonyManager.SIM_STATE_ABSENT) {
             // 没有SIM卡
             Log.e("getICCID","not found SIM card!");

+ 25 - 30
q6_felgo_iot/header/cameramanager.h

@@ -127,14 +127,12 @@ class Frames :public QObject//, public QQuickImageProvider //QObject  //
     Q_OBJECT
     QML_ELEMENT
     Q_PROPERTY( QVideoSink* videoSink READ videoSink WRITE setVideoSink NOTIFY videoSinkChanged )
-    Q_PROPERTY( qreal angle READ angle NOTIFY angleChanged )
-    Q_PROPERTY( qreal xScale READ xScale NOTIFY xScaleChanged )
-    Q_PROPERTY( qreal yScale READ yScale NOTIFY yScaleChanged )
     Q_PROPERTY( QString formatString READ formatString NOTIFY formatStringChanged )
     Q_PROPERTY( QString fpsString READ fpsString NOTIFY fpsStringChanged )
     Q_PROPERTY( QString qulityString READ qulityString NOTIFY qulityStringChanged )
     Q_PROPERTY( bool auto_clicked READ auto_clicked WRITE setChange NOTIFY btnStatusChanged )
     Q_PROPERTY( bool camera_sw READ camera_sw WRITE setCameraSw NOTIFY cameraStaChanged )
+    Q_PROPERTY(QString cam_ExposureTime READ cam_ExposureTime WRITE setExposureTime NOTIFY exposureTimeChanged)
 
 public:
     static void registerQmlType();
@@ -149,12 +147,9 @@ public:
     void setChange(bool stat_t);
     //! 相机状态
     void setCameraSw(bool stat_cam);
+
+    void setExposureTime(const QString &exptime);
     //! \return Rotation angle.
-    qreal angle() const;
-    //! \return X scale factor.
-    qreal xScale() const;
-    //! \return Y scale factor
-    qreal yScale() const;
     //! \return Format of video frame as string.
     QString formatString() const;
     //! \return FPS as string.
@@ -162,6 +157,8 @@ public:
 
     QString qulityString() const;
 
+    QString cam_ExposureTime() const;
+
     bool auto_clicked() const;
     bool camera_sw() const;
 
@@ -190,12 +187,10 @@ signals:
     //! Video sink changed.
     void videoSinkChanged();
     void cameraOpenFailed(const QString &err);
-    void angleChanged();
-    void xScaleChanged();
-    void yScaleChanged();
     void formatStringChanged();
     void fpsStringChanged();
     void qulityStringChanged();
+    void exposureTimeChanged();
     void frameAvailable(const QVideoFrame &frame);
     void frameReady(QImage image);
     void btnStatusChanged();
@@ -246,12 +241,7 @@ private slots:
     //!
     void update_qulstr(QString q_str);
     //
-    void readyForCapture(bool ready);
-    void processCapturedImage(int requestId, const QImage &img);
-    void imageSaved(int id, const QString &fileName);
-    void displayCaptureError(int id, const QImageCapture::Error error, const QString &errorString);
-    void displayCameraError();
-    void saveMatAsJpeg(const cv::Mat &mat);
+    void saveMatAsJpeg(const QVideoFrame &frame);
     //void sendData(QByteArray m_byte);
     void displayFrame(const QVideoFrame &frame);
     void mov_x_z_run();
@@ -259,12 +249,7 @@ private slots:
 private:
     Q_DISABLE_COPY( Frames )
 
-    //! Camera.
-    QCamera * m_cam;
     //声明相机捕获对象
-    //! Capture.
-    QMediaCaptureSession m_capture;
-    QImageCapture *m_imageCapture;
     //! Video sink of video output.
     //QPointer< QVideoSink > m_videoSink;
     QVideoSink *m_videoSink;
@@ -282,7 +267,6 @@ private:
     OpencvFunc m_opencvfunc;
     JsonFunc m_json;
 
-    QFuture<void> m_processThread;
     QFuture<void> m_grabThread;
 
     QJniObject *jClass;
@@ -291,14 +275,15 @@ private:
     bool m_decoding;
     bool m_streaming_active = false;
 
-    QSharedMemory sharedMemory;
-
     QImage m_image;
     int stitch_des;
+    int m_width;
+    int m_height;
+    QString m_fExposureTime;
     //ImageProvider *m_pImgProvider;
 
     //libuvc
-    mutable  QMutex frameMutex;  // 互斥锁,用于对帧队列的访问进行同步
+    mutable QMutex m_frameMutex;  // 互斥锁,用于对帧队列的访问进行同步
 
     FPSTimer* m_fps_timer = nullptr;
     cv::Mat m_frame;
@@ -311,8 +296,6 @@ private:
     int z_step = 0;
     int x_step = 0;
 
-    QMutex m_frameMutex;
-    std::unique_ptr<QVideoFrame> m_latestFrame;
     //图片归档路径
     QString picture_path_floader;
     QVector<cv::Mat> m_frame_buffer;
@@ -326,8 +309,6 @@ private:
         return ret;
     }
 
-    int requestPermission(int vid, int pid);
-
     static inline QImage  cvMatToQImage( const cv::Mat &inMat )
     {
         switch ( inMat.type() )
@@ -505,6 +486,20 @@ private:
             return false;
         }
     }
+    //地址的转换函数
+    bool ConvertToHexIp(unsigned int *nHexIP, unsigned int *nDecIP)
+    {
+        if ( nDecIP[0] < 0 || nDecIP[0] > 255
+            || nDecIP[1] < 0 || nDecIP[1] > 255
+            || nDecIP[2] < 0 || nDecIP[2] > 255
+            || nDecIP[3] < 0 || nDecIP[3] > 255)
+        {
+            return false;
+        }
+        *nHexIP = (nDecIP[0] << 24) + (nDecIP[1] << 16) + (nDecIP[2] << 8) + nDecIP[3];
+
+        return true;
+    }
 
 }; // class Frames
 } /* namespace Qt6QCamera */

+ 31 - 0
q6_felgo_iot/header/m_json.h

@@ -8,6 +8,7 @@
 #include <QObject>
 #include <QTextCodec>
 #include <QTime>
+#include <QProcess>
 
 class JsonFunc : public QObject
 {
@@ -37,6 +38,36 @@ signals:
 public slots:
     void setmqttState_d();
     void setmqttState_c();
+private:
+    QString getLteRsrp()
+    {
+        QProcess proc;
+        QStringList args;
+        args << "-c"
+             << "dumpsys telephony.registry | grep -o \"rsrp=-[0-9]*\" | head -n 1";
+
+        proc.start("sh", args);
+        proc.waitForFinished(1000);
+
+        QString out = QString::fromLocal8Bit(proc.readAllStandardOutput()).trimmed();
+
+        // out 形如: "rsrp=-103"
+        QRegularExpression re("rsrp=(-?\\d+)");
+        QRegularExpressionMatch match = re.match(out);
+        if (match.hasMatch()) {
+            if(match.captured(1).toInt()>=-80){
+                return "优秀";
+            }else if(match.captured(1).toInt()>=-90){
+                return "良好";
+            }else if (match.captured(1).toInt()>=-105) {
+                return "一般";
+            } else {
+                return "差";
+            }
+        }
+
+        return "无信号";  // 无效值
+    }
 
 };
 

+ 1 - 1
q6_felgo_iot/header/main.h

@@ -37,7 +37,7 @@
 #include <opencv2/features2d/features2d.hpp>
 #include <opencv2/xfeatures2d/nonfree.hpp>
 
-#define APP_VERSION "1.3.21"
+#define APP_VERSION "1.5.23"
 
 using namespace std;
 

+ 1 - 0
q6_felgo_iot/header/mqtthandler.h

@@ -132,6 +132,7 @@ signals:
     void appInstall();
     void signal_reupload_image(const QString &path);
     void signal_imei_change(const QString &new_imei);
+    void signal_upload_log(const QString &path);
 public slots:
     void install_app();
     void startReupload();

+ 2 - 1
q6_felgo_iot/header/mserial.h

@@ -154,7 +154,7 @@ private slots:
                 lwjson_stream_reset(&lwparser);
                 break;
             default: // 流式解析时, 其它的返回值, 都不应该出现
-                ERROR("未知错误:{}",ret);
+                ERROR("未知错误:{:d}",static_cast<int>(ret));
                 break;
             }
         }
@@ -165,6 +165,7 @@ private:
     QTimer* timeout_mov = nullptr;
     QSerialPort m_serialPort;
     SqliteOperator *sqlConfig;
+    mutable QMutex m_writeMutex;
     bool m_running;
     bool data_upload;
     int connect_board; //主板串口连接状态

+ 9 - 4
q6_felgo_iot/qml/pages/HomePage.qml

@@ -357,15 +357,18 @@ AppPage {
                                     text: "0"
                                     font.family: "Arial"
                                     font.pixelSize: 20
+                                    wrapMode: Text.NoWrap
+                                    inputMethodHints: Qt.ImhMultiLine
 
                                     // 使用验证器替代inputMask
                                     validator: DoubleValidator {
-                                        decimals: 2
+                                        decimals: 0
+                                        notation: DoubleValidator.StandardNotation
                                     }
 
                                     property real numericValue_x: Number(text) || 0
 
-                                    onAccepted: {
+                                    Keys.onReturnPressed: {
                                         console.log("X坐标:", numericValue_x)
                                         serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
                                         coordinateInputs.visible = false
@@ -404,15 +407,17 @@ AppPage {
                                     text: "0"
                                     font.family: "Arial"
                                     font.pixelSize: 20
+                                    wrapMode: Text.NoWrap
 
+                                    inputMethodHints: Qt.ImhMultiLine
                                     // 使用验证器替代inputMask
                                     validator: DoubleValidator {
-                                        decimals: 2
+                                        decimals: 0
                                     }
 
                                     property real numericValue_y: Number(text) || 0
 
-                                    onAccepted: {
+                                    Keys.onReturnPressed: {
                                         console.log("Y坐标:", numericValue_y)
                                         serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
                                         coordinateInputs.visible = false

+ 1 - 0
q6_felgo_iot/qml/pages/SqlScreen.qml

@@ -56,6 +56,7 @@ AppPage {
         //initData:  []//myClass.getdata_JsonArray()
         //initData: []
     }
+
     //表格内容(不包含表头)
     TableView{
         id: table_view

+ 400 - 377
q6_felgo_iot/qml/pages/TestPage.qml

@@ -25,6 +25,7 @@ AppPage {
     property var axisPositions: [0, 0, 0]  // 各轴当前位置
     property int speed: 50  // 当前速度 (0-100)
     property int stepDistance: 20  // 步进脉冲数量
+    property string fExposureTime: "0"
 
     function autotake(sw){
         if(sw)
@@ -92,6 +93,10 @@ AppPage {
             console.log("坐标改变",step)
             step_apptextfield.text = step
         }
+
+        onExposureTimeChanged: {
+            fExposureTime = frames.cam_ExposureTime
+        }
     }
 
 
@@ -143,11 +148,12 @@ AppPage {
     }
 
 
-    Row{
+    SplitView{
         anchors.fill: parent
-        spacing: 5
+        orientation: Qt.Horizontal
+
         Rectangle {
-            width: parent.width*0.7
+            SplitView.preferredWidth: parent.width * 0.7
             height: parent.height
             color: app.cardColor
             radius: 5
@@ -157,6 +163,7 @@ AppPage {
               //anchors.horizontalCenter: parent.horizontalCenter
               anchors.centerIn: parent
               anchors.fill: parent
+
               //text: "打开相机"
               flat: true    //边框是否可视
               onClicked: {
@@ -176,6 +183,27 @@ AppPage {
                      //uvc_camera.visible  = true
                 }
               }
+
+              Timer {
+                  id: longPressTimer
+                  interval: 1000 // 长按时间1000ms
+                  running: false // 初始状态下定时器停止
+                  repeat: false // 设置为false,以便只执行一次
+                  onTriggered: {
+                        console.log("长按触发")
+                  }
+              }
+
+              onPressed: {
+                  console.log("按钮按下,开始计时")
+                  longPressTimer.start()
+              }
+
+              onReleased: {
+                  console.log("按钮释放,停止计时")
+                  longPressTimer.stop()
+              }
+
               AppImage{
                   id: image_picdis
                   anchors.centerIn: parent
@@ -183,14 +211,6 @@ AppPage {
               }
             }
 
-//            AppImage {
-//                id: uvc_camera
-//                visible: false
-//                anchors.fill: parent
-//                cache: false
-//                source: "image://UCamera"
-//            }
-
             VideoOutput
             {
                 id: output
@@ -221,435 +241,438 @@ AppPage {
                 }
             }
         }
-        Rectangle {
-            width: parent.width*0.29
-            height: parent.height
-            color: app.cardColor
-            radius: 5
 
-            Rectangle{
-                id: rec_test
-                anchors.top: text_title.bottom
-                anchors.topMargin: 5
-                anchors.left: parent.left
-                width: parent.width*0.97
-                height: parent.height *0.6
-                border.width: 1
-                border.color: "white"
-                radius: 5
-                color: app.cardColor
-                Column {
-                    anchors.top: text_title.bottom
-                    anchors.left: parent.left
-                    anchors.leftMargin: 10
-                    spacing: dp(15)
-
-                    Row
-                    {
-                        spacing: 80
-
-                        AppText {
-                            id: text_title
-                            text: "测试调试"
-                            font.bold: true
-                            color: "#28a779"
-                            fontSize: 20
-                        }
+        ScrollView
+        {
+            SplitView.preferredWidth: parent.width*0.29
+            SplitView.minimumWidth: 200
+            clip: true
+            Column {
+                spacing: dp(15)
+                Row {
+                    spacing: 80
+                    AppText {
+                        id: text_title
+                        text: "测试调试"
+                        font.bold: true
+                        color: "#28a779"
+                        fontSize: 20
+                    }
 
-                        AppText {
-                            id: apptext_res
-                            text: "[测试结果]"
-                            fontSize:15
-                            color: "grey"
-                            anchors.verticalCenter: text_title.verticalCenter
-                        }
+                    AppText {
+                        id: apptext_res
+                        text: "[测试结果]"
+                        fontSize:15
+                        color: "grey"
+                        anchors.verticalCenter: text_title.verticalCenter
                     }
+                }
 
-                    Row {
-                        spacing: 100
+                Row {
+                    spacing: 100
 
-                        AppText{
-                            text: "一键测试"
-                            fontSize:  15
-                            color: app.fontColor
-                            //font.bold: true
-                            anchors.verticalCenter: autotest_switch.verticalCenter
-                        }
+                    AppText{
+                        text: "一键测试"
+                        fontSize:  15
+                        color: app.fontColor
+                        //font.bold: true
+                        anchors.verticalCenter: autotest_switch.verticalCenter
+                    }
 
-                        AppSwitch {
-                            id: autotest_switch
-                            onToggled: {
-                                if(autotest_switch.checked==true){
-                                    autotest_switch.enabled = false
-                                    serial.sendCmd("autotest",true,"","");
-                                }
+                    AppSwitch {
+                        id: autotest_switch
+                        onToggled: {
+                            if(autotest_switch.checked==true){
+                                autotest_switch.enabled = false
+                                serial.sendCmd("autotest",true,"","");
+                                t_autotest.start()
+                            }else{
+                                console.log("t_autotest 计数:",t_autotest.interval)
                             }
+
                         }
                     }
 
+                    Timer {
+                        id: t_autotest
+                        interval: 1000*60
+                        running: false
+                        repeat: false
+                        onTriggered: {
+                            autotest_switch.enabled = true
+                            autotest_switch.checked = false
+                        }
+                    }
+                }
 
-                    Row {
-                        spacing: 100
 
-                        AppText{
-                            text: "风机测试"
-                            color: app.fontColor
-                            fontSize:  15
-                            //font.bold: true
-                            anchors.verticalCenter: fantest_switch.verticalCenter
-                        }
+                Row {
+                    spacing: 100
 
-                        AppSwitch {
-                            id: fantest_switch
-                            onToggled: {
-                                if(fantest_switch.checked==true){
-                                    serial.sendCmd("fan",true,"","");
-                                    apptext_res.text = "打开风机"
-                                }else{
-                                    serial.sendCmd("fan",false,"","");
-                                    apptext_res.text = "关闭风机"
-                                }
+                    AppText{
+                        text: "风机测试"
+                        color: app.fontColor
+                        fontSize:  15
+                        //font.bold: true
+                        anchors.verticalCenter: fantest_switch.verticalCenter
+                    }
+
+                    AppSwitch {
+                        id: fantest_switch
+                        onToggled: {
+                            if(fantest_switch.checked==true){
+                                serial.sendCmd("fan",true,"","");
+                                apptext_res.text = "打开风机"
+                            }else{
+                                serial.sendCmd("fan",false,"","");
+                                apptext_res.text = "关闭风机"
                             }
                         }
                     }
+                }
 
-                    Row {
-                        spacing: 100
+                Row {
+                    spacing: 100
 
-                        AppText{
-                            text: "胶带测试"
-                            fontSize:  15
-                            color: app.fontColor
-                            //font.bold: true
-                            anchors.verticalCenter: jiaodai_switch.verticalCenter
-                        }
+                    AppText{
+                        text: "胶带测试"
+                        fontSize:  15
+                        color: app.fontColor
+                        //font.bold: true
+                        anchors.verticalCenter: jiaodai_switch.verticalCenter
+                    }
 
-                        AppSwitch {
-                            id: jiaodai_switch
-                            onToggled: {
-                                if(jiaodai_switch.checked==true){
-                                    //jiaodai_switch.enabled = false
-                                    apptext_res.text = "胶带测试开始"
-                                    serial.sendCmd("jiaodai",true,"","");
-                                }
+                    AppSwitch {
+                        id: jiaodai_switch
+                        onToggled: {
+                            if(jiaodai_switch.checked==true){
+                                //jiaodai_switch.enabled = false
+                                apptext_res.text = "胶带测试开始"
+                                serial.sendCmd("jiaodai",true,"","");
                             }
                         }
                     }
+                }
 
-                    Row {
-                        spacing: 100
+                Row {
+                    spacing: 100
 
-                        AppText{
-                            text: "补光测试"
-                            color: app.fontColor
-                            fontSize:  15
-                            //font.bold: true
-                            anchors.verticalCenter: led_switch.verticalCenter
-                        }
+                    AppText{
+                        text: "补光测试"
+                        color: app.fontColor
+                        fontSize:  15
+                        //font.bold: true
+                        anchors.verticalCenter: led_switch.verticalCenter
+                    }
 
-                        AppSwitch {
-                            id: led_switch
-                            onToggled: {
-                                if(led_switch.checked==true){
-                                    serial.sendCmd("led",true,"","");
-                                    apptext_res.text = "补光灯已打开"
-                                }else{
-                                    serial.sendCmd("led",false,"","");
-                                    apptext_res.text = "补光灯已关闭"
-                                }
+                    AppSwitch {
+                        id: led_switch
+                        onToggled: {
+                            if(led_switch.checked==true){
+                                serial.sendCmd("led",true,"","");
+                                apptext_res.text = "补光灯已打开"
+                            }else{
+                                serial.sendCmd("led",false,"","");
+                                apptext_res.text = "补光灯已关闭"
                             }
                         }
                     }
+                }
 
 
-                    Row {
-                        spacing: 100
+                Row {
+                    spacing: 100
 
-                        AppText{
-                            text: "立即拍照"
-                            color: app.fontColor
-                            fontSize:  15
-                            //font.bold: true
-                            anchors.verticalCenter: takephoto_switch.verticalCenter
-                        }
+                    AppText{
+                        text: "立即拍照"
+                        color: app.fontColor
+                        fontSize:  15
+                        //font.bold: true
+                        anchors.verticalCenter: takephoto_switch.verticalCenter
+                    }
 
-                        AppSwitch {
-                            id: takephoto_switch
-                            onToggled: {
-                                if(takephoto_switch.checked==true){
-                                    apptext_res.text = "立即拍照"
-                                    frames.captureImage()
-                                }
+                    AppSwitch {
+                        id: takephoto_switch
+                        onToggled: {
+                            if(takephoto_switch.checked==true){
+                                apptext_res.text = "立即拍照"
+                                frames.captureImage()
                             }
                         }
                     }
+                }
 
-                    Row {
-                        spacing: 100
+                Row {
+                    spacing: 100
 
-                        AppText{
-                            text: "对焦拍照"
-                            color: app.fontColor
-                            fontSize:  15
-                            //font.bold: true
-                            anchors.verticalCenter: focus_switch.verticalCenter
-                        }
+                    AppText{
+                        text: "对焦拍照"
+                        color: app.fontColor
+                        fontSize:  15
+                        //font.bold: true
+                        anchors.verticalCenter: focus_switch.verticalCenter
+                    }
 
-                        AppSwitch {
-                            id: focus_switch
-                            onToggled: {
-                                if(focus_switch.checked==true){
-                                    apptext_res.text = "开始对焦"
-                                    focus_switch.enabled = false
-                                    serial.auto_takephoto(true)
-                                }
+                    AppSwitch {
+                        id: focus_switch
+                        onToggled: {
+                            if(focus_switch.checked==true){
+                                apptext_res.text = "开始对焦"
+                                focus_switch.enabled = false
+                                serial.auto_takephoto(true)
                             }
                         }
-
                     }
 
+                }
+
+                AppText {
+                    id: text_title2
+                    text: "三轴步进电机控制"
+                    font.bold: true
+                    color: "#28a779"
+                    fontSize: 20
+                }
+                // 轴选择
+                Row {
+                    spacing: dp(1)
+                    width: parent.width
                     AppText {
-                        id: text_title2
-                        text: "三轴步进电机控制"
-                        font.bold: true
-                        color: "#28a779"
-                        fontSize: 20
+                        text: "选择轴:"
+                        width: dp(60)  // 固定文本宽度
+                        anchors.verticalCenter: parent.verticalCenter
                     }
-                    // 轴选择
-                    Row {
-                        spacing: dp(1)
-                        width: parent.width
-                        AppText {
-                            text: "选择轴:"
-                            width: dp(60)  // 固定文本宽度
-                            anchors.verticalCenter: parent.verticalCenter
-                        }
-                        ComboBox {
-                            width: parent.width - dp(60)  // 剩余宽度
-                            model: ["X轴", "Y轴", "Z轴"]
-                            onCurrentIndexChanged: currentAxis = currentIndex
-                        }
-                        AppButton{
-                            text: "校准"
-                            textColor: "black"
-                            flat: false
-                            borderColor: "black"
-                            borderWidth: dp(1)
-                            backgroundColor: "white"
-                            minimumHeight: dp(30)
-                            minimumWidth: dp(50)
-                            onClicked:
+                    ComboBox {
+                        width: parent.width - dp(60)  // 剩余宽度
+                        height: dp(40)
+                        model: ["X轴", "Y轴", "Z轴"]
+                        onCurrentIndexChanged: currentAxis = currentIndex
+                    }
+                    AppButton{
+                        text: "校准"
+                        textColor: "black"
+                        flat: false
+                        borderColor: "black"
+                        borderWidth: dp(1)
+                        backgroundColor: "white"
+                        minimumHeight: dp(30)
+                        minimumWidth: dp(50)
+                        onClicked:
+                        {
+                            autotake(false)
+                            if(currentAxis==0)
+                            {
+                                console.log("校准X")
+                                serial.sendCmd("calibrate",false,"x",speed.toString())
+                            }else if(currentAxis==1)
+                            {
+                                console.log("校准Y")
+                                serial.sendCmd("calibrate",false,"y",speed.toString())
+                            }else if(currentAxis==2)
                             {
-                                autotake(false)
-                                if(currentAxis==0)
-                                {
-                                    console.log("校准X")
-                                    serial.sendCmd("calibrate",false,"x",speed.toString())
-                                }else if(currentAxis==1)
-                                {
-                                    console.log("校准Y")
-                                    serial.sendCmd("calibrate",false,"y",speed.toString())
-                                }else if(currentAxis==2)
-                                {
-                                    console.log("校准Z")
-                                    serial.sendCmd("calibrate",false,"z",speed.toString())
-                                }
+                                console.log("校准Z")
+                                serial.sendCmd("calibrate",false,"z",speed.toString())
                             }
                         }
                     }
-                    // 速度调节
-                    Row {
-                        spacing: dp(2)
-                        width: parent.width
-                        AppText {
-                            text: "速度:"
-                            width: dp(40)  // 固定文本宽度
-                            anchors.verticalCenter: parent.verticalCenter
+                }
+                // 速度调节
+                Row {
+                    spacing: dp(2)
+                    width: parent.width
+                    AppText {
+                        text: "速度:"
+                        width: dp(40)  // 固定文本宽度
+                        anchors.verticalCenter: parent.verticalCenter
 
-                        }
-                        AppSlider {
-                            width: parent.width - dp(60)  // 剩余宽度
-                            from: 0
-                            to: 100
-                            value: speed
-                            stepSize: 1
-                            onValueChanged: speed = value
-                            anchors.verticalCenter: parent.verticalCenter
-                        }
-                        AppText {
-                            text: speed
-                            width: dp(40)  // 固定文本宽度
-                            anchors.verticalCenter: parent.verticalCenter
-                        }
                     }
-                    // 步进距离设置
-                    Row {
-                        spacing: dp(10)
-                        width: parent.width
-                        AppText {
-                            text: "步进脉冲次数:"
-                            width: dp(120)  // 固定文本宽度
-                            anchors.verticalCenter: parent.verticalCenter
-                        }
-                        AppTextField {
-                            id: step_apptextfield
-                            width: parent.width - dp(120)  // 剩余宽度
-                            text: stepDistance
-                            validator: IntValidator { bottom: 0; top: 2000 }
-                            onTextChanged: stepDistance = parseInt(text)
-                        }
+                    AppSlider {
+                        width: parent.width - dp(60)  // 剩余宽度
+                        from: 0
+                        to: 100
+                        value: speed
+                        stepSize: 1
+                        onValueChanged: speed = value
+                        anchors.verticalCenter: parent.verticalCenter
+                    }
+                    AppText {
+                        text: speed
+                        width: dp(40)  // 固定文本宽度
+                        anchors.verticalCenter: parent.verticalCenter
+                    }
+                }
+                // 步进距离设置
+                Row {
+                    spacing: dp(10)
+                    width: parent.width
+                    AppText {
+                        text: "步进脉冲次数:"
+                        width: dp(120)  // 固定文本宽度
+                        anchors.verticalCenter: parent.verticalCenter
+                    }
+                    AppTextField {
+                        id: step_apptextfield
+                        width: parent.width - dp(120)  // 剩余宽度
+                        text: stepDistance
+                        validator: IntValidator { bottom: 0; top: 2000 }
+                        onTextChanged: stepDistance = parseInt(text)
                     }
-                    // 运动控制按钮
-                    Row {
-                        spacing: dp(10)
-                        width: parent.width
-                        AppButton {
-                            text: " 正转 "
-                            textColor: "black"
-                            flat: false
-                            borderColor: "black"
-                            borderWidth: dp(1)
-                            backgroundColor: "grey"
-                            minimumHeight: dp(30)
-                            minimumWidth: dp(50)
-                            width: (parent.width - dp(30))/3  // 平均分配宽度
-                            onClicked:
+                }
+                // 运动控制按钮
+                Row {
+                    spacing: dp(10)
+                    width: parent.width
+                    AppButton {
+                        text: " 正转 "
+                        textColor: "black"
+                        flat: false
+                        borderColor: "black"
+                        borderWidth: dp(1)
+                        backgroundColor: "grey"
+                        minimumHeight: dp(30)
+                        minimumWidth: dp(50)
+                        width: (parent.width - dp(30))/3  // 平均分配宽度
+                        onClicked:
+                        {
+                            if(currentAxis==0)
+                            {
+                                console.log("X轴正转:",stepDistance)
+                                serial.sendCmd("movx",false,"f"+stepDistance,speed.toString())
+                            }else if(currentAxis==1)
+                            {
+                                console.log("Y轴正转:",stepDistance)
+                                serial.sendCmd("movy",false,"f"+stepDistance,speed.toString())
+                            }else if(currentAxis==2)
                             {
-                                if(currentAxis==0)
-                                {
-                                    console.log("X轴正转:",stepDistance)
-                                    serial.sendCmd("movx",false,"f"+stepDistance,speed.toString())
-                                }else if(currentAxis==1)
-                                {
-                                    console.log("Y轴正转:",stepDistance)
-                                    serial.sendCmd("movy",false,"f"+stepDistance,speed.toString())
-                                }else if(currentAxis==2)
-                                {
-                                    console.log("Z轴正转:",stepDistance)
-                                    serial.sendCmd("movz",false,"f"+stepDistance,speed.toString())
-                                }
+                                console.log("Z轴正转:",stepDistance)
+                                serial.sendCmd("movz",false,"f"+stepDistance,speed.toString())
                             }
                         }
-                        AppButton {
-                            text: " 停止 "
-                            textColor: "black"
-                            flat: false
-                            borderColor: "black"
-                            borderWidth: dp(1)
-                            backgroundColor: "red"
-                            minimumHeight: dp(30)
-                            minimumWidth: dp(50)
-                            width: (parent.width - dp(30))/3  // 平均分配宽度
-                            onClicked:
+                    }
+
+                    AppButton {
+                        text: " 停止 "
+                        textColor: "black"
+                        flat: false
+                        borderColor: "black"
+                        borderWidth: dp(1)
+                        backgroundColor: "red"
+                        minimumHeight: dp(30)
+                        minimumWidth: dp(50)
+                        width: (parent.width - dp(30))/3  // 平均分配宽度
+                        onClicked:
+                        {
+                            console.log("停止")
+                            serial.sendCmd("movx",false,"f0","")
+                        }
+                    }
+
+                    AppButton {
+                        text: " 反转 "
+                        textColor: "black"
+                        flat: false
+                        borderColor: "black"
+                        borderWidth: dp(1)
+                        backgroundColor: "grey"
+                        minimumHeight: dp(30)
+                        minimumWidth: dp(50)
+                        width: (parent.width - dp(30))/3  // 平均分配宽度
+
+                        onClicked:
+                        {
+                            if(currentAxis==0)
+                            {
+                                console.log("X轴反转:",stepDistance)
+                                serial.sendCmd("movx",false,"b"+stepDistance,speed.toString())
+                            }else if(currentAxis==1)
+                            {
+                                console.log("Y轴反转:",stepDistance)
+                                serial.sendCmd("movy",false,"b"+stepDistance,speed.toString())
+                            }else if(currentAxis==2)
                             {
-                                console.log("停止")
-                                serial.sendCmd("movx",false,"f0","")
+                                console.log("Z轴反转:",stepDistance)
+                                serial.sendCmd("movz",false,"b"+stepDistance,speed.toString())
                             }
                         }
-                        AppButton {
-                            text: " 反转 "
-                            textColor: "black"
-                            flat: false
-                            borderColor: "black"
-                            borderWidth: dp(1)
-                            backgroundColor: "grey"
-                            minimumHeight: dp(30)
-                            minimumWidth: dp(50)
-                            width: (parent.width - dp(30))/3  // 平均分配宽度
-
-                            // property var pressTime: 0
-                            // property bool isLongPress: false
-
-                            // Timer{
-                            //     id: longPressTimer
-                            //     interval: 200
-                            //     onTriggered: {
-                            //         if (myButton.pressed) {
-                            //             myButton.isLongPress = true
-                            //             console.log("长按") // 持续按下超过 200ms,打印
-                            //             if(currentAxis==0)
-                            //             {
-                            //                 console.log("X轴反转:",stepDistance)
-                            //                 serial.sendCmd("movx",false,"b1000","0")
-                            //             }else if(currentAxis==1)
-                            //             {
-                            //                 console.log("Y轴反转:",stepDistance)
-                            //                 serial.sendCmd("movy",false,"b1000","0")
-                            //             }else if(currentAxis==2)
-                            //             {
-                            //                 console.log("Z轴反转:",stepDistance)
-                            //                 serial.sendCmd("movz",false,"b1000","0")
-                            //             }
-                            //         }
-                            //     }
-                            // }
-
-                            // onPressed:
-                            // {
-                            //     console.log("反转按钮按下!")  //持续200ms后,长时运动
-                            //     longPressTimer.start() // 启动定时器
-                            // }
-                            // onReleased:
-                            // {
-                            //     console.log("反转按钮释放!")  //立即关闭电机驱动
-                            //     longPressTimer.stop() // 停止定时器
-                            //     if (myButton.isLongPress) {
-                            //         console.log("0") // 释放时打印 0
-                            //     } else {
-                            //         console.log("1") // 按下时间小于 200ms,打印 1
-                            //     }
-
-                            //     // 重置状态
-                            //     myButton.isLongPress = false
-                            // }
-
-                            onClicked:
+                    }
+                    AppButton {
+                        text: " 复位 "
+                        textColor: "black"
+                        flat: false
+                        borderColor: "black"
+                        borderWidth: dp(1)
+                        backgroundColor: "grey"
+                        minimumHeight: dp(30)
+                        minimumWidth: dp(50)
+                        width: (parent.width - dp(30))/3  // 平均分配宽度
+                        onClicked: {
+                            if(currentAxis==0)
+                            {
+                                console.log("X轴复位!")
+                                serial.sendCmd("movx",true,"",speed.toString())
+                            }else if(currentAxis==1)
+                            {
+                                console.log("Y轴复位!")
+                                serial.sendCmd("movy",true,"",speed.toString())
+                            }else if(currentAxis==2)
                             {
-                                if(currentAxis==0)
-                                {
-                                    console.log("X轴反转:",stepDistance)
-                                    serial.sendCmd("movx",false,"b"+stepDistance,speed.toString())
-                                }else if(currentAxis==1)
-                                {
-                                    console.log("Y轴反转:",stepDistance)
-                                    serial.sendCmd("movy",false,"b"+stepDistance,speed.toString())
-                                }else if(currentAxis==2)
-                                {
-                                    console.log("Z轴反转:",stepDistance)
-                                    serial.sendCmd("movz",false,"b"+stepDistance,speed.toString())
-                                }
+                                console.log("Z轴复位!")
+                                serial.sendCmd("movz",true,"",speed.toString())
                             }
                         }
-                        AppButton {
-                            text: " 复位 "
-                            textColor: "black"
-                            flat: false
-                            borderColor: "black"
-                            borderWidth: dp(1)
-                            backgroundColor: "grey"
-                            minimumHeight: dp(30)
-                            minimumWidth: dp(50)
-                            width: (parent.width - dp(30))/3  // 平均分配宽度
-                            onClicked: {
-                                if(currentAxis==0)
-                                {
-                                    console.log("X轴复位!")
-                                    serial.sendCmd("movx",true,"",speed.toString())
-                                }else if(currentAxis==1)
-                                {
-                                    console.log("Y轴复位!")
-                                    serial.sendCmd("movy",true,"",speed.toString())
-                                }else if(currentAxis==2)
-                                {
-                                    console.log("Z轴复位!")
-                                    serial.sendCmd("movz",true,"",speed.toString())
-                                }
-                            }
+                    }
+                }
+
+                AppText {
+                    id: text_camera
+                    text: "相机参数"
+                    font.bold: true
+                    color: "#28a779"
+                    fontSize: 20
+                }
+
+                Row {
+                    spacing: dp(10)
+                    width: parent.width
+                    AppText {
+                        id: txt_fExposureTime
+                        text: "曝光值:"
+                    }
+
+                    AppTextField {
+                        anchors.verticalCenter: txt_fExposureTime.verticalCenter
+                        placeholderText: fExposureTime
+                        text: fExposureTime
+
+                        width: parent.width - dp(10)  // 剩余宽度
+                        EnterKey.type: Qt.EnterKeyDone
+                        wrapMode: Text.NoWrap
+                        inputMethodHints: Qt.ImhFormattedNumbersOnly |
+                                          Qt.ImhPreferDone |
+                                          Qt.ImhNoPredictiveText
+
+                        validator: DoubleValidator {
+                            bottom: 100.00        // 最小值
+                            top: 500000.00        // 最大值
+                            decimals: 0
+                        }
+
+
+                        // 🔥 关键 3:兜底(IME 再作妖也不怕)
+                        Keys.onReturnPressed: {
+                            frames.cam_ExposureTime = text
+                            console.log("设置曝光时间:",text)
+                            Qt.inputMethod.hide()
                         }
+
+                        onAccepted: {
+                            frames.cam_ExposureTime = text
+                            console.log("设置曝光时间",text)
+                        }
+
                     }
-            }
+                }
             }
         }
-
     }
 }

+ 182 - 319
q6_felgo_iot/src/cameramanager.cpp

@@ -55,64 +55,13 @@ namespace Qt6QCamera {
 
 //< hikrobot
 void *handle = NULL;
-int nRet = MV_OK;
+unsigned int nRet = MV_OK;
 MVCC_ENUMVALUE current_pixel;
 
 
 SenderCustom sender_custom;
 cv::Mat cv_frame;
 
-// pthread 线程函数
-static void* pthreadGrab(void* ptr){
-
-    Frames *frame_p = reinterpret_cast<Frames*>(ptr);
-    MVCC_INTVALUE_EX stParam;
-    memset(&stParam, 0, sizeof(MVCC_INTVALUE_EX));
-    nRet = MV_CC_GetIntValueEx(handle, "PayloadSize", &stParam);
-    MV_FRAME_OUT_INFO_EX stImageInfo = {0};
-    memset(&stImageInfo, 0, sizeof(MV_FRAME_OUT_INFO_EX));
-    unsigned char *pData = (unsigned char *)malloc(sizeof(unsigned char) * stParam.nCurValue + 2048);
-    if (NULL == pData){
-        return NULL;
-    }
-    unsigned int nDataSize = stParam.nCurValue;
-    MV_FRAME_OUT pFrame={0};
-    qDebug() << "MV_CC_Get nDataSize:"  << nDataSize;
-    while(1){
-        nRet = MV_CC_GetOneFrameTimeout(handle, pData, nDataSize, &stImageInfo, 30000);
-        if (nRet == MV_OK){
-            qDebug() << "MV_CC_GetOneFrameTimeout Success" <<stImageInfo.enPixelType << stImageInfo.nHeight << stImageInfo.nWidth;
-            if ( stImageInfo.enPixelType == 0 )
-            {
-                //转换为Mat类型
-                //cv::Mat tempMat = Mat(stImageInfo.nHeight , stImageInfo.nWidth, CV_8UC3,pData);  //BGR
-                cv::Mat tempMat = Mat(stImageInfo.nHeight , stImageInfo.nWidth, CV_8UC2,pData);
-                if (tempMat.empty()) {
-                    // 处理转换失败的情况
-                    qDebug() << "Failed to convert QByteArray to cv::Mat";
-                    return NULL; // 可能需要根据实际情况进行处理,比如抛出异常或返回错误码
-                }
-                // 将YUV422数据转换为BGR格式
-                cv::Mat bgrImage;
-                cv::cvtColor(tempMat, bgrImage, cv::COLOR_YUV2RGB_YVYU);//nv12
-
-                // 在主线程中执行信号的槽函数
-                QMetaObject::invokeMethod(frame_p, "uvcframeAvailable", Qt::QueuedConnection, Q_ARG(cv::Mat, bgrImage));
-                //if(frame_p->camera_sw()==false) return NULL;
-            }else{
-                qDebug() << "enPixelType:" << stImageInfo.enPixelType;
-            }
-        }else{
-            qDebug() << "MV_CC_GetOneFrameTimeout fail! nRet:" << nRet;
-            if(pData){
-                free(pData);
-            }
-            return NULL;
-        }
-    }
-    return 0;
-}
-
 
 FPSTimer::FPSTimer(QObject *parent) : QObject(parent)
 {
@@ -236,19 +185,11 @@ Frames::~Frames()
         MV_CC_DestroyHandle(handle);
         handle  = NULL;
     }
-    if (m_processThread.isRunning()) {
-        m_processThread.waitForFinished();  // wait for finish thread
-    }
-
     //  清理JNI资源
     if (jClass) {
         delete jClass;
         jClass = nullptr;
     }
-    if (m_imageCapture) {
-        delete m_imageCapture;
-        m_imageCapture = nullptr;
-    }
 
     if (m_1s) {
         delete m_1s;
@@ -271,8 +212,6 @@ Frames::~Frames()
 void
 Frames::setVideoSink( QVideoSink * newVideoSink )
 {
-
-
     qDebug() << "setVideoSink:"<<newVideoSink;
     if( m_videoSink == newVideoSink )
     {
@@ -281,7 +220,6 @@ Frames::setVideoSink( QVideoSink * newVideoSink )
     }
 
     m_videoSink = newVideoSink;
-    m_capture.setVideoSink(m_videoSink);
 
     emit videoSinkChanged();
 }
@@ -296,9 +234,15 @@ Frames::setChange(bool stat_t)
 
 }
 
+
+
 void
 Frames::setCameraSw(bool stat_cam)
 {
+    unsigned int nIP[4] = {192,168,100,100};
+    unsigned int nMask[4] = {255,255,255,0};
+    unsigned int nGateway[4] = {192,168,100,1};
+    unsigned int nIpAddr = 0, nNetWorkMask = 0, nDefaultGateway = 0;
     z_step = 0;
     x_step = 0;
     auto qtContext = QJniObject(QNativeInterface::QAndroidApplication::context());
@@ -307,12 +251,14 @@ Frames::setCameraSw(bool stat_cam)
     stitch_des = 0;
     camera_sta = stat_cam;
     if(m_streaming_active&&camera_sta) return;  //如果已经是打开状态,退出
+    MVCC_FLOATVALUE stExposureTime = {0};
     static int fd = 0;
     if(camera_sta){
         if(param::camera_type.contains("hikrobot"))
         {
             int ret = testJNI();
-            qDebug()<<"testJNI ret:" << ret;
+            LOG("testJNI ret:{}",ret);
+
             #if 0
                 if(qtContext.isValid()&&jClass->isValid()){
                     jClass->callMethod<void>("EnumDevice","(Landroid/content/Context;)V",qtContext.object());
@@ -326,6 +272,7 @@ Frames::setCameraSw(bool stat_cam)
                     MV_CC_DestroyHandle(handle);
                     handle  = NULL;
                 }
+
                 unsigned int nIndex = 0;
                 MV_CC_DEVICE_INFO_LIST stDeviceList;
                 memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));
@@ -334,13 +281,12 @@ Frames::setCameraSw(bool stat_cam)
                  if (MV_OK != nRet)
                  {
                      emit cameraOpenFailed("MV_CC_EnumDevices fail!");
-                     unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                     qDebug() << "MV_CC_EnumDevices fail! nRet" << QString::number(unsignedValue, 16).toUpper();
+                     ERROR("MV_CC_EnumDevices fail! {:x}",nRet);
                      return ;
                  }
                  else
                  {
-                     qDebug() << "MV_CC_EnumDevices Success!";
+                     LOG("MV_CC_EnumDevices Success!");
                  }
                  if (stDeviceList.nDeviceNum > 0)
                  {
@@ -351,29 +297,78 @@ Frames::setCameraSw(bool stat_cam)
                          if (NULL == pDeviceInfo)
                          {
                              emit cameraOpenFailed("pDeviceInfo is NULL!");
-                             qDebug() << "pDeviceInfo is NULL!";
+                             ERROR("pDeviceInfo is NULL!");
                              return;
                          }
                          //PrintDeviceInfo(pDeviceInfo);
                      }
                  }else{
                      emit cameraOpenFailed("Find No Devices!");
-                     qDebug() << "Find No Devices!";
+                     ERROR("Find No Devices!");
                      // break;
                      return;
                  }
+                 ConvertToHexIp(&nIpAddr,nIP);
+                 ConvertToHexIp(&nNetWorkMask,nMask);
+                 ConvertToHexIp(&nDefaultGateway,nGateway);
+
                  // 选择设备并创建句柄
                  // select device and create handle
                  nRet = MV_CC_CreateHandle(&handle, stDeviceList.pDeviceInfo[nIndex]);
                  if (MV_OK != nRet)
                  {
                      emit cameraOpenFailed("MV_CC_CreateHandle fail!");
-                     unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                     qDebug() << "MV_CC_CreateHandle fail! nRet" << QString::number(unsignedValue, 16).toUpper();
-                     // break;
+                     ERROR("MV_CC_CreateHandle fail! {:x}",nRet);
                      return ;
                  }else{
-                     qDebug() << "MV_CC_CreateHandle Success!";
+                     LOG("MV_CC_CreateHandle Success!");
+                 }
+
+                 //判断设备Ip是否可达
+                 bool bAccessible = MV_CC_IsDeviceAccessible(stDeviceList.pDeviceInfo[nIndex],MV_ACCESS_Exclusive);
+                 if(bAccessible){
+                     //ch:设置IP配置选项 | en:set IP config
+                     nRet = MV_GIGE_SetIpConfig(handle,MV_IP_CFG_STATIC);
+                     if(MV_OK != nRet){
+                         ERROR("MV_GIGE_SetIpConfig failed:{:x}",nRet);
+                     }
+
+                     nRet = MV_GIGE_ForceIpEx(handle,nIpAddr,nNetWorkMask,nDefaultGateway);
+                     if(MV_OK!=nRet){
+                         ERROR("MV_GIGE_ForceIpEx failed:{:x}",nRet);
+                     }
+                 }else{
+                     nRet = MV_GIGE_ForceIpEx(handle,nIpAddr,nNetWorkMask,nDefaultGateway);
+                     if(MV_OK!=nRet){
+                         ERROR("MV_GIGE_ForceIpEx failed:{:x}",nRet);
+                     }else{
+                         LOG("MV_GIGE_ForceIpEx Success!");
+                     }
+                     if (handle)
+                     {
+                         MV_CC_DestroyHandle(handle);
+                         handle  = NULL;
+                     }
+                     MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &stDeviceList);
+                     if (stDeviceList.nDeviceNum > 0)
+                     {
+                         for (int i = 0; i < (int)stDeviceList.nDeviceNum; i++)
+                         {
+                             LOG("[device {}]:", i);
+                             MV_CC_DEVICE_INFO *pDeviceInfo = stDeviceList.pDeviceInfo[i];
+                             if (NULL == pDeviceInfo)
+                             {
+                                 emit cameraOpenFailed("pDeviceInfo is NULL!");
+                                 qDebug() << "pDeviceInfo is NULL!";
+                                 return;
+                             }
+                         }
+                     }else{
+                         emit cameraOpenFailed("Find No Devices!");
+                         WARN("Find No Devices!");
+                         return;
+                     }
+                     MV_CC_CreateHandle(&handle, stDeviceList.pDeviceInfo[nIndex]);
                  }
 
                  nRet = MV_CC_OpenDevice(handle);
@@ -382,12 +377,11 @@ Frames::setCameraSw(bool stat_cam)
                     emit cameraOpenFailed("MV_CC_OpenDevice fail!");
                     MV_CC_DestroyHandle(handle);
                     handle = NULL;
-                    unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                    qDebug() << "MV_CC_OpenDevice fail! nRet" << QString::number(unsignedValue, 16).toUpper();
+                    ERROR("MV_CC_OpenDevice fail! {:x}",nRet);
                     camera_sta = false;
                     return;
                  }else{
-                    qDebug() << "MV_CC_OpenDevice Success!";
+                    LOG("MV_CC_OpenDevice Success!");
                  }
                  // ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
                  if (stDeviceList.pDeviceInfo[nIndex]->nTLayerType == MV_GIGE_DEVICE)
@@ -398,13 +392,12 @@ Frames::setCameraSw(bool stat_cam)
                          nRet = MV_CC_SetIntValue(handle,"GevSCPSPacketSize",nPacketSize);
                          if(nRet != MV_OK)
                          {
-                             unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                             qDebug() << "Warning: Set Packet Size fail nRet:" << QString::number(unsignedValue, 16).toUpper();
+                             ERROR("Warning: Set Packet Size fail nRet:{:x}",nRet);
                          }
                      }
                      else
                      {
-                         qDebug() << "Warning: Get Packet Size fail nRet:"<< nPacketSize;
+                         WARN("Warning: Get Packet Size fail nRet:{}",nPacketSize);
                      }
                      LOG("stDeviceList.pDeviceInfo[nIndex]->nTLayerType:{}",stDeviceList.pDeviceInfo[nIndex]->nTLayerType);
                  }
@@ -413,8 +406,7 @@ Frames::setCameraSw(bool stat_cam)
                  nRet = MV_CC_SetEnumValue(handle, "TriggerMode", MV_TRIGGER_MODE_OFF);
                  if (MV_OK != nRet)
                  {
-                     unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                     qDebug() << "Set Trigger Mode fail! nRet" << QString::number(unsignedValue, 16).toUpper();
+                     ERROR("Set Trigger Mode fail! {:x}",nRet);
                      return;
                  }
                  #if 0
@@ -432,26 +424,36 @@ Frames::setCameraSw(bool stat_cam)
                  MVCC_INTVALUE_EX width,height;
                  nRet = MV_CC_GetIntValueEx(handle, "Width", &width);
                  if(nRet==MV_OK){
-                     qDebug() << "[MV_CC_GetIntValueEx Width]:"<< width.nCurValue;
+                     LOG("[MV_CC_GetIntValueEx Width]:{}",width.nCurValue);
                  }else{
-                     unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                     qDebug() << "[MV_CC_GetIntValueEx Width Failed]:"<< &nRet;
+                     ERROR("[MV_CC_GetIntValueEx Width]:{:x}",nRet);
                  }
                  nRet = MV_CC_GetIntValueEx(handle, "Height", &height);
                  if(nRet==MV_OK){
-                     qDebug() << "[MV_CC_GetIntValueEx Height]:"<< height.nCurValue;
+                     LOG("[MV_CC_GetIntValueEx Height]:{}",height.nCurValue);
                  }else{
-                     unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                     qDebug() << "[MV_CC_GetIntValueEx Height Failed]:"<< nRet;
+                     ERROR("[MV_CC_GetIntValueEx Height]:{:x}",nRet);
                  }
                  //获取像素格式
                  nRet = MV_CC_GetPixelFormat(handle,&current_pixel);
                  if(nRet==MV_OK){
                      LOG("MV_CC_GetPixelFormat:{}",current_pixel.nCurValue);
                  }else{
-                     unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                     qDebug() << "[MV_CC_GetPixelFormat Failed]:"<< nRet;
+                     ERROR("[MV_CC_GetPixelFormat Failed]:{:x}",nRet);
+                 }
+
+                 nRet = MV_CC_GetFloatValue(handle, "ExposureTime", &stExposureTime);
+                 if (MV_OK == nRet)
+                 {
+                     m_fExposureTime = QString::number(stExposureTime.fCurValue);
+                     emit exposureTimeChanged();
+                     LOG("exposure time current value:{}",stExposureTime.fCurValue);
+                 }
+                 else
+                 {
+                     ERROR("get exposure time failed! nRet [{:X}]", nRet);
                  }
+
                  // 开始取流
                  // start grab image
                  nRet = MV_CC_StartGrabbing(handle);
@@ -459,9 +461,7 @@ Frames::setCameraSw(bool stat_cam)
                  {
                      emit cameraOpenFailed("MV_CC_StartGrabbing fail!");
                      camera_sta = false;
-                     unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                     qDebug() << "MV_CC_StartGrabbing fail! nRet [{}]" << QString::number(unsignedValue, 16).toUpper();
-                     // break;
+                     ERROR("[MV_CC_StartGrabbing Failed]:{:x}",nRet);
                      return ;
                  }else{
                      //创建归档路径
@@ -494,7 +494,7 @@ Frames::setCameraSw(bool stat_cam)
         }
     }else{  //关闭相机
         if(param::camera_type.contains("qcamera")){
-            m_cam->stop();
+
         }else if(param::camera_type.contains("uvc")){
             #if 1
             if(qtContext.isValid()&&jClass->isValid()){
@@ -505,8 +505,7 @@ Frames::setCameraSw(bool stat_cam)
             nRet = MV_CC_StopGrabbing(handle);
             if (MV_OK != nRet)
             {
-                unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                qDebug() << "MV_CC_StopGrabbing fail! nRet:" << QString::number(unsignedValue, 16).toUpper();
+                ERROR("[MV_CC_StopGrabbing Failed]:{:x}",nRet);
             }
             #if 0
             // ch:注销抓图回调 | en:Unregister image callback
@@ -521,8 +520,7 @@ Frames::setCameraSw(bool stat_cam)
             nRet = MV_CC_CloseDevice(handle);
             if (MV_OK != nRet)
             {
-                unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                qDebug() << "MV_CC_CloseDevice fail! nRet" << QString::number(unsignedValue, 16).toUpper();
+                ERROR("[MV_CC_CloseDevice Failed]:{:x}",nRet);
             }
             // 销毁句柄
             // destroy handle
@@ -530,14 +528,12 @@ Frames::setCameraSw(bool stat_cam)
                 nRet = MV_CC_DestroyHandle(handle);
                 if (MV_OK != nRet)
                 {
-                    unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                    qDebug() << "MV_CC_DestroyHandle fail! nRet {}" <<  QString::number(unsignedValue, 16).toUpper();
+                    ERROR("[MV_CC_DestroyHandle Failed]:{:x}",nRet);
                 }
             }
         }
         m_fps_timer->setRunning(false);
         m_1s->stop();                       //视频信息发送定时器停止
-        m_processThread.waitForFinished();  //阻塞
     }
 
     LOG("设置相机状态:{}",camera_sta);
@@ -549,6 +545,30 @@ Frames::setCameraSw(bool stat_cam)
     }
 }
 
+void
+Frames::setExposureTime(const QString &exptime)
+{
+    bool ok = false;
+    float exposure_time = exptime.toFloat(&ok);
+    if(handle&&ok){
+        //关闭自动曝光
+        nRet = MV_CC_SetExposureAutoMode(handle,MV_EXPOSURE_AUTO_MODE_OFF);
+        if(nRet==MV_OK){
+            LOG("MV_CC_SetExposureAutoMode OFF Success");
+        }else{
+            ERROR("MV_CC_SetExposureAutoMode OFF Failed");
+        }
+
+        nRet = MV_CC_SetExposureTime(handle,exposure_time);
+        if(nRet==MV_OK){
+            LOG("MV_CC_SetExposureTime Success");
+            m_fExposureTime = exptime;
+        }else{
+            ERROR("MV_CC_SetExposureTime Failed");
+        }
+    }
+    emit exposureTimeChanged();
+}
 
 
 void
@@ -683,24 +703,19 @@ Frames::mov_x_z_run(){
 
 
 void
-Frames::saveMatAsJpeg(const cv::Mat &mat){
+Frames::saveMatAsJpeg(const QVideoFrame &frame){
     QString ts = QDateTime::currentDateTime().toString("yyyyMMddhhmmss");
-    if (!mat.empty()) {
-        std::vector<int> params = {
-            cv::IMWRITE_JPEG_QUALITY,
-            90
-        };
-        //QImage img = f.toImage().convertToFormat(QImage::Format_RGB32);
+    if (frame.isValid()) {
         QString name = picture_path_floader + "/" + ts +
                        "z" + QString::number(z_step) +
                        "x" + QString::number(x_step) + ".jpg";
-        bool ok = cv::imwrite(name.toStdString(), mat, params);
-        if (!ok) {
-            WARN("[saveMatAsJpeg] write failed:{}",name.toStdString());
-        } else {
+
+        if (frame.toImage().save(name,"jpg",90)) {
             param::ptlist.append(name);
             LOG("[saveMatAsJpeg] saved:{}",name.toStdString());
             mov_x_z_run();
+        } else {
+            WARN("[saveMatAsJpeg] write failed:{}",name.toStdString());
         }
     }else{
         ERROR("[saveMatAsJpeg] empty image!");
@@ -709,7 +724,7 @@ Frames::saveMatAsJpeg(const cv::Mat &mat){
 
 void
 Frames::processFrameAsync(const RawFrame& frame){
-    QtConcurrent::run([=]() {
+    //QtConcurrent::run([=]() {
         cv::Mat raw;
         switch (frame.pixelType) {
         case PixelType_Gvsp_BayerRG8:
@@ -739,19 +754,6 @@ Frames::processFrameAsync(const RawFrame& frame){
         default:
             return;
         }
-
-        if(param::camera_tc==1||param::camera_tc==100){
-            cv::Mat snapshot = m_frame.clone(); // 只 clone 一次
-            QtConcurrent::run([=](){
-                saveMatAsJpeg(snapshot);
-            });
-            if (param::camera_tc == 100) {
-                param::camera_tc = 0;
-                emit stopGrabbing(false);
-                return;
-            }
-            param::camera_tc = 0;
-        }
         QVideoFrameFormat vfmt(
             QSize(m_frame.cols, m_frame.rows),
             QVideoFrameFormat::Format_RGBA8888
@@ -772,7 +774,19 @@ Frames::processFrameAsync(const RawFrame& frame){
             }
         }, Qt::QueuedConnection);
 
-    });
+        if(param::camera_tc==1||param::camera_tc==100){
+            QVideoFrame snapshot = vf;
+            QtConcurrent::run([=](){
+                saveMatAsJpeg(snapshot);
+            });
+            if (param::camera_tc == 100) {
+                param::camera_tc = 0;
+                emit stopGrabbing(false);
+                return;
+            }
+            param::camera_tc = 0;
+        }
+    //});
 }
 
 void
@@ -788,8 +802,7 @@ Frames::handleGrab(bool sta_cam){
                 nRet = MV_CC_GetIntValueEx(handle, "PayloadSize", &stParam);
                 if (MV_OK != nRet)
                 {
-                    unsigned int unsignedValue = static_cast<unsigned int>(nRet);
-                    qDebug() << "Get PayloadSize fail! nRet:" <<  QString::number(unsignedValue, 16).toUpper();
+                    ERROR("[MV_CC_GetIntValueEx Failed]:{:x}",nRet);
                     return;
                 }
             }
@@ -798,21 +811,23 @@ Frames::handleGrab(bool sta_cam){
             const uint32_t payload = stParam.nCurValue;
             LOG("payload size:{}",payload);
             MV_FRAME_OUT stImageInfo = {0};
-
             bool flag_cam = sta_cam;
             std::vector<unsigned char> rgbBuf;
             while(flag_cam){
-
                 nRet = MV_CC_GetImageBuffer(handle, &stImageInfo, 10000);
                 if (nRet != MV_OK) {
                     ERROR("GetOneFrameTimeout:{:x}",nRet);
+                    emit stopGrabbing(false);
                     break;
                 }
                 RawFrame frame;
                 frame.width     = stImageInfo.stFrameInfo.nWidth;
                 frame.height    = stImageInfo.stFrameInfo.nHeight;
                 frame.pixelType = stImageInfo.stFrameInfo.enPixelType;
+                m_width = frame.width;
+                m_height = frame.height;
                 const int dataSize = stImageInfo.stFrameInfo.nFrameLen;
+
                 frame.data = QByteArray(
                     (const char*)stImageInfo.pBufAddr,
                     dataSize
@@ -834,6 +849,11 @@ Frames::handleGrab(bool sta_cam){
     }
 }
 
+QString
+Frames::cam_ExposureTime() const
+{
+    return m_fExposureTime;
+}
 
 void
 Frames::registerQmlType()
@@ -848,111 +868,13 @@ Frames::testJNI(){
                                                "()I");
 }
 
-
-int
-Frames::requestPermission(int vid, int pid){
-    int ret = 0;
-    QtAndroidPrivate::requestPermission(QtAndroidPrivate::PermissionType::Camera);
-    QJniObject activity = QtAndroidPrivate::activity();
-    if(!activity.isValid()) return 0;
-    QJniObject serviceName = QJniObject::getStaticObjectField<jstring>("android/content/Context","USB_SERVICE");
-    QJniObject usbManager = activity.callObjectMethod("getSystemService","(Ljava/lang/String;)Ljava/lang/Object;", serviceName.object<jobject>());
-    ret = QJniObject::callStaticMethod<jint>("GetUsbPermission", "requestDevicePermission",
-                                                      "(Landroid/hardware/usb/UsbManager;II)I",
-                                                        usbManager.object<jobject>(),vid,pid);
-    #if 1
-    auto qtContext = QJniObject(QNativeInterface::QAndroidApplication::context());
-    if(qtContext.isValid()){
-        QJniObject jClass("com/yfkj/cb/Q6iot/UvcCameraActivity");
-        jClass.callMethod<void>("initCameraHelper","(Landroid/content/Context;)V",qtContext.object());
-    }
-    #endif
-    return ret;
-}
-
 void
 Frames::initCam()
-{   
-    if(param::camera_type.contains("qcamera")){
-        m_cam = new QCamera( this );
-        m_imageCapture = new QImageCapture;
-        const auto fs = m_cam->cameraDevice().videoFormats();
-        if(!fs.isEmpty()) {
-            QCameraFormat bestFormat;
-            for( const auto &ss : fs )
-            {
-
-                if(bestFormat.maxFrameRate() == ss.maxFrameRate() &&
-                     bestFormat.resolution().width()*bestFormat.resolution().height() <
-                         ss.resolution().width()*ss.resolution().height()){
-                    bestFormat = ss;
-                    qDebug() << "ss相机宽度:"<<ss.resolution().width() << "ss相机高度:" << ss.resolution().height();
-                    qDebug() << "像素格式:" << ss.pixelFormat();
-                    m_cam->setCameraFormat( bestFormat );
-                }
-
-            }
-        }
-
-        m_capture.setCamera( m_cam );
-        m_capture.setImageCapture(m_imageCapture);
-        m_capture.setVideoSink(m_videoSink);
-        m_cam->setFocusMode( QCamera::FocusModeAuto );
-        connect(m_cam,&QCamera::errorOccurred,this,&Frames::displayCameraError);
-        connect(m_imageCapture, &QImageCapture::readyForCaptureChanged, this, &Frames::readyForCapture);
-        connect(m_imageCapture,&QImageCapture::imageCaptured,this,&Frames::processCapturedImage);
-        connect(m_imageCapture, &QImageCapture::imageSaved, this, &Frames::imageSaved);
-        connect(m_imageCapture, &QImageCapture::errorOccurred, this, &Frames::displayCaptureError);
-        if(m_cam->cameraFormat().isNull()){
-            auto formats = m_cam->cameraDevice().videoFormats();
-        }
-    }else if(param::camera_type.contains("uvc")){
-
-        #if 1
-        auto qtContext = QJniObject(QNativeInterface::QAndroidApplication::context());
-        if(qtContext.isValid()){
-            jClass = new  QJniObject("com/yfkj/cb/Q6iot/UvcCameraActivity");
-            if(jClass->isValid())
-                jClass->callMethod<void>("initCameraHelper","(Landroid/content/Context;)V",qtContext.object());
-        }
-        int ret = testJNI();
-        qDebug()<<"testJNI ret:" << ret;
-        #else
-        int ret = testJNI();
-        qDebug()<<"testJNI ret:" << ret;
-        int vid = 0, pid = 0;
-        findUVCDevice(vid,pid); //查找uvc设备
-        ret = requestPermission(vid,pid);   //请求权限
-        qDebug()<<"getPermission return:" << ret;
-        #endif
-    }else if(param::camera_type.contains("hikrobot")){
-        int ret = testJNI();
-        qDebug()<<"testJNI ret:" << ret;
-        #if 0
-        jClass = new  QJniObject("com/yfkj/cb/Q6iot/CameraManager");
-        #else
-        #endif
-
-    }
-}
-
-qreal
-Frames::angle() const
 {
-    return 0.0;
+    int ret = testJNI();
+    LOG("initCam:{}",ret);
 }
 
-qreal
-Frames::xScale() const
-{
-    return 1.0;
-}
-
-qreal
-Frames::yScale() const
-{
-    return 1.0;
-}
 
 QString
 Frames::formatString() const
@@ -986,7 +908,11 @@ Frames:: camera_sw()  const
 
 void
 Frames::onFPSUpdated(double fps){
-    m_fpsString = QString( "%1x%2 at %13 @%3" ).arg(QString::number(m_frame.cols),QString::number(m_frame.rows),QString::number(fps,'f',2) + " (FPS)",QString::number(param::ptlist.size()));
+    m_fpsString = QString( "%1x%2 at %3 %4 %5" ).arg(QString::number(m_width),
+                                                  QString::number(m_height),
+                                                  QString::number(param::ptlist.size()),
+                                                  QString::number(fps,'f',2) + " (FPS) ",
+                                                   cam_ExposureTime());
     emit fpsStringChanged();
 }
 
@@ -1005,7 +931,7 @@ Frames::timer()
 void
 Frames::update_qulstr(QString q_str)
 {
-    qDebug() << "update_qulstr:" << q_str;
+    LOG("update_qulstr:{}",q_str.toStdString());
     m_qulityString = q_str;
     emit qulityStringChanged();
 }
@@ -1017,22 +943,22 @@ Frames::saveImage()
     LOG("saveImage start!");
     //灰度值检测,全黑则不再往下进行,上报预警消息
     if(m_frame.empty()) return;
-    QtConcurrent::run([=](){
-        Mat image_gray;
-        cv::cvtColor(m_frame,image_gray,cv::COLOR_RGBA2GRAY);
-        double grayvalue = cv::mean(image_gray)[0];
-        m_qulityString = m_opencvfunc.Tenengrad(m_frame);
-        emit serial_data(m_json.ImageFunc(m_qulityString.toDouble()));
-        emit qulityStringChanged();
-        LOG("image_gray:{}",grayvalue);
-        LOG("Tenengrad:{}",m_qulityString.toStdString());
-        if(grayvalue<10.0){
-            emit dataUpload(m_json.MakeJsonWarn("Photo ERROR",QString::number(grayvalue)));
-            setCameraSw(false); //关闭相机
-            emit signal_photoerr();
-            return;
-        }
-    });
+    //QtConcurrent::run([=](){
+    Mat image_gray;
+    cv::cvtColor(m_frame,image_gray,cv::COLOR_RGBA2GRAY);
+    double grayvalue = cv::mean(image_gray)[0];
+    m_qulityString = m_opencvfunc.Tenengrad(m_frame);
+    emit serial_data(m_json.ImageFunc(m_qulityString.toDouble()));
+    emit qulityStringChanged();
+    LOG("image_gray:{}",grayvalue);
+    LOG("Tenengrad:{}",m_qulityString.toStdString());
+    if(grayvalue<10.0){
+        emit dataUpload(m_json.MakeJsonWarn("Photo ERROR",QString::number(grayvalue)));
+        setCameraSw(false); //关闭相机
+        emit signal_photoerr();
+        return;
+    }
+    //});
 }
 
 
@@ -1041,7 +967,7 @@ void Frames::displayFrame(const QVideoFrame &frame)
     if(m_videoSink){
         m_videoSink->setVideoFrame(frame);
     }else{
-        qDebug() << "m_videoSink Error!";
+        ERROR("m_videoSink Error!");
     }
 
 }
@@ -1049,77 +975,14 @@ void Frames::displayFrame(const QVideoFrame &frame)
 //*使用capture捕获照片*/
 void
 Frames::captureImage(){
-
-    if(param::camera_type.contains("qcamera")){
-        if(m_imageCapture->isAvailable()){
-            m_imageCapture->setResolution(1920,1080);
-            m_imageCapture->setQuality(QImageCapture::VeryHighQuality);
-            m_imageCapture->setFileFormat(QImageCapture::JPEG);
-            qDebug() <<"捕获质量:" <<m_imageCapture->quality();
-            qDebug() <<"捕获像素:" <<m_imageCapture->resolution();
-            qDebug() <<"捕获格式:" <<m_imageCapture->fileFormat();
-
-            m_imageCapture->captureToFile();
-
-        }
-    }else if(param::camera_type.contains("uvc")||param::camera_type.contains("hikrobot")){
-        setCameraSw(true);
-        // 延时10S后触发拍照
-        QTimer::singleShot(10000, [](){
-            LOG("立即拍照!");
-            param::camera_tc = 100;
-            //创建文件夹
-        });
-    }
-}
-
-void
-Frames::readyForCapture(bool ready)
-{
-    Q_UNUSED(ready);
-    const QList<QSize> supportedResolutions = m_imageCapture->captureSession()->camera()->cameraDevice().photoResolutions();
-    // 初始化最大分辨率为一个较小的值
-    QSize maxResolution = QSize(0, 0);
-    for (const QSize &resolution : supportedResolutions) {
-        qDebug() << "readyForCapture Resolution" <<QString("%1x%2").arg(resolution.width()).arg(resolution.height()),
-                QVariant(resolution);
-        // 更新最大分辨率
-        if (resolution.width() > maxResolution.width() && resolution.height() > maxResolution.height()) {
-            maxResolution = resolution;
-        }
-    }
-    m_imageCapture->setResolution(1920,1080);
-    m_imageCapture->setQuality(QImageCapture::VeryHighQuality);
-    m_imageCapture->setFileFormat(QImageCapture::JPEG);
-}
-
-void
-Frames::processCapturedImage(int requestId, const QImage &img){
-    Q_UNUSED(requestId);
-    m_image = img;
-    qDebug() <<"processCapturedImage";
-}
-
-void
-Frames::displayCaptureError(int id, const QImageCapture::Error error, const QString &errorString){
-    Q_UNUSED(id);
-    Q_UNUSED(error);
-    qDebug() <<"Image Capture Error:"<<errorString;
-}
-
-void
-Frames::imageSaved(int id, const QString &fileName){
-    Q_UNUSED(id);
-    qDebug() <<"imageSaved:" <<fileName;
-}
-
-void
-Frames::displayCameraError(){
-    if(m_cam->error()!=QCamera::NoError){
-        qDebug() <<"displayCameraError:" <<m_cam->errorString();
-    }
+    setCameraSw(true);
+    // 延时10S后触发拍照
+    QTimer::singleShot(10000, [](){
+        LOG("立即拍照!");
+        param::camera_tc = 100;
+        //创建文件夹
+    });
 }
 
 
-
 } /* namespace Qt6QCamera */

+ 1 - 1
q6_felgo_iot/src/m_json.cpp

@@ -109,7 +109,7 @@ JsonFunc::BoardMessage()
     } else {
         net_value="1";
     }
-
+    param::csq = getLteRsrp();
     QByteArray transmitDataTemp;
     // 定义 { } 对象
     QJsonObject mesageObj;

+ 14 - 8
q6_felgo_iot/src/main.cpp

@@ -12,7 +12,7 @@
 #include <TreeModel.h>
 #include <app_curlFunc.h>
 
-// uncomment this line to add the Live Client Module and use live reloading with your custom C++ code
+//uncomment this line to add the Live Client Module and use live reloading with your custom C++ code
 //#include <FelgoLiveClient>
 
 class param;
@@ -199,8 +199,11 @@ void sendBroadcastFromQt(QString btn_type) {
                 LOG("IMEI:{}",param::imei.toStdString());
             }
         }else if(btn_type=="csq"){
-            jClass.callMethod<void>("getMobileNetworkSignal","(Landroid/content/Context;)V",qtContext.object());
-
+            jint rsrp = QJniObject::callStaticMethod<jint>("com/yfkj/cb/Q6iot/StatusBarCtr",
+                                                           "getRsrp",
+                                                           "(Landroid/content/Context;)I",
+                                                           qtContext.object());
+            LOG("getRsrp:{}",rsrp);
         }else if(btn_type=="iccid"){
             QJniObject jClass("com/yfkj/cb/Q6iot/StatusBarCtr");
             QJniObject iccid_java = jClass.callObjectMethod("getICCID","(Landroid/content/Context;)Ljava/lang/String;",qtContext.object());
@@ -266,11 +269,10 @@ int main(int argc, char *argv[])
     //sendBroadcastFromQt("service");
     // get android storage permisson
     // 该接口也可以直接使用字符串,可自行跳转到头文件自行查看
-    if (QtAndroidPrivate::checkPermission(QtAndroidPrivate::Storage).result() == QtAndroidPrivate::Denied)
-    {
-        QtAndroidPrivate::requestPermission(QtAndroidPrivate::Storage).waitForFinished();
-    }
-    qInfo() << "anroid storage permission status: " << QtAndroidPrivate::checkPermission(QtAndroidPrivate::Storage).result();
+    QtAndroidPrivate::checkPermission("android.permission.WRITE_EXTERNAL_STORAGE");
+
+    QtAndroidPrivate::requestPermission("android.permission.WRITE_EXTERNAL_STORAGE");
+
 
     sendBroadcastFromQt("sleep");
     //启动铃声
@@ -483,9 +485,13 @@ int main(int argc, char *argv[])
     });
     QObject::connect(&uploader_ftp, &CurlFtpUploader::finished,
                      &mqttHandler,&MqttHandler::storage_Picture);
+
     QObject::connect(&mqttHandler, &MqttHandler::signal_reupload_image,
                      &uploader_ftp,&CurlFtpUploader::uploadFileAsync);
 
+    QObject::connect(&mqttHandler, &MqttHandler::signal_upload_log,
+                     &uploader_ftp,&CurlFtpUploader::uploadFileAsync);
+
     QObject::connect(&mqttHandler,&MqttHandler::updateStm32,[&](){
         curlHandler.seturl("ftp://8.136.98.49/_UPDATE_FILE/A7/STM32/Application_BZYV2.rbl");
         curlHandler.setfilepath(appDataPath+"/rtthread.rbl");

+ 38 - 26
q6_felgo_iot/src/mqtthandler.cpp

@@ -76,14 +76,14 @@ MqttHandler::MqttHandler(QObject *parent)
     connect(this, &MqttHandler::mediaplay, this,&MqttHandler::playSound);
     connect(this,&MqttHandler::appInstall,this,&MqttHandler::install_app);
     connect(image_reupload,&QTimer::timeout,this,[=](){
-        LOG("图片重传:{}!",m_client->state());
+        LOG("图片重传:{}!",static_cast<int>(m_client->state()));
         if(param::ptlist.size()==0&&m_storage->ImageEntries_saved()>0){
             auto pendingImage = m_storage->getPendingImagePaths(1);
             if(pendingImage.isEmpty()){ERROR("无数据!");}
             for (const auto &item : pendingImage) {
                 int dbId = item.first;           // 数据库 id
                 QString path_image = item.second;
-                LOG("触发重传,图片缓存路径:{}",path_image.toStdString());
+                LOG("触发重传,图片缓存路径:{} id:{}",path_image.toStdString(),dbId);
                 //发射信号开始上传
                 emit signal_reupload_image(path_image);
             }
@@ -190,7 +190,7 @@ MqttHandler::subscribe_m(const QString &m_topic)
     {
        auto m_sub =  m_client->subscribe(m_topic);
        if(!m_sub){
-            qDebug() <<"订阅失败!";
+           ERROR("订阅失败!");
        }
     }
 }
@@ -238,11 +238,35 @@ MqttHandler::onMessageReceived(const QByteArray &message, const QMqttTopicName &
     this->m_client_rxByte += tc->toUnicode(m_client_dataBuf).length();
     QJsonDocument jsonDocument = QJsonDocument::fromJson(m_client_dataBuf, &error);
     emit mqttclient_readSuccess(this->m_client_rxByte);
-    qDebug() << "Received message:" << m_client_dataBuf << "on topic:" << topic.name();
+    LOG("Received message:{} on topic:{}",m_client_dataBuf.constData(),topic.name().toStdString());
     if (error.error == QJsonParseError::NoError && jsonDocument.isObject()) {
         QJsonObject jsonObject = jsonDocument.object();
         QJsonValue cmdValue = jsonObject["cmd"];
         QJsonValue extValue = jsonObject["ext"];
+        QJsonValue JSONRPC = jsonObject["jsonrpc"];
+        QJsonValue METHOD = jsonObject["method"];
+        QJsonValue PARAMS = jsonObject["params"];
+        QJsonValue ID = jsonObject["id"];
+        if(!JSONRPC.isNull()&&!METHOD.isNull()&&!ID.isNull()){
+            if(METHOD.isString()){
+                if(METHOD.toString()=="upload_log"&&!PARAMS.isNull()){
+                    QJsonObject params_Obj = PARAMS.toObject();
+                    QJsonValue filename_value = params_Obj["filename"];
+                    QString appDataPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
+                    QString logFilePath = appDataPath +"/" + filename_value.toString();
+                    // 1. 创建临时副本
+                    QString tempLogFile = QDir::tempPath() + "/temp_log_" +
+                                          QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss") + ".txt";
+                    if (QFile::copy(logFilePath, tempLogFile)) {
+                        // 2. 上传副本文件
+                        emit signal_upload_log(tempLogFile);
+                        // 3. 可选:设置定时器删除临时文件
+                    } else {
+                        WARN("无法复制日志文件:{}",logFilePath.toStdString());
+                    }
+                }
+            }
+        }
         if(!cmdValue.isNull()){
              QString value_cmd = cmdValue.toString();
              if(value_cmd=="reboot"){
@@ -266,7 +290,7 @@ MqttHandler::onMessageReceived(const QByteArray &message, const QMqttTopicName &
                         if(typeValue.toString().contains("auto_takephoto")){
                             param::camera_tc = 0;
                             param::ptlist.clear();
-                            qDebug() <<"emit autotakephoto()";
+                            LOG("emit autotakephoto()");
                             emit autotakephoto(true);
                         }
                         if(typeValue.toString()=="takephoto"){
@@ -281,22 +305,7 @@ MqttHandler::onMessageReceived(const QByteArray &message, const QMqttTopicName &
                     }
 
                 }
-             //{"cmd": "sqlite", "ext": {"stitch_photonum": "2"}}
-             }else if(value_cmd=="sqlite"){     //修改配置信息
-                if(extValue.isObject()){
-                    QJsonObject extObj = extValue.toObject();
-                    QJsonValue qValue = extObj["stitch_photonum"];
-                    if(!qValue.isNull()&&qValue.isString()){
-                        QString value_int0 = qValue.toString();
-                        if(value_int0.toUInt()==1||value_int0.toUInt()==2||value_int0.toUInt()==4){
-                            param::stitch_photonum = value_int0.toUInt();
-                        }
-
-                        qDebug() <<"修改拼接数量:"<<param::stitch_photonum;
-                        emit configChange();
-                    }
-
-                }
+             //{"cmd": "setimei", "ext": {"imei": "2"}}
              }else if(value_cmd=="setimei"){
                  if(extValue.isObject()){
                      QJsonObject extObj = extValue.toObject();
@@ -395,7 +404,7 @@ MqttHandler::onMessageReceived(const QByteArray &message, const QMqttTopicName &
 void
 MqttHandler::reConnect()
 {
-    qDebug() << "reConnect";
+    WARN("reConnect.");
     // Attempt to reconnect after a delay
     m_client->connectToHost();
 
@@ -426,7 +435,7 @@ void MqttHandler::startReupload()
         QByteArray json = item.second.second;
         quint16  msgId = m_client->publish(topic, json);
         if (msgId == 0) {
-            qDebug() << "JSON 消息上传成功,删除数据库记录 id:" << dbId;
+            LOG("JSON 消息上传成功,删除数据库记录 id:{}",dbId);
             m_storage->markJsonUploaded(dbId); // ✅ 真正删除/标记
             // // 注册回调:上传成功后删除数据库记录
             // m_pendingAcks[msgId] = [this, dbId](bool success) {
@@ -438,18 +447,21 @@ void MqttHandler::startReupload()
     }
 }
 
-//保存上传失败的图片,并进行重命名处理
+//保存上传失败的图片,并进行重命名处理,只处理jpg格式
 void MqttHandler::storage_Picture(bool success,const QString &path)
 {
     if(success){
         m_storage->markImageUploaded(path);
     }else{
-        if(!path.contains("history")){
+        if(!path.contains("history")&&path.contains("jpg")){
             m_storage->cacheImagePath(path);
             // QTimer::singleShot(5000, [&](){
             //     m_storage->cacheImagePath(path);
             // });
-        }else{
+        }else if(path.contains("txt")){
+            QFile::remove(path);
+        }
+        else{
             WARN("图片已入库...");
         }
     }

+ 23 - 9
q6_felgo_iot/src/mserial.cpp

@@ -227,21 +227,35 @@ void SerialThread::stop()
 void SerialThread::sendData(const QByteArray &data)
 {
     emit netMessage(data);
-    LOG("sendData:{}",data.constData());
-    //拼接流程串口异常处理
-    if(data.contains("movx") ||data.contains("movz")) {
-        //启动定时器,超时后主动停止 param::camera_tc = 1;
-        timeout_mov->start(10000);  //超时时间10S
+
+    LOG("sendData(size={}): {}", data.size(), data.toStdString());
+
+    if (data.startsWith("movx") || data.startsWith("movz")) {
+        timeout_mov->start(10000);
+    }
+
+    if (data.contains("auto_focus")) {
+        emit autoFocusStart();
+    }
+
+    if (!m_serialPort.isOpen())
+        return;
+
+    const qint64 len = data.size();
+    if (len <= 0 || len > 4096) {
+        LOG("❌ refuse write len={}", len);
+        return;
     }
-    if(data.contains("auto_focus")) emit autoFocusStart();  //启动定时器
 
-    if (m_serialPort.isOpen()) {
-        m_serialPort.write(data);
-        m_serialPort.flush();
+    QMutexLocker locker(&m_writeMutex);
+    qint64 ret = m_serialPort.write(data.constData(), len);
+    if (ret != len) {
+        LOG("⚠️ serial write partial {}/{}", ret, len);
     }
 }
 
 
+
 void
 SerialThread::processJsonData(const QByteArray &jsonData)
 {