diff --git a/src/sexpots/sexpots.c b/src/sexpots/sexpots.c index ae990fb15d34727e968f1744f879e568f61c3b0b..04f0158fb2e83410882ac7b25ef0f965427ab7b8 100644 --- a/src/sexpots/sexpots.c +++ b/src/sexpots/sexpots.c @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2012 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2013 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -67,7 +67,11 @@ char mdm_init[INI_MAX_VALUE_LEN] = "AT&F"; char mdm_autoans[INI_MAX_VALUE_LEN] = "ATS0=1"; char mdm_cid[INI_MAX_VALUE_LEN] = "AT+VCID=1"; char mdm_cleanup[INI_MAX_VALUE_LEN] = "ATS0=0"; +char mdm_answer[INI_MAX_VALUE_LEN] = "ATA"; +char mdm_ring[INI_MAX_VALUE_LEN] = "RING"; BOOL mdm_null=FALSE; +BOOL mdm_manswer=FALSE; /* Manual Answer */ + int mdm_timeout=5; /* seconds */ int mdm_reinit=60; /* minutes */ int mdm_cmdretry=2; /* command retries (total attempts-1) */ @@ -801,7 +805,7 @@ BOOL wait_for_call(COM_HANDLE com_handle) if(!modem_command(com_handle, mdm_init)) return FALSE; } - if(mdm_autoans[0]) { + if(!mdm_manswer && mdm_autoans[0]) { lprintf(LOG_INFO,"Setting modem to auto-answer:"); if(!modem_command(com_handle, mdm_autoans)) return FALSE; @@ -813,12 +817,14 @@ BOOL wait_for_call(COM_HANDLE com_handle) } } - lprintf(LOG_INFO,"Waiting for incoming call (Carrier Detect) ..."); + lprintf(LOG_INFO,"Waiting for incoming call (%s) ...", mdm_manswer ? "Ring Indication" : "Carrier Detect"); while(1) { if(terminated) return FALSE; if(comReadLine(com_handle, str, sizeof(str), /* timeout (ms): */250) > 0) { truncsp(str); + if(str[0]==0) + continue; lprintf(LOG_DEBUG,"Received from modem: '%s'", str); p=str; SKIP_WHITESPACE(p); @@ -848,6 +854,12 @@ BOOL wait_for_call(COM_HANDLE com_handle) ZERO_VAR(cid_name); ZERO_VAR(cid_number); } + else if(mdm_ring[0] && strcmp(p,mdm_ring)==0 && mdm_manswer && mdm_answer[0]) { + if(!modem_send(com_handle, mdm_answer)) { + lprintf(LOG_ERR,"ERROR %u sending modem command (%s) on %s" + ,COM_ERROR_VALUE, mdm_answer, com_dev); + } + } } continue; /* don't check DCD until we've received all the modem msgs */ } @@ -1402,9 +1414,12 @@ void parse_ini_file(const char* ini_fname) iniGetExistingWord(list, section, "AutoAnswer", "", mdm_autoans); iniGetExistingWord(list, section, "Cleanup", "", mdm_cleanup); iniGetExistingWord(list, section, "EnableCallerID", "", mdm_cid); + iniGetExistingWord(list, section, "Answer", "", mdm_answer); + iniGetExistingWord(list, section, "Ring", "", mdm_ring); mdm_timeout = iniGetInteger(list, section, "Timeout", mdm_timeout); mdm_reinit = iniGetInteger(list, section, "ReInit", mdm_reinit); mdm_cmdretry = iniGetInteger(list, section, "CmdRetry", mdm_cmdretry); + mdm_manswer = iniGetBool(list,section,"ManualAnswer", mdm_manswer); /* [TCP] Section */ section="TCP";