|
| 1 | +diff --git a/samples/bluetooth/extended_adv/advertiser/prj.conf b/samples/bluetooth/extended_adv/advertiser/prj.conf |
| 2 | +index 0c352e3950f..2dda13d5541 100644 |
| 3 | +--- a/samples/bluetooth/extended_adv/advertiser/prj.conf |
| 4 | ++++ b/samples/bluetooth/extended_adv/advertiser/prj.conf |
| 5 | +@@ -2,5 +2,6 @@ CONFIG_BT=y |
| 6 | + CONFIG_BT_DEVICE_NAME="test_ext_adv" |
| 7 | + CONFIG_BT_PERIPHERAL=y |
| 8 | + CONFIG_BT_EXT_ADV=y |
| 9 | ++# CONFIG_ARCH_POSIX=y |
| 10 | + |
| 11 | + CONFIG_ASSERT=y |
| 12 | +diff --git a/samples/bluetooth/extended_adv/advertiser/src/main.c b/samples/bluetooth/extended_adv/advertiser/src/main.c |
| 13 | +index 66cdb6cee8f..accc93a19a5 100644 |
| 14 | +--- a/samples/bluetooth/extended_adv/advertiser/src/main.c |
| 15 | ++++ b/samples/bluetooth/extended_adv/advertiser/src/main.c |
| 16 | +@@ -8,6 +8,7 @@ |
| 17 | + #include <zephyr/bluetooth/conn.h> |
| 18 | + #include <zephyr/bluetooth/gap.h> |
| 19 | + #include <zephyr/bluetooth/hci.h> |
| 20 | ++#include "nsi_main.h" |
| 21 | + |
| 22 | + static struct bt_conn *default_conn; |
| 23 | + |
| 24 | +@@ -122,7 +123,9 @@ int main(void) |
| 25 | + return err; |
| 26 | + } |
| 27 | + |
| 28 | +- while (true) { |
| 29 | ++ // Try to terminate gracefully after 100 disconnects |
| 30 | ++ int max_disconnects = 10; |
| 31 | ++ while (max_disconnects > 0) { |
| 32 | + k_poll(&poll_evt, 1, K_FOREVER); |
| 33 | + |
| 34 | + k_poll_signal_reset(poll_evt.signal); |
| 35 | +@@ -145,7 +148,7 @@ int main(void) |
| 36 | + } |
| 37 | + } else if (atomic_test_and_clear_bit(evt_bitmask, BT_SAMPLE_EVT_DISCONNECTED) && |
| 38 | + app_st == BT_SAMPLE_ST_CONNECTED) { |
| 39 | +- |
| 40 | ++ max_disconnects--; |
| 41 | + printk("Disconnected state! Restarting advertising\n"); |
| 42 | + app_st = BT_SAMPLE_ST_ADV; |
| 43 | + err = start_advertising(adv); |
| 44 | +@@ -155,5 +158,11 @@ int main(void) |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | ++ #ifdef CONFIG_ARCH_POSIX |
| 49 | ++ // Exit gracefully - call cleanup NSI tasks |
| 50 | ++ printk("Calling nsi_exit\n"); |
| 51 | ++ nsi_exit(0); |
| 52 | ++ #endif |
| 53 | ++ |
| 54 | + return err; |
| 55 | + } |
0 commit comments