FreeCalypso > hg > freecalypso-tools
annotate uptools/atcmd/smsend_main.c @ 846:a2e17e0f9622
CHANGES: document fc-tmsync mpr & madc command additions
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 31 Jul 2021 22:37:34 +0000 |
parents | dc2fd8e6f42c |
children | 2969032bdfac |
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 |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
13 #define MAX_MSG_CHARS (153*255) |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
14 #define MAX_MSG_UNI (67*255) |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
15 |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
16 int sms_write_mode, text_mode, utf8_input, ucs2_mode; |
371
0bd06f481223
fcup-smsend: automatic -q (concat quiet) with -W
Mychaela Falconia <falcon@freecalypso.org>
parents:
370
diff
changeset
|
17 int concat_enable, concat_refno_set, concat_quiet; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 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
|
19 char msgtext[MAX_MSG_CHARS*2+2]; |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
20 u_char concat_refno; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 process_cmdline(argc, argv) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 char **argv; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 int c; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 extern int optind; |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
27 extern char *optarg; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
29 while ((c = getopt(argc, argv, "B:cC:np:qRtuUwWX:")) != EOF) { |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 if (atinterf_cmdline_opt(c)) |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 switch (c) { |
370
076d533f840d
fcup-smsend: implemented automatic concat SMS refno generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
33 case 'c': |
076d533f840d
fcup-smsend: implemented automatic concat SMS refno generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
34 concat_enable = 1; |
076d533f840d
fcup-smsend: implemented automatic concat SMS refno generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
35 continue; |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
36 case 'C': |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
37 concat_enable = 1; |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
38 concat_refno = strtoul(optarg, 0, 0); |
370
076d533f840d
fcup-smsend: implemented automatic concat SMS refno generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
39 concat_refno_set = 1; |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
40 continue; |
369
06cf82710cca
fcup-smsend: implemented -q option to suppress concat summary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
368
diff
changeset
|
41 case 'q': |
371
0bd06f481223
fcup-smsend: automatic -q (concat quiet) with -W
Mychaela Falconia <falcon@freecalypso.org>
parents:
370
diff
changeset
|
42 concat_quiet = 1; |
369
06cf82710cca
fcup-smsend: implemented -q option to suppress concat summary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
368
diff
changeset
|
43 continue; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 case 't': |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 text_mode = 1; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 case 'u': |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 utf8_input = 1; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 continue; |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
50 case 'U': |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
51 ucs2_mode = 1; |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
52 continue; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 case 'w': |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 sms_write_mode = 1; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 case 'W': |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 sms_write_mode = 2; |
371
0bd06f481223
fcup-smsend: automatic -q (concat quiet) with -W
Mychaela Falconia <falcon@freecalypso.org>
parents:
370
diff
changeset
|
58 concat_quiet = 1; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 continue; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 default: |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 /* error msg already printed */ |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
65 if (concat_enable && text_mode) { |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
66 fprintf(stderr, |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
67 "%s error: cannot send concat SMS in text mode\n", |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
68 argv[0]); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
69 exit(ERROR_USAGE); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
70 } |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
71 if (ucs2_mode && text_mode) { |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
72 fprintf(stderr, "%s error: UCS-2 not supported in text mode\n", |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
73 argv[0]); |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
74 exit(ERROR_USAGE); |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
75 } |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 if (argc > optind + 2) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 fprintf(stderr, "usage: %s [options] dest-addr [message]\n", |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 argv[0]); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 if (!argv[optind] || !argv[optind][0]) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (sms_write_mode == 2) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 dest_addr[0] = 0; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 dest_addr[1] = 0x80; |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } else { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 fprintf(stderr, |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 "error: destination address must be specified\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 } 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
|
91 fprintf(stderr, |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 "error: destination address argument is invalid\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 } |
405
ed9b67e7e741
fcup-smsend: fixed bug in the handling of -W with no dest address argument
Mychaela Falconia <falcon@freecalypso.org>
parents:
381
diff
changeset
|
95 if (argc < optind + 2) |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 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
|
97 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
|
98 fprintf(stderr, "error: message argument is too long\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 strcpy(msgtext, argv[optind+1]); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 return(1); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 read_msgtext_from_stdin() |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 { |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
107 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
|
108 int cc; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
110 pos = 0; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
111 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
|
112 for (;;) { |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
113 if (!remain) { |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
114 fprintf(stderr, |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
115 "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
|
116 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
|
117 } |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
118 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
|
119 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
|
120 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
|
121 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
|
122 } |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
123 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
|
124 break; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
125 pos += cc; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
126 remain -= cc; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 } |
365
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
128 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
|
129 } |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
130 |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
131 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
|
132 { |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
133 char *cp; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
134 |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
135 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
|
136 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
|
137 cp--; |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
138 *cp = '\0'; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
141 common_init() |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
142 { |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
143 atinterf_init(); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
144 /* enable verbose error messages */ |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
405
diff
changeset
|
145 atinterf_exec_cmd_needok("AT+CMEE=2", (char *) 0, (void *) 0); |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
146 } |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
147 |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
148 gsm7_mode_main() |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 { |
381
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
150 u_char msgtext_gsm7[MAX_MSG_CHARS]; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
151 unsigned msgtext_gsmlen; |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 int rc; |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
153 unsigned nparts, n; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
154 u_char udh[5]; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
155 unsigned pos, remain, chunk; |
362
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 (utf8_input && utf8_to_latin1(msgtext) < 0) { |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 fprintf(stderr, "error: invalid UTF-8 message\n"); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 } |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 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
|
162 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
|
163 fprintf(stderr, |
4378d70b146b
fcup-smsend: added support for multiline messages in default PDU send mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
164 "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
|
165 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
|
166 } |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 if (strlen(msgtext) > 160) { |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
168 too_long_for_one_sms: fprintf(stderr, "error: message exceeds 160 chars\n"); |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 exit(ERROR_USAGE); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 } |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
171 common_init(); |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 prep_for_text_mode(); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 send_in_text_mode(dest_addr, msgtext); |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
174 if (sms_write_mode == 1) |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
175 sendafterwr_process(); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
176 exit(0); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
177 } |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
178 rc = latin1_to_gsm7(msgtext, msgtext_gsm7, MAX_MSG_CHARS, |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
179 &msgtext_gsmlen); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
180 if (rc == -1) { |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
181 fprintf(stderr, "error: message not valid for GSM7 charset\n"); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
182 exit(ERROR_USAGE); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
183 } |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
184 if (rc == -2) { |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
185 fprintf(stderr, "error: message too long for max concat SMS\n"); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
186 exit(ERROR_USAGE); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
187 } |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
188 if (msgtext_gsmlen <= 160) { |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
189 common_init(); |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 prep_for_pdu_mode(); |
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 send_in_pdu_mode(dest_addr, msgtext_gsm7, msgtext_gsmlen, 0, 0); |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
192 if (sms_write_mode == 1) |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
193 sendafterwr_process(); |
371
0bd06f481223
fcup-smsend: automatic -q (concat quiet) with -W
Mychaela Falconia <falcon@freecalypso.org>
parents:
370
diff
changeset
|
194 if (concat_enable && !concat_quiet) |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
195 printf("Message sent as single SMS\n"); |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
196 exit(0); |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 } |
367
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
198 if (!concat_enable) |
ed1ecc249eb3
fcup-smsend: prep for adding concat SMS support
Mychaela Falconia <falcon@freecalypso.org>
parents:
366
diff
changeset
|
199 goto too_long_for_one_sms; |
370
076d533f840d
fcup-smsend: implemented automatic concat SMS refno generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
200 if (!concat_refno_set) |
076d533f840d
fcup-smsend: implemented automatic concat SMS refno generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
201 concat_refno = get_concsms_refno_from_host_fs(); |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
202 nparts = (msgtext_gsmlen + 152) / 153; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
203 udh[0] = 0x00; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
204 udh[1] = 0x03; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
205 udh[2] = concat_refno; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
206 udh[3] = nparts; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
207 common_init(); |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
208 prep_for_pdu_mode(); |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
209 if (sms_write_mode == 0) |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
405
diff
changeset
|
210 atinterf_exec_cmd_needok("AT+CMMS=1", (char *) 0, (void *) 0); |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
211 pos = 0; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
212 remain = msgtext_gsmlen; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
213 for (n = 1; n <= nparts; n++) { |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
214 udh[4] = n; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
215 chunk = 153; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
216 if (chunk > remain) |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
217 chunk = remain; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
218 send_in_pdu_mode(dest_addr, msgtext_gsm7 + pos, chunk, udh, 5); |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
219 pos += chunk; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
220 remain -= chunk; |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
221 } |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
222 if (sms_write_mode == 0) |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
405
diff
changeset
|
223 atinterf_exec_cmd_needok("AT+CMMS=0", (char *) 0, (void *) 0); |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
224 if (sms_write_mode == 1) |
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
225 sendafterwr_process(); |
371
0bd06f481223
fcup-smsend: automatic -q (concat quiet) with -W
Mychaela Falconia <falcon@freecalypso.org>
parents:
370
diff
changeset
|
226 if (!concat_quiet) |
369
06cf82710cca
fcup-smsend: implemented -q option to suppress concat summary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
368
diff
changeset
|
227 printf("Message sent as %u SMS segments\n", nparts); |
368
3cc79e260066
fcup-smsend: implemented concat SMS sending with user-given refno
Mychaela Falconia <falcon@freecalypso.org>
parents:
367
diff
changeset
|
228 exit(0); |
362
89fe66cb60f6
fcup-smsend program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 } |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
230 |
381
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
231 ucs2_mode_main() |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
232 { |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
233 u_short msgtext_uni[MAX_MSG_UNI]; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
234 unsigned msgtext_unilen; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
235 int rc; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
236 unsigned nparts, n; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
237 u_char udh[5]; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
238 unsigned pos, remain, chunk; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
239 |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
240 rc = utf8_to_ucs2(msgtext, msgtext_uni, MAX_MSG_UNI, &msgtext_unilen); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
241 if (rc == -1) { |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
242 fprintf(stderr, "error: invalid UTF-8 message\n"); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
243 exit(ERROR_USAGE); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
244 } |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
245 if (rc == -2) { |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
246 fprintf(stderr, "error: message too long for max concat SMS\n"); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
247 exit(ERROR_USAGE); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
248 } |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
249 if (msgtext_unilen <= 70) { |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
250 common_init(); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
251 prep_for_pdu_mode(); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
252 send_pdu_ucs2(dest_addr, msgtext_uni, msgtext_unilen, 0, 0); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
253 if (sms_write_mode == 1) |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
254 sendafterwr_process(); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
255 if (concat_enable && !concat_quiet) |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
256 printf("Message sent as single SMS\n"); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
257 exit(0); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
258 } |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
259 if (!concat_enable) { |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
260 fprintf(stderr, "error: message exceeds 70 UCS-2 chars\n"); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
261 exit(ERROR_USAGE); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
262 } |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
263 if (!concat_refno_set) |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
264 concat_refno = get_concsms_refno_from_host_fs(); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
265 nparts = (msgtext_unilen + 66) / 67; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
266 udh[0] = 0x00; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
267 udh[1] = 0x03; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
268 udh[2] = concat_refno; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
269 udh[3] = nparts; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
270 common_init(); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
271 prep_for_pdu_mode(); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
272 if (sms_write_mode == 0) |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
405
diff
changeset
|
273 atinterf_exec_cmd_needok("AT+CMMS=1", (char *) 0, (void *) 0); |
381
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
274 pos = 0; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
275 remain = msgtext_unilen; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
276 for (n = 1; n <= nparts; n++) { |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
277 udh[4] = n; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
278 chunk = 67; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
279 if (chunk > remain) |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
280 chunk = remain; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
281 send_pdu_ucs2(dest_addr, msgtext_uni + pos, chunk, udh, 5); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
282 pos += chunk; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
283 remain -= chunk; |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
284 } |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
285 if (sms_write_mode == 0) |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
405
diff
changeset
|
286 atinterf_exec_cmd_needok("AT+CMMS=0", (char *) 0, (void *) 0); |
381
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
287 if (sms_write_mode == 1) |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
288 sendafterwr_process(); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
289 if (!concat_quiet) |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
290 printf("Message sent as %u SMS segments\n", nparts); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
291 exit(0); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
292 } |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
293 |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
294 main(argc, argv) |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
295 char **argv; |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
296 { |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
297 if (!process_cmdline(argc, argv)) |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
298 read_msgtext_from_stdin(); |
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
299 trim_trailing_newlines(); |
381
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
300 if (ucs2_mode) |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
301 ucs2_mode_main(); |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
302 else |
40b1498ec39d
fcup-smsend: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
380
diff
changeset
|
303 gsm7_mode_main(); |
380
a8abaa85c378
fcup-smsend: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
304 } |