Пример #1
0
void application_thread_cleanup( TX_THREAD *thread_ptr, UINT condition )
{
    /* Determine if the thread was exited. */
    if ( thread_ptr && condition == TX_THREAD_EXIT )
    {
        malloc_transfer_to_curr_thread(thread_ptr->tx_thread_stack_start);
        malloc_transfer_to_curr_thread(thread_ptr);
        tx_thread_terminate( thread_ptr );
        malloc_leak_check(thread_ptr, LEAK_CHECK_THREAD);
        tx_thread_delete( thread_ptr );
        free( thread_ptr->tx_thread_stack_start );
        free( thread_ptr );
    }
}
Пример #2
0
/*
 * Callback function to handle scan results
 */
wiced_result_t sniffer( wiced_scan_handler_result_t* malloced_scan_result )
{
    malloc_transfer_to_curr_thread( malloced_scan_result );

    SnifferInfo* info = (SnifferInfo*)malloced_scan_result->user_data;
    if ( malloced_scan_result->status == WICED_SCAN_INCOMPLETE )
    {
        wiced_scan_result_t* record = &malloced_scan_result->ap_details;
        info->count++;
        if (!info->callback) {
            if (record->SSID.length==info->ssid_len && !memcmp(record->SSID.value, info->ssid, info->ssid_len)) {
                info->security = record->security;
                info->rssi = record->signal_strength;
            }
        }
        else {
            WiFiAccessPoint data;
            memcpy(data.ssid, record->SSID.value, record->SSID.length);
            memcpy(data.bssid, (uint8_t*)&record->BSSID, 6);
            data.ssidLength = record->SSID.length;
            data.ssid[data.ssidLength] = 0;
            data.security = toSecurityType(record->security);
            data.rssi = record->signal_strength;
            data.channel = record->channel;
            data.maxDataRate = record->max_data_rate;
            info->callback(&data, info->callback_data);
        }
    }
    else {
        wiced_rtos_set_semaphore(&info->complete);
    }
    free( malloced_scan_result );
    return WICED_SUCCESS;
}
Пример #3
0
 static wiced_result_t scan_handler(wiced_scan_handler_result_t* malloced_scan_result)
 {
     ScanAPCommand& cmd = *(ScanAPCommand*)malloced_scan_result->user_data;
     malloc_transfer_to_curr_thread( malloced_scan_result );
     ScanEntry& entry = cmd.write_;
     memset(&entry, 0, sizeof(entry));
     if (malloced_scan_result->status == WICED_SCAN_INCOMPLETE)
     {
         wiced_scan_result_t& ap_details = malloced_scan_result->ap_details;
         unsigned ssid_len = ap_details.SSID.length > 32 ? 32 : ap_details.SSID.length;
         memcpy(entry.ssid, ap_details.SSID.value, ssid_len);
         entry.ssid[ssid_len] = 0;
         entry.rssi = ap_details.signal_strength;
         entry.security = ap_details.security;
         entry.channel = ap_details.channel;
         entry.max_data_rate = ap_details.max_data_rate;
     }
     else
     {
         entry.done = 1;
     }
     wiced_rtos_push_to_queue(&cmd.queue_, &entry, WICED_WAIT_FOREVER);
     free(malloced_scan_result);
     return WICED_SUCCESS;
 }
