<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16226] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16226">16226</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2010-01-10 06:09:50 -0600 (Sun, 10 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>gsmopen: reinstated most accessory commands and functions</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchbranchesgmaruzzmod_gsmopenmod_gsmopencpp">freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchbranchesgmaruzzmod_gsmopenmod_gsmopencpp"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp (16225 => 16226)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp        2010-01-10 00:27:48 UTC (rev 16225)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp        2010-01-10 12:09:50 UTC (rev 16226)
</span><span class="lines">@@ -89,10 +89,10 @@
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_gsmopen_shutdown);
</span><span class="cx"> SWITCH_MODULE_DEFINITION(mod_gsmopen, mod_gsmopen_load, mod_gsmopen_shutdown, NULL);
</span><span class="cx"> SWITCH_END_EXTERN_C
</span><del>-#if 0
-SWITCH_STANDARD_API(sk_function);
</del><ins>+#if 1
+SWITCH_STANDARD_API(gsm_function);
</ins><span class="cx"> /* BEGIN: Changes here */
</span><del>-#define SK_SYNTAX "list [full] || console || gsmopen_API_msg || remove < gsmopenusername | #interface_name | #interface_id > || reload"
</del><ins>+#define GSM_SYNTAX "list [full] || console || gsmopen_API_msg || remove < gsmopenusername | #interface_name | #interface_id > || reload"
</ins><span class="cx"> /* END: Changes heres */
</span><span class="cx"> SWITCH_STANDARD_API(gsmopen_function);
</span><span class="cx"> #define GSMOPEN_SYNTAX "interface_name gsmopen_API_msg"
</span><span class="lines">@@ -171,7 +171,7 @@
</span><span class="cx">         char hold_music[256];
</span><span class="cx">         private_t GSMOPEN_INTERFACES[GSMOPEN_MAX_INTERFACES];
</span><span class="cx">         switch_mutex_t *mutex;
</span><del>-        private_t *sk_console;
</del><ins>+        private_t *gsm_console;
</ins><span class="cx"> } globals;
</span><span class="cx">
</span><span class="cx"> switch_endpoint_interface_t *gsmopen_endpoint_interface;
</span><span class="lines">@@ -186,7 +186,7 @@
</span><span class="cx">
</span><span class="cx"> /* BEGIN: Changes here */
</span><span class="cx"> static switch_status_t interface_exists(char *the_interface);
</span><del>-#if 0
</del><ins>+#if 1
</ins><span class="cx"> static switch_status_t remove_interface(char *the_interface);
</span><span class="cx"> #endif //0
</span><span class="cx"> /* END: Changes here */
</span><span class="lines">@@ -337,7 +337,7 @@
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if 0
</del><ins>+#if 1
</ins><span class="cx"> static switch_status_t remove_interface(char *the_interface)
</span><span class="cx"> {
</span><span class="cx">         int x = 10;
</span><span class="lines">@@ -385,17 +385,24 @@
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+                DEBUGA_GSMOPEN("interface '%s' exist\n", GSMOPEN_P_LOG, the_interface);
</ins><span class="cx">         globals.GSMOPEN_INTERFACES[interface_id].running = 0;
</span><span class="cx">
</span><ins>+                DEBUGA_GSMOPEN("interface '%s' exist\n", GSMOPEN_P_LOG, the_interface);
</ins><span class="cx">         if (globals.GSMOPEN_INTERFACES[interface_id].gsmopen_signaling_thread) {
</span><ins>+#if 1
</ins><span class="cx"> #ifdef WIN32
</span><span class="cx">                 switch_file_write(tech_pvt->GSMopenHandles.fdesc[1], "sciutati", &howmany);        // let's the controldev_thread die
</span><span class="cx"> #else /* WIN32 */
</span><span class="cx">                 howmany = write(tech_pvt->GSMopenHandles.fdesc[1], "sciutati", howmany);
</span><span class="cx"> #endif /* WIN32 */
</span><ins>+#endif //0
+                ERRORA("HERE will shutdown gsmopen_signaling_thread of '%s'\n", GSMOPEN_P_LOG, the_interface);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (globals.GSMOPEN_INTERFACES[interface_id].gsmopen_api_thread) {
</span><ins>+                DEBUGA_GSMOPEN("interface '%s' exist\n", GSMOPEN_P_LOG, the_interface);
+#if 0
</ins><span class="cx"> #ifdef WIN32
</span><span class="cx">                 if (SendMessage(tech_pvt->GSMopenHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) {        // let's the gsmopen_api_thread_func die
</span><span class="cx">                         DEBUGA_GSMOPEN("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", GSMOPEN_P_LOG, GetLastError());
</span><span class="lines">@@ -413,7 +420,10 @@
</span><span class="cx">
</span><span class="cx">                 XSendEvent(tech_pvt->GSMopenHandles.disp, tech_pvt->GSMopenHandles.win, False, 0, &e);
</span><span class="cx">                 XSync(tech_pvt->GSMopenHandles.disp, False);
</span><del>-#endif
</del><ins>+#endif //WIN32
+#endif //0
+
+                ERRORA("HERE will shutdown gsmopen_api_thread of '%s'\n", GSMOPEN_P_LOG, the_interface);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         while (x) {
</span><span class="lines">@@ -421,6 +431,7 @@
</span><span class="cx">                 switch_yield(50000);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+                DEBUGA_GSMOPEN("interface '%s' exist\n", GSMOPEN_P_LOG, the_interface);
</ins><span class="cx">         if (globals.GSMOPEN_INTERFACES[interface_id].gsmopen_signaling_thread) {
</span><span class="cx">                 switch_thread_join(&status, globals.GSMOPEN_INTERFACES[interface_id].gsmopen_signaling_thread);
</span><span class="cx">         }
</span><span class="lines">@@ -430,9 +441,9 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><del>-        if (globals.sk_console == &globals.GSMOPEN_INTERFACES[interface_id]) {
</del><ins>+        if (globals.gsm_console == &globals.GSMOPEN_INTERFACES[interface_id]) {
</ins><span class="cx">                 DEBUGA_GSMOPEN("interface '%s' no more console\n", GSMOPEN_P_LOG, the_interface);
</span><del>-                globals.sk_console = NULL;
</del><ins>+                globals.gsm_console = NULL;
</ins><span class="cx">         } else {
</span><span class="cx">                 DEBUGA_GSMOPEN("interface '%s' STILL console\n", GSMOPEN_P_LOG, the_interface);
</span><span class="cx">         }
</span><span class="lines">@@ -1836,9 +1847,9 @@
</span><span class="cx">
</span><span class="cx">         if (running) {
</span><span class="cx">
</span><del>-#if 0
-                SWITCH_ADD_API(commands_api_interface, "sk", "GSMopen console commands", sk_function, SK_SYNTAX);
-                SWITCH_ADD_API(commands_api_interface, "gsmopen", "GSMopen interface commands", gsmopen_function, GSMOPEN_SYNTAX);
</del><ins>+#if 1
+                SWITCH_ADD_API(commands_api_interface, "gsm", "GSMopen console AT_command", gsm_function, GSM_SYNTAX);
+                SWITCH_ADD_API(commands_api_interface, "gsmopen", "GSMopen interface AT_command", gsmopen_function, GSMOPEN_SYNTAX);
</ins><span class="cx"> #endif //0
</span><span class="cx">                 SWITCH_ADD_API(commands_api_interface, "gsmopen_sendsms", "gsmopen_sendsms interface destination_number SMS_text", sendsms_function,
</span><span class="cx">                                          SENDSMS_SYNTAX);
</span><span class="lines">@@ -2161,23 +2172,23 @@
</span><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if 0
-SWITCH_STANDARD_API(sk_function)
</del><ins>+#if 1
+SWITCH_STANDARD_API(gsm_function)
</ins><span class="cx"> {
</span><span class="cx">         char *mycmd = NULL, *argv[10] = { 0 };
</span><span class="cx">         int argc = 0;
</span><span class="cx">
</span><del>-        if (globals.sk_console)
-                stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name);
</del><ins>+        if (globals.gsm_console)
+                stream->write_function(stream, "gsm console is: |||%s|||\n", globals.gsm_console->name);
</ins><span class="cx">         else
</span><del>-                stream->write_function(stream, "sk console is NOT yet assigned\n");
</del><ins>+                stream->write_function(stream, "gsm console is NOT yet assigned\n");
</ins><span class="cx">
</span><span class="cx">         if (!zstr(cmd) && (mycmd = strdup(cmd))) {
</span><span class="cx">                 argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!argc || !argv[0]) {
</span><del>-                stream->write_function(stream, "%s", SK_SYNTAX);
</del><ins>+                stream->write_function(stream, "%s", GSM_SYNTAX);
</ins><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2218,10 +2229,10 @@
</span><span class="cx">                                 /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */
</span><span class="cx">                                 if (strlen(globals.GSMOPEN_INTERFACES[i].name)
</span><span class="cx">                                         && (strncmp(globals.GSMOPEN_INTERFACES[i].name, argv[1], strlen(argv[1])) == 0)) {
</span><del>-                                        globals.sk_console = &globals.GSMOPEN_INTERFACES[i];
-                                        stream->write_function(stream, "sk console is now: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i,
</del><ins>+                                        globals.gsm_console = &globals.GSMOPEN_INTERFACES[i];
+                                        stream->write_function(stream, "gsm console is now: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i,
</ins><span class="cx">                                                                                  globals.GSMOPEN_INTERFACES[i].name);
</span><del>-                                        stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name);
</del><ins>+                                        stream->write_function(stream, "gsm console is: |||%s|||\n", globals.gsm_console->name);
</ins><span class="cx">                                         found = 1;
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="lines">@@ -2231,7 +2242,7 @@
</span><span class="cx">                                 stream->write_function(stream, "ERROR: A GSMopen interface with name='%s' was not found\n", argv[1]);
</span><span class="cx">                 } else {
</span><span class="cx">
</span><del>-                        stream->write_function(stream, "-ERR Usage: sk console interface_name\n");
</del><ins>+                        stream->write_function(stream, "-ERR Usage: gsm console interface_name\n");
</ins><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -2240,26 +2251,30 @@
</span><span class="cx"> /* BEGIN: Changes heres */
</span><span class="cx">         } else if (!strcasecmp(argv[0], "reload")) {
</span><span class="cx">                 if (load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) {
</span><del>-                        stream->write_function(stream, "sk reload failed\n");
</del><ins>+                        stream->write_function(stream, "gsm reload failed\n");
</ins><span class="cx">                 } else {
</span><del>-                        stream->write_function(stream, "sk reload success\n");
</del><ins>+                        stream->write_function(stream, "gsm reload success\n");
</ins><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(argv[0], "remove")) {
</span><span class="cx">                 if (argc == 2) {
</span><span class="cx">                         if (remove_interface(argv[1]) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) {
</span><del>-                                        stream->write_function(stream, "sk remove '%s' failed\n", argv[1]);
</del><ins>+                                        stream->write_function(stream, "gsm remove '%s' failed\n", argv[1]);
</ins><span class="cx">                                 } else {
</span><del>-                                        stream->write_function(stream, "sk remove '%s' success\n", argv[1]);
</del><ins>+                                        stream->write_function(stream, "gsm remove '%s' success\n", argv[1]);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        stream->write_function(stream, "-ERR Usage: sk remove interface_name\n");
</del><ins>+                        stream->write_function(stream, "-ERR Usage: gsm remove interface_name\n");
</ins><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx"> /* END: Changes heres */
</span><span class="cx">
</span><span class="cx">         } else {
</span><ins>+                if (globals.gsm_console)
+                        gsmopen_serial_write_AT_noack(globals.gsm_console, (char *) cmd);
+                else
+                        stream->write_function(stream, "gsm console is NOT yet assigned\n");
</ins><span class="cx">         }
</span><span class="cx"> end:
</span><span class="cx">         switch_safe_free(mycmd);
</span><span class="lines">@@ -2308,7 +2323,7 @@
</span><span class="cx">
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 } else {
</span><del>-                        //gsmopen_signaling_write(tech_pvt, (char *) &cmd[strlen(argv[0]) + 1]);
</del><ins>+                        gsmopen_serial_write_AT_noack(tech_pvt, (char *) &cmd[strlen(argv[0]) + 1]);
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, "ERROR, usage: %s", GSMOPEN_SYNTAX);
</span><span class="lines">@@ -2450,7 +2465,7 @@
</span><span class="cx">
</span><span class="cx">         //if (gsmopen_present(GSMopenHandles))
</span><span class="cx">         if (1) {
</span><del>-                while (running) {
</del><ins>+                while (running && tech_pvt->running) {
</ins><span class="cx">                         int res;
</span><span class="cx">                         //gsmopen_sleep(1000000); //1 sec
</span><span class="cx">                         //DEBUGA_GSMOPEN("ciao!\n", GSMOPEN_P_LOG);
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>