Home | History | Annotate | Download | only in Sta_Management
      1 /*
      2  * ScanCncnSmSpecific.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  /** \file  ScanCncnSmSpecific.c
     35  *  \brief Scan concentrator state machine type-specific functions implemenattion
     36  *
     37  *  \see   ScanCncnSm.h, ScanCncnSm.c
     38  */
     39 
     40 
     41 #define __FILE_ID__  FILE_ID_80
     42 #include "scrApi.h"
     43 #include "GenSM.h"
     44 #include "TWDriver.h"
     45 #include "ScanCncnSm.h"
     46 #include "ScanCncnPrivate.h"
     47 #include "apConn.h"
     48 
     49 /*
     50  * Aplication one-shot scan
     51  */
     52 /**
     53  * \fn     scanCncnSmApp1Shot_ScrRequest
     54  * \brief  Request the SCR for one-shot application scan
     55  *
     56  * Request the SCR for one-shot application scan. handle different results.
     57  *
     58  * \param  hScanCncnClient - handle to the specific client object
     59  * \return None
     60  */
     61 void scanCncnSmApp1Shot_ScrRequest (TI_HANDLE hScanCncnClient)
     62 {
     63     TScanCncnClient         *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
     64     EScrClientRequestStatus eScrReplyStatus;
     65     EScePendReason          eScrPendReason;
     66 
     67     /* request the SCR as application scan client, and act according to return status */
     68     switch (eScrReplyStatus = scr_clientRequest (pScanCncnClient->hSCR, SCR_CID_APP_SCAN,
     69                                                  SCR_RESOURCE_SERVING_CHANNEL, &eScrPendReason))
     70     {
     71     case SCR_CRS_PEND:
     72         /* send a reject event to the SM */
     73         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmApp1Shot_ScrRequest: SCR pending, pend reason: %d.\n", eScrPendReason);
     74         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
     75         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
     76         break;
     77 
     78     case SCR_CRS_RUN:
     79         /* send a run event to the SM */
     80         TRACE0(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmApp1Shot_ScrRequest: SCR acquired.\n");
     81         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_RUN, hScanCncnClient);
     82         break;
     83 
     84     default:
     85         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmApp1Shot_ScrRequest: SCR returned unrecognized status: %d.\n", eScrReplyStatus);
     86         /* Send a reject event to recover from this error */
     87         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
     88         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
     89         break;
     90    }
     91 }
     92 
     93 /**
     94  * \fn     scanCncnSmApp1Shot_ScrRelease
     95  * \brief  Release the SCR as one-shot application scan
     96  *
     97  * Release the SCR as one-shot application scan
     98  *
     99  * \param  hScanCncnClient - handle to the specific client object
    100  * \return None
    101  */
    102 void scanCncnSmApp1Shot_ScrRelease (TI_HANDLE hScanCncnClient)
    103 {
    104     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    105 
    106     /* release the SCR */
    107     scr_clientComplete (pScanCncnClient->hSCR, SCR_CID_APP_SCAN, SCR_RESOURCE_SERVING_CHANNEL);
    108 }
    109 
    110 /**
    111  * \fn     scanCncnSmApp1Shot_StartScan
    112  * \brief  Request scan start from TWD for one-shot application scan
    113  *
    114  * Request scan start from TWD for one-shot application scan
    115  *
    116  * \param  hScanCncnClient - handle to the specific client object
    117  * \return None
    118  */
    119 void scanCncnSmApp1Shot_StartScan (TI_HANDLE hScanCncnClient)
    120 {
    121     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    122     TScanCncn       *pScanCncn = (TScanCncn*)pScanCncnClient->hScanCncn;
    123     TI_BOOL         bPsRequired;
    124     TI_STATUS       tStatus;
    125 
    126     /* if the STA is connected, it is rquired to enter PS before scan */
    127     bPsRequired = (STA_CONNECTED == pScanCncn->eConnectionStatus ? TI_TRUE : TI_FALSE);
    128 
    129     /* call the TWD start scan - enter driver mode (PS) only if station is connected */
    130     tStatus = TWD_Scan (pScanCncnClient->hTWD, &(pScanCncnClient->uScanParams.tOneShotScanParams), SCAN_RESULT_TAG_APPLICATION_ONE_SHOT,
    131                        TI_FALSE, bPsRequired, TI_FALSE, POWER_SAVE_ON, /* this parameter is used only when driver mode requested */
    132                        bPsRequired, NULL, NULL);
    133 
    134     if (TI_OK != tStatus)
    135     {
    136         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmApp1Shot_StartScan: TWD returned status %d, quitting app scan.\n", tStatus);
    137 
    138         /* mark the return status */
    139         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    140 
    141         /* could not start scan, send a scan complete event to reset the SM */
    142         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    143     }
    144 }
    145 
    146 /**
    147  * \fn     scanCncnSmApp1Shot_StopScan
    148  * \brief  Request scan stop from TWD for one-shot application scan
    149  *
    150  * Request scan stop from TWD for one-shot application scan
    151  *
    152  * \param  hScanCncnClient - handle to the specific client object
    153  * \return None
    154  */
    155 void scanCncnSmApp1Shot_StopScan (TI_HANDLE hScanCncnClient)
    156 {
    157     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    158     TScanCncn       *pScanCncn = (TScanCncn*)pScanCncnClient->hScanCncn;
    159     TI_STATUS       tStatus;
    160 
    161     /* call the TWD stop scan function */
    162     if (pScanCncn->eConnectionStatus != STA_CONNECTED)
    163     {
    164         tStatus = TWD_StopScan (pScanCncnClient->hTWD, SCAN_RESULT_TAG_APPLICATION_ONE_SHOT, TI_FALSE, NULL, NULL);
    165     }
    166     else
    167     {
    168         tStatus = TWD_StopScan (pScanCncnClient->hTWD, SCAN_RESULT_TAG_APPLICATION_ONE_SHOT, pScanCncnClient->bSendNullDataOnStop, NULL, NULL);
    169     }
    170 
    171     /* if stop scan operation failed, send a scan complete event to reset the SM */
    172     if (TI_OK != tStatus)
    173     {
    174         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmApp1Shot_StopScan: status %d from TWD_StopScan, sending scan complete to SM\n", tStatus);
    175         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    176     }
    177 }
    178 
    179 /**
    180  * \fn     scanCncnSmApp1Shot_Recovery
    181  * \brief  Handles recovery during scan for one-shot application scan
    182  *
    183  * Notifies the scan SRV to stop its timer
    184  *
    185  * \param  hScanCncnClient - handle to the specific client object
    186  * \return None
    187  */
    188 void scanCncnSmApp1Shot_Recovery (TI_HANDLE hScanCncnClient)
    189 {
    190     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    191 
    192     /* Notify scan SRV to stop its timer */
    193     TWD_StopScanOnFWReset (pScanCncnClient->hTWD);
    194 }
    195 
    196 /*
    197  * Aplication Periodic scan
    198  */
    199 /**
    200  * \fn     scanCncnSmAppP_ScrRequest
    201  * \brief  Request the SCR for periodic application scan
    202  *
    203  * Request the SCR for periodic application scan. Handle different results
    204  *
    205  * \param  hScanCncnClient - handle to the specific client object
    206  * \return None
    207  */
    208 void scanCncnSmAppP_ScrRequest (TI_HANDLE hScanCncnClient)
    209 {
    210     TScanCncnClient         *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    211     EScrClientRequestStatus eScrReplyStatus;
    212     EScePendReason          eScrPendReason;
    213 
    214     /* request the SCR as application scan client, and act according to return status */
    215     switch (eScrReplyStatus = scr_clientRequest (pScanCncnClient->hSCR, SCR_CID_APP_SCAN,
    216                                                  SCR_RESOURCE_PERIODIC_SCAN, &eScrPendReason))
    217     {
    218     case SCR_CRS_PEND:
    219         /* send a reject event to the SM */
    220         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmAppP_ScrRequest: SCR pending, pend reason: %d.\n", eScrPendReason);
    221         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    222         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
    223         break;
    224 
    225     case SCR_CRS_RUN:
    226         /* send a run event to the SM */
    227         TRACE0(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmAppP_ScrRequest: SCR acquired.\n");
    228         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_RUN, hScanCncnClient);
    229         break;
    230 
    231     default:
    232         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmAppP_ScrRequest: SCR returned unrecognized status: %d.\n", eScrReplyStatus);
    233         /* Send a reject event to recover from this error */
    234         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    235         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
    236         break;
    237    }
    238 }
    239 
    240 /**
    241  * \fn     scanCncnSmAppP_ScrRelease
    242  * \brief  Release the SCR as periodic application scan
    243  *
    244  * Release the SCR as periodic application scan
    245  *
    246  * \param  hScanCncnClient - handle to the specific client object
    247  * \return None
    248  */
    249 void scanCncnSmAppP_ScrRelease (TI_HANDLE hScanCncnClient)
    250 {
    251     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    252 
    253     /* release the SCR */
    254     scr_clientComplete (pScanCncnClient->hSCR, SCR_CID_APP_SCAN, SCR_RESOURCE_PERIODIC_SCAN);
    255 }
    256 
    257 /**
    258  * \fn     scanCncnSmAppP_StartScan
    259  * \brief  Request scan start from TWD for periodic application scan
    260  *
    261  * Request scan start from TWD for periodic application scan
    262  *
    263  * \param  hScanCncnClient - handle to the specific client object
    264  * \return None
    265  */
    266 void scanCncnSmAppP_StartScan (TI_HANDLE hScanCncnClient)
    267 {
    268     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    269     TScanCncn       *pScanCncn = (TScanCncn*)pScanCncnClient->hScanCncn;
    270     TI_STATUS       tStatus;
    271 
    272     /* call the TWD start scan */
    273     tStatus = TWD_StartConnectionScan (pScanCncnClient->hTWD, &(pScanCncnClient->uScanParams.tPeriodicScanParams),
    274                                        SCAN_RESULT_TAG_APPLICATION_PEIODIC,
    275                                        pScanCncn->tInitParams.uDfsPassiveDwellTimeMs, NULL, NULL);
    276     if (TI_OK != tStatus)
    277     {
    278         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmAppP_StartScan: TWD returned status %d, quitting app scan.\n", tStatus);
    279 
    280         /* mark the return status */
    281         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    282 
    283         /* could not start scan, send a scan complete event to reset the SM */
    284         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    285     }
    286 }
    287 
    288 /**
    289  * \fn     scanCncnSmAppP_StopScan
    290  * \brief  Request scan stop from TWD for periodic application scan
    291  *
    292  * Request scan stop from TWD for periodic application scan
    293  *
    294  * \param  hScanCncnClient - handle to the specific client object
    295  * \return None
    296  */
    297 void scanCncnSmAppP_StopScan (TI_HANDLE hScanCncnClient)
    298 {
    299     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    300     TI_STATUS       status;
    301 
    302     /* call the TWD stop periodic scan function */
    303     status = TWD_StopPeriodicScan (pScanCncnClient->hTWD, SCAN_RESULT_TAG_APPLICATION_PEIODIC, NULL, NULL);
    304 
    305     /* if stop scan operation failed, send a scan complete event to reset the SM */
    306     if (TI_OK != status)
    307     {
    308         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmAppP_StopScan: status %d from TWD_StopPeriodicScan, sending scan complete to SM\n", status);
    309         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    310     }
    311 }
    312 
    313 /**
    314  * \fn     scanCncnSmAppP_Recovery
    315  * \brief  Handles recovery during scan for periodic application scan
    316  *
    317  * Handles recovery during scan for periodic application scan
    318  *
    319  * \param  hScanCncnClient - handle to the specific client object
    320  * \return None
    321  */
    322 void scanCncnSmAppP_Recovery (TI_HANDLE hScanCncnClient)
    323 {
    324 }
    325 
    326 /*
    327  * Driver periodic scan
    328  */
    329 /**
    330  * \fn     scanCncnSmDrvP_ScrRequest
    331  * \brief  Request the SCR for periodic driver scan
    332  *
    333  * Request the SCR for periodic driver scan. Handle different results
    334  *
    335  * \param  hScanCncnClient - handle to the specific client object
    336  * \return None
    337  */
    338 void scanCncnSmDrvP_ScrRequest (TI_HANDLE hScanCncnClient)
    339 {
    340     TScanCncnClient         *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    341     EScrClientRequestStatus eScrReplyStatus;
    342     EScePendReason          eScrPendReason;
    343 
    344     /* request the SCR as driver scan client, and act according to return status */
    345     switch (eScrReplyStatus = scr_clientRequest( pScanCncnClient->hSCR, SCR_CID_DRIVER_FG_SCAN,
    346                                                  SCR_RESOURCE_PERIODIC_SCAN, &eScrPendReason ) )
    347     {
    348     case SCR_CRS_PEND:
    349         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmAppP_ScrRequest: SCR pending, pend reason: %d.\n", eScrPendReason);
    350 
    351         /* check the pending reason */
    352         if (SCR_PR_OTHER_CLIENT_ABORTING != eScrPendReason)
    353         {
    354             /*
    355              * send a reject event to the SM - would not scan if not in a different group or
    356              * another un-abortable client is running
    357              */
    358             pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    359             genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
    360         }
    361         /* if the pending reason is another client aborting wait untill it finish abort */
    362         break;
    363 
    364     case SCR_CRS_RUN:
    365         /* send a run event to the SM */
    366         TRACE0(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmAppP_ScrRequest: SCR acquired.\n");
    367         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_RUN, hScanCncnClient);
    368         break;
    369 
    370     default:
    371         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmAppP_ScrRequest: SCR returned unrecognized status: %d\n", eScrReplyStatus);
    372         /* Send a reject event to recover from this error */
    373         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    374         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
    375         break;
    376     }
    377 }
    378 
    379 /**
    380  * \fn     scanCncnSmDrvP_ScrRelease
    381  * \brief  Release the SCR as periodic driver scan
    382  *
    383  * Release the SCR as periodic driver scan
    384  *
    385  * \param  hScanCncnClient - handle to the specific client object
    386  * \return None
    387  */
    388 void scanCncnSmDrvP_ScrRelease (TI_HANDLE hScanCncnClient)
    389 {
    390     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    391 
    392     /* release the SCR */
    393     scr_clientComplete (pScanCncnClient->hSCR, SCR_CID_DRIVER_FG_SCAN, SCR_RESOURCE_PERIODIC_SCAN);
    394 }
    395 
    396 /**
    397  * \fn     scanCncnSmDrvP_StartScan
    398  * \brief  Request scan start from TWD for periodic driver scan
    399  *
    400  * Request scan start from TWD for periodic driver scan
    401  *
    402  * \param  hScanCncnClient - handle to the specific client object
    403  * \return None
    404  */
    405 void scanCncnSmDrvP_StartScan (TI_HANDLE hScanCncnClient)
    406 {
    407     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    408     TScanCncn       *pScanCncn = (TScanCncn*)pScanCncnClient->hScanCncn;
    409     TI_STATUS       status;
    410 
    411     /* call the TWD_scan function */
    412     status = TWD_StartConnectionScan (pScanCncnClient->hTWD, &(pScanCncnClient->uScanParams.tPeriodicScanParams),
    413                                       SCAN_RESULT_TAG_DRIVER_PERIODIC,
    414                                       pScanCncn->tInitParams.uDfsPassiveDwellTimeMs, NULL, NULL);
    415 
    416     if (TI_OK != status)
    417     {
    418         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmDrvP_StartScan: TWD returned status %d, quitting app scan.\n", status);
    419 
    420         /* mark the return status */
    421         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    422 
    423         /* could not start scan, send a scan complete event to reset the SM */
    424         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    425     }
    426 }
    427 
    428 /**
    429  * \fn     scanCncnSmDrvP_StopScan
    430  * \brief  Request scan stop from TWD for periodic driver scan
    431  *
    432  * Request scan stop from TWD for periodic driver scan
    433  *
    434  * \param  hScanCncnClient - handle to the specific client object
    435  * \return None
    436  */
    437 void scanCncnSmDrvP_StopScan (TI_HANDLE hScanCncnClient)
    438 {
    439     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    440     TI_STATUS       status;
    441 
    442     /* call the TWD stop periodic scan */
    443     status = TWD_StopPeriodicScan (pScanCncnClient->hTWD, SCAN_RESULT_TAG_DRIVER_PERIODIC, NULL, NULL);
    444 
    445     /* if stop scan operation failed, send a scan complete event to reset the SM */
    446     if (TI_OK != status)
    447     {
    448         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmDrvP_StopScan: status %d from TWD_StopPeriodicScan, sending scan complete to SM\n", status);
    449         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    450     }
    451 }
    452 
    453 /**
    454  * \fn     scanCncnSmApp1Shot_Recovery
    455  * \brief  Handles recovery during scan for periodic driver scan
    456  *
    457  * Handles recovery during scan for periodic driver scan
    458  *
    459  * \param  hScanCncnClient - handle to the specific client object
    460  * \return None
    461  */
    462 void scanCncnSmDrvP_Recovery (TI_HANDLE hScanCncnClient)
    463 {
    464 }
    465 
    466 /*
    467  * Continuous one-shot scan
    468  */
    469 /**
    470  * \fn     scanCncnSmCont1Shot_ScrRequest
    471  * \brief  Request the SCR for one-shot continuous scan
    472  *
    473  * Request the SCR for one-shot continuous scan. Handle different results
    474  *
    475  * \param  hScanCncnClient - handle to the specific client object
    476  * \return None
    477  */
    478 void scanCncnSmCont1Shot_ScrRequest (TI_HANDLE hScanCncnClient)
    479 {
    480     TScanCncnClient         *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    481     EScrClientRequestStatus eScrReplyStatus;
    482     EScePendReason          eScrPendReason;
    483 
    484     /* request the SCR as continuous roaming client, and act according to return status */
    485     switch (eScrReplyStatus = scr_clientRequest (pScanCncnClient->hSCR, SCR_CID_CONT_SCAN,
    486                                                 SCR_RESOURCE_SERVING_CHANNEL, &eScrPendReason ) )
    487     {
    488     case SCR_CRS_PEND:
    489         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmCont1Shot_ScrRequest: SCR pending, pend Reason: %d.\n", eScrPendReason);
    490         /* check pend reason */
    491         if (SCR_PR_DIFFERENT_GROUP_RUNNING == eScrPendReason)
    492         {
    493             /* send a reject event to the SM - will not scan if not in connected group */
    494             pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    495             genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
    496         }
    497         /* for other pending reasons wait untill current client finishes */
    498         break;
    499 
    500     case SCR_CRS_RUN:
    501         /* send a run event to the SM */
    502         TRACE0(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmCont1Shot_ScrRequest: SCR acquired.\n");
    503         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_RUN, hScanCncnClient);
    504         break;
    505 
    506     default:
    507         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmCont1Shot_ScrRequest: SCR returned unrecognized status: %d.\n", eScrReplyStatus);
    508         /* Send a reject event to recover from this error */
    509         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    510         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
    511         break;
    512     }
    513 }
    514 
    515 /**
    516  * \fn     scanCncnSmCont1Shot_ScrRelease
    517  * \brief  Release the SCR as one-shot continuous scan
    518  *
    519  * Release the SCR as one-shot continuous scan
    520  *
    521  * \param  hScanCncnClient - handle to the specific client object
    522  * \return None
    523  */
    524 void scanCncnSmCont1Shot_ScrRelease (TI_HANDLE hScanCncnClient)
    525 {
    526     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    527 
    528     /* release the SCR */
    529     scr_clientComplete (pScanCncnClient->hSCR, SCR_CID_CONT_SCAN, SCR_RESOURCE_SERVING_CHANNEL);
    530 }
    531 
    532 /**
    533  * \fn     scanCncnSmCont1Shot_StartScan
    534  * \brief  Request scan start from TWD for one-shot continuous scan
    535  *
    536  * Request scan start from TWD for one-shot continuous scan
    537  *
    538  * \param  hScanCncnClient - handle to the specific client object
    539  * \return None
    540  */
    541 void scanCncnSmCont1Shot_StartScan (TI_HANDLE hScanCncnClient)
    542 {
    543     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    544     TI_STATUS       status;
    545 
    546     /* call the TWD start scan function */
    547     status = TWD_Scan (pScanCncnClient->hTWD, &(pScanCncnClient->uScanParams.tOneShotScanParams),
    548                        SCAN_RESULT_TAG_CONTINUOUS, TI_FALSE, TI_TRUE, TI_FALSE, POWER_SAVE_ON, TI_TRUE,
    549                        NULL, NULL);
    550 
    551     if (TI_OK != status)
    552     {
    553         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmCont1Shot_StartScan: TWD returned status %d, quitting continuous scan.\n", status);
    554 
    555         /* mark the return status */
    556         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    557 
    558         /* could not start scan, send a scan complete event */
    559         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    560     }
    561 }
    562 
    563 /**
    564  * \fn     scanCncnSmCont1Shot_StopScan
    565  * \brief  Request scan stop from TWD for one-shot continuous scan
    566  *
    567  * Request scan stop from TWD for one-shot continuous scan
    568  *
    569  * \param  hScanCncnClient - handle to the specific client object
    570  * \return None
    571  */
    572 void scanCncnSmCont1Shot_StopScan (TI_HANDLE hScanCncnClient)
    573 {
    574     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    575     TI_STATUS       status;
    576 
    577     /* send a stop scan command to FW */
    578     status = TWD_StopScan (pScanCncnClient->hTWD, SCAN_RESULT_TAG_CONTINUOUS, pScanCncnClient->bSendNullDataOnStop, NULL, NULL);
    579 
    580     /* if stop scan operation failed, send a scan complete event to reset the SM */
    581     if (TI_OK != status)
    582     {
    583         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmCont1Shot_StopScan: status %d from TWD_StopScan, sending scan complete to SM\n", status);
    584         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    585     }
    586 }
    587 
    588 /**
    589  * \fn     scanCncnSmCont1Shot_Recovery
    590  * \brief  Handles recovery during scan for one-shot continuous scan
    591  *
    592  * Notifies the scan SRV to stop its timer
    593  *
    594  * \param  hScanCncnClient - handle to the specific client object
    595  * \return None
    596  */
    597 void scanCncnSmCont1Shot_Recovery (TI_HANDLE hScanCncnClient)
    598 {
    599     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    600 
    601     /* Notify scan SRV to stop its timer */
    602     TWD_StopScanOnFWReset (pScanCncnClient->hTWD);
    603 }
    604 
    605 /*
    606  * Immediate one-shot scan
    607  */
    608 /**
    609  * \fn     scanCncnSmImmed1Shot_ScrRequest
    610  * \brief  Request the SCR for one-shot immediate scan
    611  *
    612  * Request the SCR for one-shot immediate scan. Handle different results
    613  *
    614  * \param  hScanCncnClient - handle to the specific client object
    615  * \return None
    616  */
    617 void scanCncnSmImmed1Shot_ScrRequest (TI_HANDLE hScanCncnClient)
    618 {
    619     TScanCncnClient         *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    620     EScrClientRequestStatus eScrReplyStatus;
    621     EScePendReason          eScrPendReason;
    622 
    623     /* request the SCR as immediate roaming client, and act according to return status */
    624     switch (eScrReplyStatus = scr_clientRequest (pScanCncnClient->hSCR, SCR_CID_IMMED_SCAN,
    625                                                  SCR_RESOURCE_SERVING_CHANNEL, &eScrPendReason))
    626     {
    627     case SCR_CRS_PEND:
    628         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmImmed1Shot_ScrRequest: SCR pending, pend Reason: %d.\n", eScrPendReason);
    629 
    630         /* check pend reason */
    631         if ( SCR_PR_DIFFERENT_GROUP_RUNNING == eScrPendReason )
    632         {
    633             /* send a reject event to the SM - will not scan if not in the correct group */
    634             pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    635             genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
    636         }
    637         /* for other pending reasons wait untill current client finishes */
    638         break;
    639 
    640     case SCR_CRS_RUN:
    641         /* send a run event to the SM */
    642         TRACE0(pScanCncnClient->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnSmImmed1Shot_ScrRequest: SCR acquired.\n");
    643         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_RUN, hScanCncnClient);
    644         break;
    645 
    646     default:
    647         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmImmed1Shot_ScrRequest: SCR returned unrecognized status: %d.\n", eScrReplyStatus);
    648         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    649         /* Send a reject event to recover from this error */
    650         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_REJECT, hScanCncnClient);
    651         break;
    652     }
    653 }
    654 
    655 /**
    656  * \fn     scanCncnSmImmed1Shot_ScrRelease
    657  * \brief  Release the SCR as one-shot immediate scan
    658  *
    659  * Release the SCR as one-shot immediate scan
    660  *
    661  * \param  hScanCncnClient - handle to the specific client object
    662  * \return None
    663  */
    664 void scanCncnSmImmed1Shot_ScrRelease (TI_HANDLE hScanCncnClient)
    665 {
    666     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    667 
    668     /* release the SCR */
    669     scr_clientComplete (pScanCncnClient->hSCR, SCR_CID_IMMED_SCAN, SCR_RESOURCE_SERVING_CHANNEL);
    670 }
    671 
    672 /**
    673  * \fn     scanCncnSmImmed1Shot_StartScan
    674  * \brief  Request scan start from TWD for one-shot immediate scan
    675  *
    676  * Request scan start from TWD for one-shot immediate scan
    677  *
    678  * \param  hScanCncnClient - handle to the specific client object
    679  * \return None
    680  */
    681 void scanCncnSmImmed1Shot_StartScan (TI_HANDLE hScanCncnClient)
    682 {
    683     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    684     TI_BOOL         bPsRequired, bTriggeredScan;
    685     TI_STATUS       status;
    686 
    687     /* check whether enter PS is required - according to the roaming reason severity */
    688     bPsRequired = apConn_isPsRequiredBeforeScan (pScanCncnClient->hApConn);
    689     bTriggeredScan = ((SCAN_TYPE_TRIGGERED_ACTIVE == pScanCncnClient->uScanParams.tOneShotScanParams.scanType) ||
    690                       (SCAN_TYPE_TRIGGERED_PASSIVE == pScanCncnClient->uScanParams.tOneShotScanParams.scanType)
    691                       ? TI_TRUE : TI_FALSE);
    692 
    693     status = TWD_Scan (pScanCncnClient->hTWD, &(pScanCncnClient->uScanParams.tOneShotScanParams),
    694                        SCAN_RESULT_TAG_IMMEDIATE, !bTriggeredScan, /* Triggered scan cannot be high priority */
    695                        TI_TRUE, TI_TRUE, (bPsRequired ? POWER_SAVE_ON : POWER_SAVE_KEEP_CURRENT),
    696                        bPsRequired, NULL, NULL);
    697 
    698     /* call the scan SRV start scan */
    699     if (TI_OK != status)
    700     {
    701         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmImmed1Shot_StartScan: TWD start scanreturned status %d, quitting immediate scan.\n", status);
    702 
    703         /* mark the return status */
    704         pScanCncnClient->eScanResult = SCAN_CRS_SCAN_FAILED;
    705 
    706         /* could not start scan, send a scan complete event */
    707         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    708     }
    709 }
    710 
    711 /**
    712  * \fn     scanCncnSmImmed1Shot_StopScan
    713  * \brief  Request scan stop from TWD for one-shot immediate scan
    714  *
    715  * Request scan stop from TWD for one-shot immediate scan
    716  *
    717  * \param  hScanCncnClient - handle to the specific client object
    718  * \return None
    719  */
    720 void scanCncnSmImmed1Shot_StopScan (TI_HANDLE hScanCncnClient)
    721 {
    722     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    723     TI_STATUS       status;
    724 
    725     /* call the TWD stop scan */
    726     status = TWD_StopScan (pScanCncnClient->hTWD, SCAN_RESULT_TAG_IMMEDIATE, pScanCncnClient->bSendNullDataOnStop, NULL, NULL);
    727 
    728     /* if stop scan operation failed, send a scan complete event to reset the SM */
    729     if (TI_OK != status)
    730     {
    731         TRACE1(pScanCncnClient->hReport, REPORT_SEVERITY_ERROR , "scanCncnSmImmed1Shot_StopScan: status %d from TWD_StopScan, sending scan complete to SM\n", status);
    732         genSM_Event (pScanCncnClient->hGenSM, SCAN_CNCN_SM_EVENT_SCAN_COMPLETE, hScanCncnClient);
    733     }
    734 }
    735 
    736 /**
    737  * \fn     scanCncnSmImmed1Shot_Recovery
    738  * \brief  Handles recovery during scan for one-shot immediate scan
    739  *
    740  * Notifies the scan SRV to stop its timer
    741  *
    742  * \param  hScanCncnClient - handle to the specific client object
    743  * \return None
    744  */
    745 void scanCncnSmImmed1Shot_Recovery (TI_HANDLE hScanCncnClient)
    746 {
    747     TScanCncnClient *pScanCncnClient = (TScanCncnClient*)hScanCncnClient;
    748 
    749     /* Notify scan SRV to stop its timer */
    750     TWD_StopScanOnFWReset (pScanCncnClient->hTWD);
    751 }
    752 
    753