Re: [RFC 1/3] btattach: Add SetDevType ioctl call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Fred,

> ---
> tools/btattach.c  | 22 +++++++++++++++++-----
> tools/hciattach.h |  1 +
> 2 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/btattach.c b/tools/btattach.c
> index b7948a3..63620e4 100644
> --- a/tools/btattach.c
> +++ b/tools/btattach.c
> @@ -106,7 +106,7 @@ static void local_version_callback(const void *data, uint8_t size,
> }
> 
> static int attach_proto(const char *path, unsigned int proto,
> -						unsigned int flags)
> +					unsigned int flags, const char *type)
> {
> 	int fd, dev_id;
> 
> @@ -120,6 +120,14 @@ static int attach_proto(const char *path, unsigned int proto,
> 		return -1;
> 	}
> 
> +	if (type) {
> +		if (ioctl(fd, HCIUARTSETDEVTYPE, type) < 0) {
> +			perror("Failed to set device type");
> +			close(fd);
> +			return -1;
> +		}
> +	}
> +
> 	if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
> 		perror("Failed to set protocol");
> 		close(fd);
> @@ -193,6 +201,7 @@ static void usage(void)
> static const struct option main_options[] = {
> 	{ "bredr",   required_argument, NULL, 'B' },
> 	{ "amp",     required_argument, NULL, 'A' },
> +	{ "type",    required_argument, NULL, 't' },
> 	{ "version", no_argument,       NULL, 'v' },
> 	{ "help",    no_argument,       NULL, 'h' },
> 	{ }
> @@ -200,7 +209,7 @@ static const struct option main_options[] = {
> 
> int main(int argc, char *argv[])
> {
> -	const char *bredr_path = NULL, *amp_path = NULL;
> +	const char *bredr_path = NULL, *amp_path = NULL, *type = NULL;
> 	bool raw_device = false;
> 	sigset_t mask;
> 	int exit_status, count = 0;
> @@ -208,7 +217,7 @@ int main(int argc, char *argv[])
> 	for (;;) {
> 		int opt;
> 
> -		opt = getopt_long(argc, argv, "B:A:Rvh",
> +		opt = getopt_long(argc, argv, "B:A:t:Rvh",
> 						main_options, NULL);
> 		if (opt < 0)
> 			break;
> @@ -220,6 +229,9 @@ int main(int argc, char *argv[])
> 		case 'A':
> 			amp_path = optarg;
> 			break;
> +		case 't':
> +			type = optarg;
> +			break;
> 		case 'R':
> 			raw_device = true;
> 			break;
> @@ -258,7 +270,7 @@ int main(int argc, char *argv[])
> 		if (raw_device)
> 			flags = (1 << HCI_UART_RAW_DEVICE);
> 
> -		fd = attach_proto(bredr_path, HCI_UART_H4, flags);
> +		fd = attach_proto(bredr_path, HCI_UART_H4, flags, type);

I think the real feature you want to add here is the ability to choose different HCI_UART_* types. So lets define a list of types that we support. This should just be drivers/vendors and not all different chips like in hciattach.

However you need to do a lot of input verification checks here. For example AMP implies H:4 at the moment.

The kernel calls is PROTO at the moment and with that we most likely should just call it --protocol / -p here. If not specified it defaults to H:4.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux