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

BLE peripheralStateNotificationCB Error

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

目前想做到central自動連接到peripheral (參考官網wiki修改:http://processors.wiki.ti.com/index.php/MasterSlaveSwitchV1_4),那連接完後,透過periodicCentralTask 這個function 自動轉換成peripheral。

MasterSlaveSwitch如下方官方提供:

if ( events & SBP_START_DEVICE_EVT )
{
// Init device role
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)//else //PERIPHERAL
{
// Start the Device (must be in GAPROLE_INIT state)
VOID GAPRole_StartDevice( &simpleBLEPeripheral_PeripheralCBs );

masterSlave_State = BLE_STATE_ADVERTISING;
}

if(initDone == FALSE)
{
// Start Bond Manager
VOID GAPBondMgr_Register( &simpleBLEPeripheral_BondMgrCBs );

// Set timer for first periodic event
osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, 200 );
initDone = TRUE;
}

碰到的一些問題 

GAPCentralRole_TerminateLink(目前連接的connhandle);

/ set new role to peripheral
deviceRole = ROLE_PERIPHERAL;
masterSlave_State = BLE_STATE_ADVERTISING;//BLE_STATE_DISCONNECTING

initCount =3;

osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_START_DEVICE_EVT, 100 );

也有進入peripheralStateNotificationCB 中的GAPROLE_STARTED: 

並且在裡面加入

if(initCount >1)    //
{
uint8 turnOnAdv = TRUE;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &turnOnAdv );
HalUARTWrite(0,"initCount>1~",12);
}

結果接下來peripheralStateNotificationCB  就回覆Error 了

有人知道為甚麼嗎??要advertising不是只要enable就好了嗎??為啥設定完會error?

謝謝

上一篇:CC2540 PWM
下一篇:BTOOL如何抓广播包

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

网站地图

Top