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.

CC2540 BLE Attribute Size limit

Hello fellow engineers--

I'm trying to write 10 bytes to the simpleGATTProfile characteristic 0x17, UUID: 0xFFF4.  I cannot write more than 2 bytes or I get a "Invalid Attribute Value Length" error. I get this error with TI's BTTool and a Bluegiga dongle.  I cannot find in the descriptors where I specify an Attribute's size.  I can read more than 2 bytes just by changing pLen, but cannot write more than 2 bytes.  Is there something I'm missing?  i am aware of the 18 or so byte limit of wiring because of the MTU and I know I'm not hitting that limit.

Thanks,

-Phil H.

  • Hello,

    Value4 is a notification characteristic, and is defined without permissions read or write.  Notifications are used to push data out from server.

    I suspect you are writing to the characteristic configuration. This has size =2.

    // Characteristic Value 4
    {
    { ATT_BT_UUID_SIZE, simpleProfilechar4UUID },
    0,
    0,
    &simpleProfileChar4
    },

    // Characteristic 4 configuration
    {
    { ATT_BT_UUID_SIZE, clientCharCfgUUID },
    GATT_PERMIT_READ | GATT_PERMIT_WRITE,
    0,
    (uint8 *)simpleProfileChar4Config
    },

    You can check the handling for read/writes by setting breakpoints in either  

    simpleProfile_WriteAttrCB

    or

    simpleProfile_ReadAttrCB

    To enable data push, write a 1 to the characteristic configuration.

    BR,

    -Greg

  • I typo'd the UUID, it's 0xFFF3, which is Characteristic 3 in which it's write only, with handle #0x17.

    Focusing on the question:

    How can I change the size to more than 2?  If I try to write more than 2, I get an invalid attribute.  I don't see where size of 2 is defined in the services in simpleProfileAttrTbl.

  • Perhaps I used extended properties?

    GATT_CHAR_EXT_PROPS_UUID

    Then define somewhere in the extended properties:

    GATT_FORMAT_STRUCT

    Yes, no?

  • Figured it out, there was a len check inside the write handler:

    simpleProfile_WriteAttrCB:

    if ( offset == 0 )
            {
              if ( len > 1 )
                status = ATT_ERR_INVALID_VALUE_SIZE;
            }
            else
            {
              status = ATT_ERR_ATTR_NOT_LONG;
            }

    This status settings was causing the device to choke when getting more than 1 byte