Home | History | Annotate | Download | only in Test
      1 /*
      2  * roamingMgrDebug.c
      3  *
      4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  *
     11  *  * Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  *  * Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in
     15  *    the documentation and/or other materials provided with the
     16  *    distribution.
     17  *  * Neither the name Texas Instruments nor the names of its
     18  *    contributors may be used to endorse or promote products derived
     19  *    from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /** \file reportReplvl.c
     35  *  \brief Report level implementation
     36  *
     37  *  \see reportReplvl.h
     38  */
     39 
     40 /***************************************************************************/
     41 /*																									*/
     42 /*		MODULE:	reportReplvl.c						 										*/
     43 /*    PURPOSE:	Report level implementation	 										*/
     44 /*																									*/
     45 /***************************************************************************/
     46 #include "tidef.h"
     47 #include "report.h"
     48 #include "paramOut.h"
     49 #include "roamingMgrDebug.h"
     50 #include "roamingMngrApi.h"
     51 #include "apConnApi.h"
     52 
     53 
     54 void printRoamingMgrHelpMenu(void);
     55 void PrintBssListGotAfterImemediateScan(TI_HANDLE hScanMgr);
     56 
     57 
     58 /*	Function implementation */
     59 void roamingMgrDebugFunction(TI_HANDLE hRoamingMngr,
     60 					   TI_UINT32	funcType,
     61 					   void		*pParam)
     62 {
     63 	paramInfo_t			param;
     64 
     65 
     66 	switch (funcType)
     67 	{
     68 	case ROAMING_MGR_DEBUG_HELP_MENU:
     69 		printRoamingMgrHelpMenu();
     70 		break;
     71 
     72 	case PRINT_ROAMING_STATISTICS:
     73 		param.paramType = ROAMING_MNGR_PRINT_STATISTICS;
     74 		roamingMngr_getParam(hRoamingMngr, &param);
     75 		break;
     76 
     77 	case RESET_ROAMING_STATISTICS:
     78 		param.paramType = ROAMING_MNGR_RESET_STATISTICS;
     79 		roamingMngr_getParam(hRoamingMngr, &param);
     80 		break;
     81 
     82 	case PRINT_ROAMING_CURRENT_STATUS:
     83 		param.paramType = ROAMING_MNGR_PRINT_CURRENT_STATUS;
     84 		roamingMngr_getParam(hRoamingMngr, &param);
     85 		break;
     86 
     87 	case PRINT_ROAMING_CANDIDATE_TABLE:
     88 		param.paramType = ROAMING_MNGR_PRINT_CANDIDATE_TABLE;
     89 		roamingMngr_getParam(hRoamingMngr, &param);
     90 		break;
     91 
     92 	case TRIGGER_ROAMING_LOW_QUALITY_EVENT:
     93 		param.paramType = ROAMING_MNGR_TRIGGER_EVENT;
     94 		param.content.roamingTriggerType = ROAMING_TRIGGER_LOW_QUALITY;
     95 		roamingMngr_setParam(hRoamingMngr, &param);
     96 		break;
     97 
     98     case TRIGGER_ROAMING_BSS_LOSS_EVENT:
     99 		param.paramType = ROAMING_MNGR_TRIGGER_EVENT;
    100 		param.content.roamingTriggerType = ROAMING_TRIGGER_BSS_LOSS;
    101 		roamingMngr_setParam(hRoamingMngr, &param);
    102 		break;
    103 
    104 	case TRIGGER_ROAMING_SWITCH_CHANNEL_EVENT:
    105 		param.paramType = ROAMING_MNGR_TRIGGER_EVENT;
    106 		param.content.roamingTriggerType = ROAMING_TRIGGER_SWITCH_CHANNEL;
    107 		roamingMngr_setParam(hRoamingMngr, &param);
    108 		break;
    109 
    110 	case TRIGGER_ROAMING_AP_DISCONNECT_EVENT:
    111 		param.paramType = ROAMING_MNGR_TRIGGER_EVENT;
    112 		param.content.roamingTriggerType = ROAMING_TRIGGER_AP_DISCONNECT;
    113 		roamingMngr_setParam(hRoamingMngr, &param);
    114 		break;
    115 
    116 	case TRIGGER_ROAMING_CONNECT_EVENT:
    117 		param.paramType = ROAMING_MNGR_CONN_STATUS;
    118 		param.content.roamingConnStatus = CONN_STATUS_CONNECTED;
    119 		roamingMngr_setParam(hRoamingMngr, &param);
    120 		break;
    121 
    122 	case TRIGGER_ROAMING_NOT_CONNECTED_EVENT:
    123 		param.paramType = ROAMING_MNGR_CONN_STATUS;
    124 		param.content.roamingConnStatus = CONN_STATUS_NOT_CONNECTED;
    125 		roamingMngr_setParam(hRoamingMngr, &param);
    126 		break;
    127 
    128 	case TRIGGER_ROAMING_HANDOVER_SUCCESS_EVENT:
    129 		param.paramType = ROAMING_MNGR_CONN_STATUS;
    130 		param.content.roamingConnStatus = CONN_STATUS_HANDOVER_SUCCESS;
    131 		roamingMngr_setParam(hRoamingMngr, &param);
    132 		break;
    133 
    134 	case TRIGGER_ROAMING_HANDOVER_FAILURE_EVENT:
    135 		param.paramType = ROAMING_MNGR_CONN_STATUS;
    136 		param.content.roamingConnStatus = CONN_STATUS_HANDOVER_FAILURE;
    137 		roamingMngr_setParam(hRoamingMngr, &param);
    138 		break;
    139 
    140     case ROAMING_REGISTER_BSS_LOSS_EVENT: /* 1613 */
    141         roamingMngr_setBssLossThreshold(hRoamingMngr, 10, 1);
    142         break;
    143     case ROAMING_START_IMMEDIATE_SCAN: /* 1614 */
    144         {
    145             int i=0,j =0;
    146             channelList_t channels;
    147             channels.numOfChannels = 14;
    148 
    149 
    150             for ( i = 0; i < channels.numOfChannels; i++ )
    151             {
    152                 for ( j = 0; j < 6; j++ )
    153                 {
    154                     channels.channelEntry[i].normalChannelEntry.bssId[j] = 0xff;
    155                 }
    156 
    157                 channels.channelEntry[i].normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
    158                 channels.channelEntry[i].normalChannelEntry.ETMaxNumOfAPframes = 0;
    159                 channels.channelEntry[i].normalChannelEntry.maxChannelDwellTime = 60000;
    160                 channels.channelEntry[i].normalChannelEntry.minChannelDwellTime = 30000;
    161                 channels.channelEntry[i].normalChannelEntry.txPowerDbm = DEF_TX_POWER;
    162                 channels.channelEntry[i].normalChannelEntry.channel = i + 1;
    163             }
    164 
    165             /* upon this call the scanMngr_reportImmediateScanResults() should be invoked and the BssList should be printed */
    166             roamingMngr_startImmediateScan(hRoamingMngr, &channels);
    167         }
    168 
    169         break;
    170     case ROAMING_CONNECT: /* 1615 */
    171         {
    172             TargetAp_t targetAP;
    173             bssList_t *bssList;
    174             roamingMngr_t *pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
    175 
    176             bssList = scanMngr_getBSSList(((roamingMngr_t*)hRoamingMngr)->hScanMngr);
    177 
    178             WLAN_OS_REPORT(("Roaming connect: BSS LIST num of entries=%d \n", bssList->numOfEntries));
    179             PrintBssListGotAfterImemediateScan(((roamingMngr_t*)hRoamingMngr)->hScanMngr);
    180 
    181             /* The values below must be configured in manual mode */
    182             targetAP.connRequest.requestType = AP_CONNECT_FULL_TO_AP;
    183             targetAP.connRequest.dataBufLength = 0;
    184             targetAP.transitionMethod = ReAssoc;
    185 
    186             os_memoryCopy(((roamingMngr_t*)hRoamingMngr)->hOs, &(targetAP.newAP), &(bssList->BSSList[0]), sizeof(bssEntry_t));
    187 
    188             /* test if no buffer is present */
    189             targetAP.newAP.bufferLength =0;
    190             targetAP.newAP.pBuffer = 0;
    191             /* ----------------------------- */
    192 
    193             os_memoryCopy(pRoamingMngr->hOs, &(pRoamingMngr->targetAP), &targetAP , sizeof(TargetAp_t));
    194 
    195             roamingMngr_connect(hRoamingMngr, &(pRoamingMngr->targetAP));
    196         }
    197 
    198         break;
    199 
    200     case ROAMING_START_CONT_SCAN_BY_APP: /* 1616 */
    201         {
    202             roamingMngr_t *pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
    203             int i=0,j =0;
    204             channelList_t channels;
    205             channels.numOfChannels = 14;
    206 
    207             for ( i = 0; i < channels.numOfChannels; i++ )
    208             {
    209                 for ( j = 0; j < 6; j++ )
    210                 {
    211                     channels.channelEntry[i].normalChannelEntry.bssId[j] = 0xff;
    212                 }
    213 
    214                 channels.channelEntry[i].normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
    215                 channels.channelEntry[i].normalChannelEntry.ETMaxNumOfAPframes = 0;
    216                 channels.channelEntry[i].normalChannelEntry.maxChannelDwellTime = 60000;
    217                 channels.channelEntry[i].normalChannelEntry.minChannelDwellTime = 30000;
    218                 channels.channelEntry[i].normalChannelEntry.txPowerDbm = DEF_TX_POWER;
    219                 channels.channelEntry[i].normalChannelEntry.channel = i + 1;
    220             }
    221 
    222             scanMngr_startContinuousScanByApp(pRoamingMngr->hScanMngr, &channels);
    223         }
    224 
    225         break;
    226 
    227     case ROAMING_STOP_CONT_SCAN_BY_APP:
    228         {
    229             roamingMngr_t *pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
    230             scanMngr_stopContinuousScanByApp(pRoamingMngr->hScanMngr);
    231         }
    232         break;
    233 
    234 
    235     case RAOMING_SET_DEFAULT_SCAN_POLICY: /* 1618 */
    236         {
    237             int i=0;
    238             roamingMngr_t *pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
    239             TScanPolicy scanPolicy;
    240             param.paramType = SCAN_MNGR_SET_CONFIGURATION;
    241             param.content.pScanPolicy = &scanPolicy;
    242 
    243             // init default scan policy
    244             scanPolicy.normalScanInterval = 10000;
    245             scanPolicy.deterioratingScanInterval = 5000;
    246             scanPolicy.maxTrackFailures = 3;
    247             scanPolicy.BSSListSize = 4;
    248             scanPolicy.BSSNumberToStartDiscovery = 1;
    249             scanPolicy.numOfBands = 1;
    250             scanPolicy.bandScanPolicy[ 0 ].band = RADIO_BAND_2_4_GHZ;
    251             scanPolicy.bandScanPolicy[ 0 ].rxRSSIThreshold = -80;
    252             scanPolicy.bandScanPolicy[ 0 ].numOfChannles = 14;
    253             scanPolicy.bandScanPolicy[ 0 ].numOfChannlesForDiscovery = 3;
    254 
    255             for ( i = 0; i < 14; i++ )
    256             {
    257                 scanPolicy.bandScanPolicy[ 0 ].channelList[ i ] = i + 1;
    258             }
    259 
    260             scanPolicy.bandScanPolicy[ 0 ].trackingMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
    261             scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
    262             scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
    263             scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
    264             scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.minChannelDwellTime = 15000;
    265             scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.bitrate = RATE_MASK_UNSPECIFIED; /* Let the FW select */
    266             scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
    267             scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = DEF_TX_POWER;
    268             scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
    269             scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
    270             scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
    271             scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
    272             scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.minChannelDwellTime = 15000;
    273             scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.bitrate = RATE_MASK_UNSPECIFIED; /* Let the FW select */;
    274             scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
    275             scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = DEF_TX_POWER;
    276             scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
    277             scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
    278             scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
    279             scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
    280             scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.minChannelDwellTime = 15000;
    281             scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = RATE_MASK_UNSPECIFIED; /* Let the FW select */;
    282             scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
    283             scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = DEF_TX_POWER;
    284              /* we should noe store the scanPolicy now */
    285             scanMngr_setParam(pRoamingMngr->hScanMngr, &param);
    286 
    287 
    288             /* Enable roaming! */
    289             param.paramType = ROAMING_MNGR_APPLICATION_CONFIGURATION;
    290             param.content.roamingConfigBuffer.roamingMngrConfig.enableDisable = ROAMING_ENABLED;
    291             roamingMngr_setParam(hRoamingMngr,&param);
    292         }
    293 
    294         break;
    295 
    296     case ROAMING_PRINT_MANUAL_MODE: /* 1617 */
    297         WLAN_OS_REPORT(("\n ROAMING MANUAL MODE IS: %d \n",((roamingMngr_t*)hRoamingMngr)->RoamingOperationalMode));
    298         break;
    299 
    300 	default:
    301 		WLAN_OS_REPORT(("Invalid function type in Debug  Function Command, funcType= %d\n\n", funcType));
    302 		break;
    303 	}
    304 }
    305 
    306 
    307 void printRoamingMgrHelpMenu(void)
    308 {
    309 	WLAN_OS_REPORT(("\n\n   Roaming Manager Debug Menu   \n"));
    310 	WLAN_OS_REPORT(("------------------------\n"));
    311 
    312 
    313 	WLAN_OS_REPORT(("        %02d - ROAMING_MGR_DEBUG_HELP_MENU \n", ROAMING_MGR_DEBUG_HELP_MENU));
    314 
    315 	WLAN_OS_REPORT(("        %02d - PRINT_ROAMING_STATISTICS \n", PRINT_ROAMING_STATISTICS));
    316 	WLAN_OS_REPORT(("        %02d - RESET_ROAMING_STATISTICS \n", RESET_ROAMING_STATISTICS));
    317 
    318 	WLAN_OS_REPORT(("        %02d - PRINT_ROAMING_CURRENT_STATUS \n", PRINT_ROAMING_CURRENT_STATUS));
    319 	WLAN_OS_REPORT(("        %02d - PRINT_ROAMING_CANDIDATE_TABLE \n", PRINT_ROAMING_CANDIDATE_TABLE));
    320 
    321 	WLAN_OS_REPORT(("        %02d - TRIGGER_ROAMING_LOW_QUALITY_EVENT \n", TRIGGER_ROAMING_LOW_QUALITY_EVENT));
    322 	WLAN_OS_REPORT(("        %02d - TRIGGER_ROAMING_BSS_LOSS_EVENT \n", TRIGGER_ROAMING_BSS_LOSS_EVENT));
    323 	WLAN_OS_REPORT(("        %02d - TRIGGER_ROAMING_SWITCH_CHANNEL_EVENT \n", TRIGGER_ROAMING_SWITCH_CHANNEL_EVENT));
    324 	WLAN_OS_REPORT(("        %02d - TRIGGER_ROAMING_AP_DISCONNECT_EVENT \n", TRIGGER_ROAMING_AP_DISCONNECT_EVENT));
    325 
    326 	WLAN_OS_REPORT(("        %02d - TRIGGER_ROAMING_CONNECT_EVENT \n", TRIGGER_ROAMING_CONNECT_EVENT));
    327 	WLAN_OS_REPORT(("        %02d - TRIGGER_ROAMING_NOT_CONNECTED_EVENT \n", TRIGGER_ROAMING_NOT_CONNECTED_EVENT));
    328 
    329 	WLAN_OS_REPORT(("        %02d - TRIGGER_ROAMING_HANDOVER_SUCCESS_EVENT \n", TRIGGER_ROAMING_HANDOVER_SUCCESS_EVENT));
    330 	WLAN_OS_REPORT(("        %02d - TRIGGER_ROAMING_HANDOVER_FAILURE_EVENT \n", TRIGGER_ROAMING_HANDOVER_FAILURE_EVENT));
    331 
    332 
    333 	WLAN_OS_REPORT(("\n------------------------\n"));
    334 }
    335 
    336 void PrintBssListGotAfterImemediateScan(TI_HANDLE hScanMgr)
    337 {
    338     bssList_t *bssList;
    339     bssEntry_t* pBssEntry;
    340     int i=0;
    341 
    342     WLAN_OS_REPORT(("------ PRINTING BSS FOUND AFTER IMMEDIATE SCAN - MANUAL MODE----------\n"));
    343 
    344     bssList = scanMngr_getBSSList(hScanMgr);
    345 
    346     for (i=0 ; i< bssList->numOfEntries ; i++)
    347     {
    348         pBssEntry = &(bssList->BSSList[i]);
    349 
    350         WLAN_OS_REPORT( ("BSSID: %02x:%02x:%02x:%02x:%02x:%02x, band: %d\n", pBssEntry->BSSID[ 0 ],
    351                          pBssEntry->BSSID[ 1 ], pBssEntry->BSSID[ 2 ],
    352                          pBssEntry->BSSID[ 3 ], pBssEntry->BSSID[ 4 ],
    353                          pBssEntry->BSSID[ 5 ], pBssEntry->band));
    354        WLAN_OS_REPORT( ("channel: %d, beacon interval: %d, average RSSI: %d dBm\n",
    355                                       pBssEntry->channel, pBssEntry->beaconInterval, pBssEntry->RSSI));
    356 
    357     }
    358 
    359     WLAN_OS_REPORT(("-----------------------------------------------------------------------\n"));
    360 
    361 }
    362