This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640: Creating a L2CAP channel with L2CAP_RegisterPSM() using BTool

Part Number: CC2640

Hello,

I am really new in using BLE protocols and probably you can help me.. I try to create a L2CAP connection between 2 devices using Btool application. The CC2640 is flashed with host_test. 

Steps:

1. I connect the devices (connection succesul)

2. Try to execute L2CAP_RegisterPSM() with different PSM values. It always fails with Status 0x01 (Failure) which is not described in functions return values in API Documentation 

I copy here the send message and the response.

[21] : <Tx> - 12:21:18.675
-Type           : 0x01 (Command)
-OpCode         : 0xFE62 (GapInit_connect)
-Data Length    : 0x0A (10) byte(s)
 PeerAddrType   : 0x01 (1) (PEER_ADDRTYPE_RANDOM_OR_RANDOM_ID)
 PeerAddr       : C2:DE:2E:9B:28:27
 InitiatingPhy  : 0x01 (1) (
                  INIT_PHY_1M)
 Timeout        : 0x0000 (0)
Dump(Tx):
0000:01 62 FE 0A 01 27 28 9B 2E DE C2 01 00 00       .b...'(.......
--------------------------------------------------------------------
[22] : <Rx> - 12:21:18.713
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x06 (6) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x00 (0) (SUCCESS)
 OpCode         : 0xFE62 (GapInit_connect)
 DataLength     : 0x00 (0)
Dump(Rx):
0000:04 FF 06 7F 06 00 62 FE 00                      ......b..
--------------------------------------------------------------------
[23] : <Rx> - 12:21:18.768
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x14 (20) bytes(s)
 Event          : 0x0605 (1541) (GAP_EstablishLink)
 Status         : 0x00 (0) (SUCCESS)
 DevAddrType    : 0x01 (1) (ADDRTYPE_RANDOM)
 DevAddr        : C2:DE:2E:9B:28:27
 ConnHandle     : 0x0000 (0)
 ConnRole       : 0x08 (8) (
                  Central)
 ConnInterval   : 0x0050 (80)
 ConnLatency    : 0x0000 (0)
 ConnTimeout    : 0x07D0 (2000)
 ClockAccuracy  : 0x00 (0)
Dump(Rx):
0000:04 FF 14 05 06 00 01 27 28 9B 2E DE C2 00 00 08 .......'(.......
0010:50 00 00 00 D0 07 00                            P......
--------------------------------------------------------------------
[24] : <Tx> - 12:21:18.769
-Type           : 0x01 (Command)
-OpCode         : 0x2022 (HCI_LE_SetDataLength)
-Data Length    : 0x06 (6) byte(s)
 Handle         : 0x0000 (0)
 TxOctets       : 0x00FB (251)
 TxTime         : 0x0848 (2120)
Dump(Tx):
0000:01 22 20 06 00 00 FB 00 48 08                   ." .....H.
--------------------------------------------------------------------
[25] : <Info> - 12:21:18.851
Device Connected
Handle = 0x0000
Addr Type = 0x01 (ADDRTYPE_RANDOM)
BDAddr = C2:DE:2E:9B:28:27
--------------------------------------------------------------------
[26] : <Rx> - 12:21:18.822
-Type           : 0x04 (Event)
-EventCode      : 0x000E (HCI_CommandCompleteEvent)
-Data Length    : 0x06 (6) bytes(s)
 Packets        : 0x01 (1)
 OpCode         : 0x2022 (HCI_LE_SetDataLength)
 Status         : 0x00 (0) (SUCCESS)
 Handle         : 0x0000 (0)
Dump(Rx):
0000:04 0E 06 01 22 20 00 00 00                      ...." ...
--------------------------------------------------------------------
[27] : <Rx> - 12:21:19.053
-Type           : 0x04 (Event)
-EventCode      : 0x003E (HCI_LE_GenericReportEvent)
-Data Length    : 0x0C (12) bytes(s)
 LE Event Code  : 0x04 (4) (HCI_LE_ReadRemoteUsedFeaturesCompleteEvent)
 LE Event Code  : 0x04 (4) (HCI_LE_ReadRemoteUsedFeaturesCompleteEvent)
 Status         : 0x00 (0) (SUCCESS)
 ConnectionId   : 0x0000 (0)
 Features       : 0x00000000000041F5 (16885) (
                  Encryption
                  Reject_Extended_Indication
                  Ping
                  Data_Packet_Length_Extension
                  Privacy
                  Extended_Scanner_Filter_Policies
                  PHY_2M
                  Channel_Selection_Algorithm_2)
