CC2340R5: Central mode without button option CC2340R5

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Dear Experts,

I am currently working with the following setup:

  • CCS Version: 20.2.0

  • SDK: simplelink_lowpower_f3_sdk_9_11_00_18

  • Example: basic_ble

We are using a CC2340R5-based instrument that advertises BLE data. Currently, we are successfully receiving its advertising data on an Android device using the nRF Connect app.

Now, we are planning to replace the Android device with another CC2340R5 board to receive the data directly.

As I am new to working with low-power BLE devices, I would greatly appreciate your guidance to move in the right direction.

Requirements:

  • Automatically connect to a CC2340R5-based instrument using a predefined static ID and passkey.

  • Receive data from the instrument.

  • Print the received data via UART.

  • The instrument advertises once every minute and stays in advertising mode for 20 seconds, so the scanner must detect and connect during this window.

Clarification and Guidance Needed:

Please advise on how to make the following changes to the example project:

  1. Disable Button Input-Based Operation

    • How can I disable the button-triggered behavior?

    • Which source file contains this implementation?

  2. Start Scanning Automatically on Power-Up

    • How can I initiate BLE scanning automatically on device startup?

    • Where can I configure UART settings in code (not using SysConfig)?

    • I’d like to print discovered device names to UART. Can you guide me where to modify files like app_central.c, app_connection.c, etc.?

  3. Define Peripheral Passkey

    • Where can I define the passkey for connecting to the peripheral (broadcaster) device?

  4. Connect to Known Device with Passkey

    • Which file contains the logic to send a connection request and provide the passkey when the known device is found?

  5. Read/Write Request Functions

    • Which file(s) handle GATT read and write operations once the connection is established?

    • How can I read advertising or characteristic data from the peripheral?

Any suggestions, code examples, or documentation references would be highly appreciated.

Thank you for your time and support.

