adding sdp service record attributes
Hi Andreas!
Thank you very much for your email. Actually, I can connect the phone to PC now. But the new problem arises. Last time I did the things i.e. adding sdp headset profile, setting the class of my PC to be headset and then setting the channel in SDP and hciconfig, separately. Now, I wish to integrate these three separate jobs into my project's main program. The procedure is as that stated above. Then I put the part of socket programming in my main program, and this part can be said to come from rfcomm/main.c's cmd_listen function. But when my phone can connect to PC, the terminal shows "dev/rfcomm0: no such device". Then, I don't preset the address of my phone, but then when the phone can connect to PC, the following ios shown: "Can't create rfcomm TTY socket: too many open files in the system" or "dev/rfcomm0: connection refused". There is a note that in order to continue my program, the modem should be opened successfully, and the menu should be sent to my phine successfull
y. So, I
wish to know what's wrong about my program, and how I can fix it. I attach the programs here for you, and hope that other users, can find it out. Thank you very much for your kindness.P.S. bic_michael.c and bic_rfcomm.c are main programs without and with the part from rfcomm/main.c respectively, and bic_sdp.c and bic_sdp.h are files to be included in /usr/include
Michael
Andreas <[email protected]> wrote:
Quoted 11 lines · Ka Kin Cheung yahoo.com.hk> writes:
Hi Marcel!
I've set the SDP service profile and the attributes for headset and set the class of my computer to headset. Then my T610 can search my Linux PC as headset. However, when I pressed "connect" item, the phone tried to connect to the PC, but then the phone showed "Bluetooth connection failed". Is there any thing that I need to set in my PC, or how to modify my sdp program so that the phone can connect to PC?
Quoted 9 lines
My steps are as follows:
1.run my sdp program to add service and set the attributes.
2.change the class of my PC to be the one of headset. 3.let T610 to search my PC and then connect to PC. Is there anything wrong here?
Thank you very much.
Michael
Hi,
After initialising the rfcomm connection (phone to PC; phone gets the setup data via sdp from pc) the phone tries to initialize the "HS/HF-connection" via AT-commands - as I know.
You should have a look to the following pages regarding HF and HS support over BT too:
http://bluetooth-alsa.sourceforge.net/
http://www.crazygreek.co.uk/content/chan_bluetooth
http://www.soft.uni-linz.ac.at/_wiki/tiki-index.php?page=ProjectBluezHandsfree
Regards
Andreas
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users
---------------------------------
Yahoo! 工具列 - 內置防止彈出視窗工能!
/*****************************************************************************/
/*** (Final Year Project Bluetooth-Infrared Converter) bic_michael.c ***/
/*** Michael Cheung Ka Kin***/
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <malloc.h>
#include <string.h>
#include <getopt.h>
#include <signal.h>
#include <errno.h>
#include <sys/poll.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/time.h>
#include <string.h>
#include <termios.h>
#include <syslog.h>
#include <modeminit.h>
#include <modeminit.c>
#include <logging.c>
#include <logging.h>
#include <extras.h>
#include <extras.c>
#include <locking.c>
#include <locking.h>
#include <alarm.h>
#include <alarm.c>
#include <bic_sdp.c>
#include <bic_sdp.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#include <bluetooth/rfcomm.h>
#include <sys/file.h>
#include <mysql/mysql.h>
char filename[500] = { 0 };
char logfile[256] = { 0 };
char alarmhandler[256] = { 0 };
int alarmlevel = LOG_WARNING;
int loglevel = 9;
int ret_code;
char tmp[100];
char command[1024];//used for AT command only for creating menu
char buffer[1024];//used for AT command only when the number of choice1 is dynamic char answer[1024];//used for the command for the Linux PC
char type[3];
char remote[20];
char *target, *user, *password;
MYSQL mysql;MYSQL_RES *result;MYSQL_ROW row;
void TVcontrol(char remote[]);
void CDcontrol(char remote[]);
void VCDcontrol(char remote[]);
void DVDcontrol(char remote[]);
void VCRcontrol(char remote[]);
void projectorcontrol(char remote[]);
void devicecontrol(MYSQL *, char [], char []);
void parsearguments1()
{
strcpy (device, "/dev/null");
baudrate = 115200;
errorsleeptime = 10;
rtscts = 0;
strcpy (modemname, device);
}void parsearguments ()
{
strcpy (device, "/dev/rfcomm0");
baudrate = 115200;
errorsleeptime = 10;
rtscts = 0;
strcpy (modemname, device);
}void flush (char *fl,int len)
{
int m;
for (m=0;m<len;m++)
{
fl[m]='\0';
}
}int main (int argc, char **argv)
{
int submenu_selected;
int ans_selected[7];
int a,b;
int choice;
int count;
int sock, client;
socklen_t alen;
struct sockaddr_rc addr;
int which_submenu;
int type_selected;
target=user=password=NULL;
profile T610profile;
svc_info_t T610svc;
bdaddr_t bdaddr;
//char *str="00:0A:D9:DD:D8:A8";
//estr2ba(str, &bdaddr);
sdp_session_t *sess;
printf("\E[H\E[J");
printf ("Bluetooth infrared converter\n\n");
printf ("Doing initializations !\n");
//T610profile.handle=0x10001;
//T610profile.attrib=0x100;
//T610profile.attri_value="0x1108";
printf("T610 profile is added\n");
T610svc.class=0x1108;
printf("Service name is added\n");
T610svc.profile=0x1108;
T610svc.channel=3;
T610svc.name="HS";
add_service(T610profile.bdaddr, &T610svc);
//printf("Now attribute will be set\n");
sess = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0);
//set_attrib(sess, T610profile.handle, T610profile.attrib, T610profile.attri_value);
//printf("attributes are set\n");
mysql_init(&mysql);
if (!mysql_connect(&mysql, target, user, password))
{
printf("Database connection failed\n");
return 0;
}
else
printf("Database connection ok\n");
mysql_select_db(&mysql,"AVDevice");
system("hciconfig hci0 class 0x200404");
while (1)
{
addr.rc_family = AF_BLUETOOTH;
bacpy(&addr.rc_bdaddr, BDADDR_ANY);
addr.rc_channel = 3;
alen = sizeof(addr);
// request a socket from the operating system
if((sock = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0)
{
printf("socket(...) failed");
exit(1);
}
// bind the socket to the system
if(bind(sock, (struct sockaddr *)&addr, alen) < 0)
{
printf("bind(...) failed\n");
exit(2);
}
// set the socket into listen mode. handle 10 (QUEUE) connections.
if(listen(sock, 10) < 0)
{
printf("listen(...) failed\n");
exit(3);
}
// wait for the next connection or serve the next in the queue
while(client = accept(sock, (struct sockaddr *)&addr, &alen))
{
char remoteAddr[18];
ba2str(&addr.rc_bdaddr, remoteAddr);
printf("connection from %s:\n", remoteAddr);
parsearguments ();
snprintf (tmp, sizeof (tmp), "t68_remote_v2 (%s)", modemname);
tmp[sizeof (tmp) - 1] = 0;
openlogfile (tmp, logfile, LOG_DAEMON, loglevel);
set_alarmhandler (alarmhandler, alarmlevel, modemname);
openmodem ();
setmodemparams ();
sprintf (command, "at+cscs=i\"8859-1\"\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
sprintf (command, "AT*EAM=\"Bt-IrConverter\"\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
printf("Now T610 is connected to the PC\n");
while (1)
{
submenu_selected = 0;
while (!submenu_selected)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
submenu_selected = (NULL != strstr (answer, "*EAAI"));
}
while (1)
{
sprintf (command, "AT*EASM=\"Bt-IrConverter\",1,1,7,\"TV\",\"CD\",\"VCD\",\"DVD\",\"VCR\",\"Projector\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
for (a=0; a<7; a++)
ans_selected[a]=0;
count=1;
while (count)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<7; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_selected[b] = (NULL != strstr (answer, buffer));
if (ans_selected[b]==1)
{
count=0;
type_selected=b+1;
break;
}
}
}
if (ans_selected[6])
break;
else if (ans_selected[0])
printf("Mobile user selected TV\n");
else if (ans_selected[1])
printf("Mobile user selected CD\n");
else if (ans_selected[2])
printf("Mobile user selected VCD\n");
else if (ans_selected[3])
printf("Mobile user selected DVD\n");
else if (ans_selected[4])
printf("Mobile user selected VCR\n");
else if (ans_selected[5])
printf("Mobile user selected Projector\n");
switch (type_selected)
{
case 1:
devicecontrol(&mysql, "TV", remote);
break;
case 2:
devicecontrol(&mysql, "CD", remote);
break;
case 3:
devicecontrol(&mysql, "VCD", remote);
break;
case 4:
devicecontrol(&mysql, "DVD", remote);
break;
case 5:
devicecontrol(&mysql, "VCR", remote);
break;
case 6:
devicecontrol(&mysql, "Projector", remote);
break;
default:
break;
}
}
}
mysql_close(&mysql);
printf ("Mobile user has quitted!\n");
//exit(0);
sprintf(command, "AT+CMER=0,0,0,0,0\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
}
// now close the connection
close(client);
}
close(sock);
}void devicecontrol(MYSQL *mysql, char type[], char remote[])
{
char query_buffer[1000];
char buffer[1024];
char command_buffer[1024];
char device[100][20];
char model[100][20];
int item_brand;
int item_model;
int brand_selected=0;
int model_selected=0;
int db_success;
int ans_selected[100];
int a,b,c,i,j,k,l;
int count1;
int count2;
repeat1:
item_brand=0;
item_model=0;
sprintf(query_buffer, "SELECT distinct(Brand) from %s ORDER by Brand", type);
if (mysql_query(mysql, query_buffer)==0)
{
db_success=1;
result=mysql_use_result(mysql);
while (row = mysql_fetch_row(result))
{
item_brand++;
strcpy(device[item_brand-1], row[0]);
}
mysql_free_result(result);
}
else
{
printf("There is an error when showing result! \n");
db_success=0;
}
if (db_success==1)
{
for (i=0; i<item_brand; i++)
printf("%d. %s \n", i+1, device[i]);
sprintf(command_buffer, "AT*EASM=\"Bt-IrConverter\",1,1,%d", item_brand+1);
strcpy(command, command_buffer);
for (j=0; j<item_brand; j++)
{
sprintf(command_buffer, ",\"%s\"", device[j]);
strcat(command, command_buffer);
}
sprintf(command_buffer, ",\"quit\",\r");
strcat(command, command_buffer);
ret_code=put_command (command, answer, sizeof (answer), 5, 0);
for (k=0; k<item_brand+1; k++)
ans_selected[k]=0;
count1=1;
while (count1)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
for (l=0; l<item_brand+1; l++)
{
sprintf (buffer, "*EAMI: %d", l+1);
ans_selected[l] = (NULL != strstr (answer, buffer));
if (ans_selected[l]==1)
{
count1=0;
brand_selected=l;
break;
}
}
}
if (ans_selected[item_brand])
return;
else
{
printf("You have chosen %s %s \n", device[brand_selected], type);
sprintf(query_buffer, "SELECT Model from %s WHERE Brand='%s' ORDER by Model", type, device[brand_selected]);
if (mysql_query(mysql, query_buffer)==0)
{
db_success=1;
result=mysql_use_result(mysql);
while (row = mysql_fetch_row(result))
{
item_model++;
strcpy(model[item_model-1], row[0]);
}
mysql_free_result(result);
}
else
{
printf("There is an error when showing result! \n");
db_success=0;
}
if (db_success==1)
{
for (i=0; i<item_model; i++)
printf("%d. %s \n", i+1, model[i]);
sprintf(command_buffer, "AT*EASM=\"Bt-IrConverter\",1,1,%d", item_model+1);
strcpy(command, command_buffer);
for (a=0; a<item_model; a++)
{
sprintf(command_buffer, ",\"%s\"", model[a]);
strcat(command, command_buffer);
}
sprintf(command_buffer, ",\"quit\",\r");
strcat(command, command_buffer);
ret_code=put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<item_model+1; b++)
ans_selected[b]=0;
count2=1;
while (count2)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<item_model+1; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_selected[c] = (NULL != strstr (answer, buffer));
if (ans_selected[c]==1)
{
count2=0;
model_selected=c;
break;
}
}
}
if (ans_selected[item_model])
goto repeat1;
else
{
strcpy(remote, model[model_selected]);
printf("You have chosen %s %s %s \n", device[brand_selected], remote, type);
if (!strcmp(type,"TV"))
TVcontrol(remote);
else if (!strcmp(type,"CD"))
CDcontrol(remote);
else if (!strcmp(type,"VCD"))
VCDcontrol(remote);
else if (!strcmp(type,"DVD"))
DVDcontrol(remote);
else if (!strcmp(type,"VCR"))
VCRcontrol(remote);
else if (!strcmp(type,"Projector"))
projectorcontrol(remote);
}
}
}
}
}void TVcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
int channel_count=0;
int win;
printf("The user has entered TV mode \n");
TV:
sprintf (command, "AT*EASM=\"TV\",1,1,7,\"Power\",\"Channel\",\"Volume\",\"Menu\",\"Language\",\"Others\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<7; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<7; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[6])
{
printf("The user has quitted TV mode \n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the TV \n");
else
printf("Error on turning on/off TV! Please check if the TV's power is in standby mode \n");*/
break;
case 2:
printf("The user wishes to change channel\n");
sprintf (command, "AT*EAID=7,1,\"Channel\",\"Channel?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("\nThe user has chosen channel %s \n", outputint);
channel_count++;
if (channel_count==2)
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
channel_count=0;
}
goto TV;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("\nThe user has chosen channel %s \n", outputint);
goto TV;
}
break;
case 3:
printf("The user has entered volume mode\n");
vol:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"increase vol?\",\"decrease vol?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (c=0; c<3; c++)
ans_select[c]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto TV;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
goto vol;
}
break;
case 4:
menu_count=0;
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu mode \n");
menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"Menu\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
break;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has chosen an item in the menu \n");
menu_count++;
if (menu_count==1)
goto menu;
else
goto TV;
}
}
break;
case 5:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s lang", remote);
//system(instruct);
printf("The user has changed language \n");
break;
case 6:
printf("The user has entered others mode \n");
Other:
sprintf (command, "AT*EASM=\"Others\",1,1,4,\"Mode\",\"Silent\",\"Call\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (f=0; f<4; f++)
ans_select[f]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2] && !ans_select[3])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
ans_select[3]=(NULL!=strstr(answer, "*EAMI: 4"));
}
if (ans_select[3])
break;
else if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s mode", remote);
//system(instruct);
printf("The user has changed mode \n");
goto Other;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s silent", remote);
//system(instruct);
printf("The user has chosen to let TV be silent \n");
goto Other;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s call", remote);
//system(instruct);
printf("The user has done call function \n");
goto Other;
}
break;
default:
break;
}
goto TV;
}
}void CDcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int win;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
//int chapter_count=0;
printf("The user has entered CD mode \n");
CD:
sprintf (command, "AT*EASM=\"CD\",1,1,6,\"Power\",\"Chapter\",\"Play\",\"Volume\",\"Menu\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<6; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<6; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[5])
{
printf("The user has quitted CD mode\n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the CD player \n");
else
printf("Error on turning on/off CD player! Please check if the CD player's power is in standby mode \n");*/
break;
case 2:
printf("The user has entered the chapter choice mode \n");
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto CD;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto CD;
}
break;
case 3:
printf("The user has entered play mode \n");
play:
sprintf (command, "AT*EASM=\"Play\",1,1,3,\"Play by key?\",\"Play by menu?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto CD;
else if (ans_select[0])
{
play_key:
sprintf (command, "AT*EASM=\"Play\",1,1,10,\"Play\",\"Stop\",\"Pause/step\",\"Fast backward?\",\"Fast forward?\",\"Last chapter?\",\"Next chapter?\",\"Repeat?\",\"Eject?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<10; b++)
ans_select[b]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<10; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_select[c]=(NULL != strstr (answer, buffer));
if (ans_select[c]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
goto play;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s play", remote);
//system(instruct);
printf("The CD is playing \n");
goto play_key;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s stop", remote);
//system(instruct);
printf("The CD is stopped \n");
goto play_key;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s pause/step", remote);
//system(instruct);
printf("The CD is paused \n");
goto play_key;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The CD is fast-backwarding \n");
goto play_key;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The CD is fast-forwarding \n");
goto play_key;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s last", remote);
//system(instruct);
printf("The CD is playing the previous chapter \n");
goto play_key;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s next", remote);
//system(instruct);
printf("The CD is playing next chapter \n");
goto play_key;
}
else if (ans_select[7])
{
Repeat:
sprintf (command, "AT*EASM=\"Repeat\",1,1,3,\"A-B?\",\"1/All?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto play_key;
else if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat1", remote);
//system(instruct);
printf("The CD is repeating in A-B mode \n");
goto Repeat;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat2", remote);
//system(instruct);
printf("The CD is displaying in 1/all mode \n");
goto Repeat;
}
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s eject", remote);
//system(instruct);
printf("The CD is ejected out \n");
goto play_key;
}
}
}
else if (ans_select[1])
{
printf("The user has entered play menu setting mode \n");
play_menu:
sprintf (command, "AT*EASM=\"Play menu\",1,1,2,\"Set\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
ans_select[0]=0;
ans_select[1]=0;
while (!ans_select[0] && !ans_select[1])
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
}
if (ans_select[1])
goto play;
else
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user is modifying the menu\n");
select:
sprintf(command, "AT*EASM=\"Choice\",1,1,10,\"up\",\"down\",\"left\",\"right\",\"chapter\",\"enter\",\"clear\",\"next page\",\"last page\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (f=0; f<10; f++)
ans_select[f]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (g=0; g<10; g++)
{
sprintf (buffer, "*EAMI: %d", g+1);
ans_select[g]=(NULL != strstr (answer, buffer));
if (ans_select[g]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user has set the play menu \n");
goto play_menu;
}
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
goto select;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
goto select;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
goto select;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
goto select;
}
else if (ans_select[4])
{
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has entered a chapter in the play list \n");
goto play_menu;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s clear", remote);
//system(instruct);
printf("The user has cleared an item \n");
goto play_menu;
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The list has been switched to next page \n");
goto play_menu;
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The list has been switched to previous page \n");
goto play_menu;
}
}
}
}
break;
case 4:
printf("The user has entered volume mode \n");
vol:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"increase vol?\",\"decrease vol?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
break;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
goto vol;
}
break;
case 5:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu setting mode \n");
menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto CD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto CD;
}
}
break;
default:
break;
}
goto CD;
}
}void VCDcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int win;
int chapter1;
int chapter2;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
//int chapter_count=0;
printf("The user has entered VCD mode\n");
VCD:
sprintf (command, "AT*EASM=\"VCD\",1,1,8,\"Power\",\"Chapter\",\"Play\",\"Volume\",\"Menu\",\"Display\",\"Others\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<8; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<8; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[7])
{
printf("The user has quitted from VCD mode \n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the VCD player \n");
else
printf("Error on turning on/off VCD player! Please check if the VCD player's power is in standby mode \n");*/
break;
case 2:
printf("The user has entered the chapter choice mode \n");
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto VCD;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto VCD;
}
break;
case 3:
printf("The user has entered play mode \n");
play:
sprintf (command, "AT*EASM=\"Play\",1,1,3,\"Play by key?\",\"Play by menu?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto VCD;
else if (ans_select[0])
{
play_key:
sprintf (command, "AT*EASM=\"Play\",1,1,10,\"Play\",\"Stop\",\"Pause/step\",\"Fast backward?\",\"Fast forward?\",\"Last chapter?\",\"Next chapter?\",\"Repeat?\",\"Eject?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<10; b++)
ans_select[b]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<10; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_select[c]=(NULL != strstr (answer, buffer));
if (ans_select[c]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
goto play;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s play", remote);
//system(instruct);
printf("The VCD is playing \n");
goto play;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s stop", remote);
//system(instruct);
printf("The VCD is stopped \n");
goto play;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s pause/step", remote);
//system(instruct);
printf("The VCD is paused \n");
goto play;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The VCD is fast-backwarding \n");
goto play;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The VCD is fast-forwarding \n");
goto play;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s last", remote);
//system(instruct);
printf("The VCD is playing the previous chapter \n");
goto play;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s next", remote);
//system(instruct);
printf("The VCD is playing next chapter \n");
goto play;
}
else if (ans_select[7])
{
Repeat:
sprintf (command, "AT*EASM=\"Repeat\",1,1,3,\"A-B?\",\"1/All?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto play;
else if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat1", remote);
//system(instruct);
printf("The VCD is repeating in A-B mode \n");
goto Repeat;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat2", remote);
//system(instruct);
printf("The VCD is displaying in 1/all mode \n");
goto Repeat;
}
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s eject", remote);
//system(instruct);
printf("The VCD is ejected out \n");
goto play;
}
}
}
else if (ans_select[1])
{
printf("The user has entered play menu setting mode \n");
play_menu:
sprintf (command, "AT*EASM=\"Play menu\",1,1,2,\"Set\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
ans_select[0]=0;
ans_select[1]=0;
while (!ans_select[0] && !ans_select[1])
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
}
if (ans_select[1])
goto play;
else
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user is modifying the menu\n");
select:
sprintf(command, "AT*EASM=\"Choice\",1,1,10,\"up\",\"down\",\"left\",\"right\",\"chapter\",\"enter\",\"clear\",\"next page\",\"last page\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (f=0; f<10; f++)
ans_select[f]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (g=0; g<10; g++)
{
sprintf (buffer, "*EAMI: %d", g+1);
ans_select[g]=(NULL != strstr (answer, buffer));
if (ans_select[g]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user has set the play menu \n");
goto play_menu;
}
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
goto select;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
goto select;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
goto select;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
goto select;
}
else if (ans_select[4])
{
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has entered a chapter in the play list \n");
goto play_menu;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s clear", remote);
//system(instruct);
printf("The user has cleared an item \n");
goto play_menu;
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The list has been switched to next page \n");
goto play_menu;
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The list has been switched to previous page \n");
goto play_menu;
}
}
}
}
break;
case 4:
printf("The user has entered volume mode \n");
vol:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"increase vol?\",\"decrease vol?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto VCD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
goto vol;
}
break;
case 5:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu setting mode \n");
menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto VCD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto VCD;
}
}
break;
case 6:
printf("The user has entered display setting mode \n");
display:
sprintf (command, "AT*EASM=\"Display\",1,1,9,\"Display?\",\"Zoom?\",\"Browse?\",\"Signal mode?\",\"Caption?\",\"Angle?\",\"Channel?\",\"Title?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<9; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<9; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[8])
goto VCD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s display", remote);
//system(instruct);
printf("The user has chosen a display format \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s zoom", remote);
//system(instruct);
printf("The user has chosen a zooming aspects \n");
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s browse", remote);
//system(instruct);
printf("The user has chosen to browse \n");
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s signal_mode", remote);
//system(instruct);
printf("The user has searched a signal mode\n");
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s caption", remote);
//system(instruct);
printf("The user has chosen (not) to show caption\n");
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s angle", remote);
//system(instruct);
printf("The user has chosen a display angle \n");
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s channel", remote);
//system(instruct);
printf("The user has chosen a display channel \n");
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s title", remote);
//system(instruct);
printf("The user has chosen to show a title \n");
}
goto display;
}
break;
case 7:
printf("The user has entered others mode \n");
others:
sprintf (command, "AT*EASM=\"Others\",1,1,3,\"Setup\",\"Silent\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto VCD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s setup", remote);
//system(instruct);
printf("The user has entered setup menu \n");
setup:
sprintf(command, "AT*EASM=\"Setup\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto others;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto setup;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto setup;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto setup;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto setup;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto others;
}
}
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s silent", remote);
//system(instruct);
printf("The user has made the VCD player silently \n");
}
goto others;
}
break;
default:
break;
}
goto VCD;
}
}void DVDcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int win;
int chapter1;
int chapter2;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
//int chapter_count=0;
printf("The user has entered DVD mode \n");
DVD:
sprintf (command, "AT*EASM=\"DVD\",1,1,8,\"Power\",\"Chapter\",\"Play\",\"Volume\",\"Menu\",\"Display\",\"Others\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<8; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<8; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[7])
{
printf("The user has quitted from DVD mode \n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the DVD player \n");
else
printf("Error on turning on/off DVD player! Please check if the DVD player's power is in standby mode \n");*/
break;
case 2:
printf("The user has entered the chapter choice mode \n");
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto DVD;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto DVD;
}
break;
case 3:
printf("The user has entered play mode \n");
play:
sprintf (command, "AT*EASM=\"Play\",1,1,3,\"Play by key?\",\"Play by menu?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto DVD;
else if (ans_select[0])
{
play_key:
sprintf (command, "AT*EASM=\"Play\",1,1,10,\"Play\",\"Stop\",\"Pause/step\",\"Fast backward?\",\"Fast forward?\",\"Last chapter?\",\"Next chapter?\",\"Repeat?\",\"Eject?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<10; b++)
ans_select[b]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<10; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_select[c]=(NULL != strstr (answer, buffer));
if (ans_select[c]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
goto play;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s play", remote);
//system(instruct);
printf("The DVD is playing \n");
goto play;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s stop", remote);
//system(instruct);
printf("The DVD is stopped \n");
goto play;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s pause/step", remote);
//system(instruct);
printf("The DVD is paused \n");
goto play;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The DVD is fast-backwarding \n");
goto play;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The DVD is fast-forwarding \n");
goto play;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s last", remote);
//system(instruct);
printf("The DVD is playing the previous chapter \n");
goto play;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s next", remote);
//system(instruct);
printf("The DVD is playing next chapter \n");
goto play;
}
else if (ans_select[7])
{
Repeat:
sprintf (command, "AT*EASM=\"Repeat\",1,1,3,\"A-B?\",\"1/All?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto play;
else if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat1", remote);
//system(instruct);
printf("The DVD is repeating in A-B mode \n");
goto Repeat;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat2", remote);
//system(instruct);
printf("The DVD is displaying in 1/all mode \n");
goto Repeat;
}
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s eject", remote);
//system(instruct);
printf("The DVD is ejected out \n");
goto play;
}
}
}
else if (ans_select[1])
{
printf("The user has entered play menu setting mode \n");
play_menu:
sprintf (command, "AT*EASM=\"Play menu\",1,1,2,\"Set\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
ans_select[0]=0;
ans_select[1]=0;
while (!ans_select[0] && !ans_select[1])
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
}
if (ans_select[1])
goto play;
else
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user is modifying the menu\n");
select:
sprintf(command, "AT*EASM=\"Choice\",1,1,10,\"up\",\"down\",\"left\",\"right\",\"chapter\",\"enter\",\"clear\",\"next page\",\"last page\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (f=0; f<10; f++)
ans_select[f]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (g=0; g<10; g++)
{
sprintf (buffer, "*EAMI: %d", g+1);
ans_select[g]=(NULL != strstr (answer, buffer));
if (ans_select[g]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user has set the play menu \n");
goto play_menu;
}
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
goto select;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
goto select;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
goto select;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
goto select;
}
else if (ans_select[4])
{
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has entered a chapter in the play list \n");
goto play_menu;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s clear", remote);
//system(instruct);
printf("The user has cleared an item \n");
goto play_menu;
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The list has been switched to next page \n");
goto play_menu;
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The list has been switched to previous page \n");
goto play_menu;
}
}
}
}
break;
case 4:
printf("The user has entered volume mode \n");
vol:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"increase vol?\",\"decrease vol?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto DVD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
goto vol;
}
break;
case 5:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu setting mode \n");
menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto DVD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto DVD;
}
}
break;
case 6:
printf("The user has entered display setting mode \n");
display:
sprintf (command, "AT*EASM=\"Display\",1,1,9,\"Display?\",\"Zoom?\",\"Browse?\",\"Signal mode?\",\"Caption?\",\"Angle?\",\"Channel?\",\"Title?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<9; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<9; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[8])
goto DVD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s display", remote);
//system(instruct);
printf("The user has chosen a display format \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s zoom", remote);
//system(instruct);
printf("The user has chosen a zooming aspects \n");
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s browse", remote);
//system(instruct);
printf("The user has chosen to browse \n");
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s signal_mode", remote);
//system(instruct);
printf("The user has searched a signal mode\n");
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s caption", remote);
//system(instruct);
printf("The user has chosen (not) to show caption\n");
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s angle", remote);
//system(instruct);
printf("The user has chosen a display angle \n");
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s channel", remote);
//system(instruct);
printf("The user has chosen a display channel \n");
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s title", remote);
//system(instruct);
printf("The user has chosen to show a title \n");
}
goto display;
}
break;
case 7:
printf("The user has entered others mode \n");
others:
sprintf (command, "AT*EASM=\"Others\",1,1,3,\"Setup\",\"Silent\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto DVD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s setup", remote);
//system(instruct);
printf("The user has entered setup menu \n");
setup:
sprintf(command, "AT*EASM=\"Setup\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto others;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto setup;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto setup;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto setup;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto setup;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto others;
}
}
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s silent", remote);
//system(instruct);
printf("The user has made the DVD player silently \n");
}
goto others;
}
break;
default:
break;
}
goto DVD;
}
}void VCRcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int win;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
//int chapter_count=0;
printf("The user has entered VCR mode \n");
VCR:
sprintf (command, "AT*EASM=\"VCR\",1,1,6,\"Power\",\"Channel\",\"Play\",\"Recording\",\"Others\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<6; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<6; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[5])
{
printf("The user has quitted from VCR mode \n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the VCR \n");
else
printf("Error on turning on/off VCR! Please check if the VCR's power is in standby mode \n");*/
break;
case 2:
printf("The user wishes to change recording channel\n");
channel_choice1:
sprintf (command, "AT*EASM=\"Channel\",1,1,3,\"Change by key?\",\"Change by no.?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto VCR;
else if (ans_select[0])
{
channel_choice2:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"up channel?\",\"down channel?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto channel_choice1;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
}
goto channel_choice2;
}
}
else if (ans_select[1])
{
sprintf (command, "AT*EAID=7,1,\"Channel\",\"Channel?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen channel %s \n", outputint);
goto VCR;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen channel %s \n", outputint);
goto VCR;
}
}
break;
case 3:
printf("The user has entered play mode \n");
play:
sprintf (command, "AT*EASM=\"Play\",1,1,6,\"Play\",\"Stop/eject?\",\"Pause\",\"Fast backward?\",\"Fast forward?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<6; b++)
ans_select[b]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<6; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_select[c]=(NULL != strstr (answer, buffer));
if (ans_select[c]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto VCR;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s play", remote);
//system(instruct);
printf("The user has chosen to play \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s stop", remote);
//system(instruct);
printf("The user has chosen to stop \n");
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s pause/step", remote);
//system(instruct);
printf("The user has chosen to pause/play in step \n");
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The user has chosen to fast-backward \n");
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The user has chosen to fast-forward \n");
}
goto play;
}
break;
case 4:
printf("The user has entered recording mode\n");
record:
sprintf (command, "AT*EASM=\"Recording\",1,1,3,\"By key?\",\"By setting time?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
break;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s record", remote);
//system(instruct);
printf("The VCR is starting recording\n");
}
else if (ans_select[1])
{
printf("The user is setting the recording information\n");
record_set:
sprintf (command, "AT*EASM=\"Record setting\",1,1,3,\"Channel\",\"Time\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
break;
else if(ans_select[0])
{
printf("The user is choosing channel for recording\n");
sprintf (command, "AT*EAID=7,1,\"Channel\",\"Channel?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen channel %s \n", outputint);
goto record_set;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen channel %s \n", outputint);
goto record_set;
}
}
else if(ans_select[1])
{
printf("The user is setting record time\n");
rec_time:
while (1)
{
sprintf (command, "AT*EAID=9,1,\"Start Date\"\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 9,");
win = (NULL != strstr (answer, "*EAII: 9,"));
}
char year[3];
flush (year,3);
year[0]=answer[location-answer+10];
year[1]=answer[location-answer+11];
year[2]='\0';
char month[3];
flush (month,3);
month[0]=answer[location-answer+13];
month[1]=answer[location-answer+14];
month[2]='\0';
char day[3];
flush (day,3);
day[0]=answer[location-answer+16];
day[1]=answer[location-answer+17];
day[2]='\0';
printf ("%s\n",year);
printf ("%s\n",month);
printf ("%s\n",day);
printf ("Start Date (yy/mm/dd): %s/%s/%s\n", year, month, day);
win=0;
location=NULL;
sprintf (command, "AT*EAID=10,1,\"Start Time\"\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 20, 0);
location = strstr(answer, "*EAII: 10,");
win = (NULL != strstr (answer, "*EAII: 10,"));
}
printf("%s\n", answer);
char hour[3];
flush (hour,3);
//hour[0]=answer[location-answer+11];
//hour[1]=answer[location-answer+12];
hour[0]='1';
hour[1]=answer[location-answer+11];
hour[2]='\0';
char min[3];
flush (min,3);
min[0]=answer[location-answer+13];
min[1]=answer[location-answer+14];
min[2]='\0';
printf ("%s\n", hour);
printf ("%s\n", min);
printf ("Start Time (hh:mm): %s:%s\n", hour, min);
win=0;
location=NULL;
sprintf (command, "AT*EAID=9,1,\"End Date\"\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
location = strstr(answer, "*EAII: 9,");
win = (NULL != strstr (answer, "*EAII: 9,"));
}
char end_year[3];
flush (end_year,3);
end_year[0]=answer[location-answer+10];
end_year[1]=answer[location-answer+11];
end_year[2]='\0';
char end_month[3];
flush (end_month,3);
end_month[0]=answer[location-answer+13];
end_month[1]=answer[location-answer+14];
end_month[2]='\0';
char end_day[3];
flush (end_day,3);
end_day[0]=answer[location-answer+16];
end_day[1]=answer[location-answer+17];
end_day[2]='\0';
printf("%s\n",end_year);
printf("%s\n",end_month);
printf("%s\n",end_day);
printf("End Date (yy/mm/dd): %s/%s/%s\n", end_year, end_month, end_day);
win=0;
location=NULL;
sprintf (command, "AT*EAID=10,1,\"End Time\"\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 20, 0);
location = strstr(answer, "*EAII: 10,");
win = (NULL != strstr (answer, "*EAII: 10,"));
}
printf("%s",answer);
char end_hour[3];
flush (end_hour,3);
end_hour[0]='1';
//end_hour[0]=answer[location-answer+11];
end_hour[1]=answer[location-answer+11];
end_hour[2]='\0';
char end_min[3];
flush (end_min,3);
end_min[0]=answer[location-answer+13];
end_min[1]=answer[location-answer+14];
end_min[2]='\0';
printf("%s\n",end_hour);
printf("%s\n",end_min);
printf("End Time (hh:mm): %s:%s\n", end_hour, end_min);
goto record_set;
}
}
}
}
break;
case 5:
printf("The user enters other mode\n");
others:
sprintf (command, "AT*EASM=\"Others\",1,1,3,\"Menu\",\"Guide\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
break;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu setting mode\n");
vcr_menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"select\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto others;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto vcr_menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto vcr_menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto vcr_menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto vcr_menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s select", remote);
//system(instruct);
printf("The user has selected an item in menu\n");
goto VCR;
}
}
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s guide", remote);
//system(instruct);
printf("The user has entered guide mode\n");
vcr_guide:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"select\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto others;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto vcr_guide;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto vcr_guide;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto vcr_guide;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto vcr_guide;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s guide", remote);
//system(instruct);
goto VCR;
}
}
}
}
break;
default:
break;
}
goto VCR;
}
}void projectorcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
//int chapter_count=0;
printf("The user has entered projector mode \n");
projector:
sprintf (command, "AT*EASM=\"Projector\",1,1,7,\"Power\",\"menu\",\"input\",\"Display\",\"volume\",\"others\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<7; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<7; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[6])
{
printf("The user has quitted from projector mode \n");
return;
}
else
{
switch (con)
{
case 1:
printf("The user has entered the power mode\n");
power:
sprintf (command, "AT*EASM=\"Power\",1,1,3,\"Power\",\"Standby\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (c=0; c<3; c++)
ans_select[c]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
break;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
//system(instruct);
if (!system(instruct))
printf("The user has turned on/off the projector \n");
else
printf("Error on turning on/off projector!\n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s standby", remote);
//system(instruct);
if (!system(instruct))
printf("The user has turned the projector to standby mode\n");
else
printf("Error on turning the projector to standby mode!\n");
}
goto power;
}
break;
case 2:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered the power mode\n");
projector_menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,9,\"up\",\"down\",\"left\",\"right\",\"enter\",\"reset\",\"menu\",\"undo\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (c=0; c<9; c++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (d=0; d<9; d++)
{
sprintf (buffer, "*EAMI: %d", d+1);
ans_select[d]=(NULL != strstr (answer, buffer));
if (ans_select[d]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[8])
goto projector;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
goto projector_menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
goto projector_menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
goto projector_menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
goto projector_menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has selected an item in menu\n");
goto projector_menu;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s reset", remote);
//system(instruct);
printf("The user has reset all settings to default one\n");
goto projector_menu;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has quitted from menu\n");
goto projector;
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s undo", remote);
//system(instruct);
printf("The user has cancelled the setting\n");
goto projector;
}
}
break;
case 3:
printf("The user has entered input mode\n");
input:
sprintf (command, "AT*EASM=\"Input\",1,1,8,\"mode 1\",\"mode 2\",\"mode 3\",\"mode 4\",\"mode 5\",\"Computer\",\"Video\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (c=0; c<7; c++)
ans_select[c]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (d=0; d<7; d++)
{
sprintf (buffer, "*EAMI: %d", d+1);
ans_select[d]=(NULL != strstr (answer, buffer));
if (ans_select[d]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[7])
goto projector;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s input1", remote);
//system(instruct);
printf("The user has chosen input mode 1\n");
goto input;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s input2", remote);
//system(instruct);
printf("The user has chosen input mode 2\n");
goto input;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s input3", remote);
//system(instruct);
printf("The user has chosen input mode 3\n");
goto input;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s input4", remote);
//system(instruct);
printf("The user has chosen input mode 4\n");
goto input;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s input5", remote);
//system(instruct);
printf("The user has chosen input mode 5\n");
goto input;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s computer", remote);
//system(instruct);
printf("The user has chosen input from computer \n");
goto input;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s video", remote);
//system(instruct);
printf("The user has chosen input from video\n");
goto input;
}
}
break;
case 4:
printf("The user has entered the display mode\n");
display:
sprintf (command, "AT*EASM=\"Display\",1,1,7,\"Image\",\"Keystone\",\"Auto\",\"PinP\",\"Freeze\",\"Aspect\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (c=0; c<7; c++)
ans_select[c]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (d=0; d<7; d++)
{
sprintf (buffer, "*EAMI: %d", d+1);
ans_select[d]=(NULL != strstr (answer, buffer));
if (ans_select[d]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[6])
goto projector;
else
{
if (ans_select[0])
{
printf("The user has entered image mode\n");
image:
sprintf (command, "AT*EASM=\"Image\",1,1,7,\"Focus\",\"Zoom\",\"Magnify\",\"Position\",\"RGB\",\"Blank\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (e=0; e<7; e++)
ans_select[e]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (f=0; f<7; f++)
{
sprintf (buffer, "*EAMI: %d", f+1);
ans_select[f]=(NULL != strstr (answer, buffer));
if (ans_select[f]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[6])
goto display;
else
{
if (ans_select[0])
{
printf("The user is changing focus\n");
focus:
sprintf (command, "AT*EASM=\"Focus\",1,1,3,\"increase?\",\"decrease?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (g=0; g<3; g++)
ans_select[g]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto image;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upfocus", remote);
//system(instruct);
printf("The user has increased the focus\n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downfocus", remote);
//system(instruct);
printf("The user has decreased the focus\n");
}
goto focus;
}
}
else if (ans_select[1])
{
printf("The user is changing the zooming level\n");
zoom:
sprintf (command, "AT*EASM=\"zoom\",1,1,3,\"increase?\",\"decrease?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (g=0; g<3; g++)
ans_select[g]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto image;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upfocus", remote);
//system(instruct);
printf("The user has zoomed in\n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downfocus", remote);
//system(instruct);
printf("The user has zoomed out\n");
}
goto zoom;
}
}
else if (ans_select[2])
{
printf("The user is changing the magnification\n");
magnify:
sprintf (command, "AT*EASM=\"magnify\",1,1,3,\"up\",\"down\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (g=0; g<3; g++)
ans_select[g]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (h=0; h<3; h++)
{
sprintf (buffer, "*EAMI: %d", h+1);
ans_select[h]=(NULL != strstr (answer, buffer));
if (ans_select[h]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[2])
goto image;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
printf("The user has magnified the display\n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
printf("The user has made the display smaller\n");
}
goto magnify;
}
}
else if (ans_select[3])
{
printf("The user is changing the display's position\n");
position:
sprintf (command, "AT*EASM=\"position\",1,1,5,\"up\",\"down\",\"left\",\"right\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (g=0; g<5; g++)
ans_select[g]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (h=0; h<5; h++)
{
sprintf (buffer, "*EAMI: %d", h+1);
ans_select[h]=(NULL != strstr (answer, buffer));
if (ans_select[h]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[4])
goto image;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
printf("The display has been shifted up\n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
printf("The display has been shifted down\n");
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
printf("The display has been shifted left\n");
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
printf("The display has been shifted right\n");
}
goto position;
}
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s rgb", remote);
//system(instruct);
printf("The user has changed the display in rgb mode\n");
goto image;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s blank", remote);
//system(instruct);
printf("The display has been blanked\n");
goto image;
}
}
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s keystone", remote);
//system(instruct);
printf("The user has entered keystone mode\n");
keystone:
sprintf (command, "AT*EASM=\"Keystone\",1,1,7,\"up\",\"down\",\"left\",\"right\",\"keystone\",\"undo\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (e=0; e<7; e++)
ans_select[e]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (f=0; f<7; f++)
{
sprintf (buffer, "*EAMI: %d", f+1);
ans_select[f]=(NULL != strstr (answer, buffer));
if (ans_select[f]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[6])
goto display;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
printf("The user has increased the level of the keystone\n");
goto keystone;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
printf("The user has decreased the level of the keystone\n");
goto keystone;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
printf("The user has changed the direction of keystone\n");
goto keystone;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
printf("The user has changed the direction of keystone\n");
goto keystone;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s keystone", remote);
//system(instruct);
printf("The user has closed the keystone dialog\n");
goto display;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s undo", remote);
//system(instruct);
printf("The user has cleared the keystone change\n");
goto display;
}
}
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s auto", remote);
//system(instruct);
printf("The user has chosen auto position mode\n");
goto display;
}
else if (ans_select[3])
{
printf("The user has chosen Picture-in-picture mode\n");
pinp:
sprintf (command, "AT*EASM=\"PinP\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"PinP\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
ans_select[e]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (f=0; f<6; f++)
{
sprintf (buffer, "*EAMI: %d", f+1);
ans_select[f]=(NULL != strstr (answer, buffer));
if (ans_select[f]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto image;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
printf("The user has switching the images\n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
printf("The user has switching the images\n");
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
printf("The user has changed image position\n");
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
printf("The user has changed image position\n");
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s pinp", remote);
//system(instruct);
printf("The sub image disappeared\n");
}
goto pinp;
}
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s freeze", remote);
//system(instruct);
printf("The display is freezed\n");
goto display;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s aspect", remote);
//system(instruct);
printf("The user has changed the aspect\n");
goto display;
}
}
break;
case 5:
printf("The user has entered volume mode \n");
volume:
sprintf (command, "AT*EASM=\"Volume\",1,1,4,\"increase vol?\",\"decrease vol?\",\"mute?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<4; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2] && !ans_select[3])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
ans_select[3]=(NULL!=strstr(answer, "*EAMI: 4"));
}
if (ans_select[3])
goto projector;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume\n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s mute", remote);
//system(instruct);
printf("The projector was set to be silent \n");
}
goto volume;
}
break;
case 6:
printf("The user has entered others mode \n");
others:
sprintf (command, "AT*EASM=\"Others\",1,1,4,\"search\",\"laser\",\"mouse control\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<4; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2] && !ans_select[3])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
ans_select[3]=(NULL!=strstr(answer, "*EAMI: 4"));
}
if (ans_select[3])
goto projector;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s search", remote);
//system(instruct);
printf("The projector is searching..... \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s laser", remote);
//system(instruct);
printf("The projector is changed into laser mode \n");
}
else if (ans_select[2])
{
printf("The user has entered mouse mode \n");
mouse:
sprintf (command, "AT*EASM=\"Mouse control\",1,1,7,\"up\",\"down\",\"left\",\"right\",\"enter\",\"reset\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (e=0; e<7; e++)
ans_select[e]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (f=0; f<7; f++)
{
sprintf (buffer, "*EAMI: %d", f+1);
ans_select[f]=(NULL != strstr (answer, buffer));
if (ans_select[f]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[6])
goto others;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
printf("The cursor is moving upward \n");
goto mouse;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
printf("The cursor is moving downward \n");
goto mouse;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
printf("The cursor is moving left \n");
goto mouse;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
printf("The cursor is moving right \n");
goto mouse;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The cursor has chosen a point \n");
goto mouse;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s reset", remote);
//system(instruct);
printf("The user has right-clicked the mouse \n");
goto mouse;
}
}
}
}
break;
default:
break;
}
goto projector;
}
}/*****************************************************************************/
/*** (Final Year Project Bluetooth-Infrared Converter) bic_michael.c ***/
/*** Michael Cheung Ka Kin***/
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <malloc.h>
#include <string.h>
#include <getopt.h>
#include <signal.h>
#include <errno.h>
#include <sys/poll.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/time.h>
#include <string.h>
#include <termios.h>
#include <syslog.h>
#include <modeminit.h>
#include <modeminit.c>
#include <logging.c>
#include <logging.h>
#include <extras.h>
#include <extras.c>
#include <locking.c>
#include <locking.h>
#include <alarm.h>
#include <alarm.c>
#include <bic_sdp.c>
#include <bic_sdp.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#include <bluetooth/rfcomm.h>
#include <sys/file.h>
#include <mysql/mysql.h>
char filename[500] = { 0 };
char logfile[256] = { 0 };
char alarmhandler[256] = { 0 };
int alarmlevel = LOG_WARNING;
int loglevel = 9;
int ret_code;
char tmp[100];
char command[1024];//used for AT command only for creating menu
char buffer[1024];//used for AT command only when the number of choice1 is dynamic char answer[1024];//used for the command for the Linux PC
char type[3];
char remote[20];
char *target, *user, *password;
MYSQL mysql;MYSQL_RES *result;MYSQL_ROW row;
void TVcontrol(char remote[]);
void CDcontrol(char remote[]);
void VCDcontrol(char remote[]);
void DVDcontrol(char remote[]);
void VCRcontrol(char remote[]);
void projectorcontrol(char remote[]);
void devicecontrol(MYSQL *, char [], char []);
void parsearguments1()
{
strcpy (device, "/dev/null");
baudrate = 115200;
errorsleeptime = 10;
rtscts = 0;
strcpy (modemname, device);
}void parsearguments ()
{
strcpy (device, "/dev/rfcomm0");
baudrate = 115200;
errorsleeptime = 10;
rtscts = 0;
strcpy (modemname, device);
}void flush (char *fl,int len)
{
int m;
for (m=0;m<len;m++)
{
fl[m]='\0';
}
}int main (int argc, char **argv)
{
int submenu_selected;
int ans_selected[7];
int a,b;
int choice;
int count;
int ctl;
int dev;
int which_submenu;
int type_selected;
int sock;
int client;
static int rfcomm_raw_tty = 0;
struct sockaddr_rc laddr, raddr;
struct rfcomm_dev_req req;
struct termios ti;
struct sigaction sa;
struct pollfd p;
char dst[18], devname[MAXPATHLEN];
int sk, nsk, fd, alen, try = 3;
target=user=password=NULL;
profile T610profile;
svc_info_t T610svc;
bdaddr_t bdaddr;
//char *str="00:0A:D9:DD:D8:A8";
//estr2ba(str, &bdaddr);
sdp_session_t *sess;
printf("\E[H\E[J");
printf ("Bluetooth infrared converter\n\n");
printf ("Doing initializations !\n");
//T610profile.handle=0x10001;
//T610profile.attrib=0x100;
//T610profile.attri_value="0x1108";
printf("T610 profile is added\n");
T610svc.class=0x1108;
printf("Service name is added\n");
T610svc.profile=0x1108;
T610svc.channel=3;
T610svc.name="HS";
add_service(T610profile.bdaddr, &T610svc);
//printf("Now attribute will be set\n");
sess = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0);
//set_attrib(sess, T610profile.handle, T610profile.attrib, T610profile.attri_value);
//printf("attributes are set\n");
mysql_init(&mysql);
if (!mysql_connect(&mysql, target, user, password))
{
printf("Database connection failed\n");
return 0;
}
else
printf("Database connection ok\n");
mysql_select_db(&mysql,"AVDevice");
system("hciconfig hci0 class 0x200404");
while (1)
{
/*The following part is from rfcomm/main.c*/
laddr.rc_family = AF_BLUETOOTH;
bacpy(&laddr.rc_bdaddr, &bdaddr);
laddr.rc_channel =3;
if((sk = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM))< 0)
{
perror("Can't create RFCOMM socket");
return;
}
if (bind(sk, (struct sockaddr *)&laddr, sizeof(laddr)) < 0)
{
perror("Can't bind RFCOMM socket");
close(sk);
return;
}
printf("Waiting for connection on channel %d\n", laddr.rc_channel);
listen(sk, 10);
alen = sizeof(raddr);
nsk = accept(sk, (struct sockaddr *) &raddr, &alen);
alen = sizeof(laddr);
if (getsockname(nsk, (struct sockaddr *)&laddr, &alen) < 0) {
perror("Can't get RFCOMM socket name");
close(nsk);
return;
}
memset(&req, 0, sizeof(req));
req.dev_id = dev;
req.flags = (1 << RFCOMM_REUSE_DLC) | (1 << RFCOMM_RELEASE_ONHUP);
bacpy(&req.src, &laddr.rc_bdaddr);
bacpy(&req.dst, &raddr.rc_bdaddr);
req.channel = raddr.rc_channel;
if ((dev = ioctl(nsk, RFCOMMCREATEDEV, &req)) < 0) {
perror("Can't create RFCOMM TTY");
close(sk);
return;
}
snprintf(devname, MAXPATHLEN - 1, "/dev/rfcomm%d", dev);
while ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0)
{
snprintf(devname, MAXPATHLEN - 1, "/dev/bluetooth/rfcomm/%d", dev);
if ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0)
{
if (try--)
{
snprintf(devname, MAXPATHLEN - 1, "/dev/rfcomm%d", dev);
sleep(1);
continue;
}
perror("Can't open RFCOMM device");
memset(&req, 0, sizeof(req));
req.dev_id = dev;
req.flags = (1 << RFCOMM_HANGUP_NOW);
ioctl(ctl, RFCOMMRELEASEDEV, &req);
close(sk);
return;
}
}
if (rfcomm_raw_tty) {
tcflush(fd, TCIOFLUSH);
cfmakeraw(&ti);
tcsetattr(fd, TCSANOW, &ti);
}
close(sk);
close(nsk);
ba2str(&req.dst, dst);
printf("Connection from %s to %s\n", dst, devname);
/*The part from rfcomm/main.c ends*/
parsearguments ();
snprintf (tmp, sizeof (tmp), "t68_remote_v2 (%s)", modemname);
tmp[sizeof (tmp) - 1] = 0;
openlogfile (tmp, logfile, LOG_DAEMON, loglevel);
set_alarmhandler (alarmhandler, alarmlevel, modemname);
openmodem ();
setmodemparams ();
sprintf (command, "at+cscs=i\"8859-1\"\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
sprintf (command, "AT*EAM=\"Bt-IrConverter\"\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
printf("Now T610 is connected to the PC\n");
while (1)
{
submenu_selected = 0;
while (!submenu_selected)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
submenu_selected = (NULL != strstr (answer, "*EAAI"));
}
while (1)
{
sprintf (command, "AT*EASM=\"Bt-IrConverter\",1,1,7,\"TV\",\"CD\",\"VCD\",\"DVD\",\"VCR\",\"Projector\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
for (a=0; a<7; a++)
ans_selected[a]=0;
count=1;
while (count)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<7; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_selected[b] = (NULL != strstr (answer, buffer));
if (ans_selected[b]==1)
{
count=0;
type_selected=b+1;
break;
}
}
}
if (ans_selected[6])
break;
else if (ans_selected[0])
printf("Mobile user selected TV\n");
else if (ans_selected[1])
printf("Mobile user selected CD\n");
else if (ans_selected[2])
printf("Mobile user selected VCD\n");
else if (ans_selected[3])
printf("Mobile user selected DVD\n");
else if (ans_selected[4])
printf("Mobile user selected VCR\n");
else if (ans_selected[5])
printf("Mobile user selected Projector\n");
switch (type_selected)
{
case 1:
devicecontrol(&mysql, "TV", remote);
break;
case 2:
devicecontrol(&mysql, "CD", remote);
break;
case 3:
devicecontrol(&mysql, "VCD", remote);
break;
case 4:
devicecontrol(&mysql, "DVD", remote);
break;
case 5:
devicecontrol(&mysql, "VCR", remote);
break;
case 6:
devicecontrol(&mysql, "Projector", remote);
break;
default:
break;
}
}
mysql_close(&mysql);
printf ("Mobile user has quitted!\n");
//exit(0);
sprintf(command, "AT+CMER=0,0,0,0,0\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
}
// now close the connection
close(client);
}
close(sock);
}void devicecontrol(MYSQL *mysql, char type[], char remote[])
{
char query_buffer[1000];
char buffer[1024];
char command_buffer[1024];
char device[100][20];
char model[100][20];
int item_brand;
int item_model;
int brand_selected=0;
int model_selected=0;
int db_success;
int ans_selected[100];
int a,b,c,i,j,k,l;
int count1;
int count2;
repeat1:
item_brand=0;
item_model=0;
sprintf(query_buffer, "SELECT distinct(Brand) from %s ORDER by Brand", type);
if (mysql_query(mysql, query_buffer)==0)
{
db_success=1;
result=mysql_use_result(mysql);
while (row = mysql_fetch_row(result))
{
item_brand++;
strcpy(device[item_brand-1], row[0]);
}
mysql_free_result(result);
}
else
{
printf("There is an error when showing result! \n");
db_success=0;
}
if (db_success==1)
{
for (i=0; i<item_brand; i++)
printf("%d. %s \n", i+1, device[i]);
sprintf(command_buffer, "AT*EASM=\"Bt-IrConverter\",1,1,%d", item_brand+1);
strcpy(command, command_buffer);
for (j=0; j<item_brand; j++)
{
sprintf(command_buffer, ",\"%s\"", device[j]);
strcat(command, command_buffer);
}
sprintf(command_buffer, ",\"quit\",\r");
strcat(command, command_buffer);
ret_code=put_command (command, answer, sizeof (answer), 5, 0);
for (k=0; k<item_brand+1; k++)
ans_selected[k]=0;
count1=1;
while (count1)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
for (l=0; l<item_brand+1; l++)
{
sprintf (buffer, "*EAMI: %d", l+1);
ans_selected[l] = (NULL != strstr (answer, buffer));
if (ans_selected[l]==1)
{
count1=0;
brand_selected=l;
break;
}
}
}
if (ans_selected[item_brand])
return;
else
{
printf("You have chosen %s %s \n", device[brand_selected], type);
sprintf(query_buffer, "SELECT Model from %s WHERE Brand='%s' ORDER by Model", type, device[brand_selected]);
if (mysql_query(mysql, query_buffer)==0)
{
db_success=1;
result=mysql_use_result(mysql);
while (row = mysql_fetch_row(result))
{
item_model++;
strcpy(model[item_model-1], row[0]);
}
mysql_free_result(result);
}
else
{
printf("There is an error when showing result! \n");
db_success=0;
}
if (db_success==1)
{
for (i=0; i<item_model; i++)
printf("%d. %s \n", i+1, model[i]);
sprintf(command_buffer, "AT*EASM=\"Bt-IrConverter\",1,1,%d", item_model+1);
strcpy(command, command_buffer);
for (a=0; a<item_model; a++)
{
sprintf(command_buffer, ",\"%s\"", model[a]);
strcat(command, command_buffer);
}
sprintf(command_buffer, ",\"quit\",\r");
strcat(command, command_buffer);
ret_code=put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<item_model+1; b++)
ans_selected[b]=0;
count2=1;
while (count2)
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<item_model+1; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_selected[c] = (NULL != strstr (answer, buffer));
if (ans_selected[c]==1)
{
count2=0;
model_selected=c;
break;
}
}
}
if (ans_selected[item_model])
goto repeat1;
else
{
strcpy(remote, model[model_selected]);
printf("You have chosen %s %s %s \n", device[brand_selected], remote, type);
if (!strcmp(type,"TV"))
TVcontrol(remote);
else if (!strcmp(type,"CD"))
CDcontrol(remote);
else if (!strcmp(type,"VCD"))
VCDcontrol(remote);
else if (!strcmp(type,"DVD"))
DVDcontrol(remote);
else if (!strcmp(type,"VCR"))
VCRcontrol(remote);
else if (!strcmp(type,"Projector"))
projectorcontrol(remote);
}
}
}
}
}void TVcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
int channel_count=0;
int win;
printf("The user has entered TV mode \n");
TV:
sprintf (command, "AT*EASM=\"TV\",1,1,7,\"Power\",\"Channel\",\"Volume\",\"Menu\",\"Language\",\"Others\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<7; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<7; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[6])
{
printf("The user has quitted TV mode \n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the TV \n");
else
printf("Error on turning on/off TV! Please check if the TV's power is in standby mode \n");*/
break;
case 2:
printf("The user wishes to change channel\n");
sprintf (command, "AT*EAID=7,1,\"Channel\",\"Channel?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("\nThe user has chosen channel %s \n", outputint);
channel_count++;
if (channel_count==2)
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
channel_count=0;
}
goto TV;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("\nThe user has chosen channel %s \n", outputint);
goto TV;
}
break;
case 3:
printf("The user has entered volume mode\n");
vol:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"increase vol?\",\"decrease vol?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (c=0; c<3; c++)
ans_select[c]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto TV;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
goto vol;
}
break;
case 4:
menu_count=0;
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu mode \n");
menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"Menu\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
break;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has chosen an item in the menu \n");
menu_count++;
if (menu_count==1)
goto menu;
else
goto TV;
}
}
break;
case 5:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s lang", remote);
//system(instruct);
printf("The user has changed language \n");
break;
case 6:
printf("The user has entered others mode \n");
Other:
sprintf (command, "AT*EASM=\"Others\",1,1,4,\"Mode\",\"Silent\",\"Call\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (f=0; f<4; f++)
ans_select[f]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2] && !ans_select[3])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
ans_select[3]=(NULL!=strstr(answer, "*EAMI: 4"));
}
if (ans_select[3])
break;
else if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s mode", remote);
//system(instruct);
printf("The user has changed mode \n");
goto Other;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s silent", remote);
//system(instruct);
printf("The user has chosen to let TV be silent \n");
goto Other;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s call", remote);
//system(instruct);
printf("The user has done call function \n");
goto Other;
}
break;
default:
break;
}
goto TV;
}
}void CDcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int win;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
//int chapter_count=0;
printf("The user has entered CD mode \n");
CD:
sprintf (command, "AT*EASM=\"CD\",1,1,6,\"Power\",\"Chapter\",\"Play\",\"Volume\",\"Menu\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<6; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<6; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[5])
{
printf("The user has quitted CD mode\n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the CD player \n");
else
printf("Error on turning on/off CD player! Please check if the CD player's power is in standby mode \n");*/
break;
case 2:
printf("The user has entered the chapter choice mode \n");
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto CD;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto CD;
}
break;
case 3:
printf("The user has entered play mode \n");
play:
sprintf (command, "AT*EASM=\"Play\",1,1,3,\"Play by key?\",\"Play by menu?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto CD;
else if (ans_select[0])
{
play_key:
sprintf (command, "AT*EASM=\"Play\",1,1,10,\"Play\",\"Stop\",\"Pause/step\",\"Fast backward?\",\"Fast forward?\",\"Last chapter?\",\"Next chapter?\",\"Repeat?\",\"Eject?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<10; b++)
ans_select[b]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<10; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_select[c]=(NULL != strstr (answer, buffer));
if (ans_select[c]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
goto play;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s play", remote);
//system(instruct);
printf("The CD is playing \n");
goto play_key;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s stop", remote);
//system(instruct);
printf("The CD is stopped \n");
goto play_key;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s pause/step", remote);
//system(instruct);
printf("The CD is paused \n");
goto play_key;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The CD is fast-backwarding \n");
goto play_key;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The CD is fast-forwarding \n");
goto play_key;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s last", remote);
//system(instruct);
printf("The CD is playing the previous chapter \n");
goto play_key;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s next", remote);
//system(instruct);
printf("The CD is playing next chapter \n");
goto play_key;
}
else if (ans_select[7])
{
Repeat:
sprintf (command, "AT*EASM=\"Repeat\",1,1,3,\"A-B?\",\"1/All?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto play_key;
else if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat1", remote);
//system(instruct);
printf("The CD is repeating in A-B mode \n");
goto Repeat;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat2", remote);
//system(instruct);
printf("The CD is displaying in 1/all mode \n");
goto Repeat;
}
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s eject", remote);
//system(instruct);
printf("The CD is ejected out \n");
goto play_key;
}
}
}
else if (ans_select[1])
{
printf("The user has entered play menu setting mode \n");
play_menu:
sprintf (command, "AT*EASM=\"Play menu\",1,1,2,\"Set\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
ans_select[0]=0;
ans_select[1]=0;
while (!ans_select[0] && !ans_select[1])
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
}
if (ans_select[1])
goto play;
else
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user is modifying the menu\n");
select:
sprintf(command, "AT*EASM=\"Choice\",1,1,10,\"up\",\"down\",\"left\",\"right\",\"chapter\",\"enter\",\"clear\",\"next page\",\"last page\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (f=0; f<10; f++)
ans_select[f]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (g=0; g<10; g++)
{
sprintf (buffer, "*EAMI: %d", g+1);
ans_select[g]=(NULL != strstr (answer, buffer));
if (ans_select[g]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user has set the play menu \n");
goto play_menu;
}
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
goto select;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
goto select;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
goto select;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
goto select;
}
else if (ans_select[4])
{
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has entered a chapter in the play list \n");
goto play_menu;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s clear", remote);
//system(instruct);
printf("The user has cleared an item \n");
goto play_menu;
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The list has been switched to next page \n");
goto play_menu;
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The list has been switched to previous page \n");
goto play_menu;
}
}
}
}
break;
case 4:
printf("The user has entered volume mode \n");
vol:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"increase vol?\",\"decrease vol?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
break;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
goto vol;
}
break;
case 5:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu setting mode \n");
menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto CD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto CD;
}
}
break;
default:
break;
}
goto CD;
}
}void VCDcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int win;
int chapter1;
int chapter2;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
//int chapter_count=0;
printf("The user has entered VCD mode\n");
VCD:
sprintf (command, "AT*EASM=\"VCD\",1,1,8,\"Power\",\"Chapter\",\"Play\",\"Volume\",\"Menu\",\"Display\",\"Others\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<8; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<8; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[7])
{
printf("The user has quitted from VCD mode \n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the VCD player \n");
else
printf("Error on turning on/off VCD player! Please check if the VCD player's power is in standby mode \n");*/
break;
case 2:
printf("The user has entered the chapter choice mode \n");
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto VCD;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto VCD;
}
break;
case 3:
printf("The user has entered play mode \n");
play:
sprintf (command, "AT*EASM=\"Play\",1,1,3,\"Play by key?\",\"Play by menu?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto VCD;
else if (ans_select[0])
{
play_key:
sprintf (command, "AT*EASM=\"Play\",1,1,10,\"Play\",\"Stop\",\"Pause/step\",\"Fast backward?\",\"Fast forward?\",\"Last chapter?\",\"Next chapter?\",\"Repeat?\",\"Eject?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<10; b++)
ans_select[b]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<10; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_select[c]=(NULL != strstr (answer, buffer));
if (ans_select[c]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
goto play;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s play", remote);
//system(instruct);
printf("The VCD is playing \n");
goto play;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s stop", remote);
//system(instruct);
printf("The VCD is stopped \n");
goto play;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s pause/step", remote);
//system(instruct);
printf("The VCD is paused \n");
goto play;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The VCD is fast-backwarding \n");
goto play;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The VCD is fast-forwarding \n");
goto play;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s last", remote);
//system(instruct);
printf("The VCD is playing the previous chapter \n");
goto play;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s next", remote);
//system(instruct);
printf("The VCD is playing next chapter \n");
goto play;
}
else if (ans_select[7])
{
Repeat:
sprintf (command, "AT*EASM=\"Repeat\",1,1,3,\"A-B?\",\"1/All?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto play;
else if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat1", remote);
//system(instruct);
printf("The VCD is repeating in A-B mode \n");
goto Repeat;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat2", remote);
//system(instruct);
printf("The VCD is displaying in 1/all mode \n");
goto Repeat;
}
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s eject", remote);
//system(instruct);
printf("The VCD is ejected out \n");
goto play;
}
}
}
else if (ans_select[1])
{
printf("The user has entered play menu setting mode \n");
play_menu:
sprintf (command, "AT*EASM=\"Play menu\",1,1,2,\"Set\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
ans_select[0]=0;
ans_select[1]=0;
while (!ans_select[0] && !ans_select[1])
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
}
if (ans_select[1])
goto play;
else
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user is modifying the menu\n");
select:
sprintf(command, "AT*EASM=\"Choice\",1,1,10,\"up\",\"down\",\"left\",\"right\",\"chapter\",\"enter\",\"clear\",\"next page\",\"last page\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (f=0; f<10; f++)
ans_select[f]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (g=0; g<10; g++)
{
sprintf (buffer, "*EAMI: %d", g+1);
ans_select[g]=(NULL != strstr (answer, buffer));
if (ans_select[g]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user has set the play menu \n");
goto play_menu;
}
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
goto select;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
goto select;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
goto select;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
goto select;
}
else if (ans_select[4])
{
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has entered a chapter in the play list \n");
goto play_menu;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s clear", remote);
//system(instruct);
printf("The user has cleared an item \n");
goto play_menu;
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The list has been switched to next page \n");
goto play_menu;
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The list has been switched to previous page \n");
goto play_menu;
}
}
}
}
break;
case 4:
printf("The user has entered volume mode \n");
vol:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"increase vol?\",\"decrease vol?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto VCD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
goto vol;
}
break;
case 5:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu setting mode \n");
menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto VCD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto VCD;
}
}
break;
case 6:
printf("The user has entered display setting mode \n");
display:
sprintf (command, "AT*EASM=\"Display\",1,1,9,\"Display?\",\"Zoom?\",\"Browse?\",\"Signal mode?\",\"Caption?\",\"Angle?\",\"Channel?\",\"Title?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<9; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<9; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[8])
goto VCD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s display", remote);
//system(instruct);
printf("The user has chosen a display format \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s zoom", remote);
//system(instruct);
printf("The user has chosen a zooming aspects \n");
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s browse", remote);
//system(instruct);
printf("The user has chosen to browse \n");
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s signal_mode", remote);
//system(instruct);
printf("The user has searched a signal mode\n");
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s caption", remote);
//system(instruct);
printf("The user has chosen (not) to show caption\n");
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s angle", remote);
//system(instruct);
printf("The user has chosen a display angle \n");
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s channel", remote);
//system(instruct);
printf("The user has chosen a display channel \n");
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s title", remote);
//system(instruct);
printf("The user has chosen to show a title \n");
}
goto display;
}
break;
case 7:
printf("The user has entered others mode \n");
others:
sprintf (command, "AT*EASM=\"Others\",1,1,3,\"Setup\",\"Silent\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto VCD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s setup", remote);
//system(instruct);
printf("The user has entered setup menu \n");
setup:
sprintf(command, "AT*EASM=\"Setup\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto others;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto setup;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto setup;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto setup;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto setup;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto others;
}
}
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s silent", remote);
//system(instruct);
printf("The user has made the VCD player silently \n");
}
goto others;
}
break;
default:
break;
}
goto VCD;
}
}void DVDcontrol(char remote[])
{
char instruct[1024];
int item_choice1=0;
int ans_select[100];
int con;
int win;
int chapter1;
int chapter2;
int a,b,c,d,e,f,g,h,i;
int choice1;
int choice2;
int menu_count;
//int chapter_count=0;
printf("The user has entered DVD mode \n");
DVD:
sprintf (command, "AT*EASM=\"DVD\",1,1,8,\"Power\",\"Chapter\",\"Play\",\"Volume\",\"Menu\",\"Display\",\"Others\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<8; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<8; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[7])
{
printf("The user has quitted from DVD mode \n");
return;
}
else
{
switch (con)
{
case 1:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s power", remote);
/*system(instruct);
if (!system(instruct))
printf("The user has turned on/off the DVD player \n");
else
printf("Error on turning on/off DVD player! Please check if the DVD player's power is in standby mode \n");*/
break;
case 2:
printf("The user has entered the chapter choice mode \n");
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto DVD;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto DVD;
}
break;
case 3:
printf("The user has entered play mode \n");
play:
sprintf (command, "AT*EASM=\"Play\",1,1,3,\"Play by key?\",\"Play by menu?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto DVD;
else if (ans_select[0])
{
play_key:
sprintf (command, "AT*EASM=\"Play\",1,1,10,\"Play\",\"Stop\",\"Pause/step\",\"Fast backward?\",\"Fast forward?\",\"Last chapter?\",\"Next chapter?\",\"Repeat?\",\"Eject?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (b=0; b<10; b++)
ans_select[b]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (c=0; c<10; c++)
{
sprintf (buffer, "*EAMI: %d", c+1);
ans_select[c]=(NULL != strstr (answer, buffer));
if (ans_select[c]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
goto play;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s play", remote);
//system(instruct);
printf("The DVD is playing \n");
goto play;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s stop", remote);
//system(instruct);
printf("The DVD is stopped \n");
goto play;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s pause/step", remote);
//system(instruct);
printf("The DVD is paused \n");
goto play;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The DVD is fast-backwarding \n");
goto play;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The DVD is fast-forwarding \n");
goto play;
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s last", remote);
//system(instruct);
printf("The DVD is playing the previous chapter \n");
goto play;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s next", remote);
//system(instruct);
printf("The DVD is playing next chapter \n");
goto play;
}
else if (ans_select[7])
{
Repeat:
sprintf (command, "AT*EASM=\"Repeat\",1,1,3,\"A-B?\",\"1/All?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto play;
else if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat1", remote);
//system(instruct);
printf("The DVD is repeating in A-B mode \n");
goto Repeat;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s repeat2", remote);
//system(instruct);
printf("The DVD is displaying in 1/all mode \n");
goto Repeat;
}
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s eject", remote);
//system(instruct);
printf("The DVD is ejected out \n");
goto play;
}
}
}
else if (ans_select[1])
{
printf("The user has entered play menu setting mode \n");
play_menu:
sprintf (command, "AT*EASM=\"Play menu\",1,1,2,\"Set\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
ans_select[0]=0;
ans_select[1]=0;
while (!ans_select[0] && !ans_select[1])
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
}
if (ans_select[1])
goto play;
else
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user is modifying the menu\n");
select:
sprintf(command, "AT*EASM=\"Choice\",1,1,10,\"up\",\"down\",\"left\",\"right\",\"chapter\",\"enter\",\"clear\",\"next page\",\"last page\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (f=0; f<10; f++)
ans_select[f]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (g=0; g<10; g++)
{
sprintf (buffer, "*EAMI: %d", g+1);
ans_select[g]=(NULL != strstr (answer, buffer));
if (ans_select[g]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[9])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s schedule", remote);
//system(instruct);
printf("The user has set the play menu \n");
goto play_menu;
}
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s up", remote);
//system(instruct);
goto select;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s down", remote);
//system(instruct);
goto select;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s left", remote);
//system(instruct);
goto select;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s right", remote);
//system(instruct);
goto select;
}
else if (ans_select[4])
{
sprintf (command, "AT*EAID=7,1,\"Chapter\",\"Chapter?\",0,99,\r");
ret_code = put_command (command, answer, sizeof (answer), 7, 0);
win=0;
char *location=NULL;
while (!win)
{
ret_code = put_command ("", answer, sizeof (answer), 5,0);
location = strstr(answer, "*EAII: 7,");
win = (NULL != strstr (answer, "*EAII: 7,"));
}
char outputint[3];
flush (outputint,3);
outputint[0]=answer[location-answer+9];
outputint[1]=answer[location-answer+10];
outputint[2]='\0';
if ((atoi(outputint)>=10) && (atoi(outputint)<=99))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s 10+", remote);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)/10);
//system(instruct);
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %d", remote, atoi(outputint)%10);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
else if ((atoi(outputint)>=0) && (atoi(outputint)<=9))
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s %s", remote, outputint);
//system(instruct);
printf("The user has chosen chapter %s \n", outputint);
goto select;
}
}
else if (ans_select[5])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has entered a chapter in the play list \n");
goto play_menu;
}
else if (ans_select[6])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s clear", remote);
//system(instruct);
printf("The user has cleared an item \n");
goto play_menu;
}
else if (ans_select[7])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s ffw", remote);
//system(instruct);
printf("The list has been switched to next page \n");
goto play_menu;
}
else if (ans_select[8])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s fbw", remote);
//system(instruct);
printf("The list has been switched to previous page \n");
goto play_menu;
}
}
}
}
break;
case 4:
printf("The user has entered volume mode \n");
vol:
sprintf (command, "AT*EASM=\"Volume\",1,1,3,\"increase vol?\",\"decrease vol?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<3; a++)
ans_select[a]=0;
while (!ans_select[0] && !ans_select[1] && !ans_select[2])
{
ret_code = put_command ("", answer, sizeof (answer), 5, 0);
ans_select[0]=(NULL!=strstr(answer, "*EAMI: 1"));
ans_select[1]=(NULL!=strstr(answer, "*EAMI: 2"));
ans_select[2]=(NULL!=strstr(answer, "*EAMI: 3"));
}
if (ans_select[2])
goto DVD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
printf("The user has increased volume \n");
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
printf("The user has decreased volume \n");
}
goto vol;
}
break;
case 5:
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s menu", remote);
//system(instruct);
printf("The user has entered menu setting mode \n");
menu:
sprintf(command, "AT*EASM=\"Menu\",1,1,6,\"up\",\"down\",\"left\",\"right\",\"enter\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (d=0; d<6; d++)
ans_select[d]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (e=0; e<6; e++)
{
sprintf (buffer, "*EAMI: %d", e+1);
ans_select[e]=(NULL != strstr (answer, buffer));
if (ans_select[e]==1)
{
choice1=0;
break;
}
}
}
if (ans_select[5])
goto DVD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[1])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downchannel", remote);
//system(instruct);
goto menu;
}
else if (ans_select[2])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s downvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[3])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s upvol", remote);
//system(instruct);
goto menu;
}
else if (ans_select[4])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s enter", remote);
//system(instruct);
printf("The user has chosen an item\n");
goto DVD;
}
}
break;
case 6:
printf("The user has entered display setting mode \n");
display:
sprintf (command, "AT*EASM=\"Display\",1,1,9,\"Display?\",\"Zoom?\",\"Browse?\",\"Signal mode?\",\"Caption?\",\"Angle?\",\"Channel?\",\"Title?\",\"quit\",\r");
ret_code = put_command (command, answer, sizeof (answer), 5, 0);
for (a=0; a<9; a++)
ans_select[a]=0;
choice1=1;
while (choice1)
{
ret_code=put_command ("", answer, sizeof (answer), 5, 0);
for (b=0; b<9; b++)
{
sprintf (buffer, "*EAMI: %d", b+1);
ans_select[b] = (NULL != strstr (answer, buffer));
if (ans_select[b]==1)
{
choice1=0;
con=b+1;
break;
}
}
}
if (ans_select[8])
goto DVD;
else
{
if (ans_select[0])
{
sprintf(instruct, "/usr/local/irtrans/irclient localhost %s display", remote);143 lines not shown · raw message
2,400 lines not shown · raw message
Part of this message is not shown here. View the raw message.
Marcel Holtmann
maintainerHi Michael,
Quoted 3 lines
P.S.bic_michael.candbic_rfcomm.care main programs without and with the part fromrfcomm/main.crespectively, andbic_sdp.candbic_sdp.hare files to be included in/usr/include
actually I miss the GPL statement and a comment about the origin for parts of your code at the top of these files.
Regards
Marcel
-------------------------------------------------------
This SF.net email is sponsored by Microsoft Mobile & Embedded DevCon 2005 Attend MEDC 2005 May 9-12 in Vegas. Learn more about the latest Windows Embedded(r) & Windows Mobile(tm) platforms, applications & content. Register by 3/29 & save $300 http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users