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

2540 SimpleBLEPeripheral与SimpleBLECentral问题

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

各位好:

         我想更改默认SimpleBLEPeripheral与SimpleBLECentral让他们上电后直接连上。

更改如下:

    SimpleBLEPeripheral:

if ( events & SBP_START_DEVICE_EVT )
{
// Start the Device
VOID GAPRole_StartDevice( &simpleBLEPeripheral_PeripheralCBs );

// Start Bond Manager
VOID GAPBondMgr_Register( &simpleBLEPeripheral_BondMgrCBs );

// Set timer for first periodic event
bool advertising_enable=true;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &advertising_enable );

}

SimpleBLECentral:

搜索

if ( events & START_DEVICE_EVT )
{
// Start the Device
VOID GAPCentralRole_StartDevice( (gapCentralRoleCB_t *) &simpleBLERoleCB );

// Register with bond manager after starting device
GAPBondMgr_Register( (gapBondCBs_t *) &simpleBLEBondCB );

GAPCentralRole_StartDiscovery( DEFAULT_DISCOVERY_MODE,
DEFAULT_DISCOVERY_ACTIVE_SCAN,
DEFAULT_DISCOVERY_WHITE_LIST );

return ( events ^ START_DEVICE_EVT );
}

连接

case GAP_DEVICE_INFO_EVENT:
{
// if filtering device discovery results based on service UUID
if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE )
{
if ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV_UUID,
pEvent->deviceInfo.pEvtData,
pEvent->deviceInfo.dataLen ) )
{
GAPCentralRole_CancelDiscovery();
GAPCentralRole_EstablishLink( DEFAULT_LINK_HIGH_DUTY_CYCLE,
DEFAULT_LINK_WHITE_LIST,
pEvent->deviceInfo.addrType, pEvent->deviceInfo.addr );
}
}
}
break;

查询service

static void simpleBLECentralStartDiscovery( void )
{
uint8 uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID)};

// Initialize cached handles
simpleBLESvcStartHdl = simpleBLESvcEndHdl = simpleBLECharHdl = 0;

simpleBLEDiscState = BLE_DISC_STATE_SVC;

// Discovery simple BLE service
GATT_DiscPrimaryServiceByUUID( simpleBLEConnHandle,
uuid,
ATT_BT_UUID_SIZE,
simpleBLETaskId );
}

central连接成功后一直无法查询到service。service的uuid反复确认了没有问题。SimpleBLEPeripheral用TI手机的app也能连接成功。

是因为central的这个流程有问题吗?还是有些参数没有设置对。

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

网站地图

Top