1 /*
2 * measurementMgrSM.c
3 *
4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name Texas Instruments nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35 /**************************************************************************/
36 /* */
37 /* MODULE: measurementMgrSM.c */
38 /* PURPOSE: Measurement Manager State Machine module interface. */
39 /* */
40 /**************************************************************************/
41
42
43
44 #define __FILE_ID__ FILE_ID_2
45 #include "measurementMgrSM.h"
46 #include "measurementMgr.h"
47 #include "802_11Defs.h"
48 #ifdef XCC_MODULE_INCLUDED
49 #include "XCCMngr.h"
50 #include "XCCRMMngr.h"
51 #endif
52 #include "spectrumMngmntMgr.h"
53 #include "siteMgrApi.h"
54 #include "MacServices_api.h"
55 #include "regulatoryDomainApi.h"
56 #include "TWDriver.h"
57 #include "timer.h"
58 #include "sme.h"
59
60
61 char * measurementMgr_stateDesc[MEASUREMENTMGR_NUM_STATES] =
62 {
63 "STATE_IDLE",
64 "STATE_PROCESSING_REQUEST",
65 "STATE_WAITING_FOR_SCR",
66 "STATE_MEASURING"
67 };
68
69
70 char * measurementMgr_eventDesc[MEASUREMENTMGR_NUM_EVENTS] =
71 {
72 "EVENT_CONNECTED",
73 "EVENT_DISCONNECTED",
74 "EVENT_ENABLE",
75 "EVENT_DISABLE",
76 "EVENT_FRAME_RECV",
77 "EVENT_SEND_REPORT",
78 "EVENT_REQUEST_SCR",
79 "EVENT_SCR_WAIT",
80 "EVENT_SCR_RUN",
81 "EVENT_ABORT",
82 "EVENT_COMPLETE",
83 "EVENT_FW_RESET"
84 };
85
86
87
88
89 /********************************************************************************/
90 /* MeasurementMgr SM Action Prototypes */
91 /********************************************************************************/
92
93 static TI_STATUS measurementMgrSM_acUnexpected(void * pData);
94
95 static TI_STATUS measurementMgrSM_acNop(void * pData);
96
97
98 static TI_STATUS measurementMgrSM_acConnected(void * pData);
99
100 static TI_STATUS measurementMgrSM_acDisconnected_fromIdle(void * pData);
101
102 static TI_STATUS measurementMgrSM_acEnable(void * pData);
103
104 static TI_STATUS measurementMgrSM_acDisable_fromIdle(void * pData);
105
106 static TI_STATUS measurementMgrSM_acFrameReceived_fromIdle(void * pData);
107
108 static TI_STATUS measurementMgrSM_acSendReportAndCleanObj(void * pData);
109
110
111 static TI_STATUS measurementMgrSM_acDisconnected_fromProcessingRequest(void * pData);
112
113 static TI_STATUS measurementMgrSM_acDisable_fromProcessingRequest(void * pData);
114
115 static TI_STATUS measurementMgrSM_acFrameReceived_fromProcessingRequest(void * pData);
116
117 static TI_STATUS measurementMgrSM_acAbort_fromProcessingRequest(void * pData);
118
119 static TI_STATUS measurementMgrSM_acRequestSCR(void * pData);
120
121
122 static TI_STATUS measurementMgrSM_acDisconnected_fromWaitForSCR(void * pData);
123
124 static TI_STATUS measurementMgrSM_acDisable_fromWaitForSCR(void * pData);
125
126 static TI_STATUS measurementMgrSM_acFrameReceived_fromWaitForSCR(void * pData);
127
128 static TI_STATUS measurementMgrSM_acAbort_fromWaitForSCR(void * pData);
129
130 static TI_STATUS measurementMgrSM_acStartMeasurement(void * pData);
131
132
133 static TI_STATUS measurementMgrSM_acDisconnected_fromMeasuring(void * pData);
134
135 static TI_STATUS measurementMgrSM_acDisable_fromMeasuring(void * pData);
136
137 static TI_STATUS measurementMgrSM_acFrameReceived_fromMeasuring(void * pData);
138
139 static TI_STATUS measurementMgrSM_acAbort_fromMeasuring(void * pData);
140
141 static TI_STATUS measurementMgrSM_acMeasurementComplete(void * pData);
142
143 static TI_STATUS measurementMgrSM_acFirmwareReset(void * pData);
144
145
146
147
148
149
150
151
152 /********************************************************************************/
153 /* Internal Functions Prototypes */
154 /********************************************************************************/
155
156 static void measurementMgrSM_resetParams(measurementMgr_t * pMeasurementMgr);
157
158 static void measurementMgrSM_uponActivationDelayTimeout (TI_HANDLE hMeasurementMgr, TI_BOOL bTwdInitOccured);
159
160
161
162
163
164
165
166 /********************************************************************************/
167 /* MeasurementMgr SM General Use Functions */
168 /********************************************************************************/
169
170
171 /**
172 * Configures the Measurement Manager State Machine.
173 *
174 * @param hMeasurementMgr A handle to the Measurement Manager module.
175 *
176 * @date 01-Jan-2006
177 */
measurementMgrSM_config(TI_HANDLE hMeasurementMgr)178 TI_STATUS measurementMgrSM_config(TI_HANDLE hMeasurementMgr)
179 {
180 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
181 TI_STATUS status;
182
183 /* MeasurementMgr State Machine matrix */
184 fsm_actionCell_t measurementMgr_matrix[MEASUREMENTMGR_NUM_STATES][MEASUREMENTMGR_NUM_EVENTS] =
185 {
186 /* next state and actions for STATE_IDLE state */
187 {
188 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acConnected}, /* CONNECTED */
189 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromIdle}, /* DISCONNECTED */
190 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acEnable}, /* ENABLE */
191 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromIdle}, /* DISABLE */
192 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromIdle}, /* FRAME_RECV */
193 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acSendReportAndCleanObj}, /* SEND_REPORT */
194 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* REQUEST_SCR */
195 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* SCR_WAIT */
196 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* SCR_RUN */
197 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* ABORT */
198 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}, /* COMPLETE */
199 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected} /* FW_RESET */
200 },
201
202 /* next state and actions for STATE_PROCESSING_REQUEST state */
203 {
204 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}, /* CONNECTED */
205 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromProcessingRequest}, /* DISCONNECTED */
206 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acNop}, /* ENABLE */
207 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromProcessingRequest}, /* DISABLE */
208 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromProcessingRequest}, /* FRAME_RECV */
209 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acSendReportAndCleanObj}, /* SEND_REPORT */
210 {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acRequestSCR}, /* REQUEST_SCR */
211 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}, /* SCR_WAIT */
212 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}, /* SCR_RUN */
213 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromProcessingRequest}, /* ABORT */
214 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}, /* COMPLETE */
215 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected} /* FW_RESET */
216 },
217
218 /* next state and actions for STATE_WAITING_FOR_SCR state */
219 {
220 {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}, /* CONNECTED */
221 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromWaitForSCR}, /* DISCONNECTED */
222 {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acNop}, /* ENABLE */
223 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromWaitForSCR}, /* DISABLE */
224 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromWaitForSCR}, /* FRAME_RECV */
225 {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}, /* SEND_REPORT */
226 {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}, /* REQUEST_SCR */
227 {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acNop}, /* SCR_WAIT */
228 {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acStartMeasurement}, /* SCR_RUN */
229 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromWaitForSCR}, /* ABORT */
230 {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}, /* COMPLETE */
231 {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected} /* FW_RESET */
232 },
233
234 /* next state and actions for STATE_MEASURING state */
235 {
236 {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* CONNECTED */
237 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromMeasuring}, /* DISCONNECTED */
238 {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acNop}, /* ENABLE */
239 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromMeasuring}, /* DISABLE */
240 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromMeasuring}, /* FRAME_RECV */
241 {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* SEND_REPORT */
242 {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* REQUEST_SCR */
243 {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* SCR_WAIT */
244 {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected}, /* SCR_RUN */
245 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromMeasuring}, /* ABORT */
246 {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acMeasurementComplete}, /* COMPLETE */
247 {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acFirmwareReset} /* FW_RESET */
248 }
249
250 };
251
252 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Configured MeasurementMgr state machine\n");
253
254 status = fsm_Config(pMeasurementMgr->pMeasurementMgrSm,
255 &measurementMgr_matrix[0][0],
256 MEASUREMENTMGR_NUM_STATES,
257 MEASUREMENTMGR_NUM_EVENTS,
258 measurementMgrSM_event, pMeasurementMgr->hOs);
259
260 return status;
261 }
262
263
264
265 /**
266 * Raises a State Machine event in the Measurement Manager SM.
267 *
268 * @param currentState A point to the member holding the SM's current state.
269 * @param event The event we want to raise.
270 * @param hMeasurementMgr A handle to the Measurement Manager module.
271 *
272 * @date 05-Jan-2006
273 */
measurementMgrSM_event(TI_UINT8 * currentState,TI_UINT8 event,TI_HANDLE hMeasurementMgr)274 TI_STATUS measurementMgrSM_event(TI_UINT8 * currentState, TI_UINT8 event, TI_HANDLE hMeasurementMgr)
275 {
276 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
277 TI_STATUS status;
278 TI_UINT8 nextState;
279
280 status = fsm_GetNextState(pMeasurementMgr->pMeasurementMgrSm,
281 *currentState, event, &nextState);
282
283 if (status != TI_OK)
284 {
285 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": State machine error, failed getting next state\n");
286
287 return(TI_NOK);
288 }
289
290 TRACE3(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, "measurementMgrSM_event: <currentState = %d, event = %d> --> nextState = %d\n", currentState, event, nextState);
291
292 status = fsm_Event(pMeasurementMgr->pMeasurementMgrSm, currentState, event, (void *) pMeasurementMgr);
293
294 return status;
295 }
296
297
298
299
300
301
302
303 /********************************************************************************/
304 /* MeasurementMgr SM Action Functions */
305 /********************************************************************************/
306
307
308 /********************************************************************************/
309 /* IDLE State Actions */
310 /********************************************************************************/
311
312 /**
313 * Performs the required action when the Measurement Manager module has
314 * been advised that the station has connected to an AP.
315 *
316 * @date 05-Jan-2006
317 */
measurementMgrSM_acConnected(void * pData)318 static TI_STATUS measurementMgrSM_acConnected(void * pData)
319 {
320 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
321 paramInfo_t param;
322
323 #ifdef XCC_MODULE_INCLUDED
324 iappParsingRegistrationTable_t iappParsingRegistration;
325 #endif
326
327 /* do nothing if we're already in connected mode */
328 if (pMeasurementMgr->Connected)
329 {
330 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Connected flag already set\n");
331
332 return TI_OK;
333 }
334
335 pMeasurementMgr->Connected = TI_TRUE;
336
337 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Connected flag has been set\n");
338
339 /* get the current serving channel */
340 param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
341 siteMgr_getParam(pMeasurementMgr->hSiteMgr, ¶m);
342 pMeasurementMgr->servingChannelID = param.content.siteMgrCurrentChannel;
343
344 #ifdef XCC_MODULE_INCLUDED
345 if(pMeasurementMgr->Mode == MSR_MODE_XCC)
346 {
347 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr set to XCC mode\n");
348
349 if(pMeasurementMgr->isModuleRegistered == TI_FALSE)
350 {
351 /* Registering to the XCCMngr */
352 iappParsingRegistration.handler = pMeasurementMgr;
353 iappParsingRegistration.iappParsingRegistrationProcedure = measurementMgr_XCCParse;
354
355 if (XCCMngr_registerForRecvIappPacket(pMeasurementMgr->hXCCMngr,
356 iappParsingRegistration, IAPP_RADIO_MEASUREMENT) != TI_OK)
357 {
358 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_WARNING, ": Could not register to receive IAPP packets\n");
359
360 return TI_NOK;
361 }
362
363 pMeasurementMgr->isModuleRegistered = TI_TRUE;
364 }
365
366 pMeasurementMgr->parserFrameReq = measurementMgr_XCCParseFrameReq;
367 pMeasurementMgr->isTypeValid = measurementMgr_XCCIsTypeValid;
368 pMeasurementMgr->buildReport = measurementMgr_XCCBuildReport;
369 pMeasurementMgr->buildRejectReport = measurementMgr_XCCBuildRejectReport;
370 pMeasurementMgr->sendReportAndCleanObj = measurementMgr_XCCSendReportAndCleanObject;
371 requestHandler_setRequestParserFunction(pMeasurementMgr->hRequestH,
372 measurementMgr_XCCParseRequestIEHdr);
373 }
374 else
375 #endif
376 {
377 if(pMeasurementMgr->Mode == MSR_MODE_SPECTRUM_MANAGEMENT)
378 {
379 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr set to Spectrum Management mode\n");
380
381 /* NOTE: These 5 functions need to be corrected to fit the 802.11h standered */
382 pMeasurementMgr->parserFrameReq = measurementMgr_dot11hParseFrameReq;
383 pMeasurementMgr->isTypeValid = measurementMgr_dot11hIsTypeValid;
384 pMeasurementMgr->buildReport = measurementMgr_dot11hBuildReport;
385 pMeasurementMgr->buildRejectReport = measurementMgr_dot11hBuildRejectReport;
386 pMeasurementMgr->sendReportAndCleanObj = measurementMgr_dot11hSendReportAndCleanObject;
387 requestHandler_setRequestParserFunction(pMeasurementMgr->hRequestH,
388 measurementMgr_dot11hParseRequestIEHdr);
389
390 }
391 }
392
393 return TI_OK;
394 }
395
396
397
398 /**
399 * Called when the Measurement Manager has been advised that the station
400 * has disconnected from the AP.
401 *
402 * @date 05-Jan-2006
403 */
measurementMgrSM_acDisconnected_fromIdle(void * pData)404 static TI_STATUS measurementMgrSM_acDisconnected_fromIdle(void * pData)
405 {
406 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
407
408 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Connected flag unset\n");
409
410 pMeasurementMgr->Connected = TI_FALSE;
411
412 return TI_OK;
413 }
414
415
416
417 /**
418 * Called when the Measurement Manager is enabled.
419 *
420 * @date 05-Jan-2006
421 */
measurementMgrSM_acEnable(void * pData)422 static TI_STATUS measurementMgrSM_acEnable(void * pData)
423 {
424 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
425
426 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measurement Manager has been enabled\n");
427
428 pMeasurementMgr->Enabled = TI_TRUE;
429
430 return TI_OK;
431 }
432
433
434
435 /**
436 * Called when the Measurement Manager is disabled.
437 *
438 * @date 05-Jan-2006
439 */
measurementMgrSM_acDisable_fromIdle(void * pData)440 static TI_STATUS measurementMgrSM_acDisable_fromIdle(void * pData)
441 {
442 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
443
444 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measurement Manager has been disabled\n");
445
446 pMeasurementMgr->Enabled = TI_FALSE;
447
448 return TI_OK;
449 }
450
451
452
453 /**
454 * Called when the SM is in an idle state and we receive a new measurement frame.
455 *
456 * @date 05-Jan-2006
457 */
measurementMgrSM_acFrameReceived_fromIdle(void * pData)458 static TI_STATUS measurementMgrSM_acFrameReceived_fromIdle(void * pData)
459 {
460 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
461 TI_UINT16 activationDelay;
462 TI_STATUS status;
463 paramInfo_t param;
464 TI_UINT16 tbtt;
465
466 /* handle frame request only if we're connected and measurement is enabled */
467 if (pMeasurementMgr->Connected == TI_FALSE ||
468 pMeasurementMgr->Enabled == TI_FALSE)
469 {
470 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Frame received while SM is in disconnected/disabled state\n");
471
472 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
473 MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
474 }
475
476 /* Setting the frame Type */
477 pMeasurementMgr->currentFrameType = pMeasurementMgr->newFrameRequest.frameType;
478
479 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Frame Type = %d\n", pMeasurementMgr->currentFrameType);
480
481 /* Getting the Beacon Interval from the Site Mgr */
482 param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
483 status = siteMgr_getParam(pMeasurementMgr->hSiteMgr, ¶m);
484 if (status != TI_OK)
485 {
486 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Failed to retrieve beacon interval - not connected?\n");
487
488 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
489 MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
490 }
491
492 /* converting beacon interval to msec */
493 tbtt = (param.content.beaconInterval * 1024) / 1000; /* from TU to msec */
494
495 /* Initializing Activation Delay Time */
496 activationDelay = pMeasurementMgr->newFrameRequest.hdr->activatioDelay;
497 activationDelay *= tbtt;
498 /* Adding the Measurement Offset to the activation delay */
499 activationDelay += pMeasurementMgr->newFrameRequest.hdr->measurementOffset;
500
501 /* Inserting all received measurement requests into the queue */
502 status = requestHandler_insertRequests(pMeasurementMgr->hRequestH,
503 pMeasurementMgr->Mode,
504 pMeasurementMgr->newFrameRequest);
505
506 /* Clean New Frame Params */
507 os_memoryZero(pMeasurementMgr->hOs, &pMeasurementMgr->newFrameRequest,
508 sizeof(TMeasurementFrameRequest));
509
510 if (status != TI_OK)
511 {
512 pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
513
514 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Could not insert request into the queue\n");
515
516 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
517 MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
518 }
519
520 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": New frame has been inserted into the queue\n");
521
522 /* If frame type isn't Unicast add to Activation Delay a random delay */
523 if ((pMeasurementMgr->currentFrameType != MSR_FRAME_TYPE_UNICAST) && (activationDelay > 0))
524 {
525 activationDelay += ((os_timeStampMs(pMeasurementMgr->hOs) % MSR_ACTIVATION_DELAY_RANDOM)
526 + MSR_ACTIVATION_DELAY_OFFSET);
527 }
528
529 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Activation Delay in ms = %d\n", activationDelay);
530
531 if (activationDelay > 0)
532 {
533 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Going to wait for activation delay timer callback\n");
534
535 /* Starting the Activation Delay Timer */
536 tmr_StartTimer (pMeasurementMgr->hActivationDelayTimer,
537 measurementMgrSM_uponActivationDelayTimeout,
538 (TI_HANDLE)pMeasurementMgr,
539 activationDelay,
540 TI_FALSE);
541
542 return TI_OK;
543 }
544 else
545 {
546 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Activating the next request immediately without waiting for callback\n");
547
548 /* Calling to schedule the first waiting request */
549 return measurementMgr_activateNextRequest(pData);
550 }
551 }
552
553
554
555
556
557 /********************************************************************************/
558 /* PROCESSING_REQUEST State Actions */
559 /********************************************************************************/
560
561 /**
562 * Called when the station disconnects from the AP while processing
563 * a measurement request.
564 *
565 * @date 05-Jan-2006
566 */
measurementMgrSM_acDisconnected_fromProcessingRequest(void * pData)567 static TI_STATUS measurementMgrSM_acDisconnected_fromProcessingRequest(void * pData)
568 {
569 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
570
571 /* Stopping the activationDelay Timer */
572 tmr_StopTimer (pMeasurementMgr->hActivationDelayTimer);
573
574 /* Clear Measurement fields */
575 measurementMgrSM_resetParams(pMeasurementMgr);
576
577 pMeasurementMgr->Connected = TI_FALSE;
578
579 return TI_OK;
580 }
581
582
583
584 /**
585 * Called when the Measurement Manager module has been disable while
586 * processing a measurement request.
587 *
588 * @date 05-Jan-2006
589 */
measurementMgrSM_acDisable_fromProcessingRequest(void * pData)590 static TI_STATUS measurementMgrSM_acDisable_fromProcessingRequest(void * pData)
591 {
592 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
593
594 /* Stopping the activationDelay Timer */
595 tmr_StopTimer (pMeasurementMgr->hActivationDelayTimer);
596
597 /* Clear Measurement fields */
598 measurementMgrSM_resetParams(pMeasurementMgr);
599
600 pMeasurementMgr->Enabled = TI_FALSE;
601
602 return TI_OK;
603 }
604
605
606
607 /**
608 * Called when a frame has been received while we are processing another frame.
609 * In this case the older frame is discarded and the new frame is processed.
610 *
611 * @date 05-Jan-2006
612 */
measurementMgrSM_acFrameReceived_fromProcessingRequest(void * pData)613 static TI_STATUS measurementMgrSM_acFrameReceived_fromProcessingRequest(void * pData)
614 {
615 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
616
617 /* Stopping the activationDelay Timer */
618 tmr_StopTimer (pMeasurementMgr->hActivationDelayTimer);
619
620 /* Clear Measurement fields */
621 measurementMgrSM_resetParams(pMeasurementMgr);
622
623 /* Process New Frame */
624 return measurementMgrSM_acFrameReceived_fromIdle(pData);
625 }
626
627
628
629 /**
630 * Sends measurement reports to the AP and cleans up the module.
631 *
632 * @date 05-Jan-2006
633 */
measurementMgrSM_acSendReportAndCleanObj(void * pData)634 static TI_STATUS measurementMgrSM_acSendReportAndCleanObj(void * pData)
635 {
636 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
637
638 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Sending pending reports and cleaning up...\n");
639
640 return pMeasurementMgr->sendReportAndCleanObj(pData);
641 }
642
643
644
645 /**
646 * Called when for some reason we abort while processing a request.
647 *
648 * @date 05-Jan-2006
649 */
measurementMgrSM_acAbort_fromProcessingRequest(void * pData)650 static TI_STATUS measurementMgrSM_acAbort_fromProcessingRequest(void * pData)
651 {
652 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
653
654 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Entered\n");
655
656 /* Stopping the activationDelay Timer */
657 tmr_StopTimer (pMeasurementMgr->hActivationDelayTimer);
658
659 /* Clear Measurement fields */
660 measurementMgrSM_resetParams(pMeasurementMgr);
661
662 return TI_OK;
663 }
664
665
666
667 /**
668 * Called when we finished processing a request and want to request the SCR.
669 *
670 * @date 05-Jan-2006
671 */
measurementMgrSM_acRequestSCR(void * pData)672 static TI_STATUS measurementMgrSM_acRequestSCR(void * pData)
673 {
674 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
675 EScrClientRequestStatus scrStatus;
676 EScePendReason scrPendReason;
677
678 /* Request the channel */
679 scrStatus = scr_clientRequest(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE,
680 SCR_RESOURCE_SERVING_CHANNEL, &scrPendReason);
681
682 if (scrStatus == SCR_CRS_RUN)
683 {
684 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received RUN response from SCR\n");
685
686 /* The channel is allocated for the measurement */
687 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
688 MEASUREMENTMGR_EVENT_SCR_RUN, pMeasurementMgr);
689 }
690 else if ((scrStatus == SCR_CRS_PEND) && (scrPendReason == SCR_PR_DIFFERENT_GROUP_RUNNING))
691 {
692 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received PEND/DIFFGROUP response from SCR\n");
693
694 /* No need to wait for the channel allocation */
695 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
696 MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
697 }
698
699 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Going to wait for SCR callback...\n");
700
701 /* In all other cases wait for the callback function to be called */
702 return TI_OK;
703 }
704
705
706
707
708
709 /********************************************************************************/
710 /* WAIT_FOR_SCR State Actions */
711 /********************************************************************************/
712
713
714 /**
715 * Called if the station disconnects from the AP while waiting for a
716 * response from the SCR.
717 *
718 * @date 05-Jan-2006
719 */
measurementMgrSM_acDisconnected_fromWaitForSCR(void * pData)720 static TI_STATUS measurementMgrSM_acDisconnected_fromWaitForSCR(void * pData)
721 {
722 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
723
724 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
725
726 /* Release the SCR */
727 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
728
729 /* Clear Measurement fields */
730 measurementMgrSM_resetParams(pMeasurementMgr);
731
732 pMeasurementMgr->Connected = TI_FALSE;
733
734 return TI_OK;
735 }
736
737
738
739 /**
740 * Called if the Measurement Manager module is disabled while we are
741 * waiting for a response from the SCR.
742 *
743 * @date 05-Jan-2006
744 */
measurementMgrSM_acDisable_fromWaitForSCR(void * pData)745 static TI_STATUS measurementMgrSM_acDisable_fromWaitForSCR(void * pData)
746 {
747 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
748
749 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
750
751 /* Release the SCR */
752 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
753
754 /* Clear Measurement fields */
755 measurementMgrSM_resetParams(pMeasurementMgr);
756
757 pMeasurementMgr->Enabled = TI_FALSE;
758
759 return TI_OK;
760 }
761
762
763
764 /**
765 * Called if a frame is received after we requested the SCR for another frame.
766 * In this case the older frame is discarded and the new frame is processed.
767 *
768 * @date 05-Jan-2006
769 */
measurementMgrSM_acFrameReceived_fromWaitForSCR(void * pData)770 static TI_STATUS measurementMgrSM_acFrameReceived_fromWaitForSCR(void * pData)
771 {
772 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
773
774 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
775
776 /* Release the SCR */
777 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
778
779 /* Clear Measurement fields */
780 measurementMgrSM_resetParams(pMeasurementMgr);
781
782 /* Process New Frame */
783 return measurementMgrSM_acFrameReceived_fromIdle(pData);
784 }
785
786
787
788 /**
789 * Called if the SCR callbacked with a response other than RUN.
790 *
791 * @date 05-Jan-2006
792 */
measurementMgrSM_acAbort_fromWaitForSCR(void * pData)793 static TI_STATUS measurementMgrSM_acAbort_fromWaitForSCR(void * pData)
794 {
795 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
796
797 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
798
799 /* Release the SCR */
800 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
801
802 /* Build a reject report */
803 measurementMgr_rejectPendingRequests(pMeasurementMgr, MSR_REJECT_SCR_UNAVAILABLE);
804
805 /* Clear Measurement fields */
806 pMeasurementMgr->sendReportAndCleanObj(pMeasurementMgr);
807
808 return TI_OK;
809 }
810
811
812
813 /**
814 * Called when the SCR callbacks with a RUN response or if the SCR
815 * returned a RUN response when we requested it.
816 *
817 * @date 05-Jan-2006
818 */
measurementMgrSM_acStartMeasurement(void * pData)819 static TI_STATUS measurementMgrSM_acStartMeasurement(void * pData)
820 {
821 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
822
823 /* Cryptic: the first struct is the requestHandler request while */
824 /* the second one is the measurementSRV request */
825 MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
826 TMeasurementRequest request;
827 paramInfo_t *pParam;
828 TI_UINT8 numOfRequestsInParallel;
829 TI_UINT8 requestIndex;
830 TI_UINT32 timePassed;
831 TI_BOOL requestedBeaconMeasurement= TI_FALSE;
832 TI_STATUS status;
833
834 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Starting Measurement operation\n");
835
836 pParam = (paramInfo_t *)os_memoryAlloc(pMeasurementMgr->hOs, sizeof(paramInfo_t));
837 if (!pParam)
838 return TI_NOK;
839
840 request.channel = pMeasurementMgr->measuredChannelID;
841 request.startTime = 0; /* ignored by MeasurementSRV for now - for .11k */
842 request.numberOfTypes = 0;
843
844 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measured Channel = %d\n", pMeasurementMgr->measuredChannelID);
845
846 pParam->paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
847 pParam->content.channelCapabilityReq.channelNum = pMeasurementMgr->measuredChannelID;
848 pParam->content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
849
850 if (pMeasurementMgr->measuredChannelID <= MAX_CHANNEL_IN_BAND_2_4)
851 {
852 request.band = RADIO_BAND_2_4_GHZ;
853 pParam->content.channelCapabilityReq.band = RADIO_BAND_2_4_GHZ;
854 }
855 else
856 {
857 request.band = RADIO_BAND_5_0_GHZ;
858 pParam->content.channelCapabilityReq.band = RADIO_BAND_5_0_GHZ;
859 }
860
861 regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, pParam);
862
863 request.txPowerDbm = pParam->content.channelCapabilityRet.maxTxPowerDbm;
864
865 request.eTag = SCAN_RESULT_TAG_MEASUREMENT;
866 os_memoryFree(pMeasurementMgr->hOs, pParam, sizeof(paramInfo_t));
867
868 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Querying Request Handler for the next request in the queue\n");
869
870 /* Getting the next request/requests from the request handler */
871 status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, TI_TRUE, pRequestArr,
872 &numOfRequestsInParallel);
873
874 if (status != TI_OK)
875 {
876 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Failed getting next request from Request Handler\n");
877 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
878 MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);
879 }
880
881 /* Save the number of requests in parallel so that once the */
882 /* measurement operation ends we can get rid of this amount of requests */
883 /* from the requestHandler */
884 pMeasurementMgr->currentNumOfRequestsInParallel = numOfRequestsInParallel;
885
886 for (requestIndex = 0; requestIndex < numOfRequestsInParallel; requestIndex++)
887 {
888 if (pRequestArr[requestIndex]->Type == MSR_TYPE_BEACON_MEASUREMENT)
889 {
890 requestedBeaconMeasurement = TI_TRUE;
891
892 if (pRequestArr[requestIndex]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE)
893 {
894 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Beacon Table request encountered, building report now\n");
895
896 /* building Report for beacon table request */
897 pMeasurementMgr->buildReport(pMeasurementMgr, *pRequestArr[requestIndex], NULL);
898
899 continue;
900 }
901 }
902
903 /* save the request so we can reference it when results arrive */
904 pMeasurementMgr->currentRequest[request.numberOfTypes] = pRequestArr[requestIndex];
905
906 /* add the measurement type to the request's list */
907 request.msrTypes[request.numberOfTypes].duration = pRequestArr[requestIndex]->DurationTime;
908 request.msrTypes[request.numberOfTypes].scanMode = pRequestArr[requestIndex]->ScanMode;
909 request.msrTypes[request.numberOfTypes].msrType = pRequestArr[requestIndex]->Type;
910
911 TRACE3(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ":\n\nMeasurement Request #%d Details: Type = %d, Duration = %d\n\n", request.numberOfTypes+1, request.msrTypes[request.numberOfTypes].msrType, request.msrTypes[request.numberOfTypes].duration);
912
913 request.numberOfTypes++;
914 }
915
916 if (requestedBeaconMeasurement == TI_TRUE)
917 {
918 /* build a probe request template and send it to the HAL */
919 TSetTemplate templateStruct;
920 probeReqTemplate_t probeReqTemplate;
921 TSsid broadcastSSID;
922
923 templateStruct.ptr = (TI_UINT8 *) &probeReqTemplate;
924 templateStruct.type = PROBE_REQUEST_TEMPLATE;
925 templateStruct.eBand = request.band;
926 templateStruct.uRateMask = RATE_MASK_UNSPECIFIED;
927 broadcastSSID.len = 0;
928
929 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Sending probe request template...\n");
930
931 buildProbeReqTemplate( pMeasurementMgr->hSiteMgr, &templateStruct, &broadcastSSID, request.band );
932 #ifdef XCC_MODULE_INCLUDED
933 { /* Insert Radio Mngt Capability IE according XCC4*/
934 TI_UINT32 len = 0;
935 measurementMgr_radioMngtCapabilityBuild (pMeasurementMgr,
936 templateStruct.ptr + templateStruct.len,
937 (TI_UINT8*)&len);
938 templateStruct.len += len;
939 }
940 #endif
941
942 TWD_CmdTemplate (pMeasurementMgr->hTWD, &templateStruct, NULL, NULL);
943 }
944
945 /* Check if the maximum time to wait for the measurement request to */
946 /* finish has already passed */
947 timePassed = os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime;
948 if (timePassed > MSR_START_MAX_DELAY)
949 {
950 TRACE2(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Maximum delay to perform measurement operation has passed (%d / %d)\n", MSR_START_MAX_DELAY, (os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime));
951
952 pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequestsInParallel, MSR_REJECT_MAX_DELAY_PASSED);
953 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState),
954 MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);
955 }
956
957 /* Yalla, start measuring */
958 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Finished preparing request. Handing over to MeasurementSRV...\n");
959
960 TWD_StartMeasurement (pMeasurementMgr->hTWD,
961 &request,
962 MSR_START_MAX_DELAY - timePassed,
963 NULL, NULL,
964 measurementMgr_MeasurementCompleteCB,
965 pMeasurementMgr);
966 return TI_OK;
967 }
968
969
970
971
972
973
974 /********************************************************************************/
975 /* MEASURING State Actions */
976 /********************************************************************************/
977
978
measurementMgrSM_acDisconnected_fromMeasuring(void * pData)979 static TI_STATUS measurementMgrSM_acDisconnected_fromMeasuring(void * pData)
980 {
981 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
982
983 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
984
985 /* release the SCR */
986 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
987
988 /* Clear Measurement fields */
989 measurementMgrSM_resetParams(pMeasurementMgr);
990
991 pMeasurementMgr->Connected = TI_FALSE;
992
993 return TI_OK;
994 }
995
996
997
measurementMgrSM_acDisable_fromMeasuring(void * pData)998 static TI_STATUS measurementMgrSM_acDisable_fromMeasuring(void * pData)
999 {
1000 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
1001
1002 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
1003
1004 /* release the SCR */
1005 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
1006
1007 /* Clear Measurement fields */
1008 measurementMgrSM_resetParams(pMeasurementMgr);
1009
1010 pMeasurementMgr->Enabled = TI_FALSE;
1011
1012 return TI_OK;
1013 }
1014
1015
1016
measurementMgrSM_acFrameReceived_fromMeasuring(void * pData)1017 static TI_STATUS measurementMgrSM_acFrameReceived_fromMeasuring(void * pData)
1018 {
1019 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
1020
1021 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
1022
1023 /* release the SCR */
1024 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
1025
1026 /* Clear Measurement fields */
1027 measurementMgrSM_resetParams(pMeasurementMgr);
1028
1029 /* Process New Frame */
1030 return measurementMgrSM_acFrameReceived_fromIdle(pData);
1031 }
1032
1033
1034
measurementMgrSM_acAbort_fromMeasuring(void * pData)1035 static TI_STATUS measurementMgrSM_acAbort_fromMeasuring(void * pData)
1036 {
1037 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
1038
1039 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
1040
1041 /* release the SCR */
1042 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
1043
1044 /* Clear Measurement fields */
1045 measurementMgrSM_resetParams(pMeasurementMgr);
1046
1047 TWD_StopMeasurement (pMeasurementMgr->hTWD, TI_TRUE ,NULL, NULL);
1048
1049 return TI_OK;
1050 }
1051
1052
1053
1054 /**
1055 * Called when we finished a measurement request.
1056 *
1057 * @date 05-Jan-2006
1058 */
measurementMgrSM_acMeasurementComplete(void * pData)1059 static TI_STATUS measurementMgrSM_acMeasurementComplete(void * pData)
1060 {
1061 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
1062 requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
1063
1064 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Completing measurement operation and resuming normal behavior\n");
1065
1066 /* advance the activeRequestID variable to get rid of the */
1067 /* measurement requests we've already executed */
1068 TRACE2(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Increasing activeRequestID from %d to %d.\n", pRequestH->activeRequestID, pRequestH->activeRequestID + pMeasurementMgr->currentNumOfRequestsInParallel);
1069
1070 pRequestH->activeRequestID += pMeasurementMgr->currentNumOfRequestsInParallel;
1071
1072 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
1073
1074 /* move the driver result table to stable state and clear it */
1075 sme_MeansurementScanResult (pMeasurementMgr->hSme, SCAN_CRS_SCAN_COMPLETE_OK, NULL);
1076
1077 /* release the SCR */
1078 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
1079
1080 /* Process New Frame */
1081 return measurementMgr_activateNextRequest(pData);
1082 }
1083
1084
1085
1086 /**
1087 * Called when a firmware reset has been detected.
1088 *
1089 * @date 05-Jan-2006
1090 */
measurementMgrSM_acFirmwareReset(void * pData)1091 static TI_STATUS measurementMgrSM_acFirmwareReset(void * pData)
1092 {
1093 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
1094
1095 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Firmware Reset!!\n");
1096
1097 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr);
1098
1099 /* release the SCR */
1100 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL);
1101
1102 /* Clear Measurement fields */
1103 measurementMgrSM_resetParams(pMeasurementMgr);
1104
1105 return TI_OK;
1106 }
1107
1108
1109
1110
1111
1112
1113
1114 /********************************************************************************/
1115 /* Miscellaneous State Actions */
1116 /********************************************************************************/
1117
1118 /**
1119 * Called when an unexpected event has been triggered.
1120 *
1121 * @date 05-Jan-2006
1122 */
measurementMgrSM_acUnexpected(void * pData)1123 static TI_STATUS measurementMgrSM_acUnexpected(void * pData)
1124 {
1125 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
1126
1127 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Entered when state is \n");
1128
1129 return TI_OK;
1130 }
1131
1132 /**
1133 * A do nothing action.
1134 *
1135 * @date 05-Jan-2006
1136 */
measurementMgrSM_acNop(void * pData)1137 static TI_STATUS measurementMgrSM_acNop(void * pData)
1138 {
1139 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
1140
1141 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Entered when state is \n");
1142
1143 return TI_OK;
1144 }
1145
1146
1147
1148
1149
1150
1151
1152
1153 /********************************************************************************/
1154 /* Internal Functions Prototypes */
1155 /********************************************************************************/
1156
1157
measurementMgrSM_resetParams(measurementMgr_t * pMeasurementMgr)1158 static void measurementMgrSM_resetParams(measurementMgr_t *pMeasurementMgr)
1159 {
1160 /* clear the waiting requests */
1161 requestHandler_clearRequests(pMeasurementMgr->hRequestH);
1162
1163 /* clearing reports data base */
1164 #ifdef XCC_MODULE_INCLUDED
1165 os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->XCCFrameReport),
1166 sizeof(RM_report_frame_t));
1167 #endif
1168 os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->dot11hFrameReport),
1169 sizeof(MeasurementReportFrame_t));
1170
1171 pMeasurementMgr->frameLength = 0;
1172 pMeasurementMgr->nextEmptySpaceInReport = 0;
1173 pMeasurementMgr->measuredChannelID = 0;
1174 pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
1175 }
1176
1177
1178
1179 /**
1180 * The callback called when the activation delay timer has ended.
1181 *
1182 * @param hMeasurementMgr - A handle to the Measurement Manager module.
1183 * @param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started
1184 *
1185 * @date 01-Jan-2006
1186 */
measurementMgrSM_uponActivationDelayTimeout(TI_HANDLE hMeasurementMgr,TI_BOOL bTwdInitOccured)1187 static void measurementMgrSM_uponActivationDelayTimeout (TI_HANDLE hMeasurementMgr, TI_BOOL bTwdInitOccured)
1188 {
1189 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *)hMeasurementMgr;
1190
1191 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Activation delay timeout callback entered\n");
1192
1193 measurementMgr_activateNextRequest (pMeasurementMgr);
1194 }
1195
1196