Example #1
0
/** Sets the chip specific AMPDU parameters for AP and STA
 *  For SDK 3.0, and beyond, each chip will need it's own function for setting AMPDU parameters.
 */
wwd_result_t wwd_wifi_set_ampdu_parameters( void )
{
    wiced_buffer_t buffer;
    wwd_result_t retval;

    /* Set AMPDU Block ACK window size */
    uint32_t* data = (uint32_t*) wwd_sdpcm_get_iovar_buffer( &buffer, (uint16_t) 4, IOVAR_STR_AMPDU_BA_WINDOW_SIZE );
    CHECK_IOCTL_BUFFER( data );
    *data = (uint32_t) 8;
    retval = wwd_sdpcm_send_iovar( SDPCM_SET, buffer, NULL, WWD_STA_INTERFACE );

    wiced_assert("set_ampdu_parameters: Failed to set block ack window size\r\n", retval == WWD_SUCCESS );

    /* Set number of MPDUs available for AMPDU */
    data = (uint32_t*) wwd_sdpcm_get_iovar_buffer( &buffer, (uint16_t) 4, IOVAR_STR_AMPDU_MPDU );
    CHECK_IOCTL_BUFFER( data );
    *data = (uint32_t) 4;
    retval = wwd_sdpcm_send_iovar( SDPCM_SET, buffer, NULL, WWD_STA_INTERFACE );

    wiced_assert("set_ampdu_parameters: Failed to set number of MPDUs\r\n", retval == WWD_SUCCESS );

    /* Set size of advertised receive AMPDU */
    data = (uint32_t*) wwd_sdpcm_get_iovar_buffer( &buffer, (uint16_t) 4, IOVAR_STR_AMPDU_RX_FACTOR );
    CHECK_IOCTL_BUFFER( data );
    *data = (uint32_t) AMPDU_RX_FACTOR_8K;
    retval = wwd_sdpcm_send_iovar( SDPCM_SET, buffer, NULL, WWD_STA_INTERFACE );

    wiced_assert("set_ampdu_parameters: Failed to set advertised receive AMPDU size\r\n", retval == WWD_SUCCESS );

    return retval;
}
Example #2
0
static void reset_rtc_values( void )
{
    ErrorStatus status;

    /* Disable write protection of rtc registers */
    RTC_WriteProtectionCmd(DISABLE);
    status = RTC_EnterInitMode();
    REFERENCE_DEBUG_ONLY_VARIABLE(status);
    wiced_assert( "Rtc can not enter intialisation mode", status==SUCCESS );

    /* Reset calendar date registers */
    RTC->TR = 0;
    RTC_ExitInitMode();
    status = RTC_WaitForSynchro();
    wiced_assert( "Rtc can not synchronize", status==SUCCESS );

    /* Enable write protection of rtc registers */
    RTC_WriteProtectionCmd(ENABLE);

    /* Disable write protection of the rtc registers */
    RTC_WriteProtectionCmd(DISABLE);
    status = RTC_EnterInitMode();
    wiced_assert( "Rtc can not enter intialisation mode", status==SUCCESS );

    /* 2000 year 01/01 */
    RTC->DR= 0;
    RTC->DR= ( 1<<13 ) | ( 1<<8 ) | ( 1<<0 );
    RTC_ExitInitMode();
    status = RTC_WaitForSynchro();
    wiced_assert( "Rtc can not synchronize", status==SUCCESS );

    /* Enable write protection of rtc registers */
    RTC_WriteProtectionCmd(ENABLE);

}
Example #3
0
static uint32_t convert_rtc_calendar_values_to_units_passed( void )
{
    long int        temp1=0;
    long int        temp2=0;
    int             temp=0;
    long int        temp_days=0;
    uint8_t         current_year;
    RTC_TimeTypeDef rtc_read_time;
    RTC_DateTypeDef rtc_read_date;


    /* Read current rtc time */
    RTC_GetTime( RTC_Format_BIN, &rtc_read_time );
    RTC_GetDate( RTC_Format_BIN, &rtc_read_date );

    /* Calculate number of days in the previous years */
    if( rtc_read_date.RTC_Year != 0 )
    {
        for( temp = (int)( rtc_read_date.RTC_Year - 1 ); temp >= 0; temp-- )
        {
            temp_days += (LEAP_YEAR_OR_NOT(temp)) ? (LEAP_YEAR_DAY_COUNT): (NOT_LEAP_YEAR_DAY_COUNT);
        }
    }

    current_year = rtc_read_date.RTC_Year;
    wiced_assert("Inappropriate month value in RTC", (rtc_read_date.RTC_Month != 0) );
    if( rtc_read_date.RTC_Month != 0 )
    {
        /* Calculate number of days passed in the current year and add them to previous days value */
        for( temp = (int)( rtc_read_date.RTC_Month - 1 ); temp > 0; temp-- )
        {
            temp_days += LEAP_YEAR_OR_NOT(current_year)?(leap_days[temp]):(not_leap_days[temp]);
        }
    }

    /* Convert passed hours, seconds and minutes to seconds */
    temp1 = rtc_read_time.RTC_Seconds + rtc_read_time.RTC_Minutes*NUM_SECONDS_IN_MINUTE + rtc_read_time.RTC_Hours*NUM_SECONDS_IN_HOUR;

    wiced_assert("Inappropriate date value in RTC", ( rtc_read_date.RTC_Date != 0 ) );

    /* Convert passed days to seconds */
    if( rtc_read_date.RTC_Date != 0 )
    {
        temp2 = ( ( rtc_read_date.RTC_Date - 1 ) + temp_days ) * NUM_SECONDS_IN_HOUR * 24;
    }

    /* Return total number of seconds passed  */
    return (uint32_t)( temp1 + temp2 );

}
Example #4
0
static void send_char( char c )
{
    wiced_result_t result;
    result = wiced_uart_transmit_bytes( cons.uart, &c, 1 );
    wiced_assert("", result == WICED_SUCCESS);
    REFERENCE_DEBUG_ONLY_VARIABLE( result );
}
Example #5
0
wiced_result_t wiced_tls_receive_packet( wiced_tcp_socket_t* socket, wiced_packet_t** packet, uint32_t timeout )
{
    wiced_result_t result;
    wiced_tls_context_t* context = &socket->tls_context->context;


    /* Check if we already have a record which should only happen if it was larger than a packet which means it's stored in the defragmentation buffer */
    if ( context->current_record != NULL )
    {
        wiced_assert( "Something wrong", (void*)context->current_record == context->defragmentation_buffer );
        return tls_packetize_buffered_data( context, packet );
    }
    else
    {
        tls_record_t* record;
        result = tls_get_next_record( context, &record, timeout, TLS_RECEIVE_PACKET_IF_NEEDED );
        if ( result != WICED_SUCCESS )
        {
            return result;
        }
        /* Check if this record has been defragmented */
        if ( (void*)record == context->defragmentation_buffer )
        {
            return tls_packetize_buffered_data( context, packet );
        }
        else
        {
            tls_record_t* temp_record;
            uint8_t* packet_data;
            uint16_t length;
            uint16_t available;
            uint8_t* end_of_data;

            /* We have a pointer to the current record so we can move on */
            tls_skip_current_record(context);

            /* Make sure we process every record in this packet */
            end_of_data = record->message + htobe16( record->length );
            while ( tls_get_next_record( context, &temp_record, timeout, TLS_AVOID_NEW_RECORD_PACKET_RECEIVE ) == TLS_SUCCESS )
            {
                /* Make the record data contiguous with the previous record */
                uint16_t temp_record_length = htobe16( temp_record->length );
                end_of_data = MEMCAT( end_of_data, temp_record->message, temp_record_length );
                record->length = htobe16( htobe16(record->length) + temp_record_length );
                tls_skip_current_record( context );
            }

            /* Set the packet start and end */
            wiced_packet_get_data( (wiced_packet_t*)context->received_packet, 0, &packet_data, &length, &available );
            tls_host_set_packet_start( context->received_packet, record->message );
            wiced_packet_set_data_end( (wiced_packet_t*)context->received_packet, end_of_data );

            *packet = (wiced_packet_t*)context->received_packet;
            context->received_packet        = NULL;
            context->received_packet_length = 0;
        }
    }

    return WICED_SUCCESS;
}
Example #6
0
/**
 *  Main function - starts ThreadX
 *  Called from the crt0 _start function
 *
 */