Surya

  • Hello Surya,

    I would suggest to take a look at the following central example: https://github.com/TexasInstruments-Sandbox/ble_examples/tree/simplelink_low_power_f3_sdk-7.40.03/examples/rtos/LP_EM_CC2340R5/ble5stack/basic_ble_GATT_client

    1. The menu/button interaction are defined in the app_menu.c. If you dont want to use the display, you can disable it in SysConfig under BLE -> Advance Settings -> Disable Display Module.
    2. If you want to start scanning on power-up, then all of the functions executed inside Central_start() function (look inside app_central.c) must be executed.
    3. Please look into: https://software-dl.ti.com/simplelink/esd/simplelink_lowpower_f3_sdk/9.11.00.18/exports/docs/ble5stack/ble_user_guide/html/ble-stack-5.x/gapbondmngr-cc23xx.html?highlight=passkey#passcode-entry
    4. The advertising data and characteristic data are read at different moments of the process (adv and connection). The first one is read from the adv report, while the second one relies on the gatt table of the server and gatt operations executed to the corresponding handles. Please take a look at these two training material:
      1. Adv Report: https://dev.ti.com/tirex/explore/content/simplelink_academy_for_cc23xx_8_40_01_00/_build_simplelink_academy_for_cc23xx_8_40_01_00/source/ble/cc2340rx_02_ble_scan_adv_basic.html
      2. Gatt: https://dev.ti.com/tirex/explore/content/simplelink_academy_for_cc23xx_8_40_01_00/_build_simplelink_academy_for_cc23xx_8_40_01_00/source/ble/cc2340rx_01_basic_examples_advanced.html

    BR,

    David.

  • Dear  
    Thanks for the suggestions, now i have changed the device cc2340 into cc1352

    • Code Composer Studio: 20.2.0

    • SDK: simplelink_cc13xx_cc26xx_sdk_8_30_01_01

    • Example project: simple_central_CC1352R1_LAUNCHXL_tirtos7_ticlang

    Requirements

    • Automatically connect to a CC2340R5-based instrument using a predefined static address and passkey.

    • Receive data from the instrument.

    • Print the received data via UART.

    • The instrument advertises once every minute and stays in advertising mode for 20 seconds. The scanner must detect and connect during this window.

    Progress So Far

    I’ve configured the CC1352R-based device to scan without requiring button input. When scanning, the UART prints the device names. If the known BLE address is detected, scanning stops and an automatic connection is initiated.

    Example UART output (captured in HERCULES, with modified Display_printf):

    Connecting to FM_ADDR...
    Connected to 0x40791213A330
    Num Conns: 1
    *Simple Central
    < Next Item
    +Set Scanning PHY >
    Discover Devices
    +Work with
    +Set AutoConnect
    Encryption success

    Current Roadblock

    At this point, the device connects successfully and encryption is completed. Now I need to:

    • Read and write data to/from the connected instrument.

    • Possibly access or interpret advertising data (if available after connection).

    Request

    Could you please guide me on how to proceed with:

    1. Writing data to the connected BLE device.

    2. Receiving data notifications or indications.

    3. Handling GATT read/write operations post connection.

    4. (Optional) Accessing any remaining advertisement data after the connection is established, if possible.

    Any code references, TI examples, or pointers to API functions would be greatly appreciated.

    Regards
    Surya.

  • Hello Surya,

    I think the best example for this is the one I am sharing: https://github.com/TexasInstruments-Sandbox/ble_examples/tree/simplelink_cc13x2_26x2_sdk-5.10/examples/rtos/CC26X2R1_LAUNCHXL/ble5apps/simple_serial_socket_client. There you have notifications and write commands.

    Please use it as a reference and let me know if you have questions in the process.

    Best Regards,

    David.

  • Hello  ,

    Thanks for the reference link. However, the SDK example you shared is quite old and still relies on button-based operations. As I mentioned earlier, I'm specifically trying to eliminate the need for button interactions. I want the process — including scanning, connecting, writing, and reading — to be fully automatic.

    So far, I've successfully implemented auto-scanning and can find the known device using its static address. The device connects successfully, and the process reaches the "encryption success" stage, but it then gets stuck there.

    I'm seeking your advice on which API I should call next, or what steps I need to take to proceed with writing to and reading from the connected device. Could you please guide me on how to achieve this using the current SDK?

    If needed, I’m happy to share my complete code for your review.

    regards
    Surya

  •  Dear  ,
    currently the code execte the following function then stuck in this 

    else if (state == GAPBOND_PAIRING_STATE_ENCRYPTED)
      {
        if (status == SUCCESS)
        {
          Display_printf(dispHandle, 0, 0, "Encryption success\r\n");
          //SimpleCentral_autoConnect();  //NEW LINE
        }
        else
        {
          Display_printf(dispHandle, 0, 0, "Encryption failed: %d\r\n", status);
        }

        GAPBondMgr_GetParameter(GAPBOND_PAIRING_MODE, &pairMode);

        if ((autoConnect) && (pairMode == GAPBOND_PAIRING_MODE_INITIATE))
        {
          SimpleCentral_autoConnect();
        }
      }

    Please let me know what i need to do...

    regards
    Surya




  • Hello Surya,

    I assume you get a Encryption success print message correct? Does it get stuck when running SimpleCentral_autoConnect();? I would refer to the simple_central example for the configuration of the autoconnection feature. Specifically SimpleCentral_autoConnect() and SimpleCentral_doAutoConnect() in simple_central.c. Note that the central won't start automatically connecting to the chosen group until all defined group members are successfully scanned and found. Number of group members are defined by MAX_NUM_BLE_CONNS. Hence the user have to pre-define the number of members that wanted to be connected to.

    BR,

    David.

  • Hello  

    Please review the following log and let me know what steps I need to take next:

    *Simple Central
    < Next Item
    +Set Scanning PHY >
    Discover Devices
    +Set AutoConnect

    *Simple Central
    Stop Discovering >

    Discovering...

    DEFAULT_Discovered: 0x40791213A330:0x40791213A330

    FM_IDENTIFIED

    DEFAULT_Discovered: 0x40791213A330:0x40791213A330

    FM_IDENTIFIED

    Connecting to FM_ADDR...
    Connected to 0x40791213A330
    Num Conns: 1

    *Simple Central
    < Next Item
    +Set Scanning PHY >
    Discover Devices
    +Work with
    +Set AutoConnect

    Encryption success

    Notes:

    1. Automatic Scan - Completed

      The scan was automatically started and completed from the SimpleCentral_init function using:

      GapScan_enable(0, 0, 0)
    2. Device Discovery - Completed

      The known device was discovered using the following logic (when DEFAULT_DEV_DISC_BY_SVC_UUID is not defined):

      char bdAddrStr[18]; // 17 characters + null terminator
      snprintf(bdAddrStr, sizeof(bdAddrStr), "%s", Util_convertBdAddr2Str(pAdvRpt->addr));
      Display_printf(dispHandle, 0, 0, "DEFAULT_Discovered: %s:%s\r\n", Util_convertBdAddr2Str(pAdvRpt->addr), bdAddrStr);

      if (strcmp(bdAddrStr, FM_ADDR) == 0)
      {
      GapScan_disable(0);
      FM_FOUND = TRUE;
      Display_printf(dispHandle, 0, 0, "\r\nFM_IDENTIFIED\r\n"); // Store for later connection
      memcpy(knownPeerAddr, pAdvRpt->addr, B_ADDR_LEN);
      knownPeerAddrType = pAdvRpt->addrType; knownPeerFound = true;
      }



    3. Connection Request Sent

      After scan is disabled (in SC_EVT_SCAN_DISABLED case), the following logic is executed:

      if (knownPeerFound) { knownPeerFound = false; // Force pairing and bonding mode
      uint8_t pairMode = GAPBOND_PAIRING_MODE_INITIATE;
      GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode);
      uint8_t bondingEnabled = TRUE;
      GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bondingEnabled);
      status_t status = GapInit_connect( knownPeerAddrType & MASK_ADDRTYPE_ID, knownPeerAddr, DEFAULT_INIT_PHY, CONNECTION_TIMEOUT );
      if (status == SUCCESS)
      {
      Display_printf(dispHandle, 0, 0, "Connecting to FM_ADDR...");
      }
      else
      {
      Display_printf(dispHandle, 0, 0, "Connect failed");
      }
      return; // Skip the rest of SC_EVT_SCAN_DISABLED
      }
    4. Link Established

      Once connected (in GAP_LINK_ESTABLISHED_EVENT), the following is logged:

      pStrAddr = (uint8_t*) Util_convertBdAddr2Str(connList[connIndex].addr);
      Display_printf(dispHandle, 0, 0, "Connected to %s\r\n", pStrAddr);
      Display_printf(dispHandle, 0, 0, "Num Conns: %d\r\n", numConn);

    5. Pairing State Handling

      In the SimpleCentral_processPairState function, the following is executed when encryption is successful:

      else if (state == GAPBOND_PAIRING_STATE_ENCRYPTED)
      {
      if (status == SUCCESS)
      {
      Display_printf(dispHandle, 0, 0, "Encryption success\r\n");
      //SimpleCentral_autoConnect(); // Optional
      }
      else
      {
      Display_printf(dispHandle, 0, 0, "Encryption failed: %d\r\n", status);
      }
      GAPBondMgr_GetParameter(GAPBOND_PAIRING_MODE, &pairMode);
      if ((autoConnect) && (pairMode == GAPBOND_PAIRING_MODE_INITIATE))
      {
      SimpleCentral_autoConnect();
      }
      }

      6. Question: What do I need to do next?
    Regards
    Surya
  • Hello  
    i have comment the below line then i got following logs

    //SimpleCentral_buildMenu();

    Initialized
    87[10r[1;1HNum Conns: 0
    87[10r[1;1HID Addr: 0xFCA89BECB290
    87[10r[1;1HRP Addr: 0x60335EB8598C
    87[10r[1;1HDiscovering...
    87[10r[1;1HDEFAULT_Discovered: 0x420915A04C58:0x420915A04C58
    87[10r[1;1HDEFAULT_Discovered: 0x727D9F13F3E6:0x727D9F13F3E6
    87[10r[1;1HDEFAULT_Discovered: 0x73B750D511B4:0x73B750D511B4
    87[10r[1;1HDEFAULT_Discovered: 0x40791213A330:0x40791213A330
    87[10r[1;1H
    FM_IDENTIFIED
    87[10r[1;1HAutoConnect: Not all members found, only 0 members were found

    regards
    Surya