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

L2CAP sd_ble_l2cap_tx running out of buffer

FormerMember
FormerMember

Hi all, I am trying to send and receive generic data from the L2CAP layer. So, initially I am just trying to send data with sd_ble_l2cap_tx with S110. The code that I am using is attached. In it the timer handler is executed every second where the a L2CAP packet is to be transmitted, but not as the sniffer doesn't sniff any packets. The UART output through printf that I am getting is

Count:7 Count:7 Count:7 Count:7 Count:7 Count:7 Count:7 Count:7 Error of 3003 at 139 in src/main.c Error of 4 at 340 in src/SDK/app_timer.c Why is the count of the sd_ble_tx_buffer_count_get always 7, but on the 8th call of sd_ble_l2cap_tx, it complains that it has run out of buffers?

Also when two devices are communicating through the L2CAP layer, should one device have central soft device (S120) and the other peripheral (S110)?

Thanks a ton, Prithvi

main.c

  • FormerMember
    0 FormerMember

    Before this post gets lost in oblivion, I ask more generic questions:

    1. Is this enough of initialization for l2cap packets to be transmitted from s110?
    TimerHandler(){
        {initialize the l2cap header and data to send}
        sd_ble_l2cap_tx(random_connection_handle, l2cap_header, data_pointer);
    }
    main(){
        timer_init();
        ble_stack_init();
        sd_ble_l2cap_cid_register(BLE_L2CAP_CID_DYN_BASE + 1);
        timer_start();
        for(;;){
            power_manage();
        }
    }
    
    1. Can this L2CAP communication be sniffed by the sniffer software?
    2. Also when two devices are communicating through the L2CAP layer, should one device have central soft device (S120) and the other peripheral (S110)?

    Thanks, Prithvi

  • Hi there,

    sd_ble_tx_buffer_count_get() always returns the total number of available TX buffers, not the free count. For L2CAP, just like for write command and notification, you should use the guidelines here:

    devzone.nordicsemi.com/.../a00844.html devzone.nordicsemi.com/.../a01061.html

    Regarding your other questions:

    1. Is this enough of initialization for l2cap packets to be transmitted from s110?

    Yes, you only need to register the CID before starting to send data

    1. Can this L2CAP communication be sniffed by the sniffer software?

    Yes, as long as you use the sniffer you should at least see the L2CAP packets with the CID you defined.

    1. Also when two devices are communicating through the L2CAP layer, should one device have central soft device (S120) and the other peripheral (S110)?

    The S120 does not support the L2CAP APIs, so you cannot use an S120 as a central. You will have to use another device of your choice. This will be addressed in future releases.

    Thanks,

    Carles

  • FormerMember
    0 FormerMember

    Thanks Carles for your detailed answer. So, right now is there software or binary with which two nrf51822 ICs communicate with each other through L2CAP layer? Can two devices with S110 communicate with each other from L2CAP layer?

  • Hi there,

    Thanks Carles for your detailed answer. So, right now is there software or binary with which two nrf51822 ICs communicate with each other through L2CAP layer? Can two devices with S110 communicate with each other from L2CAP layer?

    No, right now you cannot send arbitrary L2CAP data between 2 nRF51 ICs. But you can define your own custom protocol on top of GATT, and that is indeed fully supported by both the S110 and S120.

    Carles

  • FormerMember
    0 FormerMember

    Thanks again Carles. Do you know of any platform where there is APIs to access the L2CAP layer in the central device? And when you mean a custom protocol over GATT, you mean having the data field long enough in an example like the one here github.com/.../ to have own custom protocol in it? Regards, Prithvi

Related