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