TI中文支持网
TI专业的中文技术问题搜集分享网站

函数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;

BB AA1:

gapRole_AdvEnabled为static全局变量,不是define,其会改变。

源代码无误。

赞(0)
未经允许不得转载:TI中文支持网 » 函数GAPRole_SetParameter中实现GAPROLE_ADVERT_ENABLED的代码看起来令我很疑惑,你来一起看看?
分享到: 更多 (0)