diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index bb626e7..793a3af 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
att_data_list_free(list);
}
-static void ccc_written_cb(guint8 status, const guint8 *pdu, guint16 plen,
- gpointer user_data)
-{
- struct gas *gas = user_data;
-
- if (status) {
- error("Write Service Changed CCC failed: %s",
- att_ecode2str(status));
- return;
- }
-
- DBG("Service Changed indications enabled");
-
- write_ctp_handle(adapter_get_address(device_get_adapter(gas->device)),
- device_get_address(gas->device),
- device_get_addr_type(gas->device),
- GATT_CHARAC_SERVICE_CHANGED,
- gas->changed_handle);
-}
-
-static void write_ccc(GAttrib *attrib, uint16_t handle, gpointer user_data)
-{
- uint8_t value[2];
-
- att_put_u16(GATT_CLIENT_CHARAC_CFG_IND_BIT, value);
- gatt_write_char(attrib, handle, value, sizeof(value), ccc_written_cb,
- user_data);
-}
-
static void indication_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
{
struct gas *gas = user_data;
- uint16_t handle, start, end, olen;
+ uint16_t start, end, olen;
size_t plen;
uint8_t *opdu;
return;
}
- handle = att_get_u16(&pdu[1]);
start = att_get_u16(&pdu[3]);
end = att_get_u16(&pdu[5]);
- if (handle != gas->changed_handle)
- return;
-
DBG("Service Changed start: 0x%04X end: 0x%04X", start, end);
if (device_is_bonded(gas->device) == FALSE) {
btd_device_gatt_set_service_changed(gas->device, start, end);
}
+static void ccc_written_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ struct gas *gas = user_data;
+
+ if (status) {
+ error("Write Service Changed CCC failed: %s",
+ att_ecode2str(status));
+ return;
+ }
+
+ DBG("Service Changed indications enabled");
+
+ gas->changed_ind = g_attrib_register(gas->attrib, ATT_OP_HANDLE_IND,
+ gas->changed_handle,
+ indication_cb, gas, NULL);
+
+ write_ctp_handle(adapter_get_address(device_get_adapter(gas->device)),
+ device_get_address(gas->device),
+ device_get_addr_type(gas->device),
+ GATT_CHARAC_SERVICE_CHANGED,
+ gas->changed_handle);
+}
+
+static void write_ccc(GAttrib *attrib, uint16_t handle, gpointer user_data)
+{
+ uint8_t value[2];
+
+ att_put_u16(GATT_CLIENT_CHARAC_CFG_IND_BIT, value);
+ gatt_write_char(attrib, handle, value, sizeof(value), ccc_written_cb,
+ user_data);
+}
+
static void gatt_descriptors_cb(guint8 status, const guint8 *pdu, guint16 len,
gpointer user_data)
{
DBG("MTU Exchange: Requesting %d", imtu);
}
- gas->changed_ind = g_attrib_register(gas->attrib, ATT_OP_HANDLE_IND,
- GATTRIB_ALL_HANDLES,
- indication_cb, gas, NULL);
-
if (device_get_appearance(gas->device, &app) < 0) {
bt_uuid_t uuid;