1 /* 2 * measurementMgrSM.c 3 * 4 * Copyright(c) 1998 - 2010 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 */ 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 */ 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 */ 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 /* upon connection to a new AP set the measurment scan flag to FALSE */ 340 pMeasurementMgr->bMeasurementScanExecuted = TI_FALSE; 341 342 /* get the current serving channel */ 343 param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM; 344 siteMgr_getParam(pMeasurementMgr->hSiteMgr, ¶m); 345 pMeasurementMgr->servingChannelID = param.content.siteMgrCurrentChannel; 346 347 #ifdef XCC_MODULE_INCLUDED 348 if(pMeasurementMgr->Mode == MSR_MODE_XCC) 349 { 350 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr set to XCC mode\n"); 351 352 if(pMeasurementMgr->isModuleRegistered == TI_FALSE) 353 { 354 /* Registering to the XCCMngr */ 355 iappParsingRegistration.handler = pMeasurementMgr; 356 iappParsingRegistration.iappParsingRegistrationProcedure = measurementMgr_XCCParse; 357 358 if (XCCMngr_registerForRecvIappPacket(pMeasurementMgr->hXCCMngr, 359 iappParsingRegistration, IAPP_RADIO_MEASUREMENT) != TI_OK) 360 { 361 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_WARNING, ": Could not register to receive IAPP packets\n"); 362 363 return TI_NOK; 364 } 365 366 pMeasurementMgr->isModuleRegistered = TI_TRUE; 367 } 368 369 pMeasurementMgr->parserFrameReq = measurementMgr_XCCParseFrameReq; 370 pMeasurementMgr->isTypeValid = measurementMgr_XCCIsTypeValid; 371 pMeasurementMgr->buildReport = measurementMgr_XCCBuildReport; 372 pMeasurementMgr->buildRejectReport = measurementMgr_XCCBuildRejectReport; 373 pMeasurementMgr->sendReportAndCleanObj = measurementMgr_XCCSendReportAndCleanObject; 374 requestHandler_setRequestParserFunction(pMeasurementMgr->hRequestH, 375 measurementMgr_XCCParseRequestIEHdr); 376 } 377 else 378 #endif 379 { 380 if(pMeasurementMgr->Mode == MSR_MODE_SPECTRUM_MANAGEMENT) 381 { 382 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": MeasurementMgr set to Spectrum Management mode\n"); 383 384 /* NOTE: These 5 functions need to be corrected to fit the 802.11h standered */ 385 pMeasurementMgr->parserFrameReq = measurementMgr_dot11hParseFrameReq; 386 pMeasurementMgr->isTypeValid = measurementMgr_dot11hIsTypeValid; 387 pMeasurementMgr->buildReport = measurementMgr_dot11hBuildReport; 388 pMeasurementMgr->buildRejectReport = measurementMgr_dot11hBuildRejectReport; 389 pMeasurementMgr->sendReportAndCleanObj = measurementMgr_dot11hSendReportAndCleanObject; 390 requestHandler_setRequestParserFunction(pMeasurementMgr->hRequestH, 391 measurementMgr_dot11hParseRequestIEHdr); 392 393 } 394 } 395 396 return TI_OK; 397 } 398 399 400 401 /** 402 * Called when the Measurement Manager has been advised that the station 403 * has disconnected from the AP. 404 * 405 * @date 05-Jan-2006 406 */ 407 static TI_STATUS measurementMgrSM_acDisconnected_fromIdle(void * pData) 408 { 409 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 410 411 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Connected flag unset\n"); 412 413 pMeasurementMgr->Connected = TI_FALSE; 414 415 return TI_OK; 416 } 417 418 419 420 /** 421 * Called when the Measurement Manager is enabled. 422 * 423 * @date 05-Jan-2006 424 */ 425 static TI_STATUS measurementMgrSM_acEnable(void * pData) 426 { 427 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 428 429 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measurement Manager has been enabled\n"); 430 431 pMeasurementMgr->Enabled = TI_TRUE; 432 433 return TI_OK; 434 } 435 436 437 438 /** 439 * Called when the Measurement Manager is disabled. 440 * 441 * @date 05-Jan-2006 442 */ 443 static TI_STATUS measurementMgrSM_acDisable_fromIdle(void * pData) 444 { 445 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 446 447 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measurement Manager has been disabled\n"); 448 449 pMeasurementMgr->Enabled = TI_FALSE; 450 451 return TI_OK; 452 } 453 454 455 456 /** 457 * Called when the SM is in an idle state and we receive a new measurement frame. 458 * 459 * @date 05-Jan-2006 460 */ 461 static TI_STATUS measurementMgrSM_acFrameReceived_fromIdle(void * pData) 462 { 463 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 464 TI_UINT16 activationDelay; 465 TI_STATUS status; 466 paramInfo_t param; 467 TI_UINT16 tbtt; 468 469 /* handle frame request only if we're connected and measurement is enabled */ 470 if (pMeasurementMgr->Connected == TI_FALSE || 471 pMeasurementMgr->Enabled == TI_FALSE) 472 { 473 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Frame received while SM is in disconnected/disabled state\n"); 474 475 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), 476 MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr); 477 } 478 479 /* Setting the frame Type */ 480 pMeasurementMgr->currentFrameType = pMeasurementMgr->newFrameRequest.frameType; 481 482 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Frame Type = %d\n", pMeasurementMgr->currentFrameType); 483 484 /* Getting the Beacon Interval from the Site Mgr */ 485 param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM; 486 status = siteMgr_getParam(pMeasurementMgr->hSiteMgr, ¶m); 487 if (status != TI_OK) 488 { 489 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Failed to retrieve beacon interval - not connected?\n"); 490 491 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), 492 MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr); 493 } 494 495 /* converting beacon interval to msec */ 496 tbtt = (param.content.beaconInterval * 1024) / 1000; /* from TU to msec */ 497 498 /* Initializing Activation Delay Time */ 499 activationDelay = pMeasurementMgr->newFrameRequest.hdr->activatioDelay; 500 activationDelay *= tbtt; 501 /* Adding the Measurement Offset to the activation delay */ 502 activationDelay += pMeasurementMgr->newFrameRequest.hdr->measurementOffset; 503 504 /* Inserting all received measurement requests into the queue */ 505 status = requestHandler_insertRequests(pMeasurementMgr->hRequestH, 506 pMeasurementMgr->Mode, 507 pMeasurementMgr->newFrameRequest); 508 509 /* Clean New Frame Params */ 510 os_memoryZero(pMeasurementMgr->hOs, &pMeasurementMgr->newFrameRequest, 511 sizeof(TMeasurementFrameRequest)); 512 513 if (status != TI_OK) 514 { 515 pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE; 516 517 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Could not insert request into the queue\n"); 518 519 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), 520 MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr); 521 } 522 523 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": New frame has been inserted into the queue\n"); 524 525 /* If frame type isn't Unicast add to Activation Delay a random delay */ 526 if ((pMeasurementMgr->currentFrameType != MSR_FRAME_TYPE_UNICAST) && (activationDelay > 0)) 527 { 528 activationDelay += ((os_timeStampMs(pMeasurementMgr->hOs) % MSR_ACTIVATION_DELAY_RANDOM) 529 + MSR_ACTIVATION_DELAY_OFFSET); 530 } 531 532 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Activation Delay in ms = %d\n", activationDelay); 533 534 if (activationDelay > 0) 535 { 536 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Going to wait for activation delay timer callback\n"); 537 538 /* Starting the Activation Delay Timer */ 539 tmr_StartTimer (pMeasurementMgr->hActivationDelayTimer, 540 measurementMgrSM_uponActivationDelayTimeout, 541 (TI_HANDLE)pMeasurementMgr, 542 activationDelay, 543 TI_FALSE); 544 545 return TI_OK; 546 } 547 else 548 { 549 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Activating the next request immediately without waiting for callback\n"); 550 551 /* Calling to schedule the first waiting request */ 552 return measurementMgr_activateNextRequest(pData); 553 } 554 } 555 556 557 558 559 560 /********************************************************************************/ 561 /* PROCESSING_REQUEST State Actions */ 562 /********************************************************************************/ 563 564 /** 565 * Called when the station disconnects from the AP while processing 566 * a measurement request. 567 * 568 * @date 05-Jan-2006 569 */ 570 static TI_STATUS measurementMgrSM_acDisconnected_fromProcessingRequest(void * pData) 571 { 572 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 573 574 /* Stopping the activationDelay Timer */ 575 tmr_StopTimer (pMeasurementMgr->hActivationDelayTimer); 576 577 /* Clear Measurement fields */ 578 measurementMgrSM_resetParams(pMeasurementMgr); 579 580 pMeasurementMgr->Connected = TI_FALSE; 581 582 return TI_OK; 583 } 584 585 586 587 /** 588 * Called when the Measurement Manager module has been disable while 589 * processing a measurement request. 590 * 591 * @date 05-Jan-2006 592 */ 593 static TI_STATUS measurementMgrSM_acDisable_fromProcessingRequest(void * pData) 594 { 595 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 596 597 /* Stopping the activationDelay Timer */ 598 tmr_StopTimer (pMeasurementMgr->hActivationDelayTimer); 599 600 /* Clear Measurement fields */ 601 measurementMgrSM_resetParams(pMeasurementMgr); 602 603 pMeasurementMgr->Enabled = TI_FALSE; 604 605 return TI_OK; 606 } 607 608 609 610 /** 611 * Called when a frame has been received while we are processing another frame. 612 * In this case the older frame is discarded and the new frame is processed. 613 * 614 * @date 05-Jan-2006 615 */ 616 static TI_STATUS measurementMgrSM_acFrameReceived_fromProcessingRequest(void * pData) 617 { 618 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 619 620 /* Stopping the activationDelay Timer */ 621 tmr_StopTimer (pMeasurementMgr->hActivationDelayTimer); 622 623 /* Clear Measurement fields */ 624 measurementMgrSM_resetParams(pMeasurementMgr); 625 626 /* Process New Frame */ 627 return measurementMgrSM_acFrameReceived_fromIdle(pData); 628 } 629 630 631 632 /** 633 * Sends measurement reports to the AP and cleans up the module. 634 * 635 * @date 05-Jan-2006 636 */ 637 static TI_STATUS measurementMgrSM_acSendReportAndCleanObj(void * pData) 638 { 639 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 640 641 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Sending pending reports and cleaning up...\n"); 642 643 return pMeasurementMgr->sendReportAndCleanObj(pData); 644 } 645 646 647 648 /** 649 * Called when for some reason we abort while processing a request. 650 * 651 * @date 05-Jan-2006 652 */ 653 static TI_STATUS measurementMgrSM_acAbort_fromProcessingRequest(void * pData) 654 { 655 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 656 657 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Entered\n"); 658 659 /* Stopping the activationDelay Timer */ 660 tmr_StopTimer (pMeasurementMgr->hActivationDelayTimer); 661 662 /* Clear Measurement fields */ 663 measurementMgrSM_resetParams(pMeasurementMgr); 664 665 return TI_OK; 666 } 667 668 669 670 /** 671 * Called when we finished processing a request and want to request the SCR. 672 * 673 * @date 05-Jan-2006 674 */ 675 static TI_STATUS measurementMgrSM_acRequestSCR(void * pData) 676 { 677 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 678 EScrClientRequestStatus scrStatus; 679 EScePendReason scrPendReason; 680 681 /* Request the channel */ 682 scrStatus = scr_clientRequest(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, 683 SCR_RESOURCE_SERVING_CHANNEL, &scrPendReason); 684 685 if (scrStatus == SCR_CRS_RUN) 686 { 687 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received RUN response from SCR\n"); 688 689 /* The channel is allocated for the measurement */ 690 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), 691 MEASUREMENTMGR_EVENT_SCR_RUN, pMeasurementMgr); 692 } 693 else if ((scrStatus == SCR_CRS_PEND) && (scrPendReason == SCR_PR_DIFFERENT_GROUP_RUNNING)) 694 { 695 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received PEND/DIFFGROUP response from SCR\n"); 696 697 /* No need to wait for the channel allocation */ 698 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), 699 MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr); 700 } 701 702 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Going to wait for SCR callback...\n"); 703 704 /* In all other cases wait for the callback function to be called */ 705 return TI_OK; 706 } 707 708 709 710 711 712 /********************************************************************************/ 713 /* WAIT_FOR_SCR State Actions */ 714 /********************************************************************************/ 715 716 717 /** 718 * Called if the station disconnects from the AP while waiting for a 719 * response from the SCR. 720 * 721 * @date 05-Jan-2006 722 */ 723 static TI_STATUS measurementMgrSM_acDisconnected_fromWaitForSCR(void * pData) 724 { 725 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 726 727 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 728 729 /* Release the SCR */ 730 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 731 732 /* Clear Measurement fields */ 733 measurementMgrSM_resetParams(pMeasurementMgr); 734 735 pMeasurementMgr->Connected = TI_FALSE; 736 737 return TI_OK; 738 } 739 740 741 742 /** 743 * Called if the Measurement Manager module is disabled while we are 744 * waiting for a response from the SCR. 745 * 746 * @date 05-Jan-2006 747 */ 748 static TI_STATUS measurementMgrSM_acDisable_fromWaitForSCR(void * pData) 749 { 750 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 751 752 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 753 754 /* Release the SCR */ 755 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 756 757 /* Clear Measurement fields */ 758 measurementMgrSM_resetParams(pMeasurementMgr); 759 760 pMeasurementMgr->Enabled = TI_FALSE; 761 762 return TI_OK; 763 } 764 765 766 767 /** 768 * Called if a frame is received after we requested the SCR for another frame. 769 * In this case the older frame is discarded and the new frame is processed. 770 * 771 * @date 05-Jan-2006 772 */ 773 static TI_STATUS measurementMgrSM_acFrameReceived_fromWaitForSCR(void * pData) 774 { 775 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 776 777 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 778 779 /* Release the SCR */ 780 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 781 782 /* Clear Measurement fields */ 783 measurementMgrSM_resetParams(pMeasurementMgr); 784 785 /* Process New Frame */ 786 return measurementMgrSM_acFrameReceived_fromIdle(pData); 787 } 788 789 790 791 /** 792 * Called if the SCR callbacked with a response other than RUN. 793 * 794 * @date 05-Jan-2006 795 */ 796 static TI_STATUS measurementMgrSM_acAbort_fromWaitForSCR(void * pData) 797 { 798 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 799 800 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 801 802 /* Release the SCR */ 803 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 804 805 /* Build a reject report */ 806 measurementMgr_rejectPendingRequests(pMeasurementMgr, MSR_REJECT_SCR_UNAVAILABLE); 807 808 /* Clear Measurement fields */ 809 pMeasurementMgr->sendReportAndCleanObj(pMeasurementMgr); 810 811 return TI_OK; 812 } 813 814 815 816 /** 817 * Called when the SCR callbacks with a RUN response or if the SCR 818 * returned a RUN response when we requested it. 819 * 820 * @date 05-Jan-2006 821 */ 822 static TI_STATUS measurementMgrSM_acStartMeasurement(void * pData) 823 { 824 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 825 826 /* Cryptic: the first struct is the requestHandler request while */ 827 /* the second one is the measurementSRV request */ 828 MeasurementRequest_t * pRequestArr[MAX_NUM_REQ]; 829 TMeasurementRequest request; 830 paramInfo_t *pParam; 831 TI_UINT8 numOfRequestsInParallel; 832 TI_UINT8 requestIndex; 833 TI_UINT32 timePassed; 834 TI_BOOL requestedBeaconMeasurement= TI_FALSE; 835 TI_STATUS status; 836 837 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Starting Measurement operation\n"); 838 839 pParam = (paramInfo_t *)os_memoryAlloc(pMeasurementMgr->hOs, sizeof(paramInfo_t)); 840 if (!pParam) 841 { 842 return TI_NOK; 843 } 844 845 request.channel = pMeasurementMgr->measuredChannelID; 846 request.startTime = 0; /* ignored by MeasurementSRV for now - for .11k */ 847 request.numberOfTypes = 0; 848 849 TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measured Channel = %d\n", pMeasurementMgr->measuredChannelID); 850 851 pParam->paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES; 852 pParam->content.channelCapabilityReq.channelNum = pMeasurementMgr->measuredChannelID; 853 pParam->content.channelCapabilityReq.scanOption = ACTIVE_SCANNING; 854 855 if (pMeasurementMgr->measuredChannelID <= MAX_CHANNEL_IN_BAND_2_4) 856 { 857 request.band = RADIO_BAND_2_4_GHZ; 858 pParam->content.channelCapabilityReq.band = RADIO_BAND_2_4_GHZ; 859 } 860 else 861 { 862 request.band = RADIO_BAND_5_0_GHZ; 863 pParam->content.channelCapabilityReq.band = RADIO_BAND_5_0_GHZ; 864 } 865 866 regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, pParam); 867 868 request.txPowerDbm = pParam->content.channelCapabilityRet.maxTxPowerDbm; 869 870 request.eTag = SCAN_RESULT_TAG_MEASUREMENT; 871 os_memoryFree(pMeasurementMgr->hOs, pParam, sizeof(paramInfo_t)); 872 873 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Querying Request Handler for the next request in the queue\n"); 874 875 /* Getting the next request/requests from the request handler */ 876 status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, TI_TRUE, pRequestArr, 877 &numOfRequestsInParallel); 878 879 if (status != TI_OK) 880 { 881 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Failed getting next request from Request Handler\n"); 882 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), 883 MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr); 884 } 885 886 /* Save the number of requests in parallel so that once the */ 887 /* measurement operation ends we can get rid of this amount of requests */ 888 /* from the requestHandler */ 889 pMeasurementMgr->currentNumOfRequestsInParallel = numOfRequestsInParallel; 890 891 for (requestIndex = 0; requestIndex < numOfRequestsInParallel; requestIndex++) 892 { 893 if (pRequestArr[requestIndex]->Type == MSR_TYPE_BEACON_MEASUREMENT) 894 { 895 requestedBeaconMeasurement = TI_TRUE; 896 897 if (pRequestArr[requestIndex]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE) 898 { 899 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Beacon Table request encountered, building report now\n"); 900 901 /* building Report for beacon table request */ 902 pMeasurementMgr->buildReport(pMeasurementMgr, *pRequestArr[requestIndex], NULL); 903 904 continue; 905 } 906 } 907 908 /* save the request so we can reference it when results arrive */ 909 pMeasurementMgr->currentRequest[request.numberOfTypes] = pRequestArr[requestIndex]; 910 911 /* add the measurement type to the request's list */ 912 request.msrTypes[request.numberOfTypes].duration = pRequestArr[requestIndex]->DurationTime; 913 request.msrTypes[request.numberOfTypes].scanMode = pRequestArr[requestIndex]->ScanMode; 914 request.msrTypes[request.numberOfTypes].msrType = pRequestArr[requestIndex]->Type; 915 916 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); 917 918 request.numberOfTypes++; 919 } 920 921 if (requestedBeaconMeasurement == TI_TRUE) 922 { 923 /* build a probe request template and send it to the HAL */ 924 TSetTemplate templateStruct; 925 probeReqTemplate_t probeReqTemplate; 926 TSsid broadcastSSID; 927 928 templateStruct.ptr = (TI_UINT8 *) &probeReqTemplate; 929 templateStruct.type = PROBE_REQUEST_TEMPLATE; 930 templateStruct.eBand = request.band; 931 templateStruct.uRateMask = RATE_MASK_UNSPECIFIED; 932 broadcastSSID.len = 0; 933 934 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Sending probe request template...\n"); 935 936 buildProbeReqTemplate( pMeasurementMgr->hSiteMgr, &templateStruct, &broadcastSSID, request.band ); 937 #ifdef XCC_MODULE_INCLUDED 938 { /* Insert Radio Mngt Capability IE according XCC4*/ 939 TI_UINT32 len = 0; 940 measurementMgr_radioMngtCapabilityBuild (pMeasurementMgr, 941 templateStruct.ptr + templateStruct.len, 942 (TI_UINT8*)&len); 943 templateStruct.len += len; 944 } 945 #endif 946 947 TWD_CmdTemplate (pMeasurementMgr->hTWD, &templateStruct, NULL, NULL); 948 } 949 950 /* Check if the maximum time to wait for the measurement request to */ 951 /* finish has already passed */ 952 timePassed = os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime; 953 if (timePassed > MSR_START_MAX_DELAY) 954 { 955 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)); 956 957 pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequestsInParallel, MSR_REJECT_MAX_DELAY_PASSED); 958 return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), 959 MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr); 960 } 961 962 /* set the measurement scan executed flag to TRUE */ 963 pMeasurementMgr->bMeasurementScanExecuted = TI_TRUE; 964 965 /* Yalla, start measuring */ 966 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Finished preparing request. Handing over to MeasurementSRV...\n"); 967 968 TWD_StartMeasurement (pMeasurementMgr->hTWD, 969 &request, 970 MSR_START_MAX_DELAY - timePassed, 971 NULL, NULL, 972 measurementMgr_MeasurementCompleteCB, 973 pMeasurementMgr); 974 return TI_OK; 975 } 976 977 978 979 980 981 982 /********************************************************************************/ 983 /* MEASURING State Actions */ 984 /********************************************************************************/ 985 986 987 static TI_STATUS measurementMgrSM_acDisconnected_fromMeasuring(void * pData) 988 { 989 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 990 991 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 992 993 /* release the SCR */ 994 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 995 996 /* Clear Measurement fields */ 997 measurementMgrSM_resetParams(pMeasurementMgr); 998 999 pMeasurementMgr->Connected = TI_FALSE; 1000 1001 return TI_OK; 1002 } 1003 1004 1005 1006 static TI_STATUS measurementMgrSM_acDisable_fromMeasuring(void * pData) 1007 { 1008 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 1009 1010 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 1011 1012 /* release the SCR */ 1013 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 1014 1015 /* Clear Measurement fields */ 1016 measurementMgrSM_resetParams(pMeasurementMgr); 1017 1018 pMeasurementMgr->Enabled = TI_FALSE; 1019 1020 return TI_OK; 1021 } 1022 1023 1024 1025 static TI_STATUS measurementMgrSM_acFrameReceived_fromMeasuring(void * pData) 1026 { 1027 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 1028 1029 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 1030 1031 /* release the SCR */ 1032 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 1033 1034 /* Clear Measurement fields */ 1035 measurementMgrSM_resetParams(pMeasurementMgr); 1036 1037 /* Process New Frame */ 1038 return measurementMgrSM_acFrameReceived_fromIdle(pData); 1039 } 1040 1041 1042 1043 static TI_STATUS measurementMgrSM_acAbort_fromMeasuring(void * pData) 1044 { 1045 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 1046 1047 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 1048 1049 /* release the SCR */ 1050 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 1051 1052 /* Clear Measurement fields */ 1053 measurementMgrSM_resetParams(pMeasurementMgr); 1054 1055 TWD_StopMeasurement (pMeasurementMgr->hTWD, TI_TRUE ,NULL, NULL); 1056 1057 return TI_OK; 1058 } 1059 1060 1061 1062 /** 1063 * Called when we finished a measurement request. 1064 * 1065 * @date 05-Jan-2006 1066 */ 1067 static TI_STATUS measurementMgrSM_acMeasurementComplete(void * pData) 1068 { 1069 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 1070 requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH; 1071 1072 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Completing measurement operation and resuming normal behavior\n"); 1073 1074 /* advance the activeRequestID variable to get rid of the */ 1075 /* measurement requests we've already executed */ 1076 TRACE2(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Increasing activeRequestID from %d to %d.\n", pRequestH->activeRequestID, pRequestH->activeRequestID + pMeasurementMgr->currentNumOfRequestsInParallel); 1077 1078 pRequestH->activeRequestID += pMeasurementMgr->currentNumOfRequestsInParallel; 1079 1080 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 1081 1082 /* move the driver result table to stable state and clear it */ 1083 sme_MeansurementScanResult (pMeasurementMgr->hSme, SCAN_CRS_SCAN_COMPLETE_OK, NULL); 1084 1085 /* release the SCR */ 1086 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 1087 1088 /* Process New Frame */ 1089 return measurementMgr_activateNextRequest(pData); 1090 } 1091 1092 1093 1094 /** 1095 * Called when a firmware reset has been detected. 1096 * 1097 * @date 05-Jan-2006 1098 */ 1099 static TI_STATUS measurementMgrSM_acFirmwareReset(void * pData) 1100 { 1101 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 1102 1103 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Firmware Reset!!\n"); 1104 1105 setDefaultProbeReqTemplate (pMeasurementMgr->hSiteMgr); 1106 1107 /* release the SCR */ 1108 scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_XCC_MEASURE, SCR_RESOURCE_SERVING_CHANNEL); 1109 1110 /* Clear Measurement fields */ 1111 measurementMgrSM_resetParams(pMeasurementMgr); 1112 1113 return TI_OK; 1114 } 1115 1116 1117 1118 1119 1120 1121 1122 /********************************************************************************/ 1123 /* Miscellaneous State Actions */ 1124 /********************************************************************************/ 1125 1126 /** 1127 * Called when an unexpected event has been triggered. 1128 * 1129 * @date 05-Jan-2006 1130 */ 1131 static TI_STATUS measurementMgrSM_acUnexpected(void * pData) 1132 { 1133 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 1134 1135 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Entered when state is \n"); 1136 1137 return TI_OK; 1138 } 1139 1140 /** 1141 * A do nothing action. 1142 * 1143 * @date 05-Jan-2006 1144 */ 1145 static TI_STATUS measurementMgrSM_acNop(void * pData) 1146 { 1147 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; 1148 1149 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Entered when state is \n"); 1150 1151 return TI_OK; 1152 } 1153 1154 1155 1156 1157 1158 1159 1160 1161 /********************************************************************************/ 1162 /* Internal Functions Prototypes */ 1163 /********************************************************************************/ 1164 1165 1166 static void measurementMgrSM_resetParams(measurementMgr_t *pMeasurementMgr) 1167 { 1168 /* clear the waiting requests */ 1169 requestHandler_clearRequests(pMeasurementMgr->hRequestH); 1170 1171 /* clearing reports data base */ 1172 #ifdef XCC_MODULE_INCLUDED 1173 os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->XCCFrameReport), 1174 sizeof(RM_report_frame_t)); 1175 #endif 1176 os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->dot11hFrameReport), 1177 sizeof(MeasurementReportFrame_t)); 1178 1179 pMeasurementMgr->frameLength = 0; 1180 pMeasurementMgr->nextEmptySpaceInReport = 0; 1181 pMeasurementMgr->measuredChannelID = 0; 1182 pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE; 1183 } 1184 1185 1186 1187 /** 1188 * The callback called when the activation delay timer has ended. 1189 * 1190 * @param hMeasurementMgr - A handle to the Measurement Manager module. 1191 * @param bTwdInitOccured - Indicates if TWDriver recovery occured since timer started 1192 * 1193 * @date 01-Jan-2006 1194 */ 1195 static void measurementMgrSM_uponActivationDelayTimeout (TI_HANDLE hMeasurementMgr, TI_BOOL bTwdInitOccured) 1196 { 1197 measurementMgr_t * pMeasurementMgr = (measurementMgr_t *)hMeasurementMgr; 1198 1199 TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Activation delay timeout callback entered\n"); 1200 1201 measurementMgr_activateNextRequest (pMeasurementMgr); 1202 } 1203 1204