sending/writing SMS in PDU mode

Erin Yueh erin_yueh at openmoko.com
Thu Aug 30 11:33:05 CEST 2007


Erin Yueh wrote:
> Hi All,
>
> I found a bug on sending/writing SMS in PDU mode. When I used send/write
> function from "libgmsd-tool -m shell", i got a CMS error = 302(operation
> not allowed). The problem is related to a <CR> in AT commands.
> Therefore, I made this patch to fix the <CR> problem.
>
> Cheers,
> Erin
>
>
>   
> ------------------------------------------------------------------------
>
> --- /home/erin/sep/gsm/src/gsmd/sms_cb.c	2007-08-22 17:08:27.000000000 +0800
> +++ src/gsmd/sms_cb.c	2007-08-22 17:13:35.000000000 +0800
> @@ -290,6 +290,7 @@ int usock_rcv_sms(struct gsmd_user *gu, 
>  {
>  	/* FIXME: TEXT mode support!!  */
>  	struct gsmd_atcmd *cmd = NULL;
> +	sturct gsmd_atcmd *atcmd = NULL;
>  	struct gsmd_sms_delete *gsd;
>  	struct gsmd_sms_submit *gss;
>  	struct gsmd_sms_write *gsw;
> @@ -297,7 +298,9 @@ int usock_rcv_sms(struct gsmd_user *gu, 
>  	enum ts0705_mem_type *storage;
>  	int *stat, *index;
>  	int atcmd_len;
> +	int atlen;
>  	char buf[1024];
> +	char buffer[15];
>  
>  	switch (gph->msg_subtype) {
>  	case GSMD_SMS_LIST:
> @@ -339,10 +342,11 @@ int usock_rcv_sms(struct gsmd_user *gu, 
>  					gss->payload.length,
>  					gss->payload.data);	/* FIXME */
>  		} else {
> -			atcmd_len = sprintf(buf, "AT+CMGS=%i\n",
> -					sms_pdu_make_smssubmit(NULL, gss) - 1);
> -			atcmd_len += sms_pdu_make_smssubmit(buf + atcmd_len,
> -					gss) * 2;
> +			atlen = sprintf(buffer, "AT+CMGS=%i", sms_pdu_make_smssubmit(NULL, gss) - 1);
> +			atcmd = atcmd_fill(buffer, atlen + 1, NULL, gu->gsmd, 0); 
> +			atcmd_submit(gu->gsmd, atcmd);
> +			/* it will append <CR> from atcmd_select_cb() */
> +			atcmd_len += sms_pdu_make_smssubmit(buf + atcmd_len,gss) * 2;
>  		}
>  		buf[atcmd_len ++] = 26;	/* ^Z ends the message */
>  		buf[atcmd_len ++] = 0;
> @@ -363,11 +367,12 @@ int usock_rcv_sms(struct gsmd_user *gu, 
>  					gsw->sms.payload.length,
>  					gsw->sms.payload.data);	/* FIXME */
>  		} else {
> -			atcmd_len = sprintf(buf, "AT+CMGW=%i,%i\n",
> -					sms_pdu_make_smssubmit(NULL,
> -						&gsw->sms) - 1, gsw->stat);
> +			atlen = sprintf(buffer, "AT+CMGW=%i,%i", sms_pdu_make_smssubmit(NULL,&gsw->sms) - 1, gsw->stat);
> +			atcmd = atcmd_fill(buffer, atlen + 1, NULL, gu->gsmd, 0); 
> +			atcmd_submit(gu->gsmd, atcmd);
> +			/* it will append <CR> from atcmd_select_cb() */
>  			atcmd_len += sms_pdu_make_smssubmit(buf + atcmd_len,
> -					&gsw->sms) * 2;
> +				       &gsw->sms) * 2;
>  		}
>  		buf[atcmd_len ++] = 26;	/* ^Z ends the message */
>  		buf[atcmd_len ++] = 0;
>   
Oops..... I just realized it's a bug from the multi-line parser and not
'\r' or '\n' problem on sending SMS at commands. After using the new
patch, there's no problem on sending/writing SMS at all.



More information about the gsmd-devel mailing list