This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to increase number of characteristics

Hi,

Using S130 via mBed, I'd like to have a fairly large number of characteristics (say 30). Unfortunately this seems to be too many, as sd_ble_gatts_characteristic_add() returns an error after I get to maybe 18 characteristics (i.e. 17 works, 18 doesn't, it also depends on the specific characteristics). Also the mBed code has a hard limit of 20 characteristics (well actually the code is buggy and will overflow/crash if you go past 20). I have submitted a patch for that.

As I understand it, some data about the characteristics (I assume UUID, characteristic value buffer, CCCD, etc.) is stored in an internal table of the softdevice. Is there any way to increase the size of this table?

According to the documentation you can specify BLE_GATTS_VLOC_USER instead of BLE_GATTS_VLOC_STACK in custom_helper.cpp, but I don't really want to change the library code, and also it says it will only store the attribute value in user memory, which is only one or two bytes in my case. The UUID is much bigger, so I doubt I'll save much there.

Is there any solution?

Parents
  • Jan's answer is great, but actually my problem turned out to be not due to the ATTR_TAB_SIZE. It was because I was using distinct UUIDs for all my characteristics. I totally forgot you are supposed to use a very small number of "base" UUIDs, and then just change the third and forth bytes.

    custom_helper.cpp in mBed restricts the number of distinct base UUIDs to 8:

    static const unsigned UUID_TABLE_MAX_ENTRIES = 8; /* This is the maximum number of 128-bit UUIDs with distinct bases that
                                                       * we expect to be in use; increase this limit if needed. */
    

    I changed my UUIDs so that the bases match and now it is fine (I also had to increase the hard limit of 20 in nRF5xGattServer.h, but I didn't have to change the ATTR_TAB_SIZE from its default (0x600).

  • My answer to this exceeds 900-word limit so I amend my answer above;)

    (Btw. I hope you've tricked your mBed drivers/SDK to accept more UUIDs under one 128-bit base because all Characteristics should share the UUID base of their ancestor Primary Service, don't they?)

Reply Children
No Data
Related