l2cap implementation on nrf5340

hello 

i have been using nrf5340 with ncs 1.9.1 i want to enable psm over l2cap in our firmware

# Using L2CAP library, we are able to connect, start recording and ask device to send audio data recorded. This is done similar to GATT existing implementation i know that the currently valid values for LE PSMs are 0x0001 - 0x007f for fixed Bluetooth SIG-defined services, and 0x0080 - 0x00ff for dynamic "custom” services as we don’t have implementation of PSM in firmware, we are unable to utilize L2CAP using current firmware due to which it is failing to open L2CAP channel and and unknown identifier error is streamed to device  may i know how can i add these values i using this to send the data to central  bt_gatt_notify_uuid do i need to change this api or configuration changes is enough

my prof.con app

#Enable MTU negotiation
CONFIG_BT_DATA_LEN_UPDATE=y
#Maximum supported L2CAP MTU for L2CAP buffers
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
# AG added
CONFIG_BT_L2CAP_TX_MTU=251  
# AG added
#CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_L2CAP_TX_BUF_COUNT=16

# ATT and GATT options
#  30 ms(24) -> AG CHANGED -> 10ms(8)
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
# 100 ms(80) -> AG CHANGED -> 12.5ms(10)
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=9

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_BUF_ACL_RX_SIZE=502
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_L2CAP_TX_BUF_COUNT=10
CONFIG_BT_L2CAP_TX_MTU=498
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_CONN_TX_MAX=10
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_BUF_ACL_TX_SIZE=502

hci_rpmsg.con 
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_RX_SIZE=251

CONFIG_BT_MAX_CONN=2
may i know how to implement psm in our firmware 
Parents
  • Hi Manikandan, 
    Could you give me some more information about the issue you have ? 
    Which PSM you tried to use?  I assume you have tested with a PSM higher than 0x7F ? 
    Could you show the code ? I assume you used the APIs listed here: https://docs.zephyrproject.org/apidoc/latest/group__bt__l2cap.html ? 

    My assumption is that you have tested with the normal ATT communication and the throughput was not enough so that you want to use L2CAP connection oriented channel ? 

  • audio_udp_custom.zipi have used this psm 0x0055 i have attached my code kindly check my main.c prof.conf and initBLE() function i have only integrated code  i have attached that kindly check and get back to me

    static int l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
    {
    	return -ENOSYS;
    }
    
    static struct bt_l2cap_server test_server = {
    	.accept		= l2cap_accept,
    };
    
    static struct bt_l2cap_server test_fixed_server = {
    	.accept		= l2cap_accept,
    	.psm		= 0x007f,
    };
    
    static struct bt_l2cap_server test_dyn_server = {
    	.accept		= l2cap_accept,
    	.psm		= 0x0055,
    };
    
    static struct bt_l2cap_server test_inv_server = {
    	.accept		= l2cap_accept,
    	.psm		= 0xffff,
    };
    //added this in ble_init
    void test_l2cap_register(void)
    {
    
    
    
    	/* Attempt to register server with dynamic PSM */
    	bt_l2cap_server_register(&test_dyn_server);
    
    
    
    }

  • Hi Manikandan, 

    We currently don't have an example on how to use L2CAP channel. But could you let us know what kind of error you have ? 
    How did you test ? I saw that you called test_l2cap_register() before the connection has been established. I don't think it's the way to go. 
    The L2CAP connection oriented channel should be established after the connection has been created. 

    Could you answer my question regarding why you want to use L2CAP channel instead of normal ATT ? 

  • hello,

    i am getting unknown identifier error when i tired to use l2cap layer

    yes i want to increase the throughput .. where should i call the test_l2cap_register() in our firmware to enable l2cap correctly

    regards

    manikandan 

Reply Children
Related