static void __bt_gatt_free_characteristic(bt_gatt_h gatt_handle);
static void __bt_gatt_free_service(bt_gatt_h gatt_handle);
+struct notify_char_changed_cb_s {
+ char *device_address;
+ bt_gatt_characteristic_s *chr;
+ bt_gatt_server_notification_sent_cb callback;
+ void *user_data;
+};
+
#define BT_CHECK_GATT_SUPPORT() \
{ \
BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE); \
return ret;
} /* LCOV_EXCL_STOP */
+static gboolean __notify_characteristic_changed_value_cb(gpointer user_data)
+{
+ struct notify_char_changed_cb_s *cb_data = user_data;
+ bt_gatt_characteristic_s *chr = cb_data->chr;
+ bt_gatt_service_s *service = chr->parent;
+ bt_gatt_server_s *server;
+
+ if (!service) {
+ g_free(cb_data->device_address);
+ g_free(cb_data);
+ return FALSE;
+ }
+ server = service->parent;
+
+ if (cb_data->callback)
+ cb_data->callback(BT_ERROR_NONE, cb_data->device_address, server, cb_data->chr, TRUE, cb_data->user_data);
+
+ g_free(cb_data->device_address);
+ g_free(cb_data);
+ return FALSE;
+}
+
int bt_gatt_server_notify_characteristic_changed_value(bt_gatt_h characteristic,
bt_gatt_server_notification_sent_cb callback,
const char *device_address, void *user_data)
BT_DBG("Enable Notifcation for the characteristic [%d]", attribute_handle);
}
param.instance_id = instance_id;
+ param.fd = -1;
ret = _bt_get_error_code(bluetooth_gatt_server_send_indication(&addr_hex, ¶m, &indication));
BT_INFO("Sent Indication to Remote GATT client: result [%d]", ret);
_bt_convert_error_to_string(ret), ret);
return BT_ERROR_OPERATION_FAILED;
}
+
+ if (param.fd > -1 && callback) {
+ struct notify_char_changed_cb_s *cb_data = g_malloc0(sizeof(struct notify_char_changed_cb_s));
+ cb_data->device_address = g_strdup(device_address);
+ cb_data->chr = chr;
+ cb_data->callback = callback;
+ cb_data->user_data = user_data;
+ g_idle_add(__notify_characteristic_changed_value_cb, cb_data);
+ }
}
}