1.. zephyr:code-sample:: bluetooth_extended_advertising
2   :name: Extended Advertising
3   :relevant-api: bluetooth
4
5   Use the Bluetooth LE extended advertising feature.
6
7Overview
8********
9
10This sample demonstrates the use of the extended advertising feature, by:
11
12- Outlining the steps required to initialize an extended advertising application.
13- Demo how to gracefully restart the functionality, after a disconnect.
14
15The sample consists of the advertiser initiating a connectable advertisement set,
16which prompts the scanner to connect after scanning for extended advertisements.
17Once the connection is established, the advertiser waits for 5 seconds to disconnect.
18After the connection is dropped, the advertiser immediately restarts broadcasting,
19while the scanner cools-down for 5 seconds to restart its process.
20
21This sample handles all actions in a separate thread, to promote good design
22practices. Even though it is not strictly required, scheduling from another context is
23strongly recommended (e.g. using a work item), as re-starting an advertiser or
24scanner from within the ``recycled`` callback exposes the application to deadlocking.
25
26Requirements
27************
28
29* Two boards with Bluetooth Low Energy support
30
31Building and Running
32********************
33
34This sample can be found under
35:zephyr_file:`samples/bluetooth/extended_adv` in the Zephyr tree.
36
37See :zephyr:code-sample-category:`bluetooth` samples for details.
38
39This sample uses two applications, so two devices need to be setup.
40Flash one device with the scanner application, and another device with the
41advertiser application.
42
43The two devices should automatically connect if they are close enough.
44
45Here are the outputs you should get by default:
46
47Advertiser:
48
49.. code-block:: console
50
51        *** Booting Zephyr OS build zephyr-v3.5.0-4935-gfc7972183da5 ***
52        Starting Extended Advertising Demo
53        Starting Extended Advertising
54        Connected (err 0x00)
55        Connected state!
56        Initiating disconnect within 5 seconds...
57        Disconnected (reason 0x16)
58        Connection object available from previous conn. Disconnect is complete!
59        Disconnected state! Restarting advertising
60        Starting Extended Advertising
61        Connected (err 0x00)
62        Connected state!
63        Initiating disconnect within 5 seconds...
64        Disconnected (reason 0x16)
65        Connection object available from previous conn. Disconnect is complete!
66        Disconnected state! Restarting advertising
67        Starting Extended Advertising
68
69Scanner:
70
71.. code-block:: console
72
73        *** Booting Zephyr OS build zephyr-v3.5.0-4935-ge3308caf97bc ***
74        Starting Extended Advertising Demo [Scanner]
75        Found extended advertisement packet!
76        Stopping scan
77        Connected (err 0x00)
78        Connected state!
79        Disconnected (reason 0x13)
80        Recycled cb called!
81        Disconnected, cooldown for 5 seconds!
82        Starting to scan for extended adv
83        Found extended advertisement packet!
84        Stopping scan
85        Connected (err 0x00)
86        Connected state!
87        Disconnected (reason 0x13)
88        Recycled cb called!
89        Disconnected, cooldown for 5 seconds!
90        Starting to scan for extended adv
91        Found extended advertisement packet!
92        Stopping scan
93        Connected (err 0x00)
94        Connected state!
95        Disconnected (reason 0x13)
96        Recycled cb called!
97        Disconnected, cooldown for 5 seconds!
98