Commit Graph

13 Commits

Author SHA1 Message Date
Aleksander Wasaznik 8cfad44852 Bluetooth: Deprecate adv auto-resume
The host-based adv auto-resume function has both a problematic
implementation and disagreement in the community around how it should
behave. See the issue linked resolved below for details.

This patch makes the deprecation visible to the user. The user will be
better served by a auto-resume tailored their applications use case,
based on more primitive host API like `conn_cb.recycled`, which has
obvious behavior that is unlikely to change.

Resolves: https://github.com/zephyrproject-rtos/zephyr/issues/72567

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-10-08 16:57:01 +02:00
Benjamin Cabé 1db9b009a7 doc: samples: Adopt code-sample-category across tree
This commit uses the new .. zephyr:code-sample-category directive to
categorize code samples across the tree.
Updates existing legacy references to manually defined targets to now
use :zephyr:code-sample-category: role instead.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-09-23 12:00:00 +02:00
Benjamin Cabé d1858d2074 samples: bluetooth: Use "Bluetooth LE" terminology
Replace occurrences of "BLE" by the recommended "Bluetooth LE" term.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-09-05 16:58:32 -04:00
Benjamin Cabé d23d19d7f0 samples: bluetooth: use zephyr:code-sample directive
Describe the samples using code-sample directive in preparation for
upcoming changes to the Zephyr documentation that will be leveraging
the provided description and metadata.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-09-05 16:58:32 -04:00
Rubin Gerritsen a4e43d013c Bluetooth: Samples: Use string printing functions for error codes
When developing Bluetooth applications, you typically run into some errors.
If you are an experienced Bluetooth developer, you would typically know
how to translate the error codes into string representations.
Others might not.

This commit to adds string printing of error codes for all
samples to make them more user-friendly.

Several formatting alternatives were considered. The chosen alternative
balances code readability and FLASH size (with and without string
printing).

Example output from the peripheral_hids sample when the
peer rejects pairing:

```
Bluetooth initialized
Bluetooth authentication callbacks registered.
Advertising successfully started
Connected 5E:67:02:D3:1C:DB (random)
Security failed: 5E:67:02:D3:1C:DB (random) \
level 1 err 6 BT_SECURITY_ERR_PAIR_NOT_ALLOWED
Disconnected from 5E:67:02:D3:1C:DB (random), \
reason 0x13 BT_HCI_ERR_REMOTE_USER_TERM_CONN
```

Other alternatives that were considered:

- Use of parantheses:
```
// strings enabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 \
err BT_SECURITY_ERR_PAIR_NOT_ALLOWED(6)
Disconnected from 5E:67:02:D3:1C:DB (random), reason \
BT_HCI_ERR_REMOTE_USER_TERM_CONN(0x13)
// strings disabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 err (6)
Disconnected from 5E:67:02:D3:1C:DB (random), reason (0x13)
```

- Spaces and parantheses:
```
// strings enabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 \
err BT_SECURITY_ERR_PAIR_NOT_ALLOWED (6)
Disconnected from 5E:67:02:D3:1C:DB (random), \
reason BT_HCI_ERR_REMOTE_USER_TERM_CONN (0x13)
// strings disabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 err  (6)
Disconnected from 5E:67:02:D3:1C:DB (random), reason  (0x13)
```

- Parantheses around everything:
```
// strings enabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 \
err (BT_SECURITY_ERR_PAIR_NOT_ALLOWED(6))
Disconnected from 5E:67:02:D3:1C:DB (random), \
reason (BT_HCI_ERR_REMOTE_USER_TERM_CONN(0x13))
// strings disabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 err ((6))
Disconnected from 5E:67:02:D3:1C:DB (random), reason ((0x13))
```

- Error code first, then string representation:
```
// strings enabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 \
err 6 (BT_SECURITY_ERR_PAIR_NOT_ALLOWED)
Disconnected from 5E:67:02:D3:1C:DB (random), reason \
0x13 (BT_HCI_ERR_REMOTE_USER_TERM_CONN)
// strings disabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 err 6 ()
Disconnected from 5E:67:02:D3:1C:DB (random), reason 0x13 ()
```

- Apostrophes around error printing:
```
// strings enabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 \
err "BT_SECURITY_ERR_PAIR_NOT_ALLOWED (6)"
Disconnected from 5E:67:02:D3:1C:DB (random), reason \
"BT_HCI_ERR_REMOTE_USER_TERM_CONN (0x13)"
// strings disabled
Security failed: 5E:67:02:D3:1C:DB (random) level 1 err " (6)"
Disconnected from 5E:67:02:D3:1C:DB (random), reason " (0x13)"
```

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-07-31 12:56:11 +02:00
Aleksander Wasaznik c6ad4a7927 Bluetooth: samples: Switch to one-time adv
This patch removes all uses of the adv auto-resume feature in the
Bluetooth samples. The auto-resume feature is planned for deprecation.

Samples that are not intended to demonstrate a technique to do with
re-connection simply do not restart the advertiser, in interest of
simplicity. The user is expected to reboot the sample when needed.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-29 10:48:04 -07:00
Théo Battrel 7bc63985af Bluetooth: Samples: Remove uses of auto name in AD
The advertiser options to automatically add the name in the scan
response and the advertising data will be deprecated.

Update the samples that were using those options by explicitly adding
the device name in the advertising data or the scan response data.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-04-23 12:42:24 +02:00
Théo Battrel e9ee3e0af0 Bluetooth: Samples: Remove usage of `BT_DEBUG_LOG`
Remove usage of Kconfig symbol `CONFIG_BT_DEBUG_LOG` from samples. It
has been deprecated since this PR:
https://github.com/zephyrproject-rtos/zephyr/pull/56183

The Kconfig symbols has been replaced by `CONFIG_LOG=y` on most of the
cases. Or it has been removed when not needed anymore.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-07 13:56:55 -04:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Keith Packard 0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Anas Nashif ba7d730e9b tests/samples: use integration_plaforms in more tests/samples
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-29 16:03:23 +01:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Vinayak Kariappa Chettimada 8e5e0bd45e samples: Bluetooth: peripheral and central GATT write command use
Samples peripheral_gatt_write and central_gatt_write to
demonstration use of GATT Write Command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-22 12:22:29 +02:00