0
|
1 |
/*
|
|
2 |
* MeasurementSrvSM.c
|
|
3 |
*
|
|
4 |
* Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
7 |
* This program and the accompanying materials are made available under the
|
|
8 |
* terms of the Eclipse Public License v1.0 or BSD License which accompanies
|
|
9 |
* this distribution. The Eclipse Public License is available at
|
|
10 |
* http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.
|
|
11 |
*
|
|
12 |
* Redistribution and use in source and binary forms, with or without
|
|
13 |
* modification, are permitted provided that the following conditions
|
|
14 |
* are met:
|
|
15 |
*
|
|
16 |
* * Redistributions of source code must retain the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer.
|
|
18 |
* * Redistributions in binary form must reproduce the above copyright
|
|
19 |
* notice, this list of conditions and the following disclaimer in
|
|
20 |
* the documentation and/or other materials provided with the
|
|
21 |
* distribution.
|
|
22 |
* * Neither the name Texas Instruments nor the names of its
|
|
23 |
* contributors may be used to endorse or promote products derived
|
|
24 |
* from this software without specific prior written permission.
|
|
25 |
*
|
|
26 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
27 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
28 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
29 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
30 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
31 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
32 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
33 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
34 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
36 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37 |
*/
|
|
38 |
|
|
39 |
/** \file measurementSrv.c
|
|
40 |
* \brief This file include the measurement SRV state machine implementation.
|
|
41 |
* \author Ronen Kalish
|
|
42 |
* \date 13-November-2005
|
|
43 |
*/
|
|
44 |
|
|
45 |
#define __FILE_ID__ FILE_ID_112
|
|
46 |
#include "osApi.h"
|
|
47 |
#include "report.h"
|
|
48 |
#include "MeasurementSrvSM.h"
|
|
49 |
#include "MeasurementSrv.h"
|
|
50 |
#include "PowerSrv_API.h"
|
|
51 |
#include "timer.h"
|
|
52 |
#include "fsm.h"
|
|
53 |
#include "TWDriverInternal.h"
|
|
54 |
#include "CmdBld.h"
|
|
55 |
|
|
56 |
|
|
57 |
TI_STATUS actionUnexpected( TI_HANDLE hMeasurementSrv );
|
|
58 |
TI_STATUS actionNop( TI_HANDLE hMeasurementSrv );
|
|
59 |
static void measurementSRVSM_requestMeasureStartResponseCB(TI_HANDLE hMeasurementSRV, TI_UINT16 uMboxStatus);
|
|
60 |
|
|
61 |
|
|
62 |
/**
|
|
63 |
* \author Ronen Kalish\n
|
|
64 |
* \date 08-November-2005\n
|
|
65 |
* \brief Initialize the measurement SRV SM.\n
|
|
66 |
*
|
|
67 |
* Function Scope \e Public.\n
|
|
68 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
69 |
* \return TI_OK if successful, TI_NOK otherwise.\n
|
|
70 |
*/
|
|
71 |
TI_STATUS measurementSRVSM_init( TI_HANDLE hMeasurementSRV )
|
|
72 |
{
|
|
73 |
measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
74 |
|
|
75 |
fsm_actionCell_t smMatrix[ MSR_SRV_NUM_OF_STATES ][ MSR_SRV_NUM_OF_EVENTS ] =
|
|
76 |
{
|
|
77 |
/* next state and actions for IDLE state */
|
|
78 |
{
|
|
79 |
{MSR_SRV_STATE_WAIT_FOR_DRIVER_MODE, measurementSRVSM_requestDriverMode}, /*"MESSURE_START_REQUEST"*/
|
|
80 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/
|
|
81 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/
|
|
82 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/
|
|
83 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/
|
|
84 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/
|
|
85 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/
|
|
86 |
{MSR_SRV_STATE_IDLE, measurementSRVSRVSM_dummyStop} /*"MEASURE_STOP_REQUEST"*/
|
|
87 |
},
|
|
88 |
|
|
89 |
|
|
90 |
/* next state and actions for WAIT_FOR_DRIVER_MODE state */
|
|
91 |
{
|
|
92 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/
|
|
93 |
{MSR_SRV_STATE_WAIT_FOR_MEASURE_START, measurementSRVSM_requestMeasureStart}, /*"DRIVER_MODE_SUCCESS"*/
|
|
94 |
{MSR_SRV_STATE_IDLE, measurementSRVSM_DriverModeFailure}, /*"DRIVER_MODE_FAILURE"*/
|
|
95 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/
|
|
96 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/
|
|
97 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/
|
|
98 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/
|
|
99 |
{MSR_SRV_STATE_IDLE, measurementSRVSM_stopFromWaitForDriverMode} /*"MEASURE_STOP_REQUEST"*/
|
|
100 |
},
|
|
101 |
|
|
102 |
/* next state and actions for WAIT_FOR_MEASURE_START state */
|
|
103 |
{
|
|
104 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/
|
|
105 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/
|
|
106 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/
|
|
107 |
{MSR_SRV_STATE_MEASURE_IN_PROGRESS, measurementSRVSM_startMeasureTypes}, /*"START_SUCCESS"*/
|
|
108 |
{MSR_SRV_STATE_IDLE, measurementSRVSM_measureStartFailure}, /*"START_FAILURE"*/
|
|
109 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/
|
|
110 |
{MSR_SRV_STATE_IDLE, measurementSRVSM_completeMeasure}, /*"STOP_COMPLETE"*/
|
|
111 |
{MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_stopFromWaitForMeasureStart}
|
|
112 |
/*"MEASURE_STOP_REQUEST"*/
|
|
113 |
},
|
|
114 |
|
|
115 |
/* next state and actions for MEASURE_IN_PROGRESS state */
|
|
116 |
{
|
|
117 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/
|
|
118 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/
|
|
119 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/
|
|
120 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/
|
|
121 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/
|
|
122 |
{MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_requestMeasureStop}, /*"ALL_TYPES_COMPLETE"*/
|
|
123 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"STOP_COMPLETE"*/
|
|
124 |
{MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSM_stopFromMeasureInProgress}
|
|
125 |
/*"MEASURE_STOP_REQUEST"*/
|
|
126 |
},
|
|
127 |
|
|
128 |
/* next state and actions for WAIT_FOR_MEASURE_STOP state */
|
|
129 |
{
|
|
130 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"MESSURE_START_REQUEST"*/
|
|
131 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_SUCCESS"*/
|
|
132 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"DRIVER_MODE_FAILURE"*/
|
|
133 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_SUCCESS"*/
|
|
134 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"START_FAILURE"*/
|
|
135 |
{MSR_SRV_STATE_IDLE, actionUnexpected}, /*"ALL_TYPES_COMPLETE"*/
|
|
136 |
{MSR_SRV_STATE_IDLE, measurementSRVSM_completeMeasure}, /*"STOP_COMPLETE"*/
|
|
137 |
{MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP, measurementSRVSRVSM_dummyStop} /*"MEASURE_STOP_REQUEST"*/
|
|
138 |
}
|
|
139 |
};
|
|
140 |
|
|
141 |
/* initialize current state */
|
|
142 |
pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE;
|
|
143 |
|
|
144 |
/* configure the state machine */
|
|
145 |
return fsm_Config( pMeasurementSRV->SM, (fsm_Matrix_t)smMatrix,
|
|
146 |
(TI_UINT8)MSR_SRV_NUM_OF_STATES, (TI_UINT8)MSR_SRV_NUM_OF_EVENTS,
|
|
147 |
(fsm_eventActivation_t)measurementSRVSM_SMEvent, pMeasurementSRV->hOS );
|
|
148 |
}
|
|
149 |
|
|
150 |
/**
|
|
151 |
* \author Ronen Kalish\n
|
|
152 |
* \date 08-November-2005\n
|
|
153 |
* \brief Processes an event.\n
|
|
154 |
*
|
|
155 |
* Function Scope \e Public.\n
|
|
156 |
* \param hMeasurementSrv - handle to the measurement SRV object.\n
|
|
157 |
* \param currentState - the current scan SRV SM state.\n
|
|
158 |
* \param event - the event to handle.\n
|
|
159 |
* \return TI_OK if successful, TI_NOK otherwise.\n
|
|
160 |
*/
|
|
161 |
TI_STATUS measurementSRVSM_SMEvent( TI_HANDLE hMeasurementSrv, measurements_SRVSMStates_e* currentState,
|
|
162 |
measurement_SRVSMEvents_e event )
|
|
163 |
{
|
|
164 |
measurementSRV_t *pMeasurementSRV = (measurementSRV_t *)hMeasurementSrv;
|
|
165 |
TI_STATUS status = TI_OK;
|
|
166 |
TI_UINT8 nextState;
|
|
167 |
|
|
168 |
/* obtain the next state */
|
|
169 |
status = fsm_GetNextState( pMeasurementSRV->SM, (TI_UINT8)*currentState, (TI_UINT8)event, &nextState );
|
|
170 |
if ( status != TI_OK )
|
|
171 |
{
|
|
172 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "measurementSRVSM_SMEvent: State machine error, failed getting next state\n");
|
|
173 |
return TI_NOK;
|
|
174 |
}
|
|
175 |
|
|
176 |
/* report the move */
|
|
177 |
TRACE3( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "measurementSRVSM_SMEvent: <currentState = %d, event = %d> --> nextState = %d\n", currentState, event, nextState);
|
|
178 |
|
|
179 |
/* move */
|
|
180 |
return fsm_Event( pMeasurementSRV->SM, (TI_UINT8*)currentState, (TI_UINT8)event, hMeasurementSrv );
|
|
181 |
}
|
|
182 |
|
|
183 |
/**
|
|
184 |
* \author Ronen Kalish\n
|
|
185 |
* \date 08-November-2005\n
|
|
186 |
* \brief Handle a MEASURE_START_REQUEST event by requesting driver mode.\n
|
|
187 |
*
|
|
188 |
* Function Scope \e Public.\n
|
|
189 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
190 |
* \return always TI_OK.\n
|
|
191 |
*/
|
|
192 |
TI_STATUS measurementSRVSM_requestDriverMode( TI_HANDLE hMeasurementSRV )
|
|
193 |
{
|
|
194 |
measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
195 |
TI_STATUS PSStatus;
|
|
196 |
TTwdParamInfo paramInfo;
|
|
197 |
|
|
198 |
/* get the current channel */
|
|
199 |
paramInfo.paramType = TWD_CURRENT_CHANNEL_PARAM_ID;
|
|
200 |
cmdBld_GetParam (pMeasurementSRV->hCmdBld, ¶mInfo);
|
|
201 |
|
|
202 |
/* check if the request is on the serving channel */
|
|
203 |
if ( paramInfo.content.halCtrlCurrentChannel == pMeasurementSRV->msrRequest.channel )
|
|
204 |
{
|
|
205 |
/* Switch Power Save SRV to driver mode w/o changing power save mode*/
|
|
206 |
PSStatus = powerSrv_ReservePS( pMeasurementSRV->hPowerSaveSRV, POWER_SAVE_KEEP_CURRENT,
|
|
207 |
TI_TRUE, hMeasurementSRV, MacServices_measurementSRV_powerSaveCB );
|
|
208 |
}
|
|
209 |
else
|
|
210 |
{
|
|
211 |
/* Switch Power Save SRV to driver mode with PS mode */
|
|
212 |
PSStatus = powerSrv_ReservePS( pMeasurementSRV->hPowerSaveSRV, POWER_SAVE_ON,
|
|
213 |
TI_TRUE, hMeasurementSRV, MacServices_measurementSRV_powerSaveCB );
|
|
214 |
}
|
|
215 |
|
|
216 |
switch (PSStatus)
|
|
217 |
{
|
|
218 |
case POWER_SAVE_802_11_IS_CURRENT:
|
|
219 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Driver mode entered successfully\n");
|
|
220 |
/* send a power save success event */
|
|
221 |
return measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
|
|
222 |
MSR_SRV_EVENT_DRIVER_MODE_SUCCESS );
|
|
223 |
|
|
224 |
case POWER_SAVE_802_11_PENDING:
|
|
225 |
case TI_OK:
|
|
226 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Driver mode pending\n");
|
|
227 |
break;
|
|
228 |
|
|
229 |
default: /* Error */
|
|
230 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Error %d when requesting driver mode\n",PSStatus);
|
|
231 |
|
|
232 |
/* Set the return status to TI_NOK */
|
|
233 |
pMeasurementSRV->returnStatus = PSStatus;
|
|
234 |
|
|
235 |
/* send a power save failure event */
|
|
236 |
measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
|
|
237 |
MSR_SRV_EVENT_DRIVER_MODE_FAILURE );
|
|
238 |
break;
|
|
239 |
}
|
|
240 |
|
|
241 |
return TI_OK;
|
|
242 |
}
|
|
243 |
|
|
244 |
/**
|
|
245 |
* \author Ronen Kalish\n
|
|
246 |
* \date 08-November-2005\n
|
|
247 |
* \brief Handle a DRIVER_MODE_SUCCESS event by sending start measure command to the FW.\n
|
|
248 |
*
|
|
249 |
* Function Scope \e Public.\n
|
|
250 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
251 |
* \return always TI_OK.\n
|
|
252 |
*/
|
|
253 |
TI_STATUS measurementSRVSM_requestMeasureStart( TI_HANDLE hMeasurementSRV )
|
|
254 |
{
|
|
255 |
measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
256 |
TMeasurementParams pMeasurementCmd;
|
|
257 |
TI_STATUS status;
|
|
258 |
TI_UINT32 currentTime = os_timeStampMs( pMeasurementSRV->hOS );
|
|
259 |
|
|
260 |
/* check if request time has expired (note: timer wrap-around is also handled)*/
|
|
261 |
if ( (pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs)
|
|
262 |
< currentTime )
|
|
263 |
{
|
|
264 |
TI_INT32 i;
|
|
265 |
|
|
266 |
TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request time has expired, request expiry time:%d, current time:%d\n", pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs, currentTime);
|
|
267 |
|
|
268 |
/* mark that all measurement types has failed */
|
|
269 |
for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
|
|
270 |
{
|
|
271 |
pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK;
|
|
272 |
}
|
|
273 |
|
|
274 |
/* send a measurement complete event */
|
|
275 |
measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
|
|
276 |
MSR_SRV_EVENT_STOP_COMPLETE );
|
|
277 |
|
|
278 |
return TI_OK;
|
|
279 |
}
|
|
280 |
|
|
281 |
pMeasurementCmd.channel = pMeasurementSRV->msrRequest.channel;
|
|
282 |
pMeasurementCmd.band = pMeasurementSRV->msrRequest.band;
|
|
283 |
pMeasurementCmd.duration = 0; /* Infinite */
|
|
284 |
pMeasurementCmd.eTag = pMeasurementSRV->msrRequest.eTag;
|
|
285 |
|
|
286 |
if ( measurementSRVIsBeaconMeasureIncluded( hMeasurementSRV ))
|
|
287 |
{ /* Beacon Measurement is one of the types */
|
|
288 |
|
|
289 |
/* get the current channel */
|
|
290 |
TTwdParamInfo paramInfo;
|
|
291 |
|
|
292 |
paramInfo.paramType = TWD_CURRENT_CHANNEL_PARAM_ID;
|
|
293 |
cmdBld_GetParam (pMeasurementSRV->hCmdBld, ¶mInfo);
|
|
294 |
|
|
295 |
pMeasurementCmd.ConfigOptions = RX_CONFIG_OPTION_FOR_MEASUREMENT;
|
|
296 |
|
|
297 |
/* check if the request is on the serving channel */
|
|
298 |
if ( paramInfo.content.halCtrlCurrentChannel == pMeasurementSRV->msrRequest.channel )
|
|
299 |
{
|
|
300 |
/* Set the RX Filter to the join one, so that any packets will
|
|
301 |
be received on the serving channel - beacons and probe requests for
|
|
302 |
the measurmenet, and also data (for normal operation) */
|
|
303 |
pMeasurementCmd.FilterOptions = RX_FILTER_OPTION_JOIN;
|
|
304 |
}
|
|
305 |
else
|
|
306 |
{
|
|
307 |
/* not on the serving channle - only beacons and rpobe responses are required */
|
|
308 |
pMeasurementCmd.FilterOptions = RX_FILTER_OPTION_DEF_PRSP_BCN;
|
|
309 |
}
|
|
310 |
}
|
|
311 |
else
|
|
312 |
{ /* No beacon measurement - use the current RX Filter */
|
|
313 |
pMeasurementCmd.ConfigOptions = 0xffffffff;
|
|
314 |
pMeasurementCmd.FilterOptions = 0xffffffff;
|
|
315 |
}
|
|
316 |
|
|
317 |
/* Send start measurement command */
|
|
318 |
status = cmdBld_CmdMeasurement (pMeasurementSRV->hCmdBld,
|
|
319 |
&pMeasurementCmd,
|
|
320 |
(void *)measurementSRVSM_requestMeasureStartResponseCB,
|
|
321 |
pMeasurementSRV);
|
|
322 |
|
|
323 |
if ( TI_OK != status )
|
|
324 |
{
|
|
325 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Failed to send measurement start command, statud=%d,\n", status);
|
|
326 |
|
|
327 |
/* keep the faulty return status */
|
|
328 |
pMeasurementSRV->returnStatus = status;
|
|
329 |
|
|
330 |
/* send a measurement start fail event */
|
|
331 |
return measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
|
|
332 |
MSR_SRV_EVENT_START_FAILURE );
|
|
333 |
}
|
|
334 |
|
|
335 |
TRACE6( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure start command sent. Params:\n channel=%d, band=%d, duration=%d, \n configOptions=0x%x, filterOptions=0x%x, status=%d, \n", pMeasurementCmd.channel, pMeasurementCmd.band, pMeasurementCmd.duration, pMeasurementCmd.ConfigOptions, pMeasurementCmd.FilterOptions, status);
|
|
336 |
|
|
337 |
/* start the FW guard timer */
|
|
338 |
pMeasurementSRV->bStartStopTimerRunning = TI_TRUE;
|
|
339 |
tmr_StartTimer (pMeasurementSRV->hStartStopTimer,
|
|
340 |
MacServices_measurementSRV_startStopTimerExpired,
|
|
341 |
(TI_HANDLE)pMeasurementSRV,
|
|
342 |
MSR_FW_GUARD_TIME,
|
|
343 |
TI_FALSE);
|
|
344 |
|
|
345 |
return TI_OK;
|
|
346 |
}
|
|
347 |
|
|
348 |
/**
|
|
349 |
* \author Ronen Kalish\n
|
|
350 |
* \date 08-November-2005\n
|
|
351 |
* \brief Handle a START_SUCCESS event by starting different measure types and setting timers.\n
|
|
352 |
*
|
|
353 |
* Function Scope \e Public.\n
|
|
354 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
355 |
* \return always TI_OK.\n
|
|
356 |
*/
|
|
357 |
TI_STATUS measurementSRVSM_startMeasureTypes( TI_HANDLE hMeasurementSRV )
|
|
358 |
{
|
|
359 |
measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
360 |
TI_UINT8 requestIndex, rangeIndex;
|
|
361 |
TI_INT8 rangeUpperBound;
|
|
362 |
TTwdParamInfo tTwdParam;
|
|
363 |
TI_STATUS status;
|
|
364 |
TNoiseHistogram pNoiseHistParams;
|
|
365 |
TApDiscoveryParams pApDiscoveryParams;
|
|
366 |
TI_UINT32 currentTime = os_timeStampMs( pMeasurementSRV->hOS );
|
|
367 |
|
|
368 |
/* check if request time has expired (note: timer wrap-around is also handled)*/
|
|
369 |
if ( (pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs)
|
|
370 |
< currentTime )
|
|
371 |
{
|
|
372 |
TI_INT32 i;
|
|
373 |
|
|
374 |
TRACE2( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": request time has expired, request expiry time:%d, current time:%d\n", pMeasurementSRV->requestRecptionTimeStampMs + pMeasurementSRV->timeToRequestExpiryMs, currentTime);
|
|
375 |
|
|
376 |
/* mark that all measurement types has failed */
|
|
377 |
for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
|
|
378 |
{
|
|
379 |
pMeasurementSRV->msrReply.msrTypes[ i ].status = MSR_REJECT_MAX_DELAY_PASSED;
|
|
380 |
}
|
|
381 |
|
|
382 |
/* send a measurement complete event */
|
|
383 |
measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
|
|
384 |
MSR_SRV_EVENT_ALL_TYPES_COMPLETE );
|
|
385 |
|
|
386 |
return TI_OK;
|
|
387 |
}
|
|
388 |
|
|
389 |
/* Going over all request types that should be executed in parallel
|
|
390 |
to start their timers and execute the measurement */
|
|
391 |
for ( requestIndex = 0; requestIndex < pMeasurementSRV->msrRequest.numberOfTypes ; requestIndex++ )
|
|
392 |
{
|
|
393 |
switch (pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType)
|
|
394 |
{
|
|
395 |
case MSR_TYPE_CCA_LOAD_MEASUREMENT:
|
|
396 |
/* Clearing the Medium Occupancy Register */
|
|
397 |
tTwdParam.paramType = TWD_MEDIUM_OCCUPANCY_PARAM_ID;
|
|
398 |
tTwdParam.content.interogateCmdCBParams.fCb = (void *)MacServices_measurementSRV_dummyChannelLoadParamCB;
|
|
399 |
tTwdParam.content.interogateCmdCBParams.hCb = hMeasurementSRV;
|
|
400 |
tTwdParam.content.interogateCmdCBParams.pCb =
|
|
401 |
(TI_UINT8*)&pMeasurementSRV->mediumOccupancyResults;
|
|
402 |
status = cmdBld_GetParam (pMeasurementSRV->hCmdBld, &tTwdParam);
|
|
403 |
if( TI_OK == status )
|
|
404 |
{
|
|
405 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Medium Usage has been nullified, starting timer.\n");
|
|
406 |
|
|
407 |
/* Start Timer */
|
|
408 |
tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex],
|
|
409 |
MacServices_measurementSRV_requestTimerExpired,
|
|
410 |
(TI_HANDLE)pMeasurementSRV,
|
|
411 |
pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration,
|
|
412 |
TI_FALSE);
|
|
413 |
pMeasurementSRV->bRequestTimerRunning[requestIndex] = TI_TRUE;
|
|
414 |
}
|
|
415 |
else
|
|
416 |
{
|
|
417 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_GetParam (for channel load) returned status %d\n", status);
|
|
418 |
}
|
|
419 |
|
|
420 |
break;
|
|
421 |
|
|
422 |
case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT:
|
|
423 |
/* Set Noise Histogram Cmd Params */
|
|
424 |
pNoiseHistParams.cmd = START_NOISE_HIST;
|
|
425 |
pNoiseHistParams.sampleInterval = DEF_SAMPLE_INTERVAL;
|
|
426 |
os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[0]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES );
|
|
427 |
|
|
428 |
/* Set Ranges */
|
|
429 |
/* (-87) - First Range's Upper Bound */
|
|
430 |
rangeUpperBound = -87;
|
|
431 |
|
|
432 |
/* Previously we converted from RxLevel to dBm - now this isn't necessary */
|
|
433 |
/* rangeUpperBound = TWD_convertRSSIToRxLevel( pMeasurementSRV->hTWD, -87); */
|
|
434 |
|
|
435 |
for(rangeIndex = 0; rangeIndex < MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES -1; rangeIndex++)
|
|
436 |
{
|
|
437 |
if(rangeUpperBound > 0)
|
|
438 |
{
|
|
439 |
pNoiseHistParams.ranges[rangeIndex] = 0;
|
|
440 |
}
|
|
441 |
else
|
|
442 |
{
|
|
443 |
pNoiseHistParams.ranges[rangeIndex] = rangeUpperBound;
|
|
444 |
}
|
|
445 |
rangeUpperBound += 5;
|
|
446 |
}
|
|
447 |
pNoiseHistParams.ranges[rangeIndex] = 0xFE;
|
|
448 |
|
|
449 |
/* Print for Debug */
|
|
450 |
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]);
|
|
451 |
|
|
452 |
/* Send a Start command to the FW */
|
|
453 |
status = cmdBld_CmdNoiseHistogram (pMeasurementSRV->hCmdBld, &pNoiseHistParams, NULL, NULL);
|
|
454 |
|
|
455 |
if ( TI_OK == status )
|
|
456 |
{
|
|
457 |
/* Print for Debug */
|
|
458 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": Sent noise histogram command. Starting timer\n");
|
|
459 |
|
|
460 |
/* Start Timer */
|
|
461 |
tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex],
|
|
462 |
MacServices_measurementSRV_requestTimerExpired,
|
|
463 |
(TI_HANDLE)pMeasurementSRV,
|
|
464 |
pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration,
|
|
465 |
TI_FALSE);
|
|
466 |
pMeasurementSRV->bRequestTimerRunning[requestIndex] = TI_TRUE;
|
|
467 |
}
|
|
468 |
else
|
|
469 |
{
|
|
470 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_NoiseHistogramCmd returned status %d\n", status);
|
|
471 |
}
|
|
472 |
break;
|
|
473 |
|
|
474 |
case MSR_TYPE_BEACON_MEASUREMENT:
|
|
475 |
/* set all parameters in the AP discovery command */
|
|
476 |
pApDiscoveryParams.scanDuration = pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration * 1000;
|
|
477 |
pApDiscoveryParams.numOfProbRqst = 1;
|
|
478 |
pApDiscoveryParams.txdRateSet = HW_BIT_RATE_1MBPS;
|
|
479 |
pApDiscoveryParams.ConfigOptions = RX_CONFIG_OPTION_FOR_MEASUREMENT;
|
|
480 |
pApDiscoveryParams.FilterOptions = RX_FILTER_OPTION_DEF_PRSP_BCN;
|
|
481 |
pApDiscoveryParams.txPowerDbm = pMeasurementSRV->msrRequest.txPowerDbm;
|
|
482 |
pApDiscoveryParams.scanOptions = SCAN_ACTIVE; /* both scan type and band are 0 for active and */
|
|
483 |
/* 2.4 GHz, respectively, but 2.4 is not defined */
|
|
484 |
|
|
485 |
/* band determined at the initiate measurement command not at that structure */
|
|
486 |
|
|
487 |
/* scan mode go into the scan option field */
|
|
488 |
if ( MSR_SCAN_MODE_PASSIVE == pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].scanMode )
|
|
489 |
{
|
|
490 |
pApDiscoveryParams.scanOptions |= SCAN_PASSIVE;
|
|
491 |
}
|
|
492 |
|
|
493 |
/* Send AP Discovery command */
|
|
494 |
status = cmdBld_CmdApDiscovery (pMeasurementSRV->hCmdBld, &pApDiscoveryParams, NULL, NULL);
|
|
495 |
|
|
496 |
if ( TI_OK == status )
|
|
497 |
{
|
|
498 |
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);
|
|
499 |
|
|
500 |
/* Start Timer */
|
|
501 |
tmr_StartTimer (pMeasurementSRV->hRequestTimer[requestIndex],
|
|
502 |
MacServices_measurementSRV_requestTimerExpired,
|
|
503 |
(TI_HANDLE)pMeasurementSRV,
|
|
504 |
pMeasurementSRV->msrRequest.msrTypes[requestIndex].duration,
|
|
505 |
TI_FALSE);
|
|
506 |
pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TI_TRUE;
|
|
507 |
}
|
|
508 |
else
|
|
509 |
{
|
|
510 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_ApDiscoveryCmd returned status %d\n", status);
|
|
511 |
}
|
|
512 |
break;
|
|
513 |
|
|
514 |
case MSR_TYPE_BASIC_MEASUREMENT: /* not supported in current implemntation */
|
|
515 |
case MSR_TYPE_FRAME_MEASUREMENT: /* not supported in current implemntation */
|
|
516 |
default:
|
|
517 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Measurement type %d is not supported\n", pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType);
|
|
518 |
break;
|
|
519 |
}
|
|
520 |
}
|
|
521 |
|
|
522 |
/* if no measurement types are running, sen al types complete event.
|
|
523 |
This can happen if all types failed to start */
|
|
524 |
if ( TI_TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV ))
|
|
525 |
{
|
|
526 |
/* send the event */
|
|
527 |
measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
|
|
528 |
MSR_SRV_EVENT_ALL_TYPES_COMPLETE );
|
|
529 |
}
|
|
530 |
|
|
531 |
return TI_OK;
|
|
532 |
}
|
|
533 |
|
|
534 |
/**
|
|
535 |
* \author Ronen Kalish\n
|
|
536 |
* \date 08-November-2005\n
|
|
537 |
* \brief Handle an ALL_TYPE_COMPLETE event by sending a stop measure command to the FW.\n
|
|
538 |
*
|
|
539 |
* Function Scope \e Public.\n
|
|
540 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
541 |
* \return always TI_OK.\n
|
|
542 |
*/
|
|
543 |
TI_STATUS measurementSRVSM_requestMeasureStop( TI_HANDLE hMeasurementSRV )
|
|
544 |
{
|
|
545 |
measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
546 |
TI_STATUS status;
|
|
547 |
|
|
548 |
/* since this function may also be called when stop is requested and start complete event
|
|
549 |
has not yet been received from the FW, we may need to stop the FW guard timer */
|
|
550 |
if (pMeasurementSRV->bStartStopTimerRunning)
|
|
551 |
{
|
|
552 |
tmr_StopTimer (pMeasurementSRV->hStartStopTimer);
|
|
553 |
pMeasurementSRV->bStartStopTimerRunning = TI_FALSE;
|
|
554 |
}
|
|
555 |
|
|
556 |
/* Send Measurement Stop command to the FW */
|
|
557 |
status = cmdBld_CmdMeasurementStop (pMeasurementSRV->hCmdBld,
|
|
558 |
(void *)pMeasurementSRV->commandResponseCBFunc,
|
|
559 |
pMeasurementSRV->commandResponseCBObj);
|
|
560 |
|
|
561 |
pMeasurementSRV->commandResponseCBFunc = NULL;
|
|
562 |
pMeasurementSRV->commandResponseCBObj = NULL;
|
|
563 |
|
|
564 |
if ( TI_OK != status )
|
|
565 |
{
|
|
566 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Failed to send measurement stop command, statud=%d,\n", status);
|
|
567 |
|
|
568 |
/* send a measurement complete event - since it can't be stopped */
|
|
569 |
measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_STOP_COMPLETE );
|
|
570 |
return TI_OK;
|
|
571 |
}
|
|
572 |
|
|
573 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure stop command sent.\n");
|
|
574 |
|
|
575 |
/* start the FW guard timer */
|
|
576 |
pMeasurementSRV->bStartStopTimerRunning = TI_TRUE;
|
|
577 |
tmr_StartTimer (pMeasurementSRV->hStartStopTimer,
|
|
578 |
MacServices_measurementSRV_startStopTimerExpired,
|
|
579 |
(TI_HANDLE)pMeasurementSRV,
|
|
580 |
MSR_FW_GUARD_TIME,
|
|
581 |
TI_FALSE);
|
|
582 |
|
|
583 |
return TI_OK;
|
|
584 |
}
|
|
585 |
|
|
586 |
/**
|
|
587 |
* \author Ronen Kalish\n
|
|
588 |
* \date 08-November-2005\n
|
|
589 |
* \brief Handle a STOP_COMPLETE event by exiting driver mode and calling the complete CB.\n
|
|
590 |
*
|
|
591 |
* Function Scope \e Public.\n
|
|
592 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
593 |
* \return always TI_OK.\n
|
|
594 |
*/
|
|
595 |
TI_STATUS measurementSRVSM_completeMeasure( TI_HANDLE hMeasurementSRV )
|
|
596 |
{
|
|
597 |
measurementSRV_t *pMeasurementSRV = (measurementSRV_t *)hMeasurementSRV;
|
|
598 |
|
|
599 |
/* Switch Power Save SRV back to user mode */
|
|
600 |
powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL );
|
|
601 |
|
|
602 |
/* if the response CB is still pending, call it (when requestExpiryTimeStamp was reached) */
|
|
603 |
if ( NULL != pMeasurementSRV->commandResponseCBFunc )
|
|
604 |
{
|
|
605 |
pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_OK );
|
|
606 |
}
|
|
607 |
|
|
608 |
/* call the complete CB */
|
|
609 |
if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
|
|
610 |
{
|
|
611 |
pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
|
|
612 |
&(pMeasurementSRV->msrReply));
|
|
613 |
}
|
|
614 |
|
|
615 |
return TI_OK;
|
|
616 |
}
|
|
617 |
|
|
618 |
/**
|
|
619 |
* \author Ronen Kalish\n
|
|
620 |
* \date 08-November-2005\n
|
|
621 |
* \brief Handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE state by exiting driver mode.
|
|
622 |
*
|
|
623 |
* Function Scope \e Public.\n
|
|
624 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
625 |
* \return always TI_OK.\n
|
|
626 |
*/
|
|
627 |
TI_STATUS measurementSRVSM_stopFromWaitForDriverMode( TI_HANDLE hMeasurementSRV )
|
|
628 |
{
|
|
629 |
measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
630 |
|
|
631 |
/* Switch Power Save SRV back to user mode */
|
|
632 |
powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL );
|
|
633 |
|
|
634 |
/* if we are not running within a stop request context (shouldn't happen), call the CBs */
|
|
635 |
if ( TI_FALSE == pMeasurementSRV->bInRequest )
|
|
636 |
{
|
|
637 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": stop from wait for driver mode: not within a request context?!? \n");
|
|
638 |
|
|
639 |
/* call the response CB - this shouldn't happen, as only GWSI has response CB, and it shouldn't call
|
|
640 |
stop before driver */
|
|
641 |
if ( NULL != pMeasurementSRV->commandResponseCBFunc )
|
|
642 |
{
|
|
643 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": stop from wait for driver mode: command response CB is not NULL?!? \n");
|
|
644 |
pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_OK );
|
|
645 |
|
|
646 |
pMeasurementSRV->commandResponseCBFunc = NULL;
|
|
647 |
pMeasurementSRV->commandResponseCBObj = NULL;
|
|
648 |
}
|
|
649 |
/* call the complete CB */
|
|
650 |
if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
|
|
651 |
{
|
|
652 |
/* mark that all types has failed */
|
|
653 |
TI_INT32 i;
|
|
654 |
for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
|
|
655 |
{
|
|
656 |
pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK;
|
|
657 |
}
|
|
658 |
/* call the complete CB */
|
|
659 |
pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
|
|
660 |
&(pMeasurementSRV->msrReply));
|
|
661 |
}
|
|
662 |
else
|
|
663 |
{
|
|
664 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": stop from wait for driver mode and response CB is NULL!!!\n");
|
|
665 |
}
|
|
666 |
}
|
|
667 |
/* we are within a stop request context */
|
|
668 |
else
|
|
669 |
{
|
|
670 |
/* if the command response Cb is valid, send a measure stop command to the FW -
|
|
671 |
although it is not necessary, we need it to get a different context for the command response.
|
|
672 |
This shouldn't happen, as only GWSI has command response, and it shouldn't call stop measure
|
|
673 |
before it got the commadn response for start measure */
|
|
674 |
if ( NULL != pMeasurementSRV->commandResponseCBFunc )
|
|
675 |
{
|
|
676 |
/* shouldn't happen - a command response is valid (GWSI) and stop measure called
|
|
677 |
before measure start response was received (driver) */
|
|
678 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": stop from wait for driver mode - within request context and command response is not NULL?!?\n");
|
|
679 |
|
|
680 |
cmdBld_CmdMeasurementStop (pMeasurementSRV->hCmdBld,
|
|
681 |
(void *)pMeasurementSRV->commandResponseCBFunc,
|
|
682 |
pMeasurementSRV->commandResponseCBObj);
|
|
683 |
|
|
684 |
pMeasurementSRV->commandResponseCBFunc = NULL;
|
|
685 |
pMeasurementSRV->commandResponseCBObj = NULL;
|
|
686 |
}
|
|
687 |
if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
|
|
688 |
{
|
|
689 |
/* Note: this is being called from request context, but there's npthing else that can be done */
|
|
690 |
/* mark that all types has failed */
|
|
691 |
TI_INT32 i;
|
|
692 |
for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
|
|
693 |
{
|
|
694 |
pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK;
|
|
695 |
}
|
|
696 |
/* call the complete CB */
|
|
697 |
pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
|
|
698 |
&(pMeasurementSRV->msrReply));
|
|
699 |
}
|
|
700 |
}
|
|
701 |
|
|
702 |
return TI_OK;
|
|
703 |
}
|
|
704 |
|
|
705 |
/**
|
|
706 |
* \author Ronen Kalish\n
|
|
707 |
* \date 27-November-2005\n
|
|
708 |
* \brief handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE by marking negative result status
|
|
709 |
* \brief and calling the ordinary stop function
|
|
710 |
*
|
|
711 |
* Function Scope \e Public.\n
|
|
712 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
713 |
* \return always TI_OK.\n
|
|
714 |
*/
|
|
715 |
TI_STATUS measurementSRVSM_stopFromWaitForMeasureStart( TI_HANDLE hMeasurementSRV )
|
|
716 |
{
|
|
717 |
measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
718 |
TI_INT32 i;
|
|
719 |
|
|
720 |
/* mark that all types has failed */
|
|
721 |
for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
|
|
722 |
{
|
|
723 |
pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK;
|
|
724 |
}
|
|
725 |
|
|
726 |
/* call the ordinary stop function (will send a measure stop command to FW) */
|
|
727 |
measurementSRVSM_requestMeasureStop( hMeasurementSRV );
|
|
728 |
|
|
729 |
return TI_OK;
|
|
730 |
}
|
|
731 |
|
|
732 |
/**
|
|
733 |
* \author Ronen Kalish\n
|
|
734 |
* \date 08-November-2005\n
|
|
735 |
* \brief handle a STOP_REQUEST event when in MEASURE_IN_PROGRESS by stopping all measure types and
|
|
736 |
* \brief requesting measure stop from the FW.\n
|
|
737 |
*
|
|
738 |
* Function Scope \e Public.\n
|
|
739 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
740 |
* \return always TI_OK.\n
|
|
741 |
*/
|
|
742 |
TI_STATUS measurementSRVSM_stopFromMeasureInProgress( TI_HANDLE hMeasurementSRV )
|
|
743 |
{
|
|
744 |
measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
745 |
TNoiseHistogram pNoiseHistParams;
|
|
746 |
TI_STATUS status;
|
|
747 |
TI_INT32 i;
|
|
748 |
|
|
749 |
/* stop all running measure types */
|
|
750 |
for (i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++)
|
|
751 |
{
|
|
752 |
if (pMeasurementSRV->bRequestTimerRunning[i])
|
|
753 |
{
|
|
754 |
/* stop timer */
|
|
755 |
tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]);
|
|
756 |
pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE;
|
|
757 |
|
|
758 |
/* if necessary, stop measurement type */
|
|
759 |
switch ( pMeasurementSRV->msrRequest.msrTypes[ i ].msrType )
|
|
760 |
{
|
|
761 |
case MSR_TYPE_BEACON_MEASUREMENT:
|
|
762 |
/* send stop AP discovery command */
|
|
763 |
status = cmdBld_CmdApDiscoveryStop (pMeasurementSRV->hCmdBld, NULL, NULL);
|
|
764 |
if ( TI_OK != status )
|
|
765 |
{
|
|
766 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_ApDiscoveryStop returned status %d\n", status);
|
|
767 |
}
|
|
768 |
break;
|
|
769 |
|
|
770 |
case MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT:
|
|
771 |
/* Set Noise Histogram Cmd Params */
|
|
772 |
pNoiseHistParams.cmd = STOP_NOISE_HIST;
|
|
773 |
pNoiseHistParams.sampleInterval = 0;
|
|
774 |
os_memoryZero( pMeasurementSRV->hOS, &(pNoiseHistParams.ranges[ 0 ]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES );
|
|
775 |
|
|
776 |
/* Send a Stop command to the FW */
|
|
777 |
status = cmdBld_CmdNoiseHistogram (pMeasurementSRV->hCmdBld, &pNoiseHistParams, NULL, NULL);
|
|
778 |
|
|
779 |
if ( TI_OK != status )
|
|
780 |
{
|
|
781 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": TWD_NoiseHistogramCmd returned status %d\n", status);
|
|
782 |
}
|
|
783 |
break;
|
|
784 |
|
|
785 |
/* These are just to avoid compilation warnings, nothing is actualy done here! */
|
|
786 |
case MSR_TYPE_BASIC_MEASUREMENT:
|
|
787 |
case MSR_TYPE_CCA_LOAD_MEASUREMENT:
|
|
788 |
case MSR_TYPE_FRAME_MEASUREMENT:
|
|
789 |
case MSR_TYPE_MAX_NUM_OF_MEASURE_TYPES:
|
|
790 |
default:
|
|
791 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": unsupported measurement type: %d\n", pMeasurementSRV->msrRequest.msrTypes[ i ].msrType);
|
|
792 |
break;
|
|
793 |
}
|
|
794 |
|
|
795 |
/* mark that measurement has failed */
|
|
796 |
pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK;
|
|
797 |
}
|
|
798 |
}
|
|
799 |
|
|
800 |
/* Send Measurement Stop command to the FW */
|
|
801 |
status = cmdBld_CmdMeasurementStop (pMeasurementSRV->hCmdBld,
|
|
802 |
(void *)pMeasurementSRV->commandResponseCBFunc,
|
|
803 |
pMeasurementSRV->commandResponseCBObj);
|
|
804 |
|
|
805 |
pMeasurementSRV->commandResponseCBFunc = NULL;
|
|
806 |
pMeasurementSRV->commandResponseCBObj = NULL;
|
|
807 |
|
|
808 |
if ( TI_OK != status )
|
|
809 |
{
|
|
810 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Failed to send measurement stop command, statud=%d,\n", status);
|
|
811 |
|
|
812 |
/* send a measurement complete event - since it can't be stopped */
|
|
813 |
measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
|
|
814 |
MSR_SRV_EVENT_STOP_COMPLETE );
|
|
815 |
return TI_OK;
|
|
816 |
}
|
|
817 |
|
|
818 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": measure stop command sent.\n");
|
|
819 |
|
|
820 |
/* start the FW guard timer */
|
|
821 |
pMeasurementSRV->bStartStopTimerRunning = TI_TRUE;
|
|
822 |
tmr_StartTimer (pMeasurementSRV->hStartStopTimer,
|
|
823 |
MacServices_measurementSRV_startStopTimerExpired,
|
|
824 |
(TI_HANDLE)pMeasurementSRV,
|
|
825 |
MSR_FW_GUARD_TIME,
|
|
826 |
TI_FALSE);
|
|
827 |
|
|
828 |
return TI_OK;
|
|
829 |
}
|
|
830 |
|
|
831 |
/**
|
|
832 |
* \author Ronen Kalish\n
|
|
833 |
* \date 08-November-2005\n
|
|
834 |
* \brief handle a DRIVER_MODE_FAILURE event by calling the response and complete CBs.\n
|
|
835 |
*
|
|
836 |
* Function Scope \e Public.\n
|
|
837 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
838 |
* \return always TI_OK.\n
|
|
839 |
*/
|
|
840 |
TI_STATUS measurementSRVSM_DriverModeFailure( TI_HANDLE hMeasurementSRV )
|
|
841 |
{
|
|
842 |
measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
843 |
|
|
844 |
/* this function can be called from within a request (when the power save SRV returned an immediate error),
|
|
845 |
or in a different context, when power save entry failed. The latter is a valid status, whereas the former
|
|
846 |
indicates a severe error. However, as there is nothing to do with the former (other than debug it), the same
|
|
847 |
failure indication is used for both of them, which will make the upper layer (Palau driver or TI measurement
|
|
848 |
manager) to return to idle state. Still, for the former the error is returned as the return status from the
|
|
849 |
measurement start API call whereas for the latter the error is indicated both by the command response and
|
|
850 |
measurement complete CBs status */
|
|
851 |
|
|
852 |
/* if we are running within a request context, don't call the CBs! The startMeasurement function
|
|
853 |
will return an invalid status instead */
|
|
854 |
if ( TI_FALSE == pMeasurementSRV->bInRequest )
|
|
855 |
{
|
|
856 |
/* if a response CB is available (GWSI) call it */
|
|
857 |
if ( NULL != pMeasurementSRV->commandResponseCBFunc )
|
|
858 |
{
|
|
859 |
pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_NOK );
|
|
860 |
}
|
|
861 |
|
|
862 |
/* if a complete CB is available (both GWSI and TI driver), call it */
|
|
863 |
if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
|
|
864 |
{
|
|
865 |
/* mark that all types has failed */
|
|
866 |
TI_INT32 i;
|
|
867 |
for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
|
|
868 |
{
|
|
869 |
pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK;
|
|
870 |
}
|
|
871 |
/* call the complete CB */
|
|
872 |
pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
|
|
873 |
&(pMeasurementSRV->msrReply));
|
|
874 |
}
|
|
875 |
else
|
|
876 |
{
|
|
877 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": driver mode failure and complete CB is NULL!!!\n");
|
|
878 |
}
|
|
879 |
}
|
|
880 |
|
|
881 |
return TI_OK;
|
|
882 |
}
|
|
883 |
|
|
884 |
/**
|
|
885 |
* \author Ronen Kalish\n
|
|
886 |
* \date 08-November-2005\n
|
|
887 |
* \brief handle a START_FAILURE event by exiting driver mode and calling the complete CB.\n
|
|
888 |
*
|
|
889 |
* Function Scope \e Public.\n
|
|
890 |
* \param hMeasurementSrv - handle to the Measurement SRV object.\n
|
|
891 |
* \return always TI_OK.\n
|
|
892 |
*/
|
|
893 |
TI_STATUS measurementSRVSM_measureStartFailure( TI_HANDLE hMeasurementSRV )
|
|
894 |
{
|
|
895 |
measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
896 |
|
|
897 |
/* This function can be called from within a request context (if the driver mode entry process
|
|
898 |
was immediate), or from the driver mode CB context. Regardless of teh context in which it runs,
|
|
899 |
The error indicates that something is wrong in the HAL. There is no way to solve this (other than debug it).
|
|
900 |
The error is either indicating by the measurement start API return status (if still in the request context),
|
|
901 |
or by calling the response (if available, only in GWSI) and complete CBs with invalid status */
|
|
902 |
|
|
903 |
/* Switch Power save SRV back to user mode */
|
|
904 |
powerSrv_ReleasePS( pMeasurementSRV->hPowerSaveSRV, pMeasurementSRV->bSendNullDataWhenExitPs, NULL, NULL );
|
|
905 |
|
|
906 |
/* if we are running within a request context, don't call the CB! The startMeasurement function
|
|
907 |
will return an invalid status instead */
|
|
908 |
if ( TI_FALSE == pMeasurementSRV->bInRequest )
|
|
909 |
{
|
|
910 |
/* if a response CB is available (GWSI) call it */
|
|
911 |
if ( NULL != pMeasurementSRV->commandResponseCBFunc )
|
|
912 |
{
|
|
913 |
pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_NOK );
|
|
914 |
}
|
|
915 |
|
|
916 |
/* if a complete CB is available (both GWSI and TI driver), call it */
|
|
917 |
if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
|
|
918 |
{
|
|
919 |
/* mark that all types has failed */
|
|
920 |
TI_INT32 i;
|
|
921 |
for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
|
|
922 |
{
|
|
923 |
pMeasurementSRV->msrReply.msrTypes[ i ].status = TI_NOK;
|
|
924 |
}
|
|
925 |
/* call the complete CB */
|
|
926 |
pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj,
|
|
927 |
&(pMeasurementSRV->msrReply));
|
|
928 |
}
|
|
929 |
else
|
|
930 |
{
|
|
931 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_ERROR, ": Start measurement failure and response and complete CBs are NULL!!!\n");
|
|
932 |
}
|
|
933 |
}
|
|
934 |
|
|
935 |
return TI_OK;
|
|
936 |
}
|
|
937 |
|
|
938 |
|
|
939 |
static void measurementSRVSM_requestMeasureStartResponseCB(TI_HANDLE hMeasurementSRV, TI_UINT16 uMboxStatus)
|
|
940 |
{
|
|
941 |
measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
|
|
942 |
TI_INT32 i;
|
|
943 |
|
|
944 |
TRACE1( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": FW has responded with CMD_STATUS = %d\n", uMboxStatus);
|
|
945 |
|
|
946 |
if (uMboxStatus == TI_OK)
|
|
947 |
{
|
|
948 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": FW has responded with CMD_STATUS_SUCCESS!\n");
|
|
949 |
|
|
950 |
if ( NULL != pMeasurementSRV->commandResponseCBFunc )
|
|
951 |
{
|
|
952 |
pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, TI_OK );
|
|
953 |
}
|
|
954 |
}
|
|
955 |
else
|
|
956 |
{
|
|
957 |
if (uMboxStatus == SG_REJECT_MEAS_SG_ACTIVE)
|
|
958 |
{
|
|
959 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": FW has responded with CMD_STATUS_REJECT_MEAS_SG_ACTIVE!\n");
|
|
960 |
}
|
|
961 |
|
|
962 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, ": FW has responded with CMD_STATUS NOK!!!\n");
|
|
963 |
|
|
964 |
|
|
965 |
/* if a timer is running, stop it */
|
|
966 |
if ( TI_TRUE == pMeasurementSRV->bStartStopTimerRunning )
|
|
967 |
{
|
|
968 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "***** STOP TIMER 8 *****\n");
|
|
969 |
tmr_StopTimer( pMeasurementSRV->hStartStopTimer );
|
|
970 |
pMeasurementSRV->bStartStopTimerRunning = TI_FALSE;
|
|
971 |
}
|
|
972 |
for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
|
|
973 |
{
|
|
974 |
if ( TI_TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
|
|
975 |
{
|
|
976 |
tmr_StopTimer( pMeasurementSRV->hRequestTimer[ i ] );
|
|
977 |
pMeasurementSRV->bRequestTimerRunning[ i ] = TI_FALSE;
|
|
978 |
}
|
|
979 |
}
|
|
980 |
|
|
981 |
measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
|
|
982 |
MSR_SRV_EVENT_START_FAILURE );
|
|
983 |
}
|
|
984 |
}
|
|
985 |
|
|
986 |
|
|
987 |
/**
|
|
988 |
* \author Ronen Kalish\n
|
|
989 |
* \date 23-December-2005\n
|
|
990 |
* \brief Handles a stop request when no stop is needed (SM is either idle or already send stop command to FW.\n
|
|
991 |
*
|
|
992 |
* Function Scope \e Private.\n
|
|
993 |
* \param hMeasurementSrv - handle to the measurement SRV object.\n
|
|
994 |
* \return always TI_OK.\n
|
|
995 |
*/
|
|
996 |
TI_STATUS measurementSRVSRVSM_dummyStop( TI_HANDLE hMeasurementSrv )
|
|
997 |
{
|
|
998 |
measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSrv;
|
|
999 |
|
|
1000 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_WARNING, ": sending unnecessary stop measurement command to FW...\n");
|
|
1001 |
|
|
1002 |
/* send a stop command to FW, to obtain a different context in ehich to cal the command response CB */
|
|
1003 |
cmdBld_CmdMeasurementStop (pMeasurementSRV->hCmdBld,
|
|
1004 |
(void *)pMeasurementSRV->commandResponseCBFunc,
|
|
1005 |
pMeasurementSRV->commandResponseCBObj);
|
|
1006 |
|
|
1007 |
pMeasurementSRV->commandResponseCBFunc = NULL;
|
|
1008 |
pMeasurementSRV->commandResponseCBObj = NULL;
|
|
1009 |
|
|
1010 |
return TI_OK;
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
/**
|
|
1014 |
* \author Ronen Kalish\n
|
|
1015 |
* \date 17-November-2005\n
|
|
1016 |
* \brief Handles an unexpected event.\n
|
|
1017 |
*
|
|
1018 |
* Function Scope \e Private.\n
|
|
1019 |
* \param hMeasurementSrv - handle to the measurement SRV object.\n
|
|
1020 |
* \return always TI_OK.\n
|
|
1021 |
*/
|
|
1022 |
TI_STATUS actionUnexpected( TI_HANDLE hMeasurementSrv )
|
|
1023 |
{
|
|
1024 |
measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSrv;
|
|
1025 |
TI_INT32 i;
|
|
1026 |
|
|
1027 |
TRACE0( pMeasurementSRV->hReport, REPORT_SEVERITY_SM, ": measurement SRV state machine error, unexpected Event\n");
|
|
1028 |
|
|
1029 |
if (pMeasurementSRV->bStartStopTimerRunning)
|
|
1030 |
{
|
|
1031 |
tmr_StopTimer (pMeasurementSRV->hStartStopTimer);
|
|
1032 |
pMeasurementSRV->bStartStopTimerRunning = TI_FALSE;
|
|
1033 |
}
|
|
1034 |
|
|
1035 |
for (i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++)
|
|
1036 |
{
|
|
1037 |
if (pMeasurementSRV->bRequestTimerRunning[i])
|
|
1038 |
{
|
|
1039 |
tmr_StopTimer (pMeasurementSRV->hRequestTimer[i]);
|
|
1040 |
pMeasurementSRV->bRequestTimerRunning[i] = TI_FALSE;
|
|
1041 |
}
|
|
1042 |
}
|
|
1043 |
|
|
1044 |
/* we must clean the old command response CB since they are no longer relevant
|
|
1045 |
since the state machine may be corrupted */
|
|
1046 |
pMeasurementSRV->commandResponseCBFunc = NULL;
|
|
1047 |
pMeasurementSRV->commandResponseCBObj = NULL;
|
|
1048 |
|
|
1049 |
/* indicate the unexpected event in the return status */
|
|
1050 |
pMeasurementSRV->returnStatus = TI_NOK;
|
|
1051 |
|
|
1052 |
return TI_OK;
|
|
1053 |
}
|
|
1054 |
|
|
1055 |
/**
|
|
1056 |
* \author Ronen Kalish\n
|
|
1057 |
* \date 10-Jan-2005\n
|
|
1058 |
* \brief Handles an event that doesn't require any action.\n
|
|
1059 |
*
|
|
1060 |
* Function Scope \e Private.\n
|
|
1061 |
* \param hMeasurementSrv - handle to the measurement SRV object.\n
|
|
1062 |
* \return always TI_OK.\n
|
|
1063 |
*/
|
|
1064 |
TI_STATUS actionNop( TI_HANDLE hMeasurementSrv )
|
|
1065 |
{
|
|
1066 |
return TI_OK;
|
|
1067 |
}
|
|
1068 |
|