Exemplo n.º 1
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;
}
Exemplo n.º 2
0
wiced_result_t wiced_rtos_init_queue( wiced_queue_t* queue, const char* name, uint32_t message_size, uint32_t number_of_messages )
{
    UNUSED_PARAMETER( name );

    return host_rtos_init_queue( WICED_GET_QUEUE_HANDLE( queue ), NULL, number_of_messages * message_size, message_size );
}
Exemplo n.º 3
0
besl_result_t besl_p2p_init( p2p_workspace_t* workspace, const besl_p2p_device_detail_t* device_details )
{
    wiced_buffer_t buffer;
    wiced_buffer_t response;
    uint32_t*      data;
    wwd_result_t result;
    REFERENCE_DEBUG_ONLY_VARIABLE(result);

    memset(workspace, 0, sizeof(p2p_workspace_t));

    workspace->p2p_capability = 0x0000;
    workspace->p2p_name       = device_details->device_name;
    workspace->group_owner_intent = 1;

    /* Turn off all the other Wi-Fi interfaces */
    wiced_network_down(WICED_STA_INTERFACE);
    wiced_network_down(WICED_AP_INTERFACE);

    /* Query the AP interface to ensure that it is up */
    data = (uint32_t*) wwd_sdpcm_get_iovar_buffer( &buffer, (uint16_t) 36, IOVAR_STR_BSSCFG_SSID );
    memset(data, 0, 36);
    data[0] = (uint32_t) CHIP_AP_INTERFACE;
    wwd_sdpcm_send_iovar( SDPCM_SET, buffer, NULL, WWD_STA_INTERFACE );

    /*  Enable discovery */
    data = wwd_sdpcm_get_iovar_buffer(&buffer, 4, IOVAR_STR_P2P_DISC );
    *data = 1;
    result = wwd_sdpcm_send_iovar(SDPCM_SET, buffer, NULL, WICED_STA_INTERFACE);
    wiced_assert("", result == WWD_SUCCESS);

    /*  Find what interface is the P2P device */
    wwd_sdpcm_get_iovar_buffer(&buffer, 4, IOVAR_STR_P2P_DEV );
    result = wwd_sdpcm_send_iovar(SDPCM_GET, buffer, &response, WICED_STA_INTERFACE);
    wiced_assert("", result == WWD_SUCCESS);
    workspace->p2p_interface = BESL_READ_32(host_buffer_get_current_piece_data_pointer(response));
    host_buffer_release(response, WWD_NETWORK_RX);

    /* Get the P2P interface MAC address */
    besl_host_get_mac_address(&workspace->device_info.mac_address, workspace->p2p_interface);

    /* Set the standard interface MAC address to be the same as the P2P interface */
    besl_host_set_mac_address(&workspace->device_info.mac_address, WICED_STA_INTERFACE);
    besl_host_set_mac_address(&workspace->device_info.mac_address, WICED_AP_INTERFACE);

    /* Get the standard MAC address to confirm */
    besl_host_get_mac_address(&workspace->intended_mac_address, WICED_STA_INTERFACE);

    BESL_INFO( ("STA MAC: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", workspace->intended_mac_address.octet[0],
        workspace->intended_mac_address.octet[1],
        workspace->intended_mac_address.octet[2],
        workspace->intended_mac_address.octet[3],
        workspace->intended_mac_address.octet[4],
        workspace->intended_mac_address.octet[5]) );


    /* Set the device details */
    workspace->wps_device_details = &device_details->wps_device_details;

    /* Allow the P2P library to initialize */
    p2p_init(workspace, workspace->p2p_name);

    /* Bring up P2P interface */
    wwd_sdpcm_get_ioctl_buffer( &buffer, 0 );
    result = wwd_sdpcm_send_ioctl( SDPCM_SET, WLC_UP, buffer, NULL, workspace->p2p_interface);
    wiced_assert("", result == WWD_SUCCESS);

    /* Set wsec to any non-zero value in the discovery bsscfg to ensure our P2P probe responses have the privacy bit set in the 802.11 WPA IE.
     * Some peer devices may not initiate WPS with us if this bit is not set. */
    data = wwd_sdpcm_get_iovar_buffer(&buffer, 8, IOVAR_STR_BSSCFG_WSEC );
    data[0] = workspace->p2p_interface;
    data[1] = WICED_SECURITY_WPA2_AES_PSK;
    result = wwd_sdpcm_send_iovar(SDPCM_SET, buffer, NULL, WICED_STA_INTERFACE);
    wiced_assert("", result == WWD_SUCCESS);

    workspace->p2p_current_state = P2P_STATE_DISCOVERING;

    /*  Add P2P event handler */
    result = wwd_management_set_event_handler( p2p_events, p2p_event_handler, workspace, workspace->p2p_interface );
    wiced_assert("", result == WWD_SUCCESS);

    /* Create the message queue */
    host_rtos_init_queue(&p2p_message_queue, p2p_message_queue_buffer, sizeof(p2p_message_queue_buffer), sizeof(p2p_message_t));

    /* Create the pending outgoing packet queue */
    host_rtos_init_queue(&p2p_outgoing_packet_queue, p2p_outgoing_packet_queue_buffer, sizeof(p2p_outgoing_packet_queue_buffer), sizeof(p2p_message_t));

    /* Create the P2P thread */
    host_rtos_create_thread_with_arg( &p2p_thread, p2p_thread_main, "p2p", p2p_thread_stack, sizeof(p2p_thread_stack), RTOS_HIGHER_PRIORTIY_THAN(RTOS_DEFAULT_THREAD_PRIORITY), (uint32_t)workspace );

    return BESL_SUCCESS;
}