/** * \\n * \date 16-November-2005\n * \brief Callback for noise histogram get param call.\n * * Function Scope \e Public.\n * \param hMeasurementSRV - handle to the measurement SRV object.\n * \param status - the get_param call status.\n * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) */ void MacServices_measurementSRV_noiseHistCallBack( TI_HANDLE hMeasurementSRV, TI_STATUS status, TI_UINT8* CB_buf ) { measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; TI_UINT8 index; TI_UINT32 sumOfSamples; TI_INT32 requestIndex; /* setting Off the Waitng for noise histogram Results Bit */ pMeasurementSRV->pendingParamCBs &= ~MSR_SRV_WAITING_NOISE_HIST_RESULTS; /* find the request index */ requestIndex = measurementSRVFindIndexByType( hMeasurementSRV, MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT ); if ( -1 == requestIndex ) { /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ return; } if ( TI_OK == status ) { sumOfSamples = pMeasurementSRV->noiseHistogramResults.numOfLostCycles; /* Print For Debug */ for ( index = 0; index < NUM_OF_NOISE_HISTOGRAM_COUNTERS; index++ ) { sumOfSamples += pMeasurementSRV->noiseHistogramResults.counters[ index ]; /* Print For Debug */ } /* If there weren't enough samples --> Reject the Request */ if ( (sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles) < NOISE_HISTOGRAM_THRESHOLD ) { /* set negative result status */ pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; } else { for (index = 0; index < NUM_OF_NOISE_HISTOGRAM_COUNTERS; index++) { pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ index ] = ( 255 * pMeasurementSRV->noiseHistogramResults.counters[ index ]) / sumOfSamples; } } } else { /* set negative result status */ pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; } /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */ if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) { /* send the event */ measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); } }
/** * \\n * \date 16-November-2005\n * \brief Callback for channel load get param call.\n * * Function Scope \e Public.\n * \param hMeasurementSRV - handle to the measurement SRV object.\n * \param status - the get_param call status.\n * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) */ void MacServices_measurementSRV_channelLoadParamCB( TI_HANDLE hMeasurementSRV, TI_STATUS status, TI_UINT8* CB_buf ) { measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; TI_UINT32 mediumUsageInMs, periodInMs; TI_INT32 requestIndex; /* when this CB is called as a result of the nulify call at the measurement beginning, the handle will be NULL. In this case, nothing needs to be done. */ if ( NULL == hMeasurementSRV ) { return; } /* setting Off the Waitng for Channel Load Results Bit */ pMeasurementSRV->pendingParamCBs &= ~MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS; /* find the request index */ requestIndex = measurementSRVFindIndexByType( hMeasurementSRV, MSR_TYPE_CCA_LOAD_MEASUREMENT ); if ( -1 == requestIndex ) { /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ return; } if ( (TI_OK == status) && (0 != pMeasurementSRV->mediumOccupancyResults.Period)) { /* calculate results */ mediumUsageInMs = pMeasurementSRV->mediumOccupancyResults.MediumUsage / 1000; periodInMs = pMeasurementSRV->mediumOccupancyResults.Period / 1000; if ( periodInMs <= pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration ) { pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.CCABusyFraction = ( 255 * pMeasurementSRV->mediumOccupancyResults.MediumUsage ) / pMeasurementSRV->mediumOccupancyResults.Period; } else { pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.CCABusyFraction = ( 255 * pMeasurementSRV->mediumOccupancyResults.MediumUsage ) / (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration * 1000); } } else { /* mark result status */ pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; } /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */ if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) { /* send the event */ measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); } }
/** * \\n * \date 15-November-2005\n * \brief called when a measurement type timer expires.\n * * Function Scope \e Public.\n * \param hMeasuremntSRV - handle to the measurement SRV object.\n * \param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started.\n */ void MacServices_measurementSRV_requestTimerExpired (TI_HANDLE hMeasurementSRV, TI_BOOL bTwdInitOccured) { measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; TI_INT32 requestIndex; /* find the expired measurement type */ requestIndex = measurementSRVFindMinDuration( hMeasurementSRV ); if ( -1 == requestIndex ) { /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Request timer expired and request index from findMinDuration is -1?!?"); return; } TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": request timer expired, request index: %d.\n", requestIndex); /* mark that the timer is not running and that this request has completed */ pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TI_FALSE; /* collect results and send stop command if necessary */ switch (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType) { case MSR_TYPE_BEACON_MEASUREMENT: measurementSRVHandleBeaconMsrComplete( hMeasurementSRV, requestIndex ); break; case MSR_TYPE_CCA_LOAD_MEASUREMENT: measurementSRVHandleChannelLoadComplete( hMeasurementSRV, requestIndex ); break; case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT: measurementSRVHandleNoiseHistogramComplete( hMeasurementSRV, requestIndex ); break; /* used here to avoid compilation warning only, does nothing */ case MSR_TYPE_BASIC_MEASUREMENT: case MSR_TYPE_FRAME_MEASUREMENT: case MSR_TYPE_MAX_NUM_OF_MEASURE_TYPES: default: TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": measure type %d not supported for request %d\n", pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType, requestIndex); break; } /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */ if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) { /* send the event */ measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); } }
/** * \\n * \brief Handle measurement start success if all measurements * failed send ALL_TYPE_COMPLETE event to stop measure command to the FW.\n * * Function Scope \e Public.\n * \param hMeasurementSrv - handle to the Measurement SRV object.\n * \return always TI_OK.\n */ TI_STATUS measurementSRVSM_startMeasureTypesSuccess( TI_HANDLE hMeasurementSRV ) { measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; /* if no measurement types are running, send 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 * \date 08-November-2005\n * \brief handle AP_DISCOVERY event received from firmware after AP_DISCOVERY_STOP command\n * * Function Scope \e Public.\n * \param hMeasurementSrv - handle to the Measurement SRV object.\n * \return always TI_OK.\n */ TI_STATUS measurementSRVSM_apDiscoveryStopComplete(TI_HANDLE hMeasurementSRV) { measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; TI_UINT32 requestIndex = pMeasurementSRV->uApDiscoveryRequestIndex; /* stop Ap Discovery event timer */ tmr_StopTimer(pMeasurementSRV->hApDiscoveryTimer); pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TI_FALSE; pMeasurementSRV->uApDiscoveryRequestIndex = INVALID_MSR_INDEX; /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */ if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) { /* send the event */ return measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); } return TI_OK; }
/** * \\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 * \date 16-November-2005\n * \brief Callback for noise histogram get param call.\n * * Function Scope \e Public.\n * \param hMeasurementSRV - handle to the measurement SRV object.\n * \param status - the get_param call status.\n * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) */ void MacServices_measurementSRV_noiseHistCallBack( TI_HANDLE hMeasurementSRV, TI_STATUS status, TI_UINT8* CB_buf ) { measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; TI_UINT8 index; TI_UINT32 sumOfSamples; TI_INT32 requestIndex; TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": noise histogram CB called, status: %d\n", status); TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "result address (reported): 0x%x, result address (assumed): 0x%x, results (reported):\n", CB_buf, &(pMeasurementSRV->noiseHistogramResults)); TRACE_INFO_HEX( pMeasurementSRV->hReport, CB_buf, sizeof(TNoiseHistogramResults)); /* setting Off the Waitng for noise histogram Results Bit */ pMeasurementSRV->pendingParamCBs &= ~MSR_SRV_WAITING_NOISE_HIST_RESULTS; /* find the request index */ requestIndex = measurementSRVFindIndexByType( hMeasurementSRV, MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT ); if ( -1 == requestIndex ) { /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request index from measurementSRVFindIndexByType is -1?!?"); return; } if ( TI_OK == status ) { sumOfSamples = pMeasurementSRV->noiseHistogramResults.numOfLostCycles; /* Print For Debug */ TRACE4( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": numOfLostCycles = %d numOfTxHwGenLostCycles = %d numOfRxLostCycles = %d numOfExceedLastThresholdLostCycles = %d\n", pMeasurementSRV->noiseHistogramResults.numOfLostCycles, pMeasurementSRV->noiseHistogramResults.numOfTxHwGenLostCycles, pMeasurementSRV->noiseHistogramResults.numOfRxLostCycles, pMeasurementSRV->noiseHistogramResults.numOfLostCycles - (pMeasurementSRV->noiseHistogramResults.numOfTxHwGenLostCycles + pMeasurementSRV->noiseHistogramResults.numOfRxLostCycles)); for ( index = 0; index < NUM_OF_NOISE_HISTOGRAM_COUNTERS; index++ ) { sumOfSamples += pMeasurementSRV->noiseHistogramResults.counters[ index ]; /* Print For Debug */ TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Counter #%d = %x\n", index, pMeasurementSRV->noiseHistogramResults.counters[index]); } /* If there weren't enough samples --> Reject the Request */ if ( (sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles) < NOISE_HISTOGRAM_THRESHOLD ) { TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_WARNING, ": noise histogram CB, rejecting request because %d samples received.\n", sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles); /* set negative result status */ pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; } else { for (index = 0; index < NUM_OF_NOISE_HISTOGRAM_COUNTERS; index++) { pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ index ] = ( 255 * pMeasurementSRV->noiseHistogramResults.counters[ index ]) / sumOfSamples; } TRACE8( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Valid noise histogram reply. RPIDensity: %d %d %d %d %d %d %d %d\n", pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 0 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 1 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 2 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 3 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 4 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 5 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 6 ], pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.RPIDensity[ 7 ]); } } else { TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_WARNING, ": noise histogram CB with status: %d, rejecting request.\n", status); /* set negative result status */ pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; } /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */ if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) { /* send the event */ measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); } }
/** * \\n * \date 16-November-2005\n * \brief Callback for channel load get param call.\n * * Function Scope \e Public.\n * \param hMeasurementSRV - handle to the measurement SRV object.\n * \param status - the get_param call status.\n * \param CB_buf - pointer to the results buffer (already on the measurement SRV object) */ void MacServices_measurementSRV_channelLoadParamCB( TI_HANDLE hMeasurementSRV, TI_STATUS status, TI_UINT8* CB_buf ) { measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV; TI_UINT32 mediumUsageInMs, periodInMs; TI_INT32 requestIndex; /* when this CB is called as a result of the nulify call at the measurement beginning, the handle will be NULL. In this case, nothing needs to be done. */ if ( NULL == hMeasurementSRV ) { return; } TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Channel load CB called, status:%d\n", status); TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "result address (reported): 0x%x, result address (assumed): 0x%x, results (reported):\n", CB_buf, &(pMeasurementSRV->mediumOccupancyResults)); TRACE_INFO_HEX( pMeasurementSRV->hReport, CB_buf, sizeof(TMediumOccupancy)); /* setting Off the Waitng for Channel Load Results Bit */ pMeasurementSRV->pendingParamCBs &= ~MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS; /* find the request index */ requestIndex = measurementSRVFindIndexByType( hMeasurementSRV, MSR_TYPE_CCA_LOAD_MEASUREMENT ); if ( -1 == requestIndex ) { /* indicates we can't find the request in the requets array. Shouldn't happen, but nothing to do */ TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request index from measurementSRVFindIndexByType is -1?!?"); return; } if ( (TI_OK == status) && (0 != pMeasurementSRV->mediumOccupancyResults.Period)) { /* calculate results */ mediumUsageInMs = pMeasurementSRV->mediumOccupancyResults.MediumUsage / 1000; periodInMs = pMeasurementSRV->mediumOccupancyResults.Period / 1000; TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": MediumUsage = %d Period = %d\n",mediumUsageInMs, periodInMs); if ( periodInMs <= pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration ) { pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.CCABusyFraction = ( 255 * pMeasurementSRV->mediumOccupancyResults.MediumUsage ) / pMeasurementSRV->mediumOccupancyResults.Period; } else { pMeasurementSRV->msrReply.msrTypes[ requestIndex ].replyValue.CCABusyFraction = ( 255 * pMeasurementSRV->mediumOccupancyResults.MediumUsage ) / (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration * 1000); } } else { TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": channel load failed. Status=%d, period=%d\n", status, pMeasurementSRV->mediumOccupancyResults.Period); /* mark result status */ pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = TI_NOK; } /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */ if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV )) { /* send the event */ measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_ALL_TYPES_COMPLETE ); } }