This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

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

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

  • // 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定义的是可读可写可通知

  • 加1037440951,给你参考源码,去年做QQ物联用过的。

x 出现错误。请重试或与管理员联系。