BLE characteristic write fails silently when value is more than 20 bytes

I'm using Nrf connect for Mobile to test my BLE firmware. I noticed that when trying to write more than 20 bytes to a characteristic, nothing gets logged which means my write callback function isn't called. Either the nrf connect app isn't sending anything above 20 bytes or the BLE stack is just silently ignoring the message for some reason. According to BLE spec, characteristic value can be up to 512 bytes so that's a bit unexpected. Am I doing something wrong? I attached my prj.conf and some code.

  • I see some suggestions to use `NRF_SDH_BLE_GATT_MAX_MTU_SIZE` in other threads, but if I set it in my prj.conf, I am getting this error: ignoring malformed line 'NRF_SDH_BLE_GATT_MAX_MTU_SIZE=128' and using a `#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 128` doesn't do anything.

  • I also tried with following configs in my prj.conf but is still failing. The Nrf Connect for Mobile app logs show "Error 6 (0x6): GATT REQ NOT SUPPORTED" when I try to  write the value.

  • Actually, I think those latest settings fixed the issue but I have to manually request the MTU change from the NrfConnect mobile app's "Request MTU" function before writing to the characteristic. Would be nice to be able to avoid doing that but not sure if it's possible.

  • Hello,

    Good to see that you found a resolution. Exercise 2 from our Bluetooth Low Energy Fundamentals course may also shed some light on this.

    As you found out, the peripheral can request an MTU change to a larger value, but it is ultimately up to the central to decide the final value.

    Best regards,

    Maria