#include "asterisk/callerid.h"
Include dependency graph for adsi.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | ADSI_BACKSPACE 0x89 |
#define | ADSI_BLANK 0x86 |
#define | ADSI_CLEAR_CALL_B 0x95 |
#define | ADSI_CLEAR_CALL_BUF 145 |
#define | ADSI_CLEAR_CHARS 0x88 |
#define | ADSI_CLEAR_SCREEN 148 |
#define | ADSI_CLEAR_SOFTKEY 136 |
#define | ADSI_CLEAR_TYPE_AHEAD 143 |
#define | ADSI_COMM_PAGE 0x1 |
#define | ADSI_CONNECT_SESSION 142 |
#define | ADSI_DELAY 0x90 |
#define | ADSI_DIAL_PULSE_ONE 0x91 |
#define | ADSI_DIAL_TONE_DETECT 0x84 |
#define | ADSI_DIR_FROM_LEFT (0) |
#define | ADSI_DIR_FROM_RIGHT (1) |
#define | ADSI_DISC_SESSION 133 |
#define | ADSI_DISP_CALL_BUF 0x94 |
#define | ADSI_DISPLAY_CALL_BUF 144 |
#define | ADSI_DOWNLOAD_CONNECT 131 |
#define | ADSI_DOWNLOAD_DISC 132 |
#define | ADSI_ENCODED_DTMF 0x80 |
#define | ADSI_EXTENDED_DTMF 0x8F |
#define | ADSI_FLASH 0x83 |
#define | ADSI_GOTO_LINE 0x8B |
#define | ADSI_GOTO_LINE_REL 0x8C |
#define | ADSI_INFO_PAGE 0x0 |
#define | ADSI_INFORMATION 132 |
#define | ADSI_INIT_SOFTKEY_LINE 129 |
#define | ADSI_INPUT_CONTROL 137 |
#define | ADSI_INPUT_FORMAT 138 |
#define | ADSI_JUST_CENT 0x0 |
#define | ADSI_JUST_IND 0x3 |
#define | ADSI_JUST_LEFT 0x2 |
#define | ADSI_JUST_RIGHT 0x1 |
#define | ADSI_KEY_APPS 16 |
#define | ADSI_KEY_HILITE 0x40 |
#define | ADSI_KEY_SKT 0x80 |
#define | ADSI_LINE_CONTROL 131 |
#define | ADSI_LINE_NUMBER 0x85 |
#define | ADSI_LOAD_DEFAULT 141 |
#define | ADSI_LOAD_PREDEF_DISP 129 |
#define | ADSI_LOAD_SCRIPT 130 |
#define | ADSI_LOAD_SOFTKEY 128 |
#define | ADSI_LOAD_SOFTKEY_TABLE 128 |
#define | ADSI_LOAD_VIRTUAL_DISP 130 |
#define | ADSI_MOVE_DATA 140 |
#define | ADSI_MSG_DISPLAY 132 |
#define | ADSI_MSG_DOWNLOAD 133 |
#define | ADSI_OFF_HOOK 0x82 |
#define | ADSI_ON_HOOK 0x81 |
#define | ADSI_PAGE_DOWN 0x8E |
#define | ADSI_PAGE_UP 0x8D |
#define | ADSI_QUERY_CONFIG 149 |
#define | ADSI_QUERY_CPEID 150 |
#define | ADSI_SEND_CHARS 0x87 |
#define | ADSI_SWITCH_TO_ALT 146 |
#define | ADSI_SWITCH_TO_APP 151 |
#define | ADSI_SWITCH_TO_DATA 134 |
#define | ADSI_SWITCH_TO_DATA2 0x92 |
#define | ADSI_SWITCH_TO_GRAPHICS 147 |
#define | ADSI_SWITCH_TO_PERIPH 139 |
#define | ADSI_SWITCH_TO_VOICE 135 |
#define | ADSI_SWITCH_TO_VOICE2 0x93 |
#define | ADSI_TAB_COLUMN 0x8A |
Functions | |
int | ast_adsi_available (struct ast_channel *chan) |
int | ast_adsi_begin_download (struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version) |
int | ast_adsi_channel_init (struct ast_channel *chan) |
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) |
int | ast_adsi_data_mode (unsigned char *buf) |
int | ast_adsi_disconnect_session (unsigned char *buf) |
int | ast_adsi_display (unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2) |
int | ast_adsi_download_connect (unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver) |
int | ast_adsi_download_disconnect (unsigned char *buf) |
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) |
int | ast_adsi_input_format (unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2) |
int | ast_adsi_load_session (struct ast_channel *chan, unsigned char *app, int ver, int data) |
int | ast_adsi_load_soft_key (unsigned char *buf, int key, const char *llabel, const char *slabel, const char *ret, int data) |
int | ast_adsi_print (struct ast_channel *chan, char **lines, int *align, int voice) |
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) |
int | ast_adsi_set_line (unsigned char *buf, int page, int line) |
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_transmit_messages (struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype) |
int | ast_adsi_unload_session (struct ast_channel *chan) |
int | ast_adsi_voice_mode (unsigned char *buf, int when) |
Definition in file adsi.h.
#define ADSI_CLEAR_SCREEN 148 |
#define ADSI_CLEAR_SOFTKEY 136 |
#define ADSI_COMM_PAGE 0x1 |
Definition at line 104 of file adsi.h.
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_logo(), adsi_password(), adsi_status(), adsi_status2(), vm_newuser(), vm_options(), and vm_tempgreeting().
#define ADSI_CONNECT_SESSION 142 |
#define ADSI_DIR_FROM_LEFT (0) |
#define ADSI_DISC_SESSION 133 |
#define ADSI_DOWNLOAD_CONNECT 131 |
#define ADSI_DOWNLOAD_DISC 132 |
#define ADSI_INFO_PAGE 0x0 |
Definition at line 103 of file adsi.h.
Referenced by ast_adsi_channel_restore(), and ast_adsi_print().
#define ADSI_INIT_SOFTKEY_LINE 129 |
#define ADSI_INPUT_CONTROL 137 |
#define ADSI_INPUT_FORMAT 138 |
#define ADSI_JUST_CENT 0x0 |
Definition at line 111 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 |
#define ADSI_JUST_LEFT 0x2 |
Definition at line 109 of file adsi.h.
Referenced by adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_password(), adsi_status(), adsi_status2(), cpeid_setstatus(), and str2align().
#define ADSI_JUST_RIGHT 0x1 |
#define ADSI_KEY_APPS 16 |
Definition at line 106 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 114 of file adsi.h.
Referenced by adsi_delete(), adsi_folders(), adsi_message(), adsi_status(), and adsi_status2().
#define ADSI_LINE_CONTROL 131 |
#define ADSI_LOAD_SOFTKEY 128 |
#define ADSI_LOAD_VIRTUAL_DISP 130 |
#define ADSI_MSG_DISPLAY 132 |
Definition at line 29 of file adsi.h.
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_password(), 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 30 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 |
#define ADSI_QUERY_CPEID 150 |
#define ADSI_SWITCH_TO_DATA 134 |
Definition at line 39 of file adsi.h.
Referenced by ast_adsi_data_mode(), and ast_adsi_transmit_message_full().
#define ADSI_SWITCH_TO_DATA2 0x92 |
#define ADSI_SWITCH_TO_VOICE 135 |
Definition at line 40 of file adsi.h.
Referenced by ast_adsi_transmit_message_full(), and ast_adsi_voice_mode().
int ast_adsi_available | ( | struct ast_channel * | chan | ) |
chan | Channel to check |
Definition at line 768 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(), ast_park_call(), vm_newuser(), vm_options(), and vm_tempgreeting().
00769 { 00770 int cpe = chan->adsicpe & 0xff; 00771 if ((cpe == AST_ADSI_AVAILABLE) || 00772 (cpe == AST_ADSI_UNKNOWN)) 00773 return 1; 00774 return 0; 00775 }
int ast_adsi_begin_download | ( | struct ast_channel * | chan, | |
char * | service, | |||
unsigned char * | fdn, | |||
unsigned char * | sec, | |||
int | version | |||
) |
Definition at line 325 of file res_adsi.c.
References ADSI_MSG_DOWNLOAD, ast_adsi_download_connect(), ast_adsi_transmit_message_full(), ast_log(), ast_readstring(), and LOG_DEBUG.
Referenced by adsi_load_vmail(), and adsi_prog().
00326 { 00327 int bytes; 00328 unsigned char buf[256]; 00329 char ack[2]; 00330 bytes = 0; 00331 /* Setup the resident soft key stuff, a piece at a time */ 00332 /* Upload what scripts we can for voicemail ahead of time */ 00333 bytes += ast_adsi_download_connect(buf + bytes, service, fdn, sec, version); 00334 if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) 00335 return -1; 00336 if (ast_readstring(chan, ack, 1, 10000, 10000, "")) 00337 return -1; 00338 if (ack[0] == 'B') 00339 return 0; 00340 ast_log(LOG_DEBUG, "Download was denied by CPE\n"); 00341 return -1; 00342 }
int ast_adsi_channel_init | ( | struct ast_channel * | chan | ) |
chan | Channel to initialize for ADSI (if supported) |
int ast_adsi_channel_restore | ( | struct ast_channel * | chan | ) |
chan | Channel to restore |
Definition at line 926 of file res_adsi.c.
References ADSI_INFO_PAGE, ADSI_MSG_DISPLAY, ADSI_SPEED_DIAL, ast_adsi_set_keys(), ast_adsi_set_line(), and ast_adsi_transmit_message_full().
00927 { 00928 unsigned char dsp[256]; 00929 int bytes; 00930 int x; 00931 unsigned char keyd[6]; 00932 00933 memset(dsp, 0, sizeof(dsp)); 00934 00935 /* Start with initial display setup */ 00936 bytes = 0; 00937 bytes += ast_adsi_set_line(dsp + bytes, ADSI_INFO_PAGE, 1); 00938 00939 /* Prepare key setup messages */ 00940 00941 if (speeds) { 00942 memset(keyd, 0, sizeof(keyd)); 00943 for (x=0;x<speeds;x++) { 00944 keyd[x] = ADSI_SPEED_DIAL + x; 00945 } 00946 bytes += ast_adsi_set_keys(dsp + bytes, keyd); 00947 } 00948 ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0); 00949 return 0; 00950 00951 }
int ast_adsi_clear_screen | ( | unsigned char * | buf | ) |
Definition at line 736 of file res_adsi.c.
References ADSI_CLEAR_SCREEN.
00737 { 00738 int bytes=0; 00739 00740 /* Message type */ 00741 buf[bytes++] = ADSI_CLEAR_SCREEN; 00742 00743 /* Reserve space for length */ 00744 bytes++; 00745 00746 buf[1] = bytes - 2; 00747 return bytes; 00748 00749 }
int ast_adsi_clear_soft_keys | ( | unsigned char * | buf | ) |
Definition at line 721 of file res_adsi.c.
References ADSI_CLEAR_SOFTKEY.
00722 { 00723 int bytes=0; 00724 00725 /* Message type */ 00726 buf[bytes++] = ADSI_CLEAR_SOFTKEY; 00727 00728 /* Reserve space for length */ 00729 bytes++; 00730 00731 buf[1] = bytes - 2; 00732 return bytes; 00733 00734 }
int ast_adsi_connect_session | ( | unsigned char * | buf, | |
unsigned char * | fdn, | |||
int | ver | |||
) |
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) |
Definition at line 486 of file res_adsi.c.
References ADSI_CONNECT_SESSION.
Referenced by ast_adsi_load_session().
00487 { 00488 int bytes=0; 00489 int x; 00490 00491 /* Message type */ 00492 buf[bytes++] = ADSI_CONNECT_SESSION; 00493 00494 /* Reserve space for length */ 00495 bytes++; 00496 00497 if (fdn) { 00498 for (x=0;x<4;x++) 00499 buf[bytes++] = fdn[x]; 00500 if (ver > -1) 00501 buf[bytes++] = ver & 0xff; 00502 } 00503 00504 buf[1] = bytes - 2; 00505 return bytes; 00506 00507 }
int ast_adsi_data_mode | ( | unsigned char * | buf | ) |
buf | Character buffer to create parameter in (must have at least 256 free) |
Definition at line 706 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().
00707 { 00708 int bytes=0; 00709 00710 /* Message type */ 00711 buf[bytes++] = ADSI_SWITCH_TO_DATA; 00712 00713 /* Reserve space for length */ 00714 bytes++; 00715 00716 buf[1] = bytes - 2; 00717 return bytes; 00718 00719 }
int ast_adsi_disconnect_session | ( | unsigned char * | buf | ) |
buf | Character buffer to create parameter in (must have at least 256 free) |
Definition at line 539 of file res_adsi.c.
References ADSI_DISC_SESSION.
Referenced by ast_adsi_unload_session().
00540 { 00541 int bytes=0; 00542 00543 /* Message type */ 00544 buf[bytes++] = ADSI_DISC_SESSION; 00545 00546 /* Reserve space for length */ 00547 bytes++; 00548 00549 buf[1] = bytes - 2; 00550 return bytes; 00551 00552 }
int ast_adsi_display | ( | unsigned char * | buf, | |
int | page, | |||
int | line, | |||
int | just, | |||
int | wrap, | |||
char * | col1, | |||
char * | col2 | |||
) |
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 |
Definition at line 792 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_status(), adsi_status2(), ast_adsi_print(), vm_newuser(), vm_options(), and vm_tempgreeting().
00794 { 00795 int bytes=0; 00796 00797 /* Sanity check line number */ 00798 00799 if (page) { 00800 if (line > 4) return -1; 00801 } else { 00802 if (line > 33) return -1; 00803 } 00804 00805 if (line < 1) 00806 return -1; 00807 /* Parameter type */ 00808 buf[bytes++] = ADSI_LOAD_VIRTUAL_DISP; 00809 00810 /* Reserve space for size */ 00811 bytes++; 00812 00813 /* Page and wrap indicator */ 00814 buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f); 00815 00816 /* Justification */ 00817 buf[bytes++] = (just & 0x3) << 5; 00818 00819 /* Omit highlight mode definition */ 00820 buf[bytes++] = 0xff; 00821 00822 /* Primary column */ 00823 bytes+= ccopy(buf + bytes, (unsigned char *)col1, 20); 00824 00825 /* Delimiter */ 00826 buf[bytes++] = 0xff; 00827 00828 /* Secondary column */ 00829 bytes += ccopy(buf + bytes, (unsigned char *)col2, 20); 00830 00831 /* Update length */ 00832 buf[1] = bytes - 2; 00833 00834 return bytes; 00835 00836 }
int ast_adsi_download_connect | ( | unsigned char * | buf, | |
char * | service, | |||
unsigned char * | fdn, | |||
unsigned char * | sec, | |||
int | ver | |||
) |
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) |
Definition at line 509 of file res_adsi.c.
References ADSI_DOWNLOAD_CONNECT, and ccopy().
Referenced by ast_adsi_begin_download().
00510 { 00511 int bytes=0; 00512 int x; 00513 00514 /* Message type */ 00515 buf[bytes++] = ADSI_DOWNLOAD_CONNECT; 00516 00517 /* Reserve space for length */ 00518 bytes++; 00519 00520 /* Primary column */ 00521 bytes+= ccopy(buf + bytes, (unsigned char *)service, 18); 00522 00523 /* Delimiter */ 00524 buf[bytes++] = 0xff; 00525 00526 for (x=0;x<4;x++) { 00527 buf[bytes++] = fdn[x]; 00528 } 00529 for (x=0;x<4;x++) 00530 buf[bytes++] = sec[x]; 00531 buf[bytes++] = ver & 0xff; 00532 00533 buf[1] = bytes - 2; 00534 00535 return bytes; 00536 00537 }
int ast_adsi_download_disconnect | ( | unsigned char * | buf | ) |
buf | Character buffer to create parameter in (must have at least 256 free) |
Definition at line 777 of file res_adsi.c.
References ADSI_DOWNLOAD_DISC.
Referenced by adsi_load_vmail(), and ast_adsi_end_download().
00778 { 00779 int bytes=0; 00780 00781 /* Message type */ 00782 buf[bytes++] = ADSI_DOWNLOAD_DISC; 00783 00784 /* Reserve space for length */ 00785 bytes++; 00786 00787 buf[1] = bytes - 2; 00788 return bytes; 00789 00790 }
int ast_adsi_end_download | ( | struct ast_channel * | chan | ) |
Definition at line 344 of file res_adsi.c.
References ADSI_MSG_DOWNLOAD, ast_adsi_download_disconnect(), and ast_adsi_transmit_message_full().
Referenced by adsi_load_vmail().
00345 { 00346 int bytes; 00347 unsigned char buf[256]; 00348 bytes = 0; 00349 /* Setup the resident soft key stuff, a piece at a time */ 00350 /* Upload what scripts we can for voicemail ahead of time */ 00351 bytes += ast_adsi_download_disconnect(buf + bytes); 00352 if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) 00353 return -1; 00354 return 0; 00355 }
int ast_adsi_get_cpeid | ( | struct ast_channel * | chan, | |
unsigned char * | cpeid, | |||
int | voice | |||
) |
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 609 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().
00610 { 00611 unsigned char buf[256]; 00612 int bytes = 0; 00613 int res; 00614 bytes += ast_adsi_data_mode(buf); 00615 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00616 00617 bytes = 0; 00618 bytes += ast_adsi_query_cpeid(buf); 00619 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00620 00621 /* Get response */ 00622 memset(buf, 0, sizeof(buf)); 00623 res = ast_adsi_read_encoded_dtmf(chan, cpeid, 4); 00624 if (res != 4) { 00625 ast_log(LOG_WARNING, "Got %d bytes back of encoded DTMF, expecting 4\n", res); 00626 res = 0; 00627 } else { 00628 res = 1; 00629 } 00630 00631 if (voice) { 00632 bytes = 0; 00633 bytes += ast_adsi_voice_mode(buf, 0); 00634 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00635 /* Ignore the resulting DTMF B announcing it's in voice mode */ 00636 ast_waitfordigit(chan, 1000); 00637 } 00638 return res; 00639 }
int ast_adsi_get_cpeinfo | ( | struct ast_channel * | chan, | |
int * | width, | |||
int * | height, | |||
int * | buttons, | |||
int | voice | |||
) |
Definition at line 641 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().
00642 { 00643 unsigned char buf[256]; 00644 int bytes = 0; 00645 int res; 00646 bytes += ast_adsi_data_mode(buf); 00647 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00648 00649 bytes = 0; 00650 bytes += ast_adsi_query_cpeinfo(buf); 00651 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00652 00653 /* Get width */ 00654 memset(buf, 0, sizeof(buf)); 00655 res = ast_readstring(chan, (char *)buf, 2, 1000, 500, ""); 00656 if (res < 0) 00657 return res; 00658 if (strlen((char *)buf) != 2) { 00659 ast_log(LOG_WARNING, "Got %d bytes of width, expecting 2\n", res); 00660 res = 0; 00661 } else { 00662 res = 1; 00663 } 00664 if (width) 00665 *width = atoi((char *)buf); 00666 /* Get height */ 00667 memset(buf, 0, sizeof(buf)); 00668 if (res) { 00669 res = ast_readstring(chan, (char *)buf, 2, 1000, 500, ""); 00670 if (res < 0) 00671 return res; 00672 if (strlen((char *)buf) != 2) { 00673 ast_log(LOG_WARNING, "Got %d bytes of height, expecting 2\n", res); 00674 res = 0; 00675 } else { 00676 res = 1; 00677 } 00678 if (height) 00679 *height= atoi((char *)buf); 00680 } 00681 /* Get buttons */ 00682 memset(buf, 0, sizeof(buf)); 00683 if (res) { 00684 res = ast_readstring(chan, (char *)buf, 1, 1000, 500, ""); 00685 if (res < 0) 00686 return res; 00687 if (strlen((char *)buf) != 1) { 00688 ast_log(LOG_WARNING, "Got %d bytes of buttons, expecting 1\n", res); 00689 res = 0; 00690 } else { 00691 res = 1; 00692 } 00693 if (buttons) 00694 *buttons = atoi((char *)buf); 00695 } 00696 if (voice) { 00697 bytes = 0; 00698 bytes += ast_adsi_voice_mode(buf, 0); 00699 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00700 /* Ignore the resulting DTMF B announcing it's in voice mode */ 00701 ast_waitfordigit(chan, 1000); 00702 } 00703 return res; 00704 }
int ast_adsi_input_control | ( | unsigned char * | buf, | |
int | page, | |||
int | line, | |||
int | display, | |||
int | format, | |||
int | just | |||
) |
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) |
Definition at line 838 of file res_adsi.c.
References ADSI_INPUT_CONTROL.
Referenced by adsi_login(), and adsi_password().
00839 { 00840 int bytes=0; 00841 00842 if (page) { 00843 if (line > 4) return -1; 00844 } else { 00845 if (line > 33) return -1; 00846 } 00847 00848 if (line < 1) 00849 return -1; 00850 00851 buf[bytes++] = ADSI_INPUT_CONTROL; 00852 bytes++; 00853 buf[bytes++] = ((page & 1) << 7) | (line & 0x3f); 00854 buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7); 00855 00856 buf[1] = bytes - 2; 00857 return bytes; 00858 00859 }
int ast_adsi_input_format | ( | unsigned char * | buf, | |
int | num, | |||
int | dir, | |||
int | wrap, | |||
char * | format1, | |||
char * | format2 | |||
) |
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 |
Definition at line 861 of file res_adsi.c.
References ADSI_INPUT_FORMAT, and ccopy().
Referenced by adsi_login(), and adsi_password().
00862 { 00863 int bytes = 0; 00864 00865 if (!strlen((char *)format1)) 00866 return -1; 00867 00868 buf[bytes++] = ADSI_INPUT_FORMAT; 00869 bytes++; 00870 buf[bytes++] = ((dir & 1) << 7) | ((wrap & 1) << 6) | (num & 0x7); 00871 bytes += ccopy(buf + bytes, (unsigned char *)format1, 20); 00872 buf[bytes++] = 0xff; 00873 if (format2 && strlen((char *)format2)) { 00874 bytes += ccopy(buf + bytes, (unsigned char *)format2, 20); 00875 } 00876 buf[1] = bytes - 2; 00877 return bytes; 00878 }
int ast_adsi_load_session | ( | struct ast_channel * | chan, | |
unsigned char * | app, | |||
int | ver, | |||
int | data | |||
) |
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 |
Definition at line 973 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_connect_session(), ast_adsi_data_mode(), ast_adsi_transmit_message_full(), ast_log(), ast_readstring(), LOG_DEBUG, and LOG_WARNING.
Referenced by adsi_announce_park(), adsi_begin(), adsi_load_vmail(), adsi_prog(), and cpeid_exec().
00974 { 00975 unsigned char dsp[256]; 00976 int bytes; 00977 int res; 00978 char resp[2]; 00979 00980 memset(dsp, 0, sizeof(dsp)); 00981 00982 /* Connect to session */ 00983 bytes = 0; 00984 bytes += ast_adsi_connect_session(dsp + bytes, app, ver); 00985 00986 if (data) 00987 bytes += ast_adsi_data_mode(dsp + bytes); 00988 00989 /* Prepare key setup messages */ 00990 if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) 00991 return -1; 00992 if (app) { 00993 res = ast_readstring(chan, resp, 1, 1200, 1200, ""); 00994 if (res < 0) 00995 return -1; 00996 if (res) { 00997 ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n"); 00998 return 0; 00999 } 01000 if (!strcmp(resp, "B")) { 01001 ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver); 01002 return 1; 01003 } else if (!strcmp(resp, "A")) { 01004 ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver); 01005 } else { 01006 ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp); 01007 } 01008 } else 01009 return 1; 01010 return 0; 01011 01012 }
int ast_adsi_load_soft_key | ( | unsigned char * | buf, | |
int | key, | |||
const char * | llabel, | |||
const char * | slabel, | |||
const char * | ret, | |||
int | data | |||
) |
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 |
Definition at line 447 of file res_adsi.c.
References ADSI_LOAD_SOFTKEY, ADSI_SWITCH_TO_DATA2, and ccopy().
Referenced by adsi_load_vmail(), and adsi_login().
00448 { 00449 int bytes=0; 00450 00451 /* Abort if invalid key specified */ 00452 if ((key < 2) || (key > 33)) 00453 return -1; 00454 buf[bytes++] = ADSI_LOAD_SOFTKEY; 00455 /* Reserve for length */ 00456 bytes++; 00457 /* Which key */ 00458 buf[bytes++] = key; 00459 00460 /* Carefully copy long label */ 00461 bytes += ccopy(buf + bytes, (const unsigned char *)llabel, 18); 00462 00463 /* Place delimiter */ 00464 buf[bytes++] = 0xff; 00465 00466 /* Short label */ 00467 bytes += ccopy(buf + bytes, (const unsigned char *)slabel, 7); 00468 00469 00470 /* If specified, copy return string */ 00471 if (ret) { 00472 /* Place delimiter */ 00473 buf[bytes++] = 0xff; 00474 if (data) 00475 buf[bytes++] = ADSI_SWITCH_TO_DATA2; 00476 /* Carefully copy return string */ 00477 bytes += ccopy(buf + bytes, (const unsigned char *)ret, 20); 00478 00479 } 00480 /* Replace parameter length */ 00481 buf[1] = bytes - 2; 00482 return bytes; 00483 00484 }
int ast_adsi_print | ( | struct ast_channel * | chan, | |
char ** | lines, | |||
int * | align, | |||
int | voice | |||
) |
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 |
Definition at line 953 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().
00954 { 00955 unsigned char buf[4096]; 00956 int bytes=0; 00957 int res; 00958 int x; 00959 for(x=0;lines[x];x++) 00960 bytes += ast_adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, aligns[x], 0, lines[x], ""); 00961 bytes += ast_adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1); 00962 if (voice) { 00963 bytes += ast_adsi_voice_mode(buf + bytes, 0); 00964 } 00965 res = ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00966 if (voice) { 00967 /* Ignore the resulting DTMF B announcing it's in voice mode */ 00968 ast_waitfordigit(chan, 1000); 00969 } 00970 return res; 00971 }
int ast_adsi_query_cpeid | ( | unsigned char * | buf | ) |
Returns number of bytes added to message
Definition at line 554 of file res_adsi.c.
References ADSI_QUERY_CPEID.
Referenced by ast_adsi_get_cpeid().
00555 { 00556 int bytes = 0; 00557 buf[bytes++] = ADSI_QUERY_CPEID; 00558 /* Reserve space for length */ 00559 bytes++; 00560 buf[1] = bytes - 2; 00561 return bytes; 00562 }
int ast_adsi_query_cpeinfo | ( | unsigned char * | buf | ) |
Definition at line 564 of file res_adsi.c.
References ADSI_QUERY_CONFIG.
Referenced by ast_adsi_get_cpeinfo().
00565 { 00566 int bytes = 0; 00567 buf[bytes++] = ADSI_QUERY_CONFIG; 00568 /* Reserve space for length */ 00569 bytes++; 00570 buf[1] = bytes - 2; 00571 return bytes; 00572 }
int ast_adsi_read_encoded_dtmf | ( | struct ast_channel * | chan, | |
unsigned char * | buf, | |||
int | maxlen | |||
) |
Returns number of bytes received
Definition at line 574 of file res_adsi.c.
References ast_waitfordigit().
Referenced by ast_adsi_get_cpeid().
00575 { 00576 int bytes = 0; 00577 int res; 00578 unsigned char current = 0; 00579 int gotstar = 0; 00580 int pos = 0; 00581 memset(buf, 0, sizeof(buf)); 00582 while(bytes <= maxlen) { 00583 /* Wait up to a second for a digit */ 00584 res = ast_waitfordigit(chan, 1000); 00585 if (!res) 00586 break; 00587 if (res == '*') { 00588 gotstar = 1; 00589 continue; 00590 } 00591 /* Ignore anything other than a digit */ 00592 if ((res < '0') || (res > '9')) 00593 continue; 00594 res -= '0'; 00595 if (gotstar) 00596 res += 9; 00597 if (pos) { 00598 pos = 0; 00599 buf[bytes++] = (res << 4) | current; 00600 } else { 00601 pos = 1; 00602 current = res; 00603 } 00604 gotstar = 0; 00605 } 00606 return bytes; 00607 }
int ast_adsi_set_keys | ( | unsigned char * | buf, | |
unsigned char * | keys | |||
) |
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 |
Definition at line 880 of file res_adsi.c.
References ADSI_INIT_SOFTKEY_LINE.
Referenced by adsi_folders(), adsi_login(), adsi_password(), adsi_status(), adsi_status2(), and ast_adsi_channel_restore().
00881 { 00882 int bytes=0; 00883 int x; 00884 /* Message type */ 00885 buf[bytes++] = ADSI_INIT_SOFTKEY_LINE; 00886 /* Space for size */ 00887 bytes++; 00888 /* Key definitions */ 00889 for (x=0;x<6;x++) 00890 buf[bytes++] = (keys[x] & 0x3f) ? keys[x] : (keys[x] | 0x1); 00891 buf[1] = bytes - 2; 00892 return bytes; 00893 }
int ast_adsi_set_line | ( | unsigned char * | buf, | |
int | page, | |||
int | line | |||
) |
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) |
Definition at line 895 of file res_adsi.c.
References ADSI_LINE_CONTROL.
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_password(), adsi_status(), adsi_status2(), ast_adsi_channel_restore(), ast_adsi_print(), vm_newuser(), vm_options(), and vm_tempgreeting().
00896 { 00897 int bytes=0; 00898 00899 /* Sanity check line number */ 00900 00901 if (page) { 00902 if (line > 4) return -1; 00903 } else { 00904 if (line > 33) return -1; 00905 } 00906 00907 if (line < 1) 00908 return -1; 00909 /* Parameter type */ 00910 buf[bytes++] = ADSI_LINE_CONTROL; 00911 00912 /* Reserve space for size */ 00913 bytes++; 00914 00915 /* Page and line */ 00916 buf[bytes++] = ((page & 0x1) << 7) | (line & 0x3f); 00917 00918 buf[1] = bytes - 2; 00919 return bytes; 00920 00921 };
int ast_adsi_transmit_message | ( | struct ast_channel * | chan, | |
unsigned char * | msg, | |||
int | msglen, | |||
int | msgtype | |||
) |
Definition at line 431 of file res_adsi.c.
References ast_adsi_transmit_message_full().
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_password(), adsi_prog(), adsi_status(), adsi_status2(), vm_newuser(), vm_options(), and vm_tempgreeting().
00432 { 00433 return ast_adsi_transmit_message_full(chan, msg, msglen, msgtype, 1); 00434 }
int ast_adsi_transmit_message_full | ( | struct ast_channel * | chan, | |
unsigned char * | msg, | |||
int | msglen, | |||
int | msgtype, | |||
int | dowait | |||
) |
Definition at line 357 of file res_adsi.c.
References __adsi_transmit_messages(), ADSI_FLAG_DATAMODE, ADSI_SWITCH_TO_DATA, ADSI_SWITCH_TO_VOICE, ast_channel::adsicpe, AST_FORMAT_ULAW, ast_log(), ast_safe_sleep(), ast_set_read_format(), ast_set_write_format(), ast_stopstream(), ast_waitfordigit(), LOG_DEBUG, 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().
00358 { 00359 unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL }; 00360 int msglens[5]; 00361 int msgtypes[5]; 00362 int newdatamode; 00363 int res; 00364 int x; 00365 int writeformat, readformat; 00366 int waitforswitch = 0; 00367 00368 writeformat = chan->writeformat; 00369 readformat = chan->readformat; 00370 00371 newdatamode = chan->adsicpe & ADSI_FLAG_DATAMODE; 00372 00373 for (x=0;x<msglen;x+=(msg[x+1]+2)) { 00374 if (msg[x] == ADSI_SWITCH_TO_DATA) { 00375 ast_log(LOG_DEBUG, "Switch to data is sent!\n"); 00376 waitforswitch++; 00377 newdatamode = ADSI_FLAG_DATAMODE; 00378 } 00379 00380 if (msg[x] == ADSI_SWITCH_TO_VOICE) { 00381 ast_log(LOG_DEBUG, "Switch to voice is sent!\n"); 00382 waitforswitch++; 00383 newdatamode = 0; 00384 } 00385 } 00386 msgs[0] = msg; 00387 00388 msglens[0] = msglen; 00389 msgtypes[0] = msgtype; 00390 00391 if (msglen > 253) { 00392 ast_log(LOG_WARNING, "Can't send ADSI message of %d bytes, too large\n", msglen); 00393 return -1; 00394 } 00395 00396 ast_stopstream(chan); 00397 00398 if (ast_set_write_format(chan, AST_FORMAT_ULAW)) { 00399 ast_log(LOG_WARNING, "Unable to set write format to ULAW\n"); 00400 return -1; 00401 } 00402 00403 if (ast_set_read_format(chan, AST_FORMAT_ULAW)) { 00404 ast_log(LOG_WARNING, "Unable to set read format to ULAW\n"); 00405 if (writeformat) { 00406 if (ast_set_write_format(chan, writeformat)) 00407 ast_log(LOG_WARNING, "Unable to restore write format to %d\n", writeformat); 00408 } 00409 return -1; 00410 } 00411 res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes); 00412 00413 if (dowait) { 00414 ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch); 00415 while(waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) { res = 0; ast_log(LOG_DEBUG, "Waiting for 'B'...\n"); } 00416 } 00417 00418 if (!res) 00419 chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode; 00420 00421 if (writeformat) 00422 ast_set_write_format(chan, writeformat); 00423 if (readformat) 00424 ast_set_read_format(chan, readformat); 00425 00426 if (!res) 00427 res = ast_safe_sleep(chan, 100 ); 00428 return res; 00429 }
int ast_adsi_transmit_messages | ( | struct ast_channel * | chan, | |
unsigned char ** | msg, | |||
int * | msglen, | |||
int * | msgtype | |||
) |
int ast_adsi_unload_session | ( | struct ast_channel * | chan | ) |
Definition at line 1014 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 ast_park_call(), cpeid_exec(), and vm_execmain().
01015 { 01016 unsigned char dsp[256]; 01017 int bytes; 01018 01019 memset(dsp, 0, sizeof(dsp)); 01020 01021 /* Connect to session */ 01022 bytes = 0; 01023 bytes += ast_adsi_disconnect_session(dsp + bytes); 01024 bytes += ast_adsi_voice_mode(dsp + bytes, 0); 01025 01026 /* Prepare key setup messages */ 01027 if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) 01028 return -1; 01029 return 0; 01030 }
int ast_adsi_voice_mode | ( | unsigned char * | buf, | |
int | when | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
when | (a time in seconds) to make the switch |
Definition at line 751 of file res_adsi.c.
References ADSI_SWITCH_TO_VOICE.
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), 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().
00752 { 00753 int bytes=0; 00754 00755 /* Message type */ 00756 buf[bytes++] = ADSI_SWITCH_TO_VOICE; 00757 00758 /* Reserve space for length */ 00759 bytes++; 00760 00761 buf[bytes++] = when & 0x7f; 00762 00763 buf[1] = bytes - 2; 00764 return bytes; 00765 00766 }