gatt: Primary service interval may not change

This patch address the "Service Changed" scenario on which the start
and end Primary Service attribute handle interval doesn't change.
This commit is contained in:
Claudio Takahasi 2012-08-20 14:22:53 -03:00 committed by Johan Hedberg
parent 8bea94707a
commit 31706d23e5
4 changed files with 20 additions and 2 deletions

View File

@ -57,6 +57,7 @@ typedef void (*gatt_cb_t) (GSList *l, guint8 status, gpointer user_data);
struct gatt_primary {
char uuid[MAX_LEN_UUID_STR + 1];
gboolean changed;
struct att_range range;
};

View File

@ -154,7 +154,7 @@ static void indication_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
gas->changed.start = start;
gas->changed.end = end;
device_browse_primary(gas->device, NULL, NULL, FALSE);
btd_device_gatt_set_service_changed(gas->device, start, end);
}
static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
@ -185,7 +185,7 @@ static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
DBG("GATT Service Changed start: 0x%04X end: 0x%04X", start, end);
device_browse_primary(gas->device, NULL, NULL, FALSE);
btd_device_gatt_set_service_changed(gas->device, start, end);
}
static void gatt_descriptors_cb(guint8 status, const guint8 *pdu, guint16 len,

View File

@ -2938,6 +2938,21 @@ GSList *btd_device_get_primaries(struct btd_device *device)
return device->primaries;
}
void btd_device_gatt_set_service_changed(struct btd_device *device,
uint16_t start, uint16_t end)
{
GSList *l;
for (l = device->primaries; l; l = g_slist_next(l)) {
struct gatt_primary *prim = l->data;
if (start <= prim->range.end && end >= prim->range.start)
prim->changed = TRUE;
}
device_browse_primary(device, NULL, NULL, FALSE);
}
void btd_device_add_uuid(struct btd_device *device, const char *uuid)
{
GSList *uuid_list;

View File

@ -53,6 +53,8 @@ void device_probe_drivers(struct btd_device *device, GSList *profiles);
const sdp_record_t *btd_device_get_record(struct btd_device *device,
const char *uuid);
GSList *btd_device_get_primaries(struct btd_device *device);
void btd_device_gatt_set_service_changed(struct btd_device *device,
uint16_t start, uint16_t end);
void device_register_services(DBusConnection *conn, struct btd_device *device,
GSList *prim_list, int psm);
GSList *device_services_from_record(struct btd_device *device,