Search code examples
bluetooth-lowenergystm32

BLE STM BlueNrg characteristic max size and max characteristic per service


I have two issues with my BlueNRG-MS BLE module which I'm not really sure if this is intended design:

  1. The maximum size of a characteristic cannot exceed 20 bytes. If I create a characteristic that is e.g. 32 bytes long, although I can read the whole 32 bytes, when the characteristic is notified (updated) by the BLE, only 20 bytes are transmitted. I've found some references which confirm this, but I havent found a reasonable explanation.

  2. I can only add 2 characteristics to one service. This seems rather odd and I wonder if there's a limiting configuration parameter which I'm missing. If I add 3 characteristics to one service, only the first two get added. I'm using the STM LightBlue App for debugging.

Update: The return value of the aci_gatt_add_char() function is ERR_UNSPECIFIED_ERROR It seems like there are others having the same issue https://community.st.com/s/question/0D50X00009XkYh6/another-question-about-bluenrg-errunspecifiederror


Solution

  • Okay, seems like in my case the problem was caused by the max_attr_records parameter of the aci_gatt_add_serv() call. I haven't found a clear specification so far, but you seem to need 1 for the service itself and and my case (with the CHAR_PROP_NOTIFY flag set) +3 for each characteristic. So it works for now, still if someone has a clear insight in how to determine the max_attr_records please let me know. Also, setting it too high also doesn't work, but here I haven't found an explanation so far.