Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
2431e0f2
提交
2431e0f2
authored
5月 03, 2012
作者:
Giovanni Maruzzelli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gsmopen: indented
上级
f28ba547
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
191 行增加
和
205 行删除
+191
-205
gsmopen_protocol.cpp
src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
+171
-185
mod_gsmopen.cpp
src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp
+20
-20
没有找到文件。
src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
浏览文件 @
2431e0f2
#include "gsmopen.h"
#include "gsmopen.h"
#ifdef WIN32
#ifdef WIN32
#include "win_iconv.c"
#include "win_iconv.c"
#endif// WIN32
#endif
// WIN32
#define WANT_GSMLIB
#define WANT_GSMLIB
#ifdef WANT_GSMLIB
#ifdef WANT_GSMLIB
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
using
namespace
std
;
using
namespace
std
;
using
namespace
gsmlib
;
using
namespace
gsmlib
;
#endif// WANT_GSMLIB
#endif
// WANT_GSMLIB
extern
int
running
;
//FIXME
extern
int
running
;
//FIXME
...
@@ -154,7 +154,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
...
@@ -154,7 +154,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
char
trash
[
4096
];
char
trash
[
4096
];
res
=
tech_pvt
->
serialPort_serial_control
->
Read
(
trash
,
4096
);
res
=
tech_pvt
->
serialPort_serial_control
->
Read
(
trash
,
4096
);
if
(
res
){
if
(
res
)
{
DEBUGA_GSMOPEN
(
"READ %d on serialport init
\n
"
,
GSMOPEN_P_LOG
,
res
);
DEBUGA_GSMOPEN
(
"READ %d on serialport init
\n
"
,
GSMOPEN_P_LOG
,
res
);
}
}
...
@@ -402,8 +402,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
...
@@ -402,8 +402,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
WARNINGA
(
"AT+CSMP do not got OK from the phone, continuing
\n
"
,
GSMOPEN_P_LOG
);
WARNINGA
(
"AT+CSMP do not got OK from the phone, continuing
\n
"
,
GSMOPEN_P_LOG
);
}
}
}
}
#else // WANT_GSMLIB
#else// WANT_GSMLIB
res
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT+CMGF=0"
);
res
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT+CMGF=0"
);
if
(
res
)
{
if
(
res
)
{
...
@@ -422,7 +421,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
...
@@ -422,7 +421,7 @@ int gsmopen_serial_config_AT(private_t *tech_pvt)
WARNINGA
(
"AT+CSMP do not got OK from the phone, continuing
\n
"
,
GSMOPEN_P_LOG
);
WARNINGA
(
"AT+CSMP do not got OK from the phone, continuing
\n
"
,
GSMOPEN_P_LOG
);
}
}
}
}
#endif// WANT_GSMLIB
#endif
// WANT_GSMLIB
#ifdef NOTDEF //GSMLIB? XXX
#ifdef NOTDEF //GSMLIB? XXX
...
@@ -566,7 +565,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
...
@@ -566,7 +565,7 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
int
at_ack
=
-
1
;
int
at_ack
=
-
1
;
int
la_read
=
0
;
int
la_read
=
0
;
int
timeout_in_msec
;
int
timeout_in_msec
;
int
msecs_passed
=
0
;
int
msecs_passed
=
0
;
timeout_in_msec
=
(
timeout_sec
*
1000
)
+
(
timeout_usec
?
(
timeout_usec
/
1000
)
:
0
);
timeout_in_msec
=
(
timeout_sec
*
1000
)
+
(
timeout_usec
?
(
timeout_usec
/
1000
)
:
0
);
...
@@ -585,16 +584,16 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
...
@@ -585,16 +584,16 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
PUSHA_UNLOCKA
(
tech_pvt
->
controldev_lock
);
PUSHA_UNLOCKA
(
tech_pvt
->
controldev_lock
);
LOKKA
(
tech_pvt
->
controldev_lock
);
LOKKA
(
tech_pvt
->
controldev_lock
);
while
((
!
tech_pvt
->
controldev_dead
)
&&
msecs_passed
<=
timeout_in_msec
){
while
((
!
tech_pvt
->
controldev_dead
)
&&
msecs_passed
<=
timeout_in_msec
)
{
char
*
token_ptr
;
char
*
token_ptr
;
timeout
.
tv_sec
=
timeout_sec
;
//reset the timeout, linux modify it
timeout
.
tv_sec
=
timeout_sec
;
//reset the timeout, linux modify it
timeout
.
tv_usec
=
timeout_usec
;
//reset the timeout, linux modify it
timeout
.
tv_usec
=
timeout_usec
;
//reset the timeout, linux modify it
read:
read:
switch_sleep
(
20000
);
switch_sleep
(
20000
);
msecs_passed
+=
20
;
msecs_passed
+=
20
;
if
(
timeout_in_msec
!=
100
){
if
(
timeout_in_msec
!=
100
)
{
//ERRORA("TIMEOUT=%d, PASSED=%d\n", GSMOPEN_P_LOG, timeout_in_msec, msecs_passed);
//ERRORA("TIMEOUT=%d, PASSED=%d\n", GSMOPEN_P_LOG, timeout_in_msec, msecs_passed);
}
}
//read_count = tech_pvt->serialPort_serial_control->Readv(tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer), (timeout_sec * 1000) + (timeout_usec ? (timeout_usec / 1000) : 0));
//read_count = tech_pvt->serialPort_serial_control->Readv(tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer), (timeout_sec * 1000) + (timeout_usec ? (timeout_usec / 1000) : 0));
...
@@ -603,7 +602,7 @@ read:
...
@@ -603,7 +602,7 @@ read:
//cicopet read_count = read(tech_pvt->controldevfd, tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer));
//cicopet read_count = read(tech_pvt->controldevfd, tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer));
if
(
read_count
==
0
)
{
if
(
read_count
==
0
)
{
if
(
msecs_passed
<=
timeout_in_msec
)
{
if
(
msecs_passed
<=
timeout_in_msec
)
{
goto
read
;
goto
read
;
}
}
}
}
...
@@ -950,7 +949,7 @@ read:
...
@@ -950,7 +949,7 @@ read:
DEBUGA_GSMOPEN
(
"|%s| +CREG: Display: %d, Registration=%d
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
line_array
.
result
[
i
],
n
,
stat
);
DEBUGA_GSMOPEN
(
"|%s| +CREG: Display: %d, Registration=%d
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
line_array
.
result
[
i
],
n
,
stat
);
if
(
err
<
2
)
{
if
(
err
<
2
)
{
DEBUGA_GSMOPEN
(
"|%s| is not formatted as: |+CREG: xx,yy|
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
line_array
.
result
[
i
]);
DEBUGA_GSMOPEN
(
"|%s| is not formatted as: |+CREG: xx,yy|
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
line_array
.
result
[
i
]);
}
else
{
}
else
{
if
(
stat
==
0
)
{
if
(
stat
==
0
)
{
ERRORA
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 additional antenna
\n
"
,
...
@@ -1015,7 +1014,6 @@ read:
...
@@ -1015,7 +1014,6 @@ read:
DEBUGA_GSMOPEN
(
"just sent GSMOPEN_CONTROL_HANGUP
\n
"
,
GSMOPEN_P_LOG
);
DEBUGA_GSMOPEN
(
"just sent GSMOPEN_CONTROL_HANGUP
\n
"
,
GSMOPEN_P_LOG
);
}
}
//
//
//tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE;
//tech_pvt->owner->hangupcause = GSMOPEN_CAUSE_FAILURE;
//gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP);
//gsmopen_queue_control(tech_pvt->owner, GSMOPEN_CONTROL_HANGUP);
...
@@ -1691,7 +1689,7 @@ read:
...
@@ -1691,7 +1689,7 @@ read:
#endif// WANT_GSMLIB
#endif
// WANT_GSMLIB
...
@@ -2324,10 +2322,10 @@ int ucs2_to_utf8(private_t *tech_pvt, char *ucs2_in, char *utf8_out, size_t outb
...
@@ -2324,10 +2322,10 @@ int ucs2_to_utf8(private_t *tech_pvt, char *ucs2_in, char *utf8_out, size_t outb
GSMOPEN_P_LOG
,
inbuf
,
(
int
)
inbytesleft
,
outbuf
,
(
int
)
outbytesleft
,
converted
,
utf8_out
);
GSMOPEN_P_LOG
,
inbuf
,
(
int
)
inbytesleft
,
outbuf
,
(
int
)
outbytesleft
,
converted
,
utf8_out
);
#ifdef WIN32
#ifdef WIN32
iconv_res
=
iconv
(
iconv_format
,
(
const
char
**
)
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
iconv_res
=
iconv
(
iconv_format
,
(
const
char
**
)
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
#else// WIN32
#else
// WIN32
iconv_res
=
iconv
(
iconv_format
,
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
iconv_res
=
iconv
(
iconv_format
,
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
#endif// WIN32
#endif
// WIN32
if
(
iconv_res
==
(
size_t
)
-
1
)
{
if
(
iconv_res
==
(
size_t
)
-
1
)
{
DEBUGA_GSMOPEN
(
"2 ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s
\n
"
,
DEBUGA_GSMOPEN
(
"2 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
);
GSMOPEN_P_LOG
,
inbuf
,
(
int
)
inbytesleft
,
outbuf
,
(
int
)
outbytesleft
,
converted
,
utf8_out
);
...
@@ -2343,6 +2341,7 @@ int ucs2_to_utf8(private_t *tech_pvt, char *ucs2_in, char *utf8_out, size_t outb
...
@@ -2343,6 +2341,7 @@ int ucs2_to_utf8(private_t *tech_pvt, char *ucs2_in, char *utf8_out, size_t outb
//#endif //WIN32
//#endif //WIN32
return
0
;
return
0
;
}
}
int
utf8_to_iso_8859_1
(
private_t
*
tech_pvt
,
char
*
utf8_in
,
size_t
inbytesleft
,
char
*
iso_8859_1_out
,
size_t
outbytesleft
)
int
utf8_to_iso_8859_1
(
private_t
*
tech_pvt
,
char
*
utf8_in
,
size_t
inbytesleft
,
char
*
iso_8859_1_out
,
size_t
outbytesleft
)
{
{
/* cicopet */
/* cicopet */
...
@@ -2365,10 +2364,10 @@ int utf8_to_iso_8859_1(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, c
...
@@ -2365,10 +2364,10 @@ int utf8_to_iso_8859_1(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, c
DEBUGA_GSMOPEN
(
"in=%s, inleft=%d, out=%s, outleft=%d, utf8_in=%s, iso_8859_1_out=%s
\n
"
,
DEBUGA_GSMOPEN
(
"in=%s, inleft=%d, out=%s, outleft=%d, utf8_in=%s, iso_8859_1_out=%s
\n
"
,
GSMOPEN_P_LOG
,
inbuf
,
(
int
)
inbytesleft
,
outbuf
,
(
int
)
outbytesleft
,
utf8_in
,
iso_8859_1_out
);
GSMOPEN_P_LOG
,
inbuf
,
(
int
)
inbytesleft
,
outbuf
,
(
int
)
outbytesleft
,
utf8_in
,
iso_8859_1_out
);
#ifdef WIN32
#ifdef WIN32
iconv_res
=
iconv
(
iconv_format
,
(
const
char
**
)
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
iconv_res
=
iconv
(
iconv_format
,
(
const
char
**
)
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
#else// WIN32
#else
// WIN32
iconv_res
=
iconv
(
iconv_format
,
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
iconv_res
=
iconv
(
iconv_format
,
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
#endif// WIN32
#endif
// WIN32
if
(
iconv_res
==
(
size_t
)
-
1
)
{
if
(
iconv_res
==
(
size_t
)
-
1
)
{
ERRORA
(
"error: %s %d
\n
"
,
GSMOPEN_P_LOG
,
strerror
(
errno
),
errno
);
ERRORA
(
"error: %s %d
\n
"
,
GSMOPEN_P_LOG
,
strerror
(
errno
),
errno
);
return
-
1
;
return
-
1
;
...
@@ -2420,10 +2419,10 @@ int iso_8859_1_to_utf8(private_t *tech_pvt, char *iso_8859_1_in, char *utf8_out,
...
@@ -2420,10 +2419,10 @@ int iso_8859_1_to_utf8(private_t *tech_pvt, char *iso_8859_1_in, char *utf8_out,
inbytesleft
=
strlen
(
iso_8859_1_in
)
*
2
;
inbytesleft
=
strlen
(
iso_8859_1_in
)
*
2
;
#ifdef WIN32
#ifdef WIN32
iconv_res
=
iconv
(
iconv_format
,
(
const
char
**
)
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
iconv_res
=
iconv
(
iconv_format
,
(
const
char
**
)
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
#else// WIN32
#else
// WIN32
iconv_res
=
iconv
(
iconv_format
,
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
iconv_res
=
iconv
(
iconv_format
,
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
#endif// WIN32
#endif
// WIN32
if
(
iconv_res
==
(
size_t
)
-
1
)
{
if
(
iconv_res
==
(
size_t
)
-
1
)
{
DEBUGA_GSMOPEN
(
"ciao in=%s, inleft=%d, out=%s, outleft=%d, utf8_out=%s
\n
"
,
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
);
...
@@ -2468,10 +2467,10 @@ int utf8_to_ucs2(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, char *u
...
@@ -2468,10 +2467,10 @@ int utf8_to_ucs2(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, char *u
DEBUGA_GSMOPEN
(
"in=%s, inleft=%d, out=%s, outleft=%d, utf8_in=%s, converted=%s
\n
"
,
DEBUGA_GSMOPEN
(
"in=%s, inleft=%d, out=%s, outleft=%d, utf8_in=%s, converted=%s
\n
"
,
GSMOPEN_P_LOG
,
inbuf
,
(
int
)
inbytesleft
,
outbuf
,
(
int
)
outbytesleft
,
utf8_in
,
converted
);
GSMOPEN_P_LOG
,
inbuf
,
(
int
)
inbytesleft
,
outbuf
,
(
int
)
outbytesleft
,
utf8_in
,
converted
);
#ifdef WIN32
#ifdef WIN32
iconv_res
=
iconv
(
iconv_format
,
(
const
char
**
)
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
iconv_res
=
iconv
(
iconv_format
,
(
const
char
**
)
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
#else// WIN32
#else
// WIN32
iconv_res
=
iconv
(
iconv_format
,
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
iconv_res
=
iconv
(
iconv_format
,
&
inbuf
,
&
inbytesleft
,
&
outbuf
,
&
outbytesleft
);
#endif// WIN32
#endif
// WIN32
if
(
iconv_res
==
(
size_t
)
-
1
)
{
if
(
iconv_res
==
(
size_t
)
-
1
)
{
ERRORA
(
"error: %s %d
\n
"
,
GSMOPEN_P_LOG
,
strerror
(
errno
),
errno
);
ERRORA
(
"error: %s %d
\n
"
,
GSMOPEN_P_LOG
,
strerror
(
errno
),
errno
);
return
-
1
;
return
-
1
;
...
@@ -2659,7 +2658,8 @@ int gsmopen_senddigit(private_t *tech_pvt, char digit)
...
@@ -2659,7 +2658,8 @@ int gsmopen_senddigit(private_t *tech_pvt, char digit)
sprintf
(
at_command
,
"%s=1,%c"
,
tech_pvt
->
at_send_dtmf
,
digit
);
sprintf
(
at_command
,
"%s=1,%c"
,
tech_pvt
->
at_send_dtmf
,
digit
);
res
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
at_command
);
res
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
at_command
);
if
(
res
)
{
if
(
res
)
{
DEBUGA_GSMOPEN
(
"XXX answer (OK) takes long to come, goes into timeout. command used: '%s=1,%c'
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
at_send_dtmf
,
digit
);
DEBUGA_GSMOPEN
(
"XXX answer (OK) takes long to come, goes into timeout. command used: '%s=1,%c'
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
at_send_dtmf
,
digit
);
}
}
}
}
...
@@ -2707,12 +2707,12 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text)
...
@@ -2707,12 +2707,12 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text)
if
(
err
)
{
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) do not got OK from the phone
\n
"
,
GSMOPEN_P_LOG
);
}
}
#else// WANT_GSMLIB
#else
// WANT_GSMLIB
err
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT+CMGF=0"
);
err
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT+CMGF=0"
);
if
(
err
)
{
if
(
err
)
{
ERRORA
(
"AT+CMGF=0 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone
\n
"
,
GSMOPEN_P_LOG
);
ERRORA
(
"AT+CMGF=0 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone
\n
"
,
GSMOPEN_P_LOG
);
}
}
#endif// WANT_GSMLIB
#endif
// WANT_GSMLIB
if
(
tech_pvt
->
no_ucs2
||
tech_pvt
->
sms_pdu_not_supported
==
0
)
{
if
(
tech_pvt
->
no_ucs2
||
tech_pvt
->
sms_pdu_not_supported
==
0
)
{
...
@@ -2720,45 +2720,33 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text)
...
@@ -2720,45 +2720,33 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text)
SMSMessageRef
smsMessage
;
SMSMessageRef
smsMessage
;
memset
(
mesg_test
,
'\0'
,
sizeof
(
mesg_test
));
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è новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"
);
//let's test the beauty of utf8
//sprintf(mesg_test,":) ciao belè èéàòìù");
//sprintf(mesg_test,":) ciao belè èéàòìù");
//text=mesg_test;
//text=mesg_test;
utf8_to_iso_8859_1
(
tech_pvt
,
text
,
strlen
(
text
),
smscommand
,
sizeof
(
smscommand
));
utf8_to_iso_8859_1
(
tech_pvt
,
text
,
strlen
(
text
),
smscommand
,
sizeof
(
smscommand
));
smsMessage
=
new
SMSSubmitMessage
(
smscommand
,
dest
);
smsMessage
=
new
SMSSubmitMessage
(
smscommand
,
dest
);
string
pdu
=
smsMessage
->
encode
();
string
pdu
=
smsMessage
->
encode
();
strncpy
(
pdu2
,
pdu
.
c_str
(),
sizeof
(
pdu2
)
-
1
);
strncpy
(
pdu2
,
pdu
.
c_str
(),
sizeof
(
pdu2
)
-
1
);
memset
(
smscommand
,
'\0'
,
sizeof
(
smscommand
));
memset
(
smscommand
,
'\0'
,
sizeof
(
smscommand
));
pdulenght
=
pdu
.
length
()
/
2
-
1
;
pdulenght
=
pdu
.
length
()
/
2
-
1
;
sprintf
(
smscommand
,
"AT+CMGS=%d"
,
pdulenght
);
sprintf
(
smscommand
,
"AT+CMGS=%d"
,
pdulenght
);
#ifdef NOTDEF
#ifdef NOTDEF
***
9.
How
to
support
unicode
?
***
9.
How
to
support
unicode
?
You
need
6
steps
:
1.
set
datacodingschema
to
DCS_SIXTEEN_BIT_ALPHABET
2.
set
your
locale
correctly
,
for
example
,
my
locale
,
china
.
setlocale
(
LC_ALL
,
"chs"
);
You
need
6
steps
:
1.
set
datacodingschema
to
DCS_SIXTEEN_BIT_ALPHABET
3.
translate
MBCS
(
multiple
byte
character
set
)
string
to
unicode
string
.
wchar_t
wstr
[
1000
];
2.
set
your
locale
correctly
,
for
example
,
my
locale
,
china
.
setlocale
(
LC_ALL
,
"chs"
);
3.
translate
MBCS
(
multiple
byte
character
set
)
string
to
unicode
string
.
wchar_t
wstr
[
1000
];
memset
(
wstr
,
0
,
2000
);
memset
(
wstr
,
0
,
2000
);
mbstowcs
(
wstr
,
data
.
c_str
(),
data
.
length
());
mbstowcs
(
wstr
,
data
.
c_str
(),
data
.
length
());
4.
get
unicode
string
length
.
4.
get
unicode
string
length
.
int
wcs_len
=
wcslen
(
wstr
);
int
wcs_len
=
wcslen
(
wstr
);
5.
change
unicode
string
to
net
order
.
for
(
int
i
=
0
;
i
<
wcs_len
;
i
++
)
wstr
[
i
]
=
htons
(
wstr
[
i
]);
6.
put
unicode
string
into
pdu
.
5.
change
unicode
string
to
net
order
.
for
(
int
i
=
0
;
i
<
wcs_len
;
i
++
)
wstr
[
i
]
=
htons
(
wstr
[
i
]);
6.
put
unicode
string
into
pdu
.
char
content2
[
1000
];
char
content2
[
1000
];
SMSMessageRef
sms
;
SMSMessageRef
sms
;
//MessageType messagetype;
//MessageType messagetype;
//Address servicecentreaddress;
//Address servicecentreaddress;
...
@@ -2795,19 +2783,18 @@ You need 6 steps:
...
@@ -2795,19 +2783,18 @@ You need 6 steps:
strncpy
(
tech_pvt
->
sms_sender
,
sms
->
address
().
toString
().
c_str
(),
sizeof
(
tech_pvt
->
sms_sender
));
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_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_datacodingscheme
,
sms
->
dataCodingScheme
().
toString
().
c_str
(),
sizeof
(
tech_pvt
->
sms_datacodingscheme
));
strncpy
(
tech_pvt
->
sms_servicecentreaddress
,
sms
->
serviceCentreAddress
().
toString
().
c_str
(),
strncpy
(
tech_pvt
->
sms_servicecentreaddress
,
sms
->
serviceCentreAddress
().
toString
().
c_str
(),
sizeof
(
tech_pvt
->
sms_servicecentreaddress
));
sizeof
(
tech_pvt
->
sms_servicecentreaddress
));
tech_pvt
->
sms_messagetype
=
sms
->
messageType
();
tech_pvt
->
sms_messagetype
=
sms
->
messageType
();
//messagetype = sms->messageType();
//messagetype = sms->messageType();
//servicecentreaddress = sms->serviceCentreAddress();
//servicecentreaddress = sms->serviceCentreAddress();
//servicecentretimestamp = sms->serviceCentreTimestamp();
//servicecentretimestamp = sms->serviceCentreTimestamp();
//sender_recipient_address = sms->address();
//sender_recipient_address = sms->address();
#endif// NOTDEF
#endif
// NOTDEF
#else// WANT_GSMLIB
#else
// WANT_GSMLIB
ERRORA
(
"tech_pvt->no_ucs2 || tech_pvt->sms_pdu_not_supported == 0 && no WANT_GSMLIB
\n
"
,
GSMOPEN_P_LOG
);
ERRORA
(
"tech_pvt->no_ucs2 || tech_pvt->sms_pdu_not_supported == 0 && no WANT_GSMLIB
\n
"
,
GSMOPEN_P_LOG
);
return
RESULT_FAILURE
;
return
RESULT_FAILURE
;
#endif// WANT_GSMLIB
#endif
// WANT_GSMLIB
}
else
{
}
else
{
char
dest2
[
1048
];
char
dest2
[
1048
];
...
@@ -2857,7 +2844,7 @@ You need 6 steps:
...
@@ -2857,7 +2844,7 @@ You need 6 steps:
#ifndef WANT_GSMLIB
#ifndef WANT_GSMLIB
memset
(
mesg_test
,
'\0'
,
sizeof
(
mesg_test
));
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è новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"
);
//let's test the beauty of utf8
//text=mesg_test;
//text=mesg_test;
memset
(
smscommand
,
'\0'
,
sizeof
(
smscommand
));
memset
(
smscommand
,
'\0'
,
sizeof
(
smscommand
));
...
@@ -2922,13 +2909,12 @@ You need 6 steps:
...
@@ -2922,13 +2909,12 @@ You need 6 steps:
UNLOCKA
(
tech_pvt
->
controldev_lock
);
UNLOCKA
(
tech_pvt
->
controldev_lock
);
POPPA_UNLOCKA
(
&
tech_pvt
->
controldev_lock
);
POPPA_UNLOCKA
(
&
tech_pvt
->
controldev_lock
);
}
}
#ifdef NOTDEF
#ifdef NOTDEF
err
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT+CMGF=0"
);
err
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT+CMGF=0"
);
if
(
err
)
{
if
(
err
)
{
DEBUGA_GSMOPEN
(
"AT+CMGF=0 (set message sending to PDU (as opposed to TEXT) do not got OK from the phone, continuing
\n
"
,
GSMOPEN_P_LOG
);
DEBUGA_GSMOPEN
(
"AT+CMGF=0 (set message sending to PDU (as opposed to TEXT) do not got OK from the phone, continuing
\n
"
,
GSMOPEN_P_LOG
);
}
}
#endif// NOTDEF
#endif
// NOTDEF
DEBUGA_GSMOPEN
(
"FINISH
\n
"
,
GSMOPEN_P_LOG
);
DEBUGA_GSMOPEN
(
"FINISH
\n
"
,
GSMOPEN_P_LOG
);
if
(
failed
)
if
(
failed
)
...
...
src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp
浏览文件 @
2431e0f2
...
@@ -867,7 +867,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
...
@@ -867,7 +867,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
//switch_core_timer_next(&tech_pvt->timer_write);
//switch_core_timer_next(&tech_pvt->timer_write);
gsmopen_sound_boost
(
frame
->
data
,
frame
->
samples
,
tech_pvt
->
playback_boost
);
gsmopen_sound_boost
(
frame
->
data
,
frame
->
samples
,
tech_pvt
->
playback_boost
);
if
(
!
tech_pvt
->
no_sound
)
{
if
(
!
tech_pvt
->
no_sound
)
{
sent
=
tech_pvt
->
serialPort_serial_audio
->
Write
((
char
*
)
frame
->
data
,
(
int
)
(
frame
->
datalen
));
sent
=
tech_pvt
->
serialPort_serial_audio
->
Write
((
char
*
)
frame
->
data
,
(
int
)
(
frame
->
datalen
));
if
(
sent
&&
sent
!=
frame
->
datalen
&&
sent
!=
-
1
)
{
if
(
sent
&&
sent
!=
frame
->
datalen
&&
sent
!=
-
1
)
{
...
@@ -926,7 +926,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
...
@@ -926,7 +926,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
case
SWITCH_MESSAGE_INDICATE_ANSWER
:
case
SWITCH_MESSAGE_INDICATE_ANSWER
:
{
{
DEBUGA_GSMOPEN
(
"%s CHANNEL got SWITCH_MESSAGE_INDICATE_ANSWER
\n
"
,
GSMOPEN_P_LOG
,
switch_channel_get_name
(
channel
));
DEBUGA_GSMOPEN
(
"%s CHANNEL got SWITCH_MESSAGE_INDICATE_ANSWER
\n
"
,
GSMOPEN_P_LOG
,
switch_channel_get_name
(
channel
));
if
(
tech_pvt
->
interface_state
!=
GSMOPEN_STATE_UP
&&
tech_pvt
->
phone_callflow
!=
CALLFLOW_CALL_ACTIVE
)
{
if
(
tech_pvt
->
interface_state
!=
GSMOPEN_STATE_UP
&&
tech_pvt
->
phone_callflow
!=
CALLFLOW_CALL_ACTIVE
)
{
DEBUGA_GSMOPEN
(
"MSG_ID=%d, TO BE ANSWERED!
\n
"
,
GSMOPEN_P_LOG
,
msg
->
message_id
);
DEBUGA_GSMOPEN
(
"MSG_ID=%d, TO BE ANSWERED!
\n
"
,
GSMOPEN_P_LOG
,
msg
->
message_id
);
channel_answer_channel
(
session
);
channel_answer_channel
(
session
);
}
}
...
@@ -936,7 +936,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
...
@@ -936,7 +936,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
case
SWITCH_MESSAGE_INDICATE_PROGRESS
:
case
SWITCH_MESSAGE_INDICATE_PROGRESS
:
{
{
DEBUGA_GSMOPEN
(
"%s CHANNEL got SWITCH_MESSAGE_INDICATE_PROGRESS
\n
"
,
GSMOPEN_P_LOG
,
switch_channel_get_name
(
channel
));
DEBUGA_GSMOPEN
(
"%s CHANNEL got SWITCH_MESSAGE_INDICATE_PROGRESS
\n
"
,
GSMOPEN_P_LOG
,
switch_channel_get_name
(
channel
));
if
(
tech_pvt
->
interface_state
!=
GSMOPEN_STATE_UP
&&
tech_pvt
->
phone_callflow
!=
CALLFLOW_CALL_ACTIVE
)
{
if
(
tech_pvt
->
interface_state
!=
GSMOPEN_STATE_UP
&&
tech_pvt
->
phone_callflow
!=
CALLFLOW_CALL_ACTIVE
)
{
DEBUGA_GSMOPEN
(
"MSG_ID=%d, TO BE ANSWERED!
\n
"
,
GSMOPEN_P_LOG
,
msg
->
message_id
);
DEBUGA_GSMOPEN
(
"MSG_ID=%d, TO BE ANSWERED!
\n
"
,
GSMOPEN_P_LOG
,
msg
->
message_id
);
channel_answer_channel
(
session
);
channel_answer_channel
(
session
);
}
}
...
@@ -961,7 +961,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
...
@@ -961,7 +961,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
break
;
break
;
default:
default:
{
{
if
(
msg
->
message_id
!=
SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC
&&
msg
->
message_id
!=
SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE
)
{
if
(
msg
->
message_id
!=
SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC
&&
msg
->
message_id
!=
SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE
)
{
DEBUGA_GSMOPEN
(
"MSG_ID=%d
\n
"
,
GSMOPEN_P_LOG
,
msg
->
message_id
);
DEBUGA_GSMOPEN
(
"MSG_ID=%d
\n
"
,
GSMOPEN_P_LOG
,
msg
->
message_id
);
}
}
}
}
...
@@ -1163,7 +1163,7 @@ static switch_status_t load_config(int reload_type)
...
@@ -1163,7 +1163,7 @@ static switch_status_t load_config(int reload_type)
SetConsoleOutputCP
(
65001
);
SetConsoleOutputCP
(
65001
);
DEBUGA_GSMOPEN
(
"Windows CODEPAGE Output =%d
\n
"
,
GSMOPEN_P_LOG
,
GetConsoleOutputCP
());
DEBUGA_GSMOPEN
(
"Windows CODEPAGE Output =%d
\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
//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
#endif
// WIN32
NOTICA
(
"GSMOPEN Charset Output Test 0 %s
\n
"
,
GSMOPEN_P_LOG
,
"èéòàù"
);
NOTICA
(
"GSMOPEN Charset Output Test 0 %s
\n
"
,
GSMOPEN_P_LOG
,
"èéòàù"
);
NOTICA
(
"GSMOPEN Charset Output Test 1 %s
\n
"
,
GSMOPEN_P_LOG
,
"ç°§^£"
);
NOTICA
(
"GSMOPEN Charset Output Test 1 %s
\n
"
,
GSMOPEN_P_LOG
,
"ç°§^£"
);
NOTICA
(
"GSMOPEN Charset Output Test 2 %s
\n
"
,
GSMOPEN_P_LOG
,
"новости"
);
NOTICA
(
"GSMOPEN Charset Output Test 2 %s
\n
"
,
GSMOPEN_P_LOG
,
"новости"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论