Exemplo n.º 1
0
int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
{
	char buf[256];
	int bytes = 0;
	int res;
	bytes += adsi_data_mode(buf);
	adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);

	bytes = 0;
	bytes += adsi_query_cpeid(buf);
	adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);

	/* Get response */
	memset(buf, 0, sizeof(buf));
	res = 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 += adsi_voice_mode(buf, 0);
		adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
		/* Ignore the resulting DTMF B announcing it's in voice mode */
		ast_waitfordigit(chan, 1000);
	}
	return res;
}
Exemplo n.º 2
0
static int adsi_unload_session(struct ast_channel *chan)
{
	unsigned char dsp[256] = "";
	int bytes = 0;

	/* Connect to session */
	bytes += adsi_disconnect_session(dsp + bytes);
	bytes += adsi_voice_mode(dsp + bytes, 0);

	/* Prepare key setup messages */
	if (adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
		return -1;
	}

	return 0;
}
Exemplo n.º 3
0
int adsi_unload_session(struct ast_channel *chan)
{
	char dsp[256];
	int bytes;

	memset(dsp, 0, sizeof(dsp));

	/* Connect to session */
	bytes = 0;
	bytes += adsi_disconnect_session(dsp + bytes);
	bytes += adsi_voice_mode(dsp + bytes, 0);

	/* Prepare key setup messages */
	if (adsi_transmit_message(chan, dsp, bytes, ADSI_MSG_DISPLAY))
		return -1;
	return 0;
}
Exemplo n.º 4
0
int adsi_print(struct ast_channel *chan, char **lines, int *aligns, int voice)
{
	char buf[4096];
	int bytes=0;
	int res;
	int x;
	for(x=0;lines[x];x++) 
		bytes += adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, aligns[x],0, lines[x], "");
	bytes += adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1);
	if (voice) {
		bytes += adsi_voice_mode(buf + bytes, 0);
	}
	res = adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
	if (voice) {
		/* Ignore the resulting DTMF B announcing it's in voice mode */
		ast_waitfordigit(chan, 1000);
	}
	return res;
}
Exemplo n.º 5
0
int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
{
	char buf[256];
	int bytes = 0;
	int res;
	bytes += adsi_data_mode(buf);
	adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);

	bytes = 0;
	bytes += adsi_query_cpeinfo(buf);
	adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);

	/* Get width */
	memset(buf, 0, sizeof(buf));
	res = ast_readstring(chan, buf, 2, 1000, 500, "");
	if (res < 0)
		return res;
	if (strlen(buf) != 2) {
		ast_log(LOG_WARNING, "Got %d bytes of width, expecting 2\n", res);
		res = 0;
	} else {
		res = 1;
	}
	if (width)
		*width = atoi(buf);
	/* Get height */
	memset(buf, 0, sizeof(buf));
	if (res) {
		res = ast_readstring(chan, buf, 2, 1000, 500, "");
		if (res < 0)
			return res;
		if (strlen(buf) != 2) {
			ast_log(LOG_WARNING, "Got %d bytes of height, expecting 2\n", res);
			res = 0;
		} else {
			res = 1;
		}	
		if (height)
			*height= atoi(buf);
	}
	/* Get buttons */
	memset(buf, 0, sizeof(buf));
	if (res) {
		res = ast_readstring(chan, buf, 1, 1000, 500, "");
		if (res < 0)
			return res;
		if (strlen(buf) != 1) {
			ast_log(LOG_WARNING, "Got %d bytes of buttons, expecting 1\n", res);
			res = 0;
		} else {
			res = 1;
		}	
		if (buttons)
			*buttons = atoi(buf);
	}
	if (voice) {
		bytes = 0;
		bytes += adsi_voice_mode(buf, 0);
		adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
		/* Ignore the resulting DTMF B announcing it's in voice mode */
		ast_waitfordigit(chan, 1000);
	}
	return res;
}