TEST, IGNORE: patch for CMS ERROR

Harald Welte laforge at openmoko.org
Sun Apr 1 15:12:47 CEST 2007


[ THIS IS A REPOST TO TEST http://patches.openmoko.org/, please ignore ]

Hi!

Current gsmd doesn't handle CMS error messages, thinking they are
extended replies and getting totally confused because it doesn't count
them as final results. The following patch adds CMS error definitions
from ETSI TS 07.05 and handles those errors in atcmd.c's ml_parse().
Question: is parse_final_result obsolete or is it only unused currently
but will handle the final results in the future?

cheers
Philipp

Index: gsm/include/gsmd/ts0705.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gsm/include/gsmd/ts0705.h	2007-03-27 17:52:38.000000000 +0200
@@ -0,0 +1,31 @@
+#ifndef _GSM_0705_H
+#define _GSM_0705_H
+
+/* Section 3.2.5 */
+enum gsm0705_cms_error {
+	GSM0705_CMS_ME_FAILURE			= 300,
+	GSM0705_CMS_SMS_SERVICE_OF_ME_RESERVED	= 301,
+	GSM0705_CMS_OPERATION_NOT_ALLOWED	= 302,
+	GSM0705_CMS_OPERATION_NOT_SUPPORTED	= 303,
+	GSM0705_CMS_INVALID_PDU_MODE_PARAMETER	= 304,
+	GSM0705_CMS_INVALID_TEXT_MODE_PARAMETER = 305,
+	GSM0705_CMS_SIM_NOT_INSERTED		= 310,
+	GSM0705_CMS_SIM_PIN_REQUIRED		= 311,
+	GSM0705_CMS_PH_SIM_PIN_REQUIRED		= 312,
+	GSM0705_CMS_SIM_FAILURE			= 313,
+	GSM0705_CMS_SIM_BUSY			= 314,
+	GSM0705_CMS_SIM_WRONG			= 315,
+	GSM0705_CMS_SIM_PUK_REQUIRED		= 316,
+	GSM0705_CMS_SIM_PIN2_REQUIRED		= 317,
+	GSM0705_CMS_SIM_PUK2_REQUIRED		= 318,
+	GSM0705_CMS_MEMORY_FAILURE		= 320,
+	GSM0705_CMS_INVALID_MEMORY_INDEX	= 321,
+	GSM0705_CMS_MEMORY_FULL			= 322,
+	GSM0705_CMS_SMSC_ADDRESS_UNKNOWN	= 330,
+	GSM0705_CMS_NO_NETWORK_SERVICE		= 331,
+	GSM0705_CMS_NETWORK_TIMEOUT		= 332,
+	GSM0705_CMS_NO_CNMA_ACK_EXPECTED	= 340,
+	GSM0705_CMS_UNKNOWN			= 500,
+};
+
+#endif /* _GSM_0705_H */
Index: gsm/src/gsmd/atcmd.c
===================================================================
--- gsm.orig/src/gsmd/atcmd.c	2007-03-27 17:14:48.000000000 +0200
+++ gsm/src/gsmd/atcmd.c	2007-03-27 17:46:42.000000000 +0200
@@ -33,6 +33,7 @@
 
 #include "gsmd.h"
 
+#include <gsmd/ts0705.h>
 #include <gsmd/ts0707.h>
 #include <gsmd/gsmd.h>
 #include <gsmd/atcmd.h>
@@ -50,7 +51,8 @@
 static const char *final_results[] = {
 	"OK",
 	"ERROR",
-	"+CME ERROR:"
+	"+CME ERROR:",
+	"+CMS ERROR:",
 };
 
 /* we basically implement a parse that can deal with
@@ -223,6 +225,16 @@
 			final = 1;
 			goto final_cb;
 		}
+		if (!strncmp(buf+1, "CMS ERROR", 9)) {
+			/* Part of Case 'C' */
+			unsigned long err_nr;
+			err_nr = strtoul(colon+1, NULL, 10);
+			DEBUGP("error number %lu\n", err_nr);
+			if (cmd)
+				cmd->ret = err_nr;
+			final = 1;
+			goto final_cb;
+		}
 
 		if (!cmd || strncmp(buf, &cmd->buf[2], colon-buf)) {
 			/* Assuming Case 'B' */
Index: gsm/include/gsmd/Makefile.am
===================================================================
--- gsm.orig/include/gsmd/Makefile.am	2007-03-27 17:45:09.000000000 +0200
+++ gsm/include/gsmd/Makefile.am	2007-03-27 17:45:16.000000000 +0200
@@ -1,4 +1,4 @@
 
 pkginclude_HEADERS = event.h usock.h
 
-noinst_HEADERS = atcmd.h gsmd.h select.h ts0707.h unsolicited.h usock.h vendorplugin.h
+noinst_HEADERS = atcmd.h gsmd.h select.h ts0705.h ts0707.h unsolicited.h usock.h vendorplugin.h

-- 
- Harald Welte <laforge at openmoko.org>          	        http://openmoko.org/
============================================================================
Software for the world's first truly open Free Software mobile phone



More information about the gsmd-devel mailing list