* [PATCH] heartrate: Always write measurement CCC on discovery
@ 2012-10-17 7:51 Andrzej Kaczmarek
2012-10-17 8:09 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Andrzej Kaczmarek @ 2012-10-17 7:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
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.
---
profiles/heartrate/heartrate.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index 9a92960..bcdce8b 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:
--
1.7.11.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] heartrate: Always write measurement CCC on discovery
2012-10-17 7:51 [PATCH] heartrate: Always write measurement CCC on discovery Andrzej Kaczmarek
@ 2012-10-17 8:09 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2012-10-17 8:09 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth
Hi Andrzej,
On Wed, Oct 17, 2012, Andrzej Kaczmarek wrote:
> 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.
> ---
> profiles/heartrate/heartrate.c | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-17 8:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 7:51 [PATCH] heartrate: Always write measurement CCC on discovery Andrzej Kaczmarek
2012-10-17 8:09 ` Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).