mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
when switching back to voice mode, wait for 'B' (bug #3833)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@6007 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -164,7 +164,7 @@ extern int adsi_unload_session(struct ast_channel *chan);
|
|||||||
/* ADSI Layer 2 transmission functions */
|
/* ADSI Layer 2 transmission functions */
|
||||||
extern int adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype);
|
extern int adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype);
|
||||||
extern int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype);
|
extern int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype);
|
||||||
|
extern int adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait);
|
||||||
//! Read some encoded DTMF data.
|
//! Read some encoded DTMF data.
|
||||||
/*!
|
/*!
|
||||||
* Returns number of bytes received
|
* Returns number of bytes received
|
||||||
|
@@ -310,7 +310,7 @@ int adsi_begin_download(struct ast_channel *chan, char *service, char *fdn, char
|
|||||||
/* Setup the resident soft key stuff, a piece at a time */
|
/* Setup the resident soft key stuff, a piece at a time */
|
||||||
/* Upload what scripts we can for voicemail ahead of time */
|
/* Upload what scripts we can for voicemail ahead of time */
|
||||||
bytes += adsi_download_connect(buf + bytes, service, fdn, sec, version);
|
bytes += adsi_download_connect(buf + bytes, service, fdn, sec, version);
|
||||||
if (adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD))
|
if (adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0))
|
||||||
return -1;
|
return -1;
|
||||||
if (ast_readstring(chan, ack, 1, 10000, 10000, ""))
|
if (ast_readstring(chan, ack, 1, 10000, 10000, ""))
|
||||||
return -1;
|
return -1;
|
||||||
@@ -328,12 +328,12 @@ int adsi_end_download(struct ast_channel *chan)
|
|||||||
/* Setup the resident soft key stuff, a piece at a time */
|
/* Setup the resident soft key stuff, a piece at a time */
|
||||||
/* Upload what scripts we can for voicemail ahead of time */
|
/* Upload what scripts we can for voicemail ahead of time */
|
||||||
bytes += adsi_download_disconnect(buf + bytes);
|
bytes += adsi_download_disconnect(buf + bytes);
|
||||||
if (adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD))
|
if (adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0))
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
|
int adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
|
||||||
{
|
{
|
||||||
unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
|
unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
|
||||||
int msglens[5];
|
int msglens[5];
|
||||||
@@ -342,6 +342,7 @@ int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msgl
|
|||||||
int res;
|
int res;
|
||||||
int x;
|
int x;
|
||||||
int writeformat, readformat;
|
int writeformat, readformat;
|
||||||
|
int waitforswitch = 0;
|
||||||
|
|
||||||
writeformat = chan->writeformat;
|
writeformat = chan->writeformat;
|
||||||
readformat = chan->readformat;
|
readformat = chan->readformat;
|
||||||
@@ -349,11 +350,17 @@ int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msgl
|
|||||||
newdatamode = chan->adsicpe & ADSI_FLAG_DATAMODE;
|
newdatamode = chan->adsicpe & ADSI_FLAG_DATAMODE;
|
||||||
|
|
||||||
for (x=0;x<msglen;x+=(msg[x+1]+2)) {
|
for (x=0;x<msglen;x+=(msg[x+1]+2)) {
|
||||||
if (msg[x] == ADSI_SWITCH_TO_DATA)
|
if (msg[x] == ADSI_SWITCH_TO_DATA) {
|
||||||
|
ast_log(LOG_DEBUG, "Switch to data is sent!\n");
|
||||||
|
waitforswitch++;
|
||||||
newdatamode = ADSI_FLAG_DATAMODE;
|
newdatamode = ADSI_FLAG_DATAMODE;
|
||||||
|
}
|
||||||
|
|
||||||
if (msg[x] == ADSI_SWITCH_TO_VOICE)
|
if (msg[x] == ADSI_SWITCH_TO_VOICE) {
|
||||||
|
ast_log(LOG_DEBUG, "Switch to voice is sent!\n");
|
||||||
|
waitforswitch++;
|
||||||
newdatamode = 0;
|
newdatamode = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msgs[0] = msg;
|
msgs[0] = msg;
|
||||||
|
|
||||||
@@ -381,6 +388,12 @@ int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msgl
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes);
|
res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes);
|
||||||
|
|
||||||
|
if (dowait) {
|
||||||
|
ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch);
|
||||||
|
while(waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) { res = 0; ast_log(LOG_DEBUG, "Waiting for 'B'...\n"); }
|
||||||
|
}
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode;
|
chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode;
|
||||||
|
|
||||||
@@ -394,6 +407,11 @@ int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msgl
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
|
||||||
|
{
|
||||||
|
return adsi_transmit_message_full(chan, msg, msglen, msgtype, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int ccopy(unsigned char *dst, unsigned char *src, int max)
|
static inline int ccopy(unsigned char *dst, unsigned char *src, int max)
|
||||||
{
|
{
|
||||||
int x=0;
|
int x=0;
|
||||||
@@ -573,11 +591,11 @@ int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
|
|||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
int res;
|
int res;
|
||||||
bytes += adsi_data_mode(buf);
|
bytes += adsi_data_mode(buf);
|
||||||
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
||||||
|
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
bytes += adsi_query_cpeid(buf);
|
bytes += adsi_query_cpeid(buf);
|
||||||
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
||||||
|
|
||||||
/* Get response */
|
/* Get response */
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
@@ -592,7 +610,7 @@ int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
|
|||||||
if (voice) {
|
if (voice) {
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
bytes += adsi_voice_mode(buf, 0);
|
bytes += adsi_voice_mode(buf, 0);
|
||||||
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
||||||
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
||||||
ast_waitfordigit(chan, 1000);
|
ast_waitfordigit(chan, 1000);
|
||||||
}
|
}
|
||||||
@@ -605,11 +623,11 @@ int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *but
|
|||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
int res;
|
int res;
|
||||||
bytes += adsi_data_mode(buf);
|
bytes += adsi_data_mode(buf);
|
||||||
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
||||||
|
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
bytes += adsi_query_cpeinfo(buf);
|
bytes += adsi_query_cpeinfo(buf);
|
||||||
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
||||||
|
|
||||||
/* Get width */
|
/* Get width */
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
@@ -657,7 +675,7 @@ int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *but
|
|||||||
if (voice) {
|
if (voice) {
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
bytes += adsi_voice_mode(buf, 0);
|
bytes += adsi_voice_mode(buf, 0);
|
||||||
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
||||||
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
||||||
ast_waitfordigit(chan, 1000);
|
ast_waitfordigit(chan, 1000);
|
||||||
}
|
}
|
||||||
@@ -906,7 +924,7 @@ int adsi_channel_restore(struct ast_channel *chan)
|
|||||||
}
|
}
|
||||||
bytes += adsi_set_keys(dsp + bytes, keyd);
|
bytes += adsi_set_keys(dsp + bytes, keyd);
|
||||||
}
|
}
|
||||||
adsi_transmit_message(chan, dsp, bytes, ADSI_MSG_DISPLAY);
|
adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -923,7 +941,7 @@ int adsi_print(struct ast_channel *chan, char **lines, int *aligns, int voice)
|
|||||||
if (voice) {
|
if (voice) {
|
||||||
bytes += adsi_voice_mode(buf + bytes, 0);
|
bytes += adsi_voice_mode(buf + bytes, 0);
|
||||||
}
|
}
|
||||||
res = adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
|
res = adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
||||||
if (voice) {
|
if (voice) {
|
||||||
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
||||||
ast_waitfordigit(chan, 1000);
|
ast_waitfordigit(chan, 1000);
|
||||||
@@ -948,7 +966,7 @@ int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int
|
|||||||
bytes += adsi_data_mode(dsp + bytes);
|
bytes += adsi_data_mode(dsp + bytes);
|
||||||
|
|
||||||
/* Prepare key setup messages */
|
/* Prepare key setup messages */
|
||||||
if (adsi_transmit_message(chan, dsp, bytes, ADSI_MSG_DISPLAY))
|
if (adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0))
|
||||||
return -1;
|
return -1;
|
||||||
if (app) {
|
if (app) {
|
||||||
res = ast_readstring(chan, resp, 1, 1200, 1200, "");
|
res = ast_readstring(chan, resp, 1, 1200, 1200, "");
|
||||||
@@ -985,7 +1003,7 @@ int adsi_unload_session(struct ast_channel *chan)
|
|||||||
bytes += adsi_voice_mode(dsp + bytes, 0);
|
bytes += adsi_voice_mode(dsp + bytes, 0);
|
||||||
|
|
||||||
/* Prepare key setup messages */
|
/* Prepare key setup messages */
|
||||||
if (adsi_transmit_message(chan, dsp, bytes, ADSI_MSG_DISPLAY))
|
if (adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0))
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user