int main( void )
{

#if defined ( __IAR_SYSTEMS_ICC__ )
/* IAR allows init functions in __low_level_init(), but it is run before global
 * variables have been initialised, so the following init still needs to be done
 * When using GCC, this is done in crt0_GCC.c
 */
    init_architecture( );
    init_platform( );
#endif /* #elif defined ( __IAR_SYSTEMS_ICC__ ) */

#ifndef WICED_DISABLE_WATCHDOG
    /* Start the watchdog kicking thread */
    xTaskCreate( system_monitor_thread_main, (signed char*)"system monitor", SYSTEM_MONITOR_THREAD_STACK_SIZE/sizeof( portSTACK_TYPE ), NULL, RTOS_HIGHEST_PRIORITY, &system_monitor_thread_handle);
#endif /* WICED_DISABLE_WATCHDOG */
    /* Create an initial thread */
    xTaskCreate( application_thread_main, (signed char*)"app_thread", APPLICATION_STACK_SIZE/sizeof( portSTACK_TYPE ), NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), &app_thread_handle);

#ifdef __GNUC__
    {
        wiced_result_t result;
        result = wiced_freertos_init_malloc_mutex();
        wiced_assert( "Unable t create a freertos malloc mutex", result == WICED_SUCCESS );
        (void) result;
    }
