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