我现在一个Central和一个Peripheral建立连接,Central通过写CHAR1和读CHAR2与Peripheral进行数据通信。BLE-CC254x-1.3.2版本的BLE协议栈的Central和Peripheral的例子好像一个Central不能和多个Peripheral建立连接。如果要一个Central不能和多个Peripheral建立连接应该如何做?
Central的是client, Peripheral都是server。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我现在一个Central和一个Peripheral建立连接,Central通过写CHAR1和读CHAR2与Peripheral进行数据通信。BLE-CC254x-1.3.2版本的BLE协议栈的Central和Peripheral的例子好像一个Central不能和多个Peripheral建立连接。如果要一个Central不能和多个Peripheral建立连接应该如何做?
Central的是client, Peripheral都是server。
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 ) )
{
simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );
}
}
这里是只发现的Server UUID的为SIMPLEPROFILE_SERV_UUID的从设备吗?
那两个从设备的Server UUID能否相同呢?
上面的代码是 simpleBLECentral.c 里 static void simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent )函数的一部分。
如果从机的Server UUID 一样的话,主机就只能发现一个设备。即simpleBLEScanRes值为1。但是如果不一样的话,simpleBLEScanRes值就为2,表明应该发现了两个设备。
static void simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent ){
。。。 。。。
if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE )
{
//发现Server UUID 为SIMPLEPROFILE_SERV1_UUID从机
if ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV1_UUID, pEvent->deviceInfo.pEvtData, pEvent->deviceInfo.dataLen ) )
{
simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );
}
//发现Server UUID 为SIMPLEPROFILE_SERV2_UUID从机
if ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV2_UUID, pEvent->deviceInfo.pEvtData, pEvent->deviceInfo.dataLen ) )
{
simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );
}
}
。。。 。。。