Revision
16441
Author
gmaruzz
Date
2010-01-21 17:43:31 -0600 (Thu, 21 Jan 2010)

Log Message

gsmopen: adding IMEI and IMSI requesting, beefing up gsmopen_dump API command and CUSTOM gsmopen::dump_event EVENT

Modified Paths

Diff

Modified: freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen.h (16440 => 16441)


--- freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen.h	2010-01-21 19:59:28 UTC (rev 16440)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen.h	2010-01-21 23:43:31 UTC (rev 16441)
@@ -488,6 +488,9 @@
 		 int registered;
 		 int got_signal;
 		 char imei[128];
+		 int requesting_imei;
+		 char imsi[128];
+		 int requesting_imsi;
 
 };
 

Modified: freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp (16440 => 16441)


--- freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp	2010-01-21 19:59:28 UTC (rev 16440)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp	2010-01-21 23:43:31 UTC (rev 16441)
@@ -744,10 +744,26 @@
 		DEBUGA_GSMOPEN("AT+CGMM failed\n", GSMOPEN_P_LOG);
 	}
 
-	res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CGSN");
+	/* IMEI */
+	tech_pvt->requesting_imei = 1;
+	res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+GSN");
+	tech_pvt->requesting_imei = 0;
 	if (res) {
-		DEBUGA_GSMOPEN("AT+CGSN failed\n", GSMOPEN_P_LOG);
+		DEBUGA_GSMOPEN("AT+GSN failed\n", GSMOPEN_P_LOG);
+		tech_pvt->requesting_imei = 1;
+		res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CGSN");
+		tech_pvt->requesting_imei = 0;
+		if (res) {
+			DEBUGA_GSMOPEN("AT+CGSN failed\n", GSMOPEN_P_LOG);
+		}
 	}
+	/* IMSI */
+	tech_pvt->requesting_imsi = 1;
+	res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CIMI");
+	tech_pvt->requesting_imsi = 0;
+	if (res) {
+		DEBUGA_GSMOPEN("AT+CIMI failed\n", GSMOPEN_P_LOG);
+	}
 
 	/* signal incoming SMS with a +CMTI unsolicited msg */
 	res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CNMI=3,1,0,0,0");
@@ -1873,6 +1889,19 @@
 				at_ack = AT_ERROR;
 			}
 
+			/* if we are requesting IMEI, put the line into the imei buffer if the line is not "OK" or "ERROR" */
+			if (tech_pvt->requesting_imei && at_ack == -1) {
+				if (strlen(tech_pvt->line_array.result[i])) {	/* we are reading the IMEI */
+					strncpy(tech_pvt->imei, tech_pvt->line_array.result[i], sizeof(tech_pvt->imei));
+				}
+			}
+
+			/* if we are requesting IMSI, put the line into the imei buffer if the line is not "OK" or "ERROR" */
+			if (tech_pvt->requesting_imsi && at_ack == -1) {
+				if (strlen(tech_pvt->line_array.result[i])) {	/* we are reading the IMSI */
+					strncpy(tech_pvt->imsi, tech_pvt->line_array.result[i], sizeof(tech_pvt->imsi));
+				}
+			}
 			/* if we are reading an sms message from memory, put the line into the sms buffer if the line is not "OK" or "ERROR" */
 			if (tech_pvt->reading_sms_msg > 1 && at_ack == -1) {
 				int c;

Modified: freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp (16440 => 16441)


--- freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp	2010-01-21 19:59:28 UTC (rev 16440)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp	2010-01-21 23:43:31 UTC (rev 16441)
@@ -103,7 +103,7 @@
 SWITCH_STANDARD_API(sendsms_function);
 #define SENDSMS_SYNTAX "gsmopen_sendsms interface_name destination_number SMS_text"
 SWITCH_STANDARD_API(gsmopen_dump_function);
-#define GSMOPEN_DUMP_SYNTAX "gsmopen_dump interface_name"
+#define GSMOPEN_DUMP_SYNTAX "gsmopen_dump <interface_name|list>"
 /* BEGIN: Changes here */
 #define FULL_RELOAD 0
 #define SOFT_RELOAD 1
@@ -2614,7 +2614,6 @@
 					stream->write_function(stream, "dumping interface '%s'\n", globals.GSMOPEN_INTERFACES[i].name);
 					tech_pvt = &globals.GSMOPEN_INTERFACES[i];
 					dump_event(tech_pvt);
-					break;
 				}
 
 			}
@@ -2960,6 +2959,7 @@
 		snprintf(value, sizeof(value)-1, "%d", tech_pvt->running);
 		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "running", value);
 		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "imei", tech_pvt->imei);
+		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "imsi", tech_pvt->imsi);
 		snprintf(value, sizeof(value)-1, "%d", tech_pvt->controldev_dead);
 		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "controldev_dead", value);
 		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "controldevice_name", tech_pvt->controldevice_name);
@@ -3029,6 +3029,7 @@
 			snprintf(value, sizeof(value)-1, "%d", tech_pvt->running);
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "running", value);
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "imei", tech_pvt->imei);
+			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "imsi", tech_pvt->imsi);
 			snprintf(value, sizeof(value)-1, "%d", tech_pvt->controldev_dead);
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "controldev_dead", value);
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "controldevice_name", tech_pvt->controldevice_name);