Example #1
0
static void* p2p_event_handler( const wwd_event_header_t* event_header, const uint8_t* event_data, /*@returned@*/ void* handler_user_data )
{
    p2p_workspace_t* workspace = handler_user_data;
    p2p_message_t    message;

    switch ( event_header->event_type )
    {
        case WLC_E_ESCAN_RESULT:
            if ( event_header->status == WLC_E_STATUS_SUCCESS )
            {
                /*  Scan complete */
                message.type = P2P_EVENT_SCAN_COMPLETE;
                host_rtos_push_to_queue(&p2p_message_queue, &message, 0);
            }
            break;

        case WLC_E_P2P_DISC_LISTEN_COMPLETE:
            message.type = P2P_EVENT_DISCOVERY_COMPLETE;
            host_rtos_push_to_queue(&p2p_message_queue, &message, 0);
            break;

        case WLC_E_P2P_PROBREQ_MSG:
            if ( event_data != NULL ) /* TODO: Check if this is needed */
            {
                if ( p2p_process_probe_request( workspace, event_data, event_header->datalen ) == BESL_SUCCESS )
                {
                    message.type = P2P_EVENT_NEW_DEVICE_DISCOVERED;
                    host_rtos_push_to_queue( &p2p_message_queue, &message, 0 );
                }
            }
            break;

        case WLC_E_ACTION_FRAME:
        {
            /* Find matching discovered_device */
            p2p_discovered_device_t* device = p2p_host_find_device(workspace, (besl_mac_t*)&event_header->addr);

            /* Check if device hasn't been seen before */
            if (device->status == P2P_DEVICE_INVALID)
            {
                memcpy( &device->mac, &event_header->addr, sizeof(besl_mac_t) );
                if ( p2p_process_new_device_data( workspace, device, event_data + 16 + sizeof(ieee80211_header_t), event_header->datalen - 16 - sizeof(ieee80211_header_t) ) == BESL_SUCCESS )
                {
                    message.type = P2P_EVENT_NEW_DEVICE_DISCOVERED;
                    host_rtos_push_to_queue( &p2p_message_queue, &message, 0 );
                }
            }
            p2p_process_action_frame( workspace, device, event_data, event_header->datalen );
            break;
        }

        default:
            break;
    }

    return handler_user_data;
}
Example #2
0
besl_result_t besl_p2p_stop( p2p_workspace_t* workspace )
{
    p2p_message_t message;
    message.type = P2P_EVENT_STOP_REQUESTED;
    host_rtos_push_to_queue( &p2p_message_queue, &message, WICED_NEVER_TIMEOUT );

    return BESL_SUCCESS;
}
Example #3
0
besl_result_t p2p_send_action_frame( p2p_workspace_t* workspace, p2p_discovered_device_t* device, p2p_action_frame_writer_t writer, uint32_t channel )
{
    wiced_buffer_t  buffer;
    wl_af_params_t* frame;
    p2p_message_t   message;
    wwd_result_t  result;

    uint32_t* a = wwd_sdpcm_get_iovar_buffer( &buffer, sizeof(wl_af_params_t) + 4, IOVAR_STR_BSSCFG_ACTFRAME );
    *a = workspace->p2p_interface;
    frame = (wl_af_params_t*) ( a + 1 );
    frame->channel    = channel;
    frame->dwell_time = 100;

    memcpy( &frame->action_frame.da, &device->mac, sizeof(besl_mac_t) );
    memcpy( &frame->BSSID, &frame->action_frame.da, 6 );

    uint8_t* end_of_data = writer( workspace, device, frame->action_frame.data );

    frame->action_frame.len      = end_of_data - frame->action_frame.data;
    frame->action_frame.packetId = 1;

    message.type = P2P_EVENT_PACKET_TO_BE_SENT;
    message.data = buffer;
    if ( workspace->p2p_current_state != P2P_STATE_SCANNING && workspace->p2p_current_state != P2P_STATE_NEGOTIATING)
    {
        result = host_rtos_push_to_queue(&p2p_message_queue, &message, WICED_NEVER_TIMEOUT);
    }
    else
    {
        result = host_rtos_push_to_queue(&p2p_outgoing_packet_queue, &message, WICED_NEVER_TIMEOUT);
    }

    if ( result != WWD_SUCCESS)
    {
        return BESL_ERROR_QUEUE_PUSH;
    }

    return BESL_SUCCESS;
}
wiced_result_t wiced_rtos_push_to_queue( wiced_queue_t* queue, void* message, uint32_t timeout_ms )
{
    return host_rtos_push_to_queue( WICED_GET_QUEUE_HANDLE( queue ), message, timeout_ms );
}
Example #5
0
void p2p_host_negotiation_complete( p2p_workspace_t* workspace )
{
    p2p_message_t message;
    message.type = P2P_EVENT_NEGOTIATION_COMPLETE;
    host_rtos_push_to_queue(&p2p_message_queue, &message, WICED_NEVER_TIMEOUT);
}