comparison uptools/atcmd/smsend_main.c @ 370:076d533f840d

fcup-smsend: implemented automatic concat SMS refno generation
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Mar 2018 17:47:58 +0000
parents 06cf82710cca
children 0bd06f481223
comparison
equal deleted inserted replaced
369:06cf82710cca 370:076d533f840d
10 #include <unistd.h> 10 #include <unistd.h>
11 #include "../../rvinterf/include/exitcodes.h" 11 #include "../../rvinterf/include/exitcodes.h"
12 12
13 #define MAX_MSG_CHARS (153*255) 13 #define MAX_MSG_CHARS (153*255)
14 14
15 int sms_write_mode, text_mode, utf8_input, concat_enable, quiet; 15 int sms_write_mode, text_mode, utf8_input, quiet;
16 int concat_enable, concat_refno_set;
16 u_char dest_addr[12]; 17 u_char dest_addr[12];
17 char msgtext[MAX_MSG_CHARS*2+2]; 18 char msgtext[MAX_MSG_CHARS*2+2];
18 u_char msgtext_gsm7[MAX_MSG_CHARS]; 19 u_char msgtext_gsm7[MAX_MSG_CHARS];
19 unsigned msgtext_gsmlen; 20 unsigned msgtext_gsmlen;
20 u_char concat_refno; 21 u_char concat_refno;
24 { 25 {
25 int c; 26 int c;
26 extern int optind; 27 extern int optind;
27 extern char *optarg; 28 extern char *optarg;
28 29
29 while ((c = getopt(argc, argv, "B:C:np:qRtuwWX:")) != EOF) { 30 while ((c = getopt(argc, argv, "B:cC:np:qRtuwWX:")) != EOF) {
30 if (atinterf_cmdline_opt(c)) 31 if (atinterf_cmdline_opt(c))
31 continue; 32 continue;
32 switch (c) { 33 switch (c) {
34 case 'c':
35 concat_enable = 1;
36 continue;
33 case 'C': 37 case 'C':
34 concat_enable = 1; 38 concat_enable = 1;
35 concat_refno = strtoul(optarg, 0, 0); 39 concat_refno = strtoul(optarg, 0, 0);
40 concat_refno_set = 1;
36 continue; 41 continue;
37 case 'q': 42 case 'q':
38 quiet = 1; 43 quiet = 1;
39 continue; 44 continue;
40 case 't': 45 case 't':
184 printf("Message sent as single SMS\n"); 189 printf("Message sent as single SMS\n");
185 exit(0); 190 exit(0);
186 } 191 }
187 if (!concat_enable) 192 if (!concat_enable)
188 goto too_long_for_one_sms; 193 goto too_long_for_one_sms;
194 if (!concat_refno_set)
195 concat_refno = get_concsms_refno_from_host_fs();
189 nparts = (msgtext_gsmlen + 152) / 153; 196 nparts = (msgtext_gsmlen + 152) / 153;
190 udh[0] = 0x00; 197 udh[0] = 0x00;
191 udh[1] = 0x03; 198 udh[1] = 0x03;
192 udh[2] = concat_refno; 199 udh[2] = concat_refno;
193 udh[3] = nparts; 200 udh[3] = nparts;