|
From: Anders J. <and...@us...> - 2001-08-21 10:17:36
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bttest.c 1.16 1.17=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Added "hotlist" to keep bd-addresses in.
The diff of the modified file(s):
--- bttest.c 2001/08/17 09:23:25 1.16
+++ bttest.c 2001/08/21 10:17:34 1.17
@@ -118,11 +118,17 @@
" bb_disc <hci handle>", /* disconnect baseband */
" lcid_disconnect <lcid>", /* Disconnects a connection with lcid =3D lc=
id */
" ",
+ "-------- Hotlist -------",
+ "(Use !<num> to expand the bdaddr from the list in any command)",
+ " hotlist_set <pos> <xx:xx:xx:xx:xx:xx>",
+ " hotlist_show",=20
"",
=20
NULL
};
=20
+static unsigned char hotlist[10][6];
+
#if !defined(HAVE_READLINE) && !defined(HAVE_READLINE_READLINE)
static void read_history(char *hist_file_name);
static void write_history(char *hist_file_name);
@@ -146,7 +152,8 @@
int
main(void)
{
- int bt_cfd;
+ int bt_cfd, i , j;
+ FILE *hotlist_fd;
=20
/* Open BT ctrl device */=20=20
if ((bt_cfd =3D bt_openctrl()) < 0)
@@ -162,6 +169,29 @@
exit(1);
}
=20
+ if(hotlist_fd =3D fopen("/etc/.hotlist", "rb"))
+ {
+ for (i =3D 0; i < 10 ; i++)=20
+ {
+ for (j =3D 0 ; j < 6 ; j++)=20
+ {
+ hotlist[i][j] =3D fgetc(hotlist_fd);
+ }
+ }
+ fclose(hotlist_fd);
+ }
+ else
+ {
+ for (i =3D 0; i < 10 ; i++)=20
+ {
+ for (j =3D 0 ; j < 6 ; j++)=20
+ {
+ hotlist[i][j] =3D 0;
+ }
+ }
+ }
+=20=20
+
read_history(BTD_HISTORY_FILE);=20=20
=20
show_menu();
@@ -169,10 +199,32 @@
while (1)
{
int tmp;
+ char *tmp_char, hotlist_entry;
+ char tmp_line[200];
char *line =3D (char*) readline("> ");
add_history(line);
=20=20=20=20=20
+ if((tmp_char =3D strstr(line, "!")))
+ {
+ if(*(tmp_char + 1) >=3D '0' && *(tmp_char + 1) <=3D '9')
+ {
+ hotlist_entry =3D *(tmp_char + 1) - '0';
+ memcpy(&tmp_line[0], line, tmp_char - line);
+ sprintf(&tmp_line[tmp_char - line], "%02X:%02X:%02X:%02X:%02X:%02X=
%s\0",=20
+ hotlist[hotlist_entry][0],
+ hotlist[hotlist_entry][1],
+ hotlist[hotlist_entry][2],
+ hotlist[hotlist_entry][3],
+ hotlist[hotlist_entry][4],
+ hotlist[hotlist_entry][5],
+ tmp_char + 2);
+ tmp =3D process_cmd(&tmp_line[0], bt_cfd);
+ }
+ }
+ else
+ {=20=20=20
tmp =3D process_cmd(line, bt_cfd);
+ }
=20=20=20=20=20
if (tmp =3D=3D QUIT_BTD)
{
@@ -466,6 +518,46 @@
{
printf("Disconnecting lcid %d", i);
bt_testcmd(bt_cfd, buf);
+ }
+ else if(sscanf(buf, "hotlist_set %d %x:%x:%x:%x:%x:%x",=20
+ &tmp[6], &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tm=
p[5]))
+ {
+ FILE *hotlist_fd;
+ int i, j;
+=20=20=20=20
+ if(tmp[6] > 9)
+ {
+ printf("Max number in hotlist is 9.\n");
+ }
+ else
+ {
+ hotlist[tmp[6]][0] =3D tmp[0];
+ hotlist[tmp[6]][1] =3D tmp[1];
+ hotlist[tmp[6]][2] =3D tmp[2];
+ hotlist[tmp[6]][3] =3D tmp[3];
+ hotlist[tmp[6]][4] =3D tmp[4];
+ hotlist[tmp[6]][5] =3D tmp[5];
+ if(hotlist_fd =3D fopen("/etc/.hotlist", "wb"))
+ {
+ for (i =3D 0; i < 10 ; i++)=20
+ {
+ for (j =3D 0 ; j < 6 ; j++)=20
+ {
+ fputc(hotlist[i][j], hotlist_fd);
+ }
+ }
+ fclose(hotlist_fd);
+ }
+ }
+ }
+ else if(strcmp(buf, "hotlist_show") =3D=3D 0)
+ {
+ int i, j;
+ for(i =3D 0 ; i < 10 ; i++)
+ {
+ printf("%d: %02X:%02X:%02X:%02X:%02X:%02X\n", i,=20
+ hotlist[i][0], hotlist[i][1], hotlist[i][2], hotlist[i][3], h=
otlist[i][4], hotlist[i][5]);
+ }
}
else
{
|