@ -553,6 +553,7 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa
mExecHdrplusMid = env - > GetMethodID ( classService , " execHdrplus " , " (IILjava/lang/String;Ljava/lang/String;)I " ) ;
mExecHdrplusMid = env - > GetMethodID ( classService , " execHdrplus " , " (IILjava/lang/String;Ljava/lang/String;)I " ) ;
mSetStaticIpMid = env - > GetMethodID ( classService , " setStaticNetwork " , " (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V " ) ;
mSetStaticIpMid = env - > GetMethodID ( classService , " setStaticNetwork " , " (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V " ) ;
mSetStaticIpMid = env - > GetMethodID ( classService , " setStaticNetwork " , " (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V " ) ;
mExecuteCmdMid = env - > GetMethodID ( classService , " executeCommand " , " (Ljava/lang/String;)I " ) ;
mExecuteCmdMid = env - > GetMethodID ( classService , " executeCommand " , " (Ljava/lang/String;)I " ) ;
mConvertDngToPngMid = env - > GetMethodID ( classService , " convertDngToPng " , " (Ljava/lang/String;Ljava/lang/String;)V " ) ;
mConvertDngToPngMid = env - > GetMethodID ( classService , " convertDngToPng " , " (Ljava/lang/String;Ljava/lang/String;)V " ) ;
@ -1613,79 +1614,15 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
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 ) ;
std : : shared_ptr < PowerControl > ethernetPowerCtrl = std : : make_shared < EthernetPowerCtrl > ( localPhotoInfo . closeDelayTime ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 2000 ) ) ;
uint64_t startTime = GetMicroTimeStamp ( ) ;
net_handle_t netHandle = 0 ;
//#if ((!defined USING_N938) && (!defined USING_PTZ))
#if 0
// Wait about 10s
for ( int idx = 0 ; idx < 84 ; idx + + )
{
// XYLOG(XYLOG_SEVERITY_INFO, "Before GetEthnetHandle %d IMGID=%u", idx, localPhotoInfo.photoId);
netHandle = GetEthnetHandle ( ) ;
// XYLOG(XYLOG_SEVERITY_INFO, "After GetEthnetHandle %d NetHandle=%llu IMGID=%u", idx, netHandle, localPhotoInfo.photoId);
if ( netHandle ! = 0 )
{
break ;
}
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 128 ) ) ;
}
if ( netHandle = = 0 )
{
// timeout
m_ethernetFailures + + ;
XYLOG ( XYLOG_SEVERITY_ERROR , " Ethernet Not Existing CH=%u PR=%X PHOTOID=%u EthFailures=%u " ,
( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId , m_ethernetFailures ) ;
TakePhotoCb ( 0 , localPhotoInfo , " " , 0 ) ;
// XYLOG(XYLOG_SEVERITY_INFO, "After TakePhotoCb %d IMGID=%u", localPhotoInfo.photoId);
if ( m_ethernetFailures > 3 )
{
time_t rebootTime = GetRebootTime ( ) ;
if ( ts - rebootTime > 1800 )
{
XYLOG ( XYLOG_SEVERITY_INFO , " Will Reboot Dev As for too much ehternet failure %d IMGID=%u " , m_ethernetFailures , localPhotoInfo . photoId ) ;
// XYLOG(XYLOG_SEVERITY_INFO, "Before Reboot %d IMGID=%u", localPhotoInfo.photoId);
Reboot ( REBOOT_TYPE_DEVICE , true , " Ethernet Not Existing " ) ;
// XYLOG(XYLOG_SEVERITY_INFO, "After Reboot %d IMGID=%u", localPhotoInfo.photoId);
}
}
return false ;
}
else
{
#if 0
unsigned int ip = 0 ;
unsigned int netMask = 0 ;
unsigned int gateway = 0 ;
char buf [ 32 ] = { 0 } ;
XYLOG ( XYLOG_SEVERITY_INFO , " Before GetNetInfo %d IMGID=%u " , localPhotoInfo . photoId ) ;
if ( GetNetInfo ( " eth0 " , ip , netMask , gateway ) )
{
XYLOG ( XYLOG_SEVERITY_INFO , " After GetNetInfo %d IMGID=%u " , localPhotoInfo . photoId ) ;
// const
sockaddr_in addrIn = { AF_INET , 0 , ip } ;
inet_ntop ( AF_INET , & addrIn . sin_addr , buf , sizeof ( buf ) ) ; //其中recvAddr为SOCKADDR_IN类型
XYLOG ( XYLOG_SEVERITY_INFO , " After ntop %d IMGID=%u " , 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 ) ;
# endif
XYLOG ( XYLOG_SEVERITY_INFO , " Ethernet is Available Handle=%llu CH=%u PR=%X PHOTOID=%u " , ( uint64_t ) netHandle , ( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId ) ;
}
# endif // USING_N938
// if (mBuildTime < 1738166400)
{
// 2025-01-30
SetStaticIp ( ) ;
SetStaticIp ( ) ;
uint64_t ethDuration = GetMicroTimeStamp ( ) - startTime ;
if ( ethDuration < 5000 )
{
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 5000 - ethDuration ) ) ;
}
}
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 3000 ) ) ;
net_handle_t netHandle = GetEthnetHandle ( ) ;
std : : string ip = GetIpStr ( localPhotoInfo . ip ) ;
std : : string ip = GetIpStr ( localPhotoInfo . ip ) ;
std : : unique_ptr < VendorCtrl > vendorCtrl ( MakeVendorCtrl ( localPhotoInfo . vendor , localPhotoInfo . channel , ip , localPhotoInfo . userName , localPhotoInfo . password , netHandle , false ) ) ;
std : : unique_ptr < VendorCtrl > vendorCtrl ( MakeVendorCtrl ( localPhotoInfo . vendor , localPhotoInfo . channel , ip , localPhotoInfo . userName , localPhotoInfo . password , netHandle , false ) ) ;
@ -1694,7 +1631,6 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
{
{
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 ) ;
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 ) ;
TakePhotoCb ( 0 , localPhotoInfo , " " , 0 ) ;
TakePhotoCb ( 0 , localPhotoInfo , " " , 0 ) ;
// ShutdownEthernet();
return false ;
return false ;
}
}
@ -1820,44 +1756,16 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
XYLOG ( XYLOG_SEVERITY_DEBUG , " Ethernet Power ON " ) ;
XYLOG ( XYLOG_SEVERITY_DEBUG , " Ethernet Power ON " ) ;
std : : shared_ptr < PowerControl > ethernetPowerCtrl = std : : make_shared < EthernetPowerCtrl > ( 1 ) ;
std : : shared_ptr < PowerControl > ethernetPowerCtrl = std : : make_shared < EthernetPowerCtrl > ( 1 ) ;
// std::shared_ptr<PowerControl> ethernetPowerCtrl;
net_handle_t netHandle = 0 ;
uint64_t startTime = GetMicroTimeStamp ( ) ;
# if ((!defined USING_N938) && (!defined USING_PTZ))
SetStaticIp ( ) ;
netHandle = GetEthnetHandle ( ) ;
uint64_t ethDuration = GetMicroTimeStamp ( ) - startTime ;
if ( netHandle = = 0 )
if ( ethDuration < 5000 )
{
// Wait about 10s
for ( int idx = 0 ; idx < 128 ; idx + + )
{
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 128 ) ) ;
netHandle = GetEthnetHandle ( ) ;
if ( netHandle ! = 0 )
{
break ;
}
}
}
if ( netHandle = = 0 )
{
// timeout
XYLOG ( XYLOG_SEVERITY_ERROR , " Ethernet not existing CH=%u PR=%X PHOTOID=%u " , ( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId ) ;
# ifdef NDEBUG
TakePhotoCb ( 0 , localPhotoInfo , " " , 0 ) ;
return false ;
# endif
}
else
{
{
XYLOG( XYLOG_SEVERITY_INFO , " Ethernet is Available CH=%u PR=%X PHOTOID=%u " , ( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 5000 - ethDuration ) ) ;
}
}
# endif
SetStaticIp ( ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 256 ) ) ;
net_handle_t netHandle = GetEthnetHandle ( ) ;
std : : string ip = GetIpStr ( localPhotoInfo . ip ) ;
std : : string ip = GetIpStr ( localPhotoInfo . ip ) ;
std : : unique_ptr < VendorCtrl > vendorCtrl ( MakeVendorCtrl ( localPhotoInfo . vendor , localPhotoInfo . channel , ip , localPhotoInfo . userName , localPhotoInfo . password , netHandle , false ) ) ;
std : : unique_ptr < VendorCtrl > vendorCtrl ( MakeVendorCtrl ( localPhotoInfo . vendor , localPhotoInfo . channel , ip , localPhotoInfo . userName , localPhotoInfo . password , netHandle , false ) ) ;
if ( ! vendorCtrl )
if ( ! vendorCtrl )
@ -1902,7 +1810,6 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
XYLOG ( XYLOG_SEVERITY_DEBUG , " Stop Recording CH=%u PR=%X PHOTOID=%u " , ( uint32_t ) localPhotoInfo . channel , ( unsigned int ) localPhotoInfo . preset , localPhotoInfo . photoId ) ;
XYLOG ( XYLOG_SEVERITY_DEBUG , " Stop Recording CH=%u PR=%X PHOTOID=%u " , ( uint32_t ) localPhotoInfo . channel , ( unsigned int ) localPhotoInfo . preset , localPhotoInfo . photoId ) ;
ethernetPowerCtrl . reset ( ) ;
ethernetPowerCtrl . reset ( ) ;
XYLOG ( XYLOG_SEVERITY_DEBUG , " Ethernet Power OFF " ) ;
XYLOG ( XYLOG_SEVERITY_DEBUG , " Ethernet Power OFF " ) ;
@ -1947,42 +1854,15 @@ bool CPhoneDevice::StartPushStreaming(IDevice::PHOTO_INFO& photoInfo, const std:
std : : shared_ptr < PowerControl > ethernetPowerCtrl = std : : make_shared < EthernetPowerCtrl > ( 1 ) ;
std : : shared_ptr < PowerControl > ethernetPowerCtrl = std : : make_shared < EthernetPowerCtrl > ( 1 ) ;
// std::shared_ptr<PowerControl> ethernetPowerCtrl;
// std::shared_ptr<PowerControl> ethernetPowerCtrl;
net_handle_t netHandle = 0 ;
uint64_t startTime = GetMicroTimeStamp ( ) ;
# if ((!defined USING_N938) && (!defined USING_PTZ))
SetStaticIp ( ) ;
netHandle = GetEthnetHandle ( ) ;
uint64_t ethDuration = GetMicroTimeStamp ( ) - startTime ;
if ( netHandle = = 0 )
if ( ethDuration < 5000 )
{
// Wait about 10s
for ( int idx = 0 ; idx < 84 ; idx + + )
{
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 128 ) ) ;
netHandle = GetEthnetHandle ( ) ;
if ( netHandle ! = 0 )
{
break ;
}
}
}
if ( netHandle = = 0 )
{
// timeout
XYLOG ( XYLOG_SEVERITY_ERROR , " Ethernet not existing CH=%u PR=%X PHOTOID=%u " , ( uint32_t ) photoInfo . channel , ( uint32_t ) photoInfo . preset , photoInfo . photoId ) ;
# ifdef NDEBUG
TakePhotoCb ( 0 , photoInfo , " " , 0 ) ;
return false ;
# endif
}
else
{
{
XYLOG( XYLOG_SEVERITY_INFO , " Ethernet is Available CH=%u PR=%X PHOTOID=%u " , ( uint32_t ) photoInfo . channel , ( uint32_t ) photoInfo . preset , photoInfo . photoId ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 5000 - ethDuration ) ) ;
}
}
# endif
SetStaticIp ( ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 256 ) ) ;
net_handle_t netHandle = GetEthnetHandle ( ) ;
std : : map < uint8_t , STREAMING_CONTEXT > : : iterator it = m_streamings . find ( photoInfo . channel ) ;
std : : map < uint8_t , STREAMING_CONTEXT > : : iterator it = m_streamings . find ( photoInfo . channel ) ;
if ( it ! = m_streamings . end ( ) )
if ( it ! = m_streamings . end ( ) )
{
{
@ -4402,10 +4282,12 @@ void CPhoneDevice::SetStaticIp(const std::string& iface, const std::string& ip,
jstring jip = env - > NewStringUTF ( ip . c_str ( ) ) ;
jstring jip = env - > NewStringUTF ( ip . c_str ( ) ) ;
# endif
# endif
jstring jnetmask = env - > NewStringUTF ( netmask . c_str ( ) ) ;
jstring jnetmask = env - > NewStringUTF ( netmask . c_str ( ) ) ;
std : : string ipPrefix = " 192.168.68.0 " ;
jstring jipPrefix = env - > NewStringUTF ( ipPrefix . c_str ( ) ) ;
jstring jgw = env - > NewStringUTF ( gateway . c_str ( ) ) ;
jstring jgw = env - > NewStringUTF ( gateway . c_str ( ) ) ;
env - > CallVoidMethod ( m_javaService , mSetStaticIpMid , jiface , jip , jnetmask , jgw ) ;
env - > CallVoidMethod ( m_javaService , mSetStaticIpMid , jiface , jip , j gw, jipPrefix , 24 ) ;
env - > DeleteLocalRef ( jgw ) ;
env - > DeleteLocalRef ( jgw ) ;
env - > DeleteLocalRef ( j netmask ) ;
env - > DeleteLocalRef ( j ipPrefix ) ;
env - > DeleteLocalRef ( jip ) ;
env - > DeleteLocalRef ( jip ) ;
env - > DeleteLocalRef ( jiface ) ;
env - > DeleteLocalRef ( jiface ) ;
@ -5246,10 +5128,7 @@ void CPhoneDevice::SetStaticIp()
}
}
else
else
{
{
# ifdef USING_N938
SetStaticIp ( " eth0 " , " 192.168.68.91 " , " 255.255.255.0 " , " 192.168.68.91 " ) ;
SetStaticIp ( " eth0 " , " 0.0.0.0 " , " 255.255.255.0 " , " 192.168.1.1 " ) ;
# endif
XYLOG ( XYLOG_SEVERITY_WARNING , " No Static IP Confg " ) ;
}
}
}
}