Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Multi peripheral with windows device API (BluetoothLEDevice/C#

Hi,

I'm using s140 trying to connect up to 8 devices to windows BLE adapter and BluetoothLEDevice object, I have 2 problems,

1- the maximum throughput with different configurations,  connection interval (7.5ms , 11.25ms , 20.25ms , 40ms) or opt.common_opt.conn_evt_ext.enable = 1/0 or different tx queue size,it is always about 220K, no matter to set tx/rx PHY as BLE_GAP_PHY_2MBPS or BLE_GAP_PHY_1MBPS , I read https://devzone.nordicsemi.com/f/nordic-q-a/37591/nrf-connect-for-desktop-max-throughput/144881#144881 hte maximum speed with windows can be 260kbps. Is there anything to do to improve the speed? I was thinking if achieving higher speed is impossible is it good idea to use one NRF52 dongle as central with USB connection to the PC and collect data from peripheral devices? what would be maximum speed we can achieve in this topology?

2- the very strange problem is as soon as connecting second device in my PC application is written by C# and windows device API(BluetoothLEDevice) the first device speed gets extremely decreased about 30kb to 8kb/s even thought the second device is not sending data. I used virtual sniffer tools  and WireShark to see if there is some hidden communication but there isn't!, I tried decrease NRF_SDH_BLE_GAP_EVENT_LENGTH to the half of connection interval and tested with different intervals but the only effect is it reduces the maximum speed but the problem still is remained which is reducing first device speed without any reason! Is that related to how windows communicate with multiple devices? if so why when i connect BT headphone it does not such an effect? 

the problem is second device as soon as connected to host application occupies almost all bandwidth and doesn't let to receive packet form the first one. We need to connect more than 8 devices to PC so is there any idea to fix this problem?

Thank you

#define NRF_SDH_BLE_GAP_EVENT_LENGTH MSEC_TO_UNITS(7.5, UNIT_1_25_MS) 

#define APP_ADV_INTERVAL                300                                     /**< The advertising interval (in units of 0.625 ms. This value corresponds to 187.5 ms). */
#define APP_ADV_DURATION                30000                                   /**< This should the same as auto shutdown timeout of PSOC. The advertising duration (300 seconds) in units of 10 milliseconds. */
#define APP_BLE_OBSERVER_PRIO           3                                       /**< Application's BLE observer priority. You shouldn't need to modify this value. */
#define APP_BLE_CONN_CFG_TAG            1                                       /**< A tag identifying the SoftDevice BLE configuration. */

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(30, UNIT_1_25_MS)        /**< Minimum acceptable connection interval (7.5 ms). */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(50, UNIT_1_25_MS)			/**< Maximum acceptable connection interval (30 ms). This is required by iOS */
#define SLAVE_LATENCY                   0                                       /**< Slave latency. */
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)         /**< Connection supervisory timeout (4 seconds). */

#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(500)                   /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(500)                  /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT    30                                       /**< Number of attempts before giving up the connection parameter negotiation. */

  • I tested more devices for the problem 2, so device #A and #B have this effect but (A# with #C ) or (B# with #C ) working fine, so is there any id or some identification number which causes conflict between 2 specific devices? or is there any RF Frequency conflict between this 2 devices? 

  • Hello,

    How do you send your packets that you measure the throughput on? And what is your event length? I see that you have a definition NRF_SDH_BLE_GAP_EVENT_LENGTH, but where do you use that in your application? By default it is used in nrf_sdh_ble.c, so unless you have changed it, it should be used there.

    Throughput on BLE with many connections is really quite complex. I suggest you test the example ble_app_att_mtu_throughput from SDK\examples\ble_central_and_peripheral\experimental\ble_app_att_mtu_throughput

    Regarding Issue 2: Does it consistently happen only when you use device A and B? And is A, B and C running the exact same application?

    Best regards,

    Edvin

  • So, for the sending process, I have an application buffer which is 16K and each time I send part of this buffer (each tx packet 244 bytes), I've either tested :

        1- pooling mode by checking sd_ble_gatts_hvx to push data and if it returns NRF_SUCCESS will prepare another 244 bytes to send. the pooling is very fast and most of time is less than 1ms.

        2- Event mode by waiting for BLE_GATTS_EVT_HVN_TX_COMPLETE to send the next tx packet

    for the measurement In the FW side I'm using UART to see successfully sd_ble_gatts_hvx  buffering time also can see BLE_GATTS_EVT_HVN_TX_COMPLETE time and distance between 2 subsequent events , The log shows almost each 7.5ms one packet is accepted as we can see in the logs here.

    In the application side I measure received RX bytes and it is 220 kb/s. It seems windows always receive packets each 7.5ms and it doesn't matter what is connection interval time!. is there any solution for that or is there anyone could achieve more than one packet each 7.5ms (more than 260kb) with windows?

    and why even when i don't send data, connecting second device reduces first connected device speed!?

    thanks!

    Maximum rate is in the PHY RX rate field

    this log above, is for 7.5ms connection interval with conn_evt_ext enabled

    this log above, is for 23.75ms connection interval with conn_evt_ext enabled

    this log above, is for 23.75ms connection interval with conn_evt_ext disabled, this one shows if we disable multipacket each interval only receives one packet and if it is enabled windows acts like 7.5ms connection interval.

  • I could find the reason of problem 1, The problem was my BT dongle adapter which is "Laird BT820-2" it seems the dongle does not support 2M PHY also the connection event always get one packet each 7.5ms., now I'm using laptop dongle which is  

    LMP 10

    Bluetooth Core Specification 5.1

    I could achieve 800K throughput , and the optimized connection interval in my case is 30ms, maybe windows only accept (specific number of packet each interval because in theory longer interval should result less overhead of interval event itself).

    ATT MTU size: 247
    hvn_tx_queue_size = 32
    #define NRF_SDH_BLE_GAP_EVENT_LENGTH MSEC_TO_UNITS(30, UNIT_1_25_MS) 
    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(30, UNIT_1_25_MS) 
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(30, UNIT_1_25_MS)		
    .tx_phys = BLE_GAP_PHY_2MBPS,
    .rx_phys = BLE_GAP_PHY_2MBPS
    opt.common_opt.conn_evt_ext.enable = 1;
    
    TX Buffer size increased to 32 has very high effect on speed(couldn't set more because of memory error but I believe we can fix this problem)
    

    The problem 2 still remained, the simple definition is when we connect several devices only one of them connects with maximum speed an the others connect with lower speed for example in the last test, 4 devices connected as , A:550K , B:80K . C:80k , D:80k 

Related