mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-26 04:27:25 +00:00
gsmopen: cleaning a little
This commit is contained in:
parent
8c7a624d0c
commit
fc4c61570b
@ -4,8 +4,6 @@ SVNDEF := -D'GSMOPEN_SVN_VERSION="$(shell svnversion -n .)"'
|
|||||||
LOCAL_CFLAGS += $(SVNDEF) -DNO_GSMLIB -DNO_ALSA -I../../../../libs/spandsp/src -I../../../..//libs/tiff-3.8.2/libtiff
|
LOCAL_CFLAGS += $(SVNDEF) -DNO_GSMLIB -DNO_ALSA -I../../../../libs/spandsp/src -I../../../..//libs/tiff-3.8.2/libtiff
|
||||||
#LOCAL_LDFLAGS=-lasound -L/usr/src/gsmlib-1.10/gsmlib/.libs -lgsmme
|
#LOCAL_LDFLAGS=-lasound -L/usr/src/gsmlib-1.10/gsmlib/.libs -lgsmme
|
||||||
LOCAL_LDFLAGS=-L../../../../libs/spandsp/src -lspandsp -lctb-0.16
|
LOCAL_LDFLAGS=-L../../../../libs/spandsp/src -lspandsp -lctb-0.16
|
||||||
|
|
||||||
LOCAL_OBJS=gsmopen_protocol.o
|
LOCAL_OBJS=gsmopen_protocol.o
|
||||||
#OUR_OBJS += /usr/src/gsmlib-1.10/gsmlib/libgsmme.la
|
#OUR_OBJS += /usr/src/gsmlib-1.10/gsmlib/libgsmme.la
|
||||||
#OUR_OBJS += libctb-0.16/lib/libctbd-0.16.a
|
|
||||||
include ../../../../build/modmake.rules
|
include ../../../../build/modmake.rules
|
||||||
|
@ -137,15 +137,6 @@
|
|||||||
|
|
||||||
#include "ctb-0.16/ctb.h"
|
#include "ctb-0.16/ctb.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TFLAG_IO = (1 << 0),
|
TFLAG_IO = (1 << 0),
|
||||||
TFLAG_INBOUND = (1 << 1),
|
TFLAG_INBOUND = (1 << 1),
|
||||||
@ -525,18 +516,11 @@ struct private_object {
|
|||||||
int network_creg_not_supported;
|
int network_creg_not_supported;
|
||||||
char creg[128];
|
char creg[128];
|
||||||
|
|
||||||
char controldevice_audio_name[50]; /*!< \brief name of the serial device controlling the interface, possibly none */
|
char controldevice_audio_name[50];
|
||||||
int controldev_audio_fd; /*!< \brief serial controlling file descriptor for this interface */
|
int controldev_audio_fd;
|
||||||
//pthread_t controldev_thread; /*!< \brief serial control thread for this interface, running during the call */
|
|
||||||
#ifdef WIN32
|
|
||||||
int controldevice_audio_speed;
|
int controldevice_audio_speed;
|
||||||
#else
|
|
||||||
speed_t controldevice_audio_speed;
|
|
||||||
#endif// WIN32
|
|
||||||
int controldev_audio_dead;
|
int controldev_audio_dead;
|
||||||
switch_mutex_t *controldev_audio_lock;
|
switch_mutex_t *controldev_audio_lock;
|
||||||
|
|
||||||
ctb::IOBase* device_serial_audio;
|
|
||||||
ctb::SerialPort* serialPort_serial_audio;
|
ctb::SerialPort* serialPort_serial_audio;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -4051,205 +4051,17 @@ int gsmopen_serial_getstatus_AT(private_t * tech_pvt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int oldgsmopen_serial_init_audio_port(private_t * tech_pvt, speed_t controldevice_audio_speed)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
int rt;
|
|
||||||
struct termios tp;
|
|
||||||
unsigned int status = 0;
|
|
||||||
unsigned int flags = TIOCM_DTR;
|
|
||||||
|
|
||||||
/* if there is a file descriptor, close it. But it is probably just an old value, so don't check for close success*/
|
|
||||||
fd = tech_pvt->controldev_audio_fd;
|
|
||||||
if (fd) {
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
/* open the serial port */
|
|
||||||
//#ifdef __CYGWIN__
|
|
||||||
fd = open(tech_pvt->controldevice_audio_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
|
||||||
sleep(1);
|
|
||||||
close(fd);
|
|
||||||
//#endif /* __CYGWIN__ */
|
|
||||||
fd = open(tech_pvt->controldevice_audio_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
|
||||||
if (fd == -1) {
|
|
||||||
perror("AUDIO open error ");
|
|
||||||
DEBUGA_GSMOPEN("AUDIO serial error: %s\n", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
tech_pvt->controldev_audio_fd = fd;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* flush it */
|
|
||||||
rt = tcflush(fd, TCIFLUSH);
|
|
||||||
if (rt == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
}
|
|
||||||
/* attributes */
|
|
||||||
tp.c_cflag = B0 | CS8 | CLOCAL | CREAD | HUPCL;
|
|
||||||
tp.c_iflag = IGNPAR;
|
|
||||||
tp.c_cflag &= ~CRTSCTS;
|
|
||||||
tp.c_oflag = 0;
|
|
||||||
tp.c_lflag = 0;
|
|
||||||
tp.c_cc[VMIN] = 1;
|
|
||||||
tp.c_cc[VTIME] = 0;
|
|
||||||
/* set controldevice_audio_speed */
|
|
||||||
rt = cfsetispeed(&tp, tech_pvt->controldevice_audio_speed);
|
|
||||||
if (rt == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s, speed was: %d", GSMOPEN_P_LOG, strerror(errno), tech_pvt->controldevice_audio_speed);
|
|
||||||
}
|
|
||||||
rt = cfsetospeed(&tp, tech_pvt->controldevice_audio_speed);
|
|
||||||
if (rt == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
}
|
|
||||||
/* set port attributes */
|
|
||||||
if (tcsetattr(fd, TCSADRAIN, &tp) == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
}
|
|
||||||
rt = tcsetattr(fd, TCSANOW, &tp);
|
|
||||||
if (rt == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
}
|
|
||||||
#ifndef __CYGWIN__
|
|
||||||
ioctl(fd, TIOCMGET, &status);
|
|
||||||
status |= TIOCM_DTR; /* Set DTR high */
|
|
||||||
status &= ~TIOCM_RTS; /* Set RTS low */
|
|
||||||
ioctl(fd, TIOCMSET, &status);
|
|
||||||
ioctl(fd, TIOCMGET, &status);
|
|
||||||
ioctl(fd, TIOCMBIS, &flags);
|
|
||||||
flags = TIOCM_RTS;
|
|
||||||
ioctl(fd, TIOCMBIC, &flags);
|
|
||||||
ioctl(fd, TIOCMGET, &status);
|
|
||||||
#else /* __CYGWIN__ */
|
|
||||||
ioctl(fd, TIOCMGET, &status);
|
|
||||||
status |= TIOCM_DTR; /* Set DTR high */
|
|
||||||
status &= ~TIOCM_RTS; /* Set RTS low */
|
|
||||||
ioctl(fd, TIOCMSET, &status);
|
|
||||||
#endif /* __CYGWIN__ */
|
|
||||||
tech_pvt->controldev_audio_fd = fd;
|
|
||||||
|
|
||||||
return (fd);
|
|
||||||
}
|
|
||||||
int old_serial_audio_init(private_t * tech_pvt)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
res=gsmopen_serial_init_audio_port(tech_pvt, tech_pvt->controldevice_audio_speed);
|
|
||||||
ERRORA("serial_audio_init res=%d\n", GSMOPEN_P_LOG, res);
|
|
||||||
|
|
||||||
if(res > 0)
|
|
||||||
err=0;
|
|
||||||
else
|
|
||||||
err=1;
|
|
||||||
|
|
||||||
|
|
||||||
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT^DDSETEX=2");
|
|
||||||
if (res) {
|
|
||||||
ERRORA("at_hangup command failed, command used: 'AT^DDSETEX=2'\n", GSMOPEN_P_LOG);
|
|
||||||
//return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
int gsmopen_serial_init_audio_port(private_t * tech_pvt, speed_t controldevice_audio_speed)
|
int gsmopen_serial_init_audio_port(private_t * tech_pvt, speed_t controldevice_audio_speed)
|
||||||
{
|
{
|
||||||
|
|
||||||
//#ifdef NOTDEF
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
tech_pvt->device_serial_audio = NULL;
|
|
||||||
tech_pvt->serialPort_serial_audio = new ctb::SerialPort();
|
tech_pvt->serialPort_serial_audio = new ctb::SerialPort();
|
||||||
|
|
||||||
if( tech_pvt->serialPort_serial_audio->Open( "/dev/ttyUSB2", 115200, "8N1", ctb::SerialPort::NoFlowControl ) >= 0 ) {
|
if( tech_pvt->serialPort_serial_audio->Open( "/dev/ttyUSB2", 115200, "8N1", ctb::SerialPort::NoFlowControl ) >= 0 ) {
|
||||||
|
|
||||||
//tech_pvt->device_serial_audio = tech_pvt->serialPort_serial_audio;
|
|
||||||
ERRORA("port SUCCESS open\n", GSMOPEN_P_LOG);
|
ERRORA("port SUCCESS open\n", GSMOPEN_P_LOG);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ERRORA("port NOT open\n", GSMOPEN_P_LOG);
|
ERRORA("port NOT open\n", GSMOPEN_P_LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
//#endif// NOTDEF
|
|
||||||
|
|
||||||
#ifdef NOTDEF
|
|
||||||
|
|
||||||
|
|
||||||
int fd;
|
|
||||||
int rt;
|
|
||||||
struct termios tp;
|
|
||||||
unsigned int status = 0;
|
|
||||||
unsigned int flags = TIOCM_DTR;
|
|
||||||
|
|
||||||
/* if there is a file descriptor, close it. But it is probably just an old value, so don't check for close success*/
|
|
||||||
fd = tech_pvt->controldev_audio_fd;
|
|
||||||
if (fd) {
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
/* open the serial port */
|
|
||||||
//#ifdef __CYGWIN__
|
|
||||||
fd = open(tech_pvt->controldevice_audio_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
|
||||||
sleep(1);
|
|
||||||
close(fd);
|
|
||||||
//#endif /* __CYGWIN__ */
|
|
||||||
fd = open(tech_pvt->controldevice_audio_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
|
||||||
if (fd == -1) {
|
|
||||||
perror("AUDIO open error ");
|
|
||||||
DEBUGA_GSMOPEN("AUDIO serial error: %s\n", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
tech_pvt->controldev_audio_fd = fd;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* flush it */
|
|
||||||
rt = tcflush(fd, TCIFLUSH);
|
|
||||||
if (rt == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
}
|
|
||||||
/* attributes */
|
|
||||||
tp.c_cflag = B0 | CS8 | CLOCAL | CREAD | HUPCL;
|
|
||||||
tp.c_iflag = IGNPAR;
|
|
||||||
tp.c_cflag &= ~CRTSCTS;
|
|
||||||
tp.c_oflag = 0;
|
|
||||||
tp.c_lflag = 0;
|
|
||||||
tp.c_cc[VMIN] = 1;
|
|
||||||
tp.c_cc[VTIME] = 0;
|
|
||||||
/* set controldevice_audio_speed */
|
|
||||||
rt = cfsetispeed(&tp, tech_pvt->controldevice_audio_speed);
|
|
||||||
if (rt == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s, speed was: %d", GSMOPEN_P_LOG, strerror(errno), tech_pvt->controldevice_audio_speed);
|
|
||||||
}
|
|
||||||
rt = cfsetospeed(&tp, tech_pvt->controldevice_audio_speed);
|
|
||||||
if (rt == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
}
|
|
||||||
/* set port attributes */
|
|
||||||
if (tcsetattr(fd, TCSADRAIN, &tp) == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
}
|
|
||||||
rt = tcsetattr(fd, TCSANOW, &tp);
|
|
||||||
if (rt == -1) {
|
|
||||||
ERRORA("AUDIO serial error: %s", GSMOPEN_P_LOG, strerror(errno));
|
|
||||||
}
|
|
||||||
#ifndef __CYGWIN__
|
|
||||||
ioctl(fd, TIOCMGET, &status);
|
|
||||||
status |= TIOCM_DTR; /* Set DTR high */
|
|
||||||
status &= ~TIOCM_RTS; /* Set RTS low */
|
|
||||||
ioctl(fd, TIOCMSET, &status);
|
|
||||||
ioctl(fd, TIOCMGET, &status);
|
|
||||||
ioctl(fd, TIOCMBIS, &flags);
|
|
||||||
flags = TIOCM_RTS;
|
|
||||||
ioctl(fd, TIOCMBIC, &flags);
|
|
||||||
ioctl(fd, TIOCMGET, &status);
|
|
||||||
#else /* __CYGWIN__ */
|
|
||||||
ioctl(fd, TIOCMGET, &status);
|
|
||||||
status |= TIOCM_DTR; /* Set DTR high */
|
|
||||||
status &= ~TIOCM_RTS; /* Set RTS low */
|
|
||||||
ioctl(fd, TIOCMSET, &status);
|
|
||||||
#endif /* __CYGWIN__ */
|
|
||||||
tech_pvt->controldev_audio_fd = fd;
|
|
||||||
|
|
||||||
return (fd);
|
|
||||||
#endif //NOTDEF
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int serial_audio_init(private_t * tech_pvt)
|
int serial_audio_init(private_t * tech_pvt)
|
||||||
@ -4273,17 +4085,10 @@ int serial_audio_shutdown(private_t * tech_pvt)
|
|||||||
int res;
|
int res;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
//res = close(tech_pvt->controldev_audio_fd);
|
|
||||||
res = tech_pvt->serialPort_serial_audio->Close();
|
res = tech_pvt->serialPort_serial_audio->Close();
|
||||||
ERRORA("serial_audio_shutdown res=%d (controldev_audio_fd is %d)\n", GSMOPEN_P_LOG, res, tech_pvt->controldev_audio_fd);
|
ERRORA("serial_audio_shutdown res=%d (controldev_audio_fd is %d)\n", GSMOPEN_P_LOG, res, tech_pvt->controldev_audio_fd);
|
||||||
tech_pvt->controldev_audio_fd = -1;
|
|
||||||
|
|
||||||
err = res;
|
err = res;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
#ifdef GSMOPEN_ALSA
|
|
||||||
int alsa_init(private_t * tech_pvt);
|
|
||||||
int alsa_shutdown(private_t * tech_pvt);
|
|
||||||
snd_pcm_t *alsa_open_dev(private_t * tech_pvt, snd_pcm_stream_t stream);
|
|
||||||
int alsa_write(private_t * tech_pvt, short *data, int datalen);
|
|
||||||
int alsa_read(private_t * tech_pvt, short *data, int datalen);
|
|
||||||
|
|
||||||
#endif /* GSMOPEN_ALSA */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||||
* Copyright (C) 2005/2011, Anthony Minessale II <anthm@freeswitch.org>
|
* Copyright (C) 2005/2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||||
@ -869,11 +860,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
switch_core_timer_next(&tech_pvt->timer_read);
|
switch_core_timer_next(&tech_pvt->timer_read);
|
||||||
#endif// GSMOPEN_PORTAUDIO
|
#endif// GSMOPEN_PORTAUDIO
|
||||||
|
|
||||||
//goto cng;
|
|
||||||
if(tech_pvt->no_sound==1){
|
if(tech_pvt->no_sound==1){
|
||||||
goto cng;
|
goto cng;
|
||||||
}
|
}
|
||||||
//#if defined(GSMOPEN_ALSA) || defined(GSMOPEN_PORTAUDIO)
|
|
||||||
#ifdef GSMOPEN_ALSA
|
#ifdef GSMOPEN_ALSA
|
||||||
//if ((samples = snd_pcm_readi(tech_pvt->alsac, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
|
//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)
|
||||||
@ -882,8 +871,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
if ((samples = gsmopen_portaudio_read(tech_pvt, (short *) tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
|
if ((samples = gsmopen_portaudio_read(tech_pvt, (short *) tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
|
||||||
#endif// GSMOPEN_PORTAUDIO
|
#endif// GSMOPEN_PORTAUDIO
|
||||||
|
|
||||||
//sent = write(tech_pvt->controldev_audio_fd, (short *) frame->data, (int) (frame->datalen));
|
|
||||||
//if ((samples = read(tech_pvt->controldev_audio_fd, (short *) tech_pvt->read_frame.data, 320)) >0)
|
|
||||||
if ((samples = tech_pvt->serialPort_serial_audio->Read((char *) tech_pvt->read_frame.data, 320)) >0)
|
if ((samples = tech_pvt->serialPort_serial_audio->Read((char *) tech_pvt->read_frame.data, 320)) >0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -914,7 +901,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//tech_pvt->read_frame.datalen = samples * 2;
|
|
||||||
tech_pvt->read_frame.datalen = samples;
|
tech_pvt->read_frame.datalen = samples;
|
||||||
tech_pvt->read_frame.samples = samples/2;
|
tech_pvt->read_frame.samples = samples/2;
|
||||||
|
|
||||||
@ -924,7 +910,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
|
|
||||||
*frame = &tech_pvt->read_frame;
|
*frame = &tech_pvt->read_frame;
|
||||||
|
|
||||||
//if ((samples2 = read(tech_pvt->controldev_audio_fd, (short *) buffer2, 320)) >0){
|
|
||||||
if ((samples2 = tech_pvt->serialPort_serial_audio->Read((char *) tech_pvt->read_frame.data, 320)) >0){
|
if ((samples2 = tech_pvt->serialPort_serial_audio->Read((char *) tech_pvt->read_frame.data, 320)) >0){
|
||||||
WARNINGA("samples2=%d\n", GSMOPEN_P_LOG, samples2);
|
WARNINGA("samples2=%d\n", GSMOPEN_P_LOG, samples2);
|
||||||
|
|
||||||
@ -935,7 +920,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
|
|
||||||
//WARNINGA("samples=%d\n", GSMOPEN_P_LOG, samples);
|
//WARNINGA("samples=%d\n", GSMOPEN_P_LOG, samples);
|
||||||
if (samples != 320) {
|
if (samples != 320) {
|
||||||
//DEBUGA_GSMOPEN("samples=%d\n", GSMOPEN_P_LOG, samples);
|
DEBUGA_GSMOPEN("samples=%d\n", GSMOPEN_P_LOG, samples);
|
||||||
goto cng;
|
goto cng;
|
||||||
}
|
}
|
||||||
//DEBUGA_GSMOPEN("samples=%d tech_pvt->read_frame.timestamp=%d\n", GSMOPEN_P_LOG, samples, tech_pvt->read_frame.timestamp);
|
//DEBUGA_GSMOPEN("samples=%d tech_pvt->read_frame.timestamp=%d\n", GSMOPEN_P_LOG, samples, tech_pvt->read_frame.timestamp);
|
||||||
@ -945,8 +930,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#ifdef NOTDEF
|
|
||||||
|
|
||||||
memset(digit_str, 0, sizeof(digit_str));
|
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));
|
//teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
|
||||||
@ -973,7 +956,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
|
tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//#endif //NOTDEF
|
|
||||||
while (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
while (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
|
if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
|
||||||
switch_clear_flag(tech_pvt, TFLAG_BREAK);
|
switch_clear_flag(tech_pvt, TFLAG_BREAK);
|
||||||
@ -1010,7 +992,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
|
|
||||||
DEBUGA_GSMOPEN("CHANNEL READ FALSE\n", GSMOPEN_P_LOG);
|
DEBUGA_GSMOPEN("CHANNEL READ FALSE\n", GSMOPEN_P_LOG);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
//#endif // defined(GSMOPEN_ALSA) || defined(GSMOPEN_PORTAUDIO)
|
|
||||||
cng:
|
cng:
|
||||||
data = (switch_byte_t *) tech_pvt->read_frame.data;
|
data = (switch_byte_t *) tech_pvt->read_frame.data;
|
||||||
data[0] = 65;
|
data[0] = 65;
|
||||||
@ -1096,8 +1077,6 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
|||||||
#endif // GSMOPEN_PORTAUDIO
|
#endif // GSMOPEN_PORTAUDIO
|
||||||
|
|
||||||
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));
|
||||||
//sent = write(tech_pvt->controldev_audio_fd, (short *) frame->data, (int) (frame->datalen));
|
|
||||||
//DEBUGA_GSMOPEN("sent=%d \n", GSMOPEN_P_LOG, sent);
|
|
||||||
|
|
||||||
if (sent && sent != frame->datalen && sent != -1) {
|
if (sent && sent != frame->datalen && sent != -1) {
|
||||||
DEBUGA_GSMOPEN("sent %d\n", GSMOPEN_P_LOG, sent);
|
DEBUGA_GSMOPEN("sent %d\n", GSMOPEN_P_LOG, sent);
|
||||||
@ -2057,49 +2036,6 @@ static switch_status_t load_config(int reload_type)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NOTDEF
|
|
||||||
/* init the serial port */
|
|
||||||
if (globals.GSMOPEN_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
|
|
||||||
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);
|
|
||||||
//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");
|
|
||||||
globals.GSMOPEN_INTERFACES[interface_id].active=0;
|
|
||||||
globals.GSMOPEN_INTERFACES[interface_id].name[0]='\0';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* config the phone/modem on the serial port */
|
|
||||||
if (globals.GSMOPEN_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
|
|
||||||
res = gsmopen_serial_config(&globals.GSMOPEN_INTERFACES[interface_id]);
|
|
||||||
if (res) {
|
|
||||||
int count = 0;
|
|
||||||
ERRORA("gsmopen_serial_config failed, let's try again\n", GSMOPEN_P_LOG);
|
|
||||||
while(res && count < 5){
|
|
||||||
switch_sleep(100000); //0.1 seconds
|
|
||||||
res = gsmopen_serial_config(&globals.GSMOPEN_INTERFACES[interface_id]);
|
|
||||||
count++;
|
|
||||||
if (res) {
|
|
||||||
ERRORA("%d: gsmopen_serial_config failed, let's try again\n", GSMOPEN_P_LOG, count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res) {
|
|
||||||
ERRORA("STARTING interface_id=%d 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");
|
|
||||||
globals.GSMOPEN_INTERFACES[interface_id].active=0;
|
|
||||||
globals.GSMOPEN_INTERFACES[interface_id].name[0]='\0';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif// NOTDEF
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2155,33 +2091,6 @@ static switch_status_t load_config(int reload_type)
|
|||||||
#endif// GSMOPEN_PORTAUDIO
|
#endif// GSMOPEN_PORTAUDIO
|
||||||
DEBUGA_GSMOPEN("gsmopen_serial_sync_period=%d\n", GSMOPEN_P_LOG, (int)globals.GSMOPEN_INTERFACES[i].gsmopen_serial_sync_period);
|
DEBUGA_GSMOPEN("gsmopen_serial_sync_period=%d\n", GSMOPEN_P_LOG, (int)globals.GSMOPEN_INTERFACES[i].gsmopen_serial_sync_period);
|
||||||
DEBUGA_GSMOPEN("controldevice_audio_name=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[i].controldevice_audio_name);
|
DEBUGA_GSMOPEN("controldevice_audio_name=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[i].controldevice_audio_name);
|
||||||
/***********************************/
|
|
||||||
#ifdef NOTDEF
|
|
||||||
|
|
||||||
ctb::IOBase* device = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
ctb::SerialPort* serialPort = new ctb::SerialPort();
|
|
||||||
|
|
||||||
//if( serialPort->Open( devname.c_str(), baudrate,
|
|
||||||
if( serialPort->Open( "/dev/ttyUSB3", 115200, "8N1", ctb::SerialPort::NoFlowControl ) >= 0 ) {
|
|
||||||
|
|
||||||
device = serialPort;
|
|
||||||
|
|
||||||
if( device->Write( "AT+CLAC\r\n", 9 ) != 7 ) {
|
|
||||||
|
|
||||||
ERRORA("BIZARRE\n", GSMOPEN_P_LOG);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ERRORA("port NOT open\n", GSMOPEN_P_LOG);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif// NOTDEF
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user