/** * \\n * \date 08-November-2005\n * \brief Handle a START_SUCCESS event by starting different measure types and setting timers.\n * * Function Scope \e Public.\n * \param hMeasurementSrv - handle to the Measurement SRV object.\n * \return always TI_OK.\n */ TI_STATUS measurementSRVSM_startMeasureTypes( TI_HANDLE hMeasurementSRV ) { measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; TI_UINT8 requestIndex, rangeIndex; TI_INT8 rangeUpperBound; TTwdParamInfo tTwdParam; TI_STATUS status; TNoiseHistogram pNoiseHistParams; TApDiscoveryParams pApDiscoveryParams; TI_UINT32 currentTime = os_timeStampMs( pMeasurementSRV->hOS ); /* check if request time has expired (note: timer wrap-around is also handled)*/ if ( (pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs) < currentTime ) { TI_INT32 i; TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request time has expired, request expiry time:%d, current time:%d\n", pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs, currentTime); /* mark that all measurement types has failed */ for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ ) { pMeasurementSRV->msrReply.msrTypes[ i ].status = MSR_REJECT_MAX_DELAY_PASSED; } /* send a measurement complete event */ measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); return TI_OK; } /* Going over all request types that should be executed in parallel to start their timers and execute the measurement */ for ( requestIndex = 0; requestIndex < pMeasurementSRV->msrRequest.numberOfTypes ; requestIndex++ ) { switch (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType) { case MSR_TYPE_CCA_LOAD_MEASUREMENT: /* Clearing the Medium Occupancy Register */ tTwdParam.paramType = TWD_MEDIUM_OCCUPANCY_PARAM_ID; tTwdParam.content.interogateCmdCBParams.fCb = (void *)MacServices_measurementSRV_dummyChannelLoadParamCB; tTwdParam.content.interogateCmdCBParams.hCb = hMeasurementSRV; tTwdParam.content.interogateCmdCBParams.pCb = (TI_UINT8*)&pMeasurementSRV->mediumOccupancyResults; status = cmdBld_GetParam (pMeasurementSRV->hCmdBld, &tTwdParam); if ( TI_OK == status ) { TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Medium Usage has been nullified, starting timer.\n"); /* Start Timer */ tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex], MacServices_measurementSRV_requestTimerExpired, (TI_HANDLE)pMeasurementSRV, pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration, TI_FALSE); pMeasurementSRV->bRequestTimerRunning[requestIndex] = TI_TRUE; } else { TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_GetParam (for channel load) returned status %d\n", status); } break; case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT: /* Set Noise Histogram Cmd Params */ pNoiseHistParams.cmd = START_NOISE_HIST; pNoiseHistParams.sampleInterval = DEF_SAMPLE_INTERVAL; os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[0]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES ); /* Set Ranges */ /* (-87) - First Range's Upper Bound */ rangeUpperBound = -87; /* Previously we converted from RxLevel to dBm - now this isn't necessary */ /* rangeUpperBound = TWD_convertRSSIToRxLevel( pMeasurementSRV->hTWD, -87); */ for (rangeIndex = 0; rangeIndex < MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES -1; rangeIndex++) { if (rangeUpperBound > 0) { pNoiseHistParams.ranges[rangeIndex] = 0; } else { pNoiseHistParams.ranges[rangeIndex] = rangeUpperBound; } rangeUpperBound += 5; } pNoiseHistParams.ranges[rangeIndex] = 0xFE; /* Print for Debug */ TRACE8(pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ":Noise histogram Measurement Ranges:\n%d %d %d %d %d %d %d %d\n", (TI_INT8) pNoiseHistParams.ranges[0], (TI_INT8) pNoiseHistParams.ranges[1], (TI_INT8) pNoiseHistParams.ranges[2], (TI_INT8) pNoiseHistParams.ranges[3], (TI_INT8) pNoiseHistParams.ranges[4], (TI_INT8) pNoiseHistParams.ranges[5], (TI_INT8) pNoiseHistParams.ranges[6], (TI_INT8) pNoiseHistParams.ranges[7]); /* Send a Start command to the FW */ status = cmdBld_CmdNoiseHistogram (pMeasurementSRV->hCmdBld, &pNoiseHistParams, NULL, NULL); if ( TI_OK == status ) { /* Print for Debug */ TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Sent noise histogram command. Starting timer\n"); /* Start Timer */ tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex], MacServices_measurementSRV_requestTimerExpired, (TI_HANDLE)pMeasurementSRV, pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration, TI_FALSE); pMeasurementSRV->bRequestTimerRunning[requestIndex] = TI_TRUE; } else { TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_NoiseHistogramCmd returned status %d\n", status); } break; case MSR_TYPE_BEACON_MEASUREMENT: /* set all parameters in the AP discovery command */ pApDiscoveryParams.scanDuration = pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration * 1000; pApDiscoveryParams.numOfProbRqst = 1; pApDiscoveryParams.txdRateSet = HW_BIT_RATE_1MBPS; pApDiscoveryParams.ConfigOptions = RX_CONFIG_OPTION_FOR_MEASUREMENT; pApDiscoveryParams.FilterOptions = RX_FILTER_OPTION_DEF_PRSP_BCN; pApDiscoveryParams.txPowerDbm = pMeasurementSRV->msrRequest.txPowerDbm; pApDiscoveryParams.scanOptions = SCAN_ACTIVE; /* both scan type and band are 0 for active and */ /* 2.4 GHz, respectively, but 2.4 is not defined */ /* band determined at the initiate measurement command not at that structure */ /* scan mode go into the scan option field */ if ( MSR_SCAN_MODE_PASSIVE == pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].scanMode ) { pApDiscoveryParams.scanOptions |= SCAN_PASSIVE; } /* Send AP Discovery command */ status = cmdBld_CmdApDiscovery (pMeasurementSRV->hCmdBld, &pApDiscoveryParams, NULL, NULL); if ( TI_OK == status ) { TRACE7( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": AP discovery command sent. Params:\n scanDuration=%d, scanOptions=%d, numOfProbRqst=%d, txdRateSet=%d, txPowerDbm=%d, configOptions=%d, filterOptions=%d\n Starting timer...\n", pApDiscoveryParams.scanDuration, pApDiscoveryParams.scanOptions, pApDiscoveryParams.numOfProbRqst, pApDiscoveryParams.txdRateSet, pApDiscoveryParams.txPowerDbm, pApDiscoveryParams.ConfigOptions, pApDiscoveryParams.FilterOptions); /* Start Timer */ tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex], MacServices_measurementSRV_requestTimerExpired, (TI_HANDLE)pMeasurementSRV, pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration, TI_FALSE); pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TI_TRUE; } else { TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_ApDiscoveryCmd returned status %d\n", status); } break; case MSR_TYPE_BASIC_MEASUREMENT: /* not supported in current implemntation */ case MSR_TYPE_FRAME_MEASUREMENT: /* not supported in current implemntation */ default: TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Measurement type %d is not supported\n", pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType); break; } } /* if no measurement types are running, sen al types complete event. This can happen if all types failed to start */ if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) { /* send the event */ measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); } return TI_OK; }
/** * \\n * \brief Handle ap discovery measurement start request * * Function Scope \e Public.\n * \param hMeasurementSrv - handle to the Measurement SRV object.\n * \return always TI_OK.\n */ TI_STATUS measurementSRVSM_waitApDiscovery(TI_HANDLE hMeasurementSRV) { measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; TApDiscoveryParams pApDiscoveryParams; TI_UINT32 i = 0; TI_UINT32 requestIndex = pMeasurementSRV->uApDiscoveryRequestIndex; TI_STATUS status; /* set all parameters in the AP discovery command */ pApDiscoveryParams.txdRateSetBandBG = HW_BIT_RATE_1MBPS; pApDiscoveryParams.txdRateSetBandA = HW_BIT_RATE_6MBPS; pApDiscoveryParams.ConfigOptions = RX_CONFIG_OPTION_FOR_MEASUREMENT; pApDiscoveryParams.FilterOptions = RX_FILTER_OPTION_DEF_PRSP_BCN; pApDiscoveryParams.scanOptions = 0; pApDiscoveryParams.ssid.len = pMeasurementSRV->msrRequest.msrTypes[requestIndex].ssid.len; os_memoryCopy(pMeasurementSRV->hOS, pApDiscoveryParams.ssid.str, pMeasurementSRV->msrRequest.msrTypes[requestIndex].ssid.str, pMeasurementSRV->msrRequest.msrTypes[requestIndex].ssid.len); pApDiscoveryParams.scanDuration = pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration*1000; if (MSR_TYPE_RRM_BEACON_MEASUREMENT == pMeasurementSRV->msrRequest.msrTypes[requestIndex].msrType) { pApDiscoveryParams.numOfProbRqst = 3; pApDiscoveryParams.ConfigOptions = RX_CONFIG_OPTION_FOR_SCAN; } else /* MSR_TYPE_kkk_BEACON_MEASUREMENT */ { pApDiscoveryParams.numOfProbRqst = 1; } for ( i = 0; i < pMeasurementSRV->msrRequest.msrTypes[requestIndex].channelListBandBG.uActualNumOfChannels; i++ ) { pApDiscoveryParams.channelListBandBG.channelList[i] = pMeasurementSRV->msrRequest.msrTypes[requestIndex].channelListBandBG.channelList[i]; pApDiscoveryParams.channelListBandBG.txPowerDbm[i] = pMeasurementSRV->msrRequest.msrTypes[requestIndex].channelListBandBG.txPowerDbm[i]; } pApDiscoveryParams.channelListBandBG.uActualNumOfChannels = i; for ( i = 0; i < pMeasurementSRV->msrRequest.msrTypes[requestIndex].channelListBandA.uActualNumOfChannels; i++ ) { pApDiscoveryParams.channelListBandA.channelList[i] = pMeasurementSRV->msrRequest.msrTypes[requestIndex].channelListBandA.channelList[i]; pApDiscoveryParams.channelListBandA.txPowerDbm[i] = pMeasurementSRV->msrRequest.msrTypes[requestIndex].channelListBandA.txPowerDbm[i]; } pApDiscoveryParams.channelListBandA.uActualNumOfChannels = i; /* band determined at the initiate measurement command not at that structure */ /* scan mode go into the scan option field */ if ( MSR_SCAN_MODE_PASSIVE == pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].scanMode ) { pApDiscoveryParams.scanOptions |= SCAN_PASSIVE; } /* Send AP Discovery command */ status = cmdBld_CmdApDiscovery (pMeasurementSRV->hCmdBld, &pApDiscoveryParams, NULL, NULL); if ( TI_OK != status ) { tmr_StartTimer(pMeasurementSRV->hApDiscoveryTimer, MacServices_measurementSRV_startStopTimerExpired, hMeasurementSRV, MSR_FW_GUARD_TIME_START, TI_FALSE); } else { TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_ApDiscoveryCmd returned status %d\n", status); } return TI_OK; }