微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > simpleGATTProfile的simpleProfile_ReadAttrCB函数相关问题

simpleGATTProfile的simpleProfile_ReadAttrCB函数相关问题

时间:10-02 整理:3721RD 点击:

我在simpleGATTProfile增加一组profile parameter,相关定义如下:

#define SIMPLEPROFILE_CHAR6                   5  // RW uint8 - Profile Characteristic 6 value

#define SIMPLEPROFILE_CHAR6_UUID            0xFFF6

#define SIMPLEPROFILE_CHAR6_LEN           20 

// Characteristic 6 UUID: 0xFFF6
CONST uint8 simpleProfilechar6UUID[ATT_BT_UUID_SIZE] =
{
LO_UINT16(SIMPLEPROFILE_CHAR6_UUID), HI_UINT16(SIMPLEPROFILE_CHAR6_UUID)
};

// Simple Profile Characteristic 6 Properties
static uint8 simpleProfileChar6Props = GATT_PROP_READ | GATT_PROP_WRITE;

// Characteristic 6 Value
static uint8 simpleProfileChar6[SIMPLEPROFILE_CHAR6_LEN] = {0};

// Simple Profile Characteristic 6 User Description
static uint8 simpleProfileChar6UserDesp[17] = "Characteristic 6\0";

gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
{
// Simple Profile Service
{
{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
GATT_PERMIT_READ, /* permissions */
0, /* handle */
(uint8 *)&simpleProfileService /* pValue */
},

..............................

// Characteristic 6 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar6Props
},

// Characteristic Value 6
{
{ ATT_BT_UUID_SIZE, simpleProfilechar6UUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
simpleProfileChar6
},

// Characteristic 6 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar6UserDesp
},

.............................

}

在bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )函数中:

case SIMPLEPROFILE_CHAR6:
if ( len == SIMPLEPROFILE_CHAR6_LEN )
{
VOID osal_memcpy( simpleProfileChar6, value, len );
}
else
{
ret = bleInvalidRange;
}
break;

在bStatus_t SimpleProfile_GetParameter( uint8 param, void *value )中:

case SIMPLEPROFILE_CHAR6:
VOID osal_memcpy( value, simpleProfileChar6, SIMPLEPROFILE_CHAR6_LEN ); //simpleProfileChar1 是数组名
break;

在static bStatus_t simpleProfile_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,uint8 *pValue, uint8 len, uint16 offset )中:

case SIMPLEPROFILE_CHAR6_UUID:
if ( offset == 0 )
{
if ( len >SIMPLEPROFILE_CHAR6_LEN )
{
status = ATT_ERR_INVALID_VALUE_SIZE;
}
}
else
{
status = ATT_ERR_ATTR_NOT_LONG;
}

//Write the value
if ( status == SUCCESS )
{
uint8 *pCurValue = (uint8 *)pAttr->pValue;
// *pCurValue = pValue[0];
VOID osal_memset(pCurValue,0,SIMPLEPROFILE_CHAR6_LEN);

VOID osal_memcpy( pCurValue, pValue, len );

notifyApp = SIMPLEPROFILE_CHAR6;

}

break;

在static uint8 simpleProfile_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )中操作1:

case SIMPLEPROFILE_CHAR6_UUID:
// *pLen = SIMPLEPROFILE_CHAR6_LEN;
//VOID osal_memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR6_LEN );
*pLen = 1;
pValue[0] = *pAttr->pValue;
break;

在static uint8 simpleProfile_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )中操作2:

case SIMPLEPROFILE_CHAR6_UUID:
 *pLen = SIMPLEPROFILE_CHAR6_LEN;
VOID osal_memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR6_LEN );
//*pLen = 1;
//pValue[0] = *pAttr->pValue;
break;

现在我问题是:

若在simpleProfile_ReadAttrCB函数中设置成操作1,则在central代码的GATTDiscoveryEvent( gattMsgEvent_t *pMsg )函数中能够成功的发现char6服务

// Characteristic found, store handle
if ( pMsg->method == ATT_READ_BY_TYPE_RSP && pMsg->msg.readByTypeRsp.numPairs > 0 )
{
BLEDemoChar6Hdl = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[0],
pMsg->msg.readByTypeRsp.dataList[1] );

LCD_WRITE_STRING( "Simple Svc6 Found", HAL_LCD_LINE_1 );
SerialPrintValue("Simple Svc6 Found:", BLEDemoChar6Hdl, 16);
SerialPrintString("\r\n");
BLEDemoProcedureInProgress = TRUE;
}

若在simpleProfile_ReadAttrCB函数中设置成操作2,则在central代码的GATTDiscoveryEvent( gattMsgEvent_t *pMsg )函数中的发现char6服务失败

请问为什么会这样,按理说应该在simpleProfile_ReadAttrCB函数中设置成操作2才对,但为什么Simple Svc6 Found失败?

 怎么没有大牛回答呢

从代码看应该没问题啊,发现char6服务失败是什么意思?handle不正确吗?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top