Пример #4
0
wiced_result_t wiced_rtos_init_queue( wiced_queue_t* queue, const char* name, uint32_t message_size, uint32_t number_of_messages )
{
    uint32_t queue_size = message_size * number_of_messages;
    wiced_result_t result;

    UNUSED_PARAMETER( name );

    if ( ( message_size % 4 ) > 0 )
    {
        return WICED_ERROR;
    }

    queue->buffer = (void*) malloc_named( "queue", queue_size );
    if ( queue->buffer == NULL )
    {
        return WICED_OUT_OF_HEAP_SPACE;
    }
    malloc_transfer_to_curr_thread( queue->buffer );

    result =  (wiced_result_t) host_rtos_init_queue( WICED_GET_QUEUE_HANDLE( queue ), queue->buffer, queue_size, message_size );

    if ( result != WICED_WWD_SUCCESS )
    {
        free( queue->buffer );
        queue->buffer = NULL;
    }

    return result;
}
Пример #5
0
wiced_result_t wiced_rtos_delete_thread( wiced_thread_t* thread )
{
    wiced_result_t result =  (wiced_result_t) host_rtos_finish_thread( WICED_GET_THREAD_HANDLE( thread ) );

    if ( result != WICED_WWD_SUCCESS )
    {
        return result;
    }

    if ( thread->stack != NULL )
    {
        malloc_transfer_to_curr_thread( thread->stack );
    }

    malloc_leak_check( &thread->handle, LEAK_CHECK_THREAD );

    result =  (wiced_result_t) host_rtos_delete_terminated_thread( WICED_GET_THREAD_HANDLE( thread ) );

    if ( result == WICED_WWD_SUCCESS )
    {
        if ( thread->stack != NULL )
        {
            free( thread->stack );
            thread->stack = NULL;
        }
    }

    return result;
}
Пример #6
0
wiced_result_t wiced_rtos_deinit_queue( wiced_queue_t* queue )
{
    wiced_result_t result;

    malloc_transfer_to_curr_thread( queue->buffer );

    result =  (wiced_result_t) host_rtos_deinit_queue( WICED_GET_QUEUE_HANDLE( queue ) );

    if ( result == WICED_WWD_SUCCESS )
    {
        free( queue->buffer );
        queue->buffer = NULL;
    }

    return result;
}
Пример #7
0
wiced_result_t wiced_bt_smart_attribute_delete( wiced_bt_smart_attribute_t* attribute )
{
    if ( attribute == NULL )
    {
        return WICED_BT_BADARG;
    }

    /* Set to NULL to make sure this doesn't point to any used attribute */
    attribute->next = NULL;

    /* For malloc debugging */
    malloc_transfer_to_curr_thread( attribute );
    free( attribute );

    attributes_deleted++;

    return WICED_BT_SUCCESS;
}
Пример #8
0
wiced_result_t gpio_keypad_disable( gpio_keypad_t *keypad )
{
    uint32_t i;

    malloc_transfer_to_curr_thread(keypad->internal);

    wiced_rtos_deinit_timer( &keypad->internal->check_state_timer );

    for ( i = 0; i < keypad->internal->total_keys; i++ )
    {
        wiced_gpio_input_irq_disable( keypad->internal->key_list[i].gpio );
    }

    free( keypad->internal );
    keypad->internal = 0;

    malloc_leak_check( NULL, LEAK_CHECK_THREAD );
    return WICED_SUCCESS;
}
Пример #9
0
wiced_result_t wiced_rtos_create_thread( wiced_thread_t* thread, uint8_t priority, const char* name, wiced_thread_function_t function, uint32_t stack_size, void* arg )
{
    wiced_result_t result;

    thread->stack = malloc_named( "stack", stack_size );
    if (thread->stack == NULL)
    {
        return WICED_OUT_OF_HEAP_SPACE;
    }
    malloc_transfer_to_curr_thread( thread->stack );

    result = (wiced_result_t) host_rtos_create_thread_with_arg( WICED_GET_THREAD_HANDLE( thread ), function, name, thread->stack, stack_size, priority, (uint32_t)arg );

    if ( result != WICED_WWD_SUCCESS )
    {
        free( thread->stack );
        thread->stack = NULL;
    }

    return result;
}
Пример #10
0
wiced_result_t bt_packet_pool_free_packet( bt_packet_t* packet )
{
    if ( packet == NULL )
    {
        return WICED_BT_BADARG;
    }

    if ( packet->pool == DYNAMIC_PACKET_POOL )
    {
        malloc_transfer_to_curr_thread( packet );
        packet->owner     = BT_PACKET_OWNER_POOL;
        packet->node.prev = NULL;
        packet->node.next = NULL;
        packet->node.data = NULL;
        free( packet );
        bt_dynamic_packet_deleted++;
        return WICED_BT_SUCCESS;
    }
    else if ( packet->packet_id == PACKET_ID )
    {
        wiced_result_t result;

        wiced_rtos_lock_mutex( &packet->pool->mutex );

        result = linked_list_insert_node_at_front( &packet->pool->pool_list, &packet->node );

        if ( result == WICED_SUCCESS )
        {
            packet->owner = BT_PACKET_OWNER_POOL;
            packet->pool->packet_deleted++;
        }

        wiced_rtos_unlock_mutex( &packet->pool->mutex );

        return result;
    }

    return WICED_BT_UNKNOWN_PACKET;
}