# HG changeset patch # User Mychaela Falconia # Date 1520526506 0 # Node ID 3cc79e26006672236a542e9c428c1441bf7d95e2 # Parent ed1ecc249eb366a47d59c4bb604269e621e5f5d0 fcup-smsend: implemented concat SMS sending with user-given refno diff -r ed1ecc249eb3 -r 3cc79e260066 uptools/atcmd/smsend_main.c --- a/uptools/atcmd/smsend_main.c Thu Mar 08 07:27:45 2018 +0000 +++ b/uptools/atcmd/smsend_main.c Thu Mar 08 16:28:26 2018 +0000 @@ -17,19 +17,22 @@ char msgtext[MAX_MSG_CHARS*2+2]; u_char msgtext_gsm7[MAX_MSG_CHARS]; unsigned msgtext_gsmlen; +u_char concat_refno; process_cmdline(argc, argv) char **argv; { int c; extern int optind; + extern char *optarg; - while ((c = getopt(argc, argv, "B:cnp:RtuwWX:")) != EOF) { + while ((c = getopt(argc, argv, "B:C:np:RtuwWX:")) != EOF) { if (atinterf_cmdline_opt(c)) continue; switch (c) { - case 'c': + case 'C': concat_enable = 1; + concat_refno = strtoul(optarg, 0, 0); continue; case 't': text_mode = 1; @@ -49,7 +52,8 @@ } } if (concat_enable && text_mode) { - fprintf(stderr, "%s error: -c and -t are mutually exclusive\n", + fprintf(stderr, + "%s error: cannot send concat SMS in text mode\n", argv[0]); exit(ERROR_USAGE); } @@ -129,6 +133,9 @@ char **argv; { int rc; + unsigned nparts, n; + u_char udh[5]; + unsigned pos, remain, chunk; if (!process_cmdline(argc, argv)) read_msgtext_from_stdin(); @@ -176,7 +183,30 @@ } if (!concat_enable) goto too_long_for_one_sms; - - fprintf(stderr, "concat SMS not yet implemented\n"); - exit(ERROR_BUG); + nparts = (msgtext_gsmlen + 152) / 153; + udh[0] = 0x00; + udh[1] = 0x03; + udh[2] = concat_refno; + udh[3] = nparts; + common_init(); + prep_for_pdu_mode(); + if (sms_write_mode == 0) + atinterf_exec_cmd_needok("AT+CMMS=1", 0, 0); + pos = 0; + remain = msgtext_gsmlen; + for (n = 1; n <= nparts; n++) { + udh[4] = n; + chunk = 153; + if (chunk > remain) + chunk = remain; + send_in_pdu_mode(dest_addr, msgtext_gsm7 + pos, chunk, udh, 5); + pos += chunk; + remain -= chunk; + } + if (sms_write_mode == 0) + atinterf_exec_cmd_needok("AT+CMMS=0", 0, 0); + if (sms_write_mode == 1) + sendafterwr_process(); + printf("Message sent as %u SMS segments\n", nparts); + exit(0); }