BLE RX error Unexpected L2CAP continuation

My Nordic device (nRF52833, using SDK 2.1.2) is a peripheral. 
I need to periodically transfer to it large amount of data from central device over connectable Nordic UART Service.
I perform this data transfer in batches of 16 packets, 128 bytes each (due to max payload limitation of 170).
After each batch of 16, peripheral sends XOFF packet, which causes central to wait, so that peripheral can write the data to SPI flash.
After write to flash is complete, peripheral sends XON packet, and transfer resumes.
Very basic flow control.
That works for the most part, but occasionally, Nordic device throws an error   

(15:14:31.168) E: Unexpected L2CAP continuation
(15:14:31.168) E: Unexpected L2CAP continuation
(15:14:31.168) E: Unexpected L2CAP continuation
(15:14:31.287) E: Unexpected L2CAP continuation
(15:14:31.287) E: Unexpected L2CAP continuation


I tried to introduce a small delay between individual packets within batch of 16, but that doesn't solve the problem.

I found an SDK's  Zephyr BT code where this message is printed, but not sure what to make of it

tatic void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf,
uint8_t flags)
{
uint16_t acl_total_len;

/* Check packet boundary flags */
switch (flags) {
case BT_ACL_START:
if (conn->rx) {
BT_ERR("Unexpected first L2CAP frame"); 
bt_conn_reset_rx_state(conn);
}

BT_DBG("First, len %u final %u", buf->len,
(buf->len < sizeof(uint16_t)) ?
0 : sys_get_le16(buf->data));

conn->rx = buf;
break;
case BT_ACL_CONT:
if (!conn->rx) {
BT_ERR("Unexpected L2CAP continuation"); <-----------------
bt_conn_reset_rx_state(conn);
net_buf_unref(buf);
return;
}
1346.config.zip

Would appreciate any insights to what might be causing it and how to avoid it.
My code recovers form this failure on application level, but it affects performance and I'd rather solve it properly

Parents Reply
  • I actually send packets much larger than 27,
    My negotiated MTU is 247

    Snippet of log from peripheral (Nordic) side

    (

    13:24:08.219) Starting advertising for 20 seconds, 10 seconds ahead of rendez-vous #11
    (13:24:20.490) Connected with MTU(20)
    (13:24:20.490) MTU exchange pending
    (13:24:20.731) MTU exchange successful
    (13:24:20.731) Current MTU: 247
    (13:24:25.660) Cmd: Request Challenge Code [30] recevied..!


    Below is a snippet form my prj.conf

    # NUS service
    CONFIG_BT_NUS=y
    #CONFIG_BT_L2CAP_TX_MTU=75
    CONFIG_BT_L2CAP_TX_MTU=300
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_GATT_DM=y
    CONFIG_BT_MAX_CONN=2
    #CONFIG_BT_BUF_ACL_RX_SIZE=79
    CONFIG_BT_BUF_ACL_RX_SIZE=300
    CONFIG_BT_BUF_ACL_TX_SIZE=300
    #CONFIG_BT_CTLR_DATA_LENGTH_MAX=270


    I did try to increase  BT_CTLR_DATA_LENGTH_MAX, it didn't seem to have an affect on negotiated MTU value, so I ;eft it at default (which apparently is 27

Children
Related