From bf124080078e747909c0177f8780999e51f1c812 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Wed, 3 Aug 2011 15:41:47 -0300 Subject: [PATCH] Skip Link Loss handle discovery Skip characteristic value handle discovery for Link Loss service if the handle is already known. --- proximity/monitor.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/proximity/monitor.c b/proximity/monitor.c index a6bdf341c..e271a5db4 100644 --- a/proximity/monitor.c +++ b/proximity/monitor.c @@ -69,6 +69,8 @@ struct monitor { char *linklosslevel; /* Link Loss Alert Level */ char *immediatelevel; /* Immediate Alert Level */ char *signallevel; /* Path Loss RSSI level */ + uint16_t linklosshandle; /* Link Loss Characteristic + * Value Handle */ guint attioid; }; @@ -145,8 +147,10 @@ static void char_discovered_cb(GSList *characteristics, guint8 status, /* Assume there is a single Alert Level characteristic */ chr = characteristics->data; + monitor->linklosshandle = chr->value_handle; - gatt_write_cmd(monitor->attrib, chr->value_handle, &value, 1, NULL, NULL); + gatt_write_cmd(monitor->attrib, monitor->linklosshandle, &value, 1, + NULL, NULL); } static int write_alert_level(struct monitor *monitor) @@ -154,6 +158,14 @@ static int write_alert_level(struct monitor *monitor) struct att_range *linkloss = monitor->linkloss; bt_uuid_t uuid; + if (monitor->linklosshandle) { + uint8_t value = str2level(monitor->linklosslevel); + + gatt_write_cmd(monitor->attrib, monitor->linklosshandle, + &value, 1, NULL, NULL); + return 0; + } + bt_uuid16_create(&uuid, ALERT_LEVEL_CHR_UUID); /* FIXME: use cache (requires service changed support) ? */ -- 2.47.3