Hi Yan,
关于CHAR4句柄获得问题,我将例程中static void simpleBLEGATTDiscoveryEvent( gattMsgEvent_t *pMsg )函数中的SIMPLEPROFILE_CHAR1_UUID替换为SIMPLEPROFILE_CHAR4_UUID,但是下载到开发板上,设备根本无法发现服务,无法获得CHAR4的UUID. 问题出在哪呢?代码如下,红色部分是被我修改的地方。
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(SIMPLEPROFILE_CHAR1_UUID);
//req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);
req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR4_UUID);
req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR4_UUID);
GATT_ReadUsingCharUUID( 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 )
[
/*simpleBLECharHdl = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[0],
pMsg->msg.readByTypeRsp.dataList[1] );*/
simpleBLECharHd4 = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[0],
pMsg->msg.readByTypeRsp.dataList[1] );
LCD_WRITE_STRING( "Simple Svc Found", HAL_LCD_LINE_1 );
simpleBLEProcedureInProgress = FALSE;
]
simpleBLEDiscState = BLE_DISC_STATE_IDLE;
]
]