Bluetooth: Samples: periodical_adv_rps: Added sync wait delay

Problem:
on cyw208xx devices i see sometime `Timed out while synchronizing`
error in samples periodical_adv_rps/periodical_sync_rps.

log:
<err> bt_scan: Could not lookup connection handle from PAST
<err> bt_scan: Unknown handle 0x0000 for periodic advertising report
Timed out while synchronizing
...

After investigation i can confirm, the sync was created successful,
but in application (periodical_sync_rsp) terminated the sync when the
connection is not valid.

periodical_adv_rps doesn't have any mechanism to wait for sync and after
gatt write (subevent, response_slot information) it immediately
performs disconnection.

Solution:
Added sync wait delay before make disconnection, to ensure sync
is established before disconnection.

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
This commit is contained in:
Nazar Palamar 2024-08-09 15:20:16 +03:00 committed by Alberto Escolar
commit 120274b0b6

View file

@ -366,6 +366,12 @@ int main(void)
printk("PAwR config written to sync %d, disconnecting\n", num_synced - 1);
disconnect:
/* Adding delay (2ms * interval value, using 2ms intead of the 1.25ms
* used by controller) to ensure sync is established before
* disconnection.
*/
k_sleep(K_MSEC(per_adv_params.interval_max * 2));
err = bt_conn_disconnect(default_conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
if (err) {
return 0;