|
From: Anders J. <and...@us...> - 2002-08-06 17:56:16
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bt_if.c 1.49 1.50=20=20=20=20=20=20=20=20=20=20=20=20=20=20
bt_if.h 1.35 1.36=20=20=20=20=20=20=20=20=20=20=20=20=20=20
btdisc.c 1.6 1.7=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Added IOCTL to disconnect the BB based on the BD-address.
* btdisc can now be called with the argument -a <BD>.
The diff of the modified file(s):
--- bt_if.c 17 Jun 2002 13:47:58 -0000 1.49
+++ bt_if.c 6 Aug 2002 17:56:15 -0000 1.50
@@ -65,7 +65,7 @@
#include "bt_user.h"
#include "bt_errno.h"
=20
-#define D(x) //x
+#define D(x)
=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=3D */
/* Functions common for kernel and usermode stack */
@@ -327,6 +327,31 @@
}
=20=20=20
ret_val =3D bt_disconnect(con_id);
+#endif
+ return ret_val;
+}
+
+/* Disconnect the BlueTooth - BlueTooth connection (Consafe)
+ * Parameter : Remote BT device BT Address=20
+ */
+int
+bt_disconnect_bb(int bt_fd, unsigned char *rem_bd)
+{
+ unsigned char buf[6];
+ int i, ret_val =3D 0;
+
+ /* Reverse before get handler */
+ for (i =3D 0; i < 6; i++)
+ {
+ buf[5-i] =3D (unsigned char)*rem_bd++;
+ }
+#ifndef BT_USERSTACK
+ if ((ret_val =3D ioctl(bt_fd, BTDISCONNECT_BB, buf)) < 0)
+ printf("Disconnect BB failed [%s (%d)] err=3D%s\n", error_msg(ret_val)=
, MSG_GET_CODE(-ret_val), strerror(errno));
+ else
+ printf("BB Disconnected\n");
+#else
+ fprintf(stderr, __FUNCTION__ ": not yet implemented...\n");
#endif
return ret_val;
}
--- bt_if.h 3 Jun 2002 10:07:28 -0000 1.35
+++ bt_if.h 6 Aug 2002 17:56:15 -0000 1.36
@@ -137,6 +137,9 @@
//#define BT_SDP_REQUEST _IOW(BT_IOC_MAGIC, 0x0F, bt_sdp_request)
#define BT_GETCACHEDLINKKEY _IOWR(BT_IOC_MAGIC, 0x10, unsigned char[22])
=20
+/* Disconnect the BB connection (Consafe) */
+#define BTDISCONNECT_BB _IOW(BT_IOC_MAGIC, 0x11, unsigned char[6])
+
/* =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=3D=3D */
/* Ioctls for executing HCI commands */
=20
@@ -327,6 +330,7 @@
=20
int bt_connect(int bt_fd, unsigned char *bd, unsigned int con_id);
int bt_disconnect(int bt_fd, unsigned int con_id);
+int bt_disconnect_bb(int bt_fd, unsigned char *rem_bd); /* (Consafe) */
=20
void bt_waitline(int bt_fd, int line);
void bt_waitconnection(int bt_fd, int line);
--- btdisc.c 14 May 2001 11:29:36 -0000 1.6
+++ btdisc.c 6 Aug 2002 17:56:15 -0000 1.7
@@ -63,9 +63,12 @@
#include "bt_misc.h"
=20=20=20=20=20
#define DEFAULT_BTDEV "/dev/ttyBT0"
+#define D(x)
=20
/*=20
* Syntax: btdisc [-d <dev>] -D <rfcomm dlci>=20
+ * also -a <bd_address_string> (disconnect BB Consafe)
+ * bd_address_string example : 00:40:8c:cd:00:00=20=20
*/
=20
int
@@ -73,7 +76,10 @@
{
char *btdev =3D DEFAULT_BTDEV;
int con_id, bt_cfd, dlci =3D -1, line, opt;
- int result;
+ int result =3D 0;
+ unsigned char bd[6];
+ int i, use_bd =3D 0, error =3D 0;
+ int tmp[6];
=20
/* Print header if called via http */
if (getenv("REQUEST_METHOD") !=3D NULL)
@@ -82,7 +88,7 @@
}
=20
/* now parse options */
- while ((opt =3D getopt(argc, argv, "d:D:")) !=3D -1)
+ while ((opt =3D getopt(argc, argv, "a:d:D:")) !=3D -1)
{
switch (opt)
{
@@ -97,15 +103,38 @@
printf("RFCOMM dlci: %d\n", dlci);
break;
=20=20=20=20=20=20=20
+ case 'a':
+ if (sscanf(optarg, "%2x:%2x:%2x:%2x:%2x:%2x",
+ &tmp[0], &tmp[1], &tmp[2],
+ &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
+ {=20
+ for (i =3D 0; i < 6; i++)
+ {
+ bd[i] =3D (unsigned char)tmp[i];=20
+ }=20=20=20=20=20=20
+=20=20=20=20=20=20=20=20
+ D(syslog(LOG_INFO,"Rem. Address:%2x:%2x:%2x:%2x:%2x:%2x\n",
+ bd[0], bd[1], bd[2],
+ bd[3], bd[4], bd[5]));
+ use_bd =3D 1;
+ }=20
+ else=20
+ {
+ error =3D 1;
+ }=20=20
+ break;
+
+=20=20=20=20=20=20
default:
break;
}
}
=20
- if (optind < argc || dlci < 0)
+ if (optind < argc || (dlci < 0 && !use_bd) || error)
{
printf("Wrong syntax or missing parameters\n");
printf("Syntax: %s [-d <dev>] -D <rfcomm dlci>\n", argv[0]);
+ printf(" %s -a <BD address>\n", argv[0]);
exit(0);
}
=20
@@ -123,15 +152,23 @@
exit(1);
}
=20
+ if(!use_bd)=20
+ {
line =3D atoi((char*)(btdev+10));
=20=20=20
- /* Connect RFCOMM session on line */
+ /* Disconnect RFCOMM session on line */
printf("Disconnecting line %d [%s]\n", line, btdev);
+ D(syslog(LOG_INFO,"Disconnecting line %d [%s]\n", line, btdev));
=20
con_id =3D CREATE_RFCOMM_ID(line, dlci);
=20
result =3D bt_disconnect(bt_cfd, con_id);
-
+ }=20
+ else=20
+ {
+ /* Disconnect any connection which match the remote bd, i.e. the baseb=
andconnection */
+ bt_disconnect_bb(bt_cfd, bd);
+ }
close(bt_cfd);
exit(result);
}
|