コード例 #1
0
static int adsi_generate(unsigned char *buf, int msgtype, char *msg, int msglen, int msgnum, int last, int codec)
{
	int sum;
	int x;	
	int bytes=0;
	/* Initial carrier (imaginary) */
	float cr = 1.0;
	float ci = 0.0;
	float scont = 0.0;

	if (msglen > 255)
		msglen = 255;

	/* If first message, Send 150ms of MARK's */
	if (msgnum == 1) {
		for (x=0;x<150;x++)	/* was 150 */
			PUT_CLID_MARKMS;
	}
	/* Put message type */
	PUT_CLID(msgtype);
	sum = msgtype;

	/* Put message length (plus one  for the message number) */
	PUT_CLID(msglen + 1);
	sum += msglen + 1;

	/* Put message number */
	PUT_CLID(msgnum);
	sum += msgnum;

	/* Put actual message */
	for (x=0;x<msglen;x++) {
		PUT_CLID(msg[x]);
		sum += msg[x];
	}

	/* Put 2's compliment of sum */
	PUT_CLID(256-(sum & 0xff));

#if 0
	if (last) {
		/* Put trailing marks */
		for (x=0;x<50;x++)
			PUT_CLID_MARKMS;
	}
#endif
	return bytes;

}
コード例 #2
0
ファイル: callerid.c プロジェクト: jpmcneely/Asterisk
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, format_t codec)
{
	int bytes = 0;
	int x, sum;
	int len;

	/* Initial carriers (real/imaginary) */
	float cr = 1.0;
	float ci = 0.0;
	float scont = 0.0;
	char msg[256];
	len = callerid_genmsg(msg, sizeof(msg), number, name, flags);
	if (!callwaiting) {
		/* Wait a half a second */
		for (x = 0; x < 4000; x++)
			PUT_BYTE(0x7f);
		/* Transmit 30 0x55's (looks like a square wave) for channel seizure */
		for (x = 0; x < 30; x++)
			PUT_CLID(0x55);
	}
	/* Send 150ms of callerid marks */
	for (x = 0; x < 150; x++)
		PUT_CLID_MARKMS;
	/* Send 0x80 indicating MDMF format */
	PUT_CLID(0x80);
	/* Put length of whole message */
	PUT_CLID(len);
	sum = 0x80 + strlen(msg);
	/* Put each character of message and update checksum */
	for (x = 0; x < len; x++) {
		PUT_CLID(msg[x]);
		sum += msg[x];
	}
	/* Send 2's compliment of sum */
	PUT_CLID(256 - (sum & 255));

	/* Send 50 more ms of marks */
	for (x = 0; x < 50; x++)
		PUT_CLID_MARKMS;
	
	return bytes;
}
コード例 #3
0
ファイル: callerid.c プロジェクト: jpmcneely/Asterisk
int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, format_t codec,
			       const char* name, const char* number, int flags)
{
	char msg[256];
	int len = 0;
	int sum;
	int x;
	int bytes = 0;
	float cr = 1.0;
	float ci = 0.0;
	float scont = 0.0;
	
	if (type == CID_MWI_TYPE_MDMF_FULL) {
		/* MDMF Message waiting with date, number, name and MWI parameter */
		msg[0] = 0x82;

		/* put date, number info at the right place */
		len = callerid_genmsg(msg+2, sizeof(msg)-2, number, name, flags); 
		
		/* length of MDMF CLI plus Message Waiting Structure */
		msg[1] = len+3;
		
		/* Go to the position to write to */
		len = len+2;
		
		/* "Message Waiting Parameter" */
		msg[len++] = 0x0b;
		/* Length of IE is one */
		msg[len++] = 1;
		/* Active or not */
		if (active)
			msg[len++] = 0xff;
		else
			msg[len++] = 0x00;
		
	} else if (type == CID_MWI_TYPE_MDMF) {
		/* MDMF Message waiting only */
		/* same as above except that the we only put MWI parameter */
		msg[len++] = 0x82;
		/* Length is 3 */
		msg[len++] = 3;
		/* IE is "Message Waiting Parameter" */
		msg[len++] = 0x0b;
		/* Length of IE is one */
		msg[len++] = 1;
		/* Active or not */
		if (active)
			msg[len++] = 0xff;
		else
			msg[len++] = 0x00;
	} else {
		/* SDMF Message waiting */
		msg[len++] = 0x6;
		/* Length is 3 */
		msg[len++] = 3;
		if (active) {
			msg[len++] = 0x42;
			msg[len++] = 0x42;
			msg[len++] = 0x42;
		} else {
			msg[len++] = 0x6f;
			msg[len++] = 0x6f;
			msg[len++] = 0x6f;
		}
	}
	sum = 0;
	for (x = 0; x < len; x++)
		sum += msg[x];
	sum = (256 - (sum & 255));
	msg[len++] = sum;
	/* Wait a half a second */
	for (x = 0; x < 4000; x++)
		PUT_BYTE(0x7f);
	/* Transmit 30 0x55's (looks like a square wave) for channel seizure */
	for (x = 0; x < 30; x++)
		PUT_CLID(0x55);
	/* Send 170ms of callerid marks */
	for (x = 0; x < 170; x++)
		PUT_CLID_MARKMS;
	for (x = 0; x < len; x++) {
		PUT_CLID(msg[x]);
	}
	/* Send 50 more ms of marks */
	for (x = 0; x < 50; x++)
		PUT_CLID_MARKMS;
	return bytes;
}