Modified: freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp (16447 => 16448)
--- freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp 2010-01-22 01:17:29 UTC (rev 16447)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp 2010-01-22 01:46:04 UTC (rev 16448)
@@ -744,6 +744,18 @@
DEBUGA_GSMOPEN("AT+CGMM failed\n", GSMOPEN_P_LOG);
}
+ /* signal network registration with a +CREG unsolicited msg */
+ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CREG=1");
+ if (res) {
+ DEBUGA_GSMOPEN("AT+CREG=1 failed\n", GSMOPEN_P_LOG);
+ tech_pvt->network_creg_not_supported = 1;
+ }
+ if(!tech_pvt->network_creg_not_supported){
+ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CREG?");
+ if (res) {
+ DEBUGA_GSMOPEN("AT+CREG? failed\n", GSMOPEN_P_LOG);
+ }
+ }
/* IMEI */
tech_pvt->requesting_imei = 1;
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+GSN");
@@ -1290,17 +1302,54 @@
ERRORA("|%s| is not formatted as: |+CSQ: xx,yy|\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
} else {
if (signal_quality < 11 || signal_quality == 99) {
- WARNINGA
+ ERRORA
("|%s| CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or additional antenna\n",
GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ tech_pvt->got_signal=0;
} else if (signal_quality < 15) {
WARNINGA("|%s| CELLPHONE GETS SIGNAL LOW\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ tech_pvt->got_signal=1;
+ } else {
+ tech_pvt->got_signal=2;
+ }
+ }
+
+ }
+ if ((strncmp(tech_pvt->line_array.result[i], "+CREG:", 6) == 0)) {
+ int n, stat, err;
+
+ n = stat = 0;
+
+ err = sscanf(&tech_pvt->line_array.result[i][6], "%d,%d", &n, &stat);
+ if (option_debug > 1)
+ DEBUGA_GSMOPEN("|%s| +CREG: Display: %d, Registration=%d\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i], n, stat);
+ if (err < 2) {
+ ERRORA("|%s| is not formatted as: |+CREG: xx,yy|\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ } else {
+ if (stat==0) {
+ ERRORA
+ ("|%s| CELLPHONE is not registered to network, consider to move it or additional antenna\n",
+ GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ tech_pvt->not_registered=1;
+ tech_pvt->home_network_registered=0;
+ tech_pvt->roaming_registered=0;
+ } else if (stat==1) {
+ DEBUGA_GSMOPEN("|%s| CELLPHONE is registered to the HOME network\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ tech_pvt->not_registered=0;
+ tech_pvt->home_network_registered=1;
+ tech_pvt->roaming_registered=0;
+ } else {
+ WARNINGA("|%s| CELLPHONE is registered to a ROAMING network\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ tech_pvt->not_registered=0;
+ tech_pvt->home_network_registered=0;
+ tech_pvt->roaming_registered=1;
}
}
}
+
if ((strncmp(tech_pvt->line_array.result[i], "+CMGW:", 6) == 0)) {
int err;
@@ -3818,6 +3867,15 @@
}
gsmopen_sleep(1000);
}
+
+ if (!p->network_creg_not_supported) {
+ res = gsmopen_serial_write_AT_ack(p, "AT+CREG?");
+ if (res) {
+ WARNINGA("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, "AT+CREG?", "OK");
+ }
+ gsmopen_sleep(1000);
+ }
+
//FIXME all the following commands in config!
if (p->sms_cnmi_not_supported) {
Modified: freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp (16447 => 16448)
--- freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp 2010-01-22 01:17:29 UTC (rev 16447)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp 2010-01-22 01:46:04 UTC (rev 16448)
@@ -2869,7 +2869,7 @@
if ((now_timestamp - tech_pvt->gsmopen_serial_synced_timestamp) > 30) { //TODO find a sensible period. 5min? in config?
gsmopen_serial_sync(tech_pvt);
- //gsmopen_serial_getstatus_AT(tech_pvt);
+ gsmopen_serial_getstatus_AT(tech_pvt);
}
}
WARNINGA("EXIT\n", GSMOPEN_P_LOG);
@@ -2952,8 +2952,18 @@
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "interface_id", tech_pvt->id);
snprintf(value, sizeof(value)-1, "%d", tech_pvt->active);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "active", value);
- snprintf(value, sizeof(value)-1, "%d", tech_pvt->registered);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "registered", value);
+ if(!tech_pvt->network_creg_not_supported){
+ snprintf(value, sizeof(value)-1, "%d", tech_pvt->not_registered);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "not_registered", value);
+ snprintf(value, sizeof(value)-1, "%d", tech_pvt->home_network_registered);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "home_network_registered", value);
+ snprintf(value, sizeof(value)-1, "%d", tech_pvt->roaming_registered);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "roaming_registered", value);
+ }else{
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "not_registered", "N/A");
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "home_network_registered", "N/A");
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "roaming_registered", "N/A");
+ }
snprintf(value, sizeof(value)-1, "%d", tech_pvt->got_signal);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "got_signal", value);
snprintf(value, sizeof(value)-1, "%d", tech_pvt->running);
@@ -3022,8 +3032,18 @@
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "interface_id", tech_pvt->id);
snprintf(value, sizeof(value)-1, "%d", tech_pvt->active);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "active", value);
- snprintf(value, sizeof(value)-1, "%d", tech_pvt->registered);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "registered", value);
+ if(!tech_pvt->network_creg_not_supported){
+ snprintf(value, sizeof(value)-1, "%d", tech_pvt->not_registered);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "not_registered", value);
+ snprintf(value, sizeof(value)-1, "%d", tech_pvt->home_network_registered);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "home_network_registered", value);
+ snprintf(value, sizeof(value)-1, "%d", tech_pvt->roaming_registered);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "roaming_registered", value);
+ }else{
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "not_registered", "N/A");
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "home_network_registered", "N/A");
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "roaming_registered", "N/A");
+ }
snprintf(value, sizeof(value)-1, "%d", tech_pvt->got_signal);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "got_signal", value);
snprintf(value, sizeof(value)-1, "%d", tech_pvt->running);