Modified: freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp (16153 => 16154)
--- freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp 2010-01-05 15:44:53 UTC (rev 16153)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp 2010-01-05 15:55:24 UTC (rev 16154)
@@ -125,28 +125,28 @@
string ciapa;
#ifdef WIN32
- Ref<Port> port = new Win32SerialPort((string)tech_pvt->controldevice_name, 38400);
+ Ref < Port > port = new Win32SerialPort((string) tech_pvt->controldevice_name, 38400);
#else
- //Ref<Port> port = new UnixSerialPort((string)argv[1], B38400);
- Ref<Port> port = new UnixSerialPort((string)tech_pvt->controldevice_name, B115200);
+ //Ref<Port> port = new UnixSerialPort((string)argv[1], B38400);
+ Ref < Port > port = new UnixSerialPort((string) tech_pvt->controldevice_name, B115200);
#endif
- MeTa m(port);
+ MeTa m(port);
- //cout << "Creating GsmAt object" << endl;
- Ref<GsmAt> gsmat = new GsmAt(m);
-
- //cout << "Using GsmAt object" << endl;
- //cout << gsmat->chat("AT", "OK", false, false) << endl;
- //cout << gsmat->chat("D3472665618;") << endl;
- gsmat->putLine("ATI9", true);
- for(i=0; i<4; i++){
- ciapa = gsmat->getLine();
- //cout << "PRESO: |||" << ciapa << "|||" << endl;
- ERRORA("PRESO %d |||%s|||\n", GSMOPEN_P_LOG, i, ciapa.c_str());
- //usleep(5000);
- }
+ //cout << "Creating GsmAt object" << endl;
+ Ref < GsmAt > gsmat = new GsmAt(m);
+ //cout << "Using GsmAt object" << endl;
+ //cout << gsmat->chat("AT", "OK", false, false) << endl;
+ //cout << gsmat->chat("D3472665618;") << endl;
+ gsmat->putLine("ATI9", true);
+ for (i = 0; i < 4; i++) {
+ ciapa = gsmat->getLine();
+ //cout << "PRESO: |||" << ciapa << "|||" << endl;
+ ERRORA("PRESO %d |||%s|||\n", GSMOPEN_P_LOG, i, ciapa.c_str());
+ //usleep(5000);
+ }
+
return (-1);
}
@@ -334,7 +334,7 @@
if (res) {
DEBUGA_GSMOPEN("AT+CNMI=3,1,0,0,0 failed, continue\n", GSMOPEN_P_LOG);
tech_pvt->sms_cnmi_not_supported = 1;
- tech_pvt->gsmopen_serial_sync_period = 30;
+ tech_pvt->gsmopen_serial_sync_period = 30; //FIXME in config
}
/* what is the Message Center address (number) to which the SMS has to be sent? */
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCA?");
@@ -346,10 +346,10 @@
if (res) {
DEBUGA_GSMOPEN("AT+CMGF? failed, continue\n", GSMOPEN_P_LOG);
}
- res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
+ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
if (res) {
ERRORA("Error setting SMS sending mode to PDU on the cellphone, falling back to TEXT mode. Continuing\n", GSMOPEN_P_LOG);
- res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");
+ res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");
if (res) {
ERRORA("Error setting SMS sending mode to TEXT on the cellphone, let's hope is TEXT by default. Continuing\n", GSMOPEN_P_LOG);
}
@@ -1170,7 +1170,8 @@
DEBUGA_GSMOPEN("phonebook entry: |%s|\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
err =
- sscanf(&tech_pvt->line_array.result[i][7], "%d,\"%255[0-9+]\",%d,\"%255[^\"]\"", &entry_id, entry_number, &entry_type, entry_text);
+ sscanf(&tech_pvt->line_array.result[i][7], "%d,\"%255[0-9+]\",%d,\"%255[^\"]\"", &entry_id, entry_number, &entry_type,
+ entry_text);
if (err < 4) {
ERRORA
("err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\"+39025458068\",145,\"ciao a tutti\"|\n",
@@ -1206,7 +1207,8 @@
DEBUGA_GSMOPEN("phonebook entry: |%s|\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
err =
- sscanf(&tech_pvt->line_array.result[i][7], "%d,\"%255[0-9+]\",%d,\"%255[^\"]\"", &entry_id, entry_number, &entry_type, entry_text);
+ sscanf(&tech_pvt->line_array.result[i][7], "%d,\"%255[0-9+]\",%d,\"%255[^\"]\"", &entry_id, entry_number, &entry_type,
+ entry_text);
if (err < 1) { //we match only on the progressive id, maybe the remote party has not sent its number, and/or there is no corresponding text entry in the phone directory
ERRORA
("err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\"+39025458068\",145,\"ciao a tutti\"|\n",
@@ -1248,7 +1250,9 @@
if ((strncmp(tech_pvt->line_array.result[i], "*ECAV", 5) == 0) || (strncmp(tech_pvt->line_array.result[i], "*ECAM", 5) == 0)) { /* sony-ericsson call processing unsolicited messages */
int res, ccid, ccstatus, calltype, processid, exitcause, number, type;
res = ccid = ccstatus = calltype = processid = exitcause = number = type = 0;
- res = sscanf(&tech_pvt->line_array.result[i][6], "%d,%d,%d,%d,%d,%d,%d", &ccid, &ccstatus, &calltype, &processid, &exitcause, &number, &type);
+ res =
+ sscanf(&tech_pvt->line_array.result[i][6], "%d,%d,%d,%d,%d,%d,%d", &ccid, &ccstatus, &calltype, &processid, &exitcause, &number,
+ &type);
/* only changes the phone_callflow if enought parameters were parsed */
if (res >= 3) {
switch (ccstatus) {
@@ -1293,12 +1297,14 @@
case 5:
if (option_debug > 1)
DEBUGA_GSMOPEN
- ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle WAITING event\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle WAITING event\n", GSMOPEN_P_LOG,
+ tech_pvt->line_array.result[i]);
break;
case 6:
if (option_debug > 1)
DEBUGA_GSMOPEN
- ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle ALERTING event\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
+ ("|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle ALERTING event\n", GSMOPEN_P_LOG,
+ tech_pvt->line_array.result[i]);
break;
case 7:
if (tech_pvt->owner) {
@@ -1404,7 +1410,7 @@
int c;
char sms_body[16000];
int err = 0;
- memset(sms_body, '\0', sizeof(sms_body));
+ memset(sms_body, '\0', sizeof(sms_body));
if (strncmp(tech_pvt->line_array.result[i], "+CMGR", 5) == 0) { /* we are reading the "header" of an SMS */
#if 1
@@ -1424,16 +1430,19 @@
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;
- NOTICA("inside_comma=%d, inside_quote=%d, we're at=%s\n", GSMOPEN_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
+ NOTICA("inside_comma=%d, inside_quote=%d, we're at=%s\n", GSMOPEN_P_LOG, inside_comma, inside_quote,
+ &tech_pvt->line_array.result[i][c]);
} else {
inside_comma = 1;
- NOTICA("inside_comma=%d, inside_quote=%d, we're at=%s\n", GSMOPEN_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
+ NOTICA("inside_comma=%d, inside_quote=%d, we're at=%s\n", GSMOPEN_P_LOG, inside_comma, inside_quote,
+ &tech_pvt->line_array.result[i][c]);
}
}
if (tech_pvt->line_array.result[i][c] == '"' && tech_pvt->line_array.result[i][c - 1] != '\\') {
if (inside_quote) {
inside_quote = 0;
- NOTICA("END_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", GSMOPEN_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
+ NOTICA("END_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", GSMOPEN_P_LOG, inside_comma, inside_quote,
+ &tech_pvt->line_array.result[i][c]);
DEBUGA_GSMOPEN("%d content=%s\n", GSMOPEN_P_LOG, which_field, content);
//strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
@@ -1455,24 +1464,25 @@
//strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
//if (!err)
- //strncat(tech_pvt->sms_message, content2, ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+ //strncat(tech_pvt->sms_message, content2, ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
//strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
memset(content, '\0', sizeof(content));
d = 0;
if (which_field == 1) {
strncpy(tech_pvt->sms_sender, content2, sizeof(tech_pvt->sms_sender));
- DEBUGA_GSMOPEN("%d content=%s\n", GSMOPEN_P_LOG, which_field, content2);
+ DEBUGA_GSMOPEN("%d content=%s\n", GSMOPEN_P_LOG, which_field, content2);
} else if (which_field == 2) {
strncpy(tech_pvt->sms_date, content2, sizeof(tech_pvt->sms_date));
- DEBUGA_GSMOPEN("%d content=%s\n", GSMOPEN_P_LOG, which_field, content2);
+ DEBUGA_GSMOPEN("%d content=%s\n", GSMOPEN_P_LOG, which_field, content2);
} else if (which_field > 2) {
WARNINGA("WHY which_field is > 2 ? (which_field is %d)\n", GSMOPEN_P_LOG, which_field);
}
which_field++;
} else {
inside_quote = 1;
- WARNINGA("START_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", GSMOPEN_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
+ WARNINGA("START_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", GSMOPEN_P_LOG, inside_comma, inside_quote,
+ &tech_pvt->line_array.result[i][c]);
}
}
if (inside_quote && tech_pvt->line_array.result[i][c] != '"') {
@@ -1488,67 +1498,68 @@
else {
DEBUGA_GSMOPEN("body=%s\n", GSMOPEN_P_LOG, sms_body);
DEBUGA_GSMOPEN("tech_pvt->line_array.result[i]=%s\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i]);
- if (tech_pvt->sms_cnmi_not_supported) {
- strncpy(tech_pvt->sms_message, tech_pvt->line_array.result[i], sizeof(tech_pvt->sms_message));
+ if (tech_pvt->sms_cnmi_not_supported) {
+ strncpy(tech_pvt->sms_message, tech_pvt->line_array.result[i], sizeof(tech_pvt->sms_message));
- char content3[1000];
- //int howmanyleft;
+ char content3[1000];
+ //int howmanyleft;
- WARNINGA("sms_message=%s\n", GSMOPEN_P_LOG, tech_pvt->sms_message);
- ucs2_to_utf8(tech_pvt, tech_pvt->sms_message, content3, sizeof(content3));
- WARNINGA("content3=%s\n", GSMOPEN_P_LOG, content3);
- strncpy(tech_pvt->sms_body, content3, sizeof(tech_pvt->sms_body));
- //sleep(10);
- //cicopet
+ WARNINGA("sms_message=%s\n", GSMOPEN_P_LOG, tech_pvt->sms_message);
+ ucs2_to_utf8(tech_pvt, tech_pvt->sms_message, content3, sizeof(content3));
+ WARNINGA("content3=%s\n", GSMOPEN_P_LOG, content3);
+ strncpy(tech_pvt->sms_body, content3, sizeof(tech_pvt->sms_body));
+ //sleep(10);
+ //cicopet
sms_incoming(tech_pvt);
- WARNINGA("2 content3=%s\n", GSMOPEN_P_LOG, content3);
- }else{
- SMSMessageRef sms;
- char content2[1000];
+ WARNINGA("2 content3=%s\n", GSMOPEN_P_LOG, content3);
+ } else {
+ SMSMessageRef sms;
+ char content2[1000];
//MessageType messagetype;
//Address servicecentreaddress;
//Timestamp servicecentretimestamp;
//Address sender_recipient_address;
- sms = SMSMessage::decode(tech_pvt->line_array.result[i]); // dataCodingScheme = 8 , text=ciao 123 belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大
+ sms = SMSMessage::decode(tech_pvt->line_array.result[i]); // dataCodingScheme = 8 , text=ciao 123 belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大
- NOTICA("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str());
+ NOTICA("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str());
- memset(content2, '\0', sizeof(content2));
- if(sms->dataCodingScheme().getAlphabet() == DCS_DEFAULT_ALPHABET){
- iso_8859_1_to_utf8(tech_pvt, (char *)sms->userData().c_str(), content2, sizeof(content2));
- } else
- if(sms->dataCodingScheme().getAlphabet() == DCS_SIXTEEN_BIT_ALPHABET){
- 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());
+ memset(content2, '\0', sizeof(content2));
+ if (sms->dataCodingScheme().getAlphabet() == DCS_DEFAULT_ALPHABET) {
+ iso_8859_1_to_utf8(tech_pvt, (char *) sms->userData().c_str(), content2, sizeof(content2));
+ } else if (sms->dataCodingScheme().getAlphabet() == DCS_SIXTEEN_BIT_ALPHABET) {
+ 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());
- }
- NOTICA("dataCodingScheme=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
- NOTICA("dataCodingScheme=%s\n", GSMOPEN_P_LOG, sms->dataCodingScheme().toString().c_str());
- NOTICA("address=%s\n", GSMOPEN_P_LOG, sms->address().toString().c_str());
- NOTICA("serviceCentreAddress=%s\n", GSMOPEN_P_LOG, sms->serviceCentreAddress().toString().c_str());
- NOTICA("serviceCentreTimestamp=%s\n", GSMOPEN_P_LOG, sms->serviceCentreTimestamp().toString().c_str());
- NOTICA("messageType=%d\n", GSMOPEN_P_LOG, sms->messageType());
- NOTICA("userData= |||%s|||\n", GSMOPEN_P_LOG, content2);
+ }
+ NOTICA("dataCodingScheme=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
+ NOTICA("dataCodingScheme=%s\n", GSMOPEN_P_LOG, sms->dataCodingScheme().toString().c_str());
+ NOTICA("address=%s\n", GSMOPEN_P_LOG, sms->address().toString().c_str());
+ NOTICA("serviceCentreAddress=%s\n", GSMOPEN_P_LOG, sms->serviceCentreAddress().toString().c_str());
+ NOTICA("serviceCentreTimestamp=%s\n", GSMOPEN_P_LOG, sms->serviceCentreTimestamp().toString().c_str());
+ NOTICA("messageType=%d\n", GSMOPEN_P_LOG, sms->messageType());
+ NOTICA("userData= |||%s|||\n", GSMOPEN_P_LOG, content2);
- memset(sms_body, '\0', sizeof(sms_body));
- strncpy(sms_body, content2, sizeof(sms_body));
- DEBUGA_GSMOPEN("body=%s\n", GSMOPEN_P_LOG, sms_body);
- strncpy(tech_pvt->sms_body, sms_body, sizeof(tech_pvt->sms_body));
- strncpy(tech_pvt->sms_sender, sms->address().toString().c_str(), sizeof(tech_pvt->sms_sender));
- strncpy(tech_pvt->sms_date, sms->serviceCentreTimestamp().toString().c_str(), sizeof(tech_pvt->sms_date));
- strncpy(tech_pvt->sms_datacodingscheme, sms->dataCodingScheme().toString().c_str(), sizeof(tech_pvt->sms_datacodingscheme));
- strncpy(tech_pvt->sms_servicecentreaddress, sms->serviceCentreAddress().toString().c_str(), sizeof(tech_pvt->sms_servicecentreaddress));
- tech_pvt->sms_messagetype = sms->messageType();
+ memset(sms_body, '\0', sizeof(sms_body));
+ strncpy(sms_body, content2, sizeof(sms_body));
+ DEBUGA_GSMOPEN("body=%s\n", GSMOPEN_P_LOG, sms_body);
+ strncpy(tech_pvt->sms_body, sms_body, sizeof(tech_pvt->sms_body));
+ strncpy(tech_pvt->sms_sender, sms->address().toString().c_str(), sizeof(tech_pvt->sms_sender));
+ strncpy(tech_pvt->sms_date, sms->serviceCentreTimestamp().toString().c_str(), sizeof(tech_pvt->sms_date));
+ strncpy(tech_pvt->sms_datacodingscheme, sms->dataCodingScheme().toString().c_str(), sizeof(tech_pvt->sms_datacodingscheme));
+ strncpy(tech_pvt->sms_servicecentreaddress, sms->serviceCentreAddress().toString().c_str(),
+ sizeof(tech_pvt->sms_servicecentreaddress));
+ tech_pvt->sms_messagetype = sms->messageType();
//messagetype = sms->messageType();
//servicecentreaddress = sms->serviceCentreAddress();
//servicecentretimestamp = sms->serviceCentreTimestamp();
//sender_recipient_address = sms->address();
- }
+ }
#if 0
//strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
@@ -1562,7 +1573,7 @@
//strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
//if (!err)
- //strncat(tech_pvt->sms_message, sms_body, ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
+ //strncat(tech_pvt->sms_message, sms_body, ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
//strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
//DEBUGA_GSMOPEN("sms_message=%s\n", GSMOPEN_P_LOG, tech_pvt->sms_message);
@@ -2008,7 +2019,7 @@
sprintf(stringa, "0x%c%c", ucs2_in[c], ucs2_in[c + 1]);
c++;
hexnum = strtod(stringa, NULL);
- converted[i] = (char)hexnum;
+ converted[i] = (char) hexnum;
i++;
}
@@ -2022,8 +2033,8 @@
}
inbytesleft = i;
- DEBUGA_GSMOPEN("1 ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n",
- GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out);
+ DEBUGA_GSMOPEN("1 ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n",
+ GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out);
iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
if (iconv_res == (size_t) -1) {
@@ -2072,13 +2083,13 @@
iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
if (iconv_res == (size_t) -1) {
DEBUGA_GSMOPEN("ciao in=%s, inleft=%d, out=%s, outleft=%d, utf8_out=%s\n",
- GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_out);
+ GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_out);
DEBUGA_GSMOPEN("error: %s %d\n", GSMOPEN_P_LOG, strerror(errno), errno);
return -1;
}
DEBUGA_GSMOPEN
(" strlen(iso_8859_1_in)=%d, iconv_res=%d, inbuf=%s, inleft=%d, out=%s, outleft=%d, utf8_out=%s\n",
- GSMOPEN_P_LOG, strlen(iso_8859_1_in), iconv_res, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_out);
+ GSMOPEN_P_LOG, strlen(iso_8859_1_in), iconv_res, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_out);
@@ -2634,20 +2645,20 @@
//sms = SMSMessage::decode("079194710167120004038571F1390099406180904480A0D41631067296EF7390383D07CD622E58CD95CB81D6EF39BDEC66BFE7207A794E2FBB4320AFB82C07E56020A8FC7D9687DBED32285C9F83A06F769A9E5EB340D7B49C3E1FA3C3663A0B24E4CBE76516680A7FCBE920725A5E5ED341F0B21C346D4E41E1BA790E4286DDE4BC0BD42CA3E5207258EE1797E5A0BA9B5E9683C86539685997EBEF61341B249BC966"); // dataCodingScheme = 0
//sms = SMSMessage::decode("0791934329002000040C9193432766658100009001211133318004D4F29C0E"); // dataCodingScheme = 0
//sms = SMSMessage::decode("0791934329002000040C919343276665810008900121612521801600CC00E800E900F900F200E00020006300690061006F"); // dataCodingScheme = 8
- sms = SMSMessage::decode("0791934329002000040C919343276665810008900172002293404C006300690061006F0020003100320033002000620065006C00E80020043D043E0432043E044104420438002005DC05E7002005E805D005EA0020FE8EFEE0FEA0FEE4FECBFE9300204EBA5927"); // dataCodingScheme = 8 , text=ciao 123 belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大
+ sms = SMSMessage::decode("0791934329002000040C919343276665810008900172002293404C006300690061006F0020003100320033002000620065006C00E80020043D043E0432043E044104420438002005DC05E7002005E805D005EA0020FE8EFEE0FEA0FEE4FECBFE9300204EBA5927"); // dataCodingScheme = 8 , text=ciao 123 belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大
//sms = SMSMessage::decode("07911497941902F00414D0E474989D769F5DE4320839001040122151820000"); // dataCodingScheme = 0
NOTICA("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str());
memset(content2, '\0', sizeof(content2));
- if(sms->dataCodingScheme().getAlphabet() == DCS_DEFAULT_ALPHABET){
- iso_8859_1_to_utf8(tech_pvt, (char *)sms->userData().c_str(), content2, sizeof(content2));
- } else
- if(sms->dataCodingScheme().getAlphabet() == DCS_SIXTEEN_BIT_ALPHABET){
- 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());
+ if (sms->dataCodingScheme().getAlphabet() == DCS_DEFAULT_ALPHABET) {
+ iso_8859_1_to_utf8(tech_pvt, (char *) sms->userData().c_str(), content2, sizeof(content2));
+ } else if (sms->dataCodingScheme().getAlphabet() == DCS_SIXTEEN_BIT_ALPHABET) {
+ 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());
- }
+ }
NOTICA("dataCodingScheme=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
NOTICA("userData= |||%s|||\n", GSMOPEN_P_LOG, content2);
@@ -3041,7 +3052,7 @@
//char *stringp = NULL;
//int found = 0;
int failed = 0;
- int err = 0;
+ int err = 0;
//strncpy(rdest, idest, sizeof(rdest) - 1);
DEBUGA_GSMOPEN("GSMopenSendsms: dest=%s text=%s\n", GSMOPEN_P_LOG, dest, text);
@@ -3062,10 +3073,10 @@
PUSHA_UNLOCKA(&tech_pvt->controldev_lock);
LOKKA(tech_pvt->controldev_lock);
- 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);
- }
+ 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);
+ }
if (tech_pvt->no_ucs2) {
@@ -3178,10 +3189,10 @@
POPPA_UNLOCKA(&tech_pvt->controldev_lock);
}
- 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);
- }
+ 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);
+ }
DEBUGA_GSMOPEN("FINISH\n", GSMOPEN_P_LOG);
@@ -3233,7 +3244,7 @@
int16_t *ptr = (int16_t *) data;
for (i = 0; i < samples_num; i++) {
- x = (int)(ptr[i] * boost) / BOOST_SCALE;
+ x = (int) (ptr[i] * boost) / BOOST_SCALE;
if (x > 32767) {
x = 32767;
} else if (x < -32768) {
@@ -3248,159 +3259,140 @@
int gsmopen_serial_getstatus_AT(private_t * tech_pvt)
{
- int res;
- private_t *p = tech_pvt;
+ int res;
+ private_t *p = tech_pvt;
#if 0
- if (p->owner) {
- if (p->owner->_state != AST_STATE_UP && p->owner->_state != AST_STATE_DOWN) {
- DEBUGA_AT("No getstatus, we're neither UP nor DOWN\n", GSMOPEN_P_LOG);
- return 0;
- }
- }
-#endif
+ if (p->owner) {
+ if (p->owner->_state != AST_STATE_UP && p->owner->_state != AST_STATE_DOWN) {
+ DEBUGA_AT("No getstatus, we're neither UP nor DOWN\n", GSMOPEN_P_LOG);
+ return 0;
+ }
+ }
+#endif
- PUSHA_UNLOCKA(p->controldev_lock);
- LOKKA(p->controldev_lock);
- res = gsmopen_serial_write_AT_ack(p, "AT");
- if (res) {
- ERRORA("AT was not acknowledged, continuing but maybe there is a problem\n",
- GSMOPEN_P_LOG);
- }
- usleep(1000);
+ PUSHA_UNLOCKA(p->controldev_lock);
+ LOKKA(p->controldev_lock);
+ res = gsmopen_serial_write_AT_ack(p, "AT");
+ if (res) {
+ ERRORA("AT was not acknowledged, continuing but maybe there is a problem\n", GSMOPEN_P_LOG);
+ }
+ usleep(1000);
- 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);
- }
- usleep(1000);
- }
+ 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);
+ }
+ usleep(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);
- }
- usleep(1000);
- }
- //FIXME all the following commands in config!
+ 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);
+ }
+ usleep(1000);
+ }
+ //FIXME all the following commands in config!
- if (p->sms_cnmi_not_supported) {
- 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 is incoming. If this happens repeatedly, and you cannot correctly receive SMSs from this interface, please manually clean all messages from the cellphone/SIM. Continuing.\n",
- GSMOPEN_P_LOG, "AT+MMGL=\"HEADER ONLY\"", "OK");
- } else {
- usleep(1000);
- if (p->unread_sms_msg_id) {
- char at_command[256];
+ if (p->sms_cnmi_not_supported) {
+ 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 is incoming. If this happens repeatedly, and you cannot correctly receive SMSs from this interface, please manually clean all messages from the cellphone/SIM. Continuing.\n",
+ GSMOPEN_P_LOG, "AT+MMGL=\"HEADER ONLY\"", "OK");
+ } else {
+ usleep(1000);
+ if (p->unread_sms_msg_id) {
+ char at_command[256];
- 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);
- memset(p->sms_message, 0, sizeof(p->sms_message));
- }
+ 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);
+ memset(p->sms_message, 0, sizeof(p->sms_message));
+ }
- memset(at_command, 0, sizeof(at_command));
- sprintf(at_command, "AT+CMGR=%d", p->unread_sms_msg_id);
- memset(p->sms_message, 0, sizeof(p->sms_message));
+ memset(at_command, 0, sizeof(at_command));
+ sprintf(at_command, "AT+CMGR=%d", p->unread_sms_msg_id);
+ memset(p->sms_message, 0, sizeof(p->sms_message));
- p->reading_sms_msg = 1;
- 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);
- }
- 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);
- }
- 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);
- }
+ p->reading_sms_msg = 1;
+ 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);
+ }
+ 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);
+ }
+ 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);
+ }
- if (strlen(p->sms_message)) {
+ if (strlen(p->sms_message)) {
#if 0
- manager_event(EVENT_FLAG_SYSTEM, "GSMOPENincomingsms", "Interface: %s\r\nSMS_Message: %s\r\n", p->name, p->sms_message);
+ manager_event(EVENT_FLAG_SYSTEM, "GSMOPENincomingsms", "Interface: %s\r\nSMS_Message: %s\r\n", p->name, p->sms_message);
- if (strlen(p->sms_receiving_program)) {
- int fd1[2];
- pid_t pid1;
- char *arg1[] = { p->sms_receiving_program, (char *) NULL };
- int i;
+ if (strlen(p->sms_receiving_program)) {
+ int fd1[2];
+ pid_t pid1;
+ char *arg1[] = { p->sms_receiving_program, (char *) NULL };
+ int i;
- DEBUGA_AT("incoming SMS message:---%s---\n", GSMOPEN_P_LOG, p->sms_message);
- pipe(fd1);
- pid1 = fork();
+ DEBUGA_AT("incoming SMS message:---%s---\n", GSMOPEN_P_LOG, p->sms_message);
+ pipe(fd1);
+ pid1 = fork();
- if (pid1 == 0) { //child
- int err;
+ if (pid1 == 0) { //child
+ int err;
- dup2(fd1[0], 0); // Connect stdin to pipe output
- close(fd1[1]); // close input pipe side
- setsid(); //session id
- err = execvp(arg1[0], arg1); //exec our program, with stdin connected to pipe output
- if (err) {
- ERRORA
- ("'sms_receiving_program' is set in config file to '%s', and it gave us back this error: %d, (%s). SMS received was:---%s---\n",
- GSMOPEN_P_LOG, p->sms_receiving_program, err, strerror(errno),
- p->sms_message);
- }
- close(fd1[0]); // close output pipe side
- } //starting here continue the parent
- close(fd1[0]); // close output pipe side
- // write the msg on the pipe input
- for (i = 0; i < strlen(p->sms_message); i++) {
- write(fd1[1], &p->sms_message[i], 1);
- }
- close(fd1[1]); // close pipe input, let our program know we've finished
- } else {
- ERRORA
- ("got SMS incoming message, but 'sms_receiving_program' is not set in config file. SMS received was:---%s---\n",
- GSMOPEN_P_LOG, p->sms_message);
- }
+ dup2(fd1[0], 0); // Connect stdin to pipe output
+ close(fd1[1]); // close input pipe side
+ setsid(); //session id
+ err = execvp(arg1[0], arg1); //exec our program, with stdin connected to pipe output
+ if (err) {
+ ERRORA
+ ("'sms_receiving_program' is set in config file to '%s', and it gave us back this error: %d, (%s). SMS received was:---%s---\n",
+ GSMOPEN_P_LOG, p->sms_receiving_program, err, strerror(errno), p->sms_message);
+ }
+ close(fd1[0]); // close output pipe side
+ } //starting here continue the parent
+ close(fd1[0]); // close output pipe side
+ // write the msg on the pipe input
+ for (i = 0; i < strlen(p->sms_message); i++) {
+ write(fd1[1], &p->sms_message[i], 1);
+ }
+ close(fd1[1]); // close pipe input, let our program know we've finished
+ } else {
+ ERRORA
+ ("got SMS incoming message, but 'sms_receiving_program' is not set in config file. SMS received was:---%s---\n",
+ GSMOPEN_P_LOG, p->sms_message);
+ }
#endif //0
- WARNINGA ("got SMS incoming message. SMS received was:---%s---\n", GSMOPEN_P_LOG, p->sms_message);
- }
-#if 0 //is this one needed? maybe it can interrupt an incoming call that is just to announce itself
- if (p->phone_callflow == CALLFLOW_CALL_IDLE
- && p->interface_state == AST_STATE_DOWN && p->owner == NULL) {
- /* 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);
- }
- }
+ WARNINGA("got SMS incoming message. SMS received was:---%s---\n", GSMOPEN_P_LOG, p->sms_message);
+ }
+#if 0 //is this one needed? maybe it can interrupt an incoming call that is just to announce itself
+ if (p->phone_callflow == CALLFLOW_CALL_IDLE && p->interface_state == AST_STATE_DOWN && p->owner == NULL) {
+ /* 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);
+ }
+ }
#endif
- }
- }
- }
+ }
+ }
+ }
- UNLOCKA(p->controldev_lock);
- POPPA_UNLOCKA(p->controldev_lock);
- return 0;
+ UNLOCKA(p->controldev_lock);
+ POPPA_UNLOCKA(p->controldev_lock);
+ return 0;
}
-
-
Modified: freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp (16153 => 16154)
--- freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp 2010-01-05 15:44:53 UTC (rev 16153)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp 2010-01-05 15:55:24 UTC (rev 16154)
@@ -115,7 +115,7 @@
"HANG_RQ",
"PREANSW"
};
-const char *phone_callflow[] = { /* should match CALLFLOW_XXX in gsmopen.h */
+const char *phone_callflow[] = { /* should match CALLFLOW_XXX in gsmopen.h */
"CALL_IDLE",
"CALL_DOWN",
"INCOMING_RNG",
@@ -197,7 +197,8 @@
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
switch_event_t *var_event,
switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
+ switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+ switch_call_cause_t *cancel_cause);
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
@@ -451,7 +452,7 @@
switch_channel_t *channel;
private_t *tech_pvt = NULL;
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
@@ -477,7 +478,7 @@
{
private_t *tech_pvt = NULL;
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
if (tech_pvt) {
@@ -518,7 +519,7 @@
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
tech_pvt->phone_callflow = CALLFLOW_CALL_HANGUP_REQUESTED;
@@ -550,7 +551,7 @@
tech_pvt->interface_state = GSMOPEN_STATE_IDLE;
//FIXME if (tech_pvt->phone_callflow == CALLFLOW_STATUS_FINISHED) {
- tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
+ tech_pvt->phone_callflow = CALLFLOW_CALL_IDLE;
//FIXME }
switch_mutex_unlock(globals.mutex);
@@ -565,7 +566,7 @@
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
DEBUGA_GSMOPEN("%s CHANNEL ROUTING\n", GSMOPEN_P_LOG, tech_pvt->name);
@@ -582,7 +583,7 @@
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
DEBUGA_GSMOPEN("%s CHANNEL EXECUTE\n", GSMOPEN_P_LOG, tech_pvt->name);
@@ -598,7 +599,7 @@
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
DEBUGA_GSMOPEN("%s CHANNEL KILL_CHANNEL\n", GSMOPEN_P_LOG, tech_pvt->name);
@@ -628,7 +629,7 @@
{
private_t *tech_pvt = NULL;
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
DEBUGA_GSMOPEN("%s CHANNEL CONSUME_MEDIA\n", GSMOPEN_P_LOG, tech_pvt->name);
return SWITCH_STATUS_SUCCESS;
@@ -638,7 +639,7 @@
static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
{
private_t *tech_pvt = NULL;
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
DEBUGA_GSMOPEN("%s CHANNEL EXCHANGE_MEDIA\n", GSMOPEN_P_LOG, tech_pvt->name);
return SWITCH_STATUS_SUCCESS;
}
@@ -646,14 +647,14 @@
static switch_status_t channel_on_soft_execute(switch_core_session_t *session)
{
private_t *tech_pvt = NULL;
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
DEBUGA_GSMOPEN("%s CHANNEL SOFT_EXECUTE\n", GSMOPEN_P_LOG, tech_pvt->name);
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t * dtmf)
+static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
- private_t *tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ private_t *tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
DEBUGA_GSMOPEN("%s CHANNEL SEND_DTMF\n", GSMOPEN_P_LOG, tech_pvt->name);
@@ -673,7 +674,7 @@
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!switch_channel_ready(channel) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
@@ -696,7 +697,7 @@
int samples;
//if ((samples = snd_pcm_readi(tech_pvt->alsac, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
- if ((samples = alsa_read(tech_pvt, (short *)tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0) {
+ if ((samples = alsa_read(tech_pvt, (short *) tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0) {
tech_pvt->read_frame.datalen = samples * 2;
tech_pvt->read_frame.samples = samples;
@@ -730,7 +731,7 @@
memset(digit_str, 0, sizeof(digit_str));
- teletone_dtmf_detect(&tech_pvt->dtmf_detect, (int16_t *)tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
+ teletone_dtmf_detect(&tech_pvt->dtmf_detect, (int16_t *) tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
if (digit_str[0]) {
@@ -808,7 +809,7 @@
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!switch_channel_ready(channel) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
@@ -829,7 +830,7 @@
//snd_pcm_writei(tech_pvt->alsap, (short *) frame->data, (int) (frame->datalen / 2));
gsmopen_sound_boost(frame->data, frame->samples, tech_pvt->playback_boost);
- sent = alsa_write(tech_pvt, (short *)frame->data, (int) (frame->datalen));
+ sent = alsa_write(tech_pvt, (short *) frame->data, (int) (frame->datalen));
//DEBUGA_GSMOPEN("sent=%d \n", GSMOPEN_P_LOG, sent);
if (sent && sent != frame->datalen / 2 && sent != -1) {
@@ -847,7 +848,7 @@
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
- tech_pvt = ( private_t *)switch_core_session_get_private(session);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
//ERRORA("%s CHANNEL INIT\n", GSMOPEN_P_LOG, tech_pvt->name);
@@ -934,7 +935,7 @@
switch_assert(tech_pvt != NULL);
if (!body) {
- body = (char *)"";
+ body = (char *) "";
}
WARNINGA("event: |||%s|||\n", GSMOPEN_P_LOG, body);
@@ -970,7 +971,8 @@
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
switch_event_t *var_event,
switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
+ switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+ switch_call_cause_t *cancel_cause)
{
private_t *tech_pvt = NULL;
if ((*new_session = switch_core_session_request(gsmopen_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
@@ -1003,7 +1005,7 @@
/* Find the first idle interface using Round Robin */
DEBUGA_GSMOPEN("Finding one available gsmopen interface RR\n", GSMOPEN_P_LOG);
tech_pvt = find_available_gsmopen_interface_rr(NULL);
- if (tech_pvt){
+ if (tech_pvt) {
found = 1;
DEBUGA_GSMOPEN("FOUND one available gsmopen interface RR\n", GSMOPEN_P_LOG);
}
@@ -1365,7 +1367,7 @@
at_indicator_callsetupoutgoing_string = val;
} else if (!strcasecmp(var, "at_indicator_callsetupremoteringing_string")) {
at_indicator_callsetupremoteringing_string = val;
- //} else if (!strcasecmp(var, "sms_receiving_program")) {
+ //} else if (!strcasecmp(var, "sms_receiving_program")) {
//sms_receiving_program = val;
} else if (!strcasecmp(var, "alsacname")) {
alsacname = val;
@@ -1431,7 +1433,8 @@
continue;
}
if (!switch_is_number(at_after_preinit_pause)) {
- ERRORA("interface param 'at_after_preinit_pause' MUST be a number, now at_after_preinit_pause='%s'\n", GSMOPEN_P_LOG, at_after_preinit_pause);
+ ERRORA("interface param 'at_after_preinit_pause' MUST be a number, now at_after_preinit_pause='%s'\n", GSMOPEN_P_LOG,
+ at_after_preinit_pause);
continue;
}
if (!switch_is_number(at_initial_pause)) {
@@ -1451,7 +1454,8 @@
continue;
}
if (!switch_is_number(alsa_periods_in_buffer)) {
- ERRORA("interface param 'alsa_periods_in_buffer' MUST be a number, now alsa_periods_in_buffer='%s'\n", GSMOPEN_P_LOG, alsa_periods_in_buffer);
+ ERRORA("interface param 'alsa_periods_in_buffer' MUST be a number, now alsa_periods_in_buffer='%s'\n", GSMOPEN_P_LOG,
+ alsa_periods_in_buffer);
continue;
}
if (!switch_is_number(gsmopen_sound_rate)) {
@@ -1604,21 +1608,21 @@
}
}
- if (alsa_init(&globals.GSMOPEN_INTERFACES[interface_id])) {
- ERRORA("alsa_init failed\n", GSMOPEN_P_LOG);
- return SWITCH_STATUS_FALSE;
+ if (alsa_init(&globals.GSMOPEN_INTERFACES[interface_id])) {
+ ERRORA("alsa_init failed\n", GSMOPEN_P_LOG);
+ return SWITCH_STATUS_FALSE;
- }
+ }
- if (alsa_shutdown(&globals.GSMOPEN_INTERFACES[interface_id])) {
- ERRORA("alsa_shutdown failed\n", GSMOPEN_P_LOG);
- return SWITCH_STATUS_FALSE;
+ if (alsa_shutdown(&globals.GSMOPEN_INTERFACES[interface_id])) {
+ ERRORA("alsa_shutdown failed\n", GSMOPEN_P_LOG);
+ return SWITCH_STATUS_FALSE;
- }
- //gsmopen_store_boost((char *)"5", &globals.GSMOPEN_INTERFACES[interface_id].capture_boost); //FIXME
- //gsmopen_store_boost((char *)"10", &globals.GSMOPEN_INTERFACES[interface_id].playback_boost); //FIXME
- gsmopen_store_boost((char *)capture_boost, &globals.GSMOPEN_INTERFACES[interface_id].capture_boost); //FIXME
- gsmopen_store_boost((char *)playback_boost, &globals.GSMOPEN_INTERFACES[interface_id].playback_boost); //FIXME
+ }
+ //gsmopen_store_boost((char *)"5", &globals.GSMOPEN_INTERFACES[interface_id].capture_boost); //FIXME
+ //gsmopen_store_boost((char *)"10", &globals.GSMOPEN_INTERFACES[interface_id].playback_boost); //FIXME
+ gsmopen_store_boost((char *) capture_boost, &globals.GSMOPEN_INTERFACES[interface_id].capture_boost); //FIXME
+ gsmopen_store_boost((char *) playback_boost, &globals.GSMOPEN_INTERFACES[interface_id].playback_boost); //FIXME
switch_sleep(100000);
switch_threadattr_create(&gsmopen_api_thread_attr, gsmopen_module_pool);
@@ -1662,7 +1666,8 @@
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint)
+static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type,
+ const char *hint)
{
char *user, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL;
private_t *tech_pvt = NULL;
@@ -1708,7 +1713,8 @@
if (strlen(globals.GSMOPEN_INTERFACES[i].name)
&& (strncmp(globals.GSMOPEN_INTERFACES[i].name, hint, strlen(hint)) == 0)) {
tech_pvt = &globals.GSMOPEN_INTERFACES[i];
- DEBUGA_GSMOPEN("Using interface: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", GSMOPEN_P_LOG, i, globals.GSMOPEN_INTERFACES[i].name);
+ DEBUGA_GSMOPEN("Using interface: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", GSMOPEN_P_LOG, i,
+ globals.GSMOPEN_INTERFACES[i].name);
found = 1;
break;
}
@@ -1762,7 +1768,7 @@
}
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- gsmopen_endpoint_interface = (switch_endpoint_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
+ gsmopen_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
gsmopen_endpoint_interface->interface_name = "gsmopen";
gsmopen_endpoint_interface->io_routines = &gsmopen_io_routines;
gsmopen_endpoint_interface->state_handler = &gsmopen_state_handlers;
@@ -1773,7 +1779,8 @@
SWITCH_ADD_API(commands_api_interface, "sk", "GSMopen console commands", sk_function, SK_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "gsmopen", "GSMopen interface commands", gsmopen_function, GSMOPEN_SYNTAX);
#endif //0
- SWITCH_ADD_API(commands_api_interface, "gsmopen_sendsms", "gsmopen_sendsms interface destination_number SMS_text", sendsms_function, SENDSMS_SYNTAX);
+ SWITCH_ADD_API(commands_api_interface, "gsmopen_sendsms", "gsmopen_sendsms interface destination_number SMS_text", sendsms_function,
+ SENDSMS_SYNTAX);
SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send);
/* indicate that the module should continue to be loaded */
@@ -1825,14 +1832,13 @@
x--;
switch_yield(50000);
}
- fd = tech_pvt->controldevfd;
- WARNINGA("SHUTDOWN tech_pvt->controldevfd=%d\n", GSMOPEN_P_LOG, tech_pvt->controldevfd);
- if (fd) {
- //close(fd);
- //tech_pvt->controldevfd = -1;
- WARNINGA("SHUTDOWN tech_pvt->controldevfd=%d\n", GSMOPEN_P_LOG, tech_pvt->controldevfd);
- }
-
+ fd = tech_pvt->controldevfd;
+ WARNINGA("SHUTDOWN tech_pvt->controldevfd=%d\n", GSMOPEN_P_LOG, tech_pvt->controldevfd);
+ if (fd) {
+ //close(fd);
+ //tech_pvt->controldevfd = -1;
+ WARNINGA("SHUTDOWN tech_pvt->controldevfd=%d\n", GSMOPEN_P_LOG, tech_pvt->controldevfd);
+ }
#ifndef WIN32
WARNINGA("SHUTDOWN interface_id=%d\n", GSMOPEN_P_LOG, interface_id);
shutdown(tech_pvt->audiogsmopenpipe[0], 2);
@@ -1864,7 +1870,7 @@
}
-void *SWITCH_THREAD_FUNC gsmopen_do_gsmopenapi_thread(switch_thread_t *thread, void *obj)
+void *SWITCH_THREAD_FUNC gsmopen_do_gsmopenapi_thread(switch_thread_t * thread, void *obj)
{
return gsmopen_do_gsmopenapi_thread_func(obj);
}
@@ -2069,8 +2075,11 @@
tech_pvt = &globals.GSMOPEN_INTERFACES[interface_id];
gsmopen_state = tech_pvt->interface_state;
- DEBUGA_GSMOPEN("gsmopen interface: %d, name: %s, state: %d\n", GSMOPEN_P_LOG, interface_id, globals.GSMOPEN_INTERFACES[interface_id].name, gsmopen_state);
- if ((tech_pvt_calling ? strcmp(tech_pvt->gsmopen_user, tech_pvt_calling->gsmopen_user) : 1) && (GSMOPEN_STATE_DOWN == gsmopen_state || 0 == gsmopen_state) && (tech_pvt->phone_callflow == CALLFLOW_STATUS_FINISHED || 0 == tech_pvt->phone_callflow)) {
+ DEBUGA_GSMOPEN("gsmopen interface: %d, name: %s, state: %d\n", GSMOPEN_P_LOG, interface_id, globals.GSMOPEN_INTERFACES[interface_id].name,
+ gsmopen_state);
+ if ((tech_pvt_calling ? strcmp(tech_pvt->gsmopen_user, tech_pvt_calling->gsmopen_user) : 1)
+ && (GSMOPEN_STATE_DOWN == gsmopen_state || 0 == gsmopen_state) && (tech_pvt->phone_callflow == CALLFLOW_STATUS_FINISHED
+ || 0 == tech_pvt->phone_callflow)) {
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 */
@@ -2149,7 +2158,8 @@
if (strlen(globals.GSMOPEN_INTERFACES[i].name)
&& (strncmp(globals.GSMOPEN_INTERFACES[i].name, argv[1], strlen(argv[1])) == 0)) {
globals.sk_console = &globals.GSMOPEN_INTERFACES[i];
- stream->write_function(stream, "sk console is now: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i, globals.GSMOPEN_INTERFACES[i].name);
+ stream->write_function(stream, "sk console is now: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i,
+ globals.GSMOPEN_INTERFACES[i].name);
stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name);
found = 1;
break;
@@ -2423,7 +2433,7 @@
usleep(100); //give other threads a chance
time(&now_timestamp);
- if ((now_timestamp - tech_pvt->gsmopen_serial_synced_timestamp) > 30) { //TODO find a sensible period. 5min? in config?
+ 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);
}
@@ -2482,8 +2492,8 @@
return SWITCH_STATUS_SUCCESS;
} else {
//gsmopen_sendsms(tech_pvt, (char *) argv[1], (char *) argv[2]);
- NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", GSMOPEN_P_LOG, MDL_CHAT_PROTO, tech_pvt->name, argv[1],
- "SIMPLE MESSAGE", switch_str_nil(argv[2]), tech_pvt->name);
+ NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", GSMOPEN_P_LOG, MDL_CHAT_PROTO, tech_pvt->name,
+ argv[1], "SIMPLE MESSAGE", switch_str_nil(argv[2]), tech_pvt->name);
chat_send(MDL_CHAT_PROTO, tech_pvt->name, argv[1], "SIMPLE MESSAGE", switch_str_nil(argv[2]), NULL, tech_pvt->name);
}
@@ -2549,9 +2559,9 @@
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->sms_sender);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "date", tech_pvt->sms_date);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "datacodingscheme", tech_pvt->sms_datacodingscheme);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "servicecentreaddress", tech_pvt->sms_servicecentreaddress);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "messagetype", "%d", tech_pvt->sms_messagetype);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "datacodingscheme", tech_pvt->sms_datacodingscheme);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "servicecentreaddress", tech_pvt->sms_servicecentreaddress);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "messagetype", "%d", tech_pvt->sms_messagetype);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE");
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname);
//switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
@@ -2625,8 +2635,8 @@
NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", GSMOPEN_P_LOG, MDL_CHAT_PROTO, tech_pvt->skype_user,
argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt->name);
- chat_send(MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]),
- NULL, tech_pvt->name);
+ chat_send(MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE",
+ switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name);
//NOTICA("TEXT is: %s\n", GSMOPEN_P_LOG, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1] );
//snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", argv[1]);