|
|
|
@ -417,10 +417,6 @@ int32_t CPhoneDevice::CJpegCamera::getOutputFormat() const
|
|
|
|
|
return AIMAGE_FORMAT_JPEG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::mutex CPhoneDevice::m_powerLocker;
|
|
|
|
|
long CPhoneDevice::mCameraPowerCount = 0;
|
|
|
|
|
long CPhoneDevice::mOtgCount = 0;
|
|
|
|
|
|
|
|
|
|
CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, unsigned int netId, unsigned int versionCode, const std::string& nativeLibDir)
|
|
|
|
|
: mVersionCode(versionCode), m_nativeLibraryDir(nativeLibDir), m_network(NULL), m_netHandle(NETWORK_UNSPECIFIED)
|
|
|
|
|
{
|
|
|
|
@ -493,7 +489,7 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa
|
|
|
|
|
m_uniqueIdFeed = (unsigned long)m_timerUidFeed;
|
|
|
|
|
|
|
|
|
|
#ifdef USING_NRSEC
|
|
|
|
|
TurnOnCameraPower(env);
|
|
|
|
|
GpioControl::setCam3V3Enable(true);
|
|
|
|
|
GpioControl::setSpiPower(true);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -671,16 +667,16 @@ bool CPhoneDevice::SelfTest(std::string& result)
|
|
|
|
|
params.burstCaptures = 1;
|
|
|
|
|
if (usbCamera)
|
|
|
|
|
{
|
|
|
|
|
TurnOnOtg(NULL);
|
|
|
|
|
GpioControl::setOtgState(true);
|
|
|
|
|
}
|
|
|
|
|
TurnOnCameraPower(NULL);
|
|
|
|
|
GpioControl::setCam3V3Enable(true);
|
|
|
|
|
|
|
|
|
|
NdkCamera camera(width, height, params);
|
|
|
|
|
int res = camera.selfTest(std::to_string(cameraId), width, height);
|
|
|
|
|
TurnOffCameraPower(NULL);
|
|
|
|
|
GpioControl::setCam3V3Enable(false);
|
|
|
|
|
if (usbCamera)
|
|
|
|
|
{
|
|
|
|
|
TurnOffOtg(NULL);
|
|
|
|
|
GpioControl::setOtgState(false);
|
|
|
|
|
}
|
|
|
|
|
if (res == 0)
|
|
|
|
|
{
|
|
|
|
@ -1457,17 +1453,17 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
|
|
|
|
|
if (photoInfo.cameraType == CAM_TYPE_USB || photoInfo.cameraType == CAM_TYPE_NET)
|
|
|
|
|
{
|
|
|
|
|
TurnOnOtg(NULL);
|
|
|
|
|
GpioControl::setOtgState(true);
|
|
|
|
|
}
|
|
|
|
|
if (photoInfo.cameraType == CAM_TYPE_NET)
|
|
|
|
|
{
|
|
|
|
|
GpioControl::set12VEnable(true);
|
|
|
|
|
#ifdef USING_N938
|
|
|
|
|
GpioControl::setInt(CMD_SET_NETWORK_POWER_EN, 1);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN_STATE, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_NETWORK_POWER_EN);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_485_EN_STATE);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
TurnOnCameraPower(NULL);
|
|
|
|
|
GpioControl::setCam3V3Enable(true);
|
|
|
|
|
|
|
|
|
|
res = true;
|
|
|
|
|
if ((mPhotoInfo.mediaType == 0) && ((mPhotoInfo.cameraType == CAM_TYPE_MIPI) || (mPhotoInfo.cameraType == CAM_TYPE_USB)))
|
|
|
|
@ -1521,10 +1517,10 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
mCamera = NULL;
|
|
|
|
|
res = false;
|
|
|
|
|
|
|
|
|
|
TurnOffCameraPower(NULL);
|
|
|
|
|
GpioControl::setCam3V3Enable(false);
|
|
|
|
|
if (photoInfo.usbCamera)
|
|
|
|
|
{
|
|
|
|
|
TurnOffOtg(NULL);
|
|
|
|
|
GpioControl::setOtgState(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasFatalError)
|
|
|
|
@ -1575,11 +1571,11 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Ethernet not existing CH=%u PR=%X PHOTOID=%u", (uint32_t)localPhotoInfo.channel, (uint32_t)localPhotoInfo.preset, localPhotoInfo.photoId);
|
|
|
|
|
pThis->TakePhotoCb(0, localPhotoInfo, "", 0);
|
|
|
|
|
|
|
|
|
|
TurnOffOtg(NULL);
|
|
|
|
|
GpioControl::setOtgState(false);
|
|
|
|
|
GpioControl::set12VEnable(false);
|
|
|
|
|
#ifdef USING_N938
|
|
|
|
|
GpioControl::setInt(CMD_SET_NETWORK_POWER_EN, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN_STATE, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_NETWORK_POWER_EN);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN_STATE);
|
|
|
|
|
#endif
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -1609,11 +1605,11 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Vendor(%u) not Supported CH=%u PR=%X PHOTOID=%u", (uint32_t)localPhotoInfo.vendor, (uint32_t)localPhotoInfo.channel, (unsigned int)localPhotoInfo.preset, localPhotoInfo.photoId);
|
|
|
|
|
pThis->TakePhotoCb(0, localPhotoInfo, "", 0);
|
|
|
|
|
|
|
|
|
|
TurnOffOtg(NULL);
|
|
|
|
|
GpioControl::setOtgState(false);
|
|
|
|
|
GpioControl::set12VEnable(false);
|
|
|
|
|
#ifdef USING_N938
|
|
|
|
|
GpioControl::setInt(CMD_SET_NETWORK_POWER_EN, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN_STATE, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_NETWORK_POWER_EN);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN_STATE);
|
|
|
|
|
#endif
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -1651,11 +1647,11 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TurnOffOtg(NULL);
|
|
|
|
|
GpioControl::setOtgState(false);
|
|
|
|
|
GpioControl::set12VEnable(false);
|
|
|
|
|
#ifdef USING_N938
|
|
|
|
|
GpioControl::setInt(CMD_SET_NETWORK_POWER_EN, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN_STATE, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_NETWORK_POWER_EN);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN_STATE);
|
|
|
|
|
#endif
|
|
|
|
|
if (netCaptureResult)
|
|
|
|
|
{
|
|
|
|
@ -3395,34 +3391,6 @@ void CPhoneDevice::UpdatePosition(double lon, double lat, double radius, time_t
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::TurnOnCameraPower(JNIEnv* env)
|
|
|
|
|
{
|
|
|
|
|
m_powerLocker.lock();
|
|
|
|
|
GpioControl::setCam3V3Enable(true);
|
|
|
|
|
m_powerLocker.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::TurnOffCameraPower(JNIEnv* env)
|
|
|
|
|
{
|
|
|
|
|
m_powerLocker.lock();
|
|
|
|
|
GpioControl::setCam3V3Enable(false);
|
|
|
|
|
m_powerLocker.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::TurnOnOtg(JNIEnv* env)
|
|
|
|
|
{
|
|
|
|
|
m_powerLocker.lock();
|
|
|
|
|
GpioControl::setInt(CMD_SET_OTG_STATE, 1);
|
|
|
|
|
m_powerLocker.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::TurnOffOtg(JNIEnv* env)
|
|
|
|
|
{
|
|
|
|
|
m_powerLocker.lock();
|
|
|
|
|
GpioControl::setInt(CMD_SET_OTG_STATE, 0);
|
|
|
|
|
m_powerLocker.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::UpdateSignalLevel(int signalLevel)
|
|
|
|
|
{
|
|
|
|
|
m_signalLevel = signalLevel;
|
|
|
|
@ -3646,18 +3614,18 @@ bool CPhoneDevice::OpenSensors(int sensortype)
|
|
|
|
|
GpioControl::set12VEnable(true);
|
|
|
|
|
GpioControl::setCam3V3Enable(true);
|
|
|
|
|
GpioControl::setRS485Enable(true);
|
|
|
|
|
GpioControl::setInt(CMD_SET_SPI_POWER, 1);
|
|
|
|
|
// GpioControl::setInt(CMD_SET_485_EN_STATE, 1); // 打开RS485电源
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_SPI_POWER);
|
|
|
|
|
// GpioControl::TurnOn(CMD_SET_485_EN_STATE); // 打开RS485电源
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#ifndef USING_PLZ
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN_STATE, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_485_EN_STATE);
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_ENABLE, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_485_ENABLE);
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SPI2SERIAL_POWER_EN, 1);
|
|
|
|
|
GpioControl::setInt(CMD_RS485_3V3_EN, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SPI2SERIAL_POWER_EN);
|
|
|
|
|
GpioControl::TurnOn(CMD_RS485_3V3_EN);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
if(sensortype == CAMERA_SENSOR_OPEN)
|
|
|
|
@ -3665,39 +3633,39 @@ bool CPhoneDevice::OpenSensors(int sensortype)
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#ifndef USING_PLZ
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_PTZ_PWR_ENABLE, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_PTZ_PWR_ENABLE);
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_PIC1_POWER, 1);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN4, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_PIC1_POWER);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_485_EN4);
|
|
|
|
|
#endif
|
|
|
|
|
// GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, 1); // 打开3.3V电压
|
|
|
|
|
// GpioControl::setInt(CMD_SET_3V3_PWR_ENABLE, 1);
|
|
|
|
|
// GpioControl::TurnOn(CMD_SET_CAM_3V3_EN_STATE); // 打开3.3V电压
|
|
|
|
|
// GpioControl::TurnOn(CMD_SET_3V3_PWR_ENABLE);
|
|
|
|
|
}
|
|
|
|
|
if(sensortype == WEATHER_SENSOR_OPEN)
|
|
|
|
|
{
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_WTH_POWER, 1);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN3, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_WTH_POWER);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_485_EN3);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
if(sensortype == ICETHICK_SENSOR_OPEN)
|
|
|
|
|
{
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_PULL_POWER, 1);
|
|
|
|
|
GpioControl::setInt(CMD_SET_ANGLE_POWER, 1);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN1, 1);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN0, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_PULL_POWER, 0);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_ANGLE_POWER, 0);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_485_EN1, 0);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_485_EN0, 0);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
if(sensortype == OTHER_SENSOR)
|
|
|
|
|
{
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_OTHER_POWER, 1);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN2, 1);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_OTHER_POWER);
|
|
|
|
|
GpioControl::TurnOn(CMD_SET_485_EN2);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
@ -3707,36 +3675,36 @@ bool CPhoneDevice::CloseSensors(int sensortype)
|
|
|
|
|
{
|
|
|
|
|
if(sensortype == MAIN_POWER_OPEN)
|
|
|
|
|
{
|
|
|
|
|
GpioControl::setInt(CMD_SET_SPI_POWER, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_SPI_POWER);
|
|
|
|
|
GpioControl::set12VEnable(false);
|
|
|
|
|
GpioControl::setCam3V3Enable(false);
|
|
|
|
|
GpioControl::setRS485Enable(false);
|
|
|
|
|
// GpioControl::setInt(CMD_SET_485_EN_STATE, 0);
|
|
|
|
|
// GpioControl::TurnOff(CMD_SET_485_EN_STATE);
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#ifndef USING_PLZ
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN_STATE, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN_STATE);
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_ENABLE, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_ENABLE);
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SPI2SERIAL_POWER_EN, 0);
|
|
|
|
|
GpioControl::setInt(CMD_RS485_3V3_EN, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SPI2SERIAL_POWER_EN);
|
|
|
|
|
GpioControl::TurnOff(CMD_RS485_3V3_EN);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(sensortype == CAMERA_SENSOR_OPEN)
|
|
|
|
|
{
|
|
|
|
|
#ifdef USING_N938
|
|
|
|
|
GpioControl::setInt(CMD_SET_PIC1_POWER, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN4, 0);
|
|
|
|
|
// GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_PIC1_POWER);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN4);
|
|
|
|
|
// GpioControl::TurnOff(CMD_SET_CAM_3V3_EN_STATE);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
// GpioControl::setInt(CMD_SET_3V3_PWR_ENABLE, 0);
|
|
|
|
|
// GpioControl::TurnOff(CMD_SET_3V3_PWR_ENABLE);
|
|
|
|
|
#ifndef USING_PLZ
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_PTZ_PWR_ENABLE, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_PTZ_PWR_ENABLE);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -3744,26 +3712,26 @@ bool CPhoneDevice::CloseSensors(int sensortype)
|
|
|
|
|
{
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_WTH_POWER, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN3, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_WTH_POWER);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN3);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
if(sensortype == ICETHICK_SENSOR_OPEN)
|
|
|
|
|
{
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_PULL_POWER, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_ANGLE_POWER, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN1, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN0, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_PULL_POWER);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_ANGLE_POWER);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN1);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN0);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
if(sensortype == OTHER_SENSOR)
|
|
|
|
|
{
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#else
|
|
|
|
|
GpioControl::setInt(CMD_SET_OTHER_POWER, 0);
|
|
|
|
|
GpioControl::setInt(CMD_SET_485_EN2, 0);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_OTHER_POWER);
|
|
|
|
|
GpioControl::TurnOff(CMD_SET_485_EN2);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
@ -3805,7 +3773,8 @@ void CPhoneDevice::SetStaticIp()
|
|
|
|
|
if (m_network != NULL)
|
|
|
|
|
{
|
|
|
|
|
SetStaticIp(m_network->iface, m_network->ip, m_network->netmask, m_network->gateway);
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Set Static IP on %s: %s", m_network->iface.c_str(), m_network->ip.c_str());
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Set Static IP on %s: %s", m_network->iface.c_str(),
|
|
|
|
|
m_network->ip.c_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|