I'm working on a BLE Peripheral device with a GATT Server based on Serialization (SPI) and STM32. The Peripheral device also has a BLE Central Device to connect to another Peripheral; though for this issue I don't believe the Central Device impacts my results.
My application requires that I utilize Write w/ Response; while I don't mind the decreased throughput it appears that I am encountering unusually high latency that does affect my application.
Quick Description: After the Android and iOS test Central Devices Write w/ Response to my BLE Peripheral device the response from the Peripheral takes between 0.5 seconds and 1 seconds to respond. This delay varies between these values but stays ~constant with changes to connection interval. The Serialization SPI transactions show that the STM32 is finished handling with the Write / Response in <3ms.
Description of Device: STM32 connected to nRF52832 w/ S132 via SPI Serialization using ble_connectivity included with nRF5 v14.0.0, currently configured for 200mS connection interval.
Test Setup: BLE Peripheral Device connected to Android or iOS device with nRF Connect. Once connect I perform a Write Request and monitor SWD Console Output of STM32 along with SPI and Wireshark Sniffed BLE.
Data:
Wireshark screenshot shows 600mS delay in Write Request and Response:
SPI Transactions:
STM32 Receives BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST from nRF chip:
STM32 Responds by Sending SD_BLE_GATTS_RW_AUTHORIZE_REPLY:
STM32 Receives response to SD_BLE_GATTS_RW_AUTHORIZE_REPLY:
STM32 Sends SD_BLE_GATTS_VALUE_SET:
STM32 Receives response to SD_BLE_GATTS_VALUE_SET:
Timing of events from STM32 Perspective:
GATTS Decode: RW Auth: 304423 ms
RW Auth RSP Decode: 304424 ms
HHS On_Write_Value:304424 ms
Name: JOB_TYPE
UUID:6
Value: 2
Report Store:
Read: UUID: 6, Val:2
Questions:
- Is this an expected amount of delay in a Write Response?
- Is there anything I can do to speed up this response?