gatt-database: Return meaningful ecodes for ccc write 63/51263/1
authorGowtham Anandha Babu <gowtham.ab@samsung.com>
Fri, 6 Nov 2015 04:30:16 +0000 (10:00 +0530)
committerGowtham Anandha Babu <gowtham.ab@samsung.com>
Fri, 6 Nov 2015 04:34:19 +0000 (10:04 +0530)
Removed generic ATT protocol error codes and added
Common Profile and Service Error Codes.

git repo link:
https://git.kernel.org/cgit/bluetooth/bluez.git/commit/?id=b58a5e5b607cd1f537428f66ed3295bb26453e99

Change-Id: Ib0020140c46151465ef3369971362f24dadc965c

src/gatt-database.c

index e887bd2..e320970 100644 (file)
@@ -1639,22 +1639,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
@@ -1663,7 +1657,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);