Hi list,

Attached is a patch implementing the validity period (relative) for
CIMD2 connections.  It has been tested with one of our swiss CIMD2
connections.

The documentation for the "validity" parameter (sendsms interface) in
the User's Guide does not mention that this functionality might not be
implemented for certain SMSC types.  We found that it wasn't implemented
for CIMD2 only after our clients told us it didn't work.  I'd be willing
to write an explanation sentence or 2 for the "validity" parameter
(sendsms interface) of the User's Guide if someone can tell me what
other SMSCs it works/doesn't work for.

Question: In this patch, the "algorithm" to convert a time in minutes
into a integer according to the GSM 03.40 (section 9.2.3.12) spec was
copied from smsc_at2.c.  Is there a place in kannel where a generic
function like this could be added rather than copying code?


Nick


Index: gw/smsc/smsc_cimd2.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_cimd2.c,v
retrieving revision 1.3
diff -u -r1.3 smsc_cimd2.c
--- gw/smsc/smsc_cimd2.c	14 Nov 2002 02:29:25 -0000	1.3
+++ gw/smsc/smsc_cimd2.c	27 Jan 2003 11:50:42 -0000
@@ -1207,6 +1207,7 @@
     int spaceleft;
     long truncated;
     int dcs = 0;
+    int setvalidity = 0;
 
     gw_assert(msg != NULL);
     gw_assert(msg->type == sms);
@@ -1255,6 +1256,41 @@
                        "which does not start with the sender-prefix.",
                     octstr_get_cstr(msg->sms.sender));
         }
+    }
+
+    /* Add the validity period if necessary.  This sets the relative validity
+     * period as this is the description of the "validity" parameter of the
+     * sendsms interface.
+     *
+     * Convert from minutes to GSM 03.40 specification (section 9.2.3.12).
+     * 0-143   = 0 to 12 hours in 5 minute increments.
+     * 144-167 = 12hrs30min to 24hrs in 30 minute increments.
+     * 168-196 = 2days to 30days in 1 day increments.
+     * 197-255 = 5weeks to 63weeks in 1 week increments.
+     *
+     * This code was copied from smsc_at2.c. 
+     */
+    if (msg->sms.validity) {
+      if (msg->sms.validity > 635040)
+	setvalidity = 255;
+      if (msg->sms.validity >= 50400 && msg->sms.validity <= 635040)
+	setvalidity = (msg->sms.validity - 1) / 7 / 24 / 60 + 192 + 1;
+      if (msg->sms.validity > 43200 && msg->sms.validity < 50400)
+	setvalidity = 197;
+      if (msg->sms.validity >= 2880 && msg->sms.validity <= 43200)
+	setvalidity = (msg->sms.validity - 1) / 24 / 60 + 166 + 1;
+      if (msg->sms.validity > 1440 && msg->sms.validity < 2880)
+	setvalidity = 168;
+      if (msg->sms.validity >= 750 && msg->sms.validity <= 1440)
+	setvalidity = (msg->sms.validity - 720 - 1) / 30 + 143 + 1;
+      if (msg->sms.validity > 720 && msg->sms.validity < 750)
+	setvalidity = 144;
+      if (msg->sms.validity >= 5 && msg->sms.validity <= 720)
+	setvalidity = (msg->sms.validity - 1) / 5 - 1 + 1;
+      if (msg->sms.validity < 5)
+	setvalidity = 0;
+
+      packet_add_int_parm(packet, P_VALIDITY_PERIOD_RELATIVE, setvalidity);
     }
 
     /* Explicitly ask not to get status reports.

Reply via email to