static int __bt_gatt_send_indication_to_all_connected_clients(bluetooth_gatt_att_data_t *data,
bluetooth_gatt_server_indication_params_t *param);
-static void __bt_remove_all_service_handles(int instance_id);
+static void __bt_remove_all_service_handles(bt_service_app_info_t *app_info);
+
static void __bt_free_service_info(bt_gatt_service_info_t *service_info);
static int __bt_do_unregister_gatt_instance(int instance_id);
if (app->instance_id != -1) {
/* GATT server */
/* Unregister all service handles with stack */
- __bt_remove_all_service_handles(app->instance_id);
+ __bt_remove_all_service_handles(app);
/* If Advertising is enabled, stop it */
if (app->adv_handle > 0) {
return BLUETOOTH_ERROR_NONE;
}
-static void __bt_remove_all_service_handles(int instance_id)
+static void __bt_remove_all_service_handles(bt_service_app_info_t *app_info)
{
GSList *l;
int *handle = NULL;
int ret = OAL_STATUS_SUCCESS;
int count;
- count = g_slist_length(numapps[instance_id].service_handles);
+ if (app_info == NULL)
+ return;
+
+ count = g_slist_length(app_info->service_handles);
BT_INFO("Before handle removal: current count [%d]", count);
- for (l = numapps[instance_id].service_handles; l != NULL;) {
+ for (l = app_info->service_handles; l != NULL;) {
handle = l->data;
l = g_slist_next(l);
if (handle) {
- BT_INFO("Server Handle to be Removed [%d] Instance ID [%d]", *handle, instance_id);
- if (_bt_gatt_server_stop_service(numapps[instance_id].sender, *handle, instance_id) != BLUETOOTH_ERROR_NONE)
+ BT_INFO("Server Handle to be Removed [%d] Instance ID [%d]", *handle, app_info->instance_id);
+ if (_bt_gatt_server_stop_service(app_info->sender, *handle, app_info->instance_id) != BLUETOOTH_ERROR_NONE)
continue;
- ret = gatts_delete_service(instance_id, *handle);
+ ret = gatts_delete_service(app_info->instance_id, *handle);
if (ret != OAL_STATUS_SUCCESS) {
BT_ERR("ret: %d", ret);
continue;
} else {
- numapps[instance_id].service_handles = g_slist_remove(numapps[instance_id].service_handles, handle);
+ app_info->service_handles = g_slist_remove(app_info->service_handles, handle);
g_free(handle);
handle = NULL;
- count = g_slist_length(numapps[instance_id].service_handles);
+ count = g_slist_length(app_info->service_handles);
BT_INFO("After deleting current count [%d]", count);
}
}
if (!g_strcmp0(info->sender, sender)) {
BT_INFO("Unregister GATT server instance [%d]", info->instance_id);
/* Unregister all service handles with stack */
- __bt_remove_all_service_handles(info->instance_id);
+ __bt_remove_all_service_handles(info);
/* Disable adv if running */
BT_INFO("Disable Advertising Adv Handle [%d] sender [%s]",