summaryrefslogtreecommitdiffstats
path: root/app/dialstr.c
blob: 1277a42a94be192ff83df3d68fc49bf3855b1e72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "project.h"
#define DIGIT_TIMEOUT 4000

static char dialstr[32] = "ATDT";
static unsigned dialstr_ptr = 4;
static int dialstr_timeout;

void
dialstr_clear (void)
{
  dialstr_ptr = 4;
  dialstr[dialstr_ptr] = ';';
  dialstr[dialstr_ptr + 1] = 0;
}


void
dialstr_digit (int digit)
{
  if (!dialstr_timeout)
    dialstr_clear ();
  if (dialstr_ptr >= (sizeof (dialstr) - 2))
    return;

  dialstr[dialstr_ptr] = '0' + digit;
  dialstr_ptr++;
  dialstr[dialstr_ptr] = ';';
  dialstr[dialstr_ptr + 1] = 0;

  dialstr_timeout = DIGIT_TIMEOUT;
  printf ("Dialstr is now %s\r\n", dialstr + 4);

}

void
dialstr_dial (void)
{
  printf ("Dialing %s\r\n", dialstr + 4);
  modem_send (dialstr);
}

void
dialstr_tick (void)
{
  if (!dialstr_timeout)
    return;
  dialstr_timeout--;
  if (dialstr_timeout)
    return;

  if (!hook)
    dialstr_dial ();

}