aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2002-11-29 02:14:13 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2002-11-29 02:14:13 +0000
commit69399315991bf7f9679e2d9b22f42415653cfc04 (patch)
treee3349bbc37c69394a11f4358e9af9f7a5d2a2329 /channels
parent2d459a804c0512bbceafe63a934770c2aa3f5edd (diff)
Version 0.3.0 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@556 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_alsa.c16
-rwxr-xr-xchannels/chan_modem_aopen.c4
-rwxr-xr-xchannels/chan_modem_bestdata.c4
-rwxr-xr-xchannels/chan_modem_i4l.c87
-rwxr-xr-xchannels/chan_phone.c7
5 files changed, 79 insertions, 39 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 3e35a821f..225c8ba74 100755
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -646,7 +646,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
f.frametype = AST_FRAME_NULL;
f.subclass = 0;
- f.timelen = 0;
+ f.samples = 0;
f.datalen = 0;
f.data = NULL;
f.offset = 0;
@@ -728,7 +728,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
}
f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_SLINEAR;
- f.timelen = FRAME_SIZE / 8;
+ f.samples = FRAME_SIZE;
f.datalen = FRAME_SIZE * 2;
f.data = buf;
f.offset = AST_FRIENDLY_OFFSET;
@@ -905,8 +905,8 @@ static char sendtext_usage[] =
static int console_sendtext(int fd, int argc, char *argv[])
{
- int tmparg = 1;
- if (argc < 1)
+ int tmparg = 2;
+ if (argc < 2)
return RESULT_SHOWUSAGE;
if (!alsa.owner) {
ast_cli(fd, "No one is calling us\n");
@@ -968,9 +968,11 @@ static int console_dial(int fd, int argc, char *argv[])
mye = exten;
myc = context;
if (argc == 2) {
+ char *stringp=NULL;
strncpy(tmp, argv[1], sizeof(tmp)-1);
- strtok(tmp, "@");
- tmp2 = strtok(NULL, "@");
+ stringp=tmp;
+ strsep(&stringp, "@");
+ tmp2 = strsep(&stringp, "@");
if (strlen(tmp))
mye = tmp;
if (tmp2 && strlen(tmp2))
@@ -995,7 +997,7 @@ static struct ast_cli_entry myclis[] = {
{ { "answer", NULL }, console_answer, "Answer an incoming console call", answer_usage },
{ { "hangup", NULL }, console_hangup, "Hangup a call on the console", hangup_usage },
{ { "dial", NULL }, console_dial, "Dial an extension on the console", dial_usage },
- { { "send text", NULL }, console_sendtext, "Send text to the remote device", sendtext_usage },
+ { { "send", "text", NULL }, console_sendtext, "Send text to the remote device", sendtext_usage },
{ { "autoanswer", NULL }, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete }
};
diff --git a/channels/chan_modem_aopen.c b/channels/chan_modem_aopen.c
index b33ce074c..a838671de 100755
--- a/channels/chan_modem_aopen.c
+++ b/channels/chan_modem_aopen.c
@@ -187,7 +187,7 @@ static struct ast_frame *aopen_handle_escape(struct ast_modem_pvt *p, char esc)
p->fr.subclass = 0;
p->fr.data = NULL;
p->fr.datalen = 0;
- p->fr.timelen = 0;
+ p->fr.samples = 0;
p->fr.offset = 0;
p->fr.mallocd = 0;
if (esc)
@@ -315,7 +315,7 @@ static struct ast_frame *aopen_read(struct ast_modem_pvt *p)
/* If we get here, we have a complete voice frame */
p->fr.frametype = AST_FRAME_VOICE;
p->fr.subclass = AST_FORMAT_SLINEAR;
- p->fr.timelen = 30;
+ p->fr.samples = 240;
p->fr.data = p->obuf;
p->fr.datalen = p->obuflen;
p->fr.mallocd = 0;
diff --git a/channels/chan_modem_bestdata.c b/channels/chan_modem_bestdata.c
index 08a1c2e89..7ec76aa5e 100755
--- a/channels/chan_modem_bestdata.c
+++ b/channels/chan_modem_bestdata.c
@@ -160,7 +160,7 @@ static struct ast_frame *bestdata_handle_escape(struct ast_modem_pvt *p, char es
p->fr.subclass = 0;
p->fr.data = NULL;
p->fr.datalen = 0;
- p->fr.timelen = 0;
+ p->fr.samples = 0;
p->fr.offset = 0;
p->fr.mallocd = 0;
if (esc)
@@ -364,7 +364,7 @@ static struct ast_frame *bestdata_read(struct ast_modem_pvt *p)
/* If we get here, we have a complete voice frame */
p->fr.frametype = AST_FRAME_VOICE;
p->fr.subclass = AST_FORMAT_SLINEAR;
- p->fr.timelen = 30;
+ p->fr.samples = 240;
p->fr.data = p->obuf;
p->fr.datalen = p->obuflen;
p->fr.mallocd = 0;
diff --git a/channels/chan_modem_i4l.c b/channels/chan_modem_i4l.c
index 553f144ee..18b5a5039 100755
--- a/channels/chan_modem_i4l.c
+++ b/channels/chan_modem_i4l.c
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
+#include <sys/ioctl.h>
#include <asterisk/lock.h>
#include <asterisk/vmodem.h>
#include <asterisk/module.h>
@@ -151,11 +152,37 @@ static int i4l_init(struct ast_modem_pvt *p)
return -1;
}
}
+ if (strlen(p->incomingmsn)) {
+ char *q;
+ snprintf(cmd, sizeof(cmd), "AT&L%s", p->incomingmsn);
+ // translate , into ; since that is the seperator I4L uses, but can't be directly
+ // put in the config file because it will interpret the rest of the line as comment.
+ q = cmd+4;
+ while (*q) {
+ if (*q == ',') *q = ';';
+ ++q;
+ }
+ if (ast_modem_send(p, cmd, 0) ||
+ ast_modem_expect(p, "OK", 5)) {
+ ast_log(LOG_WARNING, "Unable to set Listen to %s\n", p->msn);
+ return -1;
+ }
+ }
+ if (ast_modem_send(p, "AT&D2", 0) ||
+ ast_modem_expect(p, "OK", 5)) {
+ ast_log(LOG_WARNING, "Unable to set to DTR disconnect mode\n");
+ return -1;
+ }
if (ast_modem_send(p, "ATS18=1", 0) ||
ast_modem_expect(p, "OK", 5)) {
ast_log(LOG_WARNING, "Unable to set to audio only mode\n");
return -1;
}
+ if (ast_modem_send(p, "ATS13.6=1", 0) ||
+ ast_modem_expect(p, "OK", 5)) {
+ ast_log(LOG_WARNING, "Unable to set to RUNG indication\n");
+ return -1;
+ }
if (ast_modem_send(p, "ATS14=4", 0) ||
ast_modem_expect(p, "OK", 5)) {
ast_log(LOG_WARNING, "Unable to set to transparent mode\n");
@@ -189,7 +216,7 @@ static struct ast_frame *i4l_handle_escape(struct ast_modem_pvt *p, char esc)
p->fr.subclass = 0;
p->fr.data = NULL;
p->fr.datalen = 0;
- p->fr.timelen = 0;
+ p->fr.samples = 0;
p->fr.offset = 0;
p->fr.mallocd = 0;
if (esc && option_debug)
@@ -271,7 +298,15 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
int x;
if (p->ministate == STATE_COMMAND) {
/* Read the first two bytes, first, in case it's a control message */
- read(p->fd, result, 2);
+ res = read(p->fd, result, 2);
+ if (res < 2) {
+ // short read, means there was a hangup?
+ // (or is this also possible without hangup?)
+ // Anyway, reading from unitialized buffers is a bad idea anytime.
+ if (errno == EAGAIN)
+ return i4l_handle_escape(p, 0);
+ return NULL;
+ }
if (result[0] == CHAR_DLE) {
return i4l_handle_escape(p, result[1]);
@@ -283,7 +318,7 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
ast_modem_trim(result);
if (!strcasecmp(result, "VCON")) {
/* If we're in immediate mode, reply now */
- if (p->mode == MODEM_MODE_IMMEDIATE)
+// if (p->mode == MODEM_MODE_IMMEDIATE)
return i4l_handle_escape(p, 'X');
} else
if (!strcasecmp(result, "BUSY")) {
@@ -292,16 +327,22 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
} else
if (!strncasecmp(result, "CALLER NUMBER: ", 15 )) {
strncpy(p->cid, result + 15, sizeof(p->cid)-1);
- return i4l_handle_escape(p, 'R');
+ return i4l_handle_escape(p, 0);
} else
if (!strcasecmp(result, "RINGING")) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "%s is ringing...\n", p->dev);
return i4l_handle_escape(p, 'I');
} else
+ if (!strncasecmp(result, "RUNG", 4)) {
+ /* PM2002: the line was hung up before we picked it up, bye bye */
+ if (option_verbose > 2)
+ ast_verbose(VERBOSE_PREFIX_3 "%s was hung up on before we answered\n", p->dev);
+ return NULL;
+ } else
if (!strncasecmp(result, "RING", 4)) {
if (result[4]=='/')
- strncpy(p->dnid, result + 4, sizeof(p->dnid)-1);
+ strncpy(p->dnid, result + 5, sizeof(p->dnid)-1);
return i4l_handle_escape(p, 'R');
} else
if (!strcasecmp(result, "NO CARRIER")) {
@@ -329,6 +370,7 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
if (errno == EAGAIN)
return i4l_handle_escape(p, 0);
ast_log(LOG_WARNING, "Read failed: %s\n", strerror(errno));
+ return NULL;
}
for (x=0;x<res;x++) {
@@ -372,7 +414,7 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
/* If we get here, we have a complete voice frame */
p->fr.frametype = AST_FRAME_VOICE;
p->fr.subclass = AST_FORMAT_SLINEAR;
- p->fr.timelen = 30;
+ p->fr.samples = 240;
p->fr.data = p->obuf;
p->fr.datalen = p->obuflen;
p->fr.mallocd = 0;
@@ -497,32 +539,24 @@ static int i4l_dial(struct ast_modem_pvt *p, char *stuff)
static int i4l_hangup(struct ast_modem_pvt *p)
{
char dummy[50];
- sprintf(dummy, "%c%c", 0x10, 0x3);
- if (write(p->fd, dummy, 2) < 0) {
- ast_log(LOG_WARNING, "Failed to break\n");
- return -1;
- }
+ int dtr = TIOCM_DTR;
+
+ /* down DTR to hangup modem */
+ ioctl(p->fd, TIOCMBIC, &dtr);
/* Read anything outstanding */
while(read(p->fd, dummy, sizeof(dummy)) > 0);
- sprintf(dummy, "%c%c", 0x10, 0x14);
- if (write(p->fd, dummy, 2) < 0) {
- ast_log(LOG_WARNING, "Failed to break\n");
- return -1;
- }
- ast_modem_expect(p, "VCON", 1);
-#if 0
- if (ast_modem_expect(p, "VCON", 8)) {
- ast_log(LOG_WARNING, "Didn't get expected VCON\n");
- return -1;
- }
-#endif
+ /* rise DTR to re-enable line */
+ ioctl(p->fd, TIOCMBIS, &dtr);
+
+ /* Read anything outstanding */
+ while(read(p->fd, dummy, sizeof(dummy)) > 0);
+
+ /* basically we're done, just to be sure */
write(p->fd, "\n\n", 2);
read(p->fd, dummy, sizeof(dummy));
- /* Hangup by switching to data, then back to voice */
- if (ast_modem_send(p, "ATH", 0) ||
- ast_modem_expect(p, "NO CARRIER", 8)) {
+ if (ast_modem_send(p, "ATH", 0)) {
ast_log(LOG_WARNING, "Unable to hang up\n");
return -1;
}
@@ -530,6 +564,7 @@ static int i4l_hangup(struct ast_modem_pvt *p)
ast_log(LOG_WARNING, "Final 'OK' not received\n");
return -1;
}
+
return 0;
}
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 09f5b1b04..9a6bc9bcd 100755
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -320,7 +320,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
/* Some nice norms */
p->fr.datalen = 0;
- p->fr.timelen = 0;
+ p->fr.samples = 0;
p->fr.data = NULL;
p->fr.src = type;
p->fr.offset = 0;
@@ -381,7 +381,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast)
/* Some nice norms */
p->fr.datalen = 0;
- p->fr.timelen = 0;
+ p->fr.samples = 0;
p->fr.data = NULL;
p->fr.src = type;
p->fr.offset = 0;
@@ -415,6 +415,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast)
res = 4;
break;
}
+ p->fr.samples = 240;
p->fr.datalen = res;
p->fr.frametype = AST_FRAME_VOICE;
p->fr.subclass = p->lastinput;
@@ -630,6 +631,8 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
strncpy(tmp->context, context, sizeof(tmp->context)-1);
if (strlen(i->ext))
strncpy(tmp->exten, i->ext, sizeof(tmp->exten)-1);
+ else
+ strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
if (strlen(i->language))
strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
if (strlen(i->callerid))