2015-08-11 08:38:45

by Gowtham Anandha Babu

[permalink] [raw]
Subject: [PATCH v1] gatt-database: Return meaningful ecodes for ccc write

Removed generic ATT protocol error codes and added
Common Profile and Service Error Codes.
---
src/gatt-database.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 69a814d..91aba2f 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -1783,22 +1783,16 @@ static uint8_t ccc_write_cb(uint16_t value, void *user_data)
return 0;
}

- /*
- * TODO: All of the errors below should fall into the so called
- * "Application Error" range. Since there is no well defined error for
- * these, we return a generic ATT protocol error for now.
- */
-
if (chrc->ntfy_cnt == UINT_MAX) {
/* Maximum number of per-device CCC descriptors configured */
- return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
+ return BT_ATT_ERROR_INSUFFICIENT_RESOURCES;
}

/* Don't support undefined CCC values yet */
if (value > 2 ||
(value == 1 && !(chrc->props & BT_GATT_CHRC_PROP_NOTIFY)) ||
(value == 2 && !(chrc->props & BT_GATT_CHRC_PROP_INDICATE)))
- return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
+ return BT_ERROR_CCC_IMPROPERLY_CONFIGURED;

/*
* Always call StartNotify for an incoming enable and ignore the return
@@ -1807,7 +1801,7 @@ static uint8_t ccc_write_cb(uint16_t value, void *user_data)
if (g_dbus_proxy_method_call(chrc->proxy,
"StartNotify", NULL, NULL,
NULL, NULL) == FALSE)
- return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
+ return BT_ATT_ERROR_UNLIKELY;

__sync_fetch_and_add(&chrc->ntfy_cnt, 1);

--
1.9.1



2015-08-13 12:39:05

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH v1] gatt-database: Return meaningful ecodes for ccc write

Hi Gowtham,

On Thu, Aug 13, 2015 at 12:01 PM, Gowtham Anandha Babu
<[email protected]> wrote:
> Ping.
>
>> -----Original Message-----
>> From: [email protected] [mailto:linux-bluetooth-
>> [email protected]] On Behalf Of Gowtham Anandha Babu
>> Sent: Tuesday, August 11, 2015 2:09 PM
>> To: [email protected]
>> Cc: [email protected]; Gowtham Anandha Babu
>> Subject: [PATCH v1] gatt-database: Return meaningful ecodes for ccc write
>>
>> Removed generic ATT protocol error codes and added Common Profile and
>> Service Error Codes.
>> ---
>> src/gatt-database.c | 12 +++---------
>> 1 file changed, 3 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/gatt-database.c b/src/gatt-database.c index
> 69a814d..91aba2f
>> 100644
>> --- a/src/gatt-database.c
>> +++ b/src/gatt-database.c
>> @@ -1783,22 +1783,16 @@ static uint8_t ccc_write_cb(uint16_t value, void
>> *user_data)
>> return 0;
>> }
>>
>> - /*
>> - * TODO: All of the errors below should fall into the so called
>> - * "Application Error" range. Since there is no well defined error
> for
>> - * these, we return a generic ATT protocol error for now.
>> - */
>> -
>> if (chrc->ntfy_cnt == UINT_MAX) {
>> /* Maximum number of per-device CCC descriptors
>> configured */
>> - return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
>> + return BT_ATT_ERROR_INSUFFICIENT_RESOURCES;
>> }
>>
>> /* Don't support undefined CCC values yet */
>> if (value > 2 ||
>> (value == 1 && !(chrc->props &
>> BT_GATT_CHRC_PROP_NOTIFY)) ||
>> (value == 2 && !(chrc->props &
>> BT_GATT_CHRC_PROP_INDICATE)))
>> - return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
>> + return BT_ERROR_CCC_IMPROPERLY_CONFIGURED;
>>
>> /*
>> * Always call StartNotify for an incoming enable and ignore the
>> return @@ -1807,7 +1801,7 @@ static uint8_t ccc_write_cb(uint16_t value,
>> void *user_data)
>> if (g_dbus_proxy_method_call(chrc->proxy,
>> "StartNotify", NULL, NULL,
>> NULL, NULL) == FALSE)
>> - return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
>> + return BT_ATT_ERROR_UNLIKELY;
>>
>> __sync_fetch_and_add(&chrc->ntfy_cnt, 1);
>>
>> --
>> 1.9.1

Applied, thanks.


--
Luiz Augusto von Dentz

2015-08-13 09:01:55

by Gowtham Anandha Babu

[permalink] [raw]
Subject: RE: [PATCH v1] gatt-database: Return meaningful ecodes for ccc write

Ping.

> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Gowtham Anandha Babu
> Sent: Tuesday, August 11, 2015 2:09 PM
> To: [email protected]
> Cc: [email protected]; Gowtham Anandha Babu
> Subject: [PATCH v1] gatt-database: Return meaningful ecodes for ccc write
>
> Removed generic ATT protocol error codes and added Common Profile and
> Service Error Codes.
> ---
> src/gatt-database.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/src/gatt-database.c b/src/gatt-database.c index
69a814d..91aba2f
> 100644
> --- a/src/gatt-database.c
> +++ b/src/gatt-database.c
> @@ -1783,22 +1783,16 @@ static uint8_t ccc_write_cb(uint16_t value, void
> *user_data)
> return 0;
> }
>
> - /*
> - * TODO: All of the errors below should fall into the so called
> - * "Application Error" range. Since there is no well defined error
for
> - * these, we return a generic ATT protocol error for now.
> - */
> -
> if (chrc->ntfy_cnt == UINT_MAX) {
> /* Maximum number of per-device CCC descriptors
> configured */
> - return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
> + return BT_ATT_ERROR_INSUFFICIENT_RESOURCES;
> }
>
> /* Don't support undefined CCC values yet */
> if (value > 2 ||
> (value == 1 && !(chrc->props &
> BT_GATT_CHRC_PROP_NOTIFY)) ||
> (value == 2 && !(chrc->props &
> BT_GATT_CHRC_PROP_INDICATE)))
> - return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
> + return BT_ERROR_CCC_IMPROPERLY_CONFIGURED;
>
> /*
> * Always call StartNotify for an incoming enable and ignore the
> return @@ -1807,7 +1801,7 @@ static uint8_t ccc_write_cb(uint16_t value,
> void *user_data)
> if (g_dbus_proxy_method_call(chrc->proxy,
> "StartNotify", NULL, NULL,
> NULL, NULL) == FALSE)
> - return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
> + return BT_ATT_ERROR_UNLIKELY;
>
> __sync_fetch_and_add(&chrc->ntfy_cnt, 1);
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
in
> the body of a message to [email protected] More majordomo
> info at http://vger.kernel.org/majordomo-info.html