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

Specify Port for L2CAP Communication

Hi all,

I am trying to specify a fixed port for a L2CAP connection on the nRF51822. The client is a Linux box running bluez (which has BLE support). The client software is designed in Qt, which exposes the underlying bluetooth in a cross platform way.

My goal is to set up a L2CAP connection to send and receive data since Qt does not have full BLE support yet but does have L2CAP which, for my application, is more suitable as it is not a traditional BLE sensor app.

So far I can:

  1. Send L2CAP data to the Master Control using example code Ole graciously gave to me. The data shows up in the Log file correctly.
  2. Scan and identify the nRF51822 using Qt API calls.

What I am unsure about is how to specify a fixed L2CAP port number on the nRF51822 side to establish communication.

Thanks in advance,

Nick

  • There is one way that you can send data on other L2CAP CID's (as long as they are greater than BLE_L2CAP_CID_DYN_BASE) and you cannot have more than 8 custom CID Channels

    uint32_t sd_ble_l2cap_cid_register(uint16_t cid)
    
    uint32_t sd_ble_l2cap_tx ( uint16_t conn_handle,
        ble_l2cap_header_t const *const p_header,
        uint8_t const *const p_data
    )
    
    

    When you send something with sd_ble_l2cap_tx, then you will receive a BLE_EVT_TX_COMPLEPLETE when the packet is received by the peer, and a BLE_L2CAP_EVT_RX when you receive something on that CID from the peer.

  • Sorry if this question is dumb but im still learning the intricacies of bluetooth. I thought that as a standard L2CAP used Protocol Service Multiplexers which act similar to ports. Would the client/host not need to decide upon a port before they can communicate?

    Is it possible to connect to the nRF51822 without connecting through a service?

    Thanks,

    Nick

  • A connection in BLE doesn't really have anything to do with a service, and you can create a connection without actually using any service, just to do L2CAP transfers.

    With the S110 there isn't any other way to transfer L2CAP data than what Pål says, by registering a channel with sd_ble_l2cap_cid() and then send data with sd_ble_l2cap_tx().

    Unfortunately, we cannot really help you with how to read do this from the other end, through Qt's interfaces, as we don't know them. I'd recommend you to just try to first initiate a connection and only when you're successfully able to do so try to actually receive data.

    To be honest, I suspect that this L2CAP API will not be usable for BLE at all. I believe your current best bet to talk to a BLE device on Linux is the C API of BlueZ directly, as stated here.

  • From what ive searched on Qt i believe you are correct. I am going to use standard GATT and android. Much thanks.

  • From what ive searched on Qt i believe you are correct. I am going to use standard GATT and android. Much thanks.

Related