(GATT profile size) bleprofile_WriteHandleData() return value

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

I'm trying to write a long characteristic and when calling the function with:

bleprofile_WriteHandleData(MY_CHARACTERISTIC_VALUE, db_pdu, MY_CHARACTERISTIC_LEN + 2)

#define MY_CHARACTERISTIC_LEN 160

it returns with 17 which is a error. Is there a description of error numbers ?

Thanks, Marko

0 Likes
1 Solution
Anonymous
Not applicable

Hello Marco

Look in leatt.h - Error 17 is the out of memory error.

You need to add the optional patches to your make file:

APP_PATCHES_AND_LIBS += long_characteristic_support.a

APP_PATCHES_AND_LIBS += thread_and_mem_mgmt.a

You need to also test with the long characteristics sample

Thanks

JT

View solution in original post

0 Likes
6 Replies
Anonymous
Not applicable

I've noticed something very odd. I have 2 services in the GATT database. The first service has 1 characteristic that I'm mentioning in my first post and the second service has 3 characteristics.

If I change the size of the 1st service's characteristic from 160 to 64 it works. Almost like the size of the GATT database is not limited with the available RAM, nor limited by the 16bit size value parameter passed to bleapp_set_cfg().

Can somebody comment on this ?

Thanks, Marko

0 Likes
Anonymous
Not applicable

Hello.

When you are calling:

bleprofile_WriteHandleData(MY_CHARACTERISTIC_VALUE, db_pdu, MY_CHARACTERISTIC_LEN + 2);

how are you defining db_pdu?

Some extra code would help. Thanks.

James

0 Likes
Anonymous
Not applicable

jamesle1

Below is my function that updates the characteristic when new data is available.

The main point is that this function works if the characteristics is up to 64 bytes. If I increase the length it start to fail. What is even more weird is that if I remove other characteristics from the GATT profile I can increase the length of this characteristic up to 160 bytes before it starts to fails. So again. Looks like there is a limitation on the GATT database size.

static void puart_control_handle_wifi_list(PUART_CONTROL_DATA *p_command) {

  BLEPROFILE_DB_PDU *db_pdu = (BLEPROFILE_DB_PDU *)cfa_mm_Alloc(WIFI_LIST_CHARACTERISTIC_LEN + 2);

  if (db_pdu == 0) {

  puart_control_send_command_status_evt(PUART_CONTROL_STATUS_NO_MEMORY);

  return;

  }

  db_pdu->len = WIFI_LIST_CHARACTERISTIC_LEN;

  if (bleprofile_ReadHandleData(WIFI_LIST_CHARACTERISTIC_VALUE, db_pdu, WIFI_LIST_CHARACTERISTIC_LEN + 2) != 0) {

  cfa_mm_Free(db_pdu);

  ble_trace0("bleprofile_ReadHandleData failed");

  puart_control_send_command_status_evt(PUART_CONTROL_STATUS_FAILED);

  return;

  }

  int len = p_command->len;

  if(len > WIFI_LIST_CHARACTERISTIC_LEN)

  len = WIFI_LIST_CHARACTERISTIC_LEN;

  ble_trace1("len = %d", len);

  memset(db_pdu->pdu, 0, WIFI_LIST_CHARACTERISTIC_LEN);

  memcpy(db_pdu->pdu, p_command->data, len);

  ble_trace0(db_pdu->pdu);

  int rtv = bleprofile_WriteHandleData(WIFI_LIST_CHARACTERISTIC_VALUE, db_pdu, WIFI_LIST_CHARACTERISTIC_LEN + 2);

  ble_trace1("bleprofile_WriteHandleData returned: %d", rtv);

  //if (bleprofile_WriteHandleData(WIFI_LIST_CHARACTERISTIC_VALUE, db_pdu, WIFI_LIST_CHARACTERISTIC_LEN + 2) != 0) {

  if(rtv != 0) {

  ble_trace0("WriteHandleData failed");

  puart_control_send_command_status_evt(PUART_CONTROL_STATUS_FAILED);

  }

  else {

  puart_control_send_command_status_evt(PUART_CONTROL_STATUS_SUCCESS);

  }

  cfa_mm_Free(db_pdu);

}

0 Likes
Anonymous
Not applicable

My understanding is that the maximum characteristic length supported under the current BLE stack is 23 bytes.  The BLE SIG might allow for more, but it is not supported unless you use the "long characteristic" feature in the recent SDK release, which only just breaks up the "Long" characteristic into smaller packets to satisfy the 23 byte limitation.  This is my understanding and could be mistaken.  We also tried increasing beyond 23 bytes and experienced weird behavior, and I think that is due to stepping on memory locations that the system is using for some other purpose.  NOT recommended even if it seems to work.

0 Likes
Anonymous
Not applicable

Hello Marco

Look in leatt.h - Error 17 is the out of memory error.

You need to add the optional patches to your make file:

APP_PATCHES_AND_LIBS += long_characteristic_support.a

APP_PATCHES_AND_LIBS += thread_and_mem_mgmt.a

You need to also test with the long characteristics sample

Thanks

JT

0 Likes
Anonymous
Not applicable

If you check the files in the SDK, under

WICED-Smart-SDK/Wiced-Smard/inc/error.h

There is a list of error codes and descriptions.

Your error, if you meant 17 as an int (0x11): BT_ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE

0 Likes