From 7247d56f6787bc1c7e573c2b3df78d0d46fee9eb Mon Sep 17 00:00:00 2001 From: jserv Date: Wed, 17 Oct 2007 06:14:20 +0000 Subject: Added 'Ask Status report' option in shell. From: Andrzej Zaborowski I also moved the .ask_ds field from struct gsmd_sms into struct gsmd_sms_submit because it seemed more logical being a property of SMS-SUBMIT PDU. git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3201 99fdad57-331a-0410-800a-d7fa5415bdb3 --- include/gsmd/usock.h | 1 + include/libgsmd/sms.h | 1 + src/gsmd/sms_pdu.c | 3 ++- src/libgsmd/libgsmd_sms.c | 2 ++ src/util/shell.c | 35 ++++++++++++++++------------------- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h index bfd4cd0..c2f03f5 100644 --- a/include/gsmd/usock.h +++ b/include/gsmd/usock.h @@ -330,6 +330,7 @@ struct gsmd_sms { struct gsmd_sms_submit { struct gsmd_addr addr; struct gsmd_sms payload; + int ask_ds; }; /* Refer to GSM 07.05 subclause 4.4 */ diff --git a/include/libgsmd/sms.h b/include/libgsmd/sms.h index 3ada62d..9808442 100644 --- a/include/libgsmd/sms.h +++ b/include/libgsmd/sms.h @@ -46,6 +46,7 @@ struct lgsm_sms { enum gsmd_sms_alphabet alpha; u_int8_t data[LGSM_SMS_DATA_MAXLEN+1]; int length; + int ask_ds; }; /* GSM 03.40 subclause 9.2.2.2 and GSM 07.05 subclause 4.4 and subclause 3.1 */ diff --git a/src/gsmd/sms_pdu.c b/src/gsmd/sms_pdu.c index d1235dd..d461999 100644 --- a/src/gsmd/sms_pdu.c +++ b/src/gsmd/sms_pdu.c @@ -247,7 +247,8 @@ int sms_pdu_make_smssubmit(char *dest, const struct gsmd_sms_submit *src) GSMD_SMS_TP_MTI_SUBMIT | (0 << 2) | /* Reject Duplicates: 0 */ GSMD_SMS_TP_VPF_NOT_PRESENT | - GSMD_SMS_TP_SRR_STATUS_REQUEST | + (src->ask_ds ? GSMD_SMS_TP_SRR_STATUS_REQUEST : + GSMD_SMS_TP_SRR_NOT_REQUEST) | (src->payload.has_header ? GSMD_SMS_TP_UDHI_WITH_HEADER : GSMD_SMS_TP_UDHI_NO_HEADER) | GSMD_SMS_TP_RP_NOT_SET; diff --git a/src/libgsmd/libgsmd_sms.c b/src/libgsmd/libgsmd_sms.c index 22d7dbf..bbc8689 100644 --- a/src/libgsmd/libgsmd_sms.c +++ b/src/libgsmd/libgsmd_sms.c @@ -126,6 +126,7 @@ int lgsm_sms_send(struct lgsm_handle *lh, if (lgsm_number2addr(&gss->addr, sms->addr, 1)) return -EINVAL; + gss->ask_ds = sms->ask_ds; gss->payload.has_header = 0; gss->payload.length = sms->length; gss->payload.coding_scheme = sms->alpha; @@ -161,6 +162,7 @@ int lgsm_sms_write(struct lgsm_handle *lh, if (lgsm_number2addr(&gsw->sms.addr, sms_write->sms.addr, 1)) return -EINVAL; + gsw->sms.ask_ds = sms_write->sms.ask_ds; gsw->sms.payload.has_header = 0; gsw->sms.payload.length = sms_write->sms.length; gsw->sms.payload.coding_scheme = sms_write->sms.alpha; diff --git a/src/util/shell.c b/src/util/shell.c index 63261ad..04076be 100644 --- a/src/util/shell.c +++ b/src/util/shell.c @@ -389,7 +389,7 @@ static int shell_help(void) "\tsd\tSMS Delete (sd=index,delflg)\n" "\tsl\tSMS List (sl=stat)\n" "\tsr\tSMS Read (sr=index)\n" - "\tss\tSMS Send (ss=number,text|[\"text\"])\n" + "\tss\tSMS Send (ss=ask_ds,number,text|[\"text\"])\n" "\tsw\tSMS Write (sw=stat,number,text)\n" "\tsm\tSMS Storage stats\n" "\tsM\tSMS Set preferred storage (sM=mem1,mem2,mem3)\n" @@ -615,33 +615,29 @@ int shell_main(struct lgsm_handle *lgsmh) struct lgsm_sms sms; ptr = strchr(buf, '='); + sms.ask_ds = atoi(ptr+1); fcomma = strchr(buf, ','); - if (!ptr || !fcomma) { - printf("Wrong command format\n"); - } else { - strncpy(sms.addr, ptr+1, fcomma-ptr-1); - sms.addr[fcomma-ptr-1] = '\0'; - - /* todo define \" to allow " in text */ - if (fcomma[1] == '"' && - !strchr(fcomma+2, '"')) { + lcomma = strchr(fcomma+1, ','); + strncpy(sms.addr, fcomma+1, lcomma-fcomma-1); + sms.addr[lcomma-fcomma-1] = '\0'; + /* todo define \" to allow " in text */ + if (lcomma[1]=='"' && + !strchr(lcomma+2, '"')) { /* read until closing '"' */ rc = fscanf(stdin, "%[^\"]\"", - fcomma+strlen(fcomma)); + lcomma+strlen(lcomma)); if (rc == EOF) { printf("EOF\n"); return -1; } /* remove brackets */ - fcomma++; - fcomma[strlen(fcomma)] = '\0'; - } - - printf("Send SMS\n"); - packing_7bit_character(fcomma+1, &sms); - - lgsm_sms_send(lgsmh, &sms); + lcomma++; + lcomma[strlen(lcomma)] = '\0'; } + printf("Send SMS\n"); + packing_7bit_character(lcomma+1, &sms); + + lgsm_sms_send(lgsmh, &sms); } else if ( !strncmp(buf, "sw", 2)) { printf("Write SMS\n"); struct lgsm_sms_write sms_write; @@ -655,6 +651,7 @@ int shell_main(struct lgsm_handle *lgsmh) sms_write.sms.addr[lcomma-fcomma-1] = '\0'; packing_7bit_character( lcomma+1, &sms_write.sms); + sms_write.sms.ask_ds = 0; lgsm_sms_write(lgsmh, &sms_write); } else if (!strncmp(buf, "sm", 2)) { -- cgit v1.2.3