BT_HCI_ERR_CONN_LIMIT_EXCEEDED when writing to a characteristic

Using NCS 1.7.0 with a an nRf9160/nRF52820 split Host/Controller as a peripheral and an nRF52840 as a central. I can connect to the peripheral with my central fine and write to a custom service I created. I'm getting an error 9 in my bt_gatt_write_func_t callback which translates to BT_HCI_ERR_CONN_LIMIT_EXCEEDED when I try to write to another one of my custom services during the lifecycle of the connection. I'm a little confused by the error code because it seems to have to do with how many connections the central can have but I'm already connected. Is there a limit to how many services a central can write to during a connection? I can write/read characteristics in the first service I have, and I can read characteristics of the second but can't write to the second.

Parents Reply
  • Could you try to do some debugging?

    Could you set a break point inside the bt_gatt_write_func_t function when the error happens and upload an image of the call stack, then I can see where the error comes from and hopefully figure out the cause.

    You could also try to enable some more logs:

    CONFIG_LOG=y
    CONFIG_BT_DEBUG_ATT=y
    CONFIG_BT_DEBUG_GATT=y

    That may give you some more information of why it's failing.

    Best regards,

    Simon

Children
  • I'll set the breakpoint and try to figure it out. I typically don't have luck with the VS Code debugger. Also, whenever I enabled BT logging, what is printed out to the terminal is uninterpretable; I just get tons of dropped messages. I use RTT Viewer. I'll try to figure out a way to get the prints to be a bit more readable

    Edit: Got everything to work. Here's a log

    00> [00:01:41.859,100] <dbg> bt_att.bt_att_req_alloc: req 0x2003efd4
    00> [00:01:41.859,130] <dbg> bt_att.bt_att_req_send: conn 0x200029b8 req 0x2003efd4
    00> [00:01:41.859,161] <dbg> bt_att.att_req_send_process: req 0x2003efd4
    00> [00:01:41.859,161] <dbg> bt_att.bt_att_chan_req_send: req 0x2003efd4
    00> [00:01:41.859,161] <dbg> bt_att.chan_req_send: chan 0x200395a0 req 0x2003efd4 len 96
    00> [00:01:41.859,161] <dbg> bt_att.chan_send: code 0x16
    00> [00:01:41.878,326] <dbg> bt_att.att_req_sent: conn 0x200029b8 chan 0x200395a0
    00> [00:01:41.878,326] <dbg> bt_att.att_sent: conn 0x200029b8 chan 0x200395a8
    00> [00:01:41.878,356] <dbg> bt_att.bt_att_sent: chan 0x200395a0
    00> [00:01:41.878,356] <dbg> bt_att.chan_req_sent: chan 0x200395a0 chan->req 0x2003efd4
    00> [00:01:41.907,897] <dbg> bt_att.bt_att_recv: Received ATT chan 0x200395a0 code 0x17 len 95
    00> [00:01:41.907,928] <dbg> bt_att.att_handle_prepare_write_rsp: 
    00> [00:01:41.907,989] <dbg> bt_att.att_handle_rsp: chan 0x200395a0 err 0x00 len 95: 1a0000000fb10700000000000008000002000078ae07000000000000000000000~
    00> [00:01:41.907,989] <dbg> bt_att.bt_att_req_free: req 0x2003efd4
    00> [00:01:41.907,989] <dbg> bt_gatt.gatt_prepare_write_rsp: err 0x00
    00> [00:01:41.908,020] <dbg> bt_att.bt_att_req_alloc: req 0x2003efd4
    00> [00:01:41.908,081] <dbg> bt_att.bt_att_req_send: conn 0x200029b8 req 0x2003efd4
    00> [00:01:41.908,081] <dbg> bt_att.att_req_send_process: req 0x2003efd4
    00> [00:01:41.908,081] <dbg> bt_att.bt_att_chan_req_send: req 0x2003efd4
    00> [00:01:41.908,081] <dbg> bt_att.chan_req_send: chan 0x200395a0 req 0x2003efd4 len 96
    00> [00:01:41.908,111] <dbg> bt_att.chan_send: code 0x16
    00> [00:01:41.915,435] <dbg> bt_att.att_req_sent: conn 0x200029b8 chan 0x200395a0
    00> [00:01:41.915,435] <dbg> bt_att.att_sent: conn 0x200029b8 chan 0x200395a8
    00> [00:01:41.915,435] <dbg> bt_att.bt_att_sent: chan 0x200395a0
    00> [00:01:41.915,435] <dbg> bt_att.chan_req_sent: chan 0x200395a0 chan->req 0x2003efd4
    00> [00:01:41.945,404] <dbg> bt_att.bt_att_recv: Received ATT chan 0x200395a0 code 0x17 len 95
    00> [00:01:41.945,434] <dbg> bt_att.att_handle_prepare_write_rsp: 
    00> [00:01:41.945,495] <dbg> bt_att.att_handle_rsp: chan 0x200395a0 err 0x00 len 95: 1a005b00fffffffffffffffffffffffffffffffffffffffffffffffffffffffff~
    00> [00:01:41.945,495] <dbg> bt_att.bt_att_req_free: req 0x2003efd4
    00> [00:01:41.945,526] <dbg> bt_gatt.gatt_prepare_write_rsp: err 0x00
    00> [00:01:41.945,556] <dbg> bt_att.bt_att_req_alloc: req 0x2003efd4
    00> [00:01:41.945,587] <dbg> bt_att.bt_att_req_send: conn 0x200029b8 req 0x2003efd4
    00> [00:01:41.945,587] <dbg> bt_att.att_req_send_process: req 0x2003efd4
    00> [00:01:41.945,587] <dbg> bt_att.bt_att_chan_req_send: req 0x2003efd4
    00> [00:01:41.945,587] <dbg> bt_att.chan_req_send: chan 0x200395a0 req 0x2003efd4 len 96
    00> [00:01:41.945,617] <dbg> bt_att.chan_send: code 0x16
    00> [00:01:41.952,941] <dbg> bt_att.att_req_sent: conn 0x200029b8 chan 0x200395a0
    00> [00:01:41.952,972] <dbg> bt_att.att_sent: conn 0x200029b8 chan 0x200395a8
    00> [00:01:41.952,972] <dbg> bt_att.bt_att_sent: chan 0x200395a0
    00> [00:01:41.952,972] <dbg> bt_att.chan_req_sent: chan 0x200395a0 chan->req 0x2003efd4
    00> [00:01:41.973,815] <dbg> bt_att.bt_att_recv: Received ATT chan 0x200395a0 code 0x01 len 4
    00> [00:01:41.973,846] <dbg> bt_att.att_error_rsp: request 0x16 handle 0x001a error 0x09
    00> [00:01:41.973,876] <dbg> bt_att.att_handle_rsp: chan 0x200395a0 err 0x09 len 0: 
    00> [00:01:41.973,876] <dbg> bt_att.bt_att_req_free: req 0x2003efd4
    00> [00:01:41.973,907] <dbg> bt_gatt.gatt_prepare_write_rsp: err 0x09

    and here's a screenshot of the call stack:

    I have a little more to work with, it seems as if it prepares two writes successfully then fails on the third

Related