2540 SimpleBLEPeripheral与SimpleBLECentral问题
各位好:
我想更改默认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的这个流程有问题吗?还是有些参数没有设置对。
SimpleBLEPeripheral SimpleBLECentral 相关文章:
- 蓝牙从机事件处理函数 SimpleBLEPeripheral_ProcessEvent的疑问
- 我的cc2540 用simpleBLEperipheral 刷完之后怎么只有 generic access service 这一个,没有其它的服务呢?
- SimpleBLEPeripheral中的Characteristic 1 2 3 4 5的模式都是定死的吗?
- SimpleBLEPeripheral_bond实验例程
- 关于从机SimpleBLEPeripheral例程中的SBP_PERIODIC_EVT
- 关于蓝牙协议栈1.3.2中SimpleBLECentral和SimpleBLEPeripheral函数的详解