|
|
@ -32,42 +32,57 @@ bool GpioControl::m_cameraPowerStatus = false;
|
|
|
|
|
|
|
|
|
|
|
|
size_t GpioControl::turnOnImpl(const IOT_PARAM& param)
|
|
|
|
size_t GpioControl::turnOnImpl(const IOT_PARAM& param)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
size_t oldRef = 0;
|
|
|
|
size_t references = 1;
|
|
|
|
size_t references = 1;
|
|
|
|
std::vector<ITEM>::iterator it;
|
|
|
|
std::vector<ITEM>::iterator it;
|
|
|
|
int res = 0;
|
|
|
|
int res = 0;
|
|
|
|
int fd = -1;
|
|
|
|
int fd = -1;
|
|
|
|
time_t now = time(NULL);
|
|
|
|
time_t now = time(NULL);
|
|
|
|
|
|
|
|
|
|
|
|
fd = open(GPIO_NODE_MP, O_RDONLY);
|
|
|
|
m_locker.lock();
|
|
|
|
if( fd > 0 )
|
|
|
|
|
|
|
|
|
|
|
|
// check res???
|
|
|
|
|
|
|
|
for (it = m_items.begin(); it != m_items.end(); ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res = ioctl(fd, IOT_PARAM_WRITE, ¶m);
|
|
|
|
if (it->cmd == param.cmd)
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
// check res???
|
|
|
|
|
|
|
|
for (it = m_items.begin(); it != m_items.end(); ++it)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->cmd == param.cmd)
|
|
|
|
oldRef = it->references;
|
|
|
|
{
|
|
|
|
it->references++;
|
|
|
|
it->references++;
|
|
|
|
// it->closeTime = 0;
|
|
|
|
// it->closeTime = 0;
|
|
|
|
references = it->references;
|
|
|
|
references = it->references;
|
|
|
|
if(it->openTime == 0)
|
|
|
|
if(it->openTime == 0)
|
|
|
|
it->openTime = now;
|
|
|
|
it->openTime = now;
|
|
|
|
SetCamerastatus(it->cmd, true);
|
|
|
|
SetCamerastatus(it->cmd, true);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (it == m_items.end())
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it == m_items.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
oldRef = 0;
|
|
|
|
|
|
|
|
ITEM item = {param.cmd, references, 0, 0, now};
|
|
|
|
|
|
|
|
m_items.push_back(item);
|
|
|
|
|
|
|
|
SetCamerastatus(param.cmd, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_locker.unlock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (oldRef == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fd = open(GPIO_NODE_MP, O_RDONLY);
|
|
|
|
|
|
|
|
if( fd > 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ITEM item = {param.cmd, references, 0, 0, now};
|
|
|
|
res = ioctl(fd, IOT_PARAM_WRITE, ¶m);
|
|
|
|
m_items.push_back(item);
|
|
|
|
close(fd);
|
|
|
|
SetCamerastatus(param.cmd, true);
|
|
|
|
#ifdef OUTPUT_DBG_INFO
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "setInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#ifdef _DEBUG
|
|
|
|
ALOGI("PWR TurnOn cmd=%d,result=%d ref=%u\r\n",param.cmd, param.result, (uint32_t)references);
|
|
|
|
ALOGI("PWR TurnOn cmd=%d,result=%d ref=%u\r\n",param.cmd, param.result, (uint32_t)references);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return references;
|
|
|
|
return references;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -81,10 +96,11 @@ void GpioControl::setInt(int cmd, int value)
|
|
|
|
if (fd > 0)
|
|
|
|
if (fd > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int res = ioctl(fd, IOT_PARAM_WRITE, ¶m);
|
|
|
|
int res = ioctl(fd, IOT_PARAM_WRITE, ¶m);
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
#ifdef OUTPUT_DBG_INFO
|
|
|
|
#ifdef OUTPUT_DBG_INFO
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "setInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
|
|
|
|
int realVal = getInt(param.cmd);
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "setInt cmd=%d,value=%d,result=%d RealVal=%d",param.cmd, param.value, param.result, realVal);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|