Version 0.1.6 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Mark Spencer 25 years ago
parent e165a9d027
commit 0b9685cc3b

@ -55,6 +55,9 @@ static char language[MAX_LANGUAGE] = "";
/* Initialization String */ /* Initialization String */
static char initstr[AST_MAX_INIT_STR] = "ATE1Q0"; static char initstr[AST_MAX_INIT_STR] = "ATE1Q0";
/* Default MSN */
static char msn[AST_MAX_EXTENSION]="";
static int usecnt =0; static int usecnt =0;
static int baudrate = 115200; static int baudrate = 115200;
@ -348,6 +351,7 @@ static int modem_setup(struct ast_modem_pvt *p, int baudrate)
static int modem_hangup(struct ast_channel *ast) static int modem_hangup(struct ast_channel *ast)
{ {
struct ast_modem_pvt *p; struct ast_modem_pvt *p;
if (option_debug)
ast_log(LOG_DEBUG, "modem_hangup(%s)\n", ast->name); ast_log(LOG_DEBUG, "modem_hangup(%s)\n", ast->name);
p = ast->pvt->pvt; p = ast->pvt->pvt;
/* Hang up */ /* Hang up */
@ -377,7 +381,8 @@ static int modem_answer(struct ast_channel *ast)
{ {
struct ast_modem_pvt *p; struct ast_modem_pvt *p;
int res=0; int res=0;
ast_log(LOG_DEBUG, "modem_hangup(%s)\n", ast->name); if (option_debug)
ast_log(LOG_DEBUG, "modem_answer(%s)\n", ast->name);
p = ast->pvt->pvt; p = ast->pvt->pvt;
if (p->mc->answer) { if (p->mc->answer) {
res = p->mc->answer(p); res = p->mc->answer(p);
@ -467,7 +472,6 @@ static void modem_mini_packet(struct ast_modem_pvt *i)
if (fr->frametype == AST_FRAME_CONTROL) { if (fr->frametype == AST_FRAME_CONTROL) {
if (fr->subclass == AST_CONTROL_RING) { if (fr->subclass == AST_CONTROL_RING) {
ast_modem_new(i, AST_STATE_RING); ast_modem_new(i, AST_STATE_RING);
restart_monitor();
} }
} }
} }
@ -590,6 +594,21 @@ static int restart_monitor()
return 0; return 0;
} }
static void stty(struct ast_modem_pvt *p)
{
struct termios mode;
memset(&mode, 0, sizeof(mode));
if (tcgetattr(p->fd, &mode)) {
ast_log(LOG_WARNING, "Unable to get serial parameters on %s: %s\n", p->dev, strerror(errno));
return;
}
cfmakeraw(&mode);
cfsetspeed(&mode, B115200);
if (tcsetattr(p->fd, TCSANOW, &mode))
ast_log(LOG_WARNING, "Unable to set serial parameters on %s: %s\n", p->dev, strerror(errno));
}
static struct ast_modem_pvt *mkif(char *iface) static struct ast_modem_pvt *mkif(char *iface)
{ {
/* Make a ast_modem_pvt structure for this interface */ /* Make a ast_modem_pvt structure for this interface */
@ -599,6 +618,7 @@ static struct ast_modem_pvt *mkif(char *iface)
#endif #endif
tmp = malloc(sizeof(struct ast_modem_pvt)); tmp = malloc(sizeof(struct ast_modem_pvt));
memset(tmp, 0, sizeof(struct ast_modem_pvt));
if (tmp) { if (tmp) {
tmp->fd = open(iface, O_RDWR | O_NONBLOCK); tmp->fd = open(iface, O_RDWR | O_NONBLOCK);
if (tmp->fd < 0) { if (tmp->fd < 0) {
@ -607,6 +627,11 @@ static struct ast_modem_pvt *mkif(char *iface)
return NULL; return NULL;
} }
strncpy(tmp->language, language, sizeof(tmp->language)); strncpy(tmp->language, language, sizeof(tmp->language));
strncpy(tmp->msn, msn, sizeof(tmp->msn));
strncpy(tmp->dev, iface, sizeof(tmp->dev));
/* Maybe in the future we want to allow variable
serial settings */
stty(tmp);
tmp->f = fdopen(tmp->fd, "w+"); tmp->f = fdopen(tmp->fd, "w+");
/* Disable buffering */ /* Disable buffering */
setvbuf(tmp->f, NULL, _IONBF,0); setvbuf(tmp->f, NULL, _IONBF,0);
@ -625,7 +650,6 @@ static struct ast_modem_pvt *mkif(char *iface)
tmp->dialtype = dialtype; tmp->dialtype = dialtype;
tmp->mode = gmode; tmp->mode = gmode;
memset(tmp->cid, 0, sizeof(tmp->cid)); memset(tmp->cid, 0, sizeof(tmp->cid));
strncpy(tmp->dev, iface, sizeof(tmp->dev));
strncpy(tmp->context, context, sizeof(tmp->context)); strncpy(tmp->context, context, sizeof(tmp->context));
strncpy(tmp->initstr, initstr, sizeof(tmp->initstr)); strncpy(tmp->initstr, initstr, sizeof(tmp->initstr));
tmp->next = NULL; tmp->next = NULL;
@ -743,13 +767,16 @@ int load_module()
dialtype = toupper(v->value[0]); dialtype = toupper(v->value[0]);
} else if (!strcasecmp(v->name, "context")) { } else if (!strcasecmp(v->name, "context")) {
strncpy(context, v->value, sizeof(context)); strncpy(context, v->value, sizeof(context));
} else if (!strcasecmp(v->name, "msn")) {
strncpy(msn, v->value, sizeof(msn));
} else if (!strcasecmp(v->name, "language")) { } else if (!strcasecmp(v->name, "language")) {
strncpy(language, v->value, sizeof(language)); strncpy(language, v->value, sizeof(language));
} }
v = v->next; v = v->next;
} }
pthread_mutex_unlock(&iflock); pthread_mutex_unlock(&iflock);
if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */ AST_FORMAT_SLINEAR, modem_request)) { if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */
AST_FORMAT_SLINEAR, modem_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type); ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
ast_destroy(cfg); ast_destroy(cfg);
unload_module(); unload_module();

