|
From: Mattias A. <mat...@us...> - 2001-03-21 18:46:04
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btcon.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
added two more options to write BD address, e.g 001122334455, 00-11-22-33-4=
4-55
The diff of the modified file(s):
--- btcon.c 2001/03/02 10:59:57 1.1
+++ btcon.c 2001/03/21 18:46:02 1.2
@@ -100,21 +100,45 @@
{
switch(opt)
{
+=20=20=20=20=20=20
case 'a':
{
- int tmp[6];
+ int tmp[6], all_read =3D 0;
bd_str =3D optarg;
- printf("Connecting to bd : %s\n", bd_str);
- if (sscanf(optarg, "%x:%x:%x:%x:%x:%x",
+ 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=20
+ all_read =3D 1;
+ }
+ else if (sscanf(optarg, "%x:%x:%x:%x:%x:%x",
+ &tmp[0], &tmp[1], &tmp[2],
+ &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
+ {=20=20
+ all_read =3D 1;
+ }
+ else if (sscanf(optarg, "%x-%x-%x-%x-%x-%x",
&tmp[0], &tmp[1], &tmp[2],
&tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
{
+ all_read =3D 1;
+ }
+=20=20=20=20=20=20=20=20
+ /* now convert to real bd format if syntax was correct */
+ if(all_read)
+ {
for (i =3D 0; i < 6; i++)
{
bd[i] =3D (unsigned char)tmp[i];=20
}
+ printf("Connecting to bd : %2x:%2x:%2x:%2x:%2x:%2x\n",
+ bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]);
}
-=20=20=20=20=20=20=20=20
+ else
+ {
+ printf("Invalid syntax : %s\n", bd_str);
+ exit(1);
+ }
}
break;
=20
|
|
From: Peter K. <pk...@us...> - 2001-04-04 10:32:05
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btcon.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Minor clean-up.
The diff of the modified file(s):
--- btcon.c 2001/03/21 18:46:02 1.2
+++ btcon.c 2001/04/04 10:32:03 1.3
@@ -65,33 +65,24 @@
#define DEFAULT_BTDEV "/dev/ttyBT0"
=20
/*
- * Syntax : btcon -d <device> -p <pincode> -a <BD> -S <rfcomm srv ch>
+ * Syntax : btcon [-d <device>] [-p <pincode>] -a <BD> [-S <rfcomm srv ch>]
* If using 'disable' as pin, authentication is disabled=20
*/
=20
int
main(int argc, char **argv)
{
- char *btdev =3D NULL;
+ char *btdev =3D DEFAULT_BTDEV;
char *bd_str =3D NULL;
unsigned char bd[6];
int con_id, opt, i, result;
int line, bt_cfd, srvch =3D 1;
=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
-
- /* First of all check that stack is running */
- if (!bt_isinitiated())
- {
- printf("Stack not initiated, exit\n");
- exit(1);
- }
=20
/* now parse options */
#define OPTIONS_STRING "a:d:r:S:p:"
@@ -100,7 +91,6 @@
{
switch(opt)
{
-=20=20=20=20=20=20
case 'a':
{
int tmp[6], all_read =3D 0;
@@ -145,15 +135,13 @@
case 'd':
/* BT device */
btdev=3Doptarg;
- printf("btdev : %s\n", btdev);
+ printf("btdev %s\n", btdev);
break;
=20=20=20=20=20=20=20
case 'p':
- {=20
/* If using 'disable' as pin, authentication is disabled */
printf("Using pin code : %s\n", optarg);
set_pin_code(optarg);
- }
break;
=20
case 'S':
@@ -161,19 +149,22 @@
printf("Using rfcomm server ch : %d\n", srvch);
break;
=20=20=20=20=20=20=20
- case '?':
- printf("unknown option: %c\n", optopt);
+ default:
break;
}
}
=20
- if (!btdev)
- btdev =3D DEFAULT_BTDEV;
-
- if (argc < 2 || (bd_str =3D=3D NULL))
+ if (optind < argc || !bd_str)
{=20=20=20=20
printf("Wrong syntax or missing parameters\n");
- printf("Syntax : btcon -d <device> -p <pincode> -a <BD> -S <rfcomm srv=
ch>\n");=20=20=20=20=20=20=20=20
+ printf("Syntax: %s [-d <device>] [-p <pincode>] -a <BD> [-S <rfcomm sr=
v ch>]\n", argv[0]);
+ exit(1);
+ }
+
+ /* First of all check that stack is running */
+ if (!bt_isinitiated())
+ {
+ printf("Stack not initiated, exit\n");
exit(1);
}
=20
|
|
From: Mattias A. <mat...@us...> - 2001-05-21 09:07:45
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btcon.c 1.6 1.7=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* added sanity check for inparams
The diff of the modified file(s):
--- btcon.c 2001/05/14 11:29:36 1.6
+++ btcon.c 2001/05/21 09:07:45 1.7
@@ -179,6 +179,13 @@
=20=20
printf("Connecting to %s on line %d\n", bd2str(bd), line);
=20
+ /* Some sanity checks */
+ if ((srvch <=3D 0) || (srvch > 62) || (line < 0) || (line > 6))
+ {
+ printf("Invalid parameters, srvch [1-62] , line [0-6]\n");
+ exit(1);
+ }
+
con_id =3D CREATE_RFCOMM_ID(line, srvch << 1);
=20
result =3D bt_connect(bt_cfd, bd, con_id);
|