|
|
@ -14,6 +14,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kernelModuleModemManager::kernelModuleModemManager( uint32_t moduleID ): kernelModule( moduleID, KERNEL_MODULE_MODEM_MANAGER ) /*, basicThread() */{ |
|
|
kernelModuleModemManager::kernelModuleModemManager( uint32_t moduleID ): kernelModule( moduleID, KERNEL_MODULE_MODEM_MANAGER ) /*, basicThread() */{ |
|
|
|
|
|
m_cMyWanIP[0]= (char)0; |
|
|
if( checkCmdExists("mmcli") > 0 ){ |
|
|
if( checkCmdExists("mmcli") > 0 ){ |
|
|
LOG("ModemManager Present!"); |
|
|
LOG("ModemManager Present!"); |
|
|
} else { |
|
|
} else { |
|
|
@ -40,12 +41,18 @@ bool kernelModuleModemManager::startService(){ |
|
|
LOG("Start Service"); |
|
|
LOG("Start Service"); |
|
|
//Load PhoneBook
|
|
|
//Load PhoneBook
|
|
|
setWM( MDM_IDLE_WM ); |
|
|
setWM( MDM_IDLE_WM ); |
|
|
|
|
|
if ( m_sMMData.sms_enabled ) { |
|
|
|
|
|
// Get current WAN IP Address
|
|
|
|
|
|
if( updateWanIP() ) { |
|
|
|
|
|
LOG( "WAN IP OK!" ); |
|
|
|
|
|
} else LOG( "WAN IP NOK!" ); |
|
|
|
|
|
} else LOG( "SMS DISABLED!" ); |
|
|
return moduleActive = init(); |
|
|
return moduleActive = init(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
bool kernelModuleModemManager::stopService( bool force ){ |
|
|
bool kernelModuleModemManager::stopService( bool force ){ |
|
|
LOG("Stop Service"); |
|
|
LOG("Stop Service"); |
|
|
setWM( MDM_IDLE_WM ); |
|
|
|
|
|
|
|
|
setWM( MDM_STOP_WM ); |
|
|
return moduleActive = !uninit(); |
|
|
return moduleActive = !uninit(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
@ -115,6 +122,10 @@ void kernelModuleModemManager::m_fThreadProc( void ){ |
|
|
}; |
|
|
}; |
|
|
break; |
|
|
break; |
|
|
}; |
|
|
}; |
|
|
|
|
|
case MDM_STOP_WM:{ |
|
|
|
|
|
m_bThreadStatus = TH_ENDED; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
SLEEP(DEFAULT_THREAD_SLEEP_TIME); |
|
|
SLEEP(DEFAULT_THREAD_SLEEP_TIME); |
|
|
}; |
|
|
}; |
|
|
@ -153,11 +164,12 @@ bool kernelModuleModemManager::dispatchEvent( EVENT_CONTAINER *Evt ){ |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
bool kernelModuleModemManager::validate(){ |
|
|
bool kernelModuleModemManager::validate(){ |
|
|
|
|
|
//LOG("Validate");
|
|
|
if ( moduleActive ) { |
|
|
if ( moduleActive ) { |
|
|
// Get current WAN IP Address
|
|
|
|
|
|
//
|
|
|
|
|
|
//LOG("Validate");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( m_sMMData.sms_enabled ) { |
|
|
|
|
|
// Get current WAN IP Address
|
|
|
|
|
|
return updateWanIP(); |
|
|
|
|
|
}; |
|
|
}; |
|
|
}; |
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
|
@ -177,7 +189,13 @@ Successfully created new call: /org/freedesktop/ModemManager1/Call/2 |
|
|
*/ |
|
|
*/ |
|
|
FILE *fd = popen( CMD, "r"); |
|
|
FILE *fd = popen( CMD, "r"); |
|
|
if ( fd ) { |
|
|
if ( fd ) { |
|
|
|
|
|
|
|
|
|
|
|
char tB[1024]; |
|
|
|
|
|
if ( fread( tB, 1, 1023, fd ) > 0 ) { |
|
|
|
|
|
CSTR tS = strstr( tB, "Call/" ); |
|
|
|
|
|
if ( tS ) { |
|
|
|
|
|
callID = atoi( tS+5 ); |
|
|
|
|
|
}; |
|
|
|
|
|
}; |
|
|
pclose( fd ); |
|
|
pclose( fd ); |
|
|
}; |
|
|
}; |
|
|
if ( callID ) { |
|
|
if ( callID ) { |
|
|
@ -200,7 +218,32 @@ Successfully created new call: /org/freedesktop/ModemManager1/Call/2 |
|
|
void *kernelModuleModemManager::smsProc( void *ptr ){ |
|
|
void *kernelModuleModemManager::smsProc( void *ptr ){ |
|
|
MDM_SMS_DATA *DATA = (MDM_SMS_DATA *)ptr; |
|
|
MDM_SMS_DATA *DATA = (MDM_SMS_DATA *)ptr; |
|
|
if ( DATA ) { |
|
|
if ( DATA ) { |
|
|
|
|
|
char CMD[128]; |
|
|
|
|
|
uint32_t smsID = 0; |
|
|
|
|
|
sprintf( CMD, "mmcli -m %d --messaging-create-sms=\"text='%s',number='%s'\"", DATA->modem_id, DATA->text, DATA->target ); |
|
|
|
|
|
FILE *fd = popen( CMD, "r"); |
|
|
|
|
|
if ( fd ) { |
|
|
|
|
|
char tB[1024]; |
|
|
|
|
|
if ( fread( tB, 1, 1023, fd ) > 0 ) { |
|
|
|
|
|
CSTR tS = strstr( tB, "SMS/" ); |
|
|
|
|
|
if ( tS ) { |
|
|
|
|
|
smsID = atoi( tS+4 ); |
|
|
|
|
|
}; |
|
|
|
|
|
}; |
|
|
|
|
|
pclose( fd ); |
|
|
|
|
|
}; |
|
|
|
|
|
if ( smsID ) { |
|
|
|
|
|
// Wait X seconds then hang call
|
|
|
|
|
|
//SLEEP( DATA->parent->m_sMMData.call_hangup_wait * 1000 );
|
|
|
|
|
|
sprintf( CMD, "mmcli -s %d --send", smsID ); |
|
|
|
|
|
fd = popen( CMD, "r"); |
|
|
|
|
|
if ( fd ) { |
|
|
|
|
|
|
|
|
|
|
|
pclose( fd ); |
|
|
|
|
|
} else { |
|
|
|
|
|
TLOG_ERROR("Cannot Execute Call Hang Command!"); |
|
|
|
|
|
}; |
|
|
|
|
|
} else TLOG_ERROR("Call is not registered at Modem!"); |
|
|
}; |
|
|
}; |
|
|
pthread_exit( NULL ); |
|
|
pthread_exit( NULL ); |
|
|
return NULL; |
|
|
return NULL; |
|
|
@ -234,6 +277,49 @@ void kernelModuleModemManager::hangupCall( uint32_t call_id ){ |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
bool kernelModuleModemManager::updateWanIP(){ |
|
|
|
|
|
char CMD[128]; |
|
|
|
|
|
uint32_t smsID = 0; |
|
|
|
|
|
bool bDone = false; |
|
|
|
|
|
sprintf( CMD, "ifconfig" ); |
|
|
|
|
|
FILE *fd = popen( CMD, "r"); |
|
|
|
|
|
if ( fd ) { |
|
|
|
|
|
LOG( "CMD OK" ); |
|
|
|
|
|
CSTR tB = NULL; |
|
|
|
|
|
size_t bSize = 0; |
|
|
|
|
|
bool bIfMeet = false; |
|
|
|
|
|
while ( !feof( fd ) ) { |
|
|
|
|
|
ssize_t rv = getline( &tB, &bSize, fd ); |
|
|
|
|
|
if( rv ) { |
|
|
|
|
|
if( !bDone ) { |
|
|
|
|
|
if (bIfMeet) { |
|
|
|
|
|
CSTR ssp = strstr( tB, "inet "); |
|
|
|
|
|
if ( ssp ){ |
|
|
|
|
|
LOG( "IF IP OK" ); |
|
|
|
|
|
CSTR nsp = strstr( tB, "netmask"); |
|
|
|
|
|
int msl = nsp - ssp - 6; |
|
|
|
|
|
strncpy( m_cMyWanIP, ssp+5, msl ); |
|
|
|
|
|
m_cMyWanIP[msl]=(char)0; |
|
|
|
|
|
bDone = true; |
|
|
|
|
|
LOG( "WWAN IP" ); |
|
|
|
|
|
LOG( m_cMyWanIP ); |
|
|
|
|
|
}; |
|
|
|
|
|
} else { |
|
|
|
|
|
LOG( "IF MEET OK" ); |
|
|
|
|
|
if ( strstr( tB, "wwan")) bIfMeet = true; |
|
|
|
|
|
}; |
|
|
|
|
|
}; |
|
|
|
|
|
} else LOG( "READ NOK" ); |
|
|
|
|
|
if ( tB ) { |
|
|
|
|
|
free( tB ); |
|
|
|
|
|
tB = NULL; |
|
|
|
|
|
}; |
|
|
|
|
|
}; |
|
|
|
|
|
pclose( fd ); |
|
|
|
|
|
}; |
|
|
|
|
|
return bDone; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
#undef LOG
|
|
|
#undef LOG
|
|
|
#undef LOG_ERROR
|
|
|
#undef LOG_ERROR
|
|
|
|
|
|
|
|
|
|