Modified: freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp (16434 => 16435)
--- freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp 2010-01-21 18:03:54 UTC (rev 16434)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp 2010-01-21 18:23:26 UTC (rev 16435)
@@ -102,6 +102,8 @@
#define GSMOPEN_BOOST_AUDIO_SYNTAX "interface_name [<play|capt> <in decibels: -40 ... +40>]"
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"
/* BEGIN: Changes here */
#define FULL_RELOAD 0
#define SOFT_RELOAD 1
@@ -2091,7 +2093,8 @@
SWITCH_ADD_API(commands_api_interface, "gsm", "gsm 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_boost_audio", "gsmopen_boost_audio interface AT_command", gsmopen_boost_audio_function, GSMOPEN_SYNTAX);
+ SWITCH_ADD_API(commands_api_interface, "gsmopen_boost_audio", "gsmopen_boost_audio interface AT_command", gsmopen_boost_audio_function, GSMOPEN_BOOST_AUDIO_SYNTAX);
+ SWITCH_ADD_API(commands_api_interface, "gsmopen_dump", "gsmopen_dump interface", gsmopen_dump_function, GSMOPEN_DUMP_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "gsmopen_sendsms", "gsmopen_sendsms interface destination_number SMS_text", sendsms_function,
SENDSMS_SYNTAX);
SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send);
@@ -2574,6 +2577,62 @@
return SWITCH_STATUS_SUCCESS;
}
#endif //0
+SWITCH_STANDARD_API(gsmopen_dump_function)
+{
+ char *mycmd = NULL, *argv[10] = { 0 };
+ int argc = 0;
+ private_t *tech_pvt = NULL;
+
+ if (!zstr(cmd) && (mycmd = strdup(cmd))) {
+ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+ }
+
+ if (!argc) {
+ stream->write_function(stream, "ERROR, usage: %s", GSMOPEN_DUMP_SYNTAX);
+ goto end;
+ }
+ if (argc == 1) {
+ int i;
+ int found = 0;
+
+ for (i = 0; !found && i < GSMOPEN_MAX_INTERFACES; i++) {
+ /* 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[0], strlen(argv[0])) == 0)) {
+ tech_pvt = &globals.GSMOPEN_INTERFACES[i];
+ stream->write_function(stream, "Using interface: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i, globals.GSMOPEN_INTERFACES[i].name);
+ found = 1;
+ break;
+ }
+
+ }
+ if (!found && (strcmp("list", argv[0]) == 0)) {
+ int i;
+ stream->write_function(stream, "gsmopen_dump LIST\n");
+ for (i = 0; i < GSMOPEN_MAX_INTERFACES; i++) {
+ if (strlen(globals.GSMOPEN_INTERFACES[i].name)) {
+ stream->write_function(stream, "dumping interface '%s'\n", globals.GSMOPEN_INTERFACES[i].name);
+ tech_pvt = &globals.GSMOPEN_INTERFACES[i];
+ dump_event(tech_pvt);
+ break;
+ }
+
+ }
+
+ } else if(found){
+ stream->write_function(stream, "dumping interface '%s'\n", argv[0]);
+ dump_event(tech_pvt);
+ } else{
+ stream->write_function(stream, "interface '%s' was not found\n", argv[0]);
+ }
+ } else {
+ stream->write_function(stream, "ERROR, usage: %s", GSMOPEN_DUMP_SYNTAX);
+ }
+ end:
+ switch_safe_free(mycmd);
+
+ return SWITCH_STATUS_SUCCESS;
+}
SWITCH_STANDARD_API(gsmopen_boost_audio_function)
{
char *mycmd = NULL, *argv[10] = { 0 };
@@ -2629,6 +2688,7 @@
return SWITCH_STATUS_SUCCESS;
}
+
#if 0
int gsmopen_transfer(private_t * tech_pvt, char *id, char *value)
{
@@ -2872,8 +2932,59 @@
return SWITCH_STATUS_SUCCESS;
}
+int dump_event(private_t * tech_pvt)
+{
+ switch_event_t *event;
+ switch_core_session_t *session = NULL;
+ int event_sent_to_esl = 0;
+ DEBUGA_GSMOPEN("STATUS of interface %s: \n", GSMOPEN_P_LOG, tech_pvt->name );
+ if (!zstr(tech_pvt->session_uuid_str)) {
+ session = switch_core_session_locate(tech_pvt->session_uuid_str);
+ }
+ if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_DUMP) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "interface", tech_pvt->name);
+ if (session) {
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true");
+ if (switch_core_session_queue_event(session, &event) != SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
+ switch_event_fire(&event);
+ }
+ } else { //no session
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "false");
+ switch_event_fire(&event);
+ event_sent_to_esl = 1;
+ }
+
+ } else {
+ ERRORA("cannot create event on interface %s. WHY?????\n", GSMOPEN_P_LOG, tech_pvt->name);
+ }
+
+ if (!event_sent_to_esl) {
+
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "interface", tech_pvt->name);
+ if (session) {
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true");
+ } else { //no session
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "false");
+ }
+ switch_event_fire(&event);
+ } else {
+ ERRORA("cannot create event on interface %s. WHY?????\n", GSMOPEN_P_LOG, tech_pvt->name);
+ }
+ }
+
+ if (session) {
+ switch_core_session_rwunlock(session);
+ }
+ return 0;
+}
+
+
+
+
int sms_incoming(private_t * tech_pvt)
{
switch_event_t *event;