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

cc2541+cc2591 停止廣播

硬體: cc2541+cc2591

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

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

當cc2541停止廣播時,

用Debugger查看gapRoleState是GAPROLE_ADVERTISING

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

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

廣播相關的代碼如下,


#define DEFAULT_ADVERTISING_INTERVAL_MIN32  // 20ms
#define DEFAULT_ADVERTISING_INTERVAL_MAX48  // 30ms
#define DEFAULT_DISCOVERABLE_MODEGAP_ADTYPE_FLAGS_GENERAL

{// For other hardware platforms, device starts advertising upon initializationuint8 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 TRUEuint16 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 timerosal_start_timerEx( simpleBLEPeripheral_TaskID, LED_BLINKING_EVT, LED_BLINKING_PERIOD );}return (events ^ LED_BLINKING_EVT);}
}

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

Barbara Wu:

感觉是状态集混乱了,

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

赞(0)
未经允许不得转载:TI中文支持网 » cc2541+cc2591 停止廣播
分享到: 更多 (0)