Dump(Rx):
0000:04 3E 0C 04 00 00 00 F5 41 00 00 00 00 00 00    .>......A......
--------------------------------------------------------------------
[28] : <Tx> - 12:21:42.989
-Type           : 0x01 (Command)
-OpCode         : 0xFCF1 (L2CAP_RegisterPsm)
-Data Length    : 0x0A (10) byte(s)
 PSM            : 0x1001 (4097)
 MTU            : 0x0017 (23)
 InitialPeerCrs : 0x000A (10)
 PeerCrThreshld : 0x0001 (1)
 MaxNumChannels : 0x01 (1)
 SecurityVrfctn : 0x00 (0) (No)
Dump(Tx):
0000:01 F1 FC 0A 01 10 17 00 0A 00 01 00 01 00       ..............
--------------------------------------------------------------------
[29] : <Rx> - 12:21:43.038
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (HCI_LE_ExtEvent)
-Data Length    : 0x06 (6) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x01 (1) (FAILURE)
 OpCode         : 0xFCF1 (L2CAP_RegisterPsm)
 DataLength     : 0x00 (0)
Dump(Rx):
0000:04 FF 06 7F 06 01 F1 FC 00                      .........
--------------------------------------------------------------------

  • Hi Robert,

    Can you please specify the version of the SDK and BLE stack you are using?

    Best regards,

  • Hello Clement,

    SDK version: 4.10.0.10 (i have installed simplelink_cc2640r2_sdk_4_10_00_10)

    About BLE stack i don't know where to find this information. I guess is the version default with this sdk version.

    Thank you,

    Robert

  • Robert,

    I am happy to help you. 

    Can you please clarify the following?

    • Are you using CC2640R2? (not CC2640)
    • Are you using \examples\rtos\CC2640R2_LAUNCHXL\ble5stack or \examples\rtos\CC2640R2_LAUNCHXL\blestack?
    • Are you trying to use this function through the Btool under Advanced Commands -> L2CAP -> L2CAP_RegisterPsm? (as shown below)
    • More importantly, can you please elaborate on what you did on step #1, "connect the devices"? Please explain your setup and the steps. I need as much information as I can so I can reproduce your issue.

    Finally, I recommend that you read through the section on L2CAP.

    Thanks,

    Luis

  • Hello Luis,

    1. I use CC2640.

    2. The application I use is from ble5stack.

    3.The function that I want to run is that you showed in the picture. I guess there is the problem choosing the PSM 

    4.For connecting the devices I do the following

    -scan for devices (I have a peripheral)

    -establish connection with the MAC address of my peripheral.

    I've read about L2CAP, but there is not specified clearly how to create a channel and to send data between devices with L2CAP in BTool. It should be the problem if the peripheral is not supporting L2CAP, but in the example I've shared I didn't try to send data, only to registerPSM on the central device.

    Thank you,

    Robert

  • Robert, 

    Thanks for your answers.

    However, I'm not convinced that you are using CC2640, but CC2640R2, which is a newer device and is compatible with the SDK that you mentioned. Are you using a custom hardware, or one of our Launchpads?

    The image at the bottom of the page that I mentioned before shows you an example of L2CAP connection-oriented channel; and suggests that the RegisterPSM action is invoked on both sides, and occurs before the connection is established, not earlier. Are you aware of that and have you tried that?

    Thanks,

    Luis

  • Robert,

    In any case, we have some example code that you can reference. Please see this post: https://e2e.ti.com/support/wireless-connectivity/bluetooth/f/538/t/912840

    Additionally, you can checkout a project called rtls_master, on the CC26x2 SDK, v3.40. 

    I hope this helps.

    -Luis

  • Hello Luis,

    I checked with my colleagues and we are using CC2640R2F. Sorry for the misunderstanding.

    My main objective is how to use L2CAP with Btool application, but I will check your examples too. The connections is done before trying to create a PSM channel.

    Thanks,

    Robert 

  • Robert,

    No problem. I'm sure our examples will help you.

    If you have any questions, please feel free to re-open this thread, or post new questions.

    -Luis

  • Hi Luis,

    I am facing the same issue with L2CAP commands when using Btool (v1.42.16 -same version as yours) with host_test project running on CC26X2R1 LaunchPad.

    All the L2CAP commands returns event status = FAILURE (your picture show the same error, it means the commands did not send successfully).

    This is the SDK version that I am using C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\tools\ble5stack\btool.

    Can you please check if the current Btool version (v1.42.16) support for L2CAP commands? If not, please let me know which version of Btool that I can use L2CAP commands for testing my BLEapp with L2CAP function?

    Thanks,

    DuongN