|
From: Mattias A. <mat...@us...> - 2001-03-21 17:26:46
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bt_if.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* added function to send raw hci data
* added status message in bt_disconnect
* added bt_showstatus
* modified and added error codes for l2cap in error_msg()
The diff of the modified file(s):
--- bt_if.c 2001/03/13 22:21:17 1.2
+++ bt_if.c 2001/03/21 17:26:44 1.3
@@ -62,6 +62,29 @@
#include "bt_misc.h"
#include "bt_conf.h"
=20
+
+int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len)
+{
+ unsigned char buf[261];
+
+ buf[0] =3D len;
+=20=20
+ memcpy(buf+1, data, len);
+
+ print_data("data :",(char*) buf,(int) len+1);
+
+#ifndef BT_USERSTACK=20
+ if (ioctl(bt_cfd, HCISENDRAWDATA, buf) < 0)
+ {
+ perror("ecs_testctrl");
+ }
+#else
+ printf("not yet for usermode stack...\n");
+ //hci_send_raw_data(data, 16);
+#endif
+ return 0;
+}
+
/* =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 */
/* =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 */
@@ -214,16 +237,16 @@
return result;
}
=20
-void
+int
bt_disconnect(int bt_fd, unsigned int con_id)
{
-#ifndef BT_USERSTACK
+ int ret_val;
=20
- if (ioctl(bt_fd, BTDISCONNECT, &con_id) < 0)
- {
- perror("Disconnect");
- exit(1);
- }
+#ifndef BT_USERSTACK=20=20
+ if ((ret_val =3D ioctl(bt_fd, BTDISCONNECT, &con_id)))
+ printf("Disconnect failed, %s [%d]\n", error_msg(ret_val), ret_val);
+ else
+ printf("Disconnected.\n");
#else
/* fixme<3> -- only works for rfcomm */
u8 line;=09=09=09=09
@@ -236,9 +259,10 @@
return;
}
=20=20=20
- rfcomm_disconnect_req(GET_RFCOMMLINE(con_id));
+ ret_val =3D rfcomm_disconnect_req(GET_RFCOMMLINE(con_id));
#endif
- printf("Disconnected!\n");
+
+ return ret_val;
}
=20
/* Check whether this line is lower connected in stack (rfcomm ready) */
@@ -258,6 +282,21 @@
return ret;
}
=20
+void bt_showstatus(void)
+{
+#ifdef BT_USERSTACK
+
+ char tmp[4096];
+ int len;
+ len =3D bt_read_internal(tmp);
+ tmp[len] =3D 0;
+ printf("%s", tmp);
+#else
+ /*FIXME -- read /proc/bt_internal and print it on the console */
+ printf("not yet...\n");
+#endif=20
+}
+
=20
/* fixme<1> -- add usermode stack version */
int
@@ -319,6 +358,8 @@
return 0;
}
=20
+
+
void
bt_waitline(int bt_fd, int line)
{
@@ -417,29 +458,20 @@
}
=20
void
-bt_set_bd_addr(int bt_cfd, int* bd)
-{
- int i;
- unsigned char new_bd[6];
-=20=20=20=20
- for (i =3D 0; i < 6; i++)
+bt_set_bd_addr(int bt_cfd, unsigned char *bd)
{
- new_bd[i] =3D (unsigned char) *bd++;
- }
-
printf("Setting BD address to: %02X:%02X:%02X:%02X:%02X:%02X\n",
- new_bd[0], new_bd[1], new_bd[2],
- new_bd[3], new_bd[4], new_bd[5]);
+ bd[0], bd[1], bd[2],
+ bd[3], bd[4], bd[5]);
=20=20=20=20=20
#ifndef BT_USERSTACK
- if (ioctl(bt_cfd, HCIWRITEBDADDR, new_bd) < 0)
+ if (ioctl(bt_cfd, HCIWRITEBDADDR, bd) < 0)
{
perror("Set bd addr");
}
#else
- hci_set_bd_addr(new_bd);
+ hci_set_bd_addr(bd);
#endif=20=20=20=20
-=20
printf("Please reset HW to activate bd change\n");
}
=20
@@ -449,7 +481,7 @@
int bt_set_baudrate(int bt_cfd, int spd)
{
int result;
-=20=20
+ syslog(LOG_INFO, "bt_set_baudrate %d baud", spd);
#ifdef BT_USERSTACK
tcflush(phys_fd, TCIOFLUSH);
hci_set_baudrate(spd);
@@ -473,15 +505,12 @@
}
#else
BD_ADDR rev_bd;
- int i;
-=20=20
hci_read_local_bd(rev_bd);
=20
/* return as big endian */
for (i =3D 0; i < 6; i++) {
bd_addr[i] =3D rev_bd[5-i];
}
-
#endif
}
=20
@@ -755,12 +784,15 @@
{
switch(code)
{=20
- case RES_PSMNEG:
+ case L2CAP_PSMNEG:
return "L2CAP - PSM not valid";
- case RES_SECNEG:
+ case L2CAP_SECNEG:
return "L2CAP - Security block";
- case RES_NOSRC:
+ case L2CAP_NOSRC:
return "L2CAP - Remote side has no resources";
+ case L2CAP_CON_UNRESPONSIVE:
+ return "L2CAP - Unresponsive link";
+
default:
return "L2CAP - unknown reason";
}
@@ -768,7 +800,7 @@
break;
=20=20=20=20=20
default:
- return "Unknown layer - unknown reason";
+ return "General failure";
}
}
=20
|