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;
}
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)
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);
}
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;
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;
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;
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;
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;
/* 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);
}
/* 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 */
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? */
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);
}
}
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
//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
(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 */
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;
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;
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;
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;
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;
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];
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;
}
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);
}
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));
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);
}
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++;
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++;
}
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);
} 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;
} 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;
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));
}
}
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));
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);
/* 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
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;
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());
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);
}
int count;
char *Data = (char *) data;
+ if (!tech_pvt)
+ return -1;
+
howmany = strlen(Data);
for (i = 0; i < howmany; i++) {
int count;
char *Data = (char *) data;
+ if (!tech_pvt)
+ return -1;
+
howmany = strlen(Data);
for (i = 0; i < howmany; i++) {
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);
{
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);
{
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);
{
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);
{
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)
{
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
{
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) {
/*
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';
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);
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]);
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);
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);
}
*/
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) {
} else if (x < -32768) {
x = -32768;
}
- ptr[i] = x;
+ ptr[i] = (int16_t) x;
}
} else {
//printf("BOOST=%f\n", boost);
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) {
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);
}
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);
}
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);
}
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);
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));
}
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)) {
/* 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
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;
}
{
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;
}
SWITCH_END_EXTERN_C
#define GSMOPEN_CHAT_PROTO "sms"
#if 1
- SWITCH_STANDARD_API(gsm_function);
+SWITCH_STANDARD_API(gsm_function);
/* BEGIN: Changes here */
#define GSM_SYNTAX "list [full] || console || AT_command || remove < interface_name | interface_id > || reload"
/* END: Changes heres */
goto end;
}
- LOKKA(tech_pvt->controldev_lock);
+ LOKKA(tech_pvt->controldev_lock);
globals.GSMOPEN_INTERFACES[interface_id].running = 0;
close(tech_pvt->GSMopenHandles.fdesc[1]);
#endif /* WIN32 */
- UNLOCKA(tech_pvt->controldev_lock);
+ UNLOCKA(tech_pvt->controldev_lock);
switch_mutex_lock(globals.mutex);
if (globals.gsm_console == &globals.GSMOPEN_INTERFACES[interface_id]) {
DEBUGA_GSMOPEN("interface '%s' no more console\n", GSMOPEN_P_LOG, the_interface);
/* END: Changes here */
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods that get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
+ memset(tech_pvt->buffer2, 0, sizeof(tech_pvt->buffer2));
+
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
//ERRORA("%s CHANNEL INIT\n", GSMOPEN_P_LOG, tech_pvt->name);
if (tech_pvt->phone_callflow == CALLFLOW_STATUS_FINISHED) {
tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
}
+ memset(tech_pvt->buffer2, 0, sizeof(tech_pvt->buffer2));
switch_core_session_set_private(session, NULL);
} else {
DEBUGA_GSMOPEN("!!!!!!NO tech_pvt!!!! CHANNEL DESTROY %s\n", GSMOPEN_P_LOG, switch_core_session_get_uuid(session));
tech_pvt = (private_t *) switch_core_session_get_private(session);
- DEBUGA_GSMOPEN("%s CHANNEL CONSUME_MEDIA\n", GSMOPEN_P_LOG, tech_pvt->name);
+ if (tech_pvt) {
+ DEBUGA_GSMOPEN("%s CHANNEL CONSUME_MEDIA\n", GSMOPEN_P_LOG, tech_pvt->name);
+ }
return SWITCH_STATUS_SUCCESS;
}
{
private_t *tech_pvt = NULL;
tech_pvt = (private_t *) switch_core_session_get_private(session);
- DEBUGA_GSMOPEN("%s CHANNEL EXCHANGE_MEDIA\n", GSMOPEN_P_LOG, tech_pvt->name);
+ if (tech_pvt) {
+ DEBUGA_GSMOPEN("%s CHANNEL EXCHANGE_MEDIA\n", GSMOPEN_P_LOG, tech_pvt->name);
+ }
return SWITCH_STATUS_SUCCESS;
}
{
private_t *tech_pvt = NULL;
tech_pvt = (private_t *) switch_core_session_get_private(session);
- DEBUGA_GSMOPEN("%s CHANNEL SOFT_EXECUTE\n", GSMOPEN_P_LOG, tech_pvt->name);
+ if (tech_pvt) {
+ DEBUGA_GSMOPEN("%s CHANNEL SOFT_EXECUTE\n", GSMOPEN_P_LOG, tech_pvt->name);
+ }
return SWITCH_STATUS_SUCCESS;
}
switch_byte_t *data;
int samples;
- int samples2;
char digit_str[256];
char buffer2[640];
if (tech_pvt->no_sound) {
goto cng;
}
+ memset(buffer2, 0, sizeof(buffer2));
samples = tech_pvt->serialPort_serial_audio->Read(buffer2, 640);
if (samples >= 320) {
tech_pvt->buffer2_full = 0;
samples = 320;
DEBUGA_GSMOPEN("samples=%d FROM BUFFER\n", GSMOPEN_P_LOG, samples);
+ memset(tech_pvt->buffer2, 0, sizeof(tech_pvt->buffer2));
}
}
switch_mutex_unlock(tech_pvt->flag_mutex);
if (samples != 320) {
+ memset(tech_pvt->buffer2, 0, sizeof(tech_pvt->buffer2));
if (samples != 0) {
DEBUGA_GSMOPEN("samples=%d, goto cng\n", GSMOPEN_P_LOG, samples);
}
switch_time_t new_dtmf_timestamp = switch_time_now();
if ((new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp) > 350000) { //FIXME: make it configurable
char *p = digit_str;
- switch_channel_t *channel = switch_core_session_get_channel(session);
while (p && *p) {
switch_dtmf_t dtmf = { 0 };
sent = tech_pvt->serialPort_serial_audio->Write((char *) frame->data, (int) (frame->datalen));
if (sent && sent != frame->datalen && sent != -1) {
- DEBUGA_GSMOPEN("sent %d\n", GSMOPEN_P_LOG, sent);
+ DEBUGA_GSMOPEN("sent %u\n", GSMOPEN_P_LOG, sent);
}
}
return SWITCH_STATUS_SUCCESS;
private_t *tech_pvt = NULL;
int result;
- if ((*new_session = switch_core_session_request_uuid(gsmopen_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool, switch_event_get_header(var_event, "origination_uuid"))) != 0) {
+ if ((*new_session = switch_core_session_request_uuid(gsmopen_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool, switch_event_get_header(var_event, "origination_uuid"))) != 0) {
switch_channel_t *channel = NULL;
switch_caller_profile_t *caller_profile;
private_t *tech_pvt = NULL;
#ifdef WIN32
- DEBUGA_GSMOPEN("Windows CODEPAGE Input =%d\n", GSMOPEN_P_LOG, GetConsoleCP());
+ DEBUGA_GSMOPEN("Windows CODEPAGE Input =%u\n", GSMOPEN_P_LOG, GetConsoleCP());
SetConsoleCP(65001);
- DEBUGA_GSMOPEN("Windows CODEPAGE Input =%d\n", GSMOPEN_P_LOG, GetConsoleCP());
- DEBUGA_GSMOPEN("Windows CODEPAGE Output =%d\n", GSMOPEN_P_LOG, GetConsoleOutputCP());
+ DEBUGA_GSMOPEN("Windows CODEPAGE Input =%u\n", GSMOPEN_P_LOG, GetConsoleCP());
+ DEBUGA_GSMOPEN("Windows CODEPAGE Output =%u\n", GSMOPEN_P_LOG, GetConsoleOutputCP());
SetConsoleOutputCP(65001);
- DEBUGA_GSMOPEN("Windows CODEPAGE Output =%d\n", GSMOPEN_P_LOG, GetConsoleOutputCP());
+ DEBUGA_GSMOPEN("Windows CODEPAGE Output =%u\n", GSMOPEN_P_LOG, GetConsoleOutputCP());
//let's hope to have unicode in console now. You need to use Lucida Console or, much better, Courier New font for the command prompt to show unicode
#endif // WIN32
NOTICA("GSMOPEN Charset Output Test 0 %s\n", GSMOPEN_P_LOG, "èéòàù");
globals.GSMOPEN_INTERFACES[interface_id].controldevprotocol = controldevprotocol; //FIXME
globals.GSMOPEN_INTERFACES[interface_id].running = running; //FIXME
- WARNINGA("STARTING interface_id=%d\n", GSMOPEN_P_LOG, interface_id);
+ WARNINGA("STARTING interface_id=%u\n", GSMOPEN_P_LOG, interface_id);
DEBUGA_GSMOPEN("id=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].id);
DEBUGA_GSMOPEN("name=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].name);
DEBUGA_GSMOPEN("hold-music=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].hold_music);
globals.GSMOPEN_INTERFACES[interface_id].controldevfd =
gsmopen_serial_init(&globals.GSMOPEN_INTERFACES[interface_id], globals.GSMOPEN_INTERFACES[interface_id].controldevice_speed);
if (globals.GSMOPEN_INTERFACES[interface_id].controldevfd == -1) {
- ERRORA("gsmopen_serial_init failed\n", GSMOPEN_P_LOG);
- ERRORA("STARTING interface_id=%d FAILED\n", GSMOPEN_P_LOG, interface_id);
+ ERRORA("STARTING interface_id=%u FAILED: gsmopen_serial_init failed\n", GSMOPEN_P_LOG, interface_id);
//return SWITCH_STATUS_FALSE;
globals.GSMOPEN_INTERFACES[interface_id].running = 0;
alarm_event(&globals.GSMOPEN_INTERFACES[interface_id], ALARM_FAILED_INTERFACE, "gsmopen_serial_init failed");
}
}
if (res) {
- ERRORA("STARTING interface_id=%d FAILED\n", GSMOPEN_P_LOG, interface_id);
+ ERRORA("STARTING interface_id=%u FAILED\n", GSMOPEN_P_LOG, interface_id);
//return SWITCH_STATUS_FALSE;
globals.GSMOPEN_INTERFACES[interface_id].running = 0;
alarm_event(&globals.GSMOPEN_INTERFACES[interface_id], ALARM_FAILED_INTERFACE, "gsmopen_serial_config failed");
if (globals.GSMOPEN_INTERFACES[interface_id].no_sound == 0) {
if (serial_audio_init(&globals.GSMOPEN_INTERFACES[interface_id])) {
ERRORA("serial_audio_init failed\n", GSMOPEN_P_LOG);
- ERRORA("STARTING interface_id=%d FAILED\n", GSMOPEN_P_LOG, interface_id);
+ ERRORA("STARTING interface_id=%u FAILED\n", GSMOPEN_P_LOG, interface_id);
//return SWITCH_STATUS_FALSE;
globals.GSMOPEN_INTERFACES[interface_id].running = 0;
alarm_event(&globals.GSMOPEN_INTERFACES[interface_id], ALARM_FAILED_INTERFACE, "serial_audio_init failed");
if (serial_audio_shutdown(&globals.GSMOPEN_INTERFACES[interface_id])) {
ERRORA("serial_audio_shutdown failed\n", GSMOPEN_P_LOG);
- ERRORA("STARTING interface_id=%d FAILED\n", GSMOPEN_P_LOG, interface_id);
+ ERRORA("STARTING interface_id=%u FAILED\n", GSMOPEN_P_LOG, interface_id);
//return SWITCH_STATUS_FALSE;
globals.GSMOPEN_INTERFACES[interface_id].running = 0;
alarm_event(&globals.GSMOPEN_INTERFACES[interface_id], ALARM_FAILED_INTERFACE, "serial_audio_shutdown failed");
&globals.GSMOPEN_INTERFACES[interface_id], gsmopen_module_pool);
switch_sleep(100000);
- WARNINGA("STARTED interface_id=%d\n", GSMOPEN_P_LOG, interface_id);
+ WARNINGA("STARTED interface_id=%u\n", GSMOPEN_P_LOG, interface_id);
} else {
- ERRORA("interface id %d is higher than GSMOPEN_MAX_INTERFACES (%d)\n", GSMOPEN_P_LOG, interface_id, GSMOPEN_MAX_INTERFACES);
+ ERRORA("interface id %u is higher than GSMOPEN_MAX_INTERFACES (%d)\n", GSMOPEN_P_LOG, interface_id, GSMOPEN_MAX_INTERFACES);
alarm_event(&globals.GSMOPEN_INTERFACES[interface_id], ALARM_FAILED_INTERFACE, "interface id is higher than GSMOPEN_MAX_INTERFACES");
continue;
}
DEBUGA_GSMOPEN("SHUTDOWN tech_pvt->controldevfd=%d\n", GSMOPEN_P_LOG, tech_pvt->controldevfd);
}
- serial_audio_shutdown(tech_pvt);
+ if (!globals.GSMOPEN_INTERFACES[interface_id].no_sound) {
+ serial_audio_shutdown(tech_pvt);
+ }
- int res;
- res = tech_pvt->serialPort_serial_control->Close();
- DEBUGA_GSMOPEN("serial_shutdown res=%d (controldevfd is %d)\n", GSMOPEN_P_LOG, res, tech_pvt->controldevfd);
+ if (tech_pvt->serialPort_serial_control) {
+ int res;
+ res = tech_pvt->serialPort_serial_control->Close();
+ DEBUGA_GSMOPEN("serial_shutdown res=%d (controldevfd is %d)\n", GSMOPEN_P_LOG, res, tech_pvt->controldevfd);
+ }
#ifndef WIN32
shutdown(tech_pvt->audiogsmopenpipe[0], 2);
{
private_t *tech_pvt = NULL;
int i;
- //int num_interfaces = GSMOPEN_MAX_INTERFACES;
+ //int num_interfaces = GSMOPEN_MAX_INTERFACES;
//int num_interfaces = globals.real_interfaces;
switch_mutex_lock(globals.mutex);
/* Fact is the real interface start from 1 */
- //XXX no, is just a convention, but you can have it start from 0. I do not, for aestetic reasons :-)
+ //XXX no, is just a convention, but you can have it start from 0. I do not, for aestetic reasons :-)
//if (globals.next_interface == 0) globals.next_interface = 1;
for (i = 0; i < GSMOPEN_MAX_INTERFACES; i++) {
DEBUGA_GSMOPEN("returning as available gsmopen interface name: %s, state: %d callflow: %d\n", GSMOPEN_P_LOG, tech_pvt->name, gsmopen_state,
tech_pvt->phone_callflow);
/*set to Dialing state to avoid other thread fint it, don't know if it is safe */
- //XXX no, it's not safe
+ //XXX no, it's not safe
if (tech_pvt_calling == NULL) {
tech_pvt->interface_state = GSMOPEN_STATE_SELECTED;
}
stream->write_function(stream, "ERROR, usage: %s", GSMOPEN_DUMP_SYNTAX);
goto end;
}
- if (argc == 1) {
- int i;
+ if (argc == 1 && argv[0]) {
int found = 0;
+ int i = 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 (!found && (strcmp("list", argv[0]) == 0)) {
- int i;
stream->write_function(stream, "gsmopen_dump LIST\n\n");
for (i = 0; i < GSMOPEN_MAX_INTERFACES; i++) {
if (strlen(globals.GSMOPEN_INTERFACES[i].name)) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
- if (argc == 1 || argc == 3) {
+ if ((argc == 1 || argc == 3) && argv[0]) {
int i;
int found = 0;
private_t *tech_pvt = (private_t *) obj;
time_t now_timestamp;
- //if (gsmopen_present(GSMopenHandles))
- while (running && tech_pvt->running) {
+ //if (gsmopen_present(GSMopenHandles))
+ while (running && tech_pvt && tech_pvt->running) {
int res;
//gsmopen_sleep(1000000); //1 sec
//DEBUGA_GSMOPEN("ciao!\n", GSMOPEN_P_LOG);
switch_channel_t *channel = NULL;
switch_status_t status;
+ if (!tech_pvt) {
+ return -1;
+ }
session = switch_core_session_locate(tech_pvt->session_uuid_str);
if (session) {
channel = switch_core_session_get_channel(session);
int sms_incoming(private_t *tech_pvt)
{
switch_event_t *event;
+#ifdef NOTDEF
switch_core_session_t *session = NULL;
int event_sent_to_esl = 0;
+#endif
+ if (!tech_pvt) {
+ return -1;
+ }
//DEBUGA_GSMOPEN("received SMS on interface %s: %s\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_message);
DEBUGA_GSMOPEN("received SMS on interface %s: DATE=%s, SENDER=%s, BODY=%s|\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_date, tech_pvt->sms_sender,
- tech_pvt->sms_body);
-
+ tech_pvt->sms_body);
#ifdef NOTDEF
if (!zstr(tech_pvt->session_uuid_str)) {
session = switch_core_session_locate(tech_pvt->session_uuid_str);