Skip to content
Snippets Groups Projects
Commit dc7106ea authored by rswindell's avatar rswindell
Browse files

Added option for "manual answer" (default is still auto-answer).

New sexpots.ini [modem] keys:
Answer (default: "ATA")
Ring (default: "RING")
ManualAnswer (default: false)
parent 2bf0c591
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @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 * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License * * modify it under the terms of the GNU General Public License *
...@@ -67,7 +67,11 @@ char mdm_init[INI_MAX_VALUE_LEN] = "AT&F"; ...@@ -67,7 +67,11 @@ char mdm_init[INI_MAX_VALUE_LEN] = "AT&F";
char mdm_autoans[INI_MAX_VALUE_LEN] = "ATS0=1"; char mdm_autoans[INI_MAX_VALUE_LEN] = "ATS0=1";
char mdm_cid[INI_MAX_VALUE_LEN] = "AT+VCID=1"; char mdm_cid[INI_MAX_VALUE_LEN] = "AT+VCID=1";
char mdm_cleanup[INI_MAX_VALUE_LEN] = "ATS0=0"; 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_null=FALSE;
BOOL mdm_manswer=FALSE; /* Manual Answer */
int mdm_timeout=5; /* seconds */ int mdm_timeout=5; /* seconds */
int mdm_reinit=60; /* minutes */ int mdm_reinit=60; /* minutes */
int mdm_cmdretry=2; /* command retries (total attempts-1) */ int mdm_cmdretry=2; /* command retries (total attempts-1) */
...@@ -801,7 +805,7 @@ BOOL wait_for_call(COM_HANDLE com_handle) ...@@ -801,7 +805,7 @@ BOOL wait_for_call(COM_HANDLE com_handle)
if(!modem_command(com_handle, mdm_init)) if(!modem_command(com_handle, mdm_init))
return FALSE; return FALSE;
} }
if(mdm_autoans[0]) { if(!mdm_manswer && mdm_autoans[0]) {
lprintf(LOG_INFO,"Setting modem to auto-answer:"); lprintf(LOG_INFO,"Setting modem to auto-answer:");
if(!modem_command(com_handle, mdm_autoans)) if(!modem_command(com_handle, mdm_autoans))
return FALSE; return FALSE;
...@@ -813,12 +817,14 @@ BOOL wait_for_call(COM_HANDLE com_handle) ...@@ -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) { while(1) {
if(terminated) if(terminated)
return FALSE; return FALSE;
if(comReadLine(com_handle, str, sizeof(str), /* timeout (ms): */250) > 0) { if(comReadLine(com_handle, str, sizeof(str), /* timeout (ms): */250) > 0) {
truncsp(str); truncsp(str);
if(str[0]==0)
continue;
lprintf(LOG_DEBUG,"Received from modem: '%s'", str); lprintf(LOG_DEBUG,"Received from modem: '%s'", str);
p=str; p=str;
SKIP_WHITESPACE(p); SKIP_WHITESPACE(p);
...@@ -848,6 +854,12 @@ BOOL wait_for_call(COM_HANDLE com_handle) ...@@ -848,6 +854,12 @@ BOOL wait_for_call(COM_HANDLE com_handle)
ZERO_VAR(cid_name); ZERO_VAR(cid_name);
ZERO_VAR(cid_number); 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 */ 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) ...@@ -1402,9 +1414,12 @@ void parse_ini_file(const char* ini_fname)
iniGetExistingWord(list, section, "AutoAnswer", "", mdm_autoans); iniGetExistingWord(list, section, "AutoAnswer", "", mdm_autoans);
iniGetExistingWord(list, section, "Cleanup", "", mdm_cleanup); iniGetExistingWord(list, section, "Cleanup", "", mdm_cleanup);
iniGetExistingWord(list, section, "EnableCallerID", "", mdm_cid); 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_timeout = iniGetInteger(list, section, "Timeout", mdm_timeout);
mdm_reinit = iniGetInteger(list, section, "ReInit", mdm_reinit); mdm_reinit = iniGetInteger(list, section, "ReInit", mdm_reinit);
mdm_cmdretry = iniGetInteger(list, section, "CmdRetry", mdm_cmdretry); mdm_cmdretry = iniGetInteger(list, section, "CmdRetry", mdm_cmdretry);
mdm_manswer = iniGetBool(list,section,"ManualAnswer", mdm_manswer);
/* [TCP] Section */ /* [TCP] Section */
section="TCP"; section="TCP";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment