Revision
16186
Author
gmaruzz
Date
2010-01-06 11:53:01 -0600 (Wed, 06 Jan 2010)

Log Message

gsmopen: fixed receiving SMSs with interfaces that supports PDU mode but we choose to compile gsmopen without PDU (gsmlib)

Modified Paths

Diff

Modified: freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen.h (16185 => 16186)


--- freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen.h	2010-01-06 16:59:53 UTC (rev 16185)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen.h	2010-01-06 17:53:01 UTC (rev 16186)
@@ -407,6 +407,7 @@
 	char sms_servicecentreaddress[256];
 	int sms_messagetype;
 	int sms_cnmi_not_supported;
+	int sms_pdu_not_supported;
 	//char sms_receiving_program[256];
 
 

Modified: freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp (16185 => 16186)


--- freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp	2010-01-06 16:59:53 UTC (rev 16185)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp	2010-01-06 17:53:01 UTC (rev 16186)
@@ -372,14 +372,23 @@
 	if (res) {
 		DEBUGA_GSMOPEN("AT+CMGF? failed, continue\n", GSMOPEN_P_LOG);
 	}
+#ifdef NO_GSMLIB
+	res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");
+	if (res) {
+		ERRORA("Error setting SMS sending mode to TEXT on the cellphone, let's hope is TEXT by default. Continuing\n", GSMOPEN_P_LOG);
+	}
+	tech_pvt->sms_pdu_not_supported = 1;
+#else // NO_GSMLIB
 	res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
 	if (res) {
 		ERRORA("Error setting SMS sending mode to PDU on the cellphone, falling back to TEXT mode. Continuing\n", GSMOPEN_P_LOG);
+		tech_pvt->sms_pdu_not_supported = 1;
 		res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");
 		if (res) {
 			ERRORA("Error setting SMS sending mode to TEXT on the cellphone, let's hope is TEXT by default. Continuing\n", GSMOPEN_P_LOG);
 		}
 	}
+#endif // NO_GSMLIB
 	/* what is the Charset of SMSs? */
 	res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS?");
 	if (res) {
@@ -1559,7 +1568,7 @@
 				else {
 					DEBUGA_GSMOPEN("body=%s\n", GSMOPEN_P_LOG, sms_body);
 					DEBUGA_GSMOPEN("tech_pvt->line_array.result[i]=%s\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
-					if (tech_pvt->sms_cnmi_not_supported) {
+					if (tech_pvt->sms_pdu_not_supported) {
 						char content3[1000];
 						strncpy(tech_pvt->sms_message, tech_pvt->line_array.result[i], sizeof(tech_pvt->sms_message));
 
@@ -1572,8 +1581,10 @@
 						strncpy(tech_pvt->sms_body, content3, sizeof(tech_pvt->sms_body));
 						//sleep(10);
 						//cicopet
-						sms_incoming(tech_pvt);
-						WARNINGA("2 content3=%s\n", GSMOPEN_P_LOG, content3);
+						if (tech_pvt->sms_cnmi_not_supported) {
+							sms_incoming(tech_pvt);
+							WARNINGA("2 content3=%s\n", GSMOPEN_P_LOG, content3);
+						}
 					} else {
 #ifndef NO_GSMLIB
 						char content2[1000];