diff options
author | Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com> | 2012-10-17 09:51:33 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-17 11:08:14 +0300 |
commit | fd16f2cc64554bc4e9b9b04c5267c71223a04cff (patch) | |
tree | d2e01d7058f09a7c823d8bbe6bf6485cf52b9e13 /profiles/heartrate | |
parent | 9b80a1f0632998b424d20c319761326e95796096 (diff) |
heartrate: Always write measurement CCC on discovery
Measurement CCC is written during discovery only in case watcher is
registered and notifications shall be enabled. However, it may happen
that (e.g. during reconnection scenario) notifications are already
enabled on remote but watcher is no longer registered and we will
be receiving unwanted notifications.
This patch makes sure measurement CCC is written to proper value
every time it's discovered during connection.
Diffstat (limited to 'profiles/heartrate')
-rw-r--r-- | profiles/heartrate/heartrate.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c index 9a929607f..f0eb7a4ef 100644 --- a/profiles/heartrate/heartrate.c +++ b/profiles/heartrate/heartrate.c @@ -412,28 +412,30 @@ static void discover_ccc_cb(guint8 status, const guint8 *pdu, for (i = 0; i < list->num; i++) { uint8_t *value; uint16_t handle, uuid; + char *msg; + uint8_t attr_val[2]; value = list->data[i]; handle = att_get_u16(value); uuid = att_get_u16(value + 2); - if (uuid == GATT_CLIENT_CHARAC_CFG_UUID) { - char *msg; - uint8_t value[2]; + if (uuid != GATT_CLIENT_CHARAC_CFG_UUID) + continue; - hr->measurement_ccc_handle = handle; + hr->measurement_ccc_handle = handle; - if (g_slist_length(hr->hradapter->watchers) == 0) - break; - - att_put_u16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value); + if (g_slist_length(hr->hradapter->watchers) == 0) { + att_put_u16(0x0000, attr_val); + msg = g_strdup("Disable measurement"); + } else { + att_put_u16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, attr_val); msg = g_strdup("Enable measurement"); + } - gatt_write_char(hr->attrib, handle, value, - sizeof(value), char_write_cb, msg); + gatt_write_char(hr->attrib, handle, attr_val, + sizeof(attr_val), char_write_cb, msg); - break; - } + break; } done: |