微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > GAP_MakeDiscoverable bleAlreadyInRequestedMode

GAP_MakeDiscoverable bleAlreadyInRequestedMode

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

各位大神好

最近在研究 auto-switch,碰到一些問題

當CENTRAL轉換成PERIPHERAL時,透過GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );

advertising沒有起動,透過串口發現卡在GAP_MakeDiscoverable 回傳值是bleAlreadyInRequestedMode(0x11)

查了一下沒有針對這方面的解說,只有看到TI BLE Vendor Specific HCI Reference Guide中有提到: Not available at this time.

想問一下此函式的時間上使用限制,此函式也只能看到回傳的值,無法看到內部。

謝謝

论坛有相关问题的讨论,请看这边: http://e2e.ti.com/support/wireless_connectivity/f/538/p/233888/820767

 Viki Shi :

謝謝您回覆 。問題已解決。

目前想針對 在adverting 時 可以改變BDAddress嗎?

透過HCI_EXT_SetBDADDRCmd(bdAddress); 查看了一下講解只能在device state 為Standby時使用。

也看了一下GAP_ConfigDeviceAddr( ADDRTYPE_STATIC, bdAddress ); return為bleIncorrectMode。

想知道問題出在哪裡?也試過ADDRTYPE_PRIVATE_RESOLVE了

* @brief Setup the device's address type. If ADDRTYPE_PRIVATE_RESOLVE
* is selected, the address will change periodically.

Viki Shi  您好:

目前又碰到一樣的問題了,而且也針對您回覆的論壇聯結去做檢測,也把後來有新增的代碼都刪除了。還是找不到問題所在,一樣返回

 bleAlreadyInRequestedMode 

上網查看了一下,這句話的意思是"已經在此狀態了",所以我透過GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );開起Adveristing才會return  

 bleAlreadyInRequestedMode 

我這樣分析對嗎?

另外,我針對您付上的連結 所做出的代碼如下:

When switching, the following works for me:

1) When in central role, GAPCentralRole_TerminateLink () until SUCCESS, then idle till GAP_LINK_TERMINATED_EVENT. 

static uint8 state_term;
if(deviceList[1].state == BLE_STATE_CONNECTED )//斷開連接
{

//cancel current link request
//GAPCentralRole_TerminateLink(GAP_CONNHANDLE_INIT );

//GAPCentralRole_TerminateLink( GAP_CONNHANDLE_ALL );

state_term=GAPCentralRole_TerminateLink(deviceList[1].connHandle);

}

if(state_term == 0 && deviceList[1].state == BLE_STATE_IDLE )

{

masterSlave_State =BLE_STATE_DISCONNECTING;//下一次periodicCentralTask 會進入的地方 //periodic 設定為7000

}

//附上periodicCentralTask 中masterSlave_State =BLE_STATE_DISCONNECTING的地方

case BLE_STATE_DISCONNECTING:
case BLE_STATE_IDLE:

if(deviceRole == ROLE_CENTRAL)
{
//are we finished disconnecting
if(numDevices == 1)
{
// set new role to peripheral
deviceRole = ROLE_PERIPHERAL;

masterSlave_State = BLE_STATE_ADVERTISING;
//restet to peripheral and advertise
osal_start_timerEx( simpleBLETaskId, SBP_START_DEVICE_EVT, 100 );//100

}

2) From CentralEventCB, schedule Peripheral restart event with 100 delay. 3) In Peripheral restart event, call GAPRole_StartDevice, and then following check:

if ( events & SBP_START_DEVICE_EVT )

{

 

if(deviceRole == ROLE_CENTRAL) //ZH
{
  // Start the Device
  VOID GAPCentralRole_StartDevice( (gapCentralRoleCB_t *) &simpleBLERoleCB );

  // Always connecting or connected when central
  masterSlave_State = BLE_STATE_CONNECTING;
}
if(deviceRole == ROLE_PERIPHERAL)
{
  // Start the Device (must be in GAPROLE_INIT state)
  VOID GAPRole_StartDevice( &simpleBLEPeripheral_PeripheralCBs );
  if( gapProfileState != GAPROLE_CONNECTED )
  {
  GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &on_adv_enabled_status );
  }
  masterSlave_State = BLE_STATE_ADVERTISING;
}

}

return ( events ^ SBP_START_DEVICE_EVT );
}

4) Same check before GAPCentralRole_StartDevice(): I call GAPRole_TerminateConnection(), then wait until Peripheral device snaps out of  GAPROLE_CONNECTED, and only then goes:  

這邊我就沒有照做了,我是先GAPRole_TerminateConnection(),然後GAPCentralRole_StartDevice(): 進入periodicCentralTask 再做GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &off_adv_enabled_status ); 

hint:已經有先define off_adv_enabled_statuse=FALSE跟on_adv_enabled_status=TURE了。

東西有點多,不好意思,麻煩您檢查了。

已發現問題點。重點就是在當peripheral 端變成central 時的狀態停留點。

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

网站地图

Top