STM32WB data throughput issues
I have 2 STM32WB nucleo boards I'm using for testing data throughput speed. I'm running the BLE_DataThroughput example application in STM32CubeIDE v1.4.1 with STM32WB firmware v1.8.0.
One board is programmed as the client (central) and the other as the server (peripheral). Out of the box the example works. I can connect to both of them with PuTTY and see they connect to each other quickly. I press button 1 on the server and it starts transferring data to the client and I see the data rate in the client's terminal window. Pressing button 2 changing the PHY from 1 Mbps to 2 Mbps and vice versa.
The problem I'm having is the data rates appear unreliable for 1 Mbps and very slow for 2 Mbps. For 1 Mbps I'm getting this in the terminal. The data rate is all over the place and sometimes it goes up to 96,000 bytes/s. According to the calculations here (https://www.novelbits.io/bluetooth-5-speed-maximum-throughput/), I estimate a max data rate of 97,600 bytes/s for 1 Mbps PHY on BLE 5. So that seems about right but the variability in the data rate is bad.
DT = 30744 bytes/s lost = 0
DT = 22204 bytes/s lost = 0
DT = 43676 bytes/s lost = 0
DT = 42212 bytes/s lost = 0
DT = 67588 bytes/s lost = 0
DT = 28548 bytes/s lost = 0
DT = 68564 bytes/s lost = 0
DT = 58804 bytes/s lost = 0
DT = 27328 bytes/s lost = 0
DT = 50752 bytes/s lost = 0With the PHY set to 2 Mbps, I get this data rate in the client's terminal. That is extremely low. According to that website the max should be about 172,000 bytes/s.
DT = 2196 bytes/s lost = 0
DT = 2196 bytes/s lost = 0
DT = 1464 bytes/s lost = 0
DT = 2196 bytes/s lost = 0
DT = 2196 bytes/s lost = 0
DT = 1708 bytes/s lost = 0
DT = 2196 bytes/s lost = 0
DT = 2196 bytes/s lost = 0
DT = 2196 bytes/s lost = 0
DT = 2196 bytes/s lost = 0I then altered the code according to ST's AN5289 section 7.6.5 pasted below. I added to the button 2 callback to set the connection interval to 50ms. I changed DATA_NOTIFICATION_MAX_PACKET_SIZE in app_conf.h to 244. I changed hci_le_set_data_length to be (conn_handle, 251, 2120) in app_ble.c. CFG_BLE_MAX_ATT_MTU is already 250 in app_conf.h and changes upon connection.

When I now press button 2, the server terminal gives this. There is no change in the data rate in the client's terminal window.
change PHY
Read_PHY success
PHY Param TX= 1, RX= 1
hci_le_set_phy PHY Param TX= 2, RX= 2
set PHY cmd ok
change conn update to 50ms
BLE_SVC_L2CAP_Conn_Update(), Successfully
EVT_UPDATE_PHY_COMPLETE, successI don't understand why 1 Mbps transmission is erratic and 2 Mbps is slow. One thing I haven't seen is how many packets are sent per a connection interval and if that is limited for some reason.
My end application is to have the server continuously read from an SPI sensor and transfer to the client as fast as possible.
Thank you for any help!