Quantcast
Channel: 蓝牙论坛 - 最近的话题
Viewing all articles
Browse latest Browse all 7485

怎么获取多个特征值的句柄?

$
0
0

各位好!

比如,主从机连接后,想要实现,按UP键读写特征值1;按Down键读取特征值6。

在simpleBLEGATTDiscoveryEvent里面,

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);

//hc: To discover the characteristic 6
req_char6.startHandle = simpleBLESvcStartHdl;
req_char6.endHandle = simpleBLESvcEndHdl;
req_char6.type.len = ATT_BT_UUID_SIZE;
req_char6.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR6_UUID);
req_char6.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR6_UUID);

GATT_ReadUsingCharUUID( simpleBLEConnHandle, &req, simpleBLETaskId );
GATT_ReadUsingCharUUID( simpleBLEConnHandle, &req_char6, 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] );

HalLcdWriteStringValue("numPairs=",pMsg->msg.readByTypeRsp.numPairs,10,HAL_LCD_LINE_5);
HalLcdWriteStringValue("len=",pMsg->msg.readByTypeRsp.len,10,HAL_LCD_LINE_6);
HalLcdWriteStringValueValue(" dataList",pMsg->msg.readByTypeRsp.dataList[0],16,pMsg->msg.readByTypeRsp.dataList[1],16,HAL_LCD_LINE_7);

LCD_WRITE_STRING( "Simple Svc Found", HAL_LCD_LINE_3 );
simpleBLEProcedureInProgress = FALSE;
}

1、发现numPairs一直是1

2、GATT_ReadUsingCharUUID( simpleBLEConnHandle, &req, simpleBLETaskId );函数的具体作用。如果传递的是req,则len=3;如果是req_char6,则len=7;为什么?

typedef struct
{
uint8 numPairs; //!< Number of attribute handle-UUID pairs found
uint8 len; //!< Size of each attribute handle-value pair
uint8 dataList[ATT_MTU_SIZE-2]; //!< List of 1 or more attribute handle-value pairs
} attReadByTypeRsp_t;



Viewing all articles
Browse latest Browse all 7485

Trending Articles