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

Writing characteristics longer than 20 bytes

I know there are multiple different questions/answers relating to this topic but none exactly solved my issue. Further, some of the questions are many years old so it's not clear to me if some of that information is perfectly relevant. So here goes...

I am trying to create a characteristic that is up to 512 bytes which I believe I read is a BLE maximum. 

During the setup of the characteristic I set the following variables:

        attr_char_value.max_len  = VECTOR_DATA_SIZE;
        attr_char_value.init_len    = VECTOR_DATA_SIZE;

Where VECTOR_DATA_SIZE is programmable. As an experiment I set it to 64 (decimal).

I then initialize the value in the peripheral characteristic to 0,1,2,3,...63

So far so good.

If I then open up nRF Connect and attempt to READ this characteristic I see that the size of the characteristic is correct and the proper data is returned.

If I try to WRITE that data however, I get a BLE_GATT_STATUS_ATTERR_APP_BEGIN error.

As you might expect, I see this same error if the size (ie: VECTOR_DATA_SIZE) is set to any value greater than 20.

What am I missing?

Parents
  • You need to initialize the softdevice with a max mtu value require otherwise the default is 20.  look for MTU somewhere in sdk_config.h

  • I assume you mean the following #defines:

    // <o> NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size.
    #ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
    #define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 24   // Default = 23
    #endif

    If I change the size greater to anything than the default value of 23, I wind up in the app_err_fault_handler() routine in app_error_weak.c.

    Debug terminal warning messages include:

    <warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.
    <warning> nrf_sdh_ble: Change the RAM start location from 0x20002220 to 0x20002228.
    <warning> nrf_sdh_ble: Maximum RAM size for application is 0xDDD8.
    <error> nrf_sdh_ble: sd_ble_enable() returned NRF_ERROR_NO_MEM.
    <error> app: Fatal error

    Note that I am using SDK 15.0.0 with the nRF52 development kit (if that is helpful).

    Thoughts?

Reply
  • I assume you mean the following #defines:

    // <o> NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size.
    #ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
    #define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 24   // Default = 23
    #endif

    If I change the size greater to anything than the default value of 23, I wind up in the app_err_fault_handler() routine in app_error_weak.c.

    Debug terminal warning messages include:

    <warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.
    <warning> nrf_sdh_ble: Change the RAM start location from 0x20002220 to 0x20002228.
    <warning> nrf_sdh_ble: Maximum RAM size for application is 0xDDD8.
    <error> nrf_sdh_ble: sd_ble_enable() returned NRF_ERROR_NO_MEM.
    <error> app: Fatal error

    Note that I am using SDK 15.0.0 with the nRF52 development kit (if that is helpful).

    Thoughts?

Children
Related