Hello,
i have a BLE Peripheral that has a service that we use to simulate UART over BLE. Very similar to the nRF UART. I consider the time to establish a link that allows to send asynchronous data to be quite high. I'm using an android device to setup the link and i measure the time in this application. The peripheral supports a MTU size of 247 bytes, and this is negotiated during the setup.
This is the flow:
- The device is found by the BLE scanner
- Start time measurement
- Connect to the device
- When the onConnectionStateChange indicates a successfull connection, start a MTU negotiation.
- When the MTU is negotiated, start a service discovery.
- When the services are discovered, verify our service and that the corresponding characteristics exists with correct properties.
- enable notifications by writing to the corresponding descriptor.
- When the onDescriptorWrite event is fired from the gattCallback, the link is considered established.
- Stop measuring time.
I've written a test application that simulates this repeatedly. When i run this test 1500 times i get the following results:
- Worst case: 3046ms
- Best case: 389ms
- Average: 867
I might run this test again to see if i can do more statistical measurements on the result. These are my parameters:
#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(39, UNIT_1_25_MS)
#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(80, UNIT_1_25_MS)
#define BLE_SLAVE_LATENCY 0
#define BLE_CONN_SUP_TIMEOUT MSEC_TO_UNITS(2000, UNIT_10_MS)
#define BLE_FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000)
#define BLE_NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000)
#define BLE_MAX_CONN_PARAMS_UPDATE_COUNT 3
#define BLE_APP_ADV_INTERVAL 320
#define BLE_APP_ADV_TIMEOUT_IN_SECONDS 0
Any ideas of how to improve the connection time?