|
From: Anders J. <and...@us...> - 2001-10-10 14:56:01
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bt_errno.h 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
bt_if.c 1.36 1.37=20=20=20=20=20=20=20=20=20=20=20=20
bt_if.h 1.26 1.27=20=20=20=20=20=20=20=20=20=20=20=20
bttest.c 1.21 1.22=20=20=20=20=20=20=20=20=20=20=20=20
bttest.h 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Changed to use the new errorcodes from stack.=20
* Changed so that we doesn't return just a -1 on error.
The diff of the modified file(s):
--- bt_errno.h 2001/04/17 14:18:26 1.1
+++ bt_errno.h 2001/10/10 14:56:00 1.2
@@ -45,19 +45,21 @@
=20
/* Unique status codes 32 bits : | layer 16 bits | code 16 bits | */
#define MSGCODE(layer, msgcode) ((((layer)<<16)&0xffff0000) | ((msgcode)&0=
xffff))
+#define MSG_GET_LAYER(msg) ((msg >> 16) & 0x0000ffff)
+#define MSG_GET_CODE(msg) (msg & 0x0000ffff)
=20
/* Layer ID */
-#define MSG_LAYER_HCI 0
-#define MSG_LAYER_L2CAP 1
-#define MSG_LAYER_RFCOMM 2
+#define MSG_LAYER_HCI 1
+#define MSG_LAYER_L2CAP 2
+#define MSG_LAYER_RFCOMM 3
#define MSG_LAYER_SDP 4
-#define MSG_LAYER_TCS 8
-#define MSG_BT_INTERFACE 16
+#define MSG_LAYER_TCS 5
+#define MSG_BT_INTERFACE 6
=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=3D=3D=3D=3D=3D*/
/* HCI */
=20
-/* fixme */
+/* Uses errorcodes as specified in the BT specification */
=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=3D=3D=3D=3D=3D*/
/* L2CAP */
@@ -73,6 +75,10 @@
/* General l2cap return codes */
#define L2CAP_FAILED 0xf0
#define L2CAP_CON_UNRESPONSIVE 0xf1
+#define L2CAP_INVALID_STATE 0xf2
+#define L2CAP_NO_CONNECTION 0xf3
+#define L2CAP_EXCEED_REMOTE_MTU 0xf4
+#define L2CAP_RTX_TIMEOUT 0xf5
=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=3D=3D=3D=3D=3D*/
/* RFCOMM */
@@ -95,3 +101,4 @@
#define BT_NOTCONNECTED 0x1
#define BT_ALREADYCONNECTED 0x2
#define BT_TIMEOUT 0x3
+#define BT_LINE_BUSY 0x4
--- bt_if.c 2001/10/04 13:22:15 1.36
+++ bt_if.c 2001/10/10 14:56:00 1.37
@@ -287,7 +287,7 @@
=20
#ifndef BT_USERSTACK
if ((result =3D ioctl(bt_fd, BTCONNECT, &con)))
- printf("Connect failed [%s (%d)]\n", error_msg(result), result);
+ printf("Connect failed [%s (%d)]\n", error_msg(result), MSG_GET_CODE(-=
result));
else
printf("Connected.\n");=20
#else
@@ -312,7 +312,7 @@
=20=20=20
#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);
+ printf("Disconnect failed [%s (%d)]\n", error_msg(ret_val), MSG_GET_CO=
DE(-ret_val));
else
printf("Disconnected.\n");
#else
@@ -561,7 +561,7 @@
#ifndef BT_USERSTACK=20
if ((ret_val =3D ioctl(bt_cfd, BTPING, &ping)) < 0)
{
- printf("Error : %s\n", error_msg(ret_val));
+ printf("Error : [%s (%d)]\n", error_msg(ret_val), MSG_GET_CODE(-ret_va=
l));
}
else
printf("Success!\n");
@@ -584,7 +584,7 @@
#ifndef BT_USERSTACK=20
if ((ret_val =3D ioctl(bt_cfd, BTGETINFO, &msg)) < 0)
{
- printf("Error : %s\n", error_msg(ret_val));
+ printf("Error : [%s (%d)]\n", error_msg(ret_val), MSG_GET_CODE(-ret_va=
l));
}
else
printf("Success!\n");
@@ -608,8 +608,10 @@
#ifndef BT_USERSTACK=20
if ((ret_val =3D ioctl(bt_cfd, BTTESTCOMMAND, tmp)) < 0)
{
- printf("Error : %s\n", error_msg(ret_val));
+ printf("Error : [%s (%d)]\n", error_msg(ret_val), MSG_GET_CODE(-ret_va=
l));
}
+ else
+ printf("Success!\n");
#else
test_process_cmd(&tmp[1], tmp[0]);
#endif
@@ -1056,99 +1058,101 @@
/* See bt_errno.h for error codes */
const char *error_msg(int err)
{
- int layer =3D (err >> 16) & 0xffff;
- int code =3D err & 0xffff;
+ int layer, code, msg;
+ msg =3D -err;
+ layer =3D MSG_GET_LAYER(msg);
+ code =3D MSG_GET_CODE(msg);
=20
switch (layer)
{
case MSG_LAYER_HCI:
- {
-
- /* fixme -- add these as defines in bt_errno.h */
switch(code)
{=20=20=20=20=20=20=20
- case 0x03:=20=20=20=20=20=20=20=20
- return "HCI - Hardware Failure";
- case 0x04:=20=20=20=20=20=20=20=20
- return "HCI - Page Timeout";
- case 0x05:=20=20=20=20=20=20=20=20
- return "HCI - Authentications Failure";
- case 0x06:=20=20=20=20=20=20=20=20
- return "HCI - Key missing";
- case 0x09:=20=20=20=20=20=20=20=20
- return "HCI - Max number of connections";
- case 0x0b:=20=20=20=20=20=20=20=20
- return "HCI - ACL connection already exists";
- case 0x0c:=20=20=20=20=20=20=20=20
- return "HCI - Command disallowed";
- case 0x10:=20=20=20=20=20=20=20=20
- return "HCI - Host Timeout";
-
- default :
- return "HCI - Unknown reason";
- break;
- }
+ case 0x00: return "HCI: Success!";
+ case 0x01: return "HCI: Unknown HCI Command";
+ case 0x02: return "HCI: No Connection";
+ case 0x03: return "HCI: Hardware Failure";
+ case 0x04: return "HCI: Page Timeout";
+ case 0x05: return "HCI: Authentication Failure";
+ case 0x06: return "HCI: Key Missing";
+ case 0x07: return "HCI: Memory Full";
+ case 0x08: return "HCI: Connection Timeout";
+ case 0x09: return "HCI: Max Number Of Connections";
+ case 0x0A: return "HCI: Max Number Of SCO Connections To A Device";
+ case 0x0B: return "HCI: ACL connection already exists";
+ case 0x0C: return "HCI: Command Disallowed";
+ case 0x0D: return "HCI: Host Rejected due to limited resources";
+ case 0x0E: return "HCI: Host Rejected due to security reasons";
+ case 0x0F: return "HCI: Host Rejected due to remote device is only a =
personal device";
+ case 0x10: return "HCI: Host Timeout";
+ case 0x11: return "HCI: Unsupported Feature or Parameter Value";
+ case 0x12: return "HCI: Invalid HCI Command Parameters";
+ case 0x13: return "HCI: Other End Terminated Connection: User Ended C=
onnection";
+ case 0x14: return "HCI: Other End Terminated Connection: Low Resource=
s";
+ case 0x15: return "HCI: Other End Terminated Connection: About to Pow=
er Off";
+ case 0x16: return "HCI: Connection Terminated by Local Host";
+ case 0x17: return "HCI: Repeated Attempts";
+ case 0x18: return "HCI: Pairing Not Allowed";
+ case 0x19: return "HCI: Unknown LMP PDU";
+ case 0x1A: return "HCI: Unsupported Remote Feature";
+ case 0x1B: return "HCI: SCO Offset Rejected";
+ case 0x1C: return "HCI: SCO Interval Rejected";
+ case 0x1D: return "HCI: SCO Air Mode Rejected";
+ case 0x1E: return "HCI: Invalid LMP Parameters";
+ case 0x1F: return "HCI: Unspecified Error";
+ case 0x20: return "HCI: Unsupported LMP Parameter Value";
+ case 0x21: return "HCI: Role Change Not Allowed";
+ case 0x22: return "HCI: LMP Response Timeout";
+ case 0x23: return "HCI: LMP Error Transaction Collision";
+ case 0x24: return "HCI: LMP PDU Not Allowed";
+ case 0x25: return "HCI: Encryption Mode Not Acceptable";
+ case 0x26: return "HCI: Unit Key Used";
+ case 0x27: return "HCI: QOS is Not Supported";
+ case 0x28: return "HCI: Instant Passed";
+ case 0x29: return "HCI: Pairing with Unit Key Not Supported";
+ default: return "HCI: No debug msg defined";
}
- break;
-
case MSG_LAYER_L2CAP:
- {
switch(code)
{=20
- case L2CAP_PSMNEG:
- return "L2CAP - PSM not valid";
- case L2CAP_SECNEG:
- return "L2CAP - Security block";
- case L2CAP_NOSRC:
- return "L2CAP - Remote side has no resources";=09
- case L2CAP_CON_UNRESPONSIVE:
- return "L2CAP - Unresponsive link";
-
- default:
- return "L2CAP - unknown reason";
- }
+ case L2CAP_SUCCESS: return "L2CAP: Success";
+ case L2CAP_CON_PENDING: return "L2CAP: Connection Pending";
+ case L2CAP_PSMNEG: return "L2CAP: Connection Refused, PSM Not Accepte=
d";
+ case L2CAP_SECNEG: return "L2CAP: Connection Refused, Authentication =
Failed";
+ case L2CAP_NOSRC: return "L2CAP: Connection Refused, No Resources";
+ case L2CAP_FAILED: return "L2CAP: General Error";
+ case L2CAP_CON_UNRESPONSIVE: return "L2CAP: No Reply From Remote";
+ case L2CAP_INVALID_STATE: return "L2CAP: Invalid State";
+ case L2CAP_NO_CONNECTION: return "L2CAP: No Connection";
+ case L2CAP_EXCEED_REMOTE_MTU: return "L2CAP: Trying to send a frame m=
ore than remote MTU";
+ case L2CAP_RTX_TIMEOUT: return "L2CAP: Timeout Waiting For Remote To =
Reply";
+ default: return "L2CAP: No debug msg defined";
}
- break;
-=20=20=20=20
case MSG_LAYER_RFCOMM:
+ switch(code)
{
- /* fixme */
- return "RFCOMM - unknown reason";
+ default: return "RFCOMM: No debug msg defined";
}
- break;
-
case MSG_LAYER_SDP:
+ switch(code)
{
- /* fixme */
- return "SDP - unknown reason";
+ default: return "SDP: No debug msg defined";
}
- break;
-=20=20=20=20
case MSG_LAYER_TCS:
+ switch(code)
{
- /* fixme */
- return "TCS - unknown reason";
+ default: return "TCS: No debug msg defined";
}
- break;
-=20=20=20=20
case MSG_BT_INTERFACE:
- {
switch(code)
{=20
- case BT_NOTCONNECTED:
- return "BT_INTERFACE - Not connected";
- case BT_ALREADYCONNECTED:
- return "BT_INTERFACE - Already connected";
- case BT_TIMEOUT:
- return "BT_INTERFACE - Timeout";
- default:
- return "BT_INTERFACE - unknown reason";
- }
+ case BT_NOTCONNECTED: return "BT_INTERFACE: Line Not Connected";
+ case BT_ALREADYCONNECTED: return "BT_INTERFACE: Line Already Connecte=
d";
+ case BT_TIMEOUT: return "BT_INTERFACE: Timeout When Processing Comman=
d";
+ case BT_LINE_BUSY: return "BT_INTERFACE: Line Busy";
+ default: return "BT_INTERFACE: No debug msg defined";
}
- break;
-
- default:
- return "General failure";
+ default: return "General Failure";
}
}
=20
@@ -1428,7 +1432,7 @@
=20
if (status) {
/* fixme -- only works for rfcomm now */
- line =3D GET_RFCOMMLINE(con_id);
+ line =3D GET_LINE(con_id);
=20
if ((line < 0) || (line > BT_NBR_DATAPORTS)) {
=20
--- bt_if.h 2001/10/05 11:57:42 1.26
+++ bt_if.h 2001/10/10 14:56:00 1.27
@@ -93,27 +93,6 @@
=20
#define SDPSRV_CONF "/etc/sdp.xml"
=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=3D */
-/* Return code defines (see bt_errno.h in kernel)*/
-
-/* unique message status codes 32 bits : | layer 16 bits | code 16 bits | =
*/
-
-#define MSG_LAYER_HCI 0
-#define MSG_LAYER_L2CAP 1
-#define MSG_LAYER_RFCOMM 2
-#define MSG_LAYER_SDP 4
-#define MSG_LAYER_TCS 8
-
-#define L2CAP_SUCCESS 0x0
-#define L2CAP_CON_PENDING 0x1
-
-/* Result in responses in L2CAP */
-#define L2CAP_PSMNEG 0x02
-#define L2CAP_SECNEG 0x03
-#define L2CAP_NOSRC 0x04
-
-#define L2CAP_FAILED 0xf0
-#define L2CAP_CON_UNRESPONSIVE 0xf1
=20
#ifndef BT_USERSTACK
=20
--- bttest.c 2001/10/03 17:48:31 1.21
+++ bttest.c 2001/10/10 14:56:00 1.22
@@ -70,7 +70,7 @@
#include "bt_misc.h"
#include "bt_conf.h"
#include "bt_vendor.h"
-
+#include "bt_errno.h"
/* =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 */
=20
#define BTD_HISTORY_FILE "/tmp/btd_history"
@@ -240,6 +240,7 @@
process_cmd(char *buf, int bt_cfd)
{
unsigned int i, con_id, tmp[10], repeat, line =3D 0, profile, srv_ch;
+ int retval =3D 0;
unsigned char bd[6];
=20
if (!strncmp(buf, "quit", 4))
@@ -263,7 +264,7 @@
srv_ch =3D (unsigned short)(tmp[6]);
con_id =3D CREATE_RFCOMM_ID(line, srv_ch<<1);
=20=20=20=20=20
- bt_connect(bt_cfd, bd, con_id);
+ retval =3D bt_connect(bt_cfd, bd, con_id);
}
else if (sscanf(buf, "bt_wrscan %d", &tmp[0]) =3D=3D 1)
{
@@ -274,7 +275,7 @@
{
unsigned int con_id;
con_id =3D CREATE_RFCOMM_ID(line, 0 /* fixme -- don't care */);
- bt_disconnect(bt_cfd, con_id);
+ retval =3D bt_disconnect(bt_cfd, con_id);
}
else if (sscanf(buf, "rf_wait %d", &line) =3D=3D 1)
{
@@ -387,7 +388,7 @@
/* fill it with something */
memset(buf, 'A', count);
=20
- bt_ping(bt_cfd, bd, (unsigned char*)&buf , (unsigned short)count);=20=
=20
+ retval =3D bt_ping(bt_cfd, bd, (unsigned char*)&buf , (unsigned short)=
count);=20=20
}
else if (sscanf(buf, "getinfo %x:%x:%x:%x:%x:%x %d",
&tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5],=20
@@ -407,7 +408,7 @@
#ifdef CONFIG_BLUETOOTH_UNPLUG_TEST
else if (strncmp(buf, "upt", 3) =3D=3D 0)
{
- bt_testcmd(bt_cfd, buf+4);
+ retval =3D bt_testcmd(bt_cfd, buf+4);
}
#endif
else if (sscanf(buf, "getinfo %x:%x:%x:%x:%x:%x %x",
@@ -436,7 +437,7 @@
bd[0], bd[1], bd[2],
bd[3], bd[4], bd[5]);
=20
- bt_connect(bt_cfd, bd, (TCS_LAYER << 16) & 0xffff000);
+ retval =3D bt_connect(bt_cfd, bd, (TCS_LAYER << 16) & 0xffff000);
}
=20
/* FIXME so that we can specify which line to connect */
@@ -454,7 +455,7 @@
bd[3], bd[4], bd[5]);
=20=20=20=20=20
printf("RFCOMM server channel is %d\n", srv_ch);
- bt_connect(bt_cfd, bd, CREATE_RFCOMM_ID(0, srv_ch << 1));
+ retval =3D bt_connect(bt_cfd, bd, CREATE_RFCOMM_ID(0, srv_ch << 1));
}
else if(sscanf(buf, "sdp_conn %x:%x:%x:%x:%x:%x",
&tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
@@ -468,7 +469,7 @@
bd[0], bd[1], bd[2],
bd[3], bd[4], bd[5]);
=20
- bt_connect(bt_cfd, bd, (SDP_LAYER << 16) & 0xFFFF0000);
+ retval =3D bt_connect(bt_cfd, bd, (SDP_LAYER << 16) & 0xFFFF0000);
}
else if(sscanf(buf, "test_conn %x:%x:%x:%x:%x:%x %x %d",
&tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], &tmp[6], &tmp[7])=
=3D=3D 8)
@@ -481,32 +482,32 @@
printf("Connecting test layer (psm 0x%x, line %d) to bd : %02X:%02X:%0=
2X:%02X:%02X:%02X\n",=20
tmp[6], tmp[7], bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]);
=20
- bt_connect(bt_cfd, bd, ((tmp[6] << 16) & 0xffff0000) | tmp[7]);
+ retval =3D bt_connect(bt_cfd, bd, ((tmp[6] << 16) & 0xffff0000) | tmp[=
7]);
}
else if (sscanf(buf, "test_case_reject %x:%x:%x:%x:%x:%x",
&tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) =
=3D=3D 6)
{
- bt_testcmd(bt_cfd, buf);
+ retval =3D bt_testcmd(bt_cfd, buf);
}
else if (sscanf(buf, "test_disc %x", &tmp[0]) =3D=3D 1)
{
printf("Disconnecting layer (PSM: %x)\n", tmp[0]);
- bt_disconnect(bt_cfd, (tmp[0] << 16) & 0xffff0000);
+ retval =3D bt_disconnect(bt_cfd, (tmp[0] << 16) & 0xffff0000);
}
else if(sscanf(buf, "bb_conn %x:%x:%x:%x:%x:%x",
&tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
{
- bt_testcmd(bt_cfd, buf);
+ retval =3D bt_testcmd(bt_cfd, buf);
}
else if(sscanf(buf, "bb_disc %d", &i) =3D=3D 1)
{
printf("Disconnecting hci handle %d\n", i);
- bt_testcmd(bt_cfd, buf);
+ retval =3D bt_testcmd(bt_cfd, buf);
}
else if(sscanf(buf, "lcid_disconnect %d", &i) =3D=3D 1)
{
printf("Disconnecting lcid %d", i);
- bt_testcmd(bt_cfd, buf);
+ retval =3D 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]))
@@ -562,7 +563,9 @@
{
printf("> error: command not recognized or wrong syntax\n");
show_menu();
+ return 0;
}
+=20=20=20=20=20=20
return 0;
}
=20
@@ -601,6 +604,8 @@
return line;
}
#endif /* !HAVE_READLINE */
+
+
=20
/* bttest.c */
/* =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 */
--- bttest.h 2001/03/02 10:59:57 1.1
+++ bttest.h 2001/10/10 14:56:00 1.2
@@ -45,6 +45,5 @@
#define START_PPP 1
#define QUIT_BTD 2
int process_cmd(char *buf, int bt_cfd);
-
#endif /* __BT_TEST_H__*/
=20
|