FreeCalypso > hg > freecalypso-tools
annotate uptools/atcmd/smsend_main.c @ 366:9f856f843620
uptools/atcmd: smsend_basic.c renamed to smsend_main.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Mar 2018 07:09:37 +0000 |
parents | uptools/atcmd/smsend_basic.c@4378d70b146b |
children | ed1ecc249eb3 |
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 is the main module for the basic fcup-smsend utility. |
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 #include <stdlib.h> |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <unistd.h> |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "../../rvinterf/include/exitcodes.h" |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
13 #define MAX_MSG_CHARS 160 |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
14 |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int sms_write_mode, text_mode, utf8_input; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 u_char dest_addr[12]; |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
17 char msgtext[MAX_MSG_CHARS*2+2]; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
18 u_char msgtext_gsm7[MAX_MSG_CHARS]; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 unsigned msgtext_gsmlen; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 process_cmdline(argc, argv) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 char **argv; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 int c; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 extern int optind; |
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 while ((c = getopt(argc, argv, "B:np:RtuwWX:")) != EOF) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 if (atinterf_cmdline_opt(c)) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 switch (c) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 case 't': |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 text_mode = 1; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 case 'u': |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 utf8_input = 1; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 case 'w': |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 sms_write_mode = 1; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 case 'W': |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 sms_write_mode = 2; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 default: |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 /* error msg already printed */ |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (argc > optind + 2) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 fprintf(stderr, "usage: %s [options] dest-addr [message]\n", |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 argv[0]); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 if (!argv[optind] || !argv[optind][0]) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (sms_write_mode == 2) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 dest_addr[0] = 0; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 dest_addr[1] = 0x80; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } else { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 fprintf(stderr, |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 "error: destination address must be specified\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } else if (parse_and_encode_dest_addr(argv[optind], dest_addr) < 0) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 fprintf(stderr, |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 "error: destination address argument is invalid\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 if (!argv[optind+1]) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 return(0); |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
69 if (strlen(argv[optind+1]) > MAX_MSG_CHARS*2) { |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 fprintf(stderr, "error: message argument is too long\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 strcpy(msgtext, argv[optind+1]); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 return(1); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 read_msgtext_from_stdin() |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 { |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
79 unsigned pos, remain; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
80 int cc; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
82 pos = 0; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
83 remain = sizeof(msgtext); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
84 for (;;) { |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
85 if (!remain) { |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
86 fprintf(stderr, |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
87 "error: message on stdin is too long\n"); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
88 exit(ERROR_USAGE); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
89 } |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
90 cc = read(0, msgtext + pos, remain); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
91 if (cc < 0) { |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
92 fprintf(stderr, "error reading message from stdin\n"); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
93 exit(ERROR_USAGE); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
94 } |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
95 if (cc == 0) |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
96 break; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
97 pos += cc; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
98 remain -= cc; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 } |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
100 msgtext[pos] = '\0'; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
101 } |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
102 |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
103 trim_trailing_newlines() |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
104 { |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
105 char *cp; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
106 |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
107 cp = index(msgtext, '\0'); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
108 while (cp > msgtext && cp[-1] == '\n') |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
109 cp--; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
110 *cp = '\0'; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 main(argc, argv) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 char **argv; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 int rc; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 if (!process_cmdline(argc, argv)) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 read_msgtext_from_stdin(); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 if (utf8_input && utf8_to_latin1(msgtext) < 0) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 fprintf(stderr, "error: invalid UTF-8 message\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 } |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
124 trim_trailing_newlines(); |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 if (text_mode) { |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
126 if (index(msgtext, '\n')) { |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
127 fprintf(stderr, |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
128 "error: multiline messages not supported in text mode\n"); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
129 exit(ERROR_USAGE); |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
130 } |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 if (strlen(msgtext) > 160) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 toolong: fprintf(stderr, "error: message exceeds 160 chars\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 } else { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 rc = latin1_to_gsm7(msgtext, msgtext_gsm7, 160, |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 &msgtext_gsmlen); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 if (rc == -1) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 fprintf(stderr, |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 "error: message not valid for GSM7 charset\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 if (rc == -2) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 goto toolong; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 /* get to work */ |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 atinterf_init(); |
364
ac311a48630e
fcup-smdump & fcup-smsend: send AT+CMEE=2 first
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
148 /* enable verbose error messages */ |
ac311a48630e
fcup-smdump & fcup-smsend: send AT+CMEE=2 first
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
149 atinterf_exec_cmd_needok("AT+CMEE=2", 0, 0); |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 if (text_mode) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 prep_for_text_mode(); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 send_in_text_mode(dest_addr, msgtext); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 } else { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 prep_for_pdu_mode(); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 send_in_pdu_mode(dest_addr, msgtext_gsm7, msgtext_gsmlen, 0, 0); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 if (sms_write_mode == 1) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 sendafterwr_process(); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 exit(0); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 } |