annotate uptools/atcmd/smdump.c @ 838:02d92d49c9f8

doc/Audio-mode-config: update for old vs new AEC
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 30 Jul 2021 05:21:19 +0000
parents da724c67159d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This utility retrieves a dump of all stored SMS records in PDU mode.
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdlib.h>
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <unistd.h>
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "../../rvinterf/include/exitcodes.h"
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "resp_parse.h"
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern char at_response[];
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
353
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
16 struct delafter {
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
17 unsigned msgid;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
18 struct delafter *next;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
19 };
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
20
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
21 int delete_after_flag;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
22 struct delafter *delafter_head, **delafter_tail = &delafter_head;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
23
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int pdu_state;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 char *msgtype;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 u_char pbname_gsm[40];
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 unsigned pbname_len, header_len;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 u_char pdu_bin[176];
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
353
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
30 add_delafter_record(msgid)
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
31 unsigned msgid;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
32 {
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
33 struct delafter *rec;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
34
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
35 rec = malloc(sizeof(struct delafter));
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
36 if (!rec)
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
37 return;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
38 rec->msgid = msgid;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
39 rec->next = 0;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
40 *delafter_tail = rec;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
41 delafter_tail = &rec->next;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
42 }
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
43
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 validate_pbname_7bit()
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 unsigned n;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 for (n = 0; n < pbname_len; n++)
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 if (pbname_gsm[n] & 0x80)
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 return(-1);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 return(0);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 cmgl_header()
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 struct resp_field fields[4];
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 int cc;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 /* skip empty lines */
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 if (!at_response[1])
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 return;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 /* if not empty, it MUST be +CMGL */
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 if (strncmp(at_response+1, "+CMGL: ", 7)) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 fprintf(stderr, "error: response from target is not +CMGL\n");
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 exit(ERROR_TARGET);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 if (parse_structured_response(at_response+8, fields, 4) != 4) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 malformed: fprintf(stderr, "error: malformed +CMGL response\n");
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 exit(ERROR_TARGET);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 if (fields[0].type != RESP_FIELD_NUMBER ||
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 fields[1].type != RESP_FIELD_NUMBER ||
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 fields[3].type != RESP_FIELD_NUMBER)
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 goto malformed;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 if (fields[2].type != RESP_FIELD_STRING &&
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 fields[2].type != RESP_FIELD_EMPTY)
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 goto malformed;
353
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
78 if (delete_after_flag)
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
79 add_delafter_record(fields[0].num);
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 switch (fields[1].num) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 case 0:
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 case 1:
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 msgtype = "Received";
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 break;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 case 2:
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 msgtype = "Stored unsent";
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 break;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 case 3:
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 msgtype = "Sent";
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 break;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 default:
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 fprintf(stderr,
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 "error: invalid message status code in +CMGL response\n");
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 exit(ERROR_TARGET);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 if (fields[2].type == RESP_FIELD_STRING) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 cc = decode_hex_line(fields[2].str, pbname_gsm,
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 sizeof pbname_gsm);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 if (cc >= 1) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 pbname_len = cc;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 if (validate_pbname_7bit() < 0)
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 pbname_len = 0;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 } else
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 pbname_len = 0;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 } else
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 pbname_len = 0;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 header_len = fields[3].num;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 pdu_state = 1;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 emit_pb_name()
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 {
801
da724c67159d fcup-smdump: use new function for Phonebook-Name
Mychaela Falconia <falcon@freecalypso.org>
parents: 467
diff changeset
113 fputs("Phonebook-Name: ", stdout);
da724c67159d fcup-smdump: use new function for Phonebook-Name
Mychaela Falconia <falcon@freecalypso.org>
parents: 467
diff changeset
114 print_gsm7_string_to_file(pbname_gsm, pbname_len, stdout);
da724c67159d fcup-smdump: use new function for Phonebook-Name
Mychaela Falconia <falcon@freecalypso.org>
parents: 467
diff changeset
115 putchar('\n');
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 cmgl_pdu()
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 int cc;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 unsigned sca_len;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 cc = decode_hex_line(at_response+1, pdu_bin, sizeof pdu_bin);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 if (cc < 1) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 fprintf(stderr, "error: expected PDU not received\n");
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 exit(ERROR_TARGET);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 sca_len = pdu_bin[0];
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 if (1 + sca_len + header_len != cc) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 fprintf(stderr, "error: PDU length mismatch\n");
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 exit(ERROR_TARGET);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 printf("%s message:\n", msgtype);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 if (pbname_len)
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 emit_pb_name();
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 puts(at_response+1);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 putchar('\n');
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 pdu_state = 0;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 cmgl_callback()
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 if (pdu_state)
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 cmgl_pdu();
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 else
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 cmgl_header();
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148
353
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
149 delete_after_process()
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
150 {
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
151 struct delafter *rec;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
152 char cmgd_cmd[32];
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
153
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
154 for (rec = delafter_head; rec; rec = rec->next) {
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
155 sprintf(cmgd_cmd, "AT+CMGD=%u", rec->msgid);
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 406
diff changeset
156 atinterf_exec_cmd_needok(cmgd_cmd, (char *) 0, (void *) 0);
353
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
157 }
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
158 }
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
159
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 main(argc, argv)
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 char **argv;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 int c;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 extern int optind;
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165
353
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
166 while ((c = getopt(argc, argv, "B:dnp:RX:")) != EOF) {
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
167 if (atinterf_cmdline_opt(c))
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
168 continue;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
169 else if (c == 'd')
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
170 delete_after_flag = 1;
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
171 else {
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 /* error msg already printed */
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 exit(ERROR_USAGE);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 }
353
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
175 }
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 if (argc != optind) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 fprintf(stderr, "usage: %s [options]\n", argv[0]);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 exit(ERROR_USAGE);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 }
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 atinterf_init();
364
ac311a48630e fcup-smdump & fcup-smsend: send AT+CMEE=2 first
Mychaela Falconia <falcon@freecalypso.org>
parents: 353
diff changeset
181 /* enable verbose error messages */
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 406
diff changeset
182 atinterf_exec_cmd_needok("AT+CMEE=2", (char *) 0, (void *) 0);
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 /* put the 07.05 modem in PDU mode */
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 406
diff changeset
184 atinterf_exec_cmd_needok("AT+CMGF=0", (char *) 0, (void *) 0);
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 /* HEX charset for phonebook names */
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 406
diff changeset
186 atinterf_exec_cmd_needok("AT+CSCS=\"HEX\"", (char *) 0, (void *) 0);
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 /* main command */
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 406
diff changeset
188 atinterf_exec_cmd_needok("AT+CMGL=4", (char *) 0, cmgl_callback);
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 if (pdu_state) {
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 fprintf(stderr, "error: wrong state at the end of +CMGL\n");
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 exit(ERROR_TARGET);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 }
353
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
193 if (delete_after_flag)
3bcc56883b17 fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 352
diff changeset
194 delete_after_process();
406
b88a37d4f148 fcup-smdump: set AT+CSCS="IRA" at the end (don't leave HEX)
Mychaela Falconia <falcon@freecalypso.org>
parents: 364
diff changeset
195 /* be nice and restore IRA charset for manual AT command users */
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 406
diff changeset
196 atinterf_exec_cmd_needok("AT+CSCS=\"IRA\"", (char *) 0, (void *) 0);
352
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 exit(0);
02d6c8469535 fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 }