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

Multilink central - data always received from the last device

Hello,

I am having a custom nRF52832-based central device - it works fine when connecting a single nRF52832-based peripheral (the both are based on SDK 14).

Now I need to support two identical peripheral devices - I have increased NRF_SDH_BLE_CENTRAL_LINK_COUNT to 2, and enabled scanning after discovery of the first device. Now, both peripheral devices connect simulteniously to the central without a problem. In order to receive the data from the both, however, I guess I should also modify the part related to data reception. I have checked the ble_app_multilink_central example but still not sure how to implement that part. I guess I should modify somehow connection handling parts. Currently, data is always received from the last connected device. That is, when first device gets connected, data comes from it. Once the second peripheral gets connected, data reception from first device gets terminated and reception of data from the second device starts.

Any guidance or advice would be appreciated.

P.S. Here https://devzone.nordicsemi.com/f/nordic-q-a/29790/multiperipheral-uart-example  I see the following:

"you would need an array to store the attribute table (the handles), if you have 2 devices, you need space for two tables"

In my case I have

BLE_DB_DISCOVERY_DEF(m_db_disc); and I replaced it with  BLE_DB_DISCOVERY_ARRAY_DEF(m_db_disc, NRF_SDH_BLE_CENTRAL_LINK_COUNT);

At BLE_GAP_EVT_CONNECTED I have the following:

        case BLE_GAP_EVT_CONNECTED:
             // Upon connection, check which peripheral has connected, initiate DB
             // discovery, update LEDs status and resume scanning if necessary. 			
    	     DEBUGOUT1("Connection 0x%x established, starting DB discovery.", p_gap_evt->conn_handle);
    		 ble_connected();
    
            // start discovery of services. 
    
            err_code = ble_db_discovery_start(&m_db_disc[p_gap_evt->conn_handle], p_ble_evt->evt.gap_evt.conn_handle);
            APP_ERROR_CHECK(err_code);

However, still only receiving data from one peripheral device at a time. So anything else I could be missing?

  • @Håvard , If it will simplify the situation, I could share my central project source code; please, let me know what is best to do to discover the problem asap. Also, thanks for the kind attitude on solving the problem so far.

    Kind regards

  • Hi, sorry for the late reply.

    It might help me to look at the code. Since you are following the multilink example closely, I'm confident that we can figure this out together. :)

    So, if you connect to peripheral 1, and then to peripheral 2: peripheral 2 will not work as expected.
    But if you reconnect peripheral 2, then the central will do service discovery on it, and peripheral 2 will work as expected. But peripheral 1 stops sending notifications. Correct?

    have you looked at the immediate alert service by the way? The multilink example treats data from the peripherals the same way, while the ble_app_ias + ble_app_ias_c keep track of how the alerts can actually be different on the different peripherals/clients.

    How many characteristics are in the services you made? Could we be hindered by this variable BLE_DB_DISCOVERY_MAX_SRV ? (If so, it can simply be increased).

  • Hi Håvard,

    Thanks for the kind reply. I discovered by chance that changing MAX_CONNECTION_INTERVAL from 500 to 10, or even 7.5 has a great effect and with such values connection/disconnection of one peripheral does not influence the data flow from the other one, yet when the both are connected data from the both are received well. So I consider this problem solved. Now only one problem remains: if the peripherals are enabled and the central device is turned on last - it does not initiate discovering the devices. To discover a peripheral, it needs a restart. Could you give hints how to deal with that?

    Kind regards,

    Kamen

  • if the peripherals are enabled and the central device is turned on last - it does not initiate discovering the devices. To discover a peripheral, it needs a restart. Could you give hints how to deal with that?

    Could it be that you peripherals have stopped advertising? Or do they connect as expected, and then the central simply does nothing?

     

Related