TI中文支持网
TI专业的中文技术问题搜集分享网站

16位UUID改为128位UUID

把16位UUID改为128位UUID,参考官方128位UUID例程移植,数据长度为1时,读写正常。但多个字节时,在BLE DEVICE MONITOR读数据正常,但是写数据提示写失败呢。

simpleProfile_WriteAttrCB代码如下:

// 128-bit UUID
// status = ATT_ERR_INVALID_HANDLE;
uint8 UUID_number = 0;
const uint8 uuid[ATT_UUID_SIZE] = { // TI_UUID(BUILD_UINT16( pAttr->type.uuid[12], pAttr->type.uuid[13]))
pAttr->type.uuid[0],pAttr->type.uuid[1],pAttr->type.uuid[2],pAttr->type.uuid[3],
pAttr->type.uuid[4],pAttr->type.uuid[5],pAttr->type.uuid[6],pAttr->type.uuid[7],
pAttr->type.uuid[8],pAttr->type.uuid[9],pAttr->type.uuid[10],pAttr->type.uuid[11],
pAttr->type.uuid[12],pAttr->type.uuid[13],pAttr->type.uuid[14],pAttr->type.uuid[15],
};
if(osal_memcmp(uuid, simpleProfilechar1UUID, ATT_UUID_SIZE))
UUID_number = 1;
switch(UUID_number)
{
case 1: 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 )
{
VOID osal_memcpy( pAttr->pValue, pValue, SIMPLEPROFILE_CHAR6_LEN );
notifyApp = SIMPLEPROFILE_CHAR6;
}else
{ // Should never get here! (characteristics 2 and 4 do not have write permissions)
status = ATT_ERR_ATTR_NOT_FOUND;
}
break;
default: status = ATT_ERR_ATTR_NOT_FOUND; break;
}

Bellamy Lee:

这部分代码没看出什么问题,检查一下AttrTbl[]配置

xie liu:

回复 Bellamy Lee:

// Characteristic 6 Declaration { { ATT_BT_UUID_SIZE, characterUUID }, //UUID只读不可以写; GATT_PERMIT_READ, 0, &simpleProfileChar6Props },

// Characteristic Value 6 { { ATT_UUID_SIZE, simpleProfilechar6UUID }, GATT_PERMIT_READ|GATT_PERMIT_WRITE, //特征值,可读可写; 0, simpleProfileChar6 }, // Characteristic 6 configuration { { ATT_BT_UUID_SIZE, clientCharCfgUUID }, //特征值配置,可读可写; GATT_PERMIT_READ | GATT_PERMIT_WRITE, // 0, (uint8 *)simpleProfileChar6Config },

// Characteristic 6 User Description { { ATT_BT_UUID_SIZE, charUserDescUUID }, //描述信息,只读; GATT_PERMIT_READ, 0, simpleProfileChar6UserDesp },

特征值6定义的是可读可写可通知

赞(0)
未经允许不得转载:TI中文支持网 » 16位UUID改为128位UUID
分享到: 更多 (0)