Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] tools/sdptool: Check if HCI is powered UP before executing commands
@ 2015-01-28 13:40 Grzegorz Kolodziejczyk
  2015-01-29 15:47 ` Szymon Janc
  0 siblings, 1 reply; 3+ messages in thread
From: Grzegorz Kolodziejczyk @ 2015-01-28 13:40 UTC (permalink / raw)
  To: linux-bluetooth

Before executing commands should be checked if any or chosen HCI is
powered up. If not further executing of command makes no sense.
---
 android/pics-spp.txt  |  2 +-
 android/pixit-spp.txt |  2 +-
 tools/sdptool.c       | 12 ++++++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/android/pics-spp.txt b/android/pics-spp.txt
index f015236..d9bb883 100644
--- a/android/pics-spp.txt
+++ b/android/pics-spp.txt
@@ -1,6 +1,6 @@
 SPP PICS for the PTS tool.
 
-PTS version: 5.3
+PTS version: 6.0
 
 * - different than PTS defaults
 # - not yet implemented/supported
diff --git a/android/pixit-spp.txt b/android/pixit-spp.txt
index a8a8202..8e2d70f 100644
--- a/android/pixit-spp.txt
+++ b/android/pixit-spp.txt
@@ -1,6 +1,6 @@
 SPP PIXIT for the PTS tool.
 
-PTS version: 5.3
+PTS version: 6.0
 
 * - different than PTS defaults
 & - should be set to IUT Bluetooth address
diff --git a/tools/sdptool.c b/tools/sdptool.c
index 17561b1..9ff7a1c 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -4352,17 +4352,20 @@ static struct option main_options[] = {
 
 int main(int argc, char *argv[])
 {
-	int i, opt;
+	int i, opt, err;
 
 	bacpy(&interface, BDADDR_ANY);
 
+	err = hci_get_route(NULL);
+
 	while ((opt=getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) {
 		switch(opt) {
 		case 'i':
 			if (!strncmp(optarg, "hci", 3))
-				hci_devba(atoi(optarg + 3), &interface);
+				err = hci_devba(atoi(optarg + 3), &interface);
 			else
 				str2ba(optarg, &interface);
+				err = hci_get_route(&interface);
 			break;
 
 		case 'h':
@@ -4374,6 +4377,11 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	if (err < 0) {
+		printf("No powered on HCI interface found\n");
+		exit(0);
+	}
+
 	argc -= optind;
 	argv += optind;
 	optind = 0;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] tools/sdptool: Check if HCI is powered UP before executing commands
@ 2015-01-28 13:43 Grzegorz Kolodziejczyk
  0 siblings, 0 replies; 3+ messages in thread
From: Grzegorz Kolodziejczyk @ 2015-01-28 13:43 UTC (permalink / raw)
  To: linux-bluetooth

Before executing commands should be checked if any or chosen HCI is
powered up. If not further executing of command makes no sense.
---
 tools/sdptool.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/sdptool.c b/tools/sdptool.c
index 17561b1..9ff7a1c 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -4352,17 +4352,20 @@ static struct option main_options[] = {
 
 int main(int argc, char *argv[])
 {
-	int i, opt;
+	int i, opt, err;
 
 	bacpy(&interface, BDADDR_ANY);
 
+	err = hci_get_route(NULL);
+
 	while ((opt=getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) {
 		switch(opt) {
 		case 'i':
 			if (!strncmp(optarg, "hci", 3))
-				hci_devba(atoi(optarg + 3), &interface);
+				err = hci_devba(atoi(optarg + 3), &interface);
 			else
 				str2ba(optarg, &interface);
+				err = hci_get_route(&interface);
 			break;
 
 		case 'h':
@@ -4374,6 +4377,11 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	if (err < 0) {
+		printf("No powered on HCI interface found\n");
+		exit(0);
+	}
+
 	argc -= optind;
 	argv += optind;
 	optind = 0;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools/sdptool: Check if HCI is powered UP before executing commands
  2015-01-28 13:40 [PATCH] tools/sdptool: Check if HCI is powered UP before executing commands Grzegorz Kolodziejczyk
@ 2015-01-29 15:47 ` Szymon Janc
  0 siblings, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2015-01-29 15:47 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth

Hi Grzegorz,

On Wednesday 28 of January 2015 14:40:21 Grzegorz Kolodziejczyk wrote:
> Before executing commands should be checked if any or chosen HCI is
> powered up. If not further executing of command makes no sense.
> ---
>  android/pics-spp.txt  |  2 +-
>  android/pixit-spp.txt |  2 +-

This shouldn't be part of this patch.

>  tools/sdptool.c       | 12 ++++++++++--
>  3 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/android/pics-spp.txt b/android/pics-spp.txt
> index f015236..d9bb883 100644
> --- a/android/pics-spp.txt
> +++ b/android/pics-spp.txt
> @@ -1,6 +1,6 @@
>  SPP PICS for the PTS tool.
> 
> -PTS version: 5.3
> +PTS version: 6.0
> 
>  * - different than PTS defaults
>  # - not yet implemented/supported
> diff --git a/android/pixit-spp.txt b/android/pixit-spp.txt
> index a8a8202..8e2d70f 100644
> --- a/android/pixit-spp.txt
> +++ b/android/pixit-spp.txt
> @@ -1,6 +1,6 @@
>  SPP PIXIT for the PTS tool.
> 
> -PTS version: 5.3
> +PTS version: 6.0
> 
>  * - different than PTS defaults
>  & - should be set to IUT Bluetooth address
> diff --git a/tools/sdptool.c b/tools/sdptool.c
> index 17561b1..9ff7a1c 100644
> --- a/tools/sdptool.c
> +++ b/tools/sdptool.c
> @@ -4352,17 +4352,20 @@ static struct option main_options[] = {
> 
>  int main(int argc, char *argv[])
>  {
> -	int i, opt;
> +	int i, opt, err;
> 
>  	bacpy(&interface, BDADDR_ANY);
> 
> +	err = hci_get_route(NULL);
> +
>  	while ((opt=getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) {
>  		switch(opt) {
>  		case 'i':
>  			if (!strncmp(optarg, "hci", 3))
> -				hci_devba(atoi(optarg + 3), &interface);
> +				err = hci_devba(atoi(optarg + 3), &interface);
>  			else
>  				str2ba(optarg, &interface);
> +				err = hci_get_route(&interface);
>  			break;
> 
>  		case 'h':
> @@ -4374,6 +4377,11 @@ int main(int argc, char *argv[])
>  		}
>  	}
> 
> +	if (err < 0) {
> +		printf("No powered on HCI interface found\n");
> +		exit(0);
> +	}
> +
>  	argc -= optind;
>  	argv += optind;
>  	optind = 0;

-- 
BR
Szymon Janc

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-29 15:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-28 13:40 [PATCH] tools/sdptool: Check if HCI is powered UP before executing commands Grzegorz Kolodziejczyk
2015-01-29 15:47 ` Szymon Janc
  -- strict thread matches above, loose matches on Subject: below --
2015-01-28 13:43 Grzegorz Kolodziejczyk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox