6 Replies Latest reply on Nov 13, 2015 4:35 PM by jota_1939431

    (GATT profile size) bleprofile_WriteHandleData() return value



      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

        • 1. Re: bleprofile_WriteHandleData() return value

          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

          • 2. Re: (GATT profile size) bleprofile_WriteHandleData() return value

            If you check the files in the SDK, under




            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


            • 3. Re: (GATT profile size) bleprofile_WriteHandleData() return value



              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.



              • 4. Re: (GATT profile size) bleprofile_WriteHandleData() return value


                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) {






                  db_pdu->len = WIFI_LIST_CHARACTERISTIC_LEN;



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


                  ble_trace0("bleprofile_ReadHandleData failed");






                  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);






                  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");



                  else {





                • 5. Re: (GATT profile size) bleprofile_WriteHandleData() return value

                  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.

                  • 6. Re: (GATT profile size) bleprofile_WriteHandleData() return value

                    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