Code:
/*
If a confirmation of connection was received (0x02)
tell the user we're connected.
Otherwise parse the data received
and take appropriate action
App. Protocol:
Hex(02) Successfully Connected to Controller
D,char where char is Date
L,char where char is the Location
R,int where int = Number Rounds
Q,int where int = Number of Questions (Not Implemented yet)
T,char where char = Team Name
*/
if (strncmp(recBuff,"\x02",1) == 0)
{
printTop("Connected");
}
else
{
if(sscanf(recBuff,"%c,",&cmd) == 1)
{
if(strncmp(&cmd,"D",1) == 0)
{
if(sscanf(recBuff,"%c,%[^\n]s",&cmd,argcharD) == 2)
{
printat(1,1,argcharD);
}
}
if(strncmp(&cmd,"L",1) == 0)
{
if(sscanf(recBuff,"%c,%[^\n]s", &cmd,argcharL) == 2)
{
printat(1,2,argcharL);
}
}
if(strncmp(&cmd,"R",1) == 0)
{
if(sscanf(recBuff,"%c,%d",&cmd,&num) == 2)
{
Do_RoundButtons(num); }
}
if(strncmp(&cmd,"T",1) == 0)
{
if(sscanf(recBuff,"%c,%[^\n]s",&cmd,argcharT) == 2)
{
if(strncmp(argcharT,"END",3) != 0)
{
xp = 1;
Do_ShowTeam(xp,yp,argcharT);
yp = yp+3;
teams++;
}
else
{
yp=1;
}
}
}
}
}