From: Peter K. <pk...@us...> - 2001-05-14 11:09:23
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.13 1.14=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20 btcon.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20 btconfig.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 btdisc.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20 btinq.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 btsend.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 bttest.c 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: bt_isinitiated() now takes the file descriptor to the control device as argument (if it is -1 it still opens/closes it as necessary). The diff of the modified file(s): --- bt_if.c 2001/04/27 14:53:31 1.13 +++ bt_if.c 2001/05/14 11:09:22 1.14 @@ -96,17 +96,20 @@ /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Init/shutdown and control of stack */=20 =20 -int bt_isinitiated(void) +int bt_isinitiated(int bt_cfd) { - int bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY); + int fd =3D (bt_cfd < 0 ? bt_openctrl() : bt_cfd); int stack_initiated =3D -1; =20 - if (bt_cfd < 0 || ioctl(bt_cfd, BTISINITIATED, &stack_initiated) < 0) + if (fd < 0 || ioctl(fd, BTISINITIATED, &stack_initiated) < 0) { perror(__FUNCTION__); exit(1); } - close(bt_cfd); + if (bt_cfd < 0) + { + close(fd); + } return stack_initiated; } =20 --- bt_if.h 2001/04/27 14:53:31 1.8 +++ bt_if.h 2001/05/14 11:09:22 1.9 @@ -269,7 +269,7 @@ */ =20 void init_stack(int bt_cfd, int spd); -int bt_isinitiated(void); +int bt_isinitiated(int bt_cfd); void shutdown_stack(int bt_cfd); #ifndef BT_USERSTACK char* bt_hw_vendor(void); --- btcon.c 2001/04/04 10:43:04 1.4 +++ btcon.c 2001/05/14 11:09:22 1.5 @@ -161,15 +161,19 @@ exit(1); } =20 + /* Open BT ctrl device */=20=20 + if ((bt_cfd =3D bt_openctrl()) < 0) + { + perror("Could not open BT control device"); + exit(1); + } + /* First of all check that stack is running */ - if (!bt_isinitiated()) + if (!bt_isinitiated(bt_cfd)) { printf("Stack not initiated, exit\n"); exit(1); } - - /* Open BT ctrl device */=20=20 - bt_cfd =3D bt_openctrl(); =20 line =3D atoi((char*)(btdev+10)); =20=20=20 --- btconfig.c 2001/04/27 18:33:23 1.2 +++ btconfig.c 2001/05/14 11:09:22 1.3 @@ -193,13 +193,17 @@ var_write_scan_enable >=3D 0 || var_force_ms_switch >=3D 0) { + /* Open BT ctrl device */=20=20 + if ((bt_cfd =3D bt_openctrl()) < 0) + { + perror("Could not open BT control device"); + exit(1); + } + /* Wait until stack is initiated */ - while (!bt_isinitiated()) + while (!bt_isinitiated(bt_cfd)) sleep(1); =20 - /* Open BT control tty */ - if ((bt_cfd =3D bt_openctrl()) >=3D 0) - { /* Configure BT local name */ if (var_set_local_name) bt_set_local_name(bt_cfd, bt_name); @@ -213,7 +217,6 @@ bt_force_msswitch_as_server(bt_cfd, var_force_ms_switch); =20 close(bt_cfd); - } } =20 exit(0); --- btdisc.c 2001/04/04 10:33:03 1.4 +++ btdisc.c 2001/05/14 11:09:22 1.5 @@ -111,15 +111,19 @@ exit(0); } =20 + /* Open BT ctrl device */=20=20 + if ((bt_cfd =3D bt_openctrl()) < 0) + { + perror("Could not open BT control device"); + exit(1); + } + /* First of all check that stack is running */ - if (!bt_isinitiated()) + if (!bt_isinitiated(bt_cfd)) { printf("Stack not initiated, exit\n"); exit(1); } - - /* Open BT ctrl device */ - bt_cfd =3D bt_openctrl(); =20 line =3D atoi((char*)(btdev+10)); =20=20=20 --- btinq.c 2001/03/02 10:59:57 1.1 +++ btinq.c 2001/05/14 11:09:22 1.2 @@ -70,13 +70,6 @@ {=20 int bt_cfd, opt, t =3D 10, nbr =3D 10; =20 - /* First of all check that stack is running */ - if (!bt_isinitiated()) - { - printf("Stack not initiated, exit\n"); - exit(1); - } - #define OPTIONS_STRING "n:t:" =20=20 while ((opt =3D getopt(argc, argv, OPTIONS_STRING)) !=3D -1) @@ -98,7 +91,18 @@ } =20 /* Open BT ctrl device */ - bt_cfd =3D bt_openctrl(); + if ((bt_cfd =3D bt_openctrl()) < 0) + { + perror("Could not open BT control device"); + exit(1); + } + + /* First of all check that stack is running */ + if (!bt_isinitiated(bt_cfd)) + { + printf("Stack not initiated, exit\n"); + exit(1); + } =20 bt_inquiry(bt_cfd, nbr, t); =20=20 --- btsend.c 2001/03/13 22:21:17 1.2 +++ btsend.c 2001/05/14 11:09:22 1.3 @@ -76,7 +76,7 @@ int line, bt_fd, opt, len=3D-1, repeat=3D1; =20 /* First of all check that stack is running */ - if (!bt_isinitiated()) + if (!bt_isinitiated(-1)) { printf("Stack not initiated, exit\n"); exit(1); --- bttest.c 2001/04/25 17:56:54 1.7 +++ bttest.c 2001/05/14 11:09:22 1.8 @@ -147,14 +147,19 @@ { int bt_cfd; =20 + /* Open BT ctrl device */=20=20 + if ((bt_cfd =3D bt_openctrl()) < 0) + { + perror("Could not open BT control device"); + exit(1); + } + /* First of all check that stack is running */ - if (!bt_isinitiated()) + if (!bt_isinitiated(bt_cfd)) { printf("Stack not initiated, exit\n"); exit(1); } - - bt_cfd =3D bt_openctrl(); =20 read_history(BTD_HISTORY_FILE);=20=20 =20 |