All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] android/bluetooth: Add support to read LE features by Android
@ 2014-12-01 14:18 Lukasz Rymanowski
  2014-12-03  9:04 ` Szymon Janc
  0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Rymanowski @ 2014-12-01 14:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Rymanowski

This patch adds support to read LE features by Android framework.
For now we set all to 0.
---
 android/bluetooth.c | 18 ++++++++++++++++++
 android/hal-msg.h   |  1 +
 2 files changed, 19 insertions(+)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index f79ca37..989f5d5 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -176,6 +176,7 @@ static struct {
 
 	char *name;
 
+	uint8_t le_features[8];
 	uint32_t current_settings;
 	uint32_t supported_settings;
 
@@ -189,6 +190,7 @@ static struct {
 	.index = MGMT_INDEX_NONE,
 	.dev_class = 0,
 	.name = NULL,
+	.le_features = {0},
 	.current_settings = 0,
 	.supported_settings = 0,
 	.cur_discovery_type = SCAN_TYPE_NONE,
@@ -3784,6 +3786,14 @@ static uint8_t get_adapter_discoverable_timeout(void)
 	return HAL_STATUS_SUCCESS;
 }
 
+static uint8_t get_adapter_le_features(void)
+{
+	send_adapter_property(HAL_PROP_ADAPTER_LOCAL_LE_FEAT,
+					sizeof(adapter.le_features),
+					&adapter.le_features[0]);
+	return HAL_STATUS_SUCCESS;
+}
+
 static void handle_get_adapter_prop_cmd(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_get_adapter_prop *cmd = buf;
@@ -3817,6 +3827,9 @@ static void handle_get_adapter_prop_cmd(const void *buf, uint16_t len)
 	case HAL_PROP_ADAPTER_DISC_TIMEOUT:
 		status = get_adapter_discoverable_timeout();
 		break;
+	case HAL_PROP_ADAPTER_LOCAL_LE_FEAT:
+		status = get_adapter_le_features();
+		break;
 	default:
 		status = HAL_STATUS_FAILED;
 		break;
@@ -3898,6 +3911,11 @@ static void get_adapter_properties(void)
 									uuids);
 	ev->num_props++;
 
+	size += fill_hal_prop(buf + size, HAL_PROP_ADAPTER_LOCAL_LE_FEAT,
+			sizeof(adapter.le_features), &adapter.le_features[0]);
+
+	ev->num_props++;
+
 	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_BLUETOOTH,
 				HAL_EV_ADAPTER_PROPS_CHANGED, size, buf);
 }
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 33b53c5..67c6573 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -142,6 +142,7 @@ struct hal_prop_device_info {
 	uint16_t manufacturer;
 } __attribute__((packed));
 
+#define HAL_PROP_ADAPTER_LOCAL_LE_FEAT		0x0d
 #define HAL_PROP_DEVICE_TIMESTAMP		0xFF
 
 #define HAL_ADAPTER_SCAN_MODE_NONE		0x00
-- 
1.8.4


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

* Re: [PATCH] android/bluetooth: Add support to read LE features by Android
  2014-12-01 14:18 [PATCH] android/bluetooth: Add support to read LE features by Android Lukasz Rymanowski
@ 2014-12-03  9:04 ` Szymon Janc
  2014-12-03  9:27   ` Lukasz Rymanowski
  0 siblings, 1 reply; 3+ messages in thread
From: Szymon Janc @ 2014-12-03  9:04 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth

Hi Łukasz,

On Monday 01 of December 2014 15:18:00 Lukasz Rymanowski wrote:
> This patch adds support to read LE features by Android framework.
> For now we set all to 0.
> ---
>  android/bluetooth.c | 18 ++++++++++++++++++
>  android/hal-msg.h   |  1 +
>  2 files changed, 19 insertions(+)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index f79ca37..989f5d5 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -176,6 +176,7 @@ static struct {
>  
>  	char *name;
>  
> +	uint8_t le_features[8];

I'm still not sure how we get required info but I think we should construct
this on-demand to avoid doubling state ie. local_privacy_enabled can be get
from current_settings.

>  	uint32_t current_settings;
>  	uint32_t supported_settings;
>  
> @@ -189,6 +190,7 @@ static struct {
>  	.index = MGMT_INDEX_NONE,
>  	.dev_class = 0,
>  	.name = NULL,
> +	.le_features = {0},
>  	.current_settings = 0,
>  	.supported_settings = 0,
>  	.cur_discovery_type = SCAN_TYPE_NONE,
> @@ -3784,6 +3786,14 @@ static uint8_t get_adapter_discoverable_timeout(void)
>  	return HAL_STATUS_SUCCESS;
>  }
>  
> +static uint8_t get_adapter_le_features(void)
> +{
> +	send_adapter_property(HAL_PROP_ADAPTER_LOCAL_LE_FEAT,
> +					sizeof(adapter.le_features),
> +					&adapter.le_features[0]);
> +	return HAL_STATUS_SUCCESS;
> +}
> +
>  static void handle_get_adapter_prop_cmd(const void *buf, uint16_t len)
>  {
>  	const struct hal_cmd_get_adapter_prop *cmd = buf;
> @@ -3817,6 +3827,9 @@ static void handle_get_adapter_prop_cmd(const void *buf, uint16_t len)
>  	case HAL_PROP_ADAPTER_DISC_TIMEOUT:
>  		status = get_adapter_discoverable_timeout();
>  		break;
> +	case HAL_PROP_ADAPTER_LOCAL_LE_FEAT:
> +		status = get_adapter_le_features();
> +		break;
>  	default:
>  		status = HAL_STATUS_FAILED;
>  		break;
> @@ -3898,6 +3911,11 @@ static void get_adapter_properties(void)
>  									uuids);
>  	ev->num_props++;
>  
> +	size += fill_hal_prop(buf + size, HAL_PROP_ADAPTER_LOCAL_LE_FEAT,
> +			sizeof(adapter.le_features), &adapter.le_features[0]);

adapter.le_features instead of &adapter.le_features[0]

> +
> +	ev->num_props++;
> +
>  	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_BLUETOOTH,
>  				HAL_EV_ADAPTER_PROPS_CHANGED, size, buf);
>  }
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index 33b53c5..67c6573 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -142,6 +142,7 @@ struct hal_prop_device_info {
>  	uint16_t manufacturer;
>  } __attribute__((packed));
>  
> +#define HAL_PROP_ADAPTER_LOCAL_LE_FEAT		0x0d
>  #define HAL_PROP_DEVICE_TIMESTAMP		0xFF
>  
>  #define HAL_ADAPTER_SCAN_MODE_NONE		0x00
> 

-- 
Best regards, 
Szymon Janc

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

* Re: [PATCH] android/bluetooth: Add support to read LE features by Android
  2014-12-03  9:04 ` Szymon Janc
