zephyr/modules
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
..
acpica
canopennode
cmsis arch: arm: Add initial support for Cortex-M85 Core 2024-06-26 13:36:14 -04:00
cmsis-dsp
cmsis-nn modules: cmsis-nn: add *_s4.c sources 2024-06-28 07:50:12 -04:00
fatfs fs: fat_fs: make IOCTL call to de-initialize disk in fatfs_unmount() 2024-06-07 18:16:01 +01:00
hal_ambiq drivers: spi: create Ambiq SPI BLEIF driver 2024-05-27 03:27:43 -07:00
hal_ethos_u
hal_gigadevice
hal_infineon drivers: flash: Support for IFX QSPI Flash driver 2024-07-29 14:14:10 +02:00
hal_nordic modules: hal_nordic: adjust HFCLK ramp-up time. 2024-07-27 20:50:32 +03:00
hal_nxp modules: hal_nxp: Fix i2s define mistake 2024-07-11 16:13:35 +02:00
hal_rpi_pico
hal_st
hostap modules: hostap: fix disconnect print fail log 2024-07-27 15:19:56 +03:00
liblc3
littlefs
loramac-node lorawan: services: frag transport: prepare for pluggable decoder 2024-06-11 16:09:23 +03:00
lvgl input: add a user_data pointer to the callback 2024-07-31 12:55:11 +02:00
lz4
mbedtls modules: mbedtls: rename MBEDTLS_PSA_CRYPTO_RND_SOURCE 2024-07-27 15:07:44 +03:00
nanopb modules: nanopb: Pull upstream fixes 2024-05-07 21:22:43 -04:00
openthread Bluetooth: Samples: Use string printing functions for error codes 2024-07-31 12:56:11 +02:00
percepio manifest: update percepio 2024-06-13 17:50:29 +02:00
segger modules: segger: Add Kconfig option to use CCM for data 2024-04-17 14:38:54 +02:00
tflite-micro submanifests: update tflite-micro 2024-06-28 07:50:12 -04:00
thrift posix: create kconfig options for pse51, pse52, pse53 2024-06-04 16:27:12 -05:00
trusted-firmware-a
trusted-firmware-m modules: tf-m: fix git clone during build 2024-07-25 12:25:32 +02:00
uoscore-uedhoc
zcbor
Kconfig soc: renesas: ra: Add initial support for RA8M1 SOC series 2024-06-26 13:36:14 -04:00
Kconfig.altera
Kconfig.atmel
Kconfig.chre
Kconfig.cypress
Kconfig.eos_s3
Kconfig.esp32
Kconfig.imx
Kconfig.infineon
Kconfig.intel
Kconfig.libmetal
Kconfig.mcuboot mcuboot: Remove OVERWRITE_ONLY from DIRECT_XIP modes. 2024-05-08 12:04:45 +02:00
Kconfig.mcux mcux: add Kconfig to configure NXP BLE monolithic feature 2024-06-04 19:12:45 -04:00
Kconfig.microchip soc: microchip: mec: Add new HAL based MEC5 family chips 2024-05-21 16:45:30 -04:00
Kconfig.nuvoton drivers: rtc: support for Nuvoton numaker m46x 2024-04-30 14:31:29 -04:00
Kconfig.nxp_s32
Kconfig.open-amp
Kconfig.picolibc
Kconfig.renesas_fsp driver: serial: Add serial driver support for Renesas RA8 devices 2024-06-26 13:36:14 -04:00
Kconfig.silabs modules: Move away from SOC_VENDOR_SILABS 2024-06-10 15:15:34 -05:00
Kconfig.simplelink posix: deprecate PTHREAD_IPC _MUTEX _COND and _KEY 2024-06-04 16:27:12 -05:00
Kconfig.sof
Kconfig.stm32
Kconfig.sysbuild
Kconfig.syst
Kconfig.telink
Kconfig.tinycrypt
Kconfig.vega
Kconfig.wurthelektronik
Kconfig.xtensa
modules.cmake