summaryrefslogtreecommitdiffstats
path: root/app/modem.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/modem.c')
-rw-r--r--app/modem.c130
1 files changed, 73 insertions, 57 deletions
diff --git a/app/modem.c b/app/modem.c
index fa6a57a..b531761 100644
--- a/app/modem.c
+++ b/app/modem.c
@@ -7,93 +7,109 @@
#define BACKOFF 200
static char modem_buf[BUFFER_SIZE];
-static unsigned modem_ptr=0;
+static unsigned modem_ptr = 0;
static char *modem_cmd;
static int timeout;
-static int sleepy=SLEEPY;
+static int sleepy = SLEEPY;
-void modem_send(char *buf)
+void
+modem_send (char *buf)
{
-modem_cmd=buf;
-
-if (sleepy>=SLEEPY) {
- printf("modem is sleepy\r\n");
- usart2_queue('\r');
- sleepy=0;
- timeout=BACKOFF;
- return;
+ modem_cmd = buf;
+
+ if (sleepy >= SLEEPY)
+ {
+ printf ("modem is sleepy\r\n");
+ usart2_queue ('\r');
+ sleepy = 0;
+ timeout = BACKOFF;
+ return;
+ }
+ sleepy = 0;
+
+ printf ("(re)send\r\n");
+ timeout = TIMEOUT;
+ usart2_queue ('\r');
+ usart2_tx (modem_cmd, strlen (modem_cmd));
+ usart2_queue ('\r');
}
- sleepy=0;
-printf("(re)send\r\n");
-timeout=TIMEOUT;
-usart2_queue('\r');
-usart2_tx(modem_cmd,strlen(modem_cmd));
-usart2_queue('\r');
-}
-
-void modem_line()
+void
+modem_line ()
{
-printf("Modem said: %s\r\n",modem_buf);
+ printf ("Modem said: %s\r\n", modem_buf);
-sleepy=0;
+ sleepy = 0;
-if (!strncmp(modem_buf,"RING",4))
- ring(4000);
+ if (!strncmp (modem_buf, "RING", 4))
+ ring (4000);
-if (!strncmp(modem_buf,"OK",2)) {
- modem_cmd=NULL;
- timeout=0;
-}
+ if (!strncmp (modem_buf, "OK", 2))
+ {
+ modem_cmd = NULL;
+ timeout = 0;
+ }
}
-void modem_byte(uint8_t b)
+void
+modem_byte (uint8_t b)
{
-if (b=='\n') return;
+ if (b == '\n')
+ return;
-if (b=='\r') {
- if (modem_ptr)
- modem_line();
- modem_ptr=0;
- modem_buf[modem_ptr]=0;
- return;
-}
-
-if (modem_ptr>=(sizeof(modem_buf)-1))
- return;
+ if (b == '\r')
+ {
+ if (modem_ptr)
+ modem_line ();
+ modem_ptr = 0;
+ modem_buf[modem_ptr] = 0;
+ return;
+ }
+
+ if (modem_ptr >= (sizeof (modem_buf) - 1))
+ return;
-modem_buf[modem_ptr]=b;
-modem_ptr++;
-modem_buf[modem_ptr]=0;
+ modem_buf[modem_ptr] = b;
+ modem_ptr++;
+ modem_buf[modem_ptr] = 0;
}
-void answer_call(void)
+void
+answer_call (void)
{
- printf("Answering call\r\n");
- modem_send("ATA");
+ printf ("Answering call\r\n");
+ modem_send ("ATA");
}
-void terminate_call(void) {
- printf("Terminating any call\r\n");
- modem_send("ATH0");
+void
+terminate_call (void)
+{
+ printf ("Terminating any call\r\n");
+ modem_send ("ATH0");
}
-void modem_tick(void) {
+void
+modem_tick (void)
+{
-if (sleepy<SLEEPY)
-sleepy++;
+ if (sleepy < SLEEPY)
+ sleepy++;
-if (!timeout) return;
-timeout--;
-if (timeout) return;
+ if (!timeout)
+ return;
+ timeout--;
+ if (timeout)
+ return;
-modem_send(modem_cmd);
+ modem_send (modem_cmd);
}
-void modem_init(void) {
+void
+modem_init (void)
+{
}