优化网络打开时间

lowmem
Matthew 2 months ago
parent 5dae67b03b
commit 38a8498dbc

@ -1604,24 +1604,19 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
#endif #endif
XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Power ON"); XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Power ON");
std::shared_ptr<PowerControl> ethernetPowerCtrl = std::make_shared<EthernetPowerCtrl>(localPhotoInfo.closeDelayTime);
uint32_t netWaitTime = (localPhotoInfo.cameraType == CAM_TYPE_PLZ) ? 20 : 4; std::this_thread::sleep_for(std::chrono::milliseconds(5000));
std::shared_ptr<PowerControl> ethernetPowerCtrl = std::make_shared<EthernetPowerCtrl>(netWaitTime); net_handle_t netHandle = 0;
net_handle_t netHandle = GetEthnetHandle();
if (netHandle == 0)
{
// Wait about 10s // Wait about 10s
for (int idx = 0; idx < 84; idx++) for (int idx = 0; idx < 84; idx++)
{ {
std::this_thread::sleep_for(std::chrono::milliseconds(128));
netHandle = GetEthnetHandle(); netHandle = GetEthnetHandle();
if (netHandle != 0) if (netHandle != 0)
{ {
break; break;
} }
} std::this_thread::sleep_for(std::chrono::milliseconds(128));
} }
if (netHandle == 0) if (netHandle == 0)
@ -1666,7 +1661,11 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
XYLOG(XYLOG_SEVERITY_INFO, "Ethernet is Available Handle=%llu IP=%s CH=%u PR=%X PHOTOID=%u", (uint64_t)netHandle, buf, (uint32_t)localPhotoInfo.channel, (uint32_t)localPhotoInfo.preset, localPhotoInfo.photoId); XYLOG(XYLOG_SEVERITY_INFO, "Ethernet is Available Handle=%llu IP=%s CH=%u PR=%X PHOTOID=%u", (uint64_t)netHandle, buf, (uint32_t)localPhotoInfo.channel, (uint32_t)localPhotoInfo.preset, localPhotoInfo.photoId);
} }
// SetStaticIp(); if (mBuildTime < 1738166400)
{
// 2025-01-30
SetStaticIp();
}
std::this_thread::sleep_for(std::chrono::milliseconds(256)); std::this_thread::sleep_for(std::chrono::milliseconds(256));
std::string ip = GetIpStr(localPhotoInfo.ip); std::string ip = GetIpStr(localPhotoInfo.ip);
@ -1743,14 +1742,13 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
} }
img.clear(); img.clear();
netCaptureResult = requestCapture(localPhotoInfo.channel, localPhotoInfo.preset, netPhotoInfo, img); netCaptureResult = vendorCtrl->TakePhoto(localPhotoInfo.cameraId, img);
if (netCaptureResult && !img.empty()) if (netCaptureResult && !img.empty())
{ {
if(img.size() <= 1000) if(img.size() <= 1000)
{ {
lastError = ByteArrayToString(&img[0], img.size()); lastError = ByteArrayToString(&img[0], img.size());
// XYLOG(XYLOG_SEVERITY_DEBUG,"Img Size<1000, img=%s", hexStr.c_str());
} }
rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR); rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR);
if (!rgb.empty()) if (!rgb.empty())
@ -2258,8 +2256,11 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
{ {
uint32_t waitTime = localPhotoInfo.selfTestingTime; uint32_t waitTime = localPhotoInfo.selfTestingTime;
XYLOG(XYLOG_SEVERITY_INFO, "Camera is SelfTesting Time=%u s", waitTime); XYLOG(XYLOG_SEVERITY_INFO, "Camera is SelfTesting Time=%u s", waitTime);
waitTime = (waitTime != 0) ? (waitTime * 1024) : 10240; waitTime = (waitTime <= 5 ) ? 0 : ((waitTime - 5) * 1024);
if (waitTime > 0)
{
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); std::this_thread::sleep_for(std::chrono::milliseconds(waitTime));
}
XYLOG(XYLOG_SEVERITY_INFO, "Camera SeltTesting Finished"); XYLOG(XYLOG_SEVERITY_INFO, "Camera SeltTesting Finished");
pThis->TakePhotoWithNetCamera(localPhotoInfo, path, osds, powerCtrlPtr); pThis->TakePhotoWithNetCamera(localPhotoInfo, path, osds, powerCtrlPtr);
@ -4371,7 +4372,6 @@ net_handle_t CPhoneDevice::GetEthnetHandle() const
void CPhoneDevice::SetStaticIp(const std::string& iface, const std::string& ip, const std::string& netmask, const std::string& gateway) void CPhoneDevice::SetStaticIp(const std::string& iface, const std::string& ip, const std::string& netmask, const std::string& gateway)
{ {
JNIEnv* env = NULL; JNIEnv* env = NULL;
jboolean ret = JNI_FALSE; jboolean ret = JNI_FALSE;
bool didAttachThread = false; bool didAttachThread = false;

Loading…
Cancel
Save