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.

LAUNCHXL-CC2640R2: How to connect automatically peripherals to central ?

Part Number: LAUNCHXL-CC2640R2

Hello,

How to connect peripheral without using menu in multirole example.

Regards,

Jaydipsinh

  • You can take a look at simple_central project. Under the #ifdef FPGA_AUTO_CONNECT case and then incorporate it into your project.
  • Hello Christin,

    I have seen that example but in that example will connect to first device only and I want that if peripheral starts advertising then it should get connected to that only device should not be connected to any other device rather than multirole.

    regards,
    Jaydipsinh
  • Hi,

    Then what you are looking for is directed advertising(connectable directed advertising event), which only the certain device can connect to you. You can take a look at our SimpleLink Academy "Bluetooth Low Energy Scanning and Advertising" for more information.

    Then in your central, in the end of the scan event, you can extract the the needed information.(ex: adverting type and payload info) Use the extract information to decide if you want to connect or not by just adding GAPRole_EstablishLink() in the end of the scan event.
  • Hello Christin,

    I am creating a function and in that function I am adding events of scanning, connecting and disconnecting.
    but now I am little bit confused in this where I can call that function?
    do I have to call it inside the task function or in init function?
    please do reply.
    Thanks for your help.

    Regards,
    Jaydipsinh
  • I would recommend you to put all your user events under "multi_role_processAppMsg" and creating your function to process your task.

    For example, you can directly call scan under function multi_role_processRoleEvent: case GAP_DEVICE_INIT_DONE_EVENT if you just want the device to discover right away. Then add GAPRole_EstablishLink under function multi_role_processRoleEvent: GAP_DEVICE_DISCOVERY_EVENT
  • Hello Christin,
    Thanks for your detailed explanation,
    I connected one device to multirole but mutirole stopped advertising after one connection.
    I used functions of multirole mr_doConnect(uint8_t index) and connected a device.
    I am using mr_doAdvertise(uint8_t index) function to start advertising but it's not advertising even if it's going inside that function.
    so what could be the possible solution for this.

    Regards,
    jaydipsinh
  • Hi,

    In out of box multirole, the maximum available link(MAX_NUM_BLE_CONNS) is set to 4.
    So if there are less than 4 connections, the device will stay advertising.

    If you take a look at the mr_doAdvertise code, you will see that if the device is currently advertising, then calling this function will turn it off.
    Therefore, if you want the device to advertise after being connected, you should just do nothing.