FreeCalypso > hg > freecalypso-tools
annotate uptools/atcmd/smdump.c @ 663:46d7ed4ee634
loadtools/romload.c: isprint() was used without <ctype.h>
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 06 Mar 2020 01:55:40 +0000 |
parents | dc2fd8e6f42c |
children | da724c67159d |
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 { |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 u_char decoded_name[81]; |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
406
diff
changeset
|
115 gsm7_to_ascii_or_ext(pbname_gsm, pbname_len, decoded_name, |
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
406
diff
changeset
|
116 (unsigned *) 0, 0, 0, (unsigned *) 0); |
352
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 printf("Phonebook-Name: %s\n", decoded_name); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
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 cmgl_pdu() |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 { |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 int cc; |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 unsigned sca_len; |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 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
|
126 if (cc < 1) { |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 fprintf(stderr, "error: expected PDU not received\n"); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 exit(ERROR_TARGET); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 sca_len = pdu_bin[0]; |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 if (1 + sca_len + header_len != cc) { |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 fprintf(stderr, "error: PDU length mismatch\n"); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 exit(ERROR_TARGET); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 } |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 printf("%s message:\n", msgtype); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (pbname_len) |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 emit_pb_name(); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 puts(at_response+1); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 putchar('\n'); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 pdu_state = 0; |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 } |
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 cmgl_callback() |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 { |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 if (pdu_state) |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 cmgl_pdu(); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 else |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 cmgl_header(); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 } |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 |
353
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
151 delete_after_process() |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
152 { |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
153 struct delafter *rec; |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
154 char cmgd_cmd[32]; |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
155 |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
156 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
|
157 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
|
158 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
|
159 } |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
160 } |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
161 |
352
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 main(argc, argv) |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 char **argv; |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 { |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 int c; |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 extern int optind; |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 |
353
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
168 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
|
169 if (atinterf_cmdline_opt(c)) |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
170 continue; |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
171 else if (c == 'd') |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
172 delete_after_flag = 1; |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
173 else { |
352
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 /* error msg already printed */ |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 exit(ERROR_USAGE); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 } |
353
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
177 } |
352
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 if (argc != optind) { |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 fprintf(stderr, "usage: %s [options]\n", argv[0]); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 exit(ERROR_USAGE); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 } |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 atinterf_init(); |
364
ac311a48630e
fcup-smdump & fcup-smsend: send AT+CMEE=2 first
Mychaela Falconia <falcon@freecalypso.org>
parents:
353
diff
changeset
|
183 /* enable verbose error messages */ |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
406
diff
changeset
|
184 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
|
185 /* 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
|
186 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
|
187 /* HEX charset for phonebook names */ |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
406
diff
changeset
|
188 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
|
189 /* main command */ |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
406
diff
changeset
|
190 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
|
191 if (pdu_state) { |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 fprintf(stderr, "error: wrong state at the end of +CMGL\n"); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 exit(ERROR_TARGET); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 } |
353
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
195 if (delete_after_flag) |
3bcc56883b17
fcup-smdump: -d delete-after-dump option implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
352
diff
changeset
|
196 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
|
197 /* 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
|
198 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
|
199 exit(0); |
02d6c8469535
fcup-smdump implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 } |