#endif /* ifdef __GNUC__ */

    /* Start the FreeRTOS scheduler - this call should never return */
    vTaskStartScheduler( );

    /* Should never get here, unless there is an error in vTaskStartScheduler */
    return 0;
}
Example #7
0
/** Sends the first queued packet
 *
 * Checks the queue to determine if there is any packets waiting
 * to be sent. If there are, then it sends the first one.
 *
 * This function is normally used by the WWD Thread, but can be
 * called periodically by systems which have no RTOS to ensure
 * packets get sent.
 *
 * @return    1 : packet was sent
 *            0 : no packet sent
 */
int8_t wwd_thread_send_one_packet( void ) /*@modifies internalState @*/
{
    wiced_buffer_t tmp_buf_hnd = NULL;
    wwd_result_t result;

    if ( wwd_sdpcm_get_packet_to_send( &tmp_buf_hnd ) != WWD_SUCCESS )
    {
        /*@-mustfreeonly@*/ /* Failed to get a packet */
        return 0;
        /*@+mustfreeonly@*/
    }

    /* Ensure the wlan backplane bus is up */
    result = wwd_ensure_wlan_bus_is_up();
    if ( result != WWD_SUCCESS )
    {
        wiced_assert("Could not bring bus back up", 0 != 0 );
        host_buffer_release( tmp_buf_hnd, WWD_NETWORK_TX );
        return 0;
    }

    WWD_LOG(("Wcd:> Sending pkt 0x%08lX\n", (unsigned long)tmp_buf_hnd ));
    if ( wwd_bus_send_buffer( tmp_buf_hnd ) != WWD_SUCCESS )
    {
        WWD_STATS_INCREMENT_VARIABLE( tx_fail );
        return 0;
    }

    WWD_STATS_INCREMENT_VARIABLE( tx_total );
    return (int8_t) 1;
}
Example #8
0
void host_buffer_release( wiced_buffer_t buffer, wwd_buffer_dir_t direction )
{
    wiced_assert( "Error: Invalid buffer\n", buffer != NULL );

    if ( direction == WWD_NETWORK_TX )
    {
        NX_PACKET *nx_buffer = (NX_PACKET *) buffer;

        /* TCP transmit packet isn't returned immediately to the pool. The stack holds the packet temporarily
         * until ACK is received. Otherwise, the same packet is used for re-transmission.
         * Return prepend pointer to the original location which the stack expects (the start of IP header).
         * For other packets, resetting prepend pointer isn't required.
         */
        if ( nx_buffer->nx_packet_length > sizeof(wwd_buffer_header_t) + WWD_SDPCM_HEADER_TX_LENGTH + WICED_ETHERNET_SIZE )
        {
            if ( host_buffer_add_remove_at_front( &buffer, sizeof(wwd_buffer_header_t) + WWD_SDPCM_HEADER_TX_LENGTH + WICED_ETHERNET_SIZE ) != WWD_SUCCESS )
            {
                WPRINT_NETWORK_DEBUG(("Could not move packet pointer\r\n"));
            }
        }

        if ( NX_SUCCESS != nx_packet_transmit_release( nx_buffer ) )
        {
            WPRINT_NETWORK_ERROR(("Could not release packet - leaking buffer\n"));
        }
    }
    else
    {
        NX_PACKET *nx_buffer = (NX_PACKET *) buffer;
        if ( NX_SUCCESS != nx_packet_release( nx_buffer ) )
        {
            WPRINT_NETWORK_ERROR(("Could not release packet - leaking buffer\n"));
        }
    }
}
Example #9
0
wwd_result_t wwd_wifi_set_block_ack_window_size( wwd_interface_t interface )
{
    wiced_buffer_t buffer;
    wwd_result_t retval;
    uint32_t block_ack_window_size = 2;
    uint32_t* data = NULL;

    /* If the AP interface is already up then don't change the Block Ack window size */
    if ( wwd_wifi_is_ready_to_transceive( WWD_AP_INTERFACE ) == WWD_SUCCESS )
    {
        return WWD_SUCCESS;
    }

    /* AP can handle BA window size of 1 but STA can handle BA window size of 8 */
    if ( interface == WWD_STA_INTERFACE )
    {
        block_ack_window_size = 8;
    }

    /* Set AMPDU Block ACK window size */
    data = (uint32_t*) wwd_sdpcm_get_iovar_buffer( &buffer, (uint16_t) 4, IOVAR_STR_AMPDU_BA_WINDOW_SIZE );
    CHECK_IOCTL_BUFFER( data );
    *data = block_ack_window_size;
    retval = wwd_sdpcm_send_iovar( SDPCM_SET, buffer, NULL, WWD_STA_INTERFACE );

    wiced_assert("set_block_ack_window_size: Failed to set block ack window size\r\n", retval == WWD_SUCCESS );

    return retval;
}
Example #10
0
/*@shared@*/ caddr_t _sbrk( int incr )
{
    unsigned char *prev_heap;

    if ( sbrk_heap_top + incr > _eheap )
    {
        /* Out of dynamic memory heap space */

        volatile struct mallinfo mi = mallinfo();

        // See variable mi for malloc information:
        // Total allocated :  mi.uordblks
        // Total free :       mi.fordblks

        wiced_assert("Out of dynamic memory heap space", 0 != 0 );

        UNUSED_VARIABLE( mi );

        errno = ENOMEM;
        return (caddr_t) -1;
    }
    prev_heap = sbrk_heap_top;

    sbrk_heap_top += incr;

    return (caddr_t) prev_heap;
}
Example #11
0
tls_result_t tls_host_create_buffer( ssl_context* ssl, uint8_t** buffer, uint16_t buffer_size )
{
    wiced_assert("", ssl->outgoing_packet == NULL);

    /* Round requested buffer size up to next 64 byte chunk (required if encryption is active) */
    buffer_size = (uint16_t) ROUND_UP(buffer_size, 64);

    /* Check if requested buffer fits within a single MTU */
    if (buffer_size < 1300) /* TODO: Fix this */
    {
        uint16_t actual_packet_size;
        if ( wiced_packet_create_tcp( ssl->send_context, buffer_size, (wiced_packet_t**) &ssl->outgoing_packet, buffer, &actual_packet_size ) != WICED_SUCCESS )
        {
            *buffer = NULL;
            return 1;
        }
    }
    else
    {
        /* Malloc space */
        *buffer = tls_host_malloc("tls", buffer_size);
        ssl->out_buffer_size = buffer_size;
    }

    return 0;
}
Example #12
0
/**
 * Stores information about a task in the task info list. If the task is already
 * in the array, then it doesn't really do anything.
 *
 * This function should be called instead of directly inserting a task into the
 * array, because this function ensures that there are no duplicates.
 */
