Revision
16045
Author
gmaruzz
Date
2009-12-23 11:51:10 -0600 (Wed, 23 Dec 2009)

Log Message

gsmopen: beginning use gsmlib for serial

Modified Paths

Diff

Modified: freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp (16044 => 16045)


--- freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp	2009-12-23 17:49:36 UTC (rev 16044)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp	2009-12-23 17:51:10 UTC (rev 16045)
@@ -1,7 +1,15 @@
 #include "gsmopen.h"
 //#include <iostream.h>
 #include <gsmlib/gsm_sms.h>
+#ifdef WIN32
+#include <gsmlib/gsm_win32_serial.h>
+#else
+#include <gsmlib/gsm_unix_serial.h>
+#endif
+#include <gsmlib/gsm_me_ta.h>
+#include <iostream>
 
+
 using namespace std;
 using namespace gsmlib;
 
@@ -27,6 +35,8 @@
 
 
 
+#undef GSMLIBGIO
+#ifndef GSMLIBGIO
 int gsmopen_serial_init(private_t * tech_pvt, speed_t controldevice_speed)
 {
 	int fd;
@@ -108,7 +118,41 @@
 	}
 	return (fd);
 }
+#else //GSMLIBGIO
+int gsmopen_serial_init(private_t * tech_pvt, speed_t controldevice_speed)
+{
+	int i;
+	string ciapa;
 
+#ifdef WIN32
+    	Ref<Port> port = new Win32SerialPort((string)tech_pvt->controldevice_name, 38400);
+#else
+        //Ref<Port> port = new UnixSerialPort((string)argv[1], B38400);
+        Ref<Port> port = new UnixSerialPort((string)tech_pvt->controldevice_name, B115200);
+#endif
+    MeTa m(port);
+
+    //cout << "Creating GsmAt object" << endl;
+    Ref<GsmAt> gsmat =  new GsmAt(m);
+    
+    //cout << "Using GsmAt object" << endl;
+    //cout << gsmat->chat("AT", "OK", false, false) << endl;
+    //cout << gsmat->chat("D3472665618;") << endl;
+    gsmat->putLine("ATI9", true);
+    for(i=0; i<4; i++){
+	    ciapa = gsmat->getLine();
+	    //cout << "PRESO: |||" << ciapa << "|||" << endl;
+	ERRORA("PRESO %d |||%s|||\n", GSMOPEN_P_LOG, i, ciapa.c_str());
+	    //usleep(5000);
+    }
+
+
+	return (-1);
+}
+
+#endif //GSMLIBGIO
+
+
 int gsmopen_serial_read(private_t * tech_pvt)
 {
 	if (tech_pvt->controldevprotocol == PROTOCOL_AT)

Modified: freeswitch/branches/gmaruzz/mod_gsmopen/test.cc (16044 => 16045)


--- freeswitch/branches/gmaruzz/mod_gsmopen/test.cc	2009-12-23 17:49:36 UTC (rev 16044)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/test.cc	2009-12-23 17:51:10 UTC (rev 16045)
@@ -38,6 +38,13 @@
 
 int main(int argc, char *argv[])
 {
+	string ciapa;
+	int i;
+
+	if(argc<2){
+		cout << (string)"You gave no \"device\" argument!" << endl;
+		return -1;
+		}
   try
   {
     cout << (string)"Opening device " + argv[1] << endl;
@@ -48,9 +55,24 @@
         Ref<Port> port = new UnixSerialPort((string)argv[1], B115200);
 #endif
 
+
     cout << "Creating MeTa object" << endl;
     MeTa m(port);
 
+    cout << "Creating GsmAt object" << endl;
+    Ref<GsmAt> gsmat =  new GsmAt(m);
+    
+    cout << "Using GsmAt object" << endl;
+    //cout << gsmat->chat("AT", "OK", false, false) << endl;
+    //cout << gsmat->chat("D3472665618;") << endl;
+    gsmat->putLine("ATI9", true);
+    for(i=0; i<9; i++){
+	    ciapa = gsmat->getLine();
+	    cout << "PRESO: |||" << ciapa << "|||" << endl;
+	    //usleep(5000);
+    }
+
+#ifdef NOTDEF
     cout << "Getting ME info" << endl;
     MEInfo mei = m.getMEInfo();
 
@@ -169,12 +191,15 @@
     cout << "Signal strength: " << m.getSignalStrength() << endl << endl;
 
     cout << "Bit error rate: " << m.getBitErrorRate() << endl << endl;
+#endif //NOTDEF
   }
   catch (GsmException &ge)
   {
     cerr << "GsmException '" << ge.what() << "'" << endl;
     return 1;
   }
+
+
   return 0;
 }