wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_operation_update_rxtx_parameters.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Statemachine for updating rxtx parameters
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "core_operation_update_rxtx_parameters.h"
       
    20 #include "core_operation_update_tx_rate_policies.h"
       
    21 #include "core_server.h"
       
    22 #include "am_debug.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 /** Beacon lost value to be used when BT connection is disabled. */
       
    27 const u32_t CORE_BEACON_LOST_COUNT_NO_BT = 15;
       
    28 /** Beacon lost value to be used when BT connection is active. */
       
    29 const u32_t CORE_BEACON_LOST_COUNT_BT = 20;
       
    30 /**
       
    31  * Number of consecutive packets that have to be lost before
       
    32  * core_am_indication_wlan_tx_fail is indicated.
       
    33  */
       
    34 const u32_t CORE_FAILED_TX_PACKETS_COUNT = 4;
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 core_operation_update_rxtx_parameters_c::core_operation_update_rxtx_parameters_c(
       
    40     u32_t request_id,
       
    41     core_server_c* server,
       
    42     abs_core_driverif_c* drivers,
       
    43     abs_core_server_callback_c* adaptation ) :
       
    44     core_operation_base_c( core_operation_update_rxtx_parameters, request_id, server, drivers, adaptation,
       
    45         core_base_flag_only_one_instance )
       
    46     {
       
    47     DEBUG( "core_operation_update_rxtx_parameters_c::core_operation_update_rxtx_parameters_c()" );
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 core_operation_update_rxtx_parameters_c::~core_operation_update_rxtx_parameters_c()
       
    54     {
       
    55     DEBUG( "core_operation_update_rxtx_parameters_c::~core_operation_update_rxtx_parameters_c()" );
       
    56     }
       
    57     
       
    58 // ---------------------------------------------------------------------------
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 core_error_e core_operation_update_rxtx_parameters_c::next_state()
       
    62     {
       
    63     DEBUG( "core_operation_update_rxtx_parameters_c::next_state()" );
       
    64     
       
    65     switch ( operation_state_m )
       
    66         {
       
    67         case core_state_init:
       
    68             {                        
       
    69             operation_state_m = core_state_req_set_bss_lost_parameters;
       
    70 
       
    71             if( !server_m->get_core_settings().is_driver_loaded() )
       
    72                 {
       
    73                 DEBUG( "core_operation_update_rxtx_parameters_c::next_state() - driver not loaded, completing operation" );
       
    74                 return core_error_ok;
       
    75                 }
       
    76 
       
    77             core_bss_lost_parameters_s parameters =
       
    78                 { CORE_BEACON_LOST_COUNT_NO_BT, CORE_FAILED_TX_PACKETS_COUNT };
       
    79             if ( server_m->get_core_settings().is_bt_connection_established() )
       
    80                 {
       
    81                 DEBUG( "core_operation_update_rxtx_parameters_c::next_state() - BT connection on, adjusting beacon lost count" );
       
    82                 parameters.beacon_lost_count = CORE_BEACON_LOST_COUNT_BT; 
       
    83                 }
       
    84 
       
    85             DEBUG( "core_operation_update_rxtx_parameters_c::next_state() - setting bss lost parameters" );
       
    86             DEBUG1( "core_operation_update_rxtx_parameters_c::next_state() - beacon_lost_count = %u",
       
    87                 parameters.beacon_lost_count );
       
    88             DEBUG1( "core_operation_update_rxtx_parameters_c::next_state() - failed_tx_packet_count = %u",
       
    89                 parameters.failed_tx_packet_count );
       
    90 
       
    91             drivers_m->set_bss_lost_parameters(
       
    92                 request_id_m,
       
    93                 parameters );
       
    94 
       
    95             break;
       
    96             }
       
    97         case core_state_req_set_bss_lost_parameters:
       
    98             {
       
    99             operation_state_m = core_state_req_set_tx_rate_policies;
       
   100 
       
   101             if ( server_m->get_core_settings().is_connected() &&
       
   102                  server_m->get_connection_data() &&
       
   103                  server_m->get_connection_data()->current_ap_data() )
       
   104                 {
       
   105                 core_operation_base_c* operation = new core_operation_update_tx_rate_policies_c(
       
   106                     request_id_m,
       
   107                     server_m,
       
   108                     drivers_m,
       
   109                     adaptation_m,
       
   110                     *server_m->get_connection_data()->current_ap_data() );
       
   111 
       
   112                 return run_sub_operation( operation );
       
   113                 }
       
   114 
       
   115             DEBUG( "core_operation_update_rxtx_parameters_c::next_state() - not connected, no need to set TX rate policies" );
       
   116 
       
   117             return goto_state( core_state_req_set_tx_rate_policies );
       
   118             }
       
   119         case core_state_req_set_tx_rate_policies:
       
   120             {
       
   121             DEBUG( "core_operation_update_rxtx_parameters_c::next_state() - all set" );
       
   122 
       
   123             return core_error_ok;
       
   124             }
       
   125         default:
       
   126             {
       
   127             ASSERT( false_t );
       
   128             }
       
   129         }
       
   130 
       
   131     return core_error_request_pending;
       
   132     }