From 66ddffab0a8fe2f517d83859ffb20467acd0cbe6 Mon Sep 17 00:00:00 2001 From: laforge Date: Thu, 16 Aug 2007 04:18:54 +0000 Subject: From 294d27e78680d497da22e3a8ad679f50d1ba29e5 Mon Sep 17 00:00:00 2001 From: Andrzej Zaborowski Date: Wed, 11 Jul 2007 16:11:10 +0200 Subject: [PATCH] SMS support in gsmd and in libgsmd. This adds the proper support for sms related calls in libgsmd and their implementation in gsmd. I assumed that conversion between data coding schemes is to be done on the client side because the {packing,unpacking}* calls were exported. TEXT mode support is non-functional, but the code only has to be filled in the right places to make it work, if it is ever needed. I had been lucky to be able to test with the different kinds of messages with exotic formats because I just got a bunch of network messages today (urging to top-up the credit). I tried to not modify the libgsmd api, although I would prefer to have a totally different api, possibly with synchronous calls that just return the result of an operation, for a exmaple a whole list of messages, rather than the client waiting for an unknown number of events each with one message. git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@2710 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/gsmd/sms_cb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/gsmd/sms_cb.c') diff --git a/src/gsmd/sms_cb.c b/src/gsmd/sms_cb.c index 330317c..22bf613 100644 --- a/src/gsmd/sms_cb.c +++ b/src/gsmd/sms_cb.c @@ -184,18 +184,29 @@ static const struct gsmd_unsolocit gsm0705_unsolicit[] = { { "+CDS", &cds_parse }, /* SMS Status Index (stored in ME/TA) */ }; - int sms_cb_init(struct gsmd *gsmd) { struct gsmd_atcmd *atcmd; + char buffer[10]; atcmd = atcmd_fill("AT+CSMS=0", NULL, gu, 0); if (!atcmd) return -ENOMEM; atcmd_submit(gsmd, atcmd); - /* Switch into "text mode" (Section 3.2.3) */ - atcdm = atcmd_fill("AT+CMGF=1", 9, &sms_cb_init_cb, gu, 0); + /* If text mode, set the encoding */ + if (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) { + atcmd = atcmd_fill("AT+CSCS=\"IRA\"", 13, NULL, gu, 0); + if (!atcmd) + return -ENOMEM; + atcmd_submit(gsmd, atcmd); + } + + /* Switch into desired mode (Section 3.2.3) */ + snprintf(buffer, sizeof(buffer), "AT+CMGF=%i", + (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) ? + GSMD_SMS_FMT_TEXT : GSMD_SMS_FMT_PDU); + atcmd = atcmd_fill(buffer, strlen(buffer) + 1, NULL, gu, 0); if (!atcmd) return -ENOMEM; -- cgit v1.2.3