From 34a1c4377b67e8beef64f29eca4921264e0baa3c Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 15 Mar 2025 14:43:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A5=E5=A4=AA=E7=BD=91=E8=B6=85=E8=BF=873?= =?UTF-8?q?=E6=AC=A1=E6=89=BE=E4=B8=8D=E5=88=B0=EF=BC=8C=E5=88=99=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E8=AE=BE=E5=A4=87=EF=BC=8830=E5=88=86=E9=92=9F?= =?UTF-8?q?=E5=86=85=E4=B8=8D=E9=87=8D=E5=A4=8D=E9=87=8D=E5=90=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 19 ++++++++++++++++--- app/src/main/cpp/PhoneDevice.h | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 79aac15e..7e3c7b18 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -488,7 +488,7 @@ int32_t CPhoneDevice::CJpegCamera::getOutputFormat() const } CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, uint64_t activeNetHandle, unsigned int versionCode, const std::string& nativeLibDir) - : mVersionCode(versionCode), m_nativeLibraryDir(nativeLibDir), m_network(NULL), m_defNetHandle(activeNetHandle), m_ethnetHandle(NETWORK_UNSPECIFIED) + : mVersionCode(versionCode), m_nativeLibraryDir(nativeLibDir), m_network(NULL), m_defNetHandle(activeNetHandle), m_ethnetHandle(NETWORK_UNSPECIFIED), m_ethernetFailures(0) { mCamera = NULL; m_listener = NULL; @@ -1571,15 +1571,28 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c if (netHandle == 0) { // timeout + m_ethernetFailures++; + std::string pwrStatus = powerCtrlPtr->GetStatus(); pwrStatus += ethernetPowerCtrl->GetStatus(); - XYLOG(XYLOG_SEVERITY_ERROR, "Ethernet Not Existing CH=%u PR=%X PHOTOID=%u PWR:%s", - (uint32_t)localPhotoInfo.channel, (uint32_t)localPhotoInfo.preset, localPhotoInfo.photoId, pwrStatus.c_str()); + XYLOG(XYLOG_SEVERITY_ERROR, "Ethernet Not Existing CH=%u PR=%X PHOTOID=%u EthFailures=%u PWR:%s", + (uint32_t)localPhotoInfo.channel, (uint32_t)localPhotoInfo.preset, localPhotoInfo.photoId, m_ethernetFailures, pwrStatus.c_str()); TakePhotoCb(0, localPhotoInfo, "", 0); + if (m_ethernetFailures > 3) + { + time_t rebootTime = GetRebootTime(); + if (ts - rebootTime > 1800) + { + Reboot(REBOOT_TYPE_DEVICE, false, "Ethernet Not Existing"); + } + } + return false; } else { + m_ethernetFailures = 0; + unsigned int ip = 0; unsigned int netMask = 0; unsigned int gateway = 0; diff --git a/app/src/main/cpp/PhoneDevice.h b/app/src/main/cpp/PhoneDevice.h index d51b5c82..5c4b330f 100644 --- a/app/src/main/cpp/PhoneDevice.h +++ b/app/src/main/cpp/PhoneDevice.h @@ -408,6 +408,8 @@ protected: std::thread m_threadClose; std::shared_ptr m_powerCtrlPtr; + uint32_t m_ethernetFailures; + int m_signalLevel; time_t m_signalLevelUpdateTime;