Changeset 2720


Ignore:
Timestamp:
08/17/07 10:29:08 (6 years ago)
Author:
laforge
Message:

From: Andrzej Zaborowski <balrog@…>
Date: Thu, 26 Jul 2007 00:32:38 +0200
Subject: [PATCH] SMSC and Preferred Storage operations.

This adds setting and retrieval of SMS storage stats (memory type, used
entries, all entries), and of the default service centre (SMSC) number for
outgoing messages. The operation of setting a new SMSC number is untested
because my SIM doesn't seem to allow this (that or I did something wrong). New
"libgmsd-tool -m shell" commands for testing are also added.

Other changes in this patch:

  • The third, optional, parameter to +CMGL: is a string, not an integer as I

wrongly assumed earlier, this is now corrected.

  • Rename libgsmd API functions starting with lgsmd_.. to lgsm_.. for

consistency with all other identifiers.

  • Move lgsm_send_simple() to libgsmd.c and add a prototype in

lgsm_internals.h, this eliminates some compile-time warnings.

Location:
trunk/src/target/gsm
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/gsm/include/gsmd/sms.h

    r2711 r2720  
    1212                int pdulen, int len); 
    1313 
     14extern const char *ts0705_memtype_name[]; 
     15int parse_memtype(char *memtype); 
     16 
    1417#endif /* __GSMD__ */ 
    1518 
  • trunk/src/target/gsm/include/gsmd/usock.h

    r2713 r2720  
    330330}; 
    331331 
     332/* Refer to GSM 07.05 subclause 3.1 */ 
     333enum ts0705_mem_type { 
     334        GSM0705_MEMTYPE_NONE, 
     335        GSM0705_MEMTYPE_BROADCAST, 
     336        GSM0705_MEMTYPE_ME_MESSAGE, 
     337        GSM0705_MEMTYPE_MT, 
     338        GSM0705_MEMTYPE_SIM, 
     339        GSM0705_MEMTYPE_TA, 
     340        GSM0705_MEMTYPE_SR, 
     341}; 
     342 
     343/* Refer to GSM 07.05 subclause 3.2.2 */ 
     344struct __gsmd_sms_storage { 
     345        u_int8_t memtype; 
     346        u_int8_t pad[3]; 
     347        u_int16_t used; 
     348        u_int16_t total; 
     349} __attribute__ ((packed)); 
     350 
     351struct gsmd_sms_storage { 
     352        struct __gsmd_sms_storage mem[3]; 
     353} __attribute__ ((packed)); 
     354 
    332355/* Refer to GSM 07.07 subclause 8.12 */ 
    333356struct gsmd_phonebook_readrg { 
  • trunk/src/target/gsm/include/libgsmd/misc.h

    r2713 r2720  
    6666/* TBD */ 
    6767 
    68  
    69 /* SMS related functions */ 
    70 /* TBD */ 
    71  
    72  
    7368/* GPRS related functions */ 
    7469/* TBD */ 
  • trunk/src/target/gsm/include/libgsmd/sms.h

    r2710 r2720  
    6262 
    6363/* Delete Message */ 
    64 extern int lgsmd_sms_delete(struct lgsm_handle *lh,  
     64extern int lgsm_sms_delete(struct lgsm_handle *lh, 
    6565                const struct lgsm_sms_delete *sms_del); 
    6666 
    6767/* Send Message */ 
    68 extern int lgsmd_sms_send(struct lgsm_handle *lh, const struct lgsm_sms *sms); 
     68extern int lgsm_sms_send(struct lgsm_handle *lh, const struct lgsm_sms *sms); 
    6969 
    7070/* Write Message to Memory */ 
    71 extern int lgsmd_sms_write(struct lgsm_handle *lh,  
     71extern int lgsm_sms_write(struct lgsm_handle *lh, 
    7272                const struct lgsm_sms_write *sms_write); 
     73 
     74/* Retrieve SMS storage information */ 
     75extern int lgsm_sms_get_storage(struct lgsm_handle *lh); 
     76 
     77/* Set preferred SMS storage */ 
     78extern int lgsm_sms_set_storage(struct lgsm_handle *lh, 
     79                enum ts0705_mem_type mem1, enum ts0705_mem_type mem2, 
     80                enum ts0705_mem_type mem3); 
     81 
     82/* Retrieve current default service centre address */ 
     83extern int lgsm_sms_get_smsc(struct lgsm_handle *lh); 
     84 
     85/* Set new default service centre address */ 
     86extern int lgsm_sms_set_smsc(struct lgsm_handle *lh, const char *number); 
    7387 
    7488/* Packing of 7-bit characters, refer to GSM 03.38 subclause 6.1.2.1.1 */ 
  • trunk/src/target/gsm/src/gsmd/sms_cb.c

    r2712 r2720  
    3939#include <gsmd/unsolicited.h> 
    4040 
    41 enum ts0705_mem_type { 
    42         GSM0705_MEMTYPE_NONE, 
    43         GSM0705_MEMTYPE_BROADCAST, 
    44         GSM0705_MEMTYPE_ME_MESSAGE, 
    45         GSM0705_MEMTYPE_MT, 
    46         GSM0705_MEMTYPE_SIM, 
    47         GSM0705_MEMTYPE_TA, 
    48         GSM0705_MEMTYPE_SR, 
    49 }; 
    50  
    51 static const char *ts0705_memtype_name[] = { 
     41const char *ts0705_memtype_name[] = { 
    5242        [GSM0705_MEMTYPE_NONE]          = "NONE", 
    5343        [GSM0705_MEMTYPE_BROADCAST]     = "BM", 
     
    5949}; 
    6050 
    61 static inline int parse_memtype(char *memtype) 
     51inline int parse_memtype(char *memtype) 
    6252{ 
    6353        int i; 
     
    6959 
    7060        return GSM0705_MEMTYPE_NONE; 
    71 } 
    72  
    73 /* TODO: move to headers */ 
    74 struct __gsmd_sms_storage { 
    75         u_int8_t memtype; 
    76         u_int8_t pad[3]; 
    77         u_int16_t used; 
    78         u_int16_t total; 
    79 } __attribute__ ((packed)); 
    80  
    81 struct gsmd_sms_storage { 
    82         struct __gsmd_sms_storage mem[3]; 
    83 } __attribute__ ((packed)); 
    84  
    85 static int usock_cpms_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) 
    86 { 
    87         struct gsmd_user *gu = ctx; 
    88         struct gsmd_ucmd *ucmd = ucmd_alloc(sizeof(struct gsmd_sms_storage)); 
    89         struct gsmd_sms_storage *gss = (typeof(gss)) ucmd->buf; 
    90         char buf[3][3]; 
    91  
    92         DEBUGP("entering(cmd=%p, gu=%p)\n", cmd, gu); 
    93  
    94         if (!ucmd) 
    95                 return -ENOMEM; 
    96  
    97         ucmd->hdr.version = GSMD_PROTO_VERSION; 
    98         ucmd->hdr.msg_type = GSMD_MSG_SMS; 
    99         ucmd->hdr.msg_subtype = GSMD_SMS_GET_MSG_STORAGE; 
    100         ucmd->hdr.len = sizeof(struct gsmd_sms_storage); 
    101         ucmd->hdr.id = cmd->id; 
    102  
    103         if (sscanf(resp, "+CPMS: \"%2[A-Z]\",%hi,%hi," 
    104                                 "\"%2[A-Z]\",%hi,%hi,\"%2[A-Z]\",%hi,%hi", 
    105                                 buf[0], &gss->mem[0].used, &gss->mem[0].total, 
    106                                 buf[1], &gss->mem[1].used, &gss->mem[1].total, 
    107                                 buf[2], &gss->mem[2].used, &gss->mem[2].total) 
    108                         < 9) { 
    109                 talloc_free(ucmd); 
    110                 return -EINVAL; 
    111         } 
    112  
    113         gss->mem[0].memtype = parse_memtype(buf[0]); 
    114         gss->mem[1].memtype = parse_memtype(buf[1]); 
    115         gss->mem[2].memtype = parse_memtype(buf[2]); 
    116  
    117         usock_cmd_enqueue(ucmd, gu); 
    118  
    119         return 0; 
    120 } 
    121  
    122 /* main unix socket SMS receiver */ 
    123 static int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, 
    124                          int len) 
    125 { 
    126         struct gsmd_atcmd *cmd; 
    127  
    128         switch (gph->msg_subtype) { 
    129         case GSMD_SMS_GET_SERVICE_CENTRE: 
    130                 return; 
    131         case GSMD_SMS_SET_SERVICE_CENTRE: 
    132                 return; 
    133         case GSMD_SMS_SET_MSG_STORAGE: 
    134                 return; 
    135         case GSMD_SMS_GET_MSG_STORAGE: 
    136                 cmd = atcmd_fill("AT+CPMS?", 8 + 1, usock_cpms_cb, gu, 0); 
    137                 break; 
    138         } 
    139  
    140         return atcmd_submit(gu->gsmd, cmd); 
    14161} 
    14262 
  • trunk/src/target/gsm/src/gsmd/usock.c

    r2713 r2720  
    4040#include <gsmd/talloc.h> 
    4141#include <gsmd/ts0707.h> 
     42#include <gsmd/sms.h> 
    4243 
    4344static void *__ucmd_ctx, *__gu_ctx; 
     
    526527                        sscanf(resp, "+CMGL: %i,%i,,%i\n%n", 
    527528                                &idx, &stat, &len, &cr) < 3 && 
    528                         sscanf(resp, "+CMGL: %i,%i,%*i,%i\n%n", 
     529                        sscanf(resp, "+CMGL: %i,%i,\"%*[^\"]\",%i\n%n", 
    529530                                &idx, &stat, &len, &cr) < 3) 
    530531                return -EINVAL; 
     
    670671} 
    671672 
     673static int usock_cpms_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) 
     674{ 
     675        struct gsmd_user *gu = ctx; 
     676        struct gsmd_ucmd *ucmd = ucmd_alloc(sizeof(struct gsmd_sms_storage)); 
     677        struct gsmd_sms_storage *gss = (typeof(gss)) ucmd->buf; 
     678        char buf[3][3]; 
     679 
     680        DEBUGP("entering(cmd=%p, gu=%p)\n", cmd, gu); 
     681 
     682        if (!ucmd) 
     683                return -ENOMEM; 
     684 
     685        ucmd->hdr.version = GSMD_PROTO_VERSION; 
     686        ucmd->hdr.msg_type = GSMD_MSG_SMS; 
     687        ucmd->hdr.msg_subtype = GSMD_SMS_GET_MSG_STORAGE; 
     688        ucmd->hdr.len = sizeof(struct gsmd_sms_storage); 
     689        ucmd->hdr.id = cmd->id; 
     690 
     691        if (sscanf(resp, "+CPMS: \"%2[A-Z]\",%hi,%hi," 
     692                                "\"%2[A-Z]\",%hi,%hi,\"%2[A-Z]\",%hi,%hi", 
     693                                buf[0], &gss->mem[0].used, &gss->mem[0].total, 
     694                                buf[1], &gss->mem[1].used, &gss->mem[1].total, 
     695                                buf[2], &gss->mem[2].used, &gss->mem[2].total) 
     696                        < 9) { 
     697                talloc_free(ucmd); 
     698                return -EINVAL; 
     699        } 
     700 
     701        gss->mem[0].memtype = parse_memtype(buf[0]); 
     702        gss->mem[1].memtype = parse_memtype(buf[1]); 
     703        gss->mem[2].memtype = parse_memtype(buf[2]); 
     704 
     705        usock_cmd_enqueue(ucmd, gu); 
     706 
     707        return 0; 
     708} 
     709 
     710static int usock_get_smsc_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) 
     711{ 
     712        struct gsmd_user *gu = ctx; 
     713        struct gsmd_ucmd *ucmd; 
     714        struct gsmd_addr *ga; 
     715 
     716        ucmd = gsmd_ucmd_fill(sizeof(struct gsmd_addr), GSMD_MSG_SMS, 
     717                        GSMD_SMS_GET_SERVICE_CENTRE, cmd->id); 
     718        if (!ucmd) 
     719                return -ENOMEM; 
     720 
     721        ga = (struct gsmd_addr *) ucmd->buf; 
     722        if (sscanf(resp, "+CSCA: \"%31[^\"]\",%hhi", 
     723                                ga->number, &ga->type) < 2) { 
     724                talloc_free(ucmd); 
     725                return -EINVAL; 
     726        } 
     727 
     728        usock_cmd_enqueue(ucmd, gu); 
     729        return 0; 
     730} 
     731 
    672732static const char *gsmd_cmgl_stat[] = { 
    673733        "REC UNREAD", "REC READ", "STO UNSENT", "STO SENT", "ALL", 
     
    682742        struct gsmd_sms_submit *gss; 
    683743        struct gsmd_sms_write *gsw; 
     744        struct gsmd_addr *ga; 
     745        enum ts0705_mem_type *storage; 
    684746        int *stat, *index; 
    685747        int atcmd_len; 
     
    694756                        return -EINVAL; 
    695757 
    696                 /* FIXME: should we set <mem1> to "SM"/"ME" before that? */ 
    697758                if (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) 
    698759                        atcmd_len = sprintf(buf, "AT+CMGL=\"%s\"", 
     
    703764                cmd = atcmd_fill(buf, atcmd_len + 1, 
    704765                                &sms_list_cb, gu, gph->id); 
    705                 if (!cmd) 
    706                         return -ENOMEM; 
    707766                break; 
    708767 
     
    712771                index = (int *) ((void *)gph + sizeof(*gph)); 
    713772 
    714                 /* FIXME: should we set <mem1> to "SM"/"ME" before that? */ 
    715773                atcmd_len = sprintf(buf, "AT+CMGR=%i", *index); 
    716774 
    717775                cmd = atcmd_fill(buf, atcmd_len + 1, 
    718776                                 &sms_read_cb, gu, gph->id); 
    719                 if (!cmd) 
    720                         return -ENOMEM; 
    721777                break; 
    722778 
     
    741797 
    742798                cmd = atcmd_fill(buf, atcmd_len, &sms_send_cb, gu, gph->id); 
    743                 if (!cmd) 
    744                         return -ENOMEM; 
    745799                break; 
    746800 
     
    752806                        return -EINVAL; 
    753807 
    754                 /* FIXME: should we set <mem2> to "SM"/"ME" before that? */ 
    755808                if (gu->gsmd->flags & GSMD_FLAG_SMS_FMT_TEXT) { 
    756809                        atcmd_len = sprintf(buf, "AT+CMGW=\"%s\"\n%.*s", 
     
    769822 
    770823                cmd = atcmd_fill(buf, atcmd_len, &sms_write_cb, gu, gph->id); 
    771                 if (!cmd) 
    772                         return -ENOMEM; 
    773824                break; 
    774825 
     
    782833 
    783834                cmd = atcmd_fill(buf, atcmd_len + 1, 
    784                                  &sms_delete_cb, gu, gph->id); 
    785                 if (!cmd) 
    786                         return -ENOMEM; 
     835                                &sms_delete_cb, gu, gph->id); 
     836                break; 
     837 
     838        case GSMD_SMS_GET_MSG_STORAGE: 
     839                cmd = atcmd_fill("AT+CPMS?", 8 + 1, usock_cpms_cb, gu, 0); 
     840                break; 
     841 
     842        case GSMD_SMS_SET_MSG_STORAGE: 
     843                if (len < sizeof(*gph) + 3 * sizeof(enum ts0705_mem_type)) 
     844                        return -EINVAL; 
     845                storage = (enum ts0705_mem_type *) 
     846                        ((void *) gph + sizeof(*gph)); 
     847                atcmd_len = sprintf(buf, "AT+CPMS=\"%s\",\"%s\",\"%s\"", 
     848                                ts0705_memtype_name[storage[0]], 
     849                                ts0705_memtype_name[storage[1]], 
     850                                ts0705_memtype_name[storage[2]]); 
     851                cmd = atcmd_fill(buf, atcmd_len + 1, 
     852                                &null_cmd_cb, gu, gph->id); 
    787853                break;   
     854 
     855        case GSMD_SMS_GET_SERVICE_CENTRE: 
     856                cmd = atcmd_fill("AT+CSCA?", 8 + 1, &usock_get_smsc_cb, gu, 0); 
     857                break; 
     858 
     859        case GSMD_SMS_SET_SERVICE_CENTRE: 
     860                if (len < sizeof(*gph) + sizeof(struct gsmd_addr)) 
     861                        return -EINVAL; 
     862                ga = (struct gsmd_addr *) ((void *) gph + sizeof(*gph)); 
     863                atcmd_len = sprintf(buf, "AT+CSCA=\"%s\",%i", 
     864                                ga->number, ga->type); 
     865                cmd = atcmd_fill(buf, atcmd_len + 1, 
     866                                &null_cmd_cb, gu, gph->id); 
     867                break; 
     868 
    788869        default: 
    789870                return -EINVAL; 
    790871        } 
    791872 
     873        if (!cmd) 
     874                return -ENOMEM; 
     875 
    792876        gsmd_log(GSMD_DEBUG, "%s\n", cmd ? cmd->buf : 0); 
    793         if (cmd) 
    794                 return atcmd_submit(gu->gsmd, cmd); 
    795         else 
    796                 return 0; 
     877        return atcmd_submit(gu->gsmd, cmd); 
    797878} 
    798879 
  • trunk/src/target/gsm/src/libgsmd/lgsm_internals.h

    r2713 r2720  
    1212 
    1313int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh); 
     14int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type); 
    1415struct gsmd_msg_hdr *lgsm_gmh_fill(int type, int subtype, int payload_len); 
    1516#define lgsm_gmh_free(x)        free(x) 
  • trunk/src/target/gsm/src/libgsmd/libgsmd.c

    r1314 r2720  
    208208} 
    209209 
     210int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type) 
     211{ 
     212        struct gsmd_msg_hdr *gmh; 
     213        int rc; 
     214 
     215        gmh = lgsm_gmh_fill(type, sub_type, 0); 
     216        if (!gmh) 
     217                return -ENOMEM; 
     218        rc = lgsm_send(lh, gmh); 
     219        if (rc < gmh->len + sizeof(*gmh)) { 
     220                lgsm_gmh_free(gmh); 
     221                return -EIO; 
     222        } 
     223        lgsm_gmh_free(gmh); 
     224 
     225        return 0; 
     226} 
  • trunk/src/target/gsm/src/libgsmd/libgsmd_sms.c

    r2710 r2720  
    5858} 
    5959 
    60 int lgsmd_sms_delete(struct lgsm_handle *lh,  
     60int lgsm_sms_delete(struct lgsm_handle *lh, 
    6161                const struct lgsm_sms_delete *sms_del) 
    6262{ 
     
    8484} 
    8585 
    86 int lgsmd_number2addr(struct gsmd_addr *dst, const char *src) 
     86int lgsm_number2addr(struct gsmd_addr *dst, const char *src, int skipplus) 
    8787{ 
    8888        char *ch; 
     
    9595                        GSMD_TOA_TON_INTERNATIONAL | 
    9696                        GSMD_TOA_RESERVED; 
    97                 strcpy(dst->number, src + 1); 
     97                strcpy(dst->number, src + skipplus); 
    9898        } else { 
    9999                dst->type = 
     
    110110} 
    111111 
    112 int lgsmd_sms_send(struct lgsm_handle *lh, 
     112int lgsm_sms_send(struct lgsm_handle *lh, 
    113113                const struct lgsm_sms *sms) 
    114114{ 
     
    124124        gss = (struct gsmd_sms_submit *) gmh->data; 
    125125 
    126         if (lgsmd_number2addr(&gss->addr, sms->addr)) 
     126        if (lgsm_number2addr(&gss->addr, sms->addr, 1)) 
    127127                return -EINVAL; 
    128128 
     
    143143} 
    144144 
    145 int lgsmd_sms_write(struct lgsm_handle *lh, 
     145int lgsm_sms_write(struct lgsm_handle *lh, 
    146146                const struct lgsm_sms_write *sms_write) 
    147147{ 
     
    159159        gsw->stat = sms_write->stat; 
    160160 
    161         if (lgsmd_number2addr(&gsw->sms.addr, sms_write->sms.addr)) 
     161        if (lgsm_number2addr(&gsw->sms.addr, sms_write->sms.addr, 1)) 
    162162                return -EINVAL; 
    163163 
     
    176176        lgsm_gmh_free(gmh); 
    177177 
     178        return 0; 
     179} 
     180 
     181int lgsm_sms_get_storage(struct lgsm_handle *lh) 
     182{ 
     183        return lgsm_send_simple(lh, GSMD_MSG_SMS, GSMD_SMS_GET_MSG_STORAGE); 
     184} 
     185 
     186int lgsm_sms_set_storage(struct lgsm_handle *lh, enum ts0705_mem_type mem1, 
     187                enum ts0705_mem_type mem2, enum ts0705_mem_type mem3) 
     188{ 
     189        struct gsmd_msg_hdr *gmh = 
     190                lgsm_gmh_fill(GSMD_MSG_SMS, GSMD_SMS_SET_MSG_STORAGE, 
     191                                3 * sizeof(enum ts0705_mem_type)); 
     192        if (!gmh) 
     193                return -ENOMEM; 
     194 
     195        ((enum ts0705_mem_type *) gmh->data)[0] = mem1; 
     196        ((enum ts0705_mem_type *) gmh->data)[1] = mem2; 
     197        ((enum ts0705_mem_type *) gmh->data)[2] = mem3; 
     198 
     199        if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) { 
     200                lgsm_gmh_free(gmh); 
     201                return -EIO; 
     202        } 
     203 
     204        lgsm_gmh_free(gmh); 
     205        return 0; 
     206} 
     207 
     208int lgsm_sms_get_smsc(struct lgsm_handle *lh) 
     209{ 
     210        return lgsm_send_simple(lh, GSMD_MSG_SMS, GSMD_SMS_GET_SERVICE_CENTRE); 
     211} 
     212 
     213int lgsm_sms_set_smsc(struct lgsm_handle *lh, const char *number) 
     214{ 
     215        struct gsmd_msg_hdr *gmh = 
     216                lgsm_gmh_fill(GSMD_MSG_SMS, GSMD_SMS_SET_SERVICE_CENTRE, 
     217                                sizeof(struct gsmd_addr)); 
     218        if (!gmh) 
     219                return -ENOMEM; 
     220 
     221        if (lgsm_number2addr((struct gsmd_addr *) gmh->data, number, 0)) { 
     222                lgsm_gmh_free(gmh); 
     223                return -EINVAL; 
     224        } 
     225 
     226        if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) { 
     227                lgsm_gmh_free(gmh); 
     228                return -EIO; 
     229        } 
     230 
     231        lgsm_gmh_free(gmh); 
    178232        return 0; 
    179233} 
  • trunk/src/target/gsm/src/libgsmd/libgsmd_voicecall.c

    r1282 r2720  
    2828 
    2929#include "lgsm_internals.h" 
    30  
    31 int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type) 
    32 { 
    33         struct gsmd_msg_hdr *gmh; 
    34         int rc; 
    35  
    36         gmh = lgsm_gmh_fill(type, sub_type, 0); 
    37         if (!gmh) 
    38                 return -ENOMEM; 
    39         rc = lgsm_send(lh, gmh); 
    40         if (rc < gmh->len + sizeof(*gmh)) { 
    41                 lgsm_gmh_free(gmh); 
    42                 return -EIO; 
    43         } 
    44         lgsm_gmh_free(gmh); 
    45  
    46         return 0; 
    47 } 
    4830 
    4931int lgsm_voice_out_init(struct lgsm_handle *lh, 
  • trunk/src/target/gsm/src/util/shell.c

    r2713 r2720  
    8282        int *result; 
    8383        struct gsmd_sms_list *sms; 
    84         static const char *type[] = { "Unread", "Received", "Unsent", "Sent" }; 
     84        struct gsmd_addr *addr; 
     85        struct gsmd_sms_storage *mem; 
     86        static const char *msgtype[] = { 
     87                "Unread", "Received", "Unsent", "Sent" 
     88        }; 
     89        static const char *memtype[] = { 
     90                "Unknown", "Broadcast", "Me message", "MT", "SIM", "TA", "SR" 
     91        }; 
    8592 
    8693        switch (gmh->msg_subtype) { 
     
    8996                sms = (struct gsmd_sms_list *) ((void *) gmh + sizeof(*gmh)); 
    9097                printf("%s message %i from/to %s%s, at %i%i-%i%i-%i%i " 
    91                                 "%i%i:%i%i:%i%i, GMT%c%i\n", type[sms->stat], 
    92                                 sms->index, 
     98                                "%i%i:%i%i:%i%i, GMT%c%i\n", 
     99                                msgtype[sms->stat], sms->index, 
    93100                                ((sms->addr.type & __GSMD_TOA_TON_MASK) == 
    94101                                 GSMD_TOA_TON_INTERNATIONAL) ? "+" : "", 
     
    167174                } 
    168175                break; 
     176        case GSMD_SMS_GET_MSG_STORAGE: 
     177                mem = (struct gsmd_sms_storage *) 
     178                        ((void *) gmh + sizeof(*gmh)); 
     179                printf("mem1: %s (%i)       Occupied: %i / %i\n", 
     180                                memtype[mem->mem[0].memtype], 
     181                                mem->mem[0].memtype, 
     182                                mem->mem[0].used, 
     183                                mem->mem[0].total); 
     184                printf("mem2: %s (%i)       Occupied: %i / %i\n", 
     185                                memtype[mem->mem[1].memtype], 
     186                                mem->mem[1].memtype, 
     187                                mem->mem[1].used, 
     188                                mem->mem[1].total); 
     189                printf("mem3: %s (%i)       Occupied: %i / %i\n", 
     190                                memtype[mem->mem[2].memtype], 
     191                                mem->mem[2].memtype, 
     192                                mem->mem[2].used, 
     193                                mem->mem[2].total); 
     194                break; 
     195        case GSMD_SMS_GET_SERVICE_CENTRE: 
     196                addr = (struct gsmd_addr *) ((void *) gmh + sizeof(*gmh)); 
     197                printf("Number of the default Service Centre is %s\n", 
     198                                addr->number); 
     199                break; 
    169200        default: 
    170201                return -EINVAL; 
     
    245276                "\tss\tSMS Send (ss=number,text)\n" 
    246277                "\tsw\tSMS Write (sw=stat,number,text)\n" 
     278                "\tsm\tSMS Storage stats\n" 
     279                "\tsM\tSMS Set preferred storage (sM=mem1,mem2,mem3)\n" 
     280                "\tsc\tSMS Show Service Centre\n" 
     281                "\tsC\tSMS Set Service Centre (sC=number)\n" 
    247282                "\tq\tQuit\n" 
    248283                ); 
     
    358393                                printf("Delete Phonebook Entry\n");                              
    359394                                ptr = strchr(buf, '='); 
    360                                 lgsmd_pb_del_entry(lgsmh, atoi(ptr+1));                          
     395                                lgsmd_pb_del_entry(lgsmh, atoi(ptr+1)); 
    361396                        } else if ( !strncmp(buf, "prr", 3)) {   
    362397                                printf("Read Phonebook Entries\n"); 
     
    372407                                printf("Read Phonebook Entry\n"); 
    373408                                ptr = strchr(buf, '=');                          
    374                                 lgsm_pb_read_entry(lgsmh, atoi(ptr+1));  
     409                                lgsm_pb_read_entry(lgsmh, atoi(ptr+1)); 
    375410                        } else if ( !strncmp(buf, "pf", 2)) { 
    376411                                printf("Find Phonebook Entry\n"); 
     
    403438                        } else if ( !strncmp(buf, "ps", 2)) {    
    404439                                printf("Get Phonebook Support\n"); 
    405                                 lgsm_pb_get_support(lgsmh);                              
     440                                lgsm_pb_get_support(lgsmh); 
    406441                        } else if ( !strncmp(buf, "sd", 2)) {            
    407442                                printf("Delete SMS\n");                  
     
    413448                                sms_del.delflg = atoi(ptr+1);    
    414449                         
    415                                 lgsmd_sms_delete(lgsmh, &sms_del);                               
     450                                lgsm_sms_delete(lgsmh, &sms_del); 
    416451                        } else if ( !strncmp(buf, "sl", 2)) {            
    417452                                printf("List SMS\n");    
     
    434469                                packing_7bit_character(fcomma+1, &sms); 
    435470 
    436                                 lgsmd_sms_send(lgsmh, &sms); 
     471                                lgsm_sms_send(lgsmh, &sms); 
    437472                        } else if ( !strncmp(buf, "sw", 2)) {    
    438473                                printf("Write SMS\n");                           
     
    449484                                                lcomma+1, &sms_write.sms); 
    450485 
    451                                 lgsmd_sms_write(lgsmh, &sms_write); 
     486                                lgsm_sms_write(lgsmh, &sms_write); 
     487                        } else if (!strncmp(buf, "sm", 2)) { 
     488                                printf("Get SMS storage preferences\n"); 
     489                                lgsm_sms_get_storage(lgsmh); 
     490                        } else if (!strncmp(buf, "sM", 2)) { 
     491                                int mem[3]; 
     492 
     493                                printf("Set SMS storage preferences\n"); 
     494                                if (sscanf(buf, "sM=%i,%i,%i", mem, mem + 1, 
     495                                                        mem + 2) < 3) 
     496                                        printf("No.\n"); 
     497                                else 
     498                                        lgsm_sms_set_storage(lgsmh, mem[0], 
     499                                                        mem[1], mem[2]); 
     500                        } else if (!strncmp(buf, "sc", 2)) { 
     501                                printf("Get the default SMSC\n"); 
     502                                lgsm_sms_get_smsc(lgsmh); 
     503                        } else if (!strncmp(buf, "sC", 2)) { 
     504                                printf("Set the default SMSC\n"); 
     505                                ptr = strchr(buf, '='); 
     506                                if (!ptr || strlen(ptr) < 6) 
     507                                        printf("No.\n"); 
     508                                else 
     509                                        lgsm_sms_set_smsc(lgsmh, ptr + 1); 
    452510                        } else { 
    453511                                printf("Unknown command `%s'\n", buf); 
Note: See TracChangeset for help on using the changeset viewer.