Modified: freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp (16225 => 16226)
--- 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)
@@ -89,10 +89,10 @@
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_gsmopen_shutdown);
SWITCH_MODULE_DEFINITION(mod_gsmopen, mod_gsmopen_load, mod_gsmopen_shutdown, NULL);
SWITCH_END_EXTERN_C
-#if 0
-SWITCH_STANDARD_API(sk_function);
+#if 1
+SWITCH_STANDARD_API(gsm_function);
/* BEGIN: Changes here */
-#define SK_SYNTAX "list [full] || console || gsmopen_API_msg || remove < gsmopenusername | #interface_name | #interface_id > || reload"
+#define GSM_SYNTAX "list [full] || console || gsmopen_API_msg || remove < gsmopenusername | #interface_name | #interface_id > || reload"
/* END: Changes heres */
SWITCH_STANDARD_API(gsmopen_function);
#define GSMOPEN_SYNTAX "interface_name gsmopen_API_msg"
@@ -171,7 +171,7 @@
char hold_music[256];
private_t GSMOPEN_INTERFACES[GSMOPEN_MAX_INTERFACES];
switch_mutex_t *mutex;
- private_t *sk_console;
+ private_t *gsm_console;
} globals;
switch_endpoint_interface_t *gsmopen_endpoint_interface;
@@ -186,7 +186,7 @@
/* BEGIN: Changes here */
static switch_status_t interface_exists(char *the_interface);
-#if 0
+#if 1
static switch_status_t remove_interface(char *the_interface);
#endif //0
/* END: Changes here */
@@ -337,7 +337,7 @@
return SWITCH_STATUS_FALSE;
}
-#if 0
+#if 1
static switch_status_t remove_interface(char *the_interface)
{
int x = 10;
@@ -385,17 +385,24 @@
goto end;
}
+ DEBUGA_GSMOPEN("interface '%s' exist\n", GSMOPEN_P_LOG, the_interface);
globals.GSMOPEN_INTERFACES[interface_id].running = 0;
+ DEBUGA_GSMOPEN("interface '%s' exist\n", GSMOPEN_P_LOG, the_interface);
if (globals.GSMOPEN_INTERFACES[interface_id].gsmopen_signaling_thread) {
+#if 1
#ifdef WIN32
switch_file_write(tech_pvt->GSMopenHandles.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die
#else /* WIN32 */
howmany = write(tech_pvt->GSMopenHandles.fdesc[1], "sciutati", howmany);
#endif /* WIN32 */
+#endif //0
+ ERRORA("HERE will shutdown gsmopen_signaling_thread of '%s'\n", GSMOPEN_P_LOG, the_interface);
}
if (globals.GSMOPEN_INTERFACES[interface_id].gsmopen_api_thread) {
+ DEBUGA_GSMOPEN("interface '%s' exist\n", GSMOPEN_P_LOG, the_interface);
+#if 0
#ifdef WIN32
if (SendMessage(tech_pvt->GSMopenHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the gsmopen_api_thread_func die
DEBUGA_GSMOPEN("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", GSMOPEN_P_LOG, GetLastError());
@@ -413,7 +420,10 @@
XSendEvent(tech_pvt->GSMopenHandles.disp, tech_pvt->GSMopenHandles.win, False, 0, &e);
XSync(tech_pvt->GSMopenHandles.disp, False);
-#endif
+#endif //WIN32
+#endif //0
+
+ ERRORA("HERE will shutdown gsmopen_api_thread of '%s'\n", GSMOPEN_P_LOG, the_interface);
}
while (x) {
@@ -421,6 +431,7 @@
switch_yield(50000);
}
+ DEBUGA_GSMOPEN("interface '%s' exist\n", GSMOPEN_P_LOG, the_interface);
if (globals.GSMOPEN_INTERFACES[interface_id].gsmopen_signaling_thread) {
switch_thread_join(&status, globals.GSMOPEN_INTERFACES[interface_id].gsmopen_signaling_thread);
}
@@ -430,9 +441,9 @@
}
switch_mutex_lock(globals.mutex);
- if (globals.sk_console == &globals.GSMOPEN_INTERFACES[interface_id]) {
+ if (globals.gsm_console == &globals.GSMOPEN_INTERFACES[interface_id]) {
DEBUGA_GSMOPEN("interface '%s' no more console\n", GSMOPEN_P_LOG, the_interface);
- globals.sk_console = NULL;
+ globals.gsm_console = NULL;
} else {
DEBUGA_GSMOPEN("interface '%s' STILL console\n", GSMOPEN_P_LOG, the_interface);
}
@@ -1836,9 +1847,9 @@
if (running) {
-#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);
+#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);
#endif //0
SWITCH_ADD_API(commands_api_interface, "gsmopen_sendsms", "gsmopen_sendsms interface destination_number SMS_text", sendsms_function,
SENDSMS_SYNTAX);
@@ -2161,23 +2172,23 @@
return NULL;
}
-#if 0
-SWITCH_STANDARD_API(sk_function)
+#if 1
+SWITCH_STANDARD_API(gsm_function)
{
char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0;
- if (globals.sk_console)
- stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name);
+ if (globals.gsm_console)
+ stream->write_function(stream, "gsm console is: |||%s|||\n", globals.gsm_console->name);
else
- stream->write_function(stream, "sk console is NOT yet assigned\n");
+ stream->write_function(stream, "gsm console is NOT yet assigned\n");
if (!zstr(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (!argc || !argv[0]) {
- stream->write_function(stream, "%s", SK_SYNTAX);
+ stream->write_function(stream, "%s", GSM_SYNTAX);
goto end;
}
@@ -2218,10 +2229,10 @@
/* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */
if (strlen(globals.GSMOPEN_INTERFACES[i].name)
&& (strncmp(globals.GSMOPEN_INTERFACES[i].name, argv[1], strlen(argv[1])) == 0)) {
- globals.sk_console = &globals.GSMOPEN_INTERFACES[i];
- stream->write_function(stream, "sk console is now: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i,
+ globals.gsm_console = &globals.GSMOPEN_INTERFACES[i];
+ stream->write_function(stream, "gsm console is now: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i,
globals.GSMOPEN_INTERFACES[i].name);
- stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name);
+ stream->write_function(stream, "gsm console is: |||%s|||\n", globals.gsm_console->name);
found = 1;
break;
}
@@ -2231,7 +2242,7 @@
stream->write_function(stream, "ERROR: A GSMopen interface with name='%s' was not found\n", argv[1]);
} else {
- stream->write_function(stream, "-ERR Usage: sk console interface_name\n");
+ stream->write_function(stream, "-ERR Usage: gsm console interface_name\n");
goto end;
}
@@ -2240,26 +2251,30 @@
/* BEGIN: Changes heres */
} else if (!strcasecmp(argv[0], "reload")) {
if (load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) {
- stream->write_function(stream, "sk reload failed\n");
+ stream->write_function(stream, "gsm reload failed\n");
} else {
- stream->write_function(stream, "sk reload success\n");
+ stream->write_function(stream, "gsm reload success\n");
}
} else if (!strcasecmp(argv[0], "remove")) {
if (argc == 2) {
if (remove_interface(argv[1]) == SWITCH_STATUS_SUCCESS) {
if (interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) {
- stream->write_function(stream, "sk remove '%s' failed\n", argv[1]);
+ stream->write_function(stream, "gsm remove '%s' failed\n", argv[1]);
} else {
- stream->write_function(stream, "sk remove '%s' success\n", argv[1]);
+ stream->write_function(stream, "gsm remove '%s' success\n", argv[1]);
}
}
} else {
- stream->write_function(stream, "-ERR Usage: sk remove interface_name\n");
+ stream->write_function(stream, "-ERR Usage: gsm remove interface_name\n");
goto end;
}
/* END: Changes heres */
} else {
+ 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");
}
end:
switch_safe_free(mycmd);
@@ -2308,7 +2323,7 @@
return SWITCH_STATUS_SUCCESS;
} else {
- //gsmopen_signaling_write(tech_pvt, (char *) &cmd[strlen(argv[0]) + 1]);
+ gsmopen_serial_write_AT_noack(tech_pvt, (char *) &cmd[strlen(argv[0]) + 1]);
}
} else {
stream->write_function(stream, "ERROR, usage: %s", GSMOPEN_SYNTAX);
@@ -2450,7 +2465,7 @@
//if (gsmopen_present(GSMopenHandles))
if (1) {
- while (running) {
+ while (running && tech_pvt->running) {
int res;
//gsmopen_sleep(1000000); //1 sec
//DEBUGA_GSMOPEN("ciao!\n", GSMOPEN_P_LOG);