Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/4] android/bluetooth: Add support for DUT mode configure command
Date: Mon, 23 Dec 2013 10:46:09 +0200	[thread overview]
Message-ID: <20131223084607.GA19604@aemeltch-MOBL1> (raw)
In-Reply-To: <1387564210-6102-2-git-send-email-szymon.janc@tieto.com>

On Fri, Dec 20, 2013 at 07:30:08PM +0100, Szymon Janc wrote:
> This allows to enable and disable DUT mode.

Hi Szymon, could you add some more info about the mode?

Best regards 
Andrei Emeltchenko 

> ---
>  android/bluetooth.c | 29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 2e75864..59f0810 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -50,6 +50,8 @@
>  #include "utils.h"
>  #include "bluetooth.h"
>  
> +#define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
> +
>  #define DEVICE_ID_SOURCE	0x0002	/* USB */
>  #define DEVICE_ID_VENDOR	0x1d6b	/* Linux Foundation */
>  #define DEVICE_ID_PRODUCT	0x0247	/* BlueZ for Android */
> @@ -2872,13 +2874,34 @@ failed:
>  static void handle_dut_mode_conf_cmd(const void *buf, uint16_t len)
>  {
>  	const struct hal_cmd_dut_mode_conf *cmd = buf;
> +	char path[FILENAME_MAX];
> +	uint8_t status;
> +	int fd, ret;
>  
>  	DBG("enable %u", cmd->enable);
>  
> -	/* TODO */
> +	snprintf(path, sizeof(path), DUT_MODE_FILE, adapter.index);
>  
> -	ipc_send_rsp(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_DUT_MODE_CONF,
> -							HAL_STATUS_FAILED);
> +	fd = open(path, O_WRONLY);
> +	if (fd < 0) {
> +		status = HAL_STATUS_FAILED;
> +		goto failed;
> +	}
> +
> +	if (cmd->enable)
> +		ret = write(fd, "1", sizeof("1"));
> +	else
> +		ret = write(fd, "0", sizeof("0"));
> +
> +	if (ret < 0)
> +		status = HAL_STATUS_FAILED;
> +	else
> +		status = HAL_STATUS_SUCCESS;
> +
> +	close(fd);
> +
> +failed:
> +	ipc_send_rsp(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_DUT_MODE_CONF, status);
>  }
>  
>  static void handle_dut_mode_send_cmd(const void *buf, uint16_t len)
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2013-12-23  8:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 18:30 [PATCH 1/4] android/bluetooth: Add support for timestamp device property Szymon Janc
2013-12-20 18:30 ` [PATCH 2/4] android/bluetooth: Add support for DUT mode configure command Szymon Janc
2013-12-23  8:46   ` Andrei Emeltchenko [this message]
2013-12-23 13:55     ` Marcel Holtmann
2013-12-23 14:14       ` Andrei Emeltchenko
2013-12-20 18:30 ` [PATCH 3/4] android/bluetooth: Print error on unimplemented functions Szymon Janc
2013-12-20 18:30 ` [PATCH 4/4] android: Add shortcommings section to README Szymon Janc
2013-12-23  7:53 ` [PATCH 1/4] android/bluetooth: Add support for timestamp device property Luiz Augusto von Dentz
2013-12-23  9:46   ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131223084607.GA19604@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=szymon.janc@tieto.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox