This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

函数GAPRole_SetParameter中实现GAPROLE_ADVERT_ENABLED的代码看起来令我很疑惑,你来一起看看?



simpleBLEPeripheral工程中,文件peripheral.c中:

bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue )

 {   bStatus_t ret = SUCCESS;  

      switch ( param )

    ....

case GAPROLE_ADVERT_ENABLED:

      if ( len == sizeof( uint8 ) )

      {

        uint8 oldAdvEnabled = gapRole_AdvEnabled;  //函数每次调用时都会执行,oldAdvEnabled永远为ture。??

        gapRole_AdvEnabled = *((uint8*)pValue);

 

        if ( (oldAdvEnabled) && (gapRole_AdvEnabled == FALSE) )

        {

          // Turn off Advertising

          if ( gapRole_state == GAPROLE_ADVERTISING )

          {

            VOID GAP_EndDiscoverable( gapRole_TaskID );

          }

        }

        else if ( (oldAdvEnabled == FALSE) && (gapRole_AdvEnabled) )  //这个条件永远不能满足??

        {

          // Turn on Advertising

          if ( (gapRole_state == GAPROLE_STARTED)

              || (gapRole_state == GAPROLE_WAITING)

              || (gapRole_state == GAPROLE_WAITING_AFTER_TIMEOUT) )

          {

            VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );

          }

        }

      }

      else

      {

        ret = bleInvalidRange;

      }

      break;