@ -19,6 +19,7 @@
#define CHAR_DLE 0x10 #define CHAR_DLE 0x10
#define CHAR_ETX 0x03 #define CHAR_ETX 0x03
#define CHAR_DC4 0x14
#define MODEM_DEV_TELCO 0 #define MODEM_DEV_TELCO 0
#define MODEM_DEV_TELCO_SPK 4 #define MODEM_DEV_TELCO_SPK 4
@ -76,8 +77,11 @@ struct ast_modem_pvt {
int mode; /* Immediate, or wait for an answer */ int mode; /* Immediate, or wait for an answer */
int ministate; /* State of modem in miniature */ int ministate; /* State of modem in miniature */
int stripmsd; /* Digits to strip on outgoing numbers */ int stripmsd; /* Digits to strip on outgoing numbers */
int escape; /* Is the last thing we saw an escape */
char context[AST_MAX_EXTENSION]; char context[AST_MAX_EXTENSION];
char msn[AST_MAX_EXTENSION]; /* Multiple Subscriber Number */
char cid[AST_MAX_EXTENSION]; /* Caller ID if available */ char cid[AST_MAX_EXTENSION]; /* Caller ID if available */
char dnid[AST_MAX_EXTENSION]; /* Dialed Number if available */
char initstr[AST_MAX_INIT_STR]; /* Modem initialization String */ char initstr[AST_MAX_INIT_STR]; /* Modem initialization String */
char language[MAX_LANGUAGE]; /* default language */ char language[MAX_LANGUAGE]; /* default language */
char response[256]; /* Static response buffer */ char response[256]; /* Static response buffer */

Loading…
Cancel
Save