int apps[MAX_APPS_SUPPORTED];
int server_instance;
int k;
+ bt_service_app_info_t *info = NULL;
memset(&apps, -1, sizeof(apps));
if (adv_handle == 0) {
BT_DBG("Its a direct GATT Server app request to unregister");
/* Unregister server instance for each app with same sender (case: GATT Server with multiple adv handle) */
- bt_service_app_info_t *info = NULL;
for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
info = &numapps[k];
BT_ERR("No allocated server instance to be removed");
return BLUETOOTH_ERROR_INVALID_PARAM;
}
- if (!numapps[server_instance].service_handles) {
- BT_INFO("There are no Service handles with this app, safe to unregister");
- /* Unregister server instance only if this sender does not have any gatt services in it */
- result = __bt_unregister_gatt_server_instance(server_instance);
- } else {
- numapps[server_instance].adv_handle = 0;
- memset(numapps[server_instance].adv_data.data, 0x00, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX);
- numapps[server_instance].adv_data_len = 0;
- memset(numapps[server_instance].scan_rsp.data, 0x00, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX);
- numapps[server_instance].scan_rsp_len = 0;
+
+ for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
+ info = &numapps[k];
+ if (info->instance_id == server_instance) {
+ if (info->service_handles == NULL) {
+ BT_INFO("There are no Service handles with this app, safe to unregister");
+ /* Unregister server instance only if this sender does not have any gatt services in it */
+ result = __bt_unregister_gatt_server_instance(server_instance);
+ } else {
+ info->adv_handle = 0;
+ memset(info->adv_data.data, 0x00, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX);
+ info->adv_data_len = 0;
+ memset(info->scan_rsp.data, 0x00, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX);
+ info->scan_rsp_len = 0;
+ }
+ return result;
+ }
}
- return result;
}
/* Unregister all apps one by one */
int ret = OAL_STATUS_SUCCESS;
GSList *l;
int *handle = NULL;
+ int k;
+ bt_service_app_info_t *info = NULL;
ret = gatts_delete_service(instance_id, service_handle);
if (ret != OAL_STATUS_SUCCESS) {
}
/* Remove the Service Handle */
- for (l = numapps[instance_id].service_handles; l != NULL;) {
- handle = l->data;
- l = g_slist_next(l);
- if (handle && *handle == service_handle) {
- BT_INFO("Remove Service handle [%d]", *handle);
- numapps[instance_id].service_handles = g_slist_remove(numapps[instance_id].service_handles, handle);
- g_free(handle);
- handle = NULL;
+ for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
+ info = &numapps[k];
+ if (info->instance_id == instance_id) {
+ for (l = info->service_handles; l != NULL; ) {
+ handle = l->data;
+ l = g_slist_next(l);
+ if (handle && *handle == service_handle) {
+ BT_INFO("Remove Service handle [%d]", *handle);
+ info->service_handles = g_slist_remove(info->service_handles, handle);
+ g_free(handle);
+ handle = NULL;
+ }
+ }
+ break;
}
}