int AST_OPTIONAL_API_NAME(ast_adsi_get_cpeid)(struct ast_channel *chan, unsigned char *cpeid, int voice) { 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; }
static int _ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice) { 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; }
static int _ast_adsi_unload_session(struct ast_channel *chan) { 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; }
static int _ast_adsi_print(struct ast_channel *chan, char **lines, int *aligns, int voice) { 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, aligns[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; }