mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
FS-5292 gsmopen: patch from garmt
This commit is contained in:
@@ -113,13 +113,36 @@ int gettimeofday(struct timeval *tv, struct sk_timezone *tz)
|
||||
|
||||
int gsmopen_serial_init(private_t *tech_pvt, int controldevice_speed)
|
||||
{
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
tech_pvt->serialPort_serial_control = new ctb::SerialPort();
|
||||
|
||||
if (tech_pvt->serialPort_serial_control->Open(tech_pvt->controldevice_name, 115200, "8N1", ctb::SerialPort::NoFlowControl) >= 0) {
|
||||
/* windows: com ports above com9 need a special trick, which also works for com ports below com10 ... */
|
||||
char devname[512] = "";
|
||||
strcpy(devname, tech_pvt->controldevice_name);
|
||||
#ifdef WIN32
|
||||
strcpy(devname,"\\\\.\\");
|
||||
strcat(devname, tech_pvt->controldevice_name);
|
||||
#endif
|
||||
|
||||
if (tech_pvt->serialPort_serial_control->Open(devname, 115200, "8N1", ctb::SerialPort::NoFlowControl) >= 0) {
|
||||
DEBUGA_GSMOPEN("port %s, SUCCESS open\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name);
|
||||
} else {
|
||||
#ifdef WIN32
|
||||
LPVOID msg;
|
||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &msg,
|
||||
0,
|
||||
NULL);
|
||||
ERRORA("port open failed for %s - %s", GSMOPEN_P_LOG, devname, (LPCTSTR) msg);
|
||||
LocalFree(msg);
|
||||
#else
|
||||
ERRORA("port %s, NOT open\n", GSMOPEN_P_LOG, tech_pvt->controldevice_name);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -128,7 +151,7 @@ int gsmopen_serial_init(private_t *tech_pvt, int controldevice_speed)
|
||||
|
||||
int gsmopen_serial_read(private_t *tech_pvt)
|
||||
{
|
||||
if (tech_pvt->controldevprotocol == PROTOCOL_AT)
|
||||
if (tech_pvt && tech_pvt->controldevprotocol == PROTOCOL_AT)
|
||||
return gsmopen_serial_read_AT(tech_pvt, 0, 100000, 0, NULL, 1); // a 10th of a second timeout
|
||||
#ifdef GSMOPEN_FBUS2
|
||||
if (tech_pvt->controldevprotocol == PROTOCOL_FBUS2)
|
||||
@@ -179,9 +202,12 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
char at_command[5];
|
||||
int i;
|
||||
|
||||
if (!tech_pvt)
|
||||
return 0;
|
||||
|
||||
/* initial_pause? */
|
||||
if (tech_pvt->at_initial_pause) {
|
||||
DEBUGA_GSMOPEN("sleeping for %d usec\n", GSMOPEN_P_LOG, tech_pvt->at_initial_pause);
|
||||
DEBUGA_GSMOPEN("sleeping for %u usec\n", GSMOPEN_P_LOG, tech_pvt->at_initial_pause);
|
||||
gsmopen_sleep(tech_pvt->at_initial_pause);
|
||||
}
|
||||
|
||||
@@ -206,7 +232,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_preinit_1)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_1, tech_pvt->at_preinit_1_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_1, tech_pvt->at_preinit_1_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_1, tech_pvt->at_preinit_1_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -215,7 +241,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_preinit_2)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_2, tech_pvt->at_preinit_2_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_2, tech_pvt->at_preinit_2_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_2, tech_pvt->at_preinit_2_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -224,7 +250,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_preinit_3)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_3, tech_pvt->at_preinit_3_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_3, tech_pvt->at_preinit_3_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_3, tech_pvt->at_preinit_3_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -233,7 +259,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_preinit_4)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_4, tech_pvt->at_preinit_4_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_4, tech_pvt->at_preinit_4_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_4, tech_pvt->at_preinit_4_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -242,7 +268,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_preinit_5)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_5, tech_pvt->at_preinit_5_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_5, tech_pvt->at_preinit_5_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_preinit_5, tech_pvt->at_preinit_5_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -253,7 +279,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
|
||||
/* after_preinit_pause? */
|
||||
if (tech_pvt->at_after_preinit_pause) {
|
||||
DEBUGA_GSMOPEN("sleeping for %d usec\n", GSMOPEN_P_LOG, tech_pvt->at_after_preinit_pause);
|
||||
DEBUGA_GSMOPEN("sleeping for %u usec\n", GSMOPEN_P_LOG, tech_pvt->at_after_preinit_pause);
|
||||
gsmopen_sleep(tech_pvt->at_after_preinit_pause);
|
||||
}
|
||||
|
||||
@@ -267,7 +293,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
/* for motorola, bring it back to "normal" mode if it happens to be in another mode */
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+mode=0");
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("AT+mode=0 does not get OK from the phone. If it is NOT Motorola," " no problem.\n", GSMOPEN_P_LOG);
|
||||
DEBUGA_GSMOPEN("AT+mode=0 didn't get OK from the phone. If it is NOT Motorola," " no problem.\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
gsmopen_sleep(50000);
|
||||
/* for motorola end */
|
||||
@@ -411,7 +437,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,8"); //unicode, 16 bit message
|
||||
if (res) {
|
||||
WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
WARNINGA("AT+CSMP didn't get OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
|
||||
/* what is the Charset of SMSs? */
|
||||
@@ -423,18 +449,18 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
tech_pvt->no_ucs2 = 0;
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
|
||||
if (res) {
|
||||
WARNINGA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone, let's try with 'GSM'\n", GSMOPEN_P_LOG);
|
||||
WARNINGA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) didn't get OK from the phone, let's try with 'GSM'\n", GSMOPEN_P_LOG);
|
||||
tech_pvt->no_ucs2 = 1;
|
||||
}
|
||||
if (tech_pvt->no_ucs2) {
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"GSM\"");
|
||||
if (res) {
|
||||
WARNINGA("AT+CSCS=\"GSM\" (set TE messages to GSM) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
WARNINGA("AT+CSCS=\"GSM\" (set TE messages to GSM) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
//res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,16"); //"flash", class 0 sms 7 bit
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,0"); //normal, 7 bit message
|
||||
if (res) {
|
||||
WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
WARNINGA("AT+CSMP didn't get OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,12 +474,12 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (tech_pvt->no_ucs2) {
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"GSM\"");
|
||||
if (res) {
|
||||
WARNINGA("AT+CSCS=\"GSM\" (set TE messages to GSM) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
WARNINGA("AT+CSCS=\"GSM\" (set TE messages to GSM) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
//res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,16"); //"flash", class 0 sms 7 bit
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,0"); //normal, 7 bit message
|
||||
if (res) {
|
||||
WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
WARNINGA("AT+CSMP didn't get OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
}
|
||||
#endif // NOTDEF //GSMLIB? XXX
|
||||
@@ -464,7 +490,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
//res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,20"); //"flash", class 0 sms 16 bit unicode
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSMP=17,167,0,8"); //unicode, 16 bit message
|
||||
if (res) {
|
||||
WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
WARNINGA("AT+CSMP didn't get OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
}
|
||||
#endif // NOTDEF
|
||||
@@ -520,7 +546,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
(to know when call is disconnected (they
|
||||
don't give you "no carrier") */
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("AT+MCST=1 does not get OK from the phone. If it is NOT Motorola," " no problem.\n", GSMOPEN_P_LOG);
|
||||
DEBUGA_GSMOPEN("AT+MCST=1 didn't get OK from the phone. If it is NOT Motorola," " no problem.\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
/* for motorola end */
|
||||
|
||||
@@ -530,7 +556,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_postinit_1)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_1, tech_pvt->at_postinit_1_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_1, tech_pvt->at_postinit_1_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_1, tech_pvt->at_postinit_1_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -539,7 +565,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_postinit_2)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_2, tech_pvt->at_postinit_2_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_2, tech_pvt->at_postinit_2_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_2, tech_pvt->at_postinit_2_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -548,7 +574,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_postinit_3)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_3, tech_pvt->at_postinit_3_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_3, tech_pvt->at_postinit_3_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_3, tech_pvt->at_postinit_3_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -557,7 +583,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_postinit_4)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_4, tech_pvt->at_postinit_4_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_4, tech_pvt->at_postinit_4_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_4, tech_pvt->at_postinit_4_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -566,7 +592,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
|
||||
if (strlen(tech_pvt->at_postinit_5)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_postinit_5, tech_pvt->at_postinit_5_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_5, tech_pvt->at_postinit_5_expect);
|
||||
DEBUGA_GSMOPEN("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, tech_pvt->at_postinit_5, tech_pvt->at_postinit_5_expect);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -588,7 +614,6 @@ int gsmopen_serial_sync_AT(private_t *tech_pvt)
|
||||
int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_usec, int timeout_sec, const char *expected_string, int expect_crlf)
|
||||
{
|
||||
int select_err = 1;
|
||||
int res;
|
||||
struct timeval timeout;
|
||||
char tmp_answer[AT_BUFSIZ];
|
||||
char tmp_answer2[AT_BUFSIZ];
|
||||
@@ -608,7 +633,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
if (timeout_in_msec != 100)
|
||||
DEBUGA_GSMOPEN("TIMEOUT=%d\n", GSMOPEN_P_LOG, timeout_in_msec);
|
||||
|
||||
if (!running || !tech_pvt->running) {
|
||||
if (!running || !tech_pvt || !tech_pvt->running) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -728,7 +753,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
else if (tmp_answer[strlen(tmp_answer) - 1] != '\r' && tmp_answer[strlen(tmp_answer) - 1] != '\n')
|
||||
la_counter--;
|
||||
|
||||
/* let's list the complete lines read so far, without re-listing the lines that has yet been listed */
|
||||
/* let's list the complete lines read so far, without re-listing the lines that have already been listed */
|
||||
for (i = la_read; i < la_counter; i++) {
|
||||
DEBUGA_GSMOPEN("Read line %d: |%s| la_counter=%d\n", GSMOPEN_P_LOG, i, tech_pvt->line_array.result[i], la_counter);
|
||||
}
|
||||
@@ -754,7 +779,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
DEBUGA_GSMOPEN("|%s| got second RING\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
|
||||
tech_pvt->interface_state = GSMOPEN_STATE_RING;
|
||||
} else {
|
||||
/* we're at the first ring, so there is no CALLID yet thus clean the previous one
|
||||
/* we're at the first ring, so there is no CALLID yet thus clean the previous one
|
||||
just in case we don't receive the caller identification in this new call */
|
||||
memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
|
||||
memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
|
||||
@@ -762,7 +787,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
if (tech_pvt->at_has_clcc != 0) {
|
||||
/* we're at the first ring, try to get CALLID (with +CLCC) */
|
||||
DEBUGA_GSMOPEN("|%s| got first RING, sending AT+CLCC?\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
|
||||
res = gsmopen_serial_write_AT_noack(tech_pvt, "AT+CLCC?");
|
||||
int res = gsmopen_serial_write_AT_noack(tech_pvt, "AT+CLCC?");
|
||||
if (res) {
|
||||
ERRORA("AT+CLCC? (call list) was not correctly sent to the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
@@ -783,7 +808,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
|
||||
memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
|
||||
|
||||
for (a = 0; a < strlen(tech_pvt->line_array.result[i]); a++) {
|
||||
for (a = 0; a < (int) strlen(tech_pvt->line_array.result[i]); a++) {
|
||||
|
||||
if (tech_pvt->line_array.result[i][a] == ',') {
|
||||
commacount++;
|
||||
@@ -818,7 +843,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
memset(tech_pvt->callid_name, 0, sizeof(tech_pvt->callid_name));
|
||||
memset(tech_pvt->callid_number, 0, sizeof(tech_pvt->callid_number));
|
||||
|
||||
for (a = 7; a < strlen(tech_pvt->line_array.result[i]); a++) {
|
||||
for (a = 7; a < (int) strlen(tech_pvt->line_array.result[i]); a++) {
|
||||
if (tech_pvt->line_array.result[i][a] == ',') {
|
||||
commacount++;
|
||||
}
|
||||
@@ -872,7 +897,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
tech_pvt->phone_callflow = CALLFLOW_CALL_LINEBUSY;
|
||||
if (option_debug > 1)
|
||||
DEBUGA_GSMOPEN("|%s| CALLFLOW_CALL_LINEBUSY\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
|
||||
//if (tech_pvt->interface_state != GSMOPEN_STATE_DOWN && tech_pvt->owner && tech_pvt->phone_callflow != CALLFLOW_CALL_DOWN)
|
||||
//if (tech_pvt->interface_state != GSMOPEN_STATE_DOWN && tech_pvt->owner && tech_pvt->phone_callflow != CALLFLOW_CALL_DOWN)
|
||||
if (tech_pvt->interface_state != GSMOPEN_STATE_DOWN && tech_pvt->phone_callflow != CALLFLOW_CALL_DOWN) {
|
||||
//ast_setstate(tech_pvt->owner, GSMOPEN_STATE_BUSY);
|
||||
//gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_BUSY);
|
||||
@@ -983,10 +1008,10 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
} else {
|
||||
if (signal_quality < 9 || signal_quality == 99) {
|
||||
ERRORA
|
||||
("|%s| CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or additional antenna\n",
|
||||
("|%s| CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or use additional antenna\n",
|
||||
GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
|
||||
tech_pvt->got_signal = 0;
|
||||
alarm_event(tech_pvt, ALARM_NETWORK_NO_SIGNAL, "CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or additional antenna");
|
||||
alarm_event(tech_pvt, ALARM_NETWORK_NO_SIGNAL, "CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or use additional antenna");
|
||||
} else if (signal_quality < 11) {
|
||||
WARNINGA("|%s| CELLPHONE GETS SIGNAL LOW\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
|
||||
tech_pvt->got_signal = 1;
|
||||
@@ -1011,13 +1036,13 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
} else {
|
||||
if (stat == 0) {
|
||||
ERRORA
|
||||
("|%s| CELLPHONE is not registered to network, consider to move it or additional antenna\n",
|
||||
("|%s| CELLPHONE is not registered to network, consider to move it or use 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;
|
||||
alarm_event(tech_pvt, ALARM_NO_NETWORK_REGISTRATION,
|
||||
"CELLPHONE is not registered to network, consider to move it or additional antenna");
|
||||
"CELLPHONE is not registered to network, consider to move it or use additional antenna");
|
||||
} 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;
|
||||
@@ -1199,9 +1224,9 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
char at_command[256];
|
||||
|
||||
if (tech_pvt->no_ucs2 == 0) {
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
|
||||
int res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
|
||||
if (res) {
|
||||
ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) didn't get OK from the phone, continuing\n", GSMOPEN_P_LOG);
|
||||
//memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
|
||||
}
|
||||
}
|
||||
@@ -1211,15 +1236,15 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
memset(tech_pvt->sms_message, 0, sizeof(tech_pvt->sms_message));
|
||||
|
||||
tech_pvt->reading_sms_msg = 1;
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
|
||||
int res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
|
||||
tech_pvt->reading_sms_msg = 0;
|
||||
if (res) {
|
||||
ERRORA("AT+CMGR (read SMS) do not got OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
|
||||
ERRORA("AT+CMGR (read SMS) didn't get OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
|
||||
}
|
||||
/*
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"CIAPALO1\"");
|
||||
if (res) {
|
||||
ERRORA("AT+CSCS=\"CIAPALO1\" (set TE messages to GSM) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
ERRORA("AT+CSCS=\"CIAPALO1\" (set TE messages to GSM) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
*/
|
||||
memset(at_command, 0, sizeof(at_command));
|
||||
@@ -1227,7 +1252,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
tech_pvt->unread_sms_msg_id = 0;
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
|
||||
if (res) {
|
||||
ERRORA("AT+CMGD (Delete SMS) do not got OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
|
||||
ERRORA("AT+CMGD (Delete SMS) didn't get OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
|
||||
}
|
||||
|
||||
res = sms_incoming(tech_pvt);
|
||||
@@ -1236,7 +1261,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
/* we're not in a call, neither calling */
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CKPD=\"EEE\"");
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN("AT+CKPD=\"EEE\" (cellphone screen back to user) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
DEBUGA_GSMOPEN("AT+CKPD=\"EEE\" (cellphone screen back to user) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
}
|
||||
} //unread_msg_id
|
||||
@@ -1625,7 +1650,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
|
||||
memset(content, '\0', sizeof(content));
|
||||
|
||||
for (c = 0; c < strlen(tech_pvt->line_array.result[i]); c++) {
|
||||
for (c = 0; c < (int) strlen(tech_pvt->line_array.result[i]); c++) {
|
||||
if (tech_pvt->line_array.result[i][c] == ',' && tech_pvt->line_array.result[i][c - 1] != '\\' && inside_quote == 0) {
|
||||
if (inside_comma) {
|
||||
inside_comma = 0;
|
||||
@@ -1722,10 +1747,10 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
ucs2_to_utf8(tech_pvt, (char *) bufToHex((unsigned char *) sms->userData().data(), sms->userData().length()).c_str(),
|
||||
content2, sizeof(content2));
|
||||
} else {
|
||||
ERRORA("dataCodingScheme not supported=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
|
||||
ERRORA("dataCodingScheme not supported=%u\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
|
||||
|
||||
}
|
||||
DEBUGA_GSMOPEN("dataCodingScheme=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
|
||||
DEBUGA_GSMOPEN("dataCodingScheme=%u\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
|
||||
DEBUGA_GSMOPEN("dataCodingScheme=%s\n", GSMOPEN_P_LOG, sms->dataCodingScheme().toString().c_str());
|
||||
DEBUGA_GSMOPEN("address=%s\n", GSMOPEN_P_LOG, sms->address().toString().c_str());
|
||||
DEBUGA_GSMOPEN("serviceCentreAddress=%s\n", GSMOPEN_P_LOG, sms->serviceCentreAddress().toString().c_str());
|
||||
@@ -1812,7 +1837,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
|
||||
DEBUGA_GSMOPEN
|
||||
("CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n",
|
||||
GSMOPEN_P_LOG, tech_pvt->call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
|
||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CPBS=RC");
|
||||
int res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CPBS=RC");
|
||||
if (res) {
|
||||
ERRORA("AT+CPBS=RC (select memory of received calls) was not answered by the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
@@ -1865,6 +1890,9 @@ int gsmopen_serial_write_AT(private_t *tech_pvt, const char *data)
|
||||
int count;
|
||||
char *Data = (char *) data;
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
howmany = strlen(Data);
|
||||
|
||||
for (i = 0; i < howmany; i++) {
|
||||
@@ -1977,6 +2005,9 @@ int gsmopen_serial_write_AT_nocr(private_t *tech_pvt, const char *data)
|
||||
int count;
|
||||
char *Data = (char *) data;
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
howmany = strlen(Data);
|
||||
|
||||
for (i = 0; i < howmany; i++) {
|
||||
@@ -2039,7 +2070,7 @@ int gsmopen_serial_write_AT_noack(private_t *tech_pvt, const char *data)
|
||||
|
||||
PUSHA_UNLOCKA(tech_pvt->controldev_lock);
|
||||
LOKKA(tech_pvt->controldev_lock);
|
||||
if (gsmopen_serial_write_AT(tech_pvt, data) != strlen(data)) {
|
||||
if (gsmopen_serial_write_AT(tech_pvt, data) != (int) strlen(data)) {
|
||||
|
||||
ERRORA("Error sending data... (%s)\n", GSMOPEN_P_LOG, strerror(errno));
|
||||
UNLOCKA(tech_pvt->controldev_lock);
|
||||
@@ -2075,16 +2106,19 @@ int gsmopen_serial_write_AT_ack(private_t *tech_pvt, const char *data)
|
||||
{
|
||||
int at_result = AT_ERROR;
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
PUSHA_UNLOCKA(tech_pvt->controldev_lock);
|
||||
LOKKA(tech_pvt->controldev_lock);
|
||||
if (option_debug > 1)
|
||||
DEBUGA_GSMOPEN("sending: %s\n", GSMOPEN_P_LOG, data);
|
||||
if (gsmopen_serial_write_AT(tech_pvt, data) != strlen(data)) {
|
||||
if (gsmopen_serial_write_AT(tech_pvt, data) != (int) strlen(data)) {
|
||||
ERRORA("Error sending data... (%s) \n", GSMOPEN_P_LOG, strerror(errno));
|
||||
UNLOCKA(tech_pvt->controldev_lock);
|
||||
|
||||
ERRORA
|
||||
("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n",
|
||||
("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, and if it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, powered down or battery exhausted\n",
|
||||
GSMOPEN_P_LOG, tech_pvt->controldevice_name);
|
||||
tech_pvt->controldev_dead = 1;
|
||||
//cicopet close(tech_pvt->controldevfd);
|
||||
@@ -2117,16 +2151,19 @@ int gsmopen_serial_write_AT_ack_nocr_longtime(private_t *tech_pvt, const char *d
|
||||
{
|
||||
int at_result = AT_ERROR;
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
PUSHA_UNLOCKA(tech_pvt->controldev_lock);
|
||||
LOKKA(tech_pvt->controldev_lock);
|
||||
if (option_debug > 1)
|
||||
DEBUGA_GSMOPEN("sending: %s\n", GSMOPEN_P_LOG, data);
|
||||
if (gsmopen_serial_write_AT_nocr(tech_pvt, data) != strlen(data)) {
|
||||
if (gsmopen_serial_write_AT_nocr(tech_pvt, data) != (int) strlen(data)) {
|
||||
ERRORA("Error sending data... (%s) \n", GSMOPEN_P_LOG, strerror(errno));
|
||||
UNLOCKA(tech_pvt->controldev_lock);
|
||||
|
||||
ERRORA
|
||||
("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n",
|
||||
("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, and if it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, powered down or battery exhausted\n",
|
||||
GSMOPEN_P_LOG, tech_pvt->controldevice_name);
|
||||
tech_pvt->controldev_dead = 1;
|
||||
//cicopet close(tech_pvt->controldevfd);
|
||||
@@ -2159,16 +2196,19 @@ int gsmopen_serial_write_AT_expect1(private_t *tech_pvt, const char *data, const
|
||||
{
|
||||
int at_result = AT_ERROR;
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
PUSHA_UNLOCKA(tech_pvt->controldev_lock);
|
||||
LOKKA(tech_pvt->controldev_lock);
|
||||
if (option_debug > 1)
|
||||
DEBUGA_GSMOPEN("sending: %s, expecting: %s\n", GSMOPEN_P_LOG, data, expected_string);
|
||||
if (gsmopen_serial_write_AT(tech_pvt, data) != strlen(data)) {
|
||||
if (gsmopen_serial_write_AT(tech_pvt, data) != (int) strlen(data)) {
|
||||
ERRORA("Error sending data... (%s) \n", GSMOPEN_P_LOG, strerror(errno));
|
||||
UNLOCKA(tech_pvt->controldev_lock);
|
||||
|
||||
ERRORA
|
||||
("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n",
|
||||
("wrote -1 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, and if it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, powered down or battery exhausted\n",
|
||||
GSMOPEN_P_LOG, tech_pvt->controldevice_name);
|
||||
tech_pvt->controldev_dead = 1;
|
||||
//cicopet close(tech_pvt->controldevfd);
|
||||
@@ -2201,6 +2241,10 @@ int gsmopen_serial_AT_expect(private_t *tech_pvt, const char *expected_string, i
|
||||
{
|
||||
int at_result = AT_ERROR;
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
|
||||
PUSHA_UNLOCKA(tech_pvt->controldev_lock);
|
||||
LOKKA(tech_pvt->controldev_lock);
|
||||
if (option_debug > 1)
|
||||
@@ -2234,6 +2278,9 @@ int gsmopen_serial_answer_AT(private_t *tech_pvt)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_answer, tech_pvt->at_answer_expect);
|
||||
if (res) {
|
||||
DEBUGA_GSMOPEN
|
||||
@@ -2272,6 +2319,9 @@ int gsmopen_serial_hangup_AT(private_t *tech_pvt)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
if (tech_pvt->interface_state != GSMOPEN_STATE_DOWN) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_hangup, tech_pvt->at_hangup_expect);
|
||||
if (res) {
|
||||
@@ -2327,9 +2377,9 @@ int gsmopen_serial_call_AT(private_t *tech_pvt, char *dstr)
|
||||
/*
|
||||
size_t fixdstr = strspn(dstr, AST_DIGIT_ANYDIG);
|
||||
if (fixdstr == 0) {
|
||||
ERRORA("dial command failed because of invalid dial number. dial string was: %s\n",
|
||||
GSMOPEN_P_LOG, dstr);
|
||||
return -1;
|
||||
ERRORA("dial command failed because of invalid dial number. dial string was: %s\n",
|
||||
GSMOPEN_P_LOG, dstr);
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
//dstr[fixdstr] = '\0';
|
||||
@@ -2367,7 +2417,7 @@ int ucs2_to_utf8(private_t *tech_pvt, char *ucs2_in, char *utf8_out, size_t outb
|
||||
|
||||
DEBUGA_GSMOPEN("ucs2_in=|%s|, utf8_out=|%s|\n", GSMOPEN_P_LOG, ucs2_in, utf8_out);
|
||||
/* cicopet */
|
||||
for (c = 0; c < strlen(ucs2_in); c++) {
|
||||
for (c = 0; c < (int) strlen(ucs2_in); c++) {
|
||||
sprintf(stringa, "0x%c%c", ucs2_in[c], ucs2_in[c + 1]);
|
||||
c++;
|
||||
hexnum = strtod(stringa, NULL);
|
||||
@@ -2548,7 +2598,7 @@ int utf8_to_ucs2(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, char *u
|
||||
GSMOPEN_P_LOG, iconv_res, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_in, converted);
|
||||
iconv_close(iconv_format);
|
||||
|
||||
for (i = 0; i < 16000 - outbytesleft; i++) {
|
||||
for (i = 0; i < 16000 - (int) outbytesleft; i++) {
|
||||
memset(stringa, '\0', sizeof(stringa));
|
||||
memset(stringa2, '\0', sizeof(stringa2));
|
||||
sprintf(stringa, "%02X", converted[i]);
|
||||
@@ -2779,14 +2829,14 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text)
|
||||
|
||||
memset(mesg_test, '\0', sizeof(mesg_test));
|
||||
sprintf(mesg_test, ":) ciao belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"); //let's test the beauty of utf8
|
||||
//sprintf(mesg_test,":) ciao belè èéàòìù");
|
||||
//sprintf(mesg_test,":) ciao belè èéàòìù");
|
||||
//text=mesg_test;
|
||||
|
||||
bad_8859 = utf8_to_iso_8859_1(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand));
|
||||
if (!bad_8859) {
|
||||
err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
|
||||
if (err) {
|
||||
ERRORA("AT+CMGF=0 (set message sending to PDU (as opposed to TEXT) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
ERRORA("AT+CMGF=0 (set message sending to PDU (as opposed to TEXT) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
SMSMessageRef smsMessage;
|
||||
smsMessage = new SMSSubmitMessage(smscommand, dest);
|
||||
@@ -2823,13 +2873,13 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text)
|
||||
|
||||
err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");
|
||||
if (err) {
|
||||
ERRORA("AT+CMGF=1 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
ERRORA("AT+CMGF=1 (set message sending to TEXT (as opposed to PDU) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
|
||||
/*
|
||||
err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
|
||||
if (err) {
|
||||
ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -2916,7 +2966,7 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text)
|
||||
|
||||
if (tech_pvt->at_cmgw[0]) {
|
||||
|
||||
/* let's see what we've sent, just for check TODO: Motorola it's not reliable! Motorola c350 tells that all was sent, but is not true! It just sends how much it fits into one SMS FIXME: need an algorithm to calculate how many ucs2 chars fits into an SMS. It make difference based, probably, on the GSM alphabet translation, or so */
|
||||
/* let's see what we've sent, just for check TODO: Motorola isn't reliable! Motorola c350 tells that all was sent, but is not true! It just sends how much it fits into one SMS FIXME: need an algorithm to calculate how many ucs2 chars fits into an SMS. It make difference based, probably, on the GSM alphabet translation, or so */
|
||||
sprintf(smscommand, "AT+CMGR=%s", tech_pvt->at_cmgw);
|
||||
err = gsmopen_serial_write_AT_ack(tech_pvt, smscommand);
|
||||
if (err) {
|
||||
@@ -2995,7 +3045,7 @@ int gsmopen_sound_boost(void *data, int samples_num, double boost)
|
||||
} else if (x < -32768) {
|
||||
x = -32768;
|
||||
}
|
||||
ptr[i] = x;
|
||||
ptr[i] = (int16_t) x;
|
||||
}
|
||||
} else {
|
||||
//printf("BOOST=%f\n", boost);
|
||||
@@ -3009,6 +3059,9 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
int res;
|
||||
private_t *p = tech_pvt;
|
||||
|
||||
if (!p)
|
||||
return -1;
|
||||
|
||||
#if 0
|
||||
if (p->owner) {
|
||||
if (p->owner->_state != AST_STATE_UP && p->owner->_state != AST_STATE_DOWN) {
|
||||
@@ -3029,7 +3082,7 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
if (strlen(p->at_query_battchg)) {
|
||||
res = gsmopen_serial_write_AT_expect(p, p->at_query_battchg, p->at_query_battchg_expect);
|
||||
if (res) {
|
||||
WARNINGA("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, p->at_query_battchg, p->at_query_battchg_expect);
|
||||
WARNINGA("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, p->at_query_battchg, p->at_query_battchg_expect);
|
||||
}
|
||||
gsmopen_sleep(1000);
|
||||
}
|
||||
@@ -3037,7 +3090,7 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
if (strlen(p->at_query_signal)) {
|
||||
res = gsmopen_serial_write_AT_expect(p, p->at_query_signal, p->at_query_signal_expect);
|
||||
if (res) {
|
||||
WARNINGA("%s does not get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, p->at_query_signal, p->at_query_signal_expect);
|
||||
WARNINGA("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, p->at_query_signal, p->at_query_signal_expect);
|
||||
}
|
||||
gsmopen_sleep(1000);
|
||||
}
|
||||
@@ -3045,7 +3098,7 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
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");
|
||||
WARNINGA("%s didn't get %s from the phone. Continuing.\n", GSMOPEN_P_LOG, "AT+CREG?", "OK");
|
||||
}
|
||||
gsmopen_sleep(1000);
|
||||
}
|
||||
@@ -3055,7 +3108,7 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
res = gsmopen_serial_write_AT_ack(p, "AT+MMGL=\"HEADER ONLY\"");
|
||||
if (res) {
|
||||
WARNINGA
|
||||
("%s does not get %s from the phone. If your phone is not Motorola, please contact the gsmopen developers. Else, if your phone IS a Motorola, probably a long msg was incoming and ther first part was read and then deleted. The second part is now orphan. If you got this warning repeatedly, and you cannot correctly receive SMSs from this interface, please manually clean all messages (and the residual parts of them) from the cellphone/SIM. Continuing.\n",
|
||||
("%s didn't get %s from the phone. If your phone is not Motorola, please contact the gsmopen developers. Else, if your phone IS a Motorola, probably a long msg was incoming and ther first part was read and then deleted. The second part is now orphan. If you got this warning repeatedly, and you cannot correctly receive SMSs from this interface, please manually clean all messages (and the residual parts of them) from the cellphone/SIM. Continuing.\n",
|
||||
GSMOPEN_P_LOG, "AT+MMGL=\"HEADER ONLY\"", "OK");
|
||||
} else {
|
||||
gsmopen_sleep(1000);
|
||||
@@ -3064,7 +3117,7 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
|
||||
res = gsmopen_serial_write_AT_ack(p, "AT+CSCS=\"UCS2\"");
|
||||
if (res) {
|
||||
ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
memset(p->sms_message, 0, sizeof(p->sms_message));
|
||||
}
|
||||
|
||||
@@ -3076,18 +3129,18 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
res = gsmopen_serial_write_AT_ack(p, at_command);
|
||||
p->reading_sms_msg = 0;
|
||||
if (res) {
|
||||
ERRORA("AT+CMGR (read SMS) do not got OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
|
||||
ERRORA("AT+CMGR (read SMS) didn't get OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
|
||||
}
|
||||
res = gsmopen_serial_write_AT_ack(p, "AT+CSCS=\"GSM\"");
|
||||
if (res) {
|
||||
ERRORA("AT+CSCS=\"GSM\" (set TE messages to GSM) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
ERRORA("AT+CSCS=\"GSM\" (set TE messages to GSM) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
memset(at_command, 0, sizeof(at_command));
|
||||
sprintf(at_command, "AT+CMGD=%d", p->unread_sms_msg_id); /* delete the message */
|
||||
p->unread_sms_msg_id = 0;
|
||||
res = gsmopen_serial_write_AT_ack(p, at_command);
|
||||
if (res) {
|
||||
ERRORA("AT+CMGD (Delete SMS) do not got OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
|
||||
ERRORA("AT+CMGD (Delete SMS) didn't get OK from the phone, message sent was:|||%s|||\n", GSMOPEN_P_LOG, at_command);
|
||||
}
|
||||
|
||||
if (strlen(p->sms_message)) {
|
||||
@@ -3138,7 +3191,7 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
/* we're not in a call, neither calling */
|
||||
res = gsmopen_serial_write_AT_ack(p, "AT+CKPD=\"EEE\"");
|
||||
if (res) {
|
||||
ERRORA("AT+CKPD=\"EEE\" (cellphone screen back to user) do not got OK from the phone\n", GSMOPEN_P_LOG);
|
||||
ERRORA("AT+CKPD=\"EEE\" (cellphone screen back to user) didn't get OK from the phone\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -3153,13 +3206,41 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
||||
|
||||
int gsmopen_serial_init_audio_port(private_t *tech_pvt, int controldevice_audio_speed)
|
||||
{
|
||||
/*
|
||||
* TODO
|
||||
* hmm, it doesn't look very different from gsmopen_serial_init_port, does it?
|
||||
*/
|
||||
|
||||
if (!tech_pvt)
|
||||
return -1;
|
||||
|
||||
tech_pvt->serialPort_serial_audio = new ctb::SerialPort();
|
||||
|
||||
//if( tech_pvt->serialPort_serial_audio->Open( "COM8", 115200, "8N1", ctb::SerialPort::NoFlowControl ) >= 0 ) {
|
||||
if (tech_pvt->serialPort_serial_audio->Open(tech_pvt->controldevice_audio_name, 115200, "8N1", ctb::SerialPort::NoFlowControl) >= 0) {
|
||||
/* windows: com ports above com9 need a special trick, which also works for com ports below com10 ... */
|
||||
char devname[512] = "";
|
||||
strcpy(devname, tech_pvt->controldevice_audio_name);
|
||||
#ifdef WIN32
|
||||
strcpy(devname,"\\\\.\\");
|
||||
strcat(devname, tech_pvt->controldevice_audio_name);
|
||||
#endif
|
||||
|
||||
if (tech_pvt->serialPort_serial_audio->Open(devname, 115200, "8N1", ctb::SerialPort::NoFlowControl) >= 0) {
|
||||
DEBUGA_GSMOPEN("port %s, SUCCESS open\n", GSMOPEN_P_LOG, tech_pvt->controldevice_audio_name);
|
||||
} else {
|
||||
#ifdef WIN32
|
||||
LPVOID msg;
|
||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &msg,
|
||||
0,
|
||||
NULL);
|
||||
ERRORA("port open failed for %s - %s", GSMOPEN_P_LOG, devname, (LPCTSTR) msg);
|
||||
LocalFree(msg);
|
||||
#else
|
||||
ERRORA("port %s, NOT open\n", GSMOPEN_P_LOG, tech_pvt->controldevice_audio_name);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -3186,11 +3267,12 @@ int serial_audio_shutdown(private_t *tech_pvt)
|
||||
{
|
||||
|
||||
int res;
|
||||
int err;
|
||||
|
||||
if (!tech_pvt || !tech_pvt->serialPort_serial_audio)
|
||||
return -1;
|
||||
|
||||
res = tech_pvt->serialPort_serial_audio->Close();
|
||||
DEBUGA_GSMOPEN("serial_audio_shutdown res=%d (controldev_audio_fd is %d)\n", GSMOPEN_P_LOG, res, tech_pvt->controldev_audio_fd);
|
||||
err = res;
|
||||
|
||||
return err;
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user