}
#endif
+static struct device_state *
+find_device_state_by_att(struct btd_gatt_database *database, struct bt_att *att)
+{
+ bdaddr_t bdaddr;
+ uint8_t bdaddr_type;
+
+ if (!get_dst_info(att, &bdaddr, &bdaddr_type))
+ return NULL;
+
+ return find_device_state(database, &bdaddr, bdaddr_type);
+}
+
static struct device_state *get_device_state(struct btd_gatt_database *database,
struct bt_att *att)
{
database_add_record(database, service);
}
-static void register_core_services(struct btd_gatt_database *database)
-{
- gatt_db_ccc_register(database->db, gatt_ccc_read_cb, gatt_ccc_write_cb,
- NULL, database);
-
- populate_gap_service(database);
- populate_gatt_service(database);
-
- populate_devinfo_service(database);
-
-}
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
struct notify_indicate {
}
}
+static void gatt_notify_cb(struct gatt_db_attribute *attrib,
+ struct gatt_db_attribute *ccc,
+ const uint8_t *value, size_t len,
+ struct bt_att *att, void *user_data)
+{
+ struct btd_gatt_database *database = user_data;
+ struct notify notify;
+
+ memset(¬ify, 0, sizeof(notify));
+
+ notify.database = database;
+ notify.handle = gatt_db_attribute_get_handle(attrib);
+ notify.ccc_handle = gatt_db_attribute_get_handle(ccc);
+ notify.value = (void *) value;
+ notify.len = len;
+
+ if (attrib == database->svc_chngd)
+ notify.conf = service_changed_conf;
+
+ /* If a specific att is provided notify only to that device */
+ if (att) {
+ struct device_state *state;
+
+ state = find_device_state_by_att(database, att);
+ if (!state)
+ return;
+
+ send_notification_to_device(state, ¬ify);
+ } else
+ queue_foreach(database->device_states,
+ send_notification_to_device, ¬ify);
+}
+
+static void register_core_services(struct btd_gatt_database *database)
+{
+ gatt_db_ccc_register(database->db, gatt_ccc_read_cb, gatt_ccc_write_cb,
+ gatt_notify_cb, database);
+
+ populate_gap_service(database);
+ populate_gatt_service(database);
+ populate_devinfo_service(database);
+}
+
static void send_notification_to_devices(struct btd_gatt_database *database,
uint16_t handle, uint8_t *value,
uint16_t len, uint16_t ccc_handle,
put_le16(start, value);
put_le16(end, value + 2);
- send_notification_to_devices(database, handle, value, sizeof(value),
- ccc_handle, service_changed_conf, NULL);
+ gatt_db_attribute_notify(database->svc_chngd, value, sizeof(value),
+ NULL);
}
static void gatt_db_service_added(struct gatt_db_attribute *attrib,
put_le16(0x0001, value);
put_le16(0xffff, value + 2);
- send_notification_to_devices(database, handle, value, sizeof(value),
- ccc_handle, service_changed_conf, NULL);
+ gatt_db_attribute_notify(database->svc_chngd, value, sizeof(value),
+ NULL);
}