7 Replies Latest reply on Apr 14, 2017 7:25 AM by michael.m

    L2CAP connection error to non-Cypress device

    michael.m

      Hi.

         

      I'm trying to send data through L2CAP from CY5676 evaluation board to Nordic's nrf51822 chip (which runs my code).

         

      Nordic's API has only 3 functions for L2CAP - CID_REGISTER, CID_UNREGISTER and L2CAP_TX. And it has only one BLE event BLE_L2CAP_EVT_RX on receiving L2CAP packet.

         

      Cypress' API has 8 functions and more then one BLE events. It also use PSMs and CIDs, whereas Nordic has only CIDs.

         

      I register an new CID on Nordic and try to connect to it from CY5676 using CyBle_L2capCbfcConnectReq function (after running CyBle_L2capCbfcRegisterPsm). As I understand, the remotePsm parameter is the CID I've registered on Nordic (because I don't see anything else that can be related to it). But I get the CYBLE_EVT_L2CAP_COMMAND_REJ event with CYBLE_L2CAP_INVALID_CID_IN_REQUEST as the reason.

         

      Can anyone help me with this?

         

      Thanks.

        • 1. Re: L2CAP connection error to non-Cypress device
          e.pratt_1639216

          Here's a page I found that describes the CID and L2Cap layer in detail, hope it helps:

             

          http://www.amd.e-technik.uni-rostock.de/ma/gol/lectures/wirlec/bluetooth_info/l2cap.html

             

          Of particular interest:

             

          "

             

          5.2.1  Channel Identifiers

             

              Channel identifiers (CIDs) are local names representing a logical channel end-point on the device. Implementations are free to manage the CIDs in a manner best suited for that particular implementation, with the provision that the same CID is not reused as a local L2CAP channel endpoint for multiple simultaneous L2CAP channels between a local device and some remote device.

             

               CID assignment is relative to a particular device and a device can assign CIDs independently from other devices (with the exception of certain reserved CIDs , such as the signalling channel). Thus, even if the same CID value has been assigned to (remote) channel endpoints by several remote devices connected to a single local device, the local device can still uniquely associate each remote CID with a different device.

             

          5.2.2  Operation between Devices

             

              The connection-oriented data channels represent a connection between two devices, where a CID identifies each endpoint of the channel. The connectionless channels restrict data flow to a single direction. These channels are used to support a channel ’group?where the CID on the source represents one or more remote devices. There are also a number of CIDs reserved for special purposes. The signalling channel is one example of a reserved channel. This channel is used to create and establish connection-oriented data channels and to negotiate changes in the characteristics of these channels. Support for a signalling channel within an L2CAP entity is mandatory. Another CID is reserved for all incoming connectionless data traffic."

          • 2. Re: L2CAP connection error to non-Cypress device
            e.pratt_1639216

            My guess would be that you are using a reserved CID value

            • 3. Re: L2CAP connection error to non-Cypress device
              michael.m

              Hi.

                 

              I changed the CID number. Didn't make a difference.

                 

              Nordic in their API define CID similar to Cypress' definition of PSM. It's very confusing. And it doesn't work.

                 

              By the way, Nordic don't have L2CAP connection and disconnection functions. You only need CID number to initiate a transfer. I'm totally confused.

              • 4. Re: L2CAP connection error to non-Cypress device
                e.pratt_1639216

                Nordic and Cypress are *probably* both doing the same thing at the radio-level, but I suspect that they have different APIs due to how much they expose versus how much they internalize to the BLE stack.

                   

                From what I could find of CIDs and PSM online, they both sounded like they defined the same thing....

                   

                CID is unique connection identifier - To keep track of multiple devices using the same radio for multiple connections?

                   

                The PSM is Protocol Service Multiplexer, which sounds like it sets up multiple services to use the same radio?

                   

                So, I'm not sure what the difference is between them, but I would suspect that PSM and CID are different, and since CID is bluetooth specification defined, the CID should be the same between both nordic and cypress.

                   

                Here is the BLE component documentation from cypress: http://www.cypress.com/file/139326/download

                   

                Try reading through the L2CAP sections and see if that helps; Also try looking through the Nordic documentation and see if you can find information on the CID implementation.

                   

                Since I haven't worked with the L2CAP, I'm not sure what it is doing exactly, but it sounds like it is an RF communication method similar to TCP or UDP for networking.

                • 5. Re: L2CAP connection error to non-Cypress device
                  michael.m

                  This is how Nordic implement L2CAP in their API

                     

                  https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___l2_c_a_p___a_p_i___m_s_c.html

                     

                  (on the chart - SD means SoftDevice, which is their preprogrammed software stack)

                     

                  As you can see, no PSM and no connection request. You only need to register a local CID and you can start sending data after the GAP connection is established.

                     

                  In Cypress API you receive a CID only after successful execution of CyBle_L2capCbfcConnectReq, which is my problem right now...

                  • 6. Re: L2CAP connection error to non-Cypress device
                    e.pratt_1639216

                    Yeah. I see the issue you are running into :(
                    It seems like Nordic has a simpler connection method, whereas cypress is allowing the PSM to setup multiple device applications to use the L2CAP layer. Here is an example cypress project which contains code that uses the L2CAP layer: http://www.cypress.com/blog/100-projects-100-days/project-024-ble-throughput-pushing-limits

                       

                    Specifically, look at what is going on for the L2CAP Data Incoming and Data Outgoing examples; They should at least help with understanding why the cypress-side has more setup and stuff going on. 

                    • 7. Re: L2CAP connection error to non-Cypress device
                      michael.m

                      Yeah, I understand the example.

                         

                      Unfortunately, it seems there is no way to connect Nordic and Cypress chips via L2CAP...