diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 8bcbabc..7e7ebb7 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
{
struct notify_data *notify_data = data;
- /* Increment the per-characteristic ref count of notify handlers */
- __sync_fetch_and_add(¬ify_data->chrc->notify_count, 1);
-
notify_data->att_id = 0;
notify_data->callback(0, notify_data->user_data);
}
struct notify_data *notify_data = user_data;
uint16_t att_ecode;
- assert(!notify_data->chrc->notify_count);
assert(notify_data->chrc->ccc_write_id);
notify_data->chrc->ccc_write_id = 0;
notify_data->id = client->next_reg_id++;
+ /* Increment the per-characteristic ref count of notify handlers */
+ __sync_fetch_and_add(¬ify_data->chrc->notify_count, 1);
+
/*
* If a write to the CCC descriptor is in progress, then queue this
* request.
}
/*
- * If the ref count is not zero, then notifications are already enabled.
+ * If the ref count > 1, then notifications are already enabled.
*/
- if (chrc->notify_count > 0 || !chrc->ccc_handle) {
+ if (chrc->notify_count > 1 || !chrc->ccc_handle) {
complete_notify_request(notify_data);
return notify_data->id;
}
struct notify_data *notify_data = user_data;
struct notify_data *next_data;
- assert(!notify_data->chrc->notify_count);
assert(notify_data->chrc->ccc_write_id);
notify_data->chrc->ccc_write_id = 0;
if (!notify_data)
return false;
- assert(notify_data->chrc->notify_count > 0);
- assert(!notify_data->chrc->ccc_write_id);
-
complete_unregister_notify(notify_data);
return true;
}