mirror of
https://github.com/espressif/openthread.git
synced 2026-07-25 13:34:06 +00:00
6677bdd762
This fixes issues where the closing of the TLS session or sudden closing of the BLE link did not always lead to the required behavior. Changes: - detail the API for the callback otHandleBleSecureConnect() including valid state combinations and expected moments of calling. - introduce a new internal state kClosing for the BLE link. Tracking the "is closing" state avoids making duplicate platform function calls or duplicate callbacks. - if a TLS handshake is ongoing and the BLE link goes down, mTls state is now also properly cleaned up. - if the TLS session closes (for whatever reason), the BLE link is now also torn down. The 'Disconnect()' call is used to achieve this. When needed, guard time is used to properly close TLS - e.g. sending the Alert and let the BLE link transmit that beforing closing the link. - the simulation BLE platform had an issue that the closing handshake caused the simulated BLE link to be immediately 'connected' again. This is fixed by introducing a state var sIsAdvertising, draining any pending UDP data of the simulated BLE link, and checking sIsAdvertising before accepting a new BLE connection. - avoid calling platform BLE advertisement-enable function while the BleSecure link is still active/closing up. Request BLE advertising again after final disconnect. - code readability improvements. Unit tests are expanded to test more details of the flow.