cancel
Showing results for 
Search instead for 
Did you mean: 

STM BlueNRG-MS Max Characteristic length limited to 255 due to aci_gatt_add_char function limitations.

aj.sk
Associate III

My general understanding is that the BLE standard supports characteristics with a lenght of up to 512 bytes. I'm using the BlueNRG-MS chip from STM but there the function call to add a characteristic has a uint8_t value for the length parameter

tBleStatus aci_gatt_add_char(uint16_t serviceHandle,

uint8_t charUuidType,

const uint8_t* charUuid,

uint8_t charValueLen,

uint8_t charProperties,

uint8_t secPermissions,

uint8_t gattEvtMask,

uint8_t encryKeySize,

uint8_t isVariable,

uint16_t* charHandle);

So this would allow only a maximum characteristic length of 255 bytes. According to this document the stack itself supports 2 bytes with FW 7.2 or higher. I have 7.23 so this should be fine but I cannot find any reference or example of a BlueNRG-MS middleware that would support a call with

charValueLen

of type

uint16_t

. I also downloaded the latest STSW-BLUENRG-DK and the examples also only support

uint8_t charValueLen

.

14 REPLIES 14

Try to lower Max_Attribute_Records.

You declared a number too large, which consumed large memory (for attribute declarations) that will not be used in your application.

aj.sk
Associate III

Hi Winfred, thanks for your reply

I played around with this number already, Setting it to 6 (1(service) +4(2*characteristic) +1(notify)) didn't change anything, I still get 0x1F as return value. Are you sure it has to be memory related, cause in bluenrg_def.h is has a define that says "UNKNOWN_ERROR".

I tried to find the treshold and the size limit is 410 bytes. The thing is that I have even more characteristics to add. Is there a know limit that all characteristics may use up in space? I have a total value length of 551 bytes in 5 services and 14 characteristics.

0x1F is most likely to be memory related in my opinion. The value was the code for "out of memory" in previous implementation, but now used as some HCI standard error code meaning unspecific error. Otherwise i have no idea what's wrong.

>I tried to find the treshold and the size limit is 410 bytes.

Could you clarify how did you get the size limit?

>Is there a know limit that all characteristics may use up in space? I have a total value length of 551 bytes in 5 services and 14 characteristics.

For MODE2,

  • The max length for the characteristics records array is 700 bytes (36 bytes + length of the device name characteristic are reserved for GAP and GATT services)
  • The total number of attribute records for characteristics is 68 (9 records are reserved for GAP and GATT services)
  • The total number of attributes records for services is 8 (2 are reserved for the default GAP and GATT services)

The following would be my quick test adding a service and a 440-byte characteristic in addition to default attributes. (which can also be a reference about the memory array used by default attributes). There is no special meaning for the length 440 byte, i just picked up some value larger than 410 randomly.

0693W00000AM3nyQAD.pngThe followed is calling ACI_GATT_ADD_CHAR with 2-byte value (0x01B8) for charValueLen.

0693W00000AM3qdQAD.pngThe followed is the event showing ACI_GATT_ADD_CHAR was completed successfully.0693W00000AM3qOQAT.png 

aj.sk
Associate III

@Winfred LU​ 

>Could you clarify how did you get the size limit?

Just by reducing it step by step, but as mentioned, there are also other services running. So I suspect that I'm running into this 700 bytes limit

Please refer to Release Notes for BlueNRG, BlueNRG-MS Stacks, that comes with DK, by default at:

C:\Program Files (x86)\STMicroelectronics\BlueNRG DK 2.0.2\Docs\bluenrg_fw_stack_release_notes_html\BlueNRG_release_notes.html