/* talker.c prints received LNP messages on LCD and sends a message every 0.5 seconds */

#include <conio.h>
#include <unistd.h>
#include <string.h>
#include <lnp.h>

static int quit = 0;

void my_integrity_handler(const unsigned char *data, unsigned char len)
{
	char msg[7];
	int i;

	if (len > 5) len = 5;
	for (i = 0; (i < len); i++) msg[i] = data[i];
	msg[i] = '\0';
	cputs(msg);
	if (data[0] == 'o') quit = 1;
}

int main()
{
	char *s = "msg   ";
	int loop = 0;
	
	lnp_integrity_set_handler(my_integrity_handler);
	cputs("ready");

	while(!quit)
	{
		s[4] = '0' + loop / 10;
		s[5] = '0' + loop % 10;
		lnp_integrity_write(s,strlen(s));
		msleep(500);
		loop = (loop + 1) % 100;
	}
	return 0;
}


