From 7b4848824dcec8c5564bd2b11371f9c5f4a04376 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Aug 2016 01:56:47 +0100 Subject: working --- app/dialstr.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 5 deletions(-) (limited to 'app/dialstr.c') diff --git a/app/dialstr.c b/app/dialstr.c index 1277a42..26bdfe9 100644 --- a/app/dialstr.c +++ b/app/dialstr.c @@ -11,24 +11,101 @@ dialstr_clear (void) dialstr_ptr = 4; dialstr[dialstr_ptr] = ';'; dialstr[dialstr_ptr + 1] = 0; + dialstr_timeout = 0; } +static void redial(void) +{ + if (in_call) + terminate_call(); + dialstr_timeout = 1; +} + + +static void dialstr_hook(char digit) +{ +switch (digit) { +case '1': + ringer_enable(); + ringer_ring(400); + break; +case '2': + ringer_disable(); + break; +case '0': + for (;;) scb_reset_system(); + break; +} +} + +static void dialstr_call(char digit) +{ +static char cmd[]={'A','T','+','V','T','S','=','"','{','0',',','3','}','"',0}; + +switch (digit) { +case 'R': + redial(); + break; +case 'M': + modem_cmd("AT+CMUT=1"); + break; +case 'U': + modem_cmd("AT+CMUT=0"); + break; +default: + cmd[9]=digit; + modem_cmd(cmd); + break; +} +} + + + void -dialstr_digit (int digit) +dialstr_digit (char digit) { + dialtone_off (); + + printf ("Dialed %c\r\n",digit); + + if (hook) { + dialstr_timeout=0; + dialstr_hook(digit); + return; + } + + if (in_call) { + dialstr_timeout=0; + dialstr_call(digit); + return; + } + + + switch(digit) { + case 'R': + redial(); + break; + + case 'M': + break; + case 'U': + break; + default: + + if (!dialstr_timeout) dialstr_clear (); if (dialstr_ptr >= (sizeof (dialstr) - 2)) - return; + break; - dialstr[dialstr_ptr] = '0' + digit; + dialstr[dialstr_ptr] = digit; dialstr_ptr++; dialstr[dialstr_ptr] = ';'; dialstr[dialstr_ptr + 1] = 0; dialstr_timeout = DIGIT_TIMEOUT; - printf ("Dialstr is now %s\r\n", dialstr + 4); +} } @@ -36,7 +113,8 @@ void dialstr_dial (void) { printf ("Dialing %s\r\n", dialstr + 4); - modem_send (dialstr); + modem_tone(17); + modem_dial (dialstr); } void -- cgit v1.2.3