|
From: Peter K. <pk...@us...> - 2001-04-04 10:33:05
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btdisc.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Correctly support -D as option.
* Minor clean-up.
The diff of the modified file(s):
--- btdisc.c 2001/03/31 16:31:21 1.3
+++ btdisc.c 2001/04/04 10:33:03 1.4
@@ -62,34 +62,27 @@
#include "bt_conf.h"
#include "bt_misc.h"
=20=20=20=20=20
+#define DEFAULT_BTDEV "/dev/ttyBT0"
+
/*=20
- * Syntax : btdisc -d <dev> -D <rfcomm dlci>=20
+ * Syntax : btdisc [-d <dev>] -D <rfcomm dlci>=20
*/
=20
int
main(int argc, char **argv)
{
+ char *btdev =3D DEFAULT_BTDEV;
int con_id, bt_cfd, dlci=3D-1, line, opt;
- char *btdev =3D "/dev/ttyBT0"; /* default */=20=20
- int ret_val;
+ int result;
=20
-#ifdef __CRIS__
/* Print header if called via http */
if (getenv("REQUEST_METHOD") !=3D NULL)
{
printf("Content-type: text/plain\r\n\r\n");
}
-#endif
=20
- /* First of all check that stack is running */
- if (!bt_isinitiated())
- {
- printf("Stack not initiated, exit\n");
- exit(1);
- }
-
/* now parse options */
-#define OPTIONS_STRING "d:S:"
+#define OPTIONS_STRING "d:D:"
=20=20
while ((opt =3D getopt(argc, argv, OPTIONS_STRING)) !=3D -1)
{
@@ -106,19 +99,25 @@
printf("RFCOMM dlci : %d\n", dlci);
break;
=20=20=20=20=20=20=20
- case '?':
- printf("unknown option: %c\n", optopt);
+ default:
break;
}
}
=20
- if (argc < 2 || (dlci < 0))
+ if (optind < argc || dlci < 0)
{
printf("Wrong syntax or missing parameters\n");
- printf("Syntax : btdisc -d <dev> -D <rfcomm dlci>\n");
+ printf("Syntax: %s [-d <dev>] -D <rfcomm dlci>\n", argv[0]);
exit(0);
}
=20
+ /* First of all check that stack is running */
+ if (!bt_isinitiated())
+ {
+ printf("Stack not initiated, exit\n");
+ exit(1);
+ }
+
/* Open BT ctrl device */
bt_cfd =3D bt_openctrl();
=20
@@ -129,8 +128,8 @@
=20
con_id =3D CREATE_RFCOMM_ID(line, dlci);
=20
- ret_val =3D bt_disconnect(bt_cfd, con_id);
+ result =3D bt_disconnect(bt_cfd, con_id);
=20
close(bt_cfd);
- exit(ret_val);
+ exit(result);
}
|