ADSI Support (built upon Caller*ID) More...


Go to the source code of this file.
Defines | |
ADSI parameters | |
| #define | ADSI_MSG_DISPLAY 132 |
| #define | ADSI_MSG_DOWNLOAD 133 |
| #define | ADSI_LOAD_SOFTKEY 128 |
| #define | ADSI_INIT_SOFTKEY_LINE 129 |
| #define | ADSI_LOAD_VIRTUAL_DISP 130 |
| #define | ADSI_LINE_CONTROL 131 |
| #define | ADSI_INFORMATION 132 |
| #define | ADSI_DISC_SESSION 133 |
| #define | ADSI_SWITCH_TO_DATA 134 |
| #define | ADSI_SWITCH_TO_VOICE 135 |
| #define | ADSI_CLEAR_SOFTKEY 136 |
| #define | ADSI_INPUT_CONTROL 137 |
| #define | ADSI_INPUT_FORMAT 138 |
| #define | ADSI_SWITCH_TO_PERIPH 139 |
| #define | ADSI_MOVE_DATA 140 |
| #define | ADSI_LOAD_DEFAULT 141 |
| #define | ADSI_CONNECT_SESSION 142 |
| #define | ADSI_CLEAR_TYPE_AHEAD 143 |
| #define | ADSI_DISPLAY_CALL_BUF 144 |
| #define | ADSI_CLEAR_CALL_BUF 145 |
| #define | ADSI_SWITCH_TO_ALT 146 |
| #define | ADSI_SWITCH_TO_GRAPHICS 147 |
| #define | ADSI_CLEAR_SCREEN 148 |
| #define | ADSI_QUERY_CONFIG 149 |
| #define | ADSI_QUERY_CPEID 150 |
| #define | ADSI_SWITCH_TO_APP 151 |
| #define | ADSI_LOAD_SOFTKEY_TABLE 128 |
| #define | ADSI_LOAD_PREDEF_DISP 129 |
| #define | ADSI_LOAD_SCRIPT 130 |
| #define | ADSI_DOWNLOAD_CONNECT 131 |
| #define | ADSI_DOWNLOAD_DISC 132 |
| #define | ADSI_ENCODED_DTMF 0x80 |
| #define | ADSI_ON_HOOK 0x81 |
| #define | ADSI_OFF_HOOK 0x82 |
| #define | ADSI_FLASH 0x83 |
| #define | ADSI_DIAL_TONE_DETECT 0x84 |
| #define | ADSI_LINE_NUMBER 0x85 |
| #define | ADSI_BLANK 0x86 |
| #define | ADSI_SEND_CHARS 0x87 |
| #define | ADSI_CLEAR_CHARS 0x88 |
| #define | ADSI_BACKSPACE 0x89 |
| #define | ADSI_TAB_COLUMN 0x8A |
| #define | ADSI_GOTO_LINE 0x8B |
| #define | ADSI_GOTO_LINE_REL 0x8C |
| #define | ADSI_PAGE_UP 0x8D |
| #define | ADSI_PAGE_DOWN 0x8E |
| #define | ADSI_EXTENDED_DTMF 0x8F |
| #define | ADSI_DELAY 0x90 |
| #define | ADSI_DIAL_PULSE_ONE 0x91 |
| #define | ADSI_SWITCH_TO_DATA2 0x92 |
| #define | ADSI_SWITCH_TO_VOICE2 0x93 |
| #define | ADSI_DISP_CALL_BUF 0x94 |
| #define | ADSI_CLEAR_CALL_B 0x95 |
| #define | ADSI_INFO_PAGE 0x0 |
| #define | ADSI_COMM_PAGE 0x1 |
| #define | ADSI_KEY_APPS 16 |
| #define | ADSI_JUST_LEFT 0x2 |
| #define | ADSI_JUST_RIGHT 0x1 |
| #define | ADSI_JUST_CENT 0x0 |
| #define | ADSI_JUST_IND 0x3 |
| #define | ADSI_KEY_SKT 0x80 |
| #define | ADSI_KEY_HILITE 0x40 |
| #define | ADSI_DIR_FROM_LEFT (0) |
| #define | ADSI_DIR_FROM_RIGHT (1) |
Functions | |
| int | ast_adsi_available (struct ast_channel *chan) |
| Returns non-zero if Channel does or might support ADSI. | |
| int | ast_adsi_begin_download (struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version) |
| int | ast_adsi_channel_restore (struct ast_channel *chan) |
| int | ast_adsi_clear_screen (unsigned char *buf) |
| int | ast_adsi_clear_soft_keys (unsigned char *buf) |
| int | ast_adsi_connect_session (unsigned char *buf, unsigned char *fdn, int ver) |
| Connects an ADSI Display Session. | |
| int | ast_adsi_data_mode (unsigned char *buf) |
| Puts CPE in data mode. | |
| int | ast_adsi_disconnect_session (unsigned char *buf) |
| Disconnects a running session. | |
| int | ast_adsi_display (unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2) |
| Loads a line of info into the display. | |
| int | ast_adsi_download_connect (unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver) |
| Begin an ADSI script download. | |
| int | ast_adsi_download_disconnect (unsigned char *buf) |
| Disconnects (and hopefully saves) a downloaded script. | |
| int | ast_adsi_end_download (struct ast_channel *chan) |
| int | ast_adsi_get_cpeid (struct ast_channel *chan, unsigned char *cpeid, int voice) |
| int | ast_adsi_get_cpeinfo (struct ast_channel *chan, int *width, int *height, int *buttons, int voice) |
| int | ast_adsi_input_control (unsigned char *buf, int page, int line, int display, int format, int just) |
| Set input information. | |
| int | ast_adsi_input_format (unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2) |
| Set input format. | |
| int | ast_adsi_load_session (struct ast_channel *chan, unsigned char *app, int ver, int data) |
| Check if scripts for a given app are already loaded. Version may be -1, if any version is okay, or 0-255 for a specific version. | |
| int | ast_adsi_load_soft_key (unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data) |
| Creates "load soft key" parameters. | |
| int | ast_adsi_print (struct ast_channel *chan, char **lines, int *align, int voice) |
| Display some stuff on the screen. | |
| int | ast_adsi_query_cpeid (unsigned char *buf) |
| int | ast_adsi_query_cpeinfo (unsigned char *buf) |
| int | ast_adsi_read_encoded_dtmf (struct ast_channel *chan, unsigned char *buf, int maxlen) |
| int | ast_adsi_set_keys (unsigned char *buf, unsigned char *keys) |
| Set which soft keys should be displayed. | |
| int | ast_adsi_set_line (unsigned char *buf, int page, int line) |
| Sets the current line and page. | |
| int | ast_adsi_transmit_message (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype) |
| int | ast_adsi_transmit_message_full (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait) |
| int | ast_adsi_unload_session (struct ast_channel *chan) |
| int | ast_adsi_voice_mode (unsigned char *buf, int when) |
| Puts CPE in voice mode. | |
ADSI Support (built upon Caller*ID)
Definition in file adsi.h.
| #define ADSI_CLEAR_SCREEN 148 |
Definition at line 57 of file adsi.h.
Referenced by ast_adsi_clear_screen().
| #define ADSI_CLEAR_SOFTKEY 136 |
Definition at line 45 of file adsi.h.
Referenced by ast_adsi_clear_soft_keys().
| #define ADSI_COMM_PAGE 0x1 |
Definition at line 108 of file adsi.h.
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_logo(), adsi_message(), adsi_password(), adsi_status(), adsi_status2(), vm_newuser(), vm_options(), and vm_tempgreeting().
| #define ADSI_CONNECT_SESSION 142 |
Definition at line 51 of file adsi.h.
Referenced by ast_adsi_connect_session().
| #define ADSI_DIR_FROM_LEFT (0) |
Definition at line 121 of file adsi.h.
Referenced by adsi_login(), and adsi_password().
| #define ADSI_DISC_SESSION 133 |
Definition at line 42 of file adsi.h.
Referenced by ast_adsi_disconnect_session().
| #define ADSI_DOWNLOAD_CONNECT 131 |
Definition at line 66 of file adsi.h.
Referenced by ast_adsi_download_connect().
| #define ADSI_DOWNLOAD_DISC 132 |
Definition at line 67 of file adsi.h.
Referenced by ast_adsi_download_disconnect().
| #define ADSI_INFO_PAGE 0x0 |
Definition at line 107 of file adsi.h.
Referenced by adsi_prog(), ast_adsi_channel_restore(), and ast_adsi_print().
| #define ADSI_INIT_SOFTKEY_LINE 129 |
Definition at line 38 of file adsi.h.
Referenced by ast_adsi_set_keys().
| #define ADSI_INPUT_CONTROL 137 |
Definition at line 46 of file adsi.h.
Referenced by ast_adsi_input_control().
| #define ADSI_INPUT_FORMAT 138 |
Definition at line 47 of file adsi.h.
Referenced by ast_adsi_input_format().
| #define ADSI_JUST_CENT 0x0 |
Definition at line 115 of file adsi.h.
Referenced by adsi_announce_park(), adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_logo(), cpeid_setstatus(), init_state(), str2align(), vm_newuser(), vm_options(), and vm_tempgreeting().
| #define ADSI_JUST_IND 0x3 |
Definition at line 116 of file adsi.h.
Referenced by str2align().
| #define ADSI_JUST_LEFT 0x2 |
Definition at line 113 of file adsi.h.
Referenced by adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_message(), adsi_password(), adsi_prog(), adsi_status(), adsi_status2(), cpeid_setstatus(), and str2align().
| #define ADSI_JUST_RIGHT 0x1 |
Definition at line 114 of file adsi.h.
Referenced by str2align().
| #define ADSI_KEY_APPS 16 |
Definition at line 110 of file adsi.h.
Referenced by adsi_delete(), adsi_folders(), adsi_load_vmail(), adsi_login(), adsi_message(), adsi_password(), adsi_status(), and adsi_status2().
| #define ADSI_KEY_SKT 0x80 |
Definition at line 118 of file adsi.h.
Referenced by adsi_delete(), adsi_folders(), adsi_message(), adsi_status(), and adsi_status2().
| #define ADSI_LINE_CONTROL 131 |
Definition at line 40 of file adsi.h.
Referenced by ast_adsi_set_line().
| #define ADSI_LOAD_SOFTKEY 128 |
Definition at line 37 of file adsi.h.
Referenced by ast_adsi_load_soft_key().
| #define ADSI_LOAD_VIRTUAL_DISP 130 |
Definition at line 39 of file adsi.h.
Referenced by ast_adsi_display().
| #define ADSI_MSG_DISPLAY 132 |
Definition at line 33 of file adsi.h.
Referenced by adsi_delete(), adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_message(), adsi_password(), adsi_prog(), adsi_status(), adsi_status2(), ast_adsi_channel_restore(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_adsi_print(), ast_adsi_unload_session(), vm_newuser(), vm_options(), and vm_tempgreeting().
| #define ADSI_MSG_DOWNLOAD 133 |
Definition at line 34 of file adsi.h.
Referenced by adsi_load_vmail(), adsi_prog(), ast_adsi_begin_download(), and ast_adsi_end_download().
| #define ADSI_QUERY_CONFIG 149 |
Definition at line 58 of file adsi.h.
Referenced by ast_adsi_query_cpeinfo().
| #define ADSI_QUERY_CPEID 150 |
Definition at line 59 of file adsi.h.
Referenced by ast_adsi_query_cpeid().
| #define ADSI_SWITCH_TO_DATA 134 |
Definition at line 43 of file adsi.h.
Referenced by ast_adsi_data_mode(), and ast_adsi_transmit_message_full().
| #define ADSI_SWITCH_TO_DATA2 0x92 |
Definition at line 88 of file adsi.h.
Referenced by ast_adsi_load_soft_key().
| #define ADSI_SWITCH_TO_VOICE 135 |
Definition at line 44 of file adsi.h.
Referenced by ast_adsi_transmit_message_full(), and ast_adsi_voice_mode().
| int ast_adsi_available | ( | struct ast_channel * | chan | ) |
Returns non-zero if Channel does or might support ADSI.
| chan | Channel to check |
Definition at line 781 of file res_adsi.c.
References ast_channel::adsicpe, AST_ADSI_AVAILABLE, and AST_ADSI_UNKNOWN.
Referenced by adsi_begin(), adsi_delete(), adsi_exec(), adsi_folders(), adsi_goodbye(), adsi_login(), adsi_message(), adsi_password(), adsi_status(), adsi_status2(), park_call_full(), vm_newuser(), vm_options(), and vm_tempgreeting().
{
int cpe = chan->adsicpe & 0xff;
if ((cpe == AST_ADSI_AVAILABLE) ||
(cpe == AST_ADSI_UNKNOWN)) {
return 1;
}
return 0;
}
| int ast_adsi_begin_download | ( | struct ast_channel * | chan, |
| char * | service, | ||
| unsigned char * | fdn, | ||
| unsigned char * | sec, | ||
| int | version | ||
| ) |
Definition at line 329 of file res_adsi.c.
References ADSI_MSG_DOWNLOAD, ast_adsi_download_connect(), ast_adsi_transmit_message_full(), ast_debug, ast_readstring(), and version.
Referenced by adsi_load_vmail(), and adsi_prog().
{
int bytes = 0;
unsigned char buf[256];
char ack[2];
/* Setup the resident soft key stuff, a piece at a time */
/* Upload what scripts we can for voicemail ahead of time */
bytes += ast_adsi_download_connect(buf + bytes, service, fdn, sec, version);
if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) {
return -1;
}
if (ast_readstring(chan, ack, 1, 10000, 10000, "")) {
return -1;
}
if (ack[0] == 'B') {
return 0;
}
ast_debug(1, "Download was denied by CPE\n");
return -1;
}
| int ast_adsi_channel_restore | ( | struct ast_channel * | chan | ) |
Restore ADSI initialization (for applications that play with ADSI and want to restore it to normal. If you touch "INFO" then you have to use the ast_adsi_channel_init again instead.
| chan | Channel to restore |
| 0 | on success (or adsi unavailable) |
| -1 | on hangup |
Definition at line 943 of file res_adsi.c.
References ADSI_INFO_PAGE, ADSI_MSG_DISPLAY, ADSI_SPEED_DIAL, ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message_full(), and speeds.
{
unsigned char dsp[256] = "", keyd[6] = "";
int bytes, x;
/* Start with initial display setup */
bytes = 0;
bytes += ast_adsi_set_line(dsp + bytes, ADSI_INFO_PAGE, 1);
/* Prepare key setup messages */
if (speeds) {
for (x = 0; x < speeds; x++) {
keyd[x] = ADSI_SPEED_DIAL + x;
}
bytes += ast_adsi_set_keys(dsp + bytes, keyd);
}
ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0);
return 0;
}
| int ast_adsi_clear_screen | ( | unsigned char * | buf | ) |
Definition at line 749 of file res_adsi.c.
References ADSI_CLEAR_SCREEN.
{
int bytes = 0;
/* Message type */
buf[bytes++] = ADSI_CLEAR_SCREEN;
/* Reserve space for length */
bytes++;
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_clear_soft_keys | ( | unsigned char * | buf | ) |
Definition at line 734 of file res_adsi.c.
References ADSI_CLEAR_SOFTKEY.
{
int bytes = 0;
/* Message type */
buf[bytes++] = ADSI_CLEAR_SOFTKEY;
/* Reserve space for length */
bytes++;
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_connect_session | ( | unsigned char * | buf, |
| unsigned char * | fdn, | ||
| int | ver | ||
| ) |
Connects an ADSI Display Session.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| fdn | Optional 4 byte Feature Download Number (for loading soft keys) |
| ver | Optional version number (0-255, or -1 to omit) |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 493 of file res_adsi.c.
References ADSI_CONNECT_SESSION.
Referenced by ast_adsi_load_session().
{
int bytes = 0, x;
/* Message type */
buf[bytes++] = ADSI_CONNECT_SESSION;
/* Reserve space for length */
bytes++;
if (fdn) {
for (x = 0; x < 4; x++) {
buf[bytes++] = fdn[x];
}
if (ver > -1) {
buf[bytes++] = ver & 0xff;
}
}
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_data_mode | ( | unsigned char * | buf | ) |
Puts CPE in data mode.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 719 of file res_adsi.c.
References ADSI_SWITCH_TO_DATA.
Referenced by adsi_load_vmail(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), and ast_adsi_load_session().
{
int bytes = 0;
/* Message type */
buf[bytes++] = ADSI_SWITCH_TO_DATA;
/* Reserve space for length */
bytes++;
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_disconnect_session | ( | unsigned char * | buf | ) |
Disconnects a running session.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 549 of file res_adsi.c.
References ADSI_DISC_SESSION.
Referenced by ast_adsi_unload_session().
{
int bytes = 0;
/* Message type */
buf[bytes++] = ADSI_DISC_SESSION;
/* Reserve space for length */
bytes++;
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_display | ( | unsigned char * | buf, |
| int | page, | ||
| int | line, | ||
| int | just, | ||
| int | wrap, | ||
| char * | col1, | ||
| char * | col2 | ||
| ) |
Loads a line of info into the display.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| page | Page to load (ADSI_COMM_PAGE or ADSI_INFO_PAGE) |
| line | Line number to load (1-4 for Comm page, 1-33 for info page) |
| just | Line justification (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CENT, ADSI_JUST_IND) |
| wrap | Wrap (1 = yes, 0 = no) |
| col1 | Text to place in first column |
| col2 | Text to place in second column |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 806 of file res_adsi.c.
References ADSI_LOAD_VIRTUAL_DISP, and ccopy().
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_logo(), adsi_message(), adsi_prog(), adsi_status(), adsi_status2(), ast_adsi_print(), vm_newuser(), vm_options(), and vm_tempgreeting().
{
int bytes = 0;
/* Sanity check line number */
if (page) {
if (line > 4) return -1;
} else {
if (line > 33) return -1;
}
if (line < 1) {
return -1;
}
/* Parameter type */
buf[bytes++] = ADSI_LOAD_VIRTUAL_DISP;
/* Reserve space for size */
bytes++;
/* Page and wrap indicator */
buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f);
/* Justification */
buf[bytes++] = (just & 0x3) << 5;
/* Omit highlight mode definition */
buf[bytes++] = 0xff;
/* Primary column */
bytes+= ccopy(buf + bytes, (unsigned char *)col1, 20);
/* Delimiter */
buf[bytes++] = 0xff;
/* Secondary column */
bytes += ccopy(buf + bytes, (unsigned char *)col2, 20);
/* Update length */
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_download_connect | ( | unsigned char * | buf, |
| char * | service, | ||
| unsigned char * | fdn, | ||
| unsigned char * | sec, | ||
| int | ver | ||
| ) |
Begin an ADSI script download.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| service | a 1-18 byte name of the feature |
| fdn | 4 byte Feature Download Number (for loading soft keys) |
| sec | 4 byte vendor security code |
| ver | version number (0-255, or -1 to omit) |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 517 of file res_adsi.c.
References ADSI_DOWNLOAD_CONNECT, and ccopy().
Referenced by ast_adsi_begin_download().
{
int bytes = 0, x;
/* Message type */
buf[bytes++] = ADSI_DOWNLOAD_CONNECT;
/* Reserve space for length */
bytes++;
/* Primary column */
bytes+= ccopy(buf + bytes, (unsigned char *)service, 18);
/* Delimiter */
buf[bytes++] = 0xff;
for (x = 0; x < 4; x++) {
buf[bytes++] = fdn[x];
}
for (x = 0; x < 4; x++) {
buf[bytes++] = sec[x];
}
buf[bytes++] = ver & 0xff;
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_download_disconnect | ( | unsigned char * | buf | ) |
Disconnects (and hopefully saves) a downloaded script.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 791 of file res_adsi.c.
References ADSI_DOWNLOAD_DISC.
Referenced by adsi_load_vmail(), and ast_adsi_end_download().
{
int bytes = 0;
/* Message type */
buf[bytes++] = ADSI_DOWNLOAD_DISC;
/* Reserve space for length */
bytes++;
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_end_download | ( | struct ast_channel * | chan | ) |
Definition at line 351 of file res_adsi.c.
References ADSI_MSG_DOWNLOAD, ast_adsi_download_disconnect(), and ast_adsi_transmit_message_full().
Referenced by adsi_load_vmail(), and adsi_prog().
{
int bytes = 0;
unsigned char buf[256];
/* Setup the resident soft key stuff, a piece at a time */
/* Upload what scripts we can for voicemail ahead of time */
bytes += ast_adsi_download_disconnect(buf + bytes);
if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) {
return -1;
}
return 0;
}
| int ast_adsi_get_cpeid | ( | struct ast_channel * | chan, |
| unsigned char * | cpeid, | ||
| int | voice | ||
| ) |
Get CPE ID from an attached ADSI compatible CPE. Returns 1 on success, storing 4 bytes of CPE ID at buf or -1 on hangup, or 0 if there was no hangup but it failed to find the device ID. Returns to voice mode if "voice" is non-zero.
Definition at line 621 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_data_mode(), ast_adsi_query_cpeid(), ast_adsi_read_encoded_dtmf(), ast_adsi_transmit_message_full(), ast_adsi_voice_mode(), ast_log(), ast_waitfordigit(), and LOG_WARNING.
Referenced by cpeid_exec().
{
unsigned char buf[256] = "";
int bytes = 0, res;
bytes += ast_adsi_data_mode(buf);
ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
bytes = 0;
bytes += ast_adsi_query_cpeid(buf);
ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
/* Get response */
res = ast_adsi_read_encoded_dtmf(chan, cpeid, 4);
if (res != 4) {
ast_log(LOG_WARNING, "Got %d bytes back of encoded DTMF, expecting 4\n", res);
res = 0;
} else {
res = 1;
}
if (voice) {
bytes = 0;
bytes += ast_adsi_voice_mode(buf, 0);
ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
/* Ignore the resulting DTMF B announcing it's in voice mode */
ast_waitfordigit(chan, 1000);
}
return res;
}
| int ast_adsi_get_cpeinfo | ( | struct ast_channel * | chan, |
| int * | width, | ||
| int * | height, | ||
| int * | buttons, | ||
| int | voice | ||
| ) |
Definition at line 652 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_data_mode(), ast_adsi_query_cpeinfo(), ast_adsi_transmit_message_full(), ast_adsi_voice_mode(), ast_log(), ast_readstring(), ast_waitfordigit(), and LOG_WARNING.
Referenced by cpeid_exec().
{
unsigned char buf[256] = "";
int bytes = 0, res;
bytes += ast_adsi_data_mode(buf);
ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
bytes = 0;
bytes += ast_adsi_query_cpeinfo(buf);
ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
/* Get width */
if ((res = ast_readstring(chan, (char *) buf, 2, 1000, 500, "")) < 0) {
return res;
}
if (strlen((char *) buf) != 2) {
ast_log(LOG_WARNING, "Got %d bytes of width, expecting 2\n", res);
res = 0;
} else {
res = 1;
}
if (width) {
*width = atoi((char *) buf);
}
/* Get height */
memset(buf, 0, sizeof(buf));
if (res) {
if ((res = ast_readstring(chan, (char *) buf, 2, 1000, 500, "")) < 0) {
return res;
}
if (strlen((char *) buf) != 2) {
ast_log(LOG_WARNING, "Got %d bytes of height, expecting 2\n", res);
res = 0;
} else {
res = 1;
}
if (height) {
*height = atoi((char *) buf);
}
}
/* Get buttons */
memset(buf, 0, sizeof(buf));
if (res) {
if ((res = ast_readstring(chan, (char *) buf, 1, 1000, 500, "")) < 0) {
return res;
}
if (strlen((char *) buf) != 1) {
ast_log(LOG_WARNING, "Got %d bytes of buttons, expecting 1\n", res);
res = 0;
} else {
res = 1;
}
if (buttons) {
*buttons = atoi((char *) buf);
}
}
if (voice) {
bytes = 0;
bytes += ast_adsi_voice_mode(buf, 0);
ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
/* Ignore the resulting DTMF B announcing it's in voice mode */
ast_waitfordigit(chan, 1000);
}
return res;
}
| int ast_adsi_input_control | ( | unsigned char * | buf, |
| int | page, | ||
| int | line, | ||
| int | display, | ||
| int | format, | ||
| int | just | ||
| ) |
Set input information.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| page | Which page to input on (ADSI_COMM_PAGE or ADSI_INFO_PAGE) |
| line | Line number to input on |
| display | Set to zero to obscure input, or 1 to leave visible |
| format | Format number to use (0-7) |
| just | Justification (left, right center, indent) |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 853 of file res_adsi.c.
References ADSI_INPUT_CONTROL.
Referenced by adsi_login(), and adsi_password().
{
int bytes = 0;
if (page) {
if (line > 4) return -1;
} else {
if (line > 33) return -1;
}
if (line < 1) {
return -1;
}
buf[bytes++] = ADSI_INPUT_CONTROL;
bytes++;
buf[bytes++] = ((page & 1) << 7) | (line & 0x3f);
buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7);
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_input_format | ( | unsigned char * | buf, |
| int | num, | ||
| int | dir, | ||
| int | wrap, | ||
| char * | format1, | ||
| char * | format2 | ||
| ) |
Set input format.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| num | Which format we are setting |
| dir | Which direction (ADSI_DIR_FROM_LEFT or ADSI_DIR_FROM_RIGHT) |
| wrap | Set to 1 to permit line wrap, or 0 if not |
| format1 | Format for column 1 |
| format2 | Format for column 2 |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 876 of file res_adsi.c.
References ADSI_INPUT_FORMAT, ast_strlen_zero(), and ccopy().
Referenced by adsi_login(), and adsi_password().
{
int bytes = 0;
if (ast_strlen_zero((char *) format1)) {
return -1;
}
buf[bytes++] = ADSI_INPUT_FORMAT;
bytes++;
buf[bytes++] = ((dir & 1) << 7) | ((wrap & 1) << 6) | (num & 0x7);
bytes += ccopy(buf + bytes, (unsigned char *) format1, 20);
buf[bytes++] = 0xff;
if (!ast_strlen_zero(format2)) {
bytes += ccopy(buf + bytes, (unsigned char *) format2, 20);
}
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_load_session | ( | struct ast_channel * | chan, |
| unsigned char * | app, | ||
| int | ver, | ||
| int | data | ||
| ) |
Check if scripts for a given app are already loaded. Version may be -1, if any version is okay, or 0-255 for a specific version.
| chan | Channel to test for loaded app |
| app | Four character app name (must be unique to your application) |
| ver | optional version number |
| data | Non-zero if you want to be put in data mode |
| 0 | if scripts is not loaded or not an ADSI CPE |
| -1 | on hangup |
| 1 | if script already loaded. |
Definition at line 985 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_connect_session(), ast_adsi_data_mode(), ast_adsi_transmit_message_full(), ast_debug, ast_log(), ast_readstring(), ast_channel::data, and LOG_WARNING.
Referenced by adsi_announce_park(), adsi_begin(), adsi_load_vmail(), adsi_prog(), and cpeid_exec().
{
unsigned char dsp[256] = "";
int bytes = 0, res;
char resp[2];
/* Connect to session */
bytes += ast_adsi_connect_session(dsp + bytes, app, ver);
if (data) {
bytes += ast_adsi_data_mode(dsp + bytes);
}
/* Prepare key setup messages */
if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
return -1;
}
if (app) {
if ((res = ast_readstring(chan, resp, 1, 1200, 1200, "")) < 0) {
return -1;
}
if (res) {
ast_debug(1, "No response from CPE about version. Assuming not there.\n");
return 0;
}
if (!strcmp(resp, "B")) {
ast_debug(1, "CPE has script '%s' version %d already loaded\n", app, ver);
return 1;
} else if (!strcmp(resp, "A")) {
ast_debug(1, "CPE hasn't script '%s' version %d already loaded\n", app, ver);
} else {
ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp);
}
} else
return 1;
return 0;
}
| int ast_adsi_load_soft_key | ( | unsigned char * | buf, |
| int | key, | ||
| const char * | llabel, | ||
| const char * | slabel, | ||
| char * | ret, | ||
| int | data | ||
| ) |
Creates "load soft key" parameters.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| key | Key code from 2 to 33, for which key we are loading |
| llabel | Long label for key (1-18 bytes) |
| slabel | Short label for key (1-7 bytes) |
| ret | Optional return sequence (NULL for none) |
| data | whether to put CPE in data mode before sending digits |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 452 of file res_adsi.c.
References ADSI_LOAD_SOFTKEY, ADSI_SWITCH_TO_DATA2, ccopy(), and ast_channel::data.
Referenced by adsi_load_vmail(), and adsi_login().
{
int bytes = 0;
/* Abort if invalid key specified */
if ((key < 2) || (key > 33)) {
return -1;
}
buf[bytes++] = ADSI_LOAD_SOFTKEY;
/* Reserve for length */
bytes++;
/* Which key */
buf[bytes++] = key;
/* Carefully copy long label */
bytes += ccopy(buf + bytes, (const unsigned char *)llabel, 18);
/* Place delimiter */
buf[bytes++] = 0xff;
/* Short label */
bytes += ccopy(buf + bytes, (const unsigned char *)slabel, 7);
/* If specified, copy return string */
if (ret) {
/* Place delimiter */
buf[bytes++] = 0xff;
if (data) {
buf[bytes++] = ADSI_SWITCH_TO_DATA2;
}
/* Carefully copy return string */
bytes += ccopy(buf + bytes, (const unsigned char *)ret, 20);
}
/* Replace parameter length */
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_print | ( | struct ast_channel * | chan, |
| char ** | lines, | ||
| int * | align, | ||
| int | voice | ||
| ) |
Display some stuff on the screen.
| chan | Channel to display on |
| lines | NULL-terminated list of things to print (no more than 4 recommended) |
| align | list of alignments to use (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CEN, etc..) |
| voice | whether to jump into voice mode when finished |
| 0 | on success (or adsi unavailable) |
| -1 | on hangup |
Definition at line 965 of file res_adsi.c.
References ADSI_INFO_PAGE, ADSI_MSG_DISPLAY, ast_adsi_display(), ast_adsi_set_line(), ast_adsi_transmit_message_full(), ast_adsi_voice_mode(), and ast_waitfordigit().
Referenced by adsi_announce_park(), and cpeid_setstatus().
{
unsigned char buf[4096];
int bytes = 0, res, x;
for (x = 0; lines[x]; x++) {
bytes += ast_adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, alignments[x], 0, lines[x], "");
}
bytes += ast_adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1);
if (voice) {
bytes += ast_adsi_voice_mode(buf + bytes, 0);
}
res = ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
if (voice) {
/* Ignore the resulting DTMF B announcing it's in voice mode */
ast_waitfordigit(chan, 1000);
}
return res;
}
| int ast_adsi_query_cpeid | ( | unsigned char * | buf | ) |
Build Query CPE ID of equipment. Returns number of bytes added to message
Definition at line 564 of file res_adsi.c.
References ADSI_QUERY_CPEID.
Referenced by ast_adsi_get_cpeid().
{
int bytes = 0;
buf[bytes++] = ADSI_QUERY_CPEID;
/* Reserve space for length */
bytes++;
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_query_cpeinfo | ( | unsigned char * | buf | ) |
Definition at line 574 of file res_adsi.c.
References ADSI_QUERY_CONFIG.
Referenced by ast_adsi_get_cpeinfo().
{
int bytes = 0;
buf[bytes++] = ADSI_QUERY_CONFIG;
/* Reserve space for length */
bytes++;
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_read_encoded_dtmf | ( | struct ast_channel * | chan, |
| unsigned char * | buf, | ||
| int | maxlen | ||
| ) |
Read some encoded DTMF data. Returns number of bytes received
Definition at line 584 of file res_adsi.c.
References ast_waitfordigit().
Referenced by ast_adsi_get_cpeid().
{
int bytes = 0, res, gotstar = 0, pos = 0;
unsigned char current = 0;
memset(buf, 0, sizeof(buf));
while (bytes <= maxlen) {
/* Wait up to a second for a digit */
if (!(res = ast_waitfordigit(chan, 1000))) {
break;
}
if (res == '*') {
gotstar = 1;
continue;
}
/* Ignore anything other than a digit */
if ((res < '0') || (res > '9')) {
continue;
}
res -= '0';
if (gotstar) {
res += 9;
}
if (pos) {
pos = 0;
buf[bytes++] = (res << 4) | current;
} else {
pos = 1;
current = res;
}
gotstar = 0;
}
return bytes;
}
| int ast_adsi_set_keys | ( | unsigned char * | buf, |
| unsigned char * | keys | ||
| ) |
Set which soft keys should be displayed.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| keys | Array of 8 unsigned chars with the key numbers, may be OR'd with ADSI_KEY_HILITE But remember, the last two keys aren't real keys, they're for scrolling |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 896 of file res_adsi.c.
References ADSI_INIT_SOFTKEY_LINE.
Referenced by adsi_delete(), adsi_folders(), adsi_login(), adsi_message(), adsi_password(), adsi_status(), adsi_status2(), and ast_adsi_channel_restore().
{
int bytes = 0, x;
/* Message type */
buf[bytes++] = ADSI_INIT_SOFTKEY_LINE;
/* Space for size */
bytes++;
/* Key definitions */
for (x = 0; x < 6; x++) {
buf[bytes++] = (keys[x] & 0x3f) ? keys[x] : (keys[x] | 0x1);
}
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_set_line | ( | unsigned char * | buf, |
| int | page, | ||
| int | line | ||
| ) |
Sets the current line and page.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| page | Which page (ADSI_COMM_PAGE or ADSI_INFO_PAGE) |
| line | Line number (1-33 for info page, 1-4 for comm page) |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 912 of file res_adsi.c.
References ADSI_LINE_CONTROL.
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_message(), adsi_password(), adsi_prog(), adsi_status(), adsi_status2(), ast_adsi_channel_restore(), ast_adsi_print(), vm_newuser(), vm_options(), and vm_tempgreeting().
{
int bytes = 0;
/* Sanity check line number */
if (page) {
if (line > 4) return -1;
} else {
if (line > 33) return -1;
}
if (line < 1) {
return -1;
}
/* Parameter type */
buf[bytes++] = ADSI_LINE_CONTROL;
/* Reserve space for size */
bytes++;
/* Page and line */
buf[bytes++] = ((page & 0x1) << 7) | (line & 0x3f);
buf[1] = bytes - 2;
return bytes;
}
| int ast_adsi_transmit_message | ( | struct ast_channel * | chan, |
| unsigned char * | msg, | ||
| int | msglen, | ||
| int | msgtype | ||
| ) |
Definition at line 436 of file res_adsi.c.
References ast_adsi_transmit_message_full().
Referenced by adsi_delete(), adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_message(), adsi_password(), adsi_prog(), adsi_status(), adsi_status2(), vm_newuser(), vm_options(), and vm_tempgreeting().
{
return ast_adsi_transmit_message_full(chan, msg, msglen, msgtype, 1);
}
| int ast_adsi_transmit_message_full | ( | struct ast_channel * | chan, |
| unsigned char * | msg, | ||
| int | msglen, | ||
| int | msgtype, | ||
| int | dowait | ||
| ) |
Definition at line 365 of file res_adsi.c.
References __adsi_transmit_messages(), ADSI_FLAG_DATAMODE, ADSI_SWITCH_TO_DATA, ADSI_SWITCH_TO_VOICE, ast_channel::adsicpe, ast_debug, AST_FORMAT_ULAW, ast_log(), ast_safe_sleep(), ast_set_read_format(), ast_set_write_format(), ast_stopstream(), ast_waitfordigit(), LOG_WARNING, ast_channel::readformat, and ast_channel::writeformat.
Referenced by ast_adsi_begin_download(), ast_adsi_channel_restore(), ast_adsi_end_download(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_adsi_print(), ast_adsi_transmit_message(), and ast_adsi_unload_session().
{
unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
int msglens[5], msgtypes[5], newdatamode = (chan->adsicpe & ADSI_FLAG_DATAMODE), res, x, writeformat = chan->writeformat, readformat = chan->readformat, waitforswitch = 0;
for (x = 0; x < msglen; x += (msg[x+1]+2)) {
if (msg[x] == ADSI_SWITCH_TO_DATA) {
ast_debug(1, "Switch to data is sent!\n");
waitforswitch++;
newdatamode = ADSI_FLAG_DATAMODE;
}
if (msg[x] == ADSI_SWITCH_TO_VOICE) {
ast_debug(1, "Switch to voice is sent!\n");
waitforswitch++;
newdatamode = 0;
}
}
msgs[0] = msg;
msglens[0] = msglen;
msgtypes[0] = msgtype;
if (msglen > 253) {
ast_log(LOG_WARNING, "Can't send ADSI message of %d bytes, too large\n", msglen);
return -1;
}
ast_stopstream(chan);
if (ast_set_write_format(chan, AST_FORMAT_ULAW)) {
ast_log(LOG_WARNING, "Unable to set write format to ULAW\n");
return -1;
}
if (ast_set_read_format(chan, AST_FORMAT_ULAW)) {
ast_log(LOG_WARNING, "Unable to set read format to ULAW\n");
if (writeformat) {
if (ast_set_write_format(chan, writeformat)) {
ast_log(LOG_WARNING, "Unable to restore write format to %d\n", writeformat);
}
}
return -1;
}
res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes);
if (dowait) {
ast_debug(1, "Wait for switch is '%d'\n", waitforswitch);
while (waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) {
res = 0;
ast_debug(1, "Waiting for 'B'...\n");
}
}
if (!res) {
chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode;
}
if (writeformat) {
ast_set_write_format(chan, writeformat);
}
if (readformat) {
ast_set_read_format(chan, readformat);
}
if (!res) {
res = ast_safe_sleep(chan, 100 );
}
return res;
}
| int ast_adsi_unload_session | ( | struct ast_channel * | chan | ) |
Definition at line 1024 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_disconnect_session(), ast_adsi_transmit_message_full(), and ast_adsi_voice_mode().
Referenced by adsi_prog(), cpeid_exec(), park_call_full(), and vm_execmain().
{
unsigned char dsp[256] = "";
int bytes = 0;
/* Connect to session */
bytes += ast_adsi_disconnect_session(dsp + bytes);
bytes += ast_adsi_voice_mode(dsp + bytes, 0);
/* Prepare key setup messages */
if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
return -1;
}
return 0;
}
| int ast_adsi_voice_mode | ( | unsigned char * | buf, |
| int | when | ||
| ) |
Puts CPE in voice mode.
| buf | Character buffer to create parameter in (must have at least 256 free) |
| when | (a time in seconds) to make the switch |
| number | of bytes added to buffer |
| -1 | on error. |
Definition at line 764 of file res_adsi.c.
References ADSI_SWITCH_TO_VOICE.
Referenced by adsi_delete(), adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_message(), adsi_password(), adsi_status(), adsi_status2(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_print(), ast_adsi_unload_session(), vm_newuser(), vm_options(), and vm_tempgreeting().
{
int bytes = 0;
/* Message type */
buf[bytes++] = ADSI_SWITCH_TO_VOICE;
/* Reserve space for length */
bytes++;
buf[bytes++] = when & 0x7f;
buf[1] = bytes - 2;
return bytes;
}