README.rst
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
34See :zephyr:code-sample-category:`bluetooth` samples for details.
35
36This sample uses two applications, so two devices need to be setup.
37Flash one device with the scanner application, and another device with the
38advertiser application.
39
40The two devices should automatically connect if they are close enough.
41
42Here are the outputs you should get by default:
43
44Advertiser:
45
46.. code-block:: console
47
48 *** Booting Zephyr OS build zephyr-v3.5.0-4935-gfc7972183da5 ***
49 Starting Extended Advertising Demo
50 Starting Extended Advertising
51 Connected (err 0x00)
52 Connected state!
53 Initiating disconnect within 5 seconds...
54 Disconnected (reason 0x16)
55 Connection object available from previous conn. Disconnect is complete!
56 Disconnected state! Restarting advertising
57 Starting Extended Advertising
58 Connected (err 0x00)
59 Connected state!
60 Initiating disconnect within 5 seconds...
61 Disconnected (reason 0x16)
62 Connection object available from previous conn. Disconnect is complete!
63 Disconnected state! Restarting advertising
64 Starting Extended Advertising
65
66Scanner:
67
68.. code-block:: console
69
70 *** Booting Zephyr OS build zephyr-v3.5.0-4935-ge3308caf97bc ***
71 Starting Extended Advertising Demo [Scanner]
72 Found extended advertisement packet!
73 Stopping scan
74 Connected (err 0x00)
75 Connected state!
76 Disconnected (reason 0x13)
77 Recycled cb called!
78 Disconnected, cooldown for 5 seconds!
79 Starting to scan for extended adv
80 Found extended advertisement packet!
81 Stopping scan
82 Connected (err 0x00)
83 Connected state!
84 Disconnected (reason 0x13)
85 Recycled cb called!
86 Disconnected, cooldown for 5 seconds!
87 Starting to scan for extended adv
88 Found extended advertisement packet!
89 Stopping scan
90 Connected (err 0x00)
91 Connected state!
92 Disconnected (reason 0x13)
93 Recycled cb called!
94 Disconnected, cooldown for 5 seconds!
95