annotate uptools/atcmd/smsend_text.c @ 407:19e5a3e2f9c0

fcup-settime: moved time() retrieval a little closer to the output A fundamental problem with all simple time transfer tools is that there is always some delay between the time retrieval on the source system and that transmitted time being set on the destination, and the resulting time on the destination system is off by that delay amount. This delay cannot be fully eliminated when working in a simple environment like ours, but we should make our best effort to minimize it. In the present case, moving the atinterf_init() call before the time() retrieval should make a teensy-tiny improvement.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Aug 2018 21:52:17 +0000
parents 89fe66cb60f6
children dc2fd8e6f42c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
362
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements SMS sending/writing in text mode.
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 extern void cmgw_callback();
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 extern int sms_write_mode;
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 prep_for_text_mode()
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 atinterf_exec_cmd_needok("AT+CMGF=1", 0, 0);
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 atinterf_exec_cmd_needok("AT+CSCS=\"8859-1\"", 0, 0);
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 atinterf_exec_cmd_needok("AT+CSMP=1,,0,0", 0, 0);
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 }
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 send_in_text_mode(binda, textstr)
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 u_char *binda;
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 char *textstr;
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 char *cmdname;
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 void (*callback)();
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 char send_cmd[64], digits[21];
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (sms_write_mode) {
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 cmdname = "CMGW";
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 callback = cmgw_callback;
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 } else {
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 cmdname = "CMGS";
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 callback = 0;
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (binda[0]) {
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 decode_address_digits(binda + 2, digits, binda[0]);
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 sprintf(send_cmd, "AT+%s=\"%s\",%u", cmdname, digits, binda[1]);
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 } else
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 sprintf(send_cmd, "AT+%s", cmdname);
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 atinterf_exec_cmd_needok(send_cmd, textstr, callback);
89fe66cb60f6 fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }