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

BLE_L2CAP_EVT_CH_SETUP event not received

Hi,

I am trying to setup L2CAP channel in ble_app_uart. I referred the object transfer example and did the initialization of L2CAP parameters during ble_stack_init() both in central and peripheral. 

    ble_cfg_t ble_cfg;

    // Set L2CAP channel configuration.
    ble_cfg.conn_cfg.conn_cfg_tag                        = APP_BLE_CONN_CFG_TAG;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.rx_mps        = 60;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.rx_queue_size = 1;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.tx_mps        = 40;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.tx_queue_size = 1;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.ch_count      = 1;

    err_code = sd_ble_cfg_set(BLE_CONN_CFG_L2CAP, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);

After completing the NUS discovery the l2cap channel setup API is invoked in the central device

            printf("L2CAP channel setup.\r\n");
            ble_l2cap_ch_setup_params_t params;

            params.rx_params.rx_mps = 60;
            params.rx_params.rx_mtu = 30;
            params.rx_params.sdu_buf.p_data = NULL;
            params.le_psm = 0x0025;    // Used when requesting setup of an L2CAP channel, ignored otherwise.
            params.status = 0;              // Used when requesting setup of an L2CAP channel, ignored otherwise.

            uint16_t cid  = BLE_L2CAP_CID_INVALID;

            err_code = sd_ble_l2cap_ch_setup(ble_conn_handle, &cid, &params);
            APP_ERROR_CHECK(err_code);

            printf("L2CAP channel setup completed channel: %d\r\n", cid);

At the peripheral device BLE_L2CAP_EVT_CH_SETUP_REQUEST event is getting and BLE_L2CAP_EVT_CH_SETUP event also received after channel setup.

if (p_ble_evt->evt.l2cap_evt.params.ch_setup_request.le_psm != 0x0025)
    {
        ch_setup_params.status = BLE_L2CAP_CH_STATUS_CODE_LE_PSM_NOT_SUPPORTED;
        printf("l2cap setup request for PSM 0x%x, rejecting since OTS PSM is 0x%x",
                        p_ble_evt->evt.l2cap_evt.params.ch_setup_request.le_psm,
                        BLE_L2CAP_CH_STATUS_CODE_LE_PSM_NOT_SUPPORTED);
    }

    else
    {
        ch_setup_params.status = BLE_L2CAP_CH_STATUS_CODE_SUCCESS;

        ch_setup_params.rx_params.rx_mps = 0;
        if (ch_setup_params.rx_params.rx_mps < BLE_L2CAP_MPS_MIN)
        {
            ch_setup_params.rx_params.rx_mps = BLE_L2CAP_MPS_MIN;
        }
        ch_setup_params.rx_params.rx_mtu = 0;
        if (ch_setup_params.rx_params.rx_mtu < BLE_L2CAP_MTU_MIN)
        {
            ch_setup_params.rx_params.rx_mtu = BLE_L2CAP_MTU_MIN;
        }
        ch_setup_params.rx_params.sdu_buf.p_data = NULL;
    }
    uint16_t                 local_cid;

    local_cid = p_ble_evt->evt.l2cap_evt.local_cid;

    err_code = sd_ble_l2cap_ch_setup(p_ble_evt->evt.l2cap_evt.conn_handle,
                                     &local_cid,
                                     &ch_setup_params);
    if (err_code != NRF_SUCCESS)
    {
        printf("Rejected L2CAP Channel cid:%d \r\n", local_cid);
    }
    printf("Accepted L2CAP Channel cid:%d \r\n", local_cid);

But the BLE_L2CAP_EVT_CH_SETUP  event is not received at central device.  (Further data transmission from peripheral to central are also not working).

Did i miss some configurations? Any support will be greatly appreciated. 

Thanks

Parents Reply Children
No Data
Related