Sending notification with MTU size more than 23 bytes - BLE


dhguja@gmail.com
 

Hello all,
      I have a question regarding handling MTU size more than 23 bytes during notification. I have a custom service on a peripheral device app to which client app(lets say android app) will subscribe to. When the peripheral device has some data ( usually more than 23 bytes) it will send the data to the client via 'notification'. I saw many solutions with respect to nRF SDK but i am not using any SDK but just developing the peripheral device app using zephyr's BLE APIs. I would like to know how to handle this?

I came across MTU negotiation during connection while searching on this. I couldn't find any sample code on zephyr using this method. Does peripheral device app has to do anything during this negotiation?

Is there a easier and cleaner way to do this or we have to do data segmentation and reassembly ourselves in the application layer?

Will be helpful if someone can point me in the right direction. Thanks in advance.

Regards,
DJ



Johan Hedberg
 

Hi DJ,

On Fri, Dec 15, 2017, dhananjay gj wrote:
I have a question regarding handling MTU size more than 23 bytes
during notification. I have a custom service on a peripheral device app to
which client app(lets say android app) will subscribe to. When the
peripheral device has some data ( usually more than 23 bytes) it will send
the data to the client via 'notification'. I saw many solutions with
respect to nRF SDK but i am not using any SDK but just developing the
peripheral device app using zephyr's BLE APIs. I would like to know how to
handle this?

I came across MTU negotiation during connection while searching on this. I
couldn't find any sample code on zephyr using this method. Does peripheral
device app has to do anything during this negotiation?
The maxium ATT MTU Zephyr will use is based on the values you've given
to CONFIG_BT_L2CAP_TX_MTU and CONFIG_BT_L2CAP_RX_MTU. Additionally,
there's a runtime API bt_gatt_exchange_mtu() that can be used to trigger
the MTU negotiation if it doesn't otherwise happen.

Johan


dhguja@gmail.com
 

Hello Johan,
              Many thanks for the reply. I tried changing the configuration for CONFIG_BT_L2CAP_TX_MTU to my required size (30 bytes to test)
and used the nRF connect app as client on my phone. I only received data when there is 20 bytes (i assume some 3 bytes are used in GATT) in the buffer.
If i send one more character in the buffer (21 bytes) i did not receive any data at all in client. I used indications for my custom attribute.

Is it possible that my peripheral device itself is not sending any data beyond the 20 chars or client application is ignoring the data beyond default 23 bytes.
I did not try "bt_gatt_exchange_mtu()" call yet. May be i will test with simple client on zephyr also with that call.

I would like your opinion whether this is in right direction and if there any other app like nRFconnect to test BT connections with modifiable MTU size during connection.

Thanks in advance.

Regards,
DJ

On Sat, Dec 16, 2017 at 7:19 AM, Johan Hedberg <johan.hedberg@...> wrote:
Hi DJ,

On Fri, Dec 15, 2017, dhananjay gj wrote:
>       I have a question regarding handling MTU size more than 23 bytes
> during notification. I have a custom service on a peripheral device app to
> which client app(lets say android app) will subscribe to. When the
> peripheral device has some data ( usually more than 23 bytes) it will send
> the data to the client via 'notification'. I saw many solutions with
> respect to nRF SDK but i am not using any SDK but just developing the
> peripheral device app using zephyr's BLE APIs. I would like to know how to
> handle this?
>
> I came across MTU negotiation during connection while searching on this. I
> couldn't find any sample code on zephyr using this method. Does peripheral
> device app has to do anything during this negotiation?

The maxium ATT MTU Zephyr will use is based on the values you've given
to CONFIG_BT_L2CAP_TX_MTU and CONFIG_BT_L2CAP_RX_MTU. Additionally,
there's a runtime API bt_gatt_exchange_mtu() that can be used to trigger
the MTU negotiation if it doesn't otherwise happen.

Johan