OSStatus bt_smartbridge_att_cache_disable( void ) { uint32_t a; linked_list_node_t* node = NULL; bt_smartbridge_att_cache_manager_t* manager = att_cache_manager; if ( att_cache_manager == NULL ) { return MICO_BT_SUCCESS; } /* Set status at the beginning to prevent cached attributes being used even when deinitialisation failed */ att_cache_manager = NULL; while ( linked_list_remove_node_from_front( &manager->free_list, &node ) == MICO_BT_SUCCESS ) { bt_smartbridge_att_cache_t* cache = (bt_smartbridge_att_cache_t*)node->data; mico_bt_smart_attribute_delete_list( &cache->attribute_list ); } linked_list_deinit( &manager->free_list ); while ( linked_list_remove_node_from_front( &manager->used_list, &node ) == MICO_BT_SUCCESS ) { bt_smartbridge_att_cache_t* cache = (bt_smartbridge_att_cache_t*)node->data; mico_bt_smart_attribute_delete_list( &cache->attribute_list ); } linked_list_deinit( &manager->used_list ); mico_rtos_deinit_mutex( &manager->mutex ); /* Deinitialise mutexes for protecting access to cached attributes */ for ( a = 0; a < manager->count; a++ ) { mico_rtos_deinit_mutex( &manager->pool[a].mutex ); } if( manager->att_cache_services_count != 0 ) { free( manager->att_cache_services ); } memset( manager, 0, CALCULATE_ATT_CACHE_MANAGER_SIZE( manager->count ) ); free( manager ); return MICO_BT_SUCCESS; }
wiced_result_t bt_packet_pool_deinit( bt_packet_pool_t* pool ) { uint32_t a; uint32_t packet_count; if ( pool == NULL || pool->pool_id != PACKET_POOL_ID ) { return WICED_BT_BADARG; } wiced_rtos_deinit_mutex( &pool->mutex ); linked_list_get_count( &pool->pool_list, &packet_count ); for ( a = 0; a < packet_count; a++ ) { linked_list_node_t* removed_node; if ( linked_list_remove_node_from_rear( &pool->pool_list, &removed_node ) == WICED_BT_SUCCESS ) { removed_node->data = NULL; } } linked_list_deinit( &pool->pool_list ); free( pool->pool_buffer ); memset( pool, 0, sizeof( *pool ) ); return WICED_BT_SUCCESS; }