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

Do not receive BLE_L2CAP_EVT_CH_TX from softdevice s140 on calling sd_ble_l2cap_ch_tx

OS: Linux Ubuntu 18.04

Compiler: Gnu ARM embedded

HW: 2 nrf52840dk boards

NRF SDK: 16.0.0

I am trying to send data using L2CAP CoC. I have looked at the ots example, and have run it ok on 2 52840 DK boards, hence the hardware setup is ok. 

I have removed all the OTS overhead and am using sd_ble_l2cap API. It successfully connects and all the expected connection callbacks are triggered. 

Image below shows the UART log of my central device (nrf52840). You can see that BLE_L2CAP_EVT_CH_SETUP is triggered with a successful connection, state is CONNECTED, cid is ok.

Image below UART log of my peripheral device (also nrf52840). You can see that BLE_L2CAP_EVT_CH_SETUP_REQUEST is triggered, post which L2CAP_EVT_CH_SETUP is triggered indicating a successful connection. 

This assures me that the hardware setup, softdevice hex file, compiler settings, build etc are all ok. 

After connection when I try to send any data from either central or peripheral side, I never get a BLE_L2CAP_EVT_CH_TX  event from the softdevice. 

Questions:

1. What else should I check ?

2. In the connection, credits from peer are 0. Does this mean that the sender cannot send any l2cap msgs ? 

   I have called sd_ble_l2cap_ch_flow_control with 10 credits but do not get BLE_L2CAP_EVT_CH_CREDIT from the softdevice. 

3. The default value of credits is 1, however the value printed is 0. I simply print the value of "p_ble_evt->evt.l2cap_evt.params.ch_setup.tx_params.credits". This should mean that credits are not issued for any tx, however in the OTS example, I have added the same debug print and communication works even when the print is 0. Why is that ?

Parents
  • Hi

    Have you looked at the debug log at all when trying to send data from either side to see if you get an error message of any sort? I'm guessing that the amount of credits you have initially are not sufficient, which is what causes nothing to happen. You can try changing the initial credits by making sd_ble_l2cap_ch_flow_control only set initial credits in LE Credit Based Connection Request, and not send LE Flow Control Credit packets. If you call sd_ble_l2cap_ch_flow_control(...,local_cid = BLE_L2CAP_CID_INVALID) before sd_ble_l2cap_ch_setup(), the credits provided by sd_ble_l2cap_ch_flow_control will be used for the newly created channel.

    Best regards,

    Simon

  • Have you looked at the debug log at all when trying to send data from either side to see if you get an error message of any sort?

    Yes, I have added debug prints for all other L2CAP events and do not receive anything else. (EVT_CREDIT, EVT_SDU_RELEASED etc.)

    You can try changing the initial credits by making sd_ble_l2cap_ch_flow_control only set initial credits in LE Credit Based Connection Request, and not send LE Flow Control Credit packets. If you call sd_ble_l2cap_ch_flow_control(...,local_cid = BLE_L2CAP_CID_INVALID) before sd_ble_l2cap_ch_setup(), the credits provided by sd_ble_l2cap_ch_flow_control will be used for the newly created channel.

    I had not thought of this and tried this just now. I am assuming the call succeeds as I get NRF_SUCCESS as return. 

    However, this has not fixed the issue. I still get 0 credits and no tx happens. 

    For other ideas, I tried running the OTS example and added L2CAP debug prints. On the peripheral side, I get prints as expected, but I do not get L2CAP prints on the central side. That would have completely cleared the credits issue. 

    Are L2CAP prints disabled in ots central example ? I diffed the sdk_config for ots and central peripheral and there are no differences w.r.t. log config. 

    In OTS, a write command has to be written with GATT to OACP and then data is to be sent through L2CAP. 

    Is raw L2CAP data transfer possible with soft device ? Or does it have to involve OACP ?

Reply
  • Have you looked at the debug log at all when trying to send data from either side to see if you get an error message of any sort?

    Yes, I have added debug prints for all other L2CAP events and do not receive anything else. (EVT_CREDIT, EVT_SDU_RELEASED etc.)

    You can try changing the initial credits by making sd_ble_l2cap_ch_flow_control only set initial credits in LE Credit Based Connection Request, and not send LE Flow Control Credit packets. If you call sd_ble_l2cap_ch_flow_control(...,local_cid = BLE_L2CAP_CID_INVALID) before sd_ble_l2cap_ch_setup(), the credits provided by sd_ble_l2cap_ch_flow_control will be used for the newly created channel.

    I had not thought of this and tried this just now. I am assuming the call succeeds as I get NRF_SUCCESS as return. 

    However, this has not fixed the issue. I still get 0 credits and no tx happens. 

    For other ideas, I tried running the OTS example and added L2CAP debug prints. On the peripheral side, I get prints as expected, but I do not get L2CAP prints on the central side. That would have completely cleared the credits issue. 

    Are L2CAP prints disabled in ots central example ? I diffed the sdk_config for ots and central peripheral and there are no differences w.r.t. log config. 

    In OTS, a write command has to be written with GATT to OACP and then data is to be sent through L2CAP. 

    Is raw L2CAP data transfer possible with soft device ? Or does it have to involve OACP ?

Children
  • Pallavi@ said:
    I have added debug prints for all other L2CAP events and do not receive anything else.

     Please try adding DEBUG to your preprocessor definitions as this should provide more debug information than what you're currently seeing. What backend are you using to print your debugging data? If you're using RTT, please also try setting NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED to 0 in sdk_config.h

    Best regards,

    Simon

Related