写操作需要handle.其实simpleBLEGATTDiscoveryEvent的例子中的处理很清晰啊,只是这里是读取的是SIMPLEPROFILE_CHAR1_UUID。
发现完成就开始获得相应的UUID的handle.如下例子。 而读写操作在simpleBLECentral_HandleKeys里也有。调用的GATT_WriteCharValue()和
GATT_ReadCharValue().
// 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);
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] );
LCD_WRITE_STRING( "Simple Svc Found", HAL_LCD_LINE_1 );
simpleBLEProcedureInProgress = FALSE;
]
simpleBLEDiscState = BLE_DISC_STATE_IDLE;
]
写操作需要handle.其实simpleBLEGATTDiscoveryEvent的例子中的处理很清晰啊,只是这里是读取的是SIMPLEPROFILE_CHAR1_UUID。
发现完成就开始获得相应的UUID的handle.如下例子。 而读写操作在simpleBLECentral_HandleKeys里也有。调用的GATT_WriteCharValue()和
GATT_ReadCharValue().
// 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);
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] );
LCD_WRITE_STRING( "Simple Svc Found", HAL_LCD_LINE_1 );
simpleBLEProcedureInProgress = FALSE;
]
simpleBLEDiscState = BLE_DISC_STATE_IDLE;
]
举报