diff --git a/app/src/main/cpp/GPIOControl.cpp b/app/src/main/cpp/GPIOControl.cpp index 1619c2d4..fd1227e1 100644 --- a/app/src/main/cpp/GPIOControl.cpp +++ b/app/src/main/cpp/GPIOControl.cpp @@ -35,6 +35,7 @@ size_t GpioControl::turnOnImpl(const IOT_PARAM& param) std::vector::iterator it; int res = 0; int fd = -1; + time_t now = time(NULL); fd = open(GPIO_NODE_MP, O_RDONLY); if( fd > 0 ) @@ -49,13 +50,16 @@ size_t GpioControl::turnOnImpl(const IOT_PARAM& param) it->references++; // it->closeTime = 0; references = it->references; + if(it->openTime == 0) + it->openTime = now; SetCamerastatus(it->cmd, true); break; } } if (it == m_items.end()) { - ITEM item = {param.cmd, references, 0, 0}; + ITEM item = {param.cmd, references, 0, 0, 0}; + item.openTime = now; m_items.push_back(item); SetCamerastatus(param.cmd, true); } @@ -328,7 +332,10 @@ bool GpioControl::SetCamerastatus(int cmd, bool status) #endif #ifdef USING_PLZ if(cmd == CMD_SET_PTZ_PWR_ENABLE) + { m_cameraPowerStatus = status; + } + #endif return true; } @@ -337,6 +344,28 @@ bool GpioControl::GetCamerastatus() return m_cameraPowerStatus; } +bool GpioControl::GetSelftestStatus(time_t wait_time) +{ + int cmd; +#ifdef USING_N938 + cmd = CMD_SET_PIC1_POWER; +#endif +#ifdef USING_PLZ + cmd = CMD_SET_PTZ_PWR_ENABLE; +#endif + time_t now = time(NULL); + std::vector::iterator it; + for (it = m_items.begin(); it != m_items.end(); ++it) + { + if (it->cmd == cmd && (now - it->openTime >= wait_time)) + { + return true; + } + } + return false; + +} + void GpioControl::PowerControlThreadProc() { time_t ts = 0; @@ -389,6 +418,7 @@ void GpioControl::PowerControlThreadProc() // close it directly setInt(it->cmd, 0); it->closeTime = 0; + it->openTime = 0; #ifdef _DEBUG ALOGI("PWR THREAD DO TurnOff cmd=%d", it->cmd); #endif diff --git a/app/src/main/cpp/GPIOControl.h b/app/src/main/cpp/GPIOControl.h index 09752c38..3f8716a6 100644 --- a/app/src/main/cpp/GPIOControl.h +++ b/app/src/main/cpp/GPIOControl.h @@ -154,6 +154,7 @@ public: size_t references; size_t closeCmds; time_t closeTime; + time_t openTime; }; private: @@ -179,6 +180,7 @@ public: static size_t TurnOffImmediately(int cmd); static bool SetCamerastatus(int cmd, bool status); static bool GetCamerastatus(); + static bool GetSelftestStatus(time_t wait_time); static void PowerControlThreadProc(); diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index fe6972ff..6855ba5b 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1491,8 +1491,11 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c // AutoEnv autoEnv(pThis->m_vm); time_t ts = time(NULL); uint32_t waitTime = localPhotoInfo.selfTestingTime; - waitTime = (waitTime!= 0) ? (waitTime * 1024) : 10240; - std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); + if(!GpioControl::GetSelftestStatus(waitTime)) + { + waitTime = (waitTime != 0) ? (waitTime * 1024) : 10240; + std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); + } SetStaticIp(); std::this_thread::sleep_for(std::chrono::milliseconds(256));