/** * \\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 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 ); } }