TCB_NUMBER_T task_storeinfo( void *p, char TaskName[], TCB_NUMBER_T TCBNumber )
{
    /* Check if task info already exists. If it does, return it. */
    unsigned int i;
    for ( i = 0; i < task_count; i++ )
    {
        if ( strcmp( task_info[i].task_name, (const char *) TaskName ) == 0 )
        {
            /* Task info already exists... just return it */
            return task_info[i].task_tcb_number;
        }
    }

    wiced_assert( "Task info buffer is full.\r\n", task_count < TRACE_LOG_TASK_COUNT );
    /**
     * Note that if the task info buffer is full, we can continue writing into
     * the trace buffer, but won't be able to translate TCB numbers into task
     * names.
     */

    /* Generate new task info */
    task_info_t new_info;
    strcpy( new_info.task_name, (const char *) TaskName );
    new_info.p               = p;
    new_info.task_tcb_number = TCBNumber;
    task_info[task_count++]  = new_info;
    return new_info.task_tcb_number;
} /* task_storeinfo */
Example #13
0
wiced_result_t wiced_rtos_set_event_flags( wiced_event_flags_t* event_flags, uint32_t flags_to_set )
{
    UNUSED_PARAMETER( event_flags );
    UNUSED_PARAMETER( flags_to_set );
    wiced_assert( "Unsupported\n", 0!=0 );
    return WICED_UNSUPPORTED;
}
Example #14
0
/**
 * Gets a semaphore
 *
 * If value of semaphore is larger than zero, then the semaphore is decremented and function returns
 * Else If value of semaphore is zero, then current thread is suspended until semaphore is set.
 * Value of semaphore should never be below zero
 *
 * Must not be called from interrupt context, since it could block, and since an interrupt is not a
 * normal thread, so could cause RTOS problems if it tries to suspend it.
 *
 * @param semaphore   : Pointer to variable which will receive handle of created semaphore
 * @param timeout_ms  : Maximum period to block for. Can be passed NEVER_TIMEOUT to request no timeout
 * @param will_set_in_isr : True if the semaphore will be set in an ISR. Currently only used for NoOS/NoNS
 *
 */
