微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > cc2541+cc2591 停止廣播

cc2541+cc2591 停止廣播

时间:10-02 整理:3721RD 点击:

硬體: cc2541+cc2591

使用一段時間後(1小時內~12小時以上都有遇過),

發現sniffer和手機都掃描不到cc2541,

當cc2541停止廣播時,

用Debugger查看gapRoleState是GAPROLE_ADVERTISING

此時卻可以用長按按鈕來觸發LED閃爍(做法是中斷+osal timer)

reset或者斷電重啟後, 即可恢復廣播

廣播相關的代碼如下,


#define DEFAULT_ADVERTISING_INTERVAL_MIN          32  // 20ms
#define DEFAULT_ADVERTISING_INTERVAL_MAX          48  // 30ms
#define DEFAULT_DISCOVERABLE_MODE             GAP_ADTYPE_FLAGS_GENERAL

{
    // For other hardware platforms, device starts advertising upon initialization
    uint8 initial_advertising_enable = TRUE;

    // By setting this to zero, the device will go into the waiting state after
    // being discoverable for 30.72 second, and will not being advertising again
    // until the enabler is set back to TRUE
    uint16 gapRole_AdvertOffTime = 0;
}

  // Set advertising interval
  {
    uint16 advIntMin = DEFAULT_ADVERTISING_INTERVAL_MIN;
    uint16 advIntMax = DEFAULT_ADVERTISING_INTERVAL_MAX;

    // GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, advInt );
    // GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, advInt );
    GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, advIntMin );
    GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, advIntMax );
  }

閃爍的做法是用osal timer 如下

uint16 SimpleBLEPeripheral_ProcessEvent( uint8 task_id, uint16 events )
{
  // ...

  if ( events & LED_BLINKING_EVT )
  {
    LED_PIN = ~LED_PIN;                // 切換LED狀態
    
    counter_led++;
    if ( counter_led < led_blink_times )
    { // restart led blinking timer
      osal_start_timerEx( simpleBLEPeripheral_TaskID, LED_BLINKING_EVT, LED_BLINKING_PERIOD );
    }
    return (events ^ LED_BLINKING_EVT);
  }
}

請問為什麼會停止廣播呢?

感觉是状态集混乱了,

查一下软件看是不是有什么地方关掉了广播但是没有更新gapRoleState的

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top