Patch: Adding message-start support in smsc_at.c

"Nikos Balkanas" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <E2C821E75F0243BD9002465A75E084CB@drwho>
Hi,

This is a simple patch to add a configuration option to at smsc,
message-start
(in group modems). In case of sim-buffering it will set the starting buffer
index in the sim. For some modems such as the UMG181 this needs to be set to
0. Defaults to 1, and doesn't need changing for most others.

Reported and tested by Chris Holt.



BR,
Nikos
----- Original Message ----- 
From: "Alexander Malysh" <[email protected]>
To: "Nikos Balkanas" <[email protected]>
Cc: "Chris Holt" <[email protected]>; <[email protected]>
Sent: Monday, April 26, 2010 10:37 AM
Subject: Re: Patch: Adding support for sim-start in smsc_at.c


Hi Nikos,

looks ok for me, please provide userguide patch and I will commit it.

Thanks,
Alexander Malysh

Am 23.04.2010 um 12:01 schrieb Nikos Balkanas:

> Oops! Sorry about that. Here is the version for modems group.
>
> Configures parameter message-start in group modems.
>
> Can you please restest?
>
> Thanks,
> Nikos
> ----- Original Message ----- From: "Chris Holt" <[email protected]>
> To: "Nikos Balkanas" <[email protected]>
> Cc: <[email protected]>
> Sent: Friday, April 23, 2010 5:02 AM
> Subject: Re: Patch: Adding support for sim-start in smsc_at.c
>
>
>> I applied it to my 1.4.3 source and it works, except the sim-start had
>> to be in group smsc not modems.
>>
>> Many thanks!
>> -Chris
>>
>> 2010/4/22 Nikos Balkanas <[email protected]>:
>>> Hi,
>>>
>>> This is a simple patch to add a configuration option to at smsc,
>>> sim-start
>>> (in group modems). In case of sim-buffering it will set the starting
>>> buffer
>>> index in the sim. For some modems such as the UMG181 this needs to be
>>> set to
>>> 0. Defaults to 1, and doesn't need changing for most others.
>>>
>>> If admitted will also provide user-guide patch
>>>
>>> Reported by Chris Holt.
>>>
>>> @Chris: I have no way of testing this. Could you please do the honors?
>>>
>>> Thanks,
>>> Nikos
> <kannel.diff>
kannel.diff (application/octet-stream, 3.4 KB)
Index: doc/userguide/userguide.xml
===================================================================
RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
retrieving revision 1.360
diff -a -u -b -r1.360 userguide.xml
--- doc/userguide/userguide.xml	20 Mar 2010 11:20:20 -0000	1.360
+++ doc/userguide/userguide.xml	26 Apr 2010 11:01:40 -0000
@@ -3939,6 +3939,16 @@
                 storage will be used (usually "SM").
      </entry></row>
 
+   <row><entry><literal>message-start</literal></entry>
+     <entry><literal>string</literal></entry>
+     <entry valign="bottom">
+        Optional integer, defaults to 1. Specifies starting index in
+                SIM buffer for new SMS. Most modems start numbering from 1,
+                however a few like the UMG181 start numbering from 0. This
+                parameter ensures that all SMS are fetched when using
+                "SIM buffering".
+     </entry></row>
+
    <row><entry><literal>enable-mms</literal></entry>
      <entry><literal>boolean</literal></entry>
      <entry valign="bottom">
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.142
diff -a -u -b -r1.142 cfg.def
--- gwlib/cfg.def	6 Dec 2009 17:24:14 -0000	1.142
+++ gwlib/cfg.def	26 Apr 2010 11:01:40 -0000
@@ -532,6 +532,7 @@
     OCTSTR(keepalive-cmd)
     OCTSTR(broken)
     OCTSTR(message-storage)
+    OCTSTR(message-start)
     OCTSTR(enable-mms)
     OCTSTR(reset-string)
 )
Index: gw/smsc/smsc_at.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
retrieving revision 1.63
diff -a -u -b -r1.63 smsc_at.c
--- gw/smsc/smsc_at.c	24 Aug 2009 09:49:08 -0000	1.63
+++ gw/smsc/smsc_at.c	26 Apr 2010 11:01:41 -0000
@@ -1087,6 +1087,7 @@
          */
         int i;
         int message_count = 0; /* cound number of messages collected */
+        ModemDef *modem = privdata->modem;
 
         debug("bb.smsc.at2", 0, "AT2[%s]: %d messages waiting in memory", 
               octstr_get_cstr(privdata->name), privdata->sms_memory_usage);
@@ -1094,8 +1095,7 @@
         /*
          * loop till end of memory or collected enouch messages
          */
-        for (i = 1; i <= privdata->sms_memory_capacity &&
-             message_count < privdata->sms_memory_usage; ++i) { 
+        for (i = modem->message_start; i < (privdata->sms_memory_capacity  + modem->message_start) && message_count < privdata->sms_memory_usage; ++i) {
 
             /* if (meanwhile) there are pending CMTI notifications, process these first
              * to not let CMTI and sim buffering sit in each others way */
@@ -2827,6 +2827,8 @@
             modem->keepalive_cmd = octstr_create("AT");
 
         modem->message_storage = cfg_get(grp, octstr_imm("message-storage"));
+        if (cfg_get_integer(&modem->message_start, grp, octstr_imm("message-start")))
+            modem->message_start = 1;
 
         cfg_get_bool(&modem->enable_mms, grp, octstr_imm("enable-mms"));
 
Index: gw/smsc/smsc_at.h
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.h,v
retrieving revision 1.18
diff -a -u -b -r1.18 smsc_at.h
--- gw/smsc/smsc_at.h	12 Aug 2009 15:38:27 -0000	1.18
+++ gw/smsc/smsc_at.h	26 Apr 2010 11:01:42 -0000
@@ -111,6 +111,7 @@
     Octstr *keepalive_cmd;
     int	broken;
     Octstr *message_storage;
+    long message_start;
     int	enable_mms;
 } ModemDef;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.