@ 2014-12-03  9:27   ` Lukasz Rymanowski
  0 siblings, 0 replies; 3+ messages in thread
From: Lukasz Rymanowski @ 2014-12-03  9:27 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth

Hi Szymon,

On 3 December 2014 at 10:04, Szymon Janc <szymon.janc@tieto.com> wrote:
> Hi Łukasz,
>
> On Monday 01 of December 2014 15:18:00 Lukasz Rymanowski wrote:
>> This patch adds support to read LE features by Android framework.
>> For now we set all to 0.
>> ---
>>  android/bluetooth.c | 18 ++++++++++++++++++
>>  android/hal-msg.h   |  1 +
>>  2 files changed, 19 insertions(+)
>>
>> diff --git a/android/bluetooth.c b/android/bluetooth.c
>> index f79ca37..989f5d5 100644
>> --- a/android/bluetooth.c
>> +++ b/android/bluetooth.c
>> @@ -176,6 +176,7 @@ static struct {
>>
>>       char *name;
>>
>> +     uint8_t le_features[8];
>
> I'm still not sure how we get required info but I think we should construct
> this on-demand to avoid doubling state ie. local_privacy_enabled can be get
> from current_settings.
>

What we can do here is name all the features instead and omit privacy
(I believe it is the only one feature we already have somewhere else)
In that case when we construct response to Android we will build out
of those params.

\Lukasz

>>       uint32_t current_settings;
>>       uint32_t supported_settings;
>>
>> @@ -189,6 +190,7 @@ static struct {
>>       .index = MGMT_INDEX_NONE,
>>       .dev_class = 0,
>>       .name = NULL,
>> +     .le_features = {0},
>>       .current_settings = 0,
>>       .supported_settings = 0,
>>       .cur_discovery_type = SCAN_TYPE_NONE,
>> @@ -3784,6 +3786,14 @@ static uint8_t get_adapter_discoverable_timeout(void)
>>       return HAL_STATUS_SUCCESS;
>>  }
>>
>> +static uint8_t get_adapter_le_features(void)
>> +{
>> +     send_adapter_property(HAL_PROP_ADAPTER_LOCAL_LE_FEAT,
>> +                                     sizeof(adapter.le_features),
>> +                                     &adapter.le_features[0]);
>> +     return HAL_STATUS_SUCCESS;
>> +}
>> +
>>  static void handle_get_adapter_prop_cmd(const void *buf, uint16_t len)
>>  {
>>       const struct hal_cmd_get_adapter_prop *cmd = buf;
>> @@ -3817,6 +3827,9 @@ static void handle_get_adapter_prop_cmd(const void *buf, uint16_t len)
>>       case HAL_PROP_ADAPTER_DISC_TIMEOUT:
>>               status = get_adapter_discoverable_timeout();
>>               break;
>> +     case HAL_PROP_ADAPTER_LOCAL_LE_FEAT:
>> +             status = get_adapter_le_features();
>> +             break;
>>       default:
>>               status = HAL_STATUS_FAILED;
>>               break;
>> @@ -3898,6 +3911,11 @@ static void get_adapter_properties(void)
>>                                                                       uuids);
>>       ev->num_props++;
>>
>> +     size += fill_hal_prop(buf + size, HAL_PROP_ADAPTER_LOCAL_LE_FEAT,
>> +                     sizeof(adapter.le_features), &adapter.le_features[0]);
>
> adapter.le_features instead of &adapter.le_features[0]
>
>> +
>> +     ev->num_props++;
>> +
>>       ipc_send_notif(hal_ipc, HAL_SERVICE_ID_BLUETOOTH,
>>                               HAL_EV_ADAPTER_PROPS_CHANGED, size, buf);
>>  }
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index 33b53c5..67c6573 100644
>> --- a/android/hal-msg.h
>> +++ b/android/hal-msg.h
>> @@ -142,6 +142,7 @@ struct hal_prop_device_info {
>>       uint16_t manufacturer;
>>  } __attribute__((packed));
>>
>> +#define HAL_PROP_ADAPTER_LOCAL_LE_FEAT               0x0d
>>  #define HAL_PROP_DEVICE_TIMESTAMP            0xFF
>>
>>  #define HAL_ADAPTER_SCAN_MODE_NONE           0x00
>>
>
> --
> Best regards,
> Szymon Janc

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

end of thread, other threads:[~2014-12-03  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-01 14:18 [PATCH] android/bluetooth: Add support to read LE features by Android Lukasz Rymanowski
2014-12-03  9:04 ` Szymon Janc
2014-12-03  9:27   ` Lukasz Rymanowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.