gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Bosch - get SMS support


From: Ladislav Michl
Subject: [PATCH] Bosch - get SMS support
Date: Mon, 2 Dec 2002 12:11:10 +0100
User-agent: Mutt/1.2.5i

Bosch 909 violates PDU format. This patch provides software workaround.

        ladis

Index: gnokii/common/phones/atbosch.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/phones/atbosch.c,v
retrieving revision 1.1
diff -u -r1.1 atbosch.c
--- gnokii/common/phones/atbosch.c      25 Nov 2002 22:09:42 -0000      1.1
+++ gnokii/common/phones/atbosch.c      2 Dec 2002 10:53:30 -0000
@@ -57,12 +57,65 @@
        return GN_ERR_NOTSUPPORTED;
 }
 
+static GSM_RecvFunctionType replygetsms;
+
+/* 
+ * Bosch 909 (and probably also Bosch 908) doesn't provide SMSC information
+ * We insert it here to satisfy generic PDU SMS receiving function in atgen.c
+ */
+static gn_error ReplyGetSMS(int type, unsigned char *buffer, int length,
+                           GSM_Data *data, GSM_Statemachine *state)
+{
+       int i, ofs, len;
+       char *pos, *lenpos;
+       char tmp[8];
+
+       if (buffer[0] != GEAT_OK)
+               return GN_ERR_INVALIDLOCATION;
+
+       pos = buffer + 1;
+       for (i = 0; i < 2; i++) {
+               pos = findcrlf(pos, 1, length);
+               if (!pos)
+                       return GN_ERR_INTERNALERROR;
+               pos = skipcrlf(pos);
+               if (i == 0) {
+                       int j;
+                       lenpos = pos;
+                       for (j = 0; j < 2; j++) {
+                               lenpos = strchr(lenpos, ',');
+                               if (!lenpos)
+                                       return GN_ERR_INTERNALERROR;
+                               lenpos++;
+                       }
+                       len = atoi(lenpos);
+               }
+       }
+
+       /* Do we need one more digit? */
+       if (len / 10 < (len + 2) / 10)
+               memmove(lenpos + 1, lenpos, lenpos - (char*)buffer);
+       ofs = snprintf(tmp, 8, "%d", len + 2);
+       if (ofs < 1)
+               return GN_ERR_INTERNALERROR; /* something went very wrong */
+       memcpy(lenpos, tmp, ofs);
+       
+       /* Insert zero length SMSC field */
+       ofs = pos - (char*)buffer;
+       memmove(pos + 2, pos, length - ofs);
+       buffer[ofs]   = '0';
+       buffer[ofs+1] = '0';
+       return (*replygetsms)(type, buffer, length + 2, data, state);
+}
+
+
 void AT_InitBosch(GSM_Statemachine *state, char *foundmodel, char *setupmodel)
 {
        AT_InsertRecvFunction(GOPAT_GetCharset, NULL);
        AT_InsertSendFunction(GOPAT_GetCharset, GetCharset);
        AT_InsertRecvFunction(GOPAT_SetCharset, NULL);
        AT_InsertSendFunction(GOPAT_SetCharset, SetCharset);
+       replygetsms = AT_InsertRecvFunction(GOP_GetSMS, ReplyGetSMS);
        /* phone lacks many usefull commands :( */
        AT_InsertSendFunction(GOP_GetBatteryLevel, Unsupported);
        AT_InsertSendFunction(GOP_GetRFLevel, Unsupported);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]