与sensortag 捂手成功 后 ,查询不到服务?
主机使用simpleBLECentral 从机sensortag 在连接成功
但查找不到服务 ?这可能是什么原因,我很仔细的检查了 service UUID 和 char UUID 都没问题?这是什么原因?我的程序是这样的
static void simpleBLECentralStartDiscovery( void )
{
// uint8 uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_SERV_UUID),
// HI_UINT16(SIMPLEPROFILE_SERV_UUID) };
uint8 uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(0xAA00),
HI_UINT16(0xAA00) };
// 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 );
}
/*********************************************************************
* @fn simpleBLEGATTDiscoveryEvent
*
* @brief Process GATT discovery event
*
* @return none
*/
static void simpleBLEGATTDiscoveryEvent( gattMsgEvent_t *pMsg )
{
attReadByTypeReq_t req;
if ( simpleBLEDiscState == BLE_DISC_STATE_SVC )
{
// Service found, store handles
if ( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->msg.findByTypeValueRsp.numInfo > 0 )
{
simpleBLESvcStartHdl = pMsg->msg.findByTypeValueRsp.handlesInfo[0].handle;
simpleBLESvcEndHdl = pMsg->msg.findByTypeValueRsp.handlesInfo[0].grpEndHandle;
}
// If procedure complete
if ( ( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->hdr.status == bleProcedureComplete ) ||
( pMsg->method == ATT_ERROR_RSP ) )
{
if ( simpleBLESvcStartHdl != 0 )
{
// Discover characteristic
simpleBLEDiscState = BLE_DISC_STATE_CHAR;
req.startHandle = simpleBLESvcStartHdl;
req.endHandle = simpleBLESvcEndHdl;
req.type.len = ATT_BT_UUID_SIZE;
//req.type.uuid[0] = LO_UINT16(IRTEMPERATURE_DATA_UUID);
// req.type.uuid[1] = HI_UINT16(IRTEMPERATURE_DATA_UUID);
req.type.uuid[0] = LO_UINT16(0xAA01);
req.type.uuid[1] = HI_UINT16(0xAA01);
GATT_ReadUsingCharUUID( simpleBLEConnHandle, &req, simpleBLETaskId );
// GATT_DiscCharsByUUID( simpleBLEConnHandle, &req, simpleBLETaskId );
}
}
}
else if ( simpleBLEDiscState == BLE_DISC_STATE_CHAR )
{
// Characteristic found, store handle
if ( pMsg->method == ATT_READ_BY_TYPE_RSP &&
pMsg->msg.readByTypeRsp.numPairs > 0 )
{
irTempDataHdl = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[0],
pMsg->msg.readByTypeRsp.dataList[1] );
LCD_WRITE_STRING( "Simple Svc Found", HAL_LCD_LINE_1 );
ke,
你的思路是正确的。
你用packet sniffer 抓包看一下,看看空中交互有什么问题,再结合你的代码流程看一下。
HI YAN
我觉得 我 更改上面红色的部分 就可以 查找到 sensortag的服务,是这样吗?
你好!keke
请问你这个问题解决了吗?我也碰到了类似问题。。