wwd_result_t host_rtos_get_semaphore( host_semaphore_type_t* semaphore, uint32_t timeout_ms, wiced_bool_t will_set_in_isr )
{
    UINT result;

    UNUSED_PARAMETER( will_set_in_isr );

    result = tx_semaphore_get( semaphore, ( timeout_ms == NEVER_TIMEOUT ) ? TX_WAIT_FOREVER : (ULONG) ( timeout_ms * SYSTICK_FREQUENCY / 1000 ) );
    if ( result == TX_SUCCESS )
    {
        return WWD_SUCCESS;
    }
    else if ( result == TX_NO_INSTANCE )
    {
        return WWD_TIMEOUT;
    }
    else if ( result == TX_WAIT_ABORTED )
    {
        return WWD_WAIT_ABORTED;
    }
    else
    {
        wiced_assert( "semaphore error ", 0 );
        return WWD_SEMAPHORE_ERROR;
    }
}
Example #15
0
wiced_result_t wiced_rtos_deinit_mutex( wiced_mutex_t* mutex )
{
    wiced_assert("Bad args", mutex != NULL);

    vSemaphoreDelete( *mutex );
    return WICED_SUCCESS;
}
wiced_result_t wiced_tcp_stream_flush( wiced_tcp_stream_t* tcp_stream )
{
    wiced_result_t result = WICED_TCPIP_SUCCESS;

    wiced_assert("Bad args", tcp_stream != NULL);

    WICED_LINK_CHECK_TCP_SOCKET( tcp_stream->socket );

    /* Check if there is a packet to send */
    if ( tcp_stream->tx_packet != NULL )
    {
        wiced_packet_set_data_end(tcp_stream->tx_packet, tcp_stream->tx_packet_data);
        result = wiced_tcp_send_packet( tcp_stream->socket, tcp_stream->tx_packet );

        tcp_stream->tx_packet_data            = NULL;
        tcp_stream->tx_packet_space_available = 0;
        if ( result != WICED_TCPIP_SUCCESS )
        {
            wiced_packet_delete( tcp_stream->tx_packet );
        }

        tcp_stream->tx_packet = NULL;
    }
    return result;
}
Example #17
0
void application_thread_main( ULONG thread_input )
{
    UNUSED_PARAMETER( thread_input);

#ifndef WICED_DISABLE_WATCHDOG
    /* Start the watchdog kicking thread */
    wiced_rtos_create_thread( &system_monitor_thread_handle, RTOS_HIGHEST_PRIORITY, "system monitor", (wiced_thread_function_t)system_monitor_thread_main, SYSTEM_MONITOR_THREAD_STACK_SIZE, NULL );
#endif /* WICED_DISABLE_WATCHDOG */

#ifdef TX_ENABLE_EVENT_TRACE
    {
        wiced_result_t        result;
        wiced_tracex_config_t tracex_config;

        tracex_config.loop_rec = WICED_FALSE;
        tracex_config.filter = 0;
        tracex_config.tcp_server.enable = WICED_FALSE;
        tracex_config.tcp_server.port = WICED_TRACEX_TCP_SERVER_PORT;
        tracex_config.tcp_server.max_data_len = WICED_TRACEX_TCP_MAX_PACKET_LENGTH;
        tracex_config.tcp_server.timeout = WICED_TRACEX_TCP_CONNECT_TIMEOUT;
        tracex_config.tcp_server.num_retries = WICED_TRACEX_TCP_CONNECTION_NUM_RETRIES;
        SET_IPV4_ADDRESS(tracex_config.tcp_server.ip, WICED_TRACEX_TCP_SERVER_IP);
        tracex_config.buf.addr = WICED_TRACEX_BUFFER_ADDRESS;
        tracex_config.buf.size = WICED_TRACEX_BUFFER_SIZE;
        tracex_config.buf.obj_cnt = WICED_TRACEX_OBJECT_COUNT;

        result = wiced_tracex_enable(&tracex_config);
        wiced_assert( "TraceX enable failed", result == WICED_SUCCESS );
        REFERENCE_DEBUG_ONLY_VARIABLE( result );
    }
#endif /* TX_ENABLE_EVENT_TRACE */

    application_start( );
    malloc_leak_check(NULL, LEAK_CHECK_THREAD);
}
Example #18
0
int _kill( int pid, int sig )
{
    wiced_assert("", 0 != 0 );

    UNUSED_PARAMETER( pid );
    UNUSED_PARAMETER( sig );
    return 0;
}
Example #19
0
wwd_result_t host_buffer_init( void * pools_in )
{
    wiced_assert("Error: Invalid buffer pools\n", pools_in != NULL);
    tx_pool = &( (NX_PACKET_POOL*) pools_in )[0];
    rx_pool = &( (NX_PACKET_POOL*) pools_in )[1];

    return WWD_SUCCESS;
}
Example #20
0
wwd_result_t host_buffer_get( wiced_buffer_t * buffer, wwd_buffer_dir_t direction, unsigned short size, wiced_bool_t wait )
{
    volatile UINT status;
    NX_PACKET **nx_buffer = (NX_PACKET **) buffer;
    NX_PACKET_POOL* pool = ( direction == WWD_NETWORK_TX ) ? tx_pool : rx_pool;
    wiced_assert("Error: pools have not been set up\n", pool != NULL);

    if ( size > WICED_LINK_MTU )
    {
        WPRINT_NETWORK_DEBUG(("Attempt to allocate a buffer larger than the MTU of the link\n"));
        return WWD_BUFFER_UNAVAILABLE_PERMANENT;
    }
    if ( NX_SUCCESS != ( status = nx_packet_allocate( pool, nx_buffer, 0, ( wait == WICED_TRUE ) ? NX_WAIT_FOREVER : NX_NO_WAIT ) ) )
    {
        /* If there is no packet in the system TX pool, check whether there is any packet available in the application defined tx pool */
        /* and try to allocate from there */
        if( status == NX_NO_PACKET )
        {
            if( ( direction == WWD_NETWORK_TX ) && ( application_defined_tx_pool != NULL ) )
            {
                if ( NX_SUCCESS != ( status = nx_packet_allocate( application_defined_tx_pool, nx_buffer, 0, ( wait == WICED_TRUE ) ? NX_WAIT_FOREVER : NX_NO_WAIT ) ) )
                {
                    return WWD_BUFFER_UNAVAILABLE_TEMPORARY;
                }
                else
                {
                    ( *nx_buffer )->nx_packet_length = size;
                    ( *nx_buffer )->nx_packet_append_ptr = ( *nx_buffer )->nx_packet_prepend_ptr + size;
                }
            }
            else if( ( direction == WWD_NETWORK_RX ) && ( application_defined_rx_pool != NULL ) )
            {
                if ( NX_SUCCESS != ( status = nx_packet_allocate( application_defined_rx_pool, nx_buffer, 0, ( wait == WICED_TRUE ) ? NX_WAIT_FOREVER : NX_NO_WAIT ) ) )
                {
                    return WWD_BUFFER_UNAVAILABLE_TEMPORARY;
                }
                else
                {
                    ( *nx_buffer )->nx_packet_length = size;
                    ( *nx_buffer )->nx_packet_append_ptr = ( *nx_buffer )->nx_packet_prepend_ptr + size;
                }
            }
            else
            {
                return WWD_BUFFER_UNAVAILABLE_TEMPORARY;
            }
        }
        else
        {
            return WWD_BUFFER_ALLOC_FAIL;
        }
    }
    ( *nx_buffer )->nx_packet_length = size;
    ( *nx_buffer )->nx_packet_append_ptr = ( *nx_buffer )->nx_packet_prepend_ptr + size;

    return WWD_SUCCESS;
}
wwd_result_t host_rtos_register_timer_ifc( const host_rtos_timer_ifc_t *host_rtos_timer_ifc_new )
{
    if ( NULL != host_rtos_timer_ifc )
    {
        wiced_assert( "Function already registered\n", 0 != 0 );
        return WWD_BADARG;
    }
    host_rtos_timer_ifc = host_rtos_timer_ifc_new;
    return WWD_SUCCESS;
}
wiced_result_t wiced_tcp_stream_write( wiced_tcp_stream_t* tcp_stream, const void* data, uint32_t data_length )
{
    wiced_assert("Bad args", tcp_stream != NULL);

    WICED_LINK_CHECK_TCP_SOCKET( tcp_stream->socket );

    while ( data_length != 0 )
    {
        uint16_t amount_to_write;

        /* Check if we don't have a packet */
        if ( tcp_stream->tx_packet == NULL )
        {
            wiced_result_t result;
            result = wiced_packet_create_tcp( tcp_stream->socket, (uint16_t) MIN( data_length, 0xffff ), &tcp_stream->tx_packet, &tcp_stream->tx_packet_data , &tcp_stream->tx_packet_space_available );
            if ( result != WICED_TCPIP_SUCCESS )
            {
                return result;
            }
        }

        /* Write data */
        amount_to_write = (uint16_t) MIN( data_length, tcp_stream->tx_packet_space_available );
        tcp_stream->tx_packet_data     = MEMCAT( tcp_stream->tx_packet_data, data, amount_to_write );

        /* Update variables */
        data_length                           = (uint16_t)(data_length - amount_to_write);
        tcp_stream->tx_packet_space_available = (uint16_t) ( tcp_stream->tx_packet_space_available - amount_to_write );
        data                                  = (void*)((uint32_t)data + amount_to_write);

        /* Check if the packet is full */
        if ( tcp_stream->tx_packet_space_available == 0 )
        {
            wiced_result_t result;

            /* Send the packet */
            wiced_packet_set_data_end( tcp_stream->tx_packet, (uint8_t*)tcp_stream->tx_packet_data );
            result = wiced_tcp_send_packet( tcp_stream->socket, tcp_stream->tx_packet );

            tcp_stream->tx_packet_data            = NULL;
            tcp_stream->tx_packet_space_available = 0;

            if ( result != WICED_TCPIP_SUCCESS )
            {
                wiced_packet_delete( tcp_stream->tx_packet );
                tcp_stream->tx_packet = NULL;
                return result;
            }

            tcp_stream->tx_packet = NULL;
        }
    }

    return WICED_TCPIP_SUCCESS;
}
Example #23
0
static void send_charstr( const char* s )
{
    while ( *s != 0 )
    {
        wiced_result_t result;
        result = wiced_uart_transmit_bytes( cons.uart, s, 1 );
        wiced_assert("", result == WICED_SUCCESS );
        REFERENCE_DEBUG_ONLY_VARIABLE( result );
        s++;
    }
}
Example #24
0
wiced_result_t wiced_rtos_wait_for_event_flags( wiced_event_flags_t* event_flags, uint32_t flags_to_wait_for, uint32_t* flags_set, wiced_bool_t clear_set_flags, wiced_event_flags_wait_option_t wait_option, uint32_t timeout_ms )
{
    UNUSED_PARAMETER( event_flags );
    UNUSED_PARAMETER( flags_to_wait_for );
    UNUSED_PARAMETER( flags_set );
    UNUSED_PARAMETER( clear_set_flags );
    UNUSED_PARAMETER( wait_option );
    UNUSED_PARAMETER( timeout_ms );
    wiced_assert( "Unsupported\n", 0!=0 );
    return WICED_UNSUPPORTED;
}
Example #25
0
wiced_result_t wiced_rtos_unlock_mutex( wiced_mutex_t* mutex )
{
    wiced_assert("Bad args", mutex != NULL);

    if ( xSemaphoreGive( *mutex ) != pdPASS )
    {
        return WICED_ERROR;
    }

    return WICED_SUCCESS;
}
Example #26
0
static void p2p_discover( p2p_workspace_t* workspace )
{
    wwd_result_t result;
    p2p_message_t  message;
    REFERENCE_DEBUG_ONLY_VARIABLE(result);

    if ( workspace->p2p_current_state == P2P_STATE_SCANNING )
    {
        workspace->p2p_current_state = P2P_STATE_DISCOVERING;
    }

    result = p2p_set_discovery_state( P2P_DISCOVERY_STATE_LISTEN );
    wiced_assert("", result == WWD_SUCCESS);

    while ( host_rtos_pop_from_queue( &p2p_outgoing_packet_queue, &message, 0 ) == WWD_SUCCESS )
    {
        result = wwd_sdpcm_send_iovar( SDPCM_SET, (wiced_buffer_t) message.data, NULL, WICED_STA_INTERFACE );
        wiced_assert("", result == WWD_SUCCESS);
    }
}
Example #27
0
wiced_result_t wiced_rtos_lock_mutex( wiced_mutex_t* mutex )
{
    wiced_assert("Bad args", mutex != NULL);

    if ( xSemaphoreTake( *mutex, WICED_WAIT_FOREVER ) != pdPASS )
    {
        return WICED_ERROR;
    }

    return WICED_SUCCESS;
}
Example #28
0
static void send_str( const char* s )
{
    uint32_t length = strlen(s);
    if ( length > 0 )
    {
        wiced_result_t result;
        result = wiced_uart_transmit_bytes( cons.uart, s, length );
        wiced_assert("", result == WICED_SUCCESS);
        REFERENCE_DEBUG_ONLY_VARIABLE( result );
    }
}
Example #29
0
static besl_result_t wiced_tls_load_certificate( wiced_tls_certificate_t* certificate, const char* cert_string )
{
    if ( x509parse_crt( certificate, (unsigned char *) cert_string, (uint32_t) strlen( cert_string ) ) != 0 )
    {
        wiced_assert("Certificate parse error", 0 != 0 );
        return BESL_CERT_PARSE_FAIL;
    }
    else
    {
        return BESL_SUCCESS;
    }
}
Example #30
0
static besl_result_t wiced_tls_load_key( wiced_tls_key_t* key, const char* key_string )
{
    if ( x509parse_key( key, (unsigned char *) key_string, (uint32_t) strlen( key_string ), NULL, 0 ) != 0 )
    {
        wiced_assert("Key parse error", 0 != 0 );
        return BESL_KEY_PARSE_FAIL;
    }
    else
    {
        return BESL_SUCCESS;
    }
}