From f6aa44cafa22bd2a57aab19bb26b99c3c24a5479 Mon Sep 17 00:00:00 2001 From: Takumi Ando Date: Wed, 2 Feb 2022 18:58:14 +0900 Subject: [PATCH 01/52] examples/lte_azureiot: Use stat() instead of fseek() to get filelength Sometimes filelength() returns invalid length with fseek() implementations. It can be avoided with stat() one. Signed-off-by: Takumi Ando --- examples/lte_azureiot/lte_azureiot_main.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/examples/lte_azureiot/lte_azureiot_main.c b/examples/lte_azureiot/lte_azureiot_main.c index 7d4079930..b0cf0f616 100644 --- a/examples/lte_azureiot/lte_azureiot_main.c +++ b/examples/lte_azureiot/lte_azureiot_main.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "azureiot_if.h" #include "lte_connection.h" #include "mbedtls_if.h" @@ -495,25 +496,19 @@ static int recv_message(struct azureiot_info *info, /* ------------------------------------------------------------------------ */ static int filelength(const char *file_name) { - int size = ERROR; - FILE *fp = fopen(file_name, "rb"); + struct stat st; - if (fp) + if (stat(file_name, &st)) { - if (fseek(fp, 0L, SEEK_END) == 0) - { - fpos_t pos; - - if (fgetpos(fp, &pos) == 0) - { - size = (int)pos; - } - } + return ERROR; + } - fclose(fp); + if ((st.st_mode & S_IFMT) != S_IFREG) + { + return ERROR; } - return (int)size; + return st.st_size; } /* ------------------------------------------------------------------------ */ From d1bd898cd6f8b9ae8151d032d0a31234c33476eb Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 19 May 2022 07:27:23 +0900 Subject: [PATCH 02/52] Update Submodules for develop at 2022/05/19 07:27:23 --- nuttx | 2 +- sdk/apps | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuttx b/nuttx index 99d51cd4d..09af2155c 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit 99d51cd4d9ae112c08ddf84737de2a33fc079d69 +Subproject commit 09af2155c964159cce51cfea9a211a255613845d diff --git a/sdk/apps b/sdk/apps index fb3f4e3e4..6f97d735d 160000 --- a/sdk/apps +++ b/sdk/apps @@ -1 +1 @@ -Subproject commit fb3f4e3e48fb915ddcb9224d374f666d2de85aff +Subproject commit 6f97d735ddb245be4e97ee041acd13d6f8fe48a8 From 97a0d2af834a7205e3b22a56c7f61a1daf2adf5b Mon Sep 17 00:00:00 2001 From: Nimish Telang Date: Sun, 29 May 2022 00:21:36 -0400 Subject: [PATCH 03/52] use env bash --- sdk/tools/Makefile.export | 2 +- sdk/tools/build-env.sh | 2 +- sdk/tools/completion.sh | 2 +- sdk/tools/flash.sh | 2 +- sdk/tools/mkexport.sh | 2 +- sdk/tools/mkkconfig.sh | 2 +- sdk/tools/mkmsys2deps.sh | 2 +- sdk/tools/mkromfsimg.sh | 2 +- sdk/tools/mksdkexport.sh | 2 +- sdk/tools/mkversion.sh | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sdk/tools/Makefile.export b/sdk/tools/Makefile.export index 90397e899..d13b27558 100644 --- a/sdk/tools/Makefile.export +++ b/sdk/tools/Makefile.export @@ -59,7 +59,7 @@ default: all .PHONY: clean $(EXPORTDIR)/makeinfo.sh: $(TOPDIR)/.config $(EXPORTDIR)/Make.defs - @echo "#!/bin/bash" > $(EXPORTDIR)/makeinfo.sh + @echo "#!/usr/bin/env bash" > $(EXPORTDIR)/makeinfo.sh @echo "" >> $(EXPORTDIR)/makeinfo.sh @echo "ARCHSUBDIR=\"$(ARCHSUBDIR)\"" >> $(EXPORTDIR)/makeinfo.sh @echo "ARCHDIR=\"$(ARCHDIR)\"" >> $(EXPORTDIR)/makeinfo.sh diff --git a/sdk/tools/build-env.sh b/sdk/tools/build-env.sh index 06fd893cf..8b5564a85 100755 --- a/sdk/tools/build-env.sh +++ b/sdk/tools/build-env.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ############################################################################ # tools/build-env.sh # diff --git a/sdk/tools/completion.sh b/sdk/tools/completion.sh index 50bc34ba9..c3dc3f36a 100755 --- a/sdk/tools/completion.sh +++ b/sdk/tools/completion.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ############################################################################ # tools/completion.sh # diff --git a/sdk/tools/flash.sh b/sdk/tools/flash.sh index 4a5e0d964..724e0833e 100755 --- a/sdk/tools/flash.sh +++ b/sdk/tools/flash.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ############################################################################ # tools/flash.sh # diff --git a/sdk/tools/mkexport.sh b/sdk/tools/mkexport.sh index bb055b5de..fb7b170d1 100755 --- a/sdk/tools/mkexport.sh +++ b/sdk/tools/mkexport.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # tools/mkexport.sh # # Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved. diff --git a/sdk/tools/mkkconfig.sh b/sdk/tools/mkkconfig.sh index 2b23dd537..aeb5cf3df 100755 --- a/sdk/tools/mkkconfig.sh +++ b/sdk/tools/mkkconfig.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # apps/tools/mkkconfig.sh # # Copyright (C) 2015 Gregory Nutt. All rights reserved. diff --git a/sdk/tools/mkmsys2deps.sh b/sdk/tools/mkmsys2deps.sh index def1f37a6..34172782e 100755 --- a/sdk/tools/mkmsys2deps.sh +++ b/sdk/tools/mkmsys2deps.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # tools/mkmsys2deps.sh # # Copyright (C) 2016 Gregory Nutt. All rights reserved. diff --git a/sdk/tools/mkromfsimg.sh b/sdk/tools/mkromfsimg.sh index 43bc279d3..1a7a85e9a 100755 --- a/sdk/tools/mkromfsimg.sh +++ b/sdk/tools/mkromfsimg.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ############################################################################ # tools/mkromfsimg.sh # diff --git a/sdk/tools/mksdkexport.sh b/sdk/tools/mksdkexport.sh index c37701a99..5706850c2 100755 --- a/sdk/tools/mksdkexport.sh +++ b/sdk/tools/mksdkexport.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # tools/mksdkexport.sh # # Copyright 2020 Sony Semiconductor Solutions Corporation diff --git a/sdk/tools/mkversion.sh b/sdk/tools/mkversion.sh index 854f1c689..ea921b9ea 100755 --- a/sdk/tools/mkversion.sh +++ b/sdk/tools/mkversion.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ############################################################################ # tools/mkversion.sh # From 5d86680b4a2dfe8db4edfd54107a252a68109c25 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 29 Jun 2022 13:36:51 +0900 Subject: [PATCH 04/52] examples/lte_azureiot: Minor update the usage of stat() Minor update the usage of stat() function. --- examples/lte_azureiot/lte_azureiot_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/lte_azureiot/lte_azureiot_main.c b/examples/lte_azureiot/lte_azureiot_main.c index b0cf0f616..3ba6ae2d3 100644 --- a/examples/lte_azureiot/lte_azureiot_main.c +++ b/examples/lte_azureiot/lte_azureiot_main.c @@ -503,12 +503,12 @@ static int filelength(const char *file_name) return ERROR; } - if ((st.st_mode & S_IFMT) != S_IFREG) + if (!S_ISREG(st.st_mode)) { return ERROR; } - return st.st_size; + return (int)st.st_size; } /* ------------------------------------------------------------------------ */ From 4ecbc29bd0cf02ccb8e93a26980e3b776c57f920 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 6 Jul 2022 07:27:20 +0900 Subject: [PATCH 05/52] Update Submodules for develop at 2022/07/06 07:27:20 --- nuttx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuttx b/nuttx index 09af2155c..4682f2e9d 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit 09af2155c964159cce51cfea9a211a255613845d +Subproject commit 4682f2e9d37a45ddca44018b67557395942c92e5 From 9710db4365e39afa7679c1db8752b85d015e2163 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 13 Jul 2022 20:49:38 +0900 Subject: [PATCH 06/52] tools/scripts/Make.defs: Add -fno-common for loadable ELF Add -fno-common compile option for building loadable ELF to prevent SHN_COMMON relocations. Fix an issue that may cause loadable ELF to fail to load. --- sdk/tools/scripts/Make.defs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/tools/scripts/Make.defs b/sdk/tools/scripts/Make.defs index 5b1bb56cb..5aff06b1f 100644 --- a/sdk/tools/scripts/Make.defs +++ b/sdk/tools/scripts/Make.defs @@ -90,8 +90,8 @@ endif # ELF module definitions -CELFFLAGS = $(CFLAGS) -CXXELFFLAGS = $(CXXFLAGS) +CELFFLAGS = $(CFLAGS) -fno-common +CXXELFFLAGS = $(CXXFLAGS) -fno-common LDELFFLAGS = -r -e main ifeq ($(CONFIG_CYGWIN_WINTOOL),y) From d8d910689c49c2711401533ef0ec952216f7c858 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 23 Jun 2022 15:55:18 +0900 Subject: [PATCH 07/52] Add nrf52832 library nRF5_SDK_17.1.0_ddde560 from https://www.nordicsemi.com/Products/Development-software/nrf5-sdk/download . --- .../experimental_section_vars/nrf_section.h | 191 + .../nrf_section_iter.c | 125 + .../nrf_section_iter.h | 206 + .../libraries/log/nrf_log_instance.h | 163 + .../components/libraries/log/nrf_log_types.h | 93 + .../components/libraries/queue/nrf_queue.c | 580 + .../components/libraries/queue/nrf_queue.h | 471 + .../libraries/strerror/nrf_strerror.c | 161 + .../libraries/strerror/nrf_strerror.h | 89 + .../components/libraries/util/app_error.h | 192 + .../components/libraries/util/app_util.h | 1326 ++ .../libraries/util/app_util_platform.h | 278 + .../components/libraries/util/nordic_common.h | 215 + .../components/libraries/util/nrf_assert.h | 122 + .../components/libraries/util/sdk_common.h | 77 + .../components/libraries/util/sdk_errors.h | 168 + .../codecs/ble/middleware/app_mw_ble.c | 626 + .../codecs/ble/middleware/app_mw_ble_gap.c | 2043 +++ .../codecs/ble/middleware/app_mw_ble_gattc.c | 566 + .../codecs/ble/middleware/app_mw_ble_gatts.c | 773 + .../codecs/ble/middleware/app_mw_ble_l2cap.c | 453 + .../codecs/ble/middleware/app_mw_nrf_soc.c | 171 + .../ble/serializers/app_ble_gap_sec_keys.c | 216 + .../ble/serializers/app_ble_gap_sec_keys.h | 120 + .../codecs/ble/serializers/app_ble_user_mem.c | 101 + .../codecs/ble/serializers/app_ble_user_mem.h | 109 + .../codecs/ble/serializers/ble_app.c | 513 + .../codecs/ble/serializers/ble_app.h | 523 + .../codecs/ble/serializers/ble_event.c | 326 + .../codecs/ble/serializers/ble_evt_app.c | 129 + .../codecs/ble/serializers/ble_evt_app.h | 157 + .../codecs/ble/serializers/ble_gap_app.c | 1018 ++ .../codecs/ble/serializers/ble_gap_app.h | 1667 ++ .../codecs/ble/serializers/ble_gap_evt_app.c | 415 + .../codecs/ble/serializers/ble_gap_evt_app.h | 597 + .../codecs/ble/serializers/ble_gattc_app.c | 286 + .../codecs/ble/serializers/ble_gattc_app.h | 491 + .../ble/serializers/ble_gattc_evt_app.c | 262 + .../ble/serializers/ble_gattc_evt_app.h | 364 + .../codecs/ble/serializers/ble_gatts_app.c | 439 + .../codecs/ble/serializers/ble_gatts_app.h | 677 + .../ble/serializers/ble_gatts_evt_app.c | 190 + .../ble/serializers/ble_gatts_evt_app.h | 249 + .../codecs/ble/serializers/ble_l2cap_app.c | 279 + .../codecs/ble/serializers/ble_l2cap_app.h | 242 + .../ble/serializers/ble_l2cap_evt_app.c | 183 + .../ble/serializers/ble_l2cap_evt_app.h | 126 + .../codecs/ble/serializers/nrf_soc_app.c | 95 + .../codecs/ble/serializers/nrf_soc_app.h | 147 + .../application/hal/ser_app_hal.h | 116 + .../application/hal/ser_app_hal_nrf5x.c | 163 + .../hal/ser_app_power_system_off.c | 62 + .../hal/ser_app_power_system_off.h | 60 + .../application/transport/ser_sd_transport.c | 325 + .../application/transport/ser_sd_transport.h | 193 + .../transport/ser_softdevice_handler.c | 311 + .../transport/ser_softdevice_handler.h | 80 + .../serialization/common/ble_serialization.c | 549 + .../serialization/common/ble_serialization.h | 1103 ++ .../common/cond_field_serialization.c | 101 + .../common/cond_field_serialization.h | 105 + .../serialization/common/ser_config.h | 130 + .../ble/ble_gap_struct_serialization.c | 1743 +++ .../ble/ble_gap_struct_serialization.h | 612 + .../ble/ble_gatt_struct_serialization.c | 158 + .../ble/ble_gatt_struct_serialization.h | 94 + .../ble/ble_gattc_struct_serialization.c | 715 + .../ble/ble_gattc_struct_serialization.h | 293 + .../ble/ble_gatts_struct_serialization.c | 689 + .../ble/ble_gatts_struct_serialization.h | 259 + .../ble/ble_l2cap_struct_serialization.c | 227 + .../ble/ble_l2cap_struct_serialization.h | 119 + .../struct_ser/ble/ble_struct_serialization.c | 545 + .../struct_ser/ble/ble_struct_serialization.h | 217 + .../ble/nrf_soc_struct_serialization.c | 90 + .../ble/nrf_soc_struct_serialization.h | 73 + .../common/transport/ser_hal_transport.c | 514 + .../common/transport/ser_hal_transport.h | 268 + .../common/transport/ser_phy/ser_phy.h | 308 + .../common/transport/ser_phy/ser_phy_uart.c | 363 + .../common/transport/ser_phy_debug_comm.h | 203 + .../components/softdevice/common/nrf_sdh.c | 402 + .../components/softdevice/common/nrf_sdh.h | 305 + .../softdevice/common/nrf_sdh_ble.c | 326 + .../softdevice/common/nrf_sdh_ble.h | 184 + .../components/softdevice/s132/headers/ble.h | 679 + .../softdevice/s132/headers/ble_err.h | 93 + .../softdevice/s132/headers/ble_gap.h | 2838 ++++ .../softdevice/s132/headers/ble_gatt.h | 229 + .../softdevice/s132/headers/ble_gattc.h | 755 + .../softdevice/s132/headers/ble_gatts.h | 845 + .../softdevice/s132/headers/ble_hci.h | 135 + .../softdevice/s132/headers/ble_l2cap.h | 507 + .../softdevice/s132/headers/ble_ranges.h | 156 + .../softdevice/s132/headers/ble_types.h | 215 + .../softdevice/s132/headers/nrf52/nrf_mbr.h | 268 + .../softdevice/s132/headers/nrf_error.h | 90 + .../softdevice/s132/headers/nrf_error_sdm.h | 70 + .../softdevice/s132/headers/nrf_error_soc.h | 85 + .../softdevice/s132/headers/nrf_nvic.h | 491 + .../softdevice/s132/headers/nrf_sd_def.h | 71 + .../softdevice/s132/headers/nrf_sdm.h | 371 + .../softdevice/s132/headers/nrf_soc.h | 1000 ++ .../softdevice/s132/headers/nrf_svc.h | 100 + .../config/nrf52832/config/sdk_config.h | 12897 ++++++++++++++++ .../documentation/NordicS.jpg | Bin 0 -> 20023 bytes .../documentation/index.html | 198 + .../documentation/licenses.html | 87 + .../documentation/licenses.txt | 23 + .../nRF5_Garmin_Canada_license.txt | 50 + .../documentation/nRF5_Nordic_license.txt | 37 + .../documentation/nRF5x_series_logo.png | Bin 0 -> 9960 bytes .../documentation/release_notes.txt | 7564 +++++++++ .../nrf52/nRF5_SDK_17.1.0_ddde560/license.txt | 1 + .../modules/nrfx/CHANGELOG.md | 300 + .../modules/nrfx/LICENSE | 39 + .../modules/nrfx/README.md | 45 + .../modules/nrfx/mdk/compiler_abstraction.h | 264 + .../modules/nrfx/mdk/nrf.h | 198 + 119 files changed, 61716 insertions(+) create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section_iter.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section_iter.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log_instance.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log_types.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror/nrf_strerror.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror/nrf_strerror.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/nordic_common.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/nrf_assert.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_errors.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gap.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gatts.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_l2cap.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_nrf_soc.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_gap_sec_keys.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_gap_sec_keys.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_user_mem.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_user_mem.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_event.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_evt_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_evt_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_evt_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_evt_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_evt_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_evt_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_evt_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_evt_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/nrf_soc_app.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/nrf_soc_app.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ble_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ble_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/cond_field_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/cond_field_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ser_config.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gap_struct_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gap_struct_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatt_struct_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatt_struct_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gattc_struct_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gattc_struct_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatts_struct_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatts_struct_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_l2cap_struct_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_l2cap_struct_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_struct_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_struct_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/nrf_soc_struct_serialization.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/nrf_soc_struct_serialization.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy_debug_comm.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_err.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gap.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gatt.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gatts.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_hci.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_l2cap.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_ranges.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_types.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf52/nrf_mbr.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error_sdm.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error_soc.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_nvic.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_sd_def.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_sdm.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_soc.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_svc.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/NordicS.jpg create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/index.html create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/licenses.html create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/licenses.txt create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5_Garmin_Canada_license.txt create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5_Nordic_license.txt create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5x_series_logo.png create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/release_notes.txt create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/license.txt create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/CHANGELOG.md create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/LICENSE create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/README.md create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/compiler_abstraction.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section.h new file mode 100644 index 000000000..fad7e39a0 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section.h @@ -0,0 +1,191 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef NRF_SECTION_H__ +#define NRF_SECTION_H__ + +#include "nordic_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup section_vars Section variables + * @ingroup app_common + * @{ + * + * @brief Section variables. + */ + +//lint -save -e27 -esym(526,*) + +#if defined(__ICCARM__) +// Enable IAR language extensions +#pragma language=extended +#endif + +/**@brief Macro for obtaining the address of the beginning of a section. + * + * param[in] section_name Name of the section. + * @hideinitializer + */ +#if defined(__CC_ARM) +#define NRF_SECTION_START_ADDR(section_name) &CONCAT_2(section_name, $$Base) + +#elif defined(__GNUC__) +#define NRF_SECTION_START_ADDR(section_name) &CONCAT_2(__start_, section_name) + +#elif defined(__ICCARM__) +#define NRF_SECTION_START_ADDR(section_name) __section_begin(STRINGIFY(section_name)) +#endif + + +/**@brief Macro for obtaining the address of the end of a section. + * + * @param[in] section_name Name of the section. + * @hideinitializer + */ +#if defined(__CC_ARM) +#define NRF_SECTION_END_ADDR(section_name) &CONCAT_2(section_name, $$Limit) + +#elif defined(__GNUC__) +#define NRF_SECTION_END_ADDR(section_name) &CONCAT_2(__stop_, section_name) + +#elif defined(__ICCARM__) +#define NRF_SECTION_END_ADDR(section_name) __section_end(STRINGIFY(section_name)) +#endif + + +/**@brief Macro for retrieving the length of a given section, in bytes. + * + * @param[in] section_name Name of the section. + * @hideinitializer + */ +#define NRF_SECTION_LENGTH(section_name) \ + ((size_t)NRF_SECTION_END_ADDR(section_name) - \ + (size_t)NRF_SECTION_START_ADDR(section_name)) + + +/**@brief Macro for creating a section. + * + * @param[in] section_name Name of the section. + * @param[in] data_type Data type of the variables to be registered in the section. + * + * @warning Data type must be word aligned to prevent padding. + * @hideinitializer + */ +#if defined(__CC_ARM) +#define NRF_SECTION_DEF(section_name, data_type) \ + extern data_type * CONCAT_2(section_name, $$Base); \ + extern void * CONCAT_2(section_name, $$Limit) + +#elif defined(__GNUC__) +#define NRF_SECTION_DEF(section_name, data_type) \ + extern data_type * CONCAT_2(__start_, section_name); \ + extern void * CONCAT_2(__stop_, section_name) + +#elif defined(__ICCARM__) +#define NRF_SECTION_DEF(section_name, data_type) \ + _Pragma(STRINGIFY(section = STRINGIFY(section_name))); + +#endif + + +/**@brief Macro for declaring a variable and registering it in a section. + * + * @details Declares a variable and registers it in a named section. This macro ensures that the + * variable is not stripped away when using optimizations. + * + * @note The order in which variables are placed in a section is dependent on the order in + * which the linker script encounters the variables during linking. + * + * @param[in] section_name Name of the section. + * @param[in] section_var Variable to register in the given section. + * @hideinitializer + */ +#if defined(__CC_ARM) +#define NRF_SECTION_ITEM_REGISTER(section_name, section_var) \ + section_var __attribute__ ((section(STRINGIFY(section_name)))) __attribute__((used)) + +#elif defined(__GNUC__) +#define NRF_SECTION_ITEM_REGISTER(section_name, section_var) \ + section_var __attribute__ ((section("." STRINGIFY(section_name)))) __attribute__((used)) + +#elif defined(__ICCARM__) +#define NRF_SECTION_ITEM_REGISTER(section_name, section_var) \ + __root section_var @ STRINGIFY(section_name) +#endif + + +/**@brief Macro for retrieving a variable from a section. + * + * @warning The stored symbol can only be resolved using this macro if the + * type of the data is word aligned. The operation of acquiring + * the stored symbol relies on the size of the stored type. No + * padding can exist in the named section in between individual + * stored items or this macro will fail. + * + * @param[in] section_name Name of the section. + * @param[in] data_type Data type of the variable. + * @param[in] i Index of the variable in section. + * @hideinitializer + */ +#define NRF_SECTION_ITEM_GET(section_name, data_type, i) \ + ((data_type*)NRF_SECTION_START_ADDR(section_name) + (i)) + + +/**@brief Macro for getting the number of variables in a section. + * + * @param[in] section_name Name of the section. + * @param[in] data_type Data type of the variables in the section. + * @hideinitializer + */ +#define NRF_SECTION_ITEM_COUNT(section_name, data_type) \ + NRF_SECTION_LENGTH(section_name) / sizeof(data_type) + +/** @} */ + +//lint -restore + +#ifdef __cplusplus +} +#endif + +#endif // NRF_SECTION_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section_iter.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section_iter.c new file mode 100644 index 000000000..51ccfbb40 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section_iter.c @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sdk_common.h" + +#if NRF_MODULE_ENABLED(NRF_SECTION_ITER) + +#include "nrf_section_iter.h" + + +#if !defined(__GNUC__) +static void nrf_section_iter_item_set(nrf_section_iter_t * p_iter) +{ + ASSERT(p_iter != NULL); + ASSERT(p_iter->p_set != NULL); + ASSERT(p_iter->p_section != NULL); + + while (true) + { + if (p_iter->p_section == p_iter->p_set->p_last) + { + // End of the section set. + p_iter->p_item = NULL; + return; + } + + if (p_iter->p_section->p_start != p_iter->p_section->p_end) + { + // Not empty section. + p_iter->p_item = p_iter->p_section->p_start; + return; + } + + // Next section. + p_iter->p_section++; + } +} +#endif + + +void nrf_section_iter_init(nrf_section_iter_t * p_iter, nrf_section_set_t const * p_set) +{ + ASSERT(p_iter != NULL); + ASSERT(p_set != NULL); + + p_iter->p_set = p_set; + +#if defined(__GNUC__) + p_iter->p_item = p_iter->p_set->section.p_start; + if (p_iter->p_item == p_iter->p_set->section.p_end) + { + p_iter->p_item = NULL; + } +#else + p_iter->p_section = p_set->p_first; + nrf_section_iter_item_set(p_iter); +#endif +} + +void nrf_section_iter_next(nrf_section_iter_t * p_iter) +{ + ASSERT(p_iter != NULL); + ASSERT(p_iter->p_set != NULL); + + if (p_iter->p_item == NULL) + { + return; + } + + p_iter->p_item = (void *)((size_t)(p_iter->p_item) + p_iter->p_set->item_size); + +#if defined(__GNUC__) + if (p_iter->p_item == p_iter->p_set->section.p_end) + { + p_iter->p_item = NULL; + } +#else + ASSERT(p_iter->p_section != NULL); + // End of current section reached? + if (p_iter->p_item == p_iter->p_section->p_end) + { + p_iter->p_section++; + nrf_section_iter_item_set(p_iter); + } +#endif +} + +#endif // NRF_MODULE_ENABLED(NRF_SECTION_ITER) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section_iter.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section_iter.h new file mode 100644 index 000000000..7bcbc3932 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars/nrf_section_iter.h @@ -0,0 +1,206 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef NRF_SECTION_ITER_H__ +#define NRF_SECTION_ITER_H__ + +#include +#include "nrf_section.h" +#include "nrf_assert.h" +#include "app_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @defgroup nrf_section_iter Section variables iterator + * @ingroup app_common + * @{ + */ + +/**@brief Single section description structure. */ +typedef struct +{ + void * p_start; //!< Pointer to the start of section. + void * p_end; //!< Pointer to the end of section. +} nrf_section_t; + + +/**@brief Set of the sections description structure. */ +typedef struct +{ +#if defined(__GNUC__) + nrf_section_t section; //!< Description of the set of sections. + /**< + * In case of GCC all sections in the set are sorted and + * placed in contiguous area, because they are treated as + * one section. + */ +#else + nrf_section_t const * p_first; //!< Pointer to the first section in the set. + nrf_section_t const * p_last; //!< Pointer to the last section in the set. +#endif + size_t item_size; //!< Size of the single item in the section. +} nrf_section_set_t; + + +/**@brief Section iterator structure. */ +typedef struct +{ + nrf_section_set_t const * p_set; //!< Pointer to the appropriate section set. +#if !defined(__GNUC__) + nrf_section_t const * p_section; //!< Pointer to the selected section. + /**< + * In case of GCC all sections in the set are sorted and + * placed in contiguous area, because they are treated + * as one section. + */ +#endif + void * p_item; //!< Pointer to the selected item in the section. +} nrf_section_iter_t; + + +/**@brief Create a set of sections. + * + * @note This macro reserves memory for the given set of sections. + * + * @details A set of sections, is an ordered collections of sections. + * + * @param[in] _name Name of the set. + * @param[in] _type Type of the elements stored in the sections. + * @param[in] _count Number of the sections in the set. This parameter is ignored in case of GCC. + * @hideinitializer + */ +#if defined(__GNUC__) + +#define NRF_SECTION_SET_DEF(_name, _type, _count) \ + \ + NRF_SECTION_DEF(_name, _type); \ + static nrf_section_set_t const _name = \ + { \ + .section = \ + { \ + .p_start = NRF_SECTION_START_ADDR(_name), \ + .p_end = NRF_SECTION_END_ADDR(_name), \ + }, \ + .item_size = sizeof(_type), \ + } + +#else + +#define NRF_SECTION_SET_DEF(_name, _type, _count) \ +/*lint -save -emacro(14, MACRO_REPEAT_FOR*) */ \ +MACRO_REPEAT_FOR(_count, NRF_SECTION_DEF_, _name, _type) \ +static nrf_section_t const CONCAT_2(_name, _array)[] = \ +{ \ + MACRO_REPEAT_FOR(_count, NRF_SECTION_SET_DEF_, _name) \ +}; \ +/*lint -restore */ \ +static nrf_section_set_t const _name = \ +{ \ + .p_first = CONCAT_2(_name, _array), \ + .p_last = CONCAT_2(_name, _array) + ARRAY_SIZE(CONCAT_2(_name, _array)), \ + .item_size = sizeof(_type), \ +} + +#ifndef DOXYGEN +#define NRF_SECTION_DEF_(_priority, _name, _type) \ +NRF_SECTION_DEF(CONCAT_2(_name, _priority), _type); + +#define NRF_SECTION_SET_DEF_(_priority, _name) \ +{ \ + .p_start = NRF_SECTION_START_ADDR(CONCAT_2(_name, _priority)), \ + .p_end = NRF_SECTION_END_ADDR(CONCAT_2(_name, _priority)), \ +}, +#endif // DOXYGEN +#endif // __GNUC__ + + +/**@brief Macro to declare a variable and register it in the section set. + * + * @note The order of the section in the set is based on the priority. The order with which + * variables are placed in a section is dependant on the order with which the linker + * encouters the variables during linking. + * + * @param[in] _name Name of the section set. + * @param[in] _priority Priority of the desired section. + * @param[in] _var The variable to register in the given section. + * @hideinitializer + */ +#define NRF_SECTION_SET_ITEM_REGISTER(_name, _priority, _var) \ + NRF_SECTION_ITEM_REGISTER(CONCAT_2(_name, _priority), _var) + + +/**@brief Function for initializing the section set iterator. + * + * @param[in] p_iter Pointer to the iterator. + * @param[in] p_set Pointer to the sections set. + */ +void nrf_section_iter_init(nrf_section_iter_t * p_iter, nrf_section_set_t const * p_set); + + +/**@brief Function for incrementing iterator. + * + * @param[in] p_iter Pointer to the iterator. + */ +void nrf_section_iter_next(nrf_section_iter_t * p_iter); + + +/**@brief Function for getting the element pointed to by the iterator. + * + * @param[in] p_iter Pointer to the iterator. + * + * @retval Pointer to the element or NULL if iterator points end of the set. + */ +static inline void * nrf_section_iter_get(nrf_section_iter_t const * p_iter) +{ + ASSERT(p_iter); + return p_iter->p_item; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_SECTION_ITER_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log_instance.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log_instance.h new file mode 100644 index 000000000..c7e24fdeb --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log_instance.h @@ -0,0 +1,163 @@ +/** + * Copyright (c) 2018 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef NRF_LOG_INSTANCE_H +#define NRF_LOG_INSTANCE_H + +#include "sdk_config.h" +#include "nrf_section.h" +#include "nrf_log_types.h" +#include + + +/* + * For GCC, sections are sorted in the group by the linker. For IAR and KEIL, it is assumed that linker will sort + * dynamic and const section in the same order (but in different locations). Proper message formatting + * is based on that assumption. + */ +#if defined(__GNUC__) +#define NRF_LOG_DYNAMIC_SECTION_NAME(_module_name) CONCAT_2(log_dynamic_data_,_module_name) +#define NRF_LOG_FILTER_SECTION_NAME(_module_name) CONCAT_2(log_filter_data_,_module_name) +#define NRF_LOG_CONST_SECTION_NAME(_module_name) CONCAT_2(log_const_data_,_module_name) +#else +#define NRF_LOG_DYNAMIC_SECTION_NAME(_module_name) log_dynamic_data +#define NRF_LOG_FILTER_SECTION_NAME(_module_name) log_filter_data +#define NRF_LOG_CONST_SECTION_NAME(_module_name) log_const_data +#endif + +#define NRF_LOG_ITEM_DATA(_name) CONCAT_3(m_nrf_log_,_name,_logs_data) +#define NRF_LOG_ITEM_DATA_DYNAMIC(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_dynamic) +#define NRF_LOG_ITEM_DATA_FILTER(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_filter) +#define NRF_LOG_ITEM_DATA_CONST(_name) CONCAT_2(NRF_LOG_ITEM_DATA(_name),_const) + +#ifdef UNIT_TEST +#define _CONST +#else +#define _CONST const +#endif + +/*lint -save -esym(526,log_const_data*) -esym(526,log_dynamic_data*)*/ +NRF_SECTION_DEF(log_dynamic_data, nrf_log_module_dynamic_data_t); +NRF_SECTION_DEF(log_filter_data, nrf_log_module_filter_data_t); +NRF_SECTION_DEF(log_const_data, nrf_log_module_const_data_t); +/*lint -restore*/ + +#define NRF_LOG_INTERNAL_CONST_ITEM_REGISTER( \ + _name, _str_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \ + NRF_SECTION_ITEM_REGISTER(NRF_LOG_CONST_SECTION_NAME(_name), \ + _CONST nrf_log_module_const_data_t NRF_LOG_ITEM_DATA_CONST(_name)) = { \ + .p_module_name = _str_name, \ + .info_color_id = (_info_color), \ + .debug_color_id = (_debug_color), \ + .compiled_lvl = (nrf_log_severity_t)(_compiled_lvl), \ + .initial_lvl = (nrf_log_severity_t)(_initial_lvl), \ + } + +#if NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_INTERNAL_ITEM_REGISTER( \ + _name, _str_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \ + NRF_LOG_INTERNAL_CONST_ITEM_REGISTER(_name, \ + _str_name, \ + _info_color, \ + _debug_color, \ + _initial_lvl, \ + _compiled_lvl); \ + NRF_SECTION_ITEM_REGISTER(NRF_LOG_DYNAMIC_SECTION_NAME(_name), \ + nrf_log_module_dynamic_data_t NRF_LOG_ITEM_DATA_DYNAMIC(_name)); \ + NRF_SECTION_ITEM_REGISTER(NRF_LOG_FILTER_SECTION_NAME(_name), \ + nrf_log_module_filter_data_t NRF_LOG_ITEM_DATA_FILTER(_name)) + +#else +#define NRF_LOG_INTERNAL_ITEM_REGISTER( \ + _name, _str_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \ + NRF_LOG_INTERNAL_CONST_ITEM_REGISTER(_name, \ + _str_name, \ + _info_color, \ + _debug_color, \ + _initial_lvl, \ + _compiled_lvl) + +#endif +/**@file + * + * @defgroup nrf_log_instance Macros for logging on instance level + * @{ + * @ingroup nrf_log + * + * @brief Macros for logging on instance level + */ + +/** @def NRF_LOG_INSTANCE_PTR_DECLARE + * @brief Macro for declaring a logger instance pointer in the module stucture. + */ + +/** @def NRF_LOG_INSTANCE_REGISTER + * @brief Macro for creating an independent module instance. + * + * Module instance provides filtering of logs on instance level instead of module level. + */ + +/** @def NRF_LOG_INSTANCE_PTR_INIT + * @brief Macro for initializing a pointer to the logger instance. + */ + + + /** @} */ +#if NRF_LOG_ENABLED && NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_INSTANCE_PTR_DECLARE(_p_name) nrf_log_module_dynamic_data_t * _p_name; + +#define NRF_LOG_INSTANCE_REGISTER( \ + _module_name, _inst_name, _info_color, _debug_color, _initial_lvl, _compiled_lvl) \ + NRF_LOG_INTERNAL_ITEM_REGISTER(CONCAT_3(_module_name,_,_inst_name), \ + STRINGIFY(_module_name._inst_name), \ + _info_color, \ + _debug_color, \ + _initial_lvl, \ + _compiled_lvl) + +#define NRF_LOG_INSTANCE_PTR_INIT(_p_name, _module_name, _inst_name) \ + ._p_name = &NRF_LOG_ITEM_DATA_DYNAMIC(CONCAT_3(_module_name,_,_inst_name)), + +#else +#define NRF_LOG_INSTANCE_PTR_DECLARE(_p_name) +#define NRF_LOG_INSTANCE_REGISTER(_module_name, _inst_name, info_color, debug_color, _initial_lvl, compiled_lvl) +#define NRF_LOG_INSTANCE_PTR_INIT(_p_name, _module_name, _inst_name) +#endif + +#endif //NRF_LOG_INSTANCE_H diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log_types.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log_types.h new file mode 100644 index 000000000..188054c11 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log_types.h @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2018 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef NRF_LOG_TYPES_H +#define NRF_LOG_TYPES_H + +#include + +/** + * @brief Logger severity levels. + */ +typedef enum +{ + NRF_LOG_SEVERITY_NONE, + NRF_LOG_SEVERITY_ERROR, + NRF_LOG_SEVERITY_WARNING, + NRF_LOG_SEVERITY_INFO, + NRF_LOG_SEVERITY_DEBUG, + NRF_LOG_SEVERITY_INFO_RAW, /* Artificial level to pass information about skipping string postprocessing.*/ +} nrf_log_severity_t; + +/** + * @brief Structure holding dynamic data associated with a module. + * + * See @ref NRF_LOG_MODULE_REGISTER and @ref NRF_LOG_INSTANCE_REGISTER. + */ +typedef struct +{ + uint16_t order_idx; ///< Ordered index of the module (used for auto-completion). + uint16_t filter; ///< Current highest severity level accepted (redundant to @ref nrf_log_module_filter_data_t::filter_lvls, used for optimization) +} nrf_log_module_dynamic_data_t; + +/** + * @brief Structure holding dynamic filters associated with a module or instance if filtering is enabled (@ref NRF_LOG_FILTERS_ENABLED). + * + * @note Backend filters logically are part of @ref nrf_log_module_dynamic_data_t but they are kept separated to enable storing them in non-volatile memory. + */ +typedef struct +{ + uint32_t filter_lvls; ///< Current severity levels for each backend (3 bits per backend). +} nrf_log_module_filter_data_t; + +/** + * @brief Structure holding constant data associated with a module or instance. + * + * See @ref NRF_LOG_MODULE_REGISTER and @ref NRF_LOG_INSTANCE_REGISTER. + */ +typedef struct +{ + const char * p_module_name; ///< Module or instance name. + uint8_t info_color_id; ///< Color code of info messages. + uint8_t debug_color_id; ///< Color code of debug messages. + nrf_log_severity_t compiled_lvl; ///< Compiled highest severity level. + nrf_log_severity_t initial_lvl; ///< Severity level for given module or instance set on backend initialization. +} nrf_log_module_const_data_t; + +#endif //NRF_LOG_TYPES_H diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c new file mode 100644 index 000000000..03ae7aad3 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c @@ -0,0 +1,580 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_QUEUE) +#include "nrf_queue.h" +#include "app_util_platform.h" + +#if NRF_QUEUE_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL NRF_QUEUE_CONFIG_LOG_LEVEL + #define NRF_LOG_INIT_FILTER_LEVEL NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL + #define NRF_LOG_INFO_COLOR NRF_QUEUE_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_QUEUE_CONFIG_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // NRF_QUEUE_CONFIG_LOG_ENABLED +#include "nrf_log.h" + +NRF_SECTION_DEF(nrf_queue, nrf_queue_t); + +#if NRF_QUEUE_CLI_CMDS && NRF_CLI_ENABLED +#include "nrf_cli.h" + +static void nrf_queue_status(nrf_cli_t const * p_cli, size_t argc, char **argv) +{ + UNUSED_PARAMETER(argv); + + if (nrf_cli_help_requested(p_cli)) + { + nrf_cli_help_print(p_cli, NULL, 0); + return; + } + + if (argc > 1) + { + nrf_cli_fprintf(p_cli, NRF_CLI_ERROR, "Bad argument count"); + return; + } + + uint32_t num_of_instances = NRF_SECTION_ITEM_COUNT(nrf_queue, nrf_queue_t); + uint32_t i; + + for (i = 0; i < num_of_instances; i++) + { + const nrf_queue_t * p_instance = NRF_SECTION_ITEM_GET(nrf_queue, nrf_queue_t, i); + + uint32_t element_size = p_instance->element_size; + uint32_t size = p_instance->size; + uint32_t max_util = nrf_queue_max_utilization_get(p_instance); + uint32_t util = nrf_queue_utilization_get(p_instance); + const char * p_name = p_instance->p_name; + nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, + "%s\r\n\t- Element size:\t%d\r\n" + "\t- Usage:\t%u%% (%u out of %u elements)\r\n" + "\t- Maximum:\t%u%% (%u out of %u elements)\r\n" + "\t- Mode:\t\t%s\r\n\r\n", + p_name, element_size, + 100ul * util/size, util,size, + 100ul * max_util/size, max_util,size, + (p_instance->mode == NRF_QUEUE_MODE_OVERFLOW) ? "Overflow" : "No overflow"); + + } +} +// Register "queue" command and its subcommands in CLI. +NRF_CLI_CREATE_STATIC_SUBCMD_SET(nrf_queue_commands) +{ + NRF_CLI_CMD(status, NULL, "Print status of queue instances.", nrf_queue_status), + NRF_CLI_SUBCMD_SET_END +}; + +NRF_CLI_CMD_REGISTER(queue, &nrf_queue_commands, "Commands for BALLOC management", nrf_queue_status); +#endif //NRF_QUEUE_CLI_CMDS + +__STATIC_INLINE size_t circullar_buffer_size_get(nrf_queue_t const * p_queue) +{ + static const uint8_t full_queue_indicator = 1; + + /* When a queue is implemented as a cyclic buffer, it is not possible to + * distinguish a full queue from an empty queue. In order to solve this + * problem, the cyclic buffer has been implemented one element larger than + * the queue size. + */ + return p_queue->size + full_queue_indicator; +} + +/**@brief Get next element index. + * + * @param[in] p_queue Pointer to the queue instance. + * @param[in] idx Current index. + * + * @return Next element index. + */ +__STATIC_INLINE size_t nrf_queue_next_idx(nrf_queue_t const * p_queue, size_t idx) +{ + ASSERT(p_queue != NULL); + return (idx < p_queue->size) ? (idx + 1) : 0; +} + +/**@brief Get current queue utilization. This function assumes that this process will not be interrupted. + * + * @param[in] p_queue Pointer to the queue instance. + * + * @return Current queue utilization. + */ +__STATIC_INLINE size_t queue_utilization_get(nrf_queue_t const * p_queue) +{ + size_t front = p_queue->p_cb->front; + size_t back = p_queue->p_cb->back; + + return (back >= front) ? (back - front) : + (circullar_buffer_size_get(p_queue) - front + back); +} + +bool nrf_queue_is_full(nrf_queue_t const * p_queue) +{ + ASSERT(p_queue != NULL); + size_t front = p_queue->p_cb->front; + size_t back = p_queue->p_cb->back; + + return (nrf_queue_next_idx(p_queue, back) == front); +} + +ret_code_t nrf_queue_push(nrf_queue_t const * p_queue, void const * p_element) +{ + ret_code_t status = NRF_SUCCESS; + + ASSERT(p_queue != NULL); + ASSERT(p_element != NULL); + + CRITICAL_REGION_ENTER(); + bool is_full = nrf_queue_is_full(p_queue); + + if (!is_full || (p_queue->mode == NRF_QUEUE_MODE_OVERFLOW)) + { + // Get write position. + size_t write_pos = p_queue->p_cb->back; + p_queue->p_cb->back = nrf_queue_next_idx(p_queue, p_queue->p_cb->back); + if (is_full) + { + // Overwrite the oldest element. + NRF_LOG_INST_WARNING(p_queue->p_log, "Queue full. Overwriting oldest element."); + p_queue->p_cb->front = nrf_queue_next_idx(p_queue, p_queue->p_cb->front); + } + + // Write a new element. + switch (p_queue->element_size) + { + case sizeof(uint8_t): + ((uint8_t *)p_queue->p_buffer)[write_pos] = *((uint8_t *)p_element); + break; + + case sizeof(uint16_t): + ((uint16_t *)p_queue->p_buffer)[write_pos] = *((uint16_t *)p_element); + break; + + case sizeof(uint32_t): + ((uint32_t *)p_queue->p_buffer)[write_pos] = *((uint32_t *)p_element); + break; + + case sizeof(uint64_t): + ((uint64_t *)p_queue->p_buffer)[write_pos] = *((uint64_t *)p_element); + break; + + default: + memcpy((void *)((size_t)p_queue->p_buffer + write_pos * p_queue->element_size), + p_element, + p_queue->element_size); + break; + } + + // Update utilization. + size_t utilization = queue_utilization_get(p_queue); + if (p_queue->p_cb->max_utilization < utilization) + { + p_queue->p_cb->max_utilization = utilization; + } + } + else + { + status = NRF_ERROR_NO_MEM; + } + + CRITICAL_REGION_EXIT(); + + NRF_LOG_INST_DEBUG(p_queue->p_log, "pushed element 0x%08X, status:%d", p_element, status); + return status; +} + +ret_code_t nrf_queue_generic_pop(nrf_queue_t const * p_queue, + void * p_element, + bool just_peek) +{ + ret_code_t status = NRF_SUCCESS; + + ASSERT(p_queue != NULL); + ASSERT(p_element != NULL); + + CRITICAL_REGION_ENTER(); + + if (!nrf_queue_is_empty(p_queue)) + { + // Get read position. + size_t read_pos = p_queue->p_cb->front; + + // Update next read position. + if (!just_peek) + { + p_queue->p_cb->front = nrf_queue_next_idx(p_queue, p_queue->p_cb->front); + } + + // Read element. + switch (p_queue->element_size) + { + case sizeof(uint8_t): + *((uint8_t *)p_element) = ((uint8_t *)p_queue->p_buffer)[read_pos]; + break; + + case sizeof(uint16_t): + *((uint16_t *)p_element) = ((uint16_t *)p_queue->p_buffer)[read_pos]; + break; + + case sizeof(uint32_t): + *((uint32_t *)p_element) = ((uint32_t *)p_queue->p_buffer)[read_pos]; + break; + + case sizeof(uint64_t): + *((uint64_t *)p_element) = ((uint64_t *)p_queue->p_buffer)[read_pos]; + break; + + default: + memcpy(p_element, + (void const *)((size_t)p_queue->p_buffer + read_pos * p_queue->element_size), + p_queue->element_size); + break; + } + } + else + { + status = NRF_ERROR_NOT_FOUND; + } + + CRITICAL_REGION_EXIT(); + NRF_LOG_INST_DEBUG(p_queue->p_log, "%s element 0x%08X, status:%d", + just_peek ? "peeked" : "popped", p_element, status); + return status; +} + +/* Purpose of this function is to provide number of continous bytes in the queue's + * array before circullar buffer needs to wrapp. + */ +static size_t continous_items_get(nrf_queue_t const * p_queue, bool write) +{ + size_t front = p_queue->p_cb->front; + size_t back = p_queue->p_cb->back; + + /* Number of continous items for queue write operation */ + if (write) + { + return (back >= front) ? circullar_buffer_size_get(p_queue) - back : front - back; + } + else + { + return (back >= front) ? back - front : circullar_buffer_size_get(p_queue) - front; + } +} + +/**@brief Write elements to the queue. This function assumes that there is enough room in the queue + * to write the requested number of elements and that this process will not be interrupted. + * + * @param[in] p_queue Pointer to the nrf_queue_t instance. + * @param[in] p_data Pointer to the buffer with elements to write. + * @param[in] element_count Number of elements to write. + */ +static void queue_write(nrf_queue_t const * p_queue, void const * p_data, uint32_t element_count) +{ + size_t prev_available = nrf_queue_available_get(p_queue); + size_t continuous = continous_items_get(p_queue, true); + void * p_write_ptr = (void *)((size_t)p_queue->p_buffer + + p_queue->p_cb->back * p_queue->element_size); + + if (element_count <= continuous) + { + memcpy(p_write_ptr, + p_data, + element_count * p_queue->element_size); + + p_queue->p_cb->back = ((p_queue->p_cb->back + element_count) <= p_queue->size) + ? (p_queue->p_cb->back + element_count) + : 0; + } + else + { + size_t first_write_length = continuous * p_queue->element_size; + memcpy(p_write_ptr, + p_data, + first_write_length); + + size_t elements_left = element_count - continuous; + memcpy(p_queue->p_buffer, + (void const *)((size_t)p_data + first_write_length), + elements_left * p_queue->element_size); + + p_queue->p_cb->back = elements_left; + if (prev_available < element_count) + { + // Overwrite the oldest elements. + p_queue->p_cb->front = nrf_queue_next_idx(p_queue, p_queue->p_cb->back); + } + } + + // Update utilization. + size_t utilization = queue_utilization_get(p_queue); + if (p_queue->p_cb->max_utilization < utilization) + { + p_queue->p_cb->max_utilization = utilization; + } +} + +ret_code_t nrf_queue_write(nrf_queue_t const * p_queue, + void const * p_data, + size_t element_count) +{ + ret_code_t status = NRF_SUCCESS; + + ASSERT(p_queue != NULL); + ASSERT(p_data != NULL); + ASSERT(element_count <= p_queue->size); + + if (element_count == 0) + { + return NRF_SUCCESS; + } + + CRITICAL_REGION_ENTER(); + + if ((nrf_queue_available_get(p_queue) >= element_count) + || (p_queue->mode == NRF_QUEUE_MODE_OVERFLOW)) + { + queue_write(p_queue, p_data, element_count); + } + else + { + status = NRF_ERROR_NO_MEM; + } + + CRITICAL_REGION_EXIT(); + + NRF_LOG_INST_DEBUG(p_queue->p_log, "Write %d elements (start address: 0x%08X), status:%d", + element_count, p_data, status); + return status; +} + + +size_t nrf_queue_in(nrf_queue_t const * p_queue, + void const * p_data, + size_t element_count) +{ + ASSERT(p_queue != NULL); + ASSERT(p_data != NULL); + + size_t req_element_count = element_count; + + if (element_count == 0) + { + return 0; + } + + CRITICAL_REGION_ENTER(); + + if (p_queue->mode == NRF_QUEUE_MODE_OVERFLOW) + { + element_count = MIN(element_count, p_queue->size); + } + else + { + size_t available = nrf_queue_available_get(p_queue); + element_count = MIN(element_count, available); + } + + queue_write(p_queue, p_data, element_count); + + CRITICAL_REGION_EXIT(); + + NRF_LOG_INST_DEBUG(p_queue->p_log, "Put in %d elements (start address: 0x%08X), requested :%d", + element_count, p_data, req_element_count); + + return element_count; +} + +/**@brief Read elements from the queue. This function assumes that there are enough elements + * in the queue to read and that this process will not be interrupted. + * + * @param[in] p_queue Pointer to the nrf_queue_t instance. + * @param[out] p_data Pointer to the buffer where elements will be copied. + * @param[in] element_count Number of elements to read. + */ +static void queue_read(nrf_queue_t const * p_queue, void * p_data, uint32_t element_count) +{ + size_t front = p_queue->p_cb->front; + size_t continuous = continous_items_get(p_queue, false); + void const * p_read_ptr = (void const *)((size_t)p_queue->p_buffer + + front * p_queue->element_size); + + if (element_count <= continuous) + { + memcpy(p_data, + p_read_ptr, + element_count * p_queue->element_size); + + p_queue->p_cb->front = ((front + element_count) <= p_queue->size) + ? (front + element_count) + : 0; + } + else + { + size_t first_read_length = continuous * p_queue->element_size; + memcpy(p_data, + p_read_ptr, + first_read_length); + + size_t elements_left = element_count - continuous; + memcpy((void *)((size_t)p_data + first_read_length), + p_queue->p_buffer, + elements_left * p_queue->element_size); + + p_queue->p_cb->front = elements_left; + } +} + +ret_code_t nrf_queue_read(nrf_queue_t const * p_queue, + void * p_data, + size_t element_count) +{ + ret_code_t status = NRF_SUCCESS; + + ASSERT(p_queue != NULL); + ASSERT(p_data != NULL); + + if (element_count == 0) + { + return NRF_SUCCESS; + } + + CRITICAL_REGION_ENTER(); + + if (element_count <= queue_utilization_get(p_queue)) + { + queue_read(p_queue, p_data, element_count); + } + else + { + status = NRF_ERROR_NOT_FOUND; + } + + CRITICAL_REGION_EXIT(); + + NRF_LOG_INST_DEBUG(p_queue->p_log, "Read %d elements (start address: 0x%08X), status :%d", + element_count, p_data, status); + return status; +} + +size_t nrf_queue_out(nrf_queue_t const * p_queue, + void * p_data, + size_t element_count) +{ + ASSERT(p_queue != NULL); + ASSERT(p_data != NULL); + + size_t req_element_count = element_count; + + if (element_count == 0) + { + return 0; + } + + CRITICAL_REGION_ENTER(); + + size_t utilization = queue_utilization_get(p_queue); + element_count = MIN(element_count, utilization); + + queue_read(p_queue, p_data, element_count); + + CRITICAL_REGION_EXIT(); + + NRF_LOG_INST_DEBUG(p_queue->p_log, "Out %d elements (start address: 0x%08X), requested :%d", + element_count, p_data, req_element_count); + return element_count; +} + +void nrf_queue_reset(nrf_queue_t const * p_queue) +{ + ASSERT(p_queue != NULL); + + CRITICAL_REGION_ENTER(); + + memset(p_queue->p_cb, 0, sizeof(nrf_queue_cb_t)); + + CRITICAL_REGION_EXIT(); + + NRF_LOG_INST_DEBUG(p_queue->p_log, "Reset"); +} + +size_t nrf_queue_utilization_get(nrf_queue_t const * p_queue) +{ + size_t utilization; + ASSERT(p_queue != NULL); + + CRITICAL_REGION_ENTER(); + + utilization = queue_utilization_get(p_queue); + + CRITICAL_REGION_EXIT(); + + return utilization; +} + +bool nrf_queue_is_empty(nrf_queue_t const * p_queue) +{ + ASSERT(p_queue != NULL); + size_t front = p_queue->p_cb->front; + size_t back = p_queue->p_cb->back; + return (front == back); +} + +size_t nrf_queue_available_get(nrf_queue_t const * p_queue) +{ + ASSERT(p_queue != NULL); + return p_queue->size - nrf_queue_utilization_get(p_queue); +} + +size_t nrf_queue_max_utilization_get(nrf_queue_t const * p_queue) +{ + ASSERT(p_queue != NULL); + return p_queue->p_cb->max_utilization; +} + +void nrf_queue_max_utilization_reset(nrf_queue_t const * p_queue) +{ + ASSERT(p_queue != NULL); + p_queue->p_cb->max_utilization = 0; +} + + +#endif // NRF_MODULE_ENABLED(NRF_QUEUE) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h new file mode 100644 index 000000000..5d94938f1 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h @@ -0,0 +1,471 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** +* @defgroup nrf_queue Queue module +* @{ +* @ingroup app_common +* @brief Functions that handle the queue instances. +*/ + +#ifndef NRF_QUEUE_H__ +#define NRF_QUEUE_H__ + +#include +#include +#include +#include "nrf_assert.h" +#include "sdk_errors.h" +#include "app_util.h" +#include "app_util_platform.h" +#include "nrf_log_instance.h" +#include "nrf_section.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Name of the module used for logger messaging. + */ +#define NRF_QUEUE_LOG_NAME queue + +/**@brief Queue control block. */ +typedef struct +{ + volatile size_t front; //!< Queue front index. + volatile size_t back; //!< Queue back index. + size_t max_utilization; //!< Maximum utilization of the queue. +} nrf_queue_cb_t; + +/**@brief Supported queue modes. */ +typedef enum +{ + NRF_QUEUE_MODE_OVERFLOW, //!< If the queue is full, new element will overwrite the oldest. + NRF_QUEUE_MODE_NO_OVERFLOW, //!< If the queue is full, new element will not be accepted. +} nrf_queue_mode_t; + +/**@brief Instance of the queue. */ +typedef struct +{ + nrf_queue_cb_t * p_cb; //!< Pointer to the instance control block. + void * p_buffer; //!< Pointer to the memory that is used as storage. + size_t size; //!< Size of the queue. + size_t element_size; //!< Size of one element. + nrf_queue_mode_t mode; //!< Mode of the queue. +#if NRF_QUEUE_CLI_CMDS + const char * p_name; //!< Pointer to string with queue name. +#endif + NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled). +} nrf_queue_t; + +#if NRF_QUEUE_CLI_CMDS +#define __NRF_QUEUE_ASSIGN_POOL_NAME(_name) .p_name = STRINGIFY(_name), +#else +#define __NRF_QUEUE_ASSIGN_POOL_NAME(_name) +#endif +/**@brief Create a queue instance. + * + * @note This macro reserves memory for the given queue instance. + * + * @param[in] _type Type which is stored. + * @param[in] _name Name of the queue. + * @param[in] _size Size of the queue. + * @param[in] _mode Mode of the queue. + */ +#define NRF_QUEUE_DEF(_type, _name, _size, _mode) \ + static _type CONCAT_2(_name, _nrf_queue_buffer[(_size) + 1]); \ + static nrf_queue_cb_t CONCAT_2(_name, _nrf_queue_cb); \ + NRF_LOG_INSTANCE_REGISTER(NRF_QUEUE_LOG_NAME, _name, \ + NRF_QUEUE_CONFIG_INFO_COLOR, \ + NRF_QUEUE_CONFIG_DEBUG_COLOR, \ + NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL, \ + NRF_QUEUE_CONFIG_LOG_ENABLED ? \ + NRF_QUEUE_CONFIG_LOG_LEVEL : NRF_LOG_SEVERITY_NONE); \ + NRF_SECTION_ITEM_REGISTER(nrf_queue, const nrf_queue_t _name) = \ + { \ + .p_cb = &CONCAT_2(_name, _nrf_queue_cb), \ + .p_buffer = CONCAT_2(_name,_nrf_queue_buffer), \ + .size = (_size), \ + .element_size = sizeof(_type), \ + .mode = _mode, \ + __NRF_QUEUE_ASSIGN_POOL_NAME(_name) \ + NRF_LOG_INSTANCE_PTR_INIT(p_log, NRF_QUEUE_LOG_NAME, _name) \ + } + +#if !(defined(__LINT__)) +/**@brief Create multiple queue instances. + * + * @note This macro reserves memory for array of queue instances. + * + * @param[in] _type Type which is stored. + * @param[in] _name Name of the array with queue instances. + * @param[in] _size Size of single queue instance. + * @param[in] _mode Mode of single queue instance. + * @param[in] _num Number of queue instances within array. + */ +#define NRF_QUEUE_ARRAY_DEF(_type, _name, _size, _mode, _num) \ + MACRO_REPEAT_FOR(_num, NRF_QUEUE_ARRAY_INSTANCE_ELEMS_DEC, _type, _name, _size, _mode) \ + static const nrf_queue_t _name[] = \ + { \ + MACRO_REPEAT_FOR(_num, NRF_QUEUE_ARRAY_INSTANCE_INIT, _type, _name, _size, _mode) \ + }; \ + STATIC_ASSERT(ARRAY_SIZE(_name) == _num) +#else +#define NRF_QUEUE_ARRAY_DEF(_type, _name, _size, _mode, _num) \ + static const nrf_queue_t _name[_num]; +#endif // !(defined(__LINT__)) + +/**@brief Helping macro used to declare elements for nrf_queue_t instance. + * Used in @ref NRF_QUEUE_ARRAY_DEF. + */ +#define NRF_QUEUE_ARRAY_INSTANCE_ELEMS_DEC(_num, _type, _name, _size, _mode) \ + static _type CONCAT_3(_name, _num, _nrf_queue_buffer[(_size) + 1]); \ + static nrf_queue_cb_t CONCAT_3(_name, _num, _nrf_queue_cb); + +/**@brief Helping macro used to initialize nrf_queue_t instance in an array fashion. + * Used in @ref NRF_QUEUE_ARRAY_DEF. + */ +#define NRF_QUEUE_ARRAY_INSTANCE_INIT(_num, _type, _name, _size, _mode) \ + { \ + .p_cb = &CONCAT_3(_name, _num, _nrf_queue_cb), \ + .p_buffer = CONCAT_3(_name, _num, _nrf_queue_buffer), \ + .size = (_size), \ + .element_size = sizeof(_type), \ + .mode = _mode, \ + }, + +/**@brief Declare a queue interface. + * + * @param[in] _type Type which is stored. + * @param[in] _name Name of the queue. + */ +#define NRF_QUEUE_INTERFACE_DEC(_type, _name) \ + ret_code_t _name##_push(_type const * p_element); \ + ret_code_t _name##_pop(_type * p_element); \ + ret_code_t _name##_peek(_type * p_element); \ + ret_code_t _name##_write(_type const * p_data, \ + size_t element_count); \ + ret_code_t _name##_read(_type * p_data, \ + size_t element_count); \ + size_t _name##_out(_type * p_data, \ + size_t element_count); \ + size_t _name##_in(_type const * p_data, \ + size_t element_count); \ + bool _name##_is_full(void); \ + bool _name##_is_empty(void); \ + size_t _name##_utilization_get(void); \ + size_t _name##_available_get(void); \ + size_t _name##_max_utilization_get(void); \ + void _name##_reset(void) + +/**@brief Define a queue interface. + * + * @param[in] _type Type which is stored. + * @param[in] _name Name of the queue. + * @param[in] _p_queue Queue instance. + */ +#define NRF_QUEUE_INTERFACE_DEF(_type, _name, _p_queue) \ + ret_code_t _name##_push(_type const * p_element) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + ASSERT((_p_queue)->element_size == sizeof(_type)); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_push((_p_queue), p_element); \ + } \ + ret_code_t _name##_pop(_type * p_element) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + ASSERT((_p_queue)->element_size == sizeof(_type)); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_pop((_p_queue), p_element); \ + } \ + ret_code_t _name##_peek(_type * p_element) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + ASSERT((_p_queue)->element_size == sizeof(_type)); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_peek((_p_queue), p_element); \ + } \ + ret_code_t _name##_write(_type const * p_data, \ + size_t element_count) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + ASSERT((_p_queue)->element_size == sizeof(_type)); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_write((_p_queue), p_data, element_count); \ + } \ + ret_code_t _name##_read(_type * p_data, \ + size_t element_count) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + ASSERT((_p_queue)->element_size == sizeof(_type)); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_read((_p_queue), p_data, element_count); \ + } \ + size_t _name##_in(_type const * p_data, \ + size_t element_count) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + ASSERT((_p_queue)->element_size == sizeof(_type)); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_in((_p_queue), p_data, element_count); \ + } \ + size_t _name##_out(_type * p_data, \ + size_t element_count) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + ASSERT((_p_queue)->element_size == sizeof(_type)); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_out((_p_queue), p_data, element_count); \ + } \ + bool _name##_is_full(void) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + return nrf_queue_is_full(_p_queue); \ + GCC_PRAGMA("GCC diagnostic pop") \ + } \ + bool _name##_is_empty(void) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_is_empty(_p_queue); \ + } \ + size_t _name##_utilization_get(void) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_utilization_get(_p_queue); \ + } \ + size_t _name##_available_get(void) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_available_get(_p_queue); \ + } \ + size_t _name##_max_utilization_get(void) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + GCC_PRAGMA("GCC diagnostic pop") \ + return nrf_queue_max_utilization_get(_p_queue); \ + } \ + void _name##_reset(void) \ + { \ + GCC_PRAGMA("GCC diagnostic push") \ + GCC_PRAGMA("GCC diagnostic ignored \"-Waddress\"") \ + ASSERT((_p_queue) != NULL); \ + GCC_PRAGMA("GCC diagnostic pop") \ + nrf_queue_reset(_p_queue); \ + } + +/**@brief Function for pushing an element to the end of queue. + * + * @param[in] p_queue Pointer to the nrf_queue_t instance. + * @param[in] p_element Pointer to the element that will be stored in the queue. + * + * @return NRF_SUCCESS If an element has been successfully added. + * @return NRF_ERROR_NO_MEM If the queue is full (only in @ref NRF_QUEUE_MODE_NO_OVERFLOW). + */ +ret_code_t nrf_queue_push(nrf_queue_t const * p_queue, void const * p_element); + +/**@brief Generic pop implementation. + * + * @param[in] p_queue Pointer to the nrf_queue_t instance. + * @param[out] p_element Pointer where the element will be copied. + * @param[out] just_peek If true, the returned element will not be removed from queue. + * + * @return NRF_SUCCESS If an element was returned. + * @return NRF_ERROR_NOT_FOUND If there are no more elements in the queue. + */ +ret_code_t nrf_queue_generic_pop(nrf_queue_t const * p_queue, + void * p_element, + bool just_peek); + +/**@brief Pop element from the front of the queue. + * + * @param[in] _p_queue Pointer to the nrf_queue_t instance. + * @param[out] _p_element Pointer where the element will be copied. + * + * @return NRF_SUCCESS If an element was returned. + * @return NRF_ERROR_NOT_FOUND If there are no more elements in the queue. + */ +#define nrf_queue_pop(_p_queue, _p_element) nrf_queue_generic_pop((_p_queue), (_p_element), false) + +/**@brief Peek element from the front of the queue. + * + * @param[in] _p_queue Pointer to the nrf_queue_t instance. + * @param[out] _p_element Pointer where the element will be copied. + * + * @return NRF_SUCCESS If an element was returned. + * @return NRF_ERROR_NOT_FOUND If there are no more elements in the queue. + */ +#define nrf_queue_peek(_p_queue, _p_element) nrf_queue_generic_pop((_p_queue), (_p_element), true) + +/**@brief Function for writing elements to the queue. + * + * @param[in] p_queue Pointer to the nrf_queue_t instance. + * @param[in] p_data Pointer to the buffer with elements to write. + * @param[in] element_count Number of elements to write. + * + * @return NRF_SUCCESS If an element was written. + * @return NRF_ERROR_NO_MEM There is not enough space in the queue. No element was written. + */ +ret_code_t nrf_queue_write(nrf_queue_t const * p_queue, + void const * p_data, + size_t element_count); + +/**@brief Function for writing a portion of elements to the queue. + * + * @param[in] p_queue Pointer to the nrf_queue_t instance. + * @param[in] p_data Pointer to the buffer with elements to write. + * @param[in] element_count Number of elements to write. + * + * @return The number of added elements. + */ +size_t nrf_queue_in(nrf_queue_t const * p_queue, + void const * p_data, + size_t element_count); + +/**@brief Function for reading elements from the queue. + * + * @param[in] p_queue Pointer to the nrf_queue_t instance. + * @param[out] p_data Pointer to the buffer where elements will be copied. + * @param[in] element_count Number of elements to read. + * + * @return NRF_SUCCESS If an element was returned. + * @return NRF_ERROR_NOT_FOUND There is not enough elements in the queue. + */ +ret_code_t nrf_queue_read(nrf_queue_t const * p_queue, + void * p_data, + size_t element_count); + +/**@brief Function for reading a portion of elements from the queue. + * + * @param[in] p_queue Pointer to the nrf_queue_t instance. + * @param[out] p_data Pointer to the buffer where elements will be copied. + * @param[in] element_count Number of elements to read. + * + * @return The number of read elements. + */ +size_t nrf_queue_out(nrf_queue_t const * p_queue, + void * p_data, + size_t element_count); + +/**@brief Function for checking if the queue is full. + * + * @param[in] p_queue Pointer to the queue instance. + * + * @return True if the queue is full. + */ +bool nrf_queue_is_full(nrf_queue_t const * p_queue); + +/**@brief Function for checking if the queue is empty. + * + * @param[in] p_queue Pointer to the queue instance. + * + * @return True if the queue is empty. + */ +bool nrf_queue_is_empty(nrf_queue_t const * p_queue); + +/**@brief Function for getting the current queue utilization. + * + * @param[in] p_queue Pointer to the queue instance. + * + * @return Current queue utilization. + */ +size_t nrf_queue_utilization_get(nrf_queue_t const * p_queue); + +/**@brief Function for getting the size of available space. + * + * @param[in] p_queue Pointer to the queue instance. + * + * @return Size of available space. + */ +size_t nrf_queue_available_get(nrf_queue_t const * p_queue); + +/**@brief Function for getting the maximal queue utilization. + * + * @param[in] p_queue Pointer to the queue instance. + * + * @return Maximal queue utilization. + */ +size_t nrf_queue_max_utilization_get(nrf_queue_t const * p_queue); + +/**@brief Function for resetting the maximal queue utilization. + * + * @param[in] p_queue Pointer to the queue instance. + * + */ +void nrf_queue_max_utilization_reset(nrf_queue_t const * p_queue); + +/**@brief Function for resetting the queue state. + * + * @param[in] p_queue Pointer to the queue instance. + */ +void nrf_queue_reset(nrf_queue_t const * p_queue); + +#ifdef __cplusplus +} +#endif + +#endif // NRF_QUEUE_H__ +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror/nrf_strerror.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror/nrf_strerror.c new file mode 100644 index 000000000..3ee6f2701 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror/nrf_strerror.c @@ -0,0 +1,161 @@ +/** + * Copyright (c) 2011 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_STRERROR) +#include "nrf_strerror.h" + +/** + * @brief Macro for adding an entity to the description array. + * + * Macro that helps to create a single entity in the description array. + */ +#define NRF_STRERROR_ENTITY(mnemonic) {.code = mnemonic, .name = #mnemonic} + +/** + * @brief Array entity element that describes an error. + */ +typedef struct +{ + ret_code_t code; /**< Error code. */ + char const * name; /**< Descriptive name (the same as the internal error mnemonic). */ +}nrf_strerror_desc_t; + +/** + * @brief Unknown error code. + * + * The constant string used by @ref nrf_strerror_get when the error description was not found. + */ +static char const m_unknown_str[] = "Unknown error code"; + +/** + * @brief Array with error codes. + * + * Array that describes error codes. + * + * @note It is required for this array to have error codes placed in ascending order. + * This condition is checked in automatic unit test before the release. + */ +static nrf_strerror_desc_t const nrf_strerror_array[] = +{ + NRF_STRERROR_ENTITY(NRF_SUCCESS), + NRF_STRERROR_ENTITY(NRF_ERROR_SVC_HANDLER_MISSING), + NRF_STRERROR_ENTITY(NRF_ERROR_SOFTDEVICE_NOT_ENABLED), + NRF_STRERROR_ENTITY(NRF_ERROR_INTERNAL), + NRF_STRERROR_ENTITY(NRF_ERROR_NO_MEM), + NRF_STRERROR_ENTITY(NRF_ERROR_NOT_FOUND), + NRF_STRERROR_ENTITY(NRF_ERROR_NOT_SUPPORTED), + NRF_STRERROR_ENTITY(NRF_ERROR_INVALID_PARAM), + NRF_STRERROR_ENTITY(NRF_ERROR_INVALID_STATE), + NRF_STRERROR_ENTITY(NRF_ERROR_INVALID_LENGTH), + NRF_STRERROR_ENTITY(NRF_ERROR_INVALID_FLAGS), + NRF_STRERROR_ENTITY(NRF_ERROR_INVALID_DATA), + NRF_STRERROR_ENTITY(NRF_ERROR_DATA_SIZE), + NRF_STRERROR_ENTITY(NRF_ERROR_TIMEOUT), + NRF_STRERROR_ENTITY(NRF_ERROR_NULL), + NRF_STRERROR_ENTITY(NRF_ERROR_FORBIDDEN), + NRF_STRERROR_ENTITY(NRF_ERROR_INVALID_ADDR), + NRF_STRERROR_ENTITY(NRF_ERROR_BUSY), +#ifdef NRF_ERROR_CONN_COUNT + NRF_STRERROR_ENTITY(NRF_ERROR_CONN_COUNT), +#endif +#ifdef NRF_ERROR_RESOURCES + NRF_STRERROR_ENTITY(NRF_ERROR_RESOURCES), +#endif + + /* SDK Common errors */ + NRF_STRERROR_ENTITY(NRF_ERROR_MODULE_NOT_INITIALIZED), + NRF_STRERROR_ENTITY(NRF_ERROR_MUTEX_INIT_FAILED), + NRF_STRERROR_ENTITY(NRF_ERROR_MUTEX_LOCK_FAILED), + NRF_STRERROR_ENTITY(NRF_ERROR_MUTEX_UNLOCK_FAILED), + NRF_STRERROR_ENTITY(NRF_ERROR_MUTEX_COND_INIT_FAILED), + NRF_STRERROR_ENTITY(NRF_ERROR_MODULE_ALREADY_INITIALIZED), + NRF_STRERROR_ENTITY(NRF_ERROR_STORAGE_FULL), + NRF_STRERROR_ENTITY(NRF_ERROR_API_NOT_IMPLEMENTED), + NRF_STRERROR_ENTITY(NRF_ERROR_FEATURE_NOT_ENABLED), + NRF_STRERROR_ENTITY(NRF_ERROR_IO_PENDING), + + /* TWI error codes */ + NRF_STRERROR_ENTITY(NRF_ERROR_DRV_TWI_ERR_OVERRUN), + NRF_STRERROR_ENTITY(NRF_ERROR_DRV_TWI_ERR_ANACK), + NRF_STRERROR_ENTITY(NRF_ERROR_DRV_TWI_ERR_DNACK), + + /* IPSP error codes */ + NRF_STRERROR_ENTITY(NRF_ERROR_BLE_IPSP_RX_PKT_TRUNCATED), + NRF_STRERROR_ENTITY(NRF_ERROR_BLE_IPSP_CHANNEL_ALREADY_EXISTS), + NRF_STRERROR_ENTITY(NRF_ERROR_BLE_IPSP_LINK_DISCONNECTED), + NRF_STRERROR_ENTITY(NRF_ERROR_BLE_IPSP_PEER_REJECTED) +}; + + +char const * nrf_strerror_get(ret_code_t code) +{ + char const * p_ret = nrf_strerror_find(code); + return (p_ret == NULL) ? m_unknown_str : p_ret; +} + +char const * nrf_strerror_find(ret_code_t code) +{ + nrf_strerror_desc_t const * p_start; + nrf_strerror_desc_t const * p_end; + p_start = nrf_strerror_array; + p_end = nrf_strerror_array + ARRAY_SIZE(nrf_strerror_array); + + while (p_start < p_end) + { + nrf_strerror_desc_t const * p_mid = p_start + ((p_end - p_start) / 2); + ret_code_t mid_c = p_mid->code; + if (mid_c > code) + { + p_end = p_mid; + } + else if (mid_c < code) + { + p_start = p_mid + 1; + } + else + { + return p_mid->name; + } + } + return NULL; +} + +#endif /* NRF_STRERROR enabled */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror/nrf_strerror.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror/nrf_strerror.h new file mode 100644 index 000000000..201c78655 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/strerror/nrf_strerror.h @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** + * @defgroup nrf_strerror Error code to string converter + * @ingroup app_common + * + * @brief Module for converting error code into a printable string. + * @{ + */ +#ifndef NRF_STRERROR_H__ +#define NRF_STRERROR_H__ + +#include "sdk_errors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Function for getting a printable error string. + * + * @param code Error code to convert. + * + * @note This function cannot fail. + * For the function that may fail with error translation, see @ref nrf_strerror_find. + * + * @return Pointer to the printable string. + * If the string is not found, + * it returns a simple string that says that the error is unknown. + */ +char const * nrf_strerror_get(ret_code_t code); + +/** + * @brief Function for finding a printable error string. + * + * This function gets the error string in the same way as @ref nrf_strerror_get, + * but if the string is not found, it returns NULL. + * + * @param code Error code to convert. + * @return Pointer to the printable string. + * If the string is not found, NULL is returned. + */ +char const * nrf_strerror_find(ret_code_t code); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_STRERROR_H__ */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h new file mode 100644 index 000000000..34dadfa46 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h @@ -0,0 +1,192 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** @file + * + * @defgroup app_error Common application error handler + * @{ + * @ingroup app_common + * + * @brief Common application error handler and macros for utilizing a common error handler. + */ + +#ifndef APP_ERROR_H__ +#define APP_ERROR_H__ + + +#include +#include +#include +#include "nrf.h" +#include "sdk_errors.h" +#include "nordic_common.h" +#include "app_error_weak.h" +#ifdef ANT_STACK_SUPPORT_REQD +#include "ant_error.h" +#endif // ANT_STACK_SUPPORT_REQD + + + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_FAULT_ID_SDK_RANGE_START (0x00004000) /**< The start of the range of error IDs defined in the SDK. */ + +/**@defgroup APP_ERROR_FAULT_IDS Fault ID types + * @{ */ +#define NRF_FAULT_ID_SDK_ERROR (NRF_FAULT_ID_SDK_RANGE_START + 1) /**< An error stemming from a call to @ref APP_ERROR_CHECK or @ref APP_ERROR_CHECK_BOOL. The info parameter is a pointer to an @ref error_info_t variable. */ +#define NRF_FAULT_ID_SDK_ASSERT (NRF_FAULT_ID_SDK_RANGE_START + 2) /**< An error stemming from a call to ASSERT (nrf_assert.h). The info parameter is a pointer to an @ref assert_info_t variable. */ +/**@} */ + +/**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ERROR. + */ +typedef struct +{ + uint32_t line_num; /**< The line number where the error occurred. */ + uint8_t const * p_file_name; /**< The file in which the error occurred. */ + uint32_t err_code; /**< The error code representing the error that occurred. */ +} error_info_t; + +/**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ASSERT. + */ +typedef struct +{ + uint32_t line_num; /**< The line number where the error occurred. */ + uint8_t const * p_file_name; /**< The file in which the error occurred. */ +} assert_info_t; + +/**@brief Defines required by app_error_handler assembler intructions. + */ +#define APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM (offsetof(error_info_t, line_num)) +#define APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME (offsetof(error_info_t, p_file_name)) +#define APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE (offsetof(error_info_t, err_code)) +#define APP_ERROR_ERROR_INFO_SIZE (sizeof(error_info_t)) +#define APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE \ + ALIGN_NUM(APP_ERROR_ERROR_INFO_SIZE, sizeof(uint64_t)) + + +/**@brief Function for error handling, which is called when an error has occurred. + * + * @param[in] error_code Error code supplied to the handler. + * @param[in] line_num Line number where the handler is called. + * @param[in] p_file_name Pointer to the file name. + */ +void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); + +/**@brief Function for error handling, which is called when an error has occurred. + * + * @param[in] error_code Error code supplied to the handler. + */ +void app_error_handler_bare(ret_code_t error_code); + +/**@brief Function for saving the parameters and entering an eternal loop, for debug purposes. + * + * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. + * @param[in] pc The program counter of the instruction that triggered the fault, or 0 if + * unavailable. + * @param[in] info Optional additional information regarding the fault. Refer to each fault + * identifier for details. + */ +void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info); + +/**@brief Function for logging details of error and flushing logs. + * + * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. + * @param[in] pc The program counter of the instruction that triggered the fault, or 0 if + * unavailable. + * @param[in] info Optional additional information regarding the fault. Refer to each fault + * identifier for details. + */ +void app_error_log_handle(uint32_t id, uint32_t pc, uint32_t info); + + +/**@brief Macro for calling error handler function. + * + * @param[in] ERR_CODE Error code supplied to the error handler. + */ +#ifdef DEBUG +#define APP_ERROR_HANDLER(ERR_CODE) \ + do \ + { \ + app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \ + } while (0) +#else +#define APP_ERROR_HANDLER(ERR_CODE) \ + do \ + { \ + app_error_handler_bare((ERR_CODE)); \ + } while (0) +#endif +/**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS. + * + * @param[in] ERR_CODE Error code supplied to the error handler. + */ +#define APP_ERROR_CHECK(ERR_CODE) \ + do \ + { \ + const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \ + if (LOCAL_ERR_CODE != NRF_SUCCESS) \ + { \ + APP_ERROR_HANDLER(LOCAL_ERR_CODE); \ + } \ + } while (0) + +/**@brief Macro for calling error handler function if supplied boolean value is false. + * + * @param[in] BOOLEAN_VALUE Boolean value to be evaluated. + */ +#define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \ + do \ + { \ + const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \ + if (!LOCAL_BOOLEAN_VALUE) \ + { \ + APP_ERROR_HANDLER(0); \ + } \ + } while (0) + + +#ifdef __cplusplus +} +#endif + +#endif // APP_ERROR_H__ + +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h new file mode 100644 index 000000000..e56ce964b --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h @@ -0,0 +1,1326 @@ +/** + * Copyright (c) 2012 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** @file + * + * @defgroup app_util Utility Functions and Definitions + * @{ + * @ingroup app_common + * + * @brief Various types and definitions available to all applications. + */ + +#ifndef APP_UTIL_H__ +#define APP_UTIL_H__ + +#include +#include +#include +#include "compiler_abstraction.h" +#include "nordic_common.h" +#include "nrf.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @cond (NODOX) + */ +/*lint -save -e27 -e10 -e19 */ +#if defined (__LINT__) +#define STACK_BASE 0x1F000 // Arbitrary value. +#define STACK_TOP 0x20000 // Arbitrary value. + +#elif defined ( __CC_ARM ) +extern char STACK$$Base; +extern char STACK$$Length; +#define STACK_BASE &STACK$$Base +#define STACK_TOP ((void*)((uint32_t)STACK_BASE + (uint32_t)&STACK$$Length)) + +#elif defined ( __ICCARM__ ) +extern char CSTACK$$Base; +extern char CSTACK$$Length; +#define STACK_BASE &CSTACK$$Base +#define STACK_TOP ((void*)((uint32_t)STACK_BASE + (uint32_t)&CSTACK$$Length)) + +#elif defined ( __GNUC__ ) +extern uint32_t __StackTop; +extern uint32_t __StackLimit; +#define STACK_BASE &__StackLimit +#define STACK_TOP &__StackTop +#endif + +/* These macros are valid only when absolute placement is used for the application + * image. The macros are not compile time symbols. They cannot be used as a + * constant expression, for example, inside a static assert or linker script + * at-placement. */ +#if defined (__LINT__) +#define CODE_START (0) // Arbitrary value. +#define CODE_END (0x1000) // Arbitrary value. +#define CODE_SIZE (0x1000) // Arbitrary value. + +#elif defined ( __CC_ARM ) +extern char Load$$LR$$LR_IROM1$$Base; +extern char Load$$LR$$LR_IROM1$$Length; +extern char Load$$LR$$LR_IROM1$$Limit; +#define CODE_START ((uint32_t)&Load$$LR$$LR_IROM1$$Base) +#define CODE_END ((uint32_t)&Load$$LR$$LR_IROM1$$Limit) +#define CODE_SIZE ((uint32_t)&Load$$LR$$LR_IROM1$$Length) + +#elif defined ( __ICCARM__ ) +extern void * __vector_table; +extern char RO_END$$Base; +#define CODE_START ((uint32_t)&__vector_table) +#define CODE_END ((uint32_t)&RO_END$$Base) +#define CODE_SIZE (CODE_END - CODE_START) + +#elif defined(__SES_ARM) +extern uint32_t * _vectors; +extern uint32_t __FLASH1_segment_used_end__; +#define CODE_START ((uint32_t)&_vectors) +#define CODE_END ((uint32_t)&__FLASH1_segment_used_end__) +#define CODE_SIZE (CODE_END - CODE_START) + +#elif defined ( __GNUC__ ) +extern uint32_t __isr_vector; +extern uint32_t __etext; +#define CODE_START ((uint32_t)&__isr_vector) +#define CODE_END ((uint32_t)&__etext) +#define CODE_SIZE (CODE_END - CODE_START) +#endif +/** @} + * @endcond + */ +/* lint -restore */ + +#if defined(MBR_PRESENT) || defined(SOFTDEVICE_PRESENT) +#include "nrf_mbr.h" +#define BOOTLOADER_ADDRESS ((*(uint32_t *)MBR_BOOTLOADER_ADDR) == 0xFFFFFFFF ? *MBR_UICR_BOOTLOADER_ADDR : *(uint32_t *)MBR_BOOTLOADER_ADDR) /**< The currently configured start address of the bootloader. If 0xFFFFFFFF, no bootloader start address is configured. */ +#define MBR_PARAMS_PAGE_ADDRESS ((*(uint32_t *)MBR_PARAM_PAGE_ADDR) == 0xFFFFFFFF ? *MBR_UICR_PARAM_PAGE_ADDR : *(uint32_t *)MBR_PARAM_PAGE_ADDR) /**< The currently configured address of the MBR params page. If 0xFFFFFFFF, no MBR params page address is configured. */ +#else +#define BOOTLOADER_ADDRESS (NRF_UICR->NRFFW[0]) /**< Check UICR, just in case. */ +#define MBR_PARAMS_PAGE_ADDRESS (NRF_UICR->NRFFW[1]) /**< Check UICR, just in case. */ +#endif + +enum +{ + UNIT_0_625_MS = 625, /**< Number of microseconds in 0.625 milliseconds. */ + UNIT_1_25_MS = 1250, /**< Number of microseconds in 1.25 milliseconds. */ + UNIT_10_MS = 10000 /**< Number of microseconds in 10 milliseconds. */ +}; + +/** + * @brief Counts number of bits required for the given value + * + * The macro technically searches for the highest bit set. + * For value 0 it returns 0. + * + * @param val Value to be processed + * + * @return Number of bits required for the given value + */ +//lint -emacro(572,VBITS) +#define VBITS(val) VBITS_32(val) + +/** + * @def VBITS_1 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_2 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_4 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_8 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_16 + * @brief Internal macro used by @ref VBITS */ +/** + * @def VBITS_32 + * @brief Internal macro used by @ref VBITS */ +#define VBITS_1( v) ((((v) & (0x0001U << 0)) != 0) ? 1U : 0U) +#define VBITS_2( v) ((((v) & (0x0001U << 1)) != 0) ? VBITS_1 ((v) >> 1) + 1 : VBITS_1 (v)) +#define VBITS_4( v) ((((v) & (0x0003U << 2)) != 0) ? VBITS_2 ((v) >> 2) + 2 : VBITS_2 (v)) +#define VBITS_8( v) ((((v) & (0x000fU << 4)) != 0) ? VBITS_4 ((v) >> 4) + 4 : VBITS_4 (v)) +#define VBITS_16(v) ((((v) & (0x00ffU << 8)) != 0) ? VBITS_8 ((v) >> 8) + 8 : VBITS_8 (v)) +#define VBITS_32(v) ((((v) & (0xffffU << 16)) != 0) ? VBITS_16((v) >> 16) + 16 : VBITS_16(v)) + + +/*Segger embedded studio originally has offsetof macro which cannot be used in macros (like STATIC_ASSERT). + This redefinition is to allow using that. */ +#if defined(__SES_ARM) && defined(__GNUC__) +#undef offsetof +#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) +#endif + +/**@brief Implementation specific macro for delayed macro expansion used in string concatenation +* +* @param[in] lhs Left hand side in concatenation +* @param[in] rhs Right hand side in concatenation +*/ +#define STRING_CONCATENATE_IMPL(lhs, rhs) lhs ## rhs + + +/**@brief Macro used to concatenate string using delayed macro expansion +* +* @note This macro will delay concatenation until the expressions have been resolved +* +* @param[in] lhs Left hand side in concatenation +* @param[in] rhs Right hand side in concatenation +*/ +#define STRING_CONCATENATE(lhs, rhs) STRING_CONCATENATE_IMPL(lhs, rhs) + + +#ifndef __LINT__ + +#ifdef __GNUC__ +#ifdef __cplusplus +#define STATIC_ASSERT_SIMPLE(EXPR) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] +#define STATIC_ASSERT_MSG(EXPR, MSG) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] +#else +#define STATIC_ASSERT_SIMPLE(EXPR) _Static_assert(EXPR, "unspecified message") +#define STATIC_ASSERT_MSG(EXPR, MSG) _Static_assert(EXPR, MSG) +#endif +#endif + +#ifdef __CC_ARM +#define STATIC_ASSERT_SIMPLE(EXPR) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] +#define STATIC_ASSERT_MSG(EXPR, MSG) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] +#endif + +#ifdef __ICCARM__ +#define STATIC_ASSERT_SIMPLE(EXPR) static_assert(EXPR, "unspecified message") +#define STATIC_ASSERT_MSG(EXPR, MSG) static_assert(EXPR, MSG) +#endif + +#else // __LINT__ + +#define STATIC_ASSERT_SIMPLE(EXPR) extern char (*_ignore(void)) +#define STATIC_ASSERT_MSG(EXPR, MSG) extern char (*_ignore(void)) + +#endif + + +#define _SELECT_ASSERT_FUNC(x, EXPR, MSG, ASSERT_MACRO, ...) ASSERT_MACRO + +/** + * @brief Static (i.e. compile time) assert macro. + * + * @note The output of STATIC_ASSERT can be different across compilers. + * + * Usage: + * STATIC_ASSERT(expression); + * STATIC_ASSERT(expression, message); + * + * @hideinitializer + */ +//lint -save -esym(???, STATIC_ASSERT) +#define STATIC_ASSERT(...) \ + _SELECT_ASSERT_FUNC(x, ##__VA_ARGS__, \ + STATIC_ASSERT_MSG(__VA_ARGS__), \ + STATIC_ASSERT_SIMPLE(__VA_ARGS__)) +//lint -restore + + +/**@brief Implementation details for NUM_VAR_ARGS */ +#define NUM_VA_ARGS_IMPL( \ + _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ + _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ + _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \ + _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \ + _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \ + _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \ + _61, _62, N, ...) N + + +/**@brief Macro to get the number of arguments in a call variadic macro call + * + * param[in] ... List of arguments + * + * @retval Number of variadic arguments in the argument list + */ +#define NUM_VA_ARGS(...) NUM_VA_ARGS_IMPL(__VA_ARGS__, 63, 62, 61, \ + 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, \ + 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \ + 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, \ + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, \ + 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, \ + 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) + +/**@brief Implementation details for NUM_VAR_ARGS */ +#define NUM_VA_ARGS_LESS_1_IMPL( \ + _ignored, \ + _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ + _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ + _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \ + _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \ + _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \ + _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \ + _61, _62, N, ...) N + +/**@brief Macro to get the number of arguments in a call variadic macro call. + * First argument is not counted. + * + * param[in] ... List of arguments + * + * @retval Number of variadic arguments in the argument list + */ +#define NUM_VA_ARGS_LESS_1(...) NUM_VA_ARGS_LESS_1_IMPL(__VA_ARGS__, 63, 62, 61, \ + 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, \ + 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \ + 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, \ + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, \ + 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, \ + 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, ~) + + +/**@brief type for holding an encoded (i.e. little endian) 16 bit unsigned integer. */ +typedef uint8_t uint16_le_t[2]; + +/**@brief Type for holding an encoded (i.e. little endian) 32 bit unsigned integer. */ +typedef uint8_t uint32_le_t[4]; + +/**@brief Byte array type. */ +typedef struct +{ + uint16_t size; /**< Number of array entries. */ + uint8_t * p_data; /**< Pointer to array entries. */ +} uint8_array_t; + + +/**@brief Macro for performing rounded integer division (as opposed to truncating the result). + * + * @param[in] A Numerator. + * @param[in] B Denominator. + * + * @return Rounded (integer) result of dividing A by B. + */ +#define ROUNDED_DIV(A, B) (((A) + ((B) / 2)) / (B)) + + +/**@brief Macro for checking if an integer is a power of two. + * + * @param[in] A Number to be tested. + * + * @return true if value is power of two. + * @return false if value not power of two. + */ +#define IS_POWER_OF_TWO(A) ( ((A) != 0) && ((((A) - 1) & (A)) == 0) ) + + +/**@brief Macro for converting milliseconds to ticks. + * + * @param[in] TIME Number of milliseconds to convert. + * @param[in] RESOLUTION Unit to be converted to in [us/ticks]. + */ +#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION)) + + +/**@brief Macro for performing integer division, making sure the result is rounded up. + * + * @details One typical use for this is to compute the number of objects with size B is needed to + * hold A number of bytes. + * + * @param[in] A Numerator. + * @param[in] B Denominator. + * + * @return Integer result of dividing A by B, rounded up. + */ +#define CEIL_DIV(A, B) \ + (((A) + (B) - 1) / (B)) + + +/**@brief Macro for creating a buffer aligned to 4 bytes. + * + * @param[in] NAME Name of the buffor. + * @param[in] MIN_SIZE Size of this buffor (it will be rounded up to multiples of 4 bytes). + */ +#define WORD_ALIGNED_MEM_BUFF(NAME, MIN_SIZE) static uint32_t NAME[CEIL_DIV(MIN_SIZE, sizeof(uint32_t))] + + +/**@brief Macro for calculating the number of words that are needed to hold a number of bytes. + * + * @details Adds 3 and divides by 4. + * + * @param[in] n_bytes The number of bytes. + * + * @return The number of words that @p n_bytes take up (rounded up). + */ +#define BYTES_TO_WORDS(n_bytes) (((n_bytes) + 3) >> 2) + + +/**@brief The number of bytes in a word. + */ +#define BYTES_PER_WORD (4) + + +/**@brief Macro for increasing a number to the nearest (larger) multiple of another number. + * + * @param[in] alignment The number to align to. + * @param[in] number The number to align (increase). + * + * @return The aligned (increased) @p number. + */ +#define ALIGN_NUM(alignment, number) (((number) - 1) + (alignment) - (((number) - 1) % (alignment))) + +/**@brief Macro for getting first of 2 parameters. + * + * @param[in] a1 First parameter. + * @param[in] a2 Second parameter. + */ +#define GET_ARG_1(a1, a2) a1 + +/**@brief Macro for getting second of 2 parameters. + * + * @param[in] a1 First parameter. + * @param[in] a2 Second parameter. + */ +#define GET_ARG_2(a1, a2) a2 + + +/**@brief Container of macro (borrowed from Linux kernel). + * + * This macro returns parent structure address basing on child member address. + * + * @param ptr Address of child type. + * @param type Type of parent structure. + * @param member Name of child field in parent structure. + * + * @return Parent structure address. + * */ +#define CONTAINER_OF(ptr, type, member) \ + (type *)((char *)ptr - offsetof(type, member)) + + +/** + * @brief Define Bit-field mask + * + * Macro that defined the mask with selected number of bits set, starting from + * provided bit number. + * + * @param[in] bcnt Number of bits in the bit-field + * @param[in] boff Lowest bit number + */ +#define BF_MASK(bcnt, boff) ( ((1U << (bcnt)) - 1U) << (boff) ) + +/** + * @brief Get bit-field + * + * Macro that extracts selected bit-field from provided value + * + * @param[in] val Value from which selected bit-field would be extracted + * @param[in] bcnt Number of bits in the bit-field + * @param[in] boff Lowest bit number + * + * @return Value of the selected bits + */ +#define BF_GET(val, bcnt, boff) ( ( (val) & BF_MASK((bcnt), (boff)) ) >> (boff) ) + +/** + * @brief Create bit-field value + * + * Value is masked and shifted to match given bit-field + * + * @param[in] val Value to set on bit-field + * @param[in] bcnt Number of bits for bit-field + * @param[in] boff Offset of bit-field + * + * @return Value positioned of given bit-field. + */ +#define BF_VAL(val, bcnt, boff) ( (((uint32_t)(val)) << (boff)) & BF_MASK(bcnt, boff) ) + +/** + * @name Configuration of complex bit-field + * + * @sa BF_CX + * @{ + */ +/** @brief Position of bit count in complex bit-field value */ +#define BF_CX_BCNT_POS 0U +/** @brief Mask of bit count in complex bit-field value */ +#define BF_CX_BCNT_MASK (0xffU << BF_CX_BCNT_POS) +/** @brief Position of bit position in complex bit-field value */ +#define BF_CX_BOFF_POS 8U +/** @brief Mask of bit position in complex bit-field value */ +#define BF_CX_BOFF_MASK (0xffU << BF_CX_BOFF_POS) +/** @} */ + +/** + * @brief Define complex bit-field + * + * Complex bit-field would contain its position and size in one number. + * @sa BF_CX_MASK + * @sa BF_CX_POS + * @sa BF_CX_GET + * + * @param[in] bcnt Number of bits in the bit-field + * @param[in] boff Lowest bit number + * + * @return The single number that describes the bit-field completely. + */ +#define BF_CX(bcnt, boff) ( ((((uint32_t)(bcnt)) << BF_CX_BCNT_POS) & BF_CX_BCNT_MASK) | ((((uint32_t)(boff)) << BF_CX_BOFF_POS) & BF_CX_BOFF_MASK) ) + +/** + * @brief Get number of bits in bit-field + * + * @sa BF_CX + * + * @param bf_cx Complex bit-field + * + * @return Number of bits in given bit-field + */ +#define BF_CX_BCNT(bf_cx) ( ((bf_cx) & BF_CX_BCNT_MASK) >> BF_CX_BCNT_POS ) + +/** + * @brief Get lowest bit number in the field + * + * @sa BF_CX + * + * @param[in] bf_cx Complex bit-field + * + * @return Lowest bit number in given bit-field + */ +#define BF_CX_BOFF(bf_cx) ( ((bf_cx) & BF_CX_BOFF_MASK) >> BF_CX_BOFF_POS ) + +/** + * @brief Get bit mask of the selected field + * + * @sa BF_CX + * + * @param[in] bf_cx Complex bit-field + * + * @return Mask of given bit-field + */ +#define BF_CX_MASK(bf_cx) BF_MASK(BF_CX_BCNT(bf_cx), BF_CX_BOFF(bf_cx)) + +/** + * @brief Get bit-field + * + * Macro that extracts selected bit-field from provided value. + * Bit-field is given as a complex value. + * + * @sa BF_CX + * @sa BF_GET + * + * @param[in] val Value from which selected bit-field would be extracted + * @param[in] bf_cx Complex bit-field + * + * @return Value of the selected bits. + */ +#define BF_CX_GET(val, bf_cx) BF_GET(val, BF_CX_BCNT(bf_cx), BF_CX_BOFF(bf_cx)) + +/** + * @brief Create bit-field value + * + * Value is masked and shifted to match given bit-field. + * + * @param[in] val Value to set on bit-field + * @param[in] bf_cx Complex bit-field + * + * @return Value positioned of given bit-field. + */ +#define BF_CX_VAL(val, bf_cx) BF_VAL(val, BF_CX_BCNT(bf_cx), BF_CX_BOFF(bf_cx)) + +/** + * @brief Extracting data from the brackets + * + * This macro get rid of brackets around the argument. + * It can be used to pass multiple arguments in logical one argument to a macro. + * Call it with arguments inside brackets: + * @code + * #define ARGUMENTS (a, b, c) + * BRACKET_EXTRACT(ARGUMENTS) + * @endcode + * It would produce: + * @code + * a, b, c + * @endcode + * + * @param a Argument with anything inside brackets + * @return Anything that appears inside the brackets of the argument + * + * @note + * The argument of the macro have to be inside brackets. + * In other case the compilation would fail. + */ +#define BRACKET_EXTRACT(a) BRACKET_EXTRACT_(a) +#define BRACKET_EXTRACT_(a) BRACKET_EXTRACT__ a +#define BRACKET_EXTRACT__(...) __VA_ARGS__ + + +/** + * @brief Check if number of parameters is more than 1 + * + * @param ... Arguments to count + * + * @return 0 If argument count is <= 1 + * @return 1 If argument count is > 1 + * + * @sa NUM_VA_ARGS + * @sa NUM_IS_MORE_THAN_1 + */ +#define NUM_VA_ARGS_IS_MORE_THAN_1(...) NUM_IS_MORE_THAN_1(NUM_VA_ARGS(__VA_ARGS__)) + +/** + * @brief Check if given numeric value is bigger than 1 + * + * This macro accepts numeric value, that may be the result of argument expansion. + * This numeric value is then converted to 0 if it is lover than 1 or to 1 if + * its value is higher than 1. + * The generated result can be used to glue it into other macro mnemonic name. + * + * @param N Numeric value to check + * + * @return 0 If argument is <= 1 + * @return 1 If argument is > 1 + * + * @note Any existing definition of a form NUM_IS_MORE_THAN_1_PROBE_[N] can + * broke the result of this macro + */ +#define NUM_IS_MORE_THAN_1(N) NUM_IS_MORE_THAN_1_(N) +#define NUM_IS_MORE_THAN_1_(N) NUM_IS_MORE_THAN_1_PROBE_(NUM_IS_MORE_THAN_1_PROBE_ ## N, 1) +#define NUM_IS_MORE_THAN_1_PROBE_(...) GET_VA_ARG_1(GET_ARGS_AFTER_1(__VA_ARGS__)) +#define NUM_IS_MORE_THAN_1_PROBE_0 ~, 0 +#define NUM_IS_MORE_THAN_1_PROBE_1 ~, 0 + +/** + * @brief Get the first argument + * + * @param ... Arguments to select + * + * @return First argument or empty if no arguments are provided + */ +#define GET_VA_ARG_1(...) GET_VA_ARG_1_(__VA_ARGS__, ) // Make sure that also for 1 argument it works +#define GET_VA_ARG_1_(a1, ...) a1 + +/** + * @brief Get all the arguments but the first one + * + * @param ... Arguments to select + * + * @return All arguments after the first one or empty if less than 2 arguments are provided + */ +#define GET_ARGS_AFTER_1(...) GET_ARGS_AFTER_1_(__VA_ARGS__, ) // Make sure that also for 1 argument it works +#define GET_ARGS_AFTER_1_(a1, ...) __VA_ARGS__ + +/** + * @brief Size of a field in declared structure + * + * Macro that returns the size of the structure field. + * @param struct_type Variable type to get the field size from + * @param field Field name to analyze. It can be even field inside field (field.somethingelse.and_another). + * + * @return Size of the field + */ +#define FIELD_SIZE(struct_type, field) sizeof(((struct struct_type*)NULL)->field) + +/** + * @brief Number of elements in field array in declared structure + * + * Macro that returns number of elementy in structure field. + * @param struct_type Variable type to get the field size from + * @param field Field name to analyze. + * + * @return Number of elements in field array + * + * @sa FIELD_SIZE + */ +#define FIELD_ARRAY_SIZE(struct_type, field) (FIELD_SIZE(struct_type, field) / FIELD_SIZE(struct_type, field[0])) + +/** + * @brief Mapping macro + * + * Macro that process all arguments using given macro + * + * @param ... Macro name to be used for argument processing followed by arguments to process. + * Macro should have following form: MACRO(argument) + * + * @return All arguments processed by given macro + */ +#define MACRO_MAP(...) MACRO_MAP_(__VA_ARGS__) +#define MACRO_MAP_(...) MACRO_MAP_N(NUM_VA_ARGS_LESS_1(__VA_ARGS__), __VA_ARGS__) // To make sure it works also for 2 arguments in total + +/** + * @brief Mapping macro, recursive version + * + * Can be used in @ref MACRO_MAP macro + */ +#define MACRO_MAP_REC(...) MACRO_MAP_REC_(__VA_ARGS__) +#define MACRO_MAP_REC_(...) MACRO_MAP_REC_N(NUM_VA_ARGS_LESS_1(__VA_ARGS__), __VA_ARGS__) // To make sure it works also for 2 arguments in total +/** + * @brief Mapping N arguments macro + * + * Macro similar to @ref MACRO_MAP but maps exact number of arguments. + * If there is more arguments given, the rest would be ignored. + * + * @param N Number of arguments to map + * @param ... Macro name to be used for argument processing followed by arguments to process. + * Macro should have following form: MACRO(argument) + * + * @return Selected number of arguments processed by given macro + */ +#define MACRO_MAP_N(N, ...) MACRO_MAP_N_(N, __VA_ARGS__) +#define MACRO_MAP_N_(N, ...) CONCAT_2(MACRO_MAP_, N)(__VA_ARGS__, ) + +/** + * @brief Mapping N arguments macro, recursive version + * + * Can be used in @ref MACRO_MAP_N macro + */ +#define MACRO_MAP_REC_N(N, ...) MACRO_MAP_REC_N_(N, __VA_ARGS__) +#define MACRO_MAP_REC_N_(N, ...) CONCAT_2(MACRO_MAP_REC_, N)(__VA_ARGS__, ) + +#define MACRO_MAP_0( ...) +#define MACRO_MAP_1( macro, a, ...) macro(a) +#define MACRO_MAP_2( macro, a, ...) macro(a) MACRO_MAP_1 (macro, __VA_ARGS__, ) +#define MACRO_MAP_3( macro, a, ...) macro(a) MACRO_MAP_2 (macro, __VA_ARGS__, ) +#define MACRO_MAP_4( macro, a, ...) macro(a) MACRO_MAP_3 (macro, __VA_ARGS__, ) +#define MACRO_MAP_5( macro, a, ...) macro(a) MACRO_MAP_4 (macro, __VA_ARGS__, ) +#define MACRO_MAP_6( macro, a, ...) macro(a) MACRO_MAP_5 (macro, __VA_ARGS__, ) +#define MACRO_MAP_7( macro, a, ...) macro(a) MACRO_MAP_6 (macro, __VA_ARGS__, ) +#define MACRO_MAP_8( macro, a, ...) macro(a) MACRO_MAP_7 (macro, __VA_ARGS__, ) +#define MACRO_MAP_9( macro, a, ...) macro(a) MACRO_MAP_8 (macro, __VA_ARGS__, ) +#define MACRO_MAP_10(macro, a, ...) macro(a) MACRO_MAP_9 (macro, __VA_ARGS__, ) +#define MACRO_MAP_11(macro, a, ...) macro(a) MACRO_MAP_10(macro, __VA_ARGS__, ) +#define MACRO_MAP_12(macro, a, ...) macro(a) MACRO_MAP_11(macro, __VA_ARGS__, ) +#define MACRO_MAP_13(macro, a, ...) macro(a) MACRO_MAP_12(macro, __VA_ARGS__, ) +#define MACRO_MAP_14(macro, a, ...) macro(a) MACRO_MAP_13(macro, __VA_ARGS__, ) +#define MACRO_MAP_15(macro, a, ...) macro(a) MACRO_MAP_14(macro, __VA_ARGS__, ) +#define MACRO_MAP_16(macro, a, ...) macro(a) MACRO_MAP_15(macro, __VA_ARGS__, ) +#define MACRO_MAP_17(macro, a, ...) macro(a) MACRO_MAP_16(macro, __VA_ARGS__, ) +#define MACRO_MAP_18(macro, a, ...) macro(a) MACRO_MAP_17(macro, __VA_ARGS__, ) +#define MACRO_MAP_19(macro, a, ...) macro(a) MACRO_MAP_18(macro, __VA_ARGS__, ) +#define MACRO_MAP_20(macro, a, ...) macro(a) MACRO_MAP_19(macro, __VA_ARGS__, ) +#define MACRO_MAP_21(macro, a, ...) macro(a) MACRO_MAP_20(macro, __VA_ARGS__, ) +#define MACRO_MAP_22(macro, a, ...) macro(a) MACRO_MAP_21(macro, __VA_ARGS__, ) +#define MACRO_MAP_23(macro, a, ...) macro(a) MACRO_MAP_22(macro, __VA_ARGS__, ) +#define MACRO_MAP_24(macro, a, ...) macro(a) MACRO_MAP_23(macro, __VA_ARGS__, ) +#define MACRO_MAP_25(macro, a, ...) macro(a) MACRO_MAP_24(macro, __VA_ARGS__, ) +#define MACRO_MAP_26(macro, a, ...) macro(a) MACRO_MAP_25(macro, __VA_ARGS__, ) +#define MACRO_MAP_27(macro, a, ...) macro(a) MACRO_MAP_26(macro, __VA_ARGS__, ) +#define MACRO_MAP_28(macro, a, ...) macro(a) MACRO_MAP_27(macro, __VA_ARGS__, ) +#define MACRO_MAP_29(macro, a, ...) macro(a) MACRO_MAP_28(macro, __VA_ARGS__, ) +#define MACRO_MAP_30(macro, a, ...) macro(a) MACRO_MAP_29(macro, __VA_ARGS__, ) +#define MACRO_MAP_31(macro, a, ...) macro(a) MACRO_MAP_30(macro, __VA_ARGS__, ) +#define MACRO_MAP_32(macro, a, ...) macro(a) MACRO_MAP_31(macro, __VA_ARGS__, ) + + +#define MACRO_MAP_REC_0( ...) +#define MACRO_MAP_REC_1( macro, a, ...) macro(a) +#define MACRO_MAP_REC_2( macro, a, ...) macro(a) MACRO_MAP_REC_1 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_3( macro, a, ...) macro(a) MACRO_MAP_REC_2 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_4( macro, a, ...) macro(a) MACRO_MAP_REC_3 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_5( macro, a, ...) macro(a) MACRO_MAP_REC_4 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_6( macro, a, ...) macro(a) MACRO_MAP_REC_5 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_7( macro, a, ...) macro(a) MACRO_MAP_REC_6 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_8( macro, a, ...) macro(a) MACRO_MAP_REC_7 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_9( macro, a, ...) macro(a) MACRO_MAP_REC_8 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_10(macro, a, ...) macro(a) MACRO_MAP_REC_9 (macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_11(macro, a, ...) macro(a) MACRO_MAP_REC_10(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_12(macro, a, ...) macro(a) MACRO_MAP_REC_11(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_13(macro, a, ...) macro(a) MACRO_MAP_REC_12(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_14(macro, a, ...) macro(a) MACRO_MAP_REC_13(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_15(macro, a, ...) macro(a) MACRO_MAP_REC_14(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_16(macro, a, ...) macro(a) MACRO_MAP_REC_15(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_17(macro, a, ...) macro(a) MACRO_MAP_REC_16(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_18(macro, a, ...) macro(a) MACRO_MAP_REC_17(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_19(macro, a, ...) macro(a) MACRO_MAP_REC_18(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_20(macro, a, ...) macro(a) MACRO_MAP_REC_19(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_21(macro, a, ...) macro(a) MACRO_MAP_REC_20(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_22(macro, a, ...) macro(a) MACRO_MAP_REC_21(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_23(macro, a, ...) macro(a) MACRO_MAP_REC_22(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_24(macro, a, ...) macro(a) MACRO_MAP_REC_23(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_25(macro, a, ...) macro(a) MACRO_MAP_REC_24(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_26(macro, a, ...) macro(a) MACRO_MAP_REC_25(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_27(macro, a, ...) macro(a) MACRO_MAP_REC_26(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_28(macro, a, ...) macro(a) MACRO_MAP_REC_27(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_29(macro, a, ...) macro(a) MACRO_MAP_REC_28(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_30(macro, a, ...) macro(a) MACRO_MAP_REC_29(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_31(macro, a, ...) macro(a) MACRO_MAP_REC_30(macro, __VA_ARGS__, ) +#define MACRO_MAP_REC_32(macro, a, ...) macro(a) MACRO_MAP_REC_31(macro, __VA_ARGS__, ) + + +/** + * @brief Mapping macro with current index + * + * Basically macro similar to @ref MACRO_MAP, but the processing function would get an argument + * and current argument index (beginning from 0). + * + * @param ... Macro name to be used for argument processing followed by arguments to process. + * Macro should have following form: MACRO(argument, index) + * @return All arguments processed by given macro + */ +#define MACRO_MAP_FOR(...) MACRO_MAP_FOR_(__VA_ARGS__) +#define MACRO_MAP_FOR_N_LIST 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, \ + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 +#define MACRO_MAP_FOR_(...) MACRO_MAP_FOR_N(NUM_VA_ARGS_LESS_1(__VA_ARGS__), __VA_ARGS__) + +/** + * @brief Mapping N arguments macro with current index + * + * Macro is similar to @ref MACRO_MAP_FOR but maps exact number of arguments. + * If there is more arguments given, the rest would be ignored. + * + * @param N Number of arguments to map + * @param ... Macro name to be used for argument processing followed by arguments to process. + * Macro should have following form: MACRO(argument, index) + * + * @return Selected number of arguments processed by given macro + */ +#define MACRO_MAP_FOR_N(N, ...) MACRO_MAP_FOR_N_(N, __VA_ARGS__) +#define MACRO_MAP_FOR_N_(N, ...) CONCAT_2(MACRO_MAP_FOR_, N)((MACRO_MAP_FOR_N_LIST), __VA_ARGS__, ) + +#define MACRO_MAP_FOR_0( n_list, ...) +#define MACRO_MAP_FOR_1( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) +#define MACRO_MAP_FOR_2( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_1 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_3( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_2 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_4( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_3 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_5( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_4 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_6( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_5 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_7( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_6 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_8( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_7 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_9( n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_8 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_10(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_9 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_11(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_10((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_12(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_11((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_13(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_14(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_15(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_16(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_17(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_18(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_19(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_20(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_21(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_22(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_23(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_24(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_25(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_26(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_27(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_28(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_29(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_30(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_31(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_32(n_list, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list))) MACRO_MAP_FOR_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__, ) + + +/** + * @brief Mapping macro with current index and parameter + * + * Version of @ref MACRO_MAP_FOR that passes also the same parameter to all macros. + * + * @param param Parameter that would be passed to each macro call during mapping. + * @param ... Macro name to be used for argument processing followed by arguments to process. + * Macro should have following form: MACRO(argument, index, param) + * + * @return All arguments processed by given macro + */ +#define MACRO_MAP_FOR_PARAM(param, ...) MACRO_MAP_FOR_PARAM_(param, __VA_ARGS__) +#define MACRO_MAP_FOR_PARAM_(param, ...) MACRO_MAP_FOR_PARAM_N(NUM_VA_ARGS_LESS_1(__VA_ARGS__), param, __VA_ARGS__) + +/** + * @brief Mapping N arguments macro with with current index and parameter + * + * @param N Number of arguments to map + * @param param Parameter that would be passed to each macro call during mapping. + * @param ... Macro name to be used for argument processing followed by arguments to process. + * Macro should have following form: MACRO(argument, index, param) + * + * @return All arguments processed by given macro + */ +#define MACRO_MAP_FOR_PARAM_N(N, param, ...) MACRO_MAP_FOR_PARAM_N_(N, param, __VA_ARGS__) +#define MACRO_MAP_FOR_PARAM_N_(N, param, ...) CONCAT_2(MACRO_MAP_FOR_PARAM_, N)((MACRO_MAP_FOR_N_LIST), param, __VA_ARGS__, ) + + +#define MACRO_MAP_FOR_PARAM_0( n_list, param, ...) +#define MACRO_MAP_FOR_PARAM_1( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) +#define MACRO_MAP_FOR_PARAM_2( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_1 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_3( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_2 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_4( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_3 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_5( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_4 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_6( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_5 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_7( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_6 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_8( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_7 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_9( n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_8 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_10(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_9 ((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_11(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_10((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_12(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_11((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_13(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_14(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_15(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_16(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_17(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_18(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_19(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_20(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_21(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_22(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_23(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_24(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_25(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_26(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_27(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_28(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_29(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_30(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_31(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) +#define MACRO_MAP_FOR_PARAM_32(n_list, param, macro, a, ...) macro(a, GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), param) MACRO_MAP_FOR_PARAM_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), param, macro, __VA_ARGS__, ) + + + +/** + * @brief Repeating macro. + * + * @param count Count of repeats. + * @param macro Macro must have the following form: MACRO(arguments). + * @param ... Arguments passed to the macro. + * + * @return All arguments processed by the given macro. + */ +#define MACRO_REPEAT(count, macro, ...) MACRO_REPEAT_(count, macro, __VA_ARGS__) +#define MACRO_REPEAT_(count, macro, ...) CONCAT_2(MACRO_REPEAT_, count)(macro, __VA_ARGS__) + +#define MACRO_REPEAT_0(macro, ...) +#define MACRO_REPEAT_1(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_0(macro, __VA_ARGS__) +#define MACRO_REPEAT_2(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_1(macro, __VA_ARGS__) +#define MACRO_REPEAT_3(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_2(macro, __VA_ARGS__) +#define MACRO_REPEAT_4(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_3(macro, __VA_ARGS__) +#define MACRO_REPEAT_5(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_4(macro, __VA_ARGS__) +#define MACRO_REPEAT_6(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_5(macro, __VA_ARGS__) +#define MACRO_REPEAT_7(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_6(macro, __VA_ARGS__) +#define MACRO_REPEAT_8(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_7(macro, __VA_ARGS__) +#define MACRO_REPEAT_9(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_8(macro, __VA_ARGS__) +#define MACRO_REPEAT_10(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_9(macro, __VA_ARGS__) +#define MACRO_REPEAT_11(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_10(macro, __VA_ARGS__) +#define MACRO_REPEAT_12(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_11(macro, __VA_ARGS__) +#define MACRO_REPEAT_13(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_12(macro, __VA_ARGS__) +#define MACRO_REPEAT_14(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_13(macro, __VA_ARGS__) +#define MACRO_REPEAT_15(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_14(macro, __VA_ARGS__) +#define MACRO_REPEAT_16(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_15(macro, __VA_ARGS__) +#define MACRO_REPEAT_17(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_16(macro, __VA_ARGS__) +#define MACRO_REPEAT_18(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_17(macro, __VA_ARGS__) +#define MACRO_REPEAT_19(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_18(macro, __VA_ARGS__) +#define MACRO_REPEAT_20(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_19(macro, __VA_ARGS__) +#define MACRO_REPEAT_21(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_20(macro, __VA_ARGS__) +#define MACRO_REPEAT_22(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_21(macro, __VA_ARGS__) +#define MACRO_REPEAT_23(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_22(macro, __VA_ARGS__) +#define MACRO_REPEAT_24(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_23(macro, __VA_ARGS__) +#define MACRO_REPEAT_25(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_24(macro, __VA_ARGS__) +#define MACRO_REPEAT_26(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_25(macro, __VA_ARGS__) +#define MACRO_REPEAT_27(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_26(macro, __VA_ARGS__) +#define MACRO_REPEAT_28(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_27(macro, __VA_ARGS__) +#define MACRO_REPEAT_29(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_28(macro, __VA_ARGS__) +#define MACRO_REPEAT_30(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_29(macro, __VA_ARGS__) +#define MACRO_REPEAT_31(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_30(macro, __VA_ARGS__) +#define MACRO_REPEAT_32(macro, ...) macro(__VA_ARGS__) MACRO_REPEAT_31(macro, __VA_ARGS__) + + +/** + * @brief Repeating macro with current index. + * + * Macro similar to @ref MACRO_REPEAT but the processing function gets the arguments + * and the current argument index (beginning from 0). + + * @param count Count of repeats. + * @param macro Macro must have the following form: MACRO(index, arguments). + * @param ... Arguments passed to the macro. + * + * @return All arguments processed by the given macro. + */ +#define MACRO_REPEAT_FOR(count, macro, ...) MACRO_REPEAT_FOR_(count, macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_(count, macro, ...) CONCAT_2(MACRO_REPEAT_FOR_, count)((MACRO_MAP_FOR_N_LIST), macro, __VA_ARGS__) + +#define MACRO_REPEAT_FOR_0(n_list, macro, ...) +#define MACRO_REPEAT_FOR_1(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_0((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_2(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_1((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_3(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_2((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_4(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_3((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_5(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_4((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_6(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_5((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_7(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_6((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_8(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_7((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_9(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_8((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_10(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_9((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_11(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_10((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_12(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_11((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_13(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_12((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_14(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_13((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_15(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_14((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_16(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_15((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_17(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_16((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_18(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_17((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_19(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_18((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_20(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_19((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_21(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_20((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_22(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_21((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_23(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_22((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_24(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_23((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_25(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_24((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_26(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_25((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_27(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_26((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_28(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_27((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_29(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_28((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_30(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_29((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_31(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_30((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) +#define MACRO_REPEAT_FOR_32(n_list, macro, ...) macro(GET_VA_ARG_1(BRACKET_EXTRACT(n_list)), __VA_ARGS__) MACRO_REPEAT_FOR_31((GET_ARGS_AFTER_1(BRACKET_EXTRACT(n_list))), macro, __VA_ARGS__) + + +/**@brief Adding curly brace to the macro parameter. + * + * Useful in array of structures initialization. + * + * @param p Parameter to put into the curly brace. */ +#define PARAM_CBRACE(p) { p }, + + +/**@brief Function for changing the value unit. + * + * @param[in] value Value to be rescaled. + * @param[in] old_unit_reversal Reversal of the incoming unit. + * @param[in] new_unit_reversal Reversal of the desired unit. + * + * @return Number of bytes written. + */ +static __INLINE uint64_t value_rescale(uint32_t value, uint32_t old_unit_reversal, uint16_t new_unit_reversal) +{ + return (uint64_t)ROUNDED_DIV((uint64_t)value * new_unit_reversal, old_unit_reversal); +} + +/**@brief Function for encoding a uint16 value. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data is to be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint16_encode(uint16_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) ((value & 0x00FF) >> 0); + p_encoded_data[1] = (uint8_t) ((value & 0xFF00) >> 8); + return sizeof(uint16_t); +} + +/**@brief Function for encoding a three-byte value. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data is to be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint24_encode(uint32_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) ((value & 0x000000FF) >> 0); + p_encoded_data[1] = (uint8_t) ((value & 0x0000FF00) >> 8); + p_encoded_data[2] = (uint8_t) ((value & 0x00FF0000) >> 16); + return 3; +} + +/**@brief Function for encoding a uint32 value. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data is to be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint32_encode(uint32_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) ((value & 0x000000FF) >> 0); + p_encoded_data[1] = (uint8_t) ((value & 0x0000FF00) >> 8); + p_encoded_data[2] = (uint8_t) ((value & 0x00FF0000) >> 16); + p_encoded_data[3] = (uint8_t) ((value & 0xFF000000) >> 24); + return sizeof(uint32_t); +} + +/**@brief Function for encoding a uint40 value. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data is to be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint40_encode(uint64_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) ((value & 0x00000000FF) >> 0); + p_encoded_data[1] = (uint8_t) ((value & 0x000000FF00) >> 8); + p_encoded_data[2] = (uint8_t) ((value & 0x0000FF0000) >> 16); + p_encoded_data[3] = (uint8_t) ((value & 0x00FF000000) >> 24); + p_encoded_data[4] = (uint8_t) ((value & 0xFF00000000) >> 32); + return 5; +} + +/**@brief Function for encoding a uint48 value. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data is to be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint48_encode(uint64_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) ((value & 0x0000000000FF) >> 0); + p_encoded_data[1] = (uint8_t) ((value & 0x00000000FF00) >> 8); + p_encoded_data[2] = (uint8_t) ((value & 0x000000FF0000) >> 16); + p_encoded_data[3] = (uint8_t) ((value & 0x0000FF000000) >> 24); + p_encoded_data[4] = (uint8_t) ((value & 0x00FF00000000) >> 32); + p_encoded_data[5] = (uint8_t) ((value & 0xFF0000000000) >> 40); + return 6; +} + +/**@brief Function for decoding a uint16 value. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. + */ +static __INLINE uint16_t uint16_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint16_t)((uint8_t *)p_encoded_data)[0])) | + (((uint16_t)((uint8_t *)p_encoded_data)[1]) << 8 )); +} + +/**@brief Function for decoding a uint16 value in big-endian format. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. + */ +static __INLINE uint16_t uint16_big_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint16_t)((uint8_t *)p_encoded_data)[0]) << 8 ) | + (((uint16_t)((uint8_t *)p_encoded_data)[1])) ); +} + +/**@brief Function for decoding a three-byte value. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value (uint32_t). + */ +static __INLINE uint32_t uint24_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint32_t)((uint8_t *)p_encoded_data)[0]) << 0) | + (((uint32_t)((uint8_t *)p_encoded_data)[1]) << 8) | + (((uint32_t)((uint8_t *)p_encoded_data)[2]) << 16)); +} + +/**@brief Function for decoding a uint32 value. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. + */ +static __INLINE uint32_t uint32_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint32_t)((uint8_t *)p_encoded_data)[0]) << 0) | + (((uint32_t)((uint8_t *)p_encoded_data)[1]) << 8) | + (((uint32_t)((uint8_t *)p_encoded_data)[2]) << 16) | + (((uint32_t)((uint8_t *)p_encoded_data)[3]) << 24 )); +} + +/**@brief Function for decoding a uint32 value in big-endian format. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. + */ +static __INLINE uint32_t uint32_big_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint32_t)((uint8_t *)p_encoded_data)[0]) << 24) | + (((uint32_t)((uint8_t *)p_encoded_data)[1]) << 16) | + (((uint32_t)((uint8_t *)p_encoded_data)[2]) << 8) | + (((uint32_t)((uint8_t *)p_encoded_data)[3]) << 0) ); +} + +/** + * @brief Function for encoding an uint16 value in big-endian format. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data will be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint16_big_encode(uint16_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) (value >> 8); + p_encoded_data[1] = (uint8_t) (value & 0xFF); + + return sizeof(uint16_t); +} + +/*lint -esym(526, __rev) */ +/*lint -esym(628, __rev) */ +/**@brief Function for encoding a uint32 value in big-endian format. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data will be written. + * The address pointed to must be word alligned. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint32_big_encode(uint32_t value, uint8_t * p_encoded_data) +{ + *(uint32_t *)p_encoded_data = __REV(value); + return sizeof(uint32_t); +} + +/**@brief Function for decoding a uint40 value. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. (uint64_t) + */ +static __INLINE uint64_t uint40_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint64_t)((uint8_t *)p_encoded_data)[0]) << 0) | + (((uint64_t)((uint8_t *)p_encoded_data)[1]) << 8) | + (((uint64_t)((uint8_t *)p_encoded_data)[2]) << 16) | + (((uint64_t)((uint8_t *)p_encoded_data)[3]) << 24) | + (((uint64_t)((uint8_t *)p_encoded_data)[4]) << 32 )); +} + +/**@brief Function for decoding a uint48 value. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. (uint64_t) + */ +static __INLINE uint64_t uint48_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint64_t)((uint8_t *)p_encoded_data)[0]) << 0) | + (((uint64_t)((uint8_t *)p_encoded_data)[1]) << 8) | + (((uint64_t)((uint8_t *)p_encoded_data)[2]) << 16) | + (((uint64_t)((uint8_t *)p_encoded_data)[3]) << 24) | + (((uint64_t)((uint8_t *)p_encoded_data)[4]) << 32) | + (((uint64_t)((uint8_t *)p_encoded_data)[5]) << 40 )); +} + +/** @brief Function for converting the input voltage (in milli volts) into percentage of 3.0 Volts. + * + * @details The calculation is based on a linearized version of the battery's discharge + * curve. 3.0V returns 100% battery level. The limit for power failure is 2.1V and + * is considered to be the lower boundary. + * + * The discharge curve for CR2032 is non-linear. In this model it is split into + * 4 linear sections: + * - Section 1: 3.0V - 2.9V = 100% - 42% (58% drop on 100 mV) + * - Section 2: 2.9V - 2.74V = 42% - 18% (24% drop on 160 mV) + * - Section 3: 2.74V - 2.44V = 18% - 6% (12% drop on 300 mV) + * - Section 4: 2.44V - 2.1V = 6% - 0% (6% drop on 340 mV) + * + * These numbers are by no means accurate. Temperature and + * load in the actual application is not accounted for! + * + * @param[in] mvolts The voltage in mV + * + * @return Battery level in percent. +*/ +static __INLINE uint8_t battery_level_in_percent(const uint16_t mvolts) +{ + uint8_t battery_level; + + if (mvolts >= 3000) + { + battery_level = 100; + } + else if (mvolts > 2900) + { + battery_level = 100 - ((3000 - mvolts) * 58) / 100; + } + else if (mvolts > 2740) + { + battery_level = 42 - ((2900 - mvolts) * 24) / 160; + } + else if (mvolts > 2440) + { + battery_level = 18 - ((2740 - mvolts) * 12) / 300; + } + else if (mvolts > 2100) + { + battery_level = 6 - ((2440 - mvolts) * 6) / 340; + } + else + { + battery_level = 0; + } + + return battery_level; +} + +/**@brief Function for checking if a pointer value is aligned to a 4 byte boundary. + * + * @param[in] p Pointer value to be checked. + * + * @return TRUE if pointer is aligned to a 4 byte boundary, FALSE otherwise. + */ +static __INLINE bool is_word_aligned(void const* p) +{ + return (((uintptr_t)p & 0x03) == 0); +} + +/*lint -e{568, 685} */ +/** + * @brief Function for checking if provided address is located in stack space. + * + * @param[in] ptr Pointer to be checked. + * + * @return true if address is in stack space, false otherwise. + */ +static __INLINE bool is_address_from_stack(void * ptr) +{ + if (((uint32_t)ptr >= (uint32_t)STACK_BASE) && + ((uint32_t)ptr < (uint32_t)STACK_TOP) ) + { + return true; + } + else + { + return false; + } +} + +#ifdef __cplusplus +} +#endif + +#endif // APP_UTIL_H__ + +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h new file mode 100644 index 000000000..4381d7031 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h @@ -0,0 +1,278 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/**@file + * + * @defgroup app_util_platform Utility Functions and Definitions (Platform) + * @{ + * @ingroup app_common + * + * @brief Various types and definitions available to all applications when using SoftDevice. + */ + +#ifndef APP_UTIL_PLATFORM_H__ +#define APP_UTIL_PLATFORM_H__ + +#include +#include "compiler_abstraction.h" +#include "nrf.h" +#ifdef SOFTDEVICE_PRESENT +#include "nrf_soc.h" +#include "nrf_nvic.h" +#endif +#include "nrf_assert.h" +#include "app_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if __CORTEX_M == (0x00U) +#define _PRIO_SD_HIGH 0 +#define _PRIO_APP_HIGH 1 +#define _PRIO_APP_MID 1 +#define _PRIO_SD_LOW 2 +#define _PRIO_APP_LOW_MID 3 +#define _PRIO_APP_LOW 3 +#define _PRIO_APP_LOWEST 3 +#define _PRIO_THREAD 4 +#elif __CORTEX_M >= (0x04U) +#define _PRIO_SD_HIGH 0 +#define _PRIO_SD_MID 1 +#define _PRIO_APP_HIGH 2 +#define _PRIO_APP_MID 3 +#define _PRIO_SD_LOW 4 +#define _PRIO_APP_LOW_MID 5 +#define _PRIO_APP_LOW 6 +#define _PRIO_APP_LOWEST 7 +#define _PRIO_THREAD 15 +#else + #error "No platform defined" +#endif + + +//lint -save -e113 -e452 +/**@brief The interrupt priorities available to the application while the SoftDevice is active. */ +typedef enum +{ +#ifndef SOFTDEVICE_PRESENT + APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH, /**< Running in Application Highest interrupt level. */ +#else + APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH, /**< Running in Application Highest interrupt level. */ +#endif + APP_IRQ_PRIORITY_HIGH = _PRIO_APP_HIGH, /**< Running in Application High interrupt level. */ +#ifndef SOFTDEVICE_PRESENT + APP_IRQ_PRIORITY_MID = _PRIO_SD_LOW, /**< Running in Application Middle interrupt level. */ +#else + APP_IRQ_PRIORITY_MID = _PRIO_APP_MID, /**< Running in Application Middle interrupt level. */ +#endif + APP_IRQ_PRIORITY_LOW_MID = _PRIO_APP_LOW_MID, /**< Running in Application Middle Low interrupt level. */ + APP_IRQ_PRIORITY_LOW = _PRIO_APP_LOW, /**< Running in Application Low interrupt level. */ + APP_IRQ_PRIORITY_LOWEST = _PRIO_APP_LOWEST, /**< Running in Application Lowest interrupt level. */ + APP_IRQ_PRIORITY_THREAD = _PRIO_THREAD /**< Running in Thread Mode. */ +} app_irq_priority_t; +//lint -restore + + +/*@brief The privilege levels available to applications in Thread Mode */ +typedef enum +{ + APP_LEVEL_UNPRIVILEGED, + APP_LEVEL_PRIVILEGED +} app_level_t; + +/**@cond NO_DOXYGEN */ +#define EXTERNAL_INT_VECTOR_OFFSET 16 +/**@endcond */ + +/**@brief Macro for setting a breakpoint. + */ +#if defined(__GNUC__) +#define NRF_BREAKPOINT __asm__("BKPT 0"); +#else +#define NRF_BREAKPOINT __BKPT(0) +#endif + +/** @brief Macro for setting a breakpoint. + * + * If it is possible to detect debugger presence then it is set only in that case. + * + */ +#if __CORTEX_M == 0x04 +#define NRF_BREAKPOINT_COND do { \ + /* C_DEBUGEN == 1 -> Debugger Connected */ \ + if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) \ + { \ + /* Generate breakpoint if debugger is connected */ \ + NRF_BREAKPOINT; \ + } \ + }while (0) +#else +#define NRF_BREAKPOINT_COND NRF_BREAKPOINT +#endif // __CORTEX_M == 0x04 + +#if defined ( __CC_ARM ) +#define PACKED(TYPE) __packed TYPE +#define PACKED_STRUCT PACKED(struct) +#elif defined ( __GNUC__ ) +#define PACKED __attribute__((packed)) +#define PACKED_STRUCT struct PACKED +#elif defined (__ICCARM__) +#define PACKED_STRUCT __packed struct +#endif + +#if defined ( __CC_ARM ) +#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma ("push") \ + _Pragma ("O3") +#define PRAGMA_OPTIMIZATION_FORCE_END _Pragma ("pop") +#elif defined ( __GNUC__ ) +#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma("GCC push_options") \ + _Pragma ("GCC optimize (\"Os\")") +#define PRAGMA_OPTIMIZATION_FORCE_END _Pragma ("GCC pop_options") +#elif defined (__ICCARM__) +#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma ("optimize=high z") +#define PRAGMA_OPTIMIZATION_FORCE_END +#endif + + +void app_util_critical_region_enter (uint8_t *p_nested); +void app_util_critical_region_exit (uint8_t nested); + +/**@brief Macro for entering a critical region. + * + * @note Due to implementation details, there must exist one and only one call to + * CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located + * in the same scope. + */ +#ifdef SOFTDEVICE_PRESENT +#define CRITICAL_REGION_ENTER() \ + { \ + uint8_t __CR_NESTED = 0; \ + app_util_critical_region_enter(&__CR_NESTED); +#else +#define CRITICAL_REGION_ENTER() app_util_critical_region_enter(NULL) +#endif + +/**@brief Macro for leaving a critical region. + * + * @note Due to implementation details, there must exist one and only one call to + * CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located + * in the same scope. + */ +#ifdef SOFTDEVICE_PRESENT +#define CRITICAL_REGION_EXIT() \ + app_util_critical_region_exit(__CR_NESTED); \ + } +#else +#define CRITICAL_REGION_EXIT() app_util_critical_region_exit(0) +#endif + +/* Workaround for Keil 4 */ +#ifndef IPSR_ISR_Msk +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ +#endif + + + +/**@brief Macro to enable anonymous unions from a certain point in the code. + */ +#if defined(__CC_ARM) + #define ANON_UNIONS_ENABLE _Pragma("push") \ + _Pragma("anon_unions") \ + struct semicolon_swallower +#elif defined(__ICCARM__) + #define ANON_UNIONS_ENABLE _Pragma("language=extended") \ + struct semicolon_swallower +#else + #define ANON_UNIONS_ENABLE struct semicolon_swallower + // No action will be taken. + // For GCC anonymous unions are enabled by default. +#endif + +/**@brief Macro to disable anonymous unions from a certain point in the code. + * @note Call only after first calling @ref ANON_UNIONS_ENABLE. + */ +#if defined(__CC_ARM) + #define ANON_UNIONS_DISABLE _Pragma("pop") \ + struct semicolon_swallower +#elif defined(__ICCARM__) + #define ANON_UNIONS_DISABLE struct semicolon_swallower + // for IAR leave anonymous unions enabled +#else + #define ANON_UNIONS_DISABLE struct semicolon_swallower + // No action will be taken. + // For GCC anonymous unions are enabled by default. +#endif + +/**@brief Macro for adding pragma directive only for GCC. + */ +#ifdef __GNUC__ +#define GCC_PRAGMA(v) _Pragma(v) +#else +#define GCC_PRAGMA(v) +#endif + +/* Workaround for Keil 4 */ +#ifndef CONTROL_nPRIV_Msk +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ +#endif + +/**@brief Function for finding the current interrupt level. + * + * @return Current interrupt level. See @ref app_irq_priority_t for values. + */ +uint8_t current_int_priority_get(void); + + +/**@brief Function for finding out the current privilege level. + * + * @return Current privilege level. + * @retval APP_LEVEL_UNPRIVILEGED We are running in unprivileged level. + * @retval APP_LEVEL_PRIVILEGED We are running in privileged level. + */ +uint8_t privilege_level_get(void); + + +#ifdef __cplusplus +} +#endif + +#endif // APP_UTIL_PLATFORM_H__ + +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/nordic_common.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/nordic_common.h new file mode 100644 index 000000000..e50c4cac2 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/nordic_common.h @@ -0,0 +1,215 @@ +/** + * Copyright (c) 2008 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** @file + * @brief Common defines and macros for firmware developed by Nordic Semiconductor. + */ + +#ifndef NORDIC_COMMON_H__ +#define NORDIC_COMMON_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Check if selected module is enabled + * + * This is save function for driver enable checking. + * Correct from Lint point of view (not using default of undefined value). + * + * Usage: + * @code + #if NRF_MODULE_ENABLED(UART) + ... + #endif + * @endcode + * + * @param module The module name. + * + * @retval 1 The macro _ENABLE is defined and is non-zero. + * @retval 0 The macro _ENABLE is not defined or it equals zero. + * + * @note + * This macro intentionally does not implement second expansion level. + * The name of the module to be checked has to be given directly as a parameter. + * And given parameter would be connected with @c _ENABLED postfix directly + * without evaluating its value. + */ +//lint -emacro(491,NRF_MODULE_ENABLED) // Suppers warning 491 "non-standard use of 'defined' preprocessor operator" +#ifdef NRF_MODULE_ENABLE_ALL +#warning "Do not use NRF_MODULE_ENABLE_ALL for real builds." +#define NRF_MODULE_ENABLED(module) 1 +#else +#define NRF_MODULE_ENABLED(module) \ + ((defined(module ## _ENABLED) && (module ## _ENABLED)) ? 1 : 0) +#endif +/** The upper 8 bits of a 32 bit value */ +//lint -emacro(572,MSB_32) // Suppress warning 572 "Excessive shift value" +#define MSB_32(a) (((a) & 0xFF000000) >> 24) +/** The lower 8 bits (of a 32 bit value) */ +#define LSB_32(a) ((a) & 0x000000FF) + +/** The upper 8 bits of a 16 bit value */ +//lint -emacro(572,MSB_16) // Suppress warning 572 "Excessive shift value" +#define MSB_16(a) (((a) & 0xFF00) >> 8) +/** The lower 8 bits (of a 16 bit value) */ +#define LSB_16(a) ((a) & 0x00FF) + +/** Leaves the minimum of the two 32-bit arguments */ +/*lint -emacro(506, MIN) */ /* Suppress "Constant value Boolean */ +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +/** Leaves the maximum of the two 32-bit arguments */ +/*lint -emacro(506, MAX) */ /* Suppress "Constant value Boolean */ +#define MAX(a, b) ((a) < (b) ? (b) : (a)) + +/**@brief Concatenates two parameters. + * + * It realizes two level expansion to make it sure that all the parameters + * are actually expanded before gluing them together. + * + * @param p1 First parameter to concatenating + * @param p2 Second parameter to concatenating + * + * @return Two parameters glued together. + * They have to create correct C mnemonic in other case + * preprocessor error would be generated. + * + * @sa CONCAT_3 + */ +#define CONCAT_2(p1, p2) CONCAT_2_(p1, p2) +/** Auxiliary macro used by @ref CONCAT_2 */ +#define CONCAT_2_(p1, p2) p1##p2 + +/**@brief Concatenates three parameters. + * + * It realizes two level expansion to make it sure that all the parameters + * are actually expanded before gluing them together. + * + * @param p1 First parameter to concatenating + * @param p2 Second parameter to concatenating + * @param p3 Third parameter to concatenating + * + * @return Three parameters glued together. + * They have to create correct C mnemonic in other case + * preprocessor error would be generated. + * + * @sa CONCAT_2 + */ +#define CONCAT_3(p1, p2, p3) CONCAT_3_(p1, p2, p3) +/** Auxiliary macro used by @ref CONCAT_3 */ +#define CONCAT_3_(p1, p2, p3) p1##p2##p3 + +#define STRINGIFY_(val) #val +/** Converts a macro argument into a character constant. + */ +#define STRINGIFY(val) STRINGIFY_(val) + +/** Counts number of elements inside the array + */ +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +/**@brief Set a bit in the uint32 word. + * + * @param[in] W Word whose bit is being set. + * @param[in] B Bit number in the word to be set. + */ +#define SET_BIT(W, B) ((W) |= (uint32_t)(1U << (B))) + + +/**@brief Clears a bit in the uint32 word. + * + * @param[in] W Word whose bit is to be cleared. + * @param[in] B Bit number in the word to be cleared. + */ +#define CLR_BIT(W, B) ((W) &= (~(uint32_t)(1U << (B)))) + + +/**@brief Checks if a bit is set. + * + * @param[in] W Word whose bit is to be checked. + * @param[in] B Bit number in the word to be checked. + * + * @retval 1 if bit is set. + * @retval 0 if bit is not set. + */ +#define IS_SET(W, B) (((W) >> (B)) & 1) + +#define BIT_0 0x01 /**< The value of bit 0 */ +#define BIT_1 0x02 /**< The value of bit 1 */ +#define BIT_2 0x04 /**< The value of bit 2 */ +#define BIT_3 0x08 /**< The value of bit 3 */ +#define BIT_4 0x10 /**< The value of bit 4 */ +#define BIT_5 0x20 /**< The value of bit 5 */ +#define BIT_6 0x40 /**< The value of bit 6 */ +#define BIT_7 0x80 /**< The value of bit 7 */ +#define BIT_8 0x0100 /**< The value of bit 8 */ +#define BIT_9 0x0200 /**< The value of bit 9 */ +#define BIT_10 0x0400 /**< The value of bit 10 */ +#define BIT_11 0x0800 /**< The value of bit 11 */ +#define BIT_12 0x1000 /**< The value of bit 12 */ +#define BIT_13 0x2000 /**< The value of bit 13 */ +#define BIT_14 0x4000 /**< The value of bit 14 */ +#define BIT_15 0x8000 /**< The value of bit 15 */ +#define BIT_16 0x00010000 /**< The value of bit 16 */ +#define BIT_17 0x00020000 /**< The value of bit 17 */ +#define BIT_18 0x00040000 /**< The value of bit 18 */ +#define BIT_19 0x00080000 /**< The value of bit 19 */ +#define BIT_20 0x00100000 /**< The value of bit 20 */ +#define BIT_21 0x00200000 /**< The value of bit 21 */ +#define BIT_22 0x00400000 /**< The value of bit 22 */ +#define BIT_23 0x00800000 /**< The value of bit 23 */ +#define BIT_24 0x01000000 /**< The value of bit 24 */ +#define BIT_25 0x02000000 /**< The value of bit 25 */ +#define BIT_26 0x04000000 /**< The value of bit 26 */ +#define BIT_27 0x08000000 /**< The value of bit 27 */ +#define BIT_28 0x10000000 /**< The value of bit 28 */ +#define BIT_29 0x20000000 /**< The value of bit 29 */ +#define BIT_30 0x40000000 /**< The value of bit 30 */ +#define BIT_31 0x80000000 /**< The value of bit 31 */ + +#define UNUSED_VARIABLE(X) ((void)(X)) +#define UNUSED_PARAMETER(X) UNUSED_VARIABLE(X) +#define UNUSED_RETURN_VALUE(X) UNUSED_VARIABLE(X) + +#ifdef __cplusplus +} +#endif + +#endif // NORDIC_COMMON_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/nrf_assert.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/nrf_assert.h new file mode 100644 index 000000000..f0ecfc719 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/nrf_assert.h @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2006 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** @file + * @brief Utilities for verifying program logic + */ + +#ifndef NRF_ASSERT_H_ +#define NRF_ASSERT_H_ + +#include +#include "nrf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Function for handling assertions. + * + * + * @note + * This function is called when an assertion has triggered. + * + * @note + * This function is deprecated and will be removed in future releases. + * Use app_error_fault_handler instead. + * + * + * @post + * All hardware is put into an idle non-emitting state (in particular the radio is highly + * important to switch off since the radio might be in a state that makes it send + * packets continiously while a typical final infinit ASSERT loop is executing). + * + * + * @param line_num The line number where the assertion is called + * @param file_name Pointer to the file name + */ +//lint -save -esym(14, assert_nrf_callback) +void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); +//lint -restore + +#if (defined(DEBUG_NRF) || defined(DEBUG_NRF_USER)) +#define NRF_ASSERT_PRESENT 1 +#else +#define NRF_ASSERT_PRESENT 0 +#endif + +//#if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) + +/*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ +/*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \ + +/** @brief Function for checking intended for production code. + * + * Check passes if "expr" evaluates to true. */ + +#ifdef _lint +#define ASSERT(expr) \ +if (expr) \ +{ \ +} \ +else \ +{ \ + while (1); \ +} +#else //_lint +#define ASSERT(expr) \ +if (NRF_ASSERT_PRESENT) \ +{ \ + if (expr) \ + { \ + } \ + else \ + { \ + assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \ + } \ +} + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_ASSERT_H_ */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h new file mode 100644 index 000000000..84ed1a4d3 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** @cond */ +/**@file + * + * @ingroup experimental_api + * @defgroup sdk_common SDK Common Header + * @brief All common headers needed for SDK examples will be included here so that application + * developer does not have to include headers on him/herself. + * @{ + */ + +#ifndef SDK_COMMON_H__ +#define SDK_COMMON_H__ + +#include +#include +#include +#include "sdk_config.h" +#include "nordic_common.h" +#include "compiler_abstraction.h" +#include "sdk_os.h" +#include "sdk_errors.h" +#include "app_util.h" +#include "sdk_macros.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @} */ +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif // SDK_COMMON_H__ + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_errors.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_errors.h new file mode 100644 index 000000000..329fad5cf --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_errors.h @@ -0,0 +1,168 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/**@file + * + * @defgroup sdk_error SDK Error codes + * @{ + * @ingroup app_common + * @{ + * @details Error codes are 32-bit unsigned integers with the most significant 16-bit reserved for + * identifying the module where the error occurred while the least least significant LSB + * are used to provide the cause or nature of error. Each module is assigned a 16-bit + * unsigned integer. Which it will use to identify all errors that occurred in it. 16-bit + * LSB range is with module id as the MSB in the 32-bit error code is reserved for the + * module. As an example, if 0x8800 identifies a certain SDK module, all values from + * 0x88000000 - 0x8800FFFF are reserved for this module. + * It should be noted that common error reasons have been assigned values to make it + * possible to decode error reason easily. As an example, lets module uninitialized has + * been assigned an error code 0x000A0. Then, if application encounters an error code + * 0xZZZZ00A0, it knows that it accessing a certain module without initializing it. + * Apart from this, each module is allowed to define error codes that are not covered by + * the common ones, however, these values are defined in a range that does not conflict + * with common error values. For module, specific error however, it is possible that the + * same error value is used by two different modules to indicated errors of very different + * nature. If error is already defined by the NRF common error codes, these are reused. + * A range is reserved for application as well, it can use this range for defining + * application specific errors. + * + * @note Success code, NRF_SUCCESS, does not include any module identifier. + + */ + +#ifndef SDK_ERRORS_H__ +#define SDK_ERRORS_H__ + +#include +#include "nrf_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup sdk_err_base Base defined for SDK Modules + * @{ + */ +#define NRF_ERROR_SDK_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x8000) /**< Base value defined for SDK module identifiers. */ +#define NRF_ERROR_SDK_COMMON_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x0080) /**< Base error value to be used for SDK error values. */ +/** @} */ + +/** + * @defgroup sdk_module_codes Codes reserved as identification for module where the error occurred. + * @{ + */ +#define NRF_ERROR_MEMORY_MANAGER_ERR_BASE (0x8100) /**< Base address for Memory Manager related errors. */ +#define NRF_ERROR_PERIPH_DRIVERS_ERR_BASE (0x8200) /**< Base address for Peripheral drivers related errors. */ +#define NRF_ERROR_GAZELLE_ERR_BASE (0x8300) /**< Base address for Gazelle related errors. */ +#define NRF_ERROR_BLE_IPSP_ERR_BASE (0x8400) /**< Base address for BLE IPSP related errors. */ +#define NRF_ERROR_CRYPTO_ERR_BASE (0x8500) /**< Base address for crypto related errors. */ +#define NRF_ERROR_FDS_ERR_BASE (0x8600) /**< Base address for FDS related errors. */ +/** @} */ + + +/** + * @defgroup sdk_iot_errors Codes reserved as identification for IoT errors. + * @{ + */ +#define NRF_ERROR_IOT_ERR_BASE_START (0xA000) +#define NRF_ERROR_IOT_ERR_BASE_STOP (0xAFFF) +/** @} */ + + +/** + * @defgroup sdk_common_errors Codes reserved as identification for common errors. + * @{ + */ +#define NRF_ERROR_MODULE_NOT_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0000) ///< Module not initialized +#define NRF_ERROR_MUTEX_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0001) ///< Mutex initialization failed +#define NRF_ERROR_MUTEX_LOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0002) ///< Mutex lock failed +#define NRF_ERROR_MUTEX_UNLOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0003) ///< Mutex unlock failed +#define NRF_ERROR_MUTEX_COND_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0004) ///< Mutex conditional initialization failed +#define NRF_ERROR_MODULE_ALREADY_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0005) ///< Module already initialized +#define NRF_ERROR_STORAGE_FULL (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0006) ///< Storage full +#define NRF_ERROR_API_NOT_IMPLEMENTED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0010) ///< API not implemented +#define NRF_ERROR_FEATURE_NOT_ENABLED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0011) ///< Feature not enabled +#define NRF_ERROR_IO_PENDING (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0012) ///< Input/Output pending +/** @} */ + + +/** + * @defgroup drv_specific_errors Error / status codes specific to drivers. + * @{ + */ +#define NRF_ERROR_DRV_TWI_ERR_OVERRUN (NRF_ERROR_PERIPH_DRIVERS_ERR_BASE + 0x0000) +#define NRF_ERROR_DRV_TWI_ERR_ANACK (NRF_ERROR_PERIPH_DRIVERS_ERR_BASE + 0x0001) +#define NRF_ERROR_DRV_TWI_ERR_DNACK (NRF_ERROR_PERIPH_DRIVERS_ERR_BASE + 0x0002) +/** @} */ + + +/** + * @defgroup ble_ipsp_errors IPSP codes + * @brief Error and status codes specific to IPSP. + * @{ + */ +#define NRF_ERROR_BLE_IPSP_RX_PKT_TRUNCATED (NRF_ERROR_BLE_IPSP_ERR_BASE + 0x0000) +#define NRF_ERROR_BLE_IPSP_CHANNEL_ALREADY_EXISTS (NRF_ERROR_BLE_IPSP_ERR_BASE + 0x0001) +#define NRF_ERROR_BLE_IPSP_LINK_DISCONNECTED (NRF_ERROR_BLE_IPSP_ERR_BASE + 0x0002) +#define NRF_ERROR_BLE_IPSP_PEER_REJECTED (NRF_ERROR_BLE_IPSP_ERR_BASE + 0x0003) +/* @} */ + + +/** + * @brief API Result. + * + * @details Indicates success or failure of an API procedure. In case of failure, a comprehensive + * error code indicating cause or reason for failure is provided. + * + * Though called an API result, it could used in Asynchronous notifications callback along + * with asynchronous callback as event result. This mechanism is employed when an event + * marks the end of procedure initiated using API. API result, in this case, will only be + * an indicative of whether the procedure has been requested successfully. + */ +typedef uint32_t ret_code_t; + +/** @} */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif // SDK_ERRORS_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble.c new file mode 100644 index 000000000..aad7dea19 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble.c @@ -0,0 +1,626 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble.h" +#include "ble_serialization.h" +#include +#include "ble_app.h" +#include "ser_sd_transport.h" +#include "app_error.h" +#include "app_ble_user_mem.h" +#include "app_ble_gap_sec_keys.h" + +extern ser_ble_user_mem_t m_app_user_mem_table[]; + +/**@brief Structure containing @ref sd_ble_uuid_encode output parameters. */ +typedef struct +{ + uint8_t * p_uuid_le_len; /**< @ref sd_ble_uuid_encode appearance p_uuid_le_len output parameter. */ + uint8_t * p_uuid_le; /**< @ref sd_ble_uuid_encode appearance p_uuid_le output parameter. */ +} ble_uuid_encode_out_params_t; + +/**@brief Structure containing @ref sd_ble_user_mem_reply output parameters. */ +typedef struct +{ + uint16_t conn_handle; /**< @ref sd_ble_user_mem_reply conn_handle. */ + uint8_t context_allocated; /**< @ref sd_ble_user_mem_reply user memory context allocated flag. */ +} ble_user_mem_reply_out_params_t; + +/**@brief Union containing BLE command output parameters. */ +typedef union +{ + ble_uuid_encode_out_params_t ble_uuid_encode_out_params; /**< @ref sd_ble_uuid_encode output parameters. */ + ble_user_mem_reply_out_params_t ble_user_mem_reply_out_params; /**< @ref sd_ble_user_mem_reply output parameters. */ +} ble_command_output_params_t; + +static ble_command_output_params_t m_output_params; /**< BLE command output parameters. */ + +static void * mp_out_params[3]; +static uint32_t m_uint32_param; + +static void tx_buf_alloc(uint8_t * * p_data, uint32_t * p_len) +{ + uint32_t err_code; + uint16_t len16; + + do + { + err_code = ser_sd_transport_tx_alloc(p_data, &len16); + } + while (err_code != NRF_SUCCESS); + + *p_data[0] = SER_PKT_TYPE_CMD; + *p_len = (uint32_t)len16 - 1; +} + +/**@brief Command response callback function for @ref sd_ble_uuid_encode BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t uuid_encode_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_uuid_encode_rsp_dec(p_buffer, + length, + m_output_params.ble_uuid_encode_out_params.p_uuid_le_len, + m_output_params.ble_uuid_encode_out_params.p_uuid_le, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_uuid_encode +#define _sd_ble_uuid_encode sd_ble_uuid_encode +#endif +uint32_t _sd_ble_uuid_encode(ble_uuid_t const * const p_uuid, + uint8_t * const p_uuid_le_len, + uint8_t * const p_uuid_le) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + tx_buf_alloc(&p_buffer, &buffer_length); + + m_output_params.ble_uuid_encode_out_params.p_uuid_le_len = p_uuid_le_len; + m_output_params.ble_uuid_encode_out_params.p_uuid_le = p_uuid_le; + + uint32_t err_code = ble_uuid_encode_req_enc(p_uuid, + p_uuid_le_len, + p_uuid_le, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + uuid_encode_rsp_dec); + +} + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +/**@brief Command response callback function for @ref sd_ble_tx_packet_count_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t tx_packet_count_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_tx_packet_count_get_rsp_dec(p_buffer, + length, + (uint8_t * *)&mp_out_params[0], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_tx_packet_count_get +#define _sd_ble_tx_packet_count_get sd_ble_tx_packet_count_get +#endif +uint32_t _sd_ble_tx_packet_count_get(uint16_t conn_handle, uint8_t * p_count) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + tx_buf_alloc(&p_buffer, &buffer_length); + mp_out_params[0] = p_count; + + const uint32_t err_code = ble_tx_packet_count_get_req_enc(conn_handle, + p_count, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + tx_packet_count_get_rsp_dec); + +} +#endif +/**@brief Command response callback function for @ref sd_ble_uuid_vs_add BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t uuid_vs_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_uuid_vs_add_rsp_dec(p_buffer, + length, + (uint8_t * *)&mp_out_params[0], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_uuid_vs_add +#define _sd_ble_uuid_vs_add sd_ble_uuid_vs_add +#endif +uint32_t _sd_ble_uuid_vs_add(ble_uuid128_t const * const p_vs_uuid, uint8_t * const p_uuid_type) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + tx_buf_alloc(&p_buffer, &buffer_length); + mp_out_params[0] = p_uuid_type; + + const uint32_t err_code = ble_uuid_vs_add_req_enc(p_vs_uuid, p_uuid_type, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + uuid_vs_add_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_uuid_decode BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t uuid_decode_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_uuid_decode_rsp_dec(p_buffer, + length, + (ble_uuid_t * *)&mp_out_params[0], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_uuid_decode +#define _sd_ble_uuid_decode sd_ble_uuid_decode +#endif +uint32_t _sd_ble_uuid_decode(uint8_t uuid_le_len, + uint8_t const * const p_uuid_le, + ble_uuid_t * const p_uuid) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + tx_buf_alloc(&p_buffer, &buffer_length); + mp_out_params[0] = p_uuid; + + const uint32_t err_code = ble_uuid_decode_req_enc(uuid_le_len, p_uuid_le, p_uuid, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + uuid_decode_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_version_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t version_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_version_get_rsp_dec(p_buffer, + length, + (ble_version_t *)mp_out_params[0], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_version_get +#define _sd_ble_version_get sd_ble_version_get +#endif +uint32_t _sd_ble_version_get(ble_version_t * p_version) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + tx_buf_alloc(&p_buffer, &buffer_length); + mp_out_params[0] = p_version; + + const uint32_t err_code = ble_version_get_req_enc(p_version, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + version_get_rsp_dec); + +} + +/**@brief Command response callback function for @ref sd_ble_opt_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t opt_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + uint32_t uint32_param; + uint32_t err_code = ble_opt_get_rsp_dec(p_buffer, + length, + &uint32_param, + (ble_opt_t *)mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + if ((result_code == NRF_SUCCESS) && (m_uint32_param != uint32_param)) // decoded id should be the same as encoded one + { + err_code = NRF_ERROR_INVALID_PARAM; + } + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_opt_get +#define _sd_ble_opt_get sd_ble_opt_get +#endif +uint32_t _sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + tx_buf_alloc(&p_buffer, &buffer_length); + mp_out_params[0] = p_opt; + m_uint32_param = opt_id; + + const uint32_t err_code = ble_opt_get_req_enc(opt_id, + p_opt, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + opt_get_rsp_dec); + +} + +/**@brief Command response callback function for @ref sd_ble_opt_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t opt_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_opt_set_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_opt_set +#define _sd_ble_opt_set sd_ble_opt_set +#endif +uint32_t _sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + tx_buf_alloc(&p_buffer, &buffer_length); + + const uint32_t err_code = ble_opt_set_req_enc(opt_id, + p_opt, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + opt_set_rsp_dec); + +} + +/**@brief Command response callback function for @ref sd_ble_enable BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t enable_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_enable_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_enable +#define _sd_ble_enable sd_ble_enable +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t _sd_ble_enable(ble_enable_params_t * p_params, uint32_t * p_app_ram_base) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + //Ignore ram_base parameter + (void)p_app_ram_base; + + app_ble_gap_sec_keys_init(); + + tx_buf_alloc(&p_buffer, &buffer_length); + mp_out_params[0] = p_params; + + const uint32_t err_code = ble_enable_req_enc(p_params, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + enable_rsp_dec); + +} +#else +uint32_t _sd_ble_enable(uint32_t * p_app_ram_base) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + //Ignore ram_base parameter + (void)p_app_ram_base; + + app_ble_gap_sec_keys_init(); + + tx_buf_alloc(&p_buffer, &buffer_length); + + const uint32_t err_code = ble_enable_req_enc(&(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + enable_rsp_dec); + +} +#endif +/**@brief Command response callback function for @ref sd_ble_user_mem_reply BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t user_mem_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + uint32_t err_code = ble_user_mem_reply_rsp_dec(p_buffer, + length, + &result_code); + APP_ERROR_CHECK(err_code); + + if ((result_code != NRF_SUCCESS) && + (m_output_params.ble_user_mem_reply_out_params.context_allocated)) + { + err_code = app_ble_user_mem_context_destroy( + m_output_params.ble_user_mem_reply_out_params.conn_handle); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + } + + return result_code; +} + +#ifndef _sd_ble_user_mem_reply +#define _sd_ble_user_mem_reply sd_ble_user_mem_reply +#endif +uint32_t _sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block) +{ + uint8_t * p_buffer; + uint32_t buffer_length, user_mem_table_index; + uint32_t err_code = NRF_SUCCESS; + + tx_buf_alloc(&p_buffer, &buffer_length); + + // Prepare User Memory Block context for later synchronization when SoftDevice updates + // the data in the memory block + if (p_block != NULL) + { + err_code = app_ble_user_mem_context_create(conn_handle, &user_mem_table_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + m_app_user_mem_table[user_mem_table_index].mem_block.len = p_block->len; + m_app_user_mem_table[user_mem_table_index].mem_block.p_mem = p_block->p_mem; + // Save connection handle and context allocation flag for case if context destroy was needed + m_output_params.ble_user_mem_reply_out_params.conn_handle = conn_handle; + m_output_params.ble_user_mem_reply_out_params.context_allocated = 1; + } + else + { + m_output_params.ble_user_mem_reply_out_params.context_allocated = 0; + } + + err_code = ble_user_mem_reply_req_enc(conn_handle, + p_block, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + user_mem_reply_rsp_dec); +} +#if NRF_SD_BLE_API_VERSION >= 4 +/**@brief Command response callback function for @ref sd_ble_cfg_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t cfg_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_cfg_set_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_cfg_set +#define _sd_ble_cfg_set sd_ble_cfg_set +#endif +uint32_t _sd_ble_cfg_set(uint32_t cfg_id, ble_cfg_t const * p_cfg, uint32_t app_ram_base) +{ + uint8_t * p_buffer; + uint32_t buffer_length; + + //Ignore ram_base parameter + (void)app_ram_base; + + tx_buf_alloc(&p_buffer, &buffer_length); + + const uint32_t err_code = ble_cfg_set_req_enc(cfg_id, p_cfg, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + cfg_set_rsp_dec); +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gap.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gap.c new file mode 100644 index 000000000..59deb0cc7 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gap.c @@ -0,0 +1,2043 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gap.h" +#include +#include +#include "ble_serialization.h" +#include "ser_sd_transport.h" +#include "ble_gap_app.h" +#include "app_error.h" +#include "app_ble_gap_sec_keys.h" +#include "ser_config.h" + +extern ser_ble_gap_app_keyset_t m_app_keys_table[SER_MAX_CONNECTIONS]; + +/**@brief Structure containing @ref sd_ble_gap_device_name_get output parameters. */ +typedef struct +{ + uint8_t * p_dev_name; /**< @ref sd_ble_gap_device_name_get p_dev_name output parameter. */ + uint16_t * p_len; /**< @ref sd_ble_gap_device_name_get p_len output parameter. */ +} gap_device_name_get_output_params_t; + +/**@brief Structure containing @ref sd_ble_gap_appearance_get output parameters. */ +typedef struct +{ + uint16_t * p_appearance; /**< @ref sd_ble_gap_appearance_get p_appearance output parameter. */ +} gap_appearance_get_output_params_t; + +/**@brief Structure containing @ref sd_ble_gap_ppcp_get output parameters. */ +typedef struct +{ + ble_gap_conn_params_t * p_conn_params; /**< @ref sd_ble_gap_ppcp_get p_conn_params output parameter. */ +} gap_ppcp_get_out_params_t; + +/**@brief Structure containing @ref sd_ble_gap_sec_params_reply output parameters. */ +typedef struct +{ + ble_gap_sec_keyset_t const * p_sec_keyset; /**< @ref sd_ble_gap_sec_params_reply p_sec_keyset output parameter. */ + uint16_t conn_handle; /**< @ref sd_ble_gap_sec_params_reply p_conn_handle output parameter. */ +} gap_sec_params_reply_out_params_t; + +/**@brief Union containing BLE command output parameters. */ +typedef union +{ + gap_device_name_get_output_params_t gap_device_name_get_out_params; /**< @ref sd_ble_gap_device_name_get output parameters. */ + gap_appearance_get_output_params_t gap_appearance_get_out_params; /**< @ref sd_ble_gap_appearance_get output parameters. */ + gap_ppcp_get_out_params_t gap_ppcp_get_out_params; /**< @ref sd_ble_gap_ppcp_get output parameters. */ + gap_sec_params_reply_out_params_t gap_sec_params_reply_out_params;/**< @ref sd_ble_sec_params_reply output parameters. */ +} gap_command_output_params_t; + +static gap_command_output_params_t m_output_params; /**< BLE command output parameters. */ + +static void * mp_out_params[3]; + +static void tx_buf_alloc(uint8_t * * p_data, uint16_t * p_len) +{ + uint32_t err_code; + + do + { + err_code = ser_sd_transport_tx_alloc(p_data, p_len); + } + while (err_code != NRF_SUCCESS); + *p_data[0] = SER_PKT_TYPE_CMD; + *p_len -= 1; +} + +/**@brief Command response callback function for @ref sd_ble_gap_adv_start BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_adv_start_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gap_adv_start_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_adv_start +#define _sd_ble_gap_adv_start sd_ble_gap_adv_start +#endif +uint32_t _sd_ble_gap_adv_start( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t adv_handle +#else + ble_gap_adv_params_t const * const p_adv_params +#endif +#if NRF_SD_BLE_API_VERSION >= 4 + ,uint8_t conn_cfg_tag +#endif +) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gap_adv_start_req_enc( +#if NRF_SD_BLE_API_VERSION > 5 + adv_handle, +#else + p_adv_params, +#endif +#if NRF_SD_BLE_API_VERSION >= 4 + conn_cfg_tag, +#endif + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_adv_start_rsp_dec); +} + +/**@brief Command response callback function for @ref ble_gap_device_name_get_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_device_name_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_gap_device_name_get_rsp_dec(p_buffer, + length, + m_output_params.gap_device_name_get_out_params.p_dev_name, + m_output_params.gap_device_name_get_out_params.p_len, + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_device_name_get +#define _sd_ble_gap_device_name_get sd_ble_gap_device_name_get +#endif +uint32_t _sd_ble_gap_device_name_get(uint8_t * const p_dev_name, uint16_t * const p_len) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + m_output_params.gap_device_name_get_out_params.p_dev_name = p_dev_name; + m_output_params.gap_device_name_get_out_params.p_len = p_len; + + const uint32_t err_code = ble_gap_device_name_get_req_enc(p_dev_name, + p_len, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_device_name_get_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_appearance_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_appearance_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_gap_appearance_get_rsp_dec(p_buffer, + length, + m_output_params.gap_appearance_get_out_params.p_appearance, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_appearance_get +#define _sd_ble_gap_appearance_get sd_ble_gap_appearance_get +#endif +uint32_t _sd_ble_gap_appearance_get(uint16_t * const p_appearance) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + m_output_params.gap_appearance_get_out_params.p_appearance = p_appearance; + + const uint32_t err_code = ble_gap_appearance_get_req_enc(p_appearance, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_appearance_get_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_device_name_set BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_device_name_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gap_device_name_set_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_device_name_set +#define _sd_ble_gap_device_name_set sd_ble_gap_device_name_set +#endif +uint32_t _sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const * const p_write_perm, + uint8_t const * const p_dev_name, + uint16_t len) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_device_name_set_req_enc(p_write_perm, + p_dev_name, + len, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_device_name_set_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_appearance_set BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_appearance_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gap_appearance_set_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_appearance_set +#define _sd_ble_gap_appearance_set sd_ble_gap_appearance_set +#endif +uint32_t _sd_ble_gap_appearance_set(uint16_t appearance) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_appearance_set_req_enc(appearance, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_appearance_set_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_ppcp_set BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_ppcp_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gap_ppcp_set_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + + return result_code; +} + +#ifndef _sd_ble_gap_ppcp_set +#define _sd_ble_gap_ppcp_set sd_ble_gap_ppcp_set +#endif +uint32_t _sd_ble_gap_ppcp_set(ble_gap_conn_params_t const * const p_conn_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_ppcp_set_req_enc(p_conn_params, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_ppcp_set_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_adv_data_set BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +#if NRF_SD_BLE_API_VERSION <= 5 +static uint32_t gap_adv_data_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gap_adv_data_set_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} +#ifndef _sd_ble_gap_adv_data_set +#define _sd_ble_gap_adv_data_set sd_ble_gap_adv_data_set +#endif +uint32_t _sd_ble_gap_adv_data_set(uint8_t const * const p_data, + uint8_t dlen, + uint8_t const * const p_sr_data, + uint8_t srdlen) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_adv_data_set_req_enc(p_data, + dlen, + p_sr_data, + srdlen, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_adv_data_set_rsp_dec); +} +#endif + +/**@brief Command response callback function for @ref sd_ble_gap_conn_param_update BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_conn_param_update_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gap_conn_param_update_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_conn_param_update +#define _sd_ble_gap_conn_param_update sd_ble_gap_conn_param_update +#endif +uint32_t _sd_ble_gap_conn_param_update(uint16_t conn_handle, + ble_gap_conn_params_t const * const p_conn_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_conn_param_update_req_enc(conn_handle, + p_conn_params, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_conn_param_update_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_disconnect BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_disconnect_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gap_disconnect_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_disconnect +#define _sd_ble_gap_disconnect sd_ble_gap_disconnect +#endif +uint32_t _sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_disconnect_req_enc(conn_handle, + hci_status_code, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_disconnect_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_sec_info_reply BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_sec_info_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gap_sec_info_reply_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_sec_info_reply +#define _sd_ble_gap_sec_info_reply sd_ble_gap_sec_info_reply +#endif +uint32_t _sd_ble_gap_sec_info_reply(uint16_t conn_handle, + ble_gap_enc_info_t const * p_enc_info, + ble_gap_irk_t const * p_id_info, + ble_gap_sign_info_t const * p_sign_info) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_sec_info_reply_req_enc(conn_handle, + p_enc_info, + p_id_info, + p_sign_info, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_sec_info_reply_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_sec_params_reply BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_sec_params_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + uint32_t err_code = ble_gap_sec_params_reply_rsp_dec(p_buffer, length, + m_output_params.gap_sec_params_reply_out_params.p_sec_keyset, &result_code); + APP_ERROR_CHECK(err_code); + + // If soft device returned error free security context + if (result_code) + { + err_code = app_ble_gap_sec_context_destroy(m_output_params.gap_sec_params_reply_out_params.conn_handle); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + } + + return result_code; +} + +#ifndef _sd_ble_gap_sec_params_reply +#define _sd_ble_gap_sec_params_reply sd_ble_gap_sec_params_reply +#endif +uint32_t _sd_ble_gap_sec_params_reply(uint16_t conn_handle, + uint8_t sec_status, + ble_gap_sec_params_t const * p_sec_params, + ble_gap_sec_keyset_t const * p_sec_keyset) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + uint32_t sec_tab_index = 0; + uint32_t err_code = NRF_SUCCESS; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + m_output_params.gap_sec_params_reply_out_params.p_sec_keyset = p_sec_keyset; + m_output_params.gap_sec_params_reply_out_params.conn_handle = conn_handle; + + // First allocate security context for serialization + if (p_sec_keyset) + { + err_code = app_ble_gap_sec_context_create(conn_handle, &sec_tab_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + memcpy(&(m_app_keys_table[sec_tab_index].keyset), p_sec_keyset, sizeof(ble_gap_sec_keyset_t)); + } + + err_code = ble_gap_sec_params_reply_req_enc(conn_handle, + sec_status, + p_sec_params, + p_sec_keyset, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_sec_params_reply_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_ppcp_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_ppcp_get_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_ppcp_get_rsp_dec( + p_buffer, + length, + m_output_params.gap_ppcp_get_out_params. + p_conn_params, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_ppcp_get +#define _sd_ble_gap_ppcp_get sd_ble_gap_ppcp_get +#endif +uint32_t _sd_ble_gap_ppcp_get(ble_gap_conn_params_t * const p_conn_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + m_output_params.gap_ppcp_get_out_params.p_conn_params = p_conn_params; + + const uint32_t err_code = ble_gap_ppcp_get_req_enc(p_conn_params, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_ppcp_get_reply_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gap_adv_stop BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_adv_stop_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_adv_stop_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_adv_stop +#define _sd_ble_gap_adv_stop sd_ble_gap_adv_stop +#endif +uint32_t _sd_ble_gap_adv_stop( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t adv_handle +#else + void +#endif + ) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_adv_stop_req_enc( +#if NRF_SD_BLE_API_VERSION > 5 + adv_handle, +#endif + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_adv_stop_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_auth_key_reply BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_auth_key_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_auth_key_reply_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + + +#ifndef _sd_ble_gap_auth_key_reply +#define _sd_ble_gap_auth_key_reply sd_ble_gap_auth_key_reply +#endif +uint32_t _sd_ble_gap_auth_key_reply(uint16_t conn_handle, + uint8_t key_type, + uint8_t const * const key) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_auth_key_reply_req_enc(conn_handle, key_type, key, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_auth_key_reply_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_authenticate BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_authenticate_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_authenticate_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_authenticate +#define _sd_ble_gap_authenticate sd_ble_gap_authenticate +#endif +uint32_t _sd_ble_gap_authenticate(uint16_t conn_handle, + ble_gap_sec_params_t const * const p_sec_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_authenticate_req_enc(conn_handle, p_sec_params, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_authenticate_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_conn_sec_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_conn_sec_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_conn_sec_get_rsp_dec( + p_buffer, + length, + (ble_gap_conn_sec_t * *)&mp_out_params[0 + ], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_conn_sec_get +#define _sd_ble_gap_conn_sec_get sd_ble_gap_conn_sec_get +#endif +uint32_t _sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t * const p_conn_sec) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_conn_sec; + + const uint32_t err_code = ble_gap_conn_sec_get_req_enc(conn_handle, p_conn_sec, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_conn_sec_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_rssi_start BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_rssi_start_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_rssi_start_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_rssi_start +#define _sd_ble_gap_rssi_start sd_ble_gap_rssi_start +#endif +uint32_t _sd_ble_gap_rssi_start(uint16_t conn_handle, uint8_t threshold_dbm, uint8_t skip_count) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_rssi_start_req_enc(conn_handle, + threshold_dbm, + skip_count, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_rssi_start_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_rssi_stop BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_rssi_stop_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_rssi_stop_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_rssi_stop +#define _sd_ble_gap_rssi_stop sd_ble_gap_rssi_stop +#endif +uint32_t _sd_ble_gap_rssi_stop(uint16_t conn_handle) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_rssi_stop_req_enc(conn_handle, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_rssi_stop_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_tx_power_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_tx_power_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_tx_power_set_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_tx_power_set +#define _sd_ble_gap_tx_power_set sd_ble_gap_tx_power_set +#endif +uint32_t _sd_ble_gap_tx_power_set( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t role, uint16_t handle, +#endif + int8_t tx_power) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); +#if NRF_SD_BLE_API_VERSION > 5 + const uint32_t err_code = ble_gap_tx_power_set_req_enc(role, handle, tx_power, + &(p_buffer[1]), &buffer_length); +#else + const uint32_t err_code = ble_gap_tx_power_set_req_enc(tx_power, + &(p_buffer[1]), &buffer_length); +#endif + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_tx_power_set_rsp_dec); +} + +#ifndef S112 +/**@brief Command response callback function for @ref sd_ble_gap_scan_stop BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_scan_stop_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_scan_stop_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_scan_stop +#define _sd_ble_gap_scan_stop sd_ble_gap_scan_stop +#endif +uint32_t _sd_ble_gap_scan_stop(void) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_scan_stop_req_enc(&(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + app_ble_gap_scan_data_unset(true); +#endif + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_scan_stop_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_connect BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_connect_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_connect_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_connect +#define _sd_ble_gap_connect sd_ble_gap_connect +#endif +uint32_t _sd_ble_gap_connect(ble_gap_addr_t const * const p_addr, + ble_gap_scan_params_t const * const p_scan_params, + ble_gap_conn_params_t const * const p_conn_params +#if NRF_SD_BLE_API_VERSION >= 4 + ,uint8_t conn_cfg_tag +#endif + ) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_connect_req_enc(p_addr, + p_scan_params, + p_conn_params, +#if NRF_SD_BLE_API_VERSION >= 4 + conn_cfg_tag, +#endif + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_connect_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_connect_cancel BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_connect_cancel_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_connect_cancel_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_connect_cancel +#define _sd_ble_gap_connect_cancel sd_ble_gap_connect_cancel +#endif +uint32_t _sd_ble_gap_connect_cancel(void) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_connect_cancel_req_enc(&(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_connect_cancel_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_scan_start BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_scan_start_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_scan_start_rsp_dec(p_buffer, + length, + &result_code); + + if (result_code != NRF_SUCCESS) + { +#if NRF_SD_BLE_API_VERSION > 5 + app_ble_gap_scan_data_unset(true); +#endif + } + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_scan_start +#define _sd_ble_gap_scan_start sd_ble_gap_scan_start +#endif +uint32_t _sd_ble_gap_scan_start(ble_gap_scan_params_t const * const p_scan_params +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + ,ble_data_t const * p_adv_report_buffer +#endif + ) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + uint32_t err_code; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + err_code = ble_gap_scan_start_req_enc(p_scan_params, +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + p_adv_report_buffer, +#endif + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + if (p_adv_report_buffer) { + app_ble_gap_scan_data_set(p_adv_report_buffer->p_data); + } +#endif + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_scan_start_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_encrypt BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_encrypt_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_encrypt_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_encrypt +#define _sd_ble_gap_encrypt sd_ble_gap_encrypt +#endif +uint32_t _sd_ble_gap_encrypt( uint16_t conn_handle, + ble_gap_master_id_t const * p_master_id, + ble_gap_enc_info_t const * p_enc_info) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_encrypt_req_enc( conn_handle, p_master_id, p_enc_info, &(p_buffer[1]), &buffer_length ); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_encrypt_rsp_dec); +} +#endif //!S112 + +/**@brief Command response callback function for @ref sd_ble_gap_rssi_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_rssi_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_rssi_get_rsp_dec(p_buffer, + length, + (int8_t *) mp_out_params[0], +#if NRF_SD_BLE_API_VERSION > 5 + (uint8_t *) mp_out_params[1], +#endif + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_rssi_get +#define _sd_ble_gap_rssi_get sd_ble_gap_rssi_get +#endif +uint32_t _sd_ble_gap_rssi_get(uint16_t conn_handle, + int8_t * p_rssi +#if NRF_SD_BLE_API_VERSION > 5 + ,uint8_t * p_ch_index +#endif +) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_rssi; + +#if NRF_SD_BLE_API_VERSION > 5 + mp_out_params[1] = p_ch_index; + const uint32_t err_code = ble_gap_rssi_get_req_enc(conn_handle, p_rssi, p_ch_index, &(p_buffer[1]), &buffer_length); +#else + const uint32_t err_code = ble_gap_rssi_get_req_enc(conn_handle, p_rssi, &(p_buffer[1]), &buffer_length); +#endif + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_rssi_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_keypress_notify BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_keypress_notify_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_keypress_notify_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_keypress_notify +#define _sd_ble_gap_keypress_notify sd_ble_gap_keypress_notify +#endif +uint32_t _sd_ble_gap_keypress_notify( uint16_t conn_handle, uint8_t kp_not) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_keypress_notify_req_enc( conn_handle, kp_not, &p_buffer[1], &buffer_length ); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_keypress_notify_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_lesc_dhkey_reply BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_lesc_dhkey_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_lesc_dhkey_reply_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_lesc_dhkey_reply +#define _sd_ble_gap_lesc_dhkey_reply sd_ble_gap_lesc_dhkey_reply +#endif +uint32_t _sd_ble_gap_lesc_dhkey_reply( uint16_t conn_handle, ble_gap_lesc_dhkey_t const *p_dhkey) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_lesc_dhkey_reply_req_enc( conn_handle, p_dhkey, &(p_buffer[1]), &buffer_length ); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_lesc_dhkey_reply_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_lesc_oob_data_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_lesc_oob_data_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_lesc_oob_data_set_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_lesc_oob_data_set +#define _sd_ble_gap_lesc_oob_data_set sd_ble_gap_lesc_oob_data_set +#endif +uint32_t _sd_ble_gap_lesc_oob_data_set(uint16_t conn_handle, + ble_gap_lesc_oob_data_t const *p_oobd_own, + ble_gap_lesc_oob_data_t const *p_oobd_peer) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_lesc_oob_data_set_req_enc(conn_handle, p_oobd_own, p_oobd_peer, + &(p_buffer[1]), &buffer_length ); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_lesc_oob_data_set_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_lesc_oob_data_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_lesc_oob_data_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_lesc_oob_data_get_rsp_dec(p_buffer, + length, + (ble_gap_lesc_oob_data_t **) &mp_out_params[0], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_lesc_oob_data_get +#define _sd_ble_gap_lesc_oob_data_get sd_ble_gap_lesc_oob_data_get +#endif +uint32_t _sd_ble_gap_lesc_oob_data_get(uint16_t conn_handle, + ble_gap_lesc_p256_pk_t const *p_pk_own, + ble_gap_lesc_oob_data_t *p_oobd_own) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_oobd_own; + const uint32_t err_code = ble_gap_lesc_oob_data_get_req_enc(conn_handle, p_pk_own, p_oobd_own, + &(p_buffer[1]), &buffer_length ); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_lesc_oob_data_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_addr_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_addr_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_addr_get_rsp_dec(p_buffer, + length, + (ble_gap_addr_t *)mp_out_params[0], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_gap_addr_get +#define _sd_ble_gap_addr_get sd_ble_gap_addr_get +#endif +uint32_t _sd_ble_gap_addr_get(ble_gap_addr_t * const p_addr) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_addr; + + const uint32_t err_code = ble_gap_addr_get_req_enc(p_addr, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_addr_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_addr_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_addr_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_addr_set_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_gap_addr_set +#define _sd_ble_gap_addr_set sd_ble_gap_addr_set +#endif +uint32_t _sd_ble_gap_addr_set(ble_gap_addr_t const * const p_addr) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_addr_set_req_enc(p_addr, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_addr_set_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_privacy_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_privacy_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_privacy_set_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_gap_privacy_set +#define _sd_ble_gap_privacy_set sd_ble_gap_privacy_set +#endif +uint32_t _sd_ble_gap_privacy_set(ble_gap_privacy_params_t const *p_privacy_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gap_privacy_set_req_enc(p_privacy_params, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_privacy_set_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_privacy_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_privacy_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_privacy_get_rsp_dec(p_buffer, + length, + (ble_gap_privacy_params_t *)mp_out_params[0], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_gap_privacy_get +#define _sd_ble_gap_privacy_get sd_ble_gap_privacy_get +#endif +uint32_t _sd_ble_gap_privacy_get(ble_gap_privacy_params_t *p_privacy_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_privacy_params; + + const uint32_t err_code = ble_gap_privacy_get_req_enc(p_privacy_params, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_privacy_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_whitelist_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_whitelist_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_whitelist_set_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_gap_whitelist_set +#define _sd_ble_gap_whitelist_set sd_ble_gap_whitelist_set +#endif +uint32_t _sd_ble_gap_whitelist_set(ble_gap_addr_t const * const * pp_wl_addrs, uint8_t len) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gap_whitelist_set_req_enc(pp_wl_addrs, len, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_whitelist_set_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_device_identities_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_device_identities_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_device_identities_set_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_gap_device_identities_set +#define _sd_ble_gap_device_identities_set sd_ble_gap_device_identities_set +#endif +uint32_t _sd_ble_gap_device_identities_set(ble_gap_id_key_t const * const * pp_id_keys, ble_gap_irk_t const * const * pp_local_irks, uint8_t len) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gap_device_identities_set_req_enc(pp_id_keys, + pp_local_irks, + len, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_device_identities_set_rsp_dec); +} + +#if NRF_SD_BLE_API_VERSION >= 4 && !defined(S112) +/**@brief Command response callback function for @ref sd_ble_gap_data_length_update BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_data_length_update_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_data_length_update_rsp_dec(p_buffer, + length, + (ble_gap_data_length_limitation_t *)mp_out_params[0], + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_gap_data_length_update +#define _sd_ble_gap_data_length_update sd_ble_gap_data_length_update +#endif +uint32_t _sd_ble_gap_data_length_update(uint16_t conn_handle, + ble_gap_data_length_params_t const *p_dl_params, + ble_gap_data_length_limitation_t *p_dl_limitation) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_dl_limitation; + + const uint32_t err_code = ble_gap_data_length_update_req_enc(conn_handle, p_dl_params,p_dl_limitation, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_data_length_update_rsp_dec); +} + +#endif // NRF_SD_BLE_API_VERSION >= 4 && !defined(S112) + +#if NRF_SD_BLE_API_VERSION >= 5 +/**@brief Command response callback function for @ref sd_ble_gap_phy_update BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_phy_update_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + const uint32_t err_code = ble_gap_phy_update_rsp_dec(p_buffer, + length, + &result_code); + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gap_phy_update +#define _sd_ble_gap_phy_update sd_ble_gap_phy_update +#endif +uint32_t _sd_ble_gap_phy_update(uint16_t conn_handle, + ble_gap_phys_t const * const p_gap_phys) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gap_phy_update_req_enc(conn_handle, p_gap_phys, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_phy_update_rsp_dec); +} +#endif + +#if NRF_SD_BLE_API_VERSION >= 6 +/**@brief Command response callback function for @ref sd_ble_gap_adv_set_configure BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_adv_set_configure_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + uint32_t err_code = ble_gap_adv_set_configure_rsp_dec(p_buffer, + length, + (uint8_t *)mp_out_params[0], + &result_code); + + if (result_code != NRF_SUCCESS) + { + app_ble_gap_adv_buf_addr_unregister(mp_out_params[1], false); + app_ble_gap_adv_buf_addr_unregister(mp_out_params[2], false); + } + + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_adv_set_configure +#define _sd_ble_gap_adv_set_configure sd_ble_gap_adv_set_configure +#endif +uint32_t _sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle, + ble_gap_adv_data_t const *p_adv_data, + ble_gap_adv_params_t const *p_adv_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + mp_out_params[0] = p_adv_handle; + if (p_adv_handle) + { + mp_out_params[1] = p_adv_data->adv_data.p_data; + mp_out_params[2] = p_adv_data->scan_rsp_data.p_data; + } + else + { + mp_out_params[1] = NULL; + mp_out_params[2] = NULL; + } + + const uint32_t err_code = ble_gap_adv_set_configure_req_enc(p_adv_handle, p_adv_data, p_adv_params, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_adv_set_configure_rsp_dec); +} + +#ifndef S112 +/**@brief Command response callback function for @ref sd_ble_gap_qos_channel_survey_start BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_qos_channel_survey_start_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + uint32_t err_code = ble_gap_qos_channel_survey_start_rsp_dec(p_buffer, + length, + &result_code); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_qos_channel_survey_start +#define _sd_ble_gap_qos_channel_survey_start sd_ble_gap_qos_channel_survey_start +#endif +uint32_t _sd_ble_gap_qos_channel_survey_start(uint32_t interval_us) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gap_qos_channel_survey_start_req_enc(interval_us, + &(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_qos_channel_survey_start_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gap_qos_channel_survey_stop BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gap_qos_channel_survey_stop_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = 0; + + uint32_t err_code = ble_gap_qos_channel_survey_stop_rsp_dec(p_buffer, + length, + &result_code); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gap_qos_channel_survey_stop +#define _sd_ble_gap_qos_channel_survey_stop sd_ble_gap_qos_channel_survey_stop +#endif +uint32_t _sd_ble_gap_qos_channel_survey_stop(void) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gap_qos_channel_survey_stop_req_enc(&(p_buffer[1]), &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gap_qos_channel_survey_stop_rsp_dec); +} +#endif //!S112 +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c new file mode 100644 index 000000000..b50048009 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c @@ -0,0 +1,566 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include "ble_gattc.h" +#include "ble_gattc_app.h" +#include "ble_serialization.h" +#include "ser_sd_transport.h" +#include "app_error.h" + +static void tx_buf_alloc(uint8_t * * p_data, uint16_t * p_len) +{ + uint32_t err_code; + + do + { + err_code = ser_sd_transport_tx_alloc(p_data, p_len); + } + while (err_code != NRF_SUCCESS); + *p_data[0] = SER_PKT_TYPE_CMD; + *p_len -= 1; +} +/**@brief Command response callback function for @ref sd_ble_gattc_primary_services_discover BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_primary_services_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_primary_services_discover_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_primary_services_discover +#define _sd_ble_gattc_primary_services_discover sd_ble_gattc_primary_services_discover +#endif +uint32_t _sd_ble_gattc_primary_services_discover(uint16_t conn_handle, + uint16_t start_handle, + ble_uuid_t const * const p_srvc_uuid) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_primary_services_discover_req_enc(conn_handle, + start_handle, + p_srvc_uuid, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_primary_services_discover_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_relationships_discover BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_relationships_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_relationships_discover_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_relationships_discover +#define _sd_ble_gattc_relationships_discover sd_ble_gattc_relationships_discover +#endif +uint32_t _sd_ble_gattc_relationships_discover(uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_relationships_discover_req_enc(conn_handle, + p_handle_range, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_relationships_discover_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_characteristics_discover BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_characteristics_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_characteristics_discover_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_characteristics_discover +#define _sd_ble_gattc_characteristics_discover sd_ble_gattc_characteristics_discover +#endif +uint32_t _sd_ble_gattc_characteristics_discover( + uint16_t conn_handle, + ble_gattc_handle_range_t const * const + p_handle_range) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_characteristics_discover_req_enc(conn_handle, + p_handle_range, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_characteristics_discover_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_descriptors_discover BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_descriptors_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_descriptors_discover_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_descriptors_discover +#define _sd_ble_gattc_descriptors_discover sd_ble_gattc_descriptors_discover +#endif +uint32_t _sd_ble_gattc_descriptors_discover(uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_descriptors_discover_req_enc(conn_handle, + p_handle_range, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_descriptors_discover_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_char_value_by_uuid_read BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_char_value_by_uuid_read_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_char_value_by_uuid_read_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_char_value_by_uuid_read +#define _sd_ble_gattc_char_value_by_uuid_read sd_ble_gattc_char_value_by_uuid_read +#endif +uint32_t _sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, + ble_uuid_t const * const p_uuid, + ble_gattc_handle_range_t const * const p_handle_range) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_char_value_by_uuid_read_req_enc(conn_handle, + p_uuid, + p_handle_range, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_char_value_by_uuid_read_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_read BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_read_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_read_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_read +#define _sd_ble_gattc_read sd_ble_gattc_read +#endif +uint32_t _sd_ble_gattc_read(uint16_t conn_handle, + uint16_t handle, + uint16_t offset) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_read_req_enc(conn_handle, + handle, + offset, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_read_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_char_values_read BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_char_values_read_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_char_values_read_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_char_values_read +#define _sd_ble_gattc_char_values_read sd_ble_gattc_char_values_read +#endif +uint32_t _sd_ble_gattc_char_values_read(uint16_t conn_handle, + uint16_t const * const p_handles, + uint16_t handle_count) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_char_values_read_req_enc(conn_handle, + p_handles, + handle_count, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_char_values_read_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_write BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_write_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_write_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_write +#define _sd_ble_gattc_write sd_ble_gattc_write +#endif +uint32_t _sd_ble_gattc_write(uint16_t conn_handle, + ble_gattc_write_params_t const * const p_write_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_write_req_enc(conn_handle, + p_write_params, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_write_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_hv_confirm BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_hv_confirm_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_hv_confirm_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gattc_hv_confirm +#define _sd_ble_gattc_hv_confirm sd_ble_gattc_hv_confirm +#endif +uint32_t _sd_ble_gattc_hv_confirm(uint16_t conn_handle, + uint16_t handle) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_hv_confirm_req_enc(conn_handle, + handle, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_hv_confirm_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gattc_info_discover BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_attr_info_discover_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_attr_info_discover_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gattc_attr_info_discover +#define _sd_ble_gattc_attr_info_discover sd_ble_gattc_attr_info_discover +#endif +uint32_t _sd_ble_gattc_attr_info_discover(uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_attr_info_discover_req_enc(conn_handle, + p_handle_range, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_attr_info_discover_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gattc_write BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gattc_exchange_mtu_request_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gattc_exchange_mtu_request_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + return result_code; +} + +#ifndef _sd_ble_gattc_exchange_mtu_request +#define _sd_ble_gattc_exchange_mtu_request sd_ble_gattc_exchange_mtu_request +#endif +uint32_t _sd_ble_gattc_exchange_mtu_request(uint16_t conn_handle, + uint16_t client_rx_mtu) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gattc_exchange_mtu_request_req_enc(conn_handle, + client_rx_mtu, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gattc_exchange_mtu_request_rsp_dec); +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gatts.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gatts.c new file mode 100644 index 000000000..a461cc859 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_gatts.c @@ -0,0 +1,773 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gatts.h" +#include +#include "ble_serialization.h" +#include "ser_sd_transport.h" +#include "ble_gatts_app.h" +#include "app_error.h" + + +//Pointer for sd calls output params +static void * mp_out_params[3]; + +static void tx_buf_alloc(uint8_t * * p_data, uint16_t * p_len) +{ + uint32_t err_code; + + do + { + err_code = ser_sd_transport_tx_alloc(p_data, p_len); + } + while (err_code != NRF_SUCCESS); + *p_data[0] = SER_PKT_TYPE_CMD; + *p_len -= 1; +} + +/**@brief Command response callback function for @ref sd_ble_gatts_sys_attr_set BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_sys_attr_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_sys_attr_set_rsp_dec(p_buffer, length, &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gatts_sys_attr_set +#define _sd_ble_gatts_sys_attr_set sd_ble_gatts_sys_attr_set +#endif +uint32_t _sd_ble_gatts_sys_attr_set(uint16_t conn_handle, + uint8_t const * const p_sys_attr_data, + uint16_t len, + uint32_t flags) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gatts_sys_attr_set_req_enc(conn_handle, + p_sys_attr_data, + len, + flags, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_sys_attr_set_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gatts_hvx BLE command. + * + * Callback for decoding the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_hvx_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_hvx_rsp_dec(p_buffer, length, &result_code, + (uint16_t * *)&mp_out_params[0]); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gatts_hvx +#define _sd_ble_gatts_hvx sd_ble_gatts_hvx +#endif +uint32_t _sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const * const p_hvx_params) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = (p_hvx_params) ? p_hvx_params->p_len : NULL; + + const uint32_t err_code = ble_gatts_hvx_req_enc(conn_handle, + p_hvx_params, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_hvx_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gatts_service_add BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_service_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_gatts_service_add_rsp_dec(p_buffer, + length, + (uint16_t *)mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gatts_service_add +#define _sd_ble_gatts_service_add sd_ble_gatts_service_add +#endif +uint32_t _sd_ble_gatts_service_add(uint8_t type, + ble_uuid_t const * const p_uuid, + uint16_t * const p_handle) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_handle; + + const uint32_t err_code = ble_gatts_service_add_req_enc(type, + p_uuid, + p_handle, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_service_add_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_service_add BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_service_changed_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = NRF_SUCCESS; + + const uint32_t err_code = ble_gatts_service_changed_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gatts_service_changed +#define _sd_ble_gatts_service_changed sd_ble_gatts_service_changed +#endif +uint32_t _sd_ble_gatts_service_changed(uint16_t conn_handle, + uint16_t start_handle, + uint16_t end_handle) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_gatts_service_changed_req_enc(conn_handle, + start_handle, + end_handle, + &(p_buffer[1]), + &buffer_length); + + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_service_changed_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_include_add BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_include_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = NRF_SUCCESS; + + const uint32_t err_code = + ble_gatts_include_add_rsp_dec(p_buffer, + length, + (uint16_t *) mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gatts_include_add +#define _sd_ble_gatts_include_add sd_ble_gatts_include_add +#endif +uint32_t _sd_ble_gatts_include_add(uint16_t service_handle, + uint16_t inc_serv_handle, + uint16_t * const p_include_handle) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_include_handle; + + const uint32_t err_code = ble_gatts_include_add_req_enc(service_handle, + inc_serv_handle, + p_include_handle, + &(p_buffer[1]), + &buffer_length); + + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_include_add_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_characteristic_add BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_characteristic_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_characteristic_add_rsp_dec( + p_buffer, + length, + (uint16_t * *)&mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gatts_characteristic_add +#define _sd_ble_gatts_characteristic_add sd_ble_gatts_characteristic_add +#endif +uint32_t _sd_ble_gatts_characteristic_add(uint16_t service_handle, + ble_gatts_char_md_t const * const p_char_md, + ble_gatts_attr_t const * const p_attr_char_value, + ble_gatts_char_handles_t * const p_handles) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_handles; + + const uint32_t err_code = ble_gatts_characteristic_add_req_enc(service_handle, + p_char_md, + p_attr_char_value, + p_handles, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_characteristic_add_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_descriptor_add BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_descriptor_add_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = NRF_SUCCESS; + + const uint32_t err_code = + ble_gatts_descriptor_add_rsp_dec(p_buffer, + length, + (uint16_t *) mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gatts_descriptor_add +#define _sd_ble_gatts_descriptor_add sd_ble_gatts_descriptor_add +#endif +uint32_t _sd_ble_gatts_descriptor_add(uint16_t char_handle, + ble_gatts_attr_t const * const p_attr, + uint16_t * const p_handle) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_handle; + + const uint32_t err_code = ble_gatts_descriptor_add_req_enc(char_handle, + p_attr, + p_handle, + &(p_buffer[1]), + &buffer_length); + + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_descriptor_add_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_rw_authorize_reply BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_rw_authorize_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code = NRF_SUCCESS; + + const uint32_t err_code = ble_gatts_rw_authorize_reply_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gatts_rw_authorize_reply +#define _sd_ble_gatts_rw_authorize_reply sd_ble_gatts_rw_authorize_reply +#endif +uint32_t _sd_ble_gatts_rw_authorize_reply( + uint16_t conn_handle, + ble_gatts_rw_authorize_reply_params_t const * const + p_rw_authorize_reply_params) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gatts_rw_authorize_reply_req_enc(conn_handle, + p_rw_authorize_reply_params, + &(p_buffer[1]), + &buffer_length); + + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_rw_authorize_reply_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_value_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_value_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_value_get_rsp_dec(p_buffer, + length, + (ble_gatts_value_t *)mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_gatts_value_get +#define _sd_ble_gatts_value_get sd_ble_gatts_value_get +#endif +uint32_t _sd_ble_gatts_value_get(uint16_t conn_handle, + uint16_t handle, + ble_gatts_value_t * p_value) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_value; + + const uint32_t err_code = ble_gatts_value_get_req_enc(conn_handle, + handle, + p_value, + &(p_buffer[1]), + &buffer_length); + + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_value_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_value_set BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_value_set_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_value_set_rsp_dec( + p_buffer, + length, + (ble_gatts_value_t *)mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gatts_value_set +#define _sd_ble_gatts_value_set sd_ble_gatts_value_set +#endif +uint32_t _sd_ble_gatts_value_set(uint16_t conn_handle, + uint16_t handle, + ble_gatts_value_t * p_value) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_value; + + const uint32_t err_code = ble_gatts_value_set_req_enc(conn_handle, + handle, + p_value, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_value_set_rsp_dec); +} + + +/**@brief Command response callback function for @ref sd_ble_gatts_sys_attr_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_sys_attr_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_sys_attr_get_rsp_dec( + p_buffer, + length, + (uint8_t * *) &mp_out_params[0], + (uint16_t * *) &mp_out_params[1], + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gatts_sys_attr_get +#define _sd_ble_gatts_sys_attr_get sd_ble_gatts_sys_attr_get +#endif +uint32_t _sd_ble_gatts_sys_attr_get(uint16_t conn_handle, + uint8_t * const p_sys_attr_data, + uint16_t * const p_len, + uint32_t flags) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_sys_attr_data; + mp_out_params[1] = p_len; + + const uint32_t err_code = ble_gatts_sys_attr_get_req_enc(conn_handle, + p_sys_attr_data, + p_len, + flags, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_sys_attr_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_attr_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_attr_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_attr_get_rsp_dec( + p_buffer, + length, + (ble_uuid_t **)&mp_out_params[0], + (ble_gatts_attr_md_t **)&mp_out_params[1], + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gatts_attr_get +#define _sd_ble_gatts_attr_get sd_ble_gatts_attr_get +#endif +uint32_t _sd_ble_gatts_attr_get(uint16_t handle, + ble_uuid_t * p_uuid, + ble_gatts_attr_md_t * p_md) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_uuid; + mp_out_params[1] = p_md; + + const uint32_t err_code = ble_gatts_attr_get_req_enc(handle, + p_uuid, + p_md, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_attr_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_initial_user_handle_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_initial_user_handle_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_initial_user_handle_get_rsp_dec( + p_buffer, + length, + (uint16_t **)&mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gatts_initial_user_handle_get +#define _sd_ble_gatts_initial_user_handle_get sd_ble_gatts_initial_user_handle_get +#endif +uint32_t _sd_ble_gatts_initial_user_handle_get(uint16_t * p_handle) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_handle; + + const uint32_t err_code = ble_gatts_initial_user_handle_get_req_enc(p_handle, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_initial_user_handle_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ble_gatts_exchange_mtu_reply BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t gatts_exchange_mtu_reply_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ble_gatts_exchange_mtu_reply_rsp_dec( + p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_gatts_exchange_mtu_reply +#define _sd_ble_gatts_exchange_mtu_reply sd_ble_gatts_exchange_mtu_reply +#endif +uint32_t _sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu) +{ + + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + + const uint32_t err_code = ble_gatts_exchange_mtu_reply_req_enc(conn_handle, + server_rx_mtu, + &(p_buffer[1]), + &buffer_length); + + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + gatts_exchange_mtu_reply_rsp_dec); +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_l2cap.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_l2cap.c new file mode 100644 index 000000000..c33faacc0 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_ble_l2cap.c @@ -0,0 +1,453 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gap.h" +#include +#include "ble_serialization.h" +#include "ser_sd_transport.h" +#include "ble_l2cap_app.h" +#include "app_error.h" + +#if defined(NRF_SD_BLE_API_VERSION) && ((NRF_SD_BLE_API_VERSION < 4) || (NRF_SD_BLE_API_VERSION >=5)) +static void tx_buf_alloc(uint8_t * * p_data, uint16_t * p_len) +{ + uint32_t err_code; + + do + { + err_code = ser_sd_transport_tx_alloc(p_data, p_len); + } + while (err_code != NRF_SUCCESS); + *p_data[0] = SER_PKT_TYPE_CMD; + *p_len -= 1; +} + +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +/**@brief Command response callback function for @ref ble_l2cap_cid_register_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t l2cap_cid_register_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_l2cap_cid_register_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +#ifndef _sd_ble_l2cap_cid_register +#define _sd_ble_l2cap_cid_register sd_ble_l2cap_cid_register +#endif +uint32_t _sd_ble_l2cap_cid_register(uint16_t cid) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_l2cap_cid_register_req_enc(cid, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + l2cap_cid_register_rsp_dec); +} + +/**@brief Command response callback function for @ref ble_l2cap_cid_unregister_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t l2cap_cid_unregister_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_l2cap_cid_unregister_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_l2cap_cid_unregister +#define _sd_ble_l2cap_cid_unregister sd_ble_l2cap_cid_unregister +#endif +uint32_t _sd_ble_l2cap_cid_unregister(uint16_t cid) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_l2cap_cid_unregister_req_enc(cid, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + l2cap_cid_unregister_rsp_dec); +} + +/**@brief Command response callback function for @ref ble_l2cap_tx_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t l2cap_tx_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_l2cap_tx_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_l2cap_tx +#define _sd_ble_l2cap_tx sd_ble_l2cap_tx +#endif +uint32_t _sd_ble_l2cap_tx(uint16_t conn_handle, + ble_l2cap_header_t const * const p_header, + uint8_t const * const p_data) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_l2cap_tx_req_enc(conn_handle, p_header, p_data, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + l2cap_tx_rsp_dec); +} + +#endif + +#if NRF_SD_BLE_API_VERSION >= 5 +static void * mp_out_params[1]; +/**@brief Command response callback function for @ref ble_l2cap_ch_setup_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t l2cap_ch_setup_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_l2cap_ch_setup_rsp_dec(p_buffer, + length, + (uint16_t *)mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_l2cap_ch_setup +#define _sd_ble_l2cap_ch_setup sd_ble_l2cap_ch_setup +#endif +uint32_t _sd_ble_l2cap_ch_setup(uint16_t conn_handle, + uint16_t * p_local_cid, + ble_l2cap_ch_setup_params_t const *p_params) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_local_cid; + const uint32_t err_code = ble_l2cap_ch_setup_req_enc(conn_handle, p_local_cid, p_params, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + l2cap_ch_setup_rsp_dec); +} + +/**@brief Command response callback function for @ref ble_l2cap_ch_release_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t l2cap_ch_release_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_l2cap_ch_release_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_l2cap_ch_release +#define _sd_ble_l2cap_ch_release sd_ble_l2cap_ch_release +#endif +uint32_t _sd_ble_l2cap_ch_release(uint16_t conn_handle, + uint16_t local_cid) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_l2cap_ch_release_req_enc(conn_handle, local_cid, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + l2cap_ch_release_rsp_dec); +} + + +/**@brief Command response callback function for @ref ble_l2cap_ch_rx_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t l2cap_ch_rx_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_l2cap_ch_rx_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_l2cap_ch_rx +#define _sd_ble_l2cap_ch_rx sd_ble_l2cap_ch_rx +#endif +uint32_t _sd_ble_l2cap_ch_rx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_l2cap_ch_rx_req_enc(conn_handle, local_cid, p_sdu_buf, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + l2cap_ch_rx_rsp_dec); +} + + +/**@brief Command response callback function for @ref ble_l2cap_ch_tx_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t l2cap_ch_tx_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_l2cap_ch_tx_rsp_dec(p_buffer, + length, + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_l2cap_ch_tx +#define _sd_ble_l2cap_ch_tx sd_ble_l2cap_ch_tx +#endif +uint32_t _sd_ble_l2cap_ch_tx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = ble_l2cap_ch_tx_req_enc(conn_handle, local_cid, p_sdu_buf, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + l2cap_ch_tx_rsp_dec); +} + +/**@brief Command response callback function for @ref ble_l2cap_ch_flow_control_req_enc BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ +static uint32_t l2cap_ch_flow_control_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = + ble_l2cap_ch_flow_control_rsp_dec(p_buffer, + length, + (uint16_t *)mp_out_params[0], + &result_code); + + APP_ERROR_CHECK(err_code); + + + + return result_code; +} + +#ifndef _sd_ble_l2cap_ch_flow_control +#define _sd_ble_l2cap_ch_flow_control sd_ble_l2cap_ch_flow_control +#endif +uint32_t _sd_ble_l2cap_ch_flow_control(uint16_t conn_handle, + uint16_t local_cid, + uint16_t credits, + uint16_t *p_credits) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_params[0] = p_credits; + const uint32_t err_code = ble_l2cap_ch_flow_control_req_enc(conn_handle, local_cid, credits, p_credits, + &(p_buffer[1]), + &buffer_length); + //@note: Should never fail. + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + l2cap_ch_flow_control_rsp_dec); +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_nrf_soc.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_nrf_soc.c new file mode 100644 index 000000000..082a62baf --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/middleware/app_mw_nrf_soc.c @@ -0,0 +1,171 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "nrf_soc.h" +#include +#include +#include "ser_sd_transport.h" +#include "nrf_soc_app.h" +#include "nrf_error_soc.h" +#include "app_error.h" +#include "ble_serialization.h" + +#include "ser_app_power_system_off.h" + +static void * mp_out_param; + +static void tx_buf_alloc(uint8_t * * p_data, uint16_t * p_len) +{ + uint32_t err_code; + + do + { + err_code = ser_sd_transport_tx_alloc(p_data, p_len); + } + while (err_code != NRF_SUCCESS); + *p_data[0] = SER_PKT_TYPE_CMD; + *p_len -= 1; +} + + +uint32_t sd_power_system_off(void) +{ + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + const uint32_t err_code = power_system_off_req_enc(&(p_buffer[1]), &buffer_length); + APP_ERROR_CHECK(err_code); + + ser_app_power_system_off_set(); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + NULL); +} + + +/**@brief Command response callback function for @ref sd_temp_get BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ + +static uint32_t mw_temp_get_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = temp_get_rsp_dec(p_buffer, + length, + &result_code, + (int32_t * *) &mp_out_param); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +uint32_t sd_temp_get(int32_t * p_temp) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_param = p_temp; + + const uint32_t err_code = temp_get_req_enc(p_temp, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + mw_temp_get_rsp_dec); +} + +/**@brief Command response callback function for @ref sd_ecb_block_encrypt BLE command. + * + * Callback for decoding the output parameters and the command response return code. + * + * @param[in] p_buffer Pointer to begin of command response buffer. + * @param[in] length Length of data in bytes. + * + * @return Decoded command response return code. + */ + +static uint32_t mw_ecb_block_encrypt_rsp_dec(const uint8_t * p_buffer, uint16_t length) +{ + uint32_t result_code; + + const uint32_t err_code = ecb_block_encrypt_rsp_dec(p_buffer, + length, + (nrf_ecb_hal_data_t * *)&mp_out_param, + &result_code); + + APP_ERROR_CHECK(err_code); + + return result_code; +} + +uint32_t sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data) +{ + + uint8_t * p_buffer; + uint32_t buffer_length = 0; + + tx_buf_alloc(&p_buffer, (uint16_t *)&buffer_length); + mp_out_param = p_ecb_data; + + const uint32_t err_code = ecb_block_encrypt_req_enc(p_ecb_data, + &(p_buffer[1]), + &buffer_length); + APP_ERROR_CHECK(err_code); + + //@note: Increment buffer length as internally managed packet type field must be included. + return ser_sd_transport_cmd_write(p_buffer, + (++buffer_length), + mw_ecb_block_encrypt_rsp_dec); +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_gap_sec_keys.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_gap_sec_keys.c new file mode 100644 index 000000000..877dd4222 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_gap_sec_keys.c @@ -0,0 +1,216 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "app_ble_gap_sec_keys.h" +#include "ser_config.h" +#include "nrf_error.h" +#include "nordic_common.h" +#include +#include +#include + +#if NRF_SD_BLE_API_VERSION >= 6 +typedef struct { + bool active; + uint8_t adv_handle; + uint8_t * p_adv_data; + uint8_t * p_scan_rsp_data; +} adv_set_t; + +static adv_set_t m_adv_sets[4]; //todo configurable number of adv sets. + +static ble_data_t m_scan_data = {0}; +static int scan_data_id; +#endif +ser_ble_gap_app_keyset_t m_app_keys_table[SER_MAX_CONNECTIONS]; + +#if NRF_SD_BLE_API_VERSION >= 6 +static void *m_ble_gap_adv_buf_addr_storage[8]; +#endif + +void app_ble_gap_sec_keys_init(void) +{ +#if NRF_SD_BLE_API_VERSION >= 6 + memset(m_ble_gap_adv_buf_addr_storage, 0, sizeof(m_ble_gap_adv_buf_addr_storage)); + memset(&m_scan_data, 0, sizeof(m_scan_data)); + memset(m_adv_sets, 0, sizeof(m_adv_sets)); +#endif + memset(m_app_keys_table, 0, sizeof(m_app_keys_table)); +} + +uint32_t app_ble_gap_sec_context_create(uint16_t conn_handle, uint32_t *p_index) +{ + uint32_t err_code = NRF_ERROR_NO_MEM; + uint32_t i; + + for (i=0; i= 6 + +int app_ble_gap_adv_buf_register(void * p_buf) +{ + uint32_t i; + + if (p_buf == NULL) + { + return 0; + } + + for (i = 0; i < ARRAY_SIZE(m_ble_gap_adv_buf_addr_storage); i++) + { + if ((m_ble_gap_adv_buf_addr_storage[i] == NULL) || + (m_ble_gap_adv_buf_addr_storage[i] == p_buf)) + { + m_ble_gap_adv_buf_addr_storage[i] = p_buf; + return i+1; + } + } + + return -1; +} + +void *app_ble_gap_adv_buf_unregister(int id, bool event_context) +{ + (void)event_context; + if (id == 0) + { + return NULL; + } + + void * ret = m_ble_gap_adv_buf_addr_storage[id-1]; + m_ble_gap_adv_buf_addr_storage[id-1] = NULL; + + return ret; +} + +void app_ble_gap_adv_buf_addr_unregister(void * p_buf, bool event_context) +{ + (void)event_context; + uint32_t i; + + if (p_buf == NULL) + { + return; + } + + for (i = 0; i < ARRAY_SIZE(m_ble_gap_adv_buf_addr_storage); i++) + { + if (m_ble_gap_adv_buf_addr_storage[i] == p_buf) + { + m_ble_gap_adv_buf_addr_storage[i] = NULL; + } + } +} + +void app_ble_gap_scan_data_set(uint8_t * p_scan_data) +{ + uint32_t i; + + for (i = 0; i < ARRAY_SIZE(m_ble_gap_adv_buf_addr_storage); i++) + { + if (m_ble_gap_adv_buf_addr_storage[i] == p_scan_data) + { + scan_data_id = i+1; + return; + } + } + scan_data_id = 0; +} + +void app_ble_gap_scan_data_unset(bool free) +{ + if (scan_data_id) + { + if (free) + { + (void)app_ble_gap_adv_buf_unregister(scan_data_id, false); + } + scan_data_id = 0; + } +} + +#endif /* NRF_SD_BLE_API_VERSION >= 6 */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_gap_sec_keys.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_gap_sec_keys.h new file mode 100644 index 000000000..6ac257e15 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_gap_sec_keys.h @@ -0,0 +1,120 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _APP_BLE_GAP_SEC_KEYS_H +#define _APP_BLE_GAP_SEC_KEYS_H + + /**@file + * + * @defgroup app_ble_gap_sec_keys GAP Functions for managing memory for security keys in the application device. + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief GAP Application auxiliary functions for synchronizing the GAP security keys with the ones stored in the connectivity device. + */ + +#include "ble_gap.h" +#include "ble_types.h" + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief GAP connection - keyset mapping structure. + * + * @note This structure is used to map keysets to connection instances and store them in a static table. + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection handle.*/ + uint8_t conn_active; /**< Indication that keys for this connection are used by the SoftDevice. 0: keys used; 1: keys not used. */ + ble_gap_sec_keyset_t keyset; /**< Keyset structure, see @ref ble_gap_sec_keyset_t.*/ +} ser_ble_gap_app_keyset_t; + +void app_ble_gap_sec_keys_init(void); + +/**@brief Allocates the instance in m_app_keys_table[] for storage of encryption keys. + * + * @param[in] conn_handle conn_handle + * @param[out] p_index Pointer to the index of the allocated instance. + * + * @retval NRF_SUCCESS Context allocated. + * @retval NRF_ERROR_NO_MEM No free instance available. + */ +uint32_t app_ble_gap_sec_context_create(uint16_t conn_handle, uint32_t *p_index); + +/**@brief Release the instance identified by a connection handle. + * + * @param[in] conn_handle conn_handle + * + * @retval NRF_SUCCESS Context released. + * @retval NRF_ERROR_NOT_FOUND Instance with conn_handle not found. + */ +uint32_t app_ble_gap_sec_context_destroy(uint16_t conn_handle); + +/**@brief Finds index of instance identified by a connection handle in m_app_keys_table[]. + * + * @param[in] conn_handle conn_handle + * + * @param[out] p_index Pointer to the index of the entry in the context table corresponding to the given conn_handle. + * + * @retval NRF_SUCCESS Context found. + * @retval NRF_ERROR_NOT_FOUND Instance with conn_handle not found. + */ +uint32_t app_ble_gap_sec_context_find(uint16_t conn_handle, uint32_t *p_index); +/** @} */ + +#if NRF_SD_BLE_API_VERSION >= 6 + +int app_ble_gap_adv_buf_register(void * p_buf); +void *app_ble_gap_adv_buf_unregister(int id, bool event_context); +void app_ble_gap_adv_buf_addr_unregister(void * p_buf, bool event_context); + +void app_ble_gap_scan_data_set(uint8_t * p_scan_data); +void app_ble_gap_scan_data_unset(bool free); + +#endif +#ifdef __cplusplus +} +#endif + +#endif //_APP_BLE_GAP_SEC_KEYS_H diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_user_mem.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_user_mem.c new file mode 100644 index 000000000..13888e50a --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/app_ble_user_mem.c @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "app_ble_user_mem.h" +#include "ser_config.h" +#include "nrf_error.h" +#include + +ser_ble_user_mem_t m_app_user_mem_table[SER_MAX_CONNECTIONS]; + +uint32_t app_ble_user_mem_context_create(uint16_t conn_handle, uint32_t *p_index) +{ + uint32_t err_code = NRF_ERROR_NO_MEM; + uint32_t i; + + for (i=0; i + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Connection - user memory mapping structure. + * + * @note This structure is used to map user memory to connection instances and store it in a static table. + */ +//lint -esym(452,ser_ble_user_mem_t) +typedef struct +{ + uint16_t conn_handle; /**< Connection handle. */ + uint8_t conn_active; /**< Indication that user memory for this connection is used by the SoftDevice. 0: memory used; 1: memory not used. */ + ble_user_mem_block_t mem_block; /**< User memory block structure, see @ref ble_user_mem_block_t. */ +} ser_ble_user_mem_t; + +/**@brief Allocates instance in m_user_mem_table[] for storage. + * + * @param[in] conn_handle conn_handle + * @param[out] p_index Pointer to the index of the allocated instance. + * + * @retval NRF_SUCCESS Context allocated. + * @retval NRF_ERROR_NO_MEM No free instance available. + */ +uint32_t app_ble_user_mem_context_create(uint16_t conn_handle, uint32_t *p_index); + +/**@brief Release instance identified by a connection handle. + * + * @param[in] conn_handle conn_handle + * + * @retval NRF_SUCCESS Context released. + * @retval NRF_ERROR_NOT_FOUND Instance with conn_handle not found. + */ +uint32_t app_ble_user_mem_context_destroy(uint16_t conn_handle); + +/**@brief Finds index of the instance identified by a connection handle in m_user_mem_table[]. + * + * @param[in] conn_handle conn_handle + * + * @param[out] p_index Pointer to the index of the entry in the context table corresponding to the given conn_handle. + * + * @retval NRF_SUCCESS Context found. + * @retval NRF_ERROR_NOT_FOUND Instance with conn_handle not found. + */ +uint32_t app_ble_user_mem_context_find(uint16_t conn_handle, uint32_t *p_index); +/** @} */ + + +#ifdef __cplusplus +} +#endif + +#endif //_APP_BLE_USER_MEM_H diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_app.c new file mode 100644 index 000000000..963e5faec --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_app.c @@ -0,0 +1,513 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include "ble_app.h" +#include "ble_serialization.h" +#include "ble_struct_serialization.h" +#include "ble_gap_struct_serialization.h" +#include "ble_gatt_struct_serialization.h" +#include "ble_gattc_struct_serialization.h" +#include "ble_gatts_struct_serialization.h" +#include "ble_l2cap_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_enable_req_enc(ble_enable_params_t * p_ble_enable_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_ENABLE); + SER_PUSH_COND(p_ble_enable_params, ble_enable_params_t_enc); + SER_REQ_ENC_END; +} +#else +uint32_t ble_enable_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_ENABLE); + SER_REQ_ENC_END; +} +#endif + +uint32_t ble_enable_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_ENABLE); +} + +uint32_t ble_opt_get_req_enc(uint32_t opt_id, + ble_opt_t const * const p_opt, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_OPT_GET); + + SER_PUSH_uint32(&opt_id); + SER_PUSH_COND(p_opt, NULL); + + SER_REQ_ENC_END; +} + +uint32_t ble_opt_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_opt_id, + ble_opt_t * const p_opt, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_OPT_GET); + + SER_PULL_uint32(p_opt_id); + + field_decoder_handler_t fp_decoder = NULL; + void * p_struct = NULL; + + switch (*p_opt_id) + { +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + case BLE_COMMON_OPT_CONN_BW: + fp_decoder = ble_common_opt_conn_bw_t_dec; + p_struct = &(p_opt->common_opt.conn_bw); + break; +#endif + case BLE_COMMON_OPT_PA_LNA: + fp_decoder = ble_common_opt_pa_lna_t_dec; + p_struct = &(p_opt->common_opt.pa_lna); + break; + case BLE_COMMON_OPT_CONN_EVT_EXT: + fp_decoder = ble_common_opt_conn_evt_ext_t_dec; + p_struct = &(p_opt->common_opt.conn_evt_ext); + break; + case BLE_GAP_OPT_CH_MAP: + fp_decoder = ble_gap_opt_ch_map_t_dec; + p_struct =&(p_opt->gap_opt.ch_map); + break; + case BLE_GAP_OPT_LOCAL_CONN_LATENCY: + fp_decoder = ble_gap_opt_local_conn_latency_t_dec; + p_struct = &(p_opt->gap_opt.local_conn_latency); + break; + case BLE_GAP_OPT_PASSKEY: + fp_decoder = ble_gap_opt_passkey_t_dec; + p_struct = &(p_opt->gap_opt.passkey); + break; + case BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT: + fp_decoder = ble_gap_opt_auth_payload_timeout_t_dec; + p_struct = &(p_opt->gap_opt.auth_payload_timeout); + break; +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + case BLE_GAP_OPT_EXT_LEN: + fp_decoder = ble_gap_opt_ext_len_t_dec; + p_struct = &(p_opt->gap_opt.ext_len); + break; +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 + case BLE_GAP_OPT_SCAN_REQ_REPORT: + fp_decoder = ble_gap_opt_scan_req_report_t_dec; + p_struct = &(p_opt->gap_opt.scan_req_report); + break; +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + case BLE_GAP_OPT_COMPAT_MODE: + fp_decoder = ble_gap_opt_compat_mode_t_dec; + p_struct = &(p_opt->gap_opt.compat_mode); + break; +#else +#ifndef S112 + case BLE_GAP_OPT_COMPAT_MODE_1: + fp_decoder = ble_gap_opt_compat_mode_1_t_dec; + p_struct = &(p_opt->gap_opt.compat_mode_1); + break; +#endif +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION == 4 + case BLE_GAP_OPT_COMPAT_MODE_2: + fp_decoder = ble_gap_opt_compat_mode_2_t_dec; + p_struct = &(p_opt->gap_opt.compat_mode_2); + break; +#endif + default: + SER_ASSERT(NRF_ERROR_INVALID_PARAM, NRF_ERROR_INVALID_PARAM); + break; + } + + SER_PULL_FIELD(p_struct, fp_decoder); + + SER_RSP_DEC_END; +} + + + +uint32_t ble_opt_set_req_enc(uint32_t const opt_id, + ble_opt_t const * const p_opt, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_OPT_SET); + + SER_PUSH_uint32(&opt_id); + + field_encoder_handler_t fp_encoder = NULL; + void const * p_struct = NULL; + + SER_PUSH_COND(p_opt, NULL); + if (p_opt) + { + switch (opt_id) + { +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + case BLE_COMMON_OPT_CONN_BW: + fp_encoder = ble_common_opt_conn_bw_t_enc; + p_struct = &(p_opt->common_opt.conn_bw); + break; +#endif + case BLE_COMMON_OPT_PA_LNA: + fp_encoder = ble_common_opt_pa_lna_t_enc; + p_struct = &(p_opt->common_opt.pa_lna); + break; + case BLE_COMMON_OPT_CONN_EVT_EXT: + fp_encoder = ble_common_opt_conn_evt_ext_t_enc; + p_struct = &(p_opt->common_opt.conn_evt_ext); + break; + case BLE_GAP_OPT_CH_MAP: + fp_encoder = ble_gap_opt_ch_map_t_enc; + p_struct = &(p_opt->gap_opt.ch_map); + break; + case BLE_GAP_OPT_LOCAL_CONN_LATENCY: + fp_encoder = ble_gap_opt_local_conn_latency_t_enc; + p_struct = &(p_opt->gap_opt.local_conn_latency); + break; + case BLE_GAP_OPT_PASSKEY: + fp_encoder = ble_gap_opt_passkey_t_enc; + p_struct = &(p_opt->gap_opt.passkey); + break; + case BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT: + fp_encoder = ble_gap_opt_auth_payload_timeout_t_enc; + p_struct = &(p_opt->gap_opt.auth_payload_timeout); + break; +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + case BLE_GAP_OPT_EXT_LEN: + fp_encoder = ble_gap_opt_ext_len_t_enc; + p_struct = &(p_opt->gap_opt.ext_len); + break; +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 + case BLE_GAP_OPT_SCAN_REQ_REPORT: + fp_encoder = ble_gap_opt_scan_req_report_t_enc; + p_struct = &(p_opt->gap_opt.scan_req_report); + break; +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + case BLE_GAP_OPT_COMPAT_MODE: + fp_encoder = ble_gap_opt_compat_mode_t_enc; + p_struct = &(p_opt->gap_opt.compat_mode); + break; +#else +#ifndef S112 + case BLE_GAP_OPT_COMPAT_MODE_1: + fp_encoder = ble_gap_opt_compat_mode_1_t_enc; + p_struct = &(p_opt->gap_opt.compat_mode_1); + break; +#endif + case BLE_GAP_OPT_SLAVE_LATENCY_DISABLE: + fp_encoder = ble_gap_opt_slave_latency_disable_t_enc; + p_struct = &(p_opt->gap_opt.slave_latency_disable); + break; +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION == 4 + case BLE_GAP_OPT_COMPAT_MODE_2: + fp_encoder = ble_gap_opt_compat_mode_2_t_enc; + p_struct = &(p_opt->gap_opt.compat_mode_2); + break; +#endif + default: + SER_ASSERT(NRF_ERROR_INVALID_PARAM,NRF_ERROR_INVALID_PARAM); + break; + } + + SER_PUSH_FIELD(p_struct, fp_encoder); + } + + SER_REQ_ENC_END; +} + + +uint32_t ble_opt_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_OPT_SET); +} + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_tx_packet_count_get_req_enc(uint16_t conn_handle, + uint8_t const * const p_count, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_TX_PACKET_COUNT_GET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_count, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_tx_packet_count_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * * const pp_count, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_TX_PACKET_COUNT_GET); + SER_PULL_COND(pp_count, uint8_t_dec); + SER_RSP_DEC_END; +} +#endif + +uint32_t ble_user_mem_reply_req_enc(uint16_t conn_handle, + ble_user_mem_block_t const * p_block, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_USER_MEM_REPLY); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_block, ble_user_mem_block_t_enc); + + SER_REQ_ENC_END; +} + +uint32_t ble_user_mem_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_USER_MEM_REPLY); +} + + + +uint32_t ble_uuid_decode_req_enc(uint8_t uuid_le_len, + uint8_t const * const p_uuid_le, + ble_uuid_t * const p_uuid, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_UUID_DECODE); + + SER_PUSH_len8data(p_uuid_le, uuid_le_len); + SER_PUSH_COND(p_uuid, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_uuid_decode_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_uuid_t * * const pp_uuid, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_UUID_DECODE); + SER_PULL_COND(pp_uuid, ble_uuid_t_dec); + SER_RSP_DEC_END; +} + + +uint32_t ble_uuid_encode_req_enc(ble_uuid_t const * const p_uuid, + uint8_t const * const p_uuid_le_len, + uint8_t const * const p_uuid_le, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_UUID_ENCODE); + + SER_PUSH_COND(p_uuid, ble_uuid_t_enc); + SER_PUSH_COND(p_uuid_le_len, NULL); + SER_PUSH_COND(p_uuid_le, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_uuid_encode_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * const p_uuid_le_len, + uint8_t * const p_uuid_le, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_UUID_ENCODE); + + uint8_t uuid_le_len; + SER_PULL_uint8(&uuid_le_len); + if (p_uuid_le_len) + { + *p_uuid_le_len = uuid_le_len; + if (p_uuid_le) + { + SER_PULL_uint8array(p_uuid_le, uuid_le_len); + } + } + + SER_RSP_DEC_END; +} + +uint32_t ble_uuid_vs_add_req_enc(ble_uuid128_t const * const p_vs_uuid, + uint8_t * const p_uuid_type, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_UUID_VS_ADD); + + SER_PUSH_COND(p_vs_uuid, ble_uuid128_t_enc); + SER_PUSH_COND(p_uuid_type, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_uuid_vs_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * * const pp_uuid_type, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_UUID_VS_ADD); + + SER_ASSERT_NOT_NULL(pp_uuid_type); + SER_PULL_COND(pp_uuid_type, uint8_t_dec); + + SER_RSP_DEC_END; +} + +uint32_t ble_version_get_req_enc(ble_version_t const * const p_version, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_VERSION_GET); + SER_PUSH_COND(p_version, NULL); + SER_REQ_ENC_END; +} + +uint32_t ble_version_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_version_t * p_version, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_VERSION_GET); + SER_PULL_FIELD(p_version, ble_version_t_dec); + SER_RSP_DEC_END; +} +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_cfg_set_req_enc(uint32_t cfg_id, + ble_cfg_t const * p_cfg, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_CFG_SET); + SER_PUSH_uint32(&cfg_id); + field_encoder_handler_t fp_encoder = NULL; + void const * p_struct = NULL; + + SER_PUSH_COND(p_cfg, NULL); + if (p_cfg) + { + + switch (cfg_id) + { + case BLE_CONN_CFG_GAP: + fp_encoder = ble_gap_conn_cfg_t_enc; + p_struct = &(p_cfg->conn_cfg.params.gap_conn_cfg); + break; + case BLE_CONN_CFG_GATTC: + fp_encoder = ble_gattc_conn_cfg_t_enc; + p_struct = &(p_cfg->conn_cfg.params.gattc_conn_cfg); + break; + case BLE_CONN_CFG_GATTS: + fp_encoder = ble_gatts_conn_cfg_t_enc; + p_struct = &(p_cfg->conn_cfg.params.gatts_conn_cfg); + break; + case BLE_CONN_CFG_GATT: + fp_encoder = ble_gatt_conn_cfg_t_enc; + p_struct = &(p_cfg->conn_cfg.params.gatt_conn_cfg); + break; +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION >= 5 && !defined(S112) + case BLE_CONN_CFG_L2CAP: + fp_encoder = ble_l2cap_conn_cfg_t_enc; + p_struct = &(p_cfg->conn_cfg.params.l2cap_conn_cfg); + break; +#endif + case BLE_COMMON_CFG_VS_UUID: + fp_encoder = ble_common_cfg_vs_uuid_t_enc; + p_struct = &(p_cfg->common_cfg.vs_uuid_cfg); + break; + case BLE_GAP_CFG_ROLE_COUNT: + fp_encoder = ble_gap_cfg_role_count_t_enc; + p_struct = &(p_cfg->gap_cfg.role_count_cfg); + break; + case BLE_GAP_CFG_DEVICE_NAME: + fp_encoder = ble_gap_cfg_device_name_t_enc; + p_struct = &(p_cfg->gap_cfg.device_name_cfg); + break; + case BLE_GATTS_CFG_SERVICE_CHANGED: + fp_encoder = ble_gatts_cfg_service_changed_t_enc; + p_struct = &(p_cfg->gatts_cfg.service_changed); + break; + case BLE_GATTS_CFG_ATTR_TAB_SIZE: + fp_encoder = ble_gatts_cfg_attr_tab_size_t_enc; + p_struct = &(p_cfg->gatts_cfg.attr_tab_size); + break; + } + if (cfg_id >= BLE_CONN_CFG_BASE && cfg_id <= BLE_CONN_CFG_GATT) + { + SER_PUSH_uint8(&p_cfg->conn_cfg.conn_cfg_tag); + } + SER_PUSH_FIELD(p_struct, fp_encoder); + } + SER_REQ_ENC_END; +} + + +uint32_t ble_cfg_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_CFG_SET); +} +#endif //NRF_SD_BLE_API_VERSION >= 4 diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_app.h new file mode 100644 index 000000000..e65f118d7 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_app.h @@ -0,0 +1,523 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_APP_H__ +#define BLE_APP_H__ + +/** + * @addtogroup ser_codecs Serialization codecs + * @ingroup ble_sdk_lib_serialization + */ + +/** + * @addtogroup ser_app_s130_codecs Application codecs for S132 and S140 + * @ingroup ser_codecs_app + */ + +/**@file + * + * @defgroup ble_app Application command request encoders and command response decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief Application command request encoders and command response decoders. + */ +#include "ble.h" + +#ifdef __cplusplus +extern "C" { +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +/** + * @brief Encodes @ref sd_ble_tx_packet_count_get command request. + * + * @sa @ref ble_tx_packet_count_get_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_count Pointer to count value to be filled. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @note \p p_count will not be updated by the command + * request encoder. Updated values are set by @ref ble_tx_packet_count_get_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_tx_packet_count_get_req_enc(uint16_t conn_handle, + uint8_t const * const p_count, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes a response to @ref sd_ble_tx_packet_count_get command. + * + * @sa @ref ble_tx_packet_count_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of a command response packet. + * @param[in] packet_len Length (in bytes) of the response packet. + * @param[out] pp_count Pointer to the pointer to count value. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_tx_packet_count_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * * const pp_count, + uint32_t * const p_result_code); +#endif +/**@brief Encodes the @ref sd_ble_uuid_encode command request. + * + * @sa @ref ble_uuid_encode_rsp_dec for command response decoder. + * + * @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes. + * @param[in] p_uuid_le_len Size of \p p_uuid_le, if \p p_uuid_le is not NULL + * @param[in] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes(2 or 16) + * will be stored. Can be NULL to calculate the required size. + * @param[in] p_buf Pointer to a buffer where the encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @note \p p_uuid_le_len and \p p_uuid_le will not be updated by the command + * request encoder. Updated values are set by @ref ble_uuid_encode_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_uuid_encode_req_enc(ble_uuid_t const * const p_uuid, + uint8_t const * const p_uuid_le_len, + uint8_t const * const p_uuid_le, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes a response to the @ref sd_ble_uuid_encode command. + * + * @sa @ref ble_uuid_encode_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of a command response packet. + * @param[in] packet_len Length (in bytes) of a response packet. + * @param[in,out] p_uuid_le_len \c in: Size (in bytes) of \p p_uuid_le buffer. + * \c out: Length of decoded contents of \p p_uuid_le. + * @param[out] p_uuid_le Pointer to a buffer where the encoded UUID will be stored. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Length of \p p_uuid_le is too small to hold the decoded + * value from response. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match the expected + * operation code. + */ +uint32_t ble_uuid_encode_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * const p_uuid_le_len, + uint8_t * const p_uuid_le, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_uuid_decode command request. + * + * @sa @ref ble_uuid_decode_rsp_dec for command response decoder. + * + * @param[in] uuid_le_len Size of \p p_uuid_le if \p p_uuid_le is not NULL. + * @param[in] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes(2 or 16) + * are stored. + * @param[out] p_uuid Pointer to a @ref ble_uuid_t structure were the raw UUID will be decoded. + * @param[in] p_buf Pointer to the buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @note \p p_uuid will not be updated by the command request encoder. + * Updated values are set by @ref ble_uuid_decode_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_uuid_decode_req_enc(uint8_t uuid_le_len, + uint8_t const * const p_uuid_le, + ble_uuid_t * const p_uuid, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes a response to the @ref sd_ble_uuid_decode command. + * + * @sa @ref ble_uuid_decode_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of command response packet. + * @param[in] packet_len Length (in bytes) of the response packet. + * @param[out] p_uuid Pointer to a buffer where the decoded UUID will be stored. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match the expected + * operation code. + */ +uint32_t ble_uuid_decode_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_uuid_t * * const p_uuid, + uint32_t * const p_result_code); + +/**@brief Encodes the @ref sd_ble_uuid_vs_add command request. + * + * @sa @ref ble_uuid_vs_add_rsp_dec for command response decoder. + * + * @param[in] p_vs_uuid Pointer to a @ref ble_uuid128_t structure. + * @param[in] p_uuid_type Pointer to uint8_t where UUID type will be returned. + * @param[in] p_buf Pointer to buffer where the encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_uuid_type will not be updated by the command request encoder. + * Updated values are set by @ref ble_uuid_vs_add_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_uuid_vs_add_req_enc(ble_uuid128_t const * const p_vs_uuid, + uint8_t * const p_uuid_type, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to the @ref sd_ble_uuid_vs_add command. + * + * @sa @ref ble_uuid_vs_add_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of command response packet. + * @param[in] packet_len Length (in bytes) of a response packet. + * @param[out] pp_uuid_type Pointer to a pointer to uint8_t where the decoded UUID type will be stored. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_uuid_vs_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * * const pp_uuid_type, + uint32_t * const p_result_code); + +/**@brief Encodes the @ref sd_ble_version_get command request. + * + * @sa @ref ble_version_get_rsp_dec for command response decoder. + * + * @param[in] p_version Pointer to a @ref ble_version_t structure to be filled by the response. + * @param[in] p_buf Pointer to a buffer where the encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_version_get_req_enc(ble_version_t const * const p_version, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to the @ref sd_ble_version_get command. + * + * @sa @ref ble_version_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of a command response packet. + * @param[in] packet_len Length (in bytes) of the response packet. + * @param[out] p_version Pointer to a @ref ble_version_t where the decoded version will be stored. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Version information stored successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + */ +uint32_t ble_version_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_version_t * p_version, + uint32_t * const p_result_code); + + +/**@brief Encodes the @ref sd_ble_opt_set command request. + * + * @sa @ref ble_opt_set_rsp_dec for command response decoder. + * + * @param[in] opt_id Identifies type of parameter in ble_opt_t union. + * @param[in] p_opt Pointer to the ble_opt_t union. + * @param[in] p_buf Pointer to a buffer where the encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. + */ +uint32_t ble_opt_set_req_enc(uint32_t const opt_id, + ble_opt_t const * const p_opt, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to the @ref sd_ble_opt_set command. + * + * @sa @ref ble_opt_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of a command response packet. + * @param[in] packet_len Length (in bytes) of the response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Version information stored successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t ble_opt_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +/**@brief Encodes the @ref sd_ble_enable command request. + * + * @sa @ref ble_enable_rsp_dec for command response decoder. + * + * @param[in] p_ble_enable_params Pointer to the @ref ble_enable_params_t structure. + * @param[in] p_buf Pointer to the buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_enable_req_enc(ble_enable_params_t * p_ble_enable_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); +#else +/**@brief Encodes the @ref sd_ble_enable command request. + * + * @sa @ref ble_enable_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to the buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_enable_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + +#endif + +/**@brief Decodes response to the @ref sd_ble_enable command. + * + * @sa @ref ble_enable_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of a command response packet. + * @param[in] packet_len Length (in bytes) of the response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Success. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + */ +uint32_t ble_enable_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +/**@brief Encodes the @ref sd_ble_opt_get command request. + * + * @sa @ref ble_opt_get_rsp_dec for command response decoder. + * + * @param[in] opt_id Identifies the type of parameter in the ble_opt_t union. + * @param[in] p_opt Pointer to the @ref ble_opt_t union to be filled by the response. + * @param[in] p_buf Pointer to the buffer where the encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. + */ +uint32_t ble_opt_get_req_enc(uint32_t opt_id, + ble_opt_t const * const p_opt, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to the @ref sd_ble_opt_get command. + * + * @sa @ref ble_opt_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of a command response packet. + * @param[in] packet_len Length (in bytes) of the response packet. + * @param[out] p_opt_id Pointer to the decoded opt_id. + * @param[out] p_opt Pointer to the decoded @ref ble_opt_t union. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Opt stored successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. + */ + +uint32_t ble_opt_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_opt_id, + ble_opt_t * const p_opt, + uint32_t * const p_result_code); + +/**@brief Encodes the @ref sd_ble_user_mem_reply command request. + * + * @sa @ref ble_user_mem_reply_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_block Pointer to the @ref ble_user_mem_block_t structure. + * @param[in] p_buf Pointer to the buffer where the encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. + */ +uint32_t ble_user_mem_reply_req_enc(uint16_t conn_handle, + ble_user_mem_block_t const * p_block, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to the @ref sd_ble_user_mem_reply command. + * + * @sa @ref ble_user_mem_reply_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of a command response packet. + * @param[in] packet_len Length (in bytes) of the response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Opt stored successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. + */ +uint32_t ble_user_mem_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +#if NRF_SD_BLE_API_VERSION >= 4 +/**@brief Encodes the @ref sd_ble_cfg_set command request. + * + * @sa @ref ble_cfg_set_rsp_dec for command response decoder. + * + * @param[in] cfg_id Configuratio id. + * @param[in] p_cfg Pointer to the configuration. + * @param[in] p_buf Pointer to the buffer where the encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of the encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. + */ +uint32_t ble_cfg_set_req_enc(uint32_t cfg_id, + ble_cfg_t const * p_cfg, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to the @ref sd_ble_cfg_set command. + * + * @sa @ref ble_cfg_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to the beginning of a command response packet. + * @param[in] packet_len Length (in bytes) of the response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Opt stored successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + * @retval NRF_ERROR_INVALID_PARAM Invalid opt id. + */ +uint32_t ble_cfg_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +#endif //NRF_SD_BLE_API_VERSION >= 4 + +/**@brief Event decoding dispatcher. + * + * The event decoding dispatcher will route the event packet to the correct decoder, which in turn + * decodes the contents of the event and updates the \p p_event struct. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of the event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to the \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, the required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of the decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + * @retval NRF_ERROR_NOT_FOUND Decoding failure. No event decoder is available. + */ +uint32_t ble_event_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_event.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_event.c new file mode 100644 index 000000000..de719c9af --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_event.c @@ -0,0 +1,326 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_serialization.h" +#include "ble_app.h" +#include "ble_evt_app.h" +#include "ble_gap_evt_app.h" +#include "ble_gattc_evt_app.h" +#include "ble_gatts_evt_app.h" +#include "ble_l2cap_evt_app.h" +#include "app_util.h" + +uint32_t ble_event_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + uint32_t err_code; + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_event_len); + SER_ASSERT_LENGTH_LEQ(SER_EVT_HEADER_SIZE, packet_len); + SER_ASSERT_NOT_NULL(p_event); + SER_ASSERT_LENGTH_LEQ(sizeof (ble_evt_hdr_t), *p_event_len); + *p_event_len -= sizeof (ble_evt_hdr_t); + + const uint16_t event_id = uint16_decode(&p_buf[SER_EVT_ID_POS]); + const uint8_t * p_sub_buffer = &p_buf[SER_EVT_HEADER_SIZE]; + const uint32_t sub_packet_len = packet_len - SER_EVT_HEADER_SIZE; + + uint32_t (*fp_event_decoder)(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) = NULL; + + switch (event_id) + { +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + case BLE_EVT_TX_COMPLETE: + fp_event_decoder = ble_evt_tx_complete_dec; + break; + case BLE_EVT_DATA_LENGTH_CHANGED: + fp_event_decoder = ble_evt_data_length_changed_dec; + break; +#endif + case BLE_EVT_USER_MEM_REQUEST: + fp_event_decoder = ble_evt_user_mem_request_dec; + break; + + case BLE_EVT_USER_MEM_RELEASE: + fp_event_decoder = ble_evt_user_mem_release_dec; + break; + + + case BLE_GAP_EVT_PASSKEY_DISPLAY: + fp_event_decoder = ble_gap_evt_passkey_display_dec; + break; + + case BLE_GAP_EVT_AUTH_KEY_REQUEST: + fp_event_decoder = ble_gap_evt_auth_key_request_dec; + break; + + case BLE_GAP_EVT_CONN_PARAM_UPDATE: + fp_event_decoder = ble_gap_evt_conn_param_update_dec; + break; + +#ifndef S112 + case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: + fp_event_decoder = ble_gap_evt_conn_param_update_request_dec; + break; +#endif + case BLE_GAP_EVT_CONN_SEC_UPDATE: + fp_event_decoder = ble_gap_evt_conn_sec_update_dec; + break; + + case BLE_GAP_EVT_CONNECTED: + fp_event_decoder = ble_gap_evt_connected_dec; + break; + + case BLE_GAP_EVT_DISCONNECTED: + fp_event_decoder = ble_gap_evt_disconnected_dec; + break; + + case BLE_GAP_EVT_TIMEOUT: + fp_event_decoder = ble_gap_evt_timeout_dec; + break; + + case BLE_GAP_EVT_RSSI_CHANGED: + fp_event_decoder = ble_gap_evt_rssi_changed_dec; + break; + + case BLE_GAP_EVT_SEC_INFO_REQUEST: + fp_event_decoder = ble_gap_evt_sec_info_request_dec; + break; + + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: + fp_event_decoder = ble_gap_evt_sec_params_request_dec; + break; + + case BLE_GAP_EVT_AUTH_STATUS: + fp_event_decoder = ble_gap_evt_auth_status_dec; + break; + + case BLE_GAP_EVT_SEC_REQUEST: + fp_event_decoder = ble_gap_evt_sec_request_dec; + break; + + case BLE_GAP_EVT_KEY_PRESSED: + fp_event_decoder = ble_gap_evt_key_pressed_dec; + break; + + case BLE_GAP_EVT_LESC_DHKEY_REQUEST: + fp_event_decoder = ble_gap_evt_lesc_dhkey_request_dec; + break; +#if NRF_SD_BLE_API_VERSION >= 5 + case BLE_GAP_EVT_PHY_UPDATE: + fp_event_decoder = ble_gap_evt_phy_update_dec; + break; + case BLE_GAP_EVT_PHY_UPDATE_REQUEST: + fp_event_decoder = ble_gap_evt_phy_update_request_dec; + break; +#endif +#if NRF_SD_BLE_API_VERSION >= 6 +#ifndef S112 + case BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT: + fp_event_decoder = ble_gap_evt_qos_channel_survey_report_dec; + break; +#endif + case BLE_GAP_EVT_ADV_SET_TERMINATED: + fp_event_decoder = ble_gap_evt_adv_set_terminated_dec; + break; +#endif +#if NRF_SD_BLE_API_VERSION >= 4 && !defined(S112) + case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: + fp_event_decoder = ble_gap_evt_data_length_update_request_dec; + break; + case BLE_GAP_EVT_DATA_LENGTH_UPDATE: + fp_event_decoder = ble_gap_evt_data_length_update_dec; + break; +#endif + case BLE_GATTC_EVT_CHAR_DISC_RSP: + fp_event_decoder = ble_gattc_evt_char_disc_rsp_dec; + break; + + case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP: + fp_event_decoder = ble_gattc_evt_char_val_by_uuid_read_rsp_dec; + break; + + case BLE_GATTC_EVT_DESC_DISC_RSP: + fp_event_decoder = ble_gattc_evt_desc_disc_rsp_dec; + break; + + case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: + fp_event_decoder = ble_gattc_evt_prim_srvc_disc_rsp_dec; + break; + + case BLE_GATTC_EVT_READ_RSP: + fp_event_decoder = ble_gattc_evt_read_rsp_dec; + break; + + case BLE_GATTC_EVT_HVX: + fp_event_decoder = ble_gattc_evt_hvx_dec; + break; + + case BLE_GATTC_EVT_TIMEOUT: + fp_event_decoder = ble_gattc_evt_timeout_dec; + break; + + case BLE_GATTC_EVT_WRITE_RSP: + fp_event_decoder = ble_gattc_evt_write_rsp_dec; + break; + + case BLE_GATTC_EVT_CHAR_VALS_READ_RSP: + fp_event_decoder = ble_gattc_evt_char_vals_read_rsp_dec; + break; + + case BLE_GATTC_EVT_REL_DISC_RSP: + fp_event_decoder = ble_gattc_evt_rel_disc_rsp_dec; + break; + + case BLE_GATTC_EVT_ATTR_INFO_DISC_RSP: + fp_event_decoder = ble_gattc_evt_attr_info_disc_rsp_dec; + break; + + case BLE_GATTC_EVT_EXCHANGE_MTU_RSP: + fp_event_decoder = ble_gattc_evt_exchange_mtu_rsp_dec; + break; +#if NRF_SD_BLE_API_VERSION >= 4 + case BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE: + fp_event_decoder = ble_gattc_evt_write_cmd_tx_complete_dec; + break; +#endif + case BLE_GATTS_EVT_WRITE: + fp_event_decoder = ble_gatts_evt_write_dec; + break; + + case BLE_GATTS_EVT_TIMEOUT: + fp_event_decoder = ble_gatts_evt_timeout_dec; + break; + + case BLE_GATTS_EVT_SC_CONFIRM: + fp_event_decoder = ble_gatts_evt_sc_confirm_dec; + break; + + case BLE_GATTS_EVT_HVC: + fp_event_decoder = ble_gatts_evt_hvc_dec; + break; + + case BLE_GATTS_EVT_SYS_ATTR_MISSING: + fp_event_decoder = ble_gatts_evt_sys_attr_missing_dec; + break; + + case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: + fp_event_decoder = ble_gatts_evt_rw_authorize_request_dec; + break; + + case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: + fp_event_decoder = ble_gatts_evt_exchange_mtu_request_dec; + break; +#if NRF_SD_BLE_API_VERSION >= 4 + case BLE_GATTS_EVT_HVN_TX_COMPLETE: + fp_event_decoder = ble_gatts_evt_hvn_tx_complete_dec; + break; +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + case BLE_L2CAP_EVT_RX: + fp_event_decoder = ble_l2cap_evt_rx_dec; + break; +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION >= 5 && !defined(S112) + case BLE_L2CAP_EVT_CH_SETUP_REQUEST: + fp_event_decoder = ble_l2cap_evt_ch_setup_request_dec; + break; + + case BLE_L2CAP_EVT_CH_SETUP_REFUSED: + fp_event_decoder = ble_l2cap_evt_ch_setup_refused_dec; + break; + + case BLE_L2CAP_EVT_CH_SETUP: + fp_event_decoder = ble_l2cap_evt_ch_setup_dec; + break; + + case BLE_L2CAP_EVT_CH_RELEASED: + fp_event_decoder = ble_l2cap_evt_ch_released_dec; + break; + + case BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED: + fp_event_decoder = ble_l2cap_evt_ch_sdu_buf_released_dec; + break; + + case BLE_L2CAP_EVT_CH_CREDIT: + fp_event_decoder = ble_l2cap_evt_ch_credit_dec; + break; + + case BLE_L2CAP_EVT_CH_RX: + fp_event_decoder = ble_l2cap_evt_ch_rx_dec; + break; + + case BLE_L2CAP_EVT_CH_TX: + fp_event_decoder = ble_l2cap_evt_ch_tx_dec; + break; + +#endif +#ifndef S112 + case BLE_GAP_EVT_ADV_REPORT: + fp_event_decoder = ble_gap_evt_adv_report_dec; + break; +#endif + case BLE_GAP_EVT_SCAN_REQ_REPORT: + fp_event_decoder = ble_gap_evt_scan_req_report_dec; + break; + default: + break; + } + + if (fp_event_decoder) + { + err_code = fp_event_decoder(p_sub_buffer, sub_packet_len, p_event, p_event_len); + } + else + { + err_code = NRF_ERROR_NOT_FOUND; + } + + *p_event_len += offsetof(ble_evt_t, evt); + p_event->header.evt_id = (err_code == NRF_SUCCESS) ? event_id : 0; + p_event->header.evt_len = (err_code == NRF_SUCCESS) ? (uint16_t)*p_event_len : 0; + + return err_code; +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_evt_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_evt_app.c new file mode 100644 index 000000000..d85c990d4 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_evt_app.c @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2015 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_serialization.h" +#include "ble_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" +#include "ble_evt_app.h" +#include "app_ble_user_mem.h" + + +// Helper definitions for common event type names to be compliant with +// event serialization macros. +#define ble_common_evt_tx_complete_t ble_evt_tx_complete_t +#define ble_common_evt_user_mem_request_t ble_evt_user_mem_request_t +#define ble_common_evt_user_mem_release_t ble_evt_user_mem_release_t +#define ble_common_evt_data_length_changed_t ble_evt_data_length_changed_t + + +extern ser_ble_user_mem_t m_app_user_mem_table[]; + +uint32_t ble_evt_user_mem_release_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_EVT_USER_MEM_RELEASE, common, user_mem_release); + + SER_PULL_uint16(&p_event->evt.common_evt.conn_handle); + SER_PULL_uint8(&p_event->evt.common_evt.params.user_mem_release.type); + SER_PULL_uint16(&p_event->evt.common_evt.params.user_mem_release.mem_block.len); + + //Set the memory pointer to not-null value. + p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem = (uint8_t *)~0; + SER_PULL_COND(&p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem, NULL); + if (p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem) + { + // Using connection handle find which mem block to release in Application Processor + uint32_t user_mem_table_index; + err_code = app_ble_user_mem_context_find(p_event->evt.common_evt.conn_handle, &user_mem_table_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + p_event->evt.common_evt.params.user_mem_release.mem_block.p_mem = + m_app_user_mem_table[user_mem_table_index].mem_block.p_mem; + } + + // Now user memory context can be released + err_code = app_ble_user_mem_context_destroy(p_event->evt.common_evt.conn_handle); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + SER_EVT_DEC_END; +} + +uint32_t ble_evt_user_mem_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_EVT_USER_MEM_REQUEST, common, user_mem_request); + + SER_PULL_uint16(&p_event->evt.common_evt.conn_handle); + SER_PULL_uint8(&p_event->evt.common_evt.params.user_mem_request.type); + + SER_EVT_DEC_END; +} + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_evt_tx_complete_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_EVT_TX_COMPLETE, common, tx_complete); + + SER_PULL_uint16(&p_event->evt.common_evt.conn_handle); + SER_PULL_uint8(&p_event->evt.common_evt.params.tx_complete.count); + + SER_EVT_DEC_END; +} + + +uint32_t ble_evt_data_length_changed_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_EVT_DATA_LENGTH_CHANGED, common, data_length_changed); + + SER_PULL_uint16(&p_event->evt.common_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.common_evt.params.data_length_changed, ble_evt_data_length_changed_t_dec); + + SER_EVT_DEC_END; +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_evt_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_evt_app.h new file mode 100644 index 000000000..fc36a67a0 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_evt_app.h @@ -0,0 +1,157 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_EVT_APP_H__ +#define BLE_EVT_APP_H__ + +/**@file + * + * @defgroup ble_evt_app Application event decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief Application event decoders. + */ +#include "ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +/** + * @brief Decodes the ble_evt_tx_complete event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of the event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to the \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, the required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of the \p p_event buffer. + * \c out: Length of the decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + */ +uint32_t ble_evt_tx_complete_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +#endif +/** + * @brief Decodes the ble_evt_user_mem_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of the event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to the \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, the required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of the \p p_event buffer. + * \c out: Length of the decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + */ +uint32_t ble_evt_user_mem_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes the ble_evt_user_mem_release event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of the event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to the \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, the required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of the \p p_event buffer. + * \c out: Length of the decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + */ +uint32_t ble_evt_user_mem_release_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +/** + * @brief Decodes the ble_evt_data_length_changed event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of the event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to the \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, the required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of the \p p_event buffer. + * \c out: Length of the decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold the decoded event. + */ +uint32_t ble_evt_data_length_changed_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_app.c new file mode 100644 index 000000000..1d2ad1b41 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_app.c @@ -0,0 +1,1018 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gap_app.h" +#include +#include +#include "ble_serialization.h" +#include "ble_gap_struct_serialization.h" +#include "ble_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 +uint32_t ble_gap_adv_data_set_req_enc(uint8_t const * const p_data, + uint8_t dlen, + uint8_t const * const p_sr_data, + uint8_t srdlen, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_ADV_DATA_SET); + + SER_PUSH_len8data(p_data, dlen); + SER_PUSH_len8data(p_sr_data, srdlen); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_adv_data_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_ADV_DATA_SET); +} +#endif + +uint32_t ble_gap_adv_start_req_enc( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t adv_handle, +#else + ble_gap_adv_params_t const * const p_adv_params, +#endif +#if NRF_SD_BLE_API_VERSION >= 4 + uint8_t conn_cfg_tag, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_ADV_START); + +#if NRF_SD_BLE_API_VERSION > 5 + SER_PUSH_uint8(&adv_handle); +#else + SER_PUSH_COND(p_adv_params, ble_gap_adv_params_t_enc); +#endif + +#if NRF_SD_BLE_API_VERSION >= 4 + SER_PUSH_uint8(&conn_cfg_tag); +#endif + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_adv_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_ADV_START); +} + + +uint32_t ble_gap_adv_stop_req_enc( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t adv_handle, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_ADV_STOP); +#if NRF_SD_BLE_API_VERSION > 5 + SER_PUSH_uint8(&adv_handle); +#endif + SER_REQ_ENC_END; +} + +uint32_t ble_gap_adv_stop_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_ADV_STOP); +} + + + +uint32_t ble_gap_appearance_get_req_enc(uint16_t const * const p_appearance, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_APPEARANCE_GET); + SER_PUSH_COND(p_appearance, NULL); + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_appearance_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * const p_appearance, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_APPEARANCE_GET); + SER_PULL_COND(&p_appearance, uint16_t_dec); + SER_RSP_DEC_END; +} + + +uint32_t ble_gap_appearance_set_req_enc(uint16_t appearance, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_APPEARANCE_SET); + SER_PUSH_uint16(&appearance); + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_appearance_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_APPEARANCE_SET); +} + + +uint32_t ble_gap_auth_key_reply_req_enc(uint16_t conn_handle, + uint8_t key_type, + uint8_t const * const p_key, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_AUTH_KEY_REPLY); + + uint8_t key_len; + switch (key_type) + { + case BLE_GAP_AUTH_KEY_TYPE_NONE: + key_len = 0; + break; + + case BLE_GAP_AUTH_KEY_TYPE_PASSKEY: + key_len = 6; + break; + + case BLE_GAP_AUTH_KEY_TYPE_OOB: + key_len = 16; + break; + + default: + return NRF_ERROR_INVALID_PARAM; + } + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint8(&key_type); + SER_PUSH_buf(p_key, key_len); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_auth_key_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_AUTH_KEY_REPLY); +} + + + +uint32_t ble_gap_authenticate_req_enc(uint16_t conn_handle, + ble_gap_sec_params_t const * const p_sec_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_AUTHENTICATE); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_sec_params, ble_gap_sec_params_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_authenticate_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_AUTHENTICATE); +} + + +uint32_t ble_gap_conn_param_update_req_enc(uint16_t conn_handle, + ble_gap_conn_params_t const * const p_conn_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_CONN_PARAM_UPDATE); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_conn_params, ble_gap_conn_params_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_conn_param_update_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_CONN_PARAM_UPDATE); +} + + +uint32_t ble_gap_conn_sec_get_req_enc(uint16_t conn_handle, + ble_gap_conn_sec_t const * const p_conn_sec, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_CONN_SEC_GET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_conn_sec, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_conn_sec_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_conn_sec_t * * const pp_conn_sec, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_CONN_SEC_GET); + SER_PULL_COND(pp_conn_sec, ble_gap_conn_sec_t_dec); + SER_RSP_DEC_END; +} + +#ifndef S112 +uint32_t ble_gap_connect_req_enc(ble_gap_addr_t const * const p_peer_addr, + ble_gap_scan_params_t const * const p_scan_params, + ble_gap_conn_params_t const * const p_conn_params, +#if NRF_SD_BLE_API_VERSION >= 4 + uint8_t conn_cfg_tag, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_CONNECT); + + SER_PUSH_COND(p_peer_addr, ble_gap_addr_t_enc); + SER_PUSH_COND(p_scan_params, ble_gap_scan_params_t_enc); + SER_PUSH_COND(p_conn_params, ble_gap_conn_params_t_enc); +#if NRF_SD_BLE_API_VERSION >= 4 + SER_PUSH_uint8(&conn_cfg_tag); +#endif + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_connect_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_CONNECT); +} + + +uint32_t ble_gap_connect_cancel_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_CONNECT_CANCEL); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_connect_cancel_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_CONNECT_CANCEL); +} +#endif + +uint32_t ble_gap_device_name_get_req_enc(uint8_t const * const p_dev_name, + uint16_t const * const p_len, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_DEVICE_NAME_GET); + + SER_PUSH_COND(p_len, uint16_t_enc); + SER_PUSH_COND(p_dev_name, NULL); + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_device_name_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * const p_dev_name, + uint16_t * const p_dev_name_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_DEVICE_NAME_GET); + uint16_t cpy_len = 0xffff; + SER_PULL_COND(&p_dev_name_len, uint16_t_dec); + SER_PULL_len16data((uint8_t **)&p_dev_name, &cpy_len); + + SER_RSP_DEC_END; +} + + +uint32_t ble_gap_device_name_set_req_enc(ble_gap_conn_sec_mode_t const * const p_write_perm, + uint8_t const * const p_dev_name, + uint16_t len, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_DEVICE_NAME_SET); + + SER_ERROR_CHECK(len <= BLE_GAP_DEVNAME_MAX_LEN, NRF_ERROR_INVALID_PARAM); + + SER_PUSH_COND(p_write_perm, ble_gap_conn_sec_mode_t_enc); + SER_PUSH_len16data(p_dev_name, len); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_device_name_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_DEVICE_NAME_SET); +} + + +uint32_t ble_gap_disconnect_req_enc(uint16_t conn_handle, + uint8_t hci_status_code, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_DISCONNECT); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint8(&hci_status_code); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_disconnect_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_DISCONNECT); +} + +#ifndef S112 +uint32_t ble_gap_encrypt_req_enc(uint16_t conn_handle, + ble_gap_master_id_t const * const p_master_id, + ble_gap_enc_info_t const * const p_enc_info, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_ENCRYPT); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_master_id, ble_gap_master_id_t_enc); + SER_PUSH_COND(p_enc_info, ble_gap_enc_info_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_encrypt_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_ENCRYPT); +} +#endif + +uint32_t ble_gap_keypress_notify_req_enc(uint16_t conn_handle, + uint8_t kp_not, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_KEYPRESS_NOTIFY); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint8(&kp_not); + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_keypress_notify_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_KEYPRESS_NOTIFY); +} + + +uint32_t ble_gap_lesc_dhkey_reply_req_enc(uint16_t conn_handle, + ble_gap_lesc_dhkey_t const *p_dhkey, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_LESC_DHKEY_REPLY); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_dhkey, ble_gap_lesc_dhkey_t_enc); + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_lesc_dhkey_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_LESC_DHKEY_REPLY); +} + + +uint32_t ble_gap_lesc_oob_data_get_req_enc(uint16_t conn_handle, + ble_gap_lesc_p256_pk_t const *p_pk_own, + ble_gap_lesc_oob_data_t *p_oobd_own, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_LESC_OOB_DATA_GET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_pk_own, ble_gap_lesc_p256_pk_t_enc); + SER_PUSH_COND(p_oobd_own, NULL); + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_lesc_oob_data_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_lesc_oob_data_t * *pp_oobd_own, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_LESC_OOB_DATA_GET); + SER_PULL_COND(pp_oobd_own, ble_gap_lesc_oob_data_t_dec); + SER_RSP_DEC_END; +} + + +uint32_t ble_gap_lesc_oob_data_set_req_enc(uint16_t conn_handle, + ble_gap_lesc_oob_data_t const *p_oobd_own, + ble_gap_lesc_oob_data_t const *p_oobd_peer, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_LESC_OOB_DATA_SET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_oobd_own, ble_gap_lesc_oob_data_t_enc); + SER_PUSH_COND(p_oobd_peer, ble_gap_lesc_oob_data_t_enc); + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_lesc_oob_data_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_LESC_OOB_DATA_SET); +} + + +uint32_t ble_gap_ppcp_get_req_enc(ble_gap_conn_params_t const * const p_conn_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_PPCP_GET); + SER_PUSH_COND(p_conn_params, NULL); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_ppcp_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_conn_params_t * const p_conn_params, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_PPCP_GET); + SER_PULL_COND(&p_conn_params, ble_gap_conn_params_t_dec); + SER_RSP_DEC_END; +} + + +uint32_t ble_gap_ppcp_set_req_enc(ble_gap_conn_params_t const * const p_conn_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_PPCP_SET); + SER_PUSH_COND(p_conn_params, ble_gap_conn_params_t_enc); + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_ppcp_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_PPCP_SET); +} + +uint32_t ble_gap_rssi_get_req_enc(uint16_t conn_handle, + int8_t const * const p_rssi, +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t const * const p_ch_index, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_RSSI_GET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_rssi, NULL); +#if NRF_SD_BLE_API_VERSION > 5 + SER_PUSH_COND(p_ch_index, NULL); +#endif + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_rssi_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + int8_t * const p_rssi, +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t * const p_ch_index, +#endif + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_RSSI_GET); + SER_PULL_COND(&p_rssi, uint8_t_dec); +#if NRF_SD_BLE_API_VERSION > 5 + SER_PULL_COND(&p_ch_index, uint8_t_dec); +#endif + SER_RSP_DEC_END; +} + + +uint32_t ble_gap_rssi_start_req_enc(uint16_t conn_handle, + uint8_t threshold_dbm, + uint8_t skip_count, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_RSSI_START); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint8(&threshold_dbm); + SER_PUSH_uint8(&skip_count); + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_rssi_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_RSSI_START); +} + + +uint32_t ble_gap_rssi_stop_req_enc(uint16_t conn_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_RSSI_STOP); + SER_PUSH_uint16(&conn_handle); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_rssi_stop_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_RSSI_STOP); +} + +#ifndef S112 +uint32_t ble_gap_scan_start_req_enc(ble_gap_scan_params_t const * p_scan_params, +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + ble_data_t const * p_adv_report_buffer, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_SCAN_START); + SER_PUSH_COND(p_scan_params, ble_gap_scan_params_t_enc); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + SER_PUSH_COND(p_adv_report_buffer, ble_data_t_enc); +#endif + SER_REQ_ENC_END; +} +uint32_t ble_gap_scan_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_SCAN_START); + +} + + +uint32_t ble_gap_scan_stop_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_SCAN_STOP); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_scan_stop_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_SCAN_STOP); +} +#endif + +uint32_t ble_gap_sec_info_reply_req_enc(uint16_t conn_handle, + ble_gap_enc_info_t const * p_enc_info, + ble_gap_irk_t const * p_id_info, + ble_gap_sign_info_t const * p_sign_info, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_SEC_INFO_REPLY); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_enc_info, ble_gap_enc_info_t_enc); + SER_PUSH_COND(p_id_info, ble_gap_irk_t_enc); + SER_PUSH_COND(p_sign_info, ble_gap_sign_info_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_sec_info_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_SEC_INFO_REPLY); +} + + +uint32_t ble_gap_sec_params_reply_req_enc(uint16_t conn_handle, + uint8_t sec_status, + ble_gap_sec_params_t const * const p_sec_params, + ble_gap_sec_keyset_t const * const p_sec_keyset, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_SEC_PARAMS_REPLY); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint8(&sec_status); + SER_PUSH_COND(p_sec_params, ble_gap_sec_params_t_enc); + SER_PUSH_COND(p_sec_keyset, ble_gap_sec_keyset_t_enc); + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_sec_params_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_sec_keyset_t const * const p_sec_keyset, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_SEC_PARAMS_REPLY); + SER_PULL_COND(&p_sec_keyset, ble_gap_sec_keyset_t_dec); + SER_RSP_DEC_END; +} + + +uint32_t ble_gap_tx_power_set_req_enc( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t role, uint16_t handle, +#endif + int8_t tx_power, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_TX_POWER_SET); +#if NRF_SD_BLE_API_VERSION > 5 + SER_PUSH_uint8(&role); + SER_PUSH_uint16(&handle); +#endif + SER_PUSH_int8(&tx_power); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_tx_power_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_TX_POWER_SET); +} + +uint32_t ble_gap_addr_get_req_enc(ble_gap_addr_t const * const p_address, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_ADDR_GET); + SER_PUSH_COND(p_address, NULL); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_addr_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_addr_t * const p_address, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_ADDR_GET); + SER_PULL_FIELD(p_address, ble_gap_addr_t_dec); + SER_RSP_DEC_END; +} + +uint32_t ble_gap_addr_set_req_enc(ble_gap_addr_t const * const p_addr, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_ADDR_SET); + SER_PUSH_COND(p_addr, ble_gap_addr_t_enc); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_addr_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_ADDR_SET); +} + +uint32_t ble_gap_privacy_set_req_enc(ble_gap_privacy_params_t const * p_privacy_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_PRIVACY_SET); + SER_PUSH_COND(p_privacy_params, ble_gap_privacy_params_t_enc); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_privacy_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_PRIVACY_SET); +} + + +uint32_t ble_gap_privacy_get_req_enc(ble_gap_privacy_params_t const * const p_privacy_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_PRIVACY_GET); + SER_PUSH_COND(p_privacy_params, ble_gap_privacy_params_t_enc); + SER_REQ_ENC_END; +} + +uint32_t ble_gap_privacy_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_privacy_params_t const * const p_privacy_params, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_PRIVACY_GET); + SER_PULL_COND((void **)&p_privacy_params, ble_gap_privacy_params_t_dec); + SER_RSP_DEC_END; +} + +uint32_t ble_gap_whitelist_set_req_enc(ble_gap_addr_t const * const * const pp_wl_addrs, + uint8_t const len, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_WHITELIST_SET); + + uint8_t presence; + SER_PUSH_uint8(&len); + + if (pp_wl_addrs) + { + presence = SER_FIELD_PRESENT; + SER_PUSH_uint8(&presence); + + for (uint32_t i = 0; i < len; ++i) + { + SER_PUSH_COND(pp_wl_addrs[i], ble_gap_addr_t_enc); + } + } + else + { + presence = SER_FIELD_NOT_PRESENT; + SER_PUSH_uint8(&presence); + } + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_whitelist_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_WHITELIST_SET); +} + +uint32_t ble_gap_device_identities_set_req_enc(ble_gap_id_key_t const * const * const pp_id_keys, + ble_gap_irk_t const * const * const pp_local_irks, + uint8_t const len, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_DEVICE_IDENTITIES_SET); + uint8_t presence; + SER_PUSH_uint8(&len); + + if (pp_id_keys) + { + presence = SER_FIELD_PRESENT; + SER_PUSH_uint8(&presence); + + for (uint32_t i = 0; i < len; ++i) + { + SER_PUSH_COND(pp_id_keys[i], ble_gap_id_key_t_enc); + } + } + else + { + presence = SER_FIELD_NOT_PRESENT; + SER_PUSH_uint8(&presence); + } + + if (pp_local_irks) + { + presence = SER_FIELD_PRESENT; + SER_PUSH_uint8(&presence); + + for (uint32_t i = 0; i < len; ++i) + { + SER_PUSH_COND(pp_local_irks[i], ble_gap_irk_t_enc); + } + } + else + { + presence = SER_FIELD_NOT_PRESENT; + SER_PUSH_uint8(&presence); + } + + SER_REQ_ENC_END; +} + +uint32_t ble_gap_device_identities_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_DEVICE_IDENTITIES_SET); +} +#if NRF_SD_BLE_API_VERSION >= 4 && !defined(S112) +uint32_t ble_gap_data_length_update_req_enc(uint16_t conn_handle, + ble_gap_data_length_params_t const * p_dl_params, + ble_gap_data_length_limitation_t * p_dl_limitation, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_DATA_LENGTH_UPDATE); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_dl_params, ble_gap_data_length_params_t_enc); + SER_PUSH_COND(p_dl_limitation, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_data_length_update_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_data_length_limitation_t * p_dl_limitation, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_DATA_LENGTH_UPDATE); + SER_PULL_COND((void **)&p_dl_limitation, ble_gap_data_length_limitation_t_dec); + SER_RSP_DEC_END; +} +#endif +#if NRF_SD_BLE_API_VERSION >= 5 +uint32_t ble_gap_phy_update_req_enc(uint16_t conn_handle, + ble_gap_phys_t const * p_gap_phys, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_PHY_UPDATE); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_gap_phys, ble_gap_phys_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_phy_update_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_PHY_UPDATE); +} +#endif + +#if NRF_SD_BLE_API_VERSION > 5 +uint32_t ble_gap_adv_set_configure_req_enc(uint8_t * p_adv_handle, + ble_gap_adv_data_t const * p_adv_data, + ble_gap_adv_params_t const *p_adv_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_ADV_SET_CONFIGURE); + + SER_PUSH_COND(p_adv_handle, uint8_t_enc); + SER_PUSH_COND(p_adv_data, ble_gap_adv_data_t_enc); + SER_PUSH_COND(p_adv_params, ble_gap_adv_params_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_adv_set_configure_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * p_adv_handle, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GAP_ADV_SET_CONFIGURE); + SER_PULL_COND((void **)&p_adv_handle, uint8_t_dec); + + SER_RSP_DEC_END; +} + +#ifndef S112 +uint32_t ble_gap_qos_channel_survey_start_req_enc(uint32_t interval_us, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START); + + SER_PUSH_uint32(&interval_us); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_qos_channel_survey_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START); +} + +uint32_t ble_gap_qos_channel_survey_stop_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP); + SER_REQ_ENC_END; +} + + +uint32_t ble_gap_qos_channel_survey_stop_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP); +} +#endif //!S112 +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_app.h new file mode 100644 index 000000000..2addfeaf3 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_app.h @@ -0,0 +1,1667 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GAP_APP_H__ +#define BLE_GAP_APP_H__ + +/**@file + * + * @defgroup ble_gap_app GAP Application command request encoders and command response decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief GAP Application command request encoders and command response decoders. + */ +#include "ble.h" +#include "ble_gap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && (NRF_SD_BLE_API_VERSION <= 5) +/** + * @brief Encodes @ref sd_ble_gap_adv_data_set command request. + * + * @sa @ref ble_gap_adv_data_set_rsp_dec for command response decoder. + * + * @param[in] p_data Raw data to be placed in advertisement packet. If NULL, no changes + * are made to the current advertisement packet data. + * @param[in] dlen Data length for p_data. Max size: @ref BLE_GAP_ADV_SR_MAX_LEN_DEFAULT octets. + * Should be 0 if p_data is NULL, can be 0 if p_data is not NULL. + * @param[in] p_sr_data Raw data to be placed in scan response packet. If NULL, + * no changes are made to the current scan response packet data. + * @param[in] srdlen Data length for p_sr_data. Max size: @ref BLE_GAP_ADV_SR_MAX_LEN_DEFAULT octets. + * Should be 0 if p_sr_data is NULL, can be 0 if p_data is not NULL. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_adv_data_set_req_enc(uint8_t const * const p_data, + uint8_t dlen, + uint8_t const * const p_sr_data, + uint8_t srdlen, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_adv_data_set command. + * + * @sa @ref ble_gap_adv_data_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_adv_data_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +#endif + +/** + * @brief Encodes @ref sd_ble_gap_adv_start command request. + * + * @sa @ref ble_gap_adv_start_rsp_dec for command response decoder. + * + * @param[in] p_adv_params Pointer to advertising parameters structure. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_adv_start_req_enc( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t adv_handle, +#else + ble_gap_adv_params_t const * const p_adv_params, +#endif +#if NRF_SD_BLE_API_VERSION >= 4 + uint8_t conn_cfg_tag, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_adv_start command. + * + * @sa @ref ble_gap_adv_start_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_adv_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_tx_power_set command request. + * + * @sa @ref ble_gap_tx_power_set_rsp_dec for command response decoder. + * + * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_tx_power_set_req_enc( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t role, uint16_t handle, +#endif + int8_t tx_power, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_tx_power_set command. + * + * @sa @ref ble_gap_tx_power_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_tx_power_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_appearance_get command request. + * + * @sa @ref ble_gap_appearance_get_rsp_dec for command response decoder. + * + * @param[in] p_appearance Appearance (16 bit), see @ref BLE_APPEARANCES. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_appearance will not be updated by the command + * request encoder. Updated values are set by @ref ble_gap_appearance_get_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_appearance_get_req_enc(uint16_t const * const p_appearance, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_appearance_get command. + * + * @sa @ref ble_gap_appearance_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_appearance Appearance (16 bit), see @ref BLE_APPEARANCES. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_appearance_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * const p_appearance, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_appearance_set command request. + * + * @sa @ref ble_gap_appearance_set_rsp_dec for command response decoder. + * + * @param[in] appearance Appearance (16 bit), see @ref BLE_APPEARANCES. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_appearance_set_req_enc(uint16_t appearance, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_appearance_set command. + * + * @sa @ref ble_gap_appearance_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_appearance_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_device_name_get command request. + * + * @sa @ref ble_gap_device_name_get_rsp_dec for command response decoder. + * + * @param[in] p_dev_name Pointer to an empty buffer where the UTF-8 non NULL-terminated + * string will be placed. Set to NULL to obtain the complete device + * name length. + * @param[in] p_dev_name_len Length of the buffer pointed by p_dev_name. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_dev_name and \p p_len will not be updated by the command + * request encoder. Updated values are set by @ref ble_gap_device_name_get_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_device_name_get_req_enc(uint8_t const * const p_dev_name, + uint16_t const * const p_dev_name_len, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_device_name_get command. + * + * @sa @ref ble_gap_device_name_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_dev_name Pointer to an empty buffer where the UTF-8 + * non NULL-terminated string will be placed. + * @param[in,out] p_dev_name_len Length of the buffer pointed by p_dev_name, complete device name + * length on output. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_device_name_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * const p_dev_name, + uint16_t * const p_dev_name_len, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_device_name_set command request. + * + * @sa @ref ble_gap_device_name_set_rsp_dec for command response decoder. + * + * @param[in] p_write_perm Write permissions for the Device Name characteristic, see + * @ref ble_gap_conn_sec_mode_t. + * @param[in] p_dev_name Pointer to a UTF-8 encoded, non NULL-terminated string. + * @param[in] len Length of the UTF-8, non NULL-terminated string pointed + * to by p_dev_name in octets (must be smaller or equal + * than @ref BLE_GAP_DEVNAME_MAX_LEN). + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_device_name_set_req_enc(ble_gap_conn_sec_mode_t const * const p_write_perm, + uint8_t const * const p_dev_name, + uint16_t len, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_device_name_set command. + * + * @sa @ref ble_gap_device_name_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_device_name_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_ppcp_set command request. + * + * @sa @ref ble_gap_ppcp_set_rsp_dec for command response decoder. + * + * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the + * desired parameters. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_ppcp_set_req_enc(ble_gap_conn_params_t const * const p_conn_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_ppcp_set command. + * + * @sa @ref ble_gap_ppcp_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_ppcp_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_conn_param_update command request. + * + * @sa @ref ble_gap_conn_param_update_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_conn_params Pointer to desired connection parameters. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_conn_param_update_req_enc(uint16_t conn_handle, + ble_gap_conn_params_t const * const p_conn_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_conn_param_update command. + * + * @sa @ref ble_gap_conn_param_update_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_conn_param_update_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_disconnect command request. + * + * @sa @ref ble_gap_disconnect_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_disconnect_req_enc(uint16_t conn_handle, + uint8_t hci_status_code, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_disconnect command. + * + * @sa @ref ble_gap_disconnect_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_disconnect_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + + +/**@brief Encodes @ref sd_ble_gap_rssi_stop command request. + * + * @sa @ref ble_gap_rssi_stop_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_rssi_stop_req_enc(uint16_t conn_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_rssi_stop command. + * + * @sa @ref ble_gap_rssi_stop_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_rssi_stop_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + + + + +/**@brief Encodes @ref sd_ble_gap_ppcp_get command request. + * + * @sa @ref ble_gap_ppcp_get_rsp_dec for command response decoder. + * + * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the + * parameters will be stored. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_conn_params will not be updated by the command request encoder. Updated values are + * set by @ref ble_gap_ppcp_get_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_ppcp_get_req_enc(ble_gap_conn_params_t const * const p_conn_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_ppcp_get command. + * + * @sa @ref ble_gap_ppcp_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters + * will be stored. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_ppcp_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_conn_params_t * const p_conn_params, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_auth_key_reply command request. + * + * @sa @ref ble_gap_auth_key_reply_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] key_type Key type which defines length of key data as defined for + * @ref sd_ble_gap_auth_key_reply . + * @param[in] p_key Pointer to a buffer which contains key + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_PARAM Encoding failure. Incorrect param provided (key_type). + */ +uint32_t ble_gap_auth_key_reply_req_enc(uint16_t conn_handle, + uint8_t key_type, + uint8_t const * const p_key, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_auth_key_reply command. + * + * @sa @ref ble_gap_auth_key_reply_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_auth_key_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_sec_info_reply command request. + * + * @sa @ref ble_gap_sec_info_reply_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information + * structure. + * @param[in] p_id_info Pointer to a @ref ble_gap_irk_t id information + * structure. + * @param[in] p_sign_info Pointer to a @ref ble_gap_sign_info_t signing information + * structure. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_sec_info_reply_req_enc(uint16_t conn_handle, + ble_gap_enc_info_t const * p_enc_info, + ble_gap_irk_t const * p_id_info, + ble_gap_sign_info_t const * p_sign_info, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_sec_info_reply command. + * + * @sa @ref ble_gap_sec_info_reply_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_sec_info_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_sec_params_reply command request. + * + * @sa @ref ble_gap_sec_params_reply_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS. + * @param[in] p_sec_params Pointer to @ref ble_gap_sec_params_t security parameters + * structure. + * @param[in] p_sec_keyset Pointer to @ref ble_gap_sec_keyset_t security keys + * structure. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_sec_params_reply_req_enc(uint16_t conn_handle, + uint8_t sec_status, + ble_gap_sec_params_t const * const p_sec_params, + ble_gap_sec_keyset_t const * const p_sec_keyset, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_sec_params_reply command. + * + * @sa @ref ble_gap_sec_params_reply_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[in] p_sec_keyset Pointer to @ref ble_gap_sec_keyset_t security keys + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_sec_params_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_sec_keyset_t const * const p_sec_keyset, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_authenticate command request. + * + * @sa @ref ble_gap_authenticate_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters + * structure. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_authenticate_req_enc(uint16_t conn_handle, + ble_gap_sec_params_t const * const p_sec_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_authenticate command. + * + * @sa @ref ble_gap_authenticate_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_authenticate_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_adv_stop command request. + * + * @sa @ref ble_gap_adv_stop_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_adv_stop_req_enc( +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t adv_handle, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_adv_stop command. + * + * @sa @ref ble_gap_adv_stop_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_adv_stop_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_conn_sec_get command request. + * + * @sa @ref ble_gap_conn_sec_get_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_conn_sec Pointer to \ref ble_gap_conn_sec_t which will be filled in + * response. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_conn_sec_get_req_enc(uint16_t conn_handle, + ble_gap_conn_sec_t const * const p_conn_sec, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_conn_sec_get command. + * + * @sa @ref ble_gap_conn_sec_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] pp_conn_sec Pointer to pointer to \ref ble_gap_conn_sec_t which will be filled by + * the decoded data (if present). + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_conn_sec_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_conn_sec_t * * const pp_conn_sec, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_rssi_start command request. + * + * @sa @ref ble_gap_rssi_start_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] threshold_dbm Threshold in dBm. + * @param[in] skip_count Sample skip count. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_rssi_start_req_enc(uint16_t conn_handle, + uint8_t threshold_dbm, + uint8_t skip_count, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_rssi_start command. + * + * @sa @ref ble_gap_rssi_start_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_rssi_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +#ifndef S112 +/**@brief Encodes @ref sd_ble_gap_scan_stop command request. + * + * @sa @ref ble_gap_scan_stop_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_scan_stop_req_enc(uint8_t * const p_buf, uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_scan_stop command. + * + * @sa @ref ble_gap_scan_stop_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_scan_stop_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_scan_start command request. + * + * @sa @ref ble_gap_scan_start_rsp_dec for command response decoder. + * + * @param[in] p_scan_params Pointer to scan params structure. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_scan_start_req_enc(ble_gap_scan_params_t const * p_scan_params, +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + ble_data_t const * p_adv_report_buffer, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_scan_start command. + * + * @sa @ref ble_gap_scan_start_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_scan_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_connect command request. + * + * @sa @ref ble_gap_connect_rsp_dec for command response decoder. + * + * @param[in] p_peer_addr Pointer to peer address. + * @param[in] p_scan_params Pointer to scan params structure. + * @param[in] p_conn_params Pointer to desired connection parameters. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_connect_req_enc(ble_gap_addr_t const * const p_peer_addr, + ble_gap_scan_params_t const * const p_scan_params, + ble_gap_conn_params_t const * const p_conn_params, +#if NRF_SD_BLE_API_VERSION >= 4 + uint8_t conn_cfg_tag, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_connect command. + * + * @sa @ref ble_gap_connect_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_connect_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_connect_cancel command request. + * + * @sa @ref ble_gap_connect_cancel_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_connect_cancel_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_connect_cancel command. + * + * @sa @ref ble_gap_connect_cancel_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_connect_cancel_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + + +/**@brief Encodes @ref sd_ble_gap_encrypt command request. + * + * @sa @ref ble_gap_encrypt_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_master_id Pointer to a master identification structure. + * @param[in] p_enc_info Pointer to desired connection parameters. + * @param[in] p_buf Pointer to a ble_gap_enc_info_t encryption information structure. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ + +uint32_t ble_gap_encrypt_req_enc(uint16_t conn_handle, + ble_gap_master_id_t const * const p_master_id, + ble_gap_enc_info_t const * const p_enc_info, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + + +/**@brief Decodes response to @ref sd_ble_gap_encrypt command. + * + * @sa @ref ble_gap_encrypt_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_encrypt_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +#endif //!S112 + +/**@brief Encodes @ref sd_ble_gap_rssi_get command request. + * + * @sa @ref ble_gap_rssi_get_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_rssi Pointer to the RSSI value. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_rssi_get_req_enc(uint16_t conn_handle, + int8_t const * const p_rssi, +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t const * const p_ch_index, +#endif + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_rssi_get command. + * + * @sa @ref ble_gap_rssi_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_rssi Pointer to RSSI value. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_rssi_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + int8_t * const p_rssi, +#if NRF_SD_BLE_API_VERSION > 5 + uint8_t * const p_ch_index, +#endif + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_keypress_notify command request. + * + * @sa @ref ble_gap_keypress_notify_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] kp_not See @ref sd_ble_gap_keypress_notify. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_keypress_notify_req_enc(uint16_t conn_handle, + uint8_t kp_not, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_keypress_notify command. + * + * @sa @ref ble_gap_keypress_notify_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_keypress_notify_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_lesc_dhkey_reply command request. + * + * @sa @ref ble_gap_lesc_dhkey_reply_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_dhkey See @ref sd_ble_gap_lesc_dhkey_reply. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_lesc_dhkey_reply_req_enc(uint16_t conn_handle, + ble_gap_lesc_dhkey_t const *p_dhkey, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_lesc_dhkey_reply command. + * + * @sa @ref ble_gap_lesc_dhkey_reply_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_lesc_dhkey_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_lesc_oob_data_set command request. + * + * @sa @ref ble_gap_lesc_oob_data_set_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_oobd_own See @ref sd_ble_gap_lesc_oob_data_set. + * @param[in] p_oobd_peer See @ref sd_ble_gap_lesc_oob_data_set. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_lesc_oob_data_set_req_enc(uint16_t conn_handle, + ble_gap_lesc_oob_data_t const *p_oobd_own, + ble_gap_lesc_oob_data_t const *p_oobd_peer, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_lesc_oob_data_set command. + * + * @sa @ref ble_gap_lesc_oob_data_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_lesc_oob_data_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_lesc_oob_data_get command request. + * + * @sa @ref ble_gap_lesc_oob_data_get_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_pk_own See @ref sd_ble_gap_lesc_oob_data_get. + * @param[in] p_oobd_own See @ref sd_ble_gap_lesc_oob_data_get. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_lesc_oob_data_get_req_enc(uint16_t conn_handle, + ble_gap_lesc_p256_pk_t const *p_pk_own, + ble_gap_lesc_oob_data_t *p_oobd_own, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_lesc_oob_data_get command. + * + * @sa @ref ble_gap_lesc_oob_data_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] pp_oobd_own Pointer to pointer to location where OOB data is decoded. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_lesc_oob_data_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_lesc_oob_data_t * *pp_oobd_own, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_addr_get command request. + * + * @sa @ref ble_gap_addr_get_rsp_dec for command response decoder. + * + * @param[in] p_address Pointer to address. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_address will not be updated by the command + * request encoder. Updated values are set by @ref ble_gap_addr_get_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_addr_get_req_enc(ble_gap_addr_t const * const p_address, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_addr_get command. + * + * @sa @ref ble_gap_addr_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_address Pointer to address. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_addr_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_addr_t * const p_address, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_addr_set command request. + * + * @sa @ref ble_gap_addr_set_rsp_dec for command response decoder. + * + * @param[in] p_addr Pointer to address structure. + * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_addr_set_req_enc(ble_gap_addr_t const * const p_addr, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_addr_set command. + * + * @sa @ref ble_gap_addr_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_addr_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_privacy_set command request. + * + * @sa @ref ble_gap_privacy_set_rsp_dec for command response decoder. + * + * @param[in] p_privacy_params Pointer to privacy settings structure. + * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_privacy_set_req_enc(ble_gap_privacy_params_t const * p_privacy_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_privacy_set command. + * + * @sa @ref ble_gap_privacy_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_privacy_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_privacy_get command request. + * + * @sa @ref ble_gap_privacy_get_rsp_dec for command response decoder. + * + * @param[in] p_privacy_params Pointer to privacy settings structure. + * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_privacy_get_req_enc(ble_gap_privacy_params_t const * const p_privacy_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_privacy_get command. + * + * @sa @ref ble_gap_privacy_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_privacy_params Pointer to privacy settings structure. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_privacy_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_privacy_params_t const * const p_privacy_params, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_whitelist_set command request. + * + * @sa @ref ble_gap_whitelist_set_rsp_dec for command response decoder. + * + * @param[in] pp_wl_addrs Pointer to a whitelist of peer addresses. + * @param[out] len Pointer to a length of the whitelist. + * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_whitelist_set_req_enc(ble_gap_addr_t const * const * const pp_wl_addrs, + uint8_t const len, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_gap_whitelist_set command. + * + * @sa @ref ble_gap_whitelist_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_whitelist_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/** + * @brief Encodes @ref sd_ble_gap_device_identities_set command request. + * + * @sa @ref ble_gap_device_identities_set_rsp_dec for command response decoder. + * + * @param[in] pp_id_keys Pointer to an array of peer identity addresses and peer IRKs. + * @param[in] pp_local_irks Pointer to an array of local IRKs. + * @param[out] len Pointer to a length of the device identity list. + * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_device_identities_set_req_enc(ble_gap_id_key_t const * const * const pp_id_keys, + ble_gap_irk_t const * const * const pp_local_irks, + uint8_t const len, + uint8_t * const p_buf, + uint32_t * const p_buf_len); +/** + * @brief Decodes response to @ref sd_ble_gap_device_identities_set command. + * + * @sa @ref ble_gap_device_identities_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_device_identities_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +#if NRF_SD_BLE_API_VERSION >= 4 && !defined(S112) +/** + * @brief Encodes @ref sd_ble_gap_data_length_update command request. + * + * @sa @ref ble_gap_data_length_update_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_dl_params Pointer to a data length params structure. + * @param[out] p_dl_limitation Pointer to a data length limitation structure. + * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_data_length_update_req_enc(uint16_t conn_handle, + ble_gap_data_length_params_t const * p_dl_params, + ble_gap_data_length_limitation_t * p_dl_limitation, + uint8_t * const p_buf, + uint32_t * const p_buf_len); +/** + * @brief Decodes response to @ref sd_ble_gap_data_length_update command. + * + * @sa @ref ble_gap_data_length_update_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_dl_limitation Pointer to a data length limitation structure. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gap_data_length_update_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gap_data_length_limitation_t * p_dl_limitation, + uint32_t * const p_result_code); +#endif + +#if NRF_SD_BLE_API_VERSION >= 5 +/**@brief Encodes @ref sd_ble_gap_phy_update command request. + * + * @sa @ref ble_gap_phy_update_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_gap_phys Pointer to a @ref ble_gap_phys_t + * structure. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_phy_update_req_enc(uint16_t conn_handle, + ble_gap_phys_t const * p_gap_phys, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gap_phy_update command. + * + * @sa @ref ble_gap_phy_update_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_phy_update_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +#endif + +#if NRF_SD_BLE_API_VERSION >= 6 +/**@brief Encodes @ref sd_ble_gap_adv_set_configure command request. + * + * @sa @ref ble_gap_adv_set_configure_rsp_dec for command response decoder. + * + * @param[in] p_adv_handle Advertising handle. + * @param[in] p_adv_data Pointer to a @ref ble_gap_adv_data_t structure. + * @param[in] p_adv_params Pointer to a @ref ble_gap_adv_params_t structure. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_adv_set_configure_req_enc(uint8_t * p_adv_handle, + ble_gap_adv_data_t const * p_adv_data, + ble_gap_adv_params_t const *p_adv_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + + +/**@brief Decodes response to @ref sd_ble_gap_adv_set_configure command. + * + * @sa @ref ble_gap_adv_set_configure_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_adv_handle Advertising handle. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_adv_set_configure_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * p_adv_handle, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_qos_channel_survey_start command request. + * + * @sa @ref ble_gap_qos_channel_survey_start_rsp_dec for command response decoder. + * + * @param[in] interval_us Interval. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_qos_channel_survey_start_req_enc(uint32_t interval_us, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + + +/**@brief Decodes response to @ref sd_ble_gap_qos_channel_survey_start command. + * + * @sa @ref ble_gap_qos_channel_survey_start_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_qos_channel_survey_start_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gap_qos_channel_survey_stop command request. + * + * @sa @ref ble_gap_qos_channel_survey_stop_rsp_dec for command response decoder. + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gap_qos_channel_survey_stop_req_enc(uint8_t * const p_buf, + uint32_t * const p_buf_len); + + +/**@brief Decodes response to @ref sd_ble_gap_qos_channel_survey_stop command. + * + * @sa @ref ble_gap_qos_channel_survey_stop_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gap_qos_channel_survey_stop_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +#endif +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.c new file mode 100644 index 000000000..b3e99beec --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.c @@ -0,0 +1,415 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gap_evt_app.h" +#include "ble_serialization.h" +#include "app_util.h" +#include "app_ble_gap_sec_keys.h" +#include "ble_gap_struct_serialization.h" +#include "ble_struct_serialization.h" +#include "cond_field_serialization.h" +#include + +extern ser_ble_gap_app_keyset_t m_app_keys_table[]; + +#ifndef S112 +uint32_t ble_gap_evt_adv_report_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_ADV_REPORT, gap, adv_report); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION >= 6 + //get buffer stored during scan start. + app_ble_gap_scan_data_unset(false); +#endif + SER_PULL_FIELD(&p_event->evt.gap_evt.params.adv_report, ble_gap_evt_adv_report_t_dec); + + + SER_EVT_DEC_END; +} +#endif //!S112 + +uint32_t ble_gap_evt_auth_key_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_AUTH_KEY_REQUEST, gap, auth_key_request); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_uint8(&p_event->evt.gap_evt.params.auth_key_request.key_type); + + SER_EVT_DEC_END; +} + + +extern ser_ble_gap_app_keyset_t m_app_keys_table[]; + +uint32_t ble_gap_evt_auth_status_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_AUTH_STATUS, gap, auth_status); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.auth_status, ble_gap_evt_auth_status_t_dec); + + // keyset is an extension of standard event data - used to synchronize keys at application + uint32_t conn_index; + err_code = app_ble_gap_sec_context_find(p_event->evt.gap_evt.conn_handle, &conn_index); + if (err_code == NRF_SUCCESS) + { + SER_PULL_FIELD(&(m_app_keys_table[conn_index].keyset), ble_gap_sec_keyset_t_dec); + + err_code = app_ble_gap_sec_context_destroy(p_event->evt.gap_evt.conn_handle); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + } + + SER_EVT_DEC_END; +} + + +uint32_t ble_gap_evt_conn_param_update_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_CONN_PARAM_UPDATE, gap, conn_param_update); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.conn_param_update, ble_gap_evt_conn_param_update_t_dec); + + SER_EVT_DEC_END; +} + + +#ifndef S112 +uint32_t ble_gap_evt_conn_param_update_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, gap, conn_param_update_request); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.conn_param_update_request, + ble_gap_evt_conn_param_update_request_t_dec); + + SER_EVT_DEC_END; +} +#endif + +uint32_t ble_gap_evt_conn_sec_update_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_CONN_SEC_UPDATE, gap, conn_sec_update); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.conn_sec_update, ble_gap_evt_conn_sec_update_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gap_evt_connected_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_CONNECTED, gap, connected); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.connected, ble_gap_evt_connected_t_dec); + + SER_EVT_DEC_END; +} + + +uint32_t ble_gap_evt_disconnected_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_DISCONNECTED, gap, disconnected); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.disconnected, ble_gap_evt_disconnected_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gap_evt_key_pressed_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_KEY_PRESSED, gap, key_pressed); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_uint8(&p_event->evt.gap_evt.params.key_pressed.kp_not); + + SER_EVT_DEC_END; +} + + +uint32_t ble_gap_evt_lesc_dhkey_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_LESC_DHKEY_REQUEST, gap, lesc_dhkey_request); + + uint8_t ser_data; + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + + // keyset is an extension of standard event data - used to synchronize keys at application + uint32_t conn_index; + err_code = app_ble_gap_sec_context_find(p_event->evt.gap_evt.conn_handle, &conn_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + p_event->evt.gap_evt.params.lesc_dhkey_request.p_pk_peer = m_app_keys_table[conn_index].keyset.keys_peer.p_pk; + SER_PULL_COND(&p_event->evt.gap_evt.params.lesc_dhkey_request.p_pk_peer, ble_gap_lesc_p256_pk_t_dec); + + SER_PULL_uint8(&ser_data); + p_event->evt.gap_evt.params.lesc_dhkey_request.oobd_req = ser_data & 0x01; + + SER_EVT_DEC_END; +} + + +#define PASSKEY_LEN sizeof (p_event->evt.gap_evt.params.passkey_display.passkey) + + +uint32_t ble_gap_evt_passkey_display_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_PASSKEY_DISPLAY, gap, passkey_display); + + uint8_t ser_data; + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_uint8array(p_event->evt.gap_evt.params.passkey_display.passkey, BLE_GAP_PASSKEY_LEN); + SER_PULL_uint8(&ser_data); + p_event->evt.gap_evt.params.passkey_display.match_request = (ser_data & 0x01); + + SER_EVT_DEC_END; +} + + + +uint32_t ble_gap_evt_rssi_changed_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_RSSI_CHANGED, gap, rssi_changed); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_int8(&p_event->evt.gap_evt.params.rssi_changed.rssi); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + SER_PULL_uint8(&p_event->evt.gap_evt.params.rssi_changed.ch_index); +#endif + SER_EVT_DEC_END; +} + + +uint32_t ble_gap_evt_scan_req_report_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_SCAN_REQ_REPORT, gap, scan_req_report); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + SER_PULL_uint8(&p_event->evt.gap_evt.params.scan_req_report.adv_handle); +#endif + SER_PULL_FIELD(&p_event->evt.gap_evt.params.scan_req_report.peer_addr, ble_gap_addr_t_dec); + SER_PULL_int8(&p_event->evt.gap_evt.params.scan_req_report.rssi); + + SER_EVT_DEC_END; +} + +uint32_t ble_gap_evt_sec_info_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_SEC_INFO_REQUEST, gap, sec_info_request); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.sec_info_request, ble_gap_evt_sec_info_request_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gap_evt_sec_params_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_SEC_PARAMS_REQUEST, gap, sec_params_request); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.sec_params_request, ble_gap_evt_sec_params_request_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gap_evt_sec_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_SEC_REQUEST, gap, sec_request); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.sec_request, ble_gap_evt_sec_request_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gap_evt_timeout_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_TIMEOUT, gap, timeout); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_uint8(&p_event->evt.gap_evt.params.timeout.src); +#if defined(NRF_SD_BLE_API_VERSION) && (NRF_SD_BLE_API_VERSION > 5) && !defined(S112) + if (p_event->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_SCAN) + { + SER_PULL_FIELD(&p_event->evt.gap_evt.params.timeout.params.adv_report_buffer, ble_data_t_dec); + } +#endif + SER_EVT_DEC_END; +} + +#if NRF_SD_BLE_API_VERSION >= 5 +uint32_t ble_gap_evt_phy_update_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_PHY_UPDATE, gap, phy_update); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_uint8(&p_event->evt.gap_evt.params.phy_update.status); + SER_PULL_uint8(&p_event->evt.gap_evt.params.phy_update.tx_phy); + SER_PULL_uint8(&p_event->evt.gap_evt.params.phy_update.rx_phy); + + SER_EVT_DEC_END; +} + +uint32_t ble_gap_evt_phy_update_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_PHY_UPDATE_REQUEST, gap, phy_update); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.phy_update_request, ble_gap_phys_t_dec); + + SER_EVT_DEC_END; +} +#endif +#if NRF_SD_BLE_API_VERSION >= 4 && !defined(S112) +uint32_t ble_gap_evt_data_length_update_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST, gap, timeout); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.data_length_update_request.peer_params, ble_gap_data_length_params_t_dec); + + SER_EVT_DEC_END; +} +uint32_t ble_gap_evt_data_length_update_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_DATA_LENGTH_UPDATE, gap, timeout); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.data_length_update.effective_params, ble_gap_data_length_params_t_dec); + + SER_EVT_DEC_END; +} +#endif //NRF_SD_BLE_API_VERSION >= 4 @@ !defined(S112) +#if NRF_SD_BLE_API_VERSION > 5 +#ifndef S112 +uint32_t ble_gap_evt_qos_channel_survey_report_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT, gap, qos_channel_survey_report); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_uint8array((uint8_t *)p_event->evt.gap_evt.params.qos_channel_survey_report.channel_energy, BLE_GAP_CHANNEL_COUNT); + + SER_EVT_DEC_END; +} +#endif //S112 + +uint32_t ble_gap_evt_adv_set_terminated_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GAP_EVT_ADV_SET_TERMINATED, gap, adv_set_terminated); + + SER_PULL_uint16(&p_event->evt.gap_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gap_evt.params.adv_set_terminated, ble_gap_evt_adv_set_terminated_t_dec); + + SER_EVT_DEC_END; +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.h new file mode 100644 index 000000000..f98a3862c --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.h @@ -0,0 +1,597 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GAP_EVT_APP_H__ +#define BLE_GAP_EVT_APP_H__ + +/**@file + * + * @defgroup ble_gap_evt_app GAP Application event decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief GAP Application event decoders. + */ +#include "ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Decodes ble_gap_evt_auth_key_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_auth_key_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_auth_status event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_auth_status_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_conn_param_update event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_conn_param_update_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_conn_sec_update event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_conn_sec_update_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_connected event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_connected_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_disconnected event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_disconnected_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_passkey_display event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_passkey_display_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_rssi_changed event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_rssi_changed_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_sec_info_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_sec_info_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_sec_params_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_sec_params_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_timeout event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_timeout_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_sec_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_sec_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_conn_param_update_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_conn_param_update_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +/** + * @brief Decodes ble_gap_evt_adv_report event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_adv_report_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_scan_req_report event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_scan_req_report_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_key_pressed event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_key_pressed_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +/** + * @brief Decodes ble_gap_evt_lesc_dhkey_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_lesc_dhkey_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +#if NRF_SD_BLE_API_VERSION >= 5 +/** + * @brief Decodes ble_gap_evt_phy_update event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_phy_update_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gap_evt_phy_update_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_phy_update_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +#endif + +#if NRF_SD_BLE_API_VERSION >= 4 +/** + * @brief Decodes ble_gap_evt_data_length_update_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_data_length_update_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +/** + * @brief Decodes ble_gap_evt_data_length_update event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_data_length_update_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +#endif //NRF_SD_BLE_API_VERSION >= 4 + +#if NRF_SD_BLE_API_VERSION >= 6 +#ifndef S112 +/** + * @brief Decodes ble_gap_evt_qos_channel_survey_report event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_qos_channel_survey_report_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +#endif + +/** + * @brief Decodes ble_gap_evt_adv_set_terminated event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gap_evt_adv_set_terminated_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +#endif +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_app.c new file mode 100644 index 000000000..a24d33dd5 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_app.c @@ -0,0 +1,286 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gattc_app.h" +#include +#include "ble_serialization.h" +#include "ble_gattc_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" +#include "ble_struct_serialization.h" +#include "ble_types.h" + +uint32_t ble_gattc_attr_info_discover_req_enc(uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_ATTR_INFO_DISCOVER); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_handle_range, ble_gattc_handle_range_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_attr_info_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_ATTR_INFO_DISCOVER); +} + +uint32_t ble_gattc_char_value_by_uuid_read_req_enc(uint16_t conn_handle, + ble_uuid_t const * const p_uuid, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_uuid, ble_uuid_t_enc); + SER_PUSH_COND(p_handle_range, ble_gattc_handle_range_t_enc); + + SER_REQ_ENC_END; +} + +uint32_t ble_gattc_char_value_by_uuid_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ); +} + +uint32_t ble_gattc_char_values_read_req_enc(uint16_t conn_handle, + uint16_t const * const p_handles, + uint16_t handle_count, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_CHAR_VALUES_READ); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_len16data16(p_handles, handle_count); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_char_values_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_CHAR_VALUES_READ); +} + +uint32_t ble_gattc_characteristics_discover_req_enc( + uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_handle_range, ble_gattc_handle_range_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_characteristics_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER); +} + +uint32_t ble_gattc_descriptors_discover_req_enc( + uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_DESCRIPTORS_DISCOVER); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_handle_range, ble_gattc_handle_range_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_descriptors_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_DESCRIPTORS_DISCOVER); +} + +uint32_t ble_gattc_hv_confirm_req_enc(uint16_t conn_handle, + uint16_t handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_HV_CONFIRM); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&handle); + + SER_REQ_ENC_END; +} + +uint32_t ble_gattc_hv_confirm_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_HV_CONFIRM); +} + +uint32_t ble_gattc_primary_services_discover_req_enc(uint16_t conn_handle, + uint16_t start_handle, + ble_uuid_t const * const p_srvc_uuid, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&start_handle); + SER_PUSH_COND(p_srvc_uuid, ble_uuid_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_primary_services_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER); +} + +uint32_t ble_gattc_read_req_enc(uint16_t conn_handle, + uint16_t handle, + uint16_t offset, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_READ); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&handle); + SER_PUSH_uint16(&offset); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_READ); +} + +uint32_t ble_gattc_relationships_discover_req_enc( + uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_handle_range, ble_gattc_handle_range_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_relationships_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER); +} + +uint32_t ble_gattc_write_req_enc(uint16_t conn_handle, + ble_gattc_write_params_t const * const p_write_params, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_WRITE); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_write_params, ble_gattc_write_params_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_write_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_WRITE); +} + +uint32_t ble_gattc_exchange_mtu_request_req_enc(uint16_t conn_handle, + uint16_t client_rx_mtu, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTC_EXCHANGE_MTU_REQUEST); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&client_rx_mtu); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gattc_exchange_mtu_request_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTC_EXCHANGE_MTU_REQUEST); +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_app.h new file mode 100644 index 000000000..188d8a8e2 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_app.h @@ -0,0 +1,491 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GATTC_APP_H__ +#define BLE_GATTC_APP_H__ + +/**@file + * + * @defgroup ble_gattc_app GATTC Application command request encoders and command response decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief GATTC Application command request encoders and command response decoders. + */ +#include "ble_gattc.h" +#include "ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Encodes @ref sd_ble_gattc_primary_services_discover command request. + * + * @sa @ref ble_gattc_primary_services_discover_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] start_handle Handle to start searching from. + * @param[in] p_srvc_uuid Pointer to a @ref ble_uuid_t which indicates the service UUID to + * be found. If it is NULL, all primary services will be returned. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_primary_services_discover_req_enc(uint16_t conn_handle, + uint16_t start_handle, + ble_uuid_t const * const p_srvc_uuid, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_primary_services_discover command. + * + * @sa @ref ble_gattc_primary_services_discover_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_primary_services_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_descriptors_discover command request. + * + * @sa @ref ble_gattc_descriptors_discover_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform + * this procedure on. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_descriptors_discover_req_enc( + uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * p_buf_len); + + +/**@brief Decodes response to @ref sd_ble_gattc_descriptors_discover command. + * + * @sa @ref ble_gattc_primary_services_discover_rsp_dec for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_descriptors_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_relationships_discover command request. + * + * @sa @ref ble_gattc_relationships_discover_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform + * this procedure on. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_relationships_discover_req_enc( + uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_relationships_discover command. + * + * @sa @ref ble_gattc_relationships_discover_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_relationships_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_characteristics_discover command request. + * + * @sa @ref ble_gattc_characteristics_discover_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform + * this procedure on. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_characteristics_discover_req_enc + (uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_characteristics_discover command. + * + * @sa @ref ble_gattc_primary_services_discover_rsp_dec for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_characteristics_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_read command request. + * + * @sa @ref ble_gattc_read_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] handle The handle of the attribute to be read. + * @param[in] offset Offset into the attribute value to be read. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_read_req_enc(uint16_t conn_handle, + uint16_t handle, + uint16_t offset, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_read command. + * + * @sa @ref ble_gattc_read_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_char_values_read command request. + * + * @sa @ref ble_gattc_char_values_read_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read. + * @param[in] handle_count The number of handles in p_handles. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_char_values_read_req_enc(uint16_t conn_handle, + uint16_t const * const p_handles, + uint16_t handle_count, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_char_values_read command. + * + * @sa @ref ble_gattc_char_values_read_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_char_values_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_write command request. + * + * @sa @ref ble_gattc_write_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_write_params Pointer to \ref sd_ble_gattc_write params. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_write_req_enc(uint16_t conn_handle, + ble_gattc_write_params_t const * const p_write_params, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_write command. + * + * @sa @ref ble_gattc_write_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_write_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_hv_confirm command request. + * + * @sa @ref ble_gattc_hv_confirm_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] handle Handle of the attribute in the indication. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_hv_confirm_req_enc(uint16_t conn_handle, + uint16_t handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_hv_confirm command. + * + * @sa @ref ble_gattc_hv_confirm_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Pointer to command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_hv_confirm_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_char_value_by_uuid_read command request. + * + * @sa @ref ble_gattc_char_value_by_uuid_read_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_uuid Pointer to a characteristic value UUID to read. + * @param[in] p_handle_range Pointer to the range of handles to perform this procedure on. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_char_value_by_uuid_read_req_enc + (uint16_t conn_handle, + ble_uuid_t const * const p_uuid, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_char_value_by_uuid_read command. + * + * @sa @ref ble_gattc_char_value_by_uuid_read_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Pointer to command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_char_value_by_uuid_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_attr_info_discover command request. + * + * @sa @ref ble_gattc_attr_info_discover_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_handle_range Pointer to the range of handles + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_attr_info_discover_req_enc(uint16_t conn_handle, + ble_gattc_handle_range_t const * const p_handle_range, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_attr_info_discover command. + * + * @sa @ref ble_gattc_attr_info_discover_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Pointer to command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_attr_info_discover_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gattc_exchange_mtu_request command request. + * + * @sa @ref ble_gattc_exchange_mtu_request_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] client_rx_mtu Client MTU Size. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in, out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gattc_exchange_mtu_request_req_enc(uint16_t conn_handle, + uint16_t client_rx_mtu, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gattc_exchange_mtu_request command. + * + * @sa @ref ble_gattc_exchange_mtu_request_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Pointer to command response result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected + * operation code. + */ +uint32_t ble_gattc_exchange_mtu_request_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_evt_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_evt_app.c new file mode 100644 index 000000000..46a7ffcf1 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_evt_app.c @@ -0,0 +1,262 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gattc_evt_app.h" +#include +#include "ble_serialization.h" +#include "ble_gattc_struct_serialization.h" +#include "app_util.h" + +uint32_t ble_gattc_evt_attr_info_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, gattc, attr_info_disc_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.attr_info_disc_rsp, + ble_gattc_evt_attr_info_disc_rsp_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gattc_evt_char_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_CHAR_DISC_RSP, gattc, char_disc_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.char_disc_rsp, + ble_gattc_evt_char_disc_rsp_t_dec); + + SER_EVT_DEC_END; +} + + + +uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, gattc, char_val_by_uuid_read_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.char_val_by_uuid_read_rsp, + ble_gattc_evt_char_val_by_uuid_read_rsp_t_dec); + + SER_EVT_DEC_END; +} + + +uint32_t ble_gattc_evt_char_vals_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_CHAR_VALS_READ_RSP, gattc, char_vals_read_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.char_vals_read_rsp, + ble_gattc_evt_char_vals_read_rsp_t_dec); + + SER_EVT_DEC_END; +} + + +uint32_t ble_gattc_evt_desc_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_DESC_DISC_RSP, gattc, desc_disc_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.desc_disc_rsp, + ble_gattc_evt_desc_disc_rsp_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gattc_evt_hvx_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_HVX, gattc, hvx); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.hvx, + ble_gattc_evt_hvx_t_dec); + + SER_EVT_DEC_END; +} + + +uint32_t ble_gattc_evt_prim_srvc_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP, gattc, prim_srvc_disc_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.prim_srvc_disc_rsp, + ble_gattc_evt_prim_srvc_disc_rsp_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gattc_evt_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_READ_RSP, gattc, read_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.read_rsp, + ble_gattc_evt_read_rsp_t_dec); + + SER_EVT_DEC_END; +} + + +#define BLE_GATTC_EVT_REL_DISC_RSP_COUNT_POSITION 6 + + +uint32_t ble_gattc_evt_rel_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_READ_RSP, gattc, rel_disc_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.rel_disc_rsp, + ble_gattc_evt_rel_disc_rsp_t_dec); + + SER_EVT_DEC_END; +} + + +uint32_t ble_gattc_evt_timeout_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_TIMEOUT, gattc, timeout); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD(&p_event->evt.gattc_evt.params.timeout, + ble_gattc_evt_timeout_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gattc_evt_write_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_WRITE_RSP, gattc, write_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gattc_evt.params.write_rsp, + ble_gattc_evt_write_rsp_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gattc_evt_exchange_mtu_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_EXCHANGE_MTU_RSP, gattc, exchange_mtu_rsp); + + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_FIELD(&p_event->evt.gattc_evt.params.exchange_mtu_rsp, + ble_gattc_evt_exchange_mtu_rsp_t_dec); + + SER_EVT_DEC_END; +} + +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_gattc_evt_write_cmd_tx_complete_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE, gattc, write_cmd_tx_complete); + SER_PULL_uint16(&p_event->evt.gattc_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.gattc_evt.gatt_status); + SER_PULL_uint16(&p_event->evt.gattc_evt.error_handle); + SER_PULL_uint8(&p_event->evt.gattc_evt.params.write_cmd_tx_complete.count); + + SER_EVT_DEC_END; +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_evt_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_evt_app.h new file mode 100644 index 000000000..3f9eb3745 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gattc_evt_app.h @@ -0,0 +1,364 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GATTC_EVT_APP_H__ +#define BLE_GATTC_EVT_APP_H__ + +/**@file + * + * @defgroup ble_gattc_evt_app GATTC Application event decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief GATTC Application event decoders. + */ +#include "ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Decodes ble_gattc_evt_char_disc_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_char_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_char_val_by_uuid_read_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_char_vals_read_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_char_vals_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_desc_disc_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_desc_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_hvx event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_hvx_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_prim_srvc_disc_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_prim_srvc_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_read_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_read_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_rel_disc_rsp_dec event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_rel_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_timeout event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_timeout_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_write_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_write_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_attr_info_disc_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_attr_info_disc_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gattc_evt_exchange_mtu_rsp event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_exchange_mtu_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +#if NRF_SD_BLE_API_VERSION >= 4 + +/** + * @brief Decodes ble_gattc_evt_write_cmd_tx_complete event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gattc_evt_write_cmd_tx_complete_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +#endif +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_app.c new file mode 100644 index 000000000..2c95d8547 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_app.c @@ -0,0 +1,439 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gatts_app.h" +#include +#include +#include "ble_serialization.h" +#include "ble_gatts_struct_serialization.h" +#include "ble_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" + + +uint32_t ble_gatts_attr_get_req_enc(uint16_t handle, + ble_uuid_t * p_uuid, + ble_gatts_attr_md_t * p_md, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_ATTR_GET); + + SER_PUSH_uint16(&handle); + SER_PUSH_COND(p_uuid, NULL); + SER_PUSH_COND(p_md, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_attr_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_uuid_t ** pp_uuid, + ble_gatts_attr_md_t ** pp_md, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_ATTR_GET); + SER_PULL_COND(pp_uuid, ble_uuid_t_dec); + SER_PULL_COND(pp_md, ble_gatts_attr_md_t_dec); + SER_RSP_DEC_END; +} + + +uint32_t ble_gatts_characteristic_add_req_enc( + uint16_t service_handle, + ble_gatts_char_md_t const * const p_char_md, + ble_gatts_attr_t const * const p_attr_char_value, + ble_gatts_char_handles_t const * const p_handles, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_CHARACTERISTIC_ADD); + + SER_PUSH_uint16(&service_handle); + SER_PUSH_COND(p_char_md, ble_gatts_char_md_t_enc); + SER_PUSH_COND(p_attr_char_value, ble_gatts_attr_t_enc); + SER_PUSH_COND(p_handles, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_characteristic_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * * const pp_handles, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_CHARACTERISTIC_ADD); + + SER_PULL_COND(pp_handles, ble_gatts_char_handles_t_dec); + + SER_RSP_DEC_END; +} + + + +uint32_t ble_gatts_descriptor_add_req_enc(uint16_t char_handle, + ble_gatts_attr_t const * const p_attr, + uint16_t * const p_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_DESCRIPTOR_ADD); + + SER_PUSH_uint16(&char_handle); + SER_PUSH_COND(p_attr, ble_gatts_attr_t_enc); + SER_PUSH_COND(p_handle, NULL); + + SER_REQ_ENC_END; +} + +uint32_t ble_gatts_descriptor_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * const p_handle, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_DESCRIPTOR_ADD); + + SER_PULL_COND(&p_handle, uint16_t_dec); + + SER_RSP_DEC_END; +} + + +uint32_t ble_gatts_hvx_req_enc(uint16_t conn_handle, + ble_gatts_hvx_params_t const * const p_hvx_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_HVX); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_hvx_params, ble_gatts_hvx_params_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_hvx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code, + uint16_t * * const pp_bytes_written) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_HVX); + + SER_PULL_COND(pp_bytes_written, uint16_t_dec); + + SER_RSP_DEC_END; +} + + +uint32_t ble_gatts_include_add_req_enc(uint16_t service_handle, + uint16_t inc_srvc_handle, + uint16_t * const p_include_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_INCLUDE_ADD); + + SER_PUSH_uint16(&service_handle); + SER_PUSH_uint16(&inc_srvc_handle); + SER_PUSH_COND(p_include_handle, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_include_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * const p_include_handle, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_INCLUDE_ADD); + + SER_PULL_COND(&p_include_handle, uint16_t_dec); + + SER_RSP_DEC_END; +} + + +uint32_t ble_gatts_initial_user_handle_get_req_enc(uint16_t * p_handle, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET); + + SER_PUSH_COND(p_handle, NULL); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_initial_user_handle_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t ** pp_handle, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET); + + SER_PULL_COND(pp_handle, uint16_t_dec); + + SER_RSP_DEC_END; +} + + +uint32_t ble_gatts_rw_authorize_reply_req_enc(uint16_t conn_handle, + ble_gatts_rw_authorize_reply_params_t const * const p_reply_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_RW_AUTHORIZE_REPLY); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_reply_params, ble_gatts_rw_authorize_reply_params_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_rw_authorize_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTS_RW_AUTHORIZE_REPLY); +} + + +uint32_t ble_gatts_service_add_req_enc(uint8_t type, + ble_uuid_t const * const p_uuid, + uint16_t const * const p_conn_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_SERVICE_ADD); + + SER_PUSH_uint8(&type); + SER_PUSH_COND(p_uuid, ble_uuid_t_enc); + SER_PUSH_COND(p_conn_handle, NULL); + + SER_REQ_ENC_END; +} + +uint32_t ble_gatts_service_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * const p_conn_handle, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_SERVICE_ADD); + + SER_PULL_COND(&p_conn_handle, uint16_t_dec); + + SER_RSP_DEC_END; +} + + +uint32_t ble_gatts_service_changed_req_enc(uint16_t conn_handle, + uint16_t start_handle, + uint16_t end_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_SERVICE_CHANGED); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&start_handle); + SER_PUSH_uint16(&end_handle); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_service_changed_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTS_SERVICE_CHANGED); +} + + +uint32_t ble_gatts_sys_attr_get_req_enc(uint16_t conn_handle, + uint8_t const * const p_sys_attr_data, + uint16_t const * const p_sys_attr_data_len, + uint32_t flags, + uint8_t * const p_buf, + uint32_t * p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_SYS_ATTR_GET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_sys_attr_data_len, uint16_t_enc); + SER_PUSH_COND(p_sys_attr_data, NULL); + SER_PUSH_uint32(&flags); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_sys_attr_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * * const pp_sys_attr_data, + uint16_t * * const pp_sys_attr_data_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_SYS_ATTR_GET); + + SER_PULL_COND(pp_sys_attr_data_len, uint16_t_dec); + if (*pp_sys_attr_data_len) + { + SER_PULL_buf(pp_sys_attr_data, **pp_sys_attr_data_len, **pp_sys_attr_data_len); + } + + SER_RSP_DEC_END; +} + + +uint32_t ble_gatts_sys_attr_set_req_enc(uint16_t conn_handle, + uint8_t const * const p_sys_attr_data, + uint16_t sys_attr_data_len, + uint32_t flags, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_SYS_ATTR_SET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_len16data(p_sys_attr_data, sys_attr_data_len); + SER_PUSH_uint32(&flags); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_sys_attr_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SD_BLE_GATTS_SYS_ATTR_SET, p_result_code); +} + + +uint32_t ble_gatts_value_get_req_enc(uint16_t conn_handle, + uint16_t handle, + ble_gatts_value_t const * const p_value, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_VALUE_GET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&handle); + + //Special case: skip the data. + SER_PUSH_COND(p_value, NULL); + if (p_value) + { + SER_PUSH_uint16(&p_value->offset); + SER_PUSH_uint16(&p_value->len); + SER_PUSH_COND(p_value->p_value, NULL); + } + + SER_REQ_ENC_END; +} + +uint32_t ble_gatts_value_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gatts_value_t * const p_value, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_VALUE_GET); + + SER_PULL_COND(&p_value, ble_gatts_value_t_dec); + + SER_RSP_DEC_END; +} + + +uint32_t ble_gatts_value_set_req_enc(uint16_t conn_handle, + uint16_t handle, + ble_gatts_value_t * p_value, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_VALUE_SET); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&handle); + SER_PUSH_COND(p_value, ble_gatts_value_t_enc); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_value_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gatts_value_t * const p_value, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_GATTS_VALUE_SET); + + SER_PULL_COND(&p_value, ble_gatts_value_t_dec); + + SER_RSP_DEC_END; +} + +uint32_t ble_gatts_exchange_mtu_reply_req_enc(uint16_t conn_handle, + uint16_t server_rx_mtu, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_GATTS_EXCHANGE_MTU_REPLY); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&server_rx_mtu); + + SER_REQ_ENC_END; +} + + +uint32_t ble_gatts_exchange_mtu_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_GATTS_EXCHANGE_MTU_REPLY); +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_app.h new file mode 100644 index 000000000..542404ee6 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_app.h @@ -0,0 +1,677 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GATTS_APP_H__ +#define BLE_GATTS_APP_H__ + +/**@file + * + * @defgroup ble_gatts_app GATTS Application command request encoders and command response decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief GATTS Application command request encoders and command response decoders. + */ +#include "ble_gatts.h" +#include "ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Encodes @ref sd_ble_gatts_value_get command request. + * + * @sa @ref ble_gatts_value_get_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] handle Attribute handle. + * @param[in] p_value Pointer to attribute value information. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_data_len and \p p_data will not be updated by the command + * request encoder. Updated values are set by @ref ble_gatts_value_get_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_value_get_req_enc(uint16_t conn_handle, + uint16_t handle, + ble_gatts_value_t const * const p_value, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_value_get command. + * + * @sa @ref ble_gatts_value_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_value Pointer to structure where the attribute value will be stored. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Length of \p p_value is too small to hold decoded + * value from response. + */ +uint32_t ble_gatts_value_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gatts_value_t * const p_value, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_hvx command request. + * + * @sa @ref ble_gatts_hvx_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_hvx_params Pointer to an HVx parameters structure to be encoded. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_hvx_params will not be updated by the command + * request encoder. Updated values are set by @ref ble_gatts_hvx_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_hvx_req_enc(uint16_t conn_handle, + ble_gatts_hvx_params_t const * const p_hvx_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_hvx command. + * + * @sa @ref ble_gatts_hvx_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * @param[out] pp_bytes_written Pointer to pointer to location where number of bytes is written. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_hvx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code, + uint16_t * * const pp_bytes_written); + +/**@brief Encodes @ref sd_ble_gatts_characteristic_add command request. + * + * @sa @ref ble_gatts_characteristic_add_rsp_dec for command response decoder. + * + * @param[in] service_handle Handle of the service where the characteristic is to be placed. + * If @ref BLE_GATT_HANDLE_INVALID is used, it will be placed + * sequentially. + * @param[in] p_char_md Pointer to a @ref ble_gatts_char_md_t structure, characteristic + * metadata. + * @param[in] p_attr_char_value Pointer to a @ref ble_gatts_attr_t structure, corresponding to + * the characteristic value. + * @param[in] p_handles Pointer to a @ref ble_gatts_char_handles_t structure, where the + * assigned handles will be stored. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_handles will not be updated by the command + * request encoder. Updated values are set by @ref ble_gatts_characteristic_add_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_characteristic_add_req_enc + (uint16_t service_handle, + ble_gatts_char_md_t const * const p_char_md, + ble_gatts_attr_t const * const p_attr_char_value, + ble_gatts_char_handles_t const * const p_handles, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_characteristic_add command. + * + * @sa @ref ble_gatts_characteristic_add_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] pp_handles Pointer to pointer to location where handles should be decoded. + * @param[out] p_result_code Pointer to command result code decode location. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_characteristic_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * * const pp_handles, + uint32_t * const p_result_code); + + +/**@brief Encodes @ref sd_ble_gatts_service_add command request. + * + * @sa @ref ble_gatts_service_add_rsp_dec for command response decoder. + * + * @param[in] type Toggles between primary and secondary services, + * see @ref BLE_GATTS_SRVC_TYPES. + * @param[in] p_uuid Pointer to service UUID. + * @param[in] p_conn_handle Pointer to a 16-bit word where the assigned handle will be stored. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_conn_handle will not be updated by the command + * request encoder. Updated values are set by @ref ble_gatts_service_add_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_service_add_req_enc(uint8_t type, + ble_uuid_t const * const p_uuid, + uint16_t const * const p_conn_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_service_add command. + * + * @sa @ref ble_gatts_service_add_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_conn_handle Connection handle. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_service_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * const p_conn_handle, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_sys_attr_set command request. + * + * @sa @ref ble_gatts_sys_attr_set_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_sys_attr_data Pointer to a buffer (at least \p sys_attr_data_len bytes long) + * containing the attribute value to write. + * @param[in] sys_attr_data_len Length (in bytes) of \p p_sys_attr_data. + * @param[in] flags Optional additional flags. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_sys_attr_set_req_enc(uint16_t conn_handle, + uint8_t const * const p_sys_attr_data, + uint16_t sys_attr_data_len, + uint32_t flags, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_sys_attr_set command. + * + * @sa @ref ble_gatts_sys_attr_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_sys_attr_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_value_set command request. + * + * @sa @ref ble_gatts_value_set_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] handle Attribute handle. + * @param[in] p_value Pointer to attribute value information. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_value_set_req_enc(uint16_t conn_handle, + uint16_t handle, + ble_gatts_value_t * p_value, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_value_set command. + * + * @sa @ref ble_gatts_value_set_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_value Pointer to attribute value information. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_value_set_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_gatts_value_t * const p_value, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_sys_attr_get command request. + * + * @sa @ref ble_gatts_sys_attr_get_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle of the connection. + * @param[in] p_sys_attr_data Pointer to buffer where updated information about system + * attributes will be stored. Can be NULL to calculate required + * size. + * @param[in] p_sys_attr_data_len Size of p_sys_attr_data buffer if \p p_sys_attr_data is + * not NULL. + * @param[in] flags Additional optional flags. + * @param[in,out] p_buf Pointer to buffer where encoded data command will + * be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @note \p p_sys_attr_data and \p p_sys_attr_data_len will not be updated by the command + * request encoder. Updated values are set by @ref ble_gatts_sys_attr_get_rsp_dec. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_sys_attr_get_req_enc(uint16_t conn_handle, + uint8_t const * const p_sys_attr_data, + uint16_t const * const p_sys_attr_data_len, + uint32_t flags, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_sys_attr_get command. + * + * @sa @ref ble_gatts_sys_attr_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] pp_sys_attr_data Pointer to a buffer where updated information about system + * attributes will be stored. + * @param[in,out] pp_sys_attr_data_len \c in: Size (in bytes) of \p p_sys_attr_data buffer. + * \c out: Length of decoded contents of \p p_sys_attr_data. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Length of \p p_sys_attr_data is too small to hold decoded + * value from response. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_sys_attr_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t * * const pp_sys_attr_data, + uint16_t * * const pp_sys_attr_data_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_descriptor_add command request. + * + * @sa @ref ble_gatts_descriptor_add_rsp_dec for command response decoder. + * + * @param[in] char_handle Handle of the characteristic where the description is to be placed. + * If @ref BLE_GATT_HANDLE_INVALID is used, it will be placed + * sequentially. + * @param[in] p_attr Pointer to a @ref ble_gatts_attr_t structure, characteristic + * metadata. + * @param[in] p_handle Pointer to a @ref ble_gatts_char_handles_t structure, where the + * assigned handles will be stored. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_descriptor_add_req_enc(uint16_t char_handle, + ble_gatts_attr_t const * const p_attr, + uint16_t * const p_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_descriptor_add command. + * + * @sa @ref ble_gatts_descriptor_add_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_handle Pointer to bufer where descriptor handle will be + returned. + * @param[out] p_result_code Pointer to command result code decode location. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_descriptor_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * const p_handle, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_include_add command request. + * + * @sa @ref ble_gatts_include_add_rsp_dec for command response decoder. + * + * @param[in] service_handle Handle of the service where the included service is to be placed. + * @param[in] inc_srvc_handle Handle of the included service + * @param[in] p_include_handle Pointer to Pointer to a 16-bit word where the assigned handle will be stored. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_include_add_req_enc(uint16_t service_handle, + uint16_t inc_srvc_handle, + uint16_t * const p_include_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_include_add command. + * + * @sa @ref ble_gatts_include_add_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored. + * @param[out] p_result_code Pointer to command result code decode location. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_include_add_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * const p_include_handle, + uint32_t * const p_result_code); + + +/**@brief Encodes @ref sd_ble_gatts_rw_authorize_reply command request. + * + * @sa @ref ble_gatts_rw_authorize_reply_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_reply_params Pointer to \ref ble_gatts_rw_authorize_reply_params_t + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_PARAM Encoding failure. Invalid param provided in p_reply_params. + */ +uint32_t ble_gatts_rw_authorize_reply_req_enc( + uint16_t conn_handle, + ble_gatts_rw_authorize_reply_params_t const * const + p_reply_params, + uint8_t * const + p_buf, + uint32_t * const + p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_rw_authorize_reply command. + * + * @sa @ref ble_gatts_rw_authorize_reply_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_rw_authorize_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_service_changed command request. + * + * @sa @ref ble_gatts_service_changed_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] start_handle Start of affected attribute handle range. + * @param[in] end_handle End of affected attribute handle range. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_PARAM Encoding failure. Invalid param provided in p_reply_params. + */ +uint32_t ble_gatts_service_changed_req_enc(uint16_t conn_handle, + uint16_t start_handle, + uint16_t end_handle, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_service_changed command. + * + * @sa @ref ble_gatts_service_changed_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_service_changed_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_attr_get command request. + * + * @sa @ref ble_gatts_attr_get_rsp_dec for command response decoder. + * + * @param[in] handle See @ref sd_ble_gatts_attr_get. + * @param[in] p_uuid See @ref sd_ble_gatts_attr_get. + * @param[out] p_md See @ref sd_ble_gatts_attr_get. + * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_attr_get_req_enc(uint16_t handle, + ble_uuid_t * p_uuid, + ble_gatts_attr_md_t * p_md, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_attr_get command. + * + * @sa @ref ble_gatts_attr_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] pp_uuid Pointer to address where to put output data. + * @param[out] pp_md Pointer to address where to put output data. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_attr_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_uuid_t ** pp_uuid, + ble_gatts_attr_md_t ** pp_md, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_initial_user_handle_get command request. + * + * @sa @ref ble_gatts_initial_user_handle_get_rsp_dec for command response decoder. + * + * @param[out] p_handle See @ref sd_ble_gatts_initial_user_handle_get. + * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_gatts_initial_user_handle_get_req_enc(uint16_t * p_handle, + uint8_t * const p_buf, + uint32_t * p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_initial_user_handle_get command. + * + * @sa @ref ble_gatts_initial_user_handle_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] pp_handle Pointer to address where to put output data. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_initial_user_handle_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t ** pp_handle, + uint32_t * const p_result_code); + +/**@brief Encodes @ref sd_ble_gatts_exchange_mtu_reply command request. + * + * @sa @ref ble_gatts_exchange_mtu_reply_rsp_dec for command response decoder. + * + * @param[in] conn_handle Connection handle. + * @param[in] server_rx_mtu Server MTU Size. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_PARAM Encoding failure. Invalid param provided in p_reply_params. + */ +uint32_t ble_gatts_exchange_mtu_reply_req_enc(uint16_t conn_handle, + uint16_t server_rx_mtu, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ble_gatts_exchange_mtu_reply command. + * + * @sa @ref ble_gatts_exchange_mtu_reply_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_gatts_exchange_mtu_reply_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif //BLE_GATTS_APP_H__ + + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_evt_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_evt_app.c new file mode 100644 index 000000000..3add7d7ba --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_evt_app.c @@ -0,0 +1,190 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gatts_evt_app.h" +#include "ble_serialization.h" +#include "ble_gatts_struct_serialization.h" +#include "app_ble_user_mem.h" +#include "app_util.h" + +extern ser_ble_user_mem_t m_app_user_mem_table[]; + +uint32_t ble_gatts_evt_hvc_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_HVC, gatts, hvc); + + SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gatts_evt.params.hvc, + ble_gatts_evt_hvc_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_gatts_evt_rw_authorize_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_HVC, gatts, rw_authorize_request); + + SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gatts_evt.params.authorize_request, ble_gatts_evt_rw_authorize_request_t_dec); + + //Correct event length / memory sync. + if (p_event->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_READ) + { + evt_struct_len = offsetof(ble_evt_t, evt.gatts_evt.params.authorize_request.request.read) + - offsetof(ble_evt_t, evt) + + sizeof(ble_gatts_evt_read_t); + } + else if ((p_event->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) && + ( (p_event->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) || + (p_event->evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_PREP_WRITE_REQ))) + { + uint32_t conn_index; + if (app_ble_user_mem_context_find(p_event->evt.gatts_evt.conn_handle, &conn_index) != NRF_ERROR_NOT_FOUND) + { + SER_PULL_len16data(&m_app_user_mem_table[conn_index].mem_block.p_mem, &m_app_user_mem_table[conn_index].mem_block.len); + } + } + + SER_EVT_DEC_END; +} + + +uint32_t ble_gatts_evt_sc_confirm_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN_NO_STRUCT(BLE_GATTS_EVT_SC_CONFIRM, gatts); + SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); + SER_EVT_DEC_END; +} + + +uint32_t ble_gatts_evt_sys_attr_missing_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_SYS_ATTR_MISSING, gatts, sys_attr_missing); + + SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gatts_evt.params.sys_attr_missing, + ble_gatts_evt_sys_attr_missing_t_dec); + + SER_EVT_DEC_END; +} + + +uint32_t ble_gatts_evt_timeout_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_TIMEOUT, gatts, timeout); + + SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gatts_evt.params.timeout, + ble_gatts_evt_timeout_t_dec); + + SER_EVT_DEC_END; +} + + + + +uint32_t ble_gatts_evt_write_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_WRITE, gatts, write); + + SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.gatts_evt.params.write, ble_gatts_evt_write_t_dec); + + if (p_event != NULL) + { + if (p_event->evt.gatts_evt.params.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) + { + uint32_t conn_index; + if (app_ble_user_mem_context_find(p_event->evt.gatts_evt.conn_handle, &conn_index) != NRF_ERROR_NOT_FOUND) + { + SER_PULL_len16data(&m_app_user_mem_table[conn_index].mem_block.p_mem, &m_app_user_mem_table[conn_index].mem_block.len); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + } + } + } + + SER_EVT_DEC_END; +} + + +uint32_t ble_gatts_evt_exchange_mtu_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, gatts, exchange_mtu_request); + + SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); + SER_PULL_FIELD(&p_event->evt.gatts_evt.params.exchange_mtu_request, ble_gatts_evt_exchange_mtu_request_t_dec); + + SER_EVT_DEC_END; +} + +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_gatts_evt_hvn_tx_complete_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_GATTS_EVT_HVN_TX_COMPLETE, gatts, hvn_tx_complete); + + SER_PULL_uint16(&p_event->evt.gatts_evt.conn_handle); + SER_PULL_uint8(&p_event->evt.gatts_evt.params.hvn_tx_complete.count); + + SER_EVT_DEC_END; +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_evt_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_evt_app.h new file mode 100644 index 000000000..4995e7bb6 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_gatts_evt_app.h @@ -0,0 +1,249 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GATTS_EVT_APP_H__ +#define BLE_GATTS_EVT_APP_H__ + +/**@file + * + * @defgroup ble_gatts_evt_app GATTS Application event decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief GATTS Application event decoders. + */ +#include "ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Decodes ble_gatts_evt_hvc event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gatts_evt_hvc_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gatts_evt_rw_authorize_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gatts_evt_rw_authorize_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gatts_evt_sc_confirm event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gatts_evt_sc_confirm_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gatts_evt_sys_attr_missing event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gatts_evt_sys_attr_missing_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gatts_evt_timeout event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gatts_evt_timeout_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gatts_evt_write event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gatts_evt_write_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +/** + * @brief Decodes ble_gatts_evt_exchange_mtu_request event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gatts_evt_exchange_mtu_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +#if NRF_SD_BLE_API_VERSION >= 4 + +/** + * @brief Decodes ble_gatts_evt_hvn_tx_complete event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_gatts_evt_hvn_tx_complete_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +#endif +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_app.c new file mode 100644 index 000000000..cfff5fbf2 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_app.c @@ -0,0 +1,279 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include "ble_l2cap_app.h" +#include "ble_serialization.h" +#include "ble_struct_serialization.h" +#include "ble_l2cap_struct_serialization.h" +#include "ble_gap.h" +#include "app_util.h" +#include "cond_field_serialization.h" + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_l2cap_cid_register_req_enc(uint16_t cid, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + SER_ASSERT_LENGTH_LEQ(index + 3, *p_buf_len); + + p_buf[index++] = SD_BLE_L2CAP_CID_REGISTER; + err_code = uint16_t_enc(&cid, p_buf, *p_buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ble_l2cap_cid_register_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SD_BLE_L2CAP_CID_REGISTER, p_result_code); +} + +uint32_t ble_l2cap_cid_unregister_req_enc(uint16_t cid, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + SER_ASSERT_LENGTH_LEQ(index + 3, *p_buf_len); + + p_buf[index++] = SD_BLE_L2CAP_CID_UNREGISTER; + err_code = uint16_t_enc(&cid, p_buf, *p_buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + *p_buf_len = index; + + return err_code; +} + +uint32_t ble_l2cap_cid_unregister_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SD_BLE_L2CAP_CID_UNREGISTER, p_result_code); +} + + +uint32_t ble_l2cap_tx_req_enc(uint16_t conn_handle, + ble_l2cap_header_t const * const p_l2cap_header, + uint8_t const * const p_data, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + uint32_t index = 0; + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + + SER_ASSERT_LENGTH_LEQ(1, *p_buf_len); + p_buf[index++] = SD_BLE_L2CAP_TX; + + err_code = uint16_t_enc(&conn_handle, p_buf, *p_buf_len, &index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = cond_field_enc(p_l2cap_header, p_buf, *p_buf_len, &index, ble_l2cap_header_t_enc); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (p_l2cap_header != NULL) + { + err_code = buf_enc(p_data, p_l2cap_header->len, p_buf, *p_buf_len, &index); + } + else + { + err_code = buf_enc(NULL, 0, p_buf, *p_buf_len, &index); + } + + *p_buf_len = index; + + return err_code; +} + +uint32_t ble_l2cap_tx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + return ser_ble_cmd_rsp_dec(p_buf, packet_len, SD_BLE_L2CAP_TX, p_result_code); +} +#endif + +#if NRF_SD_BLE_API_VERSION >= 5 +uint32_t ble_l2cap_ch_setup_req_enc(uint16_t conn_handle, + uint16_t * p_local_cid, + ble_l2cap_ch_setup_params_t const *p_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_L2CAP_CH_SETUP); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_COND(p_local_cid, uint16_t_enc); + SER_PUSH_COND(p_params, ble_l2cap_ch_setup_params_t_enc); + + SER_REQ_ENC_END; +} + +uint32_t ble_l2cap_ch_setup_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * p_local_cid, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_L2CAP_CH_SETUP); + SER_PULL_COND((void **)&p_local_cid, uint16_t_dec); + SER_RSP_DEC_END; +} + +uint32_t ble_l2cap_ch_release_req_enc(uint16_t conn_handle, + uint16_t local_cid, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_L2CAP_CH_RELEASE); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&local_cid); + + SER_REQ_ENC_END; +} + +uint32_t ble_l2cap_ch_release_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_L2CAP_CH_RELEASE); +} + +uint32_t ble_l2cap_ch_rx_req_enc(uint16_t conn_handle, + uint16_t local_cid, + ble_data_t const *p_sdu_buf, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_L2CAP_CH_RX); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&local_cid); + + SER_PUSH_COND(p_sdu_buf, NULL); + if (p_sdu_buf) + { + SER_PUSH_uint16(&p_sdu_buf->len); + SER_PUSH_uint32(&p_sdu_buf->p_data); + } + + SER_REQ_ENC_END; +} + +uint32_t ble_l2cap_ch_rx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_L2CAP_CH_RX); +} + +uint32_t ble_l2cap_ch_tx_req_enc(uint16_t conn_handle, + uint16_t local_cid, + ble_data_t const *p_sdu_buf, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_L2CAP_CH_TX); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&local_cid); + + SER_PUSH_COND(p_sdu_buf, NULL); + if (p_sdu_buf) + { + SER_PUSH_uint32(&p_sdu_buf->p_data); + SER_PUSH_uint16(&p_sdu_buf->len); + SER_PUSH_buf(p_sdu_buf->p_data, p_sdu_buf->len); + } + + SER_REQ_ENC_END; +} + +uint32_t ble_l2cap_ch_tx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_RESULT_ONLY(SD_BLE_L2CAP_CH_TX); +} + +uint32_t ble_l2cap_ch_flow_control_req_enc(uint16_t conn_handle, + uint16_t local_cid, + uint16_t credits, + uint16_t *p_credits, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_BLE_L2CAP_CH_FLOW_CONTROL); + + SER_PUSH_uint16(&conn_handle); + SER_PUSH_uint16(&local_cid); + SER_PUSH_uint16(&credits); + SER_PUSH_COND(p_credits, NULL); + + SER_REQ_ENC_END; +} + +uint32_t ble_l2cap_ch_flow_control_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * p_credits, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_BLE_L2CAP_CH_FLOW_CONTROL); + SER_PULL_COND((void **)&p_credits, uint16_t_dec); + SER_RSP_DEC_END; +} +#endif //NRF_SD_BLE_API_VERSION >= 5 diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_app.h new file mode 100644 index 000000000..bf0cc1ccf --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_app.h @@ -0,0 +1,242 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/**@file + * + * @defgroup ble_l2cap_app L2CAP Application command request encoders and command response decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief L2CAP Application command request encoders and command response decoders. + */ + +#ifndef BLE_L2CAP_APP_H__ +#define BLE_L2CAP_APP_H__ + +#include "ble.h" +#include "ble_types.h" +#include "ble_ranges.h" +#include "ble_err.h" +#include "ble_l2cap.h" + +#ifdef __cplusplus +extern "C" { +#endif +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +/**@brief Register a CID with L2CAP. + * + * @details This registers a higher protocol layer with the L2CAP multiplexer, and is required prior to all operations on the CID. + * + * @param[in] cid L2CAP CID. + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_l2cap_cid_register_req_enc(uint16_t cid, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_l2cap_cid_register command. + * + * @sa @ref ble_l2cap_cid_register_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_l2cap_cid_register_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Unregister a CID with L2CAP. + * + * @details This unregisters a previously registered higher protocol layer with the L2CAP multiplexer. + * + * @param[in] cid L2CAP CID. + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ble_l2cap_cid_unregister_req_enc(uint16_t cid, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_l2cap_cid_unregister command. + * + * @sa @ref ble_l2cap_cid_unregister_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_l2cap_cid_unregister_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +/**@brief Transmit an L2CAP packet. + * + * @note It is important to note that a call to this function will consume an application buffer, and will therefore + * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. + * See the documentation of @ref sd_ble_tx_packet_count_get for more details. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_l2cap_header Pointer to a packet header containing length and CID. + * @param[in] p_data Pointer to the data to be transmitted. + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in,out] p_buf_len\ c in: Size of \p p_buf buffer. + * \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Successfully queued an L2CAP packet for transmission. + * @retval NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register. + * @retval NRF_ERROR_NOT_FOUND CID not found. + * @retval NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @retval NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF. + */ +uint32_t ble_l2cap_tx_req_enc(uint16_t conn_handle, + ble_l2cap_header_t const * const p_l2cap_header, + uint8_t const * const p_data, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** + * @brief Decodes response to @ref sd_ble_l2cap_tx command. + * + * @sa @ref ble_l2cap_tx_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match + * expected operation code. + */ +uint32_t ble_l2cap_tx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); +#endif + +#if NRF_SD_BLE_API_VERSION >= 5 +uint32_t ble_l2cap_ch_setup_req_enc(uint16_t conn_handle, + uint16_t * p_local_cid, + ble_l2cap_ch_setup_params_t const *p_params, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +uint32_t ble_l2cap_ch_setup_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * p_local_cid, + uint32_t * const p_result_code); + +uint32_t ble_l2cap_ch_release_req_enc(uint16_t conn_handle, + uint16_t local_cid, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +uint32_t ble_l2cap_ch_release_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +uint32_t ble_l2cap_ch_rx_req_enc(uint16_t conn_handle, + uint16_t local_cid, + ble_data_t const *p_sdu_buf, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +uint32_t ble_l2cap_ch_rx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +uint32_t ble_l2cap_ch_tx_req_enc(uint16_t conn_handle, + uint16_t local_cid, + ble_data_t const *p_sdu_buf, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +uint32_t ble_l2cap_ch_tx_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code); + +uint32_t ble_l2cap_ch_flow_control_req_enc(uint16_t conn_handle, + uint16_t local_cid, + uint16_t credits, + uint16_t *p_credits, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +uint32_t ble_l2cap_ch_flow_control_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint16_t * p_credits, + uint32_t * const p_result_code); +#endif //NRF_SD_BLE_API_VERSION >= 5 + +#ifdef __cplusplus +} +#endif + +#endif //BLE_L2CAP_APP_H__ + +/** + @} + */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_evt_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_evt_app.c new file mode 100644 index 000000000..07680c566 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_evt_app.c @@ -0,0 +1,183 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_serialization.h" +#include "ble_struct_serialization.h" +#include "ble_l2cap_struct_serialization.h" +#include "app_util.h" +#include "ble_l2cap_evt_app.h" + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_l2cap_evt_rx_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_RX, l2cap, rx); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_FIELD_EXTENDED(&p_event->evt.l2cap_evt.params.rx, ble_l2cap_evt_rx_t_dec); + + SER_EVT_DEC_END; +} +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION >= 5 + +uint32_t ble_l2cap_evt_ch_setup_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_CH_SETUP_REQUEST, l2cap, ch_setup_request); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.l2cap_evt.local_cid); + SER_PULL_uint16(&p_event->evt.l2cap_evt.params.ch_setup_request.le_psm); + SER_PULL_FIELD(&p_event->evt.l2cap_evt.params.ch_setup_request.tx_params, ble_l2cap_ch_tx_params_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_l2cap_evt_ch_setup_refused_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_CH_SETUP_REFUSED, l2cap, ch_setup_refused); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.l2cap_evt.local_cid); + SER_PULL_uint8(&p_event->evt.l2cap_evt.params.ch_setup_refused.source); + SER_PULL_uint16(&p_event->evt.l2cap_evt.params.ch_setup_refused.status); + + SER_EVT_DEC_END; +} + +uint32_t ble_l2cap_evt_ch_setup_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_CH_SETUP, l2cap, ch_setup); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.l2cap_evt.local_cid); + SER_PULL_FIELD(&p_event->evt.l2cap_evt.params.ch_setup.tx_params, ble_l2cap_ch_tx_params_t_dec); + + SER_EVT_DEC_END; +} + +uint32_t ble_l2cap_evt_ch_released_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN_NO_STRUCT(BLE_L2CAP_EVT_CH_RELEASED, l2cap); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.l2cap_evt.local_cid); + + SER_EVT_DEC_END; +} + +uint32_t ble_l2cap_evt_ch_sdu_buf_released_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED, l2cap, ch_sdu_buf_released); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.l2cap_evt.local_cid); + SER_PULL_uint16(&p_event->evt.l2cap_evt.params.ch_sdu_buf_released.sdu_buf.len); + SER_PULL_uint32(&p_event->evt.l2cap_evt.params.ch_sdu_buf_released.sdu_buf.p_data); + + SER_EVT_DEC_END; +} + +uint32_t ble_l2cap_evt_ch_credit_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_CH_CREDIT, l2cap, ch_credit); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.l2cap_evt.local_cid); + SER_PULL_uint16(&p_event->evt.l2cap_evt.params.credit.credits); + + SER_EVT_DEC_END; +} + +uint32_t ble_l2cap_evt_ch_rx_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_CH_RX, l2cap, ch_rx); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.l2cap_evt.local_cid); + SER_PULL_uint16(&p_event->evt.l2cap_evt.params.rx.sdu_len); + SER_PULL_uint16(&p_event->evt.l2cap_evt.params.rx.sdu_buf.len); + + SER_PULL_uint32(&p_event->evt.l2cap_evt.params.rx.sdu_buf.p_data); + SER_PULL_buf(&p_event->evt.l2cap_evt.params.rx.sdu_buf.p_data, p_event->evt.l2cap_evt.params.rx.sdu_buf.len, p_event->evt.l2cap_evt.params.rx.sdu_buf.len); + + SER_EVT_DEC_END; +} + + +uint32_t ble_l2cap_evt_ch_tx_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len) +{ + SER_EVT_DEC_BEGIN(BLE_L2CAP_EVT_CH_TX, l2cap, ch_tx); + + SER_PULL_uint16(&p_event->evt.l2cap_evt.conn_handle); + SER_PULL_uint16(&p_event->evt.l2cap_evt.local_cid); + SER_PULL_uint16(&p_event->evt.l2cap_evt.params.tx.sdu_buf.len); + SER_PULL_uint32(&p_event->evt.l2cap_evt.params.tx.sdu_buf.p_data); + + SER_EVT_DEC_END; +} + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_evt_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_evt_app.h new file mode 100644 index 000000000..2957f6656 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/ble_l2cap_evt_app.h @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_L2CAP_EVT_APP_H__ +#define BLE_L2CAP_EVT_APP_H__ + +/**@file + * + * @defgroup ble_l2cap_evt_app L2CAP Application event decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief L2CAP Application event decoders. + */ +#include "ble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Decodes ble_l2cap_evt_rx event. + * + * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len. + * + * @param[in] p_buf Pointer to the beginning of an event packet. + * @param[in] packet_len Length (in bytes) of the event packet. + * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be + * stored. If NULL, required length will be returned in \p p_event_len. + * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer. + * \c out: Length of decoded contents of \p p_event. + * + * @retval NRF_SUCCESS Decoding success. + * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ble_l2cap_evt_rx_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +uint32_t ble_l2cap_evt_ch_setup_request_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +uint32_t ble_l2cap_evt_ch_setup_refused_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +uint32_t ble_l2cap_evt_ch_setup_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +uint32_t ble_l2cap_evt_ch_released_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +uint32_t ble_l2cap_evt_ch_sdu_buf_released_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +uint32_t ble_l2cap_evt_ch_credit_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + +uint32_t ble_l2cap_evt_ch_rx_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); + + +uint32_t ble_l2cap_evt_ch_tx_dec(uint8_t const * const p_buf, + uint32_t packet_len, + ble_evt_t * const p_event, + uint32_t * const p_event_len); +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/nrf_soc_app.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/nrf_soc_app.c new file mode 100644 index 000000000..b749d8036 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/nrf_soc_app.c @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "nrf_soc_app.h" +#include "nrf_soc.h" +#include +#include +#include "ble_serialization.h" +#include "cond_field_serialization.h" +#include "nrf_soc_struct_serialization.h" +#include "app_util.h" + + +uint32_t ecb_block_encrypt_req_enc(nrf_ecb_hal_data_t * p_ecb_data, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_ECB_BLOCK_ENCRYPT); + SER_PUSH_COND(p_ecb_data, nrf_ecb_hal_data_t_in_enc); + SER_REQ_ENC_END; +} + + +uint32_t ecb_block_encrypt_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + nrf_ecb_hal_data_t * * const pp_ecb_data, + uint32_t * const p_result_code) +{ + SER_RSP_DEC_BEGIN(SD_ECB_BLOCK_ENCRYPT); + SER_PULL_COND(pp_ecb_data, nrf_ecb_hal_data_t_out_dec); + SER_RSP_DEC_END; +} + + +uint32_t power_system_off_req_enc(uint8_t * const p_buf, uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_POWER_SYSTEM_OFF); + SER_REQ_ENC_END; +} + + +uint32_t temp_get_req_enc(int32_t const * const p_temp, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_REQ_ENC_BEGIN(SD_TEMP_GET); + SER_PUSH_COND(p_temp, NULL); + SER_REQ_ENC_END; +} + +uint32_t temp_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code, + int32_t * * const pp_temp) +{ + SER_RSP_DEC_BEGIN(SD_TEMP_GET); + SER_PULL_COND(pp_temp, uint32_t_dec); + SER_RSP_DEC_END; +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/nrf_soc_app.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/nrf_soc_app.h new file mode 100644 index 000000000..c42c3b23e --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/codecs/ble/serializers/nrf_soc_app.h @@ -0,0 +1,147 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/**@file + * + * @defgroup soc_app SOC Application command request encoders and command response decoders + * @{ + * @ingroup ser_app_s130_codecs + * + * @brief SOC Application command request encoders and command response decoders. + */ + +#ifndef NRF_SOC_APP_H__ +#define NRF_SOC_APP_H__ + +#include +#include "nrf_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif +/**@brief Encodes @ref sd_power_system_off command request. + * + * + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of p_buf buffer. \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t power_system_off_req_enc(uint8_t * const p_buf, uint32_t * const p_buf_len); + + +/**@brief Encodes @ref sd_temp_get command request. + * + * @sa @ref temp_get_rsp_dec for command response decoder. + * + * @param[in] p_temp Pointer to result of temperature measurement. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of p_buf buffer. \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t temp_get_req_enc(int32_t const * const p_temp, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_temp_get command. + * + * @sa @ref temp_get_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_result_code Command result code. + * @param[out] pp_temp Pointer to result of temperature measurement. + * + * @retval NRF_SUCCESS Version information stored successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t temp_get_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const p_result_code, + int32_t * * const pp_temp); + +/**@brief Encodes @ref sd_ecb_block_encrypt command request. + * + * @sa @ref ecb_block_encrypt_rsp_dec for command response decoder. + * + * @param[in] p_ecb_data Pointer to ECB data. + * @param[in] p_buf Pointer to buffer where encoded data command will be returned. + * @param[in,out] p_buf_len \c in: size of p_buf buffer. \c out: Length of encoded command packet. + * + * @retval NRF_SUCCESS Encoding success. + * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length. + */ +uint32_t ecb_block_encrypt_req_enc(nrf_ecb_hal_data_t * p_ecb_data, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/**@brief Decodes response to @ref sd_ecb_block_encrypt command. + * + * @sa @ref ecb_block_encrypt_req_enc for command request encoder. + * + * @param[in] p_buf Pointer to beginning of command response packet. + * @param[in] packet_len Length (in bytes) of response packet. + * @param[out] p_ecb_data Pointer to ECB data. + * @param[out] p_result_code Command result code. + * + * @retval NRF_SUCCESS Version information stored successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to + * hold decoded event. + */ +uint32_t ecb_block_encrypt_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + nrf_ecb_hal_data_t * * const p_ecb_data, + uint32_t * const p_result_code); +/** @} */ + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_SOC_APP_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal.h new file mode 100644 index 000000000..a44da2571 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal.h @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/**@file + * + * @defgroup ser_app_hal Serialization Application Hardware Abstraction Layer (HAL) + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Functions that set up hardware on Application Board and perform the reset of the Connectivity Board. + */ + +#ifndef SER_APP_HAL_H_ +#define SER_APP_HAL_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +typedef void (*ser_app_hal_flash_op_done_handler_t)(bool success); +/**@brief Function for initializing hardware modules. + * + * @details Function can initialize hardware modules on the Application Chip. It is optional to + * implement. It is called once the Connectivity Chip is initialized. + * + * @param handler Flash operation event handler. + * + * @return @ref NRF_SUCCESS HAL initialized successfully. + * @return @ref nrf_error "NRF_ERROR_..." HAL initialization failed. + * + */ +uint32_t ser_app_hal_hw_init(ser_app_hal_flash_op_done_handler_t handler); + +/**@brief Function for waiting for a given amount of time. + * + * @param[in] ms Number of milliseconds to wait. + * + */ +void ser_app_hal_delay(uint32_t ms); + +/**@brief Function for clearing the Connectivity Chip reset pin. + * + */ +void ser_app_hal_nrf_reset_pin_clear(void); + +/**@brief Function for setting the Connectivity Chip reset pin. + * + */ +void ser_app_hal_nrf_reset_pin_set(void); + + +/**@brief Function for setting the SoftDevice event interrupt priority that serves the events incoming + * from the Connectivity Chip. + * + * @note Serialization solution on the application side mimics a SoC solution where events are handled in + * the interrupt context in two ways: either directly in the interrupt context or with a message being posted to + * the scheduler. However, it is possible that the Application Chip does not use a dedicated interrupt + * for connectivity events. In that case, this function can be left empty and + * \ref ser_app_hal_nrf_evt_pending will directly call an interrupt handler function. + */ +void ser_app_hal_nrf_evt_irq_priority_set(void); + +/**@brief Function for setting a pending interrupt for serving events incoming from the Connectivity Chip. + * + * @note The interrupt used for event from the Connectivity Chip mimics behavior of SoC and it is not + * intended to be triggered by any hardware event. This function should be the only source of + * interrupt triggering. + */ +void ser_app_hal_nrf_evt_pending(void); + + + +#ifdef __cplusplus +} +#endif + +#endif /* SER_APP_HAL_H_ */ +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c new file mode 100644 index 000000000..e5f25f69e --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c @@ -0,0 +1,163 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "app_util_platform.h" +#include "ser_app_hal.h" +#include "nrf.h" +#include "nrf_gpio.h" +#include "nrf_soc.h" +#include "nrf_delay.h" +#include "nrf_nvmc.h" +#include "boards.h" +#include "ser_phy.h" +#include "ser_phy_config_app.h" +#include "nrf_drv_clock.h" + +#define SOFTDEVICE_EVT_IRQ SD_EVT_IRQn /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */ +#define FLASH_WRITE_MAX_LENGTH ((uint16_t)NRF_FICR->CODEPAGESIZE) +#define BLE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE) /**< Size of one flash page. */ + +static ser_app_hal_flash_op_done_handler_t m_flash_op_handler; +uint32_t ser_app_hal_hw_init(ser_app_hal_flash_op_done_handler_t handler) +{ + nrf_gpio_cfg_output(CONN_CHIP_RESET_PIN_NO); + + if (NRF_SUCCESS != nrf_drv_clock_init()) + { + return NRF_ERROR_INTERNAL; + } + + nrf_drv_clock_lfclk_request(NULL); + nrf_drv_clock_hfclk_request(NULL); + + while (false == nrf_drv_clock_hfclk_is_running()); + while (false == nrf_drv_clock_lfclk_is_running()); + + m_flash_op_handler = handler; + + return NRF_SUCCESS; +} + +void ser_app_hal_delay(uint32_t ms) +{ + nrf_delay_ms(ms); +} + +void ser_app_hal_nrf_reset_pin_clear() +{ + nrf_gpio_pin_clear(CONN_CHIP_RESET_PIN_NO); +} + +void ser_app_hal_nrf_reset_pin_set() +{ + nrf_gpio_pin_set(CONN_CHIP_RESET_PIN_NO); +} + +void ser_app_hal_nrf_evt_irq_priority_set() +{ + NVIC_SetPriority(SOFTDEVICE_EVT_IRQ, APP_IRQ_PRIORITY_LOWEST); +} + +void ser_app_hal_nrf_evt_pending() +{ + NVIC_SetPendingIRQ(SOFTDEVICE_EVT_IRQ); +} + +uint32_t sd_ppi_channel_enable_get(uint32_t * p_channel_enable) +{ + *p_channel_enable = NRF_PPI->CHEN; + return NRF_SUCCESS; +} + +uint32_t sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk) +{ + NRF_PPI->CHEN = channel_enable_set_msk; + return NRF_SUCCESS; +} + +uint32_t sd_ppi_channel_assign(uint8_t channel_num, + const volatile void * evt_endpoint, + const volatile void * task_endpoint) +{ + NRF_PPI->CH[channel_num].TEP = (uint32_t)task_endpoint; + NRF_PPI->CH[channel_num].EEP = (uint32_t)evt_endpoint; + return NRF_SUCCESS; +} +/** + * @brief Check if given address is in device FLASH range. + * + * @param[in] ptr Address to check. + * @retval true Given address is located in FLASH. + * @retval false Given address is not located in FLASH. + */ +__STATIC_INLINE bool addr_is_in_FLASH(void const * const ptr) +{ + return ((((uintptr_t)ptr) & 0xFF000000u) == 0x00000000u); +} + +uint32_t sd_flash_page_erase(uint32_t page_number) +{ + uint32_t * p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_number); + + if (!addr_is_in_FLASH(p_page)) + { + return NRF_ERROR_INVALID_ADDR; + } + + nrf_nvmc_page_erase((uint32_t) p_page); + m_flash_op_handler(true); + return NRF_SUCCESS; +} + +uint32_t sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size) +{ + if (size > FLASH_WRITE_MAX_LENGTH) + { + return NRF_ERROR_INVALID_LENGTH; + } + + if (!addr_is_in_FLASH(p_dst)) + { + return NRF_ERROR_INVALID_ADDR; + } + + nrf_nvmc_write_words((uint32_t) p_dst, p_src, size); + m_flash_op_handler(true); + return NRF_SUCCESS; +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c new file mode 100644 index 000000000..7d0a3a6bb --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "nrf.h" +#include "ser_app_power_system_off.h" + +static bool m_power_system_off = false; + + +void ser_app_power_system_off_set(void) +{ + m_power_system_off = true; +} + +bool ser_app_power_system_off_get(void) +{ + return m_power_system_off; +} + +void ser_app_power_system_off_enter(void) +{ + NRF_POWER->SYSTEMOFF = POWER_SYSTEMOFF_SYSTEMOFF_Enter; + + /*Only for debugging purpose, will not be reached without connected debugger*/ + while (1); +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.h new file mode 100644 index 000000000..35506364a --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.h @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef APP_POWER_SYSTEM_OFF_H +#define APP_POWER_SYSTEM_OFF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void ser_app_power_system_off_set(void); + +bool ser_app_power_system_off_get(void); + +void ser_app_power_system_off_enter(void); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c new file mode 100644 index 000000000..67efc317e --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c @@ -0,0 +1,325 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include +#include "ser_sd_transport.h" +#include "ser_hal_transport.h" +#include "nrf_error.h" +#include "app_error.h" +#include "ble_serialization.h" +#include "ser_dbg_sd_str.h" +#include "ser_app_power_system_off.h" +#include "app_util.h" +#define NRF_LOG_MODULE_NAME ser_xfer +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +#ifdef BLE_STACK_SUPPORT_REQD +/** SoftDevice event handler. */ +static ser_sd_transport_evt_handler_t m_ble_evt_handler = NULL; +#endif // BLE_STACK_SUPPORT_REQD + +#ifdef ANT_STACK_SUPPORT_REQD +/** SoftDevice event handler for ANT events. */ +static ser_sd_transport_evt_handler_t m_ant_evt_handler = NULL; +#endif // ANT_STACK_SUPPORT_REQD + +/** 'One time' handler called in task context while waiting for response to scheduled command. */ +static ser_sd_transport_rsp_wait_handler_t m_ot_rsp_wait_handler = NULL; + +/** Handler called in task context while waiting for response to scheduled command. */ +static ser_sd_transport_rsp_wait_handler_t m_os_rsp_wait_handler = NULL; + +/** Handler called in serial peripheral interrupt context when response is received. */ +static ser_sd_transport_rsp_set_handler_t m_os_rsp_set_handler = NULL; + +/** Handler called when hal_transport notifies that packet reception has started. */ +static ser_sd_transport_rx_notification_handler_t m_rx_notify_handler = NULL; + +/** User decoder handler for expected response packet. */ +static ser_sd_transport_rsp_handler_t m_rsp_dec_handler = NULL; + +/** Flag indicated whether module is waiting for response packet. */ +static volatile bool m_rsp_wait = false; + +/** SoftDevice call return value decoded by user decoder handler. */ +static uint32_t m_return_value; + +/**@brief Function for handling the rx packets comming from hal_transport. + * + * @details + * This function is called in serial peripheral interrupt context. Response packets are handled in + * this context. Events are passed to the application and it is up to application in which context + * they are handled. + * + * @param[in] p_data Pointer to received data. + * @param[in] length Size of data. + */ +static void ser_sd_transport_rx_packet_handler(uint8_t * p_data, uint16_t length) +{ + if (p_data && (length >= SER_PKT_TYPE_SIZE)) + { + const uint8_t packet_type = p_data[SER_PKT_TYPE_POS]; + p_data += SER_PKT_TYPE_SIZE; + length -= SER_PKT_TYPE_SIZE; + + switch (packet_type) + { + case SER_PKT_TYPE_RESP: + case SER_PKT_TYPE_DTM_RESP: +#ifdef ANT_STACK_SUPPORT_REQD + case SER_PKT_TYPE_ANT_RESP: +#endif // ANT_STACK_SUPPORT_REQD + if (m_rsp_wait) + { + m_return_value = m_rsp_dec_handler(p_data, length); + (void)ser_sd_transport_rx_free(p_data); + + /* Reset response flag - cmd_write function is pending on it.*/ + m_rsp_wait = false; + + /* If os handler is set, signal os that response has arrived.*/ + if (m_os_rsp_set_handler) + { + m_os_rsp_set_handler(); + } + } + else + { + /* Unexpected packet. */ + (void)ser_sd_transport_rx_free(p_data); + APP_ERROR_HANDLER(packet_type); + } + break; + +#ifdef BLE_STACK_SUPPORT_REQD + case SER_PKT_TYPE_EVT: + /* It is ensured during opening that handler is not NULL. No check needed. */ + NRF_LOG_DEBUG("[EVT]: %s ", (uint32_t)ser_dbg_sd_evt_str_get(uint16_decode(&p_data[SER_EVT_ID_POS]))); // p_data points to EVT_ID + m_ble_evt_handler(p_data, length); + break; +#endif // BLE_STACK_SUPPORT_REQD + +#ifdef ANT_STACK_SUPPORT_REQD + case SER_PKT_TYPE_ANT_EVT: + /* It is ensured during opening that handler is not NULL. No check needed. */ + NRF_LOG_DEBUG("[ANT_EVT_ID]: %s ", (uint32_t)ser_dbg_sd_evt_str_get(uint16_decode(&p_data[SER_EVT_ID_POS]))); // p_data points to EVT_ID + m_ant_evt_handler(p_data, length); + break; +#endif // ANT_STACK_SUPPORT_REQD + + default: + (void)ser_sd_transport_rx_free(p_data); + APP_ERROR_HANDLER(packet_type); + break; + } + } +} + +/**@brief Function for handling the event from hal_transport. + * + * @param[in] event Event from hal_transport. + */ +static void ser_sd_transport_hal_handler(ser_hal_transport_evt_t event) +{ + switch (event.evt_type) + { + case SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED: + ser_sd_transport_rx_packet_handler(event.evt_params.rx_pkt_received.p_buffer, + event.evt_params.rx_pkt_received.num_of_bytes); + break; + case SER_HAL_TRANSP_EVT_RX_PKT_RECEIVING: + if (m_rx_notify_handler) + { + m_rx_notify_handler(); + } + break; + case SER_HAL_TRANSP_EVT_TX_PKT_SENT: + if (ser_app_power_system_off_get() == true) + { + ser_app_power_system_off_enter(); + } + break; + case SER_HAL_TRANSP_EVT_PHY_ERROR: + + if (m_rsp_wait) + { + m_return_value = NRF_ERROR_INTERNAL; + + /* Reset response flag - cmd_write function is pending on it.*/ + m_rsp_wait = false; + + /* If os handler is set, signal os that response has arrived.*/ + if (m_os_rsp_set_handler) + { + m_os_rsp_set_handler(); + } + } + break; + default: + break; + } +} + +uint32_t ser_sd_transport_open(ser_sd_transport_evt_handler_t ble_evt_handler, + ser_sd_transport_evt_handler_t ant_evt_handler, + ser_sd_transport_rsp_wait_handler_t os_rsp_wait_handler, + ser_sd_transport_rsp_set_handler_t os_rsp_set_handler, + ser_sd_transport_rx_notification_handler_t rx_not_handler) +{ + m_os_rsp_wait_handler = os_rsp_wait_handler; + m_os_rsp_set_handler = os_rsp_set_handler; + m_rx_notify_handler = rx_not_handler; + m_ot_rsp_wait_handler = NULL; + +#ifdef ANT_STACK_SUPPORT_REQD + m_ant_evt_handler = ant_evt_handler; + + if (m_ant_evt_handler == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } +#else + UNUSED_PARAMETER(ant_evt_handler); +#endif // ANT_STACK_SUPPORT_REQD + +#ifdef BLE_STACK_SUPPORT_REQD + m_ble_evt_handler = ble_evt_handler; + + if (m_ble_evt_handler == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } +#else + UNUSED_PARAMETER(ble_evt_handler); +#endif // BLE_STACK_SUPPORT_REQD + + return ser_hal_transport_open(ser_sd_transport_hal_handler); +} + +uint32_t ser_sd_transport_close(void) +{ +#ifdef ANT_STACK_SUPPORT_REQD + m_ant_evt_handler = NULL; +#endif // ANT_STACK_SUPPORT_REQD + +#ifdef BLE_STACK_SUPPORT_REQD + m_ble_evt_handler = NULL; +#endif // BLE_STACK_SUPPORT_REQD + + m_os_rsp_wait_handler = NULL; + m_os_rsp_set_handler = NULL; + m_ot_rsp_wait_handler = NULL; + + ser_hal_transport_close(); + + return NRF_SUCCESS; +} + +uint32_t ser_sd_transport_ot_rsp_wait_handler_set(ser_sd_transport_rsp_wait_handler_t handler) +{ + m_ot_rsp_wait_handler = handler; + + return NRF_SUCCESS; +} + +bool ser_sd_transport_is_busy(void) +{ + return m_rsp_wait; +} + +uint32_t ser_sd_transport_tx_alloc(uint8_t * * pp_data, uint16_t * p_len) +{ + uint32_t err_code; + + if (m_rsp_wait) + { + err_code = NRF_ERROR_BUSY; + } + else + { + err_code = ser_hal_transport_tx_pkt_alloc(pp_data, p_len); + } + return err_code; +} + +uint32_t ser_sd_transport_tx_free(uint8_t * p_data) +{ + return ser_hal_transport_tx_pkt_free(p_data); +} + +uint32_t ser_sd_transport_rx_free(uint8_t * p_data) +{ + p_data -= SER_PKT_TYPE_SIZE; + return ser_hal_transport_rx_pkt_free(p_data); +} + +uint32_t ser_sd_transport_cmd_write(const uint8_t * p_buffer, + uint16_t length, + ser_sd_transport_rsp_handler_t cmd_rsp_decode_callback) +{ + uint32_t err_code = NRF_SUCCESS; + + m_rsp_wait = true; + m_rsp_dec_handler = cmd_rsp_decode_callback; + err_code = ser_hal_transport_tx_pkt_send(p_buffer, length); + APP_ERROR_CHECK(err_code); + + /* Execute callback for response decoding only if one was provided.*/ + if ((err_code == NRF_SUCCESS) && cmd_rsp_decode_callback) + { + if (m_ot_rsp_wait_handler) + { + m_ot_rsp_wait_handler(); + m_ot_rsp_wait_handler = NULL; + } + + m_os_rsp_wait_handler(); + err_code = m_return_value; + } + else + { + m_rsp_wait = false; + } + + NRF_LOG_DEBUG("[SD_CALL]:%s, err_code= 0x%X", (uint32_t)ser_dbg_sd_call_str_get(p_buffer[1]), err_code); + return err_code; +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.h new file mode 100644 index 000000000..5854e6bcf --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.h @@ -0,0 +1,193 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** + * @addtogroup ser_app Application side code + * @ingroup ble_sdk_lib_serialization + * @brief SoftDevice handler and transport on the application side. + */ + +/** @file + * + * @defgroup ser_sd_transport Serialization SoftDevice Transport + * @{ + * @ingroup ser_app + * + * @brief Serialization SoftDevice Transport on application side. + * + * @details This file contains declarations of functions and definitions of data structures and + * identifiers (typedef enum) used as API of the serialization of SoftDevice. This layer + * ensures atomic nature of SoftDevice calls (command and waiting for response). Packet + * type field of incoming packets is handled in this layer - responses are handled by + * ser_sd_transport (using response decoder handler provided for each SoftDevice call), but + * events are forwarded to the user so it is up to the user to free the RX buffer. + * + */ +#ifndef SER_SD_TRANSPORT_H_ +#define SER_SD_TRANSPORT_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*ser_sd_transport_evt_handler_t)(uint8_t * p_buffer, uint16_t length); +typedef void (*ser_sd_transport_rsp_wait_handler_t)(void); +typedef void (*ser_sd_transport_rsp_set_handler_t)(void); +typedef void (*ser_sd_transport_rx_notification_handler_t)(void); + +typedef uint32_t (*ser_sd_transport_rsp_handler_t)(const uint8_t * p_buffer, uint16_t length); + +/**@brief Function for opening the module. + * + * @note 'Wait for response' and 'Response set' callbacks can be set in RTOS environment. + * It enables rescheduling while waiting for the Connectivity Chip response. In a nonOS environment, + * usually 'Wait for response' will only be used for handling incoming events or forcing the + * application to low power mode. + * + * @param[in] ble_evt_handler Handler to be called when ble event packet is received. + * @param[in] ant_evt_handler Handler to be called when ant event packet is received. + * @param[in] os_rsp_wait_handler Handler to be called after the request is send. It should + * implement a 'Wait for signal' functionality in an OS environment. + * @param[in] os_rsp_set_handler Handler to be called after response reception. It should + * implement a 'Signal Set' functionality in an OS environment. + * @param[in] rx_not_handler Handler to be called after the transport layer notifies that + * an incoming RX packet is detected. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_PARAM Operation failure. Parameter propagated from ser_hal_transport + * opening or timer creation. + * @retval NRF_ERROR_INVALID_STATE Operation failure. Parameter propagated from ser_hal_transport + * opening or timer creation. + * @retval NRF_ERROR_INTERNAL Operation failure. Parameter propagated from ser_hal_transport + * opening or timer creation. + * @retval NRF_ERROR_NO_MEM Operation failure. Parameter propagated from timer creation. + */ +uint32_t ser_sd_transport_open(ser_sd_transport_evt_handler_t ble_evt_handler, + ser_sd_transport_evt_handler_t ant_evt_handler, + ser_sd_transport_rsp_wait_handler_t os_rsp_wait_handler, + ser_sd_transport_rsp_set_handler_t os_rsp_set_handler, + ser_sd_transport_rx_notification_handler_t rx_not_handler); + + +/**@brief Function setting a 'One Time' handler to be called between sending the next request packet and + * receiving the response packet. + * @note It is intended to be used in a nonOS environment to implement concurrency. + * @note It is a 'One Time' handler meaning that it is valid only for the next SoftDevice call processing. + * + * + * @param[in] wait_handler Handler to be called after the request packet is sent. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t ser_sd_transport_ot_rsp_wait_handler_set(ser_sd_transport_rsp_wait_handler_t wait_handler); + + +/**@brief Function for closing the module. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t ser_sd_transport_close(void); + +/**@brief Function for allocating a TX packet to be used for request command. + * + * @param[out] pp_data Pointer to the data pointer to be set to point to allocated buffer. + * @param[out] p_len Pointer to allocated buffer length. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t ser_sd_transport_tx_alloc(uint8_t * * pp_data, uint16_t * p_len); + + +/**@brief Function for freeing a TX packet. + * + * @note Function should be called once the command is processed. + * + * @param[out] p_data Pointer to the allocated TX buffer. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t ser_sd_transport_tx_free(uint8_t * p_data); + + +/**@brief Function for freeing an RX event packet. + * + * @note Function should be called once the SoftDevice event buffer is processed. + * + * @param[out] p_data Pointer to the allocated RX buffer. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t ser_sd_transport_rx_free(uint8_t * p_data); + + +/**@brief Function for checking if module is busy waiting for response from connectivity side. + * + * @retval true Module busy. Cannot accept the next command. + * @retval false Module not busy. Can accept next the command. + */ +bool ser_sd_transport_is_busy(void); + +/**@brief Function for handling a SoftDevice command. + * + * @note Function blocks task context until response is received and processed. + * @note Non-blocking functionality can be achieved using OS handlers or a 'One Time' handler + * @warning Function should not be called from interrupt context, which would block switching to + * serial port interrupt. + * + * @param[in] p_buffer Pointer to command. + * @param[in] length Pointer to allocated buffer length. + * @param[in] cmd_resp_decode_callback Pointer to a function for decoding the response packet. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t ser_sd_transport_cmd_write(const uint8_t * p_buffer, + uint16_t length, + ser_sd_transport_rsp_handler_t cmd_resp_decode_callback); + + +#ifdef __cplusplus +} +#endif + +#endif /* SER_SD_TRANSPORT_H_ */ +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c new file mode 100644 index 000000000..f9fc1d5ea --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c @@ -0,0 +1,311 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include "nrf_queue.h" +#include "app_scheduler.h" +#include "nrf_sdh.h" +#include "nrf_sdm.h" +#include "ser_sd_transport.h" +#include "ser_app_hal.h" +#include "ser_config.h" +#include "nrf_soc.h" +#include "ble_serialization.h" +#if defined(BLE_STACK_SUPPORT_REQD) +#include "ble_app.h" +#include "nrf_sdh_ble.h" +#endif +#if defined(ANT_STACK_SUPPORT_REQD) +#include "ant_event.h" +#endif + +#define SD_BLE_EVT_MAILBOX_QUEUE_SIZE 5 /**< Size of mailbox queue. */ + +/** @brief Structure used to pass packet details through mailbox. + */ +#if defined(BLE_STACK_SUPPORT_REQD) +typedef struct +{ + //lint -save -e666 + uint32_t evt_data[CEIL_DIV(NRF_SDH_BLE_EVT_BUF_SIZE, sizeof (uint32_t))]; /**< Buffer for decoded event */ + //lint -restore +} ser_sd_handler_evt_data_t; +#endif + +#if defined(ANT_STACK_SUPPORT_REQD) +typedef struct +{ + uint32_t evt_data[CEIL_DIV(sizeof(ant_evt_t), sizeof (uint32_t))]; /**< Buffer for decoded event */ +} ser_ant_sd_handler_evt_data_t; +#endif + +/** @brief + * Mailbox used for communication between event handler (called from serial stream + * interrupt context) and event processing function (called from scheduler or interrupt context). + */ +#if defined(BLE_STACK_SUPPORT_REQD) +NRF_QUEUE_DEF(ser_sd_handler_evt_data_t, + m_sd_ble_evt_mailbox, + SD_BLE_EVT_MAILBOX_QUEUE_SIZE, + NRF_QUEUE_MODE_NO_OVERFLOW); +#endif + +#if defined(ANT_STACK_SUPPORT_REQD) +NRF_QUEUE_DEF(ser_ant_sd_handler_evt_data_t, + m_sd_ant_evt_mailbox, + SD_BLE_EVT_MAILBOX_QUEUE_SIZE, + NRF_QUEUE_MODE_NO_OVERFLOW); +#endif + +NRF_QUEUE_DEF(uint32_t, + m_sd_soc_evt_mailbox, + SD_BLE_EVT_MAILBOX_QUEUE_SIZE, + NRF_QUEUE_MODE_NO_OVERFLOW); + +/** + * @brief Function to be replaced by user implementation if needed. + * + * Weak function - user can add different implementation of this function if application needs it. + */ +__WEAK void os_rsp_set_handler(void) +{ + +} + +static void connectivity_reset_low(void) +{ + //Signal a reset to the connectivity chip by setting the reset pin low. + ser_app_hal_nrf_reset_pin_clear(); + ser_app_hal_delay(CONN_CHIP_RESET_TIME); + +} + +static void connectivity_reset_high(void) +{ + + //Set the reset level to high again. + ser_app_hal_nrf_reset_pin_set(); + + //Wait for connectivity chip to be ready. + ser_app_hal_delay(CONN_CHIP_WAKEUP_TIME); +} + +#if defined(BLE_STACK_SUPPORT_REQD) +static void ser_softdevice_ble_evt_handler(uint8_t * p_data, uint16_t length) +{ + ser_sd_handler_evt_data_t item; + uint32_t err_code; + uint32_t len32 = sizeof (item.evt_data); + + err_code = ble_event_dec(p_data, length, (ble_evt_t *)item.evt_data, &len32); + APP_ERROR_CHECK(err_code); + + err_code = ser_sd_transport_rx_free(p_data); + APP_ERROR_CHECK(err_code); + + err_code = nrf_queue_push(&m_sd_ble_evt_mailbox, &item); + APP_ERROR_CHECK(err_code); + + ser_app_hal_nrf_evt_pending(); +} +#endif + +#if defined(ANT_STACK_SUPPORT_REQD) +static void ser_softdevice_ant_evt_handler(uint8_t * p_data, uint16_t length) +{ + ser_ant_sd_handler_evt_data_t item; + uint32_t err_code; + uint32_t len32 = sizeof (item.evt_data); + + err_code = ant_event_dec(p_data, length, (ant_evt_t *)item.evt_data, &len32); + APP_ERROR_CHECK(err_code); + + err_code = ser_sd_transport_rx_free(p_data); + APP_ERROR_CHECK(err_code); + + err_code = nrf_queue_push(&m_sd_ant_evt_mailbox, &item); + APP_ERROR_CHECK(err_code); + + ser_app_hal_nrf_evt_pending(); +} +#endif + +void ser_softdevice_flash_operation_success_evt(bool success) +{ + uint32_t evt_type = success ? NRF_EVT_FLASH_OPERATION_SUCCESS : + NRF_EVT_FLASH_OPERATION_ERROR; + + uint32_t err_code = nrf_queue_push(&m_sd_soc_evt_mailbox, &evt_type); + APP_ERROR_CHECK(err_code); + + ser_app_hal_nrf_evt_pending(); +} + +/** + * @brief Function called while waiting for connectivity chip response. It handles incoming events. + */ +static void ser_sd_rsp_wait(void) +{ + do + { + (void)sd_app_evt_wait(); + + //intern_softdevice_events_execute(); + } + while (ser_sd_transport_is_busy()); +} + +uint32_t sd_evt_get(uint32_t * p_evt_id) +{ + return nrf_queue_pop(&m_sd_soc_evt_mailbox, p_evt_id); +} + +#if defined(BLE_STACK_SUPPORT_REQD) +uint32_t sd_ble_evt_get(uint8_t * p_data, uint16_t * p_len) +{ + uint32_t err_code = nrf_queue_pop(&m_sd_ble_evt_mailbox, p_data); + + if (err_code == NRF_SUCCESS) //if anything in the mailbox + { + if (((ble_evt_t *)p_data)->header.evt_len > *p_len) + { + err_code = NRF_ERROR_DATA_SIZE; + } + else + { + *p_len = ((ble_evt_t *)p_data)->header.evt_len; + } + } + else + { + err_code = NRF_ERROR_NOT_FOUND; + } + + return err_code; +} +#endif + +#if defined(ANT_STACK_SUPPORT_REQD) +uint32_t sd_ant_event_get(uint8_t* p_channel, uint8_t* p_event, uint8_t* p_ant_mesg) +{ + SER_ASSERT_NOT_NULL(p_channel); + SER_ASSERT_NOT_NULL(p_event); + SER_ASSERT_NOT_NULL(p_ant_mesg); + + uint32_t err_code; + + ser_ant_sd_handler_evt_data_t item; + + err_code = nrf_queue_pop(&m_sd_ant_evt_mailbox, &item); + + if (err_code == NRF_SUCCESS) + { + *p_event = ((ant_evt_t *)item.evt_data) -> event; + *p_channel = ((ant_evt_t *)item.evt_data) -> channel; + memcpy(p_ant_mesg, ((ant_evt_t *)item.evt_data)->message.aucMessage, MESG_BUFFER_SIZE); + } else { + err_code = NRF_ERROR_NOT_FOUND; + } + + return err_code; +} +#endif + +#if defined(BLE_STACK_SUPPORT_REQD) +uint32_t sd_ble_evt_mailbox_length_get(uint32_t * p_mailbox_length) +{ + *p_mailbox_length = nrf_queue_utilization_get(&m_sd_ble_evt_mailbox); + return NRF_SUCCESS; +} +#endif + +#if (defined(S332) || defined(S212)) +uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, + nrf_fault_handler_t fault_handler, + const char* p_license_key) +#else +uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, + nrf_fault_handler_t assertion_handler) +#endif +{ + uint32_t err_code; + + err_code = ser_app_hal_hw_init(ser_softdevice_flash_operation_success_evt); + + if (err_code == NRF_SUCCESS) + { + connectivity_reset_low(); + + nrf_queue_reset(&m_sd_soc_evt_mailbox); + ser_sd_transport_evt_handler_t ble_evt_handler = NULL; + ser_sd_transport_evt_handler_t ant_evt_handler = NULL; + +#ifdef BLE_STACK_SUPPORT_REQD + ble_evt_handler = ser_softdevice_ble_evt_handler; + nrf_queue_reset(&m_sd_ble_evt_mailbox); +#endif // BLE_STACK_SUPPORT_REQD + +#ifdef ANT_STACK_SUPPORT_REQD + ant_evt_handler = ser_softdevice_ant_evt_handler; + nrf_queue_reset(&m_sd_ant_evt_mailbox); +#endif // ANT_STACK_SUPPORT_REQD + err_code = ser_sd_transport_open(ble_evt_handler, + ant_evt_handler, + ser_sd_rsp_wait, + os_rsp_set_handler, + NULL); + + if (err_code == NRF_SUCCESS) + { + connectivity_reset_high(); + } + + ser_app_hal_nrf_evt_irq_priority_set(); + } + + return err_code; +} + + +uint32_t sd_softdevice_disable(void) +{ + return ser_sd_transport_close(); +} + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.h new file mode 100644 index 000000000..0a5bd059f --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.h @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** + * @addtogroup ser_app Application side code + * @ingroup ble_sdk_lib_serialization + */ + +/** @file + * + * @defgroup ser_softdevice_handler Serialization SoftDevice Handler + * @{ + * @ingroup ser_app + * + * @brief Serialization SoftDevice Handler on application side. + * + */ +#ifndef SER_SOFTDEVICE_HANDLER_H_ +#define SER_SOFTDEVICE_HANDLER_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/**@brief Function for checking if there are any more events in the internal mailbox. + * + * @param[in] p_mailbox_length Pointer to mailbox length. + * + * @retval ::NRF_SUCCESS Length succesfully obtained. + * @retval ::NRF_ERROR_NULL Null pointer provided. + */ +uint32_t sd_ble_evt_mailbox_length_get(uint32_t * p_mailbox_length); + + +#ifdef __cplusplus +} +#endif + +#endif /* SER_SOFTDEVICE_HANDLER_H_ */ +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ble_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ble_serialization.c new file mode 100644 index 000000000..f8307a9e7 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ble_serialization.c @@ -0,0 +1,549 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_serialization.h" +#include "nrf_error.h" +#include "app_util.h" +#include +#include + +uint32_t ser_ble_cmd_rsp_status_code_enc(uint8_t op_code, + uint32_t command_status, + uint8_t * const p_buf, + uint32_t * const p_buf_len) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_buf_len); + uint32_t index = 0; + + SER_ASSERT_LENGTH_LEQ(SER_CMD_RSP_HEADER_SIZE, *p_buf_len); + + //Encode Op Code. + p_buf[index++] = op_code; + + //Encode Status. + index += uint32_encode(command_status, &(p_buf[index])); + *p_buf_len = index; + + return NRF_SUCCESS; +} + + +uint32_t ser_ble_cmd_rsp_result_code_dec(uint8_t const * const p_buf, + uint32_t * const p_pos, + uint32_t packet_len, + uint8_t op_code, + uint32_t * const p_result_code) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_pos); + SER_ASSERT_NOT_NULL(p_result_code); + + if (packet_len < SER_CMD_RSP_HEADER_SIZE) + { + return NRF_ERROR_DATA_SIZE; + } + + if (p_buf[(*p_pos)] != op_code) + { + return NRF_ERROR_INVALID_DATA; + } + + *p_result_code = uint32_decode(&(p_buf[(*p_pos) + SER_CMD_RSP_STATUS_CODE_POS])); + *p_pos += SER_CMD_RSP_HEADER_SIZE; + + return NRF_SUCCESS; +} + + +uint32_t ser_ble_cmd_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t op_code, + uint32_t * const p_result_code) +{ + uint32_t index = 0; + uint32_t result_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, op_code, + p_result_code); + + if (result_code != NRF_SUCCESS) + { + return result_code; + } + + if (index != packet_len) + { + return NRF_ERROR_DATA_SIZE; + } + + return NRF_SUCCESS; +} + +uint32_t uint32_t_enc(void const * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_field); + SER_ASSERT_NOT_NULL(p_index); + + uint32_t * p_uint32 = (uint32_t *)p_field; + + SER_ASSERT_LENGTH_LEQ(4, buf_len - *p_index); + + *p_index += uint32_encode(*p_uint32, &p_buf[*p_index]); + + return NRF_SUCCESS; +} + +uint32_t uint32_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * p_field) +{ + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_index); + SER_ASSERT_NOT_NULL(p_field); + + uint32_t * p_uint32 = (uint32_t *)p_field; + + SER_ASSERT_LENGTH_LEQ(4, ((int32_t)buf_len - *p_index)); + + *p_uint32 = uint32_decode(&p_buf[*p_index]); + *p_index += 4; + + return NRF_SUCCESS; +} + +uint32_t uint16_t_enc(const void * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + uint16_t * p_u16 = (uint16_t *)p_field; + + SER_ASSERT_LENGTH_LEQ(2, buf_len - *p_index); + + *p_index += uint16_encode(*p_u16, &p_buf[*p_index]); + + return NRF_SUCCESS; +} + +uint32_t uint16_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * p_field) +{ + uint16_t * p_u16 = (uint16_t *)p_field; + + SER_ASSERT_LENGTH_LEQ(2, ((int32_t)buf_len - *p_index)); + + *p_u16 = uint16_decode(&p_buf[*p_index]); + *p_index += 2; + + return NRF_SUCCESS; +} + +void uint16_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const index, + uint16_t * const value) +{ + SER_ASSERT_VOID_RETURN(*index + 2 <= buf_len); + *value = uint16_decode(&p_buf[*index]); + *index += 2; +} + +uint32_t uint8_t_enc(const void * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index); + + uint8_t * p_u8 = (uint8_t *)p_field; + p_buf[*p_index] = *p_u8; + *p_index += 1; + + return NRF_SUCCESS; +} + +uint32_t uint8_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * p_field) +{ + uint8_t * p_u8 = (uint8_t *)p_field; + + SER_ASSERT_LENGTH_LEQ(1, ((int32_t)buf_len - *p_index)); + *p_u8 = p_buf[*p_index]; + *p_index += 1; + + return NRF_SUCCESS; +} + +void uint8_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const index, + uint8_t * const value) +{ + SER_ASSERT_VOID_RETURN(*index + 1 <= buf_len); + *value = p_buf[*index]; + *index += 1; +} + + +void int8_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const index, + int8_t * const value) +{ + SER_ASSERT_VOID_RETURN(*index + 1 <= buf_len); + *value = p_buf[*index]; + *index += 1; +} + +uint32_t len8data_enc(uint8_t const * const p_data, + uint8_t const dlen, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + uint32_t err_code = NRF_SUCCESS; + + err_code = uint8_t_enc(&dlen, p_buf, buf_len, p_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = buf_enc(p_data, dlen, p_buf, buf_len, p_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + return err_code; +} + +uint32_t len8data_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * * const pp_data, + uint8_t * const p_len) +{ + uint32_t err_code = NRF_SUCCESS; + uint16_t out_buf_len = *p_len; + + err_code = uint8_t_dec(p_buf, buf_len, p_index, p_len); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = buf_dec(p_buf, buf_len, p_index, pp_data, out_buf_len, *p_len); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + return err_code; +} + +uint32_t len16data_enc(uint8_t const * const p_data, + uint16_t const dlen, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + uint32_t err_code = NRF_SUCCESS; + + err_code = uint16_t_enc(&dlen, p_buf, buf_len, p_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = buf_enc(p_data, dlen, p_buf, buf_len, p_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + return err_code; +} + +uint32_t len16data_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * * const pp_data, + uint16_t * const p_dlen) +{ + uint32_t err_code = NRF_SUCCESS; + uint16_t out_buf_len = *p_dlen; + + err_code = uint16_t_dec(p_buf, buf_len, p_index, p_dlen); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + err_code = buf_dec(p_buf, buf_len, p_index, pp_data, out_buf_len, *p_dlen); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + return err_code; +} + +uint32_t count16_cond_data16_enc(uint16_t const * const p_data, + uint16_t const count, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + uint32_t i = 0; + + SER_ASSERT_LENGTH_LEQ(3, ((int32_t)buf_len - *p_index)); + *p_index += uint16_encode(count, &p_buf[*p_index]); + + if (p_data) + { + SER_ASSERT_LENGTH_LEQ((int32_t)(2 * count + 1), ((int32_t)buf_len - (int32_t) * p_index)); + p_buf[*p_index] = SER_FIELD_PRESENT; + *p_index += 1; + + //memcpy may fail in case of Endianness difference between application and connectivity processor + for (i = 0; i < count; i++) + { + *p_index += uint16_encode(p_data[i], &p_buf[*p_index]); + } + } + else + { + SER_ASSERT_LENGTH_LEQ((1), ((int32_t)buf_len - *p_index)); + p_buf[*p_index] = SER_FIELD_NOT_PRESENT; + *p_index += 1; + } + + return NRF_SUCCESS; +} + +uint32_t count16_cond_data16_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint16_t * * const pp_data, + uint16_t * const p_count) + +{ + uint16_t count = 0; + uint8_t is_present = 0; + uint16_t i; + + SER_ASSERT_NOT_NULL(p_count); + SER_ASSERT_NOT_NULL(pp_data); + SER_ASSERT_NOT_NULL(*pp_data); + + SER_ASSERT_LENGTH_LEQ(3, ((int32_t)buf_len - (*p_index))); + + uint16_dec(p_buf, buf_len, p_index, &count); + + if (count > *p_count) + { + return NRF_ERROR_DATA_SIZE; + } + + SER_ASSERT_LENGTH_LEQ(count, *p_count); + + uint8_dec(p_buf, buf_len, p_index, &is_present); + + if (!is_present) + { + *p_count = count; + *pp_data = NULL; + return NRF_SUCCESS; + } + else + { + for (i = 0; i < count; i++ ) + { + uint16_dec(p_buf, buf_len, p_index, &((&(**pp_data))[i]) ); + } + *p_count = i; + } + return NRF_SUCCESS; +} + + + +uint32_t cond_len16_cond_data_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * * const pp_data, + uint16_t * * const pp_len) +{ + SER_ASSERT_NOT_NULL(pp_len); + SER_ASSERT_NOT_NULL(*pp_len); + SER_ASSERT_NOT_NULL(pp_data); + SER_ASSERT_NOT_NULL(*pp_data); + + SER_ASSERT_LENGTH_LEQ(2, ((int32_t)buf_len - (*p_index))); + uint8_t is_present = 0; + + uint8_dec(p_buf, buf_len, p_index, &is_present); + + if (!is_present) + { + *pp_len = NULL; //if length field is not present + (*p_index)++; //then data can not be present + *pp_data = NULL; + return NRF_SUCCESS; + } + else + { + return len16data_dec(p_buf, buf_len, p_index, pp_data, *pp_len); + } +} + +uint32_t op_status_enc(uint8_t op_code, + uint32_t return_code, + uint8_t * const p_buff, + uint32_t * const p_buff_len, + uint32_t * const p_index) +{ + SER_ASSERT_NOT_NULL(p_buff); + SER_ASSERT_NOT_NULL(p_buff_len); + SER_ASSERT_NOT_NULL(p_index); + SER_ASSERT_LENGTH_LEQ(SER_CMD_RSP_HEADER_SIZE, *p_buff_len - *p_index); + + //Encode Op Code. + p_buff[(*p_index)++] = op_code; + //Encode Status. + *p_index += uint32_encode(return_code, &(p_buff[*p_index])); + //update size of used buffer + *p_buff_len = *p_index; + + return NRF_SUCCESS; +} + +uint32_t op_status_cond_uint16_enc(uint8_t op_code, + uint32_t return_code, + uint16_t value, + uint8_t * const p_buff, + uint32_t * const p_buff_len, + uint32_t * const p_index) +{ + uint32_t status_code; + uint32_t init_buff_len = *p_buff_len; + + status_code = op_status_enc(op_code, return_code, p_buff, p_buff_len, p_index); + SER_ASSERT(status_code == NRF_SUCCESS, status_code); + + if (return_code == NRF_SUCCESS) //Add 16bit value when return_code is a success + { + *p_buff_len = init_buff_len; //restore original value - it has been modified by op_status_enc + status_code = uint16_t_enc(&value, p_buff, *p_buff_len, p_index); + *p_buff_len = *p_index; + SER_ASSERT(status_code == NRF_SUCCESS, status_code); + } + + return status_code; +} + +uint32_t buf_enc(uint8_t const * const p_data, + uint16_t const dlen, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + uint32_t err_code = NRF_SUCCESS; + uint8_t is_present = (p_data == NULL) ? SER_FIELD_NOT_PRESENT : SER_FIELD_PRESENT; + + err_code = uint8_t_enc(&is_present, p_buf, buf_len, p_index); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + + if (p_data) + { + SER_ASSERT_LENGTH_LEQ(dlen, ((int32_t)buf_len - *p_index)); + memcpy(&p_buf[*p_index], p_data, dlen); + *p_index += dlen; + } + + return err_code; +} + +uint32_t buf_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * * const pp_data, + uint16_t data_len, + uint16_t dlen) +{ + uint8_t is_present = 0; + + SER_ASSERT_LENGTH_LEQ(1, ((int32_t)buf_len - *p_index)); + uint8_dec(p_buf, buf_len, p_index, &is_present); + + if (is_present == SER_FIELD_PRESENT) + { + SER_ASSERT_NOT_NULL(pp_data); + SER_ASSERT_NOT_NULL(*pp_data); + SER_ASSERT_LENGTH_LEQ(dlen, data_len); + SER_ASSERT_LENGTH_LEQ(dlen, ((int32_t)buf_len - *p_index)); + memcpy(*pp_data, &p_buf[*p_index], dlen); + *p_index += dlen; + } + else + { + if (pp_data) + { + *pp_data = NULL; + } + } + return NRF_SUCCESS; +} + +uint32_t uint8_vector_enc(uint8_t const * const p_data, + uint16_t const dlen, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + + SER_ASSERT_NOT_NULL(p_data); + SER_ASSERT_NOT_NULL(p_buf); + SER_ASSERT_NOT_NULL(p_index); + SER_ASSERT_LENGTH_LEQ(dlen, ((int32_t)buf_len - *p_index)); + memcpy(&p_buf[*p_index], p_data, dlen); + *p_index += dlen; + + return NRF_SUCCESS; +} + +uint32_t uint8_vector_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * const p_data, + uint16_t dlen) +{ + SER_ASSERT_NOT_NULL(p_data); + SER_ASSERT_LENGTH_LEQ(dlen, ((int32_t)buf_len - *p_index)); + memcpy(p_data, &p_buf[*p_index], dlen); + *p_index += dlen; + + return NRF_SUCCESS; +} + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ble_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ble_serialization.h new file mode 100644 index 000000000..4f7d61b7a --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ble_serialization.h @@ -0,0 +1,1103 @@ +/** + * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_SERIALIZATION_H__ +#define BLE_SERIALIZATION_H__ + +#include "nordic_common.h" +#include "nrf_error.h" +#include +#include +#include "cond_field_serialization.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Types of serialization packets. */ +typedef enum +{ + SER_PKT_TYPE_CMD = 0, /**< Command packet type. */ + SER_PKT_TYPE_RESP, /**< Command Response packet type. */ + SER_PKT_TYPE_EVT, /**< Event packet type. */ + SER_PKT_TYPE_DTM_CMD, /**< DTM Command packet type. */ + SER_PKT_TYPE_DTM_RESP, /**< DTM Response packet type. */ + SER_PKT_TYPE_GENERIC_CMD, /**< GENERIC Command packet type. */ +#if defined(ANT_STACK_SUPPORT_REQD) + SER_PKT_TYPE_ANT_CMD, /**< ANT Command packet type. */ + SER_PKT_TYPE_ANT_RESP, /**< ANT Response packet type. */ + SER_PKT_TYPE_ANT_EVT, /**< ANT Event packet type. */ +#endif + SER_PKT_TYPE_MAX /**< Upper bound. */ +} ser_pkt_type_t; + +typedef enum +{ + SER_GENERIC_CMD_RESET, + SER_GENERIC_CMD_SOFT_RESET +} ser_generic_cmd_t; + +#define LOW16(a) ((uint16_t)((a & 0x0000FFFF) >> 0)) +#define HIGH16(a) ((uint16_t)((a & 0xFFFF0000) >> 16)) + +//lint -esym(516,__INTADDR__) Symbol '__INTADDR__()' has arg. type conflict +//lint -esym(628,__INTADDR__) no argument information provided for function '__INTADDR__()' + +/** Size in bytes of the Error Code field in a Command Response packet. */ +#define SER_ERR_CODE_SIZE 4 +/** Size in bytes of the Packet Type field (@ref ser_pkt_type_t). */ +#define SER_PKT_TYPE_SIZE 1 +/** Size in bytes of the Operation Code field. */ +#define SER_OP_CODE_SIZE 1 + +/** Position of the Packet Type field in a serialized packet buffer. */ +#define SER_PKT_TYPE_POS 0 +/** Position of the Operation Code field in a serialized packet buffer. */ +#define SER_PKT_OP_CODE_POS (SER_PKT_TYPE_SIZE) +/** Position of the Data in a serialized packet buffer. */ +#define SER_PKT_DATA_POS (SER_PKT_TYPE_SIZE + SER_OP_CODE_SIZE) + +/** Position of the Operation Code field in a command buffer. */ +#define SER_CMD_OP_CODE_POS 0 +/** Position of the Data in a command buffer.*/ +#define SER_CMD_DATA_POS (SER_OP_CODE_SIZE) +/** Size of the Command header. */ +#define SER_CMD_HEADER_SIZE (SER_OP_CODE_SIZE) +/** Size of the Command Response header. */ +#define SER_CMD_RSP_HEADER_SIZE (SER_OP_CODE_SIZE + SER_ERR_CODE_SIZE) +/** Position of the Command Response code. */ +#define SER_CMD_RSP_STATUS_CODE_POS (SER_OP_CODE_SIZE) + +/** Size of event ID field. */ +#define SER_EVT_ID_SIZE 2 +/** Position of event ID field. */ +#define SER_EVT_ID_POS 0 +/** Size of event header. */ +#define SER_EVT_HEADER_SIZE (SER_EVT_ID_SIZE) +/** Size of event connection handler. */ +#define SER_EVT_CONN_HANDLE_SIZE 2 + +#if defined(ANT_STACK_SUPPORT_REQD) +/** Size of event ID field. */ +#define SER_ANT_EVT_ID_SIZE 2 +/** Position of event ID field. */ +#define SER_ANT_EVT_ID_POS 0 +/** Size of event header. */ +#define SER_ANT_EVT_HEADER_SIZE (SER_ANT_EVT_ID_SIZE) +#endif + +/** Position of the Op Code in the DTM command buffer.*/ +#define SER_DTM_CMD_OP_CODE_POS 0 +/** Position of the data in the DTM command buffer.*/ +#define SER_DTM_CMD_DATA_POS 1 + +/** Position of the Op Code in the DTM command response buffer.*/ +#define SER_DTM_RESP_OP_CODE_POS 1 +/** Position of the status field in the DTM command response buffer.*/ +#define SER_DTM_RESP_STATUS_POS 2 + +/** Value to indicate that an optional field is encoded in the serialized packet, e.g. white list.*/ +#define SER_FIELD_PRESENT 0x01 +/** Value to indicate that an optional field is not encoded in the serialized packet. */ +#define SER_FIELD_NOT_PRESENT 0x00 + + +/** Enable SER_ASSERT<*> asserts */ +#define SER_ASSERTS_ENABLED 1 + +/** Returns with error code if expr is not true. It is used for checking error which should be + * checked even when SER_ASSERTS_ENABLED is not set. */ +#define SER_ERROR_CHECK(expr, error_code) do { if (!(expr)) return (error_code); } while (0) + + +#ifdef SER_ASSERTS_ENABLED +/** Returns with error code if expr is not true. */ +#define SER_ASSERT(expr, error_code) SER_ERROR_CHECK(expr, error_code) +/** Returns if expression is not true. */ +#define SER_ASSERT_VOID_RETURN(expr) do { if (!(expr)) return; } while (0) +/** Returns with \ref NRF_ERROR_INVALID_LENGTH if len is not less or equal to maxlen. */ +#define SER_ASSERT_LENGTH_LEQ(len, maxlen) \ + SER_ASSERT((len) <= (maxlen), NRF_ERROR_INVALID_LENGTH) +/** Returns with \ref NRF_ERROR_INVALID_LENGTH if actual_len is not equal to expected_len. */ +#define SER_ASSERT_LENGTH_EQ(actual_len, expected_len) \ + SER_ASSERT((actual_len) == (expected_len), NRF_ERROR_INVALID_LENGTH) +/** Returns with \ref NRF_ERROR_NULL if pointer is null. */ +#define SER_ASSERT_NOT_NULL(ptr) SER_ASSERT((ptr) != NULL, NRF_ERROR_NULL) +#else +#define SER_ASSERT(expr, error_code) +#define SER_ASSERT_VOID_RETURN(expr) +#define SER_ASSERT_LENGTH_LEQ(len, maxlen) UNUSED_VARIABLE(maxlen) +#define SER_ASSERT_LENGTH_EQ(actual_len, expected_len) +#define SER_ASSERT_NOT_NULL(ptr) +#endif + +#if defined(BLE_GATT_MTU_SIZE_DEFAULT) && !defined(GATT_MTU_SIZE_DEFAULT) +#define GATT_MTU_SIZE_DEFAULT BLE_GATT_MTU_SIZE_DEFAULT +#endif + +/** See Bluetooth 4.0 spec: 3.4.4.7. */ +#define BLE_GATTC_HANDLE_COUNT_LEN_MAX ((GATT_MTU_SIZE_DEFAULT - 1) / 2) + +/** Subtract 1 from X if X is greater than 0. */ +#define SUB1(X) (((X)>0) ? ((X)-1) : (X)) + +static inline void static_force_impl_castable_p_void(void const * const p) {} +/** Force the argument to be a double pointer. */ +#define STATIC_FORCE_PP(PP) static_force_impl_castable_p_void(*(PP)) + +/** Field decoder for special structures containing variable length data. */ +typedef uint32_t (*field_ext_decoder_handler_t)(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_length, + void * p_field); + + +/** Push uint8_t field into the output packet. */ +#define SER_PUSH_uint8(P_VAR) do { \ + err_code = uint8_t_enc((P_VAR), p_buf, buf_len, p_index); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push uint16_t field into the output packet. */ +#define SER_PUSH_uint16(P_VAR) do { \ + err_code = uint16_t_enc((P_VAR), p_buf, buf_len, p_index); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push uint32_t field into the output packet. */ +#define SER_PUSH_uint32(P_VAR) do { \ + err_code = uint32_t_enc((P_VAR), p_buf, buf_len, p_index); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push int8_t field into the output packet. */ +#define SER_PUSH_int8(P_VAR) SER_PUSH_uint8(P_VAR) + +/** Push uint16_t field into the output packet. */ +#define SER_PUSH_int16(P_VAR) SER_PUSH_uint16(P_VAR) + +/** Push uint32_t field into the output packet. */ +#define SER_PUSH_int32(P_VAR) SER_PUSH_uint32(P_VAR) + +/** Push a constant length array of bytes into the output packet. */ +#define SER_PUSH_uint8array(P_DATA, LEN) do { \ + err_code = uint8_vector_enc((P_DATA), (LEN), p_buf, buf_len, p_index); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push a variable length (8-bit) array of bytes into the output packet. */ +#define SER_PUSH_len8data(P_DATA, LEN) do { \ + err_code = len8data_enc((P_DATA), (LEN), p_buf, buf_len, p_index); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push a variable length (16-bit) array of bytes into the output packet. */ +#define SER_PUSH_len16data(P_DATA, LEN) do { \ + err_code = len16data_enc((P_DATA), (LEN), p_buf, buf_len, p_index); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push a variable length (16-bit) array of 16-bit words into the output packet. */ +#define SER_PUSH_len16data16(P_DATA, LEN) do { \ + err_code = count16_cond_data16_enc((P_DATA), (LEN), p_buf, buf_len, p_index); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push a buffer into the output packet. */ +#define SER_PUSH_buf(P_DATA, LEN) do { \ + err_code = buf_enc((P_DATA), (LEN), p_buf, buf_len, p_index); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push a structure into the output packet. */ +#define SER_PUSH_FIELD(P_VAR, P_ENCODER) do { \ + err_code = field_enc((P_VAR), p_buf, buf_len, p_index, (P_ENCODER)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Push an array of structures into the output packet. */ +#define SER_PUSH_FIELD_ARRAY(P_ARRAY, P_ENCODER, COUNT) do { \ + for (uint32_t _idx = 0; _idx < (COUNT); ++_idx) \ + { \ + SER_PUSH_FIELD(&((P_ARRAY)[_idx]),P_ENCODER);\ + } \ + } while (0) + +/** Conditionally push a field if the specified pointer is not null. */ +#define SER_PUSH_COND(P_VAR, P_ENCODER) do { \ + err_code = cond_field_enc((P_VAR), p_buf, buf_len, p_index, (P_ENCODER)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + + +/** Pull a uint8_t field from the input packet. */ +#define SER_PULL_uint8(P_VAR) do { \ + err_code = uint8_t_dec(p_buf, packet_len, p_index, (P_VAR)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull a uint16_t field from the input packet. */ +#define SER_PULL_uint16(P_VAR) do { \ + err_code = uint16_t_dec(p_buf, packet_len, p_index, (P_VAR)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull a uint32_t field from the input packet. */ +#define SER_PULL_uint32(P_VAR) do { \ + err_code = uint32_t_dec(p_buf, packet_len, p_index, (P_VAR)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull an int8_t field from the input packet. */ +#define SER_PULL_int8(P_VAR) SER_PULL_uint8(P_VAR) + +/** Pull an int16_t field from the input packet. */ +#define SER_PULL_int16(P_VAR) SER_PULL_uint16(P_VAR) + +/** Pull an int32_t field from the input packet. */ +#define SER_PULL_int32(P_VAR) SER_PULL_uint32(P_VAR) + +/** Pull a constant length byte array from the input packet. */ +#define SER_PULL_uint8array(P_DATA, LEN) do { \ + err_code = uint8_vector_dec(p_buf, packet_len, p_index, (P_DATA), (LEN)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull a variable length (8-bit) byte array from the input packet. */ +#define SER_PULL_len8data(PP_DATA, LEN) do { \ + STATIC_FORCE_PP(PP_DATA); \ + err_code = len8data_dec(p_buf, packet_len, p_index, (PP_DATA), (LEN)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull a variable length (16-bit) byte array from the input packet. */ +#define SER_PULL_len16data(PP_DATA, P_LEN) do { \ + STATIC_FORCE_PP(PP_DATA); \ + err_code = len16data_dec(p_buf, packet_len, p_index, (PP_DATA), (P_LEN)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull a variable length (16-bit) word (16-bit) array from the input packet. */ +#define SER_PULL_len16data16(PP_DATA, P_LEN) do { \ + STATIC_FORCE_PP(PP_DATA); \ + err_code = count16_cond_data16_dec(p_buf, packet_len, p_index, (PP_DATA), (P_LEN)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull a buffer from the input packet. */ +#define SER_PULL_buf(PP_DATA, OUT_BUF_LEN, LEN) do { \ + STATIC_FORCE_PP(PP_DATA); \ + err_code = buf_dec(p_buf, packet_len, p_index, (PP_DATA), (OUT_BUF_LEN), (LEN)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull a structure from the input packet. */ +#define SER_PULL_FIELD(P_VAR, P_DECODER) do { \ + err_code = field_dec(p_buf, packet_len, p_index, (P_VAR), (P_DECODER)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + +/** Pull an array of structures from the input packet. */ +#define SER_PULL_FIELD_ARRAY(P_ARRAY, P_DECODER, COUNT) do { \ + for (uint32_t _idx = 0; _idx < (COUNT); ++_idx) \ + { \ + SER_PULL_FIELD(&((P_ARRAY)[_idx]),P_DECODER); \ + } \ + } while (0) + +/** Conditionally pull a structure from the input packet. */ +#define SER_PULL_COND(PP_VAR, P_DECODER) do { \ + STATIC_FORCE_PP(PP_VAR); \ + err_code = cond_field_dec(p_buf, packet_len, p_index, (void * *)(PP_VAR), (P_DECODER)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + } while (0) + + +/** Start the encoding of a structure and prepare local variables for the usage of SER_PUSH_ macros. */ +#define SER_STRUCT_ENC_BEGIN(STRUCT_TYPE) \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT_NOT_NULL(p_index); \ + SER_ASSERT_NOT_NULL(p_void_struct); \ + STRUCT_TYPE * p_struct = (STRUCT_TYPE *) p_void_struct; \ + uint32_t err_code = NRF_SUCCESS + +/** End the encoding of a structure. */ +#define SER_STRUCT_ENC_END return err_code + +/** Start the decoding of a structure and prepare local variables for the usage of SER_PULL_ macros. */ +#define SER_STRUCT_DEC_BEGIN(STRUCT_TYPE) \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT_NOT_NULL(p_index); \ + SER_ASSERT_NOT_NULL(p_void_struct); \ + STRUCT_TYPE * p_struct = (STRUCT_TYPE *) p_void_struct; \ + uint32_t err_code = NRF_SUCCESS; \ + uint32_t packet_len = buf_len + +/** End the encoding of a structure. */ +#define SER_STRUCT_DEC_END return err_code + + +/** Start the encoding of command request and prepare local variables for the usage of SER_PUSH_ macros. */ +#define SER_REQ_ENC_BEGIN(OPCODE) \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT_NOT_NULL(p_buf_len); \ + \ + uint32_t index = 0; \ + uint32_t * const p_index = &index; \ + uint32_t err_code = NRF_SUCCESS; \ + uint32_t buf_len = *p_buf_len; \ + \ + uint8_t opcode = (OPCODE); \ + SER_PUSH_uint8(&opcode) + +/** End the encoding of command request. */ +#define SER_REQ_ENC_END \ + *p_buf_len = index; \ + return NRF_SUCCESS \ + +/** Start the decoding of command response that does not contain any data except the result code. */ +#define SER_RSP_DEC_RESULT_ONLY(OPCODE) \ + return ser_ble_cmd_rsp_dec(p_buf, packet_len, (OPCODE), p_result_code) + +/** Start the decoding of command response and prepare local variables for the usage of SER_PULL_ macros. */ +#define SER_RSP_DEC_BEGIN(OPCODE) \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT_NOT_NULL(p_result_code); \ + uint32_t err_code = NRF_SUCCESS; \ + uint32_t index = 0; \ + uint32_t * const p_index = &index; \ + /* Decode the result code and exit if decoding has failed or \ + the decoded result is not NRF_SUCCESS. */ \ + err_code = ser_ble_cmd_rsp_result_code_dec(p_buf, &index, packet_len, (OPCODE), p_result_code); \ + \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + if (*p_result_code != NRF_SUCCESS) \ + { \ + SER_ASSERT_LENGTH_EQ(index, packet_len); \ + return NRF_SUCCESS; \ + } + +/** End the decoding of command response. */ +#define SER_RSP_DEC_END \ + /* Require all data to be pulled. */ \ + SER_ASSERT_LENGTH_EQ(index, packet_len); \ + return err_code + + +/** Start the decoding of command request and prepare local variables for the usage of SER_PULL_ macros. */ +#define SER_REQ_DEC_BEGIN(OPCODE) \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT(packet_len>0, NRF_ERROR_INVALID_PARAM); \ + uint32_t index = 0; \ + uint32_t * const p_index = &index; \ + uint32_t err_code = NRF_SUCCESS; \ + SER_ASSERT(p_buf[index] == (OPCODE), NRF_ERROR_INVALID_PARAM); \ + (void)err_code; \ + (void)p_index; \ + ++index + +/** End the decoding of command request. */ +#define SER_REQ_DEC_END \ + SER_ASSERT_LENGTH_EQ(index, packet_len); \ + return NRF_SUCCESS + +/** Start the encoding of command response and prepare local variables for the usage of SER_PUSH_ macros. */ +#define SER_RSP_ENC_BEGIN(OPCODE) \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT_NOT_NULL(p_buf_len); \ + uint32_t index = 0; \ + uint32_t * const p_index = &index; \ + uint32_t err_code = NRF_SUCCESS; \ + uint32_t buf_len = *p_buf_len; \ + /* Push the opcode + result and exit if result \ + is not NRF_SUCCESS. */ \ + uint8_t opcode = (OPCODE); \ + SER_PUSH_uint8(&opcode); \ + SER_PUSH_uint32(&return_code); \ + \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + if (return_code != NRF_SUCCESS) \ + { \ + SER_RSP_ENC_END; \ + } + +/** Start the encoding of command response that contains the result code only. */ +#define SER_RSP_ENC_RESULT_ONLY(OPCODE) \ + return ser_ble_cmd_rsp_status_code_enc((OPCODE), return_code, p_buf, p_buf_len) + +/** End the encoding of command response. */ +#define SER_RSP_ENC_END \ + *p_buf_len = index; \ + return NRF_SUCCESS + + +/** Start the encoding of an event and prepare local variables for the usage of SER_PUSH_ macros. */ +#define SER_EVT_ENC_BEGIN(EVT_HEADER) \ + SER_ASSERT_NOT_NULL(p_event); \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT_NOT_NULL(p_buf_len); \ + SER_ASSERT(p_event->header.evt_id == (EVT_HEADER), NRF_ERROR_INVALID_PARAM); \ + uint32_t index = 0; \ + uint32_t * p_index = &index; \ + uint32_t buf_len = *p_buf_len; \ + uint32_t err_code = NRF_SUCCESS; \ + uint16_t evt_header = (EVT_HEADER); \ + /* Push event header. */ \ + SER_PUSH_uint16(&evt_header) + +/** End the encoding of an event. */ +#define SER_EVT_ENC_END \ + *p_buf_len = index; \ + return err_code + + +/** Start the decoding of an event that has an event-specific data structure + and prepare local variables for the usage of SER_PULL_ macros. */ +#define SER_EVT_DEC_BEGIN(EVT_CODE, EVT_GROUP, EVT_NAME) \ + uint32_t err_code = NRF_SUCCESS; \ + uint32_t index = 0; \ + uint32_t * p_index = &index; \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT_NOT_NULL(p_event_len); \ + /* Calculate the base event structure length */ \ + /* and make sure that there is enough free space */ \ + /* in the output buffer. */ \ + uint32_t evt_struct_len = \ + offsetof(ble_evt_t, evt.EVT_GROUP##_evt.params) \ + - offsetof(ble_evt_t, evt) \ + + sizeof(ble_##EVT_GROUP##_evt_##EVT_NAME##_t); \ + SER_ASSERT_LENGTH_LEQ(evt_struct_len, *p_event_len); \ + *p_event_len -= evt_struct_len; \ + /* Some structures contains variable length arrays */ \ + /* and the overall size may be greater. */ \ + uint32_t evt_extended_len = 0; \ + (void) evt_extended_len; \ + p_event->header.evt_id = EVT_CODE + +/** Start the decoding of an event that has no event-specific data structure. + and prepare local variables for the usage of SER_PULL_ macros. */ +#define SER_EVT_DEC_BEGIN_NO_STRUCT(EVT_CODE, EVT_GROUP) \ + uint32_t err_code = NRF_SUCCESS; \ + uint32_t index = 0; \ + uint32_t * p_index = &index; \ + SER_ASSERT_NOT_NULL(p_buf); \ + SER_ASSERT_NOT_NULL(p_event_len); \ + /* Calculate the base event structure length */ \ + /* and make sure that there is enough free space */ \ + /* in the output buffer. */ \ + uint32_t evt_struct_len = \ + offsetof(ble_evt_t, evt.EVT_GROUP##_evt.params) \ + - offsetof(ble_evt_t, evt) ; \ + SER_ASSERT_LENGTH_LEQ(evt_struct_len, *p_event_len); \ + *p_event_len -= evt_struct_len; \ + /* Some structures contain variable length arrays */ \ + /* and the overall size may be greater. */ \ + uint32_t evt_extended_len = 0; \ + (void) evt_extended_len; \ + p_event->header.evt_id = EVT_CODE + +/** End the decoding of an event. */ +#define SER_EVT_DEC_END \ + SER_ASSERT_LENGTH_EQ(index, packet_len); \ + /*p_event_len = index; */ \ + /*p_event->header.evt_len = index; */ \ + *p_event_len = evt_struct_len + evt_extended_len; \ + return NRF_SUCCESS + +/** Push an event-specific special field that contains variable length fields and get the extended data size. */ +#define SER_PULL_FIELD_EXTENDED(P_VAR, P_DECODER) \ + do \ + { \ + uint32_t field_ext_len = *p_event_len; \ + err_code = field_ext_dec(p_buf, packet_len, p_index, &field_ext_len, (P_VAR), (P_DECODER)); \ + SER_ASSERT(err_code == NRF_SUCCESS, err_code); \ + *p_event_len -= field_ext_len; \ + evt_extended_len += field_ext_len; \ + } while (0) \ + + +/** Generic command response status code encoder. */ +uint32_t ser_ble_cmd_rsp_status_code_enc(uint8_t op_code, + uint32_t command_status, + uint8_t * const p_buf, + uint32_t * const p_buf_len); + +/** Generic command response result code decoder. */ +uint32_t ser_ble_cmd_rsp_result_code_dec(uint8_t const * const p_buf, + uint32_t * const p_pos, + uint32_t packet_len, + uint8_t op_code, + uint32_t * const p_result_code); + +/** Generic command response decoder. */ +uint32_t ser_ble_cmd_rsp_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint8_t op_code, + uint32_t * const p_result_code); + + + +/**@brief Function for safe field encoding field. + * + * @param[in] p_field Pointer to the input struct. Must not be a null. + * @param[in] p_buf Pointer to the beginning of the output buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to start of uint8 value in buffer. + * \c out: Index in the buffer to the first byte after the encoded data. + * @param[in] fp_field_encoder Pointer to the function that implements fields encoding. + * + * @return NRF_SUCCESS Field encoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_NULL p_field or fp_field_encoder is NULL. + */ +static inline uint32_t field_enc(void const * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + field_encoder_handler_t fp_field_encoder) +{ + SER_ASSERT_NOT_NULL(fp_field_encoder); + SER_ASSERT_NOT_NULL(p_field); + + return fp_field_encoder(p_field, p_buf, buf_len, p_index); +} + +/**@brief Function for safe field decoding. + * + * Function checks if conditional field is present in the input buffer and if it is set, it calls + * the provided parser function that attempts to parse the buffer content to the known field. + * + * @param[in] p_buf Pointer to the beginning of the input buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of uint8 value in buffer. + * \c out: Index in the buffer to the first byte after the decoded data. + * @param[in] p_field Pointer to the output location. + * @param[in] fp_field_decoder Pointer to the function that implements field decoding. + * + * @return NRF_SUCCESS Field decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_NULL p_field or fp_field_decoder is NULL. + */ +static inline uint32_t field_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_field, + field_decoder_handler_t fp_field_decoder) +{ + SER_ASSERT_NOT_NULL(fp_field_decoder); + SER_ASSERT_NOT_NULL(p_field); + + return fp_field_decoder(p_buf, buf_len, p_index, p_field); +} + +/**@brief Function for safe decoding of an event-specific field that contains extended data. + * + * Some event structures contain a variable length array (extended data), + * that may be written next to the event structure. + * + * @param[in] p_buf Pointer to the beginning of the input buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded data. + * @param[in,out] p_ext_length \c in: Maximum size of extended data. + * \c out: Extended data length in bytes. + * @param[in] p_field Pointer to output location. + * @param[in] fp_field_decoder Pointer to the function that implements field decoding. + * + * @return NRF_SUCCESS Field decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_NULL p_field or fp_field_decoder is NULL. + */ +static inline uint32_t field_ext_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_length, + void * const p_field, + field_ext_decoder_handler_t fp_field_decoder) +{ + SER_ASSERT_NOT_NULL(fp_field_decoder); + SER_ASSERT_NOT_NULL(p_field); + + return fp_field_decoder(p_buf, buf_len, p_index, p_ext_length, p_field); +} + +/**@brief Function for safe encoding an uint16 value. + * + * Safe decoding of a uint16 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_field A uint16 value to be encoded. + * @param[out] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint16 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t uint16_t_enc(const void * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +/**@brief Function for safe decoding of a uint16 value. + * + * Safe decoding of a uint16 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint16 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * @param[out] p_field Pointer to the location where the uint16 value will be decoded. + */ +uint32_t uint16_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * p_field); + +/**@brief Function for safe decoding of a uint16 value. + * + * Safe decoding of a uint16 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] index \c in: Index to the start of the uint16 value in buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * @param[out] value Decoded uint16 value. + */ +void uint16_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const index, + uint16_t * const value); + +/**@brief Function for safe encoding of a uint18 value. + * + * Safe decoding of a uint8 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * @param[out] p_field Pointer to uint8 value to be encoded. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t uint8_t_enc(const void * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +/**@brief Function for safe decoding of a uint8 value. + * + * Safe decoding of a uint8 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * @param[out] p_field Pointer to the location for decoded uint8 value. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t uint8_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * p_field); + +/**@brief Function for safe decoding of a uint8 value. + * + * Safe decoding of a uint8 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * @param[out] value Decoded uint8 value. + */ +void uint8_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const index, + uint8_t * const value); + +/**@brief Function for safe decoding of a uint18 value. + * + * Safe decoding of a uint8 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * @param[out] value Decoded uint8 value. + */ +void int8_dec(uint8_t const * const p_buf, + uint32_t packet_len, + uint32_t * const index, + int8_t * const value); + +/**@brief Function for safe encoding of a variable length field encoded as length(8bit) + data. + * + * Safe encoding of a variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[out] p_data Pointer to data to encode. + * @param[in] dlen Length of data to encode (0-255). + * @param[out] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t len8data_enc(uint8_t const * const p_data, + uint8_t const dlen, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +/**@brief Function for safe decoding of a variable length field encoded as length(8bit) + data. + * + * Safe decoding of a variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * @param[out] pp_data Pointer to decoded data (p_data is set to NULL in + * case data is not present in the buffer). + * @param[out] p_len Decoded length (0-255). + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t len8data_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * * const pp_data, + uint8_t * const p_len); + +/**@brief Function for safe encoding of a variable length field encoded as length(16 bit) + data. + * + * Safe encoding of a variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * It is possible that provided p_data is NULL. In that case, length is encoded and it is followed by + * SER_FIELD_NOT_PRESENT flag. Otherwise, the SER_FIELD_PRESENT flag precedes the data. + * + * @param[in] p_data Data to encode. + * @param[in] dlen Input data length (16 bit). + * @param[in] p_buf Pointer to the beginning of the output buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the encoded data. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t len16data_enc(uint8_t const * const p_data, + uint16_t const dlen, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +/**@brief Function for safe decoding of a variable length field encoded as length(16 bit) + data. + * + * Safe decoding of a variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * Encoded data consists of a length field, a presence flag, and conditional data (present only if the presence flag + * is set). The p_data pointer cannot be NULL if the presence flag is set. + * + * @param[in] p_buf Pointer to the beginning of the input buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded data. + * @param[in] pp_data Pointer to decoded data. + * @param[in] p_dlen Data length (16 bit). + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t len16data_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * * const pp_data, + uint16_t * const p_dlen); + + +/**@brief Function for safe encoding of a uint16 table with a given element count. + * + * Safe encoding of a variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * It is possible that the provided p_data is NULL. In that case, length is encoded and it is followed by a + * SER_FIELD_NOT_PRESENT flag. Otherwise, the SER_FIELD_PRESENT flag precedes the data. + * + * @param[in] p_data Data table to encode. + * @param[in] count Table element count. + * @param[in] p_buf Pointer to the beginning of the output buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the encoded data. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ + +uint32_t count16_cond_data16_enc(uint16_t const * const p_data, + uint16_t const count, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +/**@brief Function for safe decoding of a uint16 table with a given element count. + * + * Safe encoding of a variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * It is possible that the provided p_data is NULL. In that case, length is encoded and it is followed by a + * SER_FIELD_NOT_PRESENT flag. Otherwise, the SER_FIELD_PRESENT flag precedes the data. + * + * @param[in] p_buf Pointer to the beginning of the output buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the encoded data. + * @param[in] pp_data Pointer to the table to encode. + * @param[in,out] p_count Pointer to table element count - initialised with max count. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_DATA_SIZE Decoding failure. Initial count is smaller than actual. + */ + +uint32_t count16_cond_data16_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint16_t * * const pp_data, + uint16_t * const p_count); + + +/**@brief Function for safe decoding of a variable length field encoded as length(16 bit) + data. + * + * Safe decoding of a variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * Encoded data consists of a presence flag, an optional length field, a second presence flag, and optional data. + * + * + * @param[in] p_buf Pointer to the beginning of the input buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded data. + * @param[out] pp_data Pointer to decoded data. + * @param[out] pp_len Data length (16 bit). + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ + +uint32_t cond_len16_cond_data_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * * const pp_data, + uint16_t * * const pp_len); + +/**@brief Command response encoder - replacement of ser_ble_cmd_rsp_status_code_enc + * with layout aligned to the rest of encoder functions. + * + * @param[in] op_code Operation code - see BLE_GAP_SVCS. + * @param[in] return_code nRF error code. + * @param[in] p_buff Pointer to the start of pointer to decoded data. + * @param[in,out] p_buff_len \c in: Size of the buffer. + * \c out: Used bytes in the buffer. + * @param[in,out] p_buff_len \c in: Initial offset in the buffer. + * \c out: Final offset in the buffer. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_NULL Invalid pointer. + */ +uint32_t op_status_enc(uint8_t op_code, + uint32_t return_code, + uint8_t * const p_buff, + uint32_t * const p_buff_len, + uint32_t * const p_index); + +/**@brief Command response encoder with a conditional 16-bit field. + * + * @param[in] op_code Operation code - see BLE_GAP_SVCS. + * @param[in] return_code nRF error code. + * @param[in] value Optional 16-bit field encoded for return code == NRF_SUCCESS. + * @param[in] p_buff Pointer to the start of pointer to decoded data. + * @param[in,out] p_buff_len \c in: Size of the buffer. + * \c out: Used bytes in the buffer. + * @param[in,out] p_buff_len \c in: Initial offset in the buffer. + * \c out: Final offset in the buffer. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + * @retval NRF_ERROR_NULL Invalid pointer. + */ + +uint32_t op_status_cond_uint16_enc(uint8_t op_code, + uint32_t return_code, + uint16_t value, + uint8_t * const p_buff, + uint32_t * const p_buff_len, + uint32_t * const p_index); + +/**@brief Function for safe encoding of a buffer of known size. + * + * Safe encoding of a buffer. Encoder assumes that the size is known to the decoder and it is not + * encoded here. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_data Data to encode. + * @param[in] dlen Input data length (16 bit). + * @param[in] p_buf Pointer to the beginning of the output buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the encoded data. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t buf_enc(uint8_t const * const p_data, + uint16_t const dlen, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +/**@brief Function for safe decoding of a buffer of known size. + * + * Safe decoding of a buffer of known size. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * Encoded data consists of a presence flag and conditional data (present only if the presence flag + * is set). The p_data pointer cannot be NULL only if the presence flag is set. Length is provided + * as input to the function. + * + * @param[in] p_buf Pointer to the beginning of the input buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded data. + * @param[in] pp_data Pointer to decoded data. + * @param[in] data_len Length of the buffer for decoded data (16 bit). + * @param[in] dlen Length of the data to decode (16 bit). + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t buf_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * * const pp_data, + uint16_t data_len, + uint16_t dlen); + +/**@brief Function for safe encoding of a uint32 value. + * + * Safe decoding of a uint32 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_field A uint32 value to be encoded. + * @param[out] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint32 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t uint32_t_enc(void const * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +/**@brief Function for safe decoding of a uint32 value. + * + * Safe decoding of a uint32 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * + * @param[in] p_buf Buffer containing the value. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint32 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded value. + * @param[out] value Decoded uint32 value. + */ +uint32_t uint32_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * p_field); + +/**@brief Function for safe encoding of a uint8 vector. + * + * Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * * + * @param[in] p_data Data to encode. + * @param[in] dlen Input data length (16 bit). + * @param[in] p_buf Pointer to the beginning of the output buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the encoded data. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t uint8_vector_enc(uint8_t const * const p_data, + uint16_t const dlen, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +/**@brief Function for safe decoding a uint8 vector. + * + * Safe decoding of a buffer of known size. Range checks will be done if @ref SER_ASSERTS_ENABLED is set. + * Vector length is provided as input to the function. + * + * @param[in] p_buf Pointer to the beginning of the input buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded data. + * @param[in] p_data Pointer to decoded data. + * @param[in] dlen Length of data to decode (16 bit). + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t uint8_vector_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint8_t * const p_data, + uint16_t dlen); + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/cond_field_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/cond_field_serialization.c new file mode 100644 index 000000000..cd433651f --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/cond_field_serialization.c @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "nrf_error.h" +#include "cond_field_serialization.h" +#include "ble_serialization.h" +#include + +uint32_t cond_field_enc(void const * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + field_encoder_handler_t fp_field_encoder) +{ + uint32_t err_code = NRF_SUCCESS; + + SER_ASSERT_LENGTH_LEQ(*p_index + 1, buf_len); + p_buf[*p_index] = (p_field == NULL) ? SER_FIELD_NOT_PRESENT : SER_FIELD_PRESENT; + *p_index += 1; + + if (p_field && (fp_field_encoder != NULL)) + { + err_code = fp_field_encoder(p_field, p_buf, buf_len, p_index); + } + + return err_code; +} + + +uint32_t cond_field_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * * const pp_field, + field_decoder_handler_t fp_field_decoder) +{ + uint32_t err_code = NRF_SUCCESS; + uint8_t is_present; + + SER_ASSERT_LENGTH_LEQ(1, buf_len - *p_index); + uint8_dec(p_buf, buf_len, p_index, &is_present); + + if (is_present == SER_FIELD_PRESENT) + { + SER_ASSERT_NOT_NULL(pp_field); + SER_ASSERT_NOT_NULL(*pp_field); + + if (fp_field_decoder != NULL) + { + err_code = fp_field_decoder(p_buf, buf_len, p_index, *pp_field); + } + } + else if (is_present == SER_FIELD_NOT_PRESENT) + { + if (pp_field != NULL) + { + *pp_field = NULL; + } + } + else + { + err_code = NRF_ERROR_INVALID_DATA; + } + + return err_code; +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/cond_field_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/cond_field_serialization.h new file mode 100644 index 000000000..e14af50ff --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/cond_field_serialization.h @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef COND_FIELD_SERIALIZATION_H__ +#define COND_FIELD_SERIALIZATION_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint32_t (*field_encoder_handler_t)(void const * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +typedef uint32_t (*field_decoder_handler_t)(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * p_field); + +/**@brief Function for safe encoding of a conditional field. + * + * Function sets a presence flag and checks if conditional field is provided. If the field is not NULL, + * it calls the provided parser function which attempts to encode the field content to the buffer stream. + * + * @param[in] p_field Pointer to the input struct. + * @param[in] p_buf Pointer to the beginning of the output buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the encoded data. + * @param[in] fp_field_encoder Pointer to the function which implements fields encoding. + * + * @return NRF_SUCCESS Fields encoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t cond_field_enc(void const * const p_field, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + field_encoder_handler_t fp_field_encoder); + +/**@brief Function for safe decoding of a conditional field. + * + * Function checks if conditional field is present in the input buffer. If it is set, it calls + * the provided parser function which attempts to parse the buffer content to the known field. + * + * @param[in] p_buf Pointer to the beginning of the input buffer. + * @param[in] buf_len Size of the buffer. + * @param[in,out] p_index \c in: Index to the start of the uint8 value in the buffer. + * \c out: Index in the buffer to the first byte after the decoded data. + * @param[in] pp_field Pointer to output location. + * @param[in] fp_field_decoder Pointer to the function which implements field decoding. + * + * @return NRF_SUCCESS Fields decoded successfully. + * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length. + */ +uint32_t cond_field_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * * const pp_field, + field_decoder_handler_t fp_field_decoder); + +#ifdef __cplusplus +} +#endif + +#endif // COND_FIELD_SERIALIZATION_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ser_config.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ser_config.h new file mode 100644 index 000000000..f6b34f86a --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/ser_config.h @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef SER_CONFIG_H__ +#define SER_CONFIG_H__ + +#include + +#include "nrf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/***********************************************************************************************//** + * General parameters configuration. + **************************************************************************************************/ + +/** Value used as error code on SoftDevice stack dump. Can be used to identify stack location on + * stack unwind.*/ +#define SER_SD_ERROR_CODE (0xDEADBEEFUL) + +/** Value used as error code indicating warning - unusual situation but not critical so system + * should NOT be reset. */ +#define SER_WARNING_CODE (0xBADDCAFEUL) + +/***********************************************************************************************//** + * HAL Transport layer configuration. + **************************************************************************************************/ + +/** Max packets size in serialization HAL Transport layer (packets before adding PHY header i.e. + * packet length). */ +#ifdef S112 +#define SER_HAL_TRANSPORT_APP_TO_CONN_MAX_PKT_SIZE (128UL) +#define SER_HAL_TRANSPORT_CONN_TO_APP_MAX_PKT_SIZE (128UL) +#else +#define SER_HAL_TRANSPORT_APP_TO_CONN_MAX_PKT_SIZE (512UL) +#define SER_HAL_TRANSPORT_CONN_TO_APP_MAX_PKT_SIZE (512UL) +#endif + +#define SER_HAL_TRANSPORT_MAX_PKT_SIZE ((SER_HAL_TRANSPORT_APP_TO_CONN_MAX_PKT_SIZE) >= \ + (SER_HAL_TRANSPORT_CONN_TO_APP_MAX_PKT_SIZE) \ + ? \ + (SER_HAL_TRANSPORT_APP_TO_CONN_MAX_PKT_SIZE) : \ + (SER_HAL_TRANSPORT_CONN_TO_APP_MAX_PKT_SIZE)) +#ifdef SER_CONNECTIVITY + #define SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE SER_HAL_TRANSPORT_CONN_TO_APP_MAX_PKT_SIZE + #define SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE SER_HAL_TRANSPORT_APP_TO_CONN_MAX_PKT_SIZE + +#else /* APPLICATION SIDE */ + #define SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE SER_HAL_TRANSPORT_APP_TO_CONN_MAX_PKT_SIZE + #define SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE SER_HAL_TRANSPORT_CONN_TO_APP_MAX_PKT_SIZE +#endif /* SER_CONNECTIVITY */ + + +/***********************************************************************************************//** + * SER_PHY layer configuration. + **************************************************************************************************/ + +#define SER_PHY_HEADER_SIZE 2 + +#define SER_PHY_HCI_SLIP_TX_BUF_SIZE 30 + +#define SER_PHY_SPI_FREQUENCY NRF_DRV_SPI_FREQ_1M + +/** Max transfer unit for SPI MASTER and SPI SLAVE. */ +#define SER_PHY_SPI_MTU_SIZE 255 + +/** UART transmission parameters */ +#define SER_PHY_UART_FLOW_CTRL NRF_UART_HWFC_ENABLED +#define SER_PHY_UART_PARITY NRF_UART_PARITY_INCLUDED +#define SER_PHY_UART_BAUDRATE_VAL 1000000 + +#define SER_PHY_UART_BAUDRATE CONCAT_2(NRF_UART_BAUDRATE_,SER_PHY_UART_BAUDRATE_VAL) + +/** Configuration timeouts of connectivity MCU. */ +#define CONN_CHIP_RESET_TIME 50 /**< Time to keep the reset line to the connectivity chip low (in milliseconds). */ +#define CONN_CHIP_WAKEUP_TIME 500 /**< Time for the connectivity chip to reset and become ready to receive serialized commands (in milliseconds). */ + +#ifdef S112 +#define SER_MAX_CONNECTIONS 2 +#else +#define SER_MAX_CONNECTIONS 8 +#endif + +#ifndef SER_MAX_ADV_DATA +#define SER_MAX_ADV_DATA 256 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* SER_CONFIG_H__ */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gap_struct_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gap_struct_serialization.c new file mode 100644 index 000000000..6fe5782ff --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gap_struct_serialization.c @@ -0,0 +1,1743 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gap_struct_serialization.h" +#include "ble_struct_serialization.h" +#include "ble_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" +#include "string.h" +#include "ble_gatts.h" + +#ifndef S112 +uint32_t ble_gap_evt_adv_report_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_adv_report_t); +#if NRF_SD_BLE_API_VERSION > 5 + SER_PUSH_FIELD(&p_struct->type, ble_gap_adv_report_type_t_enc); + SER_PUSH_FIELD(&p_struct->peer_addr, ble_gap_addr_t_enc); + SER_PUSH_FIELD(&p_struct->direct_addr, ble_gap_addr_t_enc); + SER_PUSH_uint8(&p_struct->primary_phy); + SER_PUSH_uint8(&p_struct->secondary_phy); + SER_PUSH_int8(&p_struct->tx_power); + SER_PUSH_int8(&p_struct->rssi); + SER_PUSH_uint8(&p_struct->ch_index); + SER_PUSH_uint8(&p_struct->set_id); + uint16_t temp = p_struct->data_id; + SER_PUSH_uint16(&temp); + SER_PUSH_FIELD(&p_struct->data, ble_data_t_enc); + SER_PUSH_FIELD(&p_struct->aux_pointer, ble_gap_aux_pointer_t_enc); +#else + uint8_t ser_data = (p_struct->scan_rsp & 0x01) + | ((p_struct->type & 0x03) << 1); + uint8_t data_len = (p_struct->dlen & 0x1F); + SER_PUSH_FIELD(&p_struct->peer_addr, ble_gap_addr_t_enc); + SER_PUSH_FIELD(&p_struct->direct_addr, ble_gap_addr_t_enc); + SER_PUSH_int8(&p_struct->rssi); + SER_PUSH_uint8(&ser_data); + SER_PUSH_len8data(p_struct->data, data_len); +#endif + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_adv_report_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_adv_report_t); + +#if NRF_SD_BLE_API_VERSION > 5 + SER_PULL_FIELD(&p_struct->type, ble_gap_adv_report_type_t_dec); + SER_PULL_FIELD(&p_struct->peer_addr, ble_gap_addr_t_dec); + SER_PULL_FIELD(&p_struct->direct_addr, ble_gap_addr_t_dec); + SER_PULL_uint8(&p_struct->primary_phy); + SER_PULL_uint8(&p_struct->secondary_phy); + SER_PULL_int8(&p_struct->tx_power); + SER_PULL_int8(&p_struct->rssi); + SER_PULL_uint8(&p_struct->ch_index); + SER_PULL_uint8(&p_struct->set_id); + uint16_t temp; + SER_PULL_uint16(&temp); + p_struct->data_id = temp & 0x0FFF; + SER_PULL_FIELD(&p_struct->data, ble_data_t_dec); + SER_PULL_FIELD(&p_struct->aux_pointer, ble_gap_aux_pointer_t_dec); +#else + uint8_t ser_data; + uint8_t data_len = BLE_GAP_ADV_MAX_SIZE; + uint8_t * p_field_data = p_struct->data; + SER_PULL_FIELD(&p_struct->peer_addr, ble_gap_addr_t_dec); + SER_PULL_FIELD(&p_struct->direct_addr, ble_gap_addr_t_dec); + SER_PULL_int8(&p_struct->rssi); + SER_PULL_uint8(&ser_data); + SER_PULL_len8data(&p_field_data, &data_len); + + p_struct->scan_rsp = ser_data & 0x01; + p_struct->type = (ser_data >> 1) & 0x03; + p_struct->dlen = data_len; +#endif + SER_STRUCT_DEC_END; +} +#endif + +uint32_t ble_gap_irk_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_irk_t); + SER_PUSH_uint8array(p_struct->irk, BLE_GAP_SEC_KEY_LEN); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_irk_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_irk_t); + SER_PULL_uint8array(p_struct->irk, BLE_GAP_SEC_KEY_LEN); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_addr_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_addr_t); + + uint8_t ser_data = (p_struct->addr_id_peer & 0x01) + | ((p_struct->addr_type & 0x7F) << 1); + SER_PUSH_uint8(&ser_data); + SER_PUSH_uint8array(p_struct->addr, BLE_GAP_ADDR_LEN); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_addr_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_addr_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + SER_PULL_uint8array(p_struct->addr, BLE_GAP_ADDR_LEN); + + p_struct->addr_id_peer = ser_data & 0x01; + p_struct->addr_type = (ser_data >> 1) & 0x7F; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_sec_levels_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_sec_levels_t); + + uint8_t sec_levels_serialized = (p_struct->lv1 << 0) | (p_struct->lv2 << 1) + | (p_struct->lv3 << 2) | (p_struct->lv4 << 3); + SER_PUSH_uint8(&sec_levels_serialized); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_sec_levels_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_sec_levels_t); + + uint32_t sec_levels_serialized; + SER_PULL_uint8(&sec_levels_serialized); + + p_struct->lv1 = sec_levels_serialized & 0x01; + p_struct->lv2 = (sec_levels_serialized >> 1) & 0x01; + p_struct->lv3 = (sec_levels_serialized >> 2) & 0x01; + p_struct->lv4 = (sec_levels_serialized >> 3) & 0x01; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_sec_keys_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_sec_keys_t); + + SER_PUSH_COND(p_struct->p_enc_key, ble_gap_enc_key_t_enc); + SER_PUSH_COND(p_struct->p_id_key, ble_gap_id_key_t_enc); + SER_PUSH_COND(p_struct->p_sign_key, ble_gap_sign_info_t_enc); + SER_PUSH_COND(p_struct->p_pk, ble_gap_lesc_p256_pk_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_sec_keys_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_sec_keys_t); + + SER_PULL_COND(&(p_struct->p_enc_key), ble_gap_enc_key_t_dec); + SER_PULL_COND(&(p_struct->p_id_key), ble_gap_id_key_t_dec); + SER_PULL_COND(&(p_struct->p_sign_key), ble_gap_sign_info_t_dec); + SER_PULL_COND(&(p_struct->p_pk), ble_gap_lesc_p256_pk_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_enc_info_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_enc_info_t); + + SER_PUSH_uint8array(p_struct->ltk, BLE_GAP_SEC_KEY_LEN); + uint8_t ser_data = (p_struct->lesc & 0x01) + | ((p_struct->auth & 0x01) << 1) + | ((p_struct->ltk_len & 0x3F) << 2); + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_enc_info_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_enc_info_t); + + uint8_t ser_data; + SER_PULL_uint8array(p_struct->ltk, BLE_GAP_SEC_KEY_LEN); + SER_PULL_uint8(&ser_data); + p_struct->lesc = ser_data & 0x01; + p_struct->auth = (ser_data >> 1) & 0x01; + p_struct->ltk_len = (ser_data >> 2) & 0x3F; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_sign_info_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_sign_info_t); + SER_PUSH_uint8array(p_struct->csrk, BLE_GAP_SEC_KEY_LEN); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_sign_info_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_sign_info_t); + SER_PULL_uint8array(p_struct->csrk, BLE_GAP_SEC_KEY_LEN); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_auth_status_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_auth_status_t); + uint8_t ser_data = (p_struct->error_src) | ((p_struct->bonded) << 2); +#if NRF_SD_BLE_API_VERSION >= 5 + ser_data |= ((p_struct->lesc) << 3); +#endif + SER_PUSH_uint8(&(p_struct->auth_status)); + SER_PUSH_uint8(&ser_data); + + SER_PUSH_FIELD(&(p_struct->sm1_levels), ble_gap_sec_levels_t_enc); + SER_PUSH_FIELD(&(p_struct->sm2_levels), ble_gap_sec_levels_t_enc); + SER_PUSH_FIELD(&(p_struct->kdist_own), ble_gap_sec_kdist_t_enc); + SER_PUSH_FIELD(&(p_struct->kdist_peer), ble_gap_sec_kdist_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_auth_status_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_auth_status_t); + + uint8_t ser_data; + SER_PULL_uint8(&(p_struct->auth_status)); + SER_PULL_uint8(&ser_data); + p_struct->error_src = ser_data & 0x03; + p_struct->bonded = (ser_data >> 2) & 0x01; +#if NRF_SD_BLE_API_VERSION >= 5 + p_struct->lesc = (ser_data >> 3) & 0x01; +#endif + + SER_PULL_FIELD(&(p_struct->sm1_levels), ble_gap_sec_levels_t_dec); + SER_PULL_FIELD(&(p_struct->sm2_levels), ble_gap_sec_levels_t_dec); + SER_PULL_FIELD(&(p_struct->kdist_own), ble_gap_sec_kdist_t_dec); + SER_PULL_FIELD(&(p_struct->kdist_peer), ble_gap_sec_kdist_t_dec); + + SER_STRUCT_DEC_END; +} + + +uint32_t ble_gap_conn_sec_mode_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_conn_sec_mode_t); + + uint8_t ser_data = (p_struct->sm & 0x0F) + | ((p_struct->lv & 0x0F) << 4); + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_conn_sec_mode_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_conn_sec_mode_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->sm = ser_data & 0x0F; + p_struct->lv = (ser_data >> 4) & 0x0F; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_evt_conn_sec_update_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_conn_sec_update_t); + SER_PUSH_FIELD(&(p_struct->conn_sec), ble_gap_conn_sec_t_enc); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_conn_sec_update_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_conn_sec_update_t); + SER_PULL_FIELD(&(p_struct->conn_sec), ble_gap_conn_sec_t_dec); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_conn_sec_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_conn_sec_t); + + SER_PUSH_FIELD(&p_struct->sec_mode, ble_gap_conn_sec_mode_t_enc); + SER_PUSH_uint8(&p_struct->encr_key_size); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_conn_sec_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_conn_sec_t); + + SER_PULL_FIELD(&p_struct->sec_mode, ble_gap_conn_sec_mode_t_dec); + SER_PULL_uint8(&p_struct->encr_key_size); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_evt_sec_info_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_sec_info_request_t); + + uint8_t ser_data = (p_struct->enc_info & 0x01) + | ((p_struct->id_info & 0x01) << 1) + | ((p_struct->sign_info& 0x01) << 2); + SER_PUSH_FIELD(&p_struct->peer_addr, ble_gap_addr_t_enc); + SER_PUSH_FIELD(&p_struct->master_id, ble_gap_master_id_t_enc); + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_sec_info_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_sec_info_request_t); + + uint8_t ser_data; + SER_PULL_FIELD(&p_struct->peer_addr, ble_gap_addr_t_dec); + SER_PULL_FIELD(&p_struct->master_id, ble_gap_master_id_t_dec); + SER_PULL_uint8(&ser_data); + p_struct->enc_info = ser_data & 0x01; + p_struct->id_info = (ser_data >> 1) & 0x01; + p_struct->sign_info = (ser_data >> 2) & 0x01; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_evt_connected_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_connected_t); + + SER_PUSH_FIELD(&p_struct->peer_addr, ble_gap_addr_t_enc); + SER_PUSH_uint8(&p_struct->role); + SER_PUSH_FIELD(&p_struct->conn_params, ble_gap_conn_params_t_enc); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + SER_PUSH_uint8(&p_struct->adv_handle); + SER_PUSH_FIELD(&p_struct->adv_data, ble_gap_adv_data_t_enc); +#endif + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_connected_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_connected_t); + + SER_PULL_FIELD(&p_struct->peer_addr, ble_gap_addr_t_dec); + SER_PULL_uint8(&p_struct->role); + SER_PULL_FIELD(&p_struct->conn_params, ble_gap_conn_params_t_dec); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5 + SER_PULL_uint8(&p_struct->adv_handle); + SER_PULL_FIELD(&p_struct->adv_data, ble_gap_adv_data_t_dec); +#endif + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_sec_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_sec_params_t); + + uint8_t ser_data = (p_struct->bond & 0x01) + | ((p_struct->mitm & 0x01) << 1) + | ((p_struct->lesc & 0x01) << 2) + | ((p_struct->keypress & 0x01) << 3) + | ((p_struct->io_caps & 0x07) << 4) + | ((p_struct->oob & 0x01) << 7); + SER_PUSH_uint8(&ser_data); + SER_PUSH_uint8(&p_struct->min_key_size); + SER_PUSH_uint8(&p_struct->max_key_size); + SER_PUSH_FIELD(&p_struct->kdist_own, ble_gap_sec_kdist_t_enc); + SER_PUSH_FIELD(&p_struct->kdist_peer, ble_gap_sec_kdist_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_sec_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_sec_params_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + SER_PULL_uint8(&p_struct->min_key_size); + SER_PULL_uint8(&p_struct->max_key_size); + SER_PULL_FIELD(&p_struct->kdist_own, ble_gap_sec_kdist_t_dec); + SER_PULL_FIELD(&p_struct->kdist_peer, ble_gap_sec_kdist_t_dec); + p_struct->bond = ser_data & 0x01; + p_struct->mitm = (ser_data >> 1) & 0x01; + p_struct->lesc = (ser_data >> 2) & 0x01; + p_struct->keypress = (ser_data >> 3) & 0x01; + p_struct->io_caps = (ser_data >> 4) & 0x07; + p_struct->oob = (ser_data >> 7) & 0x01; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_evt_sec_params_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_sec_params_request_t); + SER_PUSH_FIELD(&(p_struct->peer_params), ble_gap_sec_params_t_enc); + SER_STRUCT_ENC_END; +} + + uint32_t ble_gap_evt_sec_params_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_sec_params_request_t); + SER_PULL_FIELD(&(p_struct->peer_params), ble_gap_sec_params_t_dec); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_evt_conn_param_update_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_conn_param_update_t); + SER_PUSH_FIELD(&(p_struct->conn_params), ble_gap_conn_params_t_enc); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_conn_param_update_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_conn_param_update_t); + SER_PULL_FIELD(&(p_struct->conn_params), ble_gap_conn_params_t_dec); + SER_STRUCT_DEC_END; +} + +#ifndef S112 +uint32_t ble_gap_evt_conn_param_update_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_conn_param_update_request_t); + SER_PUSH_FIELD(&(p_struct->conn_params), ble_gap_conn_params_t_enc); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_conn_param_update_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_conn_param_update_request_t); + SER_PULL_FIELD(&(p_struct->conn_params), ble_gap_conn_params_t_dec); + SER_STRUCT_DEC_END; +} +#endif //!S112 + +uint32_t ble_gap_conn_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_conn_params_t); + + SER_PUSH_uint16(&p_struct->min_conn_interval); + SER_PUSH_uint16(&p_struct->max_conn_interval); + SER_PUSH_uint16(&p_struct->slave_latency); + SER_PUSH_uint16(&p_struct->conn_sup_timeout); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_conn_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_conn_params_t); + + SER_PULL_uint16(&p_struct->min_conn_interval); + SER_PULL_uint16(&p_struct->max_conn_interval); + SER_PULL_uint16(&p_struct->slave_latency); + SER_PULL_uint16(&p_struct->conn_sup_timeout); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_evt_disconnected_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_disconnected_t); + SER_PUSH_uint8(&p_struct->reason); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_disconnected_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_disconnected_t); + SER_PULL_uint8(&p_struct->reason); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_master_id_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_master_id_t); + SER_PUSH_uint16(&p_struct->ediv); + SER_PUSH_uint8array(p_struct->rand, BLE_GAP_SEC_RAND_LEN); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_master_id_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_master_id_t); + SER_PULL_uint16(&p_struct->ediv); + SER_PULL_uint8array(p_struct->rand, BLE_GAP_SEC_RAND_LEN); + SER_STRUCT_DEC_END; +} + +#ifndef S112 +uint32_t ble_gap_scan_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_scan_params_t); + uint8_t ser_data; +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 + ser_data = (p_struct->active & 0x01) + | ((p_struct->use_whitelist & 0x01) << 1) + | ((p_struct->adv_dir_report & 0x01) << 2); + SER_PUSH_uint8(&ser_data); +#else + ser_data = + ((p_struct->extended & 0x01) << 0) | + ((p_struct->report_incomplete_evts & 0x01) << 1) | + ((p_struct->active & 0x01) << 2) | + ((p_struct->filter_policy & 0x03) << 3); + SER_PUSH_uint8(&ser_data); + SER_PUSH_uint8(&p_struct->scan_phys); + SER_PUSH_buf(p_struct->channel_mask, 5); +#endif + SER_PUSH_uint16(&p_struct->interval); + SER_PUSH_uint16(&p_struct->window); + SER_PUSH_uint16(&p_struct->timeout); + + SER_STRUCT_ENC_END; +} +uint32_t ble_gap_scan_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_scan_params_t); + + uint8_t ser_data; +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 + SER_PULL_uint8(&ser_data); + p_struct->active = ser_data & 0x01; + p_struct->use_whitelist = (ser_data >> 1) & 0x01; + p_struct->adv_dir_report = (ser_data >> 2) & 0x01; +#else + SER_PULL_uint8(&ser_data); + p_struct->extended = ser_data & 0x01; + p_struct->report_incomplete_evts = (ser_data >> 1) & 0x01; + p_struct->active = (ser_data >> 2) & 0x01; + p_struct->filter_policy = (ser_data >> 3) & 0x03; + + SER_PULL_uint8(&p_struct->scan_phys); + uint8_t * p_channel_mask = (uint8_t *)p_struct->channel_mask; + SER_PULL_buf(&p_channel_mask, 5, 5); +#endif + SER_PULL_uint16(&p_struct->interval); + SER_PULL_uint16(&p_struct->window); + SER_PULL_uint16(&p_struct->timeout); + + SER_STRUCT_DEC_END; +} +#endif //!S112 + +uint32_t ble_gap_enc_key_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_enc_key_t); + + SER_PUSH_FIELD(&p_struct->enc_info, ble_gap_enc_info_t_enc); + SER_PUSH_FIELD(&p_struct->master_id, ble_gap_master_id_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_enc_key_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_enc_key_t); + + SER_PULL_FIELD(&p_struct->enc_info, ble_gap_enc_info_t_dec); + SER_PULL_FIELD(&p_struct->master_id, ble_gap_master_id_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_id_key_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_id_key_t); + + SER_PUSH_FIELD(&p_struct->id_info, ble_gap_irk_t_enc); + SER_PUSH_FIELD(&p_struct->id_addr_info, ble_gap_addr_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_id_key_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_id_key_t); + + SER_PULL_FIELD(&p_struct->id_info, ble_gap_irk_t_dec); + SER_PULL_FIELD(&p_struct->id_addr_info, ble_gap_addr_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_sec_keyset_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_sec_keyset_t); + + SER_PUSH_FIELD(&p_struct->keys_own, ble_gap_sec_keys_t_enc); + SER_PUSH_FIELD(&p_struct->keys_peer, ble_gap_sec_keys_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_sec_keyset_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_sec_keyset_t); + + SER_PULL_FIELD(&p_struct->keys_own, ble_gap_sec_keys_t_dec); + SER_PULL_FIELD(&p_struct->keys_peer, ble_gap_sec_keys_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_evt_sec_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_sec_request_t); + + uint8_t ser_data = (p_struct->bond & 0x01) + | ((p_struct->mitm & 0x01) << 1) + | ((p_struct->lesc & 0x01) << 2) + | ((p_struct->keypress & 0x01) << 3); + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_sec_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_sec_request_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->bond = ser_data & 0x01; + p_struct->mitm = (ser_data >> 1) & 0x01; + p_struct->lesc = (ser_data >> 2) & 0x01; + p_struct->keypress = (ser_data >> 3) & 0x01; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_sec_kdist_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_sec_kdist_t); + + uint8_t ser_data = (p_struct->enc & 0x01) + | (p_struct->id & 0x01) << 1 + | (p_struct->sign & 0x01) << 2 + | (p_struct->link & 0x01) << 3; + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_sec_kdist_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_sec_kdist_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->enc = ser_data & 0x01; + p_struct->id = (ser_data >> 1) & 0x01; + p_struct->sign = (ser_data >> 2) & 0x01; + p_struct->link = (ser_data >> 3) & 0x01; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_opt_ch_map_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_ch_map_t); + + SER_PUSH_uint16(&p_struct->conn_handle); + SER_PUSH_uint8array(p_struct->ch_map, 5); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_ch_map_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_ch_map_t); + + SER_PULL_uint16(&p_struct->conn_handle); + SER_PULL_uint8array(p_struct->ch_map, 5); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_opt_local_conn_latency_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_local_conn_latency_t); + + SER_PUSH_uint16(&p_struct->conn_handle); + SER_PUSH_uint16(&p_struct->requested_latency); + SER_PUSH_COND(p_struct->p_actual_latency, uint16_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_local_conn_latency_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_local_conn_latency_t); + + SER_PULL_uint16(&p_struct->conn_handle); + SER_PULL_uint16(&p_struct->requested_latency); + SER_PULL_COND(&p_struct->p_actual_latency, uint16_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_opt_passkey_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_passkey_t); + SER_PUSH_buf(p_struct->p_passkey, BLE_GAP_PASSKEY_LEN); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_passkey_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_passkey_t); + SER_PULL_buf((uint8_t**)&p_struct->p_passkey, BLE_GAP_PASSKEY_LEN, BLE_GAP_PASSKEY_LEN); + SER_STRUCT_DEC_END; +} +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 +uint32_t ble_gap_opt_scan_req_report_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_scan_req_report_t); + + uint8_t ser_data = p_struct->enable & 0x01; + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_scan_req_report_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_scan_req_report_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->enable = ser_data & 0x01; + + SER_STRUCT_DEC_END; +} +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gap_opt_compat_mode_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_compat_mode_t); + + uint8_t ser_data = p_struct->mode_1_enable & 0x01; + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_compat_mode_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_compat_mode_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->mode_1_enable = ser_data & 0x01; + + SER_STRUCT_DEC_END; +} +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 +uint32_t ble_gap_adv_ch_mask_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_adv_ch_mask_t); + + uint8_t ser_data = (p_struct->ch_37_off & 0x01) + | ((p_struct->ch_38_off & 0x01) << 1) + | ((p_struct->ch_39_off & 0x01) << 2); + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_adv_ch_mask_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_adv_ch_mask_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->ch_37_off = ser_data & 0x01; + p_struct->ch_38_off = (ser_data >> 1) & 0x01; + p_struct->ch_39_off = (ser_data >> 2) & 0x01; + + SER_STRUCT_DEC_END; +} +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gap_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_enable_params_t); + + SER_PUSH_uint8(&p_struct->periph_conn_count); + SER_PUSH_uint8(&p_struct->central_conn_count); + SER_PUSH_uint8(&p_struct->central_sec_count); + SER_PUSH_COND(p_struct->p_device_name, ble_gap_device_name_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_enable_params_t); + + SER_PULL_uint8(&p_struct->periph_conn_count); + SER_PULL_uint8(&p_struct->central_conn_count); + SER_PULL_uint8(&p_struct->central_sec_count); + SER_PULL_COND(&p_struct->p_device_name, ble_gap_device_name_t_dec); + + SER_STRUCT_DEC_END; +} +#endif + +uint32_t ble_gap_lesc_p256_pk_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_lesc_p256_pk_t); + SER_PUSH_uint8array(p_struct->pk, BLE_GAP_LESC_P256_PK_LEN); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_lesc_p256_pk_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_lesc_p256_pk_t); + SER_PULL_uint8array(p_struct->pk, BLE_GAP_LESC_P256_PK_LEN); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_lesc_dhkey_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_lesc_dhkey_t); + SER_PUSH_uint8array(p_struct->key, BLE_GAP_LESC_DHKEY_LEN); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_lesc_dhkey_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_lesc_dhkey_t); + SER_PULL_uint8array(p_struct->key, BLE_GAP_LESC_DHKEY_LEN); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_lesc_oob_data_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_lesc_oob_data_t); + + SER_PUSH_FIELD(&p_struct->addr, ble_gap_addr_t_enc); + SER_PUSH_uint8array(p_struct->r, BLE_GAP_SEC_KEY_LEN); + SER_PUSH_uint8array(p_struct->c, BLE_GAP_SEC_KEY_LEN); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_lesc_oob_data_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_lesc_oob_data_t); + + SER_PULL_FIELD(&p_struct->addr, ble_gap_addr_t_dec); + SER_PULL_uint8array(p_struct->r, BLE_GAP_SEC_KEY_LEN); + SER_PULL_uint8array(p_struct->c, BLE_GAP_SEC_KEY_LEN); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_adv_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_adv_params_t); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 + SER_PUSH_uint8(&p_struct->type); + SER_PUSH_COND(p_struct->p_peer_addr, ble_gap_addr_t_enc); + SER_PUSH_uint8(&p_struct->fp); + SER_PUSH_uint16(&p_struct->interval); + SER_PUSH_uint16(&p_struct->timeout); + SER_PUSH_FIELD(&p_struct->channel_mask, ble_gap_adv_ch_mask_t_enc); +#else + SER_PUSH_FIELD(&p_struct->properties, ble_gap_adv_properties_t_enc); + SER_PUSH_COND(p_struct->p_peer_addr, ble_gap_addr_t_enc); + SER_PUSH_uint32(&p_struct->interval); + SER_PUSH_uint16(&p_struct->duration); + SER_PUSH_uint8(&p_struct->max_adv_evts); + SER_PUSH_buf(p_struct->channel_mask, 5); + SER_PUSH_uint8(&p_struct->filter_policy); + SER_PUSH_uint8(&p_struct->primary_phy); + SER_PUSH_uint8(&p_struct->secondary_phy); + uint8_t temp = p_struct->set_id | (p_struct->scan_req_notification << 4); + SER_PUSH_uint8(&temp); + +#endif + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_adv_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_adv_params_t); + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6 + SER_PULL_uint8(&p_struct->type); + SER_PULL_COND(&p_struct->p_peer_addr, ble_gap_addr_t_dec); + SER_PULL_uint8(&p_struct->fp); + SER_PULL_uint16(&p_struct->interval); + SER_PULL_uint16(&p_struct->timeout); + SER_PULL_FIELD(&p_struct->channel_mask, ble_gap_adv_ch_mask_t_dec); +#else + SER_PULL_FIELD(&p_struct->properties, ble_gap_adv_properties_t_dec); + SER_PULL_COND(&p_struct->p_peer_addr, ble_gap_addr_t_dec); + SER_PULL_uint32(&p_struct->interval); + SER_PULL_uint16(&p_struct->duration); + SER_PULL_uint8(&p_struct->max_adv_evts); + uint8_t * p_channel_mask = p_struct->channel_mask; + SER_PULL_buf((uint8_t **)&p_channel_mask, 5, 5); + SER_PULL_uint8(&p_struct->filter_policy); + SER_PULL_uint8(&p_struct->primary_phy); + SER_PULL_uint8(&p_struct->secondary_phy); + + uint8_t temp; + SER_PULL_uint8(&temp); + p_struct->set_id = temp & 0x0F; + p_struct->scan_req_notification = (temp & 0x10) ? 1 : 0; + +#endif + + SER_STRUCT_DEC_END; +} +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gap_opt_ext_len_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_ext_len_t); + SER_PUSH_uint8(&p_struct->rxtx_max_pdu_payload_size); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_ext_len_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_ext_len_t); + SER_PULL_uint8(&p_struct->rxtx_max_pdu_payload_size); + SER_STRUCT_DEC_END; +} +#endif +uint32_t ble_gap_opt_auth_payload_timeout_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_auth_payload_timeout_t); + + SER_PUSH_uint16(&p_struct->conn_handle); + SER_PUSH_uint16(&p_struct->auth_payload_timeout); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_auth_payload_timeout_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_auth_payload_timeout_t); + + SER_PULL_uint16(&p_struct->conn_handle); + SER_PULL_uint16(&p_struct->auth_payload_timeout); + + SER_STRUCT_DEC_END; +} + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gap_device_name_t_enc +#else +uint32_t ble_gap_cfg_device_name_t_enc +#endif + (void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) + +{ +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + SER_STRUCT_ENC_BEGIN(ble_gap_device_name_t); +#else + SER_STRUCT_ENC_BEGIN(ble_gap_cfg_device_name_t); +#endif + /* serializer does not support attributes on stack */ + if (p_struct->vloc != BLE_GATTS_VLOC_STACK) + { + err_code = NRF_ERROR_INVALID_PARAM; + } + + SER_PUSH_FIELD(&p_struct->write_perm, ble_gap_conn_sec_mode_t_enc); + + uint8_t ser_data = p_struct->vloc & 0x03; + SER_PUSH_uint8(&ser_data); + SER_PUSH_uint16(&p_struct->current_len); + SER_PUSH_uint16(&p_struct->max_len); + SER_PUSH_buf(p_struct->p_value, p_struct->current_len); + + SER_STRUCT_ENC_END; +} + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gap_device_name_t_dec +#else +uint32_t ble_gap_cfg_device_name_t_dec +#endif + (uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + SER_STRUCT_DEC_BEGIN(ble_gap_device_name_t); +#else + SER_STRUCT_DEC_BEGIN(ble_gap_cfg_device_name_t); +#endif + + uint16_t value_max_len = p_struct->max_len; + uint8_t ser_data; + SER_PULL_FIELD(&p_struct->write_perm, ble_gap_conn_sec_mode_t_dec); + SER_PULL_uint8(&ser_data); + p_struct->vloc = ser_data & 0x03; + SER_PULL_uint16(&p_struct->current_len); + SER_PULL_uint16(&p_struct->max_len); + SER_PULL_buf(&p_struct->p_value,value_max_len, p_struct->current_len); + + SER_STRUCT_DEC_END; +} + + + +uint32_t ble_gap_privacy_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_privacy_params_t); + + SER_PUSH_uint8(&p_struct->privacy_mode); + SER_PUSH_uint8(&p_struct->private_addr_type); + SER_PUSH_uint16(&p_struct->private_addr_cycle_s); + SER_PUSH_COND(p_struct->p_device_irk, ble_gap_irk_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_privacy_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_privacy_params_t); + + SER_PULL_uint8(&p_struct->privacy_mode); + SER_PULL_uint8(&p_struct->private_addr_type); + SER_PULL_uint16(&p_struct->private_addr_cycle_s); + SER_PULL_COND(&p_struct->p_device_irk, ble_gap_irk_t_dec); + + SER_STRUCT_DEC_END; +} + + + + +#if NRF_SD_BLE_API_VERSION >= 4 +#ifndef S112 +uint32_t ble_gap_opt_compat_mode_1_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_compat_mode_1_t); + + uint8_t enable = p_struct->enable; + SER_PUSH_uint8(&enable); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_compat_mode_1_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_compat_mode_1_t); + + uint8_t enable; + SER_PULL_uint8(&enable); + p_struct->enable = enable; + + SER_STRUCT_DEC_END; +} +#endif //!S112 + +uint32_t ble_gap_opt_slave_latency_disable_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_slave_latency_disable_t); + + SER_PUSH_uint16(&p_struct->conn_handle); + uint8_t disable = p_struct->disable; + SER_PUSH_uint8(&disable); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_slave_latency_disable_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_slave_latency_disable_t); + + SER_PULL_uint16(&p_struct->conn_handle); + uint8_t disable; + SER_PULL_uint8(&disable); + p_struct->disable = disable; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_conn_cfg_t); + + SER_PUSH_uint8(&p_struct->conn_count); + SER_PUSH_uint16(&p_struct->event_length); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_conn_cfg_t); + + SER_PULL_uint8(&p_struct->conn_count); + SER_PULL_uint16(&p_struct->event_length); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_cfg_role_count_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_cfg_role_count_t); + + SER_PUSH_uint8(&p_struct->periph_role_count); +#ifndef S112 + SER_PUSH_uint8(&p_struct->central_role_count); + SER_PUSH_uint8(&p_struct->central_sec_count); +#endif //!S112 +#if NRF_SD_BLE_API_VERSION > 5 + SER_PUSH_uint8(&p_struct->adv_set_count); +#ifndef S112 + uint32_t temp = p_struct->qos_channel_survey_role_available; + SER_PUSH_uint8(&temp); +#endif //!S112 +#endif + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_cfg_role_count_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_cfg_role_count_t); + + SER_PULL_uint8(&p_struct->periph_role_count); +#ifndef S112 + SER_PULL_uint8(&p_struct->central_role_count); + SER_PULL_uint8(&p_struct->central_sec_count); +#endif //!S112 +#if NRF_SD_BLE_API_VERSION > 5 + SER_PULL_uint8(&p_struct->adv_set_count); +#ifndef S112 + uint8_t temp; + SER_PULL_uint8(&temp); + p_struct->qos_channel_survey_role_available = temp; +#endif //!S112 +#endif + SER_STRUCT_DEC_END; +} + +#ifndef S112 +uint32_t ble_gap_data_length_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_data_length_params_t); + + SER_PUSH_uint16(&p_struct->max_tx_octets); + SER_PUSH_uint16(&p_struct->max_rx_octets); + SER_PUSH_uint16(&p_struct->max_tx_time_us); + SER_PUSH_uint16(&p_struct->max_rx_time_us); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_data_length_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_data_length_params_t); + + SER_PULL_uint16(&p_struct->max_tx_octets); + SER_PULL_uint16(&p_struct->max_rx_octets); + SER_PULL_uint16(&p_struct->max_tx_time_us); + SER_PULL_uint16(&p_struct->max_rx_time_us); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_data_length_limitation_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_data_length_limitation_t); + + SER_PUSH_uint16(&p_struct->tx_payload_limited_octets); + SER_PUSH_uint16(&p_struct->rx_payload_limited_octets); + SER_PUSH_uint16(&p_struct->tx_rx_time_limited_us); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_data_length_limitation_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_data_length_limitation_t); + + SER_PULL_uint16(&p_struct->tx_payload_limited_octets); + SER_PULL_uint16(&p_struct->rx_payload_limited_octets); + SER_PULL_uint16(&p_struct->tx_rx_time_limited_us); + + SER_STRUCT_DEC_END; +} +#endif //!S112 +#endif + +#if NRF_SD_BLE_API_VERSION == 4 + +uint32_t ble_gap_opt_compat_mode_2_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_opt_compat_mode_2_t); + + uint8_t enable = p_struct->enable; + SER_PUSH_uint8(&enable); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_opt_compat_mode_2_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_opt_compat_mode_2_t); + + uint8_t enable; + SER_PULL_uint8(&enable); + p_struct->enable = enable; + + SER_STRUCT_DEC_END; +} + +#endif + +#if NRF_SD_BLE_API_VERSION >= 5 +uint32_t ble_gap_phys_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_phys_t); + + SER_PUSH_uint8(&p_struct->tx_phys); + SER_PUSH_uint8(&p_struct->rx_phys); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_phys_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_phys_t); + + SER_PULL_uint8(&p_struct->tx_phys); + SER_PULL_uint8(&p_struct->rx_phys); + + SER_STRUCT_DEC_END; +} +#endif + +#if NRF_SD_BLE_API_VERSION > 5 +uint32_t ble_gap_adv_properties_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_adv_properties_t); + + SER_PUSH_uint8(&p_struct->type); + uint8_t temp = p_struct->anonymous | (p_struct->include_tx_power << 1); + SER_PUSH_uint8(&temp); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_adv_properties_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_adv_properties_t); + + SER_PULL_uint8(&p_struct->type); + uint8_t temp; + SER_PULL_uint8(&temp); + p_struct->anonymous = temp & 0x01; + p_struct->include_tx_power = (temp & 0x02) ? 1 : 0; + + SER_STRUCT_DEC_END; +} + +#ifndef S112 +uint32_t ble_gap_adv_report_type_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_adv_report_type_t); + + uint16_t temp = + (p_struct->connectable << 0) | + (p_struct->scannable << 1) | + (p_struct->directed << 2) | + (p_struct->scan_response << 3) | + (p_struct->extended_pdu << 4) | + (p_struct->status << 5) | + (p_struct->reserved << 7); + SER_PUSH_uint16(&temp); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_adv_report_type_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_adv_report_type_t); + + uint16_t temp; + SER_PULL_uint16(&temp); + p_struct->connectable = (temp >> 0) & 0x01; + p_struct->scannable = (temp >> 1) & 0x01; + p_struct->directed = (temp >> 2) & 0x01; + p_struct->scan_response = (temp >> 3) & 0x01; + p_struct->extended_pdu = (temp >> 4) & 0x01; + p_struct->status = (temp >> 5) & 0x03; + p_struct->reserved = (temp >> 7) & 0x1FF; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_aux_pointer_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_aux_pointer_t); + + SER_PUSH_uint16(&p_struct->aux_offset); + SER_PUSH_uint8(&p_struct->aux_phy); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_aux_pointer_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_aux_pointer_t); + + SER_PULL_uint16(&p_struct->aux_offset); + SER_PULL_uint8(&p_struct->aux_phy); + + SER_STRUCT_DEC_END; +} +#endif //!S112 + +uint32_t ble_gap_adv_data_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_adv_data_t); + + SER_PUSH_FIELD(&p_struct->adv_data, ble_data_t_enc); + SER_PUSH_FIELD(&p_struct->scan_rsp_data, ble_data_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_adv_data_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_adv_data_t); + + SER_PULL_FIELD(&p_struct->adv_data, ble_data_t_dec); + SER_PULL_FIELD(&p_struct->scan_rsp_data, ble_data_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gap_evt_adv_set_terminated_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gap_evt_adv_set_terminated_t); + + SER_PUSH_uint8(&p_struct->reason); + SER_PUSH_uint8(&p_struct->adv_handle); + SER_PUSH_uint8(&p_struct->num_completed_adv_events); + + SER_PUSH_FIELD(&p_struct->adv_data, ble_gap_adv_data_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gap_evt_adv_set_terminated_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gap_evt_adv_set_terminated_t); + + SER_PULL_uint8(&p_struct->reason); + SER_PULL_uint8(&p_struct->adv_handle); + SER_PULL_uint8(&p_struct->num_completed_adv_events); + + SER_PULL_FIELD(&p_struct->adv_data, ble_gap_adv_data_t_dec); + + SER_STRUCT_DEC_END; +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gap_struct_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gap_struct_serialization.h new file mode 100644 index 000000000..68218bbc2 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gap_struct_serialization.h @@ -0,0 +1,612 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GAP_STRUCT_SERIALIZATION_H__ +#define BLE_GAP_STRUCT_SERIALIZATION_H__ + +#include "ble_gap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t ble_gap_evt_adv_report_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_adv_report_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_irk_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_irk_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_addr_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_addr_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_sec_levels_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_sec_levels_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_sec_keys_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_sec_keys_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_enc_info_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_enc_info_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_sign_info_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_sign_info_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_auth_status_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_auth_status_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_conn_sec_mode_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_conn_sec_mode_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_conn_sec_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_conn_sec_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_conn_sec_update_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_conn_sec_update_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_sec_info_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_sec_info_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_connected_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_connected_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_sec_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_sec_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_sec_params_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_sec_params_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_conn_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_conn_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_conn_param_update_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_conn_param_update_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_conn_param_update_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_conn_param_update_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_disconnected_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_disconnected_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_scan_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_scan_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_data); + +uint32_t ble_gap_master_id_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_master_id_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_enc_key_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_enc_key_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_id_key_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_id_key_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_sec_keyset_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_sec_keyset_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_sec_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_sec_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_sec_kdist_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_sec_kdist_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_opt_ch_map_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_ch_map_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_opt_local_conn_latency_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_local_conn_latency_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_opt_passkey_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_passkey_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_opt_scan_req_report_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_scan_req_report_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gap_opt_compat_mode_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_compat_mode_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif +uint32_t ble_gap_adv_ch_mask_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_adv_ch_mask_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_lesc_p256_pk_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_lesc_p256_pk_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_lesc_dhkey_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_lesc_dhkey_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_lesc_oob_data_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_lesc_oob_data_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_adv_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_adv_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gap_opt_ext_len_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_ext_len_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif + +uint32_t ble_gap_opt_auth_payload_timeout_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_auth_payload_timeout_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gap_device_name_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_device_name_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#else +uint32_t ble_gap_cfg_device_name_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_cfg_device_name_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif + +uint32_t ble_gap_privacy_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_privacy_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_gap_opt_compat_mode_1_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_compat_mode_1_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_opt_compat_mode_2_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_compat_mode_2_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +uint32_t ble_gap_opt_slave_latency_disable_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_opt_slave_latency_disable_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_cfg_role_count_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_cfg_role_count_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_data_length_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_data_length_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_data_length_limitation_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_data_length_limitation_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif + +#if NRF_SD_BLE_API_VERSION >= 5 +uint32_t ble_gap_phys_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_phys_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif + +#if NRF_SD_BLE_API_VERSION > 5 +uint32_t ble_gap_adv_properties_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_adv_properties_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_adv_report_type_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_adv_report_type_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_aux_pointer_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_aux_pointer_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_adv_data_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_adv_data_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gap_evt_adv_set_terminated_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gap_evt_adv_set_terminated_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // BLE_GAP_STRUCT_SERIALIZATION_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatt_struct_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatt_struct_serialization.c new file mode 100644 index 000000000..c30210ea8 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatt_struct_serialization.c @@ -0,0 +1,158 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_serialization.h" +#include "ble_struct_serialization.h" +#include "ble_gatt_struct_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" +#include "ble_gatt.h" +#include + +uint32_t ble_gatt_char_props_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatt_char_props_t); + + uint8_t ser_data = (p_struct->broadcast & 0x01) + | ((p_struct->read & 0x01) << 1) + | ((p_struct->write_wo_resp & 0x01) << 2) + | ((p_struct->write & 0x01) << 3) + | ((p_struct->notify & 0x01) << 4) + | ((p_struct->indicate & 0x01) << 5) + | ((p_struct->auth_signed_wr & 0x01) << 6); + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatt_char_props_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatt_char_props_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->broadcast = ser_data & 0x01; + p_struct->read = (ser_data >> 1) & 0x01; + p_struct->write_wo_resp = (ser_data >> 2) & 0x01; + p_struct->write = (ser_data >> 3) & 0x01; + p_struct->notify = (ser_data >> 4) & 0x01; + p_struct->indicate = (ser_data >> 5) & 0x01; + p_struct->auth_signed_wr = (ser_data >> 6) & 0x01; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatt_char_ext_props_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatt_char_ext_props_t); + + uint8_t ser_data = (p_struct->reliable_wr & 0x01) + | ((p_struct->wr_aux & 0x01) << 1); + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatt_char_ext_props_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatt_char_ext_props_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->reliable_wr = ser_data & 0x01; + p_struct->wr_aux = (ser_data >> 1) & 0x01; + + SER_STRUCT_DEC_END; +} + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gatt_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatt_enable_params_t); + SER_PUSH_uint16(&p_struct->att_mtu); + SER_STRUCT_ENC_END; +} + + +uint32_t ble_gatt_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatt_enable_params_t); + SER_PULL_uint16(&p_struct->att_mtu); + SER_STRUCT_DEC_END; +} +#else +uint32_t ble_gatt_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatt_conn_cfg_t); + SER_PUSH_uint16(&p_struct->att_mtu); + SER_STRUCT_ENC_END; +} + + +uint32_t ble_gatt_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatt_conn_cfg_t); + SER_PULL_uint16(&p_struct->att_mtu); + SER_STRUCT_DEC_END; +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatt_struct_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatt_struct_serialization.h new file mode 100644 index 000000000..ad6fed1a9 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatt_struct_serialization.h @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GATT_STRUCT_SERIALIZATION_H +#define BLE_GATT_STRUCT_SERIALIZATION_H + +#include "ble_gatt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t ble_gatt_char_props_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatt_char_props_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatt_char_ext_props_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatt_char_ext_props_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gatt_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatt_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#else +uint32_t ble_gatt_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatt_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif +#ifdef __cplusplus +} +#endif + +#endif /*BLE_GATT_STRUCT_SERIALIZATION_H*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gattc_struct_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gattc_struct_serialization.c new file mode 100644 index 000000000..03b1accf1 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gattc_struct_serialization.c @@ -0,0 +1,715 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gatt_struct_serialization.h" +#include "ble_gattc_struct_serialization.h" +#include "ble_struct_serialization.h" +#include "ble_serialization.h" +#include "app_util.h" +#include "ble_gattc.h" +#include "cond_field_serialization.h" +#include + +uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_char_val_by_uuid_read_rsp_t); + + SER_PUSH_uint16(&p_struct->count); + SER_PUSH_uint16(&p_struct->value_len); + + // Copy the whole packed list. + uint16_t list_length = (p_struct->value_len + sizeof(uint16_t)) * p_struct->count; + SER_PUSH_uint8array(p_struct->handle_value, list_length); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_char_val_by_uuid_read_rsp_t); + + SER_PULL_uint16(&p_struct->count); + SER_PULL_uint16(&p_struct->value_len); + + uint16_t list_length = (p_struct->value_len + sizeof(uint16_t)) * p_struct->count; + SER_ASSERT_LENGTH_LEQ(list_length, *p_ext_len); + SER_PULL_uint8array(p_struct->handle_value, list_length); + *p_ext_len = list_length; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_char_vals_read_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_char_vals_read_rsp_t); + + SER_PUSH_uint16(&p_struct->len); + SER_PUSH_uint8array(p_struct->values, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_char_vals_read_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_char_vals_read_rsp_t); + + SER_PULL_uint16(&p_struct->len); + + SER_ASSERT_LENGTH_LEQ(p_struct->len, *p_ext_len); + SER_PULL_uint8array(p_struct->values, p_struct->len); + *p_ext_len = p_struct->len; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_handle_range_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_handle_range_t); + + SER_PUSH_uint16(&p_struct->start_handle); + SER_PUSH_uint16(&p_struct->end_handle); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_handle_range_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_handle_range_t); + + SER_PULL_uint16(&p_struct->start_handle); + SER_PULL_uint16(&p_struct->end_handle); + + SER_STRUCT_DEC_END; +} + + +uint32_t ble_gattc_service_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_service_t); + + SER_PUSH_FIELD(&p_struct->uuid, ble_uuid_t_enc); + SER_PUSH_FIELD(&p_struct->handle_range, ble_gattc_handle_range_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_service_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_service_t); + + SER_PULL_FIELD(&p_struct->uuid, ble_uuid_t_dec); + SER_PULL_FIELD(&p_struct->handle_range, ble_gattc_handle_range_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_include_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_include_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_FIELD(&p_struct->included_srvc, ble_gattc_service_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_include_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_include_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_FIELD(&p_struct->included_srvc, ble_gattc_service_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_rel_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_rel_disc_rsp_t); + + SER_PUSH_uint16(&p_struct->count); + + ble_gattc_include_t * p_include = &(p_struct->includes[0]); + uint32_t i; + + for (i = 0; i < p_struct->count; i++) + { + SER_PUSH_FIELD(p_include, ble_gattc_include_t_enc); + ++p_include; + } + + SER_STRUCT_ENC_END; +} + + + +uint32_t ble_gattc_evt_rel_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_rel_disc_rsp_t); + + SER_PULL_uint16(&p_struct->count); + + uint32_t data_len = (SUB1(p_struct->count) * sizeof(ble_gattc_include_t)); + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + ble_gattc_include_t * p_include = &(p_struct->includes[0]); + uint32_t i; + + for (i = 0; i < p_struct->count; i++) + { + SER_PULL_FIELD(p_include, ble_gattc_include_t_dec); + ++p_include; + } + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_write_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_write_params_t); + + SER_PUSH_uint8(&p_struct->write_op); + SER_PUSH_uint8(&p_struct->flags); + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_uint16(&p_struct->offset); + SER_PUSH_len16data(p_struct->p_value, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_write_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_write_params_t); + + SER_PULL_uint8(&p_struct->write_op); + SER_PULL_uint8(&p_struct->flags); + SER_PULL_uint16(&p_struct->handle); + SER_PULL_uint16(&p_struct->offset); + SER_PULL_len16data((uint8_t **) &p_struct->p_value, &p_struct->len); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_attr_info16_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_attr_info16_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_FIELD(&(p_struct->uuid), ble_uuid_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_attr_info16_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_attr_info16_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_FIELD(&(p_struct->uuid), ble_uuid_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_attr_info128_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_attr_info128_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_FIELD(&(p_struct->uuid), ble_uuid128_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_attr_info128_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_attr_info128_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_FIELD(&(p_struct->uuid), ble_uuid128_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_attr_info_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_attr_info_disc_rsp_t); + + SER_PUSH_uint16(&p_struct->count); + SER_PUSH_uint8(&p_struct->format); + + field_encoder_handler_t fp_encoder = (p_struct->format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) ? + ble_gattc_attr_info16_t_enc : ble_gattc_attr_info128_t_enc; + + uint32_t i; + for (i = 0; i < p_struct->count; ++i) + { + void * uuid_struct; + uuid_struct = (p_struct->format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) ? + (void *)&(p_struct->info.attr_info16[i]) : (void *)&(p_struct->info.attr_info128[i]); + SER_PUSH_FIELD(uuid_struct, fp_encoder); + } + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_attr_info_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_attr_info_disc_rsp_t); + + SER_PULL_uint16(&p_struct->count); + SER_PULL_uint8(&p_struct->format); + + uint32_t i; + uint32_t data_len; + field_decoder_handler_t fp_decoder; + if (p_struct->format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) + { + fp_decoder = ble_gattc_attr_info16_t_dec; + data_len = (SUB1(p_struct->count) * sizeof(ble_gattc_attr_info16_t)); + } + else + { + fp_decoder = ble_gattc_attr_info128_t_dec; + data_len = (SUB1(p_struct->count) * sizeof(ble_gattc_attr_info128_t)); + } + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + for (i = 0; i < p_struct->count; i++) + { + void * uuid_struct; + uuid_struct = (p_struct->format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) ? + (void *)&(p_struct->info.attr_info16[i]) : (void *)&(p_struct->info.attr_info128[i]); + SER_PULL_FIELD(uuid_struct, fp_decoder); + } + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_char_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_char_t); + + uint8_t ser_data; + SER_PUSH_FIELD(&p_struct->uuid, ble_uuid_t_enc); + SER_PUSH_FIELD(&p_struct->char_props, ble_gatt_char_props_t_enc); + ser_data = p_struct->char_ext_props & 0x01; + SER_PUSH_uint8(&ser_data); + SER_PUSH_uint16(&p_struct->handle_decl); + SER_PUSH_uint16(&p_struct->handle_value); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_char_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_char_t); + + uint8_t ser_data; + SER_PULL_FIELD(&p_struct->uuid, ble_uuid_t_dec); + SER_PULL_FIELD(&p_struct->char_props, ble_gatt_char_props_t_dec); + SER_PULL_uint8(&ser_data); + p_struct->char_ext_props = ser_data & 0x01; + SER_PULL_uint16(&p_struct->handle_decl); + SER_PULL_uint16(&p_struct->handle_value); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_char_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_char_disc_rsp_t); + + SER_PUSH_uint16(&p_struct->count); + SER_PUSH_FIELD_ARRAY(p_struct->chars, ble_gattc_char_t_enc, p_struct->count); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_char_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_char_disc_rsp_t); + + SER_PULL_uint16(&p_struct->count); + uint32_t data_len = (SUB1(p_struct->count) * sizeof(ble_gattc_char_t)); + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + SER_PULL_FIELD_ARRAY(p_struct->chars, ble_gattc_char_t_dec, p_struct->count); + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_desc_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_desc_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_FIELD(&p_struct->uuid, ble_uuid_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_desc_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_desc_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_FIELD(&p_struct->uuid, ble_uuid_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_desc_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_desc_disc_rsp_t); + + SER_PUSH_uint16(&p_struct->count); + SER_PUSH_FIELD_ARRAY(p_struct->descs, ble_gattc_desc_t_enc, p_struct->count); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_desc_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_desc_disc_rsp_t); + + SER_PULL_uint16(&p_struct->count); + uint32_t data_len = (SUB1(p_struct->count) * sizeof(ble_gattc_desc_t)); + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + SER_PULL_FIELD_ARRAY(p_struct->descs, ble_gattc_desc_t_dec, p_struct->count); + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_hvx_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_hvx_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_uint8(&p_struct->type); + SER_PUSH_uint16(&p_struct->len); + SER_PUSH_uint8array(p_struct->data, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_hvx_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_hvx_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_uint8(&p_struct->type); + SER_PULL_uint16(&p_struct->len); + + uint32_t data_len = (SUB1(p_struct->len)); + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + SER_PULL_uint8array(p_struct->data, p_struct->len); + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_prim_srvc_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_prim_srvc_disc_rsp_t); + + SER_PUSH_uint16(&p_struct->count); + SER_PUSH_FIELD_ARRAY(p_struct->services, ble_gattc_service_t_enc, p_struct->count); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_prim_srvc_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_prim_srvc_disc_rsp_t); + + SER_PULL_uint16(&p_struct->count); + uint32_t data_len = (SUB1(p_struct->count) * sizeof(ble_gattc_service_t)); + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + SER_PULL_FIELD_ARRAY(p_struct->services, ble_gattc_service_t_dec, p_struct->count); + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_read_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_read_rsp_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_uint16(&p_struct->offset); + SER_PUSH_uint16(&p_struct->len); + SER_PUSH_uint8array(p_struct->data, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_read_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_read_rsp_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_uint16(&p_struct->offset); + SER_PULL_uint16(&p_struct->len); + + uint32_t data_len = (SUB1(p_struct->len)); + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + SER_PULL_uint8array(p_struct->data, p_struct->len); + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_timeout_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_timeout_t); + SER_PUSH_uint8(&p_struct->src); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_timeout_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_timeout_t); + SER_PULL_uint8(&p_struct->src); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_write_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_write_rsp_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_uint8(&p_struct->write_op); + SER_PUSH_uint16(&p_struct->offset); + SER_PUSH_uint16(&p_struct->len); + SER_PUSH_uint8array(p_struct->data, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_write_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_write_rsp_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_uint8(&p_struct->write_op); + SER_PULL_uint16(&p_struct->offset); + SER_PULL_uint16(&p_struct->len); + + uint32_t data_len = (SUB1(p_struct->len)); + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + SER_PULL_uint8array(p_struct->data, p_struct->len); + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} + +uint32_t ble_gattc_evt_exchange_mtu_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_evt_exchange_mtu_rsp_t); + SER_PUSH_uint16(&p_struct->server_rx_mtu); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_evt_exchange_mtu_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_evt_exchange_mtu_rsp_t); + SER_PULL_uint16(&p_struct->server_rx_mtu); + SER_STRUCT_DEC_END; +} + +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_gattc_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gattc_conn_cfg_t); + SER_PUSH_uint8(&p_struct->write_cmd_tx_queue_size); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gattc_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gattc_conn_cfg_t); + SER_PULL_uint8(&p_struct->write_cmd_tx_queue_size); + SER_STRUCT_DEC_END; +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gattc_struct_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gattc_struct_serialization.h new file mode 100644 index 000000000..d43f15008 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gattc_struct_serialization.h @@ -0,0 +1,293 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GATTC_STRUCT_SERIALIZATION_H +#define BLE_GATTC_STRUCT_SERIALIZATION_H + +#include "ble_gattc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_char_val_by_uuid_read_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_evt_char_vals_read_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_char_vals_read_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_handle_range_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_handle_range_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_service_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_service_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_include_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_include_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_evt_rel_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_rel_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_write_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_write_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_attr_info16_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_attr_info16_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_attr_info128_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_attr_info128_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_evt_attr_info_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_attr_info_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gatt_char_props_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatt_char_props_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatt_char_ext_props_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatt_char_ext_props_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_char_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_char_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_evt_char_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_char_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_desc_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_desc_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_evt_desc_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_desc_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_evt_hvx_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_hvx_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_evt_prim_srvc_disc_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_prim_srvc_disc_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_evt_read_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_read_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_evt_timeout_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_timeout_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gattc_evt_write_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_write_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gattc_evt_exchange_mtu_rsp_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_evt_exchange_mtu_rsp_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_gattc_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gattc_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif +#ifdef __cplusplus +} +#endif + +#endif /*BLE_GATTC_STRUCT_SERIALIZATION_H*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatts_struct_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatts_struct_serialization.c new file mode 100644 index 000000000..ae4dc647a --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatts_struct_serialization.c @@ -0,0 +1,689 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_gatt_struct_serialization.h" +#include "ble_gatts_struct_serialization.h" +#include "ble_gap_struct_serialization.h" +#include "ble_struct_serialization.h" +#include "ble_serialization.h" +#include "app_util.h" +#include "ble_gatts.h" +#include "cond_field_serialization.h" +#include + +uint32_t ble_gatts_char_pf_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_char_pf_t); + + SER_PUSH_uint8(&p_struct->format); + SER_PUSH_int8(&p_struct->exponent); + SER_PUSH_uint16(&p_struct->unit); + SER_PUSH_uint8(&p_struct->name_space); + SER_PUSH_uint16(&p_struct->desc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_char_pf_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_char_pf_t); + + SER_PULL_uint8(&p_struct->format); + SER_PULL_int8(&p_struct->exponent); + SER_PULL_uint16(&p_struct->unit); + SER_PULL_uint8(&p_struct->name_space); + SER_PULL_uint16(&p_struct->desc); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_attr_md_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_attr_md_t); + + SER_PUSH_FIELD(&p_struct->read_perm, ble_gap_conn_sec_mode_t_enc); + SER_PUSH_FIELD(&p_struct->write_perm, ble_gap_conn_sec_mode_t_enc); + uint8_t ser_data = (p_struct->vlen & 0x01) + | ((p_struct->vloc & 0x03) << 1) + | ((p_struct->rd_auth & 0x01) << 3) + | ((p_struct->wr_auth & 0x01) << 4); + SER_PUSH_uint8(&ser_data); + + // Serializer does not support attributes on stack. + if (p_struct->vloc != BLE_GATTS_VLOC_STACK) + { + err_code = NRF_ERROR_INVALID_PARAM; + } + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_attr_md_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_attr_md_t); + + uint8_t ser_data; + SER_PULL_FIELD(&p_struct->read_perm, ble_gap_conn_sec_mode_t_dec); + SER_PULL_FIELD(&p_struct->write_perm, ble_gap_conn_sec_mode_t_dec); + SER_PULL_uint8(&ser_data); + + p_struct->vlen = ser_data & 0x01; + p_struct->vloc = (ser_data >> 1) & 0x03; + p_struct->rd_auth = (ser_data >> 3) & 0x01; + p_struct->wr_auth = (ser_data >> 4) & 0x01; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_char_md_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_char_md_t); + + SER_PUSH_FIELD(&p_struct->char_props, ble_gatt_char_props_t_enc); + SER_PUSH_FIELD(&p_struct->char_ext_props, ble_gatt_char_ext_props_t_enc); + SER_PUSH_uint16(&p_struct->char_user_desc_max_size); + SER_ERROR_CHECK(p_struct->char_user_desc_size <= BLE_GATTS_VAR_ATTR_LEN_MAX, + NRF_ERROR_INVALID_PARAM); + SER_PUSH_len16data(p_struct->p_char_user_desc, p_struct->char_user_desc_size); + SER_PUSH_COND(p_struct->p_char_pf, ble_gatts_char_pf_t_enc); + SER_PUSH_COND(p_struct->p_user_desc_md, ble_gatts_attr_md_t_enc); + SER_PUSH_COND(p_struct->p_cccd_md, ble_gatts_attr_md_t_enc); + SER_PUSH_COND(p_struct->p_sccd_md, ble_gatts_attr_md_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_char_md_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_char_md_t); + + SER_PULL_FIELD(&p_struct->char_props, ble_gatt_char_props_t_dec); + SER_PULL_FIELD(&p_struct->char_ext_props, ble_gatt_char_ext_props_t_dec); + SER_PULL_uint16(&p_struct->char_user_desc_max_size); +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + SER_PULL_len16data(&p_struct->p_char_user_desc, &p_struct->char_user_desc_size); +#else + SER_PULL_len16data((uint8_t * * )&p_struct->p_char_user_desc, &p_struct->char_user_desc_size); +#endif + SER_PULL_COND(&p_struct->p_char_pf, ble_gatts_char_pf_t_dec); + SER_PULL_COND(&p_struct->p_user_desc_md, ble_gatts_attr_md_t_dec); + SER_PULL_COND(&p_struct->p_cccd_md, ble_gatts_attr_md_t_dec); + SER_PULL_COND(&p_struct->p_sccd_md, ble_gatts_attr_md_t_dec); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_attr_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_attr_t); + + SER_PUSH_COND(p_struct->p_uuid, ble_uuid_t_enc); + SER_PUSH_COND(p_struct->p_attr_md, ble_gatts_attr_md_t_enc); + SER_PUSH_uint16(&p_struct->init_offs); + SER_PUSH_uint16(&p_struct->max_len); + SER_ERROR_CHECK(p_struct->init_len <= BLE_GATTS_VAR_ATTR_LEN_MAX, NRF_ERROR_INVALID_PARAM); + SER_PUSH_len16data(p_struct->p_value, p_struct->init_len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_attr_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_attr_t); + + SER_PULL_COND(&p_struct->p_uuid, ble_uuid_t_dec); + SER_PULL_COND(&p_struct->p_attr_md, ble_gatts_attr_md_t_dec); + SER_PULL_uint16(&p_struct->init_offs); + SER_PULL_uint16(&p_struct->max_len); + SER_PULL_len16data(&p_struct->p_value, &p_struct->init_len); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_char_handles_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_char_handles_t); + + SER_PUSH_uint16(&p_struct->value_handle); + SER_PUSH_uint16(&p_struct->user_desc_handle); + SER_PUSH_uint16(&p_struct->cccd_handle); + SER_PUSH_uint16(&p_struct->sccd_handle); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_char_handles_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_char_handles_t); + + SER_PULL_uint16(&p_struct->value_handle); + SER_PULL_uint16(&p_struct->user_desc_handle); + SER_PULL_uint16(&p_struct->cccd_handle); + SER_PULL_uint16(&p_struct->sccd_handle); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_hvx_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_hvx_params_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_uint8(&p_struct->type); + SER_PUSH_uint16(&p_struct->offset); + SER_PUSH_COND(p_struct->p_len, uint16_t_enc); + if (p_struct->p_len) + { + SER_PUSH_buf(p_struct->p_data, *p_struct->p_len); + } + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_hvx_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_hvx_params_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_uint8(&p_struct->type); + SER_PULL_uint16(&p_struct->offset); + SER_PULL_COND(&p_struct->p_len, uint16_t_dec); + if (p_struct->p_len) + { +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 + SER_PULL_buf(&p_struct->p_data, *p_struct->p_len, *p_struct->p_len); +#else + SER_PULL_buf((uint8_t**)&p_struct->p_data, *p_struct->p_len, *p_struct->p_len); +#endif + } + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_evt_write_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_evt_write_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_FIELD(&p_struct->uuid, ble_uuid_t_enc); + SER_PUSH_uint8(&p_struct->op); + SER_PUSH_uint8(&p_struct->auth_required); + SER_PUSH_uint16(&p_struct->offset); + SER_PUSH_uint16(&p_struct->len); + SER_PUSH_uint8array(p_struct->data, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_evt_write_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_evt_write_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_FIELD(&p_struct->uuid, ble_uuid_t_dec); + SER_PULL_uint8(&p_struct->op); + SER_PULL_uint8(&p_struct->auth_required); + SER_PULL_uint16(&p_struct->offset); + SER_PULL_uint16(&p_struct->len); + + // Data field is defined as 1-element array, so the first element + // is always allocated in the structure. + SER_ASSERT_LENGTH_LEQ(p_struct->len, *p_ext_len + 1); + SER_PULL_uint8array(p_struct->data, p_struct->len); + *p_ext_len = (p_struct->len > 1) ? p_struct->len - 1 : 0; + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_evt_read_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_evt_read_t); + + SER_PUSH_uint16(&p_struct->handle); + SER_PUSH_FIELD(&p_struct->uuid, ble_uuid_t_enc); + SER_PUSH_uint16(&p_struct->offset); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_evt_read_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_evt_read_t); + + SER_PULL_uint16(&p_struct->handle); + SER_PULL_FIELD(&p_struct->uuid, ble_uuid_t_dec); + SER_PULL_uint16(&p_struct->offset); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_evt_rw_authorize_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_evt_rw_authorize_request_t); + + SER_PUSH_uint8(&p_struct->type); + + switch (p_struct->type) + { + case BLE_GATTS_AUTHORIZE_TYPE_READ: + SER_PUSH_FIELD(&p_struct->request.read, ble_gatts_evt_read_t_enc); + break; + + case BLE_GATTS_AUTHORIZE_TYPE_WRITE: + SER_PUSH_FIELD(&p_struct->request.write, ble_gatts_evt_write_t_enc); + break; + + default: + case BLE_GATTS_AUTHORIZE_TYPE_INVALID: + err_code = NRF_ERROR_INVALID_PARAM; + break; + } + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_evt_rw_authorize_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_evt_rw_authorize_request_t); + + SER_PULL_uint8(&p_struct->type); + + switch (p_struct->type) + { + case BLE_GATTS_AUTHORIZE_TYPE_READ: + SER_PULL_FIELD(&p_struct->request.read, ble_gatts_evt_read_t_dec); + break; + + case BLE_GATTS_AUTHORIZE_TYPE_WRITE: + err_code = ble_gatts_evt_write_t_dec(p_buf, + buf_len, + p_index, + p_ext_len, + &p_struct->request.write); + SER_ASSERT(err_code == NRF_SUCCESS, err_code); + break; + + default: + case BLE_GATTS_AUTHORIZE_TYPE_INVALID: + return NRF_ERROR_INVALID_DATA; + } + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_authorize_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_authorize_params_t); + + uint8_t ser_data = p_struct->update & 0x01; + SER_PUSH_uint16(&p_struct->gatt_status); + SER_PUSH_uint8(&ser_data); + SER_PUSH_uint16(&p_struct->offset); + SER_PUSH_len16data(p_struct->p_data, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_authorize_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_authorize_params_t); + + uint8_t ser_data; + SER_PULL_uint16(&p_struct->gatt_status); + SER_PULL_uint8(&ser_data); + SER_PULL_uint16(&p_struct->offset); + SER_PULL_len16data((uint8_t **) &p_struct->p_data, &p_struct->len); + + p_struct->update = ser_data & 0x01; + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_rw_authorize_reply_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_rw_authorize_reply_params_t); + + SER_PUSH_uint8(&p_struct->type); + if (p_struct->type == BLE_GATTS_AUTHORIZE_TYPE_READ) + { + SER_PUSH_FIELD(&p_struct->params.read, ble_gatts_authorize_params_t_enc); + } + else if (p_struct->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) + { + SER_PUSH_FIELD(&p_struct->params.write, ble_gatts_authorize_params_t_enc); + } + else + { + return NRF_ERROR_INVALID_PARAM; + } + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_rw_authorize_reply_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_rw_authorize_reply_params_t); + + SER_PULL_uint8(&p_struct->type); + if (p_struct->type == BLE_GATTS_AUTHORIZE_TYPE_READ) + { + SER_PULL_FIELD(&p_struct->params.read, ble_gatts_authorize_params_t_dec); + } + else if (p_struct->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) + { + SER_PULL_FIELD(&p_struct->params.write, ble_gatts_authorize_params_t_dec); + } + else + { + return NRF_ERROR_INVALID_PARAM; + } + + SER_STRUCT_DEC_END; +} +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gatts_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_enable_params_t); + + uint8_t ser_data = p_struct->service_changed & 0x01; + SER_PUSH_uint8(&ser_data); + SER_PUSH_uint32(&p_struct->attr_tab_size); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_enable_params_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + SER_PULL_uint32(&p_struct->attr_tab_size); + + p_struct->service_changed = ser_data & 0x01; + + SER_STRUCT_DEC_END; +} +#endif + +uint32_t ble_gatts_value_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_value_t); + + SER_PUSH_uint16(&p_struct->offset); + SER_PUSH_len16data(p_struct->p_value, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_value_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_value_t); + + SER_PULL_uint16(&p_struct->offset); + SER_PULL_len16data(&p_struct->p_value, &p_struct->len); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_evt_exchange_mtu_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_evt_exchange_mtu_request_t); + SER_PUSH_uint16(&p_struct->client_rx_mtu); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_evt_exchange_mtu_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_evt_exchange_mtu_request_t); + SER_PULL_uint16(&p_struct->client_rx_mtu); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_evt_hvc_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_evt_hvc_t); + SER_PUSH_uint16(&p_struct->handle); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_evt_hvc_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_evt_hvc_t); + SER_PULL_uint16(&p_struct->handle); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_evt_sys_attr_missing_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_evt_sys_attr_missing_t); + SER_PUSH_uint8(&p_struct->hint); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_evt_sys_attr_missing_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_evt_sys_attr_missing_t); + SER_PULL_uint8(&p_struct->hint); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_evt_timeout_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_evt_timeout_t); + SER_PUSH_uint8(&p_struct->src); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_evt_timeout_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_evt_timeout_t); + SER_PULL_uint8(&p_struct->src); + SER_STRUCT_DEC_END; +} + +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_gatts_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_conn_cfg_t); + SER_PUSH_uint8(&p_struct->hvn_tx_queue_size); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_conn_cfg_t); + SER_PULL_uint8(&p_struct->hvn_tx_queue_size); + SER_STRUCT_DEC_END; +} + +uint32_t ble_gatts_cfg_service_changed_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_cfg_service_changed_t); + uint8_t service_changed = p_struct->service_changed; + SER_PUSH_uint8(&service_changed); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_cfg_service_changed_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_cfg_service_changed_t); + uint8_t service_changed; + SER_PULL_uint8(&service_changed); + p_struct->service_changed = service_changed; + SER_STRUCT_DEC_END; +} +uint32_t ble_gatts_cfg_attr_tab_size_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_gatts_cfg_attr_tab_size_t); + SER_PUSH_uint32(&p_struct->attr_tab_size); + SER_STRUCT_ENC_END; +} + +uint32_t ble_gatts_cfg_attr_tab_size_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_gatts_cfg_attr_tab_size_t); + SER_PULL_uint32(&p_struct->attr_tab_size); + SER_STRUCT_DEC_END; +} + + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatts_struct_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatts_struct_serialization.h new file mode 100644 index 000000000..97a00c653 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_gatts_struct_serialization.h @@ -0,0 +1,259 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_GATTS_STRUCT_SERIALIZATION_H +#define BLE_GATTS_STRUCT_SERIALIZATION_H + +#include "ble_gatts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t ble_gatts_char_pf_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_char_pf_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_attr_md_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_attr_md_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_char_md_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_char_md_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_attr_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_attr_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_char_handles_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_char_handles_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_evt_write_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_evt_write_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gatts_hvx_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_hvx_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_evt_read_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_evt_read_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_evt_rw_authorize_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_evt_rw_authorize_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); + +uint32_t ble_gatts_authorize_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_authorize_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_rw_authorize_reply_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_rw_authorize_reply_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_gatts_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif + +uint32_t ble_gatts_value_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_value_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_evt_exchange_mtu_request_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_evt_exchange_mtu_request_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_evt_hvc_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_evt_hvc_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_evt_sys_attr_missing_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_evt_sys_attr_missing_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_evt_timeout_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_evt_timeout_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_gatts_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_cfg_service_changed_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_cfg_service_changed_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_gatts_cfg_attr_tab_size_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_gatts_cfg_attr_tab_size_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#endif +#ifdef __cplusplus +} +#endif + +#endif /* BLE_GATTS_STRUCT_SERIALIZATION_H */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_l2cap_struct_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_l2cap_struct_serialization.c new file mode 100644 index 000000000..5ffb7a1c8 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_l2cap_struct_serialization.c @@ -0,0 +1,227 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_l2cap_struct_serialization.h" +#include "ble_struct_serialization.h" +#include "ble_serialization.h" +#include "app_util.h" +#include "cond_field_serialization.h" +#include + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_l2cap_header_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_l2cap_header_t); + + SER_PUSH_uint16(&p_struct->len); + SER_PUSH_uint16(&p_struct->cid); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_l2cap_header_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_l2cap_header_t); + + SER_PULL_uint16(&p_struct->len); + SER_PULL_uint16(&p_struct->cid); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_l2cap_evt_rx_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_l2cap_evt_rx_t); + + SER_PUSH_FIELD(&p_struct->header, ble_l2cap_header_t_enc); + SER_PUSH_uint8array(p_struct->data, p_struct->header.len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_l2cap_evt_rx_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_l2cap_evt_rx_t); + + SER_PULL_FIELD(&p_struct->header, ble_l2cap_header_t_dec); + + uint32_t data_len = (SUB1(p_struct->header.len)); + SER_ASSERT_LENGTH_LEQ(data_len, *p_ext_len); + + SER_PULL_uint8array(p_struct->data, p_struct->header.len); + + *p_ext_len = data_len; + SER_STRUCT_DEC_END; +} +#endif + +#if NRF_SD_BLE_API_VERSION >= 5 +uint32_t ble_l2cap_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_l2cap_conn_cfg_t); + + SER_PUSH_uint16(&p_struct->rx_mps); + SER_PUSH_uint16(&p_struct->tx_mps); + SER_PUSH_uint8(&p_struct->rx_queue_size); + SER_PUSH_uint8(&p_struct->tx_queue_size); + SER_PUSH_uint8(&p_struct->ch_count); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_l2cap_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_l2cap_conn_cfg_t); + + SER_PULL_uint16(&p_struct->rx_mps); + SER_PULL_uint16(&p_struct->tx_mps); + SER_PULL_uint8(&p_struct->rx_queue_size); + SER_PULL_uint8(&p_struct->tx_queue_size); + SER_PULL_uint8(&p_struct->ch_count); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_l2cap_ch_rx_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_l2cap_ch_rx_params_t); + + SER_PUSH_uint16(&p_struct->rx_mtu); + SER_PUSH_uint16(&p_struct->rx_mps); + SER_PUSH_uint16(&p_struct->sdu_buf.len); + SER_PUSH_uint32(&p_struct->sdu_buf.p_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_l2cap_ch_rx_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_l2cap_ch_rx_params_t); + + SER_PULL_uint16(&p_struct->rx_mtu); + SER_PULL_uint16(&p_struct->rx_mps); + SER_PULL_uint16(&p_struct->sdu_buf.len); + SER_PULL_uint32(&p_struct->sdu_buf.p_data); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_l2cap_ch_setup_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_l2cap_ch_setup_params_t); + + SER_PUSH_FIELD(&p_struct->rx_params, ble_l2cap_ch_rx_params_t_enc); + SER_PUSH_uint16(&p_struct->le_psm); + SER_PUSH_uint16(&p_struct->status); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_l2cap_ch_setup_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_l2cap_ch_setup_params_t); + + SER_PULL_FIELD(&p_struct->rx_params, ble_l2cap_ch_rx_params_t_dec); + SER_PULL_uint16(&p_struct->le_psm); + SER_PULL_uint16(&p_struct->status); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_l2cap_ch_tx_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_l2cap_ch_tx_params_t); + + SER_PUSH_uint16(&p_struct->tx_mtu); + SER_PUSH_uint16(&p_struct->peer_mps); + SER_PUSH_uint16(&p_struct->tx_mps); + SER_PUSH_uint16(&p_struct->credits); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_l2cap_ch_tx_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_l2cap_ch_tx_params_t); + + SER_PULL_uint16(&p_struct->tx_mtu); + SER_PULL_uint16(&p_struct->peer_mps); + SER_PULL_uint16(&p_struct->tx_mps); + SER_PULL_uint16(&p_struct->credits); + + SER_STRUCT_DEC_END; +} +#endif //NRF_SD_BLE_API_VERSION >= 5 diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_l2cap_struct_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_l2cap_struct_serialization.h new file mode 100644 index 000000000..294763bd3 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_l2cap_struct_serialization.h @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_L2CAP_STRUCT_SERIALIZATION_H +#define BLE_L2CAP_STRUCT_SERIALIZATION_H + +#ifndef S112 +#include "ble_l2cap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_l2cap_header_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_l2cap_header_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_l2cap_evt_rx_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_l2cap_evt_rx_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + uint32_t * const p_ext_len, + void * const p_void_struct); +#endif + +#if NRF_SD_BLE_API_VERSION >= 5 +uint32_t ble_l2cap_conn_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_l2cap_conn_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_l2cap_ch_rx_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_l2cap_ch_rx_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_l2cap_ch_setup_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_l2cap_ch_setup_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_l2cap_ch_tx_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_l2cap_ch_tx_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif +#endif +#ifdef __cplusplus +} +#endif + +#endif /*BLE_L2CAP_STRUCT_SERIALIZATION_H*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_struct_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_struct_serialization.c new file mode 100644 index 000000000..16f83dee5 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_struct_serialization.c @@ -0,0 +1,545 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ble_struct_serialization.h" +#include "ble_gap_struct_serialization.h" +#include "ble_gatt_struct_serialization.h" +#include "ble_gatts_struct_serialization.h" +#include "ble_serialization.h" +#include "app_util.h" +#include "ble_types.h" +#include "ble.h" +#include "cond_field_serialization.h" +#include "ser_config.h" +#include + +#if NRF_SD_BLE_API_VERSION > 5 +#ifdef UNIT_TEST +#include "conn_ble_gap_sec_keys.h" +#include "app_ble_gap_sec_keys.h" +bool serialization_connectivity_role = true; +#elif defined(SER_CONNECTIVITY) +#include "conn_ble_gap_sec_keys.h" +#else +#include "app_ble_gap_sec_keys.h" +#endif /* UNIT_TEST */ +#endif /* NRF_SD_BLE_API_VERSION > 5 */ + + +uint32_t ble_uuid_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_uuid_t); + + SER_PUSH_uint16(&p_struct->uuid); + SER_PUSH_uint8(&p_struct->type); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_uuid_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_uuid_t); + + SER_PULL_uint16(&p_struct->uuid); + SER_PULL_uint8(&p_struct->type); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_uuid128_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_uuid128_t); + SER_PUSH_uint8array(p_struct->uuid128, sizeof (p_struct->uuid128)); + SER_STRUCT_ENC_END; +} + +uint32_t ble_uuid128_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_uuid128_t); + SER_PULL_uint8array(p_struct->uuid128, sizeof (p_struct->uuid128)); + SER_STRUCT_DEC_END; +} + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_enable_params_t); + + SER_PUSH_FIELD(&p_struct->common_enable_params, ble_common_enable_params_t_enc); + SER_PUSH_FIELD(&p_struct->gap_enable_params, ble_gap_enable_params_t_enc); + SER_PUSH_FIELD(&p_struct->gatt_enable_params, ble_gatt_enable_params_t_enc); + SER_PUSH_FIELD(&p_struct->gatts_enable_params, ble_gatts_enable_params_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_enable_params_t); + + SER_PULL_FIELD(&p_struct->common_enable_params, ble_common_enable_params_t_dec); + SER_PULL_FIELD(&p_struct->gap_enable_params, ble_gap_enable_params_t_dec); + SER_PULL_FIELD(&p_struct->gatt_enable_params, ble_gatt_enable_params_t_dec); + SER_PULL_FIELD(&p_struct->gatts_enable_params, ble_gatts_enable_params_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_conn_bw_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_conn_bw_t); + + SER_PUSH_uint8(&p_struct->conn_bw_rx); + SER_PUSH_uint8(&p_struct->conn_bw_tx); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_conn_bw_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_conn_bw_t); + + SER_PULL_uint8(&p_struct->conn_bw_rx); + SER_PULL_uint8(&p_struct->conn_bw_tx); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_common_opt_conn_bw_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_common_opt_conn_bw_t); + + SER_PUSH_uint8(&p_struct->role); + SER_PUSH_FIELD(&p_struct->conn_bw, ble_conn_bw_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_common_opt_conn_bw_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_common_opt_conn_bw_t); + + SER_PULL_uint8(&p_struct->role); + SER_PULL_FIELD(&p_struct->conn_bw, ble_conn_bw_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_conn_bw_count_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_conn_bw_count_t); + + SER_PUSH_uint8(&p_struct->high_count); + SER_PUSH_uint8(&p_struct->mid_count); + SER_PUSH_uint8(&p_struct->low_count); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_conn_bw_count_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_conn_bw_count_t); + + SER_PULL_uint8(&p_struct->high_count); + SER_PULL_uint8(&p_struct->mid_count); + SER_PULL_uint8(&p_struct->low_count); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_conn_bw_counts_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_conn_bw_counts_t); + + SER_PUSH_FIELD(&p_struct->tx_counts, ble_conn_bw_count_t_enc); + SER_PUSH_FIELD(&p_struct->rx_counts, ble_conn_bw_count_t_enc); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_conn_bw_counts_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_conn_bw_counts_t); + + SER_PULL_FIELD(&p_struct->tx_counts, ble_conn_bw_count_t_dec); + SER_PULL_FIELD(&p_struct->rx_counts, ble_conn_bw_count_t_dec); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_common_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_common_enable_params_t); + + SER_PUSH_uint16(&p_struct->vs_uuid_count); + SER_PUSH_COND(p_struct->p_conn_bw_counts, ble_conn_bw_counts_t_enc); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_common_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_common_enable_params_t); + + SER_PULL_uint16(&p_struct->vs_uuid_count); + SER_PULL_COND(&p_struct->p_conn_bw_counts, ble_conn_bw_counts_t_dec); + + SER_STRUCT_DEC_END; +} +#endif +uint32_t ble_common_opt_pa_lna_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_common_opt_pa_lna_t); + + SER_PUSH_FIELD(&p_struct->pa_cfg, ble_pa_lna_cfg_t_enc); + SER_PUSH_FIELD(&p_struct->lna_cfg, ble_pa_lna_cfg_t_enc); + SER_PUSH_uint8(&p_struct->ppi_ch_id_set); + SER_PUSH_uint8(&p_struct->ppi_ch_id_clr); + SER_PUSH_uint8(&p_struct->gpiote_ch_id); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_common_opt_pa_lna_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_common_opt_pa_lna_t); + + SER_PULL_FIELD(&p_struct->pa_cfg, ble_pa_lna_cfg_t_dec); + SER_PULL_FIELD(&p_struct->lna_cfg, ble_pa_lna_cfg_t_dec); + SER_PULL_uint8(&p_struct->ppi_ch_id_set); + SER_PULL_uint8(&p_struct->ppi_ch_id_clr); + SER_PULL_uint8(&p_struct->gpiote_ch_id); + + SER_STRUCT_DEC_END; +} + + +uint32_t ble_pa_lna_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_pa_lna_cfg_t); + + uint8_t ser_data = (p_struct->enable & 0x01) + | ((p_struct->active_high & 0x01) << 1) + | ((p_struct->gpio_pin & 0x3F) << 2); + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_pa_lna_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_pa_lna_cfg_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->enable = ser_data & 0x01; + p_struct->active_high = (ser_data >> 1) & 0x01; + p_struct->gpio_pin = (ser_data >> 2) & 0x3F; + + SER_STRUCT_DEC_END; +} + + +uint32_t ble_user_mem_block_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_user_mem_block_t); + + SER_PUSH_uint16(&p_struct->len); + SER_PUSH_COND(p_struct->p_mem, NULL); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_user_mem_block_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_user_mem_block_t); + + SER_PULL_uint16(&p_struct->len); + SER_PULL_COND(&p_struct->p_mem, NULL); + + SER_STRUCT_DEC_END; +} + +uint32_t ble_version_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_version_t); + + SER_PUSH_uint8(&p_struct->version_number); + SER_PUSH_uint16(&p_struct->company_id); + SER_PUSH_uint16(&p_struct->subversion_number); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_version_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_version_t); + + SER_PULL_uint8(&p_struct->version_number); + SER_PULL_uint16(&p_struct->company_id); + SER_PULL_uint16(&p_struct->subversion_number); + + SER_STRUCT_DEC_END; +} +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4 +uint32_t ble_evt_data_length_changed_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_evt_data_length_changed_t); + + SER_PUSH_uint16(&p_struct->max_tx_octets); + SER_PUSH_uint16(&p_struct->max_tx_time); + SER_PUSH_uint16(&p_struct->max_rx_octets); + SER_PUSH_uint16(&p_struct->max_rx_time); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_evt_data_length_changed_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_evt_data_length_changed_t); + + SER_PULL_uint16(&p_struct->max_tx_octets); + SER_PULL_uint16(&p_struct->max_tx_time); + SER_PULL_uint16(&p_struct->max_rx_octets); + SER_PULL_uint16(&p_struct->max_rx_time); + + SER_STRUCT_DEC_END; +} +#endif +uint32_t ble_common_opt_conn_evt_ext_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_common_opt_conn_evt_ext_t); + + uint8_t ser_data = p_struct->enable & 0x01; + SER_PUSH_uint8(&ser_data); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_common_opt_conn_evt_ext_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_common_opt_conn_evt_ext_t); + + uint8_t ser_data; + SER_PULL_uint8(&ser_data); + p_struct->enable = ser_data & 0x01; + + SER_STRUCT_DEC_END; +} +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_common_cfg_vs_uuid_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_common_cfg_vs_uuid_t); + + SER_PUSH_uint8(&p_struct->vs_uuid_count); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_common_cfg_vs_uuid_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_common_cfg_vs_uuid_t); + + SER_PULL_uint8(&p_struct->vs_uuid_count); + + SER_STRUCT_DEC_END; +} + +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 4 +uint32_t ble_data_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(ble_data_t); + + int buf_id = 0; +#if NRF_SD_BLE_API_VERSION > 5 +#ifdef UNIT_TEST + if (serialization_connectivity_role) + { + buf_id = conn_ble_gap_ble_data_buf_free(p_struct->p_data); + } + else + { + buf_id = app_ble_gap_adv_buf_register(p_struct->p_data); + SER_ASSERT(buf_id >= 0, NRF_ERROR_NO_MEM); + } +#elif defined(SER_CONNECTIVITY) + buf_id = conn_ble_gap_ble_data_buf_free(p_struct->p_data); +#else + buf_id = app_ble_gap_adv_buf_register(p_struct->p_data); + SER_ASSERT(buf_id >= 0, NRF_ERROR_NO_MEM); +#endif +#endif /* NRF_SD_BLE_API_VERSION > 5 */ + SER_PUSH_uint32((uint32_t *)&buf_id); + SER_PUSH_len16data(p_struct->p_data, p_struct->len); + + SER_STRUCT_ENC_END; +} + +uint32_t ble_data_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(ble_data_t); + + uint32_t buf_id; + SER_PULL_uint32(&buf_id); + p_struct->len = SER_MAX_ADV_DATA; +#if NRF_SD_BLE_API_VERSION > 5 +#ifdef UNIT_TEST + if (serialization_connectivity_role) + { + if (buf_id && (p_struct->p_data == NULL)) + { + p_struct->p_data = conn_ble_gap_ble_data_buf_alloc(buf_id); + } + } + else + { + p_struct->p_data = app_ble_gap_adv_buf_unregister((int)buf_id, true); + } +#elif defined(SER_CONNECTIVITY) + if (buf_id && (p_struct->p_data == NULL)) + { + p_struct->p_data = conn_ble_gap_ble_data_buf_alloc(buf_id); + } +#else + p_struct->p_data = app_ble_gap_adv_buf_unregister(buf_id, true); +#endif +#endif /* NRF_SD_BLE_API_VERSION > 5*/ + SER_PULL_len16data(&p_struct->p_data, &p_struct->len); + + SER_STRUCT_DEC_END; +} +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_struct_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_struct_serialization.h new file mode 100644 index 000000000..10e78869a --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/ble_struct_serialization.h @@ -0,0 +1,217 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef BLE_STRUCT_SERIALIZATION_H__ +#define BLE_STRUCT_SERIALIZATION_H__ + +#include "ble_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +uint32_t ble_uuid_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_uuid_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_uuid128_t_enc(const void * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_uuid128_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_conn_bw_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_conn_bw_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_common_opt_conn_bw_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_common_opt_conn_bw_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_conn_bw_count_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_conn_bw_count_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_conn_bw_counts_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_conn_bw_counts_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_common_enable_params_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_common_enable_params_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_common_opt_pa_lna_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_common_opt_pa_lna_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_pa_lna_cfg_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_pa_lna_cfg_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_user_mem_block_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_user_mem_block_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_version_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_version_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_evt_data_length_changed_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_evt_data_length_changed_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t ble_common_opt_conn_evt_ext_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_common_opt_conn_evt_ext_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#if NRF_SD_BLE_API_VERSION >= 4 +uint32_t ble_common_cfg_vs_uuid_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_common_cfg_vs_uuid_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#endif + +#if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 4 +uint32_t ble_data_t_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t ble_data_t_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); +#endif +#ifdef __cplusplus +} +#endif + +#endif // BLE_STRUCT_SERIALIZATION_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/nrf_soc_struct_serialization.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/nrf_soc_struct_serialization.c new file mode 100644 index 000000000..3d97b1f37 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/nrf_soc_struct_serialization.c @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "nrf_soc_struct_serialization.h" +#include "ble_serialization.h" +#include "cond_field_serialization.h" +#include "app_util.h" +#include "string.h" + +uint32_t nrf_ecb_hal_data_t_in_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(nrf_ecb_hal_data_t); + + SER_PUSH_uint8array(p_struct->key, SOC_ECB_KEY_LENGTH); + SER_PUSH_uint8array(p_struct->cleartext, SOC_ECB_CLEARTEXT_LENGTH); + + SER_STRUCT_DEC_END; +} + +uint32_t nrf_ecb_hal_data_t_in_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(nrf_ecb_hal_data_t); + + SER_PULL_uint8array(p_struct->key, SOC_ECB_KEY_LENGTH); + SER_PULL_uint8array(p_struct->cleartext, SOC_ECB_CLEARTEXT_LENGTH); + + SER_STRUCT_DEC_END; +} + +uint32_t nrf_ecb_hal_data_t_out_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index) +{ + SER_STRUCT_ENC_BEGIN(nrf_ecb_hal_data_t); + SER_PUSH_uint8array(p_struct->ciphertext, SOC_ECB_CIPHERTEXT_LENGTH); + SER_STRUCT_DEC_END; +} + +uint32_t nrf_ecb_hal_data_t_out_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct) +{ + SER_STRUCT_DEC_BEGIN(nrf_ecb_hal_data_t); + SER_PULL_uint8array(p_struct->ciphertext, SOC_ECB_CIPHERTEXT_LENGTH); + SER_STRUCT_DEC_END; +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/nrf_soc_struct_serialization.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/nrf_soc_struct_serialization.h new file mode 100644 index 000000000..d8a884601 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/struct_ser/ble/nrf_soc_struct_serialization.h @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef NRF_SOC_STRUCT_SERIALIZATION_H__ +#define NRF_SOC_STRUCT_SERIALIZATION_H__ + +#include "nrf_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t nrf_ecb_hal_data_t_in_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t nrf_ecb_hal_data_t_in_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +uint32_t nrf_ecb_hal_data_t_out_enc(void const * const p_void_struct, + uint8_t * const p_buf, + uint32_t buf_len, + uint32_t * const p_index); + +uint32_t nrf_ecb_hal_data_t_out_dec(uint8_t const * const p_buf, + uint32_t buf_len, + uint32_t * const p_index, + void * const p_void_struct); + +#ifdef __cplusplus +} +#endif + +#endif // NRF_SOC_STRUCT_SERIALIZATION_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c new file mode 100644 index 000000000..03701c67e --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c @@ -0,0 +1,514 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include +#include +#include "app_error.h" +#include "sdk_config.h" +#include "ser_config.h" +#include "ser_phy.h" +#include "ser_hal_transport.h" +#if defined(APP_SCHEDULER_WITH_PAUSE) && APP_SCHEDULER_WITH_PAUSE +#include "app_scheduler.h" +#endif +#define NRF_LOG_MODULE_NAME ser_hal_transport +#if SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL + #define NRF_LOG_INFO_COLOR SER_HAL_TRANSPORT_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#else //SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL 0 +#endif //SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + +/** + * @brief States of the RX state machine. + */ +typedef enum +{ + HAL_TRANSP_RX_STATE_CLOSED = 0, + HAL_TRANSP_RX_STATE_IDLE, + HAL_TRANSP_RX_STATE_RECEIVING, + HAL_TRANSP_RX_STATE_DROPPING, + HAL_TRANSP_RX_STATE_RECEIVED, + HAL_TRANSP_RX_STATE_RECEIVED_PENDING_BUF_REQ, + HAL_TRANSP_RX_STATE_RECEIVED_DROPPING, + HAL_TRANSP_RX_STATE_MAX +}ser_hal_transp_rx_states_t; + +/** + * @brief States of the TX state machine. + */ +typedef enum +{ + HAL_TRANSP_TX_STATE_CLOSED = 0, + HAL_TRANSP_TX_STATE_IDLE, + HAL_TRANSP_TX_STATE_TX_ALLOCATED, + HAL_TRANSP_TX_STATE_TRANSMITTING, + HAL_TRANSP_TX_STATE_TRANSMITTED, + HAL_TRANSP_TX_STATE_MAX +}ser_hal_transp_tx_states_t; + +/** + * @brief RX state. + */ +static ser_hal_transp_rx_states_t m_rx_state = HAL_TRANSP_RX_STATE_CLOSED; +/** + * @brief TX state. + */ +static ser_hal_transp_tx_states_t m_tx_state = HAL_TRANSP_TX_STATE_CLOSED; + +/** + * @brief Transmission buffer. + */ +static uint8_t m_tx_buffer[SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE]; +/** + * @brief Reception buffer. + */ +static uint8_t m_rx_buffer[SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE]; + +/** + * @brief Callback function handler for Serialization HAL Transport layer events. + */ +static ser_hal_transport_events_handler_t m_events_handler = NULL; + + +/** + * @brief A callback function to be used to handle a PHY module events. This function is called in + * an interrupt context. + */ +static void phy_events_handler(ser_phy_evt_t phy_event) +{ + uint32_t err_code = 0; + ser_hal_transport_evt_t hal_transp_event; + + memset(&hal_transp_event, 0, sizeof (ser_hal_transport_evt_t)); + hal_transp_event.evt_type = SER_HAL_TRANSP_EVT_TYPE_MAX; + + NRF_LOG_INFO("phy evt:%d", phy_event.evt_type); + switch (phy_event.evt_type) + { + case SER_PHY_EVT_TX_PKT_SENT: + { + if (HAL_TRANSP_TX_STATE_TRANSMITTING == m_tx_state) + { + m_tx_state = HAL_TRANSP_TX_STATE_TRANSMITTED; + NRF_LOG_INFO("tx free"); + err_code = ser_hal_transport_tx_pkt_free(m_tx_buffer); + APP_ERROR_CHECK(err_code); + /* An event to an upper layer that a packet has been transmitted. */ + hal_transp_event.evt_type = SER_HAL_TRANSP_EVT_TX_PKT_SENT; + m_events_handler(hal_transp_event); + } + else + { + /* Lower layer should not generate this event in current state. */ + APP_ERROR_CHECK_BOOL(false); + } + break; + } + + case SER_PHY_EVT_RX_BUF_REQUEST: + { + /* An event to an upper layer that a packet is being scheduled to receive or to drop. */ + hal_transp_event.evt_type = SER_HAL_TRANSP_EVT_RX_PKT_RECEIVING; + + /* Receive or drop a packet. */ + if (phy_event.evt_params.rx_buf_request.num_of_bytes <= sizeof (m_rx_buffer)) + { + if (HAL_TRANSP_RX_STATE_IDLE == m_rx_state) + { + m_events_handler(hal_transp_event); + err_code = ser_phy_rx_buf_set(m_rx_buffer); + APP_ERROR_CHECK(err_code); + m_rx_state = HAL_TRANSP_RX_STATE_RECEIVING; + } + else if (HAL_TRANSP_RX_STATE_RECEIVED == m_rx_state) + { + /* It is OK to get know higher layer at this point that we are going to receive + * a new packet even though we will start receiving when rx buffer is freed. */ + m_events_handler(hal_transp_event); + m_rx_state = HAL_TRANSP_RX_STATE_RECEIVED_PENDING_BUF_REQ; + } + else + { + /* Lower layer should not generate this event in current state. */ + APP_ERROR_CHECK_BOOL(false); + } + } + else + { + /* There is not enough memory but packet has to be received to dummy location. */ + if (HAL_TRANSP_RX_STATE_IDLE == m_rx_state) + { + m_events_handler(hal_transp_event); + err_code = ser_phy_rx_buf_set(NULL); + APP_ERROR_CHECK(err_code); + m_rx_state = HAL_TRANSP_RX_STATE_DROPPING; + } + else if (HAL_TRANSP_RX_STATE_RECEIVED == m_rx_state) + { + m_events_handler(hal_transp_event); + err_code = ser_phy_rx_buf_set(NULL); + APP_ERROR_CHECK(err_code); + m_rx_state = HAL_TRANSP_RX_STATE_RECEIVED_DROPPING; + } + else + { + /* Lower layer should not generate this event in current state. */ + APP_ERROR_CHECK_BOOL(false); + } + } + break; + } + + case SER_PHY_EVT_RX_PKT_RECEIVED: + { + if (HAL_TRANSP_RX_STATE_RECEIVING == m_rx_state) + { + m_rx_state = HAL_TRANSP_RX_STATE_RECEIVED; + /* Generate the event to an upper layer. */ + hal_transp_event.evt_type = + SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED; + hal_transp_event.evt_params.rx_pkt_received.p_buffer = + phy_event.evt_params.rx_pkt_received.p_buffer; + hal_transp_event.evt_params.rx_pkt_received.num_of_bytes = + phy_event.evt_params.rx_pkt_received.num_of_bytes; + m_events_handler(hal_transp_event); + } + else + { + /* Lower layer should not generate this event in current state. */ + APP_ERROR_CHECK_BOOL(false); + } + break; + } + + case SER_PHY_EVT_RX_PKT_DROPPED: + { + if (HAL_TRANSP_RX_STATE_DROPPING == m_rx_state) + { + /* Generate the event to an upper layer. */ + hal_transp_event.evt_type = SER_HAL_TRANSP_EVT_RX_PKT_DROPPED; + m_events_handler(hal_transp_event); + m_rx_state = HAL_TRANSP_RX_STATE_IDLE; + } + else if (HAL_TRANSP_RX_STATE_RECEIVED_DROPPING == m_rx_state) + { + /* Generate the event to an upper layer. */ + hal_transp_event.evt_type = SER_HAL_TRANSP_EVT_RX_PKT_DROPPED; + m_events_handler(hal_transp_event); + m_rx_state = HAL_TRANSP_RX_STATE_RECEIVED; + } + else + { + /* Lower layer should not generate this event in current state. */ + APP_ERROR_CHECK_BOOL(false); + } + break; + } + + case SER_PHY_EVT_RX_OVERFLOW_ERROR: + { + /* Generate the event to an upper layer. */ + hal_transp_event.evt_type = SER_HAL_TRANSP_EVT_PHY_ERROR; + hal_transp_event.evt_params.phy_error.error_type = + SER_HAL_TRANSP_PHY_ERROR_RX_OVERFLOW; + m_events_handler(hal_transp_event); + break; + } + + case SER_PHY_EVT_TX_OVERREAD_ERROR: + { + /* Generate the event to an upper layer. */ + hal_transp_event.evt_type = SER_HAL_TRANSP_EVT_PHY_ERROR; + hal_transp_event.evt_params.phy_error.error_type = + SER_HAL_TRANSP_PHY_ERROR_TX_OVERREAD; + m_events_handler(hal_transp_event); + break; + } + + case SER_PHY_EVT_HW_ERROR: + { + /* Generate the event to an upper layer. */ + hal_transp_event.evt_type = SER_HAL_TRANSP_EVT_PHY_ERROR; + hal_transp_event.evt_params.phy_error.error_type = + SER_HAL_TRANSP_PHY_ERROR_HW_ERROR; + hal_transp_event.evt_params.phy_error.hw_error_code = + phy_event.evt_params.hw_error.error_code; + if (HAL_TRANSP_TX_STATE_TRANSMITTING == m_tx_state) + { + m_tx_state = HAL_TRANSP_TX_STATE_TRANSMITTED; + err_code = ser_hal_transport_tx_pkt_free(phy_event.evt_params.hw_error.p_buffer); + APP_ERROR_CHECK(err_code); +#if defined(APP_SCHEDULER_WITH_PAUSE) && APP_SCHEDULER_WITH_PAUSE + app_sched_resume(); +#endif + /* An event to an upper layer that a packet has been transmitted. */ + } + else if (HAL_TRANSP_RX_STATE_RECEIVING == m_rx_state) + { + m_rx_state = HAL_TRANSP_RX_STATE_RECEIVED; + err_code = ser_hal_transport_rx_pkt_free(phy_event.evt_params.hw_error.p_buffer); + APP_ERROR_CHECK(err_code); + } + m_events_handler(hal_transp_event); + + break; + } + + default: + { + APP_ERROR_CHECK_BOOL(false); + break; + } + } +} + +void ser_hal_transport_reset(void) +{ + m_rx_state = HAL_TRANSP_RX_STATE_IDLE; + m_tx_state = HAL_TRANSP_TX_STATE_IDLE; +} + +uint32_t ser_hal_transport_open(ser_hal_transport_events_handler_t events_handler) +{ + uint32_t err_code = NRF_SUCCESS; + + if ((HAL_TRANSP_RX_STATE_CLOSED != m_rx_state) || (HAL_TRANSP_TX_STATE_CLOSED != m_tx_state)) + { + err_code = NRF_ERROR_INVALID_STATE; + } + else if (NULL == events_handler) + { + err_code = NRF_ERROR_NULL; + } + else + { + /* We have to change states before calling lower layer because ser_phy_open() function is + * going to enable interrupts. On success an event from PHY layer can be emitted immediately + * after return from ser_phy_open(). */ + m_rx_state = HAL_TRANSP_RX_STATE_IDLE; + m_tx_state = HAL_TRANSP_TX_STATE_IDLE; + + m_events_handler = events_handler; + + /* Initialize a PHY module. */ + err_code = ser_phy_open(phy_events_handler); + + if (NRF_SUCCESS != err_code) + { + m_rx_state = HAL_TRANSP_RX_STATE_CLOSED; + m_tx_state = HAL_TRANSP_TX_STATE_CLOSED; + m_events_handler = NULL; + + if (NRF_ERROR_INVALID_PARAM != err_code) + { + err_code = NRF_ERROR_INTERNAL; + } + } + } + + return err_code; +} + + +void ser_hal_transport_close(void) +{ + /* Reset generic handler for all events, reset internal states and close PHY module. */ + ser_phy_interrupts_disable(); + m_rx_state = HAL_TRANSP_RX_STATE_CLOSED; + m_tx_state = HAL_TRANSP_TX_STATE_CLOSED; + + m_events_handler = NULL; + + ser_phy_close(); +} + + +uint32_t ser_hal_transport_rx_pkt_free(uint8_t * p_buffer) +{ + + NRF_LOG_INFO("rx pkt free:%d", p_buffer); + uint32_t err_code = NRF_SUCCESS; + + ser_phy_interrupts_disable(); + + if (NULL == p_buffer) + { + err_code = NRF_ERROR_NULL; + } + else if (p_buffer != m_rx_buffer) + { + err_code = NRF_ERROR_INVALID_ADDR; + } + else if (HAL_TRANSP_RX_STATE_RECEIVED == m_rx_state) + { + m_rx_state = HAL_TRANSP_RX_STATE_IDLE; + } + else if (HAL_TRANSP_RX_STATE_RECEIVED_DROPPING == m_rx_state) + { + m_rx_state = HAL_TRANSP_RX_STATE_DROPPING; + } + else if (HAL_TRANSP_RX_STATE_RECEIVED_PENDING_BUF_REQ == m_rx_state) + { + err_code = ser_phy_rx_buf_set(m_rx_buffer); + + if (NRF_SUCCESS == err_code) + { + m_rx_state = HAL_TRANSP_RX_STATE_RECEIVING; + } + else + { + err_code = NRF_ERROR_INTERNAL; + } + } + else + { + /* Upper layer should not call this function in current state. */ + err_code = NRF_ERROR_INVALID_STATE; + } + ser_phy_interrupts_enable(); + + return err_code; +} + + +uint32_t ser_hal_transport_tx_pkt_alloc(uint8_t * * pp_memory, uint16_t * p_num_of_bytes) +{ + uint32_t err_code = NRF_SUCCESS; + + if ((NULL == pp_memory) || (NULL == p_num_of_bytes)) + { + err_code = NRF_ERROR_NULL; + } + else if (HAL_TRANSP_TX_STATE_CLOSED == m_tx_state) + { + err_code = NRF_ERROR_INVALID_STATE; + } + else if (HAL_TRANSP_TX_STATE_IDLE == m_tx_state) + { + m_tx_state = HAL_TRANSP_TX_STATE_TX_ALLOCATED; + *pp_memory = &m_tx_buffer[0]; + *p_num_of_bytes = (uint16_t)sizeof (m_tx_buffer); + } + else + { + err_code = NRF_ERROR_NO_MEM; + } + + return err_code; +} + + +uint32_t ser_hal_transport_tx_pkt_send(const uint8_t * p_buffer, uint16_t num_of_bytes) +{ + uint32_t err_code = NRF_SUCCESS; + + /* The buffer provided to this function must be allocated through ser_hal_transport_tx_alloc() + * function - this assures correct state and that correct memory buffer is used. */ + if (NULL == p_buffer) + { + err_code = NRF_ERROR_NULL; + } + else if (0 == num_of_bytes) + { + err_code = NRF_ERROR_INVALID_PARAM; + } + else if (p_buffer != m_tx_buffer) + { + err_code = NRF_ERROR_INVALID_ADDR; + } + else if (num_of_bytes > sizeof (m_tx_buffer)) + { + err_code = NRF_ERROR_DATA_SIZE; + } + else if (HAL_TRANSP_TX_STATE_TX_ALLOCATED == m_tx_state) + { + ser_phy_interrupts_disable(); + err_code = ser_phy_tx_pkt_send(p_buffer, num_of_bytes); + + if (NRF_SUCCESS == err_code) + { + m_tx_state = HAL_TRANSP_TX_STATE_TRANSMITTING; + } + else + { + if (NRF_ERROR_BUSY != err_code) + { + err_code = NRF_ERROR_INTERNAL; + } + } + ser_phy_interrupts_enable(); + } + else + { + err_code = NRF_ERROR_INVALID_STATE; + } + + return err_code; +} + + +uint32_t ser_hal_transport_tx_pkt_free(uint8_t * p_buffer) +{ + uint32_t err_code = NRF_SUCCESS; + + if (NULL == p_buffer) + { + err_code = NRF_ERROR_NULL; + } + else if (p_buffer != m_tx_buffer) + { + err_code = NRF_ERROR_INVALID_ADDR; + } + else if ((HAL_TRANSP_TX_STATE_TX_ALLOCATED == m_tx_state) || + (HAL_TRANSP_TX_STATE_TRANSMITTED == m_tx_state)) + { + /* Release TX buffer for use. */ + m_tx_state = HAL_TRANSP_TX_STATE_IDLE; + } + else + { + err_code = NRF_ERROR_INVALID_STATE; + } + + return err_code; +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.h new file mode 100644 index 000000000..eaade38f2 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.h @@ -0,0 +1,268 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** @file + * + * @defgroup ser_hal_transport Serialization HAL Transport + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief HAL Transport layer for serialization. + * + * @details The @ref ser_hal_transport declares functions and typedefs used as API of the HAL + * transport layer for serialization. This layer is fully hardware-independent. + * Currently, the HAL transport layer is responsible for controlling the PHY layer and + * memory management. In the future, more features might be added to it, such as CRC + * or retransmission. + * + * \n \n + * \image html ser_hal_transport_rx_state_machine.svg "RX state machine" + * \n \n + * \image html ser_hal_transport_tx_state_machine.svg "TX state machine" + * \n + */ + +#ifndef SER_HAL_TRANSPORT_H__ +#define SER_HAL_TRANSPORT_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/**@brief Serialization HAL Transport layer event types. */ +typedef enum +{ + SER_HAL_TRANSP_EVT_TX_PKT_SENT = 0, /**< An event indicating that TX packet has been + transmitted. */ + SER_HAL_TRANSP_EVT_RX_PKT_RECEIVING, /**< An event indicating that RX packet is being + scheduled to receive or to drop. */ + SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED, /**< An event indicating that RX packet is ready for + read. */ + SER_HAL_TRANSP_EVT_RX_PKT_DROPPED, /**< An event indicating that RX packet was dropped + because it was longer than available buffer. */ + SER_HAL_TRANSP_EVT_PHY_ERROR, /**< An event indicating error on PHY layer. */ + SER_HAL_TRANSP_EVT_TYPE_MAX /**< Enumeration upper bound. */ +} ser_hal_transport_evt_type_t; + + +/**@brief Serialization PHY layer error types. */ +typedef enum +{ + SER_HAL_TRANSP_PHY_ERROR_RX_OVERFLOW = 0, /**< An error indicating that more information has + been transmitted than the PHY module could handle. */ + SER_HAL_TRANSP_PHY_ERROR_TX_OVERREAD, /**< An error indicating that the PHY module was forced to + transmit more information than possessed. */ + SER_HAL_TRANSP_PHY_ERROR_HW_ERROR, /**< An error indicating a hardware error in the PHY + module. */ + SER_HAL_TRANSP_PHY_ERROR_TYPE_MAX /**< Enumeration upper bound. */ +} ser_hal_transport_phy_error_type_t; + + +/**@brief Struct containing parameters of event of type + * @ref SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED. + */ +typedef struct +{ + uint8_t * p_buffer; /**< Pointer to a buffer containing a packet to read. */ + uint16_t num_of_bytes; /**< Length of a received packet in octets. */ +} ser_hal_transport_evt_rx_pkt_received_params_t; + + +/**@brief Struct containing parameters of event of type @ref SER_HAL_TRANSP_EVT_PHY_ERROR. */ +typedef struct +{ + ser_hal_transport_phy_error_type_t error_type; /**< Type of the PHY error. */ + uint32_t hw_error_code; /**< Hardware error code - specific for a microcontroller. Parameter + is valid only for the PHY error of type + @ref SER_HAL_TRANSP_PHY_ERROR_HW_ERROR. */ +} ser_hal_transport_evt_phy_error_params_t; + + +/**@brief Struct containing events from the Serialization HAL Transport layer. + * + * @note Some events do not have parameters, then the whole information is contained in the evt_type. + */ +typedef struct +{ + ser_hal_transport_evt_type_t evt_type; /**< Type of event. */ + union /**< Union alternative identified by evt_type in the enclosing struct. */ + { + ser_hal_transport_evt_rx_pkt_received_params_t rx_pkt_received; /**< Parameters of event of type @ref SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED. */ + ser_hal_transport_evt_phy_error_params_t phy_error; /**< Parameters of event of type @ref SER_HAL_TRANSP_EVT_PHY_ERROR. */ + } evt_params; +} ser_hal_transport_evt_t; + + +/**@brief Generic callback function type to be used by all Serialization HAL Transport layer + * events. + * + * @param[in] event Serialization HAL Transport layer event. + */ +typedef void (*ser_hal_transport_events_handler_t)(ser_hal_transport_evt_t event); + + +/**@brief Function for opening and initializing the Serialization HAL Transport layer. + * + * @note The function opens the transport channel, initializes a PHY layer, and registers the callback + * function to be used by all Serialization HAL Transport layer events. + * + * @warning If the function has been already called, the function @ref ser_hal_transport_close has + * to be called before ser_hal_transport_open can be called again. + * + * @param[in] events_handler Generic callback function to be used by all Serialization HAL + * Transport layer events. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_PARAM Operation failure. Hardware initialization parameters taken from + * the configuration file are wrong. + * @retval NRF_ERROR_INVALID_STATE Operation failure. The function has been already called. To call + * it again the function @ref ser_hal_transport_close has to be + * called first. + * @retval NRF_ERROR_INTERNAL Operation failure. Internal error ocurred. + */ +uint32_t ser_hal_transport_open(ser_hal_transport_events_handler_t events_handler); + +/**@brief Function for reseting ser_hal_transport. */ +void ser_hal_transport_reset(void); + +/**@brief Function for closing a transport channel. + * + * @note The function disables the hardware, resets internal module states, and unregisters the events + * callback function. Can be called multiple times, also for a channel that is not opened. + */ +void ser_hal_transport_close(void); + + +/**@brief Function for freeing memory allocated for an RX packet. + * + * @note The function should be called as a response to an event of type + * @ref SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED when the received data has beed processed. The function + * frees the RX memory pointed by p_buffer. The memory, immediately or at a later time, is + * reused by the underlying transport layer. + * + * @param[in] p_buffer A pointer to the beginning of the buffer that has been processed (has to be + * the same address as provided in the event of type + * @ref SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED). + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer (provided address is not + * the starting address of a buffer managed by HAL Transport layer). + * @retval NRF_ERROR_INVALID_STATE Operation failure. The function should be called as a response + * to an event of type @ref SER_HAL_TRANSP_EVT_RX_PKT_RECEIVED. + * @retval NRF_ERROR_INTERNAL Operation failure. Internal error ocurred. + */ +uint32_t ser_hal_transport_rx_pkt_free(uint8_t * p_buffer); + + +/**@brief Function for allocating memory for a TX packet. + * + * @param[out] pp_memory A pointer to pointer to which an address of the beginning of the + * allocated buffer is written. + * @param[out] p_num_of_bytes A pointer to a variable to which size in octets of the allocated + * buffer is written. + * + * @retval NRF_SUCCESS Operation success. Memory was allocated. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_NO_MEM Operation failure. No memory available. + * @retval NRF_ERROR_INVALID_STATE Operation failure. The function was called before calling + * @ref ser_hal_transport_open function. + */ +uint32_t ser_hal_transport_tx_pkt_alloc(uint8_t ** pp_memory, uint16_t * p_num_of_bytes); + +/**@brief Function for transmitting a packet. + * + * @note The function adds a packet pointed by the p_buffer parameter to a transmission queue. A buffer + * provided to this function must be allocated by the @ref ser_hal_transport_tx_pkt_alloc function. + * + * @warning Completion of this method does not guarantee that actual peripheral transmission will be completed. + * + * @param[in] p_buffer Pointer to the buffer to transmit. + * @param[in] num_of_bytes Number of octets to transmit. Must be more than 0. + * + * @retval NRF_SUCCESS Operation success. Packet was added to the transmission queue. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_PARAM Operation failure. num_of_bytes is equal to 0. + * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer (provided address is not + * the starting address of a buffer managed by HAL Transport layer). + * @retval NRF_ERROR_DATA_SIZE Operation failure. Packet size exceeds limit. + * @retval NRF_ERROR_BUSY Operation failure. Transmission queue is full so packet was not + * added to the transmission queue. + * @retval NRF_ERROR_INVALID_STATE Operation failure. Transmittion channel was not opened by + * @ref ser_hal_transport_open function or provided buffer was not + * allocated by @ref ser_hal_transport_tx_pkt_alloc function. + * @retval NRF_ERROR_INTERNAL Operation failure. Internal error ocurred. + */ +uint32_t ser_hal_transport_tx_pkt_send(const uint8_t * p_buffer, uint16_t num_of_bytes); + + +/**@brief Function for freeing memory allocated for a TX packet. + * + * @note The function frees the TX memory pointed by p_buffer. Freeing a TX buffer is possible only if + * the buffer was allocated by @ref ser_hal_transport_tx_pkt_alloc function and transmittion + * is not in progress. When transmittion has finished, this function is automatically called by + * the Serialization HAL Transport layer, so the only case when this function should be used + * from outside is when a TX buffer was allocated but a transmittion has not been started + * (@ref ser_hal_transport_tx_pkt_send function has not been called). + * + * @param[in] p_buffer Pointer to the beginning of a buffer that has been allocated by + * @ref ser_hal_transport_tx_pkt_alloc function. + * + * @retval NRF_SUCCESS Operation success. Memory was freed. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer (provided address is not + * the starting address of a buffer managed by HAL Transport layer). + * @retval NRF_ERROR_INVALID_STATE Operation failure. Freeing a TX buffer is possible only if the + * buffer was allocated by @ref ser_hal_transport_tx_pkt_alloc + * function and transmittion is not in progress. + */ +uint32_t ser_hal_transport_tx_pkt_free(uint8_t * p_buffer); + + + +#ifdef __cplusplus +} +#endif + +#endif /* SER_HAL_TRANSPORT_H__ */ +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy.h new file mode 100644 index 000000000..3e4522c7d --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy.h @@ -0,0 +1,308 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/** @file + * + * @defgroup ser_phy Serialization PHY + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief PHY layer for serialization. + * + * @details The @ref ser_phy library declares functions and definitions of data structures and + * identifiers (typedef enum) that are used as API of the serialization PHY layer. + * + * \par Rationale + * Each specific PHY layer (SPI, I2C, UART, low power UART etc.) should provide the same API. This + * allows the layer above (the HAL Transport layer), which is responsible for controlling the PHY + * layer, memory management, CRC, retransmission etc., to be hardware independent. + * + * + * \par Interlayer communication and control + * The PHY layer is controlled by the HAL transport layer by calling functions declared in + * the @ref ser_phy library. + * + * @par + * The PHY layer communicates events to the HAL transport layer by calling a callback function. + * A handler to this function is passed in the @ref ser_phy_open function. This callback function + * should be called with a parameter of type @ref ser_phy_evt_t, filled accordingly to an event to be + * passed. Types of supported events are defined in @ref ser_phy_evt_type_t. + * + * @par + * For example, to pass an event indicating that an RX packet has been successfully received, first a + * struct of type @ref ser_phy_evt_t must be filled: + * @code + * ser_phy_evt_t phy_evt; + * phy_evt.evt_type = SER_PHY_EVT_RX_PKT_RECEIVED; + * phy_evt.evt_params.rx_pkt_received.p_buffer = (pointer to the RX buffer); + * phy_evt.evt_params.rx_pkt_received.num_of_bytes = (number of received bytes); + * @endcode + * Then, the callback function must be called: + * @code + * events_handler(phy_evt); + * @endcode + * All functions declared in the @ref ser_phy file (ser_phy.h) must be implemented. Some events specified in + * @ref ser_phy_evt_type_t are optional to implement. + * + * \par Transmitting a packet + * Each PHY layer is responsible for adding the PHY header to a packet to be sent. This header + * consists of a 16-bit field that carries the packet length (the uint16_encode function defined in + * app_util.h should be used to ensure endianness independence). A pointer to a packet to be sent + * and length of the packet are parameters of the @ref ser_phy_tx_pkt_send function. When a packet + * has been transmitted, an event of type @ref SER_PHY_EVT_TX_PKT_SENT should be emitted. + * + * \image html ser_phy_transport_tx.svg "TX - interlayer communication" + * + * \par Receiving a packet + * The PHY layer should be able to store only the PHY header (16-bit field carrying the packet + * length). After the PHY header has been received, the transmission is stopped and the PHY + * layer must send a request to the HAL transport layer for memory to store the packet - an event + * of type @ref SER_PHY_EVT_RX_BUF_REQUEST with event parameters defined in + * @ref ser_phy_evt_rx_buf_request_params_t (the uint16_decode function defined in app_util.h should + * be used for header decoding to ensure endianness independence). The transmission should be + * resumed when the @ref ser_phy_rx_buf_set function has been called. + * + * @par + * When the @ref ser_phy_rx_buf_set function parameter equals NULL, there is not + * enough memory to store the packet. However, the packet will be received to a dummy location to + * ensure continuous communication. After receiving has finished, an event of type + * @ref SER_PHY_EVT_RX_PKT_DROPPED is generated. + * + * \image html ser_phy_transport_rx_dropped.svg "RX dropping - interlayer communication" + * + * @par + * When the @ref ser_phy_rx_buf_set function parameter is different than NULL, the packet is + * received to a buffer pointed to by it. After receiving has finished, an event of type + * @ref SER_PHY_EVT_RX_PKT_RECEIVED is generated with event parameters defined in + * @ref ser_phy_evt_rx_pkt_received_params_t. + * + * \image html ser_phy_transport_rx_received.svg "RX - interlayer communication" + * + * \par PHY layer errors + * PHY layer errors can be signaled by an event of type @ref SER_PHY_EVT_RX_OVERFLOW_ERROR or + * @ref SER_PHY_EVT_TX_OVERREAD_ERROR or @ref SER_PHY_EVT_HW_ERROR with event parameters defined in + * @ref ser_phy_evt_hw_error_params_t. + * + * @par Available PHY layers + * The following PHY layers are available: + * - @ref ser_phy_spi_page + * - @ref ser_phy_spi_5W_page + * - @ref ser_phy_uart_page + * - @ref ser_phy_uart_hci_page + * + * + */ + +#ifndef SER_PHY_H__ +#define SER_PHY_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/**@brief Serialization PHY module event types. */ +typedef enum +{ + SER_PHY_EVT_TX_PKT_SENT = 0, /**< Obligatory to implement. An event indicating that a TX packet + * has been transmitted. */ + SER_PHY_EVT_RX_BUF_REQUEST, /**< Obligatory to implement. An event indicating that the PHY layer + * needs a buffer for an RX packet. The PHY flow should be blocked + * until the @ref ser_phy_rx_buf_set function is called. */ + SER_PHY_EVT_RX_PKT_RECEIVED, /**< Obligatory to implement. An event indicating that an RX packet + * has been successfully received. */ + SER_PHY_EVT_RX_PKT_DROPPED, /**< Obligatory to implement. An event indicating that the RX packet + * receiving has been finished but the packet was discarded because + * it was longer than available the buffer. */ + + SER_PHY_EVT_RX_OVERFLOW_ERROR, /**< Optional to implement. An event indicating that more + * information has been transmitted than the PHY module could + * handle. */ + SER_PHY_EVT_TX_OVERREAD_ERROR, /**< Optional to implement. An event indicating that the PHY module + * was forced to transmit more information than possessed. */ + SER_PHY_EVT_HW_ERROR, /**< Optional to implement. An event indicating a hardware error + * in the PHY module. */ + SER_PHY_EVT_TYPE_MAX /**< Enumeration upper bound. */ +} ser_phy_evt_type_t; + + +/**@brief A struct containing parameters of event of type @ref SER_PHY_EVT_RX_BUF_REQUEST. */ +typedef struct +{ + uint16_t num_of_bytes; /**< Length of a buffer in octets that the layer above the PHY module should + * deliver, so that the PHY module can receive a packet. */ +} ser_phy_evt_rx_buf_request_params_t; + + +/**@brief A struct containing parameters of event of type @ref SER_PHY_EVT_RX_PKT_RECEIVED. */ +typedef struct +{ + uint8_t * p_buffer; /**< Pointer to a buffer containing the received packet. */ + uint16_t num_of_bytes; /**< Length of the received packet in octets. */ +} ser_phy_evt_rx_pkt_received_params_t; + + +/**@brief A struct containing parameters of event of type @ref SER_PHY_EVT_HW_ERROR. */ +typedef struct +{ + uint32_t error_code; /**< Hardware error code - specific for a microcontroller. */ + uint8_t * p_buffer; /**< Pointer to the buffer that was processed when error occured. */ +} ser_phy_evt_hw_error_params_t; + + +/**@brief A struct containing events from a Serialization PHY module. + * + * @note Some events do not have parameters, then whole information is contained in the evt_type. + */ +typedef struct +{ + ser_phy_evt_type_t evt_type; /**< Type of event. */ + + union /**< Union alternative identified by evt_type in enclosing struct. */ + { + /** Parameters of event of type @ref SER_PHY_EVT_RX_BUF_REQUEST. */ + ser_phy_evt_rx_buf_request_params_t rx_buf_request; + /** Parameters of event of type @ref SER_PHY_EVT_RX_PKT_RECEIVED. */ + ser_phy_evt_rx_pkt_received_params_t rx_pkt_received; + /** Parameters of the event of type @ref SER_PHY_EVT_HW_ERROR. */ + ser_phy_evt_hw_error_params_t hw_error; + } evt_params; +} ser_phy_evt_t; + + +/**@brief A type of generic callback function handler to be used by all PHY module events. + * + * @param[in] event Serialization PHY module event. + */ +typedef void (*ser_phy_events_handler_t)(ser_phy_evt_t event); + + +/**@brief Function for opening and initializing the PHY module. + * + * @note The function initializes hardware and internal module states, and registers callback + * function to be used by all PHY module events. + * + * @warning If the function has been already called, the function @ref ser_phy_close has to be + * called before ser_phy_open can be called again. + * + * @param[in] events_handler Generic callback function handler to be used by all PHY module + * events. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_INVALID_STATE Operation failure. The function has been already called. + * To call it again, the function @ref ser_phy_close has to be + * called first. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_PARAM Operation failure. Hardware initialization parameters are not + * supported. + */ +uint32_t ser_phy_open(ser_phy_events_handler_t events_handler); + + +/**@brief Function for transmitting a packet. + * + * @note The function adds a packet pointed by p_buffer parameter to a transmission queue and + * schedules generation of an event of type @ref SER_PHY_EVT_TX_PKT_SENT upon transmission + * completion. + * + * @param[in] p_buffer Pointer to a buffer to transmit. + * @param[in] num_of_bytes Number of octets to transmit. Must be more than 0. + * + * @retval NRF_SUCCESS Operation success. Packet was added to the transmission queue + * and event will be send upon transmission completion. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_PARAM Operation failure. The num_of_bytes parameter equal to 0. + * @retval NRF_ERROR_BUSY Operation failure. Transmitting of a packet in progress. + */ +uint32_t ser_phy_tx_pkt_send(const uint8_t * p_buffer, uint16_t num_of_bytes); + + +/**@brief Function for setting an RX buffer and enabling reception of data (the PHY flow). + * + * @note The function has to be called as a response to an event of type + * @ref SER_PHY_EVT_RX_BUF_REQUEST. The function sets an RX buffer and enables reception of + * data (enables the PHY flow). + * Size of a buffer pointed by the p_buffer parameter should be at least equal to the + * num_of_bytes parameter passed within the event (@ref ser_phy_evt_rx_buf_request_params_t), + * or p_buffer should be equal to NULL if there is not enough memory. + * When p_buffer is different from NULL and num_of_bytes octets have been received, an event of + * type @ref SER_PHY_EVT_RX_PKT_RECEIVED is generated + * (@ref ser_phy_evt_rx_pkt_received_params_t). + * When p_buffer is equal to NULL, data is received to dummy location to ensure continuous + * communication. Then, if num_of_bytes octets have been received, an event of type + * @ref SER_PHY_EVT_RX_PKT_DROPPED is generated. + * + * @param[in] p_buffer Pointer to an RX buffer in which to receive. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_INVALID_STATE Operation failure. A buffer was set without request. + */ +uint32_t ser_phy_rx_buf_set(uint8_t * p_buffer); + + +/**@brief Function for closing the PHY module. + * + * @note The function disables hardware, resets internal module states, and unregisters the events + * callback function. + */ +void ser_phy_close(void); + + +/**@brief Function for enabling the PHY module interrupts. + * + * @note The function enables all interrupts that are used by the PHY module (and only those). + */ +void ser_phy_interrupts_enable(void); + + +/**@brief Function for disabling the PHY module interrupts. + * + * @note The function disables all interrupts that are used by the PHY module (and only those). + */ +void ser_phy_interrupts_disable(void); + + + +#ifdef __cplusplus +} +#endif + +#endif /* SER_PHY_H__ */ +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c new file mode 100644 index 000000000..ed9f384a0 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c @@ -0,0 +1,363 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "ser_phy.h" +#include "ser_config.h" +#ifdef SER_CONNECTIVITY + #include "ser_phy_config_conn.h" +#else + #include "ser_phy_config_app.h" +#endif +#include "nrf_drv_uart.h" +#include "app_error.h" +#include "app_util.h" +#include "app_util_platform.h" + +#define UART_TRANSFER_MAX 255 + +static const nrf_drv_uart_t m_uart = NRF_DRV_UART_INSTANCE(0); +static const nrf_drv_uart_config_t m_uart_config = { + .pseltxd = SER_PHY_UART_TX, + .pselrxd = SER_PHY_UART_RX, + .pselrts = SER_PHY_UART_RTS, + .pselcts = SER_PHY_UART_CTS, + .p_context = NULL, + .interrupt_priority = UART_IRQ_PRIORITY, +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) + .use_easy_dma = true, +#endif + // These values are common for application and connectivity, they are + // defined in "ser_config.h". + .hwfc = SER_PHY_UART_FLOW_CTRL, + .parity = SER_PHY_UART_PARITY, + .baudrate = (nrf_uart_baudrate_t)SER_PHY_UART_BAUDRATE +}; + +static bool volatile m_tx_in_progress; +static uint8_t m_tx_header_buf[SER_PHY_HEADER_SIZE]; +static uint16_t m_bytes_to_transmit; +static uint8_t const * mp_tx_buffer; + +static uint8_t m_rx_header_buf[SER_PHY_HEADER_SIZE]; +static uint16_t m_bytes_to_receive; +static uint8_t m_rx_drop_buf[1]; + +static ser_phy_events_handler_t m_ser_phy_event_handler; +static ser_phy_evt_t m_ser_phy_rx_event; + + +static void packet_sent_callback(void) +{ + static ser_phy_evt_t const event = { + .evt_type = SER_PHY_EVT_TX_PKT_SENT, + }; + m_ser_phy_event_handler(event); +} + +static void buffer_request_callback(uint16_t num_of_bytes) +{ + m_ser_phy_rx_event.evt_type = SER_PHY_EVT_RX_BUF_REQUEST; + m_ser_phy_rx_event.evt_params.rx_buf_request.num_of_bytes = num_of_bytes; + m_ser_phy_event_handler(m_ser_phy_rx_event); +} + +static void packet_received_callback(void) +{ + m_ser_phy_event_handler(m_ser_phy_rx_event); +} + +static void packet_dropped_callback(void) +{ + static ser_phy_evt_t const event = { + .evt_type = SER_PHY_EVT_RX_PKT_DROPPED, + }; + m_ser_phy_event_handler(event); +} + +static void hardware_error_callback(uint32_t hw_error) +{ + ser_phy_evt_t event = { + .evt_type = SER_PHY_EVT_HW_ERROR, + .evt_params.hw_error.error_code = hw_error, + }; + m_ser_phy_event_handler(event); +} + +static void packet_rx_start(void) +{ + APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, m_rx_header_buf, + SER_PHY_HEADER_SIZE)); +} + +static void packet_byte_drop(void) +{ + APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, m_rx_drop_buf, 1)); +} + +static void uart_event_handler(nrf_drv_uart_event_t * p_event, + void * p_context) +{ + (void)p_context; + + switch (p_event->type) + { + case NRF_DRV_UART_EVT_ERROR: + // Process the error only if this is a parity or overrun error. + // Break and framing errors will always occur before the other + // side becomes active. + if (p_event->data.error.error_mask & + (NRF_UART_ERROR_PARITY_MASK | NRF_UART_ERROR_OVERRUN_MASK)) + { + // Pass error source to upper layer. + hardware_error_callback(p_event->data.error.error_mask); + } + + packet_rx_start(); + break; + + case NRF_DRV_UART_EVT_TX_DONE: + if (p_event->data.rxtx.p_data == m_tx_header_buf) + { +#if (SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE > UART_TRANSFER_MAX) + if (m_bytes_to_transmit > UART_TRANSFER_MAX) + { + APP_ERROR_CHECK(nrf_drv_uart_tx(&m_uart, mp_tx_buffer, + UART_TRANSFER_MAX)); + } + else +#endif // (SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE > UART_TRANSFER_MAX) + { + APP_ERROR_CHECK(nrf_drv_uart_tx(&m_uart, mp_tx_buffer, + m_bytes_to_transmit)); + } + } + else + { +#if (SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE > UART_TRANSFER_MAX) + ASSERT(p_event->data.rxtx.bytes <= m_bytes_to_transmit); + m_bytes_to_transmit -= p_event->data.rxtx.bytes; + if (m_bytes_to_transmit != 0) + { + APP_ERROR_CHECK(nrf_drv_uart_tx(&m_uart, + p_event->data.rxtx.p_data + p_event->data.rxtx.bytes, + m_bytes_to_transmit < UART_TRANSFER_MAX ? + m_bytes_to_transmit : UART_TRANSFER_MAX)); + } + else +#endif // (SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE > UART_TRANSFER_MAX) + { + m_tx_in_progress = false; + packet_sent_callback(); + } + } + break; + + case NRF_DRV_UART_EVT_RX_DONE: + if (p_event->data.rxtx.p_data == m_rx_header_buf) + { + m_bytes_to_receive = uint16_decode(m_rx_header_buf); + buffer_request_callback(m_bytes_to_receive); + } + else if (p_event->data.rxtx.p_data == m_rx_drop_buf) + { + --m_bytes_to_receive; + if (m_bytes_to_receive != 0) + { + packet_byte_drop(); + } + else + { + packet_dropped_callback(); + + packet_rx_start(); + } + } + else + { +#if (SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE > UART_TRANSFER_MAX) + ASSERT(p_event->data.rxtx.bytes <= m_bytes_to_receive); + m_bytes_to_receive -= p_event->data.rxtx.bytes; + if (m_bytes_to_receive != 0) + { + APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, + p_event->data.rxtx.p_data + p_event->data.rxtx.bytes, + m_bytes_to_receive < UART_TRANSFER_MAX ? + m_bytes_to_receive : UART_TRANSFER_MAX)); + } + else +#endif // (SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE > UART_TRANSFER_MAX) + { + packet_received_callback(); + + packet_rx_start(); + } + } + break; + + default: + APP_ERROR_CHECK(NRF_ERROR_INTERNAL); + } +} + +/** API FUNCTIONS */ + +uint32_t ser_phy_open(ser_phy_events_handler_t events_handler) +{ + uint32_t err_code; + + if (events_handler == NULL) + { + return NRF_ERROR_NULL; + } + + // Check if function was not called before. + if (m_ser_phy_event_handler != NULL) + { + return NRF_ERROR_INVALID_STATE; + } + + err_code = nrf_drv_uart_init(&m_uart, &m_uart_config, uart_event_handler); + if (err_code != NRF_SUCCESS) + { + return NRF_ERROR_INVALID_PARAM; + } + + m_ser_phy_event_handler = events_handler; + + packet_rx_start(); + + return err_code; +} + +uint32_t ser_phy_tx_pkt_send(const uint8_t * p_buffer, uint16_t num_of_bytes) +{ + if (p_buffer == NULL) + { + return NRF_ERROR_NULL; + } + else if (num_of_bytes == 0) + { + return NRF_ERROR_INVALID_PARAM; + } + + bool busy; + + CRITICAL_REGION_ENTER(); + busy = m_tx_in_progress; + m_tx_in_progress = true; + CRITICAL_REGION_EXIT(); + + if (busy) + { + return NRF_ERROR_BUSY; + } + + (void)uint16_encode(num_of_bytes, m_tx_header_buf); + mp_tx_buffer = p_buffer; + m_bytes_to_transmit = num_of_bytes; + APP_ERROR_CHECK(nrf_drv_uart_tx(&m_uart, m_tx_header_buf, + SER_PHY_HEADER_SIZE)); + + return NRF_SUCCESS; +} + + +uint32_t ser_phy_rx_buf_set(uint8_t * p_buffer) +{ + + if (m_ser_phy_rx_event.evt_type != SER_PHY_EVT_RX_BUF_REQUEST) + { + return NRF_ERROR_INVALID_STATE; + } + + m_ser_phy_rx_event.evt_type = SER_PHY_EVT_RX_PKT_RECEIVED; + m_ser_phy_rx_event.evt_params.rx_pkt_received.p_buffer = p_buffer; + m_ser_phy_rx_event.evt_params.rx_pkt_received.num_of_bytes = + m_bytes_to_receive; + + // If there is not enough memory to receive the packet (no buffer was + // provided), drop its data byte by byte (using an internal 1-byte buffer). + if (p_buffer == NULL) + { + packet_byte_drop(); + } +#if (SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE > UART_TRANSFER_MAX) + else if (m_bytes_to_receive > UART_TRANSFER_MAX) + { + APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, p_buffer, UART_TRANSFER_MAX)); + } +#endif // (SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE > UART_TRANSFER_MAX) + else + { + APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, p_buffer, m_bytes_to_receive)); + } + + return NRF_SUCCESS; +} + + +void ser_phy_close(void) +{ + nrf_drv_uart_uninit(&m_uart); + m_ser_phy_event_handler = NULL; +} + + +void ser_phy_interrupts_enable(void) +{ + IRQn_Type irqn; +#if defined(NRF_DRV_UART_WITH_UARTE) + irqn = nrfx_get_irq_number(m_uart.uarte.p_reg); +#else + irqn = nrfx_get_irq_number(m_uart.uart.p_reg); +#endif + NVIC_EnableIRQ(irqn); +} + + +void ser_phy_interrupts_disable(void) +{ + IRQn_Type irqn; +#if defined(NRF_DRV_UART_WITH_UARTE) + irqn = nrfx_get_irq_number(m_uart.uarte.p_reg); +#else + irqn = nrfx_get_irq_number(m_uart.uart.p_reg); +#endif + NVIC_DisableIRQ(irqn); +} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy_debug_comm.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy_debug_comm.h new file mode 100644 index 000000000..13db809cf --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy_debug_comm.h @@ -0,0 +1,203 @@ +/** + * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef SER_PHY_DEBUG_COMM_H__ +#define SER_PHY_DEBUG_COMM_H__ + +#ifndef SER_PHY_HCI_DEBUG_ENABLE + +// empty definitions here +#define DEBUG_EVT_HCI_PHY_EVT_TX_PKT_SENT(data) +#define DEBUG_EVT_HCI_PHY_EVT_BUF_REQUEST(data) +#define DEBUG_EVT_HCI_PHY_EVT_RX_PKT_RECEIVED(data) +#define DEBUG_EVT_HCI_PHY_EVT_RX_PKT_DROPPED(data) +#define DEBUG_EVT_HCI_PHY_EVT_TX_ERROR(data) +#define DEBUG_EVT_SLIP_PACKET_TX(data) +#define DEBUG_EVT_SLIP_ACK_TX(data) +#define DEBUG_EVT_SLIP_PACKET_TXED(data) +#define DEBUG_EVT_SLIP_ACK_TXED(data) +#define DEBUG_EVT_SLIP_PACKET_RXED(data) +#define DEBUG_EVT_SLIP_ACK_RXED(data) +#define DEBUG_EVT_SLIP_ERR_RXED(data) +#define DEBUG_EVT_TIMEOUT(data) +#define DEBUG_HCI_RETX(data) +#define DEBUG_EVT_MAIN_BUSY(data) +#define DEBUG_EVT_TX_REQ(data) + +#else +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//Low level hardware events +typedef enum +{ + HCI_PHY_EVT_TX_PKT_SENT, + HCI_PHY_EVT_BUF_REQUEST, + HCI_PHY_EVT_RX_PKT_RECEIVED, + HCI_PHY_EVT_RX_PKT_DROPPED, + HCI_PHY_EVT_TX_ERROR, + HCI_SLIP_EVT_PACKET_TX, + HCI_SLIP_EVT_ACK_TX, + HCI_SLIP_EVT_PACKET_TXED, + HCI_SLIP_EVT_ACK_TXED, + HCI_SLIP_EVT_PACKET_RXED, + HCI_SLIP_EVT_ACK_RXED, + HCI_SLIP_EVT_ERR_RXED, + HCI_TIMER_EVT_TIMEOUT, + HCI_RETX, + HCI_MAIN_BUSY, + HCI_TX_REQ, + HCI_PHY_EVT_MAX +} hci_dbg_evt_type_t; + + +//Low level hardware event definition +typedef struct +{ + hci_dbg_evt_type_t evt; + uint32_t data; +} hci_dbg_evt_t; + +typedef void (*hci_dbg_event_handler_t)(hci_dbg_evt_t event); + +void debug_init(hci_dbg_event_handler_t evt_callback); + +void debug_evt(hci_dbg_evt_type_t evt, uint32_t data); + + +#define DEBUG_EVT(event_type, data) \ +do { \ + debug_evt(event_type, data); \ +} while (0); + + +#define DEBUG_EVT_HCI_PHY_EVT_TX_PKT_SENT(data) \ +do { \ + DEBUG_EVT(HCI_PHY_EVT_TX_PKT_SENT, data); \ +} while (0); + + +#define DEBUG_EVT_HCI_PHY_EVT_BUF_REQUEST(data) \ +do { \ + DEBUG_EVT(HCI_PHY_EVT_BUF_REQUEST, data); \ +} while (0); + + +#define DEBUG_EVT_HCI_PHY_EVT_RX_PKT_RECEIVED(data) \ +do { \ + DEBUG_EVT(HCI_PHY_EVT_RX_PKT_RECEIVED, data); \ +} while (0); + + +#define DEBUG_EVT_HCI_PHY_EVT_RX_PKT_DROPPED(data) \ +do { \ + DEBUG_EVT(HCI_PHY_EVT_RX_PKT_DROPPED, data); \ +} while (0); + +#define DEBUG_EVT_HCI_PHY_EVT_TX_ERROR(data) \ +do { \ + DEBUG_EVT(HCI_PHY_EVT_TX_ERROR, data); \ +} while (0); + +#define DEBUG_EVT_SLIP_PACKET_TX(data) \ +do { \ + DEBUG_EVT(HCI_SLIP_EVT_PACKET_TX, data); \ +} while (0); + +#define DEBUG_EVT_SLIP_ACK_TX(data) \ +do { \ + DEBUG_EVT(HCI_SLIP_EVT_ACK_TX, data); \ +} while (0); + +#define DEBUG_EVT_SLIP_PACKET_TXED(data) \ +do { \ + DEBUG_EVT(HCI_SLIP_EVT_PACKET_TXED, data); \ +} while (0); + +#define DEBUG_EVT_SLIP_ACK_TXED(data) \ +do { \ + DEBUG_EVT(HCI_SLIP_EVT_ACK_TXED, data); \ +} while (0); + +#define DEBUG_EVT_SLIP_PACKET_RXED(data) \ +do { \ + DEBUG_EVT(HCI_SLIP_EVT_PACKET_RXED, data); \ +} while (0); + +#define DEBUG_EVT_SLIP_ACK_RXED(data) \ +do { \ + DEBUG_EVT(HCI_SLIP_EVT_ACK_RXED, data); \ +} while (0); + +#define DEBUG_EVT_SLIP_ERR_RXED(data) \ +do { \ + DEBUG_EVT(HCI_SLIP_EVT_ERR_RXED, data); \ +} while (0); + +#define DEBUG_EVT_TIMEOUT(data) \ +do { \ + DEBUG_EVT(HCI_TIMER_EVT_TIMEOUT, data); \ +} while (0); + +#define DEBUG_HCI_RETX(data) \ +do { \ + DEBUG_EVT(HCI_RETX, data); \ +} while (0); + +#define DEBUG_EVT_MAIN_BUSY(data) \ +do { \ + DEBUG_EVT(HCI_MAIN_BUSY, data); \ +} while (0); + +#define DEBUG_EVT_TX_REQ(data) \ +do { \ + DEBUG_EVT(HCI_TX_REQ, data); \ +} while (0); + +#endif // SER_PHY_HCI_DEBUG_ENABLE + + +#ifdef __cplusplus +} +#endif + +#endif // SER_PHY_DEBUG_COMM_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c new file mode 100644 index 000000000..aff3598ab --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c @@ -0,0 +1,402 @@ +/** + * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_SDH) + +#include "nrf_sdh.h" + +#include + +#include "nrf_sdm.h" +#include "nrf_nvic.h" +#include "sdk_config.h" +#include "app_error.h" +#include "app_util_platform.h" + + +#define NRF_LOG_MODULE_NAME nrf_sdh +#if NRF_SDH_LOG_ENABLED + #define NRF_LOG_LEVEL NRF_SDH_LOG_LEVEL + #define NRF_LOG_INFO_COLOR NRF_SDH_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_SDH_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // NRF_SDH_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + + +// Validate configuration options. + +#if (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_APPSH) + #if (!APP_SCHEDULER_ENABLED) + #error app_scheduler is required when NRF_SDH_DISPATCH_MODEL is set to NRF_SDH_DISPATCH_MODEL_APPSH + #endif + #include "app_scheduler.h" +#endif + +#if ( (NRF_SDH_CLOCK_LF_SRC == NRF_CLOCK_LF_SRC_RC) \ + && (NRF_SDH_CLOCK_LF_ACCURACY != NRF_CLOCK_LF_ACCURACY_500_PPM)) + #warning Please select NRF_CLOCK_LF_ACCURACY_500_PPM when using NRF_CLOCK_LF_SRC_RC +#endif + + +// Create section "sdh_req_observers". +NRF_SECTION_SET_DEF(sdh_req_observers, nrf_sdh_req_observer_t, NRF_SDH_REQ_OBSERVER_PRIO_LEVELS); + +// Create section "sdh_state_observers". +NRF_SECTION_SET_DEF(sdh_state_observers, nrf_sdh_state_observer_t, NRF_SDH_STATE_OBSERVER_PRIO_LEVELS); + +// Create section "sdh_stack_observers". +NRF_SECTION_SET_DEF(sdh_stack_observers, nrf_sdh_stack_observer_t, NRF_SDH_STACK_OBSERVER_PRIO_LEVELS); + + +static bool m_nrf_sdh_enabled; /**< Variable to indicate whether the SoftDevice is enabled. */ +static bool m_nrf_sdh_suspended; /**< Variable to indicate whether this module is suspended. */ +static bool m_nrf_sdh_continue; /**< Variable to indicate whether enable/disable process was started. */ + + +/**@brief Function for notifying request observers. + * + * @param[in] evt Type of request event. + */ +static ret_code_t sdh_request_observer_notify(nrf_sdh_req_evt_t req) +{ + nrf_section_iter_t iter; + + NRF_LOG_DEBUG("State request: 0x%08X", req); + + for (nrf_section_iter_init(&iter, &sdh_req_observers); + nrf_section_iter_get(&iter) != NULL; + nrf_section_iter_next(&iter)) + { + nrf_sdh_req_observer_t * p_observer; + nrf_sdh_req_evt_handler_t handler; + + p_observer = (nrf_sdh_req_observer_t *) nrf_section_iter_get(&iter); + handler = p_observer->handler; + + if (handler(req, p_observer->p_context)) + { + NRF_LOG_DEBUG("Notify observer 0x%08X => ready", p_observer); + } + else + { + // Process is stopped. + NRF_LOG_DEBUG("Notify observer 0x%08X => blocking", p_observer); + return NRF_ERROR_BUSY; + } + } + return NRF_SUCCESS; +} + + +/**@brief Function for stage request observers. + * + * @param[in] evt Type of stage event. + */ +static void sdh_state_observer_notify(nrf_sdh_state_evt_t evt) +{ + nrf_section_iter_t iter; + + NRF_LOG_DEBUG("State change: 0x%08X", evt); + + for (nrf_section_iter_init(&iter, &sdh_state_observers); + nrf_section_iter_get(&iter) != NULL; + nrf_section_iter_next(&iter)) + { + nrf_sdh_state_observer_t * p_observer; + nrf_sdh_state_evt_handler_t handler; + + p_observer = (nrf_sdh_state_observer_t *) nrf_section_iter_get(&iter); + handler = p_observer->handler; + + handler(evt, p_observer->p_context); + } +} + + +static void softdevices_evt_irq_enable(void) +{ +#ifdef SOFTDEVICE_PRESENT + ret_code_t ret_code = sd_nvic_EnableIRQ((IRQn_Type)SD_EVT_IRQn); + APP_ERROR_CHECK(ret_code); +#else + // In case of serialization, NVIC must be accessed directly. + NVIC_EnableIRQ(SD_EVT_IRQn); +#endif +} + + +static void softdevice_evt_irq_disable(void) +{ +#ifdef SOFTDEVICE_PRESENT + ret_code_t ret_code = sd_nvic_DisableIRQ((IRQn_Type)SD_EVT_IRQn); + APP_ERROR_CHECK(ret_code); +#else + // In case of serialization, NVIC must be accessed directly. + NVIC_DisableIRQ(SD_EVT_IRQn); +#endif +} + + +ret_code_t nrf_sdh_enable_request(void) +{ + ret_code_t ret_code; + + if (m_nrf_sdh_enabled) + { + return NRF_ERROR_INVALID_STATE; + } + + m_nrf_sdh_continue = true; + + // Notify observers about SoftDevice enable request. + if (sdh_request_observer_notify(NRF_SDH_EVT_ENABLE_REQUEST) == NRF_ERROR_BUSY) + { + // Enable process was stopped. + return NRF_SUCCESS; + } + + // Notify observers about starting SoftDevice enable process. + sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLE_PREPARE); + + nrf_clock_lf_cfg_t const clock_lf_cfg = + { + .source = NRF_SDH_CLOCK_LF_SRC, + .rc_ctiv = NRF_SDH_CLOCK_LF_RC_CTIV, + .rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV, + .accuracy = NRF_SDH_CLOCK_LF_ACCURACY + }; + + CRITICAL_REGION_ENTER(); +#ifdef ANT_LICENSE_KEY + ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler, ANT_LICENSE_KEY); +#else + ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler); +#endif + m_nrf_sdh_enabled = (ret_code == NRF_SUCCESS); + CRITICAL_REGION_EXIT(); + + if (ret_code != NRF_SUCCESS) + { + return ret_code; + } + + m_nrf_sdh_continue = false; + m_nrf_sdh_suspended = false; + + // Enable event interrupt. + // Interrupt priority has already been set by the stack. + softdevices_evt_irq_enable(); + + // Notify observers about a finished SoftDevice enable process. + sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLED); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_sdh_disable_request(void) +{ + ret_code_t ret_code; + + if (!m_nrf_sdh_enabled) + { + return NRF_ERROR_INVALID_STATE; + } + + m_nrf_sdh_continue = true; + + // Notify observers about SoftDevice disable request. + if (sdh_request_observer_notify(NRF_SDH_EVT_DISABLE_REQUEST) == NRF_ERROR_BUSY) + { + // Disable process was stopped. + return NRF_SUCCESS; + } + + // Notify observers about starting SoftDevice disable process. + sdh_state_observer_notify(NRF_SDH_EVT_STATE_DISABLE_PREPARE); + + CRITICAL_REGION_ENTER(); + ret_code = sd_softdevice_disable(); + m_nrf_sdh_enabled = false; + CRITICAL_REGION_EXIT(); + + if (ret_code != NRF_SUCCESS) + { + return ret_code; + } + + m_nrf_sdh_continue = false; + + softdevice_evt_irq_disable(); + + // Notify observers about a finished SoftDevice enable process. + sdh_state_observer_notify(NRF_SDH_EVT_STATE_DISABLED); + + return NRF_SUCCESS; +} + + +ret_code_t nrf_sdh_request_continue(void) +{ + if (!m_nrf_sdh_continue) + { + return NRF_ERROR_INVALID_STATE; + } + + if (m_nrf_sdh_enabled) + { + return nrf_sdh_disable_request(); + } + else + { + return nrf_sdh_enable_request(); + } +} + + +bool nrf_sdh_is_enabled(void) +{ + return m_nrf_sdh_enabled; +} + + +void nrf_sdh_suspend(void) +{ + if (!m_nrf_sdh_enabled) + { + return; + } + + softdevice_evt_irq_disable(); + m_nrf_sdh_suspended = true; +} + + +void nrf_sdh_resume(void) +{ + if ((!m_nrf_sdh_suspended) || (!m_nrf_sdh_enabled)) + { + return; + } + + // Force calling ISR again to make sure that events not previously pulled have been processed. +#ifdef SOFTDEVICE_PRESENT + ret_code_t ret_code = sd_nvic_SetPendingIRQ((IRQn_Type)SD_EVT_IRQn); + APP_ERROR_CHECK(ret_code); +#else + NVIC_SetPendingIRQ((IRQn_Type)SD_EVT_IRQn); +#endif + + softdevices_evt_irq_enable(); + + m_nrf_sdh_suspended = false; +} + + +bool nrf_sdh_is_suspended(void) +{ + return (!m_nrf_sdh_enabled) || (m_nrf_sdh_suspended); +} + + +void nrf_sdh_evts_poll(void) +{ + nrf_section_iter_t iter; + + // Notify observers about pending SoftDevice event. + for (nrf_section_iter_init(&iter, &sdh_stack_observers); + nrf_section_iter_get(&iter) != NULL; + nrf_section_iter_next(&iter)) + { + nrf_sdh_stack_observer_t * p_observer; + nrf_sdh_stack_evt_handler_t handler; + + p_observer = (nrf_sdh_stack_observer_t *) nrf_section_iter_get(&iter); + handler = p_observer->handler; + + handler(p_observer->p_context); + } +} + + +#if (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_INTERRUPT) + +void SD_EVT_IRQHandler(void) +{ + nrf_sdh_evts_poll(); +} + +#elif (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_APPSH) + +/**@brief Function for polling SoftDevice events. + * + * @note This function is compatible with @ref app_sched_event_handler_t. + * + * @param[in] p_event_data Pointer to the event data. + * @param[in] event_size Size of the event data. + */ +static void appsh_events_poll(void * p_event_data, uint16_t event_size) +{ + UNUSED_PARAMETER(p_event_data); + UNUSED_PARAMETER(event_size); + + nrf_sdh_evts_poll(); +} + + +void SD_EVT_IRQHandler(void) +{ + ret_code_t ret_code = app_sched_event_put(NULL, 0, appsh_events_poll); + APP_ERROR_CHECK(ret_code); +} + +#elif (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_POLLING) + +#else + +#error "Unknown SoftDevice handler dispatch model." + +#endif // NRF_SDH_DISPATCH_MODEL + +#endif // NRF_MODULE_ENABLED(NRF_SDH) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.h new file mode 100644 index 000000000..066ac89a4 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.h @@ -0,0 +1,305 @@ +/** + * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** @file + * + * @defgroup nrf_sdh SoftDevice Handler + * @{ + * @ingroup app_common + * @brief API for initializing and disabling the SoftDevice. + */ + +#ifndef NRF_SDH_H__ +#define NRF_SDH_H__ + +#include +#include "sdk_config.h" +#include "sdk_errors.h" +#include "nrf_section_iter.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Softdevice Handler dispatch models + * @{ + * @ingroup nrf_sdh */ + +/**@brief SoftDevice events are passed to the application from the interrupt context. */ +#define NRF_SDH_DISPATCH_MODEL_INTERRUPT 0 + +/**@brief SoftDevice events are passed to the application using @ref app_scheduler. + * + * @note @ref app_scheduler must be initialized before enabling the SoftDevice handler. + */ +#define NRF_SDH_DISPATCH_MODEL_APPSH 1 + +/**@brief SoftDevice events are polled manually using @ref nrf_sdh_evts_poll(). + * + * @note In this mode, a user application can also implement SD_EVT_IRQHandler() to receive a + * notification about incoming events. + */ +#define NRF_SDH_DISPATCH_MODEL_POLLING 2 + +/** @} */ + +/** + * @name SoftDevice Handler state change requests + * @{ + * @ingroup nrf_sdh */ + +/**@brief SoftDevice Handler state requests. */ +typedef enum +{ + NRF_SDH_EVT_ENABLE_REQUEST, //!< Request to enable the SoftDevice. + NRF_SDH_EVT_DISABLE_REQUEST, //!< Request to disable the SoftDevice. +} nrf_sdh_req_evt_t; + +/**@brief SoftDevice Handler state request handler. + * + * @retval true If ready for the SoftDevice to change state. + * @retval false If not ready for the SoftDevice to change state. + * If false is returned, the state change is aborted. + */ +typedef bool (*nrf_sdh_req_evt_handler_t)(nrf_sdh_req_evt_t request, void * p_context); + +/**@brief SoftDevice Handler state request observer. */ +typedef struct +{ + nrf_sdh_req_evt_handler_t handler; //!< Request handler. + void * p_context; //!< A parameter to the handler function. +} const nrf_sdh_req_observer_t; + +/**@brief Macro for registering a SoftDevice state change request observer. + * + * An observer of SoftDevice state change requests receives requests to change the state of the + * SoftDevice from enabled to disabled and vice versa. These requests may or may not be acknowledged + * by the observer, depending on the value returned by its request handler function. Thus, a + * request observer has the capability to defer the change of state of the SoftDevice. If it does + * so, it has the responsibility to call @ref nrf_sdh_request_continue when it is ready to let the + * SoftDevice change its state. If such capability is not necessary and you only need to be informed + * about changes of the SoftDevice state, use the @ref NRF_SDH_STATE_OBSERVER macro instead. + * + * @note This macro places the observer in a section named "sdh_req_observers". + * + * @param[in] _observer Name of the observer. + * @param[in] _prio Priority of the observer's event handler. + * The smaller the number, the higher the priority. + * @hideinitializer + */ +#define NRF_SDH_REQUEST_OBSERVER(_observer, _prio) \ +STATIC_ASSERT(NRF_SDH_ENABLED, "NRF_SDH_ENABLED not set!"); \ +STATIC_ASSERT(_prio < NRF_SDH_REQ_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \ +/*lint -esym(528,*_observer) -esym(529,*_observer) : Symbol not referenced. */ \ +NRF_SECTION_SET_ITEM_REGISTER(sdh_req_observers, _prio, nrf_sdh_req_observer_t const _observer) + +/** @} */ + +/** + * @name SoftDevice Handler state events + * @{ + * @ingroup nrf_sdh */ + +/**@brief SoftDevice Handler state events. */ +typedef enum +{ + NRF_SDH_EVT_STATE_ENABLE_PREPARE, //!< SoftDevice is going to be enabled. + NRF_SDH_EVT_STATE_ENABLED, //!< SoftDevice is enabled. + NRF_SDH_EVT_STATE_DISABLE_PREPARE, //!< SoftDevice is going to be disabled. + NRF_SDH_EVT_STATE_DISABLED, //!< SoftDevice is disabled. +} nrf_sdh_state_evt_t; + +/**@brief SoftDevice Handler state event handler. */ +typedef void (*nrf_sdh_state_evt_handler_t)(nrf_sdh_state_evt_t state, void * p_context); + +/**@brief SoftDevice Handler state observer. */ +typedef struct +{ + nrf_sdh_state_evt_handler_t handler; //!< State event handler. + void * p_context; //!< A parameter to the event handler. +} const nrf_sdh_state_observer_t; + +/**@brief Macro for registering a SoftDevice state observer. + * + * A SoftDevice state observer receives events when the SoftDevice state has changed or is + * about to change. These events are only meant to inform the state observer, which, contrary + * to a state change request observer, does not have the capability to defer the change of state. + * If such capability is required, use the @ref NRF_SDH_REQUEST_OBSERVER macro instead. + * + * This macro places the observer in a section named "sdh_state_observers". + * + * @param[in] _observer Name of the observer. + * @param[in] _prio Priority of the observer's event handler. + * The smaller the number, the higher the priority. + * @hideinitializer + */ +#define NRF_SDH_STATE_OBSERVER(_observer, _prio) \ +STATIC_ASSERT(NRF_SDH_ENABLED, "NRF_SDH_ENABLED not set!"); \ +STATIC_ASSERT(_prio < NRF_SDH_STATE_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \ +/*lint -esym(528,*_observer) -esym(529,*_observer) : Symbol not referenced. */ \ +NRF_SECTION_SET_ITEM_REGISTER(sdh_state_observers, _prio, static nrf_sdh_state_observer_t const _observer) + +/** @} */ + +/** + * @name SoftDevice stack events + * @{ + * @ingroup nrf_sdh */ + +/**@brief SoftDevice stack event handler. */ +typedef void (*nrf_sdh_stack_evt_handler_t)(void * p_evt); + +/**@brief SoftDevice stack event observer. */ +typedef struct +{ + nrf_sdh_stack_evt_handler_t handler; //!< SoftDevice event handler. + void * p_context; //!< A parameter to the event handler. +} const nrf_sdh_stack_observer_t; + +/**@brief Macro for registering a SoftDevice stack events observer. + * + * A SoftDevice stack event observer receives all events from the SoftDevice. These events can be + * either BLE, ANT, or SoC events. If you need to receive BLE, ANT, or SoC events separately, use the + * @ref NRF_SDH_BLE_OBSERVER, @ref NRF_SDH_ANT_OBSERVER, or @ref NRF_SDH_SOC_OBSERVER macros + * respectively. + * + * @note This macro places the observer in a section named "sdh_stack_observers". + * + * @param[in] _observer Name of the observer. + * @param[in] _prio Priority of the observer's event handler. + * The smaller the number, the higher the priority. + ** @hideinitializer + */ +#define NRF_SDH_STACK_OBSERVER(_observer, _prio) \ +STATIC_ASSERT(NRF_SDH_ENABLED, "NRF_SDH_ENABLED not set!"); \ +STATIC_ASSERT(_prio < NRF_SDH_STACK_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \ +/*lint -esym(528,*_observer) -esym(529,*_observer) : Symbol not referenced. */ \ +NRF_SECTION_SET_ITEM_REGISTER(sdh_stack_observers, _prio, static nrf_sdh_stack_observer_t const _observer) + +/** @} */ + +/**@brief Function for requesting to enable the SoftDevice. + * + * This function issues a @ref NRF_SDH_EVT_ENABLE_REQUEST request to all observers that + * were registered using the @ref NRF_SDH_REQUEST_OBSERVER macro. The observers may or + * may not acknowledge the request. If all observers acknowledge the request, the + * SoftDevice will be enabled. Otherwise, the process will be stopped and the observers + * that did not acknowledge have the responsibility to restart it by calling + * @ref nrf_sdh_request_continue when they are ready for the SoftDevice to change state. + * + * @retval NRF_SUCCESS The process is started. + * @retval NRF_ERROR_INVALID_STATE The SoftDevice is already enabled. + */ +ret_code_t nrf_sdh_enable_request(void); + + +/**@brief Function for requesting to disable the SoftDevice. + * + * This function issues a @ref NRF_SDH_EVT_DISABLE_REQUEST request to all observers that + * were registered using the @ref NRF_SDH_REQUEST_OBSERVER macro. The observers may or + * may not acknowledge the request. If all observers acknowledge the request, the + * SoftDevice will be disabled. Otherwise, the process will be stopped and the observers + * that did not acknowledge have the responsibility to restart it by calling + * @ref nrf_sdh_request_continue when they are ready for the SoftDevice to change state. + * + * @retval NRF_SUCCESS The process is started. + * @retval NRF_ERROR_INVALID_STATE The SoftDevice is already disabled. + */ +ret_code_t nrf_sdh_disable_request(void); + + +/**@brief Function for restarting the SoftDevice Enable/Disable process. + * + * Modules which did not acknowledge a @ref NRF_SDH_EVT_ENABLE_REQUEST or + * @ref NRF_SDH_EVT_DISABLE_REQUEST request must call this function to restart the + * SoftDevice state change process. + * + * @retval NRF_SUCCESS The process is restarted. + * @retval NRF_ERROR_INVALID_STATE No state change request was pending. + */ +ret_code_t nrf_sdh_request_continue(void); + + +/**@brief Function for retrieving the SoftDevice state. + * + * @retval true If the SoftDevice is enabled. + * @retval false If the SoftDevice is disabled. + */ +bool nrf_sdh_is_enabled(void); + + +/**@brief Function for stopping the incoming stack events. + * + * This function disables the SoftDevice interrupt. To resume polling for events, + * call @ref nrf_sdh_resume. + */ +void nrf_sdh_suspend(void); + + +/**@brief Function for resuming polling incoming events from the SoftDevice. */ +void nrf_sdh_resume(void); + + +/**@brief Function for retrieving the information about the module state. + * + * @retval true The SoftDevice handler is paused, and it will not fetch events from the stack. + * @retval false The SoftDevice handler is running, and it will fetch and dispatch events from + * the stack to the registered stack observers. + */ +bool nrf_sdh_is_suspended(void); + + +/**@brief Function for polling stack events from the SoftDevice. + * + * The events are passed to the application using the registered event handlers. + * + * @note @ref NRF_SDH_DISPATCH_MODEL_POLLING must be selected to use this function. + */ +void nrf_sdh_evts_poll(void); + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_SDH_H__ + +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c new file mode 100644 index 000000000..30c81587c --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c @@ -0,0 +1,326 @@ +/** + * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_SDH_BLE) + +#include "nrf_sdh_ble.h" + +#include "nrf_sdh.h" +#include "app_error.h" +#include "nrf_strerror.h" + + +#define NRF_LOG_MODULE_NAME nrf_sdh_ble +#if NRF_SDH_BLE_LOG_ENABLED + #define NRF_LOG_LEVEL NRF_SDH_BLE_LOG_LEVEL + #define NRF_LOG_INFO_COLOR NRF_SDH_BLE_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_SDH_BLE_DEBUG_COLOR +#else + #define NRF_LOG_LEVEL 0 +#endif // NRF_SDH_BLE_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); + + +// Create section set "sdh_ble_observers". +NRF_SECTION_SET_DEF(sdh_ble_observers, nrf_sdh_ble_evt_observer_t, NRF_SDH_BLE_OBSERVER_PRIO_LEVELS); + + +//lint -save -e10 -e19 -e40 -e27 Illegal character (0x24) +#if defined(__CC_ARM) + extern uint32_t Image$$RW_IRAM1$$Base; + uint32_t const * const m_ram_start = &Image$$RW_IRAM1$$Base; +#elif defined(__ICCARM__) + extern uint32_t __ICFEDIT_region_RAM_start__; + uint32_t const * const m_ram_start = &__ICFEDIT_region_RAM_start__; +#elif defined(__SES_ARM) + extern uint32_t __app_ram_start__; + uint32_t const * const m_ram_start = &__app_ram_start__; +#elif defined(__GNUC__) + extern uint32_t __data_start__; + uint32_t const * const m_ram_start = &__data_start__; +#endif +//lint -restore + +#define RAM_START 0x20000000 +#define APP_RAM_START (uint32_t)m_ram_start + + +static bool m_stack_is_enabled; + + +ret_code_t nrf_sdh_ble_app_ram_start_get(uint32_t * p_app_ram_start) +{ + if (p_app_ram_start == NULL) + { + return NRF_ERROR_NULL; + } + + *p_app_ram_start = APP_RAM_START; + + return NRF_SUCCESS; +} + + +ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_start) +{ + uint32_t ret_code; + + ret_code = nrf_sdh_ble_app_ram_start_get(p_ram_start); + if (ret_code != NRF_SUCCESS) + { + return ret_code; + } + +#if defined (S112) || defined(S312) + STATIC_ASSERT(NRF_SDH_BLE_CENTRAL_LINK_COUNT == 0, "When using s112, NRF_SDH_BLE_CENTRAL_LINK_COUNT must be 0."); +#endif + + // Overwrite some of the default settings of the BLE stack. + // If any of the calls to sd_ble_cfg_set() fail, log the error but carry on so that + // wrong RAM settings can be caught by nrf_sdh_ble_enable() and a meaningful error + // message will be printed to the user suggesting the correct value. + ble_cfg_t ble_cfg; + +#if (NRF_SDH_BLE_TOTAL_LINK_COUNT != 0) + // Configure the connection count. + memset(&ble_cfg, 0, sizeof(ble_cfg)); + ble_cfg.conn_cfg.conn_cfg_tag = conn_cfg_tag; + ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count = NRF_SDH_BLE_TOTAL_LINK_COUNT; + ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = NRF_SDH_BLE_GAP_EVENT_LENGTH; + + ret_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, *p_ram_start); + if (ret_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GAP.", + nrf_strerror_get(ret_code)); + } + + // Configure the connection roles. + memset(&ble_cfg, 0, sizeof(ble_cfg)); +#if !defined (S122) + ble_cfg.gap_cfg.role_count_cfg.periph_role_count = NRF_SDH_BLE_PERIPHERAL_LINK_COUNT; +#endif // !defined (S122) +#if !defined (S112) && !defined(S312) && !defined(S113) + ble_cfg.gap_cfg.role_count_cfg.central_role_count = NRF_SDH_BLE_CENTRAL_LINK_COUNT; + ble_cfg.gap_cfg.role_count_cfg.central_sec_count = MIN(NRF_SDH_BLE_CENTRAL_LINK_COUNT, + BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT); +#endif // !defined (S112) && !defined(S312) && !defined(S113) + + ret_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, *p_ram_start); + if (ret_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_GAP_CFG_ROLE_COUNT.", + nrf_strerror_get(ret_code)); + } + + // Configure the maximum ATT MTU. +#if (NRF_SDH_BLE_GATT_MAX_MTU_SIZE != 23) + memset(&ble_cfg, 0x00, sizeof(ble_cfg)); + ble_cfg.conn_cfg.conn_cfg_tag = conn_cfg_tag; + ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_SDH_BLE_GATT_MAX_MTU_SIZE; + + ret_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, *p_ram_start); + if (ret_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GATT.", + nrf_strerror_get(ret_code)); + } +#endif // NRF_SDH_BLE_GATT_MAX_MTU_SIZE != 23 +#endif // NRF_SDH_BLE_TOTAL_LINK_COUNT != 0 + + // Configure number of custom UUIDS. + memset(&ble_cfg, 0, sizeof(ble_cfg)); + ble_cfg.common_cfg.vs_uuid_cfg.vs_uuid_count = NRF_SDH_BLE_VS_UUID_COUNT; + + ret_code = sd_ble_cfg_set(BLE_COMMON_CFG_VS_UUID, &ble_cfg, *p_ram_start); + if (ret_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_COMMON_CFG_VS_UUID.", + nrf_strerror_get(ret_code)); + } + + // Configure the GATTS attribute table. + memset(&ble_cfg, 0x00, sizeof(ble_cfg)); + ble_cfg.gatts_cfg.attr_tab_size.attr_tab_size = NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE; + + ret_code = sd_ble_cfg_set(BLE_GATTS_CFG_ATTR_TAB_SIZE, &ble_cfg, *p_ram_start); + if (ret_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_GATTS_CFG_ATTR_TAB_SIZE.", + nrf_strerror_get(ret_code)); + } + + // Configure Service Changed characteristic. + memset(&ble_cfg, 0x00, sizeof(ble_cfg)); + ble_cfg.gatts_cfg.service_changed.service_changed = NRF_SDH_BLE_SERVICE_CHANGED; + + ret_code = sd_ble_cfg_set(BLE_GATTS_CFG_SERVICE_CHANGED, &ble_cfg, *p_ram_start); + if (ret_code != NRF_SUCCESS) + { + NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_GATTS_CFG_SERVICE_CHANGED.", + nrf_strerror_get(ret_code)); + } + + return NRF_SUCCESS; +} + + +/**@brief Function for finding the end address of the RAM. */ +static uint32_t ram_end_address_get(void) +{ + uint32_t ram_total_size; + +#ifdef NRF51 + uint32_t block_size = NRF_FICR->SIZERAMBLOCKS; + ram_total_size = block_size * NRF_FICR->NUMRAMBLOCK; +#else + ram_total_size = NRF_FICR->INFO.RAM * 1024; +#endif + + return RAM_START + ram_total_size; +} + + +ret_code_t nrf_sdh_ble_enable(uint32_t * const p_app_ram_start) +{ + // Start of RAM, obtained from linker symbol. + uint32_t const app_ram_start_link = *p_app_ram_start; + + ret_code_t ret_code = sd_ble_enable(p_app_ram_start); + if (*p_app_ram_start > app_ram_start_link) + { + NRF_LOG_WARNING("Insufficient RAM allocated for the SoftDevice."); + + NRF_LOG_WARNING("Change the RAM start location from 0x%x to 0x%x.", + app_ram_start_link, *p_app_ram_start); + NRF_LOG_WARNING("Maximum RAM size for application is 0x%x.", + ram_end_address_get() - (*p_app_ram_start)); + } + else + { + NRF_LOG_DEBUG("RAM starts at 0x%x", app_ram_start_link); + if (*p_app_ram_start != app_ram_start_link) + { + NRF_LOG_DEBUG("RAM start location can be adjusted to 0x%x.", *p_app_ram_start); + + NRF_LOG_DEBUG("RAM size for application can be adjusted to 0x%x.", + ram_end_address_get() - (*p_app_ram_start)); + } + } + + if (ret_code == NRF_SUCCESS) + { + m_stack_is_enabled = true; + } + else + { + NRF_LOG_ERROR("sd_ble_enable() returned %s.", nrf_strerror_get(ret_code)); + } + + return ret_code; +} + + +/**@brief Function for polling BLE events. + * + * @param[in] p_context Context of the observer. + */ +static void nrf_sdh_ble_evts_poll(void * p_context) +{ + UNUSED_VARIABLE(p_context); + + ret_code_t ret_code; + + if (!m_stack_is_enabled) + { + return; + } + + while (true) + { + /*lint -save -e(587) */ + __ALIGN(4) uint8_t evt_buffer[NRF_SDH_BLE_EVT_BUF_SIZE]; + /*lint -restore */ + + ble_evt_t * p_ble_evt; + uint16_t evt_len = (uint16_t)sizeof(evt_buffer); + + ret_code = sd_ble_evt_get(evt_buffer, &evt_len); + if (ret_code != NRF_SUCCESS) + { + break; + } + + p_ble_evt = (ble_evt_t *)evt_buffer; + + NRF_LOG_DEBUG("BLE event: 0x%x.", p_ble_evt->header.evt_id); + + // Forward the event to BLE observers. + nrf_section_iter_t iter; + for (nrf_section_iter_init(&iter, &sdh_ble_observers); + nrf_section_iter_get(&iter) != NULL; + nrf_section_iter_next(&iter)) + { + nrf_sdh_ble_evt_observer_t * p_observer; + nrf_sdh_ble_evt_handler_t handler; + + p_observer = (nrf_sdh_ble_evt_observer_t *)nrf_section_iter_get(&iter); + handler = p_observer->handler; + + handler(p_ble_evt, p_observer->p_context); + } + } + + if (ret_code != NRF_ERROR_NOT_FOUND) + { + APP_ERROR_HANDLER(ret_code); + } +} + + +NRF_SDH_STACK_OBSERVER(m_nrf_sdh_ble_evts_poll, NRF_SDH_BLE_STACK_OBSERVER_PRIO) = +{ + .handler = nrf_sdh_ble_evts_poll, + .p_context = NULL, +}; + +#endif // NRF_MODULE_ENABLED(NRF_SDH_BLE) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.h new file mode 100644 index 000000000..d8784b78c --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.h @@ -0,0 +1,184 @@ +/** + * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/**@file + * + * @defgroup nrf_sdh_ble BLE support in SoftDevice Handler + * @{ + * @ingroup nrf_sdh + * @brief This file contains the declarations of types and functions required for BLE stack + * support. + */ + +#ifndef NRF_SDH_BLE_H__ +#define NRF_SDH_BLE_H__ + +#include "app_util.h" +#include "ble.h" +#include "nrf_section_iter.h" +#include "sdk_config.h" +#include "sdk_errors.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Size of the buffer for a BLE event. */ +#define NRF_SDH_BLE_EVT_BUF_SIZE BLE_EVT_LEN_MAX(NRF_SDH_BLE_GATT_MAX_MTU_SIZE) + + +#if !(defined(__LINT__)) +/**@brief Macro for registering @ref nrf_sdh_soc_evt_observer_t. Modules that want to be + * notified about SoC events must register the handler using this macro. + * + * @details This macro places the observer in a section named "sdh_soc_observers". + * + * @param[in] _name Observer name. + * @param[in] _prio Priority of the observer event handler. + * The smaller the number, the higher the priority. + * @param[in] _handler BLE event handler. + * @param[in] _context Parameter to the event handler. + * @hideinitializer + */ +#define NRF_SDH_BLE_OBSERVER(_name, _prio, _handler, _context) \ +STATIC_ASSERT(NRF_SDH_BLE_ENABLED, "NRF_SDH_BLE_ENABLED not set!"); \ +STATIC_ASSERT(_prio < NRF_SDH_BLE_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \ +NRF_SECTION_SET_ITEM_REGISTER(sdh_ble_observers, _prio, static nrf_sdh_ble_evt_observer_t _name) = \ +{ \ + .handler = _handler, \ + .p_context = _context \ +} + +/**@brief Macro for registering an array of @ref nrf_sdh_ble_evt_observer_t. + * Modules that want to be notified about SoC events must register the handler using + * this macro. + * + * Each observer's handler will be dispatched an event with its relative context from @p _context. + * This macro places the observer in a section named "sdh_ble_observers". + * + * @param[in] _name Observer name. + * @param[in] _prio Priority of the observer event handler. + * The smaller the number, the higher the priority. + * @param[in] _handler BLE event handler. + * @param[in] _context An array of parameters to the event handler. + * @param[in] _cnt Number of observers to register. + * @hideinitializer + */ +#define NRF_SDH_BLE_OBSERVERS(_name, _prio, _handler, _context, _cnt) \ +STATIC_ASSERT(NRF_SDH_BLE_ENABLED, "NRF_SDH_BLE_ENABLED not set!"); \ +STATIC_ASSERT(_prio < NRF_SDH_BLE_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \ +NRF_SECTION_SET_ITEM_REGISTER(sdh_ble_observers, _prio, static nrf_sdh_ble_evt_observer_t _name[_cnt]) = \ +{ \ + MACRO_REPEAT_FOR(_cnt, HANDLER_SET, _handler, _context) \ +} + +#if !(defined(DOXYGEN)) +#define HANDLER_SET(_idx, _handler, _context) \ +{ \ + .handler = _handler, \ + .p_context = _context[_idx], \ +}, +#endif + +#else // __LINT__ + +/* Swallow semicolons */ +/*lint -save -esym(528, *) -esym(529, *) : Symbol not referenced. */ +#define NRF_SDH_BLE_OBSERVER(A, B, C, D) static int semicolon_swallow_##A +#define NRF_SDH_BLE_OBSERVERS(A, B, C, D, E) static int semicolon_swallow_##A +/*lint -restore */ + +#endif + + +/**@brief BLE stack event handler. */ +typedef void (*nrf_sdh_ble_evt_handler_t)(ble_evt_t const * p_ble_evt, void * p_context); + +/**@brief BLE event observer. */ +typedef struct +{ + nrf_sdh_ble_evt_handler_t handler; //!< BLE event handler. + void * p_context; //!< A parameter to the event handler. +} const nrf_sdh_ble_evt_observer_t; + + +/**@brief Function for retrieving the address of the start of application's RAM. + * + * @param[out] p_app_ram_start Address of the start of application's RAM. + * + * @retval NRF_SUCCESS If the address was successfully retrieved. + * @retval NRF_ERROR_NULL If @p p_app_ram_start was @c NULL. + */ +ret_code_t nrf_sdh_ble_app_ram_start_get(uint32_t * p_app_ram_start); + + +/**@brief Set the default BLE stack configuration. + * + * This function configures the BLE stack with the settings specified in the + * SoftDevice handler BLE configuration. The following configurations will be set: + * - Number of peripheral links + * - Number of central links + * - ATT MTU size (for the given connection) + * - Vendor specific UUID count + * - GATTS Attribute table size + * - Service changed + * + * @param[in] conn_cfg_tag The connection to configure. + * @param[out] p_ram_start Application RAM start address. + */ +ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_start); + + +/**@brief Function for configuring and enabling the BLE stack. + * + * @param[in] p_app_ram_start Address of the start of application's RAM. + */ +ret_code_t nrf_sdh_ble_enable(uint32_t * p_app_ram_start); + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_SDH_BLE_H__ + +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble.h new file mode 100644 index 000000000..36303bb6d --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble.h @@ -0,0 +1,679 @@ +/* + * Copyright (c) 2012 - 2020, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_COMMON BLE SoftDevice Common + @{ + @defgroup ble_api Events, type definitions and API calls + @{ + + @brief Module independent events, type definitions and API calls for the BLE SoftDevice. + + */ + +#ifndef BLE_H__ +#define BLE_H__ + +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_err.h" +#include "ble_gap.h" +#include "ble_l2cap.h" +#include "ble_gatt.h" +#include "ble_gattc.h" +#include "ble_gatts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations + * @{ */ + +/** + * @brief Common API SVC numbers. + */ +enum BLE_COMMON_SVCS +{ + SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */ + SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */ + SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific base UUID. */ + SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */ + SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */ + SD_BLE_VERSION_GET, /**< Get the local version information (company ID, Link Layer Version, Link Layer Subversion). */ + SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */ + SD_BLE_OPT_SET, /**< Set a BLE option. */ + SD_BLE_OPT_GET, /**< Get a BLE option. */ + SD_BLE_CFG_SET, /**< Add a configuration to the BLE stack. */ + SD_BLE_UUID_VS_REMOVE, /**< Remove a Vendor Specific base UUID. */ +}; + +/** + * @brief BLE Module Independent Event IDs. + */ +enum BLE_COMMON_EVTS +{ + BLE_EVT_USER_MEM_REQUEST = BLE_EVT_BASE + 0, /**< User Memory request. See @ref ble_evt_user_mem_request_t + \n Reply with @ref sd_ble_user_mem_reply. */ + BLE_EVT_USER_MEM_RELEASE = BLE_EVT_BASE + 1, /**< User Memory release. See @ref ble_evt_user_mem_release_t */ +}; + +/**@brief BLE Connection Configuration IDs. + * + * IDs that uniquely identify a connection configuration. + */ +enum BLE_CONN_CFGS +{ + BLE_CONN_CFG_GAP = BLE_CONN_CFG_BASE + 0, /**< BLE GAP specific connection configuration. */ + BLE_CONN_CFG_GATTC = BLE_CONN_CFG_BASE + 1, /**< BLE GATTC specific connection configuration. */ + BLE_CONN_CFG_GATTS = BLE_CONN_CFG_BASE + 2, /**< BLE GATTS specific connection configuration. */ + BLE_CONN_CFG_GATT = BLE_CONN_CFG_BASE + 3, /**< BLE GATT specific connection configuration. */ + BLE_CONN_CFG_L2CAP = BLE_CONN_CFG_BASE + 4, /**< BLE L2CAP specific connection configuration. */ +}; + +/**@brief BLE Common Configuration IDs. + * + * IDs that uniquely identify a common configuration. + */ +enum BLE_COMMON_CFGS +{ + BLE_COMMON_CFG_VS_UUID = BLE_CFG_BASE, /**< Vendor specific base UUID configuration */ +}; + +/**@brief Common Option IDs. + * IDs that uniquely identify a common option. + */ +enum BLE_COMMON_OPTS +{ + BLE_COMMON_OPT_PA_LNA = BLE_OPT_BASE + 0, /**< PA and LNA options */ + BLE_COMMON_OPT_CONN_EVT_EXT = BLE_OPT_BASE + 1, /**< Extended connection events option */ + BLE_COMMON_OPT_EXTENDED_RC_CAL = BLE_OPT_BASE + 2, /**< Extended RC calibration option */ +}; + +/** @} */ + +/** @addtogroup BLE_COMMON_DEFINES Defines + * @{ */ + +/** @brief Required pointer alignment for BLE Events. +*/ +#define BLE_EVT_PTR_ALIGNMENT 4 + +/** @brief Leaves the maximum of the two arguments. +*/ +#define BLE_MAX(a, b) ((a) < (b) ? (b) : (a)) + +/** @brief Maximum possible length for BLE Events. + * @note The highest value used for @ref ble_gatt_conn_cfg_t::att_mtu in any connection configuration shall be used as a parameter. + * If that value has not been configured for any connections then @ref BLE_GATT_ATT_MTU_DEFAULT must be used instead. +*/ +#define BLE_EVT_LEN_MAX(ATT_MTU) ( \ + offsetof(ble_evt_t, evt.gattc_evt.params.prim_srvc_disc_rsp.services) + ((ATT_MTU) - 1) / 4 * sizeof(ble_gattc_service_t) \ +) + +/** @defgroup BLE_USER_MEM_TYPES User Memory Types + * @{ */ +#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */ +#define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */ +/** @} */ + +/** @defgroup BLE_UUID_VS_COUNTS Vendor Specific base UUID counts + * @{ + */ +#define BLE_UUID_VS_COUNT_DEFAULT 10 /**< Default VS UUID count. */ +#define BLE_UUID_VS_COUNT_MAX 254 /**< Maximum VS UUID count. */ +/** @} */ + +/** @defgroup BLE_COMMON_CFG_DEFAULTS Configuration defaults. + * @{ + */ +#define BLE_CONN_CFG_TAG_DEFAULT 0 /**< Default configuration tag, SoftDevice default connection configuration. */ + +/** @} */ + +/** @} */ + +/** @addtogroup BLE_COMMON_STRUCTURES Structures + * @{ */ + +/**@brief User Memory Block. */ +typedef struct +{ + uint8_t *p_mem; /**< Pointer to the start of the user memory block. */ + uint16_t len; /**< Length in bytes of the user memory block. */ +} ble_user_mem_block_t; + +/**@brief Event structure for @ref BLE_EVT_USER_MEM_REQUEST. */ +typedef struct +{ + uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */ +} ble_evt_user_mem_request_t; + +/**@brief Event structure for @ref BLE_EVT_USER_MEM_RELEASE. */ +typedef struct +{ + uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */ + ble_user_mem_block_t mem_block; /**< User memory block */ +} ble_evt_user_mem_release_t; + +/**@brief Event structure for events not associated with a specific function module. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which this event occurred. */ + union + { + ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */ + ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */ + } params; /**< Event parameter union. */ +} ble_common_evt_t; + +/**@brief BLE Event header. */ +typedef struct +{ + uint16_t evt_id; /**< Value from a BLE__EVT series. */ + uint16_t evt_len; /**< Length in octets including this header. */ +} ble_evt_hdr_t; + +/**@brief Common BLE Event type, wrapping the module specific event reports. */ +typedef struct +{ + ble_evt_hdr_t header; /**< Event header. */ + union + { + ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */ + ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */ + ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */ + ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */ + ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */ + } evt; /**< Event union. */ +} ble_evt_t; + + +/** + * @brief Version Information. + */ +typedef struct +{ + uint8_t version_number; /**< Link Layer Version number. See https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer for assigned values. */ + uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */ + uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */ +} ble_version_t; + +/** + * @brief Configuration parameters for the PA and LNA. + */ +typedef struct +{ + uint8_t enable :1; /**< Enable toggling for this amplifier */ + uint8_t active_high :1; /**< Set the pin to be active high */ + uint8_t gpio_pin :6; /**< The GPIO pin to toggle for this amplifier */ +} ble_pa_lna_cfg_t; + +/** + * @brief PA & LNA GPIO toggle configuration + * + * This option configures the SoftDevice to toggle pins when the radio is active for use with a power amplifier and/or + * a low noise amplifier. + * + * Toggling the pins is achieved by using two PPI channels and a GPIOTE channel. The hardware channel IDs are provided + * by the application and should be regarded as reserved as long as any PA/LNA toggling is enabled. + * + * @note @ref sd_ble_opt_get is not supported for this option. + * @note Setting this option while the radio is in use (i.e. any of the roles are active) may have undefined consequences + * and must be avoided by the application. + */ +typedef struct +{ + ble_pa_lna_cfg_t pa_cfg; /**< Power Amplifier configuration */ + ble_pa_lna_cfg_t lna_cfg; /**< Low Noise Amplifier configuration */ + + uint8_t ppi_ch_id_set; /**< PPI channel used for radio pin setting */ + uint8_t ppi_ch_id_clr; /**< PPI channel used for radio pin clearing */ + uint8_t gpiote_ch_id; /**< GPIOTE channel used for radio pin toggling */ +} ble_common_opt_pa_lna_t; + +/** + * @brief Configuration of extended BLE connection events. + * + * When enabled the SoftDevice will dynamically extend the connection event when possible. + * + * The connection event length is controlled by the connection configuration as set by @ref ble_gap_conn_cfg_t::event_length. + * The connection event can be extended if there is time to send another packet pair before the start of the next connection interval, + * and if there are no conflicts with other BLE roles requesting radio time. + * + * @note @ref sd_ble_opt_get is not supported for this option. + */ +typedef struct +{ + uint8_t enable : 1; /**< Enable extended BLE connection events, disabled by default. */ +} ble_common_opt_conn_evt_ext_t; + +/** + * @brief Enable/disable extended RC calibration. + * + * If extended RC calibration is enabled and the internal RC oscillator (@ref NRF_CLOCK_LF_SRC_RC) is used as the SoftDevice + * LFCLK source, the SoftDevice as a peripheral will by default try to increase the receive window if two consecutive packets + * are not received. If it turns out that the packets were not received due to clock drift, the RC calibration is started. + * This calibration comes in addition to the periodic calibration that is configured by @ref sd_softdevice_enable(). When + * using only peripheral connections, the periodic calibration can therefore be configured with a much longer interval as the + * peripheral will be able to detect and adjust automatically to clock drift, and calibrate on demand. + * + * If extended RC calibration is disabled and the internal RC oscillator is used as the SoftDevice LFCLK source, the + * RC oscillator is calibrated periodically as configured by @ref sd_softdevice_enable(). + * + * @note @ref sd_ble_opt_get is not supported for this option. + */ +typedef struct +{ + uint8_t enable : 1; /**< Enable extended RC calibration, enabled by default. */ +} ble_common_opt_extended_rc_cal_t; + +/**@brief Option structure for common options. */ +typedef union +{ + ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */ + ble_common_opt_conn_evt_ext_t conn_evt_ext; /**< Parameters for enabling extended connection events. */ + ble_common_opt_extended_rc_cal_t extended_rc_cal; /**< Parameters for enabling extended RC calibration. */ +} ble_common_opt_t; + +/**@brief Common BLE Option type, wrapping the module specific options. */ +typedef union +{ + ble_common_opt_t common_opt; /**< COMMON options, opt_id in @ref BLE_COMMON_OPTS series. */ + ble_gap_opt_t gap_opt; /**< GAP option, opt_id in @ref BLE_GAP_OPTS series. */ + ble_gattc_opt_t gattc_opt; /**< GATTC option, opt_id in @ref BLE_GATTC_OPTS series. */ +} ble_opt_t; + +/**@brief BLE connection configuration type, wrapping the module specific configurations, set with + * @ref sd_ble_cfg_set. + * + * @note Connection configurations don't have to be set. + * In the case that no configurations has been set, or fewer connection configurations has been set than enabled connections, + * the default connection configuration will be automatically added for the remaining connections. + * When creating connections with the default configuration, @ref BLE_CONN_CFG_TAG_DEFAULT should be used in + * place of @ref ble_conn_cfg_t::conn_cfg_tag. + * + * @sa sd_ble_gap_adv_start() + * @sa sd_ble_gap_connect() + * + * @mscs + * @mmsc{@ref BLE_CONN_CFG} + * @endmscs + + */ +typedef struct +{ + uint8_t conn_cfg_tag; /**< The application chosen tag it can use with the + @ref sd_ble_gap_adv_start() and @ref sd_ble_gap_connect() calls + to select this configuration when creating a connection. + Must be different for all connection configurations added and not @ref BLE_CONN_CFG_TAG_DEFAULT. */ + union { + ble_gap_conn_cfg_t gap_conn_cfg; /**< GAP connection configuration, cfg_id is @ref BLE_CONN_CFG_GAP. */ + ble_gattc_conn_cfg_t gattc_conn_cfg; /**< GATTC connection configuration, cfg_id is @ref BLE_CONN_CFG_GATTC. */ + ble_gatts_conn_cfg_t gatts_conn_cfg; /**< GATTS connection configuration, cfg_id is @ref BLE_CONN_CFG_GATTS. */ + ble_gatt_conn_cfg_t gatt_conn_cfg; /**< GATT connection configuration, cfg_id is @ref BLE_CONN_CFG_GATT. */ + ble_l2cap_conn_cfg_t l2cap_conn_cfg; /**< L2CAP connection configuration, cfg_id is @ref BLE_CONN_CFG_L2CAP. */ + } params; /**< Connection configuration union. */ +} ble_conn_cfg_t; + +/** + * @brief Configuration of Vendor Specific base UUIDs, set with @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_INVALID_PARAM Too many UUIDs configured. + */ +typedef struct +{ + uint8_t vs_uuid_count; /**< Number of 128-bit Vendor Specific base UUID bases to allocate memory for. + Default value is @ref BLE_UUID_VS_COUNT_DEFAULT. Maximum value is + @ref BLE_UUID_VS_COUNT_MAX. */ +} ble_common_cfg_vs_uuid_t; + +/**@brief Common BLE Configuration type, wrapping the common configurations. */ +typedef union +{ + ble_common_cfg_vs_uuid_t vs_uuid_cfg; /**< Vendor Specific base UUID configuration, cfg_id is @ref BLE_COMMON_CFG_VS_UUID. */ +} ble_common_cfg_t; + +/**@brief BLE Configuration type, wrapping the module specific configurations. */ +typedef union +{ + ble_conn_cfg_t conn_cfg; /**< Connection specific configurations, cfg_id in @ref BLE_CONN_CFGS series. */ + ble_common_cfg_t common_cfg; /**< Global common configurations, cfg_id in @ref BLE_COMMON_CFGS series. */ + ble_gap_cfg_t gap_cfg; /**< Global GAP configurations, cfg_id in @ref BLE_GAP_CFGS series. */ + ble_gatts_cfg_t gatts_cfg; /**< Global GATTS configuration, cfg_id in @ref BLE_GATTS_CFGS series. */ +} ble_cfg_t; + +/** @} */ + +/** @addtogroup BLE_COMMON_FUNCTIONS Functions + * @{ */ + +/**@brief Enable the BLE stack + * + * @param[in, out] p_app_ram_base Pointer to a variable containing the start address of the + * application RAM region (APP_RAM_BASE). On return, this will + * contain the minimum start address of the application RAM region + * required by the SoftDevice for this configuration. + * @warning After this call, the SoftDevice may generate several events. The list of events provided + * below require the application to initiate a SoftDevice API call. The corresponding API call + * is referenced in the event documentation. + * If the application fails to do so, the BLE connection may timeout, or the SoftDevice may stop + * communicating with the peer device. + * - @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST + * - @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST + * - @ref BLE_GAP_EVT_PHY_UPDATE_REQUEST + * - @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST + * - @ref BLE_GAP_EVT_SEC_INFO_REQUEST + * - @ref BLE_GAP_EVT_SEC_REQUEST + * - @ref BLE_GAP_EVT_AUTH_KEY_REQUEST + * - @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST + * - @ref BLE_EVT_USER_MEM_REQUEST + * - @ref BLE_L2CAP_EVT_CH_SETUP_REQUEST + * + * @note The memory requirement for a specific configuration will not increase between SoftDevices + * with the same major version number. + * + * @note At runtime the IC's RAM is split into 2 regions: The SoftDevice RAM region is located + * between 0x20000000 and APP_RAM_BASE-1 and the application's RAM region is located between + * APP_RAM_BASE and the start of the call stack. + * + * @details This call initializes the BLE stack, no BLE related function other than @ref + * sd_ble_cfg_set can be called before this one. + * + * @mscs + * @mmsc{@ref BLE_COMMON_ENABLE} + * @endmscs + * + * @retval ::NRF_SUCCESS The BLE stack has been initialized successfully. + * @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized and cannot be reinitialized. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. + * @retval ::NRF_ERROR_NO_MEM One or more of the following is true: + * - The amount of memory assigned to the SoftDevice by *p_app_ram_base is not + * large enough to fit this configuration's memory requirement. Check *p_app_ram_base + * and set the start address of the application RAM region accordingly. + * - Dynamic part of the SoftDevice RAM region is larger then 64 kB which + * is currently not supported. + * @retval ::NRF_ERROR_RESOURCES The total number of L2CAP Channels configured using @ref sd_ble_cfg_set is too large. + */ +SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(uint32_t * p_app_ram_base)); + +/**@brief Add configurations for the BLE stack + * + * @param[in] cfg_id Config ID, see @ref BLE_CONN_CFGS, @ref BLE_COMMON_CFGS, @ref + * BLE_GAP_CFGS or @ref BLE_GATTS_CFGS. + * @param[in] p_cfg Pointer to a ble_cfg_t structure containing the configuration value. + * @param[in] app_ram_base The start address of the application RAM region (APP_RAM_BASE). + * See @ref sd_ble_enable for details about APP_RAM_BASE. + * + * @note The memory requirement for a specific configuration will not increase between SoftDevices + * with the same major version number. + * + * @note If a configuration is set more than once, the last one set is the one that takes effect on + * @ref sd_ble_enable. + * + * @note Any part of the BLE stack that is NOT configured with @ref sd_ble_cfg_set will have default + * configuration. + * + * @note @ref sd_ble_cfg_set may be called at any time when the SoftDevice is enabled (see @ref + * sd_softdevice_enable) while the BLE part of the SoftDevice is not enabled (see @ref + * sd_ble_enable). + * + * @note Error codes for the configurations are described in the configuration structs. + * + * @mscs + * @mmsc{@ref BLE_COMMON_ENABLE} + * @endmscs + * + * @retval ::NRF_SUCCESS The configuration has been added successfully. + * @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid cfg_id supplied. + * @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by app_ram_base is not + * large enough to fit this configuration's memory requirement. + */ +SVCALL(SD_BLE_CFG_SET, uint32_t, sd_ble_cfg_set(uint32_t cfg_id, ble_cfg_t const * p_cfg, uint32_t app_ram_base)); + +/**@brief Get an event from the pending events queue. + * + * @param[out] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length. + * This buffer must be aligned to the extend defined by @ref BLE_EVT_PTR_ALIGNMENT. + * The buffer should be interpreted as a @ref ble_evt_t struct. + * @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length. + * + * @details This call allows the application to pull a BLE event from the BLE stack. The application is signaled that + * an event is available from the BLE stack by the triggering of the SD_EVT_IRQn interrupt. + * The application is free to choose whether to call this function from thread mode (main context) or directly from the + * Interrupt Service Routine that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher + * priority than the application, this function should be called in a loop (until @ref NRF_ERROR_NOT_FOUND is returned) + * every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack. Failure to do so + * could potentially leave events in the internal queue without the application being aware of this fact. + * + * Sizing the p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to + * be copied into application memory. If the buffer provided is not large enough to fit the entire contents of the event, + * @ref NRF_ERROR_DATA_SIZE will be returned and the application can then call again with a larger buffer size. + * The maximum possible event length is defined by @ref BLE_EVT_LEN_MAX. The application may also "peek" the event length + * by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return: + * + * \code + * uint16_t len; + * errcode = sd_ble_evt_get(NULL, &len); + * \endcode + * + * @mscs + * @mmsc{@ref BLE_COMMON_IRQ_EVT_MSC} + * @mmsc{@ref BLE_COMMON_THREAD_EVT_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Event pulled and stored into the supplied buffer. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. + * @retval ::NRF_ERROR_NOT_FOUND No events ready to be pulled. + * @retval ::NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer. + */ +SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len)); + + +/**@brief Add a Vendor Specific base UUID. + * + * @details This call enables the application to add a Vendor Specific base UUID to the BLE stack's table, for later + * use with all other modules and APIs. This then allows the application to use the shorter, 24-bit @ref ble_uuid_t + * format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code + * paths. This is accomplished by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses + * for all other 128-bit UUIDs. The type field in the @ref ble_uuid_t structure is an index (relative to + * @ref BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the UUID field + * in the same structure contains the 2 bytes at indexes 12 and 13. The number of possible 128-bit UUIDs available to + * the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536, + * although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array. + * + * @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by + * the 16-bit uuid field in @ref ble_uuid_t. + * + * @note If a UUID is already present in the BLE stack's internal table, the corresponding index will be returned in + * p_uuid_type along with an @ref NRF_SUCCESS error code. + * + * @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific base UUID disregarding + * bytes 12 and 13. + * @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponding to this UUID will be stored. + * + * @retval ::NRF_SUCCESS Successfully added the Vendor Specific base UUID. + * @retval ::NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid. + * @retval ::NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs. + */ +SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type)); + + +/**@brief Remove a Vendor Specific base UUID. + * + * @details This call removes a Vendor Specific base UUID. This function allows + * the application to reuse memory allocated for Vendor Specific base UUIDs. + * + * @note Currently this function can only be called with a p_uuid_type set to @ref BLE_UUID_TYPE_UNKNOWN or the last added UUID type. + * + * @param[inout] p_uuid_type Pointer to a uint8_t where its value matches the UUID type in @ref ble_uuid_t::type to be removed. + * If the type is set to @ref BLE_UUID_TYPE_UNKNOWN, or the pointer is NULL, the last Vendor Specific + * base UUID will be removed. If the function returns successfully, the UUID type that was removed will + * be written back to @p p_uuid_type. If function returns with a failure, it contains the last type that + * is in use by the ATT Server. + * + * @retval ::NRF_SUCCESS Successfully removed the Vendor Specific base UUID. + * @retval ::NRF_ERROR_INVALID_ADDR If p_uuid_type is invalid. + * @retval ::NRF_ERROR_INVALID_PARAM If p_uuid_type points to a non-valid UUID type. + * @retval ::NRF_ERROR_FORBIDDEN If the Vendor Specific base UUID is in use by the ATT Server. + */ +SVCALL(SD_BLE_UUID_VS_REMOVE, uint32_t, sd_ble_uuid_vs_remove(uint8_t *p_uuid_type)); + + +/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure. + * + * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared + * to the corresponding ones in each entry of the table of Vendor Specific base UUIDs + * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index + * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type. + * + * @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE. + * + * @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes). + * @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes. + * @param[out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in. + * + * @retval ::NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_LENGTH Invalid UUID length. + * @retval ::NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs. + */ +SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid)); + + +/** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit). + * + * @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validity and size of p_uuid is computed. + * + * @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes. + * @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes). + * @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored. + * + * @retval ::NRF_SUCCESS Successfully encoded into the buffer. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid UUID type. + */ +SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le)); + + +/**@brief Get Version Information. + * + * @details This call allows the application to get the BLE stack version information. + * + * @param[out] p_version Pointer to a ble_version_t structure to be filled in. + * + * @retval ::NRF_SUCCESS Version information stored successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY The BLE stack is busy (typically doing a locally-initiated disconnection procedure). + */ +SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version)); + + +/**@brief Provide a user memory block. + * + * @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_block Pointer to a user memory block structure or NULL if memory is managed by the application. + * + * @mscs + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_PEER_CANCEL_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_NOAUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Successfully queued a response to the peer. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_LENGTH Invalid user memory block length supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection state or no user memory request pending. + */ +SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block)); + +/**@brief Set a BLE option. + * + * @details This call allows the application to set the value of an option. + * + * @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS, @ref BLE_GAP_OPTS, and @ref BLE_GATTC_OPTS. + * @param[in] p_opt Pointer to a @ref ble_opt_t structure containing the option value. + * + * @retval ::NRF_SUCCESS Option set successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. + * @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time. + * @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed. + */ +SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt)); + + +/**@brief Get a BLE option. + * + * @details This call allows the application to retrieve the value of an option. + * + * @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS. + * @param[out] p_opt Pointer to a ble_opt_t structure to be filled in. + * + * @retval ::NRF_SUCCESS Option retrieved successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. + * @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time. + * @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed. + * @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported. + * + */ +SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt)); + +/** @} */ +#ifdef __cplusplus +} +#endif +#endif /* BLE_H__ */ + +/** + @} + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_err.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_err.h new file mode 100644 index 000000000..1b4820dc3 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_err.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012 - 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_COMMON + @{ + @addtogroup nrf_error + @{ + @ingroup BLE_COMMON + @} + + @defgroup ble_err General error codes + @{ + + @brief General error code definitions for the BLE API. + + @ingroup BLE_COMMON +*/ +#ifndef NRF_BLE_ERR_H__ +#define NRF_BLE_ERR_H__ + +#include "nrf_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* @defgroup BLE_ERRORS Error Codes + * @{ */ +#define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */ +#define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */ +#define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */ +#define BLE_ERROR_INVALID_ADV_HANDLE (NRF_ERROR_STK_BASE_NUM+0x004) /**< Invalid advertising handle. */ +#define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x005) /**< Invalid role. */ +#define BLE_ERROR_BLOCKED_BY_OTHER_LINKS (NRF_ERROR_STK_BASE_NUM+0x006) /**< The attempt to change link settings failed due to the scheduling of other links. */ +/** @} */ + + +/** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges + * @brief Assignment of subranges for module specific error codes. + * @note For specific error codes, see ble_.h or ble_error_.h. + * @{ */ +#define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */ +#define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */ +#define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */ +#define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */ +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif + + +/** + @} + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gap.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gap.h new file mode 100644 index 000000000..a9677ff7e --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gap.h @@ -0,0 +1,2838 @@ +/* + * Copyright (c) 2011 - 2020, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_GAP Generic Access Profile (GAP) + @{ + @brief Definitions and prototypes for the GAP interface. + */ + +#ifndef BLE_GAP_H__ +#define BLE_GAP_H__ + +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@addtogroup BLE_GAP_ENUMERATIONS Enumerations + * @{ */ + +/**@brief GAP API SVC numbers. + */ +enum BLE_GAP_SVCS +{ + SD_BLE_GAP_ADDR_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */ + SD_BLE_GAP_ADDR_GET = BLE_GAP_SVC_BASE + 1, /**< Get own Bluetooth Address. */ + SD_BLE_GAP_WHITELIST_SET = BLE_GAP_SVC_BASE + 2, /**< Set active whitelist. */ + SD_BLE_GAP_DEVICE_IDENTITIES_SET = BLE_GAP_SVC_BASE + 3, /**< Set device identity list. */ + SD_BLE_GAP_PRIVACY_SET = BLE_GAP_SVC_BASE + 4, /**< Set Privacy settings*/ + SD_BLE_GAP_PRIVACY_GET = BLE_GAP_SVC_BASE + 5, /**< Get Privacy settings*/ + SD_BLE_GAP_ADV_SET_CONFIGURE = BLE_GAP_SVC_BASE + 6, /**< Configure an advertising set. */ + SD_BLE_GAP_ADV_START = BLE_GAP_SVC_BASE + 7, /**< Start Advertising. */ + SD_BLE_GAP_ADV_STOP = BLE_GAP_SVC_BASE + 8, /**< Stop Advertising. */ + SD_BLE_GAP_CONN_PARAM_UPDATE = BLE_GAP_SVC_BASE + 9, /**< Connection Parameter Update. */ + SD_BLE_GAP_DISCONNECT = BLE_GAP_SVC_BASE + 10, /**< Disconnect. */ + SD_BLE_GAP_TX_POWER_SET = BLE_GAP_SVC_BASE + 11, /**< Set TX Power. */ + SD_BLE_GAP_APPEARANCE_SET = BLE_GAP_SVC_BASE + 12, /**< Set Appearance. */ + SD_BLE_GAP_APPEARANCE_GET = BLE_GAP_SVC_BASE + 13, /**< Get Appearance. */ + SD_BLE_GAP_PPCP_SET = BLE_GAP_SVC_BASE + 14, /**< Set PPCP. */ + SD_BLE_GAP_PPCP_GET = BLE_GAP_SVC_BASE + 15, /**< Get PPCP. */ + SD_BLE_GAP_DEVICE_NAME_SET = BLE_GAP_SVC_BASE + 16, /**< Set Device Name. */ + SD_BLE_GAP_DEVICE_NAME_GET = BLE_GAP_SVC_BASE + 17, /**< Get Device Name. */ + SD_BLE_GAP_AUTHENTICATE = BLE_GAP_SVC_BASE + 18, /**< Initiate Pairing/Bonding. */ + SD_BLE_GAP_SEC_PARAMS_REPLY = BLE_GAP_SVC_BASE + 19, /**< Reply with Security Parameters. */ + SD_BLE_GAP_AUTH_KEY_REPLY = BLE_GAP_SVC_BASE + 20, /**< Reply with an authentication key. */ + SD_BLE_GAP_LESC_DHKEY_REPLY = BLE_GAP_SVC_BASE + 21, /**< Reply with an LE Secure Connections DHKey. */ + SD_BLE_GAP_KEYPRESS_NOTIFY = BLE_GAP_SVC_BASE + 22, /**< Notify of a keypress during an authentication procedure. */ + SD_BLE_GAP_LESC_OOB_DATA_GET = BLE_GAP_SVC_BASE + 23, /**< Get the local LE Secure Connections OOB data. */ + SD_BLE_GAP_LESC_OOB_DATA_SET = BLE_GAP_SVC_BASE + 24, /**< Set the remote LE Secure Connections OOB data. */ + SD_BLE_GAP_ENCRYPT = BLE_GAP_SVC_BASE + 25, /**< Initiate encryption procedure. */ + SD_BLE_GAP_SEC_INFO_REPLY = BLE_GAP_SVC_BASE + 26, /**< Reply with Security Information. */ + SD_BLE_GAP_CONN_SEC_GET = BLE_GAP_SVC_BASE + 27, /**< Obtain connection security level. */ + SD_BLE_GAP_RSSI_START = BLE_GAP_SVC_BASE + 28, /**< Start reporting of changes in RSSI. */ + SD_BLE_GAP_RSSI_STOP = BLE_GAP_SVC_BASE + 29, /**< Stop reporting of changes in RSSI. */ + SD_BLE_GAP_SCAN_START = BLE_GAP_SVC_BASE + 30, /**< Start Scanning. */ + SD_BLE_GAP_SCAN_STOP = BLE_GAP_SVC_BASE + 31, /**< Stop Scanning. */ + SD_BLE_GAP_CONNECT = BLE_GAP_SVC_BASE + 32, /**< Connect. */ + SD_BLE_GAP_CONNECT_CANCEL = BLE_GAP_SVC_BASE + 33, /**< Cancel ongoing connection procedure. */ + SD_BLE_GAP_RSSI_GET = BLE_GAP_SVC_BASE + 34, /**< Get the last RSSI sample. */ + SD_BLE_GAP_PHY_UPDATE = BLE_GAP_SVC_BASE + 35, /**< Initiate or respond to a PHY Update Procedure. */ + SD_BLE_GAP_DATA_LENGTH_UPDATE = BLE_GAP_SVC_BASE + 36, /**< Initiate or respond to a Data Length Update Procedure. */ + SD_BLE_GAP_QOS_CHANNEL_SURVEY_START = BLE_GAP_SVC_BASE + 37, /**< Start Quality of Service (QoS) channel survey module. */ + SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP = BLE_GAP_SVC_BASE + 38, /**< Stop Quality of Service (QoS) channel survey module. */ + SD_BLE_GAP_ADV_ADDR_GET = BLE_GAP_SVC_BASE + 39, /**< Get the Address used on air while Advertising. */ + SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET = BLE_GAP_SVC_BASE + 40, /**< Get the next connection event counter. */ + SD_BLE_GAP_CONN_EVT_TRIGGER_START = BLE_GAP_SVC_BASE + 41, /** Start triggering a given task on connection event start. */ + SD_BLE_GAP_CONN_EVT_TRIGGER_STOP = BLE_GAP_SVC_BASE + 42, /** Stop triggering the task configured using @ref sd_ble_gap_conn_evt_trigger_start. */ +}; + +/**@brief GAP Event IDs. + * IDs that uniquely identify an event coming from the stack to the application. + */ +enum BLE_GAP_EVTS +{ + BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connected to peer. \n See @ref ble_gap_evt_connected_t */ + BLE_GAP_EVT_DISCONNECTED = BLE_GAP_EVT_BASE + 1, /**< Disconnected from peer. \n See @ref ble_gap_evt_disconnected_t. */ + BLE_GAP_EVT_CONN_PARAM_UPDATE = BLE_GAP_EVT_BASE + 2, /**< Connection Parameters updated. \n See @ref ble_gap_evt_conn_param_update_t. */ + BLE_GAP_EVT_SEC_PARAMS_REQUEST = BLE_GAP_EVT_BASE + 3, /**< Request to provide security parameters. \n Reply with @ref sd_ble_gap_sec_params_reply. \n See @ref ble_gap_evt_sec_params_request_t. */ + BLE_GAP_EVT_SEC_INFO_REQUEST = BLE_GAP_EVT_BASE + 4, /**< Request to provide security information. \n Reply with @ref sd_ble_gap_sec_info_reply. \n See @ref ble_gap_evt_sec_info_request_t. */ + BLE_GAP_EVT_PASSKEY_DISPLAY = BLE_GAP_EVT_BASE + 5, /**< Request to display a passkey to the user. \n In LESC Numeric Comparison, reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_passkey_display_t. */ + BLE_GAP_EVT_KEY_PRESSED = BLE_GAP_EVT_BASE + 6, /**< Notification of a keypress on the remote device.\n See @ref ble_gap_evt_key_pressed_t */ + BLE_GAP_EVT_AUTH_KEY_REQUEST = BLE_GAP_EVT_BASE + 7, /**< Request to provide an authentication key. \n Reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_auth_key_request_t. */ + BLE_GAP_EVT_LESC_DHKEY_REQUEST = BLE_GAP_EVT_BASE + 8, /**< Request to calculate an LE Secure Connections DHKey. \n Reply with @ref sd_ble_gap_lesc_dhkey_reply. \n See @ref ble_gap_evt_lesc_dhkey_request_t */ + BLE_GAP_EVT_AUTH_STATUS = BLE_GAP_EVT_BASE + 9, /**< Authentication procedure completed with status. \n See @ref ble_gap_evt_auth_status_t. */ + BLE_GAP_EVT_CONN_SEC_UPDATE = BLE_GAP_EVT_BASE + 10, /**< Connection security updated. \n See @ref ble_gap_evt_conn_sec_update_t. */ + BLE_GAP_EVT_TIMEOUT = BLE_GAP_EVT_BASE + 11, /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */ + BLE_GAP_EVT_RSSI_CHANGED = BLE_GAP_EVT_BASE + 12, /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */ + BLE_GAP_EVT_ADV_REPORT = BLE_GAP_EVT_BASE + 13, /**< Advertising report. \n See @ref ble_gap_evt_adv_report_t. */ + BLE_GAP_EVT_SEC_REQUEST = BLE_GAP_EVT_BASE + 14, /**< Security Request. \n Reply with @ref sd_ble_gap_authenticate + \n or with @ref sd_ble_gap_encrypt if required security information is available +. \n See @ref ble_gap_evt_sec_request_t. */ + BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 15, /**< Connection Parameter Update Request. \n Reply with @ref sd_ble_gap_conn_param_update. \n See @ref ble_gap_evt_conn_param_update_request_t. */ + BLE_GAP_EVT_SCAN_REQ_REPORT = BLE_GAP_EVT_BASE + 16, /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */ + BLE_GAP_EVT_PHY_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 17, /**< PHY Update Request. \n Reply with @ref sd_ble_gap_phy_update. \n See @ref ble_gap_evt_phy_update_request_t. */ + BLE_GAP_EVT_PHY_UPDATE = BLE_GAP_EVT_BASE + 18, /**< PHY Update Procedure is complete. \n See @ref ble_gap_evt_phy_update_t. */ + BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 19, /**< Data Length Update Request. \n Reply with @ref sd_ble_gap_data_length_update. \n See @ref ble_gap_evt_data_length_update_request_t. */ + BLE_GAP_EVT_DATA_LENGTH_UPDATE = BLE_GAP_EVT_BASE + 20, /**< LL Data Channel PDU payload length updated. \n See @ref ble_gap_evt_data_length_update_t. */ + BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT = BLE_GAP_EVT_BASE + 21, /**< Channel survey report. \n See @ref ble_gap_evt_qos_channel_survey_report_t. */ + BLE_GAP_EVT_ADV_SET_TERMINATED = BLE_GAP_EVT_BASE + 22, /**< Advertising set terminated. \n See @ref ble_gap_evt_adv_set_terminated_t. */ +}; + +/**@brief GAP Option IDs. + * IDs that uniquely identify a GAP option. + */ +enum BLE_GAP_OPTS +{ + BLE_GAP_OPT_CH_MAP = BLE_GAP_OPT_BASE, /**< Channel Map. @ref ble_gap_opt_ch_map_t */ + BLE_GAP_OPT_LOCAL_CONN_LATENCY = BLE_GAP_OPT_BASE + 1, /**< Local connection latency. @ref ble_gap_opt_local_conn_latency_t */ + BLE_GAP_OPT_PASSKEY = BLE_GAP_OPT_BASE + 2, /**< Set passkey. @ref ble_gap_opt_passkey_t */ + BLE_GAP_OPT_COMPAT_MODE_1 = BLE_GAP_OPT_BASE + 3, /**< Compatibility mode. @ref ble_gap_opt_compat_mode_1_t */ + BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT = BLE_GAP_OPT_BASE + 4, /**< Set Authenticated payload timeout. @ref ble_gap_opt_auth_payload_timeout_t */ + BLE_GAP_OPT_SLAVE_LATENCY_DISABLE = BLE_GAP_OPT_BASE + 5, /**< Disable slave latency. @ref ble_gap_opt_slave_latency_disable_t */ +}; + +/**@brief GAP Configuration IDs. + * + * IDs that uniquely identify a GAP configuration. + */ +enum BLE_GAP_CFGS +{ + BLE_GAP_CFG_ROLE_COUNT = BLE_GAP_CFG_BASE, /**< Role count configuration. */ + BLE_GAP_CFG_DEVICE_NAME = BLE_GAP_CFG_BASE + 1, /**< Device name configuration. */ + BLE_GAP_CFG_PPCP_INCL_CONFIG = BLE_GAP_CFG_BASE + 2, /**< Peripheral Preferred Connection Parameters characteristic + inclusion configuration. */ + BLE_GAP_CFG_CAR_INCL_CONFIG = BLE_GAP_CFG_BASE + 3, /**< Central Address Resolution characteristic + inclusion configuration. */ +}; + +/**@brief GAP TX Power roles. + */ +enum BLE_GAP_TX_POWER_ROLES +{ + BLE_GAP_TX_POWER_ROLE_ADV = 1, /**< Advertiser role. */ + BLE_GAP_TX_POWER_ROLE_SCAN_INIT = 2, /**< Scanner and initiator role. */ + BLE_GAP_TX_POWER_ROLE_CONN = 3, /**< Connection role. */ +}; + +/** @} */ + +/**@addtogroup BLE_GAP_DEFINES Defines + * @{ */ + +/**@defgroup BLE_ERRORS_GAP SVC return values specific to GAP + * @{ */ +#define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */ +#define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */ +#define BLE_ERROR_GAP_INVALID_BLE_ADDR (NRF_GAP_ERR_BASE + 0x002) /**< The upper two bits of the address do not correspond to the specified address type. */ +#define BLE_ERROR_GAP_WHITELIST_IN_USE (NRF_GAP_ERR_BASE + 0x003) /**< Attempt to modify the whitelist while already in use by another operation. */ +#define BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE (NRF_GAP_ERR_BASE + 0x004) /**< Attempt to modify the device identity list while already in use by another operation. */ +#define BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE (NRF_GAP_ERR_BASE + 0x005) /**< The device identity list contains entries with duplicate identity addresses. */ +/**@} */ + + +/**@defgroup BLE_GAP_ROLES GAP Roles + * @{ */ +#define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */ +#define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */ +#define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */ +/**@} */ + + +/**@defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources + * @{ */ +#define BLE_GAP_TIMEOUT_SRC_SCAN 0x01 /**< Scanning timeout. */ +#define BLE_GAP_TIMEOUT_SRC_CONN 0x02 /**< Connection timeout. */ +#define BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD 0x03 /**< Authenticated payload timeout. */ +/**@} */ + + +/**@defgroup BLE_GAP_ADDR_TYPES GAP Address types + * @{ */ +#define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public (identity) address.*/ +#define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random static (identity) address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Random private resolvable address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Random private non-resolvable address. */ +#define BLE_GAP_ADDR_TYPE_ANONYMOUS 0x7F /**< An advertiser may advertise without its address. + This type of advertising is called anonymous. */ +/**@} */ + + +/**@brief The default interval in seconds at which a private address is refreshed. */ +#define BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S (900) /* 15 minutes. */ +/**@brief The maximum interval in seconds at which a private address can be refreshed. */ +#define BLE_GAP_MAX_PRIVATE_ADDR_CYCLE_INTERVAL_S (41400) /* 11 hours 30 minutes. */ + + +/** @brief BLE address length. */ +#define BLE_GAP_ADDR_LEN (6) + +/**@defgroup BLE_GAP_PRIVACY_MODES Privacy modes + * @{ */ +#define BLE_GAP_PRIVACY_MODE_OFF 0x00 /**< Device will send and accept its identity address for its own address. */ +#define BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY 0x01 /**< Device will send and accept only private addresses for its own address. */ +#define BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY 0x02 /**< Device will send and accept only private addresses for its own address, + and will not accept a peer using identity address as sender address when + the peer IRK is exchanged, non-zero and added to the identity list. */ +/**@} */ + +/** @brief Invalid power level. */ +#define BLE_GAP_POWER_LEVEL_INVALID 127 + +/** @brief Advertising set handle not set. */ +#define BLE_GAP_ADV_SET_HANDLE_NOT_SET (0xFF) + +/** @brief The default number of advertising sets. */ +#define BLE_GAP_ADV_SET_COUNT_DEFAULT (1) + +/** @brief The maximum number of advertising sets supported by this SoftDevice. */ +#define BLE_GAP_ADV_SET_COUNT_MAX (1) + +/**@defgroup BLE_GAP_ADV_SET_DATA_SIZES Advertising data sizes. + * @{ */ +#define BLE_GAP_ADV_SET_DATA_SIZE_MAX (31) /**< Maximum data length for an advertising set. + If more advertising data is required, use extended advertising instead. */ +#define BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED (255) /**< Maximum supported data length for an extended advertising set. */ + +#define BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED (238) /**< Maximum supported data length for an extended connectable advertising set. */ +/**@}. */ + +/** @brief Set ID not available in advertising report. */ +#define BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE 0xFF + +/**@defgroup BLE_GAP_EVT_ADV_SET_TERMINATED_REASON GAP Advertising Set Terminated reasons + * @{ */ +#define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_TIMEOUT 0x01 /**< Timeout value reached. */ +#define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_LIMIT_REACHED 0x02 /**< @ref ble_gap_adv_params_t::max_adv_evts was reached. */ +/**@} */ + +/**@defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format + * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm + * @{ */ +#define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */ +#define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */ +#define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */ +#define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */ +#define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */ +#define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */ +#define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */ +#define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */ +#define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */ +#define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */ +#define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data - 16-bit UUID. */ +#define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */ +#define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */ +#define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */ +#define BLE_GAP_AD_TYPE_ADVERTISING_INTERVAL 0x1A /**< Advertising Interval. */ +#define BLE_GAP_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS 0x1B /**< LE Bluetooth Device Address. */ +#define BLE_GAP_AD_TYPE_LE_ROLE 0x1C /**< LE Role. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C256 0x1D /**< Simple Pairing Hash C-256. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256 0x1E /**< Simple Pairing Randomizer R-256. */ +#define BLE_GAP_AD_TYPE_SERVICE_DATA_32BIT_UUID 0x20 /**< Service Data - 32-bit UUID. */ +#define BLE_GAP_AD_TYPE_SERVICE_DATA_128BIT_UUID 0x21 /**< Service Data - 128-bit UUID. */ +#define BLE_GAP_AD_TYPE_LESC_CONFIRMATION_VALUE 0x22 /**< LE Secure Connections Confirmation Value */ +#define BLE_GAP_AD_TYPE_LESC_RANDOM_VALUE 0x23 /**< LE Secure Connections Random Value */ +#define BLE_GAP_AD_TYPE_URI 0x24 /**< URI */ +#define BLE_GAP_AD_TYPE_3D_INFORMATION_DATA 0x3D /**< 3D Information Data. */ +#define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */ +/**@} */ + + +/**@defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags + * @{ */ +#define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */ +#define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */ +#define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */ +#define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */ +#define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */ +#define BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE (BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE Limited Discoverable Mode, BR/EDR not supported. */ +#define BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE (BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE General Discoverable Mode, BR/EDR not supported. */ +/**@} */ + + +/**@defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min + * @{ */ +#define BLE_GAP_ADV_INTERVAL_MIN 0x000020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */ +#define BLE_GAP_ADV_INTERVAL_MAX 0x004000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */ + /**@} */ + + +/**@defgroup BLE_GAP_SCAN_INTERVALS GAP Scan interval max and min + * @{ */ +#define BLE_GAP_SCAN_INTERVAL_MIN 0x0004 /**< Minimum Scan interval in 625 us units, i.e. 2.5 ms. */ +#define BLE_GAP_SCAN_INTERVAL_MAX 0xFFFF /**< Maximum Scan interval in 625 us units, i.e. 40,959.375 s. */ + /** @} */ + + +/**@defgroup BLE_GAP_SCAN_WINDOW GAP Scan window max and min + * @{ */ +#define BLE_GAP_SCAN_WINDOW_MIN 0x0004 /**< Minimum Scan window in 625 us units, i.e. 2.5 ms. */ +#define BLE_GAP_SCAN_WINDOW_MAX 0xFFFF /**< Maximum Scan window in 625 us units, i.e. 40,959.375 s. */ + /** @} */ + + +/**@defgroup BLE_GAP_SCAN_TIMEOUT GAP Scan timeout max and min + * @{ */ +#define BLE_GAP_SCAN_TIMEOUT_MIN 0x0001 /**< Minimum Scan timeout in 10 ms units, i.e 10 ms. */ +#define BLE_GAP_SCAN_TIMEOUT_UNLIMITED 0x0000 /**< Continue to scan forever. */ + /** @} */ + +/**@defgroup BLE_GAP_SCAN_BUFFER_SIZE GAP Minimum scanner buffer size + * + * Scan buffers are used for storing advertising data received from an advertiser. + * If ble_gap_scan_params_t::extended is set to 0, @ref BLE_GAP_SCAN_BUFFER_MIN is the minimum scan buffer length. + * else the minimum scan buffer size is @ref BLE_GAP_SCAN_BUFFER_EXTENDED_MIN. + * @{ */ +#define BLE_GAP_SCAN_BUFFER_MIN (31) /**< Minimum data length for an + advertising set. */ +#define BLE_GAP_SCAN_BUFFER_MAX (31) /**< Maximum data length for an + advertising set. */ +#define BLE_GAP_SCAN_BUFFER_EXTENDED_MIN (255) /**< Minimum data length for an + extended advertising set. */ +#define BLE_GAP_SCAN_BUFFER_EXTENDED_MAX (1650) /**< Maximum data length for an + extended advertising set. */ +#define BLE_GAP_SCAN_BUFFER_EXTENDED_MAX_SUPPORTED (255) /**< Maximum supported data length for + an extended advertising set. */ +/** @} */ + +/**@defgroup BLE_GAP_ADV_TYPES GAP Advertising types + * + * Advertising types defined in Bluetooth Core Specification v5.0, Vol 6, Part B, Section 4.4.2. + * + * The maximum advertising data length is defined by @ref BLE_GAP_ADV_SET_DATA_SIZE_MAX. + * The maximum supported data length for an extended advertiser is defined by + * @ref BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED + * Note that some of the advertising types do not support advertising data. Non-scannable types do not support + * scan response data. + * + * @{ */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED 0x01 /**< Connectable and scannable undirected + advertising events. */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE 0x02 /**< Connectable non-scannable directed advertising + events. Advertising interval is less that 3.75 ms. + Use this type for fast reconnections. + @note Advertising data is not supported. */ +#define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED 0x03 /**< Connectable non-scannable directed advertising + events. + @note Advertising data is not supported. */ +#define BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED 0x04 /**< Non-connectable scannable undirected + advertising events. */ +#define BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED 0x05 /**< Non-connectable non-scannable undirected + advertising events. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED 0x06 /**< Connectable non-scannable undirected advertising + events using extended advertising PDUs. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_DIRECTED 0x07 /**< Connectable non-scannable directed advertising + events using extended advertising PDUs. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED 0x08 /**< Non-connectable scannable undirected advertising + events using extended advertising PDUs. + @note Only scan response data is supported. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_DIRECTED 0x09 /**< Non-connectable scannable directed advertising + events using extended advertising PDUs. + @note Only scan response data is supported. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED 0x0A /**< Non-connectable non-scannable undirected advertising + events using extended advertising PDUs. */ +#define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_DIRECTED 0x0B /**< Non-connectable non-scannable directed advertising + events using extended advertising PDUs. */ +/**@} */ + +/**@defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies + * @{ */ +#define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */ +#define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */ +#define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */ +#define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */ +/**@} */ + +/**@defgroup BLE_GAP_ADV_DATA_STATUS GAP Advertising data status + * @{ */ +#define BLE_GAP_ADV_DATA_STATUS_COMPLETE 0x00 /**< All data in the advertising event have been received. */ +#define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA 0x01 /**< More data to be received. + @note This value will only be used if + @ref ble_gap_scan_params_t::report_incomplete_evts and + @ref ble_gap_adv_report_type_t::extended_pdu are set to true. */ +#define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_TRUNCATED 0x02 /**< Incomplete data. Buffer size insufficient to receive more. + @note This value will only be used if + @ref ble_gap_adv_report_type_t::extended_pdu is set to true. */ +#define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MISSED 0x03 /**< Failed to receive the remaining data. + @note This value will only be used if + @ref ble_gap_adv_report_type_t::extended_pdu is set to true. */ +/**@} */ + +/**@defgroup BLE_GAP_SCAN_FILTER_POLICIES GAP Scanner filter policies + * @{ */ +#define BLE_GAP_SCAN_FP_ACCEPT_ALL 0x00 /**< Accept all advertising packets except directed advertising packets + not addressed to this device. */ +#define BLE_GAP_SCAN_FP_WHITELIST 0x01 /**< Accept advertising packets from devices in the whitelist except directed + packets not addressed to this device. */ +#define BLE_GAP_SCAN_FP_ALL_NOT_RESOLVED_DIRECTED 0x02 /**< Accept all advertising packets specified in @ref BLE_GAP_SCAN_FP_ACCEPT_ALL. + In addition, accept directed advertising packets, where the advertiser's + address is a resolvable private address that cannot be resolved. */ +#define BLE_GAP_SCAN_FP_WHITELIST_NOT_RESOLVED_DIRECTED 0x03 /**< Accept all advertising packets specified in @ref BLE_GAP_SCAN_FP_WHITELIST. + In addition, accept directed advertising packets, where the advertiser's + address is a resolvable private address that cannot be resolved. */ +/**@} */ + +/**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values in 10 ms units + * @{ */ +#define BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX (128) /**< Maximum high duty advertising time in 10 ms units. Corresponds to 1.28 s. */ +#define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX (18000) /**< Maximum advertising time in 10 ms units corresponding to TGAP(lim_adv_timeout) = 180 s in limited discoverable mode. */ +#define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED (0) /**< Unlimited advertising in general discoverable mode. + For high duty cycle advertising, this corresponds to @ref BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX. */ +/**@} */ + + +/**@defgroup BLE_GAP_DISC_MODES GAP Discovery modes + * @{ */ +#define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */ +#define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */ +#define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */ +/**@} */ + + +/**@defgroup BLE_GAP_IO_CAPS GAP IO Capabilities + * @{ */ +#define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */ +#define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */ +#define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */ +#define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */ +#define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */ +/**@} */ + + +/**@defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types + * @{ */ +#define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */ +#define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */ +#define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */ +/**@} */ + + +/**@defgroup BLE_GAP_KP_NOT_TYPES GAP Keypress Notification Types + * @{ */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_START 0x00 /**< Passkey entry started. */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_IN 0x01 /**< Passkey digit entered. */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_OUT 0x02 /**< Passkey digit erased. */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_CLEAR 0x03 /**< Passkey cleared. */ +#define BLE_GAP_KP_NOT_TYPE_PASSKEY_END 0x04 /**< Passkey entry completed. */ +/**@} */ + + +/**@defgroup BLE_GAP_SEC_STATUS GAP Security status + * @{ */ +#define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Procedure completed with success. */ +#define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */ +#define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */ +#define BLE_GAP_SEC_STATUS_RFU_RANGE1_BEGIN 0x03 /**< Reserved for Future Use range #1 begin. */ +#define BLE_GAP_SEC_STATUS_RFU_RANGE1_END 0x80 /**< Reserved for Future Use range #1 end. */ +#define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user canceled or other). */ +#define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */ +#define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */ +#define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */ +#define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */ +#define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */ +#define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */ +#define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */ +#define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */ +#define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */ +#define BLE_GAP_SEC_STATUS_DHKEY_FAILURE 0x8B /**< DHKey check failure. */ +#define BLE_GAP_SEC_STATUS_NUM_COMP_FAILURE 0x8C /**< Numeric Comparison failure. */ +#define BLE_GAP_SEC_STATUS_BR_EDR_IN_PROG 0x8D /**< BR/EDR pairing in progress. */ +#define BLE_GAP_SEC_STATUS_X_TRANS_KEY_DISALLOWED 0x8E /**< BR/EDR Link Key cannot be used for LE keys. */ +#define BLE_GAP_SEC_STATUS_RFU_RANGE2_BEGIN 0x8F /**< Reserved for Future Use range #2 begin. */ +#define BLE_GAP_SEC_STATUS_RFU_RANGE2_END 0xFF /**< Reserved for Future Use range #2 end. */ +/**@} */ + + +/**@defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources + * @{ */ +#define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */ +#define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */ +/**@} */ + + +/**@defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits + * @{ */ +#define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connection interval specified in connect parameters. */ +#define BLE_GAP_CP_MIN_CONN_INTVL_MIN 0x0006 /**< Lowest minimum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */ +#define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connection interval specified in connect parameters. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_MIN 0x0006 /**< Lowest maximum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */ +#define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x01F3 /**< Highest slave latency permitted, in connection events. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */ +/**@} */ + + +/**@defgroup BLE_GAP_DEVNAME GAP device name defines. + * @{ */ +#define BLE_GAP_DEVNAME_DEFAULT "nRF5x" /**< Default device name value. */ +#define BLE_GAP_DEVNAME_DEFAULT_LEN 31 /**< Default number of octets in device name. */ +#define BLE_GAP_DEVNAME_MAX_LEN 248 /**< Maximum number of octets in device name. */ +/**@} */ + + +/**@brief Disable RSSI events for connections */ +#define BLE_GAP_RSSI_THRESHOLD_INVALID 0xFF + +/**@defgroup BLE_GAP_PHYS GAP PHYs + * @{ */ +#define BLE_GAP_PHY_AUTO 0x00 /**< Automatic PHY selection. Refer @ref sd_ble_gap_phy_update for more information.*/ +#define BLE_GAP_PHY_1MBPS 0x01 /**< 1 Mbps PHY. */ +#define BLE_GAP_PHY_2MBPS 0x02 /**< 2 Mbps PHY. */ +#define BLE_GAP_PHY_CODED 0x04 /**< Coded PHY. */ +#define BLE_GAP_PHY_NOT_SET 0xFF /**< PHY is not configured. */ + +/**@brief Supported PHYs in connections, for scanning, and for advertising. */ +#define BLE_GAP_PHYS_SUPPORTED (BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS) /**< All PHYs except @ref BLE_GAP_PHY_CODED are supported. */ + +/**@} */ + +/**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters + * + * See @ref ble_gap_conn_sec_mode_t. + * @{ */ +/**@brief Set sec_mode pointed to by ptr to have no access rights.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0) +/**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0) +/**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0) +/**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0) +/**@brief Set sec_mode pointed to by ptr to require LESC encryption and MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 4;} while(0) +/**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0) +/**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0) +/**@} */ + + +/**@brief GAP Security Random Number Length. */ +#define BLE_GAP_SEC_RAND_LEN 8 + + +/**@brief GAP Security Key Length. */ +#define BLE_GAP_SEC_KEY_LEN 16 + + +/**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Public Key Length. */ +#define BLE_GAP_LESC_P256_PK_LEN 64 + + +/**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman DHKey Length. */ +#define BLE_GAP_LESC_DHKEY_LEN 32 + + +/**@brief GAP Passkey Length. */ +#define BLE_GAP_PASSKEY_LEN 6 + + +/**@brief Maximum amount of addresses in the whitelist. */ +#define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8) + + +/**@brief Maximum amount of identities in the device identities list. */ +#define BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT (8) + + +/**@brief Default connection count for a configuration. */ +#define BLE_GAP_CONN_COUNT_DEFAULT (1) + + +/**@defgroup BLE_GAP_EVENT_LENGTH GAP event length defines. + * @{ */ +#define BLE_GAP_EVENT_LENGTH_MIN (2) /**< Minimum event length, in 1.25 ms units. */ +#define BLE_GAP_EVENT_LENGTH_DEFAULT (3) /**< Default event length, in 1.25 ms units. */ +/**@} */ + + +/**@defgroup BLE_GAP_ROLE_COUNT GAP concurrent connection count defines. + * @{ */ +#define BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT (1) /**< Default maximum number of connections concurrently acting as peripherals. */ +#define BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT (3) /**< Default maximum number of connections concurrently acting as centrals. */ +#define BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT (1) /**< Default number of SMP instances shared between all connections acting as centrals. */ +#define BLE_GAP_ROLE_COUNT_COMBINED_MAX (20) /**< Maximum supported number of concurrent connections in the peripheral and central roles combined. */ + +/**@} */ + +/**@brief Automatic data length parameter. */ +#define BLE_GAP_DATA_LENGTH_AUTO 0 + +/**@defgroup BLE_GAP_AUTH_PAYLOAD_TIMEOUT Authenticated payload timeout defines. + * @{ */ +#define BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX (48000) /**< Maximum authenticated payload timeout in 10 ms units, i.e. 8 minutes. */ +#define BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MIN (1) /**< Minimum authenticated payload timeout in 10 ms units, i.e. 10 ms. */ +/**@} */ + +/**@defgroup GAP_SEC_MODES GAP Security Modes + * @{ */ +#define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */ +/**@} */ + +/**@brief The total number of channels in Bluetooth Low Energy. */ +#define BLE_GAP_CHANNEL_COUNT (40) + +/**@defgroup BLE_GAP_QOS_CHANNEL_SURVEY_INTERVALS Quality of Service (QoS) Channel survey interval defines + * @{ */ +#define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_CONTINUOUS (0) /**< Continuous channel survey. */ +#define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_MIN_US (7500) /**< Minimum channel survey interval in microseconds (7.5 ms). */ +#define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_MAX_US (4000000) /**< Maximum channel survey interval in microseconds (4 s). */ + /**@} */ + +/** @} */ + +/** @defgroup BLE_GAP_CHAR_INCL_CONFIG GAP Characteristic inclusion configurations + * @{ + */ +#define BLE_GAP_CHAR_INCL_CONFIG_INCLUDE (0) /**< Include the characteristic in the Attribute Table */ +#define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITH_SPACE (1) /**< Do not include the characteristic in the Attribute table. + The SoftDevice will reserve the attribute handles + which are otherwise used for this characteristic. + By reserving the attribute handles it will be possible + to upgrade the SoftDevice without changing handle of the + Service Changed characteristic. */ +#define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITHOUT_SPACE (2) /**< Do not include the characteristic in the Attribute table. + The SoftDevice will not reserve the attribute handles + which are otherwise used for this characteristic. */ +/**@} */ + + +/** @defgroup BLE_GAP_CHAR_INCL_CONFIG_DEFAULTS Characteristic inclusion default values + * @{ */ +#define BLE_GAP_PPCP_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */ +#define BLE_GAP_CAR_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */ +/**@} */ + +/**@addtogroup BLE_GAP_STRUCTURES Structures + * @{ */ + +/**@brief Advertising event properties. */ +typedef struct +{ + uint8_t type; /**< Advertising type. See @ref BLE_GAP_ADV_TYPES. */ + uint8_t anonymous : 1; /**< Omit advertiser's address from all PDUs. + @note Anonymous advertising is only available for + @ref BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED and + @ref BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_DIRECTED. */ + uint8_t include_tx_power : 1; /**< This feature is not supported on this SoftDevice. */ +} ble_gap_adv_properties_t; + + +/**@brief Advertising report type. */ +typedef struct +{ + uint16_t connectable : 1; /**< Connectable advertising event type. */ + uint16_t scannable : 1; /**< Scannable advertising event type. */ + uint16_t directed : 1; /**< Directed advertising event type. */ + uint16_t scan_response : 1; /**< Received a scan response. */ + uint16_t extended_pdu : 1; /**< Received an extended advertising set. */ + uint16_t status : 2; /**< Data status. See @ref BLE_GAP_ADV_DATA_STATUS. */ + uint16_t reserved : 9; /**< Reserved for future use. */ +} ble_gap_adv_report_type_t; + +/**@brief Advertising Auxiliary Pointer. */ +typedef struct +{ + uint16_t aux_offset; /**< Time offset from the beginning of advertising packet to the auxiliary packet in 100 us units. */ + uint8_t aux_phy; /**< Indicates the PHY on which the auxiliary advertising packet is sent. See @ref BLE_GAP_PHYS. */ +} ble_gap_aux_pointer_t; + +/**@brief Bluetooth Low Energy address. */ +typedef struct +{ + uint8_t addr_id_peer : 1; /**< Only valid for peer addresses. + This bit is set by the SoftDevice to indicate whether the address has been resolved from + a Resolvable Private Address (when the peer is using privacy). + If set to 1, @ref addr and @ref addr_type refer to the identity address of the resolved address. + + This bit is ignored when a variable of type @ref ble_gap_addr_t is used as input to API functions. */ + uint8_t addr_type : 7; /**< See @ref BLE_GAP_ADDR_TYPES. */ + uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. + @ref addr is not used if @ref addr_type is @ref BLE_GAP_ADDR_TYPE_ANONYMOUS. */ +} ble_gap_addr_t; + + +/**@brief GAP connection parameters. + * + * @note When ble_conn_params_t is received in an event, both min_conn_interval and + * max_conn_interval will be equal to the connection interval set by the central. + * + * @note If both conn_sup_timeout and max_conn_interval are specified, then the following constraint applies: + * conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval + * that corresponds to the following Bluetooth Spec requirement: + * The Supervision_Timeout in milliseconds shall be larger than + * (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is given in milliseconds. + */ +typedef struct +{ + uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/ +} ble_gap_conn_params_t; + + +/**@brief GAP connection security modes. + * + * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n + * Security Mode 1 Level 1: No security is needed (aka open link).\n + * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n + * Security Mode 1 Level 3: MITM protected encrypted link required.\n + * Security Mode 1 Level 4: LESC MITM protected encrypted link using a 128-bit strength encryption key required.\n + * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n + * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n + */ +typedef struct +{ + uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */ + uint8_t lv : 4; /**< Level (1, 2, 3 or 4), 0 for no permissions at all. */ + +} ble_gap_conn_sec_mode_t; + + +/**@brief GAP connection security status.*/ +typedef struct +{ + ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/ + uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets (only applicable for bonding procedures). */ +} ble_gap_conn_sec_t; + +/**@brief Identity Resolving Key. */ +typedef struct +{ + uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */ +} ble_gap_irk_t; + + +/**@brief Channel mask (40 bits). + * Every channel is represented with a bit positioned as per channel index defined in Bluetooth Core Specification v5.0, + * Vol 6, Part B, Section 1.4.1. The LSB contained in array element 0 represents channel index 0, and bit 39 represents + * channel index 39. If a bit is set to 1, the channel is not used. + */ +typedef uint8_t ble_gap_ch_mask_t[5]; + + +/**@brief GAP advertising parameters. */ +typedef struct +{ + ble_gap_adv_properties_t properties; /**< The properties of the advertising events. */ + ble_gap_addr_t const *p_peer_addr; /**< Address of a known peer. + @note ble_gap_addr_t::addr_type cannot be + @ref BLE_GAP_ADDR_TYPE_ANONYMOUS. + - When privacy is enabled and the local device uses + @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE addresses, + the device identity list is searched for a matching entry. If + the local IRK for that device identity is set, the local IRK + for that device will be used to generate the advertiser address + field in the advertising packet. + - If @ref ble_gap_adv_properties_t::type is directed, this must be + set to the targeted scanner or initiator. If the peer address is + in the device identity list, the peer IRK for that device will be + used to generate @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE + target addresses used in the advertising event PDUs. */ + uint32_t interval; /**< Advertising interval in 625 us units. @sa BLE_GAP_ADV_INTERVALS. + @note If @ref ble_gap_adv_properties_t::type is set to + @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE + advertising, this parameter is ignored. */ + uint16_t duration; /**< Advertising duration in 10 ms units. When timeout is reached, + an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised. + @sa BLE_GAP_ADV_TIMEOUT_VALUES. + @note The SoftDevice will always complete at least one advertising + event even if the duration is set too low. */ + uint8_t max_adv_evts; /**< Maximum advertising events that shall be sent prior to disabling + advertising. Setting the value to 0 disables the limitation. When + the count of advertising events specified by this parameter + (if not 0) is reached, advertising will be automatically stopped + and an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised + @note If @ref ble_gap_adv_properties_t::type is set to + @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE, + this parameter is ignored. */ + ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary and secondary advertising channels. + At least one of the primary channels, that is channel index 37-39, must be used. + Masking away secondary advertising channels is not supported. */ + uint8_t filter_policy; /**< Filter Policy. @sa BLE_GAP_ADV_FILTER_POLICIES. */ + uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising channel packets + are transmitted. If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS + will be used. + The only supported value by this SoftDevice is @ref BLE_GAP_PHY_1MBPS. */ + uint8_t secondary_phy; /**< Indicates the PHY on which the secondary advertising channel packets + are transmitted. + If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS will be used. + Valid values are + @ref BLE_GAP_PHY_1MBPS and @ref BLE_GAP_PHY_2MBPS. @ref BLE_GAP_PHY_CODED + is not supported by this SoftDevice. + If @ref ble_gap_adv_properties_t::type is an extended advertising type + and connectable, this is the PHY that will be used to establish a + connection and send AUX_ADV_IND packets on. + @note This parameter will be ignored when + @ref ble_gap_adv_properties_t::type is not an extended advertising type. */ + uint8_t set_id:4; /**< The advertising set identifier distinguishes this advertising set from other + advertising sets transmitted by this and other devices. + @note This parameter will be ignored when + @ref ble_gap_adv_properties_t::type is not an extended advertising type. */ + uint8_t scan_req_notification:1; /**< Enable scan request notifications for this advertising set. When a + scan request is received and the scanner address is allowed + by the filter policy, @ref BLE_GAP_EVT_SCAN_REQ_REPORT is raised. + @note This parameter will be ignored when + @ref ble_gap_adv_properties_t::type is a non-scannable + advertising type. */ +} ble_gap_adv_params_t; + + +/**@brief GAP advertising data buffers. + * + * The application must provide the buffers for advertisement. The memory shall reside in application RAM, and + * shall never be modified while advertising. The data shall be kept alive until either: + * - @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised. + * - @ref BLE_GAP_EVT_CONNECTED is raised with @ref ble_gap_evt_connected_t::adv_handle set to the corresponding + * advertising handle. + * - Advertising is stopped. + * - Advertising data is changed. + * To update advertising data while advertising, provide new buffers to @ref sd_ble_gap_adv_set_configure. */ +typedef struct +{ + ble_data_t adv_data; /**< Advertising data. + @note + Advertising data can only be specified for a @ref ble_gap_adv_properties_t::type + that is allowed to contain advertising data. */ + ble_data_t scan_rsp_data; /**< Scan response data. + @note + Scan response data can only be specified for a @ref ble_gap_adv_properties_t::type + that is scannable. */ +} ble_gap_adv_data_t; + + +/**@brief GAP scanning parameters. */ +typedef struct +{ + uint8_t extended : 1; /**< If 1, the scanner will accept extended advertising packets. + If set to 0, the scanner will not receive advertising packets + on secondary advertising channels, and will not be able + to receive long advertising PDUs. */ + uint8_t report_incomplete_evts : 1; /**< If 1, events of type @ref ble_gap_evt_adv_report_t may have + @ref ble_gap_adv_report_type_t::status set to + @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. + This parameter is ignored when used with @ref sd_ble_gap_connect + @note This may be used to abort receiving more packets from an extended + advertising event, and is only available for extended + scanning, see @ref sd_ble_gap_scan_start. + @note This feature is not supported by this SoftDevice. */ + uint8_t active : 1; /**< If 1, perform active scanning by sending scan requests. + This parameter is ignored when used with @ref sd_ble_gap_connect. */ + uint8_t filter_policy : 2; /**< Scanning filter policy. @sa BLE_GAP_SCAN_FILTER_POLICIES. + @note Only @ref BLE_GAP_SCAN_FP_ACCEPT_ALL and + @ref BLE_GAP_SCAN_FP_WHITELIST are valid when used with + @ref sd_ble_gap_connect */ + uint8_t scan_phys; /**< Bitfield of PHYs to scan on. If set to @ref BLE_GAP_PHY_AUTO, + scan_phys will default to @ref BLE_GAP_PHY_1MBPS. + - If @ref ble_gap_scan_params_t::extended is set to 0, the only + supported PHY is @ref BLE_GAP_PHY_1MBPS. + - When used with @ref sd_ble_gap_scan_start, + the bitfield indicates the PHYs the scanner will use for scanning + on primary advertising channels. The scanner will accept + @ref BLE_GAP_PHYS_SUPPORTED as secondary advertising channel PHYs. + - When used with @ref sd_ble_gap_connect, the bitfield indicates + the PHYs the initiator will use for scanning on primary advertising + channels. The initiator will accept connections initiated on either + of the @ref BLE_GAP_PHYS_SUPPORTED PHYs. + If scan_phys contains @ref BLE_GAP_PHY_1MBPS and/or @ref BLE_GAP_PHY_2MBPS, + the primary scan PHY is @ref BLE_GAP_PHY_1MBPS. */ + uint16_t interval; /**< Scan interval in 625 us units. @sa BLE_GAP_SCAN_INTERVALS. */ + uint16_t window; /**< Scan window in 625 us units. @sa BLE_GAP_SCAN_WINDOW. */ + uint16_t timeout; /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */ + ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary and secondary advertising channels. + At least one of the primary channels, that is channel index 37-39, must be + set to 0. + Masking away secondary channels is not supported. */ +} ble_gap_scan_params_t; + + +/**@brief Privacy. + * + * The privacy feature provides a way for the device to avoid being tracked over a period of time. + * The privacy feature, when enabled, hides the local device identity and replaces it with a private address + * that is automatically refreshed at a specified interval. + * + * If a device still wants to be recognized by other peers, it needs to share it's Identity Resolving Key (IRK). + * With this key, a device can generate a random private address that can only be recognized by peers in possession of that key, + * and devices can establish connections without revealing their real identities. + * + * Both network privacy (@ref BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY) and device privacy (@ref BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY) + * are supported. + * + * @note If the device IRK is updated, the new IRK becomes the one to be distributed in all + * bonding procedures performed after @ref sd_ble_gap_privacy_set returns. + * The IRK distributed during bonding procedure is the device IRK that is active when @ref sd_ble_gap_sec_params_reply is called. + */ +typedef struct +{ + uint8_t privacy_mode; /**< Privacy mode, see @ref BLE_GAP_PRIVACY_MODES. Default is @ref BLE_GAP_PRIVACY_MODE_OFF. */ + uint8_t private_addr_type; /**< The private address type must be either @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE or @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. */ + uint16_t private_addr_cycle_s; /**< Private address cycle interval in seconds. Providing an address cycle value of 0 will use the default value defined by @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S. */ + ble_gap_irk_t *p_device_irk; /**< When used as input, pointer to IRK structure that will be used as the default IRK. If NULL, the device default IRK will be used. + When used as output, pointer to IRK structure where the current default IRK will be written to. If NULL, this argument is ignored. + By default, the default IRK is used to generate random private resolvable addresses for the local device unless instructed otherwise. */ +} ble_gap_privacy_params_t; + + +/**@brief PHY preferences for TX and RX + * @note tx_phys and rx_phys are bit fields. Multiple bits can be set in them to indicate multiple preferred PHYs for each direction. + * @code + * p_gap_phys->tx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS; + * p_gap_phys->rx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS; + * @endcode + * + */ +typedef struct +{ + uint8_t tx_phys; /**< Preferred transmit PHYs, see @ref BLE_GAP_PHYS. */ + uint8_t rx_phys; /**< Preferred receive PHYs, see @ref BLE_GAP_PHYS. */ +} ble_gap_phys_t; + +/** @brief Keys that can be exchanged during a bonding procedure. */ +typedef struct +{ + uint8_t enc : 1; /**< Long Term Key and Master Identification. */ + uint8_t id : 1; /**< Identity Resolving Key and Identity Address Information. */ + uint8_t sign : 1; /**< Connection Signature Resolving Key. */ + uint8_t link : 1; /**< Derive the Link Key from the LTK. */ +} ble_gap_sec_kdist_t; + + +/**@brief GAP security parameters. */ +typedef struct +{ + uint8_t bond : 1; /**< Perform bonding. */ + uint8_t mitm : 1; /**< Enable Man In The Middle protection. */ + uint8_t lesc : 1; /**< Enable LE Secure Connection pairing. */ + uint8_t keypress : 1; /**< Enable generation of keypress notifications. */ + uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */ + uint8_t oob : 1; /**< The OOB data flag. + - In LE legacy pairing, this flag is set if a device has out of band authentication data. + The OOB method is used if both of the devices have out of band authentication data. + - In LE Secure Connections pairing, this flag is set if a device has the peer device's out of band authentication data. + The OOB method is used if at least one device has the peer device's OOB data available. */ + uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. If 0 then not applicable in this instance. */ + uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */ + ble_gap_sec_kdist_t kdist_own; /**< Key distribution bitmap: keys that the local device will distribute. */ + ble_gap_sec_kdist_t kdist_peer; /**< Key distribution bitmap: keys that the remote device will distribute. */ +} ble_gap_sec_params_t; + + +/**@brief GAP Encryption Information. */ +typedef struct +{ + uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */ + uint8_t lesc : 1; /**< Key generated using LE Secure Connections. */ + uint8_t auth : 1; /**< Authenticated Key. */ + uint8_t ltk_len : 6; /**< LTK length in octets. */ +} ble_gap_enc_info_t; + + +/**@brief GAP Master Identification. */ +typedef struct +{ + uint16_t ediv; /**< Encrypted Diversifier. */ + uint8_t rand[BLE_GAP_SEC_RAND_LEN]; /**< Random Number. */ +} ble_gap_master_id_t; + + +/**@brief GAP Signing Information. */ +typedef struct +{ + uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /**< Connection Signature Resolving Key. */ +} ble_gap_sign_info_t; + + +/**@brief GAP LE Secure Connections P-256 Public Key. */ +typedef struct +{ + uint8_t pk[BLE_GAP_LESC_P256_PK_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Public Key. Stored in the standard SMP protocol format: {X,Y} both in little-endian. */ +} ble_gap_lesc_p256_pk_t; + + +/**@brief GAP LE Secure Connections DHKey. */ +typedef struct +{ + uint8_t key[BLE_GAP_LESC_DHKEY_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman Key. Stored in little-endian. */ +} ble_gap_lesc_dhkey_t; + + +/**@brief GAP LE Secure Connections OOB data. */ +typedef struct +{ + ble_gap_addr_t addr; /**< Bluetooth address of the device. */ + uint8_t r[BLE_GAP_SEC_KEY_LEN]; /**< Random Number. */ + uint8_t c[BLE_GAP_SEC_KEY_LEN]; /**< Confirm Value. */ +} ble_gap_lesc_oob_data_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_CONNECTED. */ +typedef struct +{ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1 + and the address is the device's identity address. */ + uint8_t role; /**< BLE role for this connection, see @ref BLE_GAP_ROLES */ + ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ + uint8_t adv_handle; /**< Advertising handle in which advertising has ended. + This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */ + ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated + advertising set. The advertising buffers provided in + @ref sd_ble_gap_adv_set_configure are now released. + This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */ +} ble_gap_evt_connected_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_DISCONNECTED. */ +typedef struct +{ + uint8_t reason; /**< HCI error code, see @ref BLE_HCI_STATUS_CODES. */ +} ble_gap_evt_disconnected_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE. */ +typedef struct +{ + ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ +} ble_gap_evt_conn_param_update_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_PHY_UPDATE_REQUEST. */ +typedef struct +{ + ble_gap_phys_t peer_preferred_phys; /**< The PHYs the peer prefers to use. */ +} ble_gap_evt_phy_update_request_t; + +/**@brief Event Structure for @ref BLE_GAP_EVT_PHY_UPDATE. */ +typedef struct +{ + uint8_t status; /**< Status of the procedure, see @ref BLE_HCI_STATUS_CODES.*/ + uint8_t tx_phy; /**< TX PHY for this connection, see @ref BLE_GAP_PHYS. */ + uint8_t rx_phy; /**< RX PHY for this connection, see @ref BLE_GAP_PHYS. */ +} ble_gap_evt_phy_update_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. */ +typedef struct +{ + ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */ +} ble_gap_evt_sec_params_request_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_SEC_INFO_REQUEST. */ +typedef struct +{ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */ + ble_gap_master_id_t master_id; /**< Master Identification for LTK lookup. */ + uint8_t enc_info : 1; /**< If 1, Encryption Information required. */ + uint8_t id_info : 1; /**< If 1, Identity Information required. */ + uint8_t sign_info : 1; /**< If 1, Signing Information required. */ +} ble_gap_evt_sec_info_request_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_PASSKEY_DISPLAY. */ +typedef struct +{ + uint8_t passkey[BLE_GAP_PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */ + uint8_t match_request : 1; /**< If 1 requires the application to report the match using @ref sd_ble_gap_auth_key_reply + with either @ref BLE_GAP_AUTH_KEY_TYPE_NONE if there is no match or + @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY if there is a match. */ +} ble_gap_evt_passkey_display_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_KEY_PRESSED. */ +typedef struct +{ + uint8_t kp_not; /**< Keypress notification type, see @ref BLE_GAP_KP_NOT_TYPES. */ +} ble_gap_evt_key_pressed_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_AUTH_KEY_REQUEST. */ +typedef struct +{ + uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */ +} ble_gap_evt_auth_key_request_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST. */ +typedef struct +{ + ble_gap_lesc_p256_pk_t *p_pk_peer; /**< LE Secure Connections remote P-256 Public Key. This will point to the application-supplied memory + inside the keyset during the call to @ref sd_ble_gap_sec_params_reply. */ + uint8_t oobd_req :1; /**< LESC OOB data required. A call to @ref sd_ble_gap_lesc_oob_data_set is required to complete the procedure. */ +} ble_gap_evt_lesc_dhkey_request_t; + + +/**@brief Security levels supported. + * @note See Bluetooth Specification Version 4.2 Volume 3, Part C, Chapter 10, Section 10.2.1. +*/ +typedef struct +{ + uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */ + uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */ + uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */ + uint8_t lv4 : 1; /**< If 1: Level 4 is supported. */ +} ble_gap_sec_levels_t; + + +/**@brief Encryption Key. */ +typedef struct +{ + ble_gap_enc_info_t enc_info; /**< Encryption Information. */ + ble_gap_master_id_t master_id; /**< Master Identification. */ +} ble_gap_enc_key_t; + + +/**@brief Identity Key. */ +typedef struct +{ + ble_gap_irk_t id_info; /**< Identity Resolving Key. */ + ble_gap_addr_t id_addr_info; /**< Identity Address. */ +} ble_gap_id_key_t; + + +/**@brief Security Keys. */ +typedef struct +{ + ble_gap_enc_key_t *p_enc_key; /**< Encryption Key, or NULL. */ + ble_gap_id_key_t *p_id_key; /**< Identity Key, or NULL. */ + ble_gap_sign_info_t *p_sign_key; /**< Signing Key, or NULL. */ + ble_gap_lesc_p256_pk_t *p_pk; /**< LE Secure Connections P-256 Public Key. When in debug mode the application must use the value defined + in the Core Bluetooth Specification v4.2 Vol.3, Part H, Section 2.3.5.6.1 */ +} ble_gap_sec_keys_t; + + +/**@brief Security key set for both local and peer keys. */ +typedef struct +{ + ble_gap_sec_keys_t keys_own; /**< Keys distributed by the local device. For LE Secure Connections the encryption key will be generated locally and will always be stored if bonding. */ + ble_gap_sec_keys_t keys_peer; /**< Keys distributed by the remote device. For LE Secure Connections, p_enc_key must always be NULL. */ +} ble_gap_sec_keyset_t; + + +/**@brief Data Length Update Procedure parameters. */ +typedef struct +{ + uint16_t max_tx_octets; /**< Maximum number of payload octets that a Controller supports for transmission of a single Link Layer Data Channel PDU. */ + uint16_t max_rx_octets; /**< Maximum number of payload octets that a Controller supports for reception of a single Link Layer Data Channel PDU. */ + uint16_t max_tx_time_us; /**< Maximum time, in microseconds, that a Controller supports for transmission of a single Link Layer Data Channel PDU. */ + uint16_t max_rx_time_us; /**< Maximum time, in microseconds, that a Controller supports for reception of a single Link Layer Data Channel PDU. */ +} ble_gap_data_length_params_t; + + +/**@brief Data Length Update Procedure local limitation. */ +typedef struct +{ + uint16_t tx_payload_limited_octets; /**< If > 0, the requested TX packet length is too long by this many octets. */ + uint16_t rx_payload_limited_octets; /**< If > 0, the requested RX packet length is too long by this many octets. */ + uint16_t tx_rx_time_limited_us; /**< If > 0, the requested combination of TX and RX packet lengths is too long by this many microseconds. */ +} ble_gap_data_length_limitation_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_AUTH_STATUS. */ +typedef struct +{ + uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */ + uint8_t error_src : 2; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */ + uint8_t bonded : 1; /**< Procedure resulted in a bond. */ + uint8_t lesc : 1; /**< Procedure resulted in a LE Secure Connection. */ + ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */ + ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */ + ble_gap_sec_kdist_t kdist_own; /**< Bitmap stating which keys were exchanged (distributed) by the local device. If bonding with LE Secure Connections, the enc bit will be always set. */ + ble_gap_sec_kdist_t kdist_peer; /**< Bitmap stating which keys were exchanged (distributed) by the remote device. If bonding with LE Secure Connections, the enc bit will never be set. */ +} ble_gap_evt_auth_status_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_CONN_SEC_UPDATE. */ +typedef struct +{ + ble_gap_conn_sec_t conn_sec; /**< Connection security level. */ +} ble_gap_evt_conn_sec_update_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_TIMEOUT. */ +typedef struct +{ + uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */ + union + { + ble_data_t adv_report_buffer; /**< If source is set to @ref BLE_GAP_TIMEOUT_SRC_SCAN, the released + scan buffer is contained in this field. */ + } params; /**< Event Parameters. */ +} ble_gap_evt_timeout_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */ +typedef struct +{ + int8_t rssi; /**< Received Signal Strength Indication in dBm. + @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */ + uint8_t ch_index; /**< Data Channel Index on which the Signal Strength is measured (0-36). */ +} ble_gap_evt_rssi_changed_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_ADV_SET_TERMINATED */ +typedef struct +{ + uint8_t reason; /**< Reason for why the advertising set terminated. See + @ref BLE_GAP_EVT_ADV_SET_TERMINATED_REASON. */ + uint8_t adv_handle; /**< Advertising handle in which advertising has ended. */ + uint8_t num_completed_adv_events; /**< If @ref ble_gap_adv_params_t::max_adv_evts was not set to 0, + this field indicates the number of completed advertising events. */ + ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated + advertising set. The advertising buffers provided in + @ref sd_ble_gap_adv_set_configure are now released. */ +} ble_gap_evt_adv_set_terminated_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_ADV_REPORT. + * + * @note If @ref ble_gap_adv_report_type_t::status is set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, + * not all fields in the advertising report may be available. + * + * @note When ble_gap_adv_report_type_t::status is not set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, + * scanning will be paused. To continue scanning, call @ref sd_ble_gap_scan_start. + */ +typedef struct +{ + ble_gap_adv_report_type_t type; /**< Advertising report type. See @ref ble_gap_adv_report_type_t. */ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr is resolved: + @ref ble_gap_addr_t::addr_id_peer is set to 1 and the address is the + peer's identity address. */ + ble_gap_addr_t direct_addr; /**< Contains the target address of the advertising event if + @ref ble_gap_adv_report_type_t::directed is set to 1. If the + SoftDevice was able to resolve the address, + @ref ble_gap_addr_t::addr_id_peer is set to 1 and the direct_addr + contains the local identity address. If the target address of the + advertising event is @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE, + and the SoftDevice was unable to resolve it, the application may try + to resolve this address to find out if the advertising event was + directed to us. */ + uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising packet was received. + See @ref BLE_GAP_PHYS. */ + uint8_t secondary_phy; /**< Indicates the PHY on which the secondary advertising packet was received. + See @ref BLE_GAP_PHYS. This field is set to @ref BLE_GAP_PHY_NOT_SET if no packets + were received on a secondary advertising channel. */ + int8_t tx_power; /**< TX Power reported by the advertiser in the last packet header received. + This field is set to @ref BLE_GAP_POWER_LEVEL_INVALID if the + last received packet did not contain the Tx Power field. + @note TX Power is only included in extended advertising packets. */ + int8_t rssi; /**< Received Signal Strength Indication in dBm of the last packet received. + @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */ + uint8_t ch_index; /**< Channel Index on which the last advertising packet is received (0-39). */ + uint8_t set_id; /**< Set ID of the received advertising data. Set ID is not present + if set to @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */ + uint16_t data_id:12; /**< The advertising data ID of the received advertising data. Data ID + is not present if @ref ble_gap_evt_adv_report_t::set_id is set to + @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */ + ble_data_t data; /**< Received advertising or scan response data. If + @ref ble_gap_adv_report_type_t::status is not set to + @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the data buffer provided + in @ref sd_ble_gap_scan_start is now released. */ + ble_gap_aux_pointer_t aux_pointer; /**< The offset and PHY of the next advertising packet in this extended advertising + event. @note This field is only set if @ref ble_gap_adv_report_type_t::status + is set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. */ +} ble_gap_evt_adv_report_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_SEC_REQUEST. */ +typedef struct +{ + uint8_t bond : 1; /**< Perform bonding. */ + uint8_t mitm : 1; /**< Man In The Middle protection requested. */ + uint8_t lesc : 1; /**< LE Secure Connections requested. */ + uint8_t keypress : 1; /**< Generation of keypress notifications requested. */ +} ble_gap_evt_sec_request_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST. */ +typedef struct +{ + ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ +} ble_gap_evt_conn_param_update_request_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_SCAN_REQ_REPORT. */ +typedef struct +{ + uint8_t adv_handle; /**< Advertising handle for the advertising set which received the Scan Request */ + int8_t rssi; /**< Received Signal Strength Indication in dBm. + @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1 + and the address is the device's identity address. */ +} ble_gap_evt_scan_req_report_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST. */ +typedef struct +{ + ble_gap_data_length_params_t peer_params; /**< Peer data length parameters. */ +} ble_gap_evt_data_length_update_request_t; + +/**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE. + */ +typedef struct +{ + ble_gap_data_length_params_t effective_params; /**< The effective data length parameters. */ +} ble_gap_evt_data_length_update_t; + + +/**@brief Event structure for @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT. */ +typedef struct +{ + int8_t channel_energy[BLE_GAP_CHANNEL_COUNT]; /**< The measured energy on the Bluetooth Low Energy + channels, in dBm, indexed by Channel Index. + If no measurement is available for the given channel, channel_energy is set to + @ref BLE_GAP_POWER_LEVEL_INVALID. */ +} ble_gap_evt_qos_channel_survey_report_t; + +/**@brief GAP event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which event occurred. */ + union /**< union alternative identified by evt_id in enclosing struct. */ + { + ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */ + ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */ + ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */ + ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */ + ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */ + ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */ + ble_gap_evt_key_pressed_t key_pressed; /**< Key Pressed Event Parameters. */ + ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */ + ble_gap_evt_lesc_dhkey_request_t lesc_dhkey_request; /**< LE Secure Connections DHKey calculation request. */ + ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */ + ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */ + ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */ + ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event Parameters. */ + ble_gap_evt_adv_report_t adv_report; /**< Advertising Report Event Parameters. */ + ble_gap_evt_adv_set_terminated_t adv_set_terminated; /**< Advertising Set Terminated Event Parameters. */ + ble_gap_evt_sec_request_t sec_request; /**< Security Request Event Parameters. */ + ble_gap_evt_conn_param_update_request_t conn_param_update_request; /**< Connection Parameter Update Parameters. */ + ble_gap_evt_scan_req_report_t scan_req_report; /**< Scan Request Report Parameters. */ + ble_gap_evt_phy_update_request_t phy_update_request; /**< PHY Update Request Event Parameters. */ + ble_gap_evt_phy_update_t phy_update; /**< PHY Update Parameters. */ + ble_gap_evt_data_length_update_request_t data_length_update_request; /**< Data Length Update Request Event Parameters. */ + ble_gap_evt_data_length_update_t data_length_update; /**< Data Length Update Event Parameters. */ + ble_gap_evt_qos_channel_survey_report_t qos_channel_survey_report; /**< Quality of Service (QoS) Channel Survey Report Parameters. */ + } params; /**< Event Parameters. */ +} ble_gap_evt_t; + + +/** + * @brief BLE GAP connection configuration parameters, set with @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_CONN_COUNT The connection count for the connection configurations is zero. + * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true: + * - The sum of conn_count for all connection configurations combined exceeds UINT8_MAX. + * - The event length is smaller than @ref BLE_GAP_EVENT_LENGTH_MIN. + */ +typedef struct +{ + uint8_t conn_count; /**< The number of concurrent connections the application can create with this configuration. + The default and minimum value is @ref BLE_GAP_CONN_COUNT_DEFAULT. */ + uint16_t event_length; /**< The time set aside for this connection on every connection interval in 1.25 ms units. + The default value is @ref BLE_GAP_EVENT_LENGTH_DEFAULT, the minimum value is @ref BLE_GAP_EVENT_LENGTH_MIN. + The event length and the connection interval are the primary parameters + for setting the throughput of a connection. + See the SoftDevice Specification for details on throughput. */ +} ble_gap_conn_cfg_t; + + +/** + * @brief Configuration of maximum concurrent connections in the different connected roles, set with + * @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_CONN_COUNT The sum of periph_role_count and central_role_count is too + * large. The maximum supported sum of concurrent connections is + * @ref BLE_GAP_ROLE_COUNT_COMBINED_MAX. + * @retval ::NRF_ERROR_INVALID_PARAM central_sec_count is larger than central_role_count. + * @retval ::NRF_ERROR_RESOURCES The adv_set_count is too large. The maximum + * supported advertising handles is + * @ref BLE_GAP_ADV_SET_COUNT_MAX. + */ +typedef struct +{ + uint8_t adv_set_count; /**< Maximum number of advertising sets. Default value is @ref BLE_GAP_ADV_SET_COUNT_DEFAULT. */ + uint8_t periph_role_count; /**< Maximum number of connections concurrently acting as a peripheral. Default value is @ref BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT. */ + uint8_t central_role_count; /**< Maximum number of connections concurrently acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT. */ + uint8_t central_sec_count; /**< Number of SMP instances shared between all connections acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT. */ + uint8_t qos_channel_survey_role_available:1; /**< If set, the Quality of Service (QoS) channel survey module is available to the + application using @ref sd_ble_gap_qos_channel_survey_start. */ +} ble_gap_cfg_role_count_t; + + +/** + * @brief Device name and its properties, set with @ref sd_ble_cfg_set. + * + * @note If the device name is not configured, the default device name will be + * @ref BLE_GAP_DEVNAME_DEFAULT, the maximum device name length will be + * @ref BLE_GAP_DEVNAME_DEFAULT_LEN, vloc will be set to @ref BLE_GATTS_VLOC_STACK and the device name + * will have no write access. + * + * @note If @ref max_len is more than @ref BLE_GAP_DEVNAME_DEFAULT_LEN and vloc is set to @ref BLE_GATTS_VLOC_STACK, + * the attribute table size must be increased to have room for the longer device name (see + * @ref sd_ble_cfg_set and @ref ble_gatts_cfg_attr_tab_size_t). + * + * @note If vloc is @ref BLE_GATTS_VLOC_STACK : + * - p_value must point to non-volatile memory (flash) or be NULL. + * - If p_value is NULL, the device name will initially be empty. + * + * @note If vloc is @ref BLE_GATTS_VLOC_USER : + * - p_value cannot be NULL. + * - If the device name is writable, p_value must point to volatile memory (RAM). + * + * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true: + * - Invalid device name location (vloc). + * - Invalid device name security mode. + * @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true: + * - The device name length is invalid (must be between 0 and @ref BLE_GAP_DEVNAME_MAX_LEN). + * - The device name length is too long for the given Attribute Table. + * @retval ::NRF_ERROR_NOT_SUPPORTED Device name security mode is not supported. + */ +typedef struct +{ + ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ + uint8_t vloc:2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/ + uint8_t *p_value; /**< Pointer to where the value (device name) is stored or will be stored. */ + uint16_t current_len; /**< Current length in bytes of the memory pointed to by p_value.*/ + uint16_t max_len; /**< Maximum length in bytes of the memory pointed to by p_value.*/ +} ble_gap_cfg_device_name_t; + + +/**@brief Peripheral Preferred Connection Parameters include configuration parameters, set with @ref sd_ble_cfg_set. */ +typedef struct +{ + uint8_t include_cfg; /**< Inclusion configuration of the Peripheral Preferred Connection Parameters characteristic. + See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_PPCP_INCL_CONFIG_DEFAULT. */ +} ble_gap_cfg_ppcp_incl_cfg_t; + + +/**@brief Central Address Resolution include configuration parameters, set with @ref sd_ble_cfg_set. */ +typedef struct +{ + uint8_t include_cfg; /**< Inclusion configuration of the Central Address Resolution characteristic. + See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_CAR_INCL_CONFIG_DEFAULT. */ +} ble_gap_cfg_car_incl_cfg_t; + + +/**@brief Configuration structure for GAP configurations. */ +typedef union +{ + ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */ + ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */ + ble_gap_cfg_ppcp_incl_cfg_t ppcp_include_cfg; /**< Peripheral Preferred Connection Parameters characteristic include + configuration, cfg_id is @ref BLE_GAP_CFG_PPCP_INCL_CONFIG. */ + ble_gap_cfg_car_incl_cfg_t car_include_cfg; /**< Central Address Resolution characteristic include configuration, + cfg_id is @ref BLE_GAP_CFG_CAR_INCL_CONFIG. */ +} ble_gap_cfg_t; + + +/**@brief Channel Map option. + * + * @details Used with @ref sd_ble_opt_get to get the current channel map + * or @ref sd_ble_opt_set to set a new channel map. When setting the + * channel map, it applies to all current and future connections. When getting the + * current channel map, it applies to a single connection and the connection handle + * must be supplied. + * + * @note Setting the channel map may take some time, depending on connection parameters. + * The time taken may be different for each connection and the get operation will + * return the previous channel map until the new one has taken effect. + * + * @note After setting the channel map, by spec it can not be set again until at least 1 s has passed. + * See Bluetooth Specification Version 4.1 Volume 2, Part E, Section 7.3.46. + * + * @retval ::NRF_SUCCESS Get or set successful. + * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true: + * - Less then two bits in @ref ch_map are set. + * - Bits for primary advertising channels (37-39) are set. + * @retval ::NRF_ERROR_BUSY Channel map was set again before enough time had passed. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied for get. + * + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle (only applicable for get) */ + uint8_t ch_map[5]; /**< Channel Map (37-bit). */ +} ble_gap_opt_ch_map_t; + + +/**@brief Local connection latency option. + * + * @details Local connection latency is a feature which enables the slave to improve + * current consumption by ignoring the slave latency set by the peer. The + * local connection latency can only be set to a multiple of the slave latency, + * and cannot be longer than half of the supervision timeout. + * + * @details Used with @ref sd_ble_opt_set to set the local connection latency. The + * @ref sd_ble_opt_get is not supported for this option, but the actual + * local connection latency (unless set to NULL) is set as a return parameter + * when setting the option. + * + * @note The latency set will be truncated down to the closest slave latency event + * multiple, or the nearest multiple before half of the supervision timeout. + * + * @note The local connection latency is disabled by default, and needs to be enabled for new + * connections and whenever the connection is updated. + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter. + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle */ + uint16_t requested_latency; /**< Requested local connection latency. */ + uint16_t * p_actual_latency; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */ +} ble_gap_opt_local_conn_latency_t; + +/**@brief Disable slave latency + * + * @details Used with @ref sd_ble_opt_set to temporarily disable slave latency of a peripheral connection + * (see @ref ble_gap_conn_params_t::slave_latency). And to re-enable it again. When disabled, the + * peripheral will ignore the slave_latency set by the central. + * + * @note Shall only be called on peripheral links. + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter. + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle */ + uint8_t disable : 1; /**< Set to 1 to disable slave latency. Set to 0 enable it again.*/ +} ble_gap_opt_slave_latency_disable_t; + +/**@brief Passkey Option. + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC} + * @endmscs + * + * @details Structure containing the passkey to be used during pairing. This can be used with @ref + * sd_ble_opt_set to make the SoftDevice use a preprogrammed passkey for authentication + * instead of generating a random one. + * + * @note Repeated pairing attempts using the same preprogrammed passkey makes pairing vulnerable to MITM attacks. + * + * @note @ref sd_ble_opt_get is not supported for this option. + * + */ +typedef struct +{ + uint8_t const * p_passkey; /**< Pointer to 6-digit ASCII string (digit 0..9 only, no NULL termination) passkey to be used during pairing. If this is NULL, the SoftDevice will generate a random passkey if required.*/ +} ble_gap_opt_passkey_t; + + +/**@brief Compatibility mode 1 option. + * + * @details This can be used with @ref sd_ble_opt_set to enable and disable + * compatibility mode 1. Compatibility mode 1 is disabled by default. + * + * @note Compatibility mode 1 enables interoperability with devices that do not support a value of + * 0 for the WinOffset parameter in the Link Layer CONNECT_IND packet. This applies to a + * limited set of legacy peripheral devices from another vendor. Enabling this compatibility + * mode will only have an effect if the local device will act as a central device and + * initiate a connection to a peripheral device. In that case it may lead to the connection + * creation taking up to one connection interval longer to complete for all connections. + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_INVALID_STATE When connection creation is ongoing while mode 1 is set. + */ +typedef struct +{ + uint8_t enable : 1; /**< Enable compatibility mode 1.*/ +} ble_gap_opt_compat_mode_1_t; + + +/**@brief Authenticated payload timeout option. + * + * @details This can be used with @ref sd_ble_opt_set to change the Authenticated payload timeout to a value other + * than the default of @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX. + * + * @note The authenticated payload timeout event ::BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD will be generated + * if auth_payload_timeout time has elapsed without receiving a packet with a valid MIC on an encrypted + * link. + * + * @note The LE ping procedure will be initiated before the timer expires to give the peer a chance + * to reset the timer. In addition the stack will try to prioritize running of LE ping over other + * activities to increase chances of finishing LE ping before timer expires. To avoid side-effects + * on other activities, it is recommended to use high timeout values. + * Recommended timeout > 2*(connInterval * (6 + connSlaveLatency)). + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. auth_payload_timeout was outside of allowed range. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter. + */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle */ + uint16_t auth_payload_timeout; /**< Requested timeout in 10 ms unit, see @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT. */ +} ble_gap_opt_auth_payload_timeout_t; + +/**@brief Option structure for GAP options. */ +typedef union +{ + ble_gap_opt_ch_map_t ch_map; /**< Parameters for the Channel Map option. */ + ble_gap_opt_local_conn_latency_t local_conn_latency; /**< Parameters for the Local connection latency option */ + ble_gap_opt_passkey_t passkey; /**< Parameters for the Passkey option.*/ + ble_gap_opt_compat_mode_1_t compat_mode_1; /**< Parameters for the compatibility mode 1 option.*/ + ble_gap_opt_auth_payload_timeout_t auth_payload_timeout; /**< Parameters for the authenticated payload timeout option.*/ + ble_gap_opt_slave_latency_disable_t slave_latency_disable; /**< Parameters for the Disable slave latency option */ +} ble_gap_opt_t; + +/**@brief Connection event triggering parameters. */ +typedef struct +{ + uint8_t ppi_ch_id; /**< PPI channel to use. This channel should be regarded as reserved until + connection event PPI task triggering is stopped. + The PPI channel ID can not be one of the PPI channels reserved by + the SoftDevice. See @ref NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK. */ + uint32_t task_endpoint; /**< Task Endpoint to trigger. */ + uint16_t conn_evt_counter_start; /**< The connection event on which the task triggering should start. */ + uint16_t period_in_events; /**< Trigger period. Valid range is [1, 32767]. + If the device is in slave role and slave latency is enabled, + this parameter should be set to a multiple of (slave latency + 1) + to ensure low power operation. */ +} ble_gap_conn_event_trigger_t; +/**@} */ + +/**@addtogroup BLE_GAP_FUNCTIONS Functions + * @{ */ + +/**@brief Set the local Bluetooth identity address. + * + * The local Bluetooth identity address is the address that identifies this device to other peers. + * The address type must be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC. + * + * @note The identity address cannot be changed while advertising, scanning or creating a connection. + * + * @note This address will be distributed to the peer during bonding. + * If the address changes, the address stored in the peer device will not be valid and the ability to + * reconnect using the old address will be lost. + * + * @note By default the SoftDevice will set an address of type @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC upon being + * enabled. The address is a random number populated during the IC manufacturing process and remains unchanged + * for the lifetime of each IC. + * + * @mscs + * @mmsc{@ref BLE_GAP_ADV_MSC} + * @endmscs + * + * @param[in] p_addr Pointer to address structure. + * + * @retval ::NRF_SUCCESS Address successfully set. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::NRF_ERROR_INVALID_STATE The identity address cannot be changed while advertising, + * scanning or creating a connection. + */ +SVCALL(SD_BLE_GAP_ADDR_SET, uint32_t, sd_ble_gap_addr_set(ble_gap_addr_t const *p_addr)); + + +/**@brief Get local Bluetooth identity address. + * + * @note This will always return the identity address irrespective of the privacy settings, + * i.e. the address type will always be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC. + * + * @param[out] p_addr Pointer to address structure to be filled in. + * + * @retval ::NRF_SUCCESS Address successfully retrieved. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied. + */ +SVCALL(SD_BLE_GAP_ADDR_GET, uint32_t, sd_ble_gap_addr_get(ble_gap_addr_t *p_addr)); + + +/**@brief Get the Bluetooth device address used by the advertiser. + * + * @note This function will return the local Bluetooth address used in advertising PDUs. When + * using privacy, the SoftDevice will generate a new private address every + * @ref ble_gap_privacy_params_t::private_addr_cycle_s configured using + * @ref sd_ble_gap_privacy_set. Hence depending on when the application calls this API, the + * address returned may not be the latest address that is used in the advertising PDUs. + * + * @param[in] adv_handle The advertising handle to get the address from. + * @param[out] p_addr Pointer to address structure to be filled in. + * + * @retval ::NRF_SUCCESS Address successfully retrieved. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. + * @retval ::NRF_ERROR_INVALID_STATE The advertising set is currently not advertising. + */ +SVCALL(SD_BLE_GAP_ADV_ADDR_GET, uint32_t, sd_ble_gap_adv_addr_get(uint8_t adv_handle, ble_gap_addr_t *p_addr)); + + +/**@brief Set the active whitelist in the SoftDevice. + * + * @note Only one whitelist can be used at a time and the whitelist is shared between the BLE roles. + * The whitelist cannot be set if a BLE role is using the whitelist. + * + * @note If an address is resolved using the information in the device identity list, then the whitelist + * filter policy applies to the peer identity address and not the resolvable address sent on air. + * + * @mscs + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC} + * @endmscs + * + * @param[in] pp_wl_addrs Pointer to a whitelist of peer addresses, if NULL the whitelist will be cleared. + * @param[in] len Length of the whitelist, maximum @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT. + * + * @retval ::NRF_SUCCESS The whitelist is successfully set/cleared. + * @retval ::NRF_ERROR_INVALID_ADDR The whitelist (or one of its entries) provided is invalid. + * @retval ::BLE_ERROR_GAP_WHITELIST_IN_USE The whitelist is in use by a BLE role and cannot be set or cleared. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied. + * @retval ::NRF_ERROR_DATA_SIZE The given whitelist size is invalid (zero or too large); this can only return when + * pp_wl_addrs is not NULL. + */ +SVCALL(SD_BLE_GAP_WHITELIST_SET, uint32_t, sd_ble_gap_whitelist_set(ble_gap_addr_t const * const * pp_wl_addrs, uint8_t len)); + + +/**@brief Set device identity list. + * + * @note Only one device identity list can be used at a time and the list is shared between the BLE roles. + * The device identity list cannot be set if a BLE role is using the list. + * + * @param[in] pp_id_keys Pointer to an array of peer identity addresses and peer IRKs, if NULL the device identity list will be cleared. + * @param[in] pp_local_irks Pointer to an array of local IRKs. Each entry in the array maps to the entry in pp_id_keys at the same index. + * To fill in the list with the currently set device IRK for all peers, set to NULL. + * @param[in] len Length of the device identity list, maximum @ref BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT. + * + * @mscs + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS The device identity list successfully set/cleared. + * @retval ::NRF_ERROR_INVALID_ADDR The device identity list (or one of its entries) provided is invalid. + * This code may be returned if the local IRK list also has an invalid entry. + * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE The device identity list is in use and cannot be set or cleared. + * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE The device identity list contains multiple entries with the same identity address. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied. + * @retval ::NRF_ERROR_DATA_SIZE The given device identity list size invalid (zero or too large); this can + * only return when pp_id_keys is not NULL. + */ +SVCALL(SD_BLE_GAP_DEVICE_IDENTITIES_SET, uint32_t, sd_ble_gap_device_identities_set(ble_gap_id_key_t const * const * pp_id_keys, ble_gap_irk_t const * const * pp_local_irks, uint8_t len)); + + +/**@brief Set privacy settings. + * + * @note Privacy settings cannot be changed while advertising, scanning or creating a connection. + * + * @param[in] p_privacy_params Privacy settings. + * + * @mscs + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Set successfully. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied. + * @retval ::NRF_ERROR_INVALID_ADDR The pointer to privacy settings is NULL or invalid. + * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer. + * @retval ::NRF_ERROR_INVALID_PARAM Out of range parameters are provided. + * @retval ::NRF_ERROR_NOT_SUPPORTED The SoftDevice does not support privacy if the Central Address Resolution + characteristic is not configured to be included and the SoftDevice is configured + to support central roles. + See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t. + * @retval ::NRF_ERROR_INVALID_STATE Privacy settings cannot be changed while advertising, scanning + * or creating a connection. + */ +SVCALL(SD_BLE_GAP_PRIVACY_SET, uint32_t, sd_ble_gap_privacy_set(ble_gap_privacy_params_t const *p_privacy_params)); + + +/**@brief Get privacy settings. + * + * @note ::ble_gap_privacy_params_t::p_device_irk must be initialized to NULL or a valid address before this function is called. + * If it is initialized to a valid address, the address pointed to will contain the current device IRK on return. + * + * @param[in,out] p_privacy_params Privacy settings. + * + * @retval ::NRF_SUCCESS Privacy settings read. + * @retval ::NRF_ERROR_INVALID_ADDR The pointer given for returning the privacy settings may be NULL or invalid. + * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer. + */ +SVCALL(SD_BLE_GAP_PRIVACY_GET, uint32_t, sd_ble_gap_privacy_get(ble_gap_privacy_params_t *p_privacy_params)); + + +/**@brief Configure an advertising set. Set, clear or update advertising and scan response data. + * + * @note The format of the advertising data will be checked by this call to ensure interoperability. + * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and + * duplicating the local name in the advertising data and scan response data. + * + * @note In order to update advertising data while advertising, new advertising buffers must be provided. + * + * @mscs + * @mmsc{@ref BLE_GAP_ADV_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @param[in,out] p_adv_handle Provide a pointer to a handle containing @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to configure + * a new advertising set. On success, a new handle is then returned through the pointer. + * Provide a pointer to an existing advertising handle to configure an existing advertising set. + * @param[in] p_adv_data Advertising data. If set to NULL, no advertising data will be used. See @ref ble_gap_adv_data_t. + * @param[in] p_adv_params Advertising parameters. When this function is used to update advertising data while advertising, + * this parameter must be NULL. See @ref ble_gap_adv_params_t. + * + * @retval ::NRF_SUCCESS Advertising set successfully configured. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied: + * - Invalid advertising data configuration specified. See @ref ble_gap_adv_data_t. + * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t. + * - Use of whitelist requested but whitelist has not been set, + * see @ref sd_ble_gap_whitelist_set. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR ble_gap_adv_params_t::p_peer_addr is invalid. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - It is invalid to provide non-NULL advertising set parameters while advertising. + * - It is invalid to provide the same data buffers while advertising. To update + * advertising data, provide new advertising buffers. + * @retval ::BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. Use @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to + * configure a new advertising handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied. + * @retval ::NRF_ERROR_INVALID_DATA Invalid data type(s) supplied. Check the advertising data format specification + * given in Bluetooth Specification Version 5.0, Volume 3, Part C, Chapter 11. + * @retval ::NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported data length or advertising parameter configuration. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to configure a new advertising handle. Update an + * existing advertising handle instead. + * @retval ::BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied. + */ +SVCALL(SD_BLE_GAP_ADV_SET_CONFIGURE, uint32_t, sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle, ble_gap_adv_data_t const *p_adv_data, ble_gap_adv_params_t const *p_adv_params)); + + +/**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). + * + * @note Only one advertiser may be active at any time. + * + * @note If privacy is enabled, the advertiser's private address will be refreshed when this function is called. + * See @ref sd_ble_gap_privacy_set(). + * + * @events + * @event{@ref BLE_GAP_EVT_CONNECTED, Generated after connection has been established through connectable advertising.} + * @event{@ref BLE_GAP_EVT_ADV_SET_TERMINATED, Advertising set has terminated.} + * @event{@ref BLE_GAP_EVT_SCAN_REQ_REPORT, A scan request was received.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_ADV_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC} + * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @param[in] adv_handle Advertising handle to advertise on, received from @ref sd_ble_gap_adv_set_configure. + * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or + * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. For non-connectable + * advertising, this is ignored. + * + * @retval ::NRF_SUCCESS The BLE stack has started advertising. + * @retval ::NRF_ERROR_INVALID_STATE adv_handle is not configured or already advertising. + * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections for this connection configuration + * tag has been reached; connectable advertiser cannot be started. + * To increase the number of available connections, + * use @ref sd_ble_cfg_set with @ref BLE_GAP_CFG_ROLE_COUNT or @ref BLE_CONN_CFG_GAP. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. Configure a new adveriting handle with @ref sd_ble_gap_adv_set_configure. + * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied: + * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t. + * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set. + * @retval ::NRF_ERROR_RESOURCES Either: + * - adv_handle is configured with connectable advertising, but the event_length parameter + * associated with conn_cfg_tag is too small to be able to establish a connection on + * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length. + * - Not enough BLE role slots available. + Stop one or more currently active roles (Central, Peripheral, Broadcaster or Observer) and try again. + * - p_adv_params is configured with connectable advertising, but the event_length parameter + * associated with conn_cfg_tag is too small to be able to establish a connection on + * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + */ +SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(uint8_t adv_handle, uint8_t conn_cfg_tag)); + + +/**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). + * + * @mscs + * @mmsc{@ref BLE_GAP_ADV_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @param[in] adv_handle The advertising handle that should stop advertising. + * + * @retval ::NRF_SUCCESS The BLE stack has stopped advertising. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Invalid advertising handle. + * @retval ::NRF_ERROR_INVALID_STATE The advertising handle is not advertising. + */ +SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle)); + + + +/**@brief Update connection parameters. + * + * @details In the central role this will initiate a Link Layer connection parameter update procedure, + * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for + * the central to perform the procedure. In both cases, and regardless of success or failure, the application + * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event. + * + * @details This function can be used as a central both to reply to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST or to start the procedure unrequested. + * + * @events + * @event{@ref BLE_GAP_EVT_CONN_PARAM_UPDATE, Result of the connection parameter update procedure.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CPU_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} + * @mmsc{@ref BLE_GAP_MULTILINK_CPU_MSC} + * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_CPU_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role, + * the parameters in the PPCP characteristic of the GAP service will be used instead. + * If NULL is provided on a central role and in response to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, the peripheral request will be rejected + * + * @retval ::NRF_SUCCESS The Connection Update procedure has been started successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. + * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established. + * @retval ::NRF_ERROR_BUSY Procedure already in progress, wait for pending procedures to complete and retry. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GAP_CONN_PARAM_UPDATE, uint32_t, sd_ble_gap_conn_param_update(uint16_t conn_handle, ble_gap_conn_params_t const *p_conn_params)); + + +/**@brief Disconnect (GAP Link Termination). + * + * @details This call initiates the disconnection procedure, and its completion will be communicated to the application + * with a @ref BLE_GAP_EVT_DISCONNECTED event. + * + * @events + * @event{@ref BLE_GAP_EVT_DISCONNECTED, Generated when disconnection procedure is complete.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CONN_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are @ref BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and @ref BLE_HCI_CONN_INTERVAL_UNACCEPTABLE). + * + * @retval ::NRF_SUCCESS The disconnection procedure has been started successfully. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established. + */ +SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code)); + + +/**@brief Set the radio's transmit power. + * + * @param[in] role The role to set the transmit power for, see @ref BLE_GAP_TX_POWER_ROLES for + * possible roles. + * @param[in] handle The handle parameter is interpreted depending on role: + * - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle. + * - If role is @ref BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle, + * will use the specified transmit power, and include it in the advertising packet headers if + * @ref ble_gap_adv_properties_t::include_tx_power set. + * - For all other roles handle is ignored. + * @param[in] tx_power Radio transmit power in dBm (see note for accepted values). + * + * @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm. + * @note The initiator will have the same transmit power as the scanner. + * @note When a connection is created it will inherit the transmit power from the initiator or + * advertiser leading to the connection. + * + * @retval ::NRF_SUCCESS Successfully changed the transmit power. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(uint8_t role, uint16_t handle, int8_t tx_power)); + + +/**@brief Set GAP Appearance value. + * + * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES. + * + * @retval ::NRF_SUCCESS Appearance value set successfully. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + */ +SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance)); + + +/**@brief Get GAP Appearance value. + * + * @param[out] p_appearance Pointer to appearance (16-bit) to be filled in, see @ref BLE_APPEARANCES. + * + * @retval ::NRF_SUCCESS Appearance value retrieved successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t *p_appearance)); + + +/**@brief Set GAP Peripheral Preferred Connection Parameters. + * + * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters. + * + * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table, + see @ref ble_gap_cfg_ppcp_incl_cfg_t. + */ +SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params)); + + +/**@brief Get GAP Peripheral Preferred Connection Parameters. + * + * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored. + * + * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table, + see @ref ble_gap_cfg_ppcp_incl_cfg_t. + */ +SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params)); + + +/**@brief Set GAP device name. + * + * @note If the device name is located in application flash memory (see @ref ble_gap_cfg_device_name_t), + * it cannot be changed. Then @ref NRF_ERROR_FORBIDDEN will be returned. + * + * @param[in] p_write_perm Write permissions for the Device Name characteristic, see @ref ble_gap_conn_sec_mode_t. + * @param[in] p_dev_name Pointer to a UTF-8 encoded, non NULL-terminated string. + * @param[in] len Length of the UTF-8, non NULL-terminated string pointed to by p_dev_name in octets (must be smaller or equal than @ref BLE_GAP_DEVNAME_MAX_LEN). + * + * @retval ::NRF_SUCCESS GAP device name and permissions set successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + * @retval ::NRF_ERROR_FORBIDDEN Device name is not writable. + */ +SVCALL(SD_BLE_GAP_DEVICE_NAME_SET, uint32_t, sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const *p_write_perm, uint8_t const *p_dev_name, uint16_t len)); + + +/**@brief Get GAP device name. + * + * @note If the device name is longer than the size of the supplied buffer, + * p_len will return the complete device name length, + * and not the number of bytes actually returned in p_dev_name. + * The application may use this information to allocate a suitable buffer size. + * + * @param[out] p_dev_name Pointer to an empty buffer where the UTF-8 non NULL-terminated string will be placed. Set to NULL to obtain the complete device name length. + * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output. + * + * @retval ::NRF_SUCCESS GAP device name retrieved successfully. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + */ +SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t *p_dev_name, uint16_t *p_len)); + + +/**@brief Initiate the GAP Authentication procedure. + * + * @details In the central role, this function will send an SMP Pairing Request (or an SMP Pairing Failed if rejected), + * otherwise in the peripheral role, an SMP Security Request will be sent. + * + * @events + * @event{Depending on the security parameters set and the packet exchanges with the peer\, the following events may be generated:} + * @event{@ref BLE_GAP_EVT_SEC_PARAMS_REQUEST} + * @event{@ref BLE_GAP_EVT_SEC_INFO_REQUEST} + * @event{@ref BLE_GAP_EVT_PASSKEY_DISPLAY} + * @event{@ref BLE_GAP_EVT_KEY_PRESSED} + * @event{@ref BLE_GAP_EVT_AUTH_KEY_REQUEST} + * @event{@ref BLE_GAP_EVT_LESC_DHKEY_REQUEST} + * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE} + * @event{@ref BLE_GAP_EVT_AUTH_STATUS} + * @event{@ref BLE_GAP_EVT_TIMEOUT} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_SEC_REQ_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_sec_params Pointer to the @ref ble_gap_sec_params_t structure with the security parameters to be used during the pairing or bonding procedure. + * In the peripheral role, only the bond, mitm, lesc and keypress fields of this structure are used. + * In the central role, this pointer may be NULL to reject a Security Request. + * + * @retval ::NRF_SUCCESS Successfully initiated authentication procedure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - No link has been established. + * - An encryption is already executing or queued. + * @retval ::NRF_ERROR_NO_MEM The maximum number of authentication procedures that can run in parallel for the given role is reached. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported. + * Distribution of own Identity Information is only supported if the Central + * Address Resolution characteristic is configured to be included or + * the Softdevice is configured to support peripheral roles only. + * See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t. + * @retval ::NRF_ERROR_TIMEOUT A SMP timeout has occurred, and further SMP operations on this link is prohibited. + */ +SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params)); + + +/**@brief Reply with GAP security parameters. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * + * @events + * @event{This function is used during authentication procedures, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_JW_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_PERIPH_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_CONFIRM_FAIL_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_KS_TOO_SMALL_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_APP_ERROR_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_REMOTE_PAIRING_FAIL_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_TIMEOUT_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS. + * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure. In the central role this must be set to NULL, as the parameters have + * already been provided during a previous call to @ref sd_ble_gap_authenticate. + * @param[in,out] p_sec_keyset Pointer to a @ref ble_gap_sec_keyset_t security keyset structure. Any keys generated and/or distributed as a result of the ongoing security procedure + * will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application + * upon reception of a @ref BLE_GAP_EVT_AUTH_STATUS event. + * Note that the SoftDevice expects the application to provide memory for storing the + * peer's keys. So it must be ensured that the relevant pointers inside this structure are not NULL. The pointers to the local key + * can, however, be NULL, in which case, the local key data will not be available to the application upon reception of the + * @ref BLE_GAP_EVT_AUTH_STATUS event. + * + * @retval ::NRF_SUCCESS Successfully accepted security parameter from the application. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Security parameters has not been requested. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported. + * Distribution of own Identity Information is only supported if the Central + * Address Resolution characteristic is configured to be included or + * the Softdevice is configured to support peripheral roles only. + * See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t. + */ +SVCALL(SD_BLE_GAP_SEC_PARAMS_REPLY, uint32_t, sd_ble_gap_sec_params_reply(uint16_t conn_handle, uint8_t sec_status, ble_gap_sec_params_t const *p_sec_params, ble_gap_sec_keyset_t const *p_sec_keyset)); + + +/**@brief Reply with an authentication key. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_AUTH_KEY_REQUEST or a @ref BLE_GAP_EVT_PASSKEY_DISPLAY, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * + * @events + * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES. + * @param[in] p_key If key type is @ref BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL. + * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination) + * or NULL when confirming LE Secure Connections Numeric Comparison. + * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in little-endian format. + * + * @retval ::NRF_SUCCESS Authentication key successfully set. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Authentication key has not been requested. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t conn_handle, uint8_t key_type, uint8_t const *p_key)); + + +/**@brief Reply with an LE Secure connections DHKey. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * + * @events + * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_dhkey LE Secure Connections DHKey. + * + * @retval ::NRF_SUCCESS DHKey successfully set. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - The peer is not authenticated. + * - The application has not pulled a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_LESC_DHKEY_REPLY, uint32_t, sd_ble_gap_lesc_dhkey_reply(uint16_t conn_handle, ble_gap_lesc_dhkey_t const *p_dhkey)); + + +/**@brief Notify the peer of a local keypress. + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] kp_not See @ref BLE_GAP_KP_NOT_TYPES. + * + * @retval ::NRF_SUCCESS Keypress notification successfully queued for transmission. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - Authentication key not requested. + * - Passkey has not been entered. + * - Keypresses have not been enabled by both peers. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time. + */ +SVCALL(SD_BLE_GAP_KEYPRESS_NOTIFY, uint32_t, sd_ble_gap_keypress_notify(uint16_t conn_handle, uint8_t kp_not)); + + +/**@brief Generate a set of OOB data to send to a peer out of band. + * + * @note The @ref ble_gap_addr_t included in the OOB data returned will be the currently active one (or, if a connection has already been established, + * the one used during connection setup). The application may manually overwrite it with an updated value. + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. Can be @ref BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet. + * @param[in] p_pk_own LE Secure Connections local P-256 Public Key. + * @param[out] p_oobd_own The OOB data to be sent out of band to a peer. + * + * @retval ::NRF_SUCCESS OOB data successfully generated. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_LESC_OOB_DATA_GET, uint32_t, sd_ble_gap_lesc_oob_data_get(uint16_t conn_handle, ble_gap_lesc_p256_pk_t const *p_pk_own, ble_gap_lesc_oob_data_t *p_oobd_own)); + +/**@brief Provide the OOB data sent/received out of band. + * + * @note An authentication procedure with OOB selected as an algorithm must be in progress when calling this function. + * @note A @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event with the oobd_req set to 1 must have been received prior to calling this function. + * + * @events + * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_oobd_own The OOB data sent out of band to a peer or NULL if the peer has not received OOB data. + * Must correspond to @ref ble_gap_sec_params_t::oob flag in @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. + * @param[in] p_oobd_peer The OOB data received out of band from a peer or NULL if none received. + * Must correspond to @ref ble_gap_sec_params_t::oob flag + * in @ref sd_ble_gap_authenticate in the central role or + * in @ref sd_ble_gap_sec_params_reply in the peripheral role. + * + * @retval ::NRF_SUCCESS OOB data accepted. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - Authentication key not requested + * - Not expecting LESC OOB data + * - Have not actually exchanged passkeys. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_LESC_OOB_DATA_SET, uint32_t, sd_ble_gap_lesc_oob_data_set(uint16_t conn_handle, ble_gap_lesc_oob_data_t const *p_oobd_own, ble_gap_lesc_oob_data_t const *p_oobd_peer)); + + +/**@brief Initiate GAP Encryption procedure. + * + * @details In the central role, this function will initiate the encryption procedure using the encryption information provided. + * + * @events + * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE, The connection security has been updated.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_ENC_MSC} + * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_master_id Pointer to a @ref ble_gap_master_id_t master identification structure. + * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure. + * + * @retval ::NRF_SUCCESS Successfully initiated authentication procedure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE No link has been established. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::BLE_ERROR_INVALID_ROLE Operation is not supported in the Peripheral role. + * @retval ::NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, wait for pending procedures to complete and retry. + */ +SVCALL(SD_BLE_GAP_ENCRYPT, uint32_t, sd_ble_gap_encrypt(uint16_t conn_handle, ble_gap_master_id_t const *p_master_id, ble_gap_enc_info_t const *p_enc_info)); + + +/**@brief Reply with GAP security information. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_INFO_REQUEST, calling it at other times will result in @ref NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * @note Data signing is not yet supported, and p_sign_info must therefore be NULL. + * + * @mscs + * @mmsc{@ref BLE_GAP_PERIPH_ENC_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure. May be NULL to signal none is available. + * @param[in] p_id_info Pointer to a @ref ble_gap_irk_t identity information structure. May be NULL to signal none is available. + * @param[in] p_sign_info Pointer to a @ref ble_gap_sign_info_t signing information structure. May be NULL to signal none is available. + * + * @retval ::NRF_SUCCESS Successfully accepted security information. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - No link has been established. + * - No @ref BLE_GAP_EVT_SEC_INFO_REQUEST pending. + * - Encryption information provided by the app without being requested. See @ref ble_gap_evt_sec_info_request_t::enc_info. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_SEC_INFO_REPLY, uint32_t, sd_ble_gap_sec_info_reply(uint16_t conn_handle, ble_gap_enc_info_t const *p_enc_info, ble_gap_irk_t const *p_id_info, ble_gap_sign_info_t const *p_sign_info)); + + +/**@brief Get the current connection security. + * + * @param[in] conn_handle Connection handle. + * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in. + * + * @retval ::NRF_SUCCESS Current connection security successfully retrieved. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_CONN_SEC_GET, uint32_t, sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t *p_conn_sec)); + + +/**@brief Start reporting the received signal strength to the application. + * + * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called. + * + * @events + * @event{@ref BLE_GAP_EVT_RSSI_CHANGED, New RSSI data available. How often the event is generated is + * dependent on the settings of the threshold_dbm + * and skip_count input parameters.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC} + * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] threshold_dbm Minimum change in dBm before triggering the @ref BLE_GAP_EVT_RSSI_CHANGED event. Events are disabled if threshold_dbm equals @ref BLE_GAP_RSSI_THRESHOLD_INVALID. + * @param[in] skip_count Number of RSSI samples with a change of threshold_dbm or more before sending a new @ref BLE_GAP_EVT_RSSI_CHANGED event. + * + * @retval ::NRF_SUCCESS Successfully activated RSSI reporting. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is already ongoing. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle, uint8_t threshold_dbm, uint8_t skip_count)); + + +/**@brief Stop reporting the received signal strength. + * + * @note An RSSI change detected before the call but not yet received by the application + * may be reported after @ref sd_ble_gap_rssi_stop has been called. + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC} + * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * + * @retval ::NRF_SUCCESS Successfully deactivated RSSI reporting. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle)); + + +/**@brief Get the received signal strength for the last connection event. + * + * @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND + * will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start. + * @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[out] p_rssi Pointer to the location where the RSSI measurement shall be stored. + * @param[out] p_ch_index Pointer to the location where Channel Index for the RSSI measurement shall be stored. + * + * @retval ::NRF_SUCCESS Successfully read the RSSI. + * @retval ::NRF_ERROR_NOT_FOUND No sample is available. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing. + */ +SVCALL(SD_BLE_GAP_RSSI_GET, uint32_t, sd_ble_gap_rssi_get(uint16_t conn_handle, int8_t *p_rssi, uint8_t *p_ch_index)); + + +/**@brief Start or continue scanning (GAP Discovery procedure, Observer Procedure). + * + * @note A call to this function will require the application to keep the memory pointed by + * p_adv_report_buffer alive until the buffer is released. The buffer is released when the scanner is stopped + * or when this function is called with another buffer. + * + * @note The scanner will automatically stop in the following cases: + * - @ref sd_ble_gap_scan_stop is called. + * - @ref sd_ble_gap_connect is called. + * - A @ref BLE_GAP_EVT_TIMEOUT with source set to @ref BLE_GAP_TIMEOUT_SRC_SCAN is received. + * - When a @ref BLE_GAP_EVT_ADV_REPORT event is received and @ref ble_gap_adv_report_type_t::status is not set to + * @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. In this case scanning is only paused to let the application + * access received data. The application must call this function to continue scanning, or call @ref sd_ble_gap_scan_stop + * to stop scanning. + * + * @note If a @ref BLE_GAP_EVT_ADV_REPORT event is received with @ref ble_gap_adv_report_type_t::status set to + * @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the scanner will continue scanning, and the application will + * receive more reports from this advertising event. The following reports will include the old and new received data. + * + * @events + * @event{@ref BLE_GAP_EVT_ADV_REPORT, An advertising or scan response packet has been received.} + * @event{@ref BLE_GAP_EVT_TIMEOUT, Scanner has timed out.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_SCAN_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @param[in] p_scan_params Pointer to scan parameters structure. When this function is used to continue + * scanning, this parameter must be NULL. + * @param[in] p_adv_report_buffer Pointer to buffer used to store incoming advertising data. + * The memory pointed to should be kept alive until the scanning is stopped. + * See @ref BLE_GAP_SCAN_BUFFER_SIZE for minimum and maximum buffer size. + * If the scanner receives advertising data larger than can be stored in the buffer, + * a @ref BLE_GAP_EVT_ADV_REPORT will be raised with @ref ble_gap_adv_report_type_t::status + * set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_TRUNCATED. + * + * @retval ::NRF_SUCCESS Successfully initiated scanning procedure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either: + * - Scanning is already ongoing and p_scan_params was not NULL + * - Scanning is not running and p_scan_params was NULL. + * - The scanner has timed out when this function is called to continue scanning. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. See @ref ble_gap_scan_params_t. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported parameters supplied. See @ref ble_gap_scan_params_t. + * @retval ::NRF_ERROR_INVALID_LENGTH The provided buffer length is invalid. See @ref BLE_GAP_SCAN_BUFFER_MIN. + * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available. + * Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + */ +SVCALL(SD_BLE_GAP_SCAN_START, uint32_t, sd_ble_gap_scan_start(ble_gap_scan_params_t const *p_scan_params, ble_data_t const * p_adv_report_buffer)); + + +/**@brief Stop scanning (GAP Discovery procedure, Observer Procedure). + * + * @note The buffer provided in @ref sd_ble_gap_scan_start is released. + * + * @mscs + * @mmsc{@ref BLE_GAP_SCAN_MSC} + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Successfully stopped scanning procedure. + * @retval ::NRF_ERROR_INVALID_STATE Not in the scanning state. + */ +SVCALL(SD_BLE_GAP_SCAN_STOP, uint32_t, sd_ble_gap_scan_stop(void)); + + +/**@brief Create a connection (GAP Link Establishment). + * + * @note If a scanning procedure is currently in progress it will be automatically stopped when calling this function. + * The scanning procedure will be stopped even if the function returns an error. + * + * @events + * @event{@ref BLE_GAP_EVT_CONNECTED, A connection was established.} + * @event{@ref BLE_GAP_EVT_TIMEOUT, Failed to establish a connection.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC} + * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC} + * @endmscs + * + * @param[in] p_peer_addr Pointer to peer identity address. If @ref ble_gap_scan_params_t::filter_policy is set to use + * whitelist, then p_peer_addr is ignored. + * @param[in] p_scan_params Pointer to scan parameters structure. + * @param[in] p_conn_params Pointer to desired connection parameters. + * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or + * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. + * + * @retval ::NRF_SUCCESS Successfully initiated connection procedure. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid parameter(s) pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * - Invalid parameter(s) in p_scan_params or p_conn_params. + * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set. + * - Peer address was not present in the device identity list, see @ref sd_ble_gap_device_identities_set. + * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found. + * @retval ::NRF_ERROR_INVALID_STATE The SoftDevice is in an invalid state to perform this operation. This may be due to an + * existing locally initiated connect procedure, which must complete before initiating again. + * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Peer address. + * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections for this connection configuration tag has been reached. + * To increase the number of available connections, + * use @ref sd_ble_cfg_set with @ref BLE_GAP_CFG_ROLE_COUNT or @ref BLE_CONN_CFG_GAP. + * @retval ::NRF_ERROR_RESOURCES Either: + * - Not enough BLE role slots available. + * Stop one or more currently active roles (Central, Peripheral or Observer) and try again. + * - The event_length parameter associated with conn_cfg_tag is too small to be able to + * establish a connection on the selected @ref ble_gap_scan_params_t::scan_phys. + * Use @ref sd_ble_cfg_set to increase the event length. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + */ +SVCALL(SD_BLE_GAP_CONNECT, uint32_t, sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params, uint8_t conn_cfg_tag)); + + +/**@brief Cancel a connection establishment. + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Successfully canceled an ongoing connection procedure. + * @retval ::NRF_ERROR_INVALID_STATE No locally initiated connect procedure started or connection + * completed occurred. + */ +SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void)); + + +/**@brief Initiate or respond to a PHY Update Procedure + * + * @details This function is used to initiate or respond to a PHY Update Procedure. It will always + * generate a @ref BLE_GAP_EVT_PHY_UPDATE event if successfully executed. + * If this function is used to initiate a PHY Update procedure and the only option + * provided in @ref ble_gap_phys_t::tx_phys and @ref ble_gap_phys_t::rx_phys is the + * currently active PHYs in the respective directions, the SoftDevice will generate a + * @ref BLE_GAP_EVT_PHY_UPDATE with the current PHYs set and will not initiate the + * procedure in the Link Layer. + * + * If @ref ble_gap_phys_t::tx_phys or @ref ble_gap_phys_t::rx_phys is @ref BLE_GAP_PHY_AUTO, + * then the stack will select PHYs based on the peer's PHY preferences and the local link + * configuration. The PHY Update procedure will for this case result in a PHY combination + * that respects the time constraints configured with @ref sd_ble_cfg_set and the current + * link layer data length. + * + * When acting as a central, the SoftDevice will select the fastest common PHY in each direction. + * + * If the peer does not support the PHY Update Procedure, then the resulting + * @ref BLE_GAP_EVT_PHY_UPDATE event will have a status set to + * @ref BLE_HCI_UNSUPPORTED_REMOTE_FEATURE. + * + * If the PHY Update procedure was rejected by the peer due to a procedure collision, the status + * will be @ref BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION or + * @ref BLE_HCI_DIFFERENT_TRANSACTION_COLLISION. + * If the peer responds to the PHY Update procedure with invalid parameters, the status + * will be @ref BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS. + * If the PHY Update procedure was rejected by the peer for a different reason, the status will + * contain the reason as specified by the peer. + * + * @events + * @event{@ref BLE_GAP_EVT_PHY_UPDATE, Result of the PHY Update Procedure.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GAP_CENTRAL_PHY_UPDATE} + * @mmsc{@ref BLE_GAP_PERIPHERAL_PHY_UPDATE} + * @endmscs + * + * @param[in] conn_handle Connection handle to indicate the connection for which the PHY Update is requested. + * @param[in] p_gap_phys Pointer to PHY structure. + * + * @retval ::NRF_SUCCESS Successfully requested a PHY Update. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call. + * @retval ::NRF_ERROR_INVALID_STATE No link has been established. + * @retval ::NRF_ERROR_BUSY Procedure is already in progress or not allowed at this time. Process pending events and wait for the pending procedure to complete and retry. + * + */ +SVCALL(SD_BLE_GAP_PHY_UPDATE, uint32_t, sd_ble_gap_phy_update(uint16_t conn_handle, ble_gap_phys_t const *p_gap_phys)); + + +/**@brief Initiate or respond to a Data Length Update Procedure. + * + * @note If the application uses @ref BLE_GAP_DATA_LENGTH_AUTO for one or more members of + * p_dl_params, the SoftDevice will choose the highest value supported in current + * configuration and connection parameters. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_dl_params Pointer to local parameters to be used in Data Length Update + * Procedure. Set any member to @ref BLE_GAP_DATA_LENGTH_AUTO to let + * the SoftDevice automatically decide the value for that member. + * Set to NULL to use automatic values for all members. + * @param[out] p_dl_limitation Pointer to limitation to be written when local device does not + * have enough resources or does not support the requested Data Length + * Update parameters. Ignored if NULL. + * + * @mscs + * @mmsc{@ref BLE_GAP_DATA_LENGTH_UPDATE_PROCEDURE_MSC} + * @endmscs + * + * @retval ::NRF_SUCCESS Successfully set Data Length Extension initiation/response parameters. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied. + * @retval ::NRF_ERROR_INVALID_STATE No link has been established. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. + * @retval ::NRF_ERROR_NOT_SUPPORTED The requested parameters are not supported by the SoftDevice. Inspect + * p_dl_limitation to see which parameter is not supported. + * @retval ::NRF_ERROR_RESOURCES The connection event length configured for this link is not sufficient for the requested parameters. + * Use @ref sd_ble_cfg_set with @ref BLE_CONN_CFG_GAP to increase the connection event length. + * Inspect p_dl_limitation to see where the limitation is. + * @retval ::NRF_ERROR_BUSY Peer has already initiated a Data Length Update Procedure. Process the + * pending @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST event to respond. + */ +SVCALL(SD_BLE_GAP_DATA_LENGTH_UPDATE, uint32_t, sd_ble_gap_data_length_update(uint16_t conn_handle, ble_gap_data_length_params_t const *p_dl_params, ble_gap_data_length_limitation_t *p_dl_limitation)); + +/**@brief Start the Quality of Service (QoS) channel survey module. + * + * @details The channel survey module provides measurements of the energy levels on + * the Bluetooth Low Energy channels. When the module is enabled, @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT + * events will periodically report the measured energy levels for each channel. + * + * @note The measurements are scheduled with lower priority than other Bluetooth Low Energy roles, + * Radio Timeslot API events and Flash API events. + * + * @note The channel survey module will attempt to do measurements so that the average interval + * between measurements will be interval_us. However due to the channel survey module + * having the lowest priority of all roles and modules, this may not be possible. In that + * case fewer than expected channel survey reports may be given. + * + * @note In order to use the channel survey module, @ref ble_gap_cfg_role_count_t::qos_channel_survey_role_available + * must be set. This is done using @ref sd_ble_cfg_set. + * + * @param[in] interval_us Requested average interval for the measurements and reports. See + * @ref BLE_GAP_QOS_CHANNEL_SURVEY_INTERVALS for valid ranges. If set + * to @ref BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_CONTINUOUS, the channel + * survey role will be scheduled at every available opportunity. + * + * @retval ::NRF_SUCCESS The module is successfully started. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter supplied. interval_us is out of the + * allowed range. + * @retval ::NRF_ERROR_INVALID_STATE Trying to start the module when already running. + * @retval ::NRF_ERROR_RESOURCES The channel survey module is not available to the application. + * Set @ref ble_gap_cfg_role_count_t::qos_channel_survey_role_available using + * @ref sd_ble_cfg_set. + */ +SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START, uint32_t, sd_ble_gap_qos_channel_survey_start(uint32_t interval_us)); + +/**@brief Stop the Quality of Service (QoS) channel survey module. + * + * @note The SoftDevice may generate one @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT event after this + * function is called. + * + * @retval ::NRF_SUCCESS The module is successfully stopped. + * @retval ::NRF_ERROR_INVALID_STATE Trying to stop the module when it is not running. + */ +SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP, uint32_t, sd_ble_gap_qos_channel_survey_stop(void)); + + +/**@brief Obtain the next connection event counter value. + * + * @details The connection event counter is initialized to zero on the first connection event. The value is incremented + * by one for each connection event. For more information see Bluetooth Core Specification v5.0, Vol 6, Part B, + * Section 4.5.1. + * + * @note The connection event counter obtained through this API will be outdated if this API is called + * at the same time as the connection event counter is incremented. + * + * @note This API will always return the last connection event counter + 1. + * The actual connection event may be multiple connection events later if: + * - Slave latency is enabled and there is no data to transmit or receive. + * - Another role is scheduled with a higher priority at the same time as the next connection event. + * + * @param[in] conn_handle Connection handle. + * @param[out] p_counter Pointer to the variable where the next connection event counter will be written. + * + * @retval ::NRF_SUCCESS The connection event counter was successfully retrieved. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET, uint32_t, sd_ble_gap_next_conn_evt_counter_get(uint16_t conn_handle, uint16_t * p_counter)); + + +/**@brief Start triggering a given task on connection event start. + * + * @details When enabled, this feature will trigger a PPI task at the start of connection events. + * The application can configure the SoftDevice to trigger every N connection events starting from + * a given connection event counter. See also @ref ble_gap_conn_event_trigger_t. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_params Connection event trigger parameters. + * + * @retval ::NRF_SUCCESS Success. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter supplied. See @ref ble_gap_conn_event_trigger_t. + * @retval ::NRF_ERROR_INVALID_STATE Either: + * - Trying to start connection event triggering when it is already ongoing. + * - @ref ble_gap_conn_event_trigger_t::conn_evt_counter_start is in the past. + * Use @ref sd_ble_gap_next_conn_evt_counter_get to find a new value + to be used as ble_gap_conn_event_trigger_t::conn_evt_counter_start. + */ +SVCALL(SD_BLE_GAP_CONN_EVT_TRIGGER_START, uint32_t, sd_ble_gap_conn_evt_trigger_start(uint16_t conn_handle, ble_gap_conn_event_trigger_t const * p_params)); + + +/**@brief Stop triggering the task configured using @ref sd_ble_gap_conn_evt_trigger_start. + * + * @param[in] conn_handle Connection handle. + * + * @retval ::NRF_SUCCESS Success. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @retval ::NRF_ERROR_INVALID_STATE Trying to stop connection event triggering when it is not enabled. + */ +SVCALL(SD_BLE_GAP_CONN_EVT_TRIGGER_STOP, uint32_t, sd_ble_gap_conn_evt_trigger_stop(uint16_t conn_handle)); + + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // BLE_GAP_H__ + +/** + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gatt.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gatt.h new file mode 100644 index 000000000..c39288441 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gatt.h @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2013 - 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_GATT Generic Attribute Profile (GATT) Common + @{ + @brief Common definitions and prototypes for the GATT interfaces. + */ + +#ifndef BLE_GATT_H__ +#define BLE_GATT_H__ + +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_GATT_DEFINES Defines + * @{ */ + +/** @brief Default ATT MTU, in bytes. */ +#define BLE_GATT_ATT_MTU_DEFAULT 23 + +/**@brief Invalid Attribute Handle. */ +#define BLE_GATT_HANDLE_INVALID 0x0000 + +/**@brief First Attribute Handle. */ +#define BLE_GATT_HANDLE_START 0x0001 + +/**@brief Last Attribute Handle. */ +#define BLE_GATT_HANDLE_END 0xFFFF + +/** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources + * @{ */ +#define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */ +/** @} */ + +/** @defgroup BLE_GATT_WRITE_OPS GATT Write operations + * @{ */ +#define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */ +#define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */ +#define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */ +#define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */ +#define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */ +/** @} */ + +/** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags + * @{ */ +#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00 /**< Cancel prepared write. */ +#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01 /**< Execute prepared write. */ +/** @} */ + +/** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations + * @{ */ +#define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */ +#define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */ +/** @} */ + +/** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes + * @{ */ +#define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */ +#define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */ +#define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */ +#define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */ +#define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */ +#define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorization. */ +#define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */ +#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */ +#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */ +#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */ +#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Insufficient resources. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */ +#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */ +#define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */ +#define BLE_GATT_STATUS_ATTERR_CPS_WRITE_REQ_REJECTED 0x01FC /**< ATT Common Profile and Service Error: Write request rejected. */ +#define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */ +#define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */ +#define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */ +/** @} */ + + +/** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats + * @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml + * @{ */ +#define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */ +#define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */ +#define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */ +#define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */ +#define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */ +#define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */ +#define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */ +#define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */ +#define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */ +#define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */ +#define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */ +#define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */ +/** @} */ + +/** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces + * @{ + */ +#define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01 /**< Bluetooth SIG defined Namespace. */ +#define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000 /**< Namespace Description Unknown. */ +/** @} */ + +/** @} */ + +/** @addtogroup BLE_GATT_STRUCTURES Structures + * @{ */ + +/** + * @brief BLE GATT connection configuration parameters, set with @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_INVALID_PARAM att_mtu is smaller than @ref BLE_GATT_ATT_MTU_DEFAULT. + */ +typedef struct +{ + uint16_t att_mtu; /**< Maximum size of ATT packet the SoftDevice can send or receive. + The default and minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT. + @mscs + @mmsc{@ref BLE_GATTC_MTU_EXCHANGE} + @mmsc{@ref BLE_GATTS_MTU_EXCHANGE} + @endmscs + */ +} ble_gatt_conn_cfg_t; + +/**@brief GATT Characteristic Properties. */ +typedef struct +{ + /* Standard properties */ + uint8_t broadcast :1; /**< Broadcasting of the value permitted. */ + uint8_t read :1; /**< Reading the value permitted. */ + uint8_t write_wo_resp :1; /**< Writing the value with Write Command permitted. */ + uint8_t write :1; /**< Writing the value with Write Request permitted. */ + uint8_t notify :1; /**< Notification of the value permitted. */ + uint8_t indicate :1; /**< Indications of the value permitted. */ + uint8_t auth_signed_wr :1; /**< Writing the value with Signed Write Command permitted. */ +} ble_gatt_char_props_t; + +/**@brief GATT Characteristic Extended Properties. */ +typedef struct +{ + /* Extended properties */ + uint8_t reliable_wr :1; /**< Writing the value with Queued Write operations permitted. */ + uint8_t wr_aux :1; /**< Writing the Characteristic User Description descriptor permitted. */ +} ble_gatt_char_ext_props_t; + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // BLE_GATT_H__ + +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h new file mode 100644 index 000000000..a71b5e155 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h @@ -0,0 +1,755 @@ +/* + * Copyright (c) 2011 - 2020, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client + @{ + @brief Definitions and prototypes for the GATT Client interface. + */ + +#ifndef BLE_GATTC_H__ +#define BLE_GATTC_H__ + +#include +#include "nrf.h" +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" +#include "ble_gatt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations + * @{ */ + +/**@brief GATTC API SVC numbers. */ +enum BLE_GATTC_SVCS +{ + SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */ + SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */ + SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */ + SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */ + SD_BLE_GATTC_ATTR_INFO_DISCOVER, /**< Attribute Information Discovery. */ + SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */ + SD_BLE_GATTC_READ, /**< Generic read. */ + SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */ + SD_BLE_GATTC_WRITE, /**< Generic write. */ + SD_BLE_GATTC_HV_CONFIRM, /**< Handle Value Confirmation. */ + SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, /**< Exchange MTU Request. */ +}; + +/** + * @brief GATT Client Event IDs. + */ +enum BLE_GATTC_EVTS +{ + BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. \n See @ref ble_gattc_evt_prim_srvc_disc_rsp_t. */ + BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. \n See @ref ble_gattc_evt_rel_disc_rsp_t. */ + BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. \n See @ref ble_gattc_evt_char_disc_rsp_t. */ + BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. \n See @ref ble_gattc_evt_desc_disc_rsp_t. */ + BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, /**< Attribute Information Response event. \n See @ref ble_gattc_evt_attr_info_disc_rsp_t. */ + BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. \n See @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t. */ + BLE_GATTC_EVT_READ_RSP, /**< Read Response event. \n See @ref ble_gattc_evt_read_rsp_t. */ + BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. \n See @ref ble_gattc_evt_char_vals_read_rsp_t. */ + BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. \n See @ref ble_gattc_evt_write_rsp_t. */ + BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. \n Confirm indication with @ref sd_ble_gattc_hv_confirm. \n See @ref ble_gattc_evt_hvx_t. */ + BLE_GATTC_EVT_EXCHANGE_MTU_RSP, /**< Exchange MTU Response event. \n See @ref ble_gattc_evt_exchange_mtu_rsp_t. */ + BLE_GATTC_EVT_TIMEOUT, /**< Timeout event. \n See @ref ble_gattc_evt_timeout_t. */ + BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE /**< Write without Response transmission complete. \n See @ref ble_gattc_evt_write_cmd_tx_complete_t. */ +}; + +/**@brief GATTC Option IDs. + * IDs that uniquely identify a GATTC option. + */ +enum BLE_GATTC_OPTS +{ + BLE_GATTC_OPT_UUID_DISC = BLE_GATTC_OPT_BASE, /**< UUID discovery. @ref ble_gattc_opt_uuid_disc_t */ +}; + +/** @} */ + +/** @addtogroup BLE_GATTC_DEFINES Defines + * @{ */ + +/** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC + * @{ */ +#define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000) /**< Procedure not Permitted. */ +/** @} */ + +/** @defgroup BLE_GATTC_ATTR_INFO_FORMAT Attribute Information Formats + * @{ */ +#define BLE_GATTC_ATTR_INFO_FORMAT_16BIT 1 /**< 16-bit Attribute Information Format. */ +#define BLE_GATTC_ATTR_INFO_FORMAT_128BIT 2 /**< 128-bit Attribute Information Format. */ +/** @} */ + +/** @defgroup BLE_GATTC_DEFAULTS GATT Client defaults + * @{ */ +#define BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT 1 /**< Default number of Write without Response that can be queued for transmission. */ +/** @} */ + +/** @} */ + +/** @addtogroup BLE_GATTC_STRUCTURES Structures + * @{ */ + +/** + * @brief BLE GATTC connection configuration parameters, set with @ref sd_ble_cfg_set. + */ +typedef struct +{ + uint8_t write_cmd_tx_queue_size; /**< The guaranteed minimum number of Write without Response that can be queued for transmission. + The default value is @ref BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT */ +} ble_gattc_conn_cfg_t; + +/**@brief Operation Handle Range. */ +typedef struct +{ + uint16_t start_handle; /**< Start Handle. */ + uint16_t end_handle; /**< End Handle. */ +} ble_gattc_handle_range_t; + + +/**@brief GATT service. */ +typedef struct +{ + ble_uuid_t uuid; /**< Service UUID. */ + ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */ +} ble_gattc_service_t; + + +/**@brief GATT include. */ +typedef struct +{ + uint16_t handle; /**< Include Handle. */ + ble_gattc_service_t included_srvc; /**< Handle of the included service. */ +} ble_gattc_include_t; + + +/**@brief GATT characteristic. */ +typedef struct +{ + ble_uuid_t uuid; /**< Characteristic UUID. */ + ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ + uint8_t char_ext_props : 1; /**< Extended properties present. */ + uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */ + uint16_t handle_value; /**< Handle of the Characteristic Value. */ +} ble_gattc_char_t; + + +/**@brief GATT descriptor. */ +typedef struct +{ + uint16_t handle; /**< Descriptor Handle. */ + ble_uuid_t uuid; /**< Descriptor UUID. */ +} ble_gattc_desc_t; + + +/**@brief Write Parameters. */ +typedef struct +{ + uint8_t write_op; /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */ + uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */ + uint16_t handle; /**< Handle to the attribute to be written. */ + uint16_t offset; /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */ + uint16_t len; /**< Length of data in bytes. */ + uint8_t const *p_value; /**< Pointer to the value data. */ +} ble_gattc_write_params_t; + +/**@brief Attribute Information for 16-bit Attribute UUID. */ +typedef struct +{ + uint16_t handle; /**< Attribute handle. */ + ble_uuid_t uuid; /**< 16-bit Attribute UUID. */ +} ble_gattc_attr_info16_t; + +/**@brief Attribute Information for 128-bit Attribute UUID. */ +typedef struct +{ + uint16_t handle; /**< Attribute handle. */ + ble_uuid128_t uuid; /**< 128-bit Attribute UUID. */ +} ble_gattc_attr_info128_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Service count. */ + ble_gattc_service_t services[1]; /**< Service data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_prim_srvc_disc_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_REL_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Include count. */ + ble_gattc_include_t includes[1]; /**< Include data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_rel_disc_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Characteristic count. */ + ble_gattc_char_t chars[1]; /**< Characteristic data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_char_disc_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_DESC_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Descriptor count. */ + ble_gattc_desc_t descs[1]; /**< Descriptor data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_desc_disc_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Attribute count. */ + uint8_t format; /**< Attribute information format, see @ref BLE_GATTC_ATTR_INFO_FORMAT. */ + union { + ble_gattc_attr_info16_t attr_info16[1]; /**< Attribute information for 16-bit Attribute UUID. + @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ + ble_gattc_attr_info128_t attr_info128[1]; /**< Attribute information for 128-bit Attribute UUID. + @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ + } info; /**< Attribute information union. */ +} ble_gattc_evt_attr_info_disc_rsp_t; + +/**@brief GATT read by UUID handle value pair. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint8_t *p_value; /**< Pointer to the Attribute Value, length is available in @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t::value_len. */ +} ble_gattc_handle_value_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */ +typedef struct +{ + uint16_t count; /**< Handle-Value Pair Count. */ + uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */ + uint8_t handle_value[1]; /**< Handle-Value(s) list. To iterate through the list use @ref sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter. + @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_char_val_by_uuid_read_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_READ_RSP. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint16_t offset; /**< Offset of the attribute data. */ + uint16_t len; /**< Attribute data length. */ + uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_read_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */ +typedef struct +{ + uint16_t len; /**< Concatenated Attribute values length. */ + uint8_t values[1]; /**< Attribute values. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_char_vals_read_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_RSP. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */ + uint16_t offset; /**< Data offset. */ + uint16_t len; /**< Data length. */ + uint8_t data[1]; /**< Data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_write_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_HVX. */ +typedef struct +{ + uint16_t handle; /**< Handle to which the HVx operation applies. */ + uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ + uint16_t len; /**< Attribute data length. */ + uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gattc_evt_hvx_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP. */ +typedef struct +{ + uint16_t server_rx_mtu; /**< Server RX MTU size. */ +} ble_gattc_evt_exchange_mtu_rsp_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_TIMEOUT. */ +typedef struct +{ + uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ +} ble_gattc_evt_timeout_t; + +/**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE. */ +typedef struct +{ + uint8_t count; /**< Number of write without response transmissions completed. */ +} ble_gattc_evt_write_cmd_tx_complete_t; + +/**@brief GATTC event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which event occurred. */ + uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ + uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases @ref BLE_GATT_HANDLE_INVALID. */ + union + { + ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */ + ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */ + ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */ + ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */ + ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */ + ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */ + ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */ + ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */ + ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */ + ble_gattc_evt_exchange_mtu_rsp_t exchange_mtu_rsp; /**< Exchange MTU Response Event Parameters. */ + ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */ + ble_gattc_evt_attr_info_disc_rsp_t attr_info_disc_rsp; /**< Attribute Information Discovery Event Parameters. */ + ble_gattc_evt_write_cmd_tx_complete_t write_cmd_tx_complete; /**< Write without Response transmission complete Event Parameters. */ + } params; /**< Event Parameters. @note Only valid if @ref gatt_status == @ref BLE_GATT_STATUS_SUCCESS. */ +} ble_gattc_evt_t; + +/**@brief UUID discovery option. + * + * @details Used with @ref sd_ble_opt_set to enable and disable automatic insertion of discovered 128-bit UUIDs to the + * Vendor Specific UUID table. Disabled by default. + * - When disabled, if a procedure initiated by + * @ref sd_ble_gattc_primary_services_discover, + * @ref sd_ble_gattc_relationships_discover, + * @ref sd_ble_gattc_characteristics_discover, + * @ref sd_ble_gattc_descriptors_discover + * finds a 128-bit UUID which was not added by @ref sd_ble_uuid_vs_add, @ref ble_uuid_t::type will be set + * to @ref BLE_UUID_TYPE_UNKNOWN in the corresponding event. + * - When enabled, all found 128-bit UUIDs will be automatically added. The application can use + * @ref sd_ble_uuid_encode to retrieve the 128-bit UUID from @ref ble_uuid_t received in the corresponding + * event. If the total number of Vendor Specific UUIDs exceeds the table capacity, @ref ble_uuid_t::type will + * be set to @ref BLE_UUID_TYPE_UNKNOWN in the corresponding event. + * See also @ref ble_common_cfg_vs_uuid_t, @ref sd_ble_uuid_vs_remove. + * + * @note @ref sd_ble_opt_get is not supported for this option. + * + * @retval ::NRF_SUCCESS Set successfully. + * + */ +typedef struct +{ + uint8_t auto_add_vs_enable : 1; /**< Set to 1 to enable (or 0 to disable) automatic insertion of discovered 128-bit UUIDs. */ +} ble_gattc_opt_uuid_disc_t; + +/**@brief Option structure for GATTC options. */ +typedef union +{ + ble_gattc_opt_uuid_disc_t uuid_disc; /**< Parameters for the UUID discovery option. */ +} ble_gattc_opt_t; + +/** @} */ + +/** @addtogroup BLE_GATTC_FUNCTIONS Functions + * @{ */ + +/**@brief Initiate or continue a GATT Primary Service Discovery procedure. + * + * @details This function initiates or resumes a Primary Service discovery procedure, starting from the supplied handle. + * If the last service has not been reached, this function must be called again with an updated start handle value to continue the search. + * See also @ref ble_gattc_opt_uuid_disc_t. + * + * @events + * @event{@ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_PRIM_SRVC_DISC_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] start_handle Handle to start searching from. + * @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const *p_srvc_uuid)); + + +/**@brief Initiate or continue a GATT Relationship Discovery procedure. + * + * @details This function initiates or resumes the Find Included Services sub-procedure. If the last included service has not been reached, + * this must be called again with an updated handle range to continue the search. + * See also @ref ble_gattc_opt_uuid_disc_t. + * + * @events + * @event{@ref BLE_GATTC_EVT_REL_DISC_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_REL_DISC_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); + + +/**@brief Initiate or continue a GATT Characteristic Discovery procedure. + * + * @details This function initiates or resumes a Characteristic discovery procedure. If the last Characteristic has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * See also @ref ble_gattc_opt_uuid_disc_t. + * + * @events + * @event{@ref BLE_GATTC_EVT_CHAR_DISC_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_CHAR_DISC_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); + + +/**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure. + * + * @details This function initiates or resumes a Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * See also @ref ble_gattc_opt_uuid_disc_t. + * + * @events + * @event{@ref BLE_GATTC_EVT_DESC_DISC_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_DESC_DISC_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)); + + +/**@brief Initiate or continue a GATT Read using Characteristic UUID procedure. + * + * @details This function initiates or resumes a Read using Characteristic UUID procedure. If the last Characteristic has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * + * @events + * @event{@ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_READ_UUID_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_uuid Pointer to a Characteristic value UUID to read. + * @param[in] p_handle_range A pointer to the range of handles to perform this procedure on. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const *p_uuid, ble_gattc_handle_range_t const *p_handle_range)); + + +/**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure. + * + * @details This function initiates or resumes a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor + * to be read is longer than ATT_MTU - 1, this function must be called multiple times with appropriate offset to read the + * complete value. + * + * @events + * @event{@ref BLE_GATTC_EVT_READ_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_VALUE_READ_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] handle The handle of the attribute to be read. + * @param[in] offset Offset into the attribute value to be read. + * + * @retval ::NRF_SUCCESS Successfully started or resumed the Read (Long) procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset)); + + +/**@brief Initiate a GATT Read Multiple Characteristic Values procedure. + * + * @details This function initiates a GATT Read Multiple Characteristic Values procedure. + * + * @events + * @event{@ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_READ_MULT_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read. + * @param[in] handle_count The number of handles in p_handles. + * + * @retval ::NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const *p_handles, uint16_t handle_count)); + + +/**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure. + * + * @details This function can perform all write procedures described in GATT. + * + * @note Only one write with response procedure can be ongoing per connection at a time. + * If the application tries to write with response while another write with response procedure is ongoing, + * the function call will return @ref NRF_ERROR_BUSY. + * A @ref BLE_GATTC_EVT_WRITE_RSP event will be issued as soon as the write response arrives from the peer. + * + * @note The number of Write without Response that can be queued is configured by @ref ble_gattc_conn_cfg_t::write_cmd_tx_queue_size + * When the queue is full, the function call will return @ref NRF_ERROR_RESOURCES. + * A @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event will be issued as soon as the transmission of the write without response is complete. + * + * @note The application can keep track of the available queue element count for writes without responses by following the procedure below: + * - Store initial queue element count in a variable. + * - Decrement the variable, which stores the currently available queue element count, by one when a call to this function returns @ref NRF_SUCCESS. + * - Increment the variable, which stores the current available queue element count, by the count variable in @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event. + * + * @events + * @event{@ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE, Write without response transmission complete.} + * @event{@ref BLE_GATTC_EVT_WRITE_RSP, Write response received from the peer.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_VALUE_WRITE_WITHOUT_RESP_MSC} + * @mmsc{@ref BLE_GATTC_VALUE_WRITE_MSC} + * @mmsc{@ref BLE_GATTC_VALUE_LONG_WRITE_MSC} + * @mmsc{@ref BLE_GATTC_VALUE_RELIABLE_WRITE_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_write_params A pointer to a write parameters structure. + * + * @retval ::NRF_SUCCESS Successfully started the Write procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + * @retval ::NRF_ERROR_BUSY For write with response, procedure already in progress. Wait for a @ref BLE_GATTC_EVT_WRITE_RSP event and retry. + * @retval ::NRF_ERROR_RESOURCES Too many writes without responses queued. + * Wait for a @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event and retry. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const *p_write_params)); + + +/**@brief Send a Handle Value Confirmation to the GATT Server. + * + * @mscs + * @mmsc{@ref BLE_GATTC_HVI_MSC} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] handle The handle of the attribute in the indication. + * + * @retval ::NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no Indication pending to be confirmed. + * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle)); + +/**@brief Discovers information about a range of attributes on a GATT server. + * + * @events + * @event{@ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, Generated when information about a range of attributes has been received.} + * @endevents + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range The range of handles to request information about. + * + * @retval ::NRF_SUCCESS Successfully started an attribute information discovery procedure. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid connection state + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_ATTR_INFO_DISCOVER, uint32_t, sd_ble_gattc_attr_info_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * p_handle_range)); + +/**@brief Start an ATT_MTU exchange by sending an Exchange MTU Request to the server. + * + * @details The SoftDevice sets ATT_MTU to the minimum of: + * - The Client RX MTU value, and + * - The Server RX MTU value from @ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP. + * + * However, the SoftDevice never sets ATT_MTU lower than @ref BLE_GATT_ATT_MTU_DEFAULT. + * + * @events + * @event{@ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTC_MTU_EXCHANGE} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] client_rx_mtu Client RX MTU size. + * - The minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT. + * - The maximum value is @ref ble_gatt_conn_cfg_t::att_mtu in the connection configuration + used for this connection. + * - The value must be equal to Server RX MTU size given in @ref sd_ble_gatts_exchange_mtu_reply + * if an ATT_MTU exchange has already been performed in the other direction. + * + * @retval ::NRF_SUCCESS Successfully sent request to the server. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid connection state or an ATT_MTU exchange was already requested once. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid Client RX MTU size supplied. + * @retval ::NRF_ERROR_BUSY Client procedure already in progress. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, uint32_t, sd_ble_gattc_exchange_mtu_request(uint16_t conn_handle, uint16_t client_rx_mtu)); + +/**@brief Iterate through Handle-Value(s) list in @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP event. + * + * @param[in] p_gattc_evt Pointer to event buffer containing @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP event. + * @note If the buffer contains different event, behavior is undefined. + * @param[in,out] p_iter Iterator, points to @ref ble_gattc_handle_value_t structure that will be filled in with + * the next Handle-Value pair in each iteration. If the function returns other than + * @ref NRF_SUCCESS, it will not be changed. + * - To start iteration, initialize the structure to zero. + * - To continue, pass the value from previous iteration. + * + * \code + * ble_gattc_handle_value_t iter; + * memset(&iter, 0, sizeof(ble_gattc_handle_value_t)); + * while (sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(&ble_evt.evt.gattc_evt, &iter) == NRF_SUCCESS) + * { + * app_handle = iter.handle; + * memcpy(app_value, iter.p_value, ble_evt.evt.gattc_evt.params.char_val_by_uuid_read_rsp.value_len); + * } + * \endcode + * + * @retval ::NRF_SUCCESS Successfully retrieved the next Handle-Value pair. + * @retval ::NRF_ERROR_NOT_FOUND No more Handle-Value pairs available in the list. + */ +__STATIC_INLINE uint32_t sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(ble_gattc_evt_t *p_gattc_evt, ble_gattc_handle_value_t *p_iter); + +/** @} */ + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +__STATIC_INLINE uint32_t sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(ble_gattc_evt_t *p_gattc_evt, ble_gattc_handle_value_t *p_iter) +{ + uint32_t value_len = p_gattc_evt->params.char_val_by_uuid_read_rsp.value_len; + uint8_t *p_first = p_gattc_evt->params.char_val_by_uuid_read_rsp.handle_value; + uint8_t *p_next = p_iter->p_value ? p_iter->p_value + value_len : p_first; + + if ((p_next - p_first) / (sizeof(uint16_t) + value_len) < p_gattc_evt->params.char_val_by_uuid_read_rsp.count) + { + p_iter->handle = (uint16_t)p_next[1] << 8 | p_next[0]; + p_iter->p_value = p_next + sizeof(uint16_t); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_NOT_FOUND; + } +} + +#endif /* SUPPRESS_INLINE_IMPLEMENTATION */ + +#ifdef __cplusplus +} +#endif +#endif /* BLE_GATTC_H__ */ + +/** + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gatts.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gatts.h new file mode 100644 index 000000000..394d8d189 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gatts.h @@ -0,0 +1,845 @@ +/* + * Copyright (c) 2011 - 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server + @{ + @brief Definitions and prototypes for the GATTS interface. + */ + +#ifndef BLE_GATTS_H__ +#define BLE_GATTS_H__ + +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_hci.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" +#include "ble_gatt.h" +#include "ble_gap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations + * @{ */ + +/** + * @brief GATTS API SVC numbers. + */ +enum BLE_GATTS_SVCS +{ + SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */ + SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */ + SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */ + SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */ + SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */ + SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */ + SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */ + SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */ + SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */ + SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */ + SD_BLE_GATTS_SYS_ATTR_GET, /**< Retrieve the persistent system attributes. */ + SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, /**< Retrieve the first valid user handle. */ + SD_BLE_GATTS_ATTR_GET, /**< Retrieve the UUID and/or metadata of an attribute. */ + SD_BLE_GATTS_EXCHANGE_MTU_REPLY /**< Reply to Exchange MTU Request. */ +}; + +/** + * @brief GATT Server Event IDs. + */ +enum BLE_GATTS_EVTS +{ + BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. \n See @ref ble_gatts_evt_write_t. */ + BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. \n Reply with @ref sd_ble_gatts_rw_authorize_reply. \n See @ref ble_gatts_evt_rw_authorize_request_t. */ + BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending. \n Respond with @ref sd_ble_gatts_sys_attr_set. \n See @ref ble_gatts_evt_sys_attr_missing_t. */ + BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. \n See @ref ble_gatts_evt_hvc_t. */ + BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. \n No additional event structure applies. */ + BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, /**< Exchange MTU Request. \n Reply with @ref sd_ble_gatts_exchange_mtu_reply. \n See @ref ble_gatts_evt_exchange_mtu_request_t. */ + BLE_GATTS_EVT_TIMEOUT, /**< Peer failed to respond to an ATT request in time. \n See @ref ble_gatts_evt_timeout_t. */ + BLE_GATTS_EVT_HVN_TX_COMPLETE /**< Handle Value Notification transmission complete. \n See @ref ble_gatts_evt_hvn_tx_complete_t. */ +}; + +/**@brief GATTS Configuration IDs. + * + * IDs that uniquely identify a GATTS configuration. + */ +enum BLE_GATTS_CFGS +{ + BLE_GATTS_CFG_SERVICE_CHANGED = BLE_GATTS_CFG_BASE, /**< Service changed configuration. */ + BLE_GATTS_CFG_ATTR_TAB_SIZE, /**< Attribute table size configuration. */ +}; + +/** @} */ + +/** @addtogroup BLE_GATTS_DEFINES Defines + * @{ */ + +/** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS + * @{ */ +#define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */ +#define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */ +/** @} */ + +/** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths + * @{ */ +#define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */ +#define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */ +/** @} */ + +/** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types + * @{ */ +#define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */ +#define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */ +#define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */ +/** @} */ + + +/** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types + * @{ */ +#define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */ +#define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */ +#define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */ +#define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */ +#define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */ +#define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */ +#define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */ +#define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */ +/** @} */ + + +/** @defgroup BLE_GATTS_OPS GATT Server Operations + * @{ */ +#define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */ +#define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */ +#define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */ +#define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */ +#define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */ +#define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */ +/** @} */ + +/** @defgroup BLE_GATTS_VLOCS GATT Value Locations + * @{ */ +#define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */ +#define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */ +#define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack + will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */ +/** @} */ + +/** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types + * @{ */ +#define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */ +#define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */ +#define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */ +/** @} */ + +/** @defgroup BLE_GATTS_SYS_ATTR_FLAGS System Attribute Flags + * @{ */ +#define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0) /**< Restrict system attributes to system services only. */ +#define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1) /**< Restrict system attributes to user services only. */ +/** @} */ + +/** @defgroup BLE_GATTS_SERVICE_CHANGED Service Changed Inclusion Values + * @{ + */ +#define BLE_GATTS_SERVICE_CHANGED_DEFAULT (1) /**< Default is to include the Service Changed characteristic in the Attribute Table. */ +/** @} */ + +/** @defgroup BLE_GATTS_ATTR_TAB_SIZE Attribute Table size + * @{ + */ +#define BLE_GATTS_ATTR_TAB_SIZE_MIN (248) /**< Minimum Attribute Table size */ +#define BLE_GATTS_ATTR_TAB_SIZE_DEFAULT (1408) /**< Default Attribute Table size. */ +/** @} */ + +/** @defgroup BLE_GATTS_DEFAULTS GATT Server defaults + * @{ + */ +#define BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT 1 /**< Default number of Handle Value Notifications that can be queued for transmission. */ +/** @} */ + +/** @} */ + +/** @addtogroup BLE_GATTS_STRUCTURES Structures + * @{ */ + +/** + * @brief BLE GATTS connection configuration parameters, set with @ref sd_ble_cfg_set. + */ +typedef struct +{ + uint8_t hvn_tx_queue_size; /**< Minimum guaranteed number of Handle Value Notifications that can be queued for transmission. + The default value is @ref BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT */ +} ble_gatts_conn_cfg_t; + +/**@brief Attribute metadata. */ +typedef struct +{ + ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */ + ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ + uint8_t vlen :1; /**< Variable length attribute. */ + uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/ + uint8_t rd_auth :1; /**< Read authorization and value will be requested from the application on every read operation. */ + uint8_t wr_auth :1; /**< Write authorization will be requested from the application on every Write Request operation (but not Write Command). */ +} ble_gatts_attr_md_t; + + +/**@brief GATT Attribute. */ +typedef struct +{ + ble_uuid_t const *p_uuid; /**< Pointer to the attribute UUID. */ + ble_gatts_attr_md_t const *p_attr_md; /**< Pointer to the attribute metadata structure. */ + uint16_t init_len; /**< Initial attribute value length in bytes. */ + uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */ + uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */ + uint8_t *p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer + that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location. + The stack may access that memory directly without the application's knowledge. For writable characteristics, this value must not be a location in flash memory.*/ +} ble_gatts_attr_t; + +/**@brief GATT Attribute Value. */ +typedef struct +{ + uint16_t len; /**< Length in bytes to be written or read. Length in bytes written or read after successful return.*/ + uint16_t offset; /**< Attribute value offset. */ + uint8_t *p_value; /**< Pointer to where value is stored or will be stored. + If value is stored in user memory, only the attribute length is updated when p_value == NULL. + Set to NULL when reading to obtain the complete length of the attribute value */ +} ble_gatts_value_t; + + +/**@brief GATT Characteristic Presentation Format. */ +typedef struct +{ + uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */ + int8_t exponent; /**< Exponent for integer data types. */ + uint16_t unit; /**< Unit from Bluetooth Assigned Numbers. */ + uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ + uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ +} ble_gatts_char_pf_t; + + +/**@brief GATT Characteristic metadata. */ +typedef struct +{ + ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ + ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */ + uint8_t const *p_char_user_desc; /**< Pointer to a UTF-8 encoded string (non-NULL terminated), NULL if the descriptor is not required. */ + uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */ + uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */ + ble_gatts_char_pf_t const *p_char_pf; /**< Pointer to a presentation format structure or NULL if the CPF descriptor is not required. */ + ble_gatts_attr_md_t const *p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */ + ble_gatts_attr_md_t const *p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */ + ble_gatts_attr_md_t const *p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */ +} ble_gatts_char_md_t; + + +/**@brief GATT Characteristic Definition Handles. */ +typedef struct +{ + uint16_t value_handle; /**< Handle to the characteristic value. */ + uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ + uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ + uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ +} ble_gatts_char_handles_t; + + +/**@brief GATT HVx parameters. */ +typedef struct +{ + uint16_t handle; /**< Characteristic Value Handle. */ + uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ + uint16_t offset; /**< Offset within the attribute value. */ + uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after return. */ + uint8_t const *p_data; /**< Actual data content, use NULL to use the current attribute value. */ +} ble_gatts_hvx_params_t; + +/**@brief GATT Authorization parameters. */ +typedef struct +{ + uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ + uint8_t update : 1; /**< If set, data supplied in p_data will be used to update the attribute value. + Please note that for @ref BLE_GATTS_AUTHORIZE_TYPE_WRITE operations this bit must always be set, + as the data to be written needs to be stored and later provided by the application. */ + uint16_t offset; /**< Offset of the attribute value being updated. */ + uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */ + uint8_t const *p_data; /**< Pointer to new value used to update the attribute value. */ +} ble_gatts_authorize_params_t; + +/**@brief GATT Read or Write Authorize Reply parameters. */ +typedef struct +{ + uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ + union { + ble_gatts_authorize_params_t read; /**< Read authorization parameters. */ + ble_gatts_authorize_params_t write; /**< Write authorization parameters. */ + } params; /**< Reply Parameters. */ +} ble_gatts_rw_authorize_reply_params_t; + +/**@brief Service Changed Inclusion configuration parameters, set with @ref sd_ble_cfg_set. */ +typedef struct +{ + uint8_t service_changed : 1; /**< If 1, include the Service Changed characteristic in the Attribute Table. Default is @ref BLE_GATTS_SERVICE_CHANGED_DEFAULT. */ +} ble_gatts_cfg_service_changed_t; + +/**@brief Attribute table size configuration parameters, set with @ref sd_ble_cfg_set. + * + * @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true: + * - The specified Attribute Table size is too small. + * The minimum acceptable size is defined by @ref BLE_GATTS_ATTR_TAB_SIZE_MIN. + * - The specified Attribute Table size is not a multiple of 4. + */ +typedef struct +{ + uint32_t attr_tab_size; /**< Attribute table size. Default is @ref BLE_GATTS_ATTR_TAB_SIZE_DEFAULT, minimum is @ref BLE_GATTS_ATTR_TAB_SIZE_MIN. */ +} ble_gatts_cfg_attr_tab_size_t; + +/**@brief Config structure for GATTS configurations. */ +typedef union +{ + ble_gatts_cfg_service_changed_t service_changed; /**< Include service changed characteristic, cfg_id is @ref BLE_GATTS_CFG_SERVICE_CHANGED. */ + ble_gatts_cfg_attr_tab_size_t attr_tab_size; /**< Attribute table size, cfg_id is @ref BLE_GATTS_CFG_ATTR_TAB_SIZE. */ +} ble_gatts_cfg_t; + + +/**@brief Event structure for @ref BLE_GATTS_EVT_WRITE. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + ble_uuid_t uuid; /**< Attribute UUID. */ + uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */ + uint8_t auth_required; /**< Writing operation deferred due to authorization requirement. Application may use @ref sd_ble_gatts_value_set to finalize the writing operation. */ + uint16_t offset; /**< Offset for the write operation. */ + uint16_t len; /**< Length of the received data. */ + uint8_t data[1]; /**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. + See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ +} ble_gatts_evt_write_t; + +/**@brief Event substructure for authorized read requests, see @ref ble_gatts_evt_rw_authorize_request_t. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + ble_uuid_t uuid; /**< Attribute UUID. */ + uint16_t offset; /**< Offset for the read operation. */ +} ble_gatts_evt_read_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */ +typedef struct +{ + uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ + union { + ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */ + ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */ + } request; /**< Request Parameters. */ +} ble_gatts_evt_rw_authorize_request_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. */ +typedef struct +{ + uint8_t hint; /**< Hint (currently unused). */ +} ble_gatts_evt_sys_attr_missing_t; + + +/**@brief Event structure for @ref BLE_GATTS_EVT_HVC. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ +} ble_gatts_evt_hvc_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST. */ +typedef struct +{ + uint16_t client_rx_mtu; /**< Client RX MTU size. */ +} ble_gatts_evt_exchange_mtu_request_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_TIMEOUT. */ +typedef struct +{ + uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ +} ble_gatts_evt_timeout_t; + +/**@brief Event structure for @ref BLE_GATTS_EVT_HVN_TX_COMPLETE. */ +typedef struct +{ + uint8_t count; /**< Number of notification transmissions completed. */ +} ble_gatts_evt_hvn_tx_complete_t; + +/**@brief GATTS event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which the event occurred. */ + union + { + ble_gatts_evt_write_t write; /**< Write Event Parameters. */ + ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */ + ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */ + ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */ + ble_gatts_evt_exchange_mtu_request_t exchange_mtu_request; /**< Exchange MTU Request Event Parameters. */ + ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */ + ble_gatts_evt_hvn_tx_complete_t hvn_tx_complete; /**< Handle Value Notification transmission complete Event Parameters. */ + } params; /**< Event Parameters. */ +} ble_gatts_evt_t; + +/** @} */ + +/** @addtogroup BLE_GATTS_FUNCTIONS Functions + * @{ */ + +/**@brief Add a service declaration to the Attribute Table. + * + * @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to + * add a secondary service declaration that is not referenced by another service later in the Attribute Table. + * + * @mscs + * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} + * @endmscs + * + * @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES. + * @param[in] p_uuid Pointer to service UUID. + * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @retval ::NRF_SUCCESS Successfully added a service declaration. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle)); + + +/**@brief Add an include declaration to the Attribute Table. + * + * @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential population is supported at this time). + * + * @note The included service must already be present in the Attribute Table prior to this call. + * + * @mscs + * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} + * @endmscs + * + * @param[in] service_handle Handle of the service where the included service is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] inc_srvc_handle Handle of the included service. + * @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @retval ::NRF_SUCCESS Successfully added an include declaration. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required. + * @retval ::NRF_ERROR_NOT_SUPPORTED Feature is not supported, service_handle must be that of the last added service. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. + */ +SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle)); + + +/**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the Attribute Table. + * + * @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential population is supported at this time). + * + * @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writable auxiliaries bits, + * readable (no security) and writable (selectable) CCCDs and SCCDs and valid presentation format values. + * + * @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions. + * + * @mscs + * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} + * @endmscs + * + * @param[in] service_handle Handle of the service where the characteristic is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] p_char_md Characteristic metadata. + * @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value. + * @param[out] p_handles Pointer to the structure where the assigned handles will be stored. + * + * @retval ::NRF_SUCCESS Successfully added a characteristic. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + */ +SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles)); + + +/**@brief Add a descriptor to the Attribute Table. + * + * @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential population is supported at this time). + * + * @mscs + * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} + * @endmscs + * + * @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] p_attr Pointer to the attribute structure. + * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @retval ::NRF_SUCCESS Successfully added a descriptor. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. + * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + */ +SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle)); + +/**@brief Set the value of a given attribute. + * + * @note Values other than system attributes can be set at any time, regardless of whether any active connections exist. + * + * @mscs + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. Ignored if the value does not belong to a system attribute. + * @param[in] handle Attribute handle. + * @param[in,out] p_value Attribute value information. + * + * @retval ::NRF_SUCCESS Successfully set the value of the attribute. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. + * @retval ::NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied on a system attribute. + */ +SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)); + +/**@brief Get the value of a given attribute. + * + * @note If the attribute value is longer than the size of the supplied buffer, + * @ref ble_gatts_value_t::len will return the total attribute value length (excluding offset), + * and not the number of bytes actually returned in @ref ble_gatts_value_t::p_value. + * The application may use this information to allocate a suitable buffer size. + * + * @note When retrieving system attribute values with this function, the connection handle + * may refer to an already disconnected connection. Refer to the documentation of + * @ref sd_ble_gatts_sys_attr_get for further information. + * + * @param[in] conn_handle Connection handle. Ignored if the value does not belong to a system attribute. + * @param[in] handle Attribute handle. + * @param[in,out] p_value Attribute value information. + * + * @retval ::NRF_SUCCESS Successfully retrieved the value of the attribute. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid attribute offset supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied on a system attribute. + * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + */ +SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)); + +/**@brief Notify or Indicate an attribute value. + * + * @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation + * (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that + * the application can atomically perform a value update and a server initiated transaction with a single API call. + * + * @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution. + * The Attribute Table has been updated if one of the following error codes is returned: @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, + * @ref NRF_ERROR_FORBIDDEN, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and @ref NRF_ERROR_RESOURCES. + * The caller can check whether the value has been updated by looking at the contents of *(@ref ble_gatts_hvx_params_t::p_len). + * + * @note Only one indication procedure can be ongoing per connection at a time. + * If the application tries to indicate an attribute value while another indication procedure is ongoing, + * the function call will return @ref NRF_ERROR_BUSY. + * A @ref BLE_GATTS_EVT_HVC event will be issued as soon as the confirmation arrives from the peer. + * + * @note The number of Handle Value Notifications that can be queued is configured by @ref ble_gatts_conn_cfg_t::hvn_tx_queue_size + * When the queue is full, the function call will return @ref NRF_ERROR_RESOURCES. + * A @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event will be issued as soon as the transmission of the notification is complete. + * + * @note The application can keep track of the available queue element count for notifications by following the procedure below: + * - Store initial queue element count in a variable. + * - Decrement the variable, which stores the currently available queue element count, by one when a call to this function returns @ref NRF_SUCCESS. + * - Increment the variable, which stores the current available queue element count, by the count variable in @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event. + * + * @events + * @event{@ref BLE_GATTS_EVT_HVN_TX_COMPLETE, Notification transmission complete.} + * @event{@ref BLE_GATTS_EVT_HVC, Confirmation received from the peer.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC} + * @mmsc{@ref BLE_GATTS_HVN_MSC} + * @mmsc{@ref BLE_GATTS_HVI_MSC} + * @mmsc{@ref BLE_GATTS_HVX_DISABLED_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in,out] p_hvx_params Pointer to an HVx parameters structure. If @ref ble_gatts_hvx_params_t::p_data + * contains a non-NULL pointer the attribute value will be updated with the contents + * pointed by it before sending the notification or indication. If the attribute value + * is updated, @ref ble_gatts_hvx_params_t::p_len is updated by the SoftDevice to + * contain the number of actual bytes written, else it will be set to 0. + * + * @retval ::NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true: + * - Invalid Connection State + * - Notifications and/or indications not enabled in the CCCD + * - An ATT_MTU exchange is ongoing + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate. + * @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated. + * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. + * @retval ::NRF_ERROR_FORBIDDEN The connection's current security level is lower than the one required by the write permissions of the CCCD associated with this characteristic. + * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + * @retval ::NRF_ERROR_BUSY For @ref BLE_GATT_HVX_INDICATION Procedure already in progress. Wait for a @ref BLE_GATTS_EVT_HVC event and retry. + * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + * @retval ::NRF_ERROR_RESOURCES Too many notifications queued. + * Wait for a @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event and retry. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params)); + +/**@brief Indicate the Service Changed attribute value. + * + * @details This call will send a Handle Value Indication to one or more peers connected to inform them that the Attribute + * Table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will + * be issued. + * + * @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here. + * + * @events + * @event{@ref BLE_GATTS_EVT_SC_CONFIRM, Confirmation of attribute table change received from peer.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_GATTS_SC_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] start_handle Start of affected attribute handle range. + * @param[in] end_handle End of affected attribute handle range. + * + * @retval ::NRF_SUCCESS Successfully queued the Service Changed indication for transmission. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_NOT_SUPPORTED Service Changed not enabled at initialization. See @ref + * sd_ble_cfg_set and @ref ble_gatts_cfg_service_changed_t. + * @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true: + * - Invalid Connection State + * - Notifications and/or indications not enabled in the CCCD + * - An ATT_MTU exchange is ongoing + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application. + * @retval ::NRF_ERROR_BUSY Procedure already in progress. + * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)); + +/**@brief Respond to a Read/Write authorization request. + * + * @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application. + * + * @mscs + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} + * @mmsc{@ref BLE_GATTS_READ_REQ_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_WRITE_REQ_AUTH_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} + * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_PEER_CANCEL_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application. + * + * @note @ref ble_gatts_authorize_params_t::p_data is ignored when this function is used to respond + * to a @ref BLE_GATTS_AUTHORIZE_TYPE_READ event if @ref ble_gatts_authorize_params_t::update + * is set to 0. + * + * @retval ::NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, Attribute Table updated. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no authorization request pending. + * @retval ::NRF_ERROR_INVALID_PARAM Authorization op invalid, + * handle supplied does not match requested handle, + * or invalid data to be written provided by the application. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params)); + + +/**@brief Update persistent system attribute information. + * + * @details Supply information about persistent system attributes to the stack, + * previously obtained using @ref sd_ble_gatts_sys_attr_get. + * This call is only allowed for active connections, and is usually + * made immediately after a connection is established with an known bonded device, + * often as a response to a @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. + * + * p_sysattrs may point directly to the application's stored copy of the system attributes + * obtained using @ref sd_ble_gatts_sys_attr_get. + * If the pointer is NULL, the system attribute info is initialized, assuming that + * the application does not have any previously saved system attribute data for this device. + * + * @note The state of persistent system attributes is reset upon connection establishment and then remembered for its duration. + * + * @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially. + * This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or + * reset the SoftDevice to return to a known state. + * + * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be modified. + * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be modified. + * + * @mscs + * @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC} + * @mmsc{@ref BLE_GATTS_SYS_ATTRS_UNK_PEER_MSC} + * @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle. + * @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL. + * @param[in] len Size of data pointed by p_sys_attr_data, in octets. + * @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS + * + * @retval ::NRF_SUCCESS Successfully set the system attribute information. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid flags supplied. + * @retval ::NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get. + * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags)); + + +/**@brief Retrieve persistent system attribute information from the stack. + * + * @details This call is used to retrieve information about values to be stored persistently by the application + * during the lifetime of a connection or after it has been terminated. When a new connection is established with the same bonded device, + * the system attribute information retrieved with this function should be restored using using @ref sd_ble_gatts_sys_attr_set. + * If retrieved after disconnection, the data should be read before a new connection established. The connection handle for + * the previous, now disconnected, connection will remain valid until a new one is created to allow this API call to refer to it. + * Connection handles belonging to active connections can be used as well, but care should be taken since the system attributes + * may be written to at any time by the peer during a connection's lifetime. + * + * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be returned. + * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be returned. + * + * @mscs + * @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC} + * @endmscs + * + * @param[in] conn_handle Connection handle of the recently terminated connection. + * @param[out] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. The format of the data is described + * in @ref BLE_GATTS_SYS_ATTRS_FORMAT. NULL can be provided to obtain the length of the data. + * @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditionally updated to actual length of system attribute data. + * @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS + * + * @retval ::NRF_SUCCESS Successfully retrieved the system attribute information. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid flags supplied. + * @retval ::NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer. + * @retval ::NRF_ERROR_NOT_FOUND No system attributes found. + */ +SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags)); + + +/**@brief Retrieve the first valid user attribute handle. + * + * @param[out] p_handle Pointer to an integer where the handle will be stored. + * + * @retval ::NRF_SUCCESS Successfully retrieved the handle. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, uint32_t, sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle)); + +/**@brief Retrieve the attribute UUID and/or metadata. + * + * @param[in] handle Attribute handle + * @param[out] p_uuid UUID of the attribute. Use NULL to omit this field. + * @param[out] p_md Metadata of the attribute. Use NULL to omit this field. + * + * @retval ::NRF_SUCCESS Successfully retrieved the attribute metadata, + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. Returned when both @c p_uuid and @c p_md are NULL. + * @retval ::NRF_ERROR_NOT_FOUND Attribute was not found. + */ +SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md)); + +/**@brief Reply to an ATT_MTU exchange request by sending an Exchange MTU Response to the client. + * + * @details This function is only used to reply to a @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST event. + * + * @details The SoftDevice sets ATT_MTU to the minimum of: + * - The Client RX MTU value from @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, and + * - The Server RX MTU value. + * + * However, the SoftDevice never sets ATT_MTU lower than @ref BLE_GATT_ATT_MTU_DEFAULT. + * + * @mscs + * @mmsc{@ref BLE_GATTS_MTU_EXCHANGE} + * @endmscs + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] server_rx_mtu Server RX MTU size. + * - The minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT. + * - The maximum value is @ref ble_gatt_conn_cfg_t::att_mtu in the connection configuration + * used for this connection. + * - The value must be equal to Client RX MTU size given in @ref sd_ble_gattc_exchange_mtu_request + * if an ATT_MTU exchange has already been performed in the other direction. + * + * @retval ::NRF_SUCCESS Successfully sent response to the client. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no ATT_MTU exchange request pending. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid Server RX MTU size supplied. + * @retval ::NRF_ERROR_TIMEOUT There has been a GATT procedure timeout. No new GATT procedure can be performed without reestablishing the connection. + */ +SVCALL(SD_BLE_GATTS_EXCHANGE_MTU_REPLY, uint32_t, sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu)); +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // BLE_GATTS_H__ + +/** + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_hci.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_hci.h new file mode 100644 index 000000000..f0dde9a03 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_hci.h @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_COMMON + @{ +*/ + + +#ifndef BLE_HCI_H__ +#define BLE_HCI_H__ +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup BLE_HCI_STATUS_CODES Bluetooth status codes + * @{ */ + +#define BLE_HCI_STATUS_CODE_SUCCESS 0x00 /**< Success. */ +#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01 /**< Unknown BLE Command. */ +#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02 /**< Unknown Connection Identifier. */ +/*0x03 Hardware Failure +0x04 Page Timeout +*/ +#define BLE_HCI_AUTHENTICATION_FAILURE 0x05 /**< Authentication Failure. */ +#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06 /**< Pin or Key missing. */ +#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07 /**< Memory Capacity Exceeded. */ +#define BLE_HCI_CONNECTION_TIMEOUT 0x08 /**< Connection Timeout. */ +/*0x09 Connection Limit Exceeded +0x0A Synchronous Connection Limit To A Device Exceeded +0x0B ACL Connection Already Exists*/ +#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C /**< Command Disallowed. */ +/*0x0D Connection Rejected due to Limited Resources +0x0E Connection Rejected Due To Security Reasons +0x0F Connection Rejected due to Unacceptable BD_ADDR +0x10 Connection Accept Timeout Exceeded +0x11 Unsupported Feature or Parameter Value*/ +#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12 /**< Invalid BLE Command Parameters. */ +#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 /**< Remote User Terminated Connection. */ +#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14 /**< Remote Device Terminated Connection due to low resources.*/ +#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15 /**< Remote Device Terminated Connection due to power off. */ +#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16 /**< Local Host Terminated Connection. */ +/* +0x17 Repeated Attempts +0x18 Pairing Not Allowed +0x19 Unknown LMP PDU +*/ +#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A /**< Unsupported Remote Feature. */ +/* +0x1B SCO Offset Rejected +0x1C SCO Interval Rejected +0x1D SCO Air Mode Rejected*/ +#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E /**< Invalid LMP Parameters. */ +#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F /**< Unspecified Error. */ +/*0x20 Unsupported LMP Parameter Value +0x21 Role Change Not Allowed +*/ +#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22 /**< LMP Response Timeout. */ +#define BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION 0x23 /**< LMP Error Transaction Collision/LL Procedure Collision. */ +#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24 /**< LMP PDU Not Allowed. */ +/*0x25 Encryption Mode Not Acceptable +0x26 Link Key Can Not be Changed +0x27 Requested QoS Not Supported +*/ +#define BLE_HCI_INSTANT_PASSED 0x28 /**< Instant Passed. */ +#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29 /**< Pairing with Unit Key Unsupported. */ +#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A /**< Different Transaction Collision. */ +/* +0x2B Reserved +0x2C QoS Unacceptable Parameter +0x2D QoS Rejected +0x2E Channel Classification Not Supported +0x2F Insufficient Security +*/ +#define BLE_HCI_PARAMETER_OUT_OF_MANDATORY_RANGE 0x30 /**< Parameter Out Of Mandatory Range. */ +/* +0x31 Reserved +0x32 Role Switch Pending +0x33 Reserved +0x34 Reserved Slot Violation +0x35 Role Switch Failed +0x36 Extended Inquiry Response Too Large +0x37 Secure Simple Pairing Not Supported By Host. +0x38 Host Busy - Pairing +0x39 Connection Rejected due to No Suitable Channel Found*/ +#define BLE_HCI_CONTROLLER_BUSY 0x3A /**< Controller Busy. */ +#define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B /**< Connection Interval Unacceptable. */ +#define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C /**< Directed Advertisement Timeout. */ +#define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D /**< Connection Terminated due to MIC Failure. */ +#define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E /**< Connection Failed to be Established. */ + +/** @} */ + + +#ifdef __cplusplus +} +#endif +#endif // BLE_HCI_H__ + +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_l2cap.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_l2cap.h new file mode 100644 index 000000000..7587350cf --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_l2cap.h @@ -0,0 +1,507 @@ +/* + * Copyright (c) 2011 - 2020, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP) + @{ + @brief Definitions and prototypes for the L2CAP interface. + */ + +#ifndef BLE_L2CAP_H__ +#define BLE_L2CAP_H__ + +#include +#include "nrf_svc.h" +#include "nrf_error.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@addtogroup BLE_L2CAP_TERMINOLOGY Terminology + * @{ + * @details + * + * L2CAP SDU + * - A data unit that the application can send/receive to/from a peer. + * + * L2CAP PDU + * - A data unit that is exchanged between local and remote L2CAP entities. + * It consists of L2CAP protocol control information and payload fields. + * The payload field can contain an L2CAP SDU or a part of an L2CAP SDU. + * + * L2CAP MTU + * - The maximum length of an L2CAP SDU. + * + * L2CAP MPS + * - The maximum length of an L2CAP PDU payload field. + * + * Credits + * - A value indicating the number of L2CAP PDUs that the receiver of the credit can send to the peer. + * @} */ + +/**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations + * @{ */ + +/**@brief L2CAP API SVC numbers. */ +enum BLE_L2CAP_SVCS +{ + SD_BLE_L2CAP_CH_SETUP = BLE_L2CAP_SVC_BASE + 0, /**< Set up an L2CAP channel. */ + SD_BLE_L2CAP_CH_RELEASE = BLE_L2CAP_SVC_BASE + 1, /**< Release an L2CAP channel. */ + SD_BLE_L2CAP_CH_RX = BLE_L2CAP_SVC_BASE + 2, /**< Receive an SDU on an L2CAP channel. */ + SD_BLE_L2CAP_CH_TX = BLE_L2CAP_SVC_BASE + 3, /**< Transmit an SDU on an L2CAP channel. */ + SD_BLE_L2CAP_CH_FLOW_CONTROL = BLE_L2CAP_SVC_BASE + 4, /**< Advanced SDU reception flow control. */ +}; + +/**@brief L2CAP Event IDs. */ +enum BLE_L2CAP_EVTS +{ + BLE_L2CAP_EVT_CH_SETUP_REQUEST = BLE_L2CAP_EVT_BASE + 0, /**< L2CAP Channel Setup Request event. + \n Reply with @ref sd_ble_l2cap_ch_setup. + \n See @ref ble_l2cap_evt_ch_setup_request_t. */ + BLE_L2CAP_EVT_CH_SETUP_REFUSED = BLE_L2CAP_EVT_BASE + 1, /**< L2CAP Channel Setup Refused event. + \n See @ref ble_l2cap_evt_ch_setup_refused_t. */ + BLE_L2CAP_EVT_CH_SETUP = BLE_L2CAP_EVT_BASE + 2, /**< L2CAP Channel Setup Completed event. + \n See @ref ble_l2cap_evt_ch_setup_t. */ + BLE_L2CAP_EVT_CH_RELEASED = BLE_L2CAP_EVT_BASE + 3, /**< L2CAP Channel Released event. + \n No additional event structure applies. */ + BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED = BLE_L2CAP_EVT_BASE + 4, /**< L2CAP Channel SDU data buffer released event. + \n See @ref ble_l2cap_evt_ch_sdu_buf_released_t. */ + BLE_L2CAP_EVT_CH_CREDIT = BLE_L2CAP_EVT_BASE + 5, /**< L2CAP Channel Credit received. + \n See @ref ble_l2cap_evt_ch_credit_t. */ + BLE_L2CAP_EVT_CH_RX = BLE_L2CAP_EVT_BASE + 6, /**< L2CAP Channel SDU received. + \n See @ref ble_l2cap_evt_ch_rx_t. */ + BLE_L2CAP_EVT_CH_TX = BLE_L2CAP_EVT_BASE + 7, /**< L2CAP Channel SDU transmitted. + \n See @ref ble_l2cap_evt_ch_tx_t. */ +}; + +/** @} */ + +/**@addtogroup BLE_L2CAP_DEFINES Defines + * @{ */ + +/**@brief Maximum number of L2CAP channels per connection. */ +#define BLE_L2CAP_CH_COUNT_MAX (64) + +/**@brief Minimum L2CAP MTU, in bytes. */ +#define BLE_L2CAP_MTU_MIN (23) + +/**@brief Minimum L2CAP MPS, in bytes. */ +#define BLE_L2CAP_MPS_MIN (23) + +/**@brief Invalid CID. */ +#define BLE_L2CAP_CID_INVALID (0x0000) + +/**@brief Default number of credits for @ref sd_ble_l2cap_ch_flow_control. */ +#define BLE_L2CAP_CREDITS_DEFAULT (1) + +/**@defgroup BLE_L2CAP_CH_SETUP_REFUSED_SRCS L2CAP channel setup refused sources + * @{ */ +#define BLE_L2CAP_CH_SETUP_REFUSED_SRC_LOCAL (0x01) /**< Local. */ +#define BLE_L2CAP_CH_SETUP_REFUSED_SRC_REMOTE (0x02) /**< Remote. */ + /** @} */ + + /** @defgroup BLE_L2CAP_CH_STATUS_CODES L2CAP channel status codes + * @{ */ +#define BLE_L2CAP_CH_STATUS_CODE_SUCCESS (0x0000) /**< Success. */ +#define BLE_L2CAP_CH_STATUS_CODE_LE_PSM_NOT_SUPPORTED (0x0002) /**< LE_PSM not supported. */ +#define BLE_L2CAP_CH_STATUS_CODE_NO_RESOURCES (0x0004) /**< No resources available. */ +#define BLE_L2CAP_CH_STATUS_CODE_INSUFF_AUTHENTICATION (0x0005) /**< Insufficient authentication. */ +#define BLE_L2CAP_CH_STATUS_CODE_INSUFF_AUTHORIZATION (0x0006) /**< Insufficient authorization. */ +#define BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC_KEY_SIZE (0x0007) /**< Insufficient encryption key size. */ +#define BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC (0x0008) /**< Insufficient encryption. */ +#define BLE_L2CAP_CH_STATUS_CODE_INVALID_SCID (0x0009) /**< Invalid Source CID. */ +#define BLE_L2CAP_CH_STATUS_CODE_SCID_ALLOCATED (0x000A) /**< Source CID already allocated. */ +#define BLE_L2CAP_CH_STATUS_CODE_UNACCEPTABLE_PARAMS (0x000B) /**< Unacceptable parameters. */ +#define BLE_L2CAP_CH_STATUS_CODE_NOT_UNDERSTOOD (0x8000) /**< Command Reject received instead of LE Credit Based Connection Response. */ +#define BLE_L2CAP_CH_STATUS_CODE_TIMEOUT (0xC000) /**< Operation timed out. */ +/** @} */ + +/** @} */ + +/**@addtogroup BLE_L2CAP_STRUCTURES Structures + * @{ */ + +/** + * @brief BLE L2CAP connection configuration parameters, set with @ref sd_ble_cfg_set. + * + * @note These parameters are set per connection, so all L2CAP channels created on this connection + * will have the same parameters. + * + * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true: + * - rx_mps is smaller than @ref BLE_L2CAP_MPS_MIN. + * - tx_mps is smaller than @ref BLE_L2CAP_MPS_MIN. + * - ch_count is greater than @ref BLE_L2CAP_CH_COUNT_MAX. + * @retval ::NRF_ERROR_NO_MEM rx_mps or tx_mps is set too high. + */ +typedef struct +{ + uint16_t rx_mps; /**< The maximum L2CAP PDU payload size, in bytes, that L2CAP shall + be able to receive on L2CAP channels on connections with this + configuration. The minimum value is @ref BLE_L2CAP_MPS_MIN. */ + uint16_t tx_mps; /**< The maximum L2CAP PDU payload size, in bytes, that L2CAP shall + be able to transmit on L2CAP channels on connections with this + configuration. The minimum value is @ref BLE_L2CAP_MPS_MIN. */ + uint8_t rx_queue_size; /**< Number of SDU data buffers that can be queued for reception per + L2CAP channel. The minimum value is one. */ + uint8_t tx_queue_size; /**< Number of SDU data buffers that can be queued for transmission + per L2CAP channel. The minimum value is one. */ + uint8_t ch_count; /**< Number of L2CAP channels the application can create per connection + with this configuration. The default value is zero, the maximum + value is @ref BLE_L2CAP_CH_COUNT_MAX. + @note if this parameter is set to zero, all other parameters in + @ref ble_l2cap_conn_cfg_t are ignored. */ +} ble_l2cap_conn_cfg_t; + +/**@brief L2CAP channel RX parameters. */ +typedef struct +{ + uint16_t rx_mtu; /**< The maximum L2CAP SDU size, in bytes, that L2CAP shall be able to + receive on this L2CAP channel. + - Must be equal to or greater than @ref BLE_L2CAP_MTU_MIN. */ + uint16_t rx_mps; /**< The maximum L2CAP PDU payload size, in bytes, that L2CAP shall be + able to receive on this L2CAP channel. + - Must be equal to or greater than @ref BLE_L2CAP_MPS_MIN. + - Must be equal to or less than @ref ble_l2cap_conn_cfg_t::rx_mps. */ + ble_data_t sdu_buf; /**< SDU data buffer for reception. + - If @ref ble_data_t::p_data is non-NULL, initial credits are + issued to the peer. + - If @ref ble_data_t::p_data is NULL, no initial credits are + issued to the peer. */ +} ble_l2cap_ch_rx_params_t; + +/**@brief L2CAP channel setup parameters. */ +typedef struct +{ + ble_l2cap_ch_rx_params_t rx_params; /**< L2CAP channel RX parameters. */ + uint16_t le_psm; /**< LE Protocol/Service Multiplexer. Used when requesting + setup of an L2CAP channel, ignored otherwise. */ + uint16_t status; /**< Status code, see @ref BLE_L2CAP_CH_STATUS_CODES. + Used when replying to a setup request of an L2CAP + channel, ignored otherwise. */ +} ble_l2cap_ch_setup_params_t; + +/**@brief L2CAP channel TX parameters. */ +typedef struct +{ + uint16_t tx_mtu; /**< The maximum L2CAP SDU size, in bytes, that L2CAP is able to + transmit on this L2CAP channel. */ + uint16_t peer_mps; /**< The maximum L2CAP PDU payload size, in bytes, that the peer is + able to receive on this L2CAP channel. */ + uint16_t tx_mps; /**< The maximum L2CAP PDU payload size, in bytes, that L2CAP is able + to transmit on this L2CAP channel. This is effective tx_mps, + selected by the SoftDevice as + MIN( @ref ble_l2cap_ch_tx_params_t::peer_mps, @ref ble_l2cap_conn_cfg_t::tx_mps ) */ + uint16_t credits; /**< Initial credits given by the peer. */ +} ble_l2cap_ch_tx_params_t; + +/**@brief L2CAP Channel Setup Request event. */ +typedef struct +{ + ble_l2cap_ch_tx_params_t tx_params; /**< L2CAP channel TX parameters. */ + uint16_t le_psm; /**< LE Protocol/Service Multiplexer. */ +} ble_l2cap_evt_ch_setup_request_t; + +/**@brief L2CAP Channel Setup Refused event. */ +typedef struct +{ + uint8_t source; /**< Source, see @ref BLE_L2CAP_CH_SETUP_REFUSED_SRCS */ + uint16_t status; /**< Status code, see @ref BLE_L2CAP_CH_STATUS_CODES */ +} ble_l2cap_evt_ch_setup_refused_t; + +/**@brief L2CAP Channel Setup Completed event. */ +typedef struct +{ + ble_l2cap_ch_tx_params_t tx_params; /**< L2CAP channel TX parameters. */ +} ble_l2cap_evt_ch_setup_t; + +/**@brief L2CAP Channel SDU Data Buffer Released event. */ +typedef struct +{ + ble_data_t sdu_buf; /**< Returned reception or transmission SDU data buffer. The SoftDevice + returns SDU data buffers supplied by the application, which have + not yet been returned previously via a @ref BLE_L2CAP_EVT_CH_RX or + @ref BLE_L2CAP_EVT_CH_TX event. */ +} ble_l2cap_evt_ch_sdu_buf_released_t; + +/**@brief L2CAP Channel Credit received event. */ +typedef struct +{ + uint16_t credits; /**< Additional credits given by the peer. */ +} ble_l2cap_evt_ch_credit_t; + +/**@brief L2CAP Channel received SDU event. */ +typedef struct +{ + uint16_t sdu_len; /**< Total SDU length, in bytes. */ + ble_data_t sdu_buf; /**< SDU data buffer. + @note If there is not enough space in the buffer + (sdu_buf.len < sdu_len) then the rest of the SDU will be + silently discarded by the SoftDevice. */ +} ble_l2cap_evt_ch_rx_t; + +/**@brief L2CAP Channel transmitted SDU event. */ +typedef struct +{ + ble_data_t sdu_buf; /**< SDU data buffer. */ +} ble_l2cap_evt_ch_tx_t; + +/**@brief L2CAP event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which the event occured. */ + uint16_t local_cid; /**< Local Channel ID of the L2CAP channel, or + @ref BLE_L2CAP_CID_INVALID if not present. */ + union + { + ble_l2cap_evt_ch_setup_request_t ch_setup_request; /**< L2CAP Channel Setup Request Event Parameters. */ + ble_l2cap_evt_ch_setup_refused_t ch_setup_refused; /**< L2CAP Channel Setup Refused Event Parameters. */ + ble_l2cap_evt_ch_setup_t ch_setup; /**< L2CAP Channel Setup Completed Event Parameters. */ + ble_l2cap_evt_ch_sdu_buf_released_t ch_sdu_buf_released;/**< L2CAP Channel SDU Data Buffer Released Event Parameters. */ + ble_l2cap_evt_ch_credit_t credit; /**< L2CAP Channel Credit Received Event Parameters. */ + ble_l2cap_evt_ch_rx_t rx; /**< L2CAP Channel SDU Received Event Parameters. */ + ble_l2cap_evt_ch_tx_t tx; /**< L2CAP Channel SDU Transmitted Event Parameters. */ + } params; /**< Event Parameters. */ +} ble_l2cap_evt_t; + +/** @} */ + +/**@addtogroup BLE_L2CAP_FUNCTIONS Functions + * @{ */ + +/**@brief Set up an L2CAP channel. + * + * @details This function is used to: + * - Request setup of an L2CAP channel: sends an LE Credit Based Connection Request packet to a peer. + * - Reply to a setup request of an L2CAP channel (if called in response to a + * @ref BLE_L2CAP_EVT_CH_SETUP_REQUEST event): sends an LE Credit Based Connection + * Response packet to a peer. + * + * @note A call to this function will require the application to keep the SDU data buffer alive + * until the SDU data buffer is returned in @ref BLE_L2CAP_EVT_CH_RX or + * @ref BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED event. + * + * @events + * @event{@ref BLE_L2CAP_EVT_CH_SETUP, Setup successful.} + * @event{@ref BLE_L2CAP_EVT_CH_SETUP_REFUSED, Setup failed.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_L2CAP_CH_SETUP_MSC} + * @endmscs + * + * @param[in] conn_handle Connection Handle. + * @param[in,out] p_local_cid Pointer to a uint16_t containing Local Channel ID of the L2CAP channel: + * - As input: @ref BLE_L2CAP_CID_INVALID when requesting setup of an L2CAP + * channel or local_cid provided in the @ref BLE_L2CAP_EVT_CH_SETUP_REQUEST + * event when replying to a setup request of an L2CAP channel. + * - As output: local_cid for this channel. + * @param[in] p_params L2CAP channel parameters. + * + * @retval ::NRF_SUCCESS Successfully queued request or response for transmission. + * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @retval ::NRF_ERROR_INVALID_LENGTH Supplied higher rx_mps than has been configured on this link. + * @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (L2CAP channel already set up). + * @retval ::NRF_ERROR_NOT_FOUND CID not found. + * @retval ::NRF_ERROR_RESOURCES The limit has been reached for available L2CAP channels, + * see @ref ble_l2cap_conn_cfg_t::ch_count. + */ +SVCALL(SD_BLE_L2CAP_CH_SETUP, uint32_t, sd_ble_l2cap_ch_setup(uint16_t conn_handle, uint16_t *p_local_cid, ble_l2cap_ch_setup_params_t const *p_params)); + +/**@brief Release an L2CAP channel. + * + * @details This sends a Disconnection Request packet to a peer. + * + * @events + * @event{@ref BLE_L2CAP_EVT_CH_RELEASED, Release complete.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_L2CAP_CH_RELEASE_MSC} + * @endmscs + * + * @param[in] conn_handle Connection Handle. + * @param[in] local_cid Local Channel ID of the L2CAP channel. + * + * @retval ::NRF_SUCCESS Successfully queued request for transmission. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is + * in progress for the L2CAP channel). + * @retval ::NRF_ERROR_NOT_FOUND CID not found. + */ +SVCALL(SD_BLE_L2CAP_CH_RELEASE, uint32_t, sd_ble_l2cap_ch_release(uint16_t conn_handle, uint16_t local_cid)); + +/**@brief Receive an SDU on an L2CAP channel. + * + * @details This may issue additional credits to the peer using an LE Flow Control Credit packet. + * + * @note A call to this function will require the application to keep the memory pointed by + * @ref ble_data_t::p_data alive until the SDU data buffer is returned in @ref BLE_L2CAP_EVT_CH_RX + * or @ref BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED event. + * + * @note The SoftDevice can queue up to @ref ble_l2cap_conn_cfg_t::rx_queue_size SDU data buffers + * for reception per L2CAP channel. + * + * @events + * @event{@ref BLE_L2CAP_EVT_CH_RX, The SDU is received.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_L2CAP_CH_RX_MSC} + * @endmscs + * + * @param[in] conn_handle Connection Handle. + * @param[in] local_cid Local Channel ID of the L2CAP channel. + * @param[in] p_sdu_buf Pointer to the SDU data buffer. + * + * @retval ::NRF_SUCCESS Buffer accepted. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is + * in progress for an L2CAP channel). + * @retval ::NRF_ERROR_NOT_FOUND CID not found. + * @retval ::NRF_ERROR_RESOURCES Too many SDU data buffers supplied. Wait for a + * @ref BLE_L2CAP_EVT_CH_RX event and retry. + */ +SVCALL(SD_BLE_L2CAP_CH_RX, uint32_t, sd_ble_l2cap_ch_rx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf)); + +/**@brief Transmit an SDU on an L2CAP channel. + * + * @note A call to this function will require the application to keep the memory pointed by + * @ref ble_data_t::p_data alive until the SDU data buffer is returned in @ref BLE_L2CAP_EVT_CH_TX + * or @ref BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED event. + * + * @note The SoftDevice can queue up to @ref ble_l2cap_conn_cfg_t::tx_queue_size SDUs for + * transmission per L2CAP channel. + * + * @note The application can keep track of the available credits for transmission by following + * the procedure below: + * - Store initial credits given by the peer in a variable. + * (Initial credits are provided in a @ref BLE_L2CAP_EVT_CH_SETUP event.) + * - Decrement the variable, which stores the currently available credits, by + * ceiling((@ref ble_data_t::len + 2) / tx_mps) when a call to this function returns + * @ref NRF_SUCCESS. (tx_mps is provided in a @ref BLE_L2CAP_EVT_CH_SETUP event.) + * - Increment the variable, which stores the currently available credits, by additional + * credits given by the peer in a @ref BLE_L2CAP_EVT_CH_CREDIT event. + * + * @events + * @event{@ref BLE_L2CAP_EVT_CH_TX, The SDU is transmitted.} + * @endevents + * + * @mscs + * @mmsc{@ref BLE_L2CAP_CH_TX_MSC} + * @endmscs + * + * @param[in] conn_handle Connection Handle. + * @param[in] local_cid Local Channel ID of the L2CAP channel. + * @param[in] p_sdu_buf Pointer to the SDU data buffer. + * + * @retval ::NRF_SUCCESS Successfully queued L2CAP SDU for transmission. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is + * in progress for the L2CAP channel). + * @retval ::NRF_ERROR_NOT_FOUND CID not found. + * @retval ::NRF_ERROR_DATA_SIZE Invalid SDU length supplied, must not be more than + * @ref ble_l2cap_ch_tx_params_t::tx_mtu provided in + * @ref BLE_L2CAP_EVT_CH_SETUP event. + * @retval ::NRF_ERROR_RESOURCES Too many SDUs queued for transmission. Wait for a + * @ref BLE_L2CAP_EVT_CH_TX event and retry. + */ +SVCALL(SD_BLE_L2CAP_CH_TX, uint32_t, sd_ble_l2cap_ch_tx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf)); + +/**@brief Advanced SDU reception flow control. + * + * @details Adjust the way the SoftDevice issues credits to the peer. + * This may issue additional credits to the peer using an LE Flow Control Credit packet. + * + * @mscs + * @mmsc{@ref BLE_L2CAP_CH_FLOW_CONTROL_MSC} + * @endmscs + * + * @param[in] conn_handle Connection Handle. + * @param[in] local_cid Local Channel ID of the L2CAP channel or @ref BLE_L2CAP_CID_INVALID to set + * the value that will be used for newly created channels. + * @param[in] credits Number of credits that the SoftDevice will make sure the peer has every + * time it starts using a new reception buffer. + * - @ref BLE_L2CAP_CREDITS_DEFAULT is the default value the SoftDevice will + * use if this function is not called. + * - If set to zero, the SoftDevice will stop issuing credits for new reception + * buffers the application provides or has provided. SDU reception that is + * currently ongoing will be allowed to complete. + * @param[out] p_credits NULL or pointer to a uint16_t. If a valid pointer is provided, it will be + * written by the SoftDevice with the number of credits that is or will be + * available to the peer. If the value written by the SoftDevice is 0 when + * credits parameter was set to 0, the peer will not be able to send more + * data until more credits are provided by calling this function again with + * credits > 0. This parameter is ignored when local_cid is set to + * @ref BLE_L2CAP_CID_INVALID. + * + * @note Application should take care when setting number of credits higher than default value. In + * this case the application must make sure that the SoftDevice always has reception buffers + * available (see @ref sd_ble_l2cap_ch_rx) for that channel. If the SoftDevice does not have + * such buffers available, packets may be NACKed on the Link Layer and all Bluetooth traffic + * on the connection handle may be stalled until the SoftDevice again has an available + * reception buffer. This applies even if the application has used this call to set the + * credits back to default, or zero. + * + * @retval ::NRF_SUCCESS Flow control parameters accepted. + * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is + * in progress for an L2CAP channel). + * @retval ::NRF_ERROR_NOT_FOUND CID not found. + */ +SVCALL(SD_BLE_L2CAP_CH_FLOW_CONTROL, uint32_t, sd_ble_l2cap_ch_flow_control(uint16_t conn_handle, uint16_t local_cid, uint16_t credits, uint16_t *p_credits)); + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // BLE_L2CAP_H__ + +/** + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_ranges.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_ranges.h new file mode 100644 index 000000000..0935bca07 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_ranges.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2012 - 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_COMMON + @{ + @defgroup ble_ranges Module specific SVC, event and option number subranges + @{ + + @brief Definition of SVC, event and option number subranges for each API module. + + @note + SVCs, event and option numbers are split into subranges for each API module. + Each module receives its entire allocated range of SVC calls, whether implemented or not, + but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range. + + Note that the symbols BLE__SVC_LAST is the end of the allocated SVC range, + rather than the last SVC function call actually defined and implemented. + + Specific SVC, event and option values are defined in each module's ble_.h file, + which defines names of each individual SVC code based on the range start value. +*/ + +#ifndef BLE_RANGES_H__ +#define BLE_RANGES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_SVC_BASE 0x60 /**< Common BLE SVC base. */ +#define BLE_SVC_LAST 0x6B /**< Common BLE SVC last. */ + +#define BLE_GAP_SVC_BASE 0x6C /**< GAP BLE SVC base. */ +#define BLE_GAP_SVC_LAST 0x9A /**< GAP BLE SVC last. */ + +#define BLE_GATTC_SVC_BASE 0x9B /**< GATTC BLE SVC base. */ +#define BLE_GATTC_SVC_LAST 0xA7 /**< GATTC BLE SVC last. */ + +#define BLE_GATTS_SVC_BASE 0xA8 /**< GATTS BLE SVC base. */ +#define BLE_GATTS_SVC_LAST 0xB7 /**< GATTS BLE SVC last. */ + +#define BLE_L2CAP_SVC_BASE 0xB8 /**< L2CAP BLE SVC base. */ +#define BLE_L2CAP_SVC_LAST 0xBF /**< L2CAP BLE SVC last. */ + + +#define BLE_EVT_INVALID 0x00 /**< Invalid BLE Event. */ + +#define BLE_EVT_BASE 0x01 /**< Common BLE Event base. */ +#define BLE_EVT_LAST 0x0F /**< Common BLE Event last. */ + +#define BLE_GAP_EVT_BASE 0x10 /**< GAP BLE Event base. */ +#define BLE_GAP_EVT_LAST 0x2F /**< GAP BLE Event last. */ + +#define BLE_GATTC_EVT_BASE 0x30 /**< GATTC BLE Event base. */ +#define BLE_GATTC_EVT_LAST 0x4F /**< GATTC BLE Event last. */ + +#define BLE_GATTS_EVT_BASE 0x50 /**< GATTS BLE Event base. */ +#define BLE_GATTS_EVT_LAST 0x6F /**< GATTS BLE Event last. */ + +#define BLE_L2CAP_EVT_BASE 0x70 /**< L2CAP BLE Event base. */ +#define BLE_L2CAP_EVT_LAST 0x8F /**< L2CAP BLE Event last. */ + + +#define BLE_OPT_INVALID 0x00 /**< Invalid BLE Option. */ + +#define BLE_OPT_BASE 0x01 /**< Common BLE Option base. */ +#define BLE_OPT_LAST 0x1F /**< Common BLE Option last. */ + +#define BLE_GAP_OPT_BASE 0x20 /**< GAP BLE Option base. */ +#define BLE_GAP_OPT_LAST 0x3F /**< GAP BLE Option last. */ + +#define BLE_GATT_OPT_BASE 0x40 /**< GATT BLE Option base. */ +#define BLE_GATT_OPT_LAST 0x5F /**< GATT BLE Option last. */ + +#define BLE_GATTC_OPT_BASE 0x60 /**< GATTC BLE Option base. */ +#define BLE_GATTC_OPT_LAST 0x7F /**< GATTC BLE Option last. */ + +#define BLE_GATTS_OPT_BASE 0x80 /**< GATTS BLE Option base. */ +#define BLE_GATTS_OPT_LAST 0x9F /**< GATTS BLE Option last. */ + +#define BLE_L2CAP_OPT_BASE 0xA0 /**< L2CAP BLE Option base. */ +#define BLE_L2CAP_OPT_LAST 0xBF /**< L2CAP BLE Option last. */ + + +#define BLE_CFG_INVALID 0x00 /**< Invalid BLE configuration. */ + +#define BLE_CFG_BASE 0x01 /**< Common BLE configuration base. */ +#define BLE_CFG_LAST 0x1F /**< Common BLE configuration last. */ + +#define BLE_CONN_CFG_BASE 0x20 /**< BLE connection configuration base. */ +#define BLE_CONN_CFG_LAST 0x3F /**< BLE connection configuration last. */ + +#define BLE_GAP_CFG_BASE 0x40 /**< GAP BLE configuration base. */ +#define BLE_GAP_CFG_LAST 0x5F /**< GAP BLE configuration last. */ + +#define BLE_GATT_CFG_BASE 0x60 /**< GATT BLE configuration base. */ +#define BLE_GATT_CFG_LAST 0x7F /**< GATT BLE configuration last. */ + +#define BLE_GATTC_CFG_BASE 0x80 /**< GATTC BLE configuration base. */ +#define BLE_GATTC_CFG_LAST 0x9F /**< GATTC BLE configuration last. */ + +#define BLE_GATTS_CFG_BASE 0xA0 /**< GATTS BLE configuration base. */ +#define BLE_GATTS_CFG_LAST 0xBF /**< GATTS BLE configuration last. */ + +#define BLE_L2CAP_CFG_BASE 0xC0 /**< L2CAP BLE configuration base. */ +#define BLE_L2CAP_CFG_LAST 0xDF /**< L2CAP BLE configuration last. */ + + + + + +#ifdef __cplusplus +} +#endif +#endif /* BLE_RANGES_H__ */ + +/** + @} + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_types.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_types.h new file mode 100644 index 000000000..88c93180c --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_types.h @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup BLE_COMMON + @{ + @defgroup ble_types Common types and macro definitions + @{ + + @brief Common types and macro definitions for the BLE SoftDevice. + */ + +#ifndef BLE_TYPES_H__ +#define BLE_TYPES_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup BLE_TYPES_DEFINES Defines + * @{ */ + +/** @defgroup BLE_CONN_HANDLES BLE Connection Handles + * @{ */ +#define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */ +#define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */ +/** @} */ + + +/** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs + * @{ */ +/* Generic UUIDs, applicable to all services */ +#define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */ +#define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */ +#define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */ +#define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */ +#define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */ +#define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */ +#define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */ +/* GATT specific UUIDs */ +#define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */ +#define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */ +/* GAP specific UUIDs */ +#define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */ +#define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_CAR 0x2AA6 /**< Central Address Resolution Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_RPA_ONLY 0x2AC9 /**< Resolvable Private Address Only Characteristic. */ +/** @} */ + + +/** @defgroup BLE_UUID_TYPES Types of UUID + * @{ */ +#define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */ +#define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */ +#define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */ +/** @} */ + + +/** @defgroup BLE_APPEARANCES Bluetooth Appearance values + * @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml + * @{ */ +#define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */ +#define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */ +#define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */ +#define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */ +#define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */ +#define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */ +#define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */ +#define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */ +#define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */ +#define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */ +#define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */ +#define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */ +#define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */ +#define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */ +#define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */ +#define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */ +#define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */ +#define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */ +#define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */ +#define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */ +#define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */ +#define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */ +#define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */ +#define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystick (HID Subtype). */ +#define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */ +#define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */ +#define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */ +#define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */ +#define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */ +#define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */ +#define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */ +#define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */ +#define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */ +#define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */ +#define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */ +#define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */ +#define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */ +#define BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 3136 /**< Generic Pulse Oximeter. */ +#define BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 3137 /**< Fingertip (Pulse Oximeter subtype). */ +#define BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN 3138 /**< Wrist Worn(Pulse Oximeter subtype). */ +#define BLE_APPEARANCE_GENERIC_WEIGHT_SCALE 3200 /**< Generic Weight Scale. */ +#define BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT 5184 /**< Generic Outdoor Sports Activity. */ +#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP 5185 /**< Location Display Device (Outdoor Sports Activity subtype). */ +#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP 5186 /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */ +#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD 5187 /**< Location Pod (Outdoor Sports Activity subtype). */ +#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD 5188 /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */ +/** @} */ + +/** @brief Set .type and .uuid fields of ble_uuid_struct to specified UUID value. */ +#define BLE_UUID_BLE_ASSIGN(instance, value) do {\ + instance.type = BLE_UUID_TYPE_BLE; \ + instance.uuid = value;} while(0) + +/** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */ +#define BLE_UUID_COPY_PTR(dst, src) do {\ + (dst)->type = (src)->type; \ + (dst)->uuid = (src)->uuid;} while(0) + +/** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */ +#define BLE_UUID_COPY_INST(dst, src) do {\ + (dst).type = (src).type; \ + (dst).uuid = (src).uuid;} while(0) + +/** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */ +#define BLE_UUID_EQ(p_uuid1, p_uuid2) \ + (((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid)) + +/** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */ +#define BLE_UUID_NEQ(p_uuid1, p_uuid2) \ + (((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid)) + +/** @} */ + +/** @addtogroup BLE_TYPES_STRUCTURES Structures + * @{ */ + +/** @brief 128 bit UUID values. */ +typedef struct +{ + uint8_t uuid128[16]; /**< Little-Endian UUID bytes. */ +} ble_uuid128_t; + +/** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */ +typedef struct +{ + uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */ + uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is @ref BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */ +} ble_uuid_t; + +/**@brief Data structure. */ +typedef struct +{ + uint8_t *p_data; /**< Pointer to the data buffer provided to/from the application. */ + uint16_t len; /**< Length of the data buffer, in bytes. */ +} ble_data_t; + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* BLE_TYPES_H__ */ + +/** + @} + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf52/nrf_mbr.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf52/nrf_mbr.h new file mode 100644 index 000000000..389cc377d --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf52/nrf_mbr.h @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @defgroup nrf_mbr_api Master Boot Record API + @{ + + @brief APIs for updating SoftDevice and BootLoader + +*/ + +#ifndef NRF_MBR_H__ +#define NRF_MBR_H__ + +#include "nrf_svc.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup NRF_MBR_DEFINES Defines + * @{ */ + +/**@brief MBR SVC Base number. */ +#define MBR_SVC_BASE (0x18) + +/**@brief Page size in words. */ +#define MBR_PAGE_SIZE_IN_WORDS (1024) + +/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash. +This is the offset where the first byte of the SoftDevice hex file is written. */ +#define MBR_SIZE (0x1000) + +/** @brief Location (in the flash memory) of the bootloader address. */ +#define MBR_BOOTLOADER_ADDR (0xFF8) + +/** @brief Location (in UICR) of the bootloader address. */ +#define MBR_UICR_BOOTLOADER_ADDR (&(NRF_UICR->NRFFW[0])) + +/** @brief Location (in the flash memory) of the address of the MBR parameter page. */ +#define MBR_PARAM_PAGE_ADDR (0xFFC) + +/** @brief Location (in UICR) of the address of the MBR parameter page. */ +#define MBR_UICR_PARAM_PAGE_ADDR (&(NRF_UICR->NRFFW[1])) + + +/** @} */ + +/** @addtogroup NRF_MBR_ENUMS Enumerations + * @{ */ + +/**@brief nRF Master Boot Record API SVC numbers. */ +enum NRF_MBR_SVCS +{ + SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */ +}; + +/**@brief Possible values for ::sd_mbr_command_t.command */ +enum NRF_MBR_COMMANDS +{ + SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see ::sd_mbr_command_copy_bl_t*/ + SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/ + SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD. Does not require any parameters in ::sd_mbr_command_t params.*/ + SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/ + SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset. @see ::sd_mbr_command_vector_table_base_set_t*/ + SD_MBR_COMMAND_RESERVED, + SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address. @see ::sd_mbr_command_irq_forward_address_set_t*/ +}; + +/** @} */ + +/** @addtogroup NRF_MBR_TYPES Types + * @{ */ + +/**@brief This command copies part of a new SoftDevice + * + * The destination area is erased before copying. + * If dst is in the middle of a flash page, that whole flash page will be erased. + * If (dst+len) is in the middle of a flash page, that whole flash page will be erased. + * + * The user of this function is responsible for setting the BPROT registers. + * + * @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly. + * @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying. + */ +typedef struct +{ + uint32_t *src; /**< Pointer to the source of data to be copied.*/ + uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/ + uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/ +} sd_mbr_command_copy_sd_t; + + +/**@brief This command works like memcmp, but takes the length in words. + * + * @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal. + * @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal. + */ +typedef struct +{ + uint32_t *ptr1; /**< Pointer to block of memory. */ + uint32_t *ptr2; /**< Pointer to block of memory. */ + uint32_t len; /**< Number of 32 bit words to compare.*/ +} sd_mbr_command_compare_t; + + +/**@brief This command copies a new BootLoader. + * + * The MBR assumes that either @ref MBR_BOOTLOADER_ADDR or @ref MBR_UICR_BOOTLOADER_ADDR is set to + * the address where the bootloader will be copied. If both addresses are set, the MBR will prioritize + * @ref MBR_BOOTLOADER_ADDR. + * + * The bootloader destination is erased by this function. + * If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased. + * + * This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set, + * see @ref sd_mbr_command. + * + * This command will use the flash protect peripheral (BPROT or ACL) to protect the flash that is + * not intended to be written. + * + * On success, this function will not return. It will start the new bootloader from reset-vector as normal. + * + * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen. + * @retval ::NRF_ERROR_FORBIDDEN if the bootloader address is not set. + * @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area. + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command. + */ +typedef struct +{ + uint32_t *bl_src; /**< Pointer to the source of the bootloader to be be copied.*/ + uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */ +} sd_mbr_command_copy_bl_t; + +/**@brief Change the address the MBR starts after a reset + * + * Once this function has been called, this address is where the MBR will start to forward + * interrupts to after a reset. + * + * To restore default forwarding, this function should be called with @ref address set to 0. If a + * bootloader is present, interrupts will be forwarded to the bootloader. If not, interrupts will + * be forwarded to the SoftDevice. + * + * The location of a bootloader can be specified in @ref MBR_BOOTLOADER_ADDR or + * @ref MBR_UICR_BOOTLOADER_ADDR. If both addresses are set, the MBR will prioritize + * @ref MBR_BOOTLOADER_ADDR. + * + * This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set, + * see @ref sd_mbr_command. + * + * On success, this function will not return. It will reset the device. + * + * @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen. + * @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size. + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command. + */ +typedef struct +{ + uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/ +} sd_mbr_command_vector_table_base_set_t; + +/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR + * + * Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not + * change where the MBR starts after reset. + * + * @retval ::NRF_SUCCESS + */ +typedef struct +{ + uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/ +} sd_mbr_command_irq_forward_address_set_t; + +/**@brief Input structure containing data used when calling ::sd_mbr_command + * + * Depending on what command value that is set, the corresponding params value type must also be + * set. See @ref NRF_MBR_COMMANDS for command types and corresponding params value type. If command + * @ref SD_MBR_COMMAND_INIT_SD is set, it is not necessary to set any values under params. + */ +typedef struct +{ + uint32_t command; /**< Type of command to be issued. See @ref NRF_MBR_COMMANDS. */ + union + { + sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/ + sd_mbr_command_compare_t compare; /**< Parameters for verify.*/ + sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */ + sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/ + sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/ + } params; /**< Command parameters. */ +} sd_mbr_command_t; + +/** @} */ + +/** @addtogroup NRF_MBR_FUNCTIONS Functions + * @{ */ + +/**@brief Issue Master Boot Record commands + * + * Commands used when updating a SoftDevice and bootloader. + * + * The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires + * parameters to be retained by the MBR when resetting the IC. This is done in a separate flash + * page. The location of the flash page should be provided by the application in either + * @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR. If both addresses are set, the MBR + * will prioritize @ref MBR_PARAM_PAGE_ADDR. This page will be cleared by the MBR and is used to + * store the command before reset. When an address is specified, the page it refers to must not be + * used by the application. If no address is provided by the application, i.e. both + * @ref MBR_PARAM_PAGE_ADDR and @ref MBR_UICR_PARAM_PAGE_ADDR is 0xFFFFFFFF, MBR commands which use + * flash will be unavailable and return @ref NRF_ERROR_NO_MEM. + * + * @param[in] param Pointer to a struct describing the command. + * + * @note For a complete set of return values, see ::sd_mbr_command_copy_sd_t, + * ::sd_mbr_command_copy_bl_t, ::sd_mbr_command_compare_t, + * ::sd_mbr_command_vector_table_base_set_t, ::sd_mbr_command_irq_forward_address_set_t + * + * @retval ::NRF_ERROR_NO_MEM No MBR parameter page provided + * @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given. +*/ +SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param)); + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // NRF_MBR_H__ + +/** + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error.h new file mode 100644 index 000000000..6badee98e --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + /** + @defgroup nrf_error SoftDevice Global Error Codes + @{ + + @brief Global Error definitions +*/ + +/* Header guard */ +#ifndef NRF_ERROR_H__ +#define NRF_ERROR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions + * @{ */ +#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base +#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base +#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base +#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base +/** @} */ + +#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command +#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing +#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled +#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error +#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation +#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found +#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported +#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter +#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state +#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length +#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags +#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data +#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size +#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out +#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer +#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation +#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address +#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy +#define NRF_ERROR_CONN_COUNT (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded. +#define NRF_ERROR_RESOURCES (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation + +#ifdef __cplusplus +} +#endif +#endif // NRF_ERROR_H__ + +/** + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error_sdm.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error_sdm.h new file mode 100644 index 000000000..530959b9d --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error_sdm.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + /** + @addtogroup nrf_sdm_api + @{ + @defgroup nrf_sdm_error SoftDevice Manager Error Codes + @{ + + @brief Error definitions for the SDM API +*/ + +/* Header guard */ +#ifndef NRF_ERROR_SDM_H__ +#define NRF_ERROR_SDM_H__ + +#include "nrf_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown LFCLK source. +#define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts). +#define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erroneous SoftDevice flashing). + +#ifdef __cplusplus +} +#endif +#endif // NRF_ERROR_SDM_H__ + +/** + @} + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error_soc.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error_soc.h new file mode 100644 index 000000000..1e784b8db --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_error_soc.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @addtogroup nrf_soc_api + @{ + @defgroup nrf_soc_error SoC Library Error Codes + @{ + + @brief Error definitions for the SoC library + +*/ + +/* Header guard */ +#ifndef NRF_ERROR_SOC_H__ +#define NRF_ERROR_SOC_H__ + +#include "nrf_error.h" +#ifdef __cplusplus +extern "C" { +#endif + +/* Mutex Errors */ +#define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken + +/* NVIC errors */ +#define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available +#define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed +#define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return + +/* Power errors */ +#define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown +#define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown +#define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return + +/* Rand errors */ +#define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values + +/* PPI errors */ +#define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel +#define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group + +#ifdef __cplusplus +} +#endif +#endif // NRF_ERROR_SOC_H__ +/** + @} + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_nvic.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_nvic.h new file mode 100644 index 000000000..1f79cc3c8 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_nvic.h @@ -0,0 +1,491 @@ +/* + * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @defgroup nrf_nvic_api SoftDevice NVIC API + * @{ + * + * @note In order to use this module, the following code has to be added to a .c file: + * \code + * nrf_nvic_state_t nrf_nvic_state = {0}; + * \endcode + * + * @note Definitions and declarations starting with __ (double underscore) in this header file are + * not intended for direct use by the application. + * + * @brief APIs for the accessing NVIC when using a SoftDevice. + * + */ + +#ifndef NRF_NVIC_H__ +#define NRF_NVIC_H__ + +#include +#include "nrf.h" +#include "nrf_svc.h" +#include "nrf_error.h" +#include "nrf_error_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@addtogroup NRF_NVIC_DEFINES Defines + * @{ */ + +/**@defgroup NRF_NVIC_ISER_DEFINES SoftDevice NVIC internal definitions + * @{ */ + +#define __NRF_NVIC_NVMC_IRQn (30) /**< The peripheral ID of the NVMC. IRQ numbers are used to identify peripherals, but the NVMC doesn't have an IRQ number in the MDK. */ + +#define __NRF_NVIC_ISER_COUNT (2) /**< The number of ISER/ICER registers in the NVIC that are used. */ + +/**@brief Interrupt priority levels used by the SoftDevice. */ +#define __NRF_NVIC_SD_IRQ_PRIOS ((uint8_t)( \ + (1U << 0) /**< Priority level high .*/ \ + | (1U << 1) /**< Priority level medium. */ \ + | (1U << 4) /**< Priority level low. */ \ + )) + +/**@brief Interrupt priority levels available to the application. */ +#define __NRF_NVIC_APP_IRQ_PRIOS ((uint8_t)~__NRF_NVIC_SD_IRQ_PRIOS) + +/**@brief Interrupts used by the SoftDevice, with IRQn in the range 0-31. */ +#define __NRF_NVIC_SD_IRQS_0 ((uint32_t)( \ + (1U << POWER_CLOCK_IRQn) \ + | (1U << RADIO_IRQn) \ + | (1U << RTC0_IRQn) \ + | (1U << TIMER0_IRQn) \ + | (1U << RNG_IRQn) \ + | (1U << ECB_IRQn) \ + | (1U << CCM_AAR_IRQn) \ + | (1U << TEMP_IRQn) \ + | (1U << __NRF_NVIC_NVMC_IRQn) \ + | (1U << (uint32_t)SWI5_IRQn) \ + )) + +/**@brief Interrupts used by the SoftDevice, with IRQn in the range 32-63. */ +#define __NRF_NVIC_SD_IRQS_1 ((uint32_t)0) + +/**@brief Interrupts available for to application, with IRQn in the range 0-31. */ +#define __NRF_NVIC_APP_IRQS_0 (~__NRF_NVIC_SD_IRQS_0) + +/**@brief Interrupts available for to application, with IRQn in the range 32-63. */ +#define __NRF_NVIC_APP_IRQS_1 (~__NRF_NVIC_SD_IRQS_1) + +/**@} */ + +/**@} */ + +/**@addtogroup NRF_NVIC_VARIABLES Variables + * @{ */ + +/**@brief Type representing the state struct for the SoftDevice NVIC module. */ +typedef struct +{ + uint32_t volatile __irq_masks[__NRF_NVIC_ISER_COUNT]; /**< IRQs enabled by the application in the NVIC. */ + uint32_t volatile __cr_flag; /**< Non-zero if already in a critical region */ +} nrf_nvic_state_t; + +/**@brief Variable keeping the state for the SoftDevice NVIC module. This must be declared in an + * application source file. */ +extern nrf_nvic_state_t nrf_nvic_state; + +/**@} */ + +/**@addtogroup NRF_NVIC_INTERNAL_FUNCTIONS SoftDevice NVIC internal functions + * @{ */ + +/**@brief Disables IRQ interrupts globally, including the SoftDevice's interrupts. + * + * @retval The value of PRIMASK prior to disabling the interrupts. + */ +__STATIC_INLINE int __sd_nvic_irq_disable(void); + +/**@brief Enables IRQ interrupts globally, including the SoftDevice's interrupts. + */ +__STATIC_INLINE void __sd_nvic_irq_enable(void); + +/**@brief Checks if IRQn is available to application + * @param[in] IRQn IRQ to check + * + * @retval 1 (true) if the IRQ to check is available to the application + */ +__STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn); + +/**@brief Checks if priority is available to application + * @param[in] priority priority to check + * + * @retval 1 (true) if the priority to check is available to the application + */ +__STATIC_INLINE uint32_t __sd_nvic_is_app_accessible_priority(uint32_t priority); + +/**@} */ + +/**@addtogroup NRF_NVIC_FUNCTIONS SoftDevice NVIC public functions + * @{ */ + +/**@brief Enable External Interrupt. + * @note Corresponds to NVIC_EnableIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt was enabled. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn); + +/**@brief Disable External Interrupt. + * @note Corresponds to NVIC_DisableIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt was disabled. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn); + +/**@brief Get Pending Interrupt. + * @note Corresponds to NVIC_GetPendingIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS. + * @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ. + * + * @retval ::NRF_SUCCESS The interrupt is available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq); + +/**@brief Set Pending Interrupt. + * @note Corresponds to NVIC_SetPendingIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt is set pending. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn); + +/**@brief Clear Pending Interrupt. + * @note Corresponds to NVIC_ClearPendingIRQ in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt pending flag is cleared. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn); + +/**@brief Set Interrupt Priority. + * @note Corresponds to NVIC_SetPriority in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * @pre Priority is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS. + * @param[in] priority A valid IRQ priority for use by the application. + * + * @retval ::NRF_SUCCESS The interrupt and priority level is available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority); + +/**@brief Get Interrupt Priority. + * @note Corresponds to NVIC_GetPriority in CMSIS. + * + * @pre IRQn is valid and not reserved by the stack. + * + * @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS. + * @param[out] p_priority Return value from NVIC_GetPriority. + * + * @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application. + */ +__STATIC_INLINE uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority); + +/**@brief System Reset. + * @note Corresponds to NVIC_SystemReset in CMSIS. + * + * @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN + */ +__STATIC_INLINE uint32_t sd_nvic_SystemReset(void); + +/**@brief Enter critical region. + * + * @post Application interrupts will be disabled. + * @note sd_nvic_critical_region_enter() and ::sd_nvic_critical_region_exit() must be called in matching pairs inside each + * execution context + * @sa sd_nvic_critical_region_exit + * + * @param[out] p_is_nested_critical_region If 1, the application is now in a nested critical region. + * + * @retval ::NRF_SUCCESS + */ +__STATIC_INLINE uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region); + +/**@brief Exit critical region. + * + * @pre Application has entered a critical region using ::sd_nvic_critical_region_enter. + * @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called. + * + * @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter. + * + * @retval ::NRF_SUCCESS + */ +__STATIC_INLINE uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region); + +/**@} */ + +#ifndef SUPPRESS_INLINE_IMPLEMENTATION + +__STATIC_INLINE int __sd_nvic_irq_disable(void) +{ + int pm = __get_PRIMASK(); + __disable_irq(); + return pm; +} + +__STATIC_INLINE void __sd_nvic_irq_enable(void) +{ + __enable_irq(); +} + +__STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn) +{ + if (IRQn < 32) + { + return ((1UL<= (1 << __NVIC_PRIO_BITS)) + || (((1 << priority) & __NRF_NVIC_APP_IRQ_PRIOS) == 0) + ) + { + return 0; + } + return 1; +} + + +__STATIC_INLINE uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn) +{ + if (!__sd_nvic_app_accessible_irq(IRQn)) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } + if (!__sd_nvic_is_app_accessible_priority(NVIC_GetPriority(IRQn))) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED; + } + + if (nrf_nvic_state.__cr_flag) + { + nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] |= (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F)); + } + else + { + NVIC_EnableIRQ(IRQn); + } + return NRF_SUCCESS; +} + +__STATIC_INLINE uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn) +{ + if (!__sd_nvic_app_accessible_irq(IRQn)) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } + + if (nrf_nvic_state.__cr_flag) + { + nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] &= ~(1UL << ((uint32_t)(IRQn) & 0x1F)); + } + else + { + NVIC_DisableIRQ(IRQn); + } + + return NRF_SUCCESS; +} + +__STATIC_INLINE uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq) +{ + if (__sd_nvic_app_accessible_irq(IRQn)) + { + *p_pending_irq = NVIC_GetPendingIRQ(IRQn); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } +} + +__STATIC_INLINE uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn) +{ + if (__sd_nvic_app_accessible_irq(IRQn)) + { + NVIC_SetPendingIRQ(IRQn); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } +} + +__STATIC_INLINE uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn) +{ + if (__sd_nvic_app_accessible_irq(IRQn)) + { + NVIC_ClearPendingIRQ(IRQn); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } +} + +__STATIC_INLINE uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if (!__sd_nvic_app_accessible_irq(IRQn)) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } + + if (!__sd_nvic_is_app_accessible_priority(priority)) + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED; + } + + NVIC_SetPriority(IRQn, (uint32_t)priority); + return NRF_SUCCESS; +} + +__STATIC_INLINE uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority) +{ + if (__sd_nvic_app_accessible_irq(IRQn)) + { + *p_priority = (NVIC_GetPriority(IRQn) & 0xFF); + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE; + } +} + +__STATIC_INLINE uint32_t sd_nvic_SystemReset(void) +{ + NVIC_SystemReset(); + return NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN; +} + +__STATIC_INLINE uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region) +{ + int was_masked = __sd_nvic_irq_disable(); + if (!nrf_nvic_state.__cr_flag) + { + nrf_nvic_state.__cr_flag = 1; + nrf_nvic_state.__irq_masks[0] = ( NVIC->ICER[0] & __NRF_NVIC_APP_IRQS_0 ); + NVIC->ICER[0] = __NRF_NVIC_APP_IRQS_0; + nrf_nvic_state.__irq_masks[1] = ( NVIC->ICER[1] & __NRF_NVIC_APP_IRQS_1 ); + NVIC->ICER[1] = __NRF_NVIC_APP_IRQS_1; + *p_is_nested_critical_region = 0; + } + else + { + *p_is_nested_critical_region = 1; + } + if (!was_masked) + { + __sd_nvic_irq_enable(); + } + return NRF_SUCCESS; +} + +__STATIC_INLINE uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region) +{ + if (nrf_nvic_state.__cr_flag && (is_nested_critical_region == 0)) + { + int was_masked = __sd_nvic_irq_disable(); + NVIC->ISER[0] = nrf_nvic_state.__irq_masks[0]; + NVIC->ISER[1] = nrf_nvic_state.__irq_masks[1]; + nrf_nvic_state.__cr_flag = 0; + if (!was_masked) + { + __sd_nvic_irq_enable(); + } + } + + return NRF_SUCCESS; +} + +#endif /* SUPPRESS_INLINE_IMPLEMENTATION */ + +#ifdef __cplusplus +} +#endif + +#endif // NRF_NVIC_H__ + +/**@} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_sd_def.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_sd_def.h new file mode 100644 index 000000000..767bb3359 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_sd_def.h @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2015 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef NRF_SD_DEF_H__ +#define NRF_SD_DEF_H__ + +#include +#include "nrf_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK +#define SD_PPI_CHANNELS_USED NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK /**< PPI channels utilized by SotfDevice (not available to the application). */ +#else +#define SD_PPI_CHANNELS_USED 0xFFFE0000uL /**< PPI channels utilized by SotfDevice (not available to the application). */ +#endif // NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK + +#ifdef NRF_SOC_SD_PPI_GROUPS_SD_ENABLED_MSK +#define SD_PPI_GROUPS_USED NRF_SOC_SD_PPI_GROUPS_SD_ENABLED_MSK /**< PPI groups utilized by SoftDevice (not available to the application). */ +#else +#define SD_PPI_GROUPS_USED 0x00000030uL /**< PPI groups utilized by SoftDevice (not available to the application). */ +#endif // NRF_SOC_SD_PPI_GROUPS_SD_ENABLED_MSK + +#define SD_TIMERS_USED 0x00000001uL /**< Timers used by SoftDevice. */ +#define SD_SWI_USED 0x00000036uL /**< Software interrupts used by SoftDevice */ + + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_SD_DEF_H__ */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_sdm.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_sdm.h new file mode 100644 index 000000000..2d8f25f4d --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_sdm.h @@ -0,0 +1,371 @@ +/* + * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + @defgroup nrf_sdm_api SoftDevice Manager API + @{ + + @brief APIs for SoftDevice management. + +*/ + +#ifndef NRF_SDM_H__ +#define NRF_SDM_H__ + +#include +#include "nrf.h" +#include "nrf_svc.h" +#include "nrf_error.h" +#include "nrf_error_sdm.h" +#include "nrf_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup NRF_SDM_DEFINES Defines + * @{ */ +#ifdef NRFSOC_DOXYGEN +/// Declared in nrf_mbr.h +#define MBR_SIZE 0 +#warning test +#endif + +/** @brief The major version for the SoftDevice binary distributed with this header file. */ +#define SD_MAJOR_VERSION (7) + +/** @brief The minor version for the SoftDevice binary distributed with this header file. */ +#define SD_MINOR_VERSION (2) + +/** @brief The bugfix version for the SoftDevice binary distributed with this header file. */ +#define SD_BUGFIX_VERSION (0) + +/** @brief The SoftDevice variant of this firmware. */ +#define SD_VARIANT_ID 132 + +/** @brief The full version number for the SoftDevice binary this header file was distributed + * with, as a decimal number in the form Mmmmbbb, where: + * - M is major version (one or more digits) + * - mmm is minor version (three digits) + * - bbb is bugfix version (three digits). */ +#define SD_VERSION (SD_MAJOR_VERSION * 1000000 + SD_MINOR_VERSION * 1000 + SD_BUGFIX_VERSION) + +/** @brief SoftDevice Manager SVC Base number. */ +#define SDM_SVC_BASE 0x10 + +/** @brief SoftDevice unique string size in bytes. */ +#define SD_UNIQUE_STR_SIZE 20 + +/** @brief Invalid info field. Returned when an info field does not exist. */ +#define SDM_INFO_FIELD_INVALID (0) + +/** @brief Defines the SoftDevice Information Structure location (address) as an offset from +the start of the SoftDevice (without MBR)*/ +#define SOFTDEVICE_INFO_STRUCT_OFFSET (0x2000) + +/** @brief Defines the absolute SoftDevice Information Structure location (address) when the + * SoftDevice is installed just above the MBR (the usual case). */ +#define SOFTDEVICE_INFO_STRUCT_ADDRESS (SOFTDEVICE_INFO_STRUCT_OFFSET + MBR_SIZE) + +/** @brief Defines the offset for the SoftDevice Information Structure size value relative to the + * SoftDevice base address. The size value is of type uint8_t. */ +#define SD_INFO_STRUCT_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET) + +/** @brief Defines the offset for the SoftDevice size value relative to the SoftDevice base address. + * The size value is of type uint32_t. */ +#define SD_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x08) + +/** @brief Defines the offset for FWID value relative to the SoftDevice base address. The FWID value + * is of type uint16_t. */ +#define SD_FWID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x0C) + +/** @brief Defines the offset for the SoftDevice ID relative to the SoftDevice base address. The ID + * is of type uint32_t. */ +#define SD_ID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x10) + +/** @brief Defines the offset for the SoftDevice version relative to the SoftDevice base address in + * the same format as @ref SD_VERSION, stored as an uint32_t. */ +#define SD_VERSION_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x14) + +/** @brief Defines the offset for the SoftDevice unique string relative to the SoftDevice base address. + * The SD_UNIQUE_STR is stored as an array of uint8_t. The size of array is @ref SD_UNIQUE_STR_SIZE. + */ +#define SD_UNIQUE_STR_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x18) + +/** @brief Defines a macro for retrieving the actual SoftDevice Information Structure size value + * from a given base address. Use @ref MBR_SIZE as the argument when the SoftDevice is + * installed just above the MBR (the usual case). */ +#define SD_INFO_STRUCT_SIZE_GET(baseaddr) (*((uint8_t *) ((baseaddr) + SD_INFO_STRUCT_SIZE_OFFSET))) + +/** @brief Defines a macro for retrieving the actual SoftDevice size value from a given base + * address. Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above + * the MBR (the usual case). */ +#define SD_SIZE_GET(baseaddr) (*((uint32_t *) ((baseaddr) + SD_SIZE_OFFSET))) + +/** @brief Defines the amount of flash that is used by the SoftDevice. + * Add @ref MBR_SIZE to find the first available flash address when the SoftDevice is installed + * just above the MBR (the usual case). + */ +#define SD_FLASH_SIZE 0x25000 + +/** @brief Defines a macro for retrieving the actual FWID value from a given base address. Use + * @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual + * case). */ +#define SD_FWID_GET(baseaddr) (*((uint16_t *) ((baseaddr) + SD_FWID_OFFSET))) + +/** @brief Defines a macro for retrieving the actual SoftDevice ID from a given base address. Use + * @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the + * usual case). */ +#define SD_ID_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_ID_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \ + ? (*((uint32_t *) ((baseaddr) + SD_ID_OFFSET))) : SDM_INFO_FIELD_INVALID) + +/** @brief Defines a macro for retrieving the actual SoftDevice version from a given base address. + * Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR + * (the usual case). */ +#define SD_VERSION_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_VERSION_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \ + ? (*((uint32_t *) ((baseaddr) + SD_VERSION_OFFSET))) : SDM_INFO_FIELD_INVALID) + +/** @brief Defines a macro for retrieving the address of SoftDevice unique str based on a given base address. + * Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR + * (the usual case). */ +#define SD_UNIQUE_STR_ADDR_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_UNIQUE_STR_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \ + ? (((uint8_t *) ((baseaddr) + SD_UNIQUE_STR_OFFSET))) : SDM_INFO_FIELD_INVALID) + +/**@defgroup NRF_FAULT_ID_RANGES Fault ID ranges + * @{ */ +#define NRF_FAULT_ID_SD_RANGE_START 0x00000000 /**< SoftDevice ID range start. */ +#define NRF_FAULT_ID_APP_RANGE_START 0x00001000 /**< Application ID range start. */ +/**@} */ + +/**@defgroup NRF_FAULT_IDS Fault ID types + * @{ */ +#define NRF_FAULT_ID_SD_ASSERT (NRF_FAULT_ID_SD_RANGE_START + 1) /**< SoftDevice assertion. The info parameter is reserved for future used. */ +#define NRF_FAULT_ID_APP_MEMACC (NRF_FAULT_ID_APP_RANGE_START + 1) /**< Application invalid memory access. The info parameter will contain 0x00000000, + in case of SoftDevice RAM access violation. In case of SoftDevice peripheral + register violation the info parameter will contain the sub-region number of + PREGION[0], on whose address range the disallowed write access caused the + memory access fault. */ +/**@} */ + +/** @} */ + +/** @addtogroup NRF_SDM_ENUMS Enumerations + * @{ */ + +/**@brief nRF SoftDevice Manager API SVC numbers. */ +enum NRF_SD_SVCS +{ + SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */ + SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */ + SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */ + SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, /**< ::sd_softdevice_vector_table_base_set */ + SVC_SDM_LAST /**< Placeholder for last SDM SVC */ +}; + +/** @} */ + +/** @addtogroup NRF_SDM_DEFINES Defines + * @{ */ + +/**@defgroup NRF_CLOCK_LF_ACCURACY Clock accuracy + * @{ */ + +#define NRF_CLOCK_LF_ACCURACY_250_PPM (0) /**< Default: 250 ppm */ +#define NRF_CLOCK_LF_ACCURACY_500_PPM (1) /**< 500 ppm */ +#define NRF_CLOCK_LF_ACCURACY_150_PPM (2) /**< 150 ppm */ +#define NRF_CLOCK_LF_ACCURACY_100_PPM (3) /**< 100 ppm */ +#define NRF_CLOCK_LF_ACCURACY_75_PPM (4) /**< 75 ppm */ +#define NRF_CLOCK_LF_ACCURACY_50_PPM (5) /**< 50 ppm */ +#define NRF_CLOCK_LF_ACCURACY_30_PPM (6) /**< 30 ppm */ +#define NRF_CLOCK_LF_ACCURACY_20_PPM (7) /**< 20 ppm */ +#define NRF_CLOCK_LF_ACCURACY_10_PPM (8) /**< 10 ppm */ +#define NRF_CLOCK_LF_ACCURACY_5_PPM (9) /**< 5 ppm */ +#define NRF_CLOCK_LF_ACCURACY_2_PPM (10) /**< 2 ppm */ +#define NRF_CLOCK_LF_ACCURACY_1_PPM (11) /**< 1 ppm */ + +/** @} */ + +/**@defgroup NRF_CLOCK_LF_SRC Possible LFCLK oscillator sources + * @{ */ + +#define NRF_CLOCK_LF_SRC_RC (0) /**< LFCLK RC oscillator. */ +#define NRF_CLOCK_LF_SRC_XTAL (1) /**< LFCLK crystal oscillator. */ +#define NRF_CLOCK_LF_SRC_SYNTH (2) /**< LFCLK Synthesized from HFCLK. */ + +/** @} */ + +/** @} */ + +/** @addtogroup NRF_SDM_TYPES Types + * @{ */ + +/**@brief Type representing LFCLK oscillator source. */ +typedef struct +{ + uint8_t source; /**< LF oscillator clock source, see @ref NRF_CLOCK_LF_SRC. */ + uint8_t rc_ctiv; /**< Only for ::NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second + units (nRF52: 1-32). + @note To avoid excessive clock drift, 0.5 degrees Celsius is the + maximum temperature change allowed in one calibration timer + interval. The interval should be selected to ensure this. + + @note Must be 0 if source is not ::NRF_CLOCK_LF_SRC_RC. */ + uint8_t rc_temp_ctiv; /**< Only for ::NRF_CLOCK_LF_SRC_RC: How often (in number of calibration + intervals) the RC oscillator shall be calibrated if the temperature + hasn't changed. + 0: Always calibrate even if the temperature hasn't changed. + 1: Only calibrate if the temperature has changed (legacy - nRF51 only). + 2-33: Check the temperature and only calibrate if it has changed, + however calibration will take place every rc_temp_ctiv + intervals in any case. + + @note Must be 0 if source is not ::NRF_CLOCK_LF_SRC_RC. + + @note For nRF52, the application must ensure calibration at least once + every 8 seconds to ensure +/-500 ppm clock stability. The + recommended configuration for ::NRF_CLOCK_LF_SRC_RC on nRF52 is + rc_ctiv=16 and rc_temp_ctiv=2. This will ensure calibration at + least once every 8 seconds and for temperature changes of 0.5 + degrees Celsius every 4 seconds. See the Product Specification + for the nRF52 device being used for more information.*/ + uint8_t accuracy; /**< External clock accuracy used in the LL to compute timing + windows, see @ref NRF_CLOCK_LF_ACCURACY.*/ +} nrf_clock_lf_cfg_t; + +/**@brief Fault Handler type. + * + * When certain unrecoverable errors occur within the application or SoftDevice the fault handler will be called back. + * The protocol stack will be in an undefined state when this happens and the only way to recover will be to + * perform a reset, using e.g. CMSIS NVIC_SystemReset(). + * If the application returns from the fault handler the SoftDevice will call NVIC_SystemReset(). + * + * @note It is recommended to either perform a reset in the fault handler or to let the SoftDevice reset the device. + * Otherwise SoC peripherals may behave in an undefined way. For example, the RADIO peripherial may + * continously transmit packets. + * + * @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback. + * + * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. + * @param[in] pc The program counter of the instruction that triggered the fault. + * @param[in] info Optional additional information regarding the fault. Refer to each Fault identifier for details. + * + * @note When id is set to @ref NRF_FAULT_ID_APP_MEMACC, pc will contain the address of the instruction being executed at the time when + * the fault is detected by the CPU. The CPU program counter may have advanced up to 2 instructions (no branching) after the one that triggered the fault. + */ +typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info); + +/** @} */ + +/** @addtogroup NRF_SDM_FUNCTIONS Functions + * @{ */ + +/**@brief Enables the SoftDevice and by extension the protocol stack. + * + * @note Some care must be taken if a low frequency clock source is already running when calling this function: + * If the LF clock has a different source then the one currently running, it will be stopped. Then, the new + * clock source will be started. + * + * @note This function has no effect when returning with an error. + * + * @post If return code is ::NRF_SUCCESS + * - SoC library and protocol stack APIs are made available. + * - A portion of RAM will be unavailable (see relevant SDS documentation). + * - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation). + * - Interrupts will not arrive from protected peripherals or interrupts. + * - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the SoftDevice. + * - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation). + * - Chosen low frequency clock source will be running. + * + * @param p_clock_lf_cfg Low frequency clock source and accuracy. + If NULL the clock will be configured as an RC source with rc_ctiv = 16 and .rc_temp_ctiv = 2 + In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock. + * @param fault_handler Callback to be invoked in case of fault, cannot be NULL. + * + * @retval ::NRF_SUCCESS + * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied. + * @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated. + * @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDevice interrupt is already enabled, or an enabled interrupt has an illegal priority level. + * @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected. + * @retval ::NRF_ERROR_INVALID_PARAM Invalid clock source configuration supplied in p_clock_lf_cfg. + */ +SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler)); + + +/**@brief Disables the SoftDevice and by extension the protocol stack. + * + * Idempotent function to disable the SoftDevice. + * + * @post SoC library and protocol stack APIs are made unavailable. + * @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest). + * @post All peripherals used by the SoftDevice will be reset to default values. + * @post All of RAM become available. + * @post All interrupts are forwarded to the application. + * @post LFCLK source chosen in ::sd_softdevice_enable will be left running. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void)); + +/**@brief Check if the SoftDevice is enabled. + * + * @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled)); + +/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the SoftDevice + * + * This function is only intended to be called when a bootloader is enabled. + * + * @param[in] address The base address of the interrupt vector table for forwarded interrupts. + + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, uint32_t, sd_softdevice_vector_table_base_set(uint32_t address)); + +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif // NRF_SDM_H__ + +/** + @} +*/ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_soc.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_soc.h new file mode 100644 index 000000000..0d2929370 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_soc.h @@ -0,0 +1,1000 @@ +/* + * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @defgroup nrf_soc_api SoC Library API + * @{ + * + * @brief APIs for the SoC library. + * + */ + +#ifndef NRF_SOC_H__ +#define NRF_SOC_H__ + +#include +#include "nrf.h" +#include "nrf_svc.h" +#include "nrf_error.h" +#include "nrf_error_soc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/**@addtogroup NRF_SOC_DEFINES Defines + * @{ */ + +/**@brief The number of the lowest SVC number reserved for the SoC library. */ +#define SOC_SVC_BASE (0x20) /**< Base value for SVCs that are available when the SoftDevice is disabled. */ +#define SOC_SVC_BASE_NOT_AVAILABLE (0x2C) /**< Base value for SVCs that are not available when the SoftDevice is disabled. */ + +/**@brief Guaranteed time for application to process radio inactive notification. */ +#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62) + +/**@brief The minimum allowed timeslot extension time. */ +#define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200) + +/**@brief The maximum processing time to handle a timeslot extension. */ +#define NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US (20) + +/**@brief The latest time before the end of a timeslot the timeslot can be extended. */ +#define NRF_RADIO_MIN_EXTENSION_MARGIN_US (82) + +#define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */ +#define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */ +#define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */ + +#define SD_EVT_IRQn (SWI2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */ +#define SD_EVT_IRQHandler (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. + The default interrupt priority for this handler is set to 6 */ +#define RADIO_NOTIFICATION_IRQn (SWI1_IRQn) /**< The radio notification IRQ number. */ +#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. + The default interrupt priority for this handler is set to 6 */ +#define NRF_RADIO_LENGTH_MIN_US (100) /**< The shortest allowed radio timeslot, in microseconds. */ +#define NRF_RADIO_LENGTH_MAX_US (100000) /**< The longest allowed radio timeslot, in microseconds. */ + +#define NRF_RADIO_DISTANCE_MAX_US (128000000UL - 1UL) /**< The longest timeslot distance, in microseconds, allowed for the distance parameter (see @ref nrf_radio_request_normal_t) in the request. */ + +#define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */ + +#define NRF_RADIO_START_JITTER_US (2) /**< The maximum jitter in @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */ + +/**@brief Mask of PPI channels reserved by the SoftDevice when the SoftDevice is disabled. */ +#define NRF_SOC_SD_PPI_CHANNELS_SD_DISABLED_MSK ((uint32_t)(0)) + +/**@brief Mask of PPI channels reserved by the SoftDevice when the SoftDevice is enabled. */ +#define NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK ((uint32_t)( \ + (1U << 17) \ + | (1U << 18) \ + | (1U << 19) \ + | (1U << 20) \ + | (1U << 21) \ + | (1U << 22) \ + | (1U << 23) \ + | (1U << 24) \ + | (1U << 25) \ + | (1U << 26) \ + | (1U << 27) \ + | (1U << 28) \ + | (1U << 29) \ + | (1U << 30) \ + | (1U << 31) \ + )) + +/**@brief Mask of PPI groups reserved by the SoftDevice when the SoftDevice is disabled. */ +#define NRF_SOC_SD_PPI_GROUPS_SD_DISABLED_MSK ((uint32_t)(0)) + +/**@brief Mask of PPI groups reserved by the SoftDevice when the SoftDevice is enabled. */ +#define NRF_SOC_SD_PPI_GROUPS_SD_ENABLED_MSK ((uint32_t)( \ + (1U << 4) \ + | (1U << 5) \ + )) + +/**@} */ + +/**@addtogroup NRF_SOC_ENUMS Enumerations + * @{ */ + +/**@brief The SVC numbers used by the SVC functions in the SoC library. */ +enum NRF_SOC_SVCS +{ + SD_PPI_CHANNEL_ENABLE_GET = SOC_SVC_BASE, + SD_PPI_CHANNEL_ENABLE_SET = SOC_SVC_BASE + 1, + SD_PPI_CHANNEL_ENABLE_CLR = SOC_SVC_BASE + 2, + SD_PPI_CHANNEL_ASSIGN = SOC_SVC_BASE + 3, + SD_PPI_GROUP_TASK_ENABLE = SOC_SVC_BASE + 4, + SD_PPI_GROUP_TASK_DISABLE = SOC_SVC_BASE + 5, + SD_PPI_GROUP_ASSIGN = SOC_SVC_BASE + 6, + SD_PPI_GROUP_GET = SOC_SVC_BASE + 7, + SD_FLASH_PAGE_ERASE = SOC_SVC_BASE + 8, + SD_FLASH_WRITE = SOC_SVC_BASE + 9, + SD_FLASH_PROTECT = SOC_SVC_BASE + 10, + SD_PROTECTED_REGISTER_WRITE = SOC_SVC_BASE + 11, + SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE, + SD_MUTEX_ACQUIRE = SOC_SVC_BASE_NOT_AVAILABLE + 1, + SD_MUTEX_RELEASE = SOC_SVC_BASE_NOT_AVAILABLE + 2, + SD_RAND_APPLICATION_POOL_CAPACITY_GET = SOC_SVC_BASE_NOT_AVAILABLE + 3, + SD_RAND_APPLICATION_BYTES_AVAILABLE_GET = SOC_SVC_BASE_NOT_AVAILABLE + 4, + SD_RAND_APPLICATION_VECTOR_GET = SOC_SVC_BASE_NOT_AVAILABLE + 5, + SD_POWER_MODE_SET = SOC_SVC_BASE_NOT_AVAILABLE + 6, + SD_POWER_SYSTEM_OFF = SOC_SVC_BASE_NOT_AVAILABLE + 7, + SD_POWER_RESET_REASON_GET = SOC_SVC_BASE_NOT_AVAILABLE + 8, + SD_POWER_RESET_REASON_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 9, + SD_POWER_POF_ENABLE = SOC_SVC_BASE_NOT_AVAILABLE + 10, + SD_POWER_POF_THRESHOLD_SET = SOC_SVC_BASE_NOT_AVAILABLE + 11, + SD_POWER_RAM_POWER_SET = SOC_SVC_BASE_NOT_AVAILABLE + 13, + SD_POWER_RAM_POWER_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 14, + SD_POWER_RAM_POWER_GET = SOC_SVC_BASE_NOT_AVAILABLE + 15, + SD_POWER_GPREGRET_SET = SOC_SVC_BASE_NOT_AVAILABLE + 16, + SD_POWER_GPREGRET_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 17, + SD_POWER_GPREGRET_GET = SOC_SVC_BASE_NOT_AVAILABLE + 18, + SD_POWER_DCDC_MODE_SET = SOC_SVC_BASE_NOT_AVAILABLE + 19, + SD_APP_EVT_WAIT = SOC_SVC_BASE_NOT_AVAILABLE + 21, + SD_CLOCK_HFCLK_REQUEST = SOC_SVC_BASE_NOT_AVAILABLE + 22, + SD_CLOCK_HFCLK_RELEASE = SOC_SVC_BASE_NOT_AVAILABLE + 23, + SD_CLOCK_HFCLK_IS_RUNNING = SOC_SVC_BASE_NOT_AVAILABLE + 24, + SD_RADIO_NOTIFICATION_CFG_SET = SOC_SVC_BASE_NOT_AVAILABLE + 25, + SD_ECB_BLOCK_ENCRYPT = SOC_SVC_BASE_NOT_AVAILABLE + 26, + SD_ECB_BLOCKS_ENCRYPT = SOC_SVC_BASE_NOT_AVAILABLE + 27, + SD_RADIO_SESSION_OPEN = SOC_SVC_BASE_NOT_AVAILABLE + 28, + SD_RADIO_SESSION_CLOSE = SOC_SVC_BASE_NOT_AVAILABLE + 29, + SD_RADIO_REQUEST = SOC_SVC_BASE_NOT_AVAILABLE + 30, + SD_EVT_GET = SOC_SVC_BASE_NOT_AVAILABLE + 31, + SD_TEMP_GET = SOC_SVC_BASE_NOT_AVAILABLE + 32, + SVC_SOC_LAST = SOC_SVC_BASE_NOT_AVAILABLE + 37 +}; + +/**@brief Possible values of a ::nrf_mutex_t. */ +enum NRF_MUTEX_VALUES +{ + NRF_MUTEX_FREE, + NRF_MUTEX_TAKEN +}; + +/**@brief Power modes. */ +enum NRF_POWER_MODES +{ + NRF_POWER_MODE_CONSTLAT, /**< Constant latency mode. See power management in the reference manual. */ + NRF_POWER_MODE_LOWPWR /**< Low power mode. See power management in the reference manual. */ +}; + + +/**@brief Power failure thresholds */ +enum NRF_POWER_THRESHOLDS +{ + NRF_POWER_THRESHOLD_V17 = 4UL, /**< 1.7 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V18, /**< 1.8 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V19, /**< 1.9 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V20, /**< 2.0 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V21, /**< 2.1 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V22, /**< 2.2 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V23, /**< 2.3 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V24, /**< 2.4 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V25, /**< 2.5 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V26, /**< 2.6 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V27, /**< 2.7 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V28 /**< 2.8 Volts power failure threshold. */ +}; + + + +/**@brief DC/DC converter modes. */ +enum NRF_POWER_DCDC_MODES +{ + NRF_POWER_DCDC_DISABLE, /**< The DCDC is disabled. */ + NRF_POWER_DCDC_ENABLE /**< The DCDC is enabled. */ +}; + +/**@brief Radio notification distances. */ +enum NRF_RADIO_NOTIFICATION_DISTANCES +{ + NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */ + NRF_RADIO_NOTIFICATION_DISTANCE_800US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_1740US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_2680US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_3620US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_4560US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_5500US /**< The distance from the active notification to start of radio activity. */ +}; + + +/**@brief Radio notification types. */ +enum NRF_RADIO_NOTIFICATION_TYPES +{ + NRF_RADIO_NOTIFICATION_TYPE_NONE = 0, /**< The event does not have a radio notification signal. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */ +}; + +/**@brief The Radio signal callback types. */ +enum NRF_RADIO_CALLBACK_SIGNAL_TYPE +{ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_START, /**< This signal indicates the start of the radio timeslot. */ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0, /**< This signal indicates the NRF_TIMER0 interrupt. */ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO, /**< This signal indicates the NRF_RADIO interrupt. */ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED, /**< This signal indicates extend action failed. */ + NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED /**< This signal indicates extend action succeeded. */ +}; + +/**@brief The actions requested by the signal callback. + * + * This code gives the SOC instructions about what action to take when the signal callback has + * returned. + */ +enum NRF_RADIO_SIGNAL_CALLBACK_ACTION +{ + NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE, /**< Return without action. */ + NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND, /**< Request an extension of the current + timeslot. Maximum execution time for this action: + @ref NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US. + This action must be started at least + @ref NRF_RADIO_MIN_EXTENSION_MARGIN_US before + the end of the timeslot. */ + NRF_RADIO_SIGNAL_CALLBACK_ACTION_END, /**< End the current radio timeslot. */ + NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END /**< Request a new radio timeslot and end the current timeslot. */ +}; + +/**@brief Radio timeslot high frequency clock source configuration. */ +enum NRF_RADIO_HFCLK_CFG +{ + NRF_RADIO_HFCLK_CFG_XTAL_GUARANTEED, /**< The SoftDevice will guarantee that the high frequency clock source is the + external crystal for the whole duration of the timeslot. This should be the + preferred option for events that use the radio or require high timing accuracy. + @note The SoftDevice will automatically turn on and off the external crystal, + at the beginning and end of the timeslot, respectively. The crystal may also + intentionally be left running after the timeslot, in cases where it is needed + by the SoftDevice shortly after the end of the timeslot. */ + NRF_RADIO_HFCLK_CFG_NO_GUARANTEE /**< This configuration allows for earlier and tighter scheduling of timeslots. + The RC oscillator may be the clock source in part or for the whole duration of the timeslot. + The RC oscillator's accuracy must therefore be taken into consideration. + @note If the application will use the radio peripheral in timeslots with this configuration, + it must make sure that the crystal is running and stable before starting the radio. */ +}; + +/**@brief Radio timeslot priorities. */ +enum NRF_RADIO_PRIORITY +{ + NRF_RADIO_PRIORITY_HIGH, /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */ + NRF_RADIO_PRIORITY_NORMAL, /**< Normal (equal priority as the priority of secondary activities of the SoftDevice stack(s)). */ +}; + +/**@brief Radio timeslot request type. */ +enum NRF_RADIO_REQUEST_TYPE +{ + NRF_RADIO_REQ_TYPE_EARLIEST, /**< Request radio timeslot as early as possible. This should always be used for the first request in a session. */ + NRF_RADIO_REQ_TYPE_NORMAL /**< Normal radio timeslot request. */ +}; + +/**@brief SoC Events. */ +enum NRF_SOC_EVTS +{ + NRF_EVT_HFCLKSTARTED, /**< Event indicating that the HFCLK has started. */ + NRF_EVT_POWER_FAILURE_WARNING, /**< Event indicating that a power failure warning has occurred. */ + NRF_EVT_FLASH_OPERATION_SUCCESS, /**< Event indicating that the ongoing flash operation has completed successfully. */ + NRF_EVT_FLASH_OPERATION_ERROR, /**< Event indicating that the ongoing flash operation has timed out with an error. */ + NRF_EVT_RADIO_BLOCKED, /**< Event indicating that a radio timeslot was blocked. */ + NRF_EVT_RADIO_CANCELED, /**< Event indicating that a radio timeslot was canceled by SoftDevice. */ + NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio timeslot signal callback handler return was invalid. */ + NRF_EVT_RADIO_SESSION_IDLE, /**< Event indicating that a radio timeslot session is idle. */ + NRF_EVT_RADIO_SESSION_CLOSED, /**< Event indicating that a radio timeslot session is closed. */ + NRF_EVT_NUMBER_OF_EVTS +}; + +/**@} */ + + +/**@addtogroup NRF_SOC_STRUCTURES Structures + * @{ */ + +/**@brief Represents a mutex for use with the nrf_mutex functions. + * @note Accessing the value directly is not safe, use the mutex functions! + */ +typedef volatile uint8_t nrf_mutex_t; + +/**@brief Parameters for a request for a timeslot as early as possible. */ +typedef struct +{ + uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */ + uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */ + uint32_t length_us; /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */ + uint32_t timeout_us; /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */ +} nrf_radio_request_earliest_t; + +/**@brief Parameters for a normal radio timeslot request. */ +typedef struct +{ + uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */ + uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */ + uint32_t distance_us; /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */ + uint32_t length_us; /**< The radio timeslot length (in the range [100..100,000] microseconds). */ +} nrf_radio_request_normal_t; + +/**@brief Radio timeslot request parameters. */ +typedef struct +{ + uint8_t request_type; /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */ + union + { + nrf_radio_request_earliest_t earliest; /**< Parameters for requesting a radio timeslot as early as possible. */ + nrf_radio_request_normal_t normal; /**< Parameters for requesting a normal radio timeslot. */ + } params; /**< Parameter union. */ +} nrf_radio_request_t; + +/**@brief Return parameters of the radio timeslot signal callback. */ +typedef struct +{ + uint8_t callback_action; /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */ + union + { + struct + { + nrf_radio_request_t * p_next; /**< The request parameters for the next radio timeslot. */ + } request; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */ + struct + { + uint32_t length_us; /**< Requested extension of the radio timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */ + } extend; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */ + } params; /**< Parameter union. */ +} nrf_radio_signal_callback_return_param_t; + +/**@brief The radio timeslot signal callback type. + * + * @note In case of invalid return parameters, the radio timeslot will automatically end + * immediately after returning from the signal callback and the + * @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent. + * @note The returned struct pointer must remain valid after the signal callback + * function returns. For instance, this means that it must not point to a stack variable. + * + * @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE. + * + * @return Pointer to structure containing action requested by the application. + */ +typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type); + +/**@brief AES ECB parameter typedefs */ +typedef uint8_t soc_ecb_key_t[SOC_ECB_KEY_LENGTH]; /**< Encryption key type. */ +typedef uint8_t soc_ecb_cleartext_t[SOC_ECB_CLEARTEXT_LENGTH]; /**< Cleartext data type. */ +typedef uint8_t soc_ecb_ciphertext_t[SOC_ECB_CIPHERTEXT_LENGTH]; /**< Ciphertext data type. */ + +/**@brief AES ECB data structure */ +typedef struct +{ + soc_ecb_key_t key; /**< Encryption key. */ + soc_ecb_cleartext_t cleartext; /**< Cleartext data. */ + soc_ecb_ciphertext_t ciphertext; /**< Ciphertext data. */ +} nrf_ecb_hal_data_t; + +/**@brief AES ECB block. Used to provide multiple blocks in a single call + to @ref sd_ecb_blocks_encrypt.*/ +typedef struct +{ + soc_ecb_key_t const * p_key; /**< Pointer to the Encryption key. */ + soc_ecb_cleartext_t const * p_cleartext; /**< Pointer to the Cleartext data. */ + soc_ecb_ciphertext_t * p_ciphertext; /**< Pointer to the Ciphertext data. */ +} nrf_ecb_hal_data_block_t; + +/**@} */ + +/**@addtogroup NRF_SOC_FUNCTIONS Functions + * @{ */ + +/**@brief Initialize a mutex. + * + * @param[in] p_mutex Pointer to the mutex to initialize. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex)); + +/**@brief Attempt to acquire a mutex. + * + * @param[in] p_mutex Pointer to the mutex to acquire. + * + * @retval ::NRF_SUCCESS The mutex was successfully acquired. + * @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired. + */ +SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex)); + +/**@brief Release a mutex. + * + * @param[in] p_mutex Pointer to the mutex to release. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex)); + +/**@brief Query the capacity of the application random pool. + * + * @param[out] p_pool_capacity The capacity of the pool. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY_GET, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity)); + +/**@brief Get number of random bytes available to the application. + * + * @param[out] p_bytes_available The number of bytes currently available in the pool. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE_GET, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available)); + +/**@brief Get random bytes from the application pool. + * + * @param[out] p_buff Pointer to unit8_t buffer for storing the bytes. + * @param[in] length Number of bytes to take from pool and place in p_buff. + * + * @retval ::NRF_SUCCESS The requested bytes were written to p_buff. + * @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available. +*/ +SVCALL(SD_RAND_APPLICATION_VECTOR_GET, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length)); + +/**@brief Gets the reset reason register. + * + * @param[out] p_reset_reason Contents of the NRF_POWER->RESETREAS register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason)); + +/**@brief Clears the bits of the reset reason register. + * + * @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk)); + +/**@brief Sets the power mode when in CPU sleep. + * + * @param[in] power_mode The power mode to use when in CPU sleep, see @ref NRF_POWER_MODES. @sa sd_app_evt_wait + * + * @retval ::NRF_SUCCESS The power mode was set. + * @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown. + */ +SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(uint8_t power_mode)); + +/**@brief Puts the chip in System OFF mode. + * + * @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN + */ +SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void)); + +/**@brief Enables or disables the power-fail comparator. + * + * Enabling this will give a SoftDevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs. + * The event can be retrieved with sd_evt_get(); + * + * @param[in] pof_enable True if the power-fail comparator should be enabled, false if it should be disabled. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable)); + + +/**@brief Sets the power failure comparator threshold value. + * + * + * @param[in] threshold The power-fail threshold value to use, see @ref NRF_POWER_THRESHOLDS. + * + * @retval ::NRF_SUCCESS The power failure threshold was set. + * @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown. + */ +SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(uint8_t threshold)); + + +/**@brief Writes the NRF_POWER->RAM[index].POWERSET register. + * + * @param[in] index Contains the index in the NRF_POWER->RAM[index].POWERSET register to write to. + * @param[in] ram_powerset Contains the word to write to the NRF_POWER->RAM[index].POWERSET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAM_POWER_SET, uint32_t, sd_power_ram_power_set(uint8_t index, uint32_t ram_powerset)); + +/**@brief Writes the NRF_POWER->RAM[index].POWERCLR register. + * + * @param[in] index Contains the index in the NRF_POWER->RAM[index].POWERCLR register to write to. + * @param[in] ram_powerclr Contains the word to write to the NRF_POWER->RAM[index].POWERCLR register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAM_POWER_CLR, uint32_t, sd_power_ram_power_clr(uint8_t index, uint32_t ram_powerclr)); + +/**@brief Get contents of NRF_POWER->RAM[index].POWER register, indicates power status of RAM[index] blocks. + * + * @param[in] index Contains the index in the NRF_POWER->RAM[index].POWER register to read from. + * @param[out] p_ram_power Content of NRF_POWER->RAM[index].POWER register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAM_POWER_GET, uint32_t, sd_power_ram_power_get(uint8_t index, uint32_t * p_ram_power)); + +/**@brief Set bits in the general purpose retention registers (NRF_POWER->GPREGRET*). + * + * @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2. + * @param[in] gpregret_msk Bits to be set in the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_id, uint32_t gpregret_msk)); + +/**@brief Clear bits in the general purpose retention registers (NRF_POWER->GPREGRET*). + * + * @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2. + * @param[in] gpregret_msk Bits to be clear in the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_id, uint32_t gpregret_msk)); + +/**@brief Get contents of the general purpose retention registers (NRF_POWER->GPREGRET*). + * + * @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2. + * @param[out] p_gpregret Contents of the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t gpregret_id, uint32_t *p_gpregret)); + +/**@brief Enable or disable the DC/DC regulator. + * + * @param[in] dcdc_mode The mode of the DCDC, see @ref NRF_POWER_DCDC_MODES. + * + * @retval ::NRF_SUCCESS + * @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid. + */ +SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(uint8_t dcdc_mode)); + + +/**@brief Request the high frequency crystal oscillator. + * + * Will start the high frequency crystal oscillator, the startup time of the crystal varies + * and the ::sd_clock_hfclk_is_running function can be polled to check if it has started. + * + * @see sd_clock_hfclk_is_running + * @see sd_clock_hfclk_release + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void)); + +/**@brief Releases the high frequency crystal oscillator. + * + * Will stop the high frequency crystal oscillator, this happens immediately. + * + * @see sd_clock_hfclk_is_running + * @see sd_clock_hfclk_request + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void)); + +/**@brief Checks if the high frequency crystal oscillator is running. + * + * @see sd_clock_hfclk_request + * @see sd_clock_hfclk_release + * + * @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running)); + +/**@brief Waits for an application event. + * + * An application event is either an application interrupt or a pended interrupt when the interrupt + * is disabled. + * + * When the application waits for an application event by calling this function, an interrupt that + * is enabled will be taken immediately on pending since this function will wait in thread mode, + * then the execution will return in the application's main thread. + * + * In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M + * MCU's System Control Register (SCR), CMSIS_SCB. In that case, when a disabled interrupt gets + * pended, this function will return to the application's main thread. + * + * @note The application must ensure that the pended flag is cleared using ::sd_nvic_ClearPendingIRQ + * in order to sleep using this function. This is only necessary for disabled interrupts, as + * the interrupt handler will clear the pending flag automatically for enabled interrupts. + * + * @note If an application interrupt has happened since the last time sd_app_evt_wait was + * called this function will return immediately and not go to sleep. This is to avoid race + * conditions that can occur when a flag is updated in the interrupt handler and processed + * in the main loop. + * + * @post An application interrupt has happened or a interrupt pending flag is set. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void)); + +/**@brief Get PPI channel enable register contents. + * + * @param[out] p_channel_enable The contents of the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable)); + +/**@brief Set PPI channel enable register. + * + * @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk)); + +/**@brief Clear PPI channel enable register. + * + * @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk)); + +/**@brief Assign endpoints to a PPI channel. + * + * @param[in] channel_num Number of the PPI channel to assign. + * @param[in] evt_endpoint Event endpoint of the PPI channel. + * @param[in] task_endpoint Task endpoint of the PPI channel. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint)); + +/**@brief Task to enable a channel group. + * + * @param[in] group_num Number of the channel group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num)); + +/**@brief Task to disable a channel group. + * + * @param[in] group_num Number of the PPI group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num)); + +/**@brief Assign PPI channels to a channel group. + * + * @param[in] group_num Number of the channel group. + * @param[in] channel_msk Mask of the channels to assign to the group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk)); + +/**@brief Gets the PPI channels of a channel group. + * + * @param[in] group_num Number of the channel group. + * @param[out] p_channel_msk Mask of the channels assigned to the group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk)); + +/**@brief Configures the Radio Notification signal. + * + * @note + * - The notification signal latency depends on the interrupt priority settings of SWI used + * for notification signal. + * - To ensure that the radio notification signal behaves in a consistent way, the radio + * notifications must be configured when there is no protocol stack or other SoftDevice + * activity in progress. It is recommended that the radio notification signal is + * configured directly after the SoftDevice has been enabled. + * - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice + * will interrupt the application to do Radio Event preparation. + * - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have + * to shorten the connection events to have time for the Radio Notification signals. + * + * @param[in] type Type of notification signal, see @ref NRF_RADIO_NOTIFICATION_TYPES. + * @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio + * notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is + * recommended (but not required) to be used with + * @ref NRF_RADIO_NOTIFICATION_TYPE_NONE. + * + * @param[in] distance Distance between the notification signal and start of radio activity, see @ref NRF_RADIO_NOTIFICATION_DISTANCES. + * This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or + * @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used. + * + * @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid. + * @retval ::NRF_ERROR_INVALID_STATE A protocol stack or other SoftDevice is running. Stop all + * running activities and retry. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(uint8_t type, uint8_t distance)); + +/**@brief Encrypts a block according to the specified parameters. + * + * 128-bit AES encryption. + * + * @note: + * - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while + * the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application + * main or low interrupt level. + * + * @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input + * parameters and one output parameter). + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data)); + +/**@brief Encrypts multiple data blocks provided as an array of data block structures. + * + * @details: Performs 128-bit AES encryption on multiple data blocks + * + * @note: + * - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while + * the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application + * main or low interrupt level. + * + * @param[in] block_count Count of blocks in the p_data_blocks array. + * @param[in,out] p_data_blocks Pointer to the first entry in a contiguous array of + * @ref nrf_ecb_hal_data_block_t structures. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_ECB_BLOCKS_ENCRYPT, uint32_t, sd_ecb_blocks_encrypt(uint8_t block_count, nrf_ecb_hal_data_block_t * p_data_blocks)); + +/**@brief Gets any pending events generated by the SoC API. + * + * The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned. + * + * @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending. + * + * @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter. + * @retval ::NRF_ERROR_NOT_FOUND No pending events. + */ +SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id)); + +/**@brief Get the temperature measured on the chip + * + * This function will block until the temperature measurement is done. + * It takes around 50 us from call to return. + * + * @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees Celsius. + * + * @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp + */ +SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp)); + +/**@brief Flash Write +* +* Commands to write a buffer to flash +* +* If the SoftDevice is enabled: +* This call initiates the flash access command, and its completion will be communicated to the +* application with exactly one of the following events: +* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed. +* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started. +* +* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the + * write has been completed +* +* @note +* - This call takes control over the radio and the CPU during flash erase and write to make sure that +* they will not interfere with the flash access. This means that all interrupts will be blocked +* for a predictable time (depending on the NVMC specification in the device's Product Specification +* and the command parameters). +* - The data in the p_src buffer should not be modified before the @ref NRF_EVT_FLASH_OPERATION_SUCCESS +* or the @ref NRF_EVT_FLASH_OPERATION_ERROR have been received if the SoftDevice is enabled. +* - This call will make the SoftDevice trigger a hardfault when the page is written, if it is +* protected. +* +* +* @param[in] p_dst Pointer to start of flash location to be written. +* @param[in] p_src Pointer to buffer with data to be written. +* @param[in] size Number of 32-bit words to write. Maximum size is the number of words in one +* flash page. See the device's Product Specification for details. +* +* @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned. +* @retval ::NRF_ERROR_BUSY The previous command has not yet completed. +* @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or higher than the maximum allowed size. +* @retval ::NRF_ERROR_FORBIDDEN Tried to write to an address outside the application flash area. +* @retval ::NRF_SUCCESS The command was accepted. +*/ +SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * p_dst, uint32_t const * p_src, uint32_t size)); + + +/**@brief Flash Erase page +* +* Commands to erase a flash page +* If the SoftDevice is enabled: +* This call initiates the flash access command, and its completion will be communicated to the +* application with exactly one of the following events: +* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed. +* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started. +* +* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the +* erase has been completed +* +* @note +* - This call takes control over the radio and the CPU during flash erase and write to make sure that +* they will not interfere with the flash access. This means that all interrupts will be blocked +* for a predictable time (depending on the NVMC specification in the device's Product Specification +* and the command parameters). +* - This call will make the SoftDevice trigger a hardfault when the page is erased, if it is +* protected. +* +* +* @param[in] page_number Page number of the page to erase +* +* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error. +* @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page. +* @retval ::NRF_ERROR_BUSY The previous command has not yet completed. +* @retval ::NRF_ERROR_FORBIDDEN Tried to erase a page outside the application flash area. +* @retval ::NRF_SUCCESS The command was accepted. +*/ +SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number)); + + +/**@brief Flash Protection set + * + * Commands to set the flash protection configuration registers. + This sets the CONFIGx registers of the BPROT peripheral. + * + * @note Not all parameters are valid for all products. Some bits in each parameter may not be + * valid for your product. Please refer your Product Specification for more details. + * + * @note To read the values read them directly. They are only write-protected. + * + * @note It is possible to use @ref sd_protected_register_write instead of this function. + * + * @param[in] block_cfg0 Value to be written to the configuration register. + * @param[in] block_cfg1 Value to be written to the configuration register. + * @param[in] block_cfg2 Value to be written to the configuration register. + * @param[in] block_cfg3 Value to be written to the configuration register. + * + * @retval ::NRF_ERROR_NOT_SUPPORTED Non-zero value supplied to one or more of the unsupported parameters. + * @retval ::NRF_SUCCESS Values successfully written to configuration registers. + */ +SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_t block_cfg1, uint32_t block_cfg2, uint32_t block_cfg3)); + +/**@brief Opens a session for radio timeslot requests. + * + * @note Only one session can be open at a time. + * @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot + * starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed + * by the application. + * @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0 + * interrupt occurs. + * @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO + * interrupt occurs. + * @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This + * implies that none of the sd_* API calls can be used from p_radio_signal_callback(). + * + * @param[in] p_radio_signal_callback The signal callback. + * + * @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer. + * @retval ::NRF_ERROR_BUSY If session cannot be opened. + * @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error. + * @retval ::NRF_SUCCESS Otherwise. + */ + SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback)); + +/**@brief Closes a session for radio timeslot requests. + * + * @note Any current radio timeslot will be finished before the session is closed. + * @note If a radio timeslot is scheduled when the session is closed, it will be canceled. + * @note The application cannot consider the session closed until the @ref NRF_EVT_RADIO_SESSION_CLOSED + * event is received. + * + * @retval ::NRF_ERROR_FORBIDDEN If session not opened. + * @retval ::NRF_ERROR_BUSY If session is currently being closed. + * @retval ::NRF_SUCCESS Otherwise. + */ + SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void)); + +/**@brief Requests a radio timeslot. + * + * @note The request type is determined by p_request->request_type, and can be one of @ref NRF_RADIO_REQ_TYPE_EARLIEST + * and @ref NRF_RADIO_REQ_TYPE_NORMAL. The first request in a session must always be of type @ref NRF_RADIO_REQ_TYPE_EARLIEST. + * @note For a normal request (@ref NRF_RADIO_REQ_TYPE_NORMAL), the start time of a radio timeslot is specified by + * p_request->distance_us and is given relative to the start of the previous timeslot. + * @note A too small p_request->distance_us will lead to a @ref NRF_EVT_RADIO_BLOCKED event. + * @note Timeslots scheduled too close will lead to a @ref NRF_EVT_RADIO_BLOCKED event. + * @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths. + * @note If an opportunity for the first radio timeslot is not found before 100 ms after the call to this + * function, it is not scheduled, and instead a @ref NRF_EVT_RADIO_BLOCKED event is sent. + * The application may then try to schedule the first radio timeslot again. + * @note Successful requests will result in nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START). + * Unsuccessful requests will result in a @ref NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS. + * @note The jitter in the start time of the radio timeslots is +/- @ref NRF_RADIO_START_JITTER_US us. + * @note The nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the + * specified radio timeslot start, but this does not affect the actual start time of the timeslot. + * @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency + * (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is + * guaranteed to be clocked from the external crystal. + * @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral + * during the radio timeslot. + * + * @param[in] p_request Pointer to the request parameters. + * + * @retval ::NRF_ERROR_FORBIDDEN Either: + * - The session is not open. + * - The session is not IDLE. + * - This is the first request and its type is not @ref NRF_RADIO_REQ_TYPE_EARLIEST. + * - The request type was set to @ref NRF_RADIO_REQ_TYPE_NORMAL after a + * @ref NRF_RADIO_REQ_TYPE_EARLIEST request was blocked. + * @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid. + * @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid. + * @retval ::NRF_SUCCESS Otherwise. + */ + SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t const * p_request)); + +/**@brief Write register protected by the SoftDevice + * + * This function writes to a register that is write-protected by the SoftDevice. Please refer to your + * SoftDevice Specification for more details about which registers that are protected by SoftDevice. + * This function can write to the following protected peripheral: + * - BPROT + * + * @note Protected registers may be read directly. + * @note Register that are write-once will return @ref NRF_SUCCESS on second set, even the value in + * the register has not changed. See the Product Specification for more details about register + * properties. + * + * @param[in] p_register Pointer to register to be written. + * @param[in] value Value to be written to the register. + * + * @retval ::NRF_ERROR_INVALID_ADDR This function can not write to the reguested register. + * @retval ::NRF_SUCCESS Value successfully written to register. + * + */ +SVCALL(SD_PROTECTED_REGISTER_WRITE, uint32_t, sd_protected_register_write(volatile uint32_t * p_register, uint32_t value)); + +/**@} */ + +#ifdef __cplusplus +} +#endif +#endif // NRF_SOC_H__ + +/**@} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_svc.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_svc.h new file mode 100644 index 000000000..231a54f94 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/nrf_svc.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2012 - 2019, Nordic Semiconductor ASA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NRF_SVC__ +#define NRF_SVC__ + +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Supervisor call declaration. + * + * A call to a function marked with @ref SVCALL, will trigger a Supervisor Call (SVC) Exception. + * The SVCs with SVC numbers 0x00-0x0F are forwared to the application. All other SVCs are handled by the SoftDevice. + * + * @param[in] number The SVC number to be used. + * @param[in] return_type The return type of the SVC function. + * @param[in] signature Function signature. The function can have at most four arguments. + */ + +#ifdef SVCALL_AS_NORMAL_FUNCTION +#define SVCALL(number, return_type, signature) return_type signature +#else + +#ifndef SVCALL +#if defined (__CC_ARM) +#define SVCALL(number, return_type, signature) return_type __svc(number) signature +#elif defined (__GNUC__) +#ifdef __cplusplus +#define GCC_CAST_CPP (uint16_t) +#else +#define GCC_CAST_CPP +#endif +#define SVCALL(number, return_type, signature) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ + __attribute__((naked)) \ + __attribute__((unused)) \ + static return_type signature \ + { \ + __asm( \ + "svc %0\n" \ + "bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \ + ); \ + } \ + _Pragma("GCC diagnostic pop") + +#elif defined (__ICCARM__) +#define PRAGMA(x) _Pragma(#x) +#define SVCALL(number, return_type, signature) \ +PRAGMA(swi_number = (number)) \ + __swi return_type signature; +#else +#define SVCALL(number, return_type, signature) return_type signature +#endif +#endif // SVCALL + +#endif // SVCALL_AS_NORMAL_FUNCTION + +#ifdef __cplusplus +} +#endif +#endif // NRF_SVC__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h new file mode 100644 index 000000000..01c330dd0 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h @@ -0,0 +1,12897 @@ +/** + * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef SDK_CONFIG_H +#define SDK_CONFIG_H +// <<< Use Configuration Wizard in Context Menu >>>\n +#ifdef USE_APP_CONFIG +#include "app_config.h" +#endif +// nRF_ANT + +//========================================================== +// ANTFS_ENABLED - ant_fs - ANT File Share module. +//========================================================== +#ifndef ANTFS_ENABLED +#define ANTFS_ENABLED 0 +#endif +// ANTFS_CONFIG_NETWORK_NUMBER - ANT-FS network number. +#ifndef ANTFS_CONFIG_NETWORK_NUMBER +#define ANTFS_CONFIG_NETWORK_NUMBER 0 +#endif + +// ANTFS_CONFIG_CHANNEL_NUMBER - ANT-FS channel number. +#ifndef ANTFS_CONFIG_CHANNEL_NUMBER +#define ANTFS_CONFIG_CHANNEL_NUMBER 0 +#endif + +// ANTFS_CONFIG_PAIRING_TIMEOUT - Pairing timeout - how long the UI will wait for a response to a pairing request before switching to the link layer, in seconds. +#ifndef ANTFS_CONFIG_PAIRING_TIMEOUT +#define ANTFS_CONFIG_PAIRING_TIMEOUT 120 +#endif + +// ANTFS_CONFIG_LINK_COMMAND_TIMEOUT - Command timeout - how long the client will wait without receiving any commands before switching to the link layer, in seconds. +#ifndef ANTFS_CONFIG_LINK_COMMAND_TIMEOUT +#define ANTFS_CONFIG_LINK_COMMAND_TIMEOUT 10 +#endif + +// ANTFS_CONFIG_TRANS_TYPE - ANT-FS Transmission Type. +#ifndef ANTFS_CONFIG_TRANS_TYPE +#define ANTFS_CONFIG_TRANS_TYPE 10 +#endif + +// ANTFS_CONFIG_DEVICE_TYPE - ANT device type for channel configuration. +#ifndef ANTFS_CONFIG_DEVICE_TYPE +#define ANTFS_CONFIG_DEVICE_TYPE 1 +#endif + +// ANTFS_CONFIG_BEACON_STATUS_PERIOD - ANT-FS Beacon Message Period. + +// <0=> 0.5 Hz +// <1=> 1 Hz +// <2=> 2 Hz +// <3=> 4 Hz +// <4=> 8 Hz + +#ifndef ANTFS_CONFIG_BEACON_STATUS_PERIOD +#define ANTFS_CONFIG_BEACON_STATUS_PERIOD 3 +#endif + +// ANTFS_CONFIG_TRANSMIT_POWER - ANT Transmit Power. + +// <0=> Lowest ANT Tx power level setting. (-20dBm) +// <1=> ANT Tx power > Lvl 0. (-12dBm) +// <2=> ANT Tx power > Lvl 1. (-4dBm) +// <3=> ANT Tx power > Lvl 2. Default tx power level. (0dBm) +// <4=> ANT Tx power > Lvl 3. (+4dBm) +// <128=> Custom tx power selection + +#ifndef ANTFS_CONFIG_TRANSMIT_POWER +#define ANTFS_CONFIG_TRANSMIT_POWER 3 +#endif + +// ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER - ANT Custom Transmit Power. +#ifndef ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER +#define ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER 0 +#endif + +// ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED - Use pairing and key exchange authentication. + + +#ifndef ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED +#define ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED 0 +#endif + +// ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED - Use passkey authentication. + + +#ifndef ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED +#define ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED 0 +#endif + +// ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED - Allow host to bypass authentication. + + +#ifndef ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED +#define ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED 0 +#endif + +// ANTFS_CONFIG_UPLOAD_ENABLED - Support upload operation. + + +#ifndef ANTFS_CONFIG_UPLOAD_ENABLED +#define ANTFS_CONFIG_UPLOAD_ENABLED 0 +#endif + +// ANTFS_CONFIG_DEBUG_LED_ENABLED - Enables LED debug in the module. + + +#ifndef ANTFS_CONFIG_DEBUG_LED_ENABLED +#define ANTFS_CONFIG_DEBUG_LED_ENABLED 0 +#endif + +// + +// ANT_BPWR_ENABLED - ant_bpwr - Bicycle Power Profile +//========================================================== +#ifndef ANT_BPWR_ENABLED +#define ANT_BPWR_ENABLED 0 +#endif +// ANT_BPWR_LOG_ENABLED - Enables general logging in the module. +//========================================================== +#ifndef ANT_BPWR_LOG_ENABLED +#define ANT_BPWR_LOG_ENABLED 0 +#endif +// ANT_BPWR_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_LOG_LEVEL +#define ANT_BPWR_LOG_LEVEL 3 +#endif + +// ANT_BPWR_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BPWR_INFO_COLOR +#define ANT_BPWR_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_COMMON_LOG_ENABLED - Enables logging of BPWR tracing common data. +//========================================================== +#ifndef ANT_BPWR_COMMON_LOG_ENABLED +#define ANT_BPWR_COMMON_LOG_ENABLED 0 +#endif +// ANT_BPWR_COMMON_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_COMMON_LOG_LEVEL +#define ANT_BPWR_COMMON_LOG_LEVEL 3 +#endif + +// ANT_BPWR_COMMON_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BPWR_COMMON_INFO_COLOR +#define ANT_BPWR_COMMON_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_TORQUE_LOG_ENABLED - Enables logging of BPWR torque page in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_TORQUE_LOG_ENABLED +#define ANT_BPWR_PAGE_TORQUE_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_TORQUE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_TORQUE_LOG_LEVEL +#define ANT_BPWR_PAGE_TORQUE_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_TORQUE_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BPWR_PAGE_TORQUE_INFO_COLOR +#define ANT_BPWR_PAGE_TORQUE_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_1_LOG_ENABLED - Enables logging of BPWR page 1 in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_1_LOG_ENABLED +#define ANT_BPWR_PAGE_1_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_1_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_1_LOG_LEVEL +#define ANT_BPWR_PAGE_1_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_1_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BPWR_PAGE_1_INFO_COLOR +#define ANT_BPWR_PAGE_1_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_16_LOG_ENABLED - Enables logging of BPWR page 16 in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_16_LOG_ENABLED +#define ANT_BPWR_PAGE_16_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_16_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_16_LOG_LEVEL +#define ANT_BPWR_PAGE_16_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_16_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BPWR_PAGE_16_INFO_COLOR +#define ANT_BPWR_PAGE_16_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_17_LOG_ENABLED - Enables logging of BPWR page 17 in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_17_LOG_ENABLED +#define ANT_BPWR_PAGE_17_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_17_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_17_LOG_LEVEL +#define ANT_BPWR_PAGE_17_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_17_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BPWR_PAGE_17_INFO_COLOR +#define ANT_BPWR_PAGE_17_INFO_COLOR 0 +#endif + +// + +// ANT_BPWR_PAGE_18_LOG_ENABLED - Enables logging of BPWR page 18 in the module. +//========================================================== +#ifndef ANT_BPWR_PAGE_18_LOG_ENABLED +#define ANT_BPWR_PAGE_18_LOG_ENABLED 0 +#endif +// ANT_BPWR_PAGE_18_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BPWR_PAGE_18_LOG_LEVEL +#define ANT_BPWR_PAGE_18_LOG_LEVEL 3 +#endif + +// ANT_BPWR_PAGE_18_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BPWR_PAGE_18_INFO_COLOR +#define ANT_BPWR_PAGE_18_INFO_COLOR 0 +#endif + +// + +// + +// ANT_BSC_ENABLED - ant_bsc - Bicycle Speed and Cadence Profile +//========================================================== +#ifndef ANT_BSC_ENABLED +#define ANT_BSC_ENABLED 0 +#endif +// ANT_BSC_LOG_ENABLED - Enables general logging in the module. +//========================================================== +#ifndef ANT_BSC_LOG_ENABLED +#define ANT_BSC_LOG_ENABLED 0 +#endif +// ANT_BSC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_LOG_LEVEL +#define ANT_BSC_LOG_LEVEL 3 +#endif + +// ANT_BSC_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BSC_INFO_COLOR +#define ANT_BSC_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED - Enables logging of BSC Combined page 0 in the module. +//========================================================== +#ifndef ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED +#define ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED 0 +#endif +// ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL +#define ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL 3 +#endif + +// ANT_BSC_COMBINED_PAGE_0_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BSC_COMBINED_PAGE_0_INFO_COLOR +#define ANT_BSC_COMBINED_PAGE_0_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_0_LOG_ENABLED - Enables logging of BSC page 0 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_0_LOG_ENABLED +#define ANT_BSC_PAGE_0_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_0_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_0_LOG_LEVEL +#define ANT_BSC_PAGE_0_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_0_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BSC_PAGE_0_INFO_COLOR +#define ANT_BSC_PAGE_0_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_1_LOG_ENABLED - Enables logging of BSC page 1 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_1_LOG_ENABLED +#define ANT_BSC_PAGE_1_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_1_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_1_LOG_LEVEL +#define ANT_BSC_PAGE_1_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_1_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BSC_PAGE_1_INFO_COLOR +#define ANT_BSC_PAGE_1_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_2_LOG_ENABLED - Enables logging of BSC page 2 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_2_LOG_ENABLED +#define ANT_BSC_PAGE_2_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_2_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_2_LOG_LEVEL +#define ANT_BSC_PAGE_2_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_2_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BSC_PAGE_2_INFO_COLOR +#define ANT_BSC_PAGE_2_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_3_LOG_ENABLED - Enables logging of BSC page 3 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_3_LOG_ENABLED +#define ANT_BSC_PAGE_3_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_3_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_3_LOG_LEVEL +#define ANT_BSC_PAGE_3_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_3_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BSC_PAGE_3_INFO_COLOR +#define ANT_BSC_PAGE_3_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_4_LOG_ENABLED - Enables logging of BSC page 4 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_4_LOG_ENABLED +#define ANT_BSC_PAGE_4_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_4_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_4_LOG_LEVEL +#define ANT_BSC_PAGE_4_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_4_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BSC_PAGE_4_INFO_COLOR +#define ANT_BSC_PAGE_4_INFO_COLOR 0 +#endif + +// + +// ANT_BSC_PAGE_5_LOG_ENABLED - Enables logging of BSC page 5 in the module. +//========================================================== +#ifndef ANT_BSC_PAGE_5_LOG_ENABLED +#define ANT_BSC_PAGE_5_LOG_ENABLED 0 +#endif +// ANT_BSC_PAGE_5_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_BSC_PAGE_5_LOG_LEVEL +#define ANT_BSC_PAGE_5_LOG_LEVEL 3 +#endif + +// ANT_BSC_PAGE_5_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_BSC_PAGE_5_INFO_COLOR +#define ANT_BSC_PAGE_5_INFO_COLOR 0 +#endif + +// + +// + +// ANT_CHANNEL_CONFIG_ENABLED - ant_channel_config - ANT common channel configuration + + +#ifndef ANT_CHANNEL_CONFIG_ENABLED +#define ANT_CHANNEL_CONFIG_ENABLED 0 +#endif + +// ANT_COMMON_PAGE_70_ENABLED - ant_common_page_70 - ANT+ common page 70 +//========================================================== +#ifndef ANT_COMMON_PAGE_70_ENABLED +#define ANT_COMMON_PAGE_70_ENABLED 0 +#endif +// ANT_COMMON_PAGE_70_LOG_ENABLED - Enables logging of common page 70 in the module. +//========================================================== +#ifndef ANT_COMMON_PAGE_70_LOG_ENABLED +#define ANT_COMMON_PAGE_70_LOG_ENABLED 0 +#endif +// ANT_COMMON_PAGE_70_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_COMMON_PAGE_70_LOG_LEVEL +#define ANT_COMMON_PAGE_70_LOG_LEVEL 3 +#endif + +// ANT_COMMON_PAGE_70_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_COMMON_PAGE_70_INFO_COLOR +#define ANT_COMMON_PAGE_70_INFO_COLOR 0 +#endif + +// + +// + +// ANT_COMMON_PAGE_80_ENABLED - ant_common_page_80 - ANT+ common page 80 +//========================================================== +#ifndef ANT_COMMON_PAGE_80_ENABLED +#define ANT_COMMON_PAGE_80_ENABLED 0 +#endif +// ANT_COMMON_PAGE_80_LOG_ENABLED - Enables logging of common page 80 in the module. +//========================================================== +#ifndef ANT_COMMON_PAGE_80_LOG_ENABLED +#define ANT_COMMON_PAGE_80_LOG_ENABLED 0 +#endif +// ANT_COMMON_PAGE_80_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_COMMON_PAGE_80_LOG_LEVEL +#define ANT_COMMON_PAGE_80_LOG_LEVEL 3 +#endif + +// ANT_COMMON_PAGE_80_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_COMMON_PAGE_80_INFO_COLOR +#define ANT_COMMON_PAGE_80_INFO_COLOR 0 +#endif + +// + +// + +// ANT_COMMON_PAGE_81_ENABLED - ant_common_page_81 - ANT+ common page 81 +//========================================================== +#ifndef ANT_COMMON_PAGE_81_ENABLED +#define ANT_COMMON_PAGE_81_ENABLED 0 +#endif +// ANT_COMMON_PAGE_81_LOG_ENABLED - Enables logging of common page 81 in the module. +//========================================================== +#ifndef ANT_COMMON_PAGE_81_LOG_ENABLED +#define ANT_COMMON_PAGE_81_LOG_ENABLED 0 +#endif +// ANT_COMMON_PAGE_81_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_COMMON_PAGE_81_LOG_LEVEL +#define ANT_COMMON_PAGE_81_LOG_LEVEL 3 +#endif + +// ANT_COMMON_PAGE_81_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_COMMON_PAGE_81_INFO_COLOR +#define ANT_COMMON_PAGE_81_INFO_COLOR 0 +#endif + +// + +// + +// ANT_ENCRYPT_CONFIG_ENABLED - ant_encrypt_config - Cryptographic ANT stack configuration + + +#ifndef ANT_ENCRYPT_CONFIG_ENABLED +#define ANT_ENCRYPT_CONFIG_ENABLED 0 +#endif + +// ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED - ant_encrypt_negotiation_slave - Encryption negotiation for encrypted ANT slave channels + + +#ifndef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED +#define ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED 0 +#endif + +// ANT_HRM_ENABLED - ant_hrm - Heart Rate Monitor Profile +//========================================================== +#ifndef ANT_HRM_ENABLED +#define ANT_HRM_ENABLED 0 +#endif +// ANT_HRM_LOG_ENABLED - Enables general logging in the module. +//========================================================== +#ifndef ANT_HRM_LOG_ENABLED +#define ANT_HRM_LOG_ENABLED 0 +#endif +// ANT_HRM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_LOG_LEVEL +#define ANT_HRM_LOG_LEVEL 3 +#endif + +// ANT_HRM_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_HRM_INFO_COLOR +#define ANT_HRM_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_0_LOG_ENABLED - Enables logging of HRM page 0 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_0_LOG_ENABLED +#define ANT_HRM_PAGE_0_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_0_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_0_LOG_LEVEL +#define ANT_HRM_PAGE_0_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_0_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_HRM_PAGE_0_INFO_COLOR +#define ANT_HRM_PAGE_0_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_1_LOG_ENABLED - Enables logging of HRM page 1 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_1_LOG_ENABLED +#define ANT_HRM_PAGE_1_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_1_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_1_LOG_LEVEL +#define ANT_HRM_PAGE_1_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_1_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_HRM_PAGE_1_INFO_COLOR +#define ANT_HRM_PAGE_1_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_2_LOG_ENABLED - Enables logging of HRM page 2 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_2_LOG_ENABLED +#define ANT_HRM_PAGE_2_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_2_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_2_LOG_LEVEL +#define ANT_HRM_PAGE_2_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_2_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_HRM_PAGE_2_INFO_COLOR +#define ANT_HRM_PAGE_2_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_3_LOG_ENABLED - Enables logging of HRM page 3 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_3_LOG_ENABLED +#define ANT_HRM_PAGE_3_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_3_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_3_LOG_LEVEL +#define ANT_HRM_PAGE_3_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_3_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_HRM_PAGE_3_INFO_COLOR +#define ANT_HRM_PAGE_3_INFO_COLOR 0 +#endif + +// + +// ANT_HRM_PAGE_4_LOG_ENABLED - Enables logging of HRM page 4 in the module. +//========================================================== +#ifndef ANT_HRM_PAGE_4_LOG_ENABLED +#define ANT_HRM_PAGE_4_LOG_ENABLED 0 +#endif +// ANT_HRM_PAGE_4_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_HRM_PAGE_4_LOG_LEVEL +#define ANT_HRM_PAGE_4_LOG_LEVEL 3 +#endif + +// ANT_HRM_PAGE_4_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_HRM_PAGE_4_INFO_COLOR +#define ANT_HRM_PAGE_4_INFO_COLOR 0 +#endif + +// + +// + +// ANT_KEY_MANAGER_ENABLED - ant_key_manager - Software Component + + +#ifndef ANT_KEY_MANAGER_ENABLED +#define ANT_KEY_MANAGER_ENABLED 0 +#endif + +// ANT_REQUEST_CONTROLLER_ENABLED - ant_request_controller - ANT+ request controller + + +#ifndef ANT_REQUEST_CONTROLLER_ENABLED +#define ANT_REQUEST_CONTROLLER_ENABLED 0 +#endif + +// ANT_SDM_ENABLED - ant_sdm - Stride Based Speed and Distance Monitor Profile +//========================================================== +#ifndef ANT_SDM_ENABLED +#define ANT_SDM_ENABLED 0 +#endif +// ANT_SDM_LOG_ENABLED - Enables general logging in the module. +//========================================================== +#ifndef ANT_SDM_LOG_ENABLED +#define ANT_SDM_LOG_ENABLED 0 +#endif +// ANT_SDM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef ANT_SDM_LOG_LEVEL +#define ANT_SDM_LOG_LEVEL 3 +#endif + +// ANT_SDM_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef ANT_SDM_INFO_COLOR +#define ANT_SDM_INFO_COLOR 0 +#endif + +// + +// + +// ANT_SEARCH_CONFIG_ENABLED - ant_search_config - ANT common search configuration +//========================================================== +#ifndef ANT_SEARCH_CONFIG_ENABLED +#define ANT_SEARCH_CONFIG_ENABLED 0 +#endif +// ANT_DEFAULT_LOW_PRIORITY_TIMEOUT - Default low priority search time-out. <0-255> + + +#ifndef ANT_DEFAULT_LOW_PRIORITY_TIMEOUT +#define ANT_DEFAULT_LOW_PRIORITY_TIMEOUT 2 +#endif + +// ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT - Default high priority search time-out. <0-255> + + +#ifndef ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT +#define ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT 10 +#endif + +// + +// ANT_STATE_INDICATOR_ENABLED - ant_state_indicator - ANT state indicator using BSP +//========================================================== +#ifndef ANT_STATE_INDICATOR_ENABLED +#define ANT_STATE_INDICATOR_ENABLED 0 +#endif +// ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY - Shutdown observer priority. +#ifndef ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY +#define ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY 1 +#endif + +// + +// +//========================================================== + +// nRF_BLE + +//========================================================== +// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module + + +#ifndef BLE_ADVERTISING_ENABLED +#define BLE_ADVERTISING_ENABLED 0 +#endif + +// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands +//========================================================== +#ifndef BLE_DTM_ENABLED +#define BLE_DTM_ENABLED 0 +#endif +// NRF_RADIO_ANTENNA_PIN_1 - Antenna 1 GPIO pin +#ifndef NRF_RADIO_ANTENNA_PIN_1 +#define NRF_RADIO_ANTENNA_PIN_1 21 +#endif + +// NRF_RADIO_ANTENNA_PIN_2 - Antenna 2 GPIO pin +#ifndef NRF_RADIO_ANTENNA_PIN_2 +#define NRF_RADIO_ANTENNA_PIN_2 23 +#endif + +// NRF_RADIO_ANTENNA_PIN_3 - Antenna 3 GPIO pin +#ifndef NRF_RADIO_ANTENNA_PIN_3 +#define NRF_RADIO_ANTENNA_PIN_3 26 +#endif + +// NRF_RADIO_ANTENNA_PIN_4 - Antenna 4 GPIO pin +#ifndef NRF_RADIO_ANTENNA_PIN_4 +#define NRF_RADIO_ANTENNA_PIN_4 27 +#endif + +// NRF_RADIO_ANTENNA_PIN_5 - Antenna 5 GPIO pin +#ifndef NRF_RADIO_ANTENNA_PIN_5 +#define NRF_RADIO_ANTENNA_PIN_5 28 +#endif + +// NRF_RADIO_ANTENNA_PIN_6 - Antenna 6 GPIO pin +#ifndef NRF_RADIO_ANTENNA_PIN_6 +#define NRF_RADIO_ANTENNA_PIN_6 29 +#endif + +// NRF_RADIO_ANTENNA_PIN_7 - Antenna 7 GPIO pin +#ifndef NRF_RADIO_ANTENNA_PIN_7 +#define NRF_RADIO_ANTENNA_PIN_7 30 +#endif + +// NRF_RADIO_ANTENNA_PIN_8 - Antenna 8 GPIO pin +#ifndef NRF_RADIO_ANTENNA_PIN_8 +#define NRF_RADIO_ANTENNA_PIN_8 31 +#endif + +// NRF_RADIO_ANTENNA_COUNT +#ifndef NRF_RADIO_ANTENNA_COUNT +#define NRF_RADIO_ANTENNA_COUNT 12 +#endif + +// DTM_RADIO_IRQ_PRIORITY - RADIO interrupt priority +#ifndef DTM_RADIO_IRQ_PRIORITY +#define DTM_RADIO_IRQ_PRIORITY 2 +#endif + +// DTM_TIMER_IRQ_PRIORITY - DTM timer interrupt priority +#ifndef DTM_TIMER_IRQ_PRIORITY +#define DTM_TIMER_IRQ_PRIORITY 3 +#endif + +// DTM_ANOMALY_172_TIMER_IRQ_PRIORITY - DTM anomaly 172 timer interrupt priority +#ifndef DTM_ANOMALY_172_TIMER_IRQ_PRIORITY +#define DTM_ANOMALY_172_TIMER_IRQ_PRIORITY 2 +#endif + +// NRF_DTM_TIMER_INSTANCE - DTM TIMER instance + +// <0=> TIMER0 +// <2=> TIMER2 +// <3=> TIMER3 +// <4=> TIMER4 + +#ifndef NRF_DTM_TIMER_INSTANCE +#define NRF_DTM_TIMER_INSTANCE 0 +#endif + +// + +// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library + + +#ifndef BLE_RACP_ENABLED +#define BLE_RACP_ENABLED 0 +#endif + +// NRF_BLE_QWR_ENABLED - nrf_ble_qwr - Queued writes support module (prepare/execute write) +//========================================================== +#ifndef NRF_BLE_QWR_ENABLED +#define NRF_BLE_QWR_ENABLED 0 +#endif +// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. +#ifndef NRF_BLE_QWR_MAX_ATTR +#define NRF_BLE_QWR_MAX_ATTR 0 +#endif + +// + +// PEER_MANAGER_ENABLED - peer_manager - Peer Manager +//========================================================== +#ifndef PEER_MANAGER_ENABLED +#define PEER_MANAGER_ENABLED 0 +#endif +// PM_MAX_REGISTRANTS - Number of event handlers that can be registered. +#ifndef PM_MAX_REGISTRANTS +#define PM_MAX_REGISTRANTS 3 +#endif + +// PM_FLASH_BUFFERS - Number of internal buffers for flash operations. +// Decrease this value to lower RAM usage. + +#ifndef PM_FLASH_BUFFERS +#define PM_FLASH_BUFFERS 4 +#endif + +// PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. + + +// Enable/disable central-specific Peer Manager functionality. + +#ifndef PM_CENTRAL_ENABLED +#define PM_CENTRAL_ENABLED 1 +#endif + +// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. + + +// If not using a GATT server, or using a server wihout a service changed characteristic, +// disable this to save code space. + +#ifndef PM_SERVICE_CHANGED_ENABLED +#define PM_SERVICE_CHANGED_ENABLED 1 +#endif + +// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. + + +// Set this to false to save code space if not using the peer rank API. + +#ifndef PM_PEER_RANKS_ENABLED +#define PM_PEER_RANKS_ENABLED 1 +#endif + +// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. + + +// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. + +#ifndef PM_LESC_ENABLED +#define PM_LESC_ENABLED 0 +#endif + +// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. +//========================================================== +#ifndef PM_RA_PROTECTION_ENABLED +#define PM_RA_PROTECTION_ENABLED 0 +#endif +// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. +#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM +#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 +#endif + +// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL +#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 +#endif + +// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL +#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 +#endif + +// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). +// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. + +#ifndef PM_RA_PROTECTION_REWARD_PERIOD +#define PM_RA_PROTECTION_REWARD_PERIOD 10000 +#endif + +// + +// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. +// This might be necessary for interoperability reasons, especially as peripheral. + +#ifndef PM_HANDLER_SEC_DELAY_MS +#define PM_HANDLER_SEC_DELAY_MS 0 +#endif + +// + +// +//========================================================== + +// nRF_BLE_Services + +//========================================================== +// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client + + +#ifndef BLE_ANCS_C_ENABLED +#define BLE_ANCS_C_ENABLED 0 +#endif + +// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client + + +#ifndef BLE_ANS_C_ENABLED +#define BLE_ANS_C_ENABLED 0 +#endif + +// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client + + +#ifndef BLE_BAS_C_ENABLED +#define BLE_BAS_C_ENABLED 0 +#endif + +// BLE_BAS_ENABLED - ble_bas - Battery Service +//========================================================== +#ifndef BLE_BAS_ENABLED +#define BLE_BAS_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_BAS_CONFIG_LOG_ENABLED +#define BLE_BAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_BAS_CONFIG_LOG_LEVEL +#define BLE_BAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_BAS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_BAS_CONFIG_INFO_COLOR +#define BLE_BAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_BAS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_BAS_CONFIG_DEBUG_COLOR +#define BLE_BAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service + + +#ifndef BLE_CSCS_ENABLED +#define BLE_CSCS_ENABLED 0 +#endif + +// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client + + +#ifndef BLE_CTS_C_ENABLED +#define BLE_CTS_C_ENABLED 0 +#endif + +// BLE_DIS_ENABLED - ble_dis - Device Information Service + + +#ifndef BLE_DIS_ENABLED +#define BLE_DIS_ENABLED 0 +#endif + +// BLE_GLS_ENABLED - ble_gls - Glucose Service + + +#ifndef BLE_GLS_ENABLED +#define BLE_GLS_ENABLED 0 +#endif + +// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service + + +#ifndef BLE_HIDS_ENABLED +#define BLE_HIDS_ENABLED 0 +#endif + +// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client + + +#ifndef BLE_HRS_C_ENABLED +#define BLE_HRS_C_ENABLED 0 +#endif + +// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service + + +#ifndef BLE_HRS_ENABLED +#define BLE_HRS_ENABLED 0 +#endif + +// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service + + +#ifndef BLE_HTS_ENABLED +#define BLE_HTS_ENABLED 0 +#endif + +// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client + + +#ifndef BLE_IAS_C_ENABLED +#define BLE_IAS_C_ENABLED 0 +#endif + +// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +//========================================================== +#ifndef BLE_IAS_ENABLED +#define BLE_IAS_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_IAS_CONFIG_LOG_ENABLED +#define BLE_IAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_IAS_CONFIG_LOG_LEVEL +#define BLE_IAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_IAS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_IAS_CONFIG_INFO_COLOR +#define BLE_IAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_IAS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_IAS_CONFIG_DEBUG_COLOR +#define BLE_IAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client + + +#ifndef BLE_LBS_C_ENABLED +#define BLE_LBS_C_ENABLED 0 +#endif + +// BLE_LBS_ENABLED - ble_lbs - LED Button Service + + +#ifndef BLE_LBS_ENABLED +#define BLE_LBS_ENABLED 0 +#endif + +// BLE_LLS_ENABLED - ble_lls - Link Loss Service + + +#ifndef BLE_LLS_ENABLED +#define BLE_LLS_ENABLED 0 +#endif + +// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service + + +#ifndef BLE_NUS_C_ENABLED +#define BLE_NUS_C_ENABLED 0 +#endif + +// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +//========================================================== +#ifndef BLE_NUS_ENABLED +#define BLE_NUS_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_NUS_CONFIG_LOG_ENABLED +#define BLE_NUS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_NUS_CONFIG_LOG_LEVEL +#define BLE_NUS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_NUS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_NUS_CONFIG_INFO_COLOR +#define BLE_NUS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_NUS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_NUS_CONFIG_DEBUG_COLOR +#define BLE_NUS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client + + +#ifndef BLE_RSCS_C_ENABLED +#define BLE_RSCS_C_ENABLED 0 +#endif + +// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service + + +#ifndef BLE_RSCS_ENABLED +#define BLE_RSCS_ENABLED 0 +#endif + +// BLE_TPS_ENABLED - ble_tps - TX Power Service + + +#ifndef BLE_TPS_ENABLED +#define BLE_TPS_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Core + +//========================================================== +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 0 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. + +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes + +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 +#endif + +// + +// +//========================================================== + +// nRF_Crypto + +//========================================================== +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 1 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator + + +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. + + +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation + + +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. + + +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality + + +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 + + +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + + +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. + + +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + + +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + + +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + + +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve + + +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + + +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + + +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + + +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + + +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + + +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 +#endif + +// + +// +//========================================================== + +// nRF_DFU + +//========================================================== +// ble_dfu - Device Firmware Update + +//========================================================== +// BLE_DFU_ENABLED - Enable DFU Service. + + +#ifndef BLE_DFU_ENABLED +#define BLE_DFU_ENABLED 0 +#endif + +// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. + + +#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS +#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef COMP_CONFIG_REF +#define COMP_CONFIG_REF 1 +#endif + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef COMP_CONFIG_SPEED_MODE +#define COMP_CONFIG_SPEED_MODE 2 +#endif + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef COMP_CONFIG_ISOURCE +#define COMP_CONFIG_ISOURCE 0 +#endif + +// COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef COMP_CONFIG_INPUT +#define COMP_CONFIG_INPUT 0 +#endif + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef COMP_CONFIG_IRQ_PRIORITY +#define COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 0 +#endif +// GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef GPIOTE_CONFIG_IRQ_PRIORITY +#define GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// I2S_CONFIG_MCK_SETUP - MCK behavior + +// <0=> Disabled +// <2147483648=> 32MHz/2 +// <1342177280=> 32MHz/3 +// <1073741824=> 32MHz/4 +// <805306368=> 32MHz/5 +// <671088640=> 32MHz/6 +// <536870912=> 32MHz/8 +// <402653184=> 32MHz/10 +// <369098752=> 32MHz/11 +// <285212672=> 32MHz/15 +// <268435456=> 32MHz/16 +// <201326592=> 32MHz/21 +// <184549376=> 32MHz/23 +// <142606336=> 32MHz/30 +// <138412032=> 32MHz/31 +// <134217728=> 32MHz/32 +// <100663296=> 32MHz/42 +// <68157440=> 32MHz/63 +// <34340864=> 32MHz/125 + +#ifndef I2S_CONFIG_MCK_SETUP +#define I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// I2S_CONFIG_RATIO - MCK/LRCK ratio + +// <0=> 32x +// <1=> 48x +// <2=> 64x +// <3=> 96x +// <4=> 128x +// <5=> 192x +// <6=> 256x +// <7=> 384x +// <8=> 512x + +#ifndef I2S_CONFIG_RATIO +#define I2S_CONFIG_RATIO 2000 +#endif + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef I2S_CONFIG_IRQ_PRIORITY +#define I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef I2S_CONFIG_LOG_LEVEL +#define I2S_CONFIG_LOG_LEVEL 3 +#endif + +// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef I2S_CONFIG_INFO_COLOR +#define I2S_CONFIG_INFO_COLOR 0 +#endif + +// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef I2S_CONFIG_DEBUG_COLOR +#define I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// LPCOMP_CONFIG_REFERENCE - Reference voltage + +// <0=> Supply 1/8 +// <1=> Supply 2/8 +// <2=> Supply 3/8 +// <3=> Supply 4/8 +// <4=> Supply 5/8 +// <5=> Supply 6/8 +// <6=> Supply 7/8 +// <8=> Supply 1/16 (nRF52) +// <9=> Supply 3/16 (nRF52) +// <10=> Supply 5/16 (nRF52) +// <11=> Supply 7/16 (nRF52) +// <12=> Supply 9/16 (nRF52) +// <13=> Supply 11/16 (nRF52) +// <14=> Supply 13/16 (nRF52) +// <15=> Supply 15/16 (nRF52) +// <7=> External Ref 0 +// <65543=> External Ref 1 + +#ifndef LPCOMP_CONFIG_REFERENCE +#define LPCOMP_CONFIG_REFERENCE 3 +#endif + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef LPCOMP_CONFIG_INPUT +#define LPCOMP_CONFIG_INPUT 0 +#endif + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef LPCOMP_CONFIG_IRQ_PRIORITY +#define LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_I2S_CONFIG_MCK_SETUP - MCK behavior + +// <0=> Disabled +// <2147483648=> 32MHz/2 +// <1342177280=> 32MHz/3 +// <1073741824=> 32MHz/4 +// <805306368=> 32MHz/5 +// <671088640=> 32MHz/6 +// <536870912=> 32MHz/8 +// <402653184=> 32MHz/10 +// <369098752=> 32MHz/11 +// <285212672=> 32MHz/15 +// <268435456=> 32MHz/16 +// <201326592=> 32MHz/21 +// <184549376=> 32MHz/23 +// <142606336=> 32MHz/30 +// <138412032=> 32MHz/31 +// <134217728=> 32MHz/32 +// <100663296=> 32MHz/42 +// <68157440=> 32MHz/63 +// <34340864=> 32MHz/125 + +#ifndef NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_I2S_CONFIG_RATIO - MCK/LRCK ratio + +// <0=> 32x +// <1=> 48x +// <2=> 64x +// <3=> 96x +// <4=> 128x +// <5=> 192x +// <6=> 256x +// <7=> 384x +// <8=> 512x + +#ifndef NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_REFERENCE - Reference voltage + +// <0=> Supply 1/8 +// <1=> Supply 2/8 +// <2=> Supply 3/8 +// <3=> Supply 4/8 +// <4=> Supply 5/8 +// <5=> Supply 6/8 +// <6=> Supply 7/8 +// <8=> Supply 1/16 (nRF52) +// <9=> Supply 3/16 (nRF52) +// <10=> Supply 5/16 (nRF52) +// <11=> Supply 7/16 (nRF52) +// <12=> Supply 9/16 (nRF52) +// <13=> Supply 11/16 (nRF52) +// <14=> Supply 13/16 (nRF52) +// <15=> Supply 15/16 (nRF52) +// <7=> External Ref 0 +// <65543=> External Ref 1 + +#ifndef NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_NFCT_ENABLED - nrfx_nfct - NFCT peripheral driver +//========================================================== +#ifndef NRFX_NFCT_ENABLED +#define NRFX_NFCT_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_NFCT_CONFIG_IRQ_PRIORITY +#define NRFX_NFCT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_NFCT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_NFCT_CONFIG_LOG_ENABLED +#define NRFX_NFCT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_NFCT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_NFCT_CONFIG_LOG_LEVEL +#define NRFX_NFCT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_NFCT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_NFCT_CONFIG_INFO_COLOR +#define NRFX_NFCT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_NFCT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_NFCT_CONFIG_DEBUG_COLOR +#define NRFX_NFCT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 1 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 0 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 0 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock + +// <0=> 16 MHz +// <1=> 8 MHz +// <2=> 4 MHz +// <3=> 2 MHz +// <4=> 1 MHz +// <5=> 500 kHz +// <6=> 250 kHz +// <7=> 125 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE - EGU instance used by the nRF52 Anomaly 109 workaround for PWM. + +// <0=> EGU0 +// <1=> EGU1 +// <2=> EGU2 +// <3=> EGU3 +// <4=> EGU4 +// <5=> EGU5 + +#ifndef NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_REPORTPER - Report period + +// <0=> 10 Samples +// <1=> 40 Samples +// <2=> 80 Samples +// <3=> 120 Samples +// <4=> 160 Samples +// <5=> 200 Samples +// <6=> 240 Samples +// <7=> 280 Samples + +#ifndef NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLEPER - Sample period + +// <0=> 128 us +// <1=> 256 us +// <2=> 512 us +// <3=> 1024 us +// <4=> 2048 us +// <5=> 4096 us +// <6=> 8192 us +// <7=> 16384 us + +#ifndef NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 0 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 0 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 0 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 0 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 0 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 0 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 0 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 0 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 0 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 0 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 0 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 0 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode + +// <0=> 16 MHz +// <1=> 8 MHz +// <2=> 4 MHz +// <3=> 2 MHz +// <4=> 1 MHz +// <5=> 500 kHz +// <6=> 250 kHz +// <7=> 125 kHz +// <8=> 62.5 kHz +// <9=> 31.25 kHz + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 0 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 0 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// Optimization flag. Registers used by TWIS are shared by other peripherals. Normally, during initialization driver tries to clear all registers to known state before doing the initialization itself. This gives initialization safe procedure, no matter when it would be called. If you activate TWIS only once and do never uninitialize it - set this flag to 1 what gives more optimal code. + +#ifndef NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// Synchronous mode would be used in specific situations. And it uses some additional code and data memory to safely process state machine by polling it in status functions. If this functionality is not required it may be disabled to free some resources. + +#ifndef NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 0 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3862528=> 14400 baud +// <5152768=> 19200 baud +// <7716864=> 28800 baud +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 0 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode + +// <1=> Run in SLEEP, Pause in HALT +// <8=> Pause in SLEEP, Run in HALT +// <9=> Run in SLEEP and HALT +// <0=> Pause in SLEEP and HALT + +#ifndef NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value in ms <1-131072000> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 0 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef CLOCK_CONFIG_IRQ_PRIORITY +#define CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef PDM_CONFIG_CLOCK_FREQ +#define PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef PDM_CONFIG_IRQ_PRIORITY +#define PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 1 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef POWER_CONFIG_IRQ_PRIORITY +#define POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef POWER_CONFIG_DEFAULT_DCDCEN +#define POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef POWER_CONFIG_DEFAULT_DCDCENHV +#define POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock + +// <0=> 16 MHz +// <1=> 8 MHz +// <2=> 4 MHz +// <3=> 2 MHz +// <4=> 1 MHz +// <5=> 500 kHz +// <6=> 250 kHz +// <7=> 125 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef PWM_DEFAULT_CONFIG_COUNT_MODE +#define PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef PWM_DEFAULT_CONFIG_LOAD_MODE +#define PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef PWM_DEFAULT_CONFIG_STEP_MODE +#define PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 0 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 0 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 0 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// PWM_NRF52_ANOMALY_109_EGU_INSTANCE - EGU instance used by the nRF52 Anomaly 109 workaround for PWM. + +// <0=> EGU0 +// <1=> EGU1 +// <2=> EGU2 +// <3=> EGU3 +// <4=> EGU4 +// <5=> EGU5 + +#ifndef PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// QDEC_CONFIG_REPORTPER - Report period + +// <0=> 10 Samples +// <1=> 40 Samples +// <2=> 80 Samples +// <3=> 120 Samples +// <4=> 160 Samples +// <5=> 200 Samples +// <6=> 240 Samples +// <7=> 280 Samples + +#ifndef QDEC_CONFIG_REPORTPER +#define QDEC_CONFIG_REPORTPER 0 +#endif + +// QDEC_CONFIG_SAMPLEPER - Sample period + +// <0=> 128 us +// <1=> 256 us +// <2=> 512 us +// <3=> 1024 us +// <4=> 2048 us +// <5=> 4096 us +// <6=> 8192 us +// <7=> 16384 us + +#ifndef QDEC_CONFIG_SAMPLEPER +#define QDEC_CONFIG_SAMPLEPER 7 +#endif + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef QDEC_CONFIG_IRQ_PRIORITY +#define QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer +//========================================================== +#ifndef QSPI_ENABLED +#define QSPI_ENABLED 0 +#endif +// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> + + +#ifndef QSPI_CONFIG_SCK_DELAY +#define QSPI_CONFIG_SCK_DELAY 1 +#endif + +// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef QSPI_CONFIG_XIP_OFFSET +#define QSPI_CONFIG_XIP_OFFSET 0 +#endif + +// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. + +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO + +#ifndef QSPI_CONFIG_READOC +#define QSPI_CONFIG_READOC 0 +#endif + +// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef QSPI_CONFIG_WRITEOC +#define QSPI_CONFIG_WRITEOC 0 +#endif + +// QSPI_CONFIG_ADDRMODE - Addressing mode. + +// <0=> 24bit +// <1=> 32bit + +#ifndef QSPI_CONFIG_ADDRMODE +#define QSPI_CONFIG_ADDRMODE 0 +#endif + +// QSPI_CONFIG_MODE - SPI mode. + +// <0=> Mode 0 +// <1=> Mode 1 + +#ifndef QSPI_CONFIG_MODE +#define QSPI_CONFIG_MODE 0 +#endif + +// QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 + +#ifndef QSPI_CONFIG_FREQUENCY +#define QSPI_CONFIG_FREQUENCY 15 +#endif + +// QSPI_PIN_SCK - SCK pin value. +#ifndef QSPI_PIN_SCK +#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_CSN - CSN pin value. +#ifndef QSPI_PIN_CSN +#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO0 - IO0 pin value. +#ifndef QSPI_PIN_IO0 +#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO1 - IO1 pin value. +#ifndef QSPI_PIN_IO1 +#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO2 - IO2 pin value. +#ifndef QSPI_PIN_IO2 +#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO3 - IO3 pin value. +#ifndef QSPI_PIN_IO3 +#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef QSPI_CONFIG_IRQ_PRIORITY +#define QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 0 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef RNG_CONFIG_IRQ_PRIORITY +#define RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 0 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef SAADC_CONFIG_OVERSAMPLE +#define SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef SAADC_CONFIG_IRQ_PRIORITY +#define SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// SPIS_DEFAULT_MODE - Mode + +// <0=> MODE_0 +// <1=> MODE_1 +// <2=> MODE_2 +// <3=> MODE_3 + +#ifndef SPIS_DEFAULT_MODE +#define SPIS_DEFAULT_MODE 0 +#endif + +// SPIS_DEFAULT_BIT_ORDER - SPIS default bit order + +// <0=> MSB first +// <1=> LSB first + +#ifndef SPIS_DEFAULT_BIT_ORDER +#define SPIS_DEFAULT_BIT_ORDER 0 +#endif + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 0 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 0 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 0 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 0 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 0 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 1 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode + +// <0=> 16 MHz +// <1=> 8 MHz +// <2=> 4 MHz +// <3=> 2 MHz +// <4=> 1 MHz +// <5=> 500 kHz +// <6=> 250 kHz +// <7=> 125 kHz +// <8=> 62.5 kHz +// <9=> 31.25 kHz + +#ifndef TIMER_DEFAULT_CONFIG_FREQUENCY +#define TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 0 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 0 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 0 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 0 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 0 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 0 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 0 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// Optimization flag. Registers used by TWIS are shared by other peripherals. Normally, during initialization driver tries to clear all registers to known state before doing the initialization itself. This gives initialization safe procedure, no matter when it would be called. If you activate TWIS only once and do never uninitialize it - set this flag to 1 what gives more optimal code. + +#ifndef TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// Synchronous mode would be used in specific situations. And it uses some additional code and data memory to safely process state machine by polling it in status functions. If this functionality is not required it may be disabled to free some resources. + +#ifndef TWIS_NO_SYNC_MODE +#define TWIS_NO_SYNC_MODE 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef TWIS_DEFAULT_CONFIG_SCL_PULL +#define TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef TWIS_DEFAULT_CONFIG_SDA_PULL +#define TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// TWI_DEFAULT_CONFIG_CLR_BUS_INIT - Enables bus clearing procedure during init + + +#ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT +#define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0 +#endif + +// TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 0 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 0 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 0 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3862528=> 14400 baud +// <5152768=> 19200 baud +// <7716864=> 28800 baud +// <10289152=> 38400 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 0 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef USBD_CONFIG_IRQ_PRIORITY +#define USBD_CONFIG_IRQ_PRIORITY 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. +// NOTE: This option does not work on Engineering A chip. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode + +// <1=> Run in SLEEP, Pause in HALT +// <8=> Pause in SLEEP, Run in HALT +// <9=> Run in SLEEP and HALT +// <0=> Pause in SLEEP and HALT + +#ifndef WDT_CONFIG_BEHAVIOUR +#define WDT_CONFIG_BEHAVIOUR 1 +#endif + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef WDT_CONFIG_IRQ_PRIORITY +#define WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// nrfx_qspi - QSPI peripheral driver + +//========================================================== +// +//========================================================== + +// nrfx_usbd - USBD peripheral driver + +//========================================================== +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers_External + +//========================================================== +// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module + + +#ifndef NRF_TWI_SENSOR_ENABLED +#define NRF_TWI_SENSOR_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 0 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 0 +#endif +// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. + +// <0=> 32768 Hz +// <1=> 16384 Hz +// <3=> 8192 Hz +// <7=> 4096 Hz +// <15=> 2048 Hz +// <31=> 1024 Hz + +#ifndef APP_TIMER_CONFIG_RTC_FREQUENCY +#define APP_TIMER_CONFIG_RTC_FREQUENCY 1 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY +#define APP_TIMER_CONFIG_IRQ_PRIORITY 6 +#endif + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler + + +#ifndef APP_TIMER_CONFIG_USE_SCHEDULER +#define APP_TIMER_CONFIG_USE_SCHEDULER 0 +#endif + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// This option can be used when app_timer is used for timestamping. + +#ifndef APP_TIMER_KEEPS_RTC_ACTIVE +#define APP_TIMER_KEEPS_RTC_ACTIVE 0 +#endif + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class + + +#ifndef APP_USBD_AUDIO_ENABLED +#define APP_USBD_AUDIO_ENABLED 0 +#endif + +// APP_USBD_ENABLED - app_usbd - USB Device library +//========================================================== +#ifndef APP_USBD_ENABLED +#define APP_USBD_ENABLED 0 +#endif +// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ + +#ifndef APP_USBD_VID +#define APP_USBD_VID 0 +#endif + +// APP_USBD_PID - Product ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Selected Product ID + +#ifndef APP_USBD_PID +#define APP_USBD_PID 0 +#endif + +// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> + + +// Major device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_MAJOR +#define APP_USBD_DEVICE_VER_MAJOR 1 +#endif + +// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> + + +// Minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_MINOR +#define APP_USBD_DEVICE_VER_MINOR 0 +#endif + +// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> + + +// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_SUB +#define APP_USBD_DEVICE_VER_SUB 0 +#endif + +// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. + + +#ifndef APP_USBD_CONFIG_SELF_POWERED +#define APP_USBD_CONFIG_SELF_POWERED 1 +#endif + +// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> + + +#ifndef APP_USBD_CONFIG_MAX_POWER +#define APP_USBD_CONFIG_MAX_POWER 100 +#endif + +// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. + + +// Enable processing power events in USB event handler. + +#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS +#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 +#endif + +// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. + +// This is the default configuration when all the events are placed into internal queue. +// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. +// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. +// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. +//========================================================== +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 +#endif +// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> + + +// The size of the queue for the events that would be processed in the main loop. + +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE +#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 +#endif + +// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. + + +// Normal queue - SOF events are pushed normally into the event queue. +// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. +// This prevents the queue from filling up with SOF events. +// Interrupt - SOF events are processed in interrupt. +// <0=> Normal queue +// <1=> Compress queue +// <2=> Interrupt + +#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE +#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 +#endif + +// + +// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. + + +// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. +// Use it when initializing the logger. +// SOF processing is always enabled when this configuration parameter is active. +// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. +// This means that it works even if the logging in this very module is disabled. + +#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE +#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 +#endif + +// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> + + +// 31 characters can be stored in the internal USB buffer used for transfers. +// Any value higher than 31 creates an additional buffer just for descriptor strings. + +#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE +#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 +#endif + +// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. + + +// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. + +#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED +#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 +#endif + +// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of supported languages. +#ifndef APP_USBD_STRINGS_LANGIDS +#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) +#endif + +// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_MANUFACTURER +#define APP_USBD_STRING_ID_MANUFACTURER 1 +#endif +// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of manufacturer names for each defined language. +// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. +// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. +// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. +// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. +// Setting string to NULL disables that string. +// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. +#ifndef APP_USBD_STRINGS_MANUFACTURER +#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") +#endif + +// + +// APP_USBD_STRING_ID_PRODUCT - Define product string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_PRODUCT +#define APP_USBD_STRING_ID_PRODUCT 2 +#endif +// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 +#endif + +// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. + +// Note: This value is not editable in Configuration Wizard. +// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_PRODUCT +#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") +#endif + +// + +// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_SERIAL +#define APP_USBD_STRING_ID_SERIAL 3 +#endif +// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +// APP_USBD_STRING_SERIAL - String descriptor for the serial number. + +// Note: This value is not editable in Configuration Wizard. +// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRING_SERIAL +#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") +#endif + +// + +// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_CONFIGURATION +#define APP_USBD_STRING_ID_CONFIGURATION 4 +#endif +// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. + + +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 +#endif + +// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. + +// Note: This value is not editable in Configuration Wizard. +// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_CONFIGURATION +#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") +#endif + +// + +// APP_USBD_STRINGS_USER - Default values for user strings. + +// Note: This value is not editable in Configuration Wizard. +// This value stores all application specific user strings with the default initialization. +// The setup is done by X-macros. +// Expected macro parameters: +// @code +// X(mnemonic, [=str_idx], ...) +// @endcode +// - @c mnemonic: Mnemonic of the string descriptor that would be added to +// @ref app_usbd_string_desc_idx_t enumerator. +// - @c str_idx : String index value, can be set or left empty. +// For example, WinUSB driver requires descriptor to be present on 0xEE index. +// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) +// - @c ... : List of string descriptors for each defined language. +#ifndef APP_USBD_STRINGS_USER +#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) +#endif + +// + +// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class +//========================================================== +#ifndef APP_USBD_HID_ENABLED +#define APP_USBD_HID_ENABLED 0 +#endif +// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> + + +// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. + +#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE +#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 +#endif + +// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> + + +// Must be higher than the highest report ID used. + +#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE +#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 +#endif + +// + +// APP_USBD_HID_GENERIC_ENABLED - app_usbd_hid_generic - USB HID generic + + +#ifndef APP_USBD_HID_GENERIC_ENABLED +#define APP_USBD_HID_GENERIC_ENABLED 0 +#endif + +// APP_USBD_HID_KBD_ENABLED - app_usbd_hid_kbd - USB HID keyboard + + +#ifndef APP_USBD_HID_KBD_ENABLED +#define APP_USBD_HID_KBD_ENABLED 0 +#endif + +// APP_USBD_HID_MOUSE_ENABLED - app_usbd_hid_mouse - USB HID mouse + + +#ifndef APP_USBD_HID_MOUSE_ENABLED +#define APP_USBD_HID_MOUSE_ENABLED 0 +#endif + +// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class + + +#ifndef APP_USBD_MSC_ENABLED +#define APP_USBD_MSC_ENABLED 0 +#endif + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 0 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// The size of a virtual page must be a multiple of the size of a physical page. +// <1024=> 1024 +// <2048=> 2048 + +#ifndef FDS_VIRTUAL_PAGE_SIZE +#define FDS_VIRTUAL_PAGE_SIZE 1024 +#endif + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 2 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 0 +#endif + +// HCI_MEM_POOL_ENABLED - hci_mem_pool - memory pool implementation used by HCI +//========================================================== +#ifndef HCI_MEM_POOL_ENABLED +#define HCI_MEM_POOL_ENABLED 0 +#endif +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// HCI_UART_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3862528=> 14400 baud +// <5152768=> 19200 baud +// <7716864=> 28800 baud +// <10289152=> 38400 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 31 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 31 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 31 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 31 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// HCI_MAX_PACKET_SIZE_IN_BITS - Maximum size of a single application packet in bits. +#ifndef HCI_MAX_PACKET_SIZE_IN_BITS +#define HCI_MAX_PACKET_SIZE_IN_BITS 8000 +#endif + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block. <0-255> + + +#ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT +#define MEMORY_MANAGER_SMALL_BLOCK_COUNT 1 +#endif + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_SMALL_BLOCK_SIZE +#define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32 +#endif + +// MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block. <0-255> + + +#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_COUNT +#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_SIZE +#define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256 +#endif + +// MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block. <0-255> + + +#ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT +#define MEMORY_MANAGER_LARGE_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// Size of each memory blocks identified as 'large' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_LARGE_BLOCK_SIZE +#define MEMORY_MANAGER_LARGE_BLOCK_SIZE 256 +#endif + +// MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block. <0-255> + + +#ifndef MEMORY_MANAGER_XLARGE_BLOCK_COUNT +#define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_XLARGE_BLOCK_SIZE +#define MEMORY_MANAGER_XLARGE_BLOCK_SIZE 1320 +#endif + +// MEMORY_MANAGER_XXLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra large' block. <0-255> + + +#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_COUNT +#define MEMORY_MANAGER_XXLARGE_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// Size of each memory blocks identified as 'extra extra large' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_SIZE +#define MEMORY_MANAGER_XXLARGE_BLOCK_SIZE 3444 +#endif + +// MEMORY_MANAGER_XSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra small' block. <0-255> + + +#ifndef MEMORY_MANAGER_XSMALL_BLOCK_COUNT +#define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_XSMALL_BLOCK_SIZE +#define MEMORY_MANAGER_XSMALL_BLOCK_SIZE 64 +#endif + +// MEMORY_MANAGER_XXSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra small' block. <0-255> + + +#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_COUNT +#define MEMORY_MANAGER_XXSMALL_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// Size of each memory blocks identified as 'extra extra small' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_SIZE +#define MEMORY_MANAGER_XXSMALL_BLOCK_SIZE 32 +#endif + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// MEM_MANAGER_DISABLE_API_PARAM_CHECK - Disable API parameter checks in the module. + + +#ifndef MEM_MANAGER_DISABLE_API_PARAM_CHECK +#define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0 +#endif + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 0 +#endif + +// + +// + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// NRF_CSENSE_PAD_HYSTERESIS - Minimum value of change required to determine that a pad was touched. +#ifndef NRF_CSENSE_PAD_HYSTERESIS +#define NRF_CSENSE_PAD_HYSTERESIS 15 +#endif + +// NRF_CSENSE_PAD_DEVIATION - Minimum value measured on a pad required to take it into account while calculating the step. +#ifndef NRF_CSENSE_PAD_DEVIATION +#define NRF_CSENSE_PAD_DEVIATION 70 +#endif + +// NRF_CSENSE_MIN_PAD_VALUE - Minimum normalized value on a pad required to take its value into account. +#ifndef NRF_CSENSE_MIN_PAD_VALUE +#define NRF_CSENSE_MIN_PAD_VALUE 20 +#endif + +// NRF_CSENSE_MAX_PADS_NUMBER - Maximum number of pads used for one instance. +#ifndef NRF_CSENSE_MAX_PADS_NUMBER +#define NRF_CSENSE_MAX_PADS_NUMBER 20 +#endif + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// I_SOURCE, VUP, and VDOWN are values used to initialize COMP and C is the capacitance of the used pad. + +#ifndef MEASUREMENT_PERIOD +#define MEASUREMENT_PERIOD 20 +#endif + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 0 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 1 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 0 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 0 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// app_usbd_cdc_acm - USB CDC ACM class + +//========================================================== +// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library + + +#ifndef APP_USBD_CDC_ACM_ENABLED +#define APP_USBD_CDC_ACM_ENABLED 0 +#endif + +// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint + + +// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. +// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. + +#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE +#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1 +#endif + +// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. + + +#ifndef NRF_FPRINTF_DOUBLE_ENABLED +#define NRF_FPRINTF_DOUBLE_ENABLED 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 0 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 0 +#endif + +// NRF_LOG_DEFAULT_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LOG_DEFAULT_LEVEL +#define NRF_LOG_DEFAULT_LEVEL 3 +#endif + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. + + +// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. +// Log output will never be corrupted as access to the log backend is exclusive +// but system will spend significant amount of time in critical section + +#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED +#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string +//========================================================== +#ifndef NRF_LOG_USES_COLORS +#define NRF_LOG_USES_COLORS 0 +#endif +// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LOG_COLOR_DEFAULT +#define NRF_LOG_COLOR_DEFAULT 0 +#endif + +// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LOG_ERROR_COLOR +#define NRF_LOG_ERROR_COLOR 2 +#endif + +// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LOG_WARNING_COLOR +#define NRF_LOG_WARNING_COLOR 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef CLOCK_CONFIG_LOG_LEVEL +#define CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef CLOCK_CONFIG_INFO_COLOR +#define CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef CLOCK_CONFIG_DEBUG_COLOR +#define CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef COMP_CONFIG_LOG_LEVEL +#define COMP_CONFIG_LOG_LEVEL 3 +#endif + +// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef COMP_CONFIG_INFO_COLOR +#define COMP_CONFIG_INFO_COLOR 0 +#endif + +// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef COMP_CONFIG_DEBUG_COLOR +#define COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef GPIOTE_CONFIG_LOG_LEVEL +#define GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef GPIOTE_CONFIG_INFO_COLOR +#define GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef GPIOTE_CONFIG_DEBUG_COLOR +#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef LPCOMP_CONFIG_LOG_LEVEL +#define LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef LPCOMP_CONFIG_INFO_COLOR +#define LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef LPCOMP_CONFIG_DEBUG_COLOR +#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 +#endif + +// MAX3421E_HOST_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 +#endif + +// MAX3421E_HOST_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PDM_CONFIG_LOG_LEVEL +#define PDM_CONFIG_LOG_LEVEL 3 +#endif + +// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PDM_CONFIG_INFO_COLOR +#define PDM_CONFIG_INFO_COLOR 0 +#endif + +// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PDM_CONFIG_DEBUG_COLOR +#define PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 +#endif +// PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PPI_CONFIG_LOG_LEVEL +#define PPI_CONFIG_LOG_LEVEL 3 +#endif + +// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PPI_CONFIG_INFO_COLOR +#define PPI_CONFIG_INFO_COLOR 0 +#endif + +// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PPI_CONFIG_DEBUG_COLOR +#define PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 +#endif +// PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PWM_CONFIG_LOG_LEVEL +#define PWM_CONFIG_LOG_LEVEL 3 +#endif + +// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PWM_CONFIG_INFO_COLOR +#define PWM_CONFIG_INFO_COLOR 0 +#endif + +// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PWM_CONFIG_DEBUG_COLOR +#define PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 +#endif +// QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef QDEC_CONFIG_LOG_LEVEL +#define QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef QDEC_CONFIG_INFO_COLOR +#define QDEC_CONFIG_INFO_COLOR 0 +#endif + +// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef QDEC_CONFIG_DEBUG_COLOR +#define QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 +#endif +// RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef RNG_CONFIG_LOG_LEVEL +#define RNG_CONFIG_LOG_LEVEL 3 +#endif + +// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef RNG_CONFIG_INFO_COLOR +#define RNG_CONFIG_INFO_COLOR 0 +#endif + +// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef RNG_CONFIG_DEBUG_COLOR +#define RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED - Enables logging of random numbers. + + +#ifndef RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED +#define RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED 0 +#endif + +// + +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 +#endif +// RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef RTC_CONFIG_LOG_LEVEL +#define RTC_CONFIG_LOG_LEVEL 3 +#endif + +// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef RTC_CONFIG_INFO_COLOR +#define RTC_CONFIG_INFO_COLOR 0 +#endif + +// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef RTC_CONFIG_DEBUG_COLOR +#define RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 +#endif +// SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SAADC_CONFIG_LOG_LEVEL +#define SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SAADC_CONFIG_INFO_COLOR +#define SAADC_CONFIG_INFO_COLOR 0 +#endif + +// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SAADC_CONFIG_DEBUG_COLOR +#define SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 +#endif +// SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SPIS_CONFIG_LOG_LEVEL +#define SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SPIS_CONFIG_INFO_COLOR +#define SPIS_CONFIG_INFO_COLOR 0 +#endif + +// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SPIS_CONFIG_DEBUG_COLOR +#define SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 +#endif +// SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SPI_CONFIG_LOG_LEVEL +#define SPI_CONFIG_LOG_LEVEL 3 +#endif + +// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 +#endif + +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 +#endif +// TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TIMER_CONFIG_LOG_LEVEL +#define TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 +#endif + +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 +#endif +// TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 +#endif + +// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 +#endif +// TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 +#endif + +// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 +#endif + +// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 +#endif +// UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 +#endif + +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 +#endif + +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 +#endif +// USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 +#endif + +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 +#endif + +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 +#endif +// WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 +#endif + +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 +#endif + +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Libraries + +//========================================================== +// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_BUTTON_CONFIG_LOG_ENABLED +#define APP_BUTTON_CONFIG_LOG_ENABLED 0 +#endif +// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_LOG_LEVEL +#define APP_BUTTON_CONFIG_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL +#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_BUTTON_CONFIG_INFO_COLOR +#define APP_BUTTON_CONFIG_INFO_COLOR 0 +#endif + +// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR +#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. +//========================================================== +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 +#endif +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 +#endif + +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED +#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL +#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MEMOBJ_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_MEMOBJ_CONFIG_INFO_COLOR +#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MEMOBJ_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_MEMOBJ_CONFIG_DEBUG_COLOR +#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED +#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL +#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_PWR_MGMT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_PWR_MGMT_CONFIG_INFO_COLOR +#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#endif + +// NRF_PWR_MGMT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_COLOR +#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. +//========================================================== +#ifndef NRF_SDH_ANT_LOG_ENABLED +#define NRF_SDH_ANT_LOG_ENABLED 1 +#endif +// NRF_SDH_ANT_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_ANT_LOG_LEVEL +#define NRF_SDH_ANT_LOG_LEVEL 3 +#endif + +// NRF_SDH_ANT_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_ANT_INFO_COLOR +#define NRF_SDH_ANT_INFO_COLOR 0 +#endif + +// NRF_SDH_ANT_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_ANT_DEBUG_COLOR +#define NRF_SDH_ANT_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +//========================================================== +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 +#endif +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 +#endif + +// NRF_SDH_BLE_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 +#endif + +// NRF_SDH_BLE_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +//========================================================== +#ifndef NRF_SDH_LOG_ENABLED +#define NRF_SDH_LOG_ENABLED 1 +#endif +// NRF_SDH_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_LOG_LEVEL +#define NRF_SDH_LOG_LEVEL 3 +#endif + +// NRF_SDH_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_INFO_COLOR +#define NRF_SDH_INFO_COLOR 0 +#endif + +// NRF_SDH_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_DEBUG_COLOR +#define NRF_SDH_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. +//========================================================== +#ifndef NRF_SDH_SOC_LOG_ENABLED +#define NRF_SDH_SOC_LOG_ENABLED 1 +#endif +// NRF_SDH_SOC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_SOC_LOG_LEVEL +#define NRF_SDH_SOC_LOG_LEVEL 3 +#endif + +// NRF_SDH_SOC_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_SOC_INFO_COLOR +#define NRF_SDH_SOC_INFO_COLOR 0 +#endif + +// NRF_SDH_SOC_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_SOC_DEBUG_COLOR +#define NRF_SDH_SOC_DEBUG_COLOR 0 +#endif + +// + +// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED +#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 +#endif +// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL +#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_SORTLIST_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SORTLIST_CONFIG_INFO_COLOR +#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 +#endif + +// NRF_SORTLIST_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SORTLIST_CONFIG_DEBUG_COLOR +#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// +//========================================================== + +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + +// +//========================================================== + +// nRF_NFC + +//========================================================== +// NFC_AC_REC_ENABLED - nfc_ac_rec - NFC NDEF Alternative Carrier record encoder + + +#ifndef NFC_AC_REC_ENABLED +#define NFC_AC_REC_ENABLED 0 +#endif + +// NFC_AC_REC_PARSER_ENABLED - nfc_ac_rec_parser - Alternative Carrier record parser + + +#ifndef NFC_AC_REC_PARSER_ENABLED +#define NFC_AC_REC_PARSER_ENABLED 0 +#endif + +// NFC_BLE_OOB_ADVDATA_ENABLED - nfc_ble_oob_advdata - AD data for OOB pairing encoder +//========================================================== +#ifndef NFC_BLE_OOB_ADVDATA_ENABLED +#define NFC_BLE_OOB_ADVDATA_ENABLED 0 +#endif +// ADVANCED_ADVDATA_SUPPORT - Non-mandatory AD types for BLE OOB pairing are encoded inside the NDEF message (e.g. service UUIDs) + +// <1=> Enabled +// <0=> Disabled + +#ifndef ADVANCED_ADVDATA_SUPPORT +#define ADVANCED_ADVDATA_SUPPORT 0 +#endif + +// + +// NFC_BLE_OOB_ADVDATA_PARSER_ENABLED - nfc_ble_oob_advdata_parser - BLE OOB pairing AD data parser + + +#ifndef NFC_BLE_OOB_ADVDATA_PARSER_ENABLED +#define NFC_BLE_OOB_ADVDATA_PARSER_ENABLED 0 +#endif + +// NFC_BLE_PAIR_LIB_ENABLED - nfc_ble_pair_lib - Library parameters +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_ENABLED +#define NFC_BLE_PAIR_LIB_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_LOG_ENABLED +#define NFC_BLE_PAIR_LIB_LOG_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_BLE_PAIR_LIB_LOG_LEVEL +#define NFC_BLE_PAIR_LIB_LOG_LEVEL 3 +#endif + +// NFC_BLE_PAIR_LIB_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_BLE_PAIR_LIB_INFO_COLOR +#define NFC_BLE_PAIR_LIB_INFO_COLOR 0 +#endif + +// NFC_BLE_PAIR_LIB_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_BLE_PAIR_LIB_DEBUG_COLOR +#define NFC_BLE_PAIR_LIB_DEBUG_COLOR 0 +#endif + +// + +// NFC_BLE_PAIR_LIB_SECURITY_PARAMETERS - Common Peer Manager security parameters. + +//========================================================== +// BLE_NFC_SEC_PARAM_BOND - Enables device bonding. + +// If bonding is enabled at least one of the BLE_NFC_SEC_PARAM_KDIST options must be enabled. +//========================================================== +#ifndef BLE_NFC_SEC_PARAM_BOND +#define BLE_NFC_SEC_PARAM_BOND 1 +#endif +// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +#endif + +// + +// BLE_NFC_SEC_PARAM_MIN_KEY_SIZE - Minimal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MIN_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MIN_KEY_SIZE 7 +#endif + +// BLE_NFC_SEC_PARAM_MAX_KEY_SIZE - Maximal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MAX_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MAX_KEY_SIZE 16 +#endif + +// +//========================================================== + +// + +// NFC_BLE_PAIR_MSG_ENABLED - nfc_ble_pair_msg - NDEF message for OOB pairing encoder + + +#ifndef NFC_BLE_PAIR_MSG_ENABLED +#define NFC_BLE_PAIR_MSG_ENABLED 0 +#endif + +// NFC_CH_COMMON_ENABLED - nfc_ble_pair_common - OOB pairing common data + + +#ifndef NFC_CH_COMMON_ENABLED +#define NFC_CH_COMMON_ENABLED 0 +#endif + +// NFC_EP_OOB_REC_ENABLED - nfc_ep_oob_rec - EP record for BLE pairing encoder + + +#ifndef NFC_EP_OOB_REC_ENABLED +#define NFC_EP_OOB_REC_ENABLED 0 +#endif + +// NFC_HS_REC_ENABLED - nfc_hs_rec - Handover Select NDEF record encoder + + +#ifndef NFC_HS_REC_ENABLED +#define NFC_HS_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_ENABLED - nfc_le_oob_rec - LE record for BLE pairing encoder + + +#ifndef NFC_LE_OOB_REC_ENABLED +#define NFC_LE_OOB_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_PARSER_ENABLED - nfc_le_oob_rec_parser - LE record parser + + +#ifndef NFC_LE_OOB_REC_PARSER_ENABLED +#define NFC_LE_OOB_REC_PARSER_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_MSG_ENABLED - nfc_launchapp_msg - Encoding data for NDEF Application Launching message for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_MSG_ENABLED +#define NFC_NDEF_LAUNCHAPP_MSG_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_REC_ENABLED - nfc_launchapp_rec - Encoding data for NDEF Application Launching record for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_REC_ENABLED +#define NFC_NDEF_LAUNCHAPP_REC_ENABLED 0 +#endif + +// NFC_NDEF_MSG_ENABLED - nfc_ndef_msg - NFC NDEF Message generator module +//========================================================== +#ifndef NFC_NDEF_MSG_ENABLED +#define NFC_NDEF_MSG_ENABLED 0 +#endif +// NFC_NDEF_MSG_TAG_TYPE - NFC Tag Type + +// <2=> Type 2 Tag +// <4=> Type 4 Tag + +#ifndef NFC_NDEF_MSG_TAG_TYPE +#define NFC_NDEF_MSG_TAG_TYPE 2 +#endif + +// + +// NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_ENABLED +#define NFC_NDEF_MSG_PARSER_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED +#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL +#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_MSG_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_NDEF_MSG_PARSER_INFO_COLOR +#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_RECORD_ENABLED - nfc_ndef_record - NFC NDEF Record generator module + + +#ifndef NFC_NDEF_RECORD_ENABLED +#define NFC_NDEF_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_RECORD_PARSER_ENABLED - nfc_ndef_record_parser - NFC NDEF Record parser module +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_ENABLED +#define NFC_NDEF_RECORD_PARSER_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_LOG_ENABLED +#define NFC_NDEF_RECORD_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_RECORD_PARSER_LOG_LEVEL +#define NFC_NDEF_RECORD_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_RECORD_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_NDEF_RECORD_PARSER_INFO_COLOR +#define NFC_NDEF_RECORD_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_TEXT_RECORD_ENABLED - nfc_text_rec - Encoding data for a text record for NFC Tag + + +#ifndef NFC_NDEF_TEXT_RECORD_ENABLED +#define NFC_NDEF_TEXT_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_URI_MSG_ENABLED - nfc_uri_msg - Encoding data for NDEF message with URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_MSG_ENABLED +#define NFC_NDEF_URI_MSG_ENABLED 0 +#endif + +// NFC_NDEF_URI_REC_ENABLED - nfc_uri_rec - Encoding data for a URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_REC_ENABLED +#define NFC_NDEF_URI_REC_ENABLED 0 +#endif + +// NFC_PLATFORM_ENABLED - nfc_platform - NFC platform module for Clock control. +//========================================================== +#ifndef NFC_PLATFORM_ENABLED +#define NFC_PLATFORM_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_PLATFORM_LOG_ENABLED +#define NFC_PLATFORM_LOG_ENABLED 0 +#endif +// NFC_PLATFORM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_PLATFORM_LOG_LEVEL +#define NFC_PLATFORM_LOG_LEVEL 3 +#endif + +// NFC_PLATFORM_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_PLATFORM_INFO_COLOR +#define NFC_PLATFORM_INFO_COLOR 0 +#endif + +// NFC_PLATFORM_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_PLATFORM_DEBUG_COLOR +#define NFC_PLATFORM_DEBUG_COLOR 0 +#endif + +// + +// + +// NFC_T2T_PARSER_ENABLED - nfc_type_2_tag_parser - Parser for decoding Type 2 Tag data +//========================================================== +#ifndef NFC_T2T_PARSER_ENABLED +#define NFC_T2T_PARSER_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T2T_PARSER_LOG_ENABLED +#define NFC_T2T_PARSER_LOG_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T2T_PARSER_LOG_LEVEL +#define NFC_T2T_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T2T_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T2T_PARSER_INFO_COLOR +#define NFC_T2T_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_APDU_ENABLED - nfc_t4t_apdu - APDU encoder/decoder for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_APDU_ENABLED +#define NFC_T4T_APDU_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_APDU_LOG_ENABLED +#define NFC_T4T_APDU_LOG_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_APDU_LOG_LEVEL +#define NFC_T4T_APDU_LOG_LEVEL 3 +#endif + +// NFC_T4T_APDU_LOG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_APDU_LOG_COLOR +#define NFC_T4T_APDU_LOG_COLOR 0 +#endif + +// + +// + +// NFC_T4T_CC_FILE_PARSER_ENABLED - nfc_t4t_cc_file - Capability Container file for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_ENABLED +#define NFC_T4T_CC_FILE_PARSER_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_ENABLED +#define NFC_T4T_CC_FILE_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_LEVEL +#define NFC_T4T_CC_FILE_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_CC_FILE_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_CC_FILE_PARSER_INFO_COLOR +#define NFC_T4T_CC_FILE_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED - nfc_t4t_hl_detection_procedures - NDEF Detection Procedure for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL 3 +#endif + +// NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR +#define NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR 0 +#endif + +// + +// APDU_BUFF_SIZE - Size (in bytes) of the buffer for APDU storage +#ifndef APDU_BUFF_SIZE +#define APDU_BUFF_SIZE 250 +#endif + +// CC_STORAGE_BUFF_SIZE - Size (in bytes) of the buffer for CC file storage +#ifndef CC_STORAGE_BUFF_SIZE +#define CC_STORAGE_BUFF_SIZE 64 +#endif + +// + +// NFC_T4T_TLV_BLOCK_PARSER_ENABLED - nfc_t4t_tlv_block - TLV block for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR +#define NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// +//========================================================== + +// nRF_SoftDevice + +//========================================================== +// NRF_SDH_ANT_ENABLED - nrf_sdh_ant - SoftDevice ANT event handler +//========================================================== +#ifndef NRF_SDH_ANT_ENABLED +#define NRF_SDH_ANT_ENABLED 0 +#endif +// ANT Channels + +//========================================================== +// NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED - Allocated ANT channels. +#ifndef NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED +#define NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED 0 +#endif + +// NRF_SDH_ANT_ENCRYPTED_CHANNELS - Encrypted ANT channels. +#ifndef NRF_SDH_ANT_ENCRYPTED_CHANNELS +#define NRF_SDH_ANT_ENCRYPTED_CHANNELS 0 +#endif + +// +//========================================================== + +// ANT Queues + +//========================================================== +// NRF_SDH_ANT_EVENT_QUEUE_SIZE - Event queue size. +#ifndef NRF_SDH_ANT_EVENT_QUEUE_SIZE +#define NRF_SDH_ANT_EVENT_QUEUE_SIZE 32 +#endif + +// NRF_SDH_ANT_BURST_QUEUE_SIZE - ANT burst queue size. +#ifndef NRF_SDH_ANT_BURST_QUEUE_SIZE +#define NRF_SDH_ANT_BURST_QUEUE_SIZE 128 +#endif + +// +//========================================================== + +// ANT Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_ANT_OBSERVER_PRIO_LEVELS - Total number of priority levels for ANT observers. +// This setting configures the number of priority levels available for the ANT event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_ANT_OBSERVER_PRIO_LEVELS +#define NRF_SDH_ANT_OBSERVER_PRIO_LEVELS 2 +#endif + +// ANT Observers priorities - Invididual priorities + +//========================================================== +// ANT_BPWR_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Bicycle Power Profile. + +#ifndef ANT_BPWR_ANT_OBSERVER_PRIO +#define ANT_BPWR_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_BSC_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Bicycle Speed and Cadence Profile. + +#ifndef ANT_BSC_ANT_OBSERVER_PRIO +#define ANT_BSC_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_ENCRYPT_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Cryptographic ANT stack configuration module. + +#ifndef ANT_ENCRYPT_ANT_OBSERVER_PRIO +#define ANT_ENCRYPT_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_HRM_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Heart Rate Monitor. + +#ifndef ANT_HRM_ANT_OBSERVER_PRIO +#define ANT_HRM_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_SDM_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Stride Based Speed and Distance Monitor Profile. + +#ifndef ANT_SDM_ANT_OBSERVER_PRIO +#define ANT_SDM_ANT_OBSERVER_PRIO 1 +#endif + +// ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the ANT state indicator module. + +#ifndef ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO +#define ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO 1 +#endif + +// BSP_BTN_ANT_OBSERVER_PRIO +// Priority with which ANT events are dispatched to the Button Control module. + +#ifndef BSP_BTN_ANT_OBSERVER_PRIO +#define BSP_BTN_ANT_OBSERVER_PRIO 1 +#endif + +// NRF_DFU_ANT_EVT_HANDLER_PRIO - DFU ANT event handling priority. +// Priority used to register the ANT event handler for DFU purposes. Change this if there is other ANT event handlers that should be higher priority. + +#ifndef NRF_DFU_ANT_EVT_HANDLER_PRIO +#define NRF_DFU_ANT_EVT_HANDLER_PRIO 1 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler +//========================================================== +#ifndef NRF_SDH_BLE_ENABLED +#define NRF_SDH_BLE_ENABLED 0 +#endif +// BLE Stack configuration - Stack configuration parameters + +// The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set. +// Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set. +//========================================================== +// NRF_SDH_BLE_GAP_DATA_LENGTH <27-251> + + +// Requested BLE GAP data length to be negotiated. + +#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +#endif + +// NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. +#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT +#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. +#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT +#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. +// Maximum number of total concurrent connections using the default configuration. + +#ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT +#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 +#endif + +// NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. +// The time set aside for this connection on every connection interval in 1.25 ms units. + +#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH +#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6 +#endif + +// NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. +#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE +#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23 +#endif + +// NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. +#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE +#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408 +#endif + +// NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs. +#ifndef NRF_SDH_BLE_VS_UUID_COUNT +#define NRF_SDH_BLE_VS_UUID_COUNT 0 +#endif + +// NRF_SDH_BLE_SERVICE_CHANGED - Include the Service Changed characteristic in the Attribute Table. + + +#ifndef NRF_SDH_BLE_SERVICE_CHANGED +#define NRF_SDH_BLE_SERVICE_CHANGED 0 +#endif + +// +//========================================================== + +// BLE Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_BLE_OBSERVER_PRIO_LEVELS - Total number of priority levels for BLE observers. +// This setting configures the number of priority levels available for BLE event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_BLE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4 +#endif + +// BLE Observers priorities - Invididual priorities + +//========================================================== +// BLE_ADV_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Advertising module. + +#ifndef BLE_ADV_BLE_OBSERVER_PRIO +#define BLE_ADV_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_ANCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Apple Notification Service Client. + +#ifndef BLE_ANCS_C_BLE_OBSERVER_PRIO +#define BLE_ANCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_ANS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Alert Notification Service Client. + +#ifndef BLE_ANS_C_BLE_OBSERVER_PRIO +#define BLE_ANS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service. + +#ifndef BLE_BAS_BLE_OBSERVER_PRIO +#define BLE_BAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service Client. + +#ifndef BLE_BAS_C_BLE_OBSERVER_PRIO +#define BLE_BAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Blood Pressure Service. + +#ifndef BLE_BPS_BLE_OBSERVER_PRIO +#define BLE_BPS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection parameters module. + +#ifndef BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_CONN_STATE_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection State module. + +#ifndef BLE_CONN_STATE_BLE_OBSERVER_PRIO +#define BLE_CONN_STATE_BLE_OBSERVER_PRIO 0 +#endif + +// BLE_CSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Cycling Speed and Cadence Service. + +#ifndef BLE_CSCS_BLE_OBSERVER_PRIO +#define BLE_CSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Current Time Service Client. + +#ifndef BLE_CTS_C_BLE_OBSERVER_PRIO +#define BLE_CTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DB_DISC_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Database Discovery module. + +#ifndef BLE_DB_DISC_BLE_OBSERVER_PRIO +#define BLE_DB_DISC_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_DFU_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_BLE_OBSERVER_PRIO +#define BLE_DFU_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DIS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Device Information Client. + +#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO +#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_GLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Glucose Service. + +#ifndef BLE_GLS_BLE_OBSERVER_PRIO +#define BLE_GLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HIDS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Human Interface Device Service. + +#ifndef BLE_HIDS_BLE_OBSERVER_PRIO +#define BLE_HIDS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service. + +#ifndef BLE_HRS_BLE_OBSERVER_PRIO +#define BLE_HRS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service Client. + +#ifndef BLE_HRS_C_BLE_OBSERVER_PRIO +#define BLE_HRS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Health Thermometer Service. + +#ifndef BLE_HTS_BLE_OBSERVER_PRIO +#define BLE_HTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service. + +#ifndef BLE_IAS_BLE_OBSERVER_PRIO +#define BLE_IAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service Client. + +#ifndef BLE_IAS_C_BLE_OBSERVER_PRIO +#define BLE_IAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service. + +#ifndef BLE_LBS_BLE_OBSERVER_PRIO +#define BLE_LBS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service Client. + +#ifndef BLE_LBS_C_BLE_OBSERVER_PRIO +#define BLE_LBS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Link Loss Service. + +#ifndef BLE_LLS_BLE_OBSERVER_PRIO +#define BLE_LLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LNS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Location Navigation Service. + +#ifndef BLE_LNS_BLE_OBSERVER_PRIO +#define BLE_LNS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Service. + +#ifndef BLE_NUS_BLE_OBSERVER_PRIO +#define BLE_NUS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Central Service. + +#ifndef BLE_NUS_C_BLE_OBSERVER_PRIO +#define BLE_NUS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service. + +#ifndef BLE_OTS_BLE_OBSERVER_PRIO +#define BLE_OTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service client. + +#ifndef BLE_OTS_C_BLE_OBSERVER_PRIO +#define BLE_OTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Service. + +#ifndef BLE_RSCS_BLE_OBSERVER_PRIO +#define BLE_RSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Client. + +#ifndef BLE_RSCS_C_BLE_OBSERVER_PRIO +#define BLE_RSCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_TPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the TX Power Service. + +#ifndef BLE_TPS_BLE_OBSERVER_PRIO +#define BLE_TPS_BLE_OBSERVER_PRIO 2 +#endif + +// BSP_BTN_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Button Control module. + +#ifndef BSP_BTN_BLE_OBSERVER_PRIO +#define BSP_BTN_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_BMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Bond Management Service. + +#ifndef NRF_BLE_BMS_BLE_OBSERVER_PRIO +#define NRF_BLE_BMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_CGMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Contiuon Glucose Monitoring Service. + +#ifndef NRF_BLE_CGMS_BLE_OBSERVER_PRIO +#define NRF_BLE_CGMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_ES_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Eddystone module. + +#ifndef NRF_BLE_ES_BLE_OBSERVER_PRIO +#define NRF_BLE_ES_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Service Client. + +#ifndef NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +#define NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATT_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT module. + +#ifndef NRF_BLE_GATT_BLE_OBSERVER_PRIO +#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_GQ_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Queue module. + +#ifndef NRF_BLE_GQ_BLE_OBSERVER_PRIO +#define NRF_BLE_GQ_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_QWR_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Queued writes module. + +#ifndef NRF_BLE_QWR_BLE_OBSERVER_PRIO +#define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_SCAN_OBSERVER_PRIO +// Priority for dispatching the BLE events to the Scanning Module. + +#ifndef NRF_BLE_SCAN_OBSERVER_PRIO +#define NRF_BLE_SCAN_OBSERVER_PRIO 1 +#endif + +// PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. +#ifndef PM_BLE_OBSERVER_PRIO +#define PM_BLE_OBSERVER_PRIO 1 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_ENABLED - nrf_sdh - SoftDevice handler +//========================================================== +#ifndef NRF_SDH_ENABLED +#define NRF_SDH_ENABLED 0 +#endif +// Dispatch model + +// This setting configures how Stack events are dispatched to the application. +//========================================================== +// NRF_SDH_DISPATCH_MODEL + + +// NRF_SDH_DISPATCH_MODEL_INTERRUPT: SoftDevice events are passed to the application from the interrupt context. +// NRF_SDH_DISPATCH_MODEL_APPSH: SoftDevice events are scheduled using @ref app_scheduler. +// NRF_SDH_DISPATCH_MODEL_POLLING: SoftDevice events are to be fetched manually. +// <0=> NRF_SDH_DISPATCH_MODEL_INTERRUPT +// <1=> NRF_SDH_DISPATCH_MODEL_APPSH +// <2=> NRF_SDH_DISPATCH_MODEL_POLLING + +#ifndef NRF_SDH_DISPATCH_MODEL +#define NRF_SDH_DISPATCH_MODEL 0 +#endif + +// +//========================================================== + +// Clock - SoftDevice clock configuration + +//========================================================== +// NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source. + +// <0=> NRF_CLOCK_LF_SRC_RC +// <1=> NRF_CLOCK_LF_SRC_XTAL +// <2=> NRF_CLOCK_LF_SRC_SYNTH + +#ifndef NRF_SDH_CLOCK_LF_SRC +#define NRF_SDH_CLOCK_LF_SRC 1 +#endif + +// NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. +#ifndef NRF_SDH_CLOCK_LF_RC_CTIV +#define NRF_SDH_CLOCK_LF_RC_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. +// How often (in number of calibration intervals) the RC oscillator shall be calibrated +// if the temperature has not changed. + +#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV +#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. + +// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM +// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM +// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM +// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM +// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM +// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM +// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM +// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM +// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM +// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM +// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM +// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM + +#ifndef NRF_SDH_CLOCK_LF_ACCURACY +#define NRF_SDH_CLOCK_LF_ACCURACY 7 +#endif + +// +//========================================================== + +// SDH Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_REQ_OBSERVER_PRIO_LEVELS - Total number of priority levels for request observers. +// This setting configures the number of priority levels available for the SoftDevice request event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_REQ_OBSERVER_PRIO_LEVELS +#define NRF_SDH_REQ_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STATE_OBSERVER_PRIO_LEVELS - Total number of priority levels for state observers. +// This setting configures the number of priority levels available for the SoftDevice state event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STATE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STATE_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STACK_OBSERVER_PRIO_LEVELS - Total number of priority levels for stack event observers. +// This setting configures the number of priority levels available for the SoftDevice stack event handlers (ANT, BLE, SoC). +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STACK_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STACK_OBSERVER_PRIO_LEVELS 2 +#endif + + +// State Observers priorities - Invididual priorities + +//========================================================== +// CLOCK_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_STATE_OBSERVER_PRIO +#define CLOCK_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_STATE_OBSERVER_PRIO +#define POWER_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// RNG_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to this module. + +#ifndef RNG_CONFIG_STATE_OBSERVER_PRIO +#define RNG_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// Stack Event Observers priorities - Invididual priorities + +//========================================================== +// NRF_SDH_ANT_STACK_OBSERVER_PRIO +// This setting configures the priority with which ANT events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have ANT events dispatched before or after other stack events, such as BLE or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_ANT_STACK_OBSERVER_PRIO +#define NRF_SDH_ANT_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_BLE_STACK_OBSERVER_PRIO +// This setting configures the priority with which BLE events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have BLE events dispatched before or after other stack events, such as ANT or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_BLE_STACK_OBSERVER_PRIO +#define NRF_SDH_BLE_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_SOC_STACK_OBSERVER_PRIO +// This setting configures the priority with which SoC events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have SoC events dispatched before or after other stack events, such as ANT or BLE. +// Zero is the highest priority. + +#ifndef NRF_SDH_SOC_STACK_OBSERVER_PRIO +#define NRF_SDH_SOC_STACK_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_SOC_ENABLED - nrf_sdh_soc - SoftDevice SoC event handler +//========================================================== +#ifndef NRF_SDH_SOC_ENABLED +#define NRF_SDH_SOC_ENABLED 0 +#endif +// SoC Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_SOC_OBSERVER_PRIO_LEVELS - Total number of priority levels for SoC observers. +// This setting configures the number of priority levels available for the SoC event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_SOC_OBSERVER_PRIO_LEVELS +#define NRF_SDH_SOC_OBSERVER_PRIO_LEVELS 2 +#endif + +// SoC Observers priorities - Invididual priorities + +//========================================================== +// BLE_DFU_SOC_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_SOC_OBSERVER_PRIO +#define BLE_DFU_SOC_OBSERVER_PRIO 1 +#endif + +// CLOCK_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_SOC_OBSERVER_PRIO +#define CLOCK_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_SOC_OBSERVER_PRIO +#define POWER_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// +//========================================================== + +// <<< end of configuration section >>> +#endif //SDK_CONFIG_H + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/NordicS.jpg b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/NordicS.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2edfeee845bb5e4cab76070f067d63e97a3791cb GIT binary patch literal 20023 zcmZ6zby!tlvpx)hgoG$aBi-Fy3P_hocf%$nq*Fxcj!kX4yBnl)Bi$)o;s&<#x6t?f z&N;t7xVWyxta)mlnS1V;#Wz*ucUaGepCKS1V9Ci!sUsjD^&uc2K0!kPp3F(O$pOF6 zon&=f5D?g?AAb-%^2OZ|5GWAjq$D*w(vMgC?MSV_>+nXJ;akf0N@1b}rXbegIL=T7 z3U%3lu71RvekZn1h{}@=>j->L)P{N`9fGJcI_*%cV!7g++q%PqA{=9u^rcwi1k+;; z-pBi&SXO~v&NnMjEr*?-C_8X85`JW7Li{8EIK*Z^E(Mr0G;H2(+*w+#z_wj7CjnKI;5@_iveq7b^k8W@0 zEcnR>bW>$wGnq)vxBV$*diO&)oR&j`+*T2(kD>`XXWvYl7!;+*Ouqhf?3;@h zL7M^k@67Ho-tBt4M?^pfFvsI!xLj=)%0pDDW$rOC?{kcU(5;Od=zyn3gY31wG}=-z zV2^^F6m@xlsTu2J2bq==B^mFOZ5z4C1)BwdNq>Mh_90>dCHO&`T?w~h4F%QYEQyK^BhWR(yQuA+uZR>Mzb z8lHd&ai+}^X0b-3hCPHUA!87Ms-n3U#aDokM8roDJWz>iUS!P6H>&ZJz)mVzOOO^j zG{vR_Z6f?vh6vC5)G(42QXQa_KhcKSEAp8=KM5#EF=H~JJCg>1ETaRVzXPZOQ zt2(D=*~OE}`3u5$c&IzP0(5^xLUuJ&({u3^8dyQ{7j_*+mM)KmqFCzC^a3?_vx~Mp zO7`(CNSFxX;(@|x4@J#fEDeLfAyiqPfxDx8P`_mkZtnq3;jcF7WG~e+x1RVs`Nr*_ zf*yR^J{3I{!7R&D4^>i%f8!I=vOY|8OG+WLX(vDLW# ztn0jf*&pCO@s!MsS0RN?B}Aa~$<#ilv)%wMVStDN&0kqX==>A#WMl$Y^Jbx2&&T6* zr*$XYIN(^Sin=*j(*dW1|9c*2+tg z)w5W;IhVB%b!d;avpOMSuTVMxlBf6c|jz0T!J+owwT?2~9#lbgFkY*od6n$S{%C&`+`77qk0Z_anNB?|e^pePhw(m3e-XrtQMx zpc1vkl9GF$kKuWY$MMgLV9*0%0?Z#(kJ`Q6xK8V{JO*=6 z2JFip4?<%PRM-U^Y8bvUAmsGH`cde^q=A)nwT5*vuYki}0~xbk`DpS2&#`2$|)0NVC1JB~ojK)-5?sMA~M{B($$D0?lzo z_xm5uK%zvb;r=6Vob>3xV`M%p?|W#-+5>8*+O<0r`*dw9FB`oF93|c_hXe?NUu!c0 zMn^my^dz=y1?GR~e}8e1o%LaMPSDJH(gsj7O#sMIe9)UJw6bpgY-#_e;D(-mwq;e< zu$-lQZTmKxXxEJk8yHx&k6*I7K&e)bL$|>l%5HG`r=a=I*;wLCD_kJx}M0D2H?bH){FzLHJ@7J}sGu#rJ4^Zs)JT)ZSmIA~mu+m8E_nA0Z&2UP^E6S4Z zPuXYZ9!?~pA5P)!?k?^>0;chy&Or$L9+?D+8Z*k;yx_Jtd=SQUXL1nx8a&xU0kP{f z6qbjn)R9*@AUnqXOwUPs!s^rU1KW{{cdg2qzrV#kee(Um&W~t^6;@#<#lh@>*9)F^ z;zWByqz7KsJ+S3m6=!qQJAx>#0F;+MJq+X2+Fg-)vBMv`hNsN;GSG@ce=CSp zRi)Vy{z9{qD(M0<5bPMYtOIvF&4@?qK#TCZ8G&e48_rCOt($xE0z)6E%-u+9;X1W& zq!Jk>FcFnet*2q)SD05F3*j#|^D80mNq_eRV zC!QU-FLvyPoix9p>1pQfSl_vc=Mel(5grwFrax#r627(D1fj!muhzF!<6j;z2q4|P zNP);#l~gj{r0P&keyD?!2_!J!^J-_7>O?Y2RULU6+L4U^+!rL9I27+U+e9 zYqXjYBg6`Nz%U#2w~4q);@n|YqEGg=YvkN{Z#F8<+kdOv{!JV`%)-Lb=g_Fk{?E>H zvAd7kDw=b0#a~{n2)7NdF~g6p(^|>*hhRi>3{m6$8`dXc%W*icuA2l5a;I`Ch7OhY zxfZItsoB17*+Bho*win$i18eEYq0$?PVi%@As)gZgEUI~*dejC|Iz=C5nr?HC8|W#G!twz|s3+XK~3&$imF zmJ6+r@3HvG54V+_2Ui>Kj3&OLr|sz+eI~kdl93srketG`aQet;hE#_8a@r%aF|T;Q zDY%WDKoqKXA>s(O`pio!I=36i**SS*tjjGL^Oh@i%QF)>p_8jWeQd9P0QG!+8=O(T zQ1pYz7yB-RbEh-up%mA&lNOh@;$uv5js(XPR%rA^%+JLLTa=Y+h`x78mDb+m+Hhfa$Ic&I#R z)B^4bag62Q$WhEDkW?z8rw+^)!f<+28U0H!23HW+hyGqQMN^KM#+PsU5wd)2Q+-^&kDSTn^9a_-=e zxZNMq+ivu42g1hiwGchB>`b))|C>NxF70tSjEE zh9Ao4y^G-Fr)AXjH-t%6|M1#MhMy9V`qxBznQ5yvdsq6LZKdsO4)7QAqfBzYMc8D! zqwp8cZ;-bU%x1Qr$2bSq8f$AsdK$%jAR&d7xhGU4uvycosAYVmu9d2UJ;?Kq3+dFx zyJr0zv@w!X{Flh-T(@t|8XR7Sf7KZ)?pUgGG$q=~cNl53Jl87I&T04Pa_`^GG0kMH zYL}`yV$wKhe`5Rc)>X#Gq;>qoQ%Yuw(-&w0^d3ewF*pf4MW&12Er0N5x5TAxe^;1- z8o5vAeM$c6pUA??OOcgY5N$;k26A4=RJ2yf%BjzJ-vwaoPKE(LtEhGn44j)%V2c}; zSRmuk-bg*Ph$$DvDGk8~#vk8Wp3!-%%G~$nMmh(PH=m9v1Z0lxuP^)8pNn6AzpXtqGNjKZmPNJ)s~7mP=s3^6wrO=} z8I0N}X57EBdc$pUP1-X2)1s&v?6qzwt9tVx*uPVSA5wM~hrVrdcSAmRZzlSM?J5gE zS%}5_ey|A%U>ISMXnf(XE1kuwL<#uH>W-rePs@ZQ+jW1t4oohjUsTtH%*ere8@5<< zUnUUZ5YkIzi4(Xyyjl8`tt{$=C+ELOalH{&~GP*t8 z^`s<77e1zuc(@PRIt6z=D431rgDcnOW)(KYOJJhGfCDN=?JFo)^*ER?gh^SUGR}O> zm?lxcC?xkge+qz7Z^Cst&=+uBQbeukQG!_;d9iR;f$Jp>4uAek-F`sXpKGid^80!C zT{XD!VH$oX+Ctn00?CD1)+{F_97zE=;xtL8dzF9fY6`w`)kgdh$u^8!6BE!3`m%J) z{nbhL?dUV-L)m=y5gx|2V&)fw1JMCZjK_IOsD2f^UF>{Uz7O9CYYmofKGoAsvA@I$ zLsECVy`0*fEFN&LJUz!`b;l8wE51KAs;rp$j$XCNLb5lX8;?DW(-<9@xlD;jX!=2}y+d{dCBkOq9A!*$QpxrYjeDH&=skx(9` zDcV}E3^qY`{qmIP4J%TG`>IY(%8OMZFG~$wJ0e`CGd~VuLg?>Xhv8YgJeXV7_3GJcu+} zoYNDVowN5l-AbE#IGA1Ou8T&$QU@Fs%SFF`uGQQ{C-(&R{9LSj5ONGZYTZuaeHG`A z84?291_HM#`rwifOC)(;GHRh;#7cr34Evy=+u@Yco9c3}!vH_owXAq_tO$kc)|wjj z?l+^mJ{rL>>#Kxv)%H-tmEP!ATeD+AlkPS;Ya{EPE3RI@lXfMYeEY8!H)YdSX#(pl z-`_p&Pk9)FwRQgT?R5WLVz_?Sm36o~?Ktwl)8E!|WhJhCJ5l_7BqXh|MEv^aPR79( z6@T_#heE3o=+S-)>~{5}x1thbj%kGdWZA{JVP1Lw0C@es*I8adVLR&jh(a@OaD73W zA_N_$-st2vZ^B4GW1uQ768J$Zwipc|u>z+=lBCY&eydLNYd2Mq?9}GZ0e6`TK8M`%_5be3nN&CvHw2e&}vK%)##-CZ-t$lxJiet)d_A5B)*pi$<)q zb7azN4$19*cN$G^xol3y_G9TRK% zs*wJP*l+7yH&kp?L2B0Y`zs^=8QAzcBmIY;mne?x6GDqT^>S9_@fFnAK^xUHhxTp| zUa-28NDua4q>U4ceN{tjX>U_CXRM1!jH^6P6QA;Q%XIsvhn&4ahh z*u8Z(HYY>F9erIXkS4^86vC;QW*WMvl=%n;stq3a6%QTzVJt!o-Qlj{U~OwoK4L@k zJN2witB9-bgj1l1tI#-NR>te@}HSxFJ&j~m{L)!u#OYbf08(vh$>yDwe-gejfp|xAjTij2BRdY+e(_kUEF}LON7qM7x2D%*$aJyF zz7a}|IX^xykzAA`_bE->e3Cu2(!*9osTK7#q>0_2fP-sGdoHYpABqYz*q4;k8fa^= z^ibW8dA3w86Z2P_{O7QP%z7Pc?i{XeLtnwBNIQzeb@+TwqX zl>q4Pffb=j9|1>w9-27Z+2I+EZz92SWJx@J$>fZKW98tKQ)=3PWTqKTJqf2iaHv&# zf!9b8*wvKKWo}SlUDA2{VN;={nOHsH3L-#p(Z41xGI613L{QrQH6u^s!6Sc>l{LMH zALY$Z7t@(nPDHgJLWwyq1-3PXrMJ`gx_C>|)G2zHULO2HE<9dlnc#ViuNc}_ve-1p zymkAT!j0Dm5d45B-OXuA&zcTkf-HlF-$INt5^rl>4y@afv~1OlHM~y6{)*JnT0G|0 zOh5lkh-()#87`$jWtUi-a8C5W1AOMXxap})L*f3e;{OfLYZ|AR@{ibJ2N}stsb=J; z!45mfaOiu1u9}V=2A=UIN-9lzMJLQTAeNUZlba6B<+-RSRY(W>?)xFw_d1963z!Cojn!0^+N?53HYD66v?$V@>~`(< z&-V8nm=sk>=htRT48`Zg|E$noY83N-!SeTlXeq~h;#Q#+4eISl4xQ^W^s$N z#$b4B$9^2Xawp8h!ot4CiX*TrwW^BgQ^2(;iq7%GN|AjTK7sEqa_QyW(CHt9HcSEq9HvidQ=XCFp(^`;KJ7muY#?=Q#`XoBkA;QT?hTM;DYwo(VGV1HPemwfP+}Qz1qgiAqY)ao9!+`}rJV>CI zZf+`~yj41mN6X!a5;b<`UlaM18YYbmEX-m){K&8h@9zh(scGGEKw)$&b@@7U0#*I} z?P|R@-(^IdUu4aszERZ=tpirFRs7c5;;CofP%tvWi0d!gT;JY>pr@34h9F8*9ibP- zW|J*NHg`*tH?X!4a;1YhQND3|pgs}KyoKBsMa_UsdC~vBJrF`ju3LI_;r0+kwuC*{ z4wEIERG;Hdqb!oC-W-8sHLcJ$A~^Q3bQ(*|nb+=u@rW;S-wV0+v$Rl@VRgsl4bQ_= z0c(V>(3E^WCFuphg?@=}h=3t-AN+kmrEWWzWzZz*i6Q-Fy$4yg~jLR4Gx3qN}uU&hS5S4Hk) z1sq)ReljuI$Q^y)fiy-u zzuu3y{*L+6$e?2h`>oo+ewx>&v)$ullK6gs?$#;AN6z(1jEsj7+NU0+SS1QfHL=HdBlmH}|6>4r+=|vjRu?3l zFe#ECG5$Tl?&OZw} zc3Lgc6z7PVU{`6~JRIX>)gH~9LdF;!bxr3uO`bu*OGXBcpiR7g zS){YkDe*-=LX9$NhZ(+MKf29S@6+ELlOr1(sT3q`P4%y;SSuDxsTq`i)cP8%yjQ`p zn+D1M} zLW`&|uWd{UwS!s;l!k8BZ~SI!1wZz{L`ZNgrJsdut@6a7k48{1xF<}L_&@xTnB(>} zC?iH1#3Q3Hs&N|SCbFM0HV?A{yG}|sx`+$E(9dZ%=EK1g zR{WQZC3$Vp3kjn|A)0?XB5o&zoyp_yWYm{-O-2=jton?q&q^#`{PLt`wzhJ$@QBFp z%6N6to_)6${=J{(d1)V!glak>u#m;>`!O#wT>-?wCkCQIHXEuc-kDZgyNmcY$dcWk zwi`GH&HG@IT&qoGt-~WFzrLQ{aF<~Uv!8h9T5l3Bcl3ur!u_k;MdB~ zvR8LL2u^7Y7O6D=R3ySglgo}uj+`5((|ZoS^nJ)XVuF@974(wf5gd1{>lgq|gXsJ* zBW}b_ZjBaM^labTeG;&gw=)5pMruU+1>fXz^sue%^Yt~jZ{=!o$XH;6gTuQ;t1o-z zCd>7g$bHAcG6vN^NrYP-*qhZ(t6wwOelU+m=z@?OsUzDRFWE2kWz~%Yshp)Cwoz$n zR{`J8H3{{B&)tWh7ITNYuisoPy9SwMR)yfVX9g`WpT^G8o;JTK|6i>tN5$%nm|fCf zFB|Fr(X8x57C?=<%wg%0#TKttO*)lbwZ?`7N-bB|;r$s=gAEbtzrrI_5BM8%>He zB-4M1RI1MD;P1CPQ=Pn>Lr>1BJ`)j8`!)6=1JK7!-%;Os-v8d)8-RH05KfF%j^`w1 zblkr!xhHJ1%BT0+%DyZxe88ESCJ=`9_l87%8)d1w5HbEZWP;o$Nb?vmwRHv5fR(*k z9PaCf7%!`@EjEqmUN=h|rnaBAWs7b;T!he$C*7q?}T`E5$E}!SX1PUu)z16Ri zgX32@JI;d#UBJrgi$%`6NF#}cw7~`4>dZMT{|$7FFdx5fR|1GKMq4SxLmSz#16Y|+|r!> zMAp@;&?LN*YEH7ck8G{abCDCw6r<9~UCF>zvUwcWMX;>G5!& zhvtfu+T())<)=g}3KSF-RUfY?Ms6gKm2n9RqalQD|0nS7vLIFseLT)}IlovmjE$Xc z%V)_~2ehP7o%lEiQk#L5f{!L|Ji0$d-hCEJ`vsxNBzQ?^^^uC3f<)9Svk^RFg(%5M z3}CoNTK<26au>0EBurjyyz2BOJ_!^aS-~)7k$o3>lAa+Y;nOTz+N(F;vSU4E9_x_F zZ&j_;n4Q!lc4t?kqemL!H-(|Ig!?9H4kjY_&Z>4fG!;S^dvtohQAvJ8etUxJT>^mC zD(NMjF@im0`syc?!3l6zdaK>RlAyAfy#OZk5PMp4VCM5PAeNEy^bSW(3n7VTK4$Ug zZt^kTqDytGE9pxY0l(^|fby2^h65Kbm+}AlnsiYF{B#!iG&+M+Iop@U%dj@uWL-X+ z%B80UlycuSe%w^*D(Ak2zE`N?8S+fHnfZ-<6i8*IB9#M;q@nlCYhMithXZw;mv!vC z));*8^%_n=rgcAi8{LyvJ!~DH1Mz%Qv+jEHvr%c;o3>NWRXebo5iim`481JiX%epm z+2v#rmOXee7v7&DKJ}>NkJ$^^81L*!hVVmP_C#e zAlF`9=ad5=kMz1m+n2oh#Z#}o7JrW3`pmhb6?dKV(^!FTa&oaY59PL=@DKAytJ-^` z+7HhtqNB7xYURZStOym!e1EKHPcP4~yQFqIEl!E9R>K8)QHET@Hv8|LPwB zgi16b%vr<+fwH+t*LBzpH0563`wyxseB^$$myp;jEQ>Z~GETlF&r3sH07nQG6rUBn zeXpuAyG(LQONvQy627C;;rN|&>WDw`VW&$rt6?G2(^K01POHj7YRe48i>g_~U)R2%SL zlVY4iQns^CrjVALZgM(ydu&GPu2NiW;Tz~4wZq3o)Yk?20T{B;q zk$QDMF2A+O54EIWXb?Q3!DXSA%kU39C7)xF{}sRK8ygB~QUQSs43Kqaw?H&QR+o&d z;U6_aM^HnLfE#v3e>2=!w#wNFKOCTm}0Xd;E`(T5p| z7{7e@2h)E4qwWFkLLw2~|7^CP7$+@4hcDLrz#+*-=_V&X*-4jAo4G&L)i5Noelr(J zP;qRXz7`3F5PtJ;a8#Mo3msX3p1YMh^&|2qfbyQzI!8ak!G3$e+<1(yo!V`sQ!hOBJ{9W0if)1Z0xUdO#&1fB;xzSCJTme2pfX} zny@-fRrKtz_*m@CUwTp&@v2}|`y%(p3Z^{{It^s^ODf3<(C6nG05-r0!9IHSp-0-7 zR4ybyfRFDGKH%m;MY9!DmquHV0@OocLZ>JJ9E)7G zC9?GL01HLgKrk);5@(?6BXNC-8?P_dJEp}ag&a2=O>aOE@4^#)OjGSn0@L0=2Bz)# zklC#jdOfz4L54hlKwQ(NR}s&%Cp^y7i&T_Y2dLn^=yNxi^$v1Lf9d-=QoAkmw`p(w zoTMsd;s5Iz(bQ7-ln@PQ$xW;3<<#H4lf|m<-*K285P_P#;x-&<5mFqXMIH2}C_d~@ z(F*fpYoN?BqQ3Ur0YaXDOJYpOPg>A;R|W4WO0p3Mfe?71^j@(=3Q^P^x7hm7?UJ<0uKR0fh7#SMbrHTz zE7-xov`SFk#C}zl7NA%{Hu}9b4MLa-kRGc5y6^*1D&5fCa@aT`2YgB-19Tcglj;li z^_N8*@dQ((%xUba@lDCUdtx(PXkZ83gaEO8@f}CHf$lw5fsU9bb`<+z?M+^I@#GRE zgUpV|(%j75T@R80P*H3}?OI+7IC%3zl2#Nb*hD@5eSyt1AL_5kObZ5F zdTJe*7d!d%dQgLzV787}eYf-L{<>GbtlbyjVk>@0PAe8V&|MWz$D&*}QLqmR7i#`AOgL2u?{?MHT%2eFuLFG{R%hIHYV?jY z`Ti`WbD&V90fagr2^z>cVt%Oc8n``qmniSn!|u!%Xc}ic0TUt8*WZ5m2Mn~UmO9b% zV!6+Un3X!~Am!+&zghX<;@|GLPZ25#O`En0ZHq^zU_{lPd~on{z9UHPfY(Dosh^46 zetD8<&+c9-8p`XTg~ek02d9v)7F9g_nX0_ST62Ys=Schv=BfBluUIKN7+SmQSu^~m zG?`e)g*~lJaSnMf_d4<1e6z-|(&Z`IXTVv%r!R$P?q>Y>z)HX>IA5apu-4}Hr6@=Lp)%Ry9_*Hc?c!neB34(PX%24ig8TP$5#g0pJ8Lpy>B;VT?d_pt~ zG7i4(Rz0`zAfqxL*F&~$XLlStBX$Td``QCBU07#wgE>K&?JrOfI!b`~-cQRc zlp#HCLEEf_HIZBp@&ab5^y+rjxy{d{f1FI46HN2sUDk5jTY$Hd%4HmrR2@N)MOf$1 zovjCeSu_9S(gOG7k`0^x^@r_f2Muz7NOU!)BPKPI<8b6XHKgAC>Ie*lxuqq#$sE5CmLUO~Xav zU%I{i5D=3SYYw;x&o2n z3t9lyhn@ph(FyZWBZ4GnRUgnFG5SCJS^DD}6rDwkCX4Dt`;&)}bn<9_xg;zcD zoD&kNe`^z-IkmwFwvVD#Xkme90F723e3y37U+47L?DsnuLTDWXY~244*R}o4j|;Df z1pdRc{+qeIdwookPYgVBB9-Jc4g}`)uMP$v zuE&Q2z{A+TTqXhhq5{Ygfrm|@U{eajN1BxU`1lB@{@898W_?gd2b$p#y0FUdkkDfv zUF5$MZ2#{o0s#<0+4-)D49nZ04uCL$|96}7zMk7q(EcYvcj_7#dBd-hR}I!qH`^ta zMW7_HQ6~KMu(hXaa4k}nh!aCrX<^T{PZAD7t!bwVIq|(P_tk9`%61n&adC^+!>#}?VPZJpnp2OGIBrq^?Ga+ zk(zs!&j*H@<=6b1zVvWAs1x)Tl$qclL1Fz7obmlBNJ_VL(m)$Kr{ygCE)*5B)3l3GQXa1VRP+DwN3z8-BjzC^Fp(># zmU(jtyYt|iHUMG&=5}?`ASA}KFD!?xd#(-%ol3VSCM(8CLNG0XwzQeUQz;C@>K}(r z`jtJ+D5nZ6KZWMLeTGMJ7U~J?#QCk=c&()?p4|zTmM(kpl_7bcgIBrxeNH@A%Z?9e zpa;vXJ?xi`+uhJC^F52f!CG3J=4A25hAAItOEv)|M+?l)fV`v{=1Dv$x z?5R8Za*?}ljeF>&&|}xg|KI0forL{mckvHS1+BPQi!l<|tGhRl4=KY72`sQmPrrAi zGbuqkPIeh>Qzb|Mr%>?Atca=O3e<>hD?D8gSfv}qW5xM_=*ht->9mY2YJ`D*vJ!W% zh<-p<)`^3vEtHJPBVaf<@p;Y$D~g-9T3K~D2y2ahuA{}^x)xfxvy*|Pd4VGg0E3(T zkNeYRt#hBeEF-xizFL~To>n9%8*fs>nVJl3MUipSGN|b&DJ-SpZZWm0T}ekCsK$Ec zR@E?JIc!YbeO6FyD^iw^E6r2ZeP)M9j{@HDT&=T|?d4^xBlBcShk6^AmG0b%u@ z%HG@u*GazQbA38BB!fu_ZiT?Jg))(FfJk?O0olU3OuZt|L-t7e|L=@B!fP`#q*J47 zrKm>}OONR5XJ3__gNo5$MCUlhb^GVYpeLI&`Mh6QO^MygO`dEW+u$TmnUVPf85|WPN z57_3P{pLSErB8M%=x{gY%4tP%OkPcs8lLhYStB_-NqV6bH~Ix=qVzMZ!+nuexmej3WO z-q2^86?y+evb4Zby>dIXX7PKoy=ME(4=JCA$ospL!v(8e1Z-G4wIIg>vhAm@rdvF)TP3i)huRYT6%uRgkOGkj>#$#mzzP zOCxdMGnZ=|%U7(eG!VM>y2MHPM z^Pwc?{!|i>p+L3f0Je|cC(GdT3ud`uv9t1(eE!VEB>+oMS^trwAur-WJM%RX`x#B( z8lPDdTqujwR)y7IOFF0?R@zZfG&k@R{TgU$K_k(a(+|$|!kVr4)f-Dk$Y+cpE7K>r zPfoUxLQn@i@BYfHo}Yjc67Q)%nItESb-wMUB>gAJOnL!PP-^;H_K4c4fy;wo%7k18 zBi0wC%&CI3rsQow0jfFBeDlPimpXK78%fZ0OnWxpgbgibRD?iFR+tYzE#wnd$3Hd<-fniR)?-7>YWeMWCB5TR$9%Nkp?jq1Bo0fd zmd&XqtbgQ*>aMztNSXA@EwfXpPs=H1worSr#lywVQz)U z-~tqm;^ui`7&F*B?LtV4`#tffqH4EeD$5PI5B=Feq<=??ZNGK?$W}v> zZ|Rx00SvnWJLI@czZ!=@+VjEw7>$gtV9-0QU?|4L2?AjSf3E;O1UjMp5yk*bXo6aR zp$P(l21d%N={ZoxmE%~iEtT05AQP8a&Rg~PUpOe;UoGf`4x@*W-pBP0&7etpR7TyU zSNXGLnzavN&M%hynmr6cu<)$5DzfLY2sHJqKnSfkHM(9Dl^1W;SB%w5*Jc2j^TTHDlGCclpyf7>1?+m6*pTrM=L6zJlsHIBx(8jcQMk7RO1 z0PVxS-07zw%@4&`b)zetK})M3O{&a&LfNm9gp?LtT}|Rs8ZsG8E?SCF`n)niM77da zd*dPVF94%+?9?XDTP17|`ERw<>bgancf8V4QzA&nY%yV)oQ6FVQ>uXkVVVT*b3T2G znCf#9CqV+7LyB@Wdw5Oxwbfm7o=#9@FX#^ORrrWfLZ)5 z^*g8Bg~$Z<9Lipq9MZbd4sxDBlaDJ@1{!fj1EB#0JdMce^qEA2u zT*R?qJ12?^0@5Jiuhvi4`i^XZ<7=LC9{pEKSs75kWouPu64K!apj zXLlNu;%!||-ebI0f9ZbOlCrT;QU|r@!D?i&@Q;)m`Vh?CJXayZQ0eT){~H@M3UNtW zr*rAjxrdCp#U*~S=OB3MZEh#^D7rJW-tY*pE!^N}eDvzu@jPzI2 z;cq;>%4?%?|I5t+Wx%1I3d+_oTrW)qhRgGkZDRQhY&4i#1+}LG8Vor|?3!kZ_*yT0 zW=RO~So3kwCqVpmu(X_H6$IxEF|Ya5GIL0*SOz8ksa?u*2aS>Kil};|R$*F<%2FUV zJOeJ}BV1`~@SD3`9pJBgm?>`!PG7Z~O4TVw1L6i;@kzJ#1tdf6Ij%s6KycmaJP-*xP7J1ls5JkJY93||t{0CA zjaCa*1#VnbMP9y~x2Fv}D;py+T!S0zm1=*AskSH_T|jYLT$&;AhxzJF_7h{3=&xc4 zl!@_$Gt)Gnrm*R+1)_^)dJ&<=QF0~ciayn@Zgph)Nz~UI#>T?XaEJNayHa0P4Vx~A z-eAq%i+Qq;o2iKZ9ze7;L5lLcrf@qWE%@|%B*}K?MDBF^-y3<7*12RhjZANRo!iN{ z$+i1tyBZP$Ob!J{53r|Af?1QFbV5NQ&er=ie(_OI(efZVlk zVe19|h7iR5%ST4@;Ot`*@iFC>BGah+G@^^ZSE6=RGm6niQhSiHA9U|g?Jf>xK&5I) zO0@ftR_BWtps9qb#7#7kPz$%(oFplRA;NJG^q@%^O{hFWVc!+!w~C$8B`Mt3Xp!zb z^ujPX@rVW9M#nJz4YK-YQLAyzw}^=iS(Oi$8{O_e zH!OPJpA;-B`|09bHrpKP1HQDhwD(1=(zul;zjx4P`jz>y^4xc;nUlneR%EuX89;X` z(DQ%w*xy8!**H!#&UO_r<$5qe$xa0=c2nbDD47|xb#BL!IlwZMuc(;cD*?@SE%v$I zR3TVXog|p}KJTH6pIn~bGan3t=51XZyX|`uxu4jVe`!qfH0E9rJG-G6_+CLy0!@hZ zBH@{>%G}QO#@0s@jw&-$cq|tG^_xrz?amh`qCiKa@}FNlWofsku0TY_90j;%2Kjt3cB;0$t=jQ3qJGGL|t%=vJ;Q4601d%wDvsP zO}PE6(Bh~F+Rdu_qy)?mg>PvVt=8b0}GXGE-=1_`I%*>rET9^w!`2iTB zLC3Le;|7`i>xX}=OBn_CRh$}e(gc5?OUx!Lle zHVAl^ei>1v?uP!#^I_xLb^O^s_!!kHwno2toGg)*g_h4Y)X5hWPhIfcEln%8^0D5b zjhqX_22Xn)zPX-7Rqp+xn2O%Y7ng1xo+3lG#LWxz)jS1Uqn3DSQW4OW2lS`@`~Jh* z-Al0}Pkv7g2K*C&ACLbRAaBg8Zqy;-2NPM-tR5CdYgA8A&vuN?jiN(CesH$}<%6Q8 z+|DLi#I{v$-EUG_oR;|$3gylRQ^kS!&s8k3k26d*+e;@2T29!Is-8h6RDwXo69CFRsJ+y+x{jpo6P;4))9J*JV`oDJ0v^4vw(^n0f@z zQpbfO`R}8T4cGQLui|LPa5~t1W%Mwk!sp|1iep zcFAPjyLdh2CHi?1PkOVH3?~_H`jcKBi&fS26?7TDe{k2;Pvb5iN{l8P(to=i(d?7)}U(RK80#Q8k zGXX7Xr#+VLdgF0P!KO3TF^f(iG3KrDA{YuYgCXRcOMmU%9wWj!w@_tPa3F`PF3+o;2qt=xvoxF441tt7gYtKSHi1_ zDX-&bd;TGHmtz*Gw%siz=WkwjLss7_c_0{fEX6LTVG}nDJvn0Ue_rdyz;Kf!Yqv%C zj^xUc;tgrBr4(~tkE{0wz=Qjq`=UlscsmH?dI%{)<&iAN4xqBIA@=r<1i?!C8 z+z-{WYl^kFHIkm8MFAgOx|zPBWqvb>!rbzVvoM%_!P!evD?aobiS;NL9>=rkc;V`i zIk(46H>~I_3Vd+dNNW5!FJH;#5G=DMo`;lNZcd#wF>OM`!LLmwM4U}-St{;r_=(Ih zeAiPA6;_YW`?c8D-d9NSg*#ct=8d0Ta4Fqn8i@7aY__5obDxv{<{H`?(*fd15z^bO z)bsLB^AUf08jaTJSkdj>F;9_}Q`vXuz%zbdObOR+H$(G#P>o;n&d#t}(PUjkE!g25 zomp;FTaDJv6kPfNt$`ojwO`KF%g|%4f`0F6*=8~-@a}TT>Er|YYf*rfI3LX0pnWkr?Q18YpIk>A^>QMh=UYDnyth$GV*RqfKe-KrI6C$}?l z?{OSDR|cuIYoudAj9$}oGwEv{K7*SB_iq5u;sW?`fL)&a{>^La&t635*eoMVCuPN6 zEf-NP@3{lf&!GV05v^(1%-)({mP1i++K&`IgfOZk9$N!vj3pKphvY>Aoq8qIIc0J) z47;bjas?S#b*{H&=xeCWO1ZP%!uu~jYu6~7;w331eY@Ty^IY)6ImS4Mq*Y3Pgn56P zXa{pME-KjPv?g@do~XEnIm#lwBKsi9w9sgu*Cq zMI$E3HpqAv=!+?Gg6NF_v0;dwSw5bQzpEsHilM7IUPEEJzb?tg(q(smPSQk&xVcXX}e!m zs+vIdgV8qu&gQ@OZcrmpl%xMFhRUJWZ=fA&2f@|Xvemzo_3v~=vz4z%^IyX;A~bbs zK32Pr8WTksha*_aQ2`bLq_V~GS3HyWc$p6ZiW1dfxc;<;;gf_rv?%)N&Upv~kFx^~9nPM?z0@}FWQKW&k_?4!58wb~vGNeS*Qhtb4D@=WUV9v6!p zP2j36K80c8^zP5-48$?iRIiHh{~}gAa2iw2=?u%UE`4fztOBVU*i*N)S>3X%aJn6h zql09w{%-v!NS^qGR+kio1J1MmHfDV;mNNN`Yn;O_U*`%e%}5Gt#M>Y3(xO|KQ`#p{ z&F}QoidZ~hrgedXB}#1!n2-cq)QlT7I*)eG-Y%3#_vMW;Nhng6yHjTRsT?M_LWn4t z^Qot-#HA3b{QHF@-*{fF3V;v5*8bzoj|t?=pX|dkcO8W0)7HWhW~ZFJY`Wi^e=+-f zq-T2ae8-wzRw^#~VfZ0LK=3Ya&#%apj{-wk9EXO)<>9Avd*<7_StMqTQo`cT{OVzz ze4Q=kiR}+gad9-{vE{p@(SFP)u?};%G8`9f>Cvg0;8)R7 zOZP53SNOdNx$|ycQ0(mF7PlyKZa*(Yo_UwDGxkaP_vrS`1vd_HyheD-VFN)o&`H6QcoDZlU+vY}*bpzQ9=kiwu4Zs1HtqW8*#Zn=Ij zHiWqCnmoCSxX26stfwwjK_{V!huAYA+K?E-w$HZsWyL43hJ$RG-H}-vd+d#=E~=rY zQ8uJ8;?N*OZUp_G4)*?eEy*ktz~_^754pYfXQXCIor61(3$Yd>z<4?NWLP_R$`UqTu<)>m60 z8?TyFcS_^ESL!y$lXg~@Ate&45&P(Ac&j8Y+RJt`660^}4?M=EuL2zwvLr}0lj!1n@J8(YRx zhTadlw^OP~u2$5bVO|gf*7R*~3xfcHO?Id;W8$k5Ps4%dU1WKrsF(4YoAW1^I|y+V zUrxY07QWV+Y4A!Nm^gtOOL_~nHvfC7f-E{sU^(X(mg3bvXZojXSIK=jl*r_q24&Z z1|mCY53>t_$B~*+_DgrpBXc{fH~~d3wfv>`5J#$eg36yx6a@h%zhL#-IWNRGu7Rzu zpstZe_`0R(`w_P{cS+iZ#RZ)Frl#%8>t8pW zf+~O>oeWfT3`0_K&9?t8Z=P8s{nsYQ{ofYm9|c&g&m_%6`B;b5<<0~FSDd;qM!oXj z%KRv_wS3%wGE@OG&XSB>s{e7Cnb@k*Ba>c!K81UeF$p{qiYqh@pyhT-Bcm&jsftPiO`;UsF-Xyq2ibO_-PBggJxr?dp7bt~K8UboR2H7}vnddJjOw^vR|s{})e_6-3Uu>vJie~+Okt|DZWh2nnpJ&&j#cQITers_@%L?<7a(Lsv7 zA81yLp@v$JTzvG^E`{jk8I_HPI+I)oHqa=lr!SiOx%y18!Ouir-4yrQeXTJneRCO; zYcv=2QU>h3Ka`E)c(v zt8I^Ss;Hwc|BsN75ElQqw4oAC1hsHQ>fB;4S|i?&H0N#k0tzkYPx0FZBx$;Yo_+Q; zraUrjfN6hS7Jz#o3{1lbg6!itTbxzF3?b9q9Rl3w7#1&R8kefFvdbve+Zy16-!L{e ikb~&&KcqnE<}S}naftB2Y#9#p1ZQY=vG~GG;{O2S!*%ii literal 0 HcmV?d00001 diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/index.html b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/index.html new file mode 100644 index 000000000..777d29f31 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/index.html @@ -0,0 +1,198 @@ + + + +nRF5 SDK Documentation + + + + +
+ + +
+ nRF5 Software Development Kit v17.1.0
+

The nRF5 Software Development Kit (SDK) enables Bluetooth® low energy, ANT, and 2.4 GHz proprietary product development with Nordic Semiconductor's advanced nRF5 Series System on Chip (SoC) devices.

+ +

+ SDK documentation +
+ The SDK documentation is available in Nordic Semiconductor's Infocenter. +
+ VIEW DOCUMENTATION » +

+ +

+ S112 SoftDevice API documentation +
+ Bluetooth® low energy Peripheral protocol stack for the nRF52810, nRF52811, and nRF52832 SoCs. +
+ VIEW API DOCUMENTATION » +

+ +

+ S113 SoftDevice API documentation +
+ Bluetooth® low energy Peripheral protocol stack for the nRF52833 SoC. Compatible with nRF52840. +
+ VIEW API DOCUMENTATION » +

+ +

+ S122 SoftDevice API documentation +
+ Bluetooth® low energy Central protocol stack for the nRF52820 SoC. +
+ VIEW API DOCUMENTATION » +

+ +

+ S132 SoftDevice API documentation +
+ Bluetooth® low energy Peripheral and Central protocol stack for the nRF52832 SoC. +
+ VIEW API DOCUMENTATION » +

+ +

+ S140 SoftDevice API documentation +
+ Bluetooth® low energy Peripheral and Central protocol stack for the nRF52840 SoC. Compatible with nRF52833. +
+ VIEW API DOCUMENTATION » +

+ +

+ S212 SoftDevice API documentation +
+ ANT protocol stack for the nRF52 Series. +
+ VIEW API DOCUMENTATION » +

+ +

+ S312 SoftDevice API documentation +
+ ANT and BLE protocol stack for the nRF52810 SoC. Compatible with nRF52832. +
+ VIEW API DOCUMENTATION » +

+ +

+ S332 SoftDevice API documentation +
+ ANT and BLE protocol stack for the nRF52832 SoC. +
+ VIEW API DOCUMENTATION » +

+ +

+ S340 SoftDevice API documentation +
+ ANT and BLE protocol stack for the nRF52840 SoC. +
+ VIEW API DOCUMENTATION » +

+ +

+ Offline documentation +
+ You can download documentation for offline use from http://developer.nordicsemi.com. +
+ DOWNLOAD OFFLINE DOCUMENTATION » +

+ +
+ + To view Nordic Semiconductor's license agreement, please click here.
+ To see release notes for this product, please click here.
+ +
+ +
+ + + \ No newline at end of file diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/licenses.html b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/licenses.html new file mode 100644 index 000000000..66d224df5 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/licenses.html @@ -0,0 +1,87 @@ + + + +Licenses in the nRF5 SDK + + + + +
+ + +
+ Licenses in the nRF5 SDK
+ +

+See the top of each source file for the license under which the file is +released.

+

+The following licenses are used in the nRF5 SDK: +

    +
  1. nRF5 SDK license: The majority of the source code included in the nRF5 SDK (nRF5_Nordic_license.txt)
  2. +
  3. nRF5 Garmin Canada license: Files released by Garmin Canada included in the nRF5 SDK (nRF5_Garmin_Canada_license.txt)
  4. +
  5. SoftDevice license: The SoftDevice and its headers (..\components\softdevice\sxxx\doc\license_file)
  6. +
  7. ARM 3-clause BSD license: CMSIS and system files (..\components\toolchain)
  8. +
  9. FreeRTOS license: FreeRTOS configuration files (FreeRTOSConfig.h in the examples that show how to use FreeRTOS)
  10. +
  11. Third-party licenses: All third-party code contained in ..\external (respective licenses included in each of the imported projects)
  12. +
+

+ + +
+
+ + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/licenses.txt b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/licenses.txt new file mode 100644 index 000000000..5bfda63fa --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/licenses.txt @@ -0,0 +1,23 @@ +See the top of each source file for the license under which the file is +released. +The following licenses are used in the nRF5 SDK: + + i) nRF5 SDK license: The majority of the source code included in the + nRF5 SDK (nRF5_Nordic_license.txt) + + ii) nRF5 Garmin Canada license: Files released by Garmin Canada + included in the nRF5 SDK (nRF5_Garmin_Canada_license.txt) + + iii) SoftDevice license: The SoftDevice and its headers + (..\components\softdevice\sxxx\doc\) + + iv) ARM 3-clause BSD license: CMSIS and system files (..\components\toolchain) + + v) FreeRTOS license: FreeRTOS configuration files (FreeRTOSConfig.h + in the examples that show how to use FreeRTOS) + + vi) Third-party licenses: All third-party code contained in + ..\external (respective licenses included in each of the imported + projects) + + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5_Garmin_Canada_license.txt b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5_Garmin_Canada_license.txt new file mode 100644 index 000000000..58c176ac4 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5_Garmin_Canada_license.txt @@ -0,0 +1,50 @@ +This software is subject to the ANT+ Shared Source License +www.thisisant.com/swlicenses +Copyright (c) Garmin Canada Inc. 2010 +All rights reserved. + +Redistribution and use in source and binary forms, with or +without modification, are permitted provided that the following +conditions are met: + + 1) Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + + 2) Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + + 3) Neither the name of Garmin nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission. + +The following actions are prohibited: + + 1) Redistribution of source code containing the ANT+ Network + Key. The ANT+ Network Key is available to ANT+ Adopters. + Please refer to http://thisisant.com to become an ANT+ + Adopter and access the key. + + 2) Reverse engineering, decompilation, and/or disassembly of + software provided in binary form under this license. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE HEREBY +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; DAMAGE TO ANY DEVICE, LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. SOME STATES DO NOT ALLOW +THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE +ABOVE LIMITATIONS MAY NOT APPLY TO YOU. + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5_Nordic_license.txt b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5_Nordic_license.txt new file mode 100644 index 000000000..ec39ce2f1 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5_Nordic_license.txt @@ -0,0 +1,37 @@ +Copyright (c) 2010 - 2021, Nordic Semiconductor ASA + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form, except as embedded into a Nordic + Semiconductor ASA integrated circuit in a product or a software update for + such product, must reproduce the above copyright notice, this list of + conditions and the following disclaimer in the documentation and/or other + materials provided with the distribution. + +3. Neither the name of Nordic Semiconductor ASA nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +4. This software, with or without modification, must only be used with a + Nordic Semiconductor ASA integrated circuit. + +5. Any software provided in binary form under this license must not be reverse + engineered, decompiled, modified and/or disassembled. + +THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5x_series_logo.png b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/documentation/nRF5x_series_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..4002538deab14e17d8e400cafa160eaf1fd343a0 GIT binary patch literal 9960 zcmVP)D;rIb{n zLPH2q`4TEPl*(67iAq!wsS=f_BvK_RQAwmqRH71&^_3cY$W@hmn%3vTl zIhm)QdWx*9ta5#hs0e7*0Gc-x)Qy4Ys$e#Olpq9X8YG{Cqo-hh0_;8@IdTGu>7D_O z(PfOcXUvo}t49~P)v6IA+qZ5br%ahrpiOd8vJ4LnDYjkS*0pmNzwhhRxz%#}krAGM zzx(dH^8N=ND0Ezp9zA5O=o<2xn3}S7jTqUeegpZ{(q&T9Gp`f7q%)=9#W({;ogobQXacx zJMRANs3LQBD{}AGihSn`3AV98R1}L{LwChbEcv<}{>~G;P?3 z9lQU)VzDrP_FUrj?8Rg<;c~f96a}Z#$#Y}J(x-1@XQcF zpKbz6B;W*c-CK?qClFvXLepl@w3XoTA+T$gVCEvpXR9R+XF02O=gyrYH8mB0h=>Sm zHX8@x50H_OK}1A2b?enDvYn=B3?Dw6hK(8_0ZntUdgUs%Y}ta@Y-aiL<-9U!B1U7u z&S|w+m^OVnxlZS$?*V&ou+Jt@?8(WTNnMPp27}N)`ho=ua5|j`AsF$UVB#E*TjaW%7L0tH2vi3kKgKP;5X3km{#-EP-tICZJ_&_^5+m z)F8pAH#C0UR*ppa^wUq7I{7sag12VOVA8~iq^72#C<-o@iw+$+uz1N53`RpCyXU4Z zo$1`Ai)Y`!`|jhRL4(<}X%pGm*(4_?6CE90pq*+o((mp8{#s~&35i70G`1!Di>%yO zgs=b?N6Gc;f5KoeU^1H-_4HE!?Ao=9#4~5G+H3@ehw;XnQvqnvq$yb$nXF#Dx}XSLYu0p z0YBH+p@OeJ6jYA}E)*CC%N`jZTrh5|;Hy~zo28t+b~z3Q3qSdo@bGXZyfT45cI*TJ zA1_=;yY}r09dET1^spT~aDZ>utU&;(!9exu)eE)B%*^2SuH6ceCN(vct=qSi<~bqP znauVh_u+76B7~#JvBF@`AKQ_S$eT88LRA!`5ZrUmJ)Zsh7>PV*YV`&(YT~U z6@ou@?JBY#+<*W53>Z*Qb5K>4?CflA>ePvZgap5zW&ERp3C{~%VmL3?h@=y?-`#>` zW*G3eBqz5Vh~#p)7&>eyU2eGrDJA1y9#8M?Juq7=Bpg0m=y+9C88&1HMx#-;kz6hk z6BDu7Y`B~*+H`1x$z&?hwkqm;-bjRuoP%sn7>Xnfgg_P}a2q#n%&r|fICb(AlP0{1 z01m|M$D|sFs#X;t1X46TN%)uFym>8;xw+zMYA$zKWER+3&tf{{aK& z=2r8<)v8Nkx0;yu zP4~pb@yLh~94=;%Jd>En@#Dum&Y8S8RBmoA**Q6W-Tw{O!&@&2-5KDzf-mv{4EdMf zw_UJcsVrL}fk4auF=Qz=izca8zaF;WV6rkZIe73O0%+E>S+OJnu-onYxN$>~A6-gW z;@liXkw|F-#R;N-JZEC3AcA|@)*I|pC!jmmw~gvUpS=3_*W;eV%194e!mWrRkz@F?AXrq z>C^qP0m^EEn-GF-x824cd;VnUS6?#k{rCCq|9;?$FTU{fzVPsHw(ZzKi!TVC9w(m=0-N2& z@|7zJ#k#IWWTdC__+yWeos)x8)9Bfw2mcu}=CWKn$OfYx65a(?FDEkL{<{QqYnBm_ zr29`%1X;XAbaXWL-g~beN!K)b_3CxS-p|B|6RA`C8k#n`7$eEZ$l&zp)13b6v`1wX zLSPgMkzwJy{`%_`)?1g~Mk%Q3Dn%cc&l!+^|K`n`nL1?(2Di=h$}6wXrfu6I&!;G5 zHwNF;O;EofffGpps@q^uee9q`!3n`t;J!X0a3Yz_W+EaY2#<*HxQzjXst_C=PI!1Y zLHRNctR@R#;o*dYhoc$_+7%ODe~l(BniCNoj&wNr?6c22&mS2PL0CjM!C|50-uVb&sn$x=Zbp_&EVPRo}hlFA^TPh@x^3r>tpgTX$gI3gWxj8ww+|QnW zKfvp+zs}FU{DRZv!e+BE{jIkyh70n?mz-tim%gtzfhFb(zy{dC<%H}EaOMIQASgh+ z%K`mwFP%uDwBjduMt)Itik8o~%^RUgI{wn%^S3MNT)ray)I?5R_)@>-CC&zcMyTy3 zT3$1o$rC5?{`~i_+N{LJ?+4(UZ@yvVu!m7qmHmefVm6xrhzgG&Bshd8Mvr3j(@$Ly zvXo@2*zCbnsZw1J)MuoTocx#Pw}{AU1O@5Y?kQ&zNl(9^KU38h>~{&kl3=H|pj(;JUjs_9yu5wael{MgrN+176BW z0c2uOYfvTlW}ln}WvMC@Ga`U=alD2QkA7J)>yyIr;LtJ2nvHPx z8dy9-U@_vmTU`TF2()Y>*ql`|%6)T{c`RY#<| z?+`4SA;?MhzKuB;rp%T+_tur4=-9j=U__4{`3f6MpHno6^5d)TC3R=On=cDU_v1RM zexG09w?vW%Oen(S1Cb<(ywWijp${bpkSYd)m3DQOV={#o?rU-gEw02j`{tdG4L4BlTR8T~IoObtI&JdIL4cZxS%QvcJtP5>Hp!%0UGZgeQoc!`KA>v2pN<9-Y}+k4 ze%iak&!@sK+a;L&xRwUhBTMD=Rb?^c6D_#}8C%f0-U3jHWl~;`_=L#nLieosI#`9kVIR%4L&yEsJW4a+FB6emx}h(OZn>H_EM)7q zAoGNy1Q9?AzNP{aO>+?)(w8PNFS)Ntv3gulbp`V86G9+0t+L0L6W;wmvT6-J&rmfP zVdp;I+Blp6sPOWN5J?oW)-tk>lHo`o$8i#umIVS73>egK%*LwN&2_ODV*-{)noOr| z_%qat9tpB&!y!00h?tlduRVoQ%0e?iuVx4VcB?MPH3^y7P+nun@*ggr!=pwN{>Q7t z2cE5(5uK{n`co#56E(5i``b~HqU>gtT9L25cAroe%t zlI?q8<2K2@!{tY=@lSyf?Onwk^<$rT7XJ4xhNpM3Mqhb9Mn5 z3U2#E-dmN09_d(K0 zx^?SD_nuctjk_%9)kQG4pP)v4x2c+g*RdQ`f!1xHbw|OAj|e8smCRWZcqN{4Q&oXi zo)mhw$@ItehCkx2h>auzwCaTC?@6ia*ycD!>)Ib8qzM$W7q6{kY}~McO&d3Qe@9Xh z9UXo35XlM6o4H^01^+r$Ug3}`Rbl27LI2wXgP+s9c1K@Mj2kJqt((vbsQ3y6axTEu zKV@l$Rct5-(zEun^XLdY|6B&Hm}^qgH_iL)s#}jO7ys;qqRw*xx^#nIK38bopkh7d zz@CChV}yT_2*3ir{s{+;ToH*>_DIi)WB2J%To*Gd;ByTfHjG}qdgYb5^Fl^S8aHiP zX;_t{M5IEkIR#vPqt;WTkEXzdSF_~@(BJIddNNK!aSO8to=#%0v0 zIxwJfb?w@rx zsRt_-D1?RuKq7b6+bc6AnO=0Yznza*lFiN|W08I(O}T9(O(Sk!94(qQ{xpD>`6vuW+h3yMH&pfU(oxO%TK0jqG9#>ie6YUki{@U z;M1=pUw-GE{{J@&wkV`#ZNuU8e_o8DC_Fr52w9n#n2bgonubei*ljj8Zrs46iIdnL zx1TnxTCwztFRu4HFE|NUw;jQs-mhYAHDxRJ#N39RCiHIi`h(@)~zcE z;tR5%T^qQ&`{j{J!FKra9fj*#O=?J~(mZAwk-;~jDEW(rPK2rL$}heQDN>et8VaAHtZ($mwKyI?;32MoCSVn~+~$fgtL zLK6IS7K|!HM}f5p7uO*2Qz~_CBWO}zvhPs&J;H)Xf3H~)$1SW|Tzz&n9OWyie`hAKr9^o`la%oWQ34$z5-EKs;%*-n|CKU8! zRU0)U?ni3=+=d`MD?T8hT4=I|qImY1EEcY62*3i9-jehjA^Co@B>5b;G{|+r$uls2 zsifmSHR2EG$NH<{b#7ZekMPRlf>DpUNfgNRh+vpDOY+j&{%alvZ?2@5z*oF`YnlZ` zaS{{S&z-DlDOUAT6qR~aALB^UydtN8mxlD5_<%lyrfH0O{&`PL^Yba^Fu1F#zV+60 zPvL&)PFlU=jytX%BH3Z(YROBpO71+z|AJ8yCEqS|Pr3KCuQ{MaLxG~mGM#oYYOvtt zXWhk20wmG3~Ho)r=k?uk3z7mDH++mlOii8 zfU?Iz&+7i-vn2(|?XE()?%TB&A4$`wUbR}qB$7ez48Ga}S`NH6*SpTM_Gih@zroF& zgzvE#7u2W`#ELyS;C-W&_;Z z**`leEC{Mblns&kb``ugMO-Z6;xEEr)k?{rF%nru<5>x#wjZ{OD9!>Y{_+-MwEo76 zsE}GBku?7#(!l%gr_;?hqj>2=kWx~oPMr!#q>bD38LQ=u-*-#M^+Uar`plQ`P=EBo zg1Ds}ESf1W8VRgUcnJLT0}LJ`$t|NfR23p=)u06DQ}w(re&W*n^UF4B)QCon8hJ&a ztJY)ZBaWX2M<#kF_LUDRgalafqIDBJ2{kyFz*2vLVaM-q&*K`YWtdc3Au<~jVFBUP z1G7F!KmUf4Su;eHUR|d$u+!XJ>l&aYMduma56v@ucCh@N`sH*xuPnt4^ z0JF*WW}!i_Vy;5d=J+>FJP%ela~k@M&^TC56Anux(!s>JB&Ds^V?o|Z7sY|lLh07@ z7lbG!2To{!fgER&U&2up0aQV)3?Kzrjs(AM-l$str~Bw_9R)XB4>>;i zTueqda1@rV^?o!7wt?M--*FqK5A761PeQ%@4iOlM%#fM}caPNT@s%e^CX%@c;B=SB z@^%E02r|jYI!2hih1(%e++|!K45Vhp`X{lCwg0Dy)b(a~{slien+107fMsjFkD*kF za1+TNNiM;c1^(tu5ZrxFfFv^NHr=36lApGgzxq+4J{4+dkMz|uCP8Xe_M95$jtiAQ zLMb?T_DfvSKP%E^^1sBfxI|VO@-4WWS4{sBld8hufBU~XwR6yD$=B;Ij}C7rQAsn}Pzgr*lt(W>XgHjQ zIeGR=Vj}O+B@Z&+d=S&jg*q4q$G?+ zBSHuU4;qX?RS|&QZuccdd|7egjQdsk8tZgHP!;HUgW%)k-Zi|X1Dy;iRb?N_?GQ)AiU*4RMmfxs2b@$k5N{bL>chG^1%b z1Y4TmkGD?>0g6)UY7}{bNRzTcN~PncAn6?XLdL#!zHI1x6O0)unD#-*oo?#0f@(29 zhJQWm@JU%>X|8|VDVYDd&?gYO0w7T^ygXSlZQ-XZdUJhQPF$ zflr4hAJq;Q;r5nTjdgLjP6ZHpk)UK>47z#>>ig#clA4t|QA7N`8>`id)oLxAODEm= zb(gI0SCMn>Hg1!2x=Hv)B)920{#n7$djuPQmwMD+K%E+J%MF6CY6KPx)nLQcqJQex z5|+&sn62nZsQ%{J1i=RjuN;Xe{nm9=u2$qgWI#2y#U&Q8B#?-x-CPf=v4;P&mXf%* zIM)C4Q=!{j`|Y=MY~O*Xh)C+!t;cg?pDVDwY(>Mj8zgxdR{nN$(jlfM+;^{F^kah2 zj|%$r6@-NnSVbNqoH`C0e=q#4n>B#1<|u@OxTUG)=VpQ>OC-Zyys~y|394PexBYWm zS6uQuSI!yiCZbU3(qIEZH5Ie0rFZDt=Pq_^+s2TgLl{3{0;;O=`)^z6)29!?R-4DO zC#57NCWiH!e)f8WzssrGsS0dcq0q89{y7866Cp5jj^wE#)ViA0ph}p&h?%13DMYG4 zkC-@}?!3ODo>$c~&~tL!Q{RB2ry)D{%08->hKhshYRzWHu?G;+03w&mo$o3{7A}{K zx>X-R2)o~z-vF_D_Ofm3RxB0^8`f{|?4LGuDnT~e#m*}w2*L5=$2qt^o@<*lu5c2` zrNM&FC3B{VibW&?q$R_+O=zAx7&+6 z@A2cuNl(|sZ-WL6h>niN>2wkwAJ5sdrDwT%xrnMtsI4&#syy!Qz*k^omKLgpbfa#S zp`Zp*a1B2D>@&<}Gn&iA%2lgSRh87VG&Z`|Omaxcu04C$zH1lh>FFqn!n}F&Dy(|< z$$usL_TYcDpYlKu%w8lpbgT%D84SELdp1WB;`sfyjl{+7ATBoaPJ|Q+Xmc6mD#KpyVw%FKM&%z3CzxytG_w8fj#*J*=yqSIb_cL?WEYCRu zlSuA$Uu#tv%DJ3BNlyLA9Yl3q231d&3?cURG_N@&AOHO)^TC4$Q51!Us#OV%2nS&0 zf0tu2nb0(iVIziPv+I(nUcGuG{&j}Ed-qmYB4uR5xM`B*?+N|2T(#5NUAs0N+O?y9|NgxG+G`$FHZ?Vs*u8r_Dz(jKWAEO*sH%$5 zXvCl>97;$aGcyyD$wd8n^?3ZzN6F60;+ZjHPz?r;#K|KtK-~WQBqb)IswzSVEEWq# zj~?ZLL4$bWvByX{dzPPm`iZEhC~oc2g&y6z^YZxdWue;T!O3+oZxbuW@mKmX6oM)L zG-?N-wpO&NHQya`k_0-jH&3*i^X2xhUAq>e(TL0C;?YMQ@$64?i~Ep}5GpcO{2-b8 z5j-*?z(R?E!VIbBVdz+m^kOo*vUl=!zl`B>hI`1g= z0^KW?FK76}4+GG-b7yiLjshxU;6!p8_f2cPhCPzhU77#@25Ct|K~%W~htEz$aRI{R zTViXe+NJ=UAWcLD_n}3t@%S1LE(tZFquHiuoIZJqV+lvFT5W9o^;d+1u!smEA|e1d zcH}5YiHX?lb~<(HL`BC_uSu@02i@zR-ZW^+P9LIDX>9J+Sxiq&ex zVzFQ}8aZ<02;Z+;$I+ul0T_7SeT0ODvgVs__-^f5&YU?@R$jYH?G+7#6Q?VK?Fqxl z)OI0UL1pwcG^A!g7|pc5<}+;OYw%37EF;A3jpepmZoy`^d(;RiC1{cxyL9H`MV|mL zeAqC4{Nex5G>t!Y?y2w=z<$-+|7j$&eB_+r^I zZtU36v+sOrDsN7m%4?G+^WZ}d@zKJCIGj$5hKpmpl#(V*nsDI20S+8GMBO@dSiXEY ziHV7r%x1cG?@o>C)tNnK4v#(;H~ z&O7fUA|is%moDY@Zrv`b%~@H@e)nCTf9|;wS0pj``DFnk1~r@x4VICabBz6G-XJl3 zEoMSM(GZ#$aL=w4nx4@h)qLuif*=>93900OG@;2{%%<8jt~!>8;G5m6m{aCPS@3%>-Lpl2aSOG?pz9u8#m^W#~$@er)bio3G?4uz{n9JS+#ia6^kMHgR~5| zXOv|0c9{6Iz+MGCPtH{iQpf^ZHo&l#G-AChlz+`N*Ko_Nx3cJyPuQ?w122pl$1j^V zb3=y?G-}j{tSmiEW*5%;@|yL2vO z#*veI8i#fPhcg*PF=AAzVK#;lWVsfLId5{Fbl0?Vx+Pcnt4e+Q^`&pWzQrDQSKq#L z@7WWBLFMlT3C#FJvf@X{#3uy*>@6^cp~sqX15o+g8P*u#)FGHWPqJW{^l9SWoVj!9 z*`o)KJ^narzWD~5-A>~sO+1=FgN6+OxV~jeKKkSnPa#jU+05?UyLofU6wf#OZR=M4 z*tLuL_3JZv@?_qeHjPcc{KAohgu*JZ``@FVdWwGi`+K~27K?>qZ&?cZPMIp3NwLjrQhkRips zi_M!iOS9Q5PnUT`K{(X3ZKYrIgP<|GWg`mMvR~ zJ@2q#!(^YnePvvHe4*bKEnX}Q21AL@|=y08&+YNfsXoK2KvT+;yutl=xAORP|x7lp8ZP$**jT_@~x!AsaJG*x7)K#n+ zHE7i8EgCmzf)IkAH*Tasg9gOZ ztjWIESdJb&N}D!q2#<&;RKw6QfkTS zN+SJ_5vh=wW76w#M@8r)vs%FE(sSL?GW2@g$>;Qam8c|AC6Ovou23ppK_x0tNu)|t mqLN6Js6-`^Dp83_c<}!f-2EdRVo?(S0000 + +2. In the .emProject file: + In "linker_section_placements_segments" you must refer to "RAM1", replacing "RAM": + linker_section_placements_segments="FLASH RX 0x0 0x100000;RAM1 RWX 0x20000000 0x40000" + +------------------ + +Observation of unaligned memory layout: +Certain SES projects that use section variables have been observed +to create memory sections that do not end on a word-aligned address. +This has caused issues when the hex file has been processed by a hex file utility tool +like mergehex.exe, which can produce a corrupted hex file. +The issue has been fixed in the SES section-placement file (flash_placement.xml) +by setting the memory section size attribute to 4. + +***** +Note for IAR 8 users: + +When using IAR 8, you must apply the following workaround in the MDK: + +- Apply a patch to modules/nrfx/mdk/compiler_abstraction.h at line 140 + (fix the '__ALIGN()' macro definition): use the argument 'n' in the macro expansion instead of 'x'. + +------------------- + +Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits. + +To run a project using IAR 8, follow these instructions: + 1. Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file. + 2. If the project contains one of the precompiled libraries listed below, replace it + with the IAR 8 compatible alternative (there are no projects targeting nRF51 in this SDK). + 3. Save the project. + 4. When building the project, you might get the warning: "The header file 'cmsis_iar.h' is obsolete and should not be used. [...]". + - The problem is described in DevZone post: https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h + The solution is to remove all occurrences of #include . + +The affected libraries are: + - micro-ecc crypto: + - IAR7: Includes library located in the folder named “…_iar\…”. + - IAR8: Switch to using the library from the folder named “…_armgcc\…”. + - nrf_cc310, nrf_cc310_bl, and nrf_oberon: + - IAR7: Link to a library where “short_wchar” is part of the folder name. + - IAR8: Link to a library without “short_wchar” in the folder name. + - Gazell, NFC Tag, and 802.15.4: + - IAR7: Includes the library where the file name ends with “_iar”. + - IAR8: Switch to using the library with similar file name that ends with “_gcc”. +***** + +Supported SoftDevices: + - S112 v7.2.x + - S113 v7.2.x + - S122 v8.x.x + - S132 v7.2.x + - S140 v7.2.x + - S212 v6.1.x + - S312 v6.1.x + - S332 v6.1.x + - S340 v6.1.x + +Supported boards: + +- PCA10040 +- PCA10040E (nRF52810 emulation on PCA10040) +- PCA10056 +- PCA10056E (nRF52811 emulation on PCA10056) +- PCA10100 (support in selected examples) +- PCA10100E (nRF52820 emulation on PCA10100) +- PCA10059 (support in selected examples) +- D52DK1 from Garmin Canada (only for ANT examples) +- PCA10112 (nRF52840 with the nRF2140 front-end chip) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** New features +***************** + +** Drivers and libraries ** + +- nrfx has been updated to version 1.9.0. + For details, see .\modules\nrfx\changelog.md. + +** Crypto ** + +- Updated nrf_oberon from v3.0.6 to v3.0.8 with the following new features: + - Added support for SHA-224 and SHA-384. + - Added support for the p224 curve for ECDH and ECDSA. + - Added support for HMAC-SHA256 with AAD. + - Added support for ChaChaPoly. + - See Mbed TLS release notes for details. + +*** Changes +*********** + +** Drivers and libraries ** + +- NRFFOETT-1832: Reduced radio noise in the Radio Test example + by moving CPU to idle state in the main loop. + +** Bluetooth Low Energy ** + +- NRFFOSDK-13484: Added an option in the Peer Manager to decide + that a connection will not be processed by this module. +- NRFFOSDK-13611: GATT Module: automatic MTU negotiation is now optional. + +** Bluetooth Low Energy examples ** + +- NRFFOSDK-13616: Updated handling of bonding events to be more sceptical of failed bonding/encryption + attempts, since they can be the sign of an attack. + +** Direct Test Mode ** + +- NRFFOSDK-13580: Redesigned the Direct Test Mode library to run in the interrupt context. + +** NFC ** + +- Added support for encoding empty NDEF records. +- NRFFOSDK-13614: Added Frame Waiting Time (FWT) management logic to the NFC T4T library. + FWT is now changed according to the ISO-DEP timing requirements (e.g. WTX frame). +- NRFFOSDK-13627: Changed the behavior of the nfc_t4t_done() function so that + it uninitializes the NFCT driver to achieve symmetry with the nfc_t4t_setup() function, + where the driver is initialized. + + +*** Bug fixes +**************** + +** Drivers and libraries ** + +- NRFFOSDK-13607: Reduced the Radio IRQ priority in the Radio Test example + when nRF21540 support is enabled, to avoid potential deadlock. +- NRFFOETT-2532: nrf_ringbuf - prevented data from being overwritten. +- NRFFOETT-2608: BSP - fixed port mapping for nRF52866 / PCA-10100. +- NRFFOETT-2557: app_timer2 - fixed the library to allow it to be started and stopped from higher interrupt priority. + +** DFU / Bootloader ** + +- NRFFOETT-2068: Updated to allow GPREGET to be used outside of the bootloader. +- NRFFOETT-2510: Fixed a misinterpretation of bit field in GPREGET. + +** Bluetooth Low Energy ** + +- NRFFOETT-2521: Removed the Address Type checking in the Scanning Module. +- NRFFOSDK-13616: Fixed bond deletion mechanism in the Bond Management Service + in a scenario with multiple connections. + +** Peer Manager ** + +- NRFFOETT-2519: The local db data will not be written to flash if it is already up to date. + This means that if a client updates a CCCD to the same value as before, + no flash operation will happen. +- NRFFOSDK-13591: Added a mitigation mechanism to address a security vulnerability + in the Bluetooth Core spec: CVE-2020-26558 + +** FDS ** + +- Fixed a bug that would prevent re-initialization when fds_init() returned + FDS_ERR_NO_PAGES or FDS_ERR_NO_SWAP (NRFFOETT-2552). +- Fixed a bug in FDS that could occur if the device lost power during garbage collection, + that would result in the swap page being incorrectly tagged, and fds_init() returning + FDS_ERR_NO_SWAP on initialization (NRFFOETT-2506). + +** DTM ** + +- NRFFOSDK-13481: Added missing support of 256kByte for nRF52832. +- NRFFOETT-2537: Added missing +8dBm output power. +- NRFFOETT-2573: Fixed a bug with payload length > 63 bytes. + +** ANT ** + +- NRFFOSDK-13460: Fixed ANT File Sharing Client module to allow using channel numbers other than 0. + Previously, using such channel numbers would cause misbehavior of this module. + +** NFC ** + +- NRFFOSDK-13691: Fixed a potential race condition in the Type 4 Tag library + in case of coexistence with other communication protocols + (i.e. when there is high CPU load and ISR takes long time to execute). + + +*** Known Issues +**************** + +** General ** + +- The workaround for Anomaly 198 for nRF52840 SPIM3 peripheral + that has been implemented in nrfx_spim cannot be used with a SoftDevice. + Flag NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED must be set to zero. + The workaround based on a dedicated RAM block for SPIM3 must be used instead. + +- usbd_msc example has a limitation. With setting "APP_USBD_CONFIG_EVENT_QUEUE_ENABLE = 0", when USB + cable is unplugged and re-plugged, the application goes into an endless loop. + This is due to an issue in the unsupported block device library. + +** Bluetooth Low Energy ** + +- GATTC: the ble_gattc_service_t::uuid field is incorrectly populated + in the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event if the + sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read() + are called when a Primary Service Discovery by Service UUID is already ongoing. + When the application has called sd_ble_gattc_primary_services_discover(), + it should wait for the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event before calling + sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read(). +- The TFTP Background DFU example has known instabilities. +- BLE Interactive CLI example: the command to set a custom ATT MTU only takes + effect on the subsequent connection and the updated MTU parameter is not + maintained in further connections with the same peer, even when bonded. +- ANT Shared Channels example: when testing BLE connection with an Android device, + the link might be terminated by Android due to unhandled LL requests. +- Bluetooth ANCS example: when connected from iPhone and pressing DK buttons, + the example may assert before the BLE link is authenticated. + +** Bluetooth Low Energy examples ** + +- NRFFOSDK-13653: Using the Bluetooth LE privacy feature is recommended in the following ways: + - In the Scanner role: + In active scanning do not use accept list (whitelist) or only use passive scanning. + - In the Advertiser role: + Only use non-scannable advertising or limit to minimum the duration + of connectable and scannable advertising (e.g. just for establishing the connection). +- NRFFOSDK-13685: The examples do not check the security requirements on notifications + received before encryption is established, as is mandated in the + Bluetooth Core Spec 5.3 3.C.10.3.1.1. +- NRFFOSDK-13686: When reconnecting to a bonded peer, the examples do not check whether + encryption is enabled before sending notifications/indications on a protected characteristic, + as is mandated in the Bluetooth Core Spec 5.3 3.C.10.3.1.1. +- NRFFOSDK-13697: Example ble_app_buttonless_dfu fails when booting up when built targeting + PCA10040E running on nRF52832 Revision 3. + Workaround: Run the example on a DK with nRF52832 Revision 2. +- NRFFOSDK-13713: The serialized target of the Heart Rate example for the S112 SoftDevice + and the HCI transport (ble_app_hrs/pca10040/ser_s112_hci) asserts when trying to + establish a Bluetooth Low Energy connection with it. + +** ANT ** + +- NRFFOSDK-13710: The Heart Rate Monitor Relay Application might disconnect the BLE link + if long connection interval is used and an ANT channel reopens after a search timeout. + +** DFU ** + +- NRFFOETT-2579: If the transfer is aborted when transferring a SoftDevice to a device + with no SoftDevice present (using sd-req = 0), the device can erroneously think that the SoftDevice + was transferred correctly. On smaller devices there could be no room + to transfer the SoftDevice again. + Workaround: Transfer any application with sd-req set to 0. + The application must be at least 3 pages (0x3000 bytes) long. + The application will overwrite the SoftDevice, allowing it to be retransferred. + +** Crypto ** + +- The nrf_crypto CLI example may fail when using ecc private key converted + from raw function for specific curve types. + + +** Drivers and libraries ** + +- The SAADC driver does not handle detection limits 'high' and 'low' correctly + if SAADC resolution is greater than 10 bits. +- USBD: + - The library may handle Remote Wakeup incorrectly. + - Issuing a SET_ADDRESS(0) request does not cause the device to change + its state to default. + - The device does not STALL when a DATA transaction is received outside of SETUP. + It ACKs instead. +- LEDS_OFF, LEDS_ON, LED_IS_ON, LEDS_INVERT, LEDS_CONFIGURE macros defined in boards.h + work only with pins on port 0 + + +======================================================================================= + + +nRF5 SDK v17.0.2 +------------------------ +Release Date: September, 2020 + +This SDK release is a bug fix release replacing nRF5 SDK v17.0.0. +This version contains the latest MDK (v8.35.0) with a bug fix that properly handles errata +on future devices with unknown HW ID. +If you are using v17.0.0 for development, it is strongly recommended to switch to v17.0.2. + +Highlights: + +- Added support for version 7.2.0 of SoftDevices S112, S113, S132, and S140. +- Added workarounds for anomalies 211 and 223. +- Added new nrfx v1.8.6 with a new MDK. + See 'Compatibility of SES projects'. + +The following toolchains/devices have been used for testing and verification: + + - ARM: MDK-ARM version 5.25 + - GCC: GCC ARM Embedded 9.2019q4.major + - IAR: IAR Workbench 7.80.4 + - SES: SES 4.50 + + +**** +Compatibility of SES projects: + +Updates and fixes in the MDK used by Segger Embedded Studio break backwards compatibility +with old SES project files. +To use old projects in combination with this version of the SDK (MDK), +make the following updates: + +1. In the flash_placement.xml file: + MemorySegment name must be changed from "RAM" to "RAM1": + + +2. In the .emProject file: + In "linker_section_placements_segments" you must refer to "RAM1", replacing "RAM": + linker_section_placements_segments="FLASH RX 0x0 0x100000;RAM1 RWX 0x20000000 0x40000" + +***** +Note for IAR 8 users: +(Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits). + +To run a project using IAR 8, follow these intructions: + 1. Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file. + 2. If the project contains one of the precompiled libraries listed below, replace it + with the IAR 8 compatible alternative (there are no projects targeting nRF51 in this SDK). + 3. Save the project. + 4. When building the project, you might get the warning: "The header file 'cmsis_iar.h' is obsolete and should not be used. [...]". + - The problem is described in DevZone post: https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h + The solution is to remove all occurrences of #include . + +The affected libraries are: + - micro-ecc crypto: + - IAR7: Includes library located in the folder named “…_iar\…”. + - IAR8: Switch to using the library from the folder named “…_armgcc\…”. + - nrf_cc310, nrf_cc310_bl, and nrf_oberon: + - IAR7: Link to a library where “short_wchar” is part of the folder name. + - IAR8: Link to a library without “short_wchar” in the folder name. + - Gazell, NFC Tag, and 802.15.4: + - IAR7: Includes the library where the file name ends with “_iar”. + - IAR8: Switch to using the library with similar file name that ends with “_gcc”. +***** + +Supported SoftDevices: + - S112 v7.2.x + - S113 v7.2.x + - S122 v8.x.x + - S132 v7.2.x + - S140 v7.2.x + - S212 v6.1.x + - S312 v6.1.x + - S332 v6.1.x + - S340 v6.1.x + +Supported boards: + +- PCA10040 +- PCA10040E (nRF52810 emulation on PCA10040) +- PCA10056 +- PCA10056E (nRF52811 emulation on PCA10056) +- PCA10100 (support in selected examples) +- PCA10100E (nRF52820 emulation on PCA10100) +- PCA10059 (support in selected examples) +- D52DK1 from Garmin Canada (only for ANT examples) +- PCA10112 (nRF52840 with the nRF2140 front-end chip) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** New features +***************** + +** Drivers and libraries ** + +- nrfx has been updated to version 1.8.6. + For details, see .\modules\nrfx\changelog.md. + +** DTM ** + +- Added support for new commands added in Bluetooth Core Specification 5.1 and 5.2. +- You can now use a vendor-specific command to control the output power on the nRF21540 PA/LNA chip at runtime. + +*** Changes +*********** + +** Drivers and libraries ** + +- Radio Test Example: + Updated the radio_test_init() implementation to enable calling it multiple times. + Documented how to use the API from radio_test.h directly. + +** USB ** + +- Added an optional workaround for anomaly 211. + If `NRFX_USBD_USE_WORKAROUND_FOR_ANOMALY_211 = 1` is set, + the USB stack will handle cases of waking up not preceeded by a resume signal. + +- Added a workaround for anomaly 223 in nrfx_usbd.h. + The workaround fixes a possible but unlikely case where USB might be in incorrect state after power-on. + +- Implemented a bug fix on USB HID related to usage with MacOS. + The USB stack has been fixed to update the HID report buffer when idle mode is set to a non-zero value. + This fixes the issues with USB HID Composite Example on macOS devices. + +*** Bug fixes +**************** + +** nrfx/MDK ** + +- Added a new nrfx version that includes a new MDK. + The MDK contains a fix for an issue where it would not properly handle errata + on future devices with unknown HW ID. + The bug was introduced in nRF5 SDK v17.0.0. + +** Proprietary ** + +- Enhanced ShockBurst library: + - Fixed a bug in ESB PRX related to ACK payload. + When there is only one ACK payload, it sends the same payload twice. + +** Crypto ** + +- nrf_crypto: + - Added nrf_oberon v3.0.6 with the following bug fixes: + - Fixed alignment issues when wrapping SHA-1 and SHA-256 contexts inside other context types. + - Added missing symbol for HKDF/HMAC using SHA-1. + - Added extra parameter check in nrf_crypto_ecc_byte_order_invert to prevent undefined behavior + when invalid input is given. + +** Bluetooth Low Energy ** + +- Fixed a potential variable overflow in the Queued Writes library. + +*** Known Issues +**************** + +** General ** + +- The workaround for Anomaly 198 for nRF52840 SPIM3 peripheral + that has been implemented in nrfx_spim cannot be used with a SoftDevice. + Flag NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED must be set to zero. + The workaround based on a dedicated RAM block for SPIM3 must be used instead. + +- usbd_msc example has a limitation. With setting "APP_USBD_CONFIG_EVENT_QUEUE_ENABLE = 0", when USB + cable is unplugged and re-plugged, the application goes into an endless loop. + This is due to an issue in the unsupported block device library. + +** BLE ** + +- GATTC: the ble_gattc_service_t::uuid field is incorrectly populated + in the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event if the + sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read() + are called when a Primary Service Discovery by Service UUID is already ongoing. + When the application has called sd_ble_gattc_primary_services_discover(), + it should wait for the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event before calling + sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read(). +- The TFTP Background DFU example has known instabilities. +- BLE Interactive CLI example: the command to set a custom ATT MTU only takes + effect on the subsequent connection and the updated MTU parameter is not + maintained in further connections with the same peer, even when bonded. +- ANT Shared Channels example: when testing BLE connection with an Android device, + the link is terminated by Android due to unhandled LL requests. +- Bluetooth ANCS example: when connected from iPhone and pressing DK buttons, + the example may assert before the BLE link is authenticated. + + +** Crypto ** + +- The nrf_crypto CLI example may fail when using ecc private key converted + from raw function for specific curve types. + + +** Drivers and libraries ** + +- The SAADC driver does not handle detection limits 'high' and 'low' correctly + if SAADC resolution is greater than 10 bits. +- USBD: + - The library may handle Remote Wakeup incorrectly. + - Issuing a SET_ADDRESS(0) request does not cause the device to change + its state to default. + - The device does not STALL when a DATA transaction is received outside of SETUP. + It ACKs instead. +- LEDS_OFF, LEDS_ON, LED_IS_ON, LEDS_INVERT, LEDS_CONFIGURE macros defined in boards.h + work only with pins on port 0 + +--------------------------------------------------------------------------- + + +nRF5 SDK v17.0.0 +------------------------ +Release Date: June, 2020 + +Highlights: + +- Added support for a new chip: nRF52820 +- Added support for a new SoftDevice: S122 + (size-optimized central-only Bluetooth Low Energy SoftDevice) +- Added a driver for the new RF front-end module nRF21540 +- Removed IoT components and examples +- Removed Keil 4 support + +The following toolchains/devices have been used for testing and verification: + + - ARM: MDK-ARM version 5.25 + - GCC: GCC ARM Embedded 9.2019q4.major + - IAR: IAR Workbench 7.80.4 + - SES: SES 4.50 + + +***** +Note for IAR 8 users: +(Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits). + +To run a project using IAR 8, follow these intructions: + - Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file. + - If the project contains one of the precompiled libraries listed below, replace it + with the IAR 8 compatible alternative (there are no projects targeting nRF51 in this SDK). + - Save the project. + - When building the project, you might get the warning: "The header file 'cmsis_iar.h' is obsolete and should not be used. [...]". + - The problem is described in DevZone post: https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h + The solution is to remove all occurrences of #include . + +The affected libraries are: + - micro-ecc crypto: + - IAR7: Includes library located in the folder named “…_iar\…”. + - IAR8: Switch to using the library from the folder named “…_armgcc\…”. + - nrf_cc310, nrf_cc310_bl, and nrf_oberon: + - IAR7: Link to a library where “short_wchar” is part of the folder name. + - IAR8: Link to a library without “short_wchar” in part of the folder name. + - Gazell, NFC Tag, and 802.15.4: + - IAR7: Includes the library where the file name ends with “_iar”. + - IAR8: Switch to using the library with similar file name that ends with “_gcc”. +***** + +Supported SoftDevices: + - S112 v7.x.x + - S113 v7.x.x + - S122 v8.x.x + - S132 v7.x.x + - S140 v7.x.x + - S212 v6.1.x + - S312 v6.1.x + - S332 v6.1.x + - S340 v6.1.x + +Supported boards: + +- PCA10040 +- PCA10040E (nRF52810 emulation on PCA10040) +- PCA10056 +- PCA10056E (nRF52811 emulation on PCA10056) +- PCA10100 (support in selected examples) +- PCA10100E (nRF52820 emulation on PCA10100) +- PCA10059 (support in selected examples) +- D52DK1 from Garmin Canada (only for ANT examples) +- PCA10112 (nRF52840 with the nRF2140 front-end chip) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** New features +***************** + +** Drivers and libraries ** + +- nRF21540 Front-End Module support: + - New driver supporting the nRF21540 RF front-end module + can be found in '.\driver_ext\nrf21540\' + - The DTM and Radio Test examples have been updated + to include the nRF21540 driver (only GPIO control has been tested). + - Workaround handling Errata 1 for nRF21540 is not included as part of + the driver and must be applied separately. +- Radio Test example: + - Extended the 'start_tx_modulated_carrier' command with an additional + option for setting the specific number of packets to transmit. + - Added printing of the received packet statistics in the 'print_rx' command handler. +- nrfx: + - Updated version to 1.8.4. + - Added support of the nRF52820 device. + - Added new SAADC driver backported from nrfx 2.2.0 branch. +- nrf_cc310: + - Updated version to 0.9.13. + - Bugfix release with new mechanism for enabling and disabling the hardware + and for interrupt masking. See Migration Guide for details. +- nrf_cc310_bl + - Updated version to 0.9.13. + - Bugfix release with new mechanism for interrupt masking. +- nrf_oberon + - Updated version to 3.0.5. + - General version update supporting more nRF5 architectures. + - Addition of header files for the mbedcrypto frontend. + See Migration Guide for details. +- USB: added support for nRF52820. + + +*** Changes +*********** + +** Drivers and libraries ** + +- Radio Test example: refactored to use the Radio HAL module (nrf_radio.h) functions. +- nrfx: see the nrfx 1.8.4 changelog in modules/nrfx/CHANGELOG.md. + +** Crypto ** + +- nrf_cc310 library now automates enabling and disabling of CryptoCell hardware + and interrupts. It is no longer done in nrf_crypto. See Migration Guide for details. + +** NFC ** + +- T4T: allowed dynamic R/W NDEF message buffer changing. + Now you can change the NDEF buffer in any protocol state, + without having to disable the T4T emulation. +- T4T: added pointer to the NDEF message buffer for the 'NDEF Updated' event. + +** Bluetooth Low Energy ** + +- Scanning Module: removed the 'Scan Request' event + that is irrelevant for the scanner role. +- External Tile library: integrated a new library version. + +** DTM ** + + - Updated DTM to support the nRF52820 device. + - Added new example targets: + - pca10100e: for nRF52820 emulation on pca10100. + - pca10112: a version for a development kit with the nRF52840 device + and the nRF2140 front-end chip. + + +*** Bug fixes +**************** + +** Drivers and libraries ** + +- nrfx: see the nrfx 1.8.4 changelog in modules/nrfx/CHANGELOG.md. +- Fixed a bug where FDS garbage collection ran on more pages than necessary, + causing unnecessary flash wear. + +** ANT ** + +- ANT Shared Channels example (slave project): fixed array size check. + +** NFC ** + +- T4T: fixed detecting of the end of reading NDEF message procedure + (NFC_T4T_EVENT_NDEF_READ). +- T4T: fixed an issue where NDEF Read event was triggered even when + NDEF Message was empty. + +** Bluetooth Low Energy ** + +- Fixed nrf_sd_def.h file contents in all SoftDevices + (in some cases, the definitions in this file were outdated). +- External Tile library: fixed a few minor issues. +- Nordic UART Service: added a null-pointer check in the + notification transmitted handler. +- Fixed a vulnerability issue reported by IOActive where malformed + advertising data could be used to attack a device that does scanning. + The fix is included in ble_advdata_search() in ble_advdata.c where + an extra check has been added to ensure that the length values specified + within the advertising packet are within the boundary of the advertising packet. + +** DFU ** + +- SES will now return a linker error if the bootloader is too large. +- Fixed a bug that caused SD+BL updates to fail if the SD had signature boot validation. +- Fixed an error in the code that booted the app, which could happen + with certain optimization settings. +- Fixed a false positive assert that could sometimes happen after a reset + during an upgrade. +- Fixed a bug that caused compilation errors when building with a board with no buttons. + +** DTM ** + +- DTM reports regarding Max Octets are now correct for devices without long range support. + +** USB ** + +- Fixed issues and optimized app_usbd_string_desc. +- Fixed issues in USB CLI backend when handling a port close. + +** Proprietary ** + +- Gazell: fixed an assertion that would be sometimes generated after + a packet transmission. +- ESB: fixed a bug in the nrf_esb_pop_tx function where packages would get sent anyway + in certain situations. + + +*** Known Issues +**************** + +** General ** + +- The workaround for Anomaly 198 for nRF52840 SPIM3 peripheral + that has been implemented in nrfx_spim cannot be used with a SoftDevice. + Flag NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED must be set to zero. + The workaround based on a dedicated RAM block for SPIM3 must be used instead. +- usbd_msc example has a limitation. + With setting "APP_USBD_CONFIG_EVENT_QUEUE_ENABLE = 0", + when USB cable is unplugged and re-plugged, the application goes into an endless loop. + This is due to an issue in the unsupported block device library. + +** Bluetooth Low Energy ** + +- GATTC: the ble_gattc_service_t::uuid field is incorrectly populated + in the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event if the + sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read() + are called when a Primary Service Discovery by Service UUID is already ongoing. + When the application has called sd_ble_gattc_primary_services_discover(), + it should wait for the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event before calling + sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read(). +- BLE Interactive CLI example: the command to set a custom ATT MTU only takes + effect on the subsequent connection and the updated MTU parameter is not + maintained in further connections with the same peer, even when bonded. +- ANT Shared Channels example: when testing a Bluetooth Low Energy connection + with an Android device, the link is terminated by Android due to unhandled LL requests. +- Bluetooth ANCS example: when connected from iPhone and pressing DK buttons, + the example may assert before the Bluetooth Low Energy link is authenticated. + + +** Crypto ** + +- The nrf_crypto CLI example may fail when using an ECC private key converted + from raw function for specific curve types. + +** Drivers and libraries ** + +- The SAADC driver (from nrfx 1.8.x) does not handle detection limits 'high' and 'low' + correctly if SAADC resolution is greater than 10 bits. + SAADC driver ported from nrfx 2.2.x is not affected by this. +- USBD: + - The library may handle Remote Wakeup incorrectly. + - Issuing a SET_ADDRESS(0) request does not cause the device to change + its state to default. + - The device does not STALL when a DATA transaction is received outside of SETUP. + It ACKs instead. +- The following macros defined in boards.h work only with pins on port 0: + - LEDS_OFF + - LEDS_ON + - LED_IS_ON + - LEDS_INVERT + - LEDS_CONFIGURE +- The low_power_pwm library does not correctly initialize GPIOs + that are placed on PORT1 in the low_power_pwm_init function. + This indirectly affects the led_softblink library and can also affect + the DFU open bootloader. + + +============================== + +nRF5 SDK v16.0.0 +------------------------ +Release Date: October, 2019 + +Highlights: + +- Added support for a new chip: nRF52833 +- Added support for new BLE SoftDevices version 7, as well as the new SoftDevice S113. +- Added an external Tile BLE library and a corresponding example + demonstrating the "find me" feature. +- App Timer v2 is now out of experimental and replaces the legacy App Timer + in all examples. + + +The following toolchains/devices have been used for testing and verification: + + - ARM: MDK-ARM version 5.25 + - GCC: GCC ARM Embedded 7.2018q2.update + - IAR: IAR Workbench 7.80.4 + - SES: SES 4.18 + + +***** +Note for IAR 8 users: +(Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits). + +To run a project using IAR 8, follow these intructions: + - Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file. + - If the project contains one of the precompiled libraries listed below, replace it + with the IAR 8 compatible alternative (there are no projects targeting nRF51 in this SDK). + - Save the project. + - When building the project, you might get the warning: "The header file 'cmsis_iar.h' is obsolete and should not be used. [...]". + - The problem is described in DevZone post: https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h + The solution is to remove all occurrences of #include . + +The affected libraries are: + - micro-ecc crypto: + - IAR7: Includes library located in the folder named “…_iar\…”. + - IAR8: Switch to using the library from the folder named “…_armgcc\…”. + - nrf_cc310, nrf_cc310_bl, and nrf_oberon: + - IAR7: Link to a library where “short_wchar” is part of the folder name. + - IAR8: Link to a library without “short_wchar” in part of the folder name. + - Gazell, NFC Tag, and 802.15.4: + - IAR7: Includes the library where the file name ends with “_iar”. + - IAR8: Switch to using the library with similar file name that ends with “_gcc”. +***** + +Supported SoftDevices: + - S112 v7.x.x + - S113 v7.x.x + - S132 v7.x.x + - S140 v7.x.x + - S212 v6.1.x + - S312 v6.1.x + - S332 v6.1.x + - S340 v6.1.x + +Supported boards: + +- PCA10040 +- PCA10040E (nRF52810 emulation on PCA10040) +- PCA10056 +- PCA10056E (nRF52811 emulation on PCA10056) +- PCA10100 (support in selected examples) +- PCA10059 (support in selected examples) +- D52DK1 from Garmin Canada (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** New features +***************** + +** Drivers and libraries ** + +- nRF52833: added USB support - both USB device hardware driver and USB Device library. +- Radio Test Example: added a project for nRF52833. + + +** BLE** + +- Added a new library GATT Queue which can be used for buffering GATT procedures when + the SoftDevice cannot process them immediately. It can be used with, for example, + Indications, Read or Write Requests etc. The queued procedure is automatically + retried when events from the SoftDevice indicate that it can be processed. + Most of the GATT Client libraries use this module. +- Added support for the new SoftDevice S113 in selected BLE examples. +- Improved Database Discovery Module design to enable multiple instances, + for example to perform independent discovery on each connection. +- BLE Interactive CLI Example: added discovery of 128-bit UUID Services and + Characteristics at the first attempt. +- Advertising Module: improved dynamic advertising data update, no additional buffer + is needed now - swap buffer was introduced within the module implementation. +- Added a new external BLE library: Tile, and a corresponding example: ble_app_tile. + The project implements proprietary GATT services for demonstrating the + "find me" feature. + The integrated modules include source code as well as a precompiled linkable library. + + +** DFU ** + +- Updated documentation with information on Secure Boot and platform architecture + security. + + +** NFC ** + +- Added support for new chip: nRF52833. Added corresponding projects in selected + examples. + + +** USB ** + +- APP_USBD_BCD_VER_MAKE macro now includes a sub-minor version parameter. +- Feature reports functionality is now supported in HID generic class. + + +** Proprietary ** + +- ESB: added support for the new chip nRF52833. +- Gazell: added support for nRF52810 and nRF52811. + +** DTM ** + +- Updated Direct Test Mode to support nRF52833. + +*** Changes +*********** + +** Drivers and libraries ** + +- app_timer: App Timer v2 moved out of experimental. It is updated and + API-compatible with the old implementation making it easy to replace. + All SDK examples using App Timer are updated to use the new version. +- libuarte: + - libuarte moved out of experimental. + - nrf_libuarte renamed to nrf_libuarte_drv (file names and API). + - Added option to use an app_timer instance for RX timeout instead of the TIMER or + RTC peripheral. +- nrf_cli: CLI now automatically adds an `\r` character before each printed `\n` + character. This feature can be switched off in sdk_config with flag + `NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF`. +- FDS: FDS-specific error codes have been moved so their values do not overlap with + other error codes. + Also, NRF_SUCCESS is now used instead of FDS_SUCCESS. + + +** Crypto ** + +- Updated OPTIGA Trust X library code and example. +- Updated the nrf_oberon library version to 3.0.1, changing the API prefixes from + occ_* to ocrypto_*. + + +** BLE ** + +- Peer Manager: + - Changed the pm_peer_data_* API to use uint32_t length variables instead of + uint16_t. + - The flash cleaning algorithm in peer_manager_handler now also runs garbage + collection if other users of FDS have deleted data. + - The fds_error member variable has been removed from PM events. + - Added a LESC flag to pm_conn_sec_status_t. + - Add a new function pm_sec_is_sufficient() where the security state of the + connection is checked against a reference security state. + - Function pm_sec_is_sufficient() is now used internally when responding + to slave security requests. + - pm_handler has been augmented with new event handlers based on + pm_sec_is_sufficient(). +- Advertising Module: removed obsolete API. +- ble_conn_state: Added a LESC flag to connection state (i.e. whether LESC was used + for bonding/pairing). It can be false even if LESC was used. + See Peer Manager for a completely accurate reporting of LESC. +- BLE Central UART Example: added support for Windows-type line end characters. +- Running Speed and Cadence Example: added handling of the Database Discovery Available + event. +- Heart Rate Example: + - Changed default configuration for nRF52810 and nRF52811. + - Service Change Characteristic disabled. + - Disabled protection against repeated pairing attempts in Peer Manager. + - FDS: Reduced number of virtual flash pages to use. + + + +** DFU ** + +- Bootloader start address is now placed in UICR at compile time, and the MBR page is + populated at runtime. This is to mitigate problems with flashing + where the MBR was erased. +- The MBR folders have been merged into a single folder since the MBR is identical for + all nRF52 variants. +- The bootloader now disallows upgrading the SoftDevice to another family + (e.g. s140 -> s113). +- nrf_bootloader_app_start() can no longer be called from an interrupt handler. +- BLE DFU: Disconnect link when aborting DFU (OP_ABORT). +- The bootloader will now wait a configurable number of milliseconds before each chip + reset. Configured with NRF_BL_RESET_DELAY_MS. +- Added a configuration option for disabling a debug port: NRF_BL_DEBUG_PORT_DISABLE. +- When the bootloader is compiled in a configuration where the app does not need access + to the settings page, the page itself, not just the backup, is locked before booting + the app. + + +** USB ** + +- USB driver: all changes listed here: + https://github.com/NordicSemiconductor/nrfx/blob/v1.8.0/CHANGELOG.md +- USB libraries: APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERNINAL + has been renamed to APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERMINAL. +- bDescriptorSubType field in app_usbd_audio_ac_iface_header_desc_t struct + has been renamed to bDescriptorSubtype. +- bmRequest field in app_usbd_cdc_notify_t struct has been renamed to bRequest. +- bmRequest field in app_usbd_setup_t struct has been renamed to bRequest. +- New values have been added to app_usbd_msc_subclass_t and app_usbd_msc_req_t enums. +- Terminal link in AS Interface Descriptor has been added as a parameter + for the APP_USBD_AUDIO_GLOBAL_DEF macro. + + +*** Bug fixes +**************** + +** Drivers and libraries ** + +- FDS: fixed two bugs where a power loss at very specific times during garbage + collection could corrupt the file system, making FDS unable to initialize and return + FDS_ERR_NO_PAGES on initialization. +- FDS: fixed a bug that prevented using the last word of a flash page to save a record. + + +** ANT ** + +- Fixed a bug in ANT-FS Library, where incoming burst frames could be incorrectly + handled due to wrong bitfield checking. + + +** NFC ** + +- Fixed a bug where the Tag could respond to an ALL_REQ frame with incorrect timing when + in the sleep state. + This bug would occur after the Tag received an SLP_REQ frame and when an ALL_REQ frame + was received shortly after - in a time shorter than what was configured + in the NFCT FRAMEDELAYMAX register (in Type 4 Tag default configuration: 4.8 ms). + + +** BLE ** + +- Eddystone: fixed bug for handling 0.625 unit in advertising interval. +- Advertising Module: fixed a bug where a secondary PHY configuration might get + overwritten. +- Advertising Data Encoder: fixed a bug causing underflow of a return value + of the parsing function when malformed data was provided as input. +- Nordic UART Service: fixed a bug where incorrect Characteristic CCCD + was checked on connection event. +- Database Discovery: fixed counting of discovered services. + - Fixed a bug where "available" events (indicating the module is ready + for the next discovery process) were not triggered. +- BLE Interactive CLI Example: fixed a bug where not all + GATT Characteristics and Descriptors were discovered when a short ATT MTU was used. +- Peer Manager: + - Fixed a bug where peer ranks would not work after deleting all peers. + - Fixed a bug where the indications for service changed would be dropped + if they were sent at the same time as an MTU exchange. + + +** DFU ** + +- Fixed a bug where resuming a DFU procedure with a disconnect (but no reset) + in-between could leave the bootloader in a semi-locked state. +- Fixed an issue where write protection of the application was not applied. + + +*** Known Issues +**************** + +** General ** + +- The workaround for Anomaly 198 for nRF52840 SPIM3 peripheral + that has been implemented in nrfx_spim cannot be used with a SoftDevice. + Flag NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED must be set to zero. + The workaround based on a dedicated RAM block for SPIM3 must be used instead. + + +** BLE ** + +- GATTC: the ble_gattc_service_t::uuid field is incorrectly populated + in the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event if the + sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read() + are called when a Primary Service Discovery by Service UUID is already ongoing. + When the application has called sd_ble_gattc_primary_services_discover(), + it should wait for the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event before calling + sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read(). +- The TFTP Background DFU example has known instabilities. +- The Tile example disconnects when notifications in the Tile service are on + and the application sends the first Battery Level notification. +- BLE Interactive CLI example: the command to set a custom ATT MTU only takes + effect on the subsequent connection and the updated MTU parameter is not + maintained in further connections with the same peer, even when bonded. +- ANT Shared Channels example: when testing BLE connection with an Android device, + the link is terminated by Android due to unhandled LL requests. +- Bluetooth ANCS example: when connected from iPhone and pressing DK buttons, + the example may assert before the BLE link is authenticated. + + +** Crypto ** + +- The nrf_crypto CLI example may fail when using ecc private key converted + from raw function for specific curve types. + + +** Drivers and libraries ** + +- The SAADC driver does not handle detection limits 'high' and 'low' correctly + if SAADC resolution is greater than 10 bits. +- USBD: + - The library may handle Remote Wakeup incorrectly. + - Issuing a SET_ADDRESS(0) request does not cause the device to change + its state to default. + - The device does not STALL when a DATA transaction is received outside of SETUP. + It ACKs instead. + + +** IoT ** + +- The MQTT example does not compile when run on PCA10040 with commissioning + enabled (COMMISSIONING_ENABLED=1). +- DTLS example: the server and the client application of the DTLS example should + not be run on two kits. Instead, either the server or the client application + should be run against the PC application as described in the documentation. + + + + +=========================================== + +nRF5 SDK v15.3.0 +------------------------ +Release Date: Week 7, 2019 + +Highlights: + +- Added support for a new chip - nRF52811. +- Added support for two new ANT SoftDevices: S312 targeting nRF52810 and nRF52832, and S340 targeting nRF52840. +- Added back support for the ANT SoftDevice S332 v6.1.1, as well as updated the latest SoftDevices S112, S132, S140 and S212 v6.1.1. +- Updated the SDFU solution with ANT transport layer. +- Updated DTM to support nRF52811, and updated the existing code to correctly handle Anomaly 172. + + + +The following toolchains/devices have been used for testing and verification: + + - ARM: MDK-ARM version 5.25 + - GCC: GCC ARM Embedded 7.2018q2.update + - IAR: IAR Workbench 7.80.4 + - SES: SES 4.12 + +Note: The selected GCC version has shown instabilities when using the Link Time Optimization feature, and using the feature is not recommended. + +***** +Note for IAR 8 users: +(Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits). + +To run a project using IAR 8, follow these intructions: + - Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file. + - If the project contains one of the precompiled libraries listed below, replace it with the IAR 8 compatible alternative + (there are no projects targeting nRF51 in this SDK). + - Save the project. + - When building the project, you might get the warning: "The header file 'cmsis_iar.h' is obsolete and should not be used. [...]". + - The problem is described in DevZone post: https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h + The solution is to remove all occurrences of #include . + +The affected libraries are: + - micro-ecc crypto: + - IAR7: Includes library located in the folder named “…_iar\…”. + - IAR8: Switch to using the library from the folder named “…_armgcc\…”. + - nrf_cc310, nrf_cc310_bl, and nrf_oberon: + - IAR7: Link to a library where “short_wchar” is part of the folder name. + - IAR8: Link to a library without “short_wchar” in part of the folder name. + - Gazell, NFC Tag, and 802.15.4: + - IAR7: Includes the library where the file name ends with “_iar”. + - IAR8: Switch to using the library with similar file name that ends with “_gcc”. +***** + +Supported SoftDevices: + - S112 v6.1.x + - S132 v6.1.x + - S140 v6.1.x + - S212 v6.1.x + - S312 v6.1.x + - S332 v6.1.x + - S340 v6.1.x + +Supported boards: + - PCA10040 + - PCA10040E (nRF52810 emulation on PCA10040) + - PCA10056 + - PCA10056E (nRF52811 emulation on PCA10056) + - PCA10059 (support in selected examples) + - D52DK1 from Garmin Canada (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** New features +***************** + +** ANT ** + +- Added the new ANT Secure DFU Bootloader example. + The example demonstrates how to use the new ANT transport with Secure DFU components + (with support only for SES and GCC toolchains). +- Removed legacy ANT bootloader solution. + + +** Drivers and libraries ** + +- nrf_cli can now prompt and autocomplete both sorted and unsorted subcommands. +- nrf_libuarte and nrf_libuarte_async now support multiple instances. + + +** BLE** + +- nrf_ble_lesc (part of the Peer Manager) now supports the LESC OOB pairing mode. + The ble_nfc_pairing_reference_c example demonstrates how to pass the OOB data to the module. + + +** DFU ** + +- Added the option to perform signature validation of the application on each boot. + This functionality requires nrfutil version 5.0.0 or higher. +- The DFU procedure can now mandate strictly increasing application versions. +- Added the option to send applications that will not be activated, but will remain in slot 1 ("external applications"). + This functionality requires nrfutil version 5.0.0 or higher. +- Added masking of GPREGRET and GPREGRET2 registers, enabling the upper 3 bytes of each register to be used by the application independently of the bootloader. + +** Crypto ** + +- Added nrf_crypto backend support for Infineon OPTIGA™ Trust X devices (selected features). +- Added new example to showcase Infineon OPTIGA Trust X functionality: examples/crypto/ifx_optiga_custom_example. + + +*** Changes +************ + +** DFU ** + +- Turned off Link Time Optimization in all DFU projects due to instabilities in the supported GCC compiler. + +** Drivers and libraries ** + +- nrf_cli: CLI will now automatically add the `\r` character before each printed `\n` character. + This feature can be switched off in sdk_config using flag `NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF`. +- USB: A complete list of changes is available under this link: https://github.com/NordicSemiconductor/nrfx/blob/a0dcb1350f6798f12479921a0a376d00e2316fd4/CHANGELOG.md + +** NFC ** + +- The NFC libraries (nfc_t2t_lib and nfc_t4t_lib) now use the NFCT driver instead of the NFC HAL modules (hal_nfc_t2t and hal_nfc_t4t). + The NFCT driver is a part of nrfx repository. +- Replaced hal_nfc_t2t and hal_nfc_t4t components with the nrfx_nfct driver. +- Added the NFC platform module (nfc_platform) to abstract runtime environment specific implementation from the driver. + HFCLK activation, required for NFC to operate correctly, is managed in this module. +- Removed the nfc_fixes.h file with NFC workaround description. The content of this file was moved to nrfx_nfct.h. + +** Crypto ** + +- nrf_oberon, nrf_cc310, and nrf_cc310_bl libraries have changed naming and placement compared to the previous release. + They are now available in the following folder scheme: + - GCC and IAR 8.x: lib//hard-float/.a + - IAR 7.80.x: lib//hard-float/short-wchar/.a + - Keil: lib//hard-float/short-wchar/.lib + Due to this naming convention change, updated nrf_cc310 and nrf_cc310_bl library version to 0.9.12. + Due to this naming convention change, updated nrf_oberon library version to 2.0.7. +- Changed ECC Public Key Validation from "Full" to "Partial" in nrf_crypto backend for ARM CC310. + This improves LESC pairing and ECDSA verify timing. + + +*** Bug fixes +**************** + +** Drivers and libraries ** + +- nrf_cli: The module can now be used with terminals with no standard background color (for example, white). +- USB: Fixed a bug where USB IRQ was not cleared after unplugging the USB cable. +- Fixed an issue where NRF_LOG_INIT(timestamp, frequency) failed to compile if the logger was disabled. +- Fixed a compilation failure issue when using NRF_LOG_HEXDUMP_WARNING. +- Fixed a scenario where the emulated project delay function (nrfx_coredep_delay_us) did not work correctly. + +** BLE ** + +- Peer Manager: + - Slave Security Requests received during a pairing or encryption procedure will now be ignored (to align with the BLE specification). + - Fixed a bug where Peer Manager would misinterpret a peer central's ability to resolve resolvable addresses in directed advertisements. + - Fixed a bug where Peer Manager would sometimes give a fatal error if the link disconnected during a pairing procedure. + - Fixed a bug where flash could be full but no Peer Manager event was sent. + - Fixed a bug where Peer Manager would silently drop Service Changed indications if an ATT MTU exchange was happening at the same time. +- Eddystone: + - Fixed a bug where EID was not correctly updated. + - Fixed bug where factory reset would not work correctly when followed by an immediate disconnect. + +** DFU ** + +- Various security improvements and fixes. +- Fixed various bugs in background DFU. +- Fixed bugs that appeared when combining transports (for example, UART + BLE). + +** DTM ** + +- Fixed a bug which made the workaround for nRF52840 Anomaly 172 non-functional. + +** Serialization ** + +- Fixed an issue with HCI transport sending redundant bytes on certain packet payloads containing escape codes. +- Fixes in serialization codecs. + + +*** Known Issues +**************** + +** General ** + +- Programming and debugging the nRF52811 chip may require an update of the J-Link firmware in order to recognize the new chip. +- The workaround for Anomaly 198 for nRF52840 SPIM3 peripheral that has been implemented in nrfx_spim cannot be used with a SoftDevice. + Flag NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED must be set to zero. + The workaround based on a dedicated RAM block for SPIM3 must be used instead. + +** BLE ** + +- GATTC: the ble_gattc_service_t::uuid field is incorrectly populated in the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event + if the sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read() are called when a Primary Service Discovery by Service UUID is already ongoing. + When the application has called sd_ble_gattc_primary_services_discover(), it should wait for the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event before calling sd_ble_gattc_primary_services_discover() or sd_ble_gattc_read(). +- The TFTP Background DFU example has known instabilities. + +** Drivers and libraries ** + +- The SAADC driver does not handle detection limits 'high' and 'low' correctly if SAADC resolution is greater than 10 bits. +- USBD: + - The library may handle Remote Wakeup incorrectly. + - Issuing a SET_ADDRESS(0) request does not cause the device to change its state to default. + - The device does not STALL when a DATA transaction is received outside of SETUP. It ACKs instead. + +** IoT ** + +- For Linux kernels >= 4.12, The BLE_6LOWPAN_LEGACY_MODE configuration parameter must be set to 0 (the default is 1). + The default value must be kept for Linux kernels < 4.12. + With this configuration set up incorrectly, the examples do not work and are difficult to debug. + + + +====================================================================== + +nRF5 SDK v15.2.0 +------------------------ +Release Date: Week 37, 2018 + +This SDK release is an update replacing the non-published nRF5 SDK release v15.1.0. +The main updates compared to v15.1.0 are summarized in the last three points of the Highlights section. + +Highlights: + - Added support for the new SoftDevices S140, S132, and S112 v6.1.0. + - Added new targets for running S112 on nRF52832 (PCA10040). + - Updated ESB library to support all nRF52 devices (nRF52810, nRF52832 (Rev.1 & Rev.2), and nRF52840). + - Updated SDFU to include nRF52810 target (PCA10040E). + - Released nrf_log in production quality. + - Removed the workaround in nrf_sdh.c overriding the default priority level on SWI interrupt SD_EVT_IRQn and RADIO_NOTIFICATION_IRQn used by the SoftDevice. + - Changed the default interrupt priority level for the peripherals from 7 to 6. This is done to be aligned with the priority of the SWI coming from the SoftDevice. + - Fixed an interoperability issue with some Windows 10 versions when bonded and using directed advertising. + +Note: Due to compatibility issues, you must run the upgrade using nRF Connect Desktop v2.5.0 or later when testing the Bluetooth examples in nRF5 SDK v15.2.0. + +The following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM version 5.18a + - GCC: GCC ARM Embedded 6.3 2017-q2-update + - IAR: IAR Workbench 7.80.4 (IAR 8 - see note below) + - SES: SES 3.40 + +***** +Note for IAR 8 users: +(Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits). + +To run a project using IAR 8, follow these intructions: + - Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file. + - If the project contains one of the precompiled libraries listed below, replace it with the IAR 8 compatible alternative + (there are no projects targeting nRF51 in this SDK). + - Save the project. + - When building the project, you might get the warning: "The header file 'cmsis_iar.h' is obsolete and should not be used. [...]". + - The problem is described in DevZone post: https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h + The solution is to remove all occurrences of #include . + +The affected libraries are: + - micro-ecc crypto: + - IAR7: Includes library located in the folder named “…_iar\…”. + - IAR8: Switch to using the library from the folder named “…_armgcc\…”. + - nrf_cc310, nrf_cc310_bl, and nrf_oberon: + - IAR7: Includes the library where “_short_wchar_” is part of the file name. + - IAR8: Switch to using the library with similar naming, but where the “short_wchar” is removed. + - Gazell, NFC Tag, and 802.15.4: + - IAR7: Includes the library where the file name ends with “_iar”. + - IAR8: Switch to using the library with similar file name that ends with “_gcc”. +***** + +Supported SoftDevices: + - S112 v6.1.x + - S132 v6.1.x + - S140 v6.1.x + - S212 v5.0.x + +Supported boards: + - PCA10040 + - PCA10040E (nRF52810 emulation on PCA10040) + - PCA10056 + - PCA10059 (support in selected examples) + - D52DK1 from Garmin Canada (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** New features +***************** + +** BLE ** + - Added new targets to demonstrate the use of S112 on nRF52832 (PCA10040). + - Added "Property Read" for the Object Transfer Service client (ble_app_ots_c). + - Added a Scanning Module to simplify scanning for BLE devices in central role. + - Peer Manager: + - peer_manager_handler.h: There are now standard event handlers available to users of the Peer Manager. + The event handlers provide features like logging, automatically securing the link, and automatically + deleting the oldest bond if the flash is full. + - PM_RA_PROTECTION_ENABLED: The Peer Manager can now be configured to reject repeated security requests + from peers that failed pairing. + - PM_LESC_ENABLED: Improved LESC support. + - PM_LOG_ENABLED: Added error and warning level logging messages to the Peer Manager. + - PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED: Added new event. + - PM_PEER_DATA_ID_CENTRAL_ADDR_RES: Added automatic storing of the peer's Central Address Resolution value during bonding. + - pm_peer_id_list(): Added a new function for creating lists of Peer IDs, including some filtering. + - Added LESC support to the following examples: ble_app_hrs, ble_app_hrs_c, and ble_app_gls. + - Added support for nRF52840 (PCA10056) in the beacon example (ble_app_beacon). + - Added Swift Pair support to the HID mouse example (ble_app_hids_mouse). + - Battery Service: Added the possibility to notify a reconnected, bonded peer of an updated battery level. + This feature is demonstrated in the Immediate Alert Server example. + +** Crypto ** + - EdDSA: Added support for Edwards-curve Digital Signature Algorithm (Ed25519). + - In documentation, added a table showing supported nrf_crypto backends for different examples: + http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/nrf_crypto_default_backends.html + +** DFU/Bootloader ** + - Added a new target to the SDFU example to demonstrate SDFU running on nRF52810 (PCA10040E). In a single bank update, there is only + about 60 kB of flash available. This restricts what can be updated. + - The bootloader settings page is now backed up before being updated. This increases protection from corruption caused by chance events + (for example, power failure) and malicious apps. + - The advertising interval of BLE DFU can now be configured in sdk_config (NRF_DFU_BLE_ADV_INTERVAL). + - The size of the application data area that is left alone by the bootloader can now be configured + in sdk_config (NRF_DFU_APP_DATA_AREA_SIZE). + - The bootloader code now supports most of nrf_crypto backends. However, the size of the binary will likely be too large if other backends + are used, so you will need to accomodate by increasing the size of the bootloader. + +** USB ** + - Added response/no response to an IN token on ISO IN endpoint with a ZLP when no data is ready. This can be set with USBD_CONFIG_ISO_IN_ZLP. + - Added support for configuration string ID. + - Added an option to give priority to isochronous transfers using USBD_CONFIG_DMASCHEDULER_ISO_BOOST. + - Implemented SOF event callback in interrupt for classes. + - Added an enum and get function for a selected protocol (boot or report) in HID. Implemented a SET_PROTOCOL propagation mechanism using + on_set_protocol methods. Buffers can now be cleared after the SET_PROTOCOL command using clear_buffer methods. + - Redesigned the idle report mechanism in HID. It now allows a callback function and handles multiple report IDs. + - Added an option to send a ZLP on write with the same size as the endpoint in CDC ACM class using APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE. + - Implemented macros to set interval for individual endpoints. See APP_USBD_EP_WITH_INTERVAL. + - Transfers in Audio class can now be started in SOF interrupt set in the app_usbd_audio_sof_interrupt_register function. + + +*** Changes +************ + +** BLE ** + - Increased the length of the advertising name for the Running Speed and Cadence sensor example (ble_app_rscs) to make it easy to verify + that it is using the extended advertising. + - Included the Scanning module into all BLE examples. This aligns how scanning is performed in these examples. + - Updated the NFC pairing examples (ble_app_hids_keyboard_pairing_nfc, ble_app_hrs_nfc_pairing, ble_nfc_pairing_reference) to start using + the LESC functionality in the Peer Manager (which uses the nrf_ble_lesc module). + - Removed the manual handling of credits for the Object Transfer Service (ble_app_ots and ble_app_ots_c). Most use cases now work faster + and simpler when the SoftDevice is controlling it. + - Updated the API documentation for advertising_init in the Advertising module (ble_advertising). It was clarified that UUID arrays were not + copied into the Advertising module. + - Advertising module (ble_advertising) is no longer dependent on the fstorage module. + - Changed the ANCS example (ble_app_ancs_c) so that it no longer performs service discovery after connecting to an already bonded peer. + - Lowered the advertising interval in the Eddystone example (ble_app_eddystone), because some advertising packets would be lost when combined + with the timeslot API. + - Reduced the maximum supported value for advertising interval in Eddystone from 20000 to 16384. If a higher value is set, the SoftDevice returns + an error code that asserts the application. + - Peer Manager: + - Various improvements to documentation. + - The Peer Manager will now take less space for the same features. + - To decrease complexity, the Peer Manager no longer uses the 'reserve' functionality in FDS, meaning that PM_EVT_STORAGE_FULL + events will come slightly later if bonds cannot be stored during bonding. + - Error event parameters now specify whether the error code is to be interpreted as an FDS_ error or an NRF_ error. + - Peers without a stored rank are now never returned from pm_peer_ranks_get(). + - The function pm_peer_data_load() now fills the array even when returning NRF_ERROR_DATA_SIZE. + - Enabled internal LESC key handling through PM_LESC_ENABLED. Function pm_lesc_public_key_set() is now deprecated because of this change. + - All examples using the Peer Manager now use the new standard event handlers. + While some examples implement custom behavior, all examples do the following: + - Log Peer Manager events (at different log levels). + - Encrypt immediately on connection with bonded peers. + - Delete old bonds to make room for new peer data. + - Some examples supporting central mode disconnect when link encryption fails. Look for functions calling pm_handler_disconnect_on_sec_failure(). + - The ble_app_bms example will now request for security procedure to be initiated if the Central does not initiate it. + - Updated examples with directed advertisement to take into account Central Address Resolution value. + +** IEEE 802.15.4 ** + - Updated the radio test example to support 802.15.4 radio modes. + +** Crypto ** + - Updated documentation about RAM requirements on mbed TLS. + - Added endianness change Curve25519 (to little endian). + - Removed the following defines. A compile error is shown if they are enabled in a configuration: + - NRF_CRYPTO_BACKEND_CC310_BL_HASH_LITTLE_ENDIAN_DIGEST_ENABLED + - NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED + - NRF_CRYPTO_BACKEND_MICRO_ECC_LITTLE_ENDIAN_ENABLED + - NRF_CRYPTO_BACKEND_NRF_SW_HASH_LITTLE_ENDIAN_DIGEST_ENABLED + - nrf_crypto micro-ecc backend: Moved ECDH public key validation from the key convert function to ECDH compute + (moved from nrf_crypto_backend_micro_ecc_public_key_from_raw to nrf_crypto_backend_micro_ecc_ecdh_compute). + - Upgraded nrf_cc310 and nrf_cc310_bl to version 0.9.10 including minor changes to some default configurations. + - Removed micro-ecc library/mbed TLS from BLE LESC examples for better user experience. + - micro-ecc library prevented a working compilation in a fresh LESC example (requires external download). + - mbed TLS significantly increases compilation time in the project, even if it is not configured as the enabled nrf_crypto backend. + +** DFU and Bootloader ** + - Updated documentation about how to change the existing SDFU project, so that the application can be uploaded without signature verification, + but at the same time to keep the signature verification when updating a SoftDevice and/or bootloader. + - The bootloader now does not use app_timer, which saves flash space. + - The bootloader now does the endian-conversion in code, instead of relying on endian-conversion in nrf_crypto. + +** Drivers and libraries ** + - Changed the peripherals' default interrupt priority level from 7 to 6. + - Included new version of nrfx (v1.1.0). For the nrfx changelog, see https://github.com/NordicSemiconductor/nrfx/blob/master/CHANGELOG.md + - nrf_log: + - Updated to production quality. + - You can now store/load the filtering configuration in FDS. + - You can now control one backend from another. + - nrf_cli: Added support for terminal meta keys. + +** Proprietary ** + - Updated ESB library to support all current variants of nRF52. This mainly involves adding proper handling of Errata related to the radio. + - Added a function to skip the next packet in the TX queue. This was previously a function used internally in the module under another name. + +** USB ** + - Moved USBD strings configuration to sdk_config. + - Rebuilt MSC class write procedure. + - Moved APP_USBD_CONFIG_LOG_ENABLED to nrf_log settings. + - HID report protocol is now default after reset. + - HID default idle rate after reset can now be defined. + - OUT transfers are now dropped when clearing stall on endpoint. + - SET_ADDRESS command is now defined as a separate event in app_usbd. It does not change the state of the device anymore. + - EP0 is now disabled until USB RESET condition is detected. + - HID OUT reports are now limited to 63 bytes of data + 1 byte reserved for report ID. + + +*** Bug fixes +**************** + +** BLE ** + - Fixed a bug in the BLE UART client (ble_app_uart_c) where it would check the wrong error code when issuing multiple write commands. + - Fixed a bug in the ANCS example (ble_app_ancs) where app_timer was included too many times. + - Fixed a bug in the Advertising module (ble_advertising) where a comment referred to seconds instead of 10 ms. + - Fixed a bug in the LESC connection example (ble_app_multirole_lesc) where the procedure for connection parameter update would not be started + immediately upon connection. + - Fixed a bug where a precompiled hex was missing for Immediate Alert Server (ble_app_ias) and Service Changed server (ble_app_gatts) examples. + - Fixed a bug in the Radio Notification Event Handler (ble_radio_notification) where a missing include stopped it from compiling. + - Fixed a bug in the BLE Interactive Command Line Interface Example in service discovery procedure. + - Fixed a bug in the Alert Notification Service, where it was not possible to enable notifications for an unread alert. + - Peer Manager: + - Fixed a bug where the event PM_EVT_FLASH_GARBAGE_COLLECTED was also sent when garbage collection failed. + - Fixed a bug in pm_next_peer_id_get() where it could report a peer with no data attached to it if used during bonding. + - Fixed a bug where peer data would not be written because the internal retry mechanism failed after two attempts. + - Fixed a bug where pairing (no bonding) could happen with an already bonded peer without triggering a PM_EVT_CONN_SEC_CONFIG_REQ event. + - Fixed several documentation bugs related to error codes. + - Eddystone: + - Fixed a bug where the default TX power was set to 0 instead of using the DEFAULT_FRAME_TX_POWER define. + - Fixed a bug where an invalid reference of a variable could cause incorrect data to be sent. + +** IEEE 802.15.4 ** + - Adjusted CCA threshold value to be correct for nRF52840 Rev. 1 (different from what was available on the Engineering sample). + - Implemented a fix for Anomaly 153 (temperature correction of RSSI measurement): added an API in RAL module for calculating the corrected RSSI value. + +** Drivers and libraries ** + - Fixed a bug in the SPI manager where app_timer was included too many times. + - Fixed a wrapping issue in the Ring Buffer library. + +** DFU/Bootloader ** + - Fixed a bug where the watchdog feeding in the bootloader did not happen during a certain FW activation. + +** DTM ** + - Added support for 8 dB on nRF52840 targets. + - Implemented the workaround for nRF52840 Anomaly 172 which caused the device to fail a test with interference in co-channels (RF-PHY/RCV/BV-29-C). + +** Proprietary ** + - Fixed a bug in bytewise_bit_swap where it was harder to backport the implementation to nRF51. + - Fixed a bug in nrf_esb_pop_tx where the packet queue would occasionally be corrupted. + - Added shutdown of the system timer as the workaround for Anomaly 78 and to save energy. + +** NFC ** + - Integrated fixes from EMVCo test suite (improved interoperability). + - Added automatic fix for Anomaly 181. + - Fixed a bug where HFCLK was requested too early for nRF52840 Rev. 1 chip. + - Changed the way the fixes for chip errata are switched: use chip defines from MDK instead of board defines (simplifying usage of custom boards). + +** USB ** + - Removed redundant barriers in USBD HAL. + - Fixed a bug in HID library where the report descriptor was limited to 64 bytes. + - Fixed a bug where USBD was not able to wake up after SOF event. + - Fixed a bug where the SET_ADDRESS command was not processed in time. + - USB application library (stack) now properly supports a situation when the HOST requests a descriptor but sets wLength Setup field to 0. + + +*** Known Issues +**************** + +** BLE ** + - Peer Manager: + - When a link is already secured and the peer sends a slave security request for a higher level of security, the request will not be honored. + - Service Changed indications might be silently dropped without being sent if the attempt to send them happens during an ATT MTU exchange. + - Service Changed indications might be silently dropped if the flash is full when the Service Changed flag is being stored in flash. + +** BLE IOT ** + - Neighbor discovery module for lwIP requires the on-link flag in the router advertisement to be set to create a SLAAC address from the prefix. + However, RFC 7668 (https://tools.ietf.org/html/rfc7668) requires this bit to be zero. Therefore, the nd6.c from lwIP source has been modified + to relax this check. + - There are some issues when using the IoT examples against Linux Kernel 4.12+ that cause the kernel to only work with one 6LoWPAN connection. + If more than one kit is connected using 6LoWPAN, none of the nodes will be accessible. + - Scheduler has been included in most IoT examples to avoid race conditions found when using the lwIP stack, more precisely the TCP examples. + The issue was that the TCP client would stop working after about 15 hours. However, when using mbed TLS, the use of scheduler is not possible. + Therefore, the MQTT client examples might be affected by this issue. + - The use of security, both with TLS and DTLS, should be treated as experimental. + - MQTT examples cannot be used with commissioning on nRF52832. There is not enough RAM to accommodate both TLS and the commissioning service. + - If enabled, RTT logs in IoT bootloader might not be printed before resetting. + - The background_dfu example does not work. + +** Drivers and libraries ** + - SAADC driver is not handling detection limits: high and low correctly if SAADC resolution is greater than 10 bits. + - In the radio test example, modulated packets will only have the requested content in the first two bytes. + Further bytes have random values. + - In the radio test example, start_duty_cycle_modulated_tx is not working as intended. + The actual duty cycle on air is not what was requested in the command. + +** USBD ** + - Due to Anomaly 199, the USBD driver blocks code execution during EasyDMA transfer (for stability). + - USBD BLE UART FreeRTOS example is not working when combined with Nordic UART Service Client example. + + +======================================================================== + +nRF5 SDK v15.1.0 +------------------------ +Release Date: Week 34, 2018 + +Highlights: + - Added support for the new SoftDevices S140, S132, and S112 v6.1.0. + - Added new targets for running S112 on nRF52832 (PCA10040). + - Updated ESB library to support all nRF52 devices (nRF52810, nRF52832 (Rev.1 & Rev.2), and nRF52840). + - Updated SDFU to include nRF52810 target (PCA10040E). + - Released nrf_log in production quality. + +Note: Due to compatibility issues, you must run the upgrade using nRF Connect Desktop v2.5.0 or later when testing the Bluetooth examples in nRF5 SDK v15.1.0. + +The following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM version 5.18a + - GCC: GCC ARM Embedded 6.3 2017-q2-update + - IAR: IAR Workbench 7.80.4 (IAR 8 - see note below) + - SES: SES 3.40 + +***** +Note for IAR 8 users: +(Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits). + +To run a project using IAR 8, follow these intructions: + - Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file. + - If the project contains one of the precompiled libraries listed below, replace it with the IAR 8 compatible alternative + (there are no projects targeting nRF51 in this SDK). + - Save the project. + - When building the project, you might get the warning: "The header file 'cmsis_iar.h' is obsolete and should not be used. [...]". + - The problem is described in DevZone post: https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h + The solution is to remove all occurrences of #include . + +The affected libraries are: + - micro-ecc crypto: + - IAR7: Includes library located in the folder named “…_iar\…”. + - IAR8: Switch to using the library from the folder named “…_armgcc\…”. + - nrf_cc310, nrf_cc310_bl, and nrf_oberon: + - IAR7: Includes the library where “_short_wchar_” is part of the file name. + - IAR8: Switch to using the library with similar naming, but where the “short_wchar” is removed. + - Gazell, NFC Tag, and 802.15.4: + - IAR7: Includes the library where the file name ends with “_iar”. + - IAR8: Switch to using the library with similar file name that ends with “_gcc”. +***** + +Supported SoftDevices: + - S112 v6.1.x + - S132 v6.1.x + - S140 v6.1.x + - S212 v5.0.x + +Supported boards: + - PCA10040 + - PCA10040E (nRF52810 emulation on PCA10040) + - PCA10056 + - PCA10059 (support in selected examples) + - D52DK1 from Garmin Canada (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** New features +***************** + +** BLE ** + - Added new targets to demonstrate the use of S112 on nRF52832 (PCA10040). + - Added "Property Read" for the Object Transfer Service client (ble_app_ots_c). + - Added a Scanning Module to simplify scanning for BLE devices in central role. + - Peer Manager: + - peer_manager_handler.h: There are now standard event handlers available to users of the Peer Manager. + The event handlers provide features like logging, automatically securing the link, and automatically + deleting the oldest bond if the flash is full. + - PM_RA_PROTECTION_ENABLED: The Peer Manager can now be configured to reject repeated security requests + from peers that failed pairing. + - PM_LESC_ENABLED: Improved LESC support. + - PM_LOG_ENABLED: Added error and warning level logging messages to the Peer Manager. + - PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED: Added new event. + - Added LESC support to the following examples: ble_app_hrs, ble_app_hrs_c, and ble_app_gls. + - Added support for nRF52840 (PCA10056) in the beacon example (ble_app_beacon). + - Added Swift Pair support to the HID mouse example (ble_app_hids_mouse). + - Battery Service: Added the possibility to notify a reconnected, bonded peer of an updated battery level. + This feature is demonstrated in the Immediate Alert Server example. + +** Crypto ** + - EdDSA: Added support for Edwards-curve Digital Signature Algorithm (Ed25519). + - In documentation, added a table showing supported nrf_crypto backends for different examples: + http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.1.0/nrf_crypto_default_backends.html + +** DFU/Bootloader ** + - Added a new target to the SDFU example to demonstrate SDFU running on nRF52810 (PCA10040E). In a single bank update, there is only + about 60 kB of flash available. This restricts what can be updated. + - The bootloader settings page is now backed up before being updated. This increases protection from corruption caused by chance events + (for example, power failure) and malicious apps. + - The advertising interval of BLE DFU can now be configured in sdk_config (NRF_DFU_BLE_ADV_INTERVAL). + - The size of the application data area that is left alone by the bootloader can now be configured + in sdk_config (NRF_DFU_APP_DATA_AREA_SIZE). + - The bootloader code now supports most of nrf_crypto backends. However, the size of the binary will likely be too large if other backends + are used, so you will need to accomodate by increasing the size of the bootloader. + +** USB ** + - Added response/no response to an IN token on ISO IN endpoint with a ZLP when no data is ready. This can be set with USBD_CONFIG_ISO_IN_ZLP. + - Added support for configuration string ID. + - Added an option to give priority to isochronous transfers using USBD_CONFIG_DMASCHEDULER_ISO_BOOST. + - Implemented SOF event callback in interrupt for classes. + - Added an enum and get function for a selected protocol (boot or report) in HID. Implemented a SET_PROTOCOL propagation mechanism using + on_set_protocol methods. Buffers can now be cleared after the SET_PROTOCOL command using clear_buffer methods. + - Redesigned the idle report mechanism in HID. It now allows a callback function and handles multiple report IDs. + - Added an option to send a ZLP on write with the same size as the endpoint in CDC ACM class using APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE. + - Implemented macros to set interval for individual endpoints. See APP_USBD_EP_WITH_INTERVAL. + - Transfers in Audio class can now be started in SOF interrupt set in the app_usbd_audio_sof_interrupt_register function. + + +*** Changes +************ + +** BLE ** + - Increased the length of the advertising name for the Running Speed and Cadence sensor example (ble_app_rscs) to make it easy to verify + that it is using the extended advertising. + - Included the Scanning module into all BLE examples. This aligns how scanning is performed in these examples. + - Updated the NFC pairing examples (ble_app_hids_keyboard_pairing_nfc, ble_app_hrs_nfc_pairing, ble_nfc_pairing_reference) to start using + the LESC functionality in the Peer Manager (which uses the nrf_ble_lesc module). + - Removed the manual handling of credits for the Object Transfer Service (ble_app_ots and ble_app_ots_c). Most use cases now work faster + and simpler when the SoftDevice is controlling it. + - Updated the API documentation for advertising_init in the Advertising module (ble_advertising). It was clarified that UUID arrays were not + copied into the Advertising module. + - Advertising module (ble_advertising) is no longer dependent on the fstorage module. + - Changed the ANCS example (ble_app_ancs_c) so that it no longer performs service discovery after connecting to an already bonded peer. + - Lowered the advertising interval in the Eddystone example (ble_app_eddystone), because some advertising packets would be lost when combined + with the timeslot API. + - Reduced the maximum supported value for advertising interval in Eddystone from 20000 to 16384. If a higher value is set, the SoftDevice returns + an error code that asserts the application. + - Peer Manager: + - Various improvements to documentation. + - The Peer Manager will now take less space for the same features. + - To decrease complexity, the Peer Manager no longer uses the 'reserve' functionality in FDS, meaning that PM_EVT_STORAGE_FULL + events will come slightly later if bonds cannot be stored during bonding. + - Error event parameters now specify whether the error code is to be interpreted as an FDS_ error or an NRF_ error. + - Peers without a stored rank are now never returned from pm_peer_ranks_get(). + - The function pm_peer_data_load() now fills the array even when returning NRF_ERROR_DATA_SIZE. + - Enabled internal LESC key handling through PM_LESC_ENABLED. Function pm_lesc_public_key_set() is now deprecated because of this change. + - All examples using the Peer Manager now use the new standard event handlers. + While some examples implement custom behavior, all examples do the following: + - Log Peer Manager events (at different log levels). + - Encrypt immediately on connection with bonded peers. + - Delete old bonds to make room for new peer data. + - Some examples supporting central mode disconnect when link encryption fails. Look for functions calling pm_handler_disconnect_on_sec_failure(). + - The ble_app_bms example will now request for security procedure to be initiated if the Central does not initiate it. + +** IEEE 802.15.4 ** + - Updated the radio test example to support 802.15.4 radio modes. + +** Crypto ** + - Updated documentation about RAM requirements on mbed TLS. + - Added endianness change Curve25519 (to little endian). + - Removed the following defines. A compile error is shown if they are enabled in a configuration: + - NRF_CRYPTO_BACKEND_CC310_BL_HASH_LITTLE_ENDIAN_DIGEST_ENABLED + - NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED + - NRF_CRYPTO_BACKEND_MICRO_ECC_LITTLE_ENDIAN_ENABLED + - NRF_CRYPTO_BACKEND_NRF_SW_HASH_LITTLE_ENDIAN_DIGEST_ENABLED + - nrf_crypto micro-ecc backend: Moved ECDH public key validation from the key convert function to ECDH compute + (moved from nrf_crypto_backend_micro_ecc_public_key_from_raw to nrf_crypto_backend_micro_ecc_ecdh_compute). + - Upgraded nrf_cc310 and nrf_cc310_bl to version 0.9.10 including minor changes to some default configurations. + +** DFU and Bootloader ** + - Updated documentation about how to change the existing SDFU project, so that the application can be uploaded without signature verification, + but at the same time to keep the signature verification when updating a SoftDevice and/or bootloader. + - The bootloader now does not use app_timer, which saves flash space. + - The bootloader now does the endian-conversion in code, instead of relying on endian-conversion in nrf_crypto. + +** Drivers and libraries ** + - Included new version of nrfx (v1.1.0). For the nrfx changelog, see https://github.com/NordicSemiconductor/nrfx/blob/master/CHANGELOG.md + - nrf_log: + - Updated to production quality. + - You can now store/load the filtering configuration in FDS. + - You can now control one backend from another. + - nrf_cli: Added support for terminal meta keys. + +** Proprietary ** + - Updated ESB library to support all current variants of nRF52. This mainly involves adding proper handling of Errata related to the radio. + - Added a function to skip the next packet in the TX queue. This was previously a function used internally in the module under another name. + +** USB ** + - Moved USBD strings configuration to sdk_config. + - Rebuilt MSC class write procedure. + - Moved APP_USBD_CONFIG_LOG_ENABLED to nrf_log settings. + - HID report protocol is now default after reset. + - HID default idle rate after reset can now be defined. + - OUT transfers are now dropped when clearing stall on endpoint. + - SET_ADDRESS command is now defined as a separate event in app_usbd. It does not change the state of the device anymore. + - EP0 is now disabled until USB RESET condition is detected. + - HID OUT reports are now limited to 63 bytes of data + 1 byte reserved for report ID. + + +*** Bug fixes +**************** + +** BLE ** + - Fixed a bug in the BLE UART client (ble_app_uart_c) where it would check the wrong error code when issuing multiple write commands. + - Fixed a bug in the Eddystone example (ble_app_eddystone) where the default TX power was set to 0 directly + instead of using the DEFAULT_FRAME_TX_POWER define. + - Fixed a bug in the ANCS example (ble_app_ancs) where app_timer was included too many times. + - Fixed a bug in the Advertising module (ble_advertising) where a comment referred to seconds instead of 10 ms. + - Fixed a bug in the LESC connection example (ble_app_multirole_lesc) where the procedure for connection parameter update would not be started + immediately upon connection. + - Fixed a bug where a precompiled hex was missing for Immediate Alert Server (ble_app_ias) and Service Changed server (ble_app_gatts) examples. + - Fixed a bug in the Radio Notification Event Handler (ble_radio_notification) where a missing include stopped it from compiling. + - Fixed a bug in the BLE Interactive Command Line Interface Example in service discovery procedure. + - Fixed a bug in the Alert Notification Service, where it was not possible to enable notifications for an unread alert. + - Peer Manager: + - Fixed a bug where the event PM_EVT_FLASH_GARBAGE_COLLECTED was also sent when garbage collection failed. + - Fixed a bug in pm_next_peer_id_get() where it could report a peer with no data attached to it if used during bonding. + - Fixed a bug where peer data would not be written because the internal retry mechanism failed after two attempts. + - Fixed several documentation bugs related to error codes. + +** IEEE 802.15.4 ** + - Adjusted CCA threshold value to be correct for nRF52840 Rev. 1 (different from what was available on the Engineering sample). + - Implemented a fix for Anomaly 153 (temperature correction of RSSI measurement): added an API in RAL module for calculating the corrected RSSI value. + +** Drivers and libraries ** + - Fixed a bug in the SPI manager where app_timer was included too many times. + - Fixed a wrapping issue in the Ring Buffer library. + +** DTM ** + - Added support for 8 dB on nRF52840 targets. + - Implemented the workaround for nRF52840 Anomaly 172 which caused the device to fail a test with interference in co-channels (RF-PHY/RCV/BV-29-C). + +** Proprietary ** + - Fixed a bug in bytewise_bit_swap where it was harder to backport the implementation to nRF51. + - Fixed a bug in nrf_esb_pop_tx where the packet queue would occasionally be corrupted. + - Added shutdown of the system timer as the workaround for Anomaly 78 and to save energy. + +** NFC ** + - Integrated fixes from EMVCo test suite (improved interoperability). + - Added automatic fix for Anomaly 181. + - Fixed a bug where HFCLK was requested too early for nRF52840 Rev. 1 chip. + - Changed the way the fixes for chip errata are switched: use chip defines from MDK instead of board defines (simplifying usage of custom boards). + +** USB ** + - Removed redundant barriers in USBD HAL. + - Fixed a bug in HID library where the report descriptor was limited to 64 bytes. + - Fixed a bug where USBD was not able to wake up after SOF event. + - Fixed a bug where the SET_ADDRESS command was not processed in time. + + +*** Known Issues +**************** + +** BLE ** + - Peer Manager: + - When a link is already secured and the peer sends a slave security request for a higher level of security, the request will not be honored. + - Service Changed indications might be silently dropped without being sent if the attempt to send them happens during an ATT MTU exchange. + +** BLE IOT ** + - Neighbor discovery module for lwIP requires the on-link flag in the router advertisement to be set to create a SLAAC address from the prefix. + However, RFC 7668 (https://tools.ietf.org/html/rfc7668) requires this bit to be zero. Therefore, the nd6.c from lwIP source has been modified + to relax this check. + - There are some issues when using the IoT examples against Linux Kernel 4.12+ that cause the kernel to only work with one 6LoWPAN connection. + If more than one kit is connected using 6LoWPAN, none of the nodes will be accessible. + - Scheduler has been included in most IoT examples to avoid race conditions found when using the lwIP stack, more precisely the TCP examples. + The issue was that the TCP client would stop working after about 15 hours. However, when using mbed TLS, the use of scheduler is not possible. + Therefore, the MQTT client examples might be affected by this issue. + - The use of security, both with TLS and DTLS, should be treated as experimental. + - MQTT examples cannot be used with commissioning on nRF52832. There is not enough RAM to accommodate both TLS and the commissioning service. + - If enabled, RTT logs in IoT bootloader might not be printed before resetting. + - The background_dfu example does not work. + +** Drivers and libraries ** + - SAADC driver is not handling detection limits: high and low correctly if SAADC resolution is greater than 10 bits. + - In the radio test example, modulated packets will only have the requested content in the first two bytes. + Further bytes have random values. + - In the radio test example, start_duty_cycle_modulated_tx is not working as intended. + The actual duty cycle on air is not what was requested in the command. + +** USBD ** + - Due to Anomaly 199, the USBD driver blocks code execution during EasyDMA transfer (for stability). + + +======================================================================== + +nRF5 SDK v15.0.0 +------------------------ +Release Date: Week 12, 2018 + +Highlights: +- Full support for nRF52840 and production quality of libraries and examples for this device. +- Support for the new SoftDevices S140, S132, and S112 v6.0.0. +- Peripheral drivers now use nrfx. +- Extensive rework of the DFU functionality. +- Extensive rework of the cryptography library (nrf_crypto). +- USB firmware is now in production quality. +- Serialization of SoftDevices S140, S132, and S112 v6.0.0. +- IEEE 802.15.4 protocol in production quality. +- Included nrf_oberon crypto library with standard Nordic 5-clause license. + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 6.3 2017-q2-update +- IAR: IAR Workbench 7.80.4 (IAR 8 - see note below) +- SES: SES 3.34 +- Linux: Ubuntu 17.04, Kernel 4.10.0. +- Jlink: 6.22g +     +***** +Note for IAR 8 users: +Libraries for IAR 8 require wchar_t to be of size 32 bits while IAR 7 requires 16 bits. +To run a project using IAR 8, follow these intructions: + - Open the IAR project in IAR 8. The IAR workbench will automatically generate an IAR 8 compatible project file. + - If the project contains one of the precompiled libraries listed below, replace it with the IAR 8 compatible alternative +   (there are no projects targeting nRF51 in this SDK). + - Save the project. + - When building the project, you might get the warning: "The header file 'cmsis_iar.h' is obsolete and should not be used. ....". +   The problem is described in DevZone post: https://devzone.nordicsemi.com/f/nordic-q-a/31123/iar-ewarm-8-22-1-complains-about-cmsis_iar-h +   The solution is to remove all occurrences of #include . + +The affected libraries are +- micro-ecc crypto: +    - IAR 7: Includes the library located in the folder named "…_iar\…". +    - IAR 8: Switch to using the library from the folder named "…_armgcc\…". +- nrf_cc310, nrf_cc310_bl, and nrf_oberon: +    - IAR 7: Includes the library where "_short_wchar_" is part of the file name. +    - IAR 8: Switch to using the library with similar naming, but where the "short_wchar" is removed. +- Gazell, NFC Tag, and 802.15.4: +    - IAR 7: Includes the library where the file name ends with "_iar". +    - IAR 8: Switch to using the library with similar file name that ends with "_gcc". +***** +  +Supported SoftDevices: +- S112 v6.0.x +- S132 v6.0.x +- S140 v6.0.0 +- S212 v5.0.x +      +Supported boards: +- PCA10040 +- PCA10040E (nRF52810 emulation on PCA10040) +- PCA10056 +- PCA10059 (support in selected examples) +- Dynastream's D52DK1 (only for ANT examples) +      +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". +      +  +*** New features +***************** +  +** IEEE 802.15.4 ** + - Added support for SES toolchain. +  +** ANT ** + - Added support for SES and GCC toolchains in the following examples: +    - ANT-FS Client +    - ANT Bootloader/DFU +  +** BLE ** + - Added support for the new SoftDevices S140, S132, and S112 v6.0.0. For more information about SoftDevice v6.0.0, refer to the SoftDevice documentation. + - Extended advertising and selection of advertising PHYs can now be configured using the advertising module (ble_advertising). + - Running Speed and Cadence Service Application (ble_app_rscs) now advertises using extended advertising. Note that this makes it incompatible with devices that do not support extended advertising. + - Added multilink support for a selected group of BLE services (including separate GATT context for each connected client). +    - Affected services: +        - Human Interface Device Service: ble_hids. +        - Nordic UART Service: ble_nus. +        - Immediate Alert Service: ble_ias. +        - Battery Service: ble_bas. +    - Added BLE Link Context Manager module +    - Modified the Immediate Alert Application to show this feature. + - Added a new application: BLE Interactive Command Line Interface Example. + - Added Device Information Service client. This module can be used to read any characteristic of Device Information Service. +    - Modified the Running Speed and Cadence Collector example application (ble_app_rscs) to show the use of this module. + - Immediate Alert Service client example application (ble_app_ias_c) is no longer experimental. + - Immediate Alert Service server example application (ble_app_ias) is no longer experimental. + - GATT Service Client Example Application (ble_app_gatts_c) is no longer experimental. + - GATT Service Server Example Application (ble_app_gatts) is no longer experimental. + - Improved the test description documentation for Continuous Glucose Monitoring Service Example Application (ble_app_cgms). It now showcases more capabilities of the application and how to test them. + - ble_conn_state: Added new function ble_conn_state_for_each_set_user_flag() which calls a function for each flag in a collection that is set. + - Peer Manager: +    - Two new configuration parameters to disable functionality to save space: +        - PM_SERVICE_CHANGED_ENABLED to enable/disable Service Changed sending. This must be enabled if Service Changed is enabled in the GATT database. +        - PM_PEER_RANKS_ENABLED to enable/disable the tracking of peer ranks. +    - The relevant APIs have gained the error code NRF_ERROR_NOT_SUPPORTED if the function is called when the configuration is disabled. + - Added NRF_SDH_BLE_GAP_DATA_LENGTH configuration (under nrf_sdh_ble) to configure BLE data length negotiated by the nrf_ble_gatt module. + - Added BLE LESC module as experimental. +  +** BLE IOT ** + - Added support for the nRF52840 (PCA10056 board) with the use of the S140 SoftDevice. +  +** NFC ** + - Added support for SES toolchain in the Adafruit Tag Reader Example. + +** Crypto ** + - Production quality nrf_crypto interface that supports software and hardware backends (using the CC310 hardware accelarator in nRF52840 devices). + - nrf_crypto API supports the following cryptographic family of algorithms (subject to support in nrf_crypto backends): +    - AES (CBC, CTR, CFB, ECB, CBC_MAC, CMAC) +    - AEAD (CCM, CCM*, EAX, GCM, ChaCha-Poly) +    - ECC (Elliptic Curve Cryptography) +        - Key generation +        - Key validation +        - Key conversions (from/to raw format) +    - ECDH (multiple curves) +    - ECDSA (multiple curves) +    - SHA-2 family hash +    - HMAC +    - HKDF +    - RNG using AES CTR or through dedicated hardware/sofware (on nRF52840) +    - Experimental Ed25519 support (available through the nrf_crypto_ecdsa API) + - nrf_crypto API support for dynamic memory management by configuration: +    - User-specified macros to NRF_CRYPTO_ALLOC and NRF_CRYPTO_FREE +    - Stack allocation (using alloca) +    - C dynamic allocation (malloc) +    - SDK Memory Manager (nrf_malloc) + - nrf_crypto backends include the following: +    - Cifra +    - mbed TLS +    - micro-ecc +    - nrf_cc310 +    - nrf_cc310_bl (code size optimized, to use in Secure DFU) +    - nRF HW (for RNG) +    - nrf_oberon +    - nRF software (legacy) + - Examples of nrf_crypto usage with the option to change the nrf_crypto backends. + - Test example to verify the cryptographic routines and APIs through standardized test vectors. +  +** DFU/Bootloader ** + - SoftDevice independence: +     - Only the BLE bootloader is now dependent on the SoftDevice. The others depend only on the MBR (which is now part of the SDK). +     - The DFU now supports updating applications that do not use the SoftDevice. Such an application must be compiled to be placed above the MBR. + - The DFU protocol has been extended to support new messages: +     - Protocol version - To retrieve information about the protocol version. +     - Firmware version - To retrieve information (size, version) about each piece of firmware on the chip. +     - Hardware version - To retrieve information (flash/RAM size, page size) about the hardware. +     - DFU Abort - To instruct the bootloader to abort the DFU procedure and reset the device. + - Configurable security: New configuration parameters to turn on and off version checking and signature checking of application transfers. Added a new example using the new configurations (open_bootloader). + - DFU Trigger (USB): Added a library to allow DFU mode to be triggered through USB in the application. The library is used in the new ble_connectivity example that uses USB CDC ACM. + - Added optional skipping of application CRC check. CRC check can be skipped on wakeup from System Off or on special value written to GPREGRET2 register. + - Added watchdog support to the bootloader. If application had enabled watchdog before resetting to the bootloader, it is fed in the bootloader. +  + ** Drivers and libraries ** + - Added support for wildcards in the CLI module. + - Added TWI sensor module. + - Added drivers for sensors on Thingy:52 (LPS22HB, BH1745, HTS221, CCS811, SX1509B, LIS2DH12). + - Added the nrfx project as a set of default drivers and provided a legacy layer for supporting deprecated API. + - Added support for filtering log messages on instance level in the logger module. Instance level logging added to nrf_balloc, nrf_queue, and nrf_atfifo. + - Added new logger backends for writing logs to flash: flashlog backend for storing logs in standard operation, crashlog backend for dumping logs on error condition. Added CLI commands for controlling data stored in flash. + - Added optional timestamp formatting in the logger.  + - Added new implementation of app_timer (libraries/timer/experimental/app_timer2.c) which does not use SWI, uses less RAM and flash, and has modular, simpler design. It shares the same API as the legacy implementation. The new implementation is used by bootloaders and peripheral/CLI. + - Added bsp_cli module to send BSP events through CLI. + - Added nrf_atflags module for atomic manipulation of bit fields. + - Added improved CLI UART backend called libUARTE. This backend is recommended when the CLI must exchange big amounts of data fast, for example when CLI is used with a script. +  +** Serialization ** + - Added serialization of the S112, S132, and S140 v6.0.0 SoftDevices. + - Added serialization connectivity application for PCA10059 using USB CDC ACM as the transport layer. +  +** USB ** + - Added example with the SoftDevice and USB (usbd_ble_uart). + - Added configuration of the self-powered descriptor bit (APP_USBD_CONFIG_SELF_POWERED). + - Added buffering of transfers in CDC. + - Added configuration of power in a descriptor (APP_USBD_CONFIG_MAX_POWER). + - Added option to specify the CDC ACM protocol. + - Added dummy interface class. + - Implemented USBD power event processing in app_usbd event queue. + - Implemented different ways of processing SOF events: +    - Normal - SOF events are pushed normally into the event queue. +    - Compress - SOF events are counted and bound with other events or executed when the queue is empty. This prevents the queue from filling up with SOF events. +    - Interrupt - SOF events are processed in the interrupt. + - Implemented Get Output Report in HID class. + - New SoftDevice API used for USB power events. + - Button events can now be sent through CLI in the usbd_cdc_acm, usbd_hid_composide, and usbd_hid generic examples. +  +  +*** Changes +************ +  +** ANT ** + - Added welcome message to all ANT examples. Logging is enabled by default in all of them. + - Removed obsolete module: ant_stack_config. The ANT SoftDevice Handler module has taken over its functionality. +  +** BLE ** + - Minor improvements to consistency of BLE examples main functions (comments, function call ordering, function names). + - BLE examples changed to use the Queued Write module (nrf_ble_qwr). Applications must explicitly configure characteristics to accept long writes. See app_ble_qwr for an example of this. This fixes a problem where peers could cause our devices to assert by issuing long writes. + - BLE examples changed to use the Power Management library. Most examples now call nrf_pwr_mgmt_run() instead of sd_app_evt_wait(). + - Eddystone modules have been moved from components/libraries to components/ble. + - ble_app_uart changed to have 247-byte MTU, up from 64. + - Peer Manager: +     - The members of pm_conn_sec_procedure_t have been renamed from PM_LINK_SECURED_PROCEDURE_* to PM_CONN_SEC_PROCEDURE_*. +     - The following functions have gained new error codes: +         - pm_conn_secure() +         - pm_peer_data_store() +         - pm_peer_ranks_get() +         - pm_peer_rank_highest() +  +** BLE IOT ** + - Minor updates in TFTP background DFU modules to align with changed DFU libraries. +  +** Crypto ** + - nrf_crypto APIs have been changed to use big-endian only. +    - Previous versions of nrf_crypto used little-endian ordering to conform to BLE requirements in LESC. +      This has now been changed to big-endian everywhere. There are conversion functions available to +      change between little-endian and big-endian input/output. +    - See the Migration Guide for details. + - nrf_crypto memory management has changed extensively. +    - See the Migration Guide for details. + - nrf_crypto configuration of frontends and backends is now primarily done through sdk_config.h. +    - See the Migration Guide for details. +  +** DFU/Bootloader ** + - Configuration parameters (sdk_config) have changed. See the Migration Guide for details. + - Refactoring: The DFU/bootloader code has been extensively refactored. +     - The split between DFU and bootloader has been improved. +        - New events from DFU. +        - Resetting has been moved from DFU to bootloader, based on DFU events. +        - Much of the code in nrf_dfu_utils has been extracted into the new nrf_bootloader_fw_activation and nrf_bootloader_dfu_timers modules. +     - Request handling module: +        - The dfu_req_handling module has been renamed to nrf_dfu_req_handler and moved to components/libraries/bootloader/dfu. +        - The request handling now uses app_scheduler and is entirely asynchronous and executed in the main context. +        - The init command validation was refactored out and into two new modules nrf_dfu_validation and nrf_dfu_ver_validation. +     - The Serial transport is now called UART. +     - The shared parts of the USB and UART transports have been placed in a separate module nrf_dfu_serial. +     - Most of the assembly code in bootloader_app_start has been replaced with C code and extracted into a separate file nrf_bootloader_app_start_final. +     - Examples: +        - The secure bootloader examples have been moved into a 'secure_bootloader' folder. +        - The experimental ANT bootloader has been moved into an 'experimental' folder. +        - The USB secure bootloader is no longer experimental. + - Bootloader examples have been reorganized. Examples "bootloader_secure_ble", "bootloader_secure_serial", and "experimental_bootloader_secure_usb" have been merged into "secure_bootloader" with projects for each transport and board. + - Write protection of the bootloader: Before booting the app, the bootloader will write-protect the flash areas of the bootloader and MBR (using BPROT on nRF52832/nRF52810 and ACL on nRF52840). +     - The BLE Buttonless SVCI interface needs access to the bootloader settings page from the application, so there is a new configuration parameter to specify whether that page should be part of the protection. +     - The SVCI interface will now return NRF_ERROR_FORBIDDEN if using the interface when the page is protected. + - WDT compatibility: The bootloader will feed the WDT if the app has started it. + - BLE DFU: +     - The BLE DFU bootloader now explicitly requests the preferred connection interval upon connection. The minimum and maximum connection intervals can be set in sdk_config.h. +     - The BLE DFU bootloader will use long ATT MTUs and data length extension when the host supports these features. This increases DFU transfer speed considerably. +     - Several stability improvements over different transport configurations. + - USB serial number: The serial number of the USB bootloaders has changed to be the same as the default BLE address (found under DEVICEADDR in FICR). + - New crypto backend for nRF52840: The bootloaders for nRF52840 use the hardware crypto backend (CC310) instead of micro-ecc. +  +** Drivers and libraries ** + - The way peripheral drivers are handled in the SDK has been reorganized: +     - Replaced existing drivers with the "external" drivers from nrfx project. See https://github.com/NordicSemiconductor/nrfx/blob/master/README.md for more information on nrfx. +     - New drivers from nrfx are located in "..\modules\nrfx". +     - Drivers replaced by nrfx are removed from "..\components\driver_nrf". +     - A glue layer is added to make the nrfx driver compatible with SDK and the SoftDevice. + - Refactored I2S driver. + - New reliable delay implementation. + - Added CLI commands to nrf_balloc and nrf_queue which print out the status of all instances present in the system. + - CLI built-in root commands: cli_stats, colors, and echo have been changed to subcommands: cli colors, cli echo, and cli stats. + - The CMSIS-SVD files with device descriptions have been moved from the "..\svd" folder to the "..\modules\nrfx\mdk" folder. + - Infineon OPTIGA: +     - Replaced "crypto\ifx_optiga_auth" example with the new one: "crypto\ifx_optiga_ecdsa_simple". +     - Updated related libraries from the "external\infineon" directory. +     - Replaced support for Infineon OPTIGA Trust E HSM with Infineon OPTIGA Trust X HSM. +     - Added support for IAR toolchain. +  +** Proprietary ** + - New Gazell functionalities: +     - Transmission statistics gathering - counts successful packet transactions and timeouts on each of the RF channels. +     - External analog frontend module control - generates TX/RX signals during transmission/receiving, which can be used to control the external PA/LNA module. + - Updated gzll_ack_payload examples with the example usage of the new Gazell features. + - Dynamic changes of TX attempts and TX power parameters are now allowed when the Gazell stack is enabled. + - Removed the nRF52840 project from ble_app_gzll example (removed "pca10056" folder). +  +** NFC ** + - Type 2 Tag Library: +    - Modified Dynamic Memory structure of the Tag. Added Terminator TLV to indicate that there is no more relevant user data after NDEF TLV. + - Type 4 Tag HAL: +    - Modified Frame Wait Time setting to support full range available on the nRF52840 Rev. 1 chip. + - Type 4 Tag Library: +    - Modified behavior of the NFC_T4T_EVENT_NDEF_READ event: the event is always triggered when the last byte of the NDEF File is sent to an NFC Reader device - even if the Reader repeats the read operation multiple times in one session, i.e. before the Reader sends a DESELECT or SLP_REQ frame. + - NFC BLE pairing library: modified to support multiple connections. + - BLE/NFC examples: updated application behavior to comply with NFC Forum user experience recommendations. + - NFC libraries which can enable nrf_log independently (using sdk_config.h) register the logger instance conditionally, i.e. only if nrf_log is enabled in the sdk_config.h +  +** USB ** + - app_usbd_init: when called with NULL configuration structure or NULL ev_handler member of a structure, the default event handler will be used. + - app_usbd_init: removed clock initialization. + - Descriptors are now generated on the fly using simple stackless thread code. + - Added a warning for wrong interface order. + - Combined USB CDC ACM driver for all examples into one. +  +    +*** Bugfixes +**************** +  +** ANT ** + - Added missing logger backends to all examples. +  +** BLE ** +  - Fixed a bug in ble_app_uart where Data Length update requests would be handled twice. +  - Fixed a bug in ble_app_uart and ble_app_uart_c where the "start" message in the main function was not followed by a line feed. This could make the applications seem unresponsive. +  - Fixed a bug in ble_app_cgms where properties of the characteristics were not configured. +  - Fixed a bug in ble_app_cgms where directed advertising was enabled by the advertising module but was ignored by the application. Directed advertising is now disabled. +  - Fixed a bug in ble_app_cgms where advertising was triggered twice when deleting bonds. The second call to advertising start would cause the example to assert on the busy error. +  - Fixed a bug in ble_app_gls  where the seconds field of the glucose measurement was never updated. +  - Fixed a bug in ble_tps where documentation for ble_tps_tx_power_level_set() was describing another unrelated function. +  - Fixed a bug in most main.c files where fds garbage collection fds_gc() would retry upon returning FDS_ERR_BUSY. However, this function call will never return FDS_ERR_BUSY. +  - Fixed a bug in nrf_ble_gatts_c where setting NRF_LOG_DEFAULT_LEVEL to debug (4) would cause an assert because it was not registered with the logger module (NRF_LOG_MODULE_REGISTER();) +  - Added missing Errata workaround to Direct Test Mode (DTM) on nRF52840. +  - Peer Manager: +      - Fixed the bonded flag in pm_conn_sec_status_get(). +      - Fixed a performance bug in peer_database.c. +      - Split the error code NRF_ERROR_INVALID_STATE from pm_conn_secure() that could have two different meanings. +  +** BLE IOT ** +  - Corrected logging module name, such that logs could be enabled in the LWIP platform module. +  - Fixed a reassembly bug in BSD socket module. +  - Fixed flushing of ports when the kit disconnects. Added API to flush the ports. +  - Added handling of BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED event to generate the BLE_IPSP_EVT_CHANNEL_DATA_TX_COMPLETE in case link disconnection occured before the TX was complete. +  - Resolved an issue with MQTT/lwIP packets stuck in a TX queue. Now forcing out enqueued data before close. +  - Conformed to MQTT specification in the use of QoS flag in MQTT connect. +  +** DFU/Bootloader ** +  - Bootloaders for nRF52840 now support bootloader updates (if used with the new MBR or SoftDevice). +   +** Drivers and libraries ** +  - Extended input pin configuration in the GPIOTE driver: configuration of GPIOTE INPUT pin added, which does not change the current GPIO configuration. +  - CLI module - fixed echo command behavior. When echo is off, the command will not be printed after log print. +  - Logger modules - stability fixes (including https://devzone.nordicsemi.com/f/nordic-q-a/31178/bug-nrf_log_frontend-m_log_data-buffer-overflow). +  - More changes in drivers can be found in the modules/nrfx directory in the CHANGELOG.md file. + +** Proprietary ** + - Gazell stack: +    - Fixed a bug with high current consumption in disabled state, related with TIMER issue 78. +    - Fixed a bug with reenabling Gazell stack after the SoftDevice activity. + - Gazell Pairing Library: +    - Fixed a bug with unreserved flash memory region for the Host ID. +    - Fixed a bug with wrong initialization of database flash memory page on nRF52 chips. +  +** NFC ** + - Type 2 Tag Library: +    - Modified Dynamic Memory content of the Tag. Dynamic Lock Bytes use proper values now. +    - Updated CC1 byte setting (one of the Type 2 Tag Reserved bytes) according to the new NFC Forum Type 2 Tag Technical Specification v1.0. + - Type 2 Tag HAL: +    - Handling of erroneous NFC-A data frames (with parity and CRC errors) has been improved. + +** USB ** + - Fixed a bug in USB CDC ACM class where the APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN event was not raised. + - Fixed a bug in USB CDC ACM class where RX stopped working after the port was closed or the cable was detached. + - Fixed a bug in USB MSC where it could not satisfy the number of required bytes by the host. + - Fixed a bug in app_usbd.c where APP_USBD_EVT_DRV_RESUME event was raised after a reset instead of APP_USBD_EVT_DRV_RESET. + - Fixed a bug in HID class where Remote Wake Up was not properly handled. + - Fixed a bug in nrf_drv_usbd_transfer_out_drop() where it was clearing an isochronous endpoint. + - Fixed a bug in app_usbd_core.c where transfer status was not checked during EP0 processing. + - FTPAN-171 workaround has been implemented. + - FTPAN-199 workaround has been implemented. + - Fixed minor issues. +  + +*** Known Issues +**************** +  +** Missing feature on nRF52840 ** +  - ANT protocol support is missing due to ANT SoftDevices not available for this device. +  - FreeRTOS +  - ESB +  +** BLE ** + - BLE LESC module should be treated as experimental, even though it has not been marked as such. + - Eddystone example should be treated as experimental on nRF52840. +  +** BLE IOT ** + - Neighbor discovery module for lwIP requires the on-link flag in the +   router advertisement to be set in order to create a SLAAC address +   from the prefix. However, RFC 7668 (https://tools.ietf.org/html/rfc7668) +   requires this bit to be zero. Therefore, the nd6.c from lwIP source +   has been modified to relax this check. + - There are some issues when using the IoT examples against Linux +   Kernel 4.12+ which causes the kernel to only work with one 6LoWPAN +   connection. If more than one kit is connected using 6LoWPAN, none of +   the nodes will be accessible. + - Scheduler has been included in most IoT examples to avoid race +   conditions found when using the lwIP stack, more precisely the TCP +   examples. +   The issue was that the TCP client stopped working after about 15 +   hours. However, when using mbed TLS, the use of scheduler is not +   possible. +   Therefore, the MQTT client examples might be affected by this issue. + - The use of security, both with TLS and DTLS, should be treated as +   experimental. + - MQTT examples cannot be used with commissioning on nRF52832. There is not enough +   RAM to accommodate both TLS and the commissioning service. + - If enabled, RTT logs in IoT bootloader might not be printed before resetting. +  +** DFU/Bootloader ** + - Changing the backend for nrf_crypto in sdk_config.h alone is not sufficient +   because the relevant files are not included in the build and include paths. +   See the Migration Guide for a walkthrough of changing from the µECC to the +   Oberon backend. + - ble_app_buttonless_dfu will silently hang during bootup if a compatible +   bootloader, i.e. the BLE bootloader, is not present. + - SES will not detect whether the debug bootloader is too large, instead it will place the code in the MBR params page. To make SES detect this, add the following line in flash_placement.xml: +  + Place this line immediately after: + + The production bootloader is not affected by this issue. + - nrfutil version 3.5.0 has an optional argument to increase the time delay "--connect-delay ". + It is recommended to set this value to 10 when Serial DFU (UART / USB) is performed for large images (SoftDevice + Application or SoftDevice + Bootloader + Application). + - You may experience some instability with the µECC library in IAR due to faulty decoding of symbol information. Compile the µECC library without symbol information to fix these issues. + +** Proprietary ** + - Gazell stack for all devices is working with sensitivity reduced by 3 dB due to the RADIO issues 102, 106, 107, and 143. +  +** NFC ** + - NFC Type 2 and Type 4 Tag HAL modules require using TIMER 4 on nRF52840 and nRF52832 chips. +  +** USBD ** + - For the sake of stability, the USBD driver blocks code execution during EasyDMA transfer. + - Isochronous transfers must be processed as fast as possible, but using the event queue may postpone SOF processing too long if the CPU is busy. In such situations, isochronous transfers should be started inside a SOF interrupt. Configure APP_USBD_CONFIG_SOF_HANDLING_MODE as interrupt. The implementation of special SOF interrupt callbacks is subject of the future updates. +  +** Drivers and Libraries ** + - SAADC driver is not handling detection limits: high and low correctly if SAADC resolution is greater than 10 bits. + - The following examples do not have Keil 4 support: nrf_cc310, nrf_cc310_bl, ifx_optiga_ecdsa_simple. + +======================================================================== + +nRF5 SDK v14.2.0 +------------------------ +Release Date: Week 46, 2017 + +Highlights: + +- Support for the new S112 SoftDevice v5.1.0. + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.80.4 +- SES: SES 3.30 +- Linux: Ubuntu 17.04, Kernel 4.10.0. +- Jlink: 6.20d + +Supported SoftDevices: +- S112 v5.1.x +- S132 v5.0.x (for v5.1.x, see the note below) +- S140 v5.0.0-2.alpha +- S212 v5.0.x +- S332 v5.0.x + +S132 compatibility: +The newly released S132 SoftDevice v5.1.0 is drop-in compatible with +S132 v5.0.0, which is included in this SDK release. +However, there are some limitations that you must be aware of when +replacing the included SoftDevice with the new one: +- In S132 v5.1.0, the SoftDevice RAM usage is reduced. Examples that are + optimized on RAM usage return a warning that the application RAM start + address can be lowered. The examples work as before but are not fully + optimized on RAM usage. +- The test images in examples\dfu\secure_dfu_test_images are tightly + connected with the precompiled HEX files located in + examples\dfu\bootloader_secure_ble\hex. Therefore, they cannot be used + in combination with the new SoftDevice. + +Supported boards: +- PCA10040E (nRF52810 emulation on PCA10040) +- PCA10040 +- PCA10056 (limited support; see the "Scope for the nRF52840 chip" section) +- Dynastream's D52DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** Scope for the nRF52840 chip +******************************** +All examples and libraries for the new chip must be treated as +experimental. +Some examples have not been ported to run on nRF52840. Check the +existing example projects to see which targets are supported. + +The following SDK features are supported on the new nRF52840 chip: + - IEEE 802.15.4 stack library with an example + - Most BLE, hardware peripheral, and NFC examples (with some + exceptions; see the available example projects for details) + - Peripheral HAL and drivers (both for existing and new peripherals) + - Cryptography library including CryptoCell CC310 backend + - NFC Type 2 Tag and Type 4 Tag + - Secure DFU (only with micro-ecc backend) + - DTM including support for the new Bluetooth 5 features + - Gazell + +The following SDK features are not supported on the new nRF52840 chip: + - ANT + - Eddystone + - ESB + - FreeRTOS + - IoT components + - Serialization of the S140 SoftDevice v5.0.0-2.alpha + +*** New features +***************** + +** BLE ** + - Added support for the S112 SoftDevice v5.1.0. + +** Crypto ** + - Added a makefile for compiling the micro-ecc library with a "soft" + FPU ABI (required for nRF52810, which does not have hardware FPU + support). + +** Drivers and libraries ** + - Added support for a "soft" FPU ABI in the Task Manager library + (required for nRF52810, which does not have hardware FPU support). + +*** Changes +************ + +** Drivers and libraries ** + - TWI Transaction Manager: Added support for passing the TWI + configuration in function nrf_twi_mngr_perform(). Pass NULL if you do + not want to use this new feature. + - Command Line Interface: Added support for commands longer than 255 + characters. + + +*** Bugfixes +**************** + +** Drivers and libraries ** + - Fixed "echo" command behavior in nrf_cli. + - Fixed a bug in nrf_ringbuf where allocation protection failed on a + second attempt to allocate a buffer in use. + - Fixed a compile error in the Task Manager library when stack guard is + off. + - Fixed invalid module names in logger output when LTO was used in the + GCC compiler. + - Fixed a bug in the logger where output could get corrupted when + logging was interrupted by NRF_LOG_PROCESS() (for example, flushing + in error handler). + +** DTM ** + - Fixed a bug preventing certain TX power values to be set. + - Set the PDU header payload type field of coded PHY 0xFF packets to + 0x04 instead of 0x03 to make the 0xFF packets valid. + +*** Known Issues +**************** + +** BLE ** + - When working on the emulated nRF52810 target, if you change the + optimization level and/or add the logging functionality, the project + might not compile or fail at runtime due to not enough flash + available for FDS or Peer Manager. + - All Bluetooth applications not using the nrf_queued_write module will + assert when a peer sends a Write request with the opcode 'cancel all + operations' (BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL), after the + SoftDevice call to sd_ble_gatts_rw_authorize_reply. This SoftDevice + call, for the opcode 'cancel all operations', returns + NRF_INVALID_PARAMS if the gatt_status is not BLE_GATT_STATUS_SUCCESS. + +** BLE IOT ** + - Neighbor discovery module for lwIP requires the on-link flag in the + router advertisement to be set in order to create a SLAAC address + from the prefix. However, RFC 7668 (https://tools.ietf.org/html/rfc7668) + requires this bit to be zero. Therefore, the nd6.c from lwIP source + has been modified to relax this check. + - There are some issues when using the IoT examples against Linux + Kernel 4.12+ which causes the kernel to only work with one 6LoWPAN + connection. If more than one kit is connected using 6LoWPAN, none of + the nodes will be accessible. + - Scheduler has been included in most IoT examples to avoid race + conditions found when using lwIP stack, more precisely the TCP + examples. + The issue was that the TCP client stopped working after about 15 + hours. However, when using mbedTLS, the use of scheduler is not + possible. + Therefore, the MQTT client examples might be affected by this issue. + - The use of security, both with TLS and DTLS, should be treated as + experimental. + - MQTT examples cannot be used with commissioning. There is not enough + RAM to accommodate both TLS and the commissioning service. + +** NFC ** + - NFC Type 2 and Type 4 Tag HAL modules require using TIMER 4 on + nRF52832. + - Some mobile phone apps cannot write Type 4 Tag ("NFC Tools" and + "TagWriter" v4.1 seem to be okay to use). + +** USB (experimental) ** + - MSC implementation does not stall when the host requires more bytes + than are available in the selected descriptor. It is not a problem + for any tested driver on Windows and Linux, but still violates the + specification. + - During high USB traffic, in rare cases, communication might hang or + the endpoint data might be transferred twice. See PAN 104. + +** Drivers and libraries ** + - SAADC driver is not handling detection limits 'high' and 'low' + correctly if SAADC resolution is greater than 10 bits. + +======================================================================== + +nRF5 SDK v14.1.0 +------------------------ +Release Date: Week 42, 2017 + +Highlights: + +- Integrated nRF5 IoT SDK into nRF5 SDK. Subsequent updates of IoT components will be available through nRF5 SDK. + This release marks IoT SDK v1.0.0. The IoT SDK is no longer prototype. +- Added Segger Embedded Studio (SES) IDE support. +- The new SoC nRF52810 supported for the BLE examples using the new S112 SoftDevice and for a few peripheral examples. + Examples targeting this new device are located in the 'PCA10040E' folder. + For more details, see 'Developing for nRF52810' in the SDK documentation. +- Support for the new S112 SoftDevice. + Added new S112 target for most of the Bluetooth Peripheral examples. +- The NFC library includes an API change that may need extra attention. See Changes -> NFC BLE Pairing Library. + +The following toolchains/devices have been used for testing and +verification: +- SES: SES 3.30 +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.80.4 +- Linux: Ubuntu 17.04, Kernel 4.10.0. (for the 6LoWPAN Border Router) +- J-link: 6.20d + +Supported SoftDevices: +- S112 v5.1.0-2.alpha +- S132 v5.0.x +- S140 v5.0.0-2.alpha +- S212 v5.0.x +- S332 v5.0.x + +Supported boards: +- PCA10040E (nRF52810 emulation on PCA10040) +- PCA10040 +- PCA10056 (limited support; see the "Scope for the nRF52840 chip" section) +- Dynastream's D52DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** Scope for the nRF52840 chip +******************************** +All examples and libraries for the new chip must be treated as +experimental. +Some examples have not been ported to run on nRF52840. Check the +existing example projects to see which targets are supported. + +The following SDK features are supported on the new nRF52840 chip: + - IEEE 802.15.4 stack library with an example + - Most BLE, hardware peripheral, and NFC examples (with some + exceptions; see the available example projects for details) + - Peripheral HAL and drivers (both for existing and new peripherals) + - Cryptography library including CryptoCell CC310 backend + - NFC Type 2 Tag and Type 4 Tag + - Secure DFU (only with micro-ecc backend) + - DTM including support for the new Bluetooth 5 features + - Gazell + +The following SDK features are not supported on the new nRF52840 chip: + - ANT + - Eddystone + - ESB + - FreeRTOS + - IoT components + - Serialization of the S140 SoftDevice v5.0.0-2.alpha + +*** New features +***************** + +** Common ** + - Added support for the new chip nRF52810. + - New example flash_fstorage added to examples\peripheral\flash_fstorage. + This example shows how to use the nrf_fstorage library. + - New example flash_fds added to examples\peripheral\flash_fds. + This example shows how to use the FDS library. + - Added support in Segger Embedded Studio and armgcc for editing the sdk_config.h file in the external graphical editor (CMSIS Configuration Wizard). + +** BLE ** + - Bluetooth Peripheral examples now support the S112 SoftDevice. + S112 is designed to work with the new SoC nRF52810. Examples targeting this new device are located in folder 'PCA10040E'. + See SDK documentation for more details. + + - Added support for IPSP (Internet Protocol Support Profile). + IPSP is now based on production-quality SoftDevice S132 v5.0.0. The IPSP is, also, a qualified profile. + The IPSP service uses L2CAP Connection Oriented Channels to transfer data between devices. + - The profile implementation added to components\ble\ble_services. + - The IPSP Acceptor example added to examples\ble_peripheral\ble_app_ipsp_acceptor. + - The IPSP Initiator example added to examples\ble_central\ble_app_ipsp_initiator. + + - Added all IoT components, including BLE 6LoWPAN, Nordic's IPv6 Stack, CoAP, MQTT, DFU over TFTP, lwIP port on nRF platform, and others. + - Changes in these components in comparison to IoT SDK v0.9.0 are described in the Changes section of the release notes. + + - The SDK now supports firmware upgrade over TFTP (IPv6). + - This mechanism for updating the firmware was earlier available in the IoT SDK, and is now a part of the nRF SDK. + + - New example app_ble_gatts added to examples\ble_central\experimental\ble_app_gatts. + This application can be used to test the Service Changed indications together with app_ble_gatts_c. + + - Added S332 projects in Heart Rate Sensor and Heart Rate Collector examples. + +** ANT ** + - Added support for the new SoftDevices: S212 v5.0.x and S332 v5.0.x. + - Added S332 examples: 'Ant Shared Channels' and 'ANT and BLE Heart Rate Monitor Relay Application'. + - Added S332 projects in ANT Message Types and ANT Bootloader examples. + +** NFC ** + - Dynamic NFCID1 configuration in Type 2 and Type 4 Tag libraries. + +** USB (Experimental) ** +NOTE: The USB implementation is currently experimental and work in progress. Because of this, the code base and APIs +will change in-between SDK versions and will not necessarily be backwards compatible. This also applies to minor and +bugfix versions. Migration notes might not be complete for these changes. + - nrf_drv_usbd: + - New API function nrf_drv_usbd_ep_dtoggle_clear() implemented. + - app_usbd: + - Added a new function app_usbd_sof_timestamp_get() and its configuration APP_USBD_PROVIDE_SOF_TIMESTAMP. + This function may be used to stamp the timing of the logger messages. + - Interface selection mechanism provided. + Currently, every class that contains alternate interface settings requires the class methods + iface_select, iface_deselect, and iface_selection_get to be implemented. + No action is required if only the classes provided in the SDK are used. + - New event implemented: + APP_USBD_EVT_STATE_CHANGED – called when the state of USB interface is updated. + +** DTM ** + - Added support for the new SoC nRF52810. + +** Serialization ** + - Added solution for serialization of the combined BLE and ANT SoftDevice, using the ble_ant_app_hrm example as the use case. + - Added BLE connectivity (S132) support for nRF52810 (emulated on PCA10040). + +** Drivers and libraries ** + - Added examples: UART and SAADC for nRF52810. + Examples targeting this new chip are located in the 'PCA10040E' folder. See SDK documentation for more details. + - Added the sorted list module (nrf_sortlist). + +** IOT ** + - Added experimental examples under the "examples\iot" folder and libraries in the "components\iot" folder. + They show the usage of IPv6 over Bluetooth low energy using IPSP and 6LoWPAN. The demonstrated protocols include: + - BSD Sockets, + - UDP and TCP, + - DTLS and TLS, + - CoAP and Secure CoAP, + - MQTT and Secure MQTT, + - TFTP and LWM2M, + - Device Firmware Upgrade (DFU) over TFTP, + - DNS, ICMP, and SNTP. + + +*** Changes +************ + +** BLE ** + - BLE event handler priorities have changed (BLE_OBSERVER_PRIO). + - The order of some module BLE event handlers has been changed. This means that compiling + new sdk_config.h files with old modules might lead to crashes. + - A new priority has been added, and all BLE applications have been changed to have + the new priority (NRF_SDH_BLE_OBSERVER_PRIO_LEVELS has been changed from 3 to 4). + This means that compiling new main files with old sdk_config.h files will not work + unless NRF_SDH_BLE_OBSERVER_PRIO_LEVELS is set to 4 or more. + - Peer Manager + - Added a new event PM_EVT_CONN_SEC_PARAMS_REQ and a new function pm_conn_sec_params_reply() + to allow setting security parameters for individual security procedures. Calling + pm_conn_sec_params_reply() is optional. + - Added a new configuration parameter PM_CENTRAL_ENABLED which removes the pairing functionality + for the central role when turned off, saving code size. + - Added a new informational event PM_EVT_SLAVE_SECURITY_REQ. No further Peer Manager action is + expected from the user in response to this event. + - Added a new event PM_EVT_FLASH_GARBAGE_COLLECTED which indicates that garbage collection has happened + in the flash storage, possibly freeing up space for new bonds. + - Added new function pm_address_resolve() for resolving BLE addresses. + - NFC BLE Pairing Library + - Added library support for the PM_EVT_CONN_SEC_PARAMS_REQ event from the Peer Manager. + NOTE: + ---------------------------------------- + After the change in Peer Manager priority, this change in API was necessary to properly support all pairing modes. + Action: Call the nfc_ble_pair_on_pm_params_req() function inside the Peer Manager event handler in response to the + PM_EVT_CONN_SEC_PARAMS_REQ event: + case PM_EVT_CONN_SEC_PARAMS_REQ: + { + // Send event to the NFC BLE pairing library as it may dynamically alternate + // security parameters to achieve highest possible security level. + err_code = nfc_ble_pair_on_pm_params_req(p_evt); + APP_ERROR_CHECK(err_code); + } break; + ------------------------------------------ + - The Heart Rate Application with BLE Pairing Using NFC Pairing Library now requires LESC + pairing to enable Heart Rate notifications. + - The LESC example now generates the DH key in the main thread so as not to hold up the + SoftDevice's BLE event queue. + +** BLE IoT ** + - Changes from the previous IoT SDK v0.9.0 release: + - The 6LoWPAN library has been rewritten to adopt the new S132 v5.0.0 SoftDevice providing L2CAP Connection Oriented Channels feature. + The library is now distributed in source code format and not as a precompiled library. + - API breakers in many of the components including BLE IPSP, BLE 6LoWPAN, MQTT, nRF lwIP driver port, and background DFU. + - Deprecated the cloud examples. Cloud services used in them were not suitable any more. + The protocol features required to connect to a cloud are included and supported. + - lwIP external component has been updated to version 2.0.2. + - mbedTLS external component has been updated to version 2.4.2. + +** NFC ** + - Removed the SoftDevice from the Writable NDEF Message example. + This example no longer requires the SoftDevice. + - All NFC libraries now have static configuration in the sdk_config.h file. + +** USB (experimental) ** + - nrf_drv_usbd: + - Endpoint transfers are no longer aborted inside the USB RESET handler, + any transfer is now aborted when an endpoint is disabled. + - The nrf_drv_usbd_transfer_out_drop() function now does not start any dummy transfer – the endpoint is cleared by + writing correct values to SIZE.EPOUT registers or backdoor interface for the sample chip. + - Transfer can be started on a stalled endpoint. + In the previous version, NRF_ERROR_FORBIDDEN error was returned. + However, the possibility to stall the endpoint and prepare the answer that will be sent + after the stall is cleared by the HOST appeared to be widely used in MSC. + - Function rename: usbd_drv_ep_abort -> nrf_drv_usbd_ep_abort. + - app_usbd: + - All endpoints but 0 are disabled when the device is not configured. + This matches USB requirements. + - Function app_usbd_active_check provided – this allows to check whether + there is any active USB traffic or interface is suspended. + The macros APP_USB_STATE_BASE and APP_USBD_STATE_SUSPENDED_MASK removed. + The app_usbd_state_t enumeration now provides no information about suspended states. + Use app_usbd_active_check function whenever the SUSPEND state was checked via app_usbd_core_state_get function. + - The SETUP event processing cleaned up, normalized, and documented. + Clear rules for the order in which a class and default handlers are called. + - Functions app_usbd_core_ep_(handled_)transfer() and app_usbd_core_setup_data_(handled_)transfer() + unified and replaced by app_usbd_ep_(handled_)transfer functions: + app_usbd_core_ep_transfer() -> app_usbd_ep_transfer() + app_usbd_core_ep_handled_transfer() -> app_usbd_ep_handled_transfer() + app_usbd_core_setup_data_transfer() -> app_usbd_ep_transfer() + app_usbd_core_setup_data_handled_transfer() -> app_usbd_ep_handled_transfer() + - Classes implementation: + - Audio class implementation aligned to use the new alternate interface selection functionality. + - MSC class implementation error handling totally rebuilt to match the specification. + Now, it is stable and passes all USB precertification tests (with one small warning to be corrected in the future). + +** Crypto ** + - Infineon Optiga Trust E communication library and authentication example are now in production quality. + +** Drivers and libraries ** + - Command Line Interface (CLI) library is now in production quality. + - Logger (nrf_log) can process logs after panic mode. + - app_twi modules renamed to nrf_twi_mngr. Translation layer (app_twi.h) kept for backward compatibility. + + +*** Bugfixes +**************** + +** BLE ** + - Peer Manager: + - Fixed a bug where a bonded and encrypted link could have invalid peer ID when the + Central uses a random non-resolvable address. + - Fixed a bug where the Service Changed state was always reported as "true" when + changed. + - Fixed a bug where peer rank was not written during pm_peer_rank_highest() if the + highest ranked peer was deleted and the peer ID was reused, or if the peer rank + value was manually changed or deleted. + - Fixed a bug where pm_conn_sec_status() would incorrectly return false for bonded field when + called during the PM_EVT_CONN_SEC_SUCCEEDED event for a reconnected bonded peer. + - Fixed a bug where pm_conn_secure() would return an undocumented error code if called + multiple times before the first procedure has completed. + - Fixed the ordering of events from pm_peers_delete(). The PM_EVT_PEERS_DELETE_SUCCEEDED + will now arrive after all PM_EVT_PEER_DELETE_SUCCEEDED events. + - Fixed a bug in ble_app_queued_writes where the characteristic would use the BLE UUID type + instead of a vendor type. + - Fixed a bug in ble_app_gls where the connection handle would be unassigned before the + disconnect call is issued (The connection handle is needed for the disconnect call). + - Fixed a bug in ble_app_gls where the Record Access Control Point indications would not be retried if an indication procedure was already in progress. + - Fixed a bug in ble_app_ancs_c where a missing C++ guard prevented it from compiling + correctly using C++. + - Fixed the LESC example so that it properly handles simultaneous security operations on both + links (numeric match and DHKEY generation). + - Fixed a bug in ble_app_ias_c where receiving a "Mild Alert" would print "No Alert" on the log, and "No Alert" would print "Mild Alert". + - Fixed a bug in ble_app_cgms where the connection handle would be set to invalid before calling sd_ble_gap_disconnect(). This would cause the call to fail and the app would assert. + - Fixed a bug in ble_app_hids_keyboard and ble_app_hids_mouse where the battery reading done before the connection was secured could cause the app to assert. + - Fixed a bug in ble_app_multirole_lesc where it would not handle PHY update requests. + - Fixed a bug that could prevent FDS from working properly when using the new nrf_fstorage_nvmc backend. + - Fixed a bug that could prevent FDS from working properly when using the nrf_fstorage_sd backend with the SoftDevice disabled. + - Keil will no longer delete the SoftDevice HEX file if the flash_softdevice target is compiled. + +** Crypto ** + - Enforced the alignment on nrf_crypto buffers for signature types. + - Removed an unused file (nrf_crypto.c) that would cause compilation errors for some users. + +** DFU ** + - Added a workaround for updating SoftDevices with changed size (from SDK 12.x.y -> 14.1.x). See configuration parameter NRF_DFU_WORKAROUND_PRE_SDK_14_1_0_SD_BL_UPDATE. + +** NFC ** + - Type 4 Tag HAL: + - Handling of erroneous NFC-A data frames (with parity and CRC errors) has been + improved. + +** USB (Experimental) ** + - HAL: + - Function nrf_usbd_dtoggle_set() is fixed. The previous version was not functional. + It was working in the examples thanks to the fact that nrf_usbd_dtoggle_get() + function was called before every nrf_usbd_dtoggle_set(). + +** Drivers and libraries ** + - Fixed a bug where SPI MISO was missing a pulldown. + Currently, the pulldown status can be configured with the SDK configuration parameter: NRF_SPI_DRV_MISO_PULLUP_CFG. + - Fixed a bug where the length parameters passed to macro NRF_LOG_HEXDUMP_DEBUG were not calculated correctly. + - Fixed a bug where a user could receive a "wrong configuration" error during the compilation of SPI driver. + - Fixed a bug where extern "C" was not terminated correctly in the Logger module. + - Fixed a bug in the PPI example where Timer 2 was not generating a CC event every odd second. + - Fixed the header guard in the ble_l2cap_conn.h file. + - Fixed a bug where nrf_log could crash when heavily loaded. + - Fixed the pwm_library example which was not working correcly when compiled with highest optimization on IAR. + +** Serialization ** + - Fixed encoding of ble_gap_data_length_params_t and ble_gap_data_length_limitation_t structures. + - Fixed encoding of ble_gap_evt_auth_status_t::lesc. + - Fixed serialization of GATT MTU value + (https://devzone.nordicsemi.com/question/165596/scanner-doesnt-work-on-nrf52832sdk-14/) + - Fixed improper configuration of scheduler event size in serialized examples + (https://devzone.nordicsemi.com/question/166657/serialization-for-s132-5x-triggers-buffer-overflow-in-event-scheduling/) + + +*** Known Issues +**************** + +** BLE ** + - When working on the emulated nRF52810 target, if you change the optimization level and/or add the logging functionality, the project might not compile or fail at runtime due to not enough flash available for FDS or Peer Manager. + - All Bluetooth applications not using the nrf_queued_write module will assert when a peer sends a Write request with the opcode 'cancel all operations' (BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL), after the SoftDevice call to sd_ble_gatts_rw_authorize_reply. This SoftDevice call, for the opcode 'cancel all operations', returns NRF_INVALID_PARAMS if the gatt_status is not BLE_GATT_STATUS_SUCCESS. + +** BLE IOT ** + - Neighbor discovery module for lwIP requires the on-link flag in the router advertisement to be set in order to create a SLAAC address from the prefix. However, RFC 7668 (https://tools.ietf.org/html/rfc7668) requires this bit to be zero. Therefore, the nd6.c from lwIP source has been modified to relax this check. + - There are some issues when using the IoT examples against Linux Kernel 4.12+ which causes the kernel to only work with one 6LoWPAN connection. If more than one kit is connected using 6LoWPAN, none of the nodes will be accessible. + - Scheduler has been included in most IoT examples to avoid race conditions found when using lwIP stack, more precisely the TCP examples. + The issue was that the TCP client stopped working after about 15 hours. However, when using mbedTLS, the use of scheduler is not possible. + Therefore, the MQTT client examples might be affected by this issue. + - The use of security, both with TLS and DTLS, should be treated as experimental. + - MQTT examples cannot be used with commissioning. There is not enough RAM to accommodate both TLS and the commissioning service. + +** NFC ** + - NFC Type 2 and Type 4 Tag HAL modules require using TIMER 4 on nRF52832. + - Some mobile phone apps cannot write Type 4 Tag ("NFC Tools" and "TagWriter" v4.1 + seem to be okay to use). + +** USB (experimental) ** + - MSC implementation does not stall when the host requires more bytes than are available in the selected descriptor. It is not a problem for any tested driver on Windows and Linux, but still violates the specification. + - During high USB traffic, in rare cases, communication might hang or the endpoint data might be transferred twice. See PAN 104. + +** Drivers and libraries ** + - SAADC driver is not handling detection limits 'high' and 'low' correctly if SAADC resolution is greater than 10 bits. + + +======================================================================== + +nRF5 SDK v14.1.0-1.alpha +------------------------ +Release Date: Week 32, 2017 + +Highlights: +- Integrated what was previously known as nRF5 IoT SDK into nRF5 SDK. Subsequent updates of IoT components will be available through nRF5 SDK. +- Migrated IoT components to use L2CAP Connection Oriented Channels feature of S132 v5.0.0. + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.80.4 +- Linux: Ubuntu 17.04, Kernel 4.10.0. + +Supported SoftDevices: +- S132 v5.0.x +- S140 v5.0.0-2.alpha +- S212 v4.0.x + +Supported boards: +- PCA10040 +- PCA10056 (limited support; see the "Scope for the nRF52840 chip" section) +- Dynastream's D52DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** Scope for the nRF52840 chip +******************************** +All examples and libraries for the new chip must be treated as +experimental. +Some examples have not been ported to run on nRF52840. Check the +existing example projects to see which targets are supported. + +The following SDK features are supported on the new nRF52840 chip: + - IEEE 802.15.4 stack library with an example + - Most BLE, hardware peripheral, and NFC examples (with some + exceptions; see the available example projects for details) + - Peripheral HAL and drivers (both for existing and new peripherals) + - Cryptography library including CryptoCell CC310 backend + - NFC Type 2 Tag and Type 4 Tag + - Secure DFU (only with micro-ecc backend) + - DTM including support for the new Bluetooth 5 features + +The following SDK features are not supported on the new nRF52840 chip: + - ANT + - ESB and Gazell + - FreeRTOS + - Eddystone + - Serialization of the S140 SoftDevice v5.0.0-2.alpha + + +*** New features +***************** + +** BLE ** + - Added support for IPSP (Internet Protocol Support Profile). The IPSP service uses L2CAP Connection Oriented Channels to transfer data between devices. + - Implementation added to components\ble\ble_services. + - IPSP Acceptor example added to examples\ble_peripheral\ble_app_ipsp_acceptor. + - IPSP Initiator example added to examples\ble_central\ble_app_ipsp_initiator. + +** Drivers and libraries ** + - Added experimental examples under the "examples\iot" folder and libraries in the "components\iot" folder that show the usage of IPv6 over Bluetooth Smart using IPSP and 6LoWPAN. The demonstrated protocols include: + - BSD Sockets, + - UDP and TCP, + - DTLS and TLS, + - CoAP and Secure CoAP, + - MQTT and Secure MQTT, + - TFTP and LWM2M, + - Device Firmware Upgrade (DFU) over TFTP, + - DNS, ICMP, and SNTP. + +*** Changes +************ + +** BLE IOT ** + - Changes from the previous nRF5 IoT SDK 0.9.0 release + - The 6LoWPAN library has been rewritten to adopt the new S132 v5.0.0 SoftDevice providing L2CAP Connection Oriented Channels. The library is now distributed in source code format and not as a precompiled library. + - LWIP external component has been updated to version 2.0.2. + - mbedTLS external component has been updated to version 2.4.2. + +*** Known Issues +**************** + +** Overall ** + - In the UART peripheral example, only a line feed (LF) is output on startup and when resetting the board. + - Serialized Direct Test Mode does not report RX packet count correctly. + +** BLE ** + - It is possible that the Peer Manager may return corrupt data when attempting to read the GATT attributes table under some circumstances when FDS CRC checks are enabled. + - In the Multiperipheral Example, LED 3 will toggle when writing any non-zero value to it. Also, two notifications instead of one are received on the Button Characteristic (0x1524) when pressing Button 1. + - For all serialized applications, the MTU size (NRF_SDH_BLE_GATT_MAX_MTU_SIZE in sdk_config.h) should be kept at the default level. Changing this value makes the application non-functional as the connectivity application uses static size buffers. + - Eddystone Beacon Application - LED indication might differ from what is described in documentation under the Testing section. + +** BLE IOT ** + - Neighbor discovery module for lwIP requires the on-link flag in the router advertisement to be set in order to create a SLAAC address from the prefix. However, RFC 7668 (https://tools.ietf.org/html/rfc7668) requires this bit to be zero. Therefore, the nd6.c from lwIP source has been modified to relax this check. + - There are some issues using the IoT examples against Linux Kernel 4.12+ which causes the kernel to only work with one 6LoWPAN connection. If more than one kit is connected using 6LoWPAN, none of the nodes will be accessible. + +** ANT ** +- Most ANT examples do not have the nrf_log backend in the project files, so enabling logging does not have any effect. + +** NFC ** + - NFC Type 2 and Type 4 Tag HAL modules require using TIMER4 on nRF52832. + - Some mobile phone apps cannot write Type 4 Tag (the "NFC Tools" app seems to + be okay to use). + - BLE peripheral examples with NFC pairing work as expected only with Android 7.1.2. + +** DFU ** + - Downgrading from nRF5 SDK v14.0.0 to nRF5 SDK v13.0.0 has been observed to cause the v13.0.0 bootloader to corrupt itself (Upgrading works as expected). + - The S140 SoftDevice currently does not support updating of the bootloader. + - The CTX pin (P0.07) should be grounded to run the Serial Secure DFU on both nRF52832 and nRF52840 boards. + - BLE/Serial Secure DFU only supports nrfutil 2.3.0. + - For nRF52840, a combined SoftDevice and application update on Serial transport fails when using nrfutil 2.3.0. Running a single SoftDevice and application update sequentially works as expected. + + ** USB ** + - USB driver Anomaly 104 solution is very unstable in IAR compilation with high optimization level. + + +======================================================================== + +nRF5 SDK v14.0.0 +------------------------ +Release Date: Week 31, 2017 + +Highlights: +- Added nRF52810 peripheral driver support. +- Added support for the latest SoftDevice (S132 v5.0.0). +- Added a new BLE example, Object Transfer Service, that shows how to set up and use the L2CAP Connection Oriented Channels feature of S132 v5.0.0. +- Updated Direct Test Mode (DTM) to support the new features of Bluetooth 5. +- Added a new NFC example: ISO-DEP raw mode. +- Buttonless DFU feature is now in production quality. +- Added USB CDC as a transport layer for DFU (Experimental, only nRF52840). +- Added a library and examples that show how to integrate and use the Infineon OPTIGA Trust E hardware security module. +- Refactored the logging system (nrf_log) to support multiple independent backends and dynamic logs filtering. +- Refactored the console (nrf_cli). The console can now act as one of the logger backends. Bluetooth UART is now a supported transport (using the ble_nus service). + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.80.4 + +Supported SoftDevices: +- S132 v5.0.x +- S140 v5.0.0-2.alpha +- S212 v4.0.x + +Supported boards: +- PCA10040 +- PCA10056 (limited support; see the "Scope for the nRF52840 chip" section) +- Dynastream's D52DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** Scope for the nRF52840 chip +******************************** +All examples and libraries for the new chip must be treated as +experimental. +Some examples have not been ported to run on nRF52840. Check the +existing example projects to see which targets are supported. + +The following SDK features are supported on the new nRF52840 chip: + - IEEE 802.15.4 stack library with an example + - Most BLE, hardware peripheral, and NFC examples (with some + exceptions; see the available example projects for details) + - Peripheral HAL and drivers (both for existing and new peripherals) + - Cryptography library including CryptoCell CC310 backend + - NFC Type 2 Tag and Type 4 Tag + - Secure DFU (only with micro-ecc backend) + - DTM including support for the new Bluetooth 5 features + +The following SDK features are not supported on the new nRF52840 chip: + - ANT + - ESB and Gazell + - FreeRTOS + - Eddystone + - Serialization of the S140 SoftDevice v5.0.0-2.alpha + + +*** New features +***************** + +** Common ** + - SoftDevice Handler: + - Can now register 'state event observers' that are notified when the SoftDevice state changes. + - Can now register 'request event observers' that are notified when a change of the SoftDevice state is requested. + - Console: + - Advanced cooperation with the Logger module (nrf_log). Console can work as a logger backend. + - Added support for static and dynamic subcommands. + - Easy-to-use macros for creating commands and subcommands. + - Added a smart auto-completion feature for commands and subcommands. + - Added a convenient help handler. + - Added support for multiline commands. + - Added support for text edition using the following keys: Left, Right, End, Home, and Insert. + - Implemented transport layers include: Bluetooth, USB CDC ACM, UART, RTT. + +** BLE ** + - Added support the for the latest SoftDevice (S132 v5.0.0). + - Object Transfer Service added as experimental. The Object Transfer service uses L2CAP Connection Oriented Channels to transfer data between devices. + - Client implementation added to components\ble\ble_services. + - Server implementation added to components\ble\ble_services. + - Central client example application added to examples\ble_central\experimental\ble_ots_c. + - Peripheral server example application added to examples\ble_peripheral\experimental\ble_app_ots. + - GATT Service client added as experimental. The GATT Service client is used to receive Service Changed indications from the connected peer. + - Services featured in the Proximity example are now also accessible as stand-alone service examples. + - Immediate Alert Service client example application added as experimental. + - Immediate Alert Service server example application added as experimental. + - Link Loss Service server example application added as experimental. + - Added BLE transport Command Line Interface. An example "ble_app_cli" can be found in the 'experimental' folder. + +** NFC ** + - Added a new example showing how to use the NFC Type 4 Tag library in raw ISO-DEP mode: NFC UART Example. + - Added a new pairing mode in the NFC BLE pairing library that supports OOB pairing in both "Secure Connections" and "Legacy" modes. + - Added flash support in the Writable NDEF Message Example - after the NDEF update operation, the new tag content is stored in flash. + +** DFU ** + - Added production quality buttonless bootloader with support for bond sharing. + - Added configurable inactivity timeout timer that automatically resets the device in case no new commands are received before the timeout triggers. Default value is 120 seconds. + - Added support for USB CDC as a new transport layer for DFU (Experimental, only for nRF52840). + +** DTM ** + - Added support for new Bluetooth 5 features LE 2M and LE Coded PHY. + - Added support for nRF52840 devices. + +** Drivers and libraries ** + - Added a new example that demonstrates strong cryptographic authentication using the Infineon OPTIGA Trust E hardware security module. + This example uses the following two new libraries located in the 'external' folder: + - Infineon OPTIGA Trust E command library that provides a high-level API to access cryptographic and security-related functions. + - Infineon I2C Protocol Stack library that enables communication with Infineon OPTIGA Trust E and is placed on top of the TWI transaction manager (app_twi). + - Added Stack guard module that allows for enabling stack violation control. + - Added Task Manager module, a simple co-operative scheduler. + - Added fprintf module that can be used for writing C strings. + - Added Ring Buffer module that provides functions to manage a ring buffer. + - Added Memory Object module that allows for creating and managing memory object pools. + +*** Changes +************ +** Common ** + - All examples are modified to use the new SoftDevice Handler (nrf_sdh). + +** BLE ** + - BLE Connection Parameter module supports multiple peripheral links. + - BLE ATT MTU example uses nrf_cli for the user interface. + +** NFC ** + - Improved the Type 4 Tag library interoperability (added support for fragmented command APDUs and fixed DID field handling). + - NDEF record and message definition macros are defined as automatic data (used to be static). + +** DFU ** + - Serial DFU has been updated to be production quality. + +** Proprietary ** + - ESB: Added workarounds for several anomalies that were impacting performance for certain addresses. + - ESB: Added functionality to update certain radio parameters while ESB is running: + - uint32_t nrf_esb_set_retransmit_delay(uint16_t delay); + - uint32_t nrf_esb_set_retransmit_count(uint16_t count); + - uint32_t nrf_esb_set_bitrate(nrf_esb_bitrate_t bitrate); + - uint32_t nrf_esb_reuse_pid(uint8_t pipe); + - Gazell: Released in production quality, added workarounds for RADIO anomalies. + +** Serialization ** + - Added S132 v5.0.0 support. Removed support for S140 5.0.0-2.alpha. + +** Drivers and libraries ** +- Reworked and improved the fstorage library (now called nrf_fstorage). + - Now supports operation with no SoftDevice. + - Now supports operation when the SoftDevice is present and its state changes. +- Refactored nrf_log to support multiple backends. Each backend has independent, dynamic filtering of logs. +- Refactored nrf_cli to act as the logger backend. Improved user interface with smart auto-completion and easy commands addition. +- Updated drivers to work with the nRF52810 device. +- Updated Flash data storage (FDS). + - Can now work with no SoftDevice by using the nrf_fstorage_nvmc backend. + - The 'Chunk' functionality has been removed. + +*** Bugfixes +**************** + +** BLE ** + - Fixed a bug where the multiperipheral example would not be able to connect to more than one link. + +** NFC ** + - Implemented several fixes in Type 2 and Type 4 libraries (fixed nfc_t4t_parameter_set function, removed nRF52 startup code and FPU support from library compilation). + +** Drivers and libraries ** + - Fixed potential overflow in the watchdog timer (WDT) driver initialization. + - Fixed wrong header guard in nrf_nvic.h (https://devzone.nordicsemi.com/question/121041/incorrect-header-guard-in-nrf_nvich/). + - Fixed a bug where nrf_drv_spi_uninit did not clear an event (https://devzone.nordicsemi.com/question/116308/spi-init-triggers-old-nrf_spim_event_end). + - Implemented a fix for nrf_drv_spi - no pulldown on MISO line. + +*** Known Issues +**************** + +** Overall ** + - In the UART peripheral example, only a line feed (LF) is output on startup and when resetting the board. + - Serialized Direct Test Mode does not report RX packet count correctly. + +** BLE ** + - It is possible that the Peer Manager may return corrupt data when attempting to read the GATT attributes table under some circumstances when FDS CRC checks are enabled. + - In the Multiperipheral Example, LED 3 will toggle when writing any non-zero value to it. Also, two notifications instead of one are received on the Button Characteristic (0x1524) when pressing Button 1. + - For all serialized applications, the MTU size (NRF_SDH_BLE_GATT_MAX_MTU_SIZE in sdk_config.h) should be kept at the default level. Changing this value makes the application non-functional as the connectivity application uses static size buffers. + - Eddystone Beacon Application - LED indication might differ from what is described in documentation under the Testing section. + +** ANT ** +- Most ANT examples do not have the nrf_log backend in the project files, so enabling logging does not have any effect. + +** NFC ** + - NFC Type 2 and Type 4 Tag HAL modules require using TIMER4 on nRF52832. + - Some mobile phone apps cannot write Type 4 Tag (the "NFC Tools" app seems to + be okay to use). + - BLE peripheral examples with NFC pairing work as expected only with Android 7.1.2. + +** DFU ** + - Downgrading from nRF5 SDK v14.0.0 to nRF5 SDK v13.0.0 has been observed to cause the v13.0.0 bootloader to corrupt itself (Upgrading works as expected). + - The S140 SoftDevice currently does not support updating of the bootloader. + - The CTX pin (P0.07) should be grounded to run the Serial Secure DFU on both nRF52832 and nRF52840 boards. + - BLE/Serial Secure DFU only supports nrfutil 2.3.0. + - For nRF52840, a combined SoftDevice and application update on Serial transport fails when using nrfutil 2.3.0. Running a single SoftDevice and application update sequentially works as expected. + + ** USB ** + - USB driver Anomaly 104 solution is very unstable in IAR compilation with high optimization level. + + +======================================================================== + +nRF5 SDK v13.1.0 +------------------------ +Release Date: Week 27, 2017 + +Highlights: +- Added support for the SoftDevice S332 v4.0.x. +- Added serialization solution for the combined BLE and ANT SoftDevice. + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.80.4 + +Supported SoftDevices: +- S132 v4.0.x +- S140 v5.0.0-2.alpha +- S212 v4.0.x +- S332 v4.0.x + +Supported boards: +- PCA10040 +- PCA10056 (limited support; see the "Scope for the nRF52840 chip" section) +- Dynastream's D52DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** Scope for the nRF52840 chip +******************************** +All examples and libraries for the new chip must be treated as +experimental. +Some examples have not been ported to run on nRF52840. Check the +existing example projects to see which targets are supported. + +The following SDK features are supported on the new nRF52840 chip: + - New 804.15.4 stack library with an example + - Most BLE, hardware peripheral, and NFC examples (with some + exceptions; see the available example projects for details) + - Peripheral HAL and drivers (both for existing and new peripherals) + - Cryptography library including CryptoCell CC310 backend + - NFC Type 2 Tag and Type 4 Tag + - Secure DFU (only with micro-ecc backend) + - Serialization of the S140 SoftDevice v5.0.0-2.alpha with UART + +The following SDK features are not supported on the new nRF52840 chip yet: + - ANT + - DTM + - ESB and Gazell + - FreeRTOS + - Eddystone + + +*** New features +***************** + +** BLE ** +- Added S332 projects in Heart Rate Sensor and Heart Rate Collector examples. + +** ANT ** +- Added support the for the new SoftDevice S332 v4.0.x. +- Added S332 examples: 'Ant Shared Channels' and 'ANT and BLE Heart Rate Monitor Relay Application'. +- Added an S332 project for the D52DK1 Development Kit in the ANT Message Types example. + +** Serialization ** +- Added a solution for serialization of combined BLE and ANT SoftDevice + using the ble_ant_app_hrm example as the use case. + + +*** Changes +************ + +** ANT ** +- Removed the nrf_sd_def.h file. It will be now distributed just like the rest of SoftDevice header files through + https://www.thisisant.com + + +*** Bugfixes +************* + +** Drivers and libraries ** +- Fixed a potential overflow in watchdog timer (WDT) driver initialization. + + +*** Known Issues +***************** + +** Overall ** +- Updating the MDK requires to manually copy the header and linker files + into the SDK folder (ARM Keil uVision 4, IAR Workbench, ARMGCC). +- When uploading an application to an nRF52 IC using nrfjprog, you must + provide the "--reset/-r" argument or powercycle the board. + +** BLE ** +- Some examples might have excessively verbose logging. +- Examples that use the Peer Manager might assert when deleting bonds, + because advertising is started twice. +- In the Proximity Application, writing "High Alert" to the AlertLevel + characteristic of the Link Loss Service does not trigger a high alert + when the link is lost. +- When an Android device is used as a peripheral, it sends slave + security request with the MITM bit set. The central applications in + the SDK will reject the security request (Pairing Failed) because + they do not support MITM. +- Advertisement intervals in the Eddystone Beacon Application are not + verified. Clients must ensure that the configured advertisement + interval is within the valid range. Note that EID/eTLM configurations + might require advertisement intervals to be larger than the default value. + +** NFC ** +- NFC Type 2 and Type 4 Tag HAL modules require using TIMER4 on nRF52832. +- Type 2 Tag on nRF52840 chips might fail unpredictably. +- Some mobile phone apps cannot write Type 4 Tag ("NFC Tool" seems to + be okay to use). + + +======================================================================== + +nRF5 SDK v13.0.0 +------------------------ +Release Date: Week 11, 2017 + +Highlights: +- Implemented a new license scheme for the SDK distribution. See the + documentation folder for details. +- Updated the Bluetooth and ANT examples to support the newest + SoftDevices S132 v4.0.2, S140 v5.0.0-2.alpha, and S212 v4.0.0. +- Included a new 804.15.4 stack library with an example. +- Released the Eddystone example and the NFC Type 4 Tag stack in + production quality. +- Added workarounds for the nRF52832 anomaly 109 (DMA: DMA access + transfers might be corrupted). +- Added serialization of the ANT S212 SoftDevice v4.0.0 (experimental). +- Added an example showing secure DFU with UART transport layer. +- This release does not support nRF51. +- This release does not support the S332 SoftDevice. + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.60.2 + +Supported SoftDevices: +- S132 v4.0.2 +- S140 v5.0.0-2.alpha +- S212 v4.0.0 + +Supported boards: +- PCA10040 +- PCA10056 (limited support; see the "Scope for the nRF52840 chip" section) +- Dynastream's D52DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** Scope for the nRF52840 chip +******************************** +All examples and libraries for the new chip must be treated as +experimental. +Some examples have not been ported to run on nRF52840. Check the +existing example projects to see which targets are supported. + +The following SDK features are supported on the new nRF52840 chip: + - New 804.15.4 stack library with an example + - Most BLE, hardware peripheral, and NFC examples (with some + exceptions; see the available example projects for details) + - Peripheral HAL and drivers (both for existing and new peripherals) + - Cryptography library including CryptoCell CC310 backend + - NFC Type 2 Tag and Type 4 Tag + - Secure DFU (only with micro-ecc backend) + - Serialization of the S140 SoftDevice v5.0.0-2.alpha with UART + +The following SDK features are not supported on the new nRF52840 chip yet: + - ANT + - DTM + - ESB and Gazell + - FreeRTOS + - Eddystone + + +*** New features +***************** + +** BLE ** +- Added an experimental BLE Multiperipheral example + (experimental_ble_app_multiperipheral) that uses the proprietary LED + Button Service to show how a peripheral device can manage connections + with multiple peers simultaneously. + +** ANT ** +- Added serialization for S212 v4.0.0. With this solution, an ANT + application can run on any architecture, without the SoftDevice. All + SoftDevice API calls are transported via UART to an nRF52 device that + runs the ANT connectivity application (examples\connectivity\experimental_ant) + and the S212 SoftDevice. The ANT I/O example demonstrates the new + serialization solution (examples\ant\ant_io_demo, see targets: + "ser_s212_uart"). Note that the serialized solution does not support + the new API calls added in S212 v4.0.0. + The SDK folders with the ANT serialization implementation are not + marked as experimental, because the paths would be too long. +- Added a new ANT Frequency Agility example + (examples\ant\experimental\ant_frequency_agility). + +** 804.15.4 ** +- Added a full 802.15.4 stack implementation to the SDK. The library + (components\experimental_802_15_4) is available only for nRF52840 + devices. The MAC layer API is located in + components\experimental_802_15_4\api\MAC. The example application is + located in examples\802_15_4\experimental\wireless_uart. +- Added an experimental Wireless UART example (wireless_uart) that shows + how to use the new 804.15.4 stack. + +** NFC ** +- Added two experimental examples that show NFC pairing (BLE Pairing + Using NFC - experimental_ble_nfc_pairing_reference and + ble_nfc_pairing_reference_c). + +** DFU ** +- Added support for serial/UART and an example for a secure DFU + bootloader using UART (experimental). +- Implemented SoftDevice major version checks for certain upgrade types. +- Implemented a delayed reset after the DFU: After a SoftDevice, + bootloader, or SoftDevice and bootloader update, a timer will start. + If no new update is initiated before its expiration, the device will + look for a valid application and launch it. +- Added a new set of error codes (extended error codes) that the DFU + target may send as a response to the DFU controller to convey the + reason for a failure. + +** Serialization ** +- Added serialization support for the ANT S212 SoftDevice v4.0.0 + (experimental). See the ANT section for details. + +** Drivers and libraries ** +- Added workarounds for the nRF52832 anomaly 109 (DMA: DMA access + transfers might be corrupted). Affected drivers: PWM, SPIM, TWIM, + SPIS, and TWIS. +- Added several new libraries: + - Command line interface (CLI) library: Console that supports + various serial interfaces (UART, RTT, USB CDC ACM). + See the usage example in examples/peripheral/cli. + - GFX library: Graphics library that supports simple operations like + drawing circles, lines, rectangles, or bitmaps and printing + strings. GFX uses an LCD driver interface. Two implementations for + popular TFTs have been added (ILI9341, ST7735). + See the usage example in examples/peripheral/gfx. + - Serial port library: Module for handling UART communication. It + supports multibyte transfers, time-outs, and buffering of data. + The module is a replacement for app_uart. + See the usage example in examples/peripheral/serial. + - SPI transaction manager: Module for managing thread-safe access to + the SPI driver. The module supports scheduling transactions that + consist of multiple transfers. See the usage example in + examples/peripheral/spi_master_using_nrf_spi_mngr. + - Error code to string converter (STRERR): Module for converting + error codes to strings. The module is used by nrf_log. +- Added two drivers for TFT LCDs: ILI9341 and ST7735. + + +*** Changes +************ + +** BLE ** +- Updated all BLE examples to use the nRF Connect PC application + (replacing Master Control Panel). +- Modified all BLE example to have logging enabled by default, to make + testing and debugging the SDK examples more consistent. Note that + logging greatly increases power consumption. Therefore, logging should + be disabled in any final product or when performing power profiling + tests. +- Updated the Eddystone example so that it can be released in production + quality. +- Updated all BLE examples to support the newest SoftDevices S132 v4.0.2 + and S140 v5.0.0-2.alpha. +- Updated the Peer Manager to handle more than eight links. +- Updated all BLE examples to use the GATT module. +- Updated the GATT module to handle Data Length update related events. +- Improved the Alert Notification example application to more clearly + convey the Alert Notification Service. Increased the verbosity on UART + instead of relying only on the LEDs. +- Removed the experimental label from the Running Speed and Cadence + central example application. +- Cleaned up the use of RX/TX in the Nordic UART Service (NUS) to match + the terminology used in external tools (nRF Connect, nRF Toolbox). +- Modified the BLE UART example to enable the use of long ATT_MTU. + +** DFU ** +- Updated the experimental BLE Buttonless DFU Service to use the + RAM-retention register to enter bootloader mode instead of flash + access. +- Updated the experimental BLE Buttonless DFU Service to use the + Secure-DFU UUID (16-bit proprietary Nordic UUID). +- Updated the BLE Buttonless DFU characteristic to use a new + vendor-specific base UUID (0x8EC9xxxx-F315-4F60-9FB8-838830DAEA50). + The UUID changed to 0x8EC90003-F315-4F60-9FB8-838830DAEA50. +- Changed the BLE Buttonless DFU characteristic from notification to + indication. +- Changed the minimum version requirement for nrfutil to v2.2.0. + +** NFC ** +- Updated the NFC Type 4 Tag library so that it can be released in + production quality. The library was moved to components\nfc\t4t_lib. + The example that shows the Type 4 Tag library is located in + examples\nfc\writable_ndef_msg. +- Updated the BLE Heart Rate Collector Example with NFC Pairing and the + HID Keyboard Application with BLE pairing using NFC to use the NFC BLE + Pairing library (nfc_pair_lib). +- Updated the BSP NFC Module so that it can be used without restrictions + together with Type 2 and Type 4 Tag libraries. + +** Serialization ** +- Updated serialization to support the latest BLE SoftDevices S132 + v4.0.2 and S140 v5.0.0-2.alpha. + +** Drivers and libraries ** +- Updated the implementation of app_uart. +- Moved the static configuration of app_timer to sdk_config.h. +- Updated several hardware drivers: + - nrf_drv_power: Added initial support for USB plugging with SoftDevice. + - nrf_drv_pwm: Allowed for playbacks to be started using PPI. + - nrf_drv_spi: Added an abort function. + - nrf_drv_twi: Added a function for checking if the driver is busy. + - nrf_drv_uart: Added a function for checking the receiver state. + - nrf_drv_csense: Extended the driver to perform measurements using + SAADC. COMP is still supported, but it is not recommended for + production (see anomaly 84). + + +*** Bugfixes +************* + +- Fixed several bugs in secure DFU to prevent handling invalid updates. +- Updated secure DFU on nRF52840 to utilize the entire 1 MB of flash, up + from the old (unintended) limitation of 512 KB. +- Fixed a bug where ble_app_hrs_rscs_relay would not dispatch + advertising time-out events to the advertising module. +- Fixed a bug where ble_app_uart would not handle the disconnected event + if it was received before a service discovery was completed. +- Fixed a bug where ble_app_pwr_profiling did not initialize the button + module. +- Fixed a bug where ble_app_proximity would not always trigger "High + Alert" on the AlertLevel characteristic when the link was lost. +- Fixed a bug where ble_app_uart would be blocked if app_uart_put + returned an error. +- Fixed a bug where Peer Manager corrupted FDS data in flash. +- Fixed a bug where FDS records updated with fds_record_update() would + not be garbage collected. +- Fixed an unaligned access error in FDS when using certain compiler + options in GCC. +- Fixed a bug in FDS where a missing swap page went undetected. +- Fixed the tick update method in FreeRTOS. +- Fixed a bug where wake-on-field functionality would not work with Type + 2 and Type 4 Tag libraries. +- Several bugfixes and improvements on drivers: + - nrf_drv_timer: Fixed a bug in NRF_TIMER_IS_BIT_WIDTH_VALID. + - nrf_drv_saadc: Fixed a bug where nrf_drv_saadc_calibrate_offset() + enabled a wrong interrupt. + - nrf_drv_pwm: Fixed inaccurate description of the + NRF_DRV_PWM_FLAG_LOOP flag. + + +*** Known Issues +***************** + +** BLE ** +- If the S132 SoftDevice is configured with 0 Peripheral roles and 0 + Central roles, sd_ble_enable() may corrupt up to 8 bytes above the + returned app_ram_base. For applications having such a configuration, + set the application RAM start to 8 bytes or more above the returned + app_ram_base. + +** DFU ** +- The S140 SoftDevice currently does not support updating the bootloader. +- Secure DFU (serial): + - nrfutil currently does not support sending combined zip images + (SD+APP, SD+BL+APP, BL+SD). Use individually generated zip-images + instead. + - The device will not automatically boot the application after a + SoftDevice update. Reset the device manually. +- Secure DFU (BLE): Updates of SD+BL+APP may time out between the SD+BL + and APP stage on certain Android phones. Investigate the time-out + value with respect to your mobile app and consider increasing it. + + +------------------------------------------------------------------------ + +nRF5 SDK v13.0.0-1.alpha +------------------------ +Release Date: Week 50, 2016 + +This release is an alpha release and should ONLY be used for the +following purposes: +- Exploring and trying out the new Bluetooth 5 features available + with the new SoftDevices. +- Trying out new features on the nRF52840 chip. + +Highlights: +- Updated the BLE ATT_MTU Throughput Example (ble_app_att_mtu_throughput) + to showcase a PHY data rate of 2 Ms/s and coded PHY for long-range + transmission. +- Updated the cryptography library to include a CryptoCell CC310 + backend (API changes compared to SDK 12.2.0). +- Updated the BLE LE Secure Connections Multirole Example + (ble_app_multirole_lesc) to use the CryptoCell CC310 backend of the + cryptography library (available only for nRF52840). +- Added serialization of the new SoftDevices S132 v5.0.0-1.alpha and + S140 v5.0.0-1.alpha. Added USB CDC ACM serial as transport layer. +- Dropped support for nRF51 Series devices. +- Dropped support for RTX. + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.30.4 + +Supported SoftDevices: +- S140 v5.0.0-1.alpha +- S132 v5.0.0-1.alpha +- S212 v2.0.0 +- S332 v2.0.0 + +Supported boards: +- PCA10040 +- PCA10056 (limited support; see the "Scope for the nRF52840" section) +- Dynastream's N5DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** Scope for the nRF52840 chip +******************************** +All examples and libraries for the new chip must be treated as +experimental. +Some examples have not been ported to run on nRF52840. Check the +existing example projects to see which targets are supported. + +The following SDK features are supported on the new nRF52840 chip: + - Most BLE, hardware peripheral, and NFC examples (with some + exceptions; see the available example projects for details) + - Peripheral HAL and drivers (both for existing and new peripherals) + - Cryptography library including CryptoCell CC310 backend + - NFC Type 2 Tag and Type 4 Tag + - Secure DFU (only with micro-ecc backend) + - Serialization of the SoftDevices S132 v5.0.0-1.alpha and + S140 v5.0.0-1.alpha with UART and USB CDC ACM transport layers + +The following SDK features are not supported on the new nRF52840 chip yet: + - ANT + - DTM + - ESB and Gazell + - FreeRTOS + - Eddystone + + +*** New features +***************** + +** BLE ** +- Updated the BLE ATT_MTU Throughput Example to demonstrate the use of + Bluetooth 5 features: + - PHY data rate of 2 Ms/s (nRF52832 and nRF52840) + - Coded PHY for long-range transmission (nRF52840 only) + +** NFC ** +- Added a layer of abstraction for NFC OOB pairing, the NFC BLE Pairing + Library (nfc_ble_pair_lib). +- Added a central and a peripheral NFC BLE example that use the new NFC + BLE Pairing Library: + - Heart Rate Collector Application with NFC pairing (ble_app_hrs_nfc_c, + to be used with the Adafruit shield) + - BLE Peripheral example: Heart Rate Application with BLE pairing + using NFC Pairing Library (ble_app_hrs_nfc_pairing_lib) + +** Cryptography ** +- Added a backend to the cryptography library that supports the ARM + CryptoCell 310 hardware-accelerated cryptography engine. +- Updated the LE Secure Connections Multirole Example to showcase how + to use the cryptography library with the CryptoCell CC310 backend + (nRF52840 only). + +** Serialization ** +- Added serialization of the new SoftDevices S132 v5.0.0-1.alpha and + S140 v5.0.0-1.alpha. +- Added the transport layer USB CDC ACM (nRF52840 only). + + +*** Changes +************ + +** Drivers and libraries ** +- Refactored the RNG driver. + +** BLE ** +- Fixed a bug in the Multi-link Example where disconnecting all central + links would disable the app_button module. +- Fixed two bugs in the Buttonless DFU Template Application: + - The example now has writable set on the Control Point characteristic. + - The example is now using the correct part of the flash, enabling + flashing when a bootloader is present. +- Fixed a bug in the ANCS Client Application where NULL-termination of a + received attribute could happen outside its allocated buffer. +- Fixed a bug in the ANCS Client Application where using RFU attribute + IDs could cause illegal memory access. +- Modified the LE Secure Connections Multirole Example to prevent + creation of a second link to the same peer simultaneously. + +** NFC ** +- Fixed a bug in NFC Type 2 and Type 4 Tag HAL where NFC would hang when + the chip was woken up from SYSTEM_OFF and HFXO was started before NFCT + requested it. + +** Serialization ** +- UART and HCI UART transports have been optimized to better utilize + EasyDMA. + + +*** Known Issues +**************** + +** Overall ** +- Updating the MDK requires to manually copy the header and linker files + into the SDK folder (ARM Keil uVision 4, IAR Workbench, ARMGCC). +- When uploading an application to an nRF52 IC using nrfjprog, you must + provide the "--reset/-r" argument or powercycle the board. + +** BLE ** +- Some examples might have excessively verbose logging. +- Examples that use the Peer Manager might assert when deleting bonds, + because advertising is started twice. +- In the Proximity Application, writing "High Alert" to the AlertLevel + characteristic of the Link Loss Service does not trigger a high alert + when the link is lost. +- When an Android device is used as a peripheral, it sends slave + security request with the MITM bit set. The central applications in + the SDK will reject the security request (Pairing Failed) because + they do not support MITM. +- Advertisement intervals in the Eddystone Beacon Application are not + verified. Clients must ensure that the configured advertisement + interval is within the valid range. Note that EID/eTLM configurations + might require advertisement intervals larger than the default value. + +** NFC ** +- NFC Type 2 and Type 4 Tag HAL modules require using TIMER4 on nRF52832. +- Type 2 Tag on nRF52840 chips might fail unpredictably. +- Some mobile phone apps cannot write Type 4 Tag ("NFC Tool" seems to + be okay to use). + + +======================================================================== + +nRF5 SDK v12.2.0 +---------------- +Release Date: Week 49, 2016 + +Highlights: +- Added an NFC Type 4 Tag stack (experimental). +- Replaced the existing Eddystone example with a new implementation. +- Added experimental support for the new nRF52840 chip. See the section + "Scope for the nRF52840" for information about which SDK features are + supported on the new chip. + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.30.4 + +Supported SoftDevices: +- S130 v2.0.1 +- S132 v3.0.0 +- S212 v2.0.0 +- S332 v2.0.0 + +Supported boards: +- PCA10028 +- PCA10031 +- PCA10040 +- PCA10056 (limited support; see the "Scope for the nRF52840" section) +- PCA20006 (only for beacon examples) +- Dynastream's N5DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +*** Scope for the nRF52840 chip +******************************** +Support for the new development board PCA10056 has been added. +All examples and libraries for the new chip should be treated as +experimental. + +The following SDK features are supported on the new nRF52840 chip: + - Most BLE, hardware peripheral, and NFC examples (with some + exceptions; see the available example projects for details) + - Peripheral HAL and drivers (both for existing and new peripherals) + - Library supporting CC310 CryptoCell + - NFC Type 2 Tag and Type 4 Tag + +The following SDK features are not supported on the new nRF52840 chip: + - ANT + - Secure DFU + - Serialization + - DTM + - ESB and Gazell + - RTX and FreeRTOS + - Eddystone + + +*** New features +***************** + +** Drivers and libraries ** +- Added a SysTick driver. +- Added a queue module (nrf_queue). +- Added a memory block allocator module (nrf_balloc). +- Added an atomic operations module (nrf_atomic, nRF52 Series only). +- Added an atomic FIFO module (app_atfifo, nRF52 Series only). +- Added a power management module (nrf_pwr_mgmt). +- Added an asynchronous SD card driver using SPI. +- Ported fatfs for nRF5 (external library). + +*** nRF52840 specific updates *** +- Added a USB device stack and the following USB classes: HID, MSC, + CDC ACM, Audio. +- Added a QSPI driver for external memories. +- Added support for 2 UART instances. +- Added support for 4 PWM instances. +- Added support for more GPIO (48 pins). + +** BLE ** +- Integrated the Eddystone project from GitHub, replacing the existing + Eddystone Beacon example. The new implementation follows the + specification at https://github.com/google/eddystone (commit 97225a9 + from Sep 28, 2016). The new Eddystone library and example supports both + nRF51 and nRF52 (experimental). +- Added an example to demonstrate ATT throughput with long ATT_MTU and + DLE (experimental). +- Added a GATT module that encapsulates the long ATT_MTU feature. +- Extended the Apple Notification Center Service (ANCS) Service module + and example application: + - Added 'notification actions' that depend on the app (for example, + marking a new email as read or dialing up a missed call). + - Added functionality to retrieve app attributes, which allows to + get the name of the app that provided a notification. +- Extended the Continuous Glucose Monitoring Service (CGMS) example + application to handle greater, lesser, or equal filtering for the + Record Access control point. +- Updated the BLE examples to no longer attempt to re-initiate bonding + if encryption fails due to a missing or wrong key. + +** NFC ** +- Added support for NFC Type 4 Tag with both read and write NDEF + access (experimental). +- Added support for raw ISO-DEP transmission protocol mode. +- Added Type 4 Tag support to the Adafruit Tag Reader example. + +** Cryptography ** +- Added support for the ARM CryptoCell 310 hardware-accelerated + cryptography engine. +- Added examples to show how to use the hardware-accelerated + cryptography functionality. + + +*** Changes +************ + +** Overall ** +- Changed the default interrupt priorities for nRF52 to be the same as + the SoftDevice event priority. +- Prefixed error codes with "NRF_". +- Fixed a bug in the clock driver where the driver was failing to handle + two requests coming from the same source. +- Removed nRF52 support for RTX. RTX is now supported on nRF51 chips + only. +- Updated the example Secure DFU images. They are now created with the + debug flag enabled. +- Modified the SoftDevice header files nrf_soc.h and nrf_nvic.h to + support PCA10056 (nRF52840). +- Split up the files located in the examples\bsp folder to new locations: + components\libraries\bsp and components\boards. + +** Drivers and libraries ** +- Updated the RNG driver so that it supports the SoftDevice being + enabled and disabled. Removed the function nrf_drv_rng_pool_capacity(). +- Changed the API for function app_button_is_pushed() (located in + app_button.h). +- Extended the app_gpiote API to support more than 32 pins. Removed + unimplemented functions from the API. +- Extended the nrf_gpio API to support more than 32 pins. Removed + functions that referred to 8-bit ports (for example, + nrf_gpio_port_read). +- Removed the function nrf_drv_adc_gpio_to_ain() from the + nrf_drv_adc API. +- Removed the function nrf_drv_comp_gpio_to_ain() from the + nrf_drv_comp API. +- Removed the function nrf_drv_saadc_gpio_to_ain() from the + nrf_drv_saadc API. + +** BLE ** +- Fixed an issue that would cause some central examples to fail when + restarting scanning using a whitelist. +- Updated the Peer Manager modules to return NRF_ERROR_STORAGE_FULL + instead of NRF_ERROR_NO_MEM. +- The field "peer_id" in the Peer Manager structure + "pm_peer_data_bonding_t" has been renamed to "peer_ble_id". +- Fixed an issue where the Database Discovery Module would not + re-initialize properly upon successive discoveries. +- Fixed an issue where the Database Discovery Module would fail to + discover the extended properties descriptor and the characteristic + user description descriptors. +- Fixed an issue where the Apple Notification Center Service (ANCS) + example application could crash if the connecting iPhone disconnected + immediately after connecting. + +** NFC ** +- Modified the Adafruit NFC Shield library to support reading Type 2 and + Type 4 Tags. +- Improved performance of the Adafruit library in Type 2 Tag reader mode + (faster read). +- Added LE Secure Connections OOB values encoding in ble_pair_msg. +- Enabled dynamic update of the TK value in ble_pair_msg. + + +*** Known Issues +**************** + +** Overall ** +- Updating the MDK requires to manually copy the header and linker files + into the SDK folder (ARM Keil uVision 4, IAR Workbench, ARMGCC). +- When uploading an application to an nRF52 IC using nrfjprog, you must + provide the "--reset/-r" argument or powercycle the board. +- RTX is not supported on nRF52 chips. + +** BLE ** +- Some examples might have excessively verbose logging. +- In the Proximity Application, writing "High Alert" to the AlertLevel + characteristic of the Link Loss Service does not trigger a high alert + when the link is lost. +- When an Android device is used as a peripheral, it sends slave + security request with the MITM bit set. The central applications in + the SDK will reject the security request (Pairing Failed) because + they do not support MITM. +- Eddystone Beacon Application: + - Advertisement intervals are not verified. Clients must ensure that + the configured advertisement interval is within the valid range. + Note that EID/eTLM configurations might require advertisement + intervals larger than the default value. + - Caution: On nRF51 devices, eTLM calculation takes around 500 ms + and is performed once per EID slot in the same interrupt level + priority as the 'Unlock' functionality. Therefore, if multiple EID + slots and an eTLM slot are configured, the client might not be able + to unlock a beacon that has an eTLM slot and uses the default + advertisement interval. To resolve this issue, increase the + advertisement interval. +- Buttonless DFU Template Application (experimental): + - The project setup of the example is wrong and does not fit into the + available space below the DFU bootloader. To fix this problem, + change the IROM1 size from 0x61000 to 0x59000. In addition, comment + out the code section that reserves a codepage at 0x7E000 for MBR + parameters. For details, see + https://devzone.nordicsemi.com/question/100609/sdk-12-bootloader-erased-after-programming/ + - To switch to DFU mode, you must write to the DFU control point. + However, this characteristic is set as read only. Add the following + code line to enable the write property: + char_md.char_props.write = 1; + For details, see + https://devzone.nordicsemi.com/question/93414/sdk12-ble_app_buttonless_dfu/#95079 + + +** NFC ** +- NFC Type 2 and Type 4 Tag HAL modules require using TIMER4 on nRF52832. +- Type 2 Tag on nRF52840 chips might fail unpredictably. +- Some mobile phone apps cannot write Type 4 Tag ("NFC Tool" seems to be + okay to use). + + +======================================================================== + +nRF5 SDK v12.1.0 +---------------- +Release Date: Week 40, 2016 + +Highlights: +- Added serialization of the S132 SoftDevice v3.0.0. Serialization of S130 is now deprecated. +- Included the latest MDK v8.9.0 with a crucial workaround for nRF52832 Errata 108: +http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.Rev1.errata/anomaly_832_108.html + +The following toolchains/devices have been used for testing and verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.30.4 + +Supported SoftDevices: +- S130 v2.0.1 +- S132 v3.0.0 +- S212 v2.0.0 +- S332 v2.0.0 + +Supported IC revisions: +- nRF51422/nRF51822 IC revision 3 +- nRF52832 IC revision 1 + +Supported boards: +- PCA10028 +- PCA10031 +- PCA10040 +- PCA20006 (only for beacon examples) +- Dynastream's D52 Starter Kit (only for ANT examples) +- Arduino Primo v2.1 (board header only) +For other devices and boards, see the SDK documentation, section "Using the SDK with other boards". + +*** New features +**************** +** Overall ** +- Serialization of the S132 SoftDevice v3.0. + + +*** Changes +*********** + +** Overall ** +- Includes the latest Nordic MDK v8.9.0. +- Small documentation updates. + + +*** Known issues +**************** + +** Overall ** +- Updating the MDK requires to manually copy the header and linker files + into the SDK folder (ARM Keil uVision 4, IAR Workbench, ARMGCC). +- When uploading an application to an nRF52 IC using nrfjprog, you must + provide the "--reset/-r" argument or powercycle the board. + +** BLE ** +- When performing service discoveries after a reconnect, + ble_db_discovery might fail to initialize. Refer to this link for a fix: + https://devzone.nordicsemi.com/question/92452/nrf52-ble_db_discovery-failed-to-initialize-correctly-when-repeats-the-service-discovery/ +- The "UART/Serial Port Emulation over BLE" (ble_app_uart) example + does not compile with nrf_log enabled (missing nrf_log sources) +- Some examples might have excessively verbose logging. +- Performing pairing without bonding will cause examples to assert. To + fix this, make sure the call to pm_peer_rank_highest() during + PM_EVT_CONN_SEC_SUCCEEDED happens only when the procedure is + PM_LINK_SECURED_PROCEDURE_BONDING. +- When an Android device is used as a peripheral, it sends slave + security request with the MITM bit set. The central applications in + the SDK will reject the security request (Pairing Failed) because + they do not support MITM. + +** Secure DFU ** + - nRF Toolbox for iPhone: + - When an error occurs, nRF Toolbox does not automatically + disconnect. You must therefore reset the board manually to + disconnect before you can connect again. + - It is not possible to abort a transfer when the device connection + is lost. + - On resumption, nRF Toolbox does not call execute, which makes it + impossible to resume a transfer. + - When transferring a combined SoftDevice and bootloader image, the + bootloader might not be updated. + - On nRF52 devices, the DFU operation is sometimes reported as + completed, even though the device is not updated. + +** NFC ** +- NFC Type 2 Tag HAL requires using TIMER4 on nRF52832. + +------------------------------------------------------------------------ + +nRF5 SDK v12.0.0 +---------------- +Release Date: Week 35, 2016 + +Highlights: +- Added a secure DFU bootloader example and bootloader libraries. + This is an improved implementation that replaces the legacy DFU. +- Added an implementation of the Continuous Glucose Monitoring + Service (CGMS). +- Added support for the S132 SoftDevice v3.0.0. +- Added support for the S212 and S332 SoftDevices v2.0.0. +- Added a capacitive sensor driver and library (csense). +- Added Gazell support on nRF52 (experimental). +- Added new SDK configuration header files to manage static + configuration of an application. +- Overhauled the log subsystem. +- Removed support for the PCA10036 board and nRF52832 Engineering A + and B MCUs. +- Included a critical MDK update (v8.7.1). +- Added support for the CMSIS DSP library. +- Missing feature: Serialization of the latest S132 SoftDevice v3.0.0 + API (work in progress). + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.18a +- GCC: GCC ARM Embedded 4.9 2015q3 +- IAR: IAR Workbench 7.30.4 + +Supported SoftDevices: +- S130 v2.0.1 +- S132 v3.0.0 +- S212 v2.0.0 +- S332 v2.0.0 + +Supported IC revisions: +- nRF51422/nRF51822 IC revision 3 +- nRF52832 IC revision 1 +- nRF52832 Engineering C + +Supported boards: +- PCA10028 +- PCA10031 +- PCA10040 +- PCA20006 (only for beacon examples) +- Dynastream's D52 Starter Kit (only for ANT examples) +- Arduino Primo v2.1 (board header only) +For other devices and boards see the SDK documentation, section +"Using the SDK with other boards". + + +*** New features +**************** + +** Overall ** +- Added a secure DFU bootloader example and bootloader libraries. This + is an improved implementation that replaces the legacy DFU. The + example includes support for cryptographically signed operations. + +** Drivers and libraries ** +- Added a capacitive sensor driver and library for nRF51 and nRF52 + based systems. +- Added an app_timer profiler to get maximum operation queue usage. +- Reduced RAM usage in app_timer and changed the app_timer_cnt_get + function (see the migration note in the Timer library documentation). +- Added pull-up configuration to the TWIS driver. +- Added an FFT FPU example with the CMSIS DSP library. + +** BLE ** +- Added a Continuous Glucose Monitoring Service (CGMS) implementation, + including an example application (experimental). +- Added a Bond Management Service (BMS) implementation, including an + example application (experimental). +- Expanded APIs to support Privacy 1.2. +- Updated Direct Test Mode (DTM), including support for nRF52. + +** ANT ** +- Added new examples: Continuous Waveform Mode, High Duty Search and + Background Scanning, and Time Synchronization. + +** NFC ** +- Added an NFC BSP module (bsp_nfc) and an example showing the usage of + NFC as a wakeup source. + +** Proprietary ** +- Gazell: Ported examples and library to nRF52 (experimental). + + +*** Changes +*********** + +** Overall ** +- Added a new log system across all SDK sources. Replaced printf and + the old log system. + +** Drivers and libraries ** +- Unified the configuration subsystem and moved configuration to one + file (sdk_config.h). +- Changed the NRF51 and NRF52 ifdefs in drivers to peripheral related + ifdefs. +- Improved the PWM library (app_pwm): SET/CLEAR tasks instead of TOGGLE + in nRF52. +- Updated the TWI driver to de-configure GPIO pins in the uninit + function (power-saving change). +- Unified field names in HAL. +- FreeRTOS fixes: + - Fixed invalid assertion. + - Improved tickless mode. +- Simplified the TWI sensor example. +- Added PCA10031 support to the led_softblink and low_power_pwm + examples. + +** Serialization ** +- No support. + +** BLE ** +- Removed the Device Manager modules. All example applications now use + the Peer Manager. +- Removed the pstorage module. All example applications now use the + fstorage module. + +** ANT ** +- Moved the following examples from experimental to production level: + - Advanced Burst + - Asynchronous Transmitter + - Continuous Scanning Controller + - Debug + - Message Types + - Relay + - Search Sharing + - Search Uplink + +** NFC ** +- Moved BLE OOB Pairing Data encoding to a separate module + (nfc_ble_oob_advdata). +- Modified nfc_t2t_lib and hal_nfc_t2t to conform with Nordic's + coding standard. + + +*** Fixed issues +**************** + +** Drivers and libraries ** +- APP_FIFO: Fixed an issue with app_fifo_write writing one byte even + though it was requested to write zero bytes. +- APP_BUTTON: Memory improvements. +- GPIOTE: Fixed handler pointer checking. +- PDM: Fixed high power usage and unexpected restart after calling + nrf_drv_pdm_stop(). +- QDEC: Fixed QDEC un-initialization sequence. +- SAADC: Added missing channel calibration. +- SAADC: Fixed high power consumption and burst mode (oversampling + without external trigger). +- SPI: Fixed STOPPED interrupt handling. +- SPIS: Fixed registers in get function of the amount of TX and RX done. +- TWI: Fixed misc sending bytes and misleading error codes. +- TWI: Added pin toggling functionality configuration during init (pin + toggling sequence during init may cause issues with some devices). +- UART: Fixed data corruption at 1 Mbaud and race conditions. +- DELAY: Fixed nrf_delay_us(0) case. + +** BLE ** +- Fixed an issue where BLE example applications could assert if Button + 2 was held to start advertising while in a connection. +- Fixed several minor documentation mistakes that could make testing + the BLE examples less clear. + +** ANT ** +- Fixed channel type setup in the following examples: Broadcast, Multi + Channels, and Continuous Scanning Controller. + +** NFC ** +- NDEF Text record: Fixed UTF selection. +- NDEF message size calculation. + + +*** Known issues +**************** + +** Overall ** +- Updating the MDK requires to manually copy the header and linker files + into the SDK folder (ARM Keil uVision 4, IAR Workbench, ARMGCC). +- When uploading an application to an nRF52 IC using nrfjprog, you must + provide the "--reset/-r" argument or powercycle the board. + +** BLE ** +- Some examples might have excessively verbose logging. +- Performing pairing without bonding will cause examples to assert. To + fix this, make sure the call to pm_peer_rank_highest() during + PM_EVT_CONN_SEC_SUCCEEDED happens only when the procedure is + PM_LINK_SECURED_PROCEDURE_BONDING. +- When an Android device is used as a peripheral, it sends slave + security request with the MITM bit set. The central applications in + the SDK will reject the security request (Pairing Failed) because + they do not support MITM. + +** Secure DFU ** + - nRF Toolbox for iPhone: + - When an error occurs, nRF Toolbox does not automatically + disconnect. You must therefore reset the board manually to + disconnect before you can connect again. + - It is not possible to abort a transfer when the device connection + is lost. + - On resumption, nRF Toolbox does not call execute, which makes it + impossible to resume a transfer. + - When transferring a combined SoftDevice and bootloader image, the + bootloader might not be updated. + - On nRF52 devices, the DFU operation is sometimes reported as + completed, even though the device is not updated. + +** NFC ** +- NFC Type 2 Tag HAL requires using TIMER4 on nRF52832. + + +======================================================================== + +nRF5 SDK v11.0.0 +---------------- +Release date: Week 10, 2016 + +Highlights: +- Combined SDK supporting both the nRF51 and the nRF52 Series +- Moved Peer Manager out of experimental +- Moved NFC libraries out of experimental and added support for low + power mode +- Added drivers for all nRF52 peripherals +- Added serialization of the S132 and S130 SoftDevices +- Added support for SoftDevices S130 v2.0.0, S132 v2.0.0, S212 v0.9.x, + and S332 v0.9.x +- Replaced the Enhanced ShockBurst library with a new implementation + (based on µESB) +- Included a critical MDK update (v8.5.0) +- Removed support for CMSIS Packs + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.16a +- GCC: GCC ARM Embedded 4.9 2015q1 +- IAR: IAR Workbench 7.30.4 + +Supported SoftDevices: +- S130 v2.0.0 +- S132 v2.0.0 +- S212 v0.9.x +- S332 v0.9.x + +Supported IC revisions: +- nRF51 IC revision 3 +- nRF52 IC revision 1 +- nRF52 Engineering C +- nRF52 Engineering A and Engineering B (see Compatibility) + +Supported boards: +- PCA10028 +- PCA10031 +- PCA10036 (see Compatibility) +- PCA10040 (see Compatibility) +- PCA20006 (only for beacon examples) +For other devices and boards, see the SDK documentation, section +"Using the SDK with other boards". + +Compatibility: +The SoftDevices that are supported in this SDK are not compatible +out-of-the-box with nRF52 Engineering A and Engineering B (the +IC revisions present on all versions of PCA10036 and on PCA10040 +v0.9.0). +However, you can use the latest SoftDevices on Engineering A and B +nRF52 chips for development purposes if you implement the +workaround for anomaly 73 (TIMER: Event lost, see +http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52/dita/nrf52/errata.html). + +*** New features +**************** + +** Drivers and libraries ** +- Added a COMP driver (nRF52 only) + +** BLE ** +- Extended the Peer Manager functionality: + - Added an additional data unit (Peer Rank) that can be used for + tracking which bonds are most (and least) recently used + - Added support for LE Secure Connections in Peer Manager + (experimental) +- Added an example application for LE Secure Connections (experimental, + support for Keil5, IAR, and GCC only) + +** ANT ** +- Added new examples (experimental): + - Advanced Burst + - Asynchronous Transmitter + - Continuous Scanning Controller + - Debug Demo + - IO Demo + - Message Types + - Search Sharing + - Search Uplink +- ANT OTA bootloader application now uses the SoCLibrary API to perform + NVIC operations instead of direct operations +- Added multiprotocol examples for the S332 SoftDevice: + - Heart Rate Monitor Relay Application + - Shared Channels (experimental) + +** Serialization ** +- Added serialization of the S130 and S132 v2.0.0 SoftDevices + +** NFC ** +- Added a generic NDEF message parser that can parse NDEF messages to + the format that is used by the generic NFC NDEF message builder +- Added a module and example for creating NDEF text records +- Added and modified NFC pairing examples (experimental): + - HID Keyboard Application with BLE pairing using NFC (new) + - Heart Rate Application with BLE pairing using NFC (improved user + experience) + +** Proprietary ** +- Added a Low Power Transmitter/Receiver example for ESB + +*** Changes +*********** + +** Overall ** +- Support for CMSIS Packs has been removed. The SDK is delivered as zip + file only. + +** Drivers and libraries ** +- The MSB and LSB macros have been renamed to MSB_32 and LSB_32. Code + using these macros should be changed to use either the 16- or the + 32-bit variant. + +** BLE ** +- Multi-instance handling of Service client modules has been greatly + improved. The client examples now handle service discovery in the main + application context. The main application context must manage which + client instance belongs to which connection link. +- The Multi-link Example has been modified to demonstrate multiple + client instances in a better way. +- The ble_app_multilink_peripheral example has been removed. + ble_app_blinky now acts as the peripheral for ble_app_multilink_central. +- Heart Rate Application with RTX: Support for nRF52 has been removed. +- The Peer Manager is no longer experimental. +- The following BLE examples now use Peer Manager: + - Central: + Running Speed and Cadence Collector (ble_app_rscs_c) + - Central and Peripheral: + BLE Relay (ble_app_hrs_rscs_relay) + BLE LE Secure Connections Multirole (ble_app_multirole_lesc) + - Peripheral: + Alert Notification (ble_app_alert_notification) + Proximity (ble_app_proximity) + Glucose (ble_app_gls) + HID Keyboard Application with BLE pairing using NFC (experimental_ble_app_hids_keyboard_pairing_nfc) +- The behavior of Peer Manager and Device Manager has changed to reject + pairing requests from already bonded peer centrals. +- Several BLE peripheral examples now support the S332 SoftDevice. +- Minor bugfixes in DFU. + +** ANT ** +- The ANT bootloader was aligned to MBR version 2.0.0. +- The following ANT examples now support the S332 SoftDevice + (experimental): + - ANT Bootloader/DFU + - Message Types + +** NFC ** +- The Adafruit Tag Reader Example has been extended to show added NDEF + parsing functionality. +- The NFC Type 2 Tag HAL was improved with a workaround for supporting + low power mode. + +** Proprietary ** +- A new implementation of the Enhanced ShockBurst (ESB) protocol + supporting both nRF51 and nRF52 has been added. + +*** Fixed issues +**************** + +** Drivers and libraries ** +- GPIOTE: Fixed the problem of lost events in low-accuracy sense toggle + mode +- SAADC: Added functionality to use one AIN with multiple channels +- UART: Fixed a glitch on TX pin when initializing the driver +- UART: Fixed the problem that TX bytes were sent in wrong order in + app_uart_fifo + +** BLE ** +- Removed a vulnerability in Peer Manager and Device Manager that would + allow malicious attackers to overwrite the bonding information of a + bonded device + +** ANT ** +- Fixed the handling of send-until-success request types in the ANT + request controller +- Fixed an ant_evt_t structure member alignment bug + +** NFC ** +- Fixed the NFC examples to work when the UART logger is enabled +- Fixed a buffer leakage bug in the module for creating + application/vnd.bluetooth.le.oob records + +*** Known issues +**************** + +** Drivers and libraries ** +- Using the NVIC API directly and not through a SoftDevice causes + problems, especially when NVIC_EnableIRQ or NVIC_DisableIRQ are called + from critical sections. + +** BLE ** +- All BLE examples have been tested only on PCA10028 and PCA10040. +- BLE Examples that use pairing are incompatible with examples in SDK + version 6.1 and earlier that do not use pairing. + +** ANT ** +- Previous versions of the ANT DFU example are incompatible with the ANT + S212/S332 SoftDevices version 0.9.x. + +** NFC ** +- NFCT requires using TIMER4 on nRF52832. + +** FPU ** +- When the FPU is in use, it triggers the FPU_IRQn interrupt when one of + the six exception flags (IDC, IXC, UFC, OFC, DZC, IOC) is set. + The FPU interrupt will always set the pending flag (even if the + interrupt is not enabled), irrespective of whether the user is + interested in the exception bit. + The pending flag then prevents the SoftDevice from going into low + power mode when sd_app_evt_wait() is called. + Therefore, always clear the exception bits and the pending interrupt + before calling sd_app_evt_wait(). See the code below for an example + implementation. + FPU exception bit definition: + http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/BABBFJEC.html + Example code: + { + // Set bit 7 and bits 4..0 in the mask to one (0x ...00 1001 1111) + #define FPU_EXCEPTION_MASK 0x0000009F + + ... + /* Clear exceptions and PendingIRQ from the FPU unit */ + __set_FPSCR(__get_FPSCR() & ~(FPU_EXCEPTION_MASK)); + (void) __get_FPSCR(); + NVIC_ClearPendingIRQ(FPU_IRQn); + + /* Call SoftDevice Wait For event */ + error_code = sd_app_evt_wait(); + } + + +======================================================================== + +nRF5 SDK v11.0.0-2.alpha +------------------------ +Release date: Week 51, 2015 + +Highlights: +- Common SDK supporting both the nRF51 and the nRF52 Series +- Added support for SoftDevices S130 v2.0.0, S132 v2.0.0, and S212 v0.5.1 +- Permanently removed support for SoftDevices S110 and S120 +- Temporarily removed support for ANTBLE SoftDevices +- Enhanced Peer Manager and FDS modules +- Enhanced DFU module +- Configured nrf_log to use UART by default +- Added HardFault handler +- Added drivers for nRF52 peripherals: nrf_drv_i2s, nrf_drv_pdm, + nrf_drv_pwm +- Enhanced drivers to work for both nRF51 and nRF52: nrf_drv_twi, + nrf_drv_spi, nrf_drv_uart, nrf_drv_timer, nrf_drv_ppi, nrf_drv_clock +- Added FreeRTOS and RTX support for nRF52 +- Added NFC modules: Type 2 Tag parser, generic NDEF message builder, + new NFC records and messages +- Added support for Adafruit PN532 NFC shield to provide NFC Forum + Device (Poller) functionality +- Improved support for NFC: enhanced NFC Type 2 Tag library and + Connection Handover module + +The following toolchains/devices have been used for testing and +verification: +- ARM: MDK-ARM version 5.16a +- GCC: GCC ARM Embedded 4.9 2015q1 +- IAR: IAR Workbench 7.30.4 +- Windows XP SP3 32-bit +- Windows 7 SP1 64-bit +- Windows 8.1 + +Supported SoftDevices: +- S130 v2.0.0-7.alpha +- S132 v2.0.0-7.alpha +- S210 v5.0.0 +- S212 v0.5.1.alpha + +Supported boards: +- PCA10028 +- PCA10031 +- PCA10036 +- PCA10040 +- PCA20006 (only for beacon examples) +- Dynastream's N5DK1 (only for ANT examples) + +For other devices and boards, see the SDK documentation, section "Using +the SDK with other boards". + + +Drivers and libraries: + + New features: + - Added driver and example for PWM peripheral (nrf_drv_pwm). + - Added driver and example for I2S peripheral (nrf_drv_i2s). + - Added driver for PDM peripheral (nrf_drv_pdm). + - Enhanced nrf_drv_twi and nrf_drv_spi to support AUTOLOG and + triggering transfers from PPI. + - Added double buffering of RX buffers to nrf_drv_uart. + - Extended nrf_drv_timer to support more compare channels and low + power counter mode in nRF52. + - Extended nrf_drv_ppi API to support forks. + - Added support for FreeRTOS and RTX on nRF52. + - Simplified SPI and SPIS examples. + + Fixed issues: + - In certain cases, FreeRTOS on nRF51 kept interrupts disabled after + context switch (see https://devzone.nordicsemi.com/question/57993/tickless-freertos-in-sdk-100-app_uart). + + Known issues: + - The FreeRTOS nRF51 port has a wrong assertion during system startup. + If you are using assertions, you can safely ignore it. Alternatively, + comment out line 188 in port_cmsis.c. + + Changes: + - Enhanced nrf_drv_clock driver (asynchronous clock management). + + +Serialization: + + - Work in progress; not included in this release. + + +ANT: + + New features: + - Added support for the S212 SoftDevice v0.5.1.alpha. + - Added ANT DFU support for nRF52. + + Known issues: + - When using the ANT OTA Updater v1.2. for nRF52, there is a flash + memory address limitation of 0x40000 (256 KB) for the application. + + +BLE: + + Changes: + - All BLE examples have been tested only on PCA10028 and PCA10040. + - The S13x SoftDevice v2.0.0-7.alpha is configurable, which leads to a + variable RAM setup: + - Added a macro to the softdevice_handler module to check the RAM + configuration against the SoftDevice parameters. + - Added a wrapper function for the sd_enable function to the + softdevice_handler module, which can output the required RAM + start address if the one passed to the SoftDevice is not + correct. + - DFU: + - Added an experimental nRF52 bootloader. + - Updated the SoftDevice initalization according to API changes in + S132 v2.0.0-7.alpha. + - Updated to MBR version v2.0.0-1 alpha. + - Introduced nrf_log as default logging module (UART) in all BLE + examples. + - Peer Manager & FDS have received incremental improvements and bug + fixes. + + Known issues: + - In the HRS/RSCS Relay example, button presses do not have any effect. + - ble_app_cts_c requires an increased UART_TX_BUF_SIZE. The size can be + set in nrf_log.c. + - DTM for nRF52 does not support long packets according to the + Bluetooth 4.2 specification. + - Inconsistent behavior in DFU with devices running Android v6.0.1. + - The BLE and serial DFU examples do not work when using CMSIS Packs. + Use the zip version of the SDK instead. + + +NFC: + + New features: + - Added a Type 2 Tag parser. + - Added a generic NFC NDEF message builder (the builder is used to + implement all specific records and messages). + - Added modules to create Windows LaunchApp records, Android + Application Records, and common application launch messages. Added + an associated example. + - Ported the Adafruit NFC library for the Adafruit PN532 Shield, which + provides NFC Forum Device capabilities. Added an associated example + to read tags. + - Added modules to create application/vnd.bluetooth.le.oob records, + application/vnd.bluetooth.ep.oob records, ac records, Hs records, + and BLE pairing messages. + + Changes: + - Improved the NFC Type 2 Tag library: tested and power-optimized the + library and enhanced it with RTT logger capability. + - Re-implemented NFC URI record and message. Refactored the associated + example. + - Enhanced and re-implemented the NFC Connection Handover solution + (pairing using NFC). + - Re-implemented the BLE NFC pairing example. + + Known issues: + - NFC examples do not work when UART logger is enabled. + + +======================================================================== + +nRF51 SDK v10.0.0 +----------------- +Release date: Week 46, 2015 + +Highlights: + - New BLE Peer Manager (experimental), replacement for the BLE Device + Manager + - FreeRTOS support + - New ANT modules, additional examples, and new and expanded ANT+ + profiles + - Support for Dynastream's N5 Starter Kit + - Three new BLE Services + - Precompiled HEX files + +The following toolchains/devices have been used for testing and +verification: + - ARM: MDK-ARM version 5.14.0.0 and 5.16a + - GCC: GCC ARM Embedded 4.9 2015q1 + - IAR: IAR Workbench 7.30.4 + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + - Windows 8.1 + +Supported SoftDevices: + - S110 v8.0.0 + - S120 v2.1.0 + - S130 v1.0.0 + - S210 v5.0.0 + - S310 v3.0.0 + +Supported boards: + - PCA10028 + - PCA10031 + - Dynastream's N5DK1 (only for ANT examples) + + For other devices and boards, see the SDK documentation, section "Using + the SDK with other boards". + +Changes: + + Drivers and libraries: + New features: + - Ported FreeRTOS to run on nRF51. Added two FreeRTOS examples: one + to run on bare metal and one running a BLE HRS example using the + S110 and S130 SoftDevices. + - Added a TWI transaction manager module for managing access to an + I2C bus. Added an example that uses this module to control two + sensors on the same I2C bus. + - Added an example that shows how to use the TWI driver. + - Added a low-power PWM module (software-controlled low-accuracy + PWM). Added an example that shows how to use this module. + - Added an LED softblink module that uses the low-power PWM. Added + an example that shows how to use this module. + - Ported app_uart to use the UART driver and moved it to the + libraries folder. + - Ported app_gpiote to use the GPIOTE driver. + - Added nrf_log, a logging module that supports printf and that can + use either UART or SEGGER RTT as transport medium. + Fixed issues: + - Mailbox module moved out of serialization. + - Bug fixes in app_timer module. + - App_timer module no longer requires to define the number of + timers used in the application. + - Bug fixes in PWM module. + Changes: + - FIFO library: Extended APIs for multi-byte read and write to the + FIFO. + - Memory Manager module: + - Extended number of block categories to 7 (from 3). + - More RAM-efficient management of memory blocks. + - Added a diagnostic function to help determine the right + configuration needed for the application. + + Serialization: + New features: + - Added a command for resetting the connectivity chip. + + ANT: + New features: + - Added the following new ANT modules: + - ant_encryption + - ant_key_manager + - ant_search_config + - Extended/changed the following existing ANT modules: + - ant_channel_config + - ant_stack_config + - ant_state_indicator + - Refactored the ANT/ANT+ examples and profiles to make them look more + similar to the BLE profiles and examples: + - The following ANT+ profiles have been extracted and extended: + Bicycle Power (ant_bpwr), Bicycle Speed & Cadence (ant_bsc), + Stride Based Speed & Distance (ant_sdm) + - All ANT+ examples have been refactored to use extracted + profiles. + - All ANT+/ANT examples have been refactored to use created + modules. + - Added three new ANT examples: + - ant_scalable + - ant_scalable_encrypted + - ant_scan_and_forward + + BLE: + - Added an experimental module named Peer Manager. This module will + eventually replace the existing Device Manager. The new Peer Manager + improves on the Device Manager in multiple ways, mainly by + supporting concurrent central and peripheral connections. + - Added an experimental flash memory module named Flash Data Storage + (FDS), which greatly reduces the need for time-consuming write and + clear operations. When using FDS, data can be arbitrarily long or + short (within about a page). All pieces of data are tagged with + types, which makes it easy to version data. + - Updated the experimental HRS/RSCS Relay example: + - It now uses the new Peer Manager instead of the Device Manager. + Therefore, it now supports bonding in both central and peripheral + roles. + - It uses the new nrf_log module, which can use SEGGER RTT. + - Removed the app_s130_demo example. + - Added an experimental example supporting the Eddystone beacon + format. + - Added the BLE Connection State module, which keeps track of certain + states of each connection (for example, whether it is encrypted) and + can also keep track of user-defined states. + - Added the Mapped Flags module, which keeps track of flags that are + mapped to keys. It is used by the BLE Connection State module. + - Added ble_gatt_db.h (containing a GATT service structure) and + modified ble_db_discovery module to use it. + BLE Services: + - Updated the Bluetoothds_template application (experimental) to be + compatible with Bluetooth Developer Studio v1.0 and the Nordic + Semiconductor NRF5X v1.1.8 plugin. + - Added three new services: + - Location Navigation Service (experimental) + - Proprietary LED Button Service (experimental) + - Nordic UART Client Service (experimental) + +Fixed issues: + - App_pwm occasionally gives inverted signal. + +Known issues: + - Device Manager is not supported in multi-role S130 operation. + - Device Manager works in peripheral or central only operation on + S130. This must be decided at compile time. + - The DFU over BLE example has been tested to work with a minimum + connection interval of 11.25 ms. The application cannot handle + connection intervals lower than 11.25 ms and may undergo a system + reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during the firmware + update process, consider increasing the connection + interval used by the master. + - The old manual procedure for testing buttonless DFU, as specified in + the documentation, can lead to the DFU process hanging or returning + an error when used with Master Control Panel 3.8 and newer. + - Bootloader binaries (.bin files) generated with the GCC makefile + should not be used. Instead, generate the bootloader bin files using + nrfutils, found on GitHub. + +======================================================================== + +nRF52 SDK v0.9.2 +---------------- +Release date: Week 42, 2015 + +This is an amendment to nRF52 SDK v0.9.1. + +Highlights: + - New targets to enable the two near field communication (NFC) + examples to run on the new PCA10040 development board with + nRF52832 IC rev. Engineering B. + +Libraries: + - Extended the NFC HAL layer of the NFC library to support the NFCT + peripherial for both the chip version delivered with the nRF52 + Preview Development Kit (Engineering A: QFAA-AA0, QFAA-AC0, + CGAA-AA0) and the chip version delivered with the nRF52 Development + Kit (Engineering B: QFAA-BA0, QFAA-BB0, CHAA-AA0, CHAA-AB0). + +Examples: + - Added PCA10040 as target bord for the following examples: + - Heart Rate Example with pairing over NFC + - NFC URL Record Application + +Known issues/workarounds: + - To use the software workarounds implemented for PCA10036 (part + of nRF52 Preview Development Kit), globally define + HAL_NFC_ENGINEERING_A_FTPAN_WORKAROUND in your project. + - The TIMER4 peripheral is used to implement one of the workarounds + for PCA10036. This workaround is not used for PCA10040. + - The ble_app_hrs_pairing_nfc example is unable to wake up from + system off. + +======================================================================== + +nRF52 SDK v0.9.1 +---------------- +Release date: Week 29, 2015 + +This is an amendment to nRF52 SDK v0.9.0. + +Highlights: + - Support for near field communication (NFC) + +Libraries/Services: + - Added a library that supports Type 2 NFC-A tag functionality in + read-only state + - Added a module to generate NFC NDEF messages for BLE pairing over NFC + - Added a module to generate NFC NDEF messages with an URI record type + - Extended the ble_advdata module + +Examples: + - Added ble_app_hrs_pairing_nfc example that demonstrates pairing over + NFC (with S132 SoftDevice) + - Added record_url NFC example that demonstrates exposing a URL record + (without SoftDevice) + +Limitations: + - The current version of the NFC library uses TIMER4. + - The ble_app_hrs_pairing_nfc example has been tested only with Samsung + Galaxy S6. + - If the path to the SDK directory is too long, compilation in Keil fails. + To work around this problem, move the SDK higher in the folder tree + or use shorter folder names. + +======================================================================== + +nRF51 SDK v9.0.0 +---------------- +Release Date: Week 28, 2015 + +Highlights: + - Support for S210 SoftDevice v5.0.0 + - Support for S310 SoftDevice v3.0.0 + - Documentation moved to Infocenter + - DFU Signing using Elliptic Curve Cryptography added as experimental + - Available in the zip file only + - Running Speed and Cadence relay example showing concurrent + central/peripheral functionality of S130 + +The following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM version 5.14.0.0 + - GCC: GCC ARM Embedded 4.9 2015q1 + - IAR: IAR Workbench 7.20 + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + - Windows 8.1 + +Supported SoftDevices: + - S110 v8.0.0 + - S120 v2.1.0 + - S130 v1.0.0 + - S210 v5.0.0 + - S310 v3.0.0 + +Supported boards: + - PCA10028 + - PCA10031 + + For other devices and boards, see the SDK documentation, section + "Using the SDK with other boards". + +Changes: + + - Flash access module has been refactored (pstorage). + + ANT: + - Both the S310 and the S210 SoftDevices now support an extended + number of ANT channels (16). + + + Libraries: + - Heart Rate Monitor Profile + - ANT stack configuration + - ANT channel configuration + - ANT channel state indicator + - ANT pulse simulator + + Examples: + - The ANT HRM examples have been refactored. + - The Bicycle Power examples (ant_bicycle_pwr) support S310. + + ANT + BLE (S310): + The following examples were added: + - Bluetooth LE and ANT combined heart rate example (ble_ant_app_hrm). + - Experimental ANT Shared Channels (experimental_ant_shared_channel_master_to_master, + experimental_ant_shared_channel_slave). + + BLE: + - Advertising module has a new mode: Low Duty Cycle Directed Advertising. + - Running Speed and Cadence Client added as experimental. + - Bluetooth Developer Studio template added as experimental. + - Heart Rate Sensor example (ble_app_hrs) supports S310. + - Running Speed and Cadence example (ble_app_rscs) supports S310. + - Combined Peripheral and Central example added as experimental. + - DFU Signing using Elliptic Curve Cryptography added as experimental + (using the same elliptic curve and hashing algorithm as Bluetooth + Low Energy 4.2 Secure Connections). + +Fixed issues: + - Pstorage now supports updates of bond split across two pages. + - Advertising module can be set to infinite time-out. + - Corrected clock source in BLE multiactivity beacon example. + - Serialization HCI transport layer: Receiving packet-buffer is not + freed while sending ACK or NACK. + +Known issues: + - Device Manager is not supported in multi-role S130 operation. + - Device Manager works in peripheral or central only operation on + S130. This must be decided at compile time. + - The DFU over BLE example has been tested to work with a minimum + connection interval of 11.25 ms. The application cannot handle + connection intervals lower than 11.25 ms and may undergo a system + reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during the firmware + update process, consider increasing the connection interval used + by the master. + - App_pwm occasionally gives inverted signal. + - The old manual procedure for testing buttonless DFU, as specified in + the documentation, can lead to the DFU process hanging or returning + an error when used with Master Control Panel 3.8 and newer. + +======================================================================== + +nRF52 SDK v0.9.0 +---------------- +Release date: 17.06.2015 + +Highlights: + - Support for PCA10036 board v1.0.0 with nRF52832 QFAAAA + - Support for S132 SoftDevice v1.0.0-3.alpha (hex included) + - Support for S212 SoftDevice v0.2.0-1.alpha + - Support for Keil5 without CMSIS Packs + - Support for GCC + - Same structure as nRF51 SDK v8.1.0 + - New peripheral drivers + - Documentation moved to Infocenter + +The following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM version 5.14.0.0 + - GCC: GCC ARM Embedded 4.9 2015q1 + - Windows 7 SP1 64-bit + +Supported SoftDevices: + - S132 v1.0.0-3.alpha + - S212 v0.2.0-1.alpha + +Supported boards: + - PCA10036 v1.0.0 + +Examples: + - Most examples are ported from nRF51 SDK v8.1.0 + - BLE examples run with the S132 SoftDevice + - ANT examples run with the S212 SoftDevice + - The following examples are included: + - BLE peripheral examples + - BLE central example + - New BLE combined central and peripheral example + - ANT examples + - HW peripheral examples + - New SAADC example + - New TWI master with TWI slave example + - BLE/serial DFU bootloader + - Direct Test Mode Application + +Drivers: + - Includes all drivers from nRF51 SDK v8.1.0 + - New drivers: + - SPI driver that supports SPI and SPIM + - UART driver that supports UART and UARTE + - SAADC HAL driver + - TWI slave driver + - SAADC driver + +Libraries/Services: + - Same functionality as for nRF51 SDK v8.1.0 + - The following libraries and services are included: + - BLE libraries + - BLE Services + - Transport Services + - Other libraries/components + +Known issues: + - Device might reset when a Bluetooth link layer procedure and flash operation happens in parallel. + - Inconsistent behavior with Nexus devices running Android v5.1.1, for example: + - DFU fails + - Link loss might reset the nRF52 device + (such behavior might occur with other devices as well) + - After a power cycle, a UART lockup between Segger J-Link and nRF52 might occur + - Before a serial DFU operation or DTM can be executed, "nrfjprog --reset" must be run + +======================================================================== + +nRF51 SDK v. 8.1.1 +------------------ +This is a supplement to the nRF51 SDK v8.1.0 release notes. +This release does not include any code changes compared to nRF51 SDK v8.1.0., except for a minor addition that is described in the "Changes" section. + +Fixed issues: + + - Project does not compile if nrf_drv_ppi is used together with SoftDevice S110, S120 or S210. + Issue exists only in CMSIS PACK release. + +Changes: + - Released new SoftDevice packs: nRF_SoftDevice_S110.8.0.1, nRF_SoftDevice_S120.2.0.1 and + nRF_SoftDevice_S210.4.0.1-5 with updated nrf_sd_def.h. + +Supported SoftDevices: + - S110 8.0.0 + - S120 2.0.0 + - S130 1.0.0 + - S210 4.0.1 + +======================================================================== + +nRF51 SDK v8.1.0 +---------------- + +Highlights: + - Support for SoftDevice S130 v1.0.0 + - Serialization supporting SoftDevice S110, S120, and S130 + - ANCS updated and no longer in experimental state + - GCC updated to new version: ARMGCC 4.9 q1-2015 + - DFU example now has support for IAR and GCC + +The following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM version 4.72.10, 5.13.0.0, 5.14.0.0 + - GCC: gcc-arm-embedded 4.9 2015q1 + - IAR: IAR Embedded Workbench for ARM version 7.20.2 + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + - Windows 8.1 + +Supported devices: + - This SDK is optimized for IC revision 3. + For details, see the "nRF51 Series Compatibility Matrix" document (ATTN-51) available on + www.nordicsemi.com. + + Note 1: To run the ANT examples, you must use an nRF51422 device. + Note 2: Some of the examples using the SoftDevice will not fit on the 128 kB variant of the + chip. + +Supported SoftDevices: + - S110 8.0.0 + - S120 2.0.0 + - S130 1.0.0 + - S210 4.0.1 + +Supported boards: + - PCA10028 + - PCA10031 + + For other devices and boards, see the SDK documentation, section "Using the SDK with other + boards", or use SDK v6.x.x. + +Changes: + ANT + BLE (dual stack): + - Not included in this release due to conflicting interface between SoftDevice S310 and S110. Use SDK v7.2.0 for S310 support. + - S310 support will be reintroduced in a future release. + BLE: + - SoftDevices: + - Support for S130 v1.0.0. + - Serialization: + - Fully serialized S110, S120, and S130 API. + - Modules/Services: + - New button module (bsp_btn_ble) that enables functionality such as disconnect, turn off whitelist, go to sleep. + - Advertising module now supports scan response data + - Examples: + - ANCS example is no longer in experimental state. + Proprietary: + - IAR support for proprietary examples. + +Peripheral drivers & libraries: + - New peripheral drivers: TWI, SWI, and GPIOTE. + - New PWM driver. PWM example updated to use the driver. + +Fixed issues: + - NRFFOSDK-2044: Fixed issue in app_gpiote. + - NRFFOSDK-3855: Fixed issue in Current Time Service. + +Known issues: + - Device Manager is not supported in multirole S130 operation. + - Device Manager works in peripheral or central only operation on S130. This must be decided at compile time. + - The DFU over BLE example has been tested to work with a minimum connection interval of + 11.25 ms. The application cannot handle connection intervals lower than 11.25 ms and may + undergo a system reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during the firmware update process, consider + increasing the connection interval. + + - ANT: + - NRFFOSDK-755: HRM TX buttons example may report wrong total elapsed time. + + - BLE: + - A few APIs of the Device Manager are not implemented. Also, documentation providing + examples of how the API can be used is missing. + - NRFFOSDK-2824: Device Manager (pstorage) does not support update of bond split across two + pages. + + - Proprietary: + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box + with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy + Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and + channel tables require adjustment. + - Timeslot period: Edit the gzll_params.h file used in the nRF24Lxx projects or use the + nrf_gzll_set_timeslot_period() function in the nRF51 projects + (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit the gzll_params.h file used in the nRF24Lxx projects or use the + nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v8.0.0 +---------------- + +Highlights: + - Support for the latest S110, S120, and S130 SoftDevices. (S310 is not supported.) + - SoftDevices included in the SDK. + - Greatly increased driver and HAL coverage. + - New service client and profile example: Current Time Service/Time Profile. + - IAR support for most examples. + +The following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.72.10, 5.13.0.0, 5.14.0.0 + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: IAR Embedded Workbench for ARM version 7.20.2 + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + - Windows 8.1 + +Supported devices: + - This SDK is optimized for IC revision 3. + For details, see the "nRF51 Series Compatibility Matrix" document (ATTN-51) available on + www.nordicsemi.com. + + Note 1: To run the ANT examples, you must use an nRF51422 device. + Note 2: Some of the examples using the SoftDevice will not fit on the 128 kB variant of the + chip. + +Supported SoftDevices: + - S110 8.0.0 + - S120 2.0.0 + - S130 0.9.0-1.alpha + - S210 4.0.1 + +Supported boards: + - PCA10028 + - PCA10031 + + For other devices and boards, see the SDK documentation, section "Using the SDK with other + boards", or use SDK v6.x.x. + +Changes: + Toolchain/IDE: + - The nRF51 SDK now supports the following toolchains in most examples: + - Keil 5.14 (with packs) + - Keil 5.14 (without packs) + - Keil 4.72.10 + - ARM GCC 4.7 2013q1 + - IAR 7.20.2 + - The supported SoftDevices are now included in the SDK and can be flashed directly from + Keil, as a separate target. + + ANT + BLE (dual stack): + - Removed support for the S310 SoftDevice for BLE API compatibility reasons. For support, + use SDK v7.2.0. + + BLE: + - SoftDevices: + - The SDK now supports the S110 SoftDevice v8.0.0. + - The SDK now supports the S120 SoftDevice v2.0.0. + - The SDK now supports the S130 SoftDevice v0.9.0-1.alpha. + - Serialization: + - Serialization support has been removed. For support, use SDK v7.2.0 with appropriate + SoftDevices. + - Modules/Services: + - Added a new advertising module (ble_advertising) that provides automatic handling of + directed/fast/slow advertising, with and without whitelist. + - Nordic UART Service (ble_nus), detached from the UART over BLE Example. + - Added Current Time Service Client (ble_cts_c). + - Service Changed characteristic has been implemented for DFU, so that the indication is + sent when transitioning between application and bootloader. + - Implemented a mechanism for sharing of IRK and LTK from application to bootloader. + This allows for whitelist advertising and reconnection in DFU mode using existing + keys. + - Examples: + - The UART over BLE Example is no longer experimental. + - Added a Time Profile (ble_app_cts_c) example using the Current Time Service Client + implementation. + + Drivers/Libraries: + - Added hardware abstraction layer for the following hardware peripherals: + - ADC (Analog-to-digital converter) + - CLOCK (Clock management) + - LPCOMP (Low power comparator) + - PPI (Programmable Peripheral Interconnect) + - QDEC (Quadrature decoder) + - RNG (Random number generator) + - RTC (Real time counter) + - TIMER (Timer/counter) + - WDT (Watchdog timer) + - Added drivers for the following peripherals: + - CLOCK (Clock management) + - LPCOMP (Low power comparator) + - PPI (Programmable Peripheral Interconnect) + - QDEC (Quadrature decoder) + - RNG (Random number generator) + - RTC (Real time counter) + - TIMER (Timer/counter) + - WDT (Watchdog timer) + - Added modules: + - app_simple_timer (Simple timer based on TIMER1) + + Hardware Examples: + - Added: + - adc_simple (NRF_ADC) + - clock (NRF_DRV_CLOCK) + - lpcomp (NRF_DRV_LPCOMP) + - qdec (NRF_DRV_QDEC) + - simple_timer (APP_SIMPLE_TIMER) + - wdt (NRF_DRV_WDT) + - Modified: + - ppi (NRF_DRV_PPI) + - rng (NRF_DRV_RNG) + - rtc (NRF_DRV_RTC) + - timer (NRF_DRV_TIMER) + +Fixed issues: + - Fixed pstorage issue where different applications could write to the same page. + +Known issues: + - The DFU over BLE example has been tested to work with a minimum connection interval of + 11.25 ms. The application cannot handle connection intervals lower than 11.25 ms and may + undergo a system reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during the firmware update process, consider + increasing the connection interval used by the master. + + - ANT: + - NRFFOSDK-755: HRM TX buttons example may report wrong total elapsed time + + - BLE: + - A few APIs of the Device Manager are not implemented. Also, documentation providing + examples of how the API can be used is missing. + - NRFFOSDK-2824: Device Manager (pstorage) does not support update of bond split across two + pages. + + - Proprietary: + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box + with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy + Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and + channel tables require adjustment. + - Timeslot period: Edit the gzll_params.h file used in the nRF24Lxx projects or use the + nrf_gzll_set_timeslot_period() function in the nRF51 projects + (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit the gzll_params.h file used in the nRF24Lxx projects or use the + nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v7.2.0 +---------------- + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 5.12, 5.13 + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: no support in this release + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + - Windows 8.1 + +Supported devices + - This SDK is optimized for IC revision 3. + For details, see the "nRF51 Series Compatibility Matrix" document (ATTN-51) available on + www.nordicsemi.com. + + Note 1: To run the ANT examples, you must use an nRF51422 device. + Note 2: Some of the examples using the SoftDevice will not fit on the 128 kB variant of the + chip. + Note 3: Some of the serialization examples are too big to be compiled using the free version + of Keil. + +Supported SoftDevices: + - S110 7.1.0 + - S120 1.0.1 + - S130 0.5.0-1.alpha + - S210 4.0.1 + - S310 2.0.1 + +Supported boards: + - PCA10028 + - PCA10031 + - S110 connectivity support for Wavetek WT51822 + + For other devices and boards, see the SDK documentation, section "Using the SDK with other + boards", or use SDK v6.x.x. + +Changes: + - ANT: + - ANT-FS client example: Added callback to allow applications to execute custom code while + waiting for the burst to complete + - Major rework on ANT DFU example + - Added new ANT hub-2-hub/shared channel example + - Added S310 target support for DTM example + - BLE DFU is now supported for S310 + +Fixed issues: + - ANT: + - ANT-FS: Fixed bug with transfer sequence number error causing download failures + - ANT-FS: Fixed bug where upon exhaustion of m_retry, the link time-out has been mistakenly + disabled by a burst transfer + - Fixed issue in linker script for S310 + - Fixed memory corruption issue by using dedicated buffers for ANT and BLE stack events + respectively on S310 + - Fixed an issue where the ANT OTA Updater application v0.8 would not support hex files + with code size larger than 65535 bytes + +Known issues: + - SEGGER J-Link software has some issues with Keil. + See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for details. + - Keil 5.13 may issue a warning about missing packs even when all Nordic Semiconductor packs are + correctly installed. + - The DFU over BLE example has been tested to work with a minimum connection interval of + 11.25 ms. The application cannot handle connection intervals lower than 11.25 ms and may + undergo a system reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during the firmware update process, consider + increasing the connection interval used by the master. + + - ANT: + - NRFFOSDK-755: HRM TX buttons example may report wrong total elapsed time + + - BLE: + - NRFFOSDK-3135: S120 examples: RAM is limited to 16 kB, because S120 V1.0.1 does not + support utilizing the whole flash on the QFACAB chip + - NRFFOSDK-119: Only the ble_app_proximity_low_power and ble_app_hrs applications are power + optimized + - S120 examples: Flash clear operation may fail when connected. Impact of this in the S120 + examples is that if the peer loses the bond and a rebonding occurs, flash clear fails and + a DM_EVT_DEVICE_CONTEXT_STORED event is notified with a failure. + - A few APIs of the Device Manager are not implemented. Also, documentation providing + examples of how the API can be used is missing. + - NRFFOSDK-2824: Device Manager (pstorage) does not support update of bond split across two + pages. + + - Proprietary: + - Temperature example does not give sane output values. This is a hardware-related issue + described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box + with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy + Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and + channel tables require adjustment. + - Timeslot period: Edit the gzll_params.h file used in the nRF24Lxx projects or use the + nrf_gzll_set_timeslot_period() function in the nRF51 projects + (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit the gzll_params.h file used in the nRF24Lxx projects or use the + nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v7.1.0 +---------------- + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 5.12 + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: no support in this release + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + - Windows 8.1 + +Tested with devices: + - nRF51422 QFACAB + + For others devices, use SDK 6.x.x. + +Supported SoftDevices: + - S110 7.1.0 + - S120 1.0.1 + - S130 0.5.0-1.alpha + - S210 4.0.1 + - S310 2.0.0 + +Supported boards: + - PCA10028 + - PCA10031 + - S110 connectivity support for Wavetek WT51822 + + For other boards, use SDK V6.x.x. + +Changes: + - Experimental support for over-the-air firmware update using the ANT radio protocol + - New experimental example ANT relay demo + - Support for S310 ANT+BLE version 2.0.0 + - Re-introduce Device Firmware Update via UART + - BLE DFU single bank support for bootloader+softdevice update + +Fixed issues: + - NRFFOSDK-3119 Fixed issue in app_timer where issuing start/stop from interrupt context caused long delays + +Known issues: + + - SEGGER J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. The application cannot handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during the firmware update process, consider increasing the connection interval used by the master + + ANT + - The OTA Updater application v.0.8 does not support hex files with code size larger than 65535 bytes. + - NRFFOSDK-366: ANT-FS host: download sometimes fails when downloading a large file + - NRFFOSDK-755: HRM TX buttons example may report wrong total elapsed time + + BLE + - NRFFOSDK-3135: S120 examples: RAM is limited to 16 kB, because S120 V1.0.1 does not support utilizing the whole flash on the QFACAB chip + - NRFFOSDK-119: Only the ble_app_proximity_low_power and ble_app_hrs applications are power optimized + - S120 examples: Flash clear operation may fail when connected. Impact of this in the S120 examples is that if the peer loses the bond and a rebonding occurs, flash clear fails and a DM_EVT_DEVICE_CONTEXT_STORED event is notified with a failure. + - A few APIs of the Device Manager are not implemented. Also, documentation providing examples of how the API can be used is missing. + - NRFFOSDK-2824: Device Manager (pstorage) does not support update of bond split across two pages. + + Proprietary: + - Temperature example does not give sane output values. This is a hardware-related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit the gzll_params.h file used in the nRF24Lxx projects or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit the gzll_params.h file used in the nRF24Lxx projects or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 7.0.1 +------------------ +This is a supplement to the nRF51 SDK v7.0.0 release notes. +This release does not include any code changes compared to nRF51 SDK v7.0.0, except for a minor addition that is described in the "Changes" section. + +Fixed issues: + + - Replaced DeviceFamilyPack v1.1.3, which has a wrong URL, with DeviceFamilyPack v1.1.4. + - Added a version field to Pack examples descriptions (NordicSemiconductor.nRF_Examples.pdsc). + - Added missing Nordic Semiconductor nRF51 MDK installer to the repository distribution (nRF51_SDK_x.x.x_xxxxxxx.zip). + - Added missing message sequence charts to the documentation. + - Changed incorrect description of supported SoftDevices in the release notes (see below for the correct list of supported SoftDevices). + +Changes: + + - Added all the register and bitfields for the SPIM peripheral (present in the nRF51802 device) to the HAL header files and replaced the pack nRF_Drivers v1.0.0 with nRF_Drivers v1.1.0. + +Supported SoftDevices: + + - S110 7.1.0 + - S120 1.0.1 + - S130 0.5.0-1.alpha + - S210 4.0.1 + +nRF51 SDK v7.0.0 +---------------- + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 5.12 + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: no support in this release + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + - Windows 8.1 + +Tested with devices: + + - nRF51422 QFACAB + + For others devices, use SDK 6.x.x. + +Supported SoftDevices: + + - S110 7.1.0 + - S120 1.0.0 S120 1.0.1 + - S130 0.5.0-1.alpha + - S210 4.0.1 + - S310 1.0.0 + +Supported boards: + + - PCA10028 + - PCA10031 + - S110 connectivity support for Wavetek WT51822 + + For other boards, use SDK V6.x.x. + + + +Changes: + + - New folder structure + - Moved from installer to CMSIS pack format + - Added support for PCA100028 and PCA10031 + - Deprecated support for previous boards + - Added support for RTX tickless + + ANT + - Changed the ANT examples to support S210 SoftDevice v4.0.1 + - Added experimental Background Scanning example + + ANT + BLE (Dual stack) + - Removed support for S310 SoftDevice (for support, use SDK v6.x.x) + + BLE + - DFU: Added experimental mechanism to exchange encryption keys between application and BootLoader + - DFU: Added identification of firmware versions in the init packet + - Added experimental BLE nRF UART example + - Added experimental ANCS example + - Added experimental example demonstrating usage of S130 SoftDevice + - Added HRS example with RTX + + Proprietary + - Deprecated the following examples (for support, use SDK v6.x.x): + * ADNS2080 Mouse Sensor Driver Application + * Cherry8x16 Keyboard Application + * Button Debouncer Example + * nRF6350 Radio Configuration Example + * PWM Analyzer Example + * Motor Control Example + * TWI Master Example + + +Fixed issues: + + - NRFFOSDK-362: Reset button won't work after programming without cycling the target power + - NRFFOETT-205: The nRF51822 installer will not run if no C:\ drive exists - No installer + - NRFFOSDK-236: When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear - No installer + - NRFFOSDK-363: Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + +Known issues: + + - SEGGER J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. The application cannot handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during the firmware update process, consider increasing the connection interval used by the master + + ANT + - NRFFOSDK-366: ANT-FS host: download sometimes fails when downloading a large file + - NRFFOSDK-755: HRM TX buttons example may report wrong total elapsed time + + BLE + - NRFFOSDK-3135: S120 examples: RAM is limited to 16 kB, because S120 V1.0.1 does not support utilizing the whole flash on the QFACAB chip + - NRFFOSDK-119: Only the ble_app_proximity_low_power and ble_app_hrs applications are power optimized + - S120 examples: Flash clear operation may fail when connected. Impact of this in the S120 examples is that if the peer loses the bond and a rebonding occurs, flash clear fails and a DM_EVT_DEVICE_CONTEXT_STORED event is notified with a failure. + - A few APIs of the Device Manager are not implemented. Also, documentation providing examples of how the API can be used is missing. + - NRFFOSDK-2824: Device Manager (pstorage) does not support update of bond split across two pages. + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Temperature example does not give sane output values. This is a hardware-related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit the gzll_params.h file used in the nRF24Lxx projects or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit the gzll_params.h file used in the nRF24Lxx projects or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 6.1.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 5.10.x/5.11.x + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: Embedded Workbench for ARM 6.60 + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - Windows 8.0/8.1 + +Tested with devices: + + - nRF51822 QFAAG0 + - nRF51822 QFAAGC + - nRF51822 QFAAFA + - nRF51422 QFAAE0 + + For others devices, use SDK 4.x.x + +Supported SoftDevices: + + - S110 7.0.0 + - S120 1.0.0 + - S210 3.0.0 + - S310 1.0.0 + +Supported boards: + + - PCA10000 v1.0 (Only for use with Master Emulator) + - PCA10000 v2.1.0 and 2.2.0 + - PCA10001 v2.1.0 and 2.2.0 + - PCA10004 v2.1.0 + - PCA10005 v2.1.0 and 2.2.0 + - PCA10003 v3.0.0 + + +Changes: + + - Added Keil 5 uvprojx files for most example projects. + - Extended GCC support, most examples now supplied with Makefiles. + + ANT + - None. + + ANT + BLE (Dual stack) + - None. + + BLE + - Device firmware upgrade with support for OTA update of SoftDevice, app and bootloader is no longer in experimental status. + - Buttonless bootloader mode, enter bootloader mode via over-the-air command (see ble_app_hrs example, using ble_app_hrs_dfu.uvproj project). + - Device manager (BLE bond handling) for S110 and S120 are no longer in experimental status. + - db_discovery module (for GATT database discovery) for S120 is no longer in experimental status. + - New reliable transport layer for S110 SoftDevice serialization. + - Example ble_app_hrs_c (heart rate collector) for S120 is no longer in experimental status. + - Example ble_app_multilink_central for S120 is no longer in experimental status. + - Example ble_app_multilink_peripheral for S110 is no longer in experimental status. + - Experimental examples ble_app_ancs and ble_app_multiactivity have been deprecated from this release. + - Experimental example ble_app_uart for pca10001 has been deprecated from this release. + + Proprietary + - None. + +Fixed issues: + - NRFFOSDK-2884: Fixed issue in app_button module (function app_button_is_pushed). + - NRFFOSDK-1341: Added missing characteristic in Blood Glucose application. + - NRFFOSDK-2859: Removed redundant code in Blood Glucose application. + - NRFFOSDK-2557: Fixed some doxygen documentation errors. + +Known issues: + + - When flashing from Keil 4, a pop-up might appear stating "Cannot Load Flash Device Description !". + Solution: + - Write new flash algorithm settings to the uvopt file. + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Utilities". + Press "Settings" button to see flashing algorithms. + Verify that "nRF51xxx" is in the list of flashing algorithms, if not add it by pressing the "Add" button. + Exit and save settings by pressing "OK". This is also important to do if you did find the "nRF51xxx" in the list of flashing algorithms. + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. + This application will not be able to handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during firmware update process, consider increasing the connection interval used by the master. + + ANT + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - S120 Examples: Flash clear operation may fail when connected. Impact of this in the S120 examples is that if peer loses the bond and a re-bonding occurs, flash clear fails, and DM_EVT_DEVICE_CONTEXT_STORED event is notified with a failure. + - Device manager has a few APIs unimplemented. Also documentation providing examples of how API can be used is missing. + - NRFFOSDK-2824: Device manager (pstorage) doesn't support update of bond split across two pages. + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 6.0.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 5.10.x/5.11.x + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: Embedded Workbench for ARM 6.60 + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - Windows 8.0/8.1 + +Tested with devices: + + - nRF51822 QFAAG0 + - nRF51822 QFAAGC + - nRF51822 QFAAFA + - nRF51422 QFAAE0 + + For others devices, use SDK 4.x.x + +Supported SoftDevices: + + - S110 7.0.0 + - S120 1.0.0 + - S210 3.0.0 + - S310 1.0.0 + +Supported boards: + + - PCA10000 v1.0 (Only for use with Master Emulator) + - PCA10000 v2.1.0 and 2.2.0 + - PCA10001 v2.1.0 and 2.2.0 + - PCA10004 v2.1.0 + - PCA10005 v2.1.0 and 2.2.0 + - PCA10003 v3.0.0 + + +Changes: + + - Added partial support for Keil 5 uvprojx files. + + ANT + - None + + ANT + BLE (Dual stack) + + BLE + - New module device manager replaces bond manager for storing persistent data + - Experimental device manager support for s120 (BLE central) + - S110 serialization solution has been reworked + - 100% s110 BLE APIs are now serialized + - S110 support for application concurrent multiprotocol radio access + - Pstorage module: Added API for doing range updates + - Experimental: Device firmware upgrade now supports updating both SoftDevice and bootloader for s110 + + Proprietary + - Enhanced ShockBurst: Added nrf_esb_reuse_pid() function to API, giving "reuse payload" functionality. + - Gazell: Added "suspend" mode enabling sharing of radio and PPI. + - Gazell: HW resources are released when Gazell is being disabled or entering suspend mode. + - Gazell: HW resources are reconfigured when Gazell is being enabled or exiting from suspend mode. + +Fixed issues: + + - NRFFOSDK-2542 - SoftDevice related documentation for S110, S120 and S310 BLE stack is not consistent. When looking up SoftDevice application interface or message sequence charts, it is possible that one is looking at incorrect interface. Recommendation hence is to look at SoftDevice headers to ensure correct appplication interface. This is also applicable for Serialization library references. This will be fixed in next release. + - SDK documentation has been splitted into 4 seperate documents with a common index page. + + ANT + - None + + ANT + BLE (Dual stack) + - S310 Heart Rate Relay Example: Bonding does not always function as expected. If bonding is enabled using compiler flag it is recommended to perform service discovery before bonding to minimize chances of unexpected behaviour. + + BLE + + Proprietary + - Enhanced ShockBurst/Gazell: Received packets in Host/PRX mode with CRC error can no longer return ACK to device. + - NRFFOSDK-2470: app_timer - Fixed issue where starting and stopping the timer repeatedly caused errors in the module + +Known issues: + + - When flashing from Keil 4, a pop-up might appear stating "Cannot Load Flash Device Description !". + Solution: + - Write new flash algorithm settings to the uvopt file. + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Utilities". + Press "Settings" button to see flashing algorithms. + Verify that "nRF51xxx" is in the list of flashing algorithms, if not add it by pressing the "Add" button. + Exit and save settings by pressing "OK". This is also important to do if you did find the "nRF51xxx" in the list of flashing algorithms. + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. + This application will not be able to handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firmware update. + Workaround: If you face unexpected disconnects during firmware update process, consider increasing the connection interval used by the master. + + ANT + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - S120 Examples: Flash clear operation may fail when connected. Impact of this in the S120 examples is that if peer loses the bond and a re-bonding occurs, flash clear fails, and DM_EVT_DEVICE_CONTEXT_STORED event is notified with a failure. + - Device manager has a few APIs unimplemented. Also documentation providing examples of how API can be used is missing. + - NRFFOSDK-2824: Device manager (pstorage) doesn't support update of bond split across two pages. + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 5.2.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 5.10.x + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: Embedded Workbench for ARM 6.60 + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - Windows 8.0/8.1 + - The BLE example applications for HID Keyboard and HID Mouse have been tested with HID host running on Windows 8.1. + +Tested with devices: + + - nRF51822 QFAAG0 + - nRF51822 QFAAGC + - nRF51822 QFAAFA + - nRF51422 QFAAE0 + + For others devices, use SDK 4.x.x + +Supported SoftDevices: + + - S110 6.0.0 + - S120 1.0.0-1.alpha + - S210 3.0.0 + - S310 1.0.0 + +Supported boards: + + - PCA10000 v1.0 (Only for use with Master Emulator) + - PCA10000 v2.1.0 and 2.2.0 + - PCA10001 v2.1.0 and 2.2.0 + - PCA10004 v2.1.0 + - PCA10005 v2.1.0 and 2.2.0 + - PCA10003 v3.0.0 + + +Changes: + + - app_button module: Detect both push and release, instead of just push + - Persistent storage (pstorage) module: + - Support for writing to used memory regions with the new update API. + - Support for clearing single blocks. + - Added get_status API to identify pending flash operations. + + ANT + - None + + ANT + BLE (Dual stack) + - Support for s310 SoftDevice added. + - Heart rate monitor example project support added. + - Added Device Firmware Update (DFU) example for s310. + BLE + - New experimental device manager module for managing bonds on s120. + - Beacon example added. It is available at nrf51822\Board\nrf6310\s110\ble_app_beacon + and nrf51822\Board\pca10001\s110\ble_app_beacon. + - Multiple GATT clients: The Database Discovery module available in + nrf51822\Board\nrf6310\s120\experimental\common folder can now be used to + discover two GATT services at the peer. + - Serialized s110 advertisement example has been removed. + - HID Keyboard application modified to send upper case letters on pressing Button 2. + + Proprietary + - None + +Fixed issues: + + ANT + - None + + ANT + BLE (Dual stack) + - None + + BLE + - NRFFOSDK-1897: Glucose: Fixed bug where authentication was not initiated when connecting to already bonded master. + - NRFFOSDK-2318: Glucose Feature values had incorrect values for 'General Device Fault Supported', 'Time fault Supported', and 'Multiple Bond Supported'. This has been fixed. + - ANCS: The advertising interval of the Apple Notification Center Client example application is reduced to 25 ms. Previously it was 250 ms which made it hard to discover from the peer device. + - NRFFOSDK-2357: Blood Pressure application changed to check if indication is enabled before attempting to send an indication to the peer + - NRFFOSDK-2336: HID Keyboard application fixed to send the correct Input Report bytes when in Boot Mode. + - Fixed issue in bond manager related to clearing of whitelist on deleting all bonds. + - NRFFOSDK-2162: New pstorage get_status API used to allow for flash access to be completed before system off. + + Proprietary + - NRFFOETT-644 - Gazell / ESB: Fixed some documentation issues. + +Known issues: + + - NRFFOSDK-2542 - SoftDevice related documentation for S110, S120 and S310 BLE stack is not consistent. When looking up SoftDevice application interface or message sequence charts, it is possible that one is looking at incorrect interface. Recommendation hence is to look at SoftDevice headers to ensure correct appplication interface. This is also applicable for Serialization library references. This will be fixed in next release. + + - When flashing from Keil 4, a pop-up might appear stating "Cannot Load Flash Device Description !". + Solution: + - Write new flash algorithm settings to the uvopt file. + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Utilities". + Press "Settings" button to see flashing algorithms. + Verify that "nRF51xxx" is in the list of flashing algorithms, if not add it by pressing the "Add" button. + Exit and save settings by pressing "OK". This is also important to do if you did find the "nRF51xxx" in the list of flashing algorithms. + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. + This application will not be able to handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firware update. + Workaround: If you face unexpected disconnects during firmware update process, consider increasing the connection interval used by the master. + + ANT + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + ANT + BLE (Dual stack) + - S310 Heart Rate Relay Example: Bonding does not always function as expected. If bonding is enabled using compiler flag it is recommended to perform service discovery before bonding to minimize chances of unexpected behavior. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + - S120 Examples: Flash clear operation may fail when connected. Impact of this in the S120 examples is that if peer loses the bond and a re-bonding occurs, flash clear fails, and DM_EVT_DEVICE_CONTEXT_STORED event is notified with a failure. + - Device manager is an experimental module and has a few APIs unimplemented. Also documentation providing examples of how API can be used is missing. + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 5.1.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 5.0.5.x + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: Embedded Workbench for ARM 6.60 + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - Windows 8.0/8.1 + - The BLE example applications for HID Keyboard and HID Mouse have been tested with HID host running on Windows 8.1. + +Tested with devices: + + - nRF51822 QFAAGC (For others, use SDK 4.x.x) + - nRF51822 QFAAFA (For others, use SDK 4.x.x) + - nRF51422 QFAADA (For others, use SDK 4.x.x) + +Supported SoftDevices: + + - S110 6.0.0 + - S120 0.8.0-2.alpha + - S210 3.0.0-3.beta + - S310 1.0.0-2.alpha + + +Supported boards: + + - PCA10000 v1.0 (Only for use with Master Emulator) + - PCA10000 v2.1.0 and 2.2.0 + - PCA10001 v2.1.0 and 2.2.0 + - PCA10004 v2.1.0 + - PCA10005 v2.1.0 and 2.2.0 + + +Changes: + + - Moved and renamed SoftDevice header folders: + from nrf51822/Include/ble/softdevice to nrf51822/Include/s110 + from nrf51422/Include/ble/softdevice to nrf51422/Include/s210 + - Added SoftDevice headers for s120 and s310 at: + nrf51822/Include/s120 + nrf51422/Include/s310 + - Moved ANT examples from nrf51422/Board//ant to nrf51422/Board//s210 + - Moved s110 SoftDevice examples from nrf51822/Board//ble to nrf51822/Board//s110 + - Added folder for s310 examples in nrf51422/Board//s310 + - Added folder for s120 SoftDevice examples in nrf51822/Board//s120 + + ANT + - The flash layout settings of all ANT examples have been adapted to suit the new flash layout of S210 SoftDevice. + + + BLE + - Added experimental Multilink (up to 8) Central example which uses s120 SoftDevice. + - Added experimental Heart Rate collector example which uses s120 SoftDevice. + - Added prototype iBeacon example. + + Proprietary + +Fixed issues: + + - NRFFOETT-671: Added support for creating new nRF51 projects in Keil 5. + + ANT + - NRFFOETT-438: The API documentation of S210 SoftDevice is now correctly structured in the SDK documentation. + BLE + + Proprietary + +Known issues: + + - When flashing from Keil 4, a pop-up might appear stating "Cannot Load Flash Device Description !". + Solution: + - Write new flash algorithm settings to the uvopt file. + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Utilities". + Press "Settings" button to see flashing algorithms. + Verify that "nRF51xxx" is in the list of flashing algorithms, if not add it by pressing the "Add" button. + Exit and save settings by pressing "OK". This is also important to do if you did find the "nRF51xxx" in the list of flashing algorithms. + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. + This application will not be able to handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firware update. + Workaround: If you face unexpected disconnects during firmware update process, consider increasing the connection interval used by the master. + + + ANT + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + - NRFFOSDK-2162 - Heart Rate application for PCA10001 possible inconsistent system attributes on power cycle. It is possible that the system attributes on power cycle are not consistent with the ones updated during previous connection. + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 5.0.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.72.1.0 + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: embedded workbench for ARM 6.60 + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - Windows 8.0/8.1 + - The BLE example applications for HID Keyboard and HID Mouse have been tested with HID host running on Windows 8.1. + +Tested with devices: + + - nRF51822 QFAAGC (For others, use SDK 4.x.x) + - nRF51822 QFAAFA (For others, use SDK 4.x.x) + - nRF51422 QFAADA (For others, use SDK 4.x.x) + +Supported SoftDevices: + + - S110 6.0.0-3 Beta + - Expected to be Compatible with SoftDevice S110 V6.0.0 production version + +Supported boards: + + - PCA10000 v1.0 (Only for use with Master Emulator) + - PCA10000 v2.1.0 and 2.2.0 + - PCA10001 v2.1.0 and 2.2.0 + - PCA10004 v2.1.0 + - PCA10005 v2.1.0 + + NOTE: The ANT examples in this release will only work on nRF51422 QFAADA engineering samples. + Currently no official boards/kits exist that work with these examples. + + +Changes: + + - Added pstorage module for handling asynchronous non-volatile memory (flash) access via SoftDevice API + - Existing BLE event handler has been extended into the new SoftDevice handler module. The new SoftDevice handler module allows for fetching SoC, BLE and ANT events + - Restructured documentation + + + ANT + + BLE + - Changes for support of S110 V6.0.0-3 Beta + - Added Apple Notification Center in experimental + + Proprietary + - SPI slave driver and example code added + - Include new ESB library which uses the same peripherals as the S110 SoftDevice + +Fixed issues: + + ANT + + BLE + + Proprietary + +Known issues: + + - Creating a blank project with Keil V5.0 it is not possible to choose the nRF51 series. + Solution: + Start new projects by making a copy of any existing keil project from the SDK + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. + This application will not be able to handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firware update. + Workaround: If you face unexpected disconnects during firmware update process, consider increasing the connection interval used by the master. + + + ANT + - NRFFOETT-438 - Documentation on S210 SoftDevice API wrongly structured. All SoftDevice functions appear as SVCALL in the Doxygen page. + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + - NRFFOSDK-2162 - Heart Rate application for PCA10001 possible inconsistent system attributes on power cycle. It is possible that the system attributes on power cycle are not consistent with the ones updated during previous connection. + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 4.4.2 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.72.1.0 + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: embedded workbench for ARM 6.60 + - N51822 QFAACA on PCA10004 module on nRF6310 motherboard + - N51822 QFAAFA on PCA10005 module on nRF6310 motherboard + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - Windows 8.0/8.1 + - BLE SoftDevice Version : s110_nrf51822_5.2.1 + - The BLE example applications for HID Keyboard and HID Mouse have been tested with HID host running on Windows 8.1. + +- Supported boards in nRF51 SDK v. 4.4.2: + - PCA10000 v1.0 (Only for use with Master Emulator) + - PCA10000 v2.0.0 + - PCA10001 v1.0 through v2.1.0 + - PCA10003 v1.0 through v2.0.0 + - PCA10004 v1.0 through v2.0.0 + - PCA10005 v1.0 through v2.1.0 + - PCA10006 v1.0 through v2.0.0 + - PCA10007 v1.0 through v2.0.0 + - PCA10014 v1.0 + - PCA10018 v1.0.0 through v1.1.0 + +Changes: + + ANT + None + + BLE + - Removed ble_dfu_send_hex.exe from device_firmware_update experimental folder. Similar feature is now available in latest Master Control Panel application. + + Proprietary + None + +Fixed issues: + + - NRFFOSDK-1750 - Added PAN-11 workaround in PPI, PWM, and Simple PWM motor control examples. + - NRFFOSDK-1633 - Added PAN-56 workaround in TWI master driver. + + ANT + None + + BLE + - NRFFOSDK-1025 - The field max_len in rep_char_add signature in ble_hids.c has been corrected to uint16_t. + - NRFFOSDK-1921 - In case IRK is distrubuted by a peer using public address whitelist is updated for both IRK and address. + - NRFFOSDK-1899 - System attributes re-initialized on rebonding. + - NRFFOSDK-1900 - Removed false detection of DIV collisions. + - NRFFOSDK-1993 - Increased buffer in hci_mem_pool_internal.h fix the serialization examples. + Proprietary + None + +Known issues: + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. + This application will not be able to handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firware update. + Workaround: If you face unexpected disconnects during firmware update process, consider increasing the connection interval used by the master. + + + ANT + - NRFFOETT-438 - Documentation on S210 SoftDevice API wrongly structured. All SoftDevice functions appear as SVCALL in the Doxygen page. + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 4.4.1 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.71.2 + - GCC: gcc-arm-embedded 4.7 2013q1 + - IAR: embedded workbench for ARM 6.60 + - N51422 QFAACA on PCA10003 evaluation kit board + - N51822 QFAACA on PCA10004/5 module on nRF6310 motherboard + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - BLE SoftDevice Version : s110_nrf51822_5.2.1 + - The BLE example applications for HID Keyboard and HID Mouse have been tested with HID host running on Windows 8.1 Preview. + +Changes: + + - DFU documentation improved. + + ANT + None + + BLE + - NRFFOSDK-1759: Example IAR application for Heart Rate Service added. + - NRFFOSDK-1271: Speed and Cadence Control Point added to Cycling Speed and Cadence Service. + + Proprietary + - ESB: Improved tolerance to delayed interrupts. + + +Fixed issues: + + - NRFFOSDK-1592: Risk of losing timer interrupts when the resolution of the timer is very high, e.g. 1 ms resolution, is now fixed. + + ANT + None + + BLE + - NRFFOETT-399: An IRK is added to the bond manager's whitelist only if the address type of the master is 'resolvable'. + - NRFFOETT-552: DTM application is now implementing PCN_083 + - NRFFOSDK-1828: Key refresh was triggering a link failure when re-bonding to a master. This is now fixed. + - NRFFOETT-571: Premature disconnection scenario handling added to bond manager. Previously this was resulting in system attributes of a master to be cleared. + + Proprietary + - ESB: The nrf_esb_tx_failed() callback function was never called when dynamic acknowledgement was used. This is now fixed. + +Known issues: + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. + This application will not be able to handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firware update. + Workaround: If you face unexpected disconnects during firmware update process, consider increasing the connection interval used by the master. + + + ANT + - NRFFOETT-438 - Documentation on S210 SoftDevice API wrongly structured. All SoftDevice functions appear as SVCALL in the Doxygen page. + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 4.4.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.71.2 + - GCC: gcc-arm-embedded 4.7 2013q1 + - N51422 QFAACA on PCA10003 evaluation kit board + - N51822 QFAACA on PCA10004/5 module on nRF6310 motherboard + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - BLE SoftDevice Version : s110_nrf51822_5.2.1 + - The BLE example applications for HID Keyboard and HID Mouse have been tested with HID host running on Windows 8. + +Changes: + + - Device Firmware Update example released as part of the main SDK. + - Added support for image transfer over BLE. + - HCI Transport Layer used for serial transfer. + - Note: This example is implemented to work on nRF6310 motherboard because it uses Button 7 to enter bootloader mode on reset. + This is because Button 0 and Button 1 are used by other SDK applications as wakeup buttons. + If this example is to be changed to work for evaluation kit board, then this should be taken into consideration. + - PC application examples for performing firmware updates using HCI and BLE added in nrf6310\device_firmware_updates\experimental folder. + + - UICR Configuration example added to the SDK. It can be found in nrf6310\uicr_config_example folder. + + ANT + None + + BLE + - NRFFOETT-507: ble_app_dtm missing bytes on UART fixed. + - NRFFOSDK-73 : HID keyboard application will now send one key press per notification. + + + Proprietary + None + +Fixed issues: + + ANT + None + + BLE + - NRFFOSDK-1432: Buffer overflow issue in ble_bondmngr_sys_attr_store() function fixed. + - NRFFOETT-339: CCCD values (System Atributes) are now restored on reconnection to a known master only after the link is encrypted. + + Proprietary + None + +Known issues: + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + - NRFFOSDK-1774: During SDK installation, chosing custom install location for SDK examples will create Start Menu shortcuts that point to Keil installation location. + - NRFFOSDK-1592: There is a risk of losing timer interrupts when the resolution of the timer is very high, e.g. 1 ms resolution. + - The DFU over BLE example has been tested to work with a minimum connection interval of 11.25 ms. + This application will not be able to handle connection intervals lower than 11.25 ms and may undergo a system reset in the middle of a firware update. + Workaround: If you face unexpected disconnects during firmware update process, consider increasing the connection interval used by the master. + + + ANT + - NRFFOETT-438 - Documentation on S210 SoftDevice API wrongly structured. All SoftDevice functions appear as SVCALL in the Doxygen page. + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOETT-399 - The bond manager will use distrubted IRK in its whitelist regardless of the type of central's address and should actually use the irk if distributed and if the central's address is not public, and not random_static and not random_private_non_resovable. + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + + Proprietary: + - NRFFOSDK-1769: Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 4.3.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.60 + - GCC: gcc-arm-embedded 4.7 2013q1 + - N51422 QFAACA on PCA10003 evaluation kit board + - N51822 QFAACA on PCA10004/5 module on nRF6310 motherboard + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - BLE SoftDevice Version : s110_nrf51822_5.2.0 + +Changes: + + - Supported GCC toolchain switched from CodeSourcery to gcc-arm-embedded. + - New gcc startup file, linker scripts, and makefiles. + - Updated CMSIS header files in Include/gcc to the latest revision (3.20). + - Makefile target "all" now runs "clean" and "debug" targets instead of incremental "release" target. + - nrf.h requires projects to have a define for a chip to enable some needed workarounds. + - SDK examples now support PCA10000 v2.0.0. To make the examples work on the older PCA10000 v1.0, the UART pins need to be remapped in the pca10000.h header file. + For v1.0 + #define RX_PIN_NUMBER 3 + #define TX_PIN_NUMBER 1 + #define CTS_PIN_NUMBER 2 + #define RTS_PIN_NUMBER 0 + For v2.0.0 + #define RX_PIN_NUMBER 11 + #define TX_PIN_NUMBER 9 + #define CTS_PIN_NUMBER 10 + #define RTS_PIN_NUMBER 8 + + ANT + - ANT examples have been updated to support the newest UART API. + BLE + - HCI Transport Layer from Bluetooth Specification v4.0 introduced for BLE S110 Serialized Applications. + - BLE S110 Serialization Examples released as part of the main SDK. + - Updated serialized ble_app_advertising and ble_app_hrs to use app_scheduler. + - Connection Parameter update module : Added possibility to request different connection parameters multiple times. A new event, BLE_CONN_PARAMS_EVT_SUCCEEDED has been created. Event handler implementation needs to take this into account, especially if they were implemented to trigger a disconnect regardless of the type of event. + - Added Makefile and Eclipse project file for ble_app_hrs. + - Changed hard coded flash pages to be FICR CODESIZE dependent. + + Proprietary + - Gazell: + - Added Gazell Pairing Host source code and board example. Backwards compatible with nRF24L Gazell Pairing Device and Host modules. + - Added function nrf_gzll_set_auto_disable(uint32_t num_ticks), to disable Gazell after a number of timeslots. + - Added function nrf_gzll_get_tick_count(). + - Gazell Pairing Device now uses nrf_gzll_get_tick_count() in order to implement a delay. This reduces current consumption. + - Default sync_lifetime value has been increased to 3*channel_table_size*number_of_timeslots_per_channel. This improves performance in high-interference environments. Current users who are satisfied with the performance may wish to maintain the minimum value of 1*channel_table_size*number_of_timeslots_per_channel, in order to avoid any slight increase in current consumption. + - Enhanced ShockBurst: + - ESB PTX now calls nrf_esb_tx_success() callback instead of nrf_esb_tx_failed() for NOACK packets. + - Fix in nrf_esb_set_mode() + - Information concerning backwards compatibility with nRF24L devices has been moved to the User Guide. + +Fixed issues: + + - Examples doing flash writes were not waiting for writes to finish. + + ANT + - NRFFOSDK-1312 - Changed ANTFS_TRANSMIT_POWER define in antfs.h from 0 to 3. The define previously had an incorrect definition which set the power value to -20dBm instead of 0dBm even though the comment indicated 0dBm. + + BLE + - NRFFOETT-402 - DFU Bootloader application in experimental project now sets stack pointer correctly before executing reset vector of application. + + Proprietary + - NRFFOETT-301 - Radio example uses obsolete RADIO_TXPOWER_TXPOWER_Neg40dBm definition. + - Fixed issue in TWI HW driver. Event was not cleared before waiting it to get cleared. + - Floating point ABI used by Makefiles was incorrect. Now using mabi-float=soft. + - Gazell/ESB: Fixed set_mode() functionality. + - Gazell GCC board examples startup and run correctly with the GCC libraries. + - A Gazell Device nows stop the RSSI measurement when no ACK is received, improving the base current consumption. + +Known issues: + + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYSTEM_OFF before flashing a new application. + + ANT + - NRFFOETT-438 - Documentation on S210 SoftDevice API wrongly structured. All SoftDevice functions appear as SVCALL in the Doxygen page. + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOETT-399 - The bond manager will use distrubted IRK in its whitelist regardless of the type of central's address and should actually use the irk if distributed and if the central's address is not public, and not random_static and not random_private_non_resovable. + - NRFFOSDK-1432 - A buffer overflow has been discovered in the BLE bond manager upon system attributes store. Workaround, define BLE_BONDMNGR_MAX_BONDED_MASTERS in ble_bondmngr_cfg.h to be 1 higher than the number of bond required by the applicaiton. + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + + Proprietary: + - Not all examples have makefiles, nor have they been tested with the new toolchain. Expect minor compilation issues. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 4.2.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.60 + - N51422 QFAACA on PCA10003 evaluation kit board + - N51822 QFAACA on PCA10004/5 module on nRF6310 motherboard + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - BLE SoftDevice Version : s110_nrf51822_5.1.0 + +Changes: + + ANT + + BLE + - NRFFOSDK-623 - BLE S110 DFU Bootloader prototype added to experimental folder. + - NRFFOSDK-996 - Delete of individual bonds in Bond Manager. API extension. + Validity check of stored bond added to Bond Manager API. + - NRFFOSDK-745 - Extended BLE S110 Serialized API. + Added serialized Heartrate example to exprimental folder. + + Proprietary + +Fixed issues: + + - NRFFOSDK-1015 - nRFgo Display lock up after a reset + + ANT + + BLE + - NRFFOSDK-486 - All applications using bond manager will assert when the maximum number of bonded masters is passed. + + Proprietary + +Known issues: + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + + + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYTEM_OFF before flashing a new application. + + ANT + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + + Proprietary: + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 4.1.0 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.60 + - N51422 QFAACA on PCA10003 evaluation kit board + - N51822 QFAACA on PCA10004/5 module on nRF6310 motherboard + - Windows XP SP3 32 bit + - Windows 7 SP1 64 bit + - BLE SoftDevice Version : s110_nrf51822_5.0.0 + +Changes: + - nRF51 device variant removed from KEIL device database and replaced with nRF51 series specific devices. + - Added nrf6310_experimental folder to the nRF51 SDK which contains examples and modules under development. + - Experimental version of the SoftDevice S110 serialization API with examples. + - Removed obsolete Master Emulator firmware from the release (nrf51822\Board\pca10000\ble\master_emulator\MEFW_nRF51822_firmware.hex). + - Renamed twi_sw_master_example to twi_master_example + ANT + + BLE + - Updated SoftDevice S110 specific documentation to include message sequence charts. + Proprietary + +Fixed issues: + - NRFFOETT-257 - twi_master_clear_bus() functionality fix done. + - NRFFOSDK-953 - twi_hw_master.c functionality fix done. + ANT + + BLE + - NRFFOSDK-758 - Button 1 does not wake up Bluetooth examples applications. To erase bonding information from system-off mode, press both button 0 and button 1. + + Proprietary + +Known issues: + - If you have an existing KEIL project target set to use device variant "nRF51", a pop-up might appear stating that you have to "update your device selection". + Solution: + Press ALT+F7 to open "Options for Target" dialog. + Select "Options for Target" -> "Device". + Choose "Nordic nRF51 Series Devices" from the Database list. + Select the variant of the nRF51 chip that is used for the KEIL project target. + + + - When using J-Link software prior to version 4.66, a warning might appear when entering "Options for Target" -> "Debug" -> "Settings". The warning indicates that the device is unknown to the specific version of the J-Link software. + Solution: Upgrade J-Link software to version 4.66 or later. + + - Segger J-Link software has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines, J-Link CDC installer fails producing an error message saying it could not find JLinkCDCDriver_x86.msi. + Solution: Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled J-Link OB CDC driver installation dialog appears, the error message "Failed to install driver (Timeout occurred)" might appear . Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power. + - NRFFOSDK-363 - Flashing software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + Solution: Wake-up the current application from SYTEM_OFF before flashing a new application. + + ANT + - NRFFOSDK-366 - ANT-FS host: download sometimes fails when downloading a large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized. + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application. + (If the bonding information is not erased manually - by pressing button 1 during start-up - the new application might assert. ) + - NRFFOSDK-486 - All applications using the bond manager will assert when the maximum number of bonded masters is passed. See proximity application documentation. + + Proprietary: + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 4.0.1 +------------------ + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.60 + - N51422 QFAACA on PCA10006 module on nRF6310 motherboard + - N51822 QFAACA on PCA10001 evaluation kit board + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + - BLE SoftDevice Version : s110_nrf51822_4.0.0-2.beta + +Changes: + - Adressed poor search functionality in the documentation by upgrading used Doxygen version and adding a CHM version of the documentation. + Proprietary + - ESB/Gazell: A hard PLL rampdown is now implemented which shortens the TX to RX switching time to match nRF24L devices. + +Fixed issues: + - NRFFOSDK-801 - Project memory layout was incorrect for S110 4.0.0 targets. + - NRFFOETT-249 - gcc_nrf51_s110.ld had wrong SoftDevice size. + + ANT + + BLE + - NRFFOSDK-807 - Made changes to the default assert handler. + - NRFFOSDK-800 - Bug when switching between BLE and Gazell mode on buttons presses fixed. + - NRFFOETT-225 - DTM didn't work with Tescom TC3000C and R&S CBT. + - NRFFOETT-262 - Evaluation kit BLE examples had button pin pullup resistors disabled. + - NRFFOSDK-804 - Excluded ble_sps.c and ble_sps.h from release as they have not been fully implemented. + + Proprietary + - ESB/Gazell: The peripherals are no longer prepared for use by the nrf_esb_init() and nrf_gzll_init() functions. This is performed in the SystemInit() function. + +Known issues: + - Segger JLink has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + On some Windows XP machines JLink CDC installer fails with error message saying it could not find JLinkCDCDriver_x86.msi. + Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51 SDK installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled JLink OB CDC driver installation dialog appears, it might pop up an error saying "Failed to install driver (Timeout occurred)". Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power + - NRFFOSDK-363 - Flashing a software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode (implies to wake-up the current application from SYTEM_OFF before flashing a new application) + + ANT + - NRFFOSDK-366 - ANT-FS host: download some times fails when downloading large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application + If the bonding information are not erased manually - by pressing button 1 during start-up - the new application might assert. + - NRFFOSDK-486 - All applications using bond manager will assert when the maximum number of bonded masters is passed - See proximity application documentation. + - NRFFOSDK-758 - Button 1 does not wake up Bluetooth examples applications. To erase bonding information from system-off mode, press on both button 0 and button 1. + - NRFFOSDK-759 - Unable to switch to BLE mode from gazell mode in Multiprotocol application + + Proprietary: + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v. 4.0.0 +----------------- + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.60 + - N51422 QFAACA on PCA10006 module on nRF6310 motherboard + - N51822 QFAACA on PCA10001 evaluation kit board + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + +Changes: + - NRFFOSDK-192 - Interrupt driven low power UART module added. + - NRFFOSDK-543 - Set of common modules used by nRF51xxx examples added. + + ANT + - NRFFOSDK-312 - adapt to renaming of SoftDevice S210 V2.0.0 APIs + + BLE + - NRFFOSDK-55 - adapt to renaming of SoftDevice S110 V4.0.0 APIs + + +Fixed issues: + - NRFFOSDK-563 - nRF51 SDK installer - Keil CDB not installing correctly on PC's running Win7 w/Asian Locales (prim: Japanese/Chinese). + + ANT + - NRFFOSDK-484 - HRM TX background pages are not following 65th packet rule according to spec + + BLE + - NRFFOSDK-361 - System attributes are stored in flash only after disconnect. API ble_bondmngr_sys_attr_store to save system attributes while in a connection is now available. + + + +Known issues: + - Segger JLink has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + On some Windows XP machines JLink CDC installer fails with error message saying it could not find JLinkCDCDriver_x86.msi. + Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - NRFFOETT-205 - The nRF51822 installer will not run if no C:\ drive exists + - NRFFOSDK-236 - When the bundled JLink OB CDC driver installation dialog appears, it might pop up an error saying "Failed to install driver (Timeout occurred)". Ignore it. + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power + - NRFFOSDK-363 - Flashing a software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode (implies to wake-up the current application from SYTEM_OFF before flashing a new application) + + ANT + - NRFFOSDK-366 - ANT-FS host: download some times fails when downloading large file. + - NRFFOSDK-755 - HRM TX buttons example may report wrong total elapsed time. + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application + If the bonding information are not erased manually - by pressing button 1 during start-up - the new application might assert. + - NRFFOSDK-486 - All applications using bond manager will assert when the maximum number of bonded masters is passed - See proximity application documentation. + - NRFFOSDK-758 - Button 1 does not wake up Bluetooth examples applications. To erase bonding information from system-off mode, press on both button 0 and button 1. + - NRFFOSDK-759 - Unable to switch to BLE mode from gazell mode in Multiprotocol application + + Proprietary: + - ESB/Gazell: Calling nrf_esb_init() or nrf_gzll_init() will disable usage of the GPIOTE peripheral. + + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the + nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the + payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + + - Gazell does not support "Low Power Host mode" (Host mode 1). + +======================================================================== + +nRF51 SDK v3.0.0 +----------------- +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.60 + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + +Changes: + + - Merged nRF514 and nRF518 SDKs + + - system_nrf51.c: GPIOTE peripheral turned on during system init. + + ANT + - Added ANT bicycle power-only sensor example + - Added ANT combined bicycle speed and cadence sensor example + + BLE + - Added Direct Test Mode (DTM) source code + - Added Glucose Meter service and example + - Added Health Thermometer service and example + - Added Blood Pressure service and example + - Added Proximity example for evaluation board + - Bond manager and flash module modified to write bonding information in flash while in a connection + +Fixed issues: + BLE + -NRFFOSDK-120 - ble_bondmngr_store_bonded_masters function from the bond manager cannot be used when advertising nor when in a connection + The bonding information are now written while in a connection but not the system attributes information. + + ANT + - Fixed incorrect event time generation in ANT HRM Tx example + - NRFFOSDK-469 - ANT - bicycle power rx: doxygen architecture picture defect + + - NRFFOSDK-470 - ANT - bicycle power tx: doxygen architecture picture defect + + Proprietary: + - twi_hw_master example : Fixed deadlock when stop condition was not issued. (NRFFOETT-167) + + - Bugfix: Polarity of on-air "no_ack" bit inverted to comply with legacy nRF24L01 + hardware ESB. + + +Known issues: + - Segger JLink has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + On some Windows XP machines JLink CDC installer fails with error message saying it could not find JLinkCDCDriver_x86.msi. + Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + + - NRFFOSDK-236 - When the bundled JLink OB CDC driver installation dialog appears, it might pop up an error saying "Failed to install driver (Timeout occurred)". Ignore it. + + - NRFFOSDK-362 - Reset button won't work after programming without cycling the target power + + - NRFFOSDK-363 - Flashing a software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode + (implies to wake-up the current application from SYTEM_OFF before flashing a new application) + ANT + - ARCH-506 - ANT-FS host; download could fail when downloading large files. + + - NRFFOSDK-484 - HRM TX background pages are not following 65th packet rule according to spec + + BLE + - NRFFOSDK-119 - Only the "....\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\","....\sdk\nrf5822\Board\pca10001\ble\ble_app_proximity\ ", and "....\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ " applications are power optimized + + - NRFFOSDK-361 - System attributes are stored in flash only after disconnect. + + - NRFFOSDK-472 - Bonding information in flash are not erased during programming of a new application + If the bonding information are not erased manually - by pressing button 1 during start-up - the new application might assert. + + - NRFFOSDK-486 - All applications using bond manager will assert when the maximum number of bonded masters is passed + For more information, see proximity application documentation. + + + + Proprietary: + - ESB/Gazell: Calling nrf_esb_init() or nrf_gzll_init() will disable usage of the GPIOTE peripheral. + + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + + - The nRF24Lxx ESB examples found in the legacy nRFready SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + The legacy examples need to add the following in order to work with the + nRF51 examples: + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + In addition, the legacy PTX example must add code for handling the + payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx devices. The timeslot periods and channel tables require adjustment. + + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + + - Gazell does not support "Low Power Host mode" (Host mode 1). + +Notification ANT: + - This is last release that will support N51422 QFAACA (ANT). Next release will contain API changes. + + + + + + +======================================================== +Old release notes from before SDK merge +======================================================== + + +nRF518 SDK v2.0.0 +----------------- + +Following toolchains/devices have been used for testing and verification: + - ARM: MDK-ARM Version 4.60 + - N51822 QFAACA on PCA10000 evaluation kit USB dongle + - N51822 QFAACA on PCA10001 evaluation kit board + - N51822 QFAACA on PCA10004 module on nRF6310 motherboard + - Windows XP SP3 32-bit + - Windows 7 SP1 64-bit + + Bluetooth: + - Bluetooth Low Energy SoftDevice S110_nRF51822_2.0.0_alpha1 + + Gazell / ESB libraries on-air compatible with the following SDKs for legacy nRF24Lxx devices: + - nRFgo SDK 2.3.0 + - nRFready Desktop 1.2.3 + +Changes: + + Bluetooth: + - Adapted examples for updated S110 API (S110_nRF51822_2.0.0_alpha1). + - Added Find Me (Immediate Alert Service as client) to Proximity Application. + - Added Alert Notification (client) service and example. + - Added Cycling Speed and Cadence service and example. + - Added Running Speed and Cadence service and example. + - Bond Manager modified to add Whitelist handling and CRC verification of flash. + - Bond Manager usage added to all examples except for power profiling application. + - Use of Whitelist added to Proximity, HID Mouse and HID Keyboard examples. + - Use of directed advertisement added to HID Mouse and HID Keyboard examples. + - Timer Module refactored. + + Proprietary: + - Added nRF24L series address conversion functions to radio_example. + - Added support for GCC to nRF51 Code Examples, ESB and Gazell examples. + - Examples no longer use deprecated PERPOWER register. + - Disabled "Download to flash" and "Verify Code Download" in JLink debug Download Options. + - All SDK release notes are now in this file. + - Added hardware flow control option to simple_uart. + - Fixed compilation problems with Keil ARM MDK v4.60 and ram retention, temperature and blinky examples. + - debouncer_example, ppi_example and timer_example now explicitly set timer bitmode. + - keil_arm_uv4.lnt include folder changed from C:\Keil\ARM\RV31\INC to C:\Keil\ARM\ARMCC\INC. + - Corrected location of SFR files in UV projects. + + - ESB: ESB PRX transceiver operations are shorted, removing continuous wave transmission and improving speed and current consumption. + - ESB: PRX starts listening immediately after sending an ACK, no longer waiting for the next timeslot. + - ESB: The NOACK bit is changed to an ACK bit to ensure compatibility with L01 radios. The L01 product specification is incorrect, only devices using dynamic ack will see this. + - ESB: esb_is_enabled function added. + - ESB: Disabling CRC checking on PRX/Host side works correctly + - ESB: Added support for controlling the XOSC outside the ESB library + + - Gazell: Added support for controlling the XOSC outside the Gazell library + - GZP: No longer deletes pairing data on gzp_init. Added functions to check if device has pairing data and delete all pairing info from flash. + - GZP: gzp_desktop_emulator example requires only one key press to pair and has been tested to work on SoftDevice. + - GZP: nrf_nvmc_write_bytes correctly iterates through bytes. + +Fixed issues: + - Examples use deprecated PERPOWER register. + + Proprietary: + - When using Keil ARM MDK v4.60 the ram retention, temperature and blinky examples might fail during compilation. + - Gazell and ESB examples point to wrong SFR file (should be SFD\Nordic\nRF51\nRF51822.sfr). + + Bluetooth: + - The buttons on the evaluation board are not debounced. + +Known issues: + - Segger JLink has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. + - On some Windows XP machines JLink CDC installer fails with error message saying it could not find JLinkCDCDriver_x86.msi. + Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. + - When the bundled JLink OB CDC driver installation dialog appears, it might pop up an error saying "Failed to install driver (Timeout occurred)". Ignore it. (DRGN-1807) + - Reset button won't work after programing without cycling the target power. (DRGN-1885) + - Flashing a software using SEGGER is possible only when NOT in SYSTEM_OFF mode (implies to wake-up the current application with a button press for example before flashing a new application).(DRGN-1925) + + Bluetooth: + - Only the ..\sdk\nrf5822\Board\nrf6310\ble\ble_app_pwr_profiling\ and ..\sdk\nrf5822\Board\pca10001\ble\ble_app_hrs\ applications are power optimized.(DRGN-1914) + - ble_bondmngr_store_bonded_masters function from the bond manager cannot be used when advertising nor when in a connection (DRGN-1915) + (flash erase/write prevents the CPU from running which means the stack will not be able to run properly.) + If ble_bondmngr_store_bonded_masters function is called while advertising or in a connection, the behavior is UNDEFINED. + + Proprietary: + - ESB/Gazell: Calling nrf_esb_init() or nrf_gzll_init() will disable usage of the GPIOTE peripheral. In order to use the GPIOTE peripheral, the workaround in PAN 22 must be performed after calling these functions. + - Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. + - Temperature example does not give sane output values. This is hardware related issue described in PAN_028 and will be fixed in future silicon. + + - The nRF24Lxx ESB examples found in the legacy nRFready + SDKs do not work out of the box with the nRF51 ESB examples. This is due to: + - The legacy examples do not use "payload in ACK". + - The legacy examples use RF channel 2 (not 10 as the nRF51 examples). + - The examples do not use dynamic payload length. + + The legacy examples need to add the following in order to work with the + nRF51 examples: + + hal_nrf_setup_dynamic_payload(0xFF); + hal_nrf_enable_dynamic_payload(true); + hal_nrf_enable_ack_payload(true); + hal_nrf_set_rf_channel(10); + + In addition, the legacy PTX example must add code for handling the + payloads received in ACK. + + - The Gazell Link Layer examples are not fully "out of the box" compatible + with the legacy Gazell examples provided in the nRFgo SDK for nRF24Lxx + devices. The timeslot periods and channel tables require adjustment. + - Timeslot period: Edit gzll_params.h file used in the nRF24Lxx projects, + or use the nrf_gzll_set_timeslot_period() function in the nRF51 projects + (nRF51 Gazell timeslot period = 0.5*GZLL_RX_PERIOD). + - Channel table: Edit gzll_params.h file used in the nRF24Lxx projects, + or use the nrf_gzll_set_channel_table() function in the nRF51 projects. + - Gazell does not support "Low Power Host mode" (Host mode 1). + + + + + + + +nRF518 SDK v1.1.1 +----------------- + +Changes: +- Master Control Panel updated to version 3.1.1. Includes fix for issue where pca10000 master emulator devices did not get detected. + +Known issues: +- When the bundled JLink OB CDC driver installation dialog appears, it might pop up an error saying "Failed to install driver (Timeout occurred)". Ignore it. +- When using Keil ARM MDK v4.60 the ram retention, temperature and blinky examples might fail during compilation and leave an error message like this: + C3900U: Unrecognized option '--asm'. + C3900U: Unrecognized option '--interleave'. + To fix this Click Alt+F7, choose "Listing" tab. Uncheck "C Compiler Listing" +- Previous issues from v1.1.0 does still apply + + + + + + + +nRF518 SDK v1.1.0 +----------------- + +Following toolchains/devices have been used for testing and verification: +- ARM: MDK-ARM Version 4.54 +- N51822 QFAACA on PCA10004 module on nRF6310 motherboard +- N51822 QFAACA on PCA10000 USB dongle +- N51822 QFAACA on PCA10001 board +- Windows XP SP3 32-bit +- Windows 7 SP1 64-bit + +Known issues: +- Examples use depracated PERPOWER register. Future silicon will power up peripherals after reset and PERPOWER register will be removed. +- Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. +- Temperature example does not give sane output values. This is hardware related issue described in +- Segger JLink has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. +- On some Windows XP machines JLink CDC installer fails with error message saying it could not find JLinkCDCDriver_x86.msi. + Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. +- Gazell and ESB examples point to wrong SFR file (should be SFD\Nordic\nRF51\nRF51822.sfr). +- Reset button wont work after programing without cycling the target power. Workaround is to update system_nrf51.c with + void SystemInit (void) + { + /* Switch ON both RAM banks */ + NRF_POWER->RESET = POWER_RESET_RESET_Enabled; + NRF_POWER->RAMON |= (POWER_RAMON_ONRAM0_RAM0On << POWER_RAMON_ONRAM0_Pos) | + (POWER_RAMON_ONRAM1_RAM1On << POWER_RAMON_ONRAM1_Pos); + } + +Bluetooth: + - The button on the evaluation board are not debounced in hardware and the application implementing for it does not debounce the button presses either (using software mechanisms). So there will be additional increments/decrements of heart rate measurement while pressing the buttons. + + + + + +nRF518 SDK v1.0.0 +----------------- + +Following toolchains/devices have been used for testing and verification: +- ARM: MDK-ARM Version 4.54 +- N51822 QFAACA on nRF2752 module on nRF6310 motherboard +- Windows XP SP3 32-bit +- Windows 7 SP1 64-bit +Bluetooth: + - S110 SoftDevice v1.0.0 + - J-Link ARM v4.52b or higher + +This release contains the following: +Bluetooth: + - Complete source code needed for writing applications on top of S110 SoftDevice (BLE Stack) + - Template application that can be used as a starting point to develop custom applications. + - Example application for Heart Rate Service + - Example application for Proximity profile + - Example application for HID Mouse + - Example application for HID Keyboard + - Power profiling application + - Example application using Heart Rate Service for Evaluation Board (PCA10001) + - Multiprotocol application that implements the Heart Rate profile in Bluetooth mode and the Gazell 'device' mode. + - Documentation + +Known issues: +- Examples use depracated PERPOWER register. Future silicon will power up peripherals after reset and PERPOWER register will be removed. +- Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. +- Temperature example does not give sane output values. This is hardware related issue described in +- Segger JLink has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. +- On some Windows XP machines JLink CDC installer fails with error message saying it could not find JLinkCDCDriver_x86.msi. + Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. +- Gazell and ESB examples point to wrong SFR file (should be SFD\Nordic\nRF51\nRF51822.sfr). +- Reset button wont work after programing without cycling the target power. Workaround is to update system_nrf51.c with + void SystemInit (void) + { + /* Switch ON both RAM banks */ + NRF_POWER->RESET = POWER_RESET_RESET_Enabled; + NRF_POWER->RAMON |= (POWER_RAMON_ONRAM0_RAM0On << POWER_RAMON_ONRAM0_Pos) | + (POWER_RAMON_ONRAM1_RAM1On << POWER_RAMON_ONRAM1_Pos); + } +- Spi master function spi_master_init() sends two dummy bytes. This will be removed in a future release. +- timer_example nrf_timer_delay_ms() will not give expected results using parameter values over 65 ms. + +Bluetooth: + - The button on the evaluation board are not debounced in hardware and the application implementing for it does not debounce the button presses either (using software mechanisms). So there will be additional increments/decrements of heart rate measurement while pressing the buttons. + + + + +nRF514 SDK v.1.2.0 +------------------ + +Following toolchains/devices have been used for testing and verification: +- ARM: MDK-ARM Version 4.60 +- N51422 QFAACA on PCA10004 module on nRF6310 motherboard +- N51422 QFAACA on PCA10006 module on nRF6310 motherboard +- N51822 QFAACA on nRF2752 module on nRF6310 motherboard +- N51822 QFAACA on PCA10001 evaluation kit board +- Windows XP SP3 32-bit +- Windows 7 SP1 64-bit + +Changes: +- Added Bicycle Power minimal slave example. +- Added Stride and Distance Monitor minimal slave and master example. +- Removed deprecated PERPOWER register from examples and header files. + +Known issues: +- Segger JLink has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. +- On some Windows XP machines JLink CDC installer fails with error message saying it could not find JLinkCDCDriver_x86.msi. + - Try running the installer C:\Program Files\SEGGER\JLinkARM_V\USBDriver\JLinkCDCInstaller_V1.2b.exe manually. +- When the bundled JLink OB CDC driver installation dialog appears, it might pop up an error saying "Failed to install driver (Timeout occurred)". Ignore it. +- Flashing a software using SEGGER is NOT possible when the device is in SYSTEM_OFF mode (implies to wake-up the current application from SYTEM_OFF before flashing a new application) +- Reset button won't work after programming with Keil without cycling the target power. On the other hand if nrfjprog with -p (pin reset) is used to program the device, reset button will work. +- Using -p option in nrfjprog too heavily might block JLink. This block can be resolved by re-cycling the JLink power. + + +nRF514 SDK v1.1.0 +----------------- + +Following toolchains/devices have been used for testing and verification: +- ARM: MDK-ARM Version 4.54 +- N51422 QFAACA on PCA10001 module +- N51422 QFAACA on a PCA10005 modulea on nRF6310 motherboard + +Known issues: +- When having an application which starts up by putting the chip in SystemOff mode, and wakeup source is not configured correctly, the device cannot be programmed. + Workaround: Use nrfjprog with "recover" option to wipe the application keeping the application in SystemOff mode. +- For PCA10003 examples using UART, the terminal program on the PC has to release the COM port when PCA10003 is power cycled. It is not possible for the PCA10003 to keep a connection up when performing a power cycle. + Workaround: Close terminal program for each time you want to perform a power recycle + +Changes: +- Added examples for PCA10003 Evaluation kit. +- Added nrfjprog.exe - Nordic Semiconductor command line nRF51 programming tool using JLink dll's. +- Added custom system_nrf51422.c in templates folder for handling reset after flashing and turning all peripherals on (except GPIOTE) as described in PAN028. +- Removed references to depricated PERPOWER register in ANT code examples. +- Added compiler flag to the ANT examples, to easier being able to run examples without any UART. +- Modified simple_uart_config() parameters. Added new parameters for flow control +- Added include/boards folder for handling examples targeted for different boards +- Fixed bug in timer_example +- Fixed bug in spi_example + + +nRF514 SDK v1.0.0 +----------------- + +Following toolchains/devices have been used for testing and verification: +- ARM: MDK-ARM Version 4.54 +- N51822 QFAACA on nRF2754 module on nRF6310 motherboard +- Tested on Windows 7 64-bit + +Known issues: +- Examples use depracated PERPOWER register. Future silicon will power up peripherals after reset and PERPOWER register will be removed. +- Using Keil versions 4.53 and older will not work unless you change configuration in jlinksettings.ini. See User Guide for more details. +- Temperature example does not give sane output values. This is hardware related issue described in +- Segger JLink has some issues with Keil. See http://www.segger.com/IDE_Integration_Keil.html#knownproblems for more details. +- Reset button wont work after programing without cycling the target power. Workaround is to update system_nrf51.c with + void SystemInit (void) + { + /* Switch ON both RAM banks */ + NRF_POWER->RESET = POWER_RESET_RESET_Enabled; + NRF_POWER->RAMON |= (POWER_RAMON_ONRAM0_RAM0On << POWER_RAMON_ONRAM0_Pos) | + (POWER_RAMON_ONRAM1_RAM1On << POWER_RAMON_ONRAM1_Pos); + } +- Spi master function spi_master_init() sends two dummy bytes. This will be removed in a future release. +- timer_example nrf_timer_delay_ms() will not give expected results using parameter values over 65 ms. + +Changes: +- First public release + diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/license.txt b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/license.txt new file mode 100644 index 000000000..03042d903 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/license.txt @@ -0,0 +1 @@ +For details on licenses, see .\documentation\licenses.txt or .\documentation\licenses.html. diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/CHANGELOG.md b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/CHANGELOG.md new file mode 100644 index 000000000..22c076cb3 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/CHANGELOG.md @@ -0,0 +1,300 @@ +# Changelog +All notable changes to this project are documented in this file. + +## [1.9.0] - 2021-07-15 +### Added +- Added high-drive pin configuration in the QSPI driver. +- Added report period setting of 1 sample in the QDEC HAL. + +### Changed +- Updated MDK to version 8.40.3. + +### Fixed +- Fixed register access sequence in the COMP driver. +- Fixed memory corruption when uninitialized channel was freed in the GPIOTE driver. +- Fixed a race condition in the NFCT driver when starting the transfer. + +## [1.8.6] - 2020-08-31 +### Added +- Implemented workaround for anomaly 223 in the USBD driver. + +### Changed +- Updated MDK to version 8.35.0. + +## [1.8.5] - 2020-07-09 +### Added +- Implemented workaround for anomaly 211 in the USBD driver. + +### Changed +- Updated MDK to version 8.32.3. + +## [1.8.4] - 2020-04-27 +- Fixed an issue in the NFCT driver where the FIELDDETECTED event would be ignored and the FIELDLOST event would be processed twice. The driver now properly handles FIELDDETECTED and FIELDLOST events. + +## [1.8.3] - 2020-03-20 +### Added +- Added documentation pages for nRF52820. +- Added possibility to use the nRF52833 DK in development for nRF52820. LEDs and buttons in this DK use GPIOs that are not present in the actual nRF52820 device, so accesses to these need special handling in the GPIO HAL. + +### Fixed +- Fixed assertions that check input pin selections in the legacy SAADC driver. Now the VDDHDIV5 setting is handled properly. +- Fixed the number of machine cycles per single delay loop for nRF52820 in the nrfx_coredep module. + +## [1.8.2] - 2020-03-05 +### Added +- Added support for nRF52820. +- Added new implementation of the SAADC driver. The new version is enabled when the NRFX_SAADC_API_V2 symbol is defined, otherwise the legacy one is used. +- Introduced the NRFX_TWIM_NO_SPURIOUS_STOP_CHECK flag in the TWIM driver. +- Added function for getting the configuration of shortcuts in the TWIM HAL. +- Implemented workaround for nRF9160 anomaly 23 in the UARTE driver. + +### Changed +- Updated MDK to version 8.32.1. +- Improved the UARTE driver to consume less current after the driver uninitialization. Now all clocks are disabled properly. +- Improved the GPIOTE driver robustness by setting the LATCH functionality to be used by default. +- Improved handling of spurious STOP condition in the TWIM driver. +- Removed support for revision Engineering A of nRF52840 in the USBD driver. + +### Fixed +- Fixed assertions that check write addresses in the NVMC driver. Now the UICR memory region is handled properly. +- Fixed an issue in the TWI driver that would make the driver stuck when a premature STOP condition was generated by a slave device. The driver now handles this situation properly and signals that a bus error occurred. +- Fixed the stopping procedure in the PWM driver. Previously in very specific circumstances the PWM output might be not stopped at all or might be immediately restarted. +- Fixed a race condition in the CLOCK driver when requested clock was stopped during ramp-up from high priority interrupt. +- Fixed assertions that check pin numbers in the GPIO HAL and GPIOTE driver. Now noncontiguous groups of available pin numbers are handled properly. + +## [1.8.1] - 2019-10-21 +### Added +- Added functions in the GPIOTE driver for getting task or event for the specified GPIO pin. + +### Changed +- Updated MDK to version 8.27.1. +- Moved the nrfx_gppi helper from helpers/nrfx_gppi/ to helpers/. +- Changed the interrupt initialization in the GPIOTE driver, so that mapping of the GPIOTEx_IRQn enumeration values is no longer needed for nRF9160. + +## [1.8.0] - 2019-08-27 +### Added +- Added support for nRF52833. +- Added bus recovery feature in the TWI and TWIM drivers. +- Added the nrfx_gppi helper layer to facilitate developing generic code that can utilize PPI or DPPI, depending on which interface is available in a given SoC. + +### Changed +- Updated MDK to version 8.27.0. + +### Fixed +- Fixed an issue in the TWIM driver that would make the driver stuck when a premature STOP condition was generated by a slave device. The driver now handles this situation properly and signals that a bus error occurred. +- Fixed a frame timing bug in the NFCT driver. Previously, the timing of the SENS_RES response could be violated after the NFCT peripheral was put to the Sleep state with the SLP_REQ command. + +## [1.7.2] - 2019-07-25 +### Added +- Added functions in the DPPI, GPIOTE, PPI, RTC, and TIMER HALs for getting tasks and events specified by index. +- Added the possibility of suspending transfers in the TWI driver. This allows combining several transfers into one continuous TWI transaction. +- Added termination of transfers at deinitialization of the UARTE driver. +- Added buffer alignment checks in the QSPI driver. +- Introduced the NRFX_OFFSETOF macro that duplicates the functionality of the built-in offsetof() mechanism, but can be used without issues also with non-constant expressions. +- Added an alternative way of ending the DMA transfer loop in the USBD driver. +- Added the CTSTARTED and CTSTOPPED events to the CLOCK HAL. + +### Changed +- Removed an assertion that prevented setting the data payload size of isochronous endpoints to zero, to fulfill requirements of the USB 2.0 specification, paragraph 5.6.3. +- Declared the tx_buffer_length field in the UART driver's control block as volatile to prevent issues in case of compilation with high optimization level. + +### Fixed +- Fixed an incorrect conversion of frequency values in the RADIO HAL. +- Fixed an incorrectly enabled interrupt in the QSPI driver. +- Corrected the LFCLK source selection values in the template configuration file for nRF9160. +- Fixed support for external LFCLK sources for nRF52811. + +## [1.7.1] - 2019-04-08 +### Added +- Added functions in the NVMC driver for getting the flash page size, the count of pages and the total flash size. + +### Fixed +- Fixed handling of short unaligned write requests (1 or 2 bytes in length) in the nrfx_nvmc_bytes_write() function. + +## [1.7.0] - 2019-03-29 +### Added +- Added drivers for NVMC and TEMP. +- Added HALs: AAR and FICR. +- Added support for the custom instruction long frame mode in the QSPI driver. + +### Changed +- Reworked HAL for NVMC. Now it can be used for all SoCs supported by nrfx. +- Reworked HAL for TEMP. +- Improved documentation. Now it is more precise and can be generated without warnings with newer versions of doxygen. +- Improved the UARTE driver to consume less current after the TX operation. Now at the end of the transmission the transmitter is turned off by the STOPTX task. +- Improved C++ support in drivers. Now fields in structures are filled up in the correct order. +- Changed to size_t the type used for holding the amount of data in the TWIS driver. + +### Fixed +- Fixed a race condition in the USBD driver. It could occur when an IN transfer was interrupted by an OUT transaction, which in turn was interrupted by a process with a higher priority. + +## [1.6.2] - 2019-02-12 +### Added +- Added the possibility to use the macro NRFX_COREDEP_DELAY_US_LOOP_CYCLES to specify the number of cycles consumed by one iteration of the internal loop in the function nrfx_coredep_delay_us(). + +### Changed +- Updated MDK to version 8.24.1. + +## [1.6.1] - 2019-01-29 +### Fixed +- Fixed an issue in the NFCT driver that caused a performance loss on nRF52832. The interrupt configuration is now properly restored after the NRFX_NFCT_EVT_FIELD_LOST event. + +## [1.6.0] - 2019-01-18 +### Added +- Added support for nRF52811. +- Added support for the legacy peripherals SPI, TWI, and UART in nRF52810. +- Added support for SAMPLERATE in nrf_saadc.h. +- Added clearing of the STOPPED event in the nrfx_saadc_init() function to prevent driver deadlock in some cases. +- Added HALs: BPROT, MPU, MWU. +- Added function for reading the pin input buffer configuration in the GPIO HAL. +- Implemented workaround for nRF9160 anomaly 1 in the I2S driver. + +### Changed +- Improved handling of hardware anomalies in the USBD driver. +- Updated MDK to version 8.23.1. + +### Fixed +- Fixed the condition in NRFX_WAIT_FOR in the nrfx_saadc_abort() function. The macro now correctly waits for a stop of the driver. +- Fixed the pending interrupt clearing in NVIC in the nrfx_usbd_stop() function. The driver now correctly handles power management. +- Fixed the case when nrfx_uarte_tx_in_progress() function would return an incorrect value. The driver now correctly updates the tx_buffer_length variable internally. + +## [1.5.0] - 2018-12-12 +### Added +- Added support for nRF9160. +- Added allocator for DPPI. +- Added HALs: DPPI, KMU, REGULATORS, SPU, VMC. +- Added support for DPPI subscription and publishing in HALs related to nRF9160. +- Added support for instances 2 and 3 in SPIS, TWIM, TWIS, and UARTE drivers. + +### Changed +- Updated MDK to version 8.21.1. + +### Fixed +- Corrected NRFX_I2S_CONFIG_RATIO value in nrfx_config.h. It now correctly uses supported value. + +## [1.4.0] - 2018-11-30 +### Added +- Added the nrfx_is_word_aligned() function for checking whether an address is word-aligned. +- Added HAL for ACL. +- Added functions for disabling and re-enabling interrupts in the SWI driver. +- Added possibility to completely remove interrupt handling from the WDT driver. + +### Changed +- Updated the documentation for the nrfx_uarte_rx() function. It now correctly reflects the actual behavior of the function. + +### Fixed +- Corrected the type of the nrfx_uarte_xfer_evt_t structure field that holds the amount of transferred bytes. +- Corrected the way of disabling interrupts in the NFCT driver when moving the peripheral to the disabled state. +- Fixed a typo in the name of the bmRequest field in the nrfx_usbd_setup_t structure. The new correct name is bRequest. +- Fixed the nrfx_ppi_channel_fork_assign() function. It now accepts also pre-programmed channels. +- Fixed handling of long custom instruction responses in the QSPI driver. +- Fixed a bug affecting the conversion of time to ticks in the TIMER HAL. + +## [1.3.1] - 2018-09-28 +### Fixed +- Corrected the type of nrfx_usbd_ep_status_get() return value. +- Corrected calls to undefined macros in NFCT and USBD drivers. + +## [1.3.0] - 2018-09-21 +### Added +- Added HAL and driver for NFCT. +- Added driver for USBD. +- Added function for setting the burst mode in the SAADC HAL. +- Added the NRFX_ARRAY_SIZE macro. + +### Changed +- Moved the implementation of nrfx_power_clock_irq_handler() to nrfx_power.c, removed nrfx_power_clock.c. + +### Fixed +- Replaced ARRAY_SIZE macro calls with NRFX_ARRAY_SIZE ones. + +## [1.2.0] - 2018-09-06 +### Added +- Added function for checking if a specific channel is enabled in the GPIOTE HAL. +- Added support for using the QDEC driver without LED. +- Added functions for modifying only the event endpoint or only the task endpoint in the PPI HAL. +- Added function for reading the pin pull configuration in the GPIO HAL. + +### Changed +- Corrected ISOSPLIT enumerator names in the USBD HAL. + +### Fixed +- Fixed a double buffering bug that occurred in the UARTE driver after the RX abort. +- Fixed the TXRX transfers in the TWIM driver. They can now be started after transfers that are not ended with the stop condition. + +## [1.1.0] - 2018-06-15 +### Added +- Implemented workaround for nRF52832 and nRF52840 anomaly 194 in the I2S driver. +- Implemented workaround for nRF52840 anomaly 195 in the SPIM driver. +- Added HALs for CCM, ECB, and RADIO. +- Extended HALs for GPIO, PPI, SAADC, and USBD. +- Added support for external LFCLK sources. + +### Changed +- Corrected handling of transfer lengths in the TWI driver. +- Updated MDK to version 8.17.0. + +### Fixed +- Fixed logging in the PPI driver. +- Fixed SPIM interrupt definition for nRF52810. +- Fixed Slave Select configuration in the SPIM driver. +- Corrected default settings for NRF_SPIM3. +- Fixed a typo in the UARTE TXDRDY event definition. +- Corrected the TIMEOUT event clearing in the WDT interrupt handler. + +## [1.0.0] - 2018-03-21 +### Added +- Added the NRFX_WAIT_FOR macro to improve the time-out functionality in QSPI and SAADC drivers. +- Added glue layer macros for checking and modifying the pending status of interrupts. +- Added new enumeration values for interrupts and events in the UARTE HAL. +- Implemented workarounds for nRF52 anomalies 192 and 201 in the CLOCK driver. +- Implemented workaround for nRF52840 anomaly 122 in the QSPI driver. +- Implemented workaround for nRF52840 anomaly 198 in the SPIM driver. + +### Changed +- Updated MDK to 8.16.0. +- Extended input pin configuration in the GPIOTE driver. +- Unified the way of checking if a required event handler was provided. Now, all drivers do it with assertions. +- Changed the RNG bias correction configuration option to be enabled by default. +- Refactored the ADC driver and HAL. +- Corrected assertions in the TIMER driver to make it usable in debug version with PPI. +- Improved buffer handling in the I2S driver. The API of the driver has been slightly modified. +- Enhanced SPIS driver API: added the "p_context" parameter, allowed NULL pointers for zero-length buffers. + +### Fixed +- Fixed result value casting in the TEMP HAL. +- Fixed types of conversion result and buffer size in the ADC HAL and driver. +- Fixed time-out in the SAADC driver in abort function. + +## [0.8.0] - 2017-12-20 +### Added +- Added XIP support in the QSPI driver. +- Implemented Errata 132 in the CLOCK driver. +- Added function for checking if a TIMER instance is enabled. +- Added extended SPIM support. + +### Changed +- Updated MDK to 8.15.0. Introduced Segger Embedded Studio startup files. +- Updated drivers: COMP, PWM, QDEC, SAADC, SPIS, TIMER, TWI, TWIS. +- Changed the type used for transfer lengths to 'size_t' in drivers: SPI, SPIM, SPIS, TWI, TWIM, TWIS, UART, UARTE. Introduced checking of EasyDMA transfers limits. +- Updated HALs: COMP, NVMC, UART, UARTE, USBD. +- Updated template files and documentation of configuration options. + +### Fixed +- Fixed TWI and TWIM drivers so that they now support GPIOs from all ports. +- Fixed definitions related to compare channels in the TIMER HAL. + +### Removed +- Removed the possibility of passing NULL instead of configuration to get default settings during drivers initialization. +- Removed support for UART1 and PRS box #5. + +## [0.7.0] - 2017-10-20 +### Added +- This CHANGELOG.md file. +- README.md file with simple description and explanations. +- HAL for: ADC, CLOCK, COMP, ECB, EGU, GPIO, GPIOTE, I2S, LPCOMP, NVMC, PDM, POWER, PPI, PWM, QDEC, QSPI, RNG, RTC, SAADC, SPI, SPIM, SPIS, ARM(R) SysTick, TEMP, TIMER, TWI, TWIM, TWIS, UART, UARTE, USBD, WDT. +- Drivers for: ADC, CLOCK, COMP, GPIOTE, I2S, LPCOMP, PDM, POWER, PWM, QDEC, QSPI, RNG, RTC, SAADC, SPI, SPIM, SPIS, ARM(R) SysTick, TIMER, TWI, TWIM, TWIS, UART, UARTE, WDT. +- Allocators for: PPI, SWI/EGU. +- MDK in version 8.14.0. +- Offline documentation for every added driver and simple integration description. +- Template integration files. diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/LICENSE b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/LICENSE new file mode 100644 index 000000000..7d58b8ae9 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/LICENSE @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/README.md b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/README.md new file mode 100644 index 000000000..397f9d29a --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/README.md @@ -0,0 +1,45 @@ +# nrfx + +## Overview + +nrfx is a standalone set of drivers for peripherals present in Nordic +Semiconductor's SoCs. It originated as an extract from the nRF5 SDK. +The intention was to provide drivers that can be used in various environments +without the necessity to integrate other parts of the SDK into them. +For the user's convenience, the drivers come with the MDK package. This package +contains definitions of register structures and bitfields for all supported +SoCs, as well as startup and initialization files for them. + +## Supported SoCs + +* nRF51 Series +* nRF52810 +* nRF52811 +* nRF52820 +* nRF52832 +* nRF52833 +* nRF52840 +* nRF9160 + +## Directories + +``` + . + ├── doc # Project documentation files + ├── drivers # nrfx driver files + │ └── include # nrfx driver headers + │ └── src # nrfx driver sources + ├── hal # Hardware Access Layer files + ├── helpers # nrfx driver helper files + ├── mdk # nRF MDK files + ├── soc # SoC specific files + └── templates # Templates of nrfx integration files +``` + +## Generating documentation + +nrfx documentation is available in the `doc\html` folder of the release package. + +You can also generate documentation yourself from the source code. To do it, install doxygen +and run one of the scripts: `generate_html_doc.bat` or `generate_html_doc.sh`. Generated +documentation will be stored in the `doc\html` directory. Use `index.html` to open it. diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/compiler_abstraction.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/compiler_abstraction.h new file mode 100644 index 000000000..061a61aff --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/compiler_abstraction.h @@ -0,0 +1,264 @@ +/* + +Copyright (c) 2010 - 2021, Nordic Semiconductor ASA + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form, except as embedded into a Nordic + Semiconductor ASA integrated circuit in a product or a software update for + such product, must reproduce the above copyright notice, this list of + conditions and the following disclaimer in the documentation and/or other + materials provided with the distribution. + +3. Neither the name of Nordic Semiconductor ASA nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +4. This software, with or without modification, must only be used with a + Nordic Semiconductor ASA integrated circuit. + +5. Any software provided in binary form under this license must not be reverse + engineered, decompiled, modified and/or disassembled. + +THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef _COMPILER_ABSTRACTION_H +#define _COMPILER_ABSTRACTION_H + +/*lint ++flb "Enter library region" */ + +#ifndef NRF_STRING_CONCATENATE_IMPL + #define NRF_STRING_CONCATENATE_IMPL(lhs, rhs) lhs ## rhs +#endif +#ifndef NRF_STRING_CONCATENATE + #define NRF_STRING_CONCATENATE(lhs, rhs) NRF_STRING_CONCATENATE_IMPL(lhs, rhs) +#endif + +#if defined ( __CC_ARM ) + + #ifndef __ASM + #define __ASM __asm + #endif + + #ifndef __INLINE + #define __INLINE __inline + #endif + + #ifndef __WEAK + #define __WEAK __weak + #endif + + #ifndef __ALIGN + #define __ALIGN(n) __align(n) + #endif + + #ifndef __PACKED + #define __PACKED __packed + #endif + + #ifndef __UNUSED + #define __UNUSED __attribute__((unused)) + #endif + + #define GET_SP() __current_sp() + + #ifndef NRF_STATIC_ASSERT + #define NRF_STATIC_ASSERT(cond, msg) \ + ;enum { NRF_STRING_CONCATENATE(static_assert_on_line_, __LINE__) = 1 / (!!(cond)) } + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + + #ifndef __ASM + #define __ASM __asm + #endif + + #ifndef __INLINE + #define __INLINE __inline + #endif + + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + + #ifndef __ALIGN + #define __ALIGN(n) __attribute__((aligned(n))) + #endif + + #ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) + #endif + + #ifndef __UNUSED + #define __UNUSED __attribute__((unused)) + #endif + + #define GET_SP() __current_sp() + + #ifndef NRF_STATIC_ASSERT + #ifdef __cplusplus + #ifndef _Static_assert + #define _Static_assert static_assert + #endif + #endif + #define NRF_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) + #endif + +#elif defined ( __ICCARM__ ) + + #ifndef __ASM + #define __ASM __asm + #endif + + #ifndef __INLINE + #define __INLINE inline + #endif + + #ifndef __WEAK + #define __WEAK __weak + #endif + + #if (__VER__ >= 8000000) + #ifndef __ALIGN + #define __ALIGN(n) __attribute__((aligned(x))) + #endif + + #ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) + #endif + #else + #ifndef __ALIGN + #define STRING_PRAGMA(x) _Pragma(#x) + #define __ALIGN(n) STRING_PRAGMA(data_alignment = n) + #endif + + #ifndef __PACKED + #define __PACKED __packed + #endif + #endif + + #ifndef __UNUSED + #define __UNUSED + #endif + + #define GET_SP() __get_SP() + + #ifndef NRF_STATIC_ASSERT + #define NRF_STATIC_ASSERT(cond, msg) static_assert(cond, msg) + #endif + +#elif defined ( __GNUC__ ) || defined ( __clang__ ) + + #ifndef __ASM + #define __ASM __asm + #endif + + #ifndef __INLINE + #define __INLINE inline + #endif + + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + + #ifndef __ALIGN + #define __ALIGN(n) __attribute__((aligned(n))) + #endif + + #ifndef __PACKED + #define __PACKED __attribute__((packed)) + #endif + + #ifndef __UNUSED + #define __UNUSED __attribute__((unused)) + #endif + + #define GET_SP() gcc_current_sp() + + static inline unsigned int gcc_current_sp(void) + { + unsigned int stack_pointer = 0; + __asm__ __volatile__ ("mov %0, sp" : "=r"(stack_pointer)); + return stack_pointer; + } + + #ifndef NRF_STATIC_ASSERT + #ifdef __cplusplus + #ifndef _Static_assert + #define _Static_assert static_assert + #endif + #endif + #define NRF_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) + #endif + +#elif defined ( __TASKING__ ) + + #ifndef __ASM + #define __ASM __asm + #endif + + #ifndef __INLINE + #define __INLINE inline + #endif + + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + + #ifndef __ALIGN + #define __ALIGN(n) __align(n) + #endif + + /* Not defined for TASKING. */ + #ifndef __PACKED + #define __PACKED + #endif + + #ifndef __UNUSED + #define __UNUSED __attribute__((unused)) + #endif + + #define GET_SP() __get_MSP() + + #ifndef NRF_STATIC_ASSERT + #define NRF_STATIC_ASSERT(cond, msg) static_assert(cond, msg) + #endif + +#endif + +#define NRF_MDK_VERSION_ASSERT_AT_LEAST(major, minor, micro) \ + NRF_STATIC_ASSERT( \ + ( \ + (major < MDK_MAJOR_VERSION) || \ + (major == MDK_MAJOR_VERSION && minor < MDK_MINOR_VERSION) || \ + (major == MDK_MAJOR_VERSION && minor == MDK_MINOR_VERSION && micro < MDK_MICRO_VERSION) \ + ), "MDK version mismatch.") + +#define NRF_MDK_VERSION_ASSERT_EXACT(major, minor, micro) \ + NRF_STATIC_ASSERT( \ + ( \ + (major != MDK_MAJOR_VERSION) || \ + (major != MDK_MAJOR_VERSION) || \ + (major != MDK_MAJOR_VERSION) \ + ), "MDK version mismatch.") + +/*lint --flb "Leave library region" */ + +#endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h new file mode 100644 index 000000000..7c21b14fd --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h @@ -0,0 +1,198 @@ +/* + +Copyright (c) 2010 - 2021, Nordic Semiconductor ASA + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form, except as embedded into a Nordic + Semiconductor ASA integrated circuit in a product or a software update for + such product, must reproduce the above copyright notice, this list of + conditions and the following disclaimer in the documentation and/or other + materials provided with the distribution. + +3. Neither the name of Nordic Semiconductor ASA nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +4. This software, with or without modification, must only be used with a + Nordic Semiconductor ASA integrated circuit. + +5. Any software provided in binary form under this license must not be reverse + engineered, decompiled, modified and/or disassembled. + +THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef NRF_H +#define NRF_H + +/* MDK version */ +#define MDK_MAJOR_VERSION 8 +#define MDK_MINOR_VERSION 40 +#define MDK_MICRO_VERSION 3 + + +/* Define coprocessor domains */ +#if defined (NRF5340_XXAA_APPLICATION) || defined (NRF5340_XXAA_NETWORK) + #ifndef NRF5340_XXAA + #define NRF5340_XXAA + #endif +#endif +#if defined (NRF5340_XXAA_APPLICATION) + #ifndef NRF_APPLICATION + #define NRF_APPLICATION + #endif +#endif +#if defined (NRF5340_XXAA_NETWORK) + #ifndef NRF_NETWORK + #define NRF_NETWORK + #endif +#endif + +/* Apply compatibility macros for old nRF5340 macros */ +#if defined(NRF5340_XXAA) + #if defined (NRF_APPLICATION) + #ifndef NRF5340_XXAA_APPLICATION + #define NRF5340_XXAA_APPLICATION + #endif + #endif + #if defined (NRF_NETWORK) + #ifndef NRF5340_XXAA_NETWORK + #define NRF5340_XXAA_NETWORK + #endif + #endif +#endif + +/* Define NRF51_SERIES for common use in nRF51 series devices. Only if not previously defined. */ +#if defined (NRF51) ||\ + defined (NRF51422_XXAA) ||\ + defined (NRF51422_XXAB) ||\ + defined (NRF51422_XXAC) ||\ + defined (NRF51801_XXAB) ||\ + defined (NRF51802_XXAA) ||\ + defined (NRF51822_XXAA) ||\ + defined (NRF51822_XXAB) ||\ + defined (NRF51822_XXAC) ||\ + defined (NRF51824_XXAA) + #ifndef NRF51_SERIES + #define NRF51_SERIES + #endif + #ifndef NRF51 + #define NRF51 + #endif +#endif + +/* Redefine "old" too-generic name NRF52 to NRF52832_XXAA to keep backwards compatibility. */ +#if defined (NRF52) + #ifndef NRF52832_XXAA + #define NRF52832_XXAA + #endif +#endif + +/* Define NRF52_SERIES for common use in nRF52 series devices. Only if not previously defined. */ +#if defined (NRF52805_XXAA) || defined (NRF52810_XXAA) || defined (NRF52811_XXAA) || defined (NRF52820_XXAA) || defined (NRF52832_XXAA) || defined (NRF52832_XXAB) || defined (NRF52833_XXAA) || defined (NRF52840_XXAA) + #ifndef NRF52_SERIES + #define NRF52_SERIES + #endif +#endif + +/* Define NRF53_SERIES for common use in nRF53 series devices. */ +#if defined (NRF5340_XXAA) + #ifndef NRF53_SERIES + #define NRF53_SERIES + #endif +#endif + +/* Define NRF91_SERIES for common use in nRF91 series devices. */ +#if defined (NRF9160_XXAA) + #ifndef NRF91_SERIES + #define NRF91_SERIES + #endif +#endif + +/* Device selection for device includes. */ +#if defined (NRF51) + #include "nrf51.h" + #include "nrf51_bitfields.h" + #include "nrf51_deprecated.h" + +#elif defined (NRF52805_XXAA) + #include "nrf52805.h" + #include "nrf52805_bitfields.h" + #include "nrf51_to_nrf52810.h" + #include "nrf52_to_nrf52810.h" + #include "nrf52810_to_nrf52811.h" +#elif defined (NRF52810_XXAA) + #include "nrf52810.h" + #include "nrf52810_bitfields.h" + #include "nrf51_to_nrf52810.h" + #include "nrf52_to_nrf52810.h" + #include "nrf52810_name_change.h" +#elif defined (NRF52811_XXAA) + #include "nrf52811.h" + #include "nrf52811_bitfields.h" + #include "nrf51_to_nrf52810.h" + #include "nrf52_to_nrf52810.h" + #include "nrf52810_to_nrf52811.h" +#elif defined (NRF52820_XXAA) + #include "nrf52820.h" + #include "nrf52820_bitfields.h" + #include "nrf51_to_nrf52.h" + #include "nrf52_to_nrf52833.h" + #include "nrf52833_to_nrf52820.h" +#elif defined (NRF52832_XXAA) || defined (NRF52832_XXAB) + #include "nrf52.h" + #include "nrf52_bitfields.h" + #include "nrf51_to_nrf52.h" + #include "nrf52_name_change.h" +#elif defined (NRF52833_XXAA) + #include "nrf52833.h" + #include "nrf52833_bitfields.h" + #include "nrf52_to_nrf52833.h" + #include "nrf51_to_nrf52.h" +#elif defined (NRF52840_XXAA) + #include "nrf52840.h" + #include "nrf52840_bitfields.h" + #include "nrf51_to_nrf52840.h" + #include "nrf52_to_nrf52840.h" + +#elif defined (NRF5340_XXAA) + #if defined(NRF_APPLICATION) + #include "nrf5340_application.h" + #include "nrf5340_application_bitfields.h" + #include "nrf5340_application_name_change.h" + #elif defined (NRF_NETWORK) + #include "nrf5340_network.h" + #include "nrf5340_network_bitfields.h" + #include "nrf5340_network_name_change.h" + #endif + +#elif defined (NRF9160_XXAA) + #include "nrf9160.h" + #include "nrf9160_bitfields.h" + #include "nrf9160_name_change.h" + +#else + #error "Device must be defined. See nrf.h." +#endif /* NRF51, NRF52805_XXAA, NRF52810_XXAA, NRF52811_XXAA, NRF52820_XXAA, NRF52832_XXAA, NRF52832_XXAB, NRF52833_XXAA, NRF52840_XXAA, NRF5340_XXAA_APPLICATION, NRF5340_XXAA_NETWORK, NRF9160_XXAA */ + +#include "compiler_abstraction.h" + +#endif /* NRF_H */ + From 2f089e14f240b46890db161df42f958452d86c19 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Fri, 24 Jun 2022 11:06:04 +0900 Subject: [PATCH 08/52] Support bluetooth on nrf52832 externals/nrf52/: Modify for Spresense. sdk/modules/bluetooth/: Add nrf52. --- externals/nrf52/Kconfig | 27 + externals/nrf52/LibIncludes.mk | 56 + externals/nrf52/Library.mk | 40 + externals/nrf52/Make.defs | 39 + externals/nrf52/Makefile | 64 + .../components/libraries/queue/nrf_queue.c | 23 +- .../components/libraries/queue/nrf_queue.h | 2 +- .../components/libraries/util/app_error.h | 118 +- .../components/libraries/util/app_util.h | 2 + .../libraries/util/app_util_platform.h | 204 +- .../components/libraries/util/sdk_common.h | 4 +- .../application/hal/ser_app_hal_nrf5x.c | 114 +- .../hal/ser_app_power_system_off.c | 4 - .../application/transport/ser_sd_transport.c | 28 +- .../transport/ser_softdevice_handler.c | 98 +- .../common/transport/ser_hal_transport.c | 27 +- .../common/transport/ser_phy/ser_phy_uart.c | 705 +- .../components/softdevice/common/nrf_sdh.c | 118 +- .../softdevice/common/nrf_sdh_ble.c | 121 +- .../softdevice/s132/headers/ble_gattc.h | 2 + .../config/nrf52832/config/sdk_config.h | 12719 +--------------- .../modules/nrfx/mdk/nrf.h | 2 +- sdk/configs/device/nrf52/defconfig | 4 + sdk/configs/examples/ble_peripheral/defconfig | 1 - sdk/modules/bluetooth/Makefile | 4 + sdk/modules/bluetooth/bluetooth_hal_init.c | 4 + sdk/modules/bluetooth/hal/Kconfig | 1 + sdk/modules/bluetooth/hal/nrf52/Kconfig | 30 + sdk/modules/bluetooth/hal/nrf52/Make.defs | 65 + sdk/modules/bluetooth/hal/nrf52/ble_comm.c | 2733 ++++ .../bluetooth/hal/nrf52/ble_comm_internal.h | 203 + sdk/modules/bluetooth/hal/nrf52/ble_gap.c | 1092 ++ sdk/modules/bluetooth/hal/nrf52/ble_gattc.c | 459 + sdk/modules/bluetooth/hal/nrf52/ble_gatts.c | 328 + .../hal/nrf52/ble_storage_operations.c | 403 + .../hal/nrf52/ble_storage_operations.h | 159 + .../hal/nrf52/include/ble/ble_comm.h | 266 + .../bluetooth/hal/nrf52/include/ble/ble_gap.h | 1033 ++ .../hal/nrf52/include/ble/ble_gattc.h | 338 + .../hal/nrf52/include/ble/ble_gatts.h | 320 + .../bluetooth/hal/nrf52/include/bt/bt_comm.h | 1004 ++ sdk/modules/bluetooth/hal/nrf52/nrf52_hal.c | 136 + sdk/modules/bluetooth/hal/nrf52/queue.h | 851 ++ sdk/modules/include/bluetooth/bluetooth.h | 5 + 44 files changed, 10357 insertions(+), 13599 deletions(-) create mode 100644 externals/nrf52/Kconfig create mode 100644 externals/nrf52/LibIncludes.mk create mode 100644 externals/nrf52/Library.mk create mode 100644 externals/nrf52/Make.defs create mode 100644 externals/nrf52/Makefile create mode 100644 sdk/configs/device/nrf52/defconfig create mode 100644 sdk/modules/bluetooth/hal/nrf52/Kconfig create mode 100644 sdk/modules/bluetooth/hal/nrf52/Make.defs create mode 100644 sdk/modules/bluetooth/hal/nrf52/ble_comm.c create mode 100644 sdk/modules/bluetooth/hal/nrf52/ble_comm_internal.h create mode 100644 sdk/modules/bluetooth/hal/nrf52/ble_gap.c create mode 100644 sdk/modules/bluetooth/hal/nrf52/ble_gattc.c create mode 100644 sdk/modules/bluetooth/hal/nrf52/ble_gatts.c create mode 100644 sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.c create mode 100644 sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.h create mode 100644 sdk/modules/bluetooth/hal/nrf52/include/ble/ble_comm.h create mode 100644 sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gap.h create mode 100644 sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gattc.h create mode 100644 sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gatts.h create mode 100644 sdk/modules/bluetooth/hal/nrf52/include/bt/bt_comm.h create mode 100644 sdk/modules/bluetooth/hal/nrf52/nrf52_hal.c create mode 100644 sdk/modules/bluetooth/hal/nrf52/queue.h diff --git a/externals/nrf52/Kconfig b/externals/nrf52/Kconfig new file mode 100644 index 000000000..8905f268b --- /dev/null +++ b/externals/nrf52/Kconfig @@ -0,0 +1,27 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config EXTERNALS_NRF52 + bool "NRF52 Libraries" + depends on BLUETOOTH_NRF52 + default n + ---help--- + Enable NRF52 Libraries. + from https://www.nordicsemi.com/Products/Development-software/nRF5-SDK/Download + For details, see https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_sdk%2Fstruct%2Fsdk_nrf5_latest.html . + +if EXTERNALS_NRF52 + +choice + prompt "nRF52xxx & Soft Device" + default EXTERNALS_NRF52_S132 + +config EXTERNALS_NRF52_S132 + bool "Select nRF52832 & SoftDevice S132" + +endchoice + +endif # EXTERNALS_NRF52 + diff --git a/externals/nrf52/LibIncludes.mk b/externals/nrf52/LibIncludes.mk new file mode 100644 index 000000000..a09637dc2 --- /dev/null +++ b/externals/nrf52/LibIncludes.mk @@ -0,0 +1,56 @@ +############################################################################ +# externals/nrf52/LibIncludes.mk +# +# Copyright 2022 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Semiconductor Solutions Corporation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +BLEDIR := $(SDKDIR)$(DELIM)modules$(DELIM)bluetooth$(DELIM)hal$(DELIM)nrf52 + +BLE_IGNORE_DIR := "*s132*" +BLE_API_VERSION := 7 + +ifeq ($(CONFIG_EXTERNALS_NRF52),y) +CFLAGS += -DBLE_STACK_SUPPORT_REQD -DNRF_SD_BLE_API_VERSION=$(BLE_API_VERSION) -DSVCALL_AS_NORMAL_FUNCTION -DBLE_SUPPORT_BLE5 -std=c99 +CFLAGS += -DBLE_ENABLE_NORDIC_ORIGINAL +endif + +ifeq ($(CONFIG_EXTERNALS_NRF52),y) +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560"} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common"} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers"} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars"} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util"} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue"} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log"} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk"} +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config"} +endif diff --git a/externals/nrf52/Library.mk b/externals/nrf52/Library.mk new file mode 100644 index 000000000..7b8bc19c6 --- /dev/null +++ b/externals/nrf52/Library.mk @@ -0,0 +1,40 @@ +############################################################################ +# externals/nrf52/Library.mk +# +# Copyright 2022 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Semiconductor Solutions Corporation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_EXTERNALS_NRF52),y) + EXTRA_LIBPATHS += -L "$(EXTLIBDIR)$(DELIM)nrf52" + EXTRA_LIBS += -lnrf52 +endif + diff --git a/externals/nrf52/Make.defs b/externals/nrf52/Make.defs new file mode 100644 index 000000000..dba38f934 --- /dev/null +++ b/externals/nrf52/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# nrf52/Make.defs +# +# Copyright 2022 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Semiconductor Solutions Corporation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_EXTERNALS_NRF52),y) +CONFIGURED_APPS += nrf52 +endif + diff --git a/externals/nrf52/Makefile b/externals/nrf52/Makefile new file mode 100644 index 000000000..2c0fb6b84 --- /dev/null +++ b/externals/nrf52/Makefile @@ -0,0 +1,64 @@ +############################################################################ +# externals/nrf52/Makefile +# +# Copyright 2022 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Semiconductor Solutions Corporation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(APPDIR)/Make.defs +-include $(SDKDIR)/Make.defs + +BIN = libnrf52$(LIBEXT) + +NRF52_ROOT = nRF5_SDK_17.1.0_ddde560 + + +NRF52_SER_DIRS := $(shell find $(NRF52_ROOT)/components/serialization -type d) +NRF52_SD_DIRS := $(shell find $(NRF52_ROOT)/components/softdevice -type d) +NRF52_MOD_DIRS := $(shell find $(NRF52_ROOT)/modules -type d) + +#NRF52_DIRS := $(NRF52_SER_DIRS) $(NRF52_SD_DIRS) $(NRF52_MOD_DIRS) + +NRF52_DIRS := $(shell find $(NRF52_ROOT) -type d) +NRF52_SRCS := $(foreach dir, $(NRF52_DIRS), $(wildcard $(dir)/*.c)) +NRF52_OBJS := $(NRF52_SRCS:.c=.o) + +CSRCS := $(NRF52_SRCS) +CFLAGS += -DBLE_STACK_SUPPORT_REQD -DNRF_SD_BLE_API_VERSION=$(BLE_API_VERSION) -DSVCALL_AS_NORMAL_FUNCTION -DBLE_SUPPORT_BLE5 -std=c99 +CFLAGS += -DBLE_ENABLE_NORDIC_ORIGINAL +CFLAGS += -DNOT_USE_NRF_SECTION + +CFLAGS += $(addprefix "-I", $(NRF52_DIRS)) + +VPATH := $(NRF52_DIRS) +ROOTDEPPATH := $(foreach dir,$(NRF52_DIRS), --dep-path $(dir)) + +include $(APPDIR)/Application.mk diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c index 03ae7aad3..e6e490ff8 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c @@ -42,15 +42,18 @@ #include "nrf_queue.h" #include "app_util_platform.h" -#if NRF_QUEUE_CONFIG_LOG_ENABLED - #define NRF_LOG_LEVEL NRF_QUEUE_CONFIG_LOG_LEVEL - #define NRF_LOG_INIT_FILTER_LEVEL NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - #define NRF_LOG_INFO_COLOR NRF_QUEUE_CONFIG_INFO_COLOR - #define NRF_LOG_DEBUG_COLOR NRF_QUEUE_CONFIG_DEBUG_COLOR +//#define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define NRF_LOG_INST_WARNING printf +#define NRF_LOG_INST_DEBUG(...) #else - #define NRF_LOG_LEVEL 0 -#endif // NRF_QUEUE_CONFIG_LOG_ENABLED -#include "nrf_log.h" +#define NRF_LOG_INST_WARNING(...) +#define NRF_LOG_INST_DEBUG(...) +#endif + +#define __STATIC_INLINE static __inline + NRF_SECTION_DEF(nrf_queue, nrf_queue_t); @@ -394,8 +397,6 @@ size_t nrf_queue_in(nrf_queue_t const * p_queue, ASSERT(p_queue != NULL); ASSERT(p_data != NULL); - size_t req_element_count = element_count; - if (element_count == 0) { return 0; @@ -502,7 +503,7 @@ size_t nrf_queue_out(nrf_queue_t const * p_queue, ASSERT(p_queue != NULL); ASSERT(p_data != NULL); - size_t req_element_count = element_count; + //size_t req_element_count = element_count; if (element_count == 0) { diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h index 5d94938f1..8c5962606 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h @@ -91,7 +91,7 @@ typedef struct #if NRF_QUEUE_CLI_CMDS const char * p_name; //!< Pointer to string with queue name. #endif - NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled). + nrf_log_module_dynamic_data_t * p_log; //!< Pointer to instance of the logger object (Conditionally compiled). } nrf_queue_t; #if NRF_QUEUE_CLI_CMDS diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h index 34dadfa46..c4d54373d 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h @@ -50,137 +50,27 @@ #define APP_ERROR_H__ -#include -#include -#include -#include "nrf.h" -#include "sdk_errors.h" -#include "nordic_common.h" -#include "app_error_weak.h" -#ifdef ANT_STACK_SUPPORT_REQD -#include "ant_error.h" -#endif // ANT_STACK_SUPPORT_REQD - - - #ifdef __cplusplus extern "C" { #endif -#define NRF_FAULT_ID_SDK_RANGE_START (0x00004000) /**< The start of the range of error IDs defined in the SDK. */ - -/**@defgroup APP_ERROR_FAULT_IDS Fault ID types - * @{ */ -#define NRF_FAULT_ID_SDK_ERROR (NRF_FAULT_ID_SDK_RANGE_START + 1) /**< An error stemming from a call to @ref APP_ERROR_CHECK or @ref APP_ERROR_CHECK_BOOL. The info parameter is a pointer to an @ref error_info_t variable. */ -#define NRF_FAULT_ID_SDK_ASSERT (NRF_FAULT_ID_SDK_RANGE_START + 2) /**< An error stemming from a call to ASSERT (nrf_assert.h). The info parameter is a pointer to an @ref assert_info_t variable. */ -/**@} */ - -/**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ERROR. - */ -typedef struct -{ - uint32_t line_num; /**< The line number where the error occurred. */ - uint8_t const * p_file_name; /**< The file in which the error occurred. */ - uint32_t err_code; /**< The error code representing the error that occurred. */ -} error_info_t; - -/**@brief Structure containing info about an error of the type @ref NRF_FAULT_ID_SDK_ASSERT. - */ -typedef struct -{ - uint32_t line_num; /**< The line number where the error occurred. */ - uint8_t const * p_file_name; /**< The file in which the error occurred. */ -} assert_info_t; - -/**@brief Defines required by app_error_handler assembler intructions. - */ -#define APP_ERROR_ERROR_INFO_OFFSET_LINE_NUM (offsetof(error_info_t, line_num)) -#define APP_ERROR_ERROR_INFO_OFFSET_P_FILE_NAME (offsetof(error_info_t, p_file_name)) -#define APP_ERROR_ERROR_INFO_OFFSET_ERR_CODE (offsetof(error_info_t, err_code)) -#define APP_ERROR_ERROR_INFO_SIZE (sizeof(error_info_t)) -#define APP_ERROR_ERROR_INFO_SIZE_ALIGNED_8BYTE \ - ALIGN_NUM(APP_ERROR_ERROR_INFO_SIZE, sizeof(uint64_t)) - - -/**@brief Function for error handling, which is called when an error has occurred. - * - * @param[in] error_code Error code supplied to the handler. - * @param[in] line_num Line number where the handler is called. - * @param[in] p_file_name Pointer to the file name. - */ -void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); - -/**@brief Function for error handling, which is called when an error has occurred. - * - * @param[in] error_code Error code supplied to the handler. - */ -void app_error_handler_bare(ret_code_t error_code); - -/**@brief Function for saving the parameters and entering an eternal loop, for debug purposes. - * - * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. - * @param[in] pc The program counter of the instruction that triggered the fault, or 0 if - * unavailable. - * @param[in] info Optional additional information regarding the fault. Refer to each fault - * identifier for details. - */ -void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info); - -/**@brief Function for logging details of error and flushing logs. - * - * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. - * @param[in] pc The program counter of the instruction that triggered the fault, or 0 if - * unavailable. - * @param[in] info Optional additional information regarding the fault. Refer to each fault - * identifier for details. - */ -void app_error_log_handle(uint32_t id, uint32_t pc, uint32_t info); - - /**@brief Macro for calling error handler function. * * @param[in] ERR_CODE Error code supplied to the error handler. */ -#ifdef DEBUG -#define APP_ERROR_HANDLER(ERR_CODE) \ - do \ - { \ - app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \ - } while (0) -#else -#define APP_ERROR_HANDLER(ERR_CODE) \ - do \ - { \ - app_error_handler_bare((ERR_CODE)); \ - } while (0) -#endif +#define APP_ERROR_HANDLER(ERR_CODE) ((void)(ERR_CODE)) + /**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS. * * @param[in] ERR_CODE Error code supplied to the error handler. */ -#define APP_ERROR_CHECK(ERR_CODE) \ - do \ - { \ - const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \ - if (LOCAL_ERR_CODE != NRF_SUCCESS) \ - { \ - APP_ERROR_HANDLER(LOCAL_ERR_CODE); \ - } \ - } while (0) +#define APP_ERROR_CHECK(ERR_CODE) ((void)(ERR_CODE)) /**@brief Macro for calling error handler function if supplied boolean value is false. * * @param[in] BOOLEAN_VALUE Boolean value to be evaluated. */ -#define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \ - do \ - { \ - const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \ - if (!LOCAL_BOOLEAN_VALUE) \ - { \ - APP_ERROR_HANDLER(0); \ - } \ - } while (0) +#define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) ((void)(BOOLEAN_VALUE)) #ifdef __cplusplus diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h index e56ce964b..201d24587 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h @@ -56,6 +56,8 @@ #include "nordic_common.h" #include "nrf.h" +extern uint32_t __REV(uint32_t val); + #ifdef __cplusplus extern "C" { #endif diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h index 4381d7031..88bdef0bc 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h @@ -49,145 +49,17 @@ #ifndef APP_UTIL_PLATFORM_H__ #define APP_UTIL_PLATFORM_H__ -#include -#include "compiler_abstraction.h" -#include "nrf.h" -#ifdef SOFTDEVICE_PRESENT -#include "nrf_soc.h" -#include "nrf_nvic.h" -#endif -#include "nrf_assert.h" -#include "app_error.h" - #ifdef __cplusplus extern "C" { #endif -#if __CORTEX_M == (0x00U) -#define _PRIO_SD_HIGH 0 -#define _PRIO_APP_HIGH 1 -#define _PRIO_APP_MID 1 -#define _PRIO_SD_LOW 2 -#define _PRIO_APP_LOW_MID 3 -#define _PRIO_APP_LOW 3 -#define _PRIO_APP_LOWEST 3 -#define _PRIO_THREAD 4 -#elif __CORTEX_M >= (0x04U) -#define _PRIO_SD_HIGH 0 -#define _PRIO_SD_MID 1 -#define _PRIO_APP_HIGH 2 -#define _PRIO_APP_MID 3 -#define _PRIO_SD_LOW 4 -#define _PRIO_APP_LOW_MID 5 -#define _PRIO_APP_LOW 6 -#define _PRIO_APP_LOWEST 7 -#define _PRIO_THREAD 15 -#else - #error "No platform defined" -#endif - - -//lint -save -e113 -e452 -/**@brief The interrupt priorities available to the application while the SoftDevice is active. */ -typedef enum -{ -#ifndef SOFTDEVICE_PRESENT - APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH, /**< Running in Application Highest interrupt level. */ -#else - APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH, /**< Running in Application Highest interrupt level. */ -#endif - APP_IRQ_PRIORITY_HIGH = _PRIO_APP_HIGH, /**< Running in Application High interrupt level. */ -#ifndef SOFTDEVICE_PRESENT - APP_IRQ_PRIORITY_MID = _PRIO_SD_LOW, /**< Running in Application Middle interrupt level. */ -#else - APP_IRQ_PRIORITY_MID = _PRIO_APP_MID, /**< Running in Application Middle interrupt level. */ -#endif - APP_IRQ_PRIORITY_LOW_MID = _PRIO_APP_LOW_MID, /**< Running in Application Middle Low interrupt level. */ - APP_IRQ_PRIORITY_LOW = _PRIO_APP_LOW, /**< Running in Application Low interrupt level. */ - APP_IRQ_PRIORITY_LOWEST = _PRIO_APP_LOWEST, /**< Running in Application Lowest interrupt level. */ - APP_IRQ_PRIORITY_THREAD = _PRIO_THREAD /**< Running in Thread Mode. */ -} app_irq_priority_t; -//lint -restore - - -/*@brief The privilege levels available to applications in Thread Mode */ -typedef enum -{ - APP_LEVEL_UNPRIVILEGED, - APP_LEVEL_PRIVILEGED -} app_level_t; - -/**@cond NO_DOXYGEN */ -#define EXTERNAL_INT_VECTOR_OFFSET 16 -/**@endcond */ - -/**@brief Macro for setting a breakpoint. - */ -#if defined(__GNUC__) -#define NRF_BREAKPOINT __asm__("BKPT 0"); -#else -#define NRF_BREAKPOINT __BKPT(0) -#endif - -/** @brief Macro for setting a breakpoint. - * - * If it is possible to detect debugger presence then it is set only in that case. - * - */ -#if __CORTEX_M == 0x04 -#define NRF_BREAKPOINT_COND do { \ - /* C_DEBUGEN == 1 -> Debugger Connected */ \ - if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) \ - { \ - /* Generate breakpoint if debugger is connected */ \ - NRF_BREAKPOINT; \ - } \ - }while (0) -#else -#define NRF_BREAKPOINT_COND NRF_BREAKPOINT -#endif // __CORTEX_M == 0x04 - -#if defined ( __CC_ARM ) -#define PACKED(TYPE) __packed TYPE -#define PACKED_STRUCT PACKED(struct) -#elif defined ( __GNUC__ ) -#define PACKED __attribute__((packed)) -#define PACKED_STRUCT struct PACKED -#elif defined (__ICCARM__) -#define PACKED_STRUCT __packed struct -#endif - -#if defined ( __CC_ARM ) -#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma ("push") \ - _Pragma ("O3") -#define PRAGMA_OPTIMIZATION_FORCE_END _Pragma ("pop") -#elif defined ( __GNUC__ ) -#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma("GCC push_options") \ - _Pragma ("GCC optimize (\"Os\")") -#define PRAGMA_OPTIMIZATION_FORCE_END _Pragma ("GCC pop_options") -#elif defined (__ICCARM__) -#define PRAGMA_OPTIMIZATION_FORCE_START _Pragma ("optimize=high z") -#define PRAGMA_OPTIMIZATION_FORCE_END -#endif - - -void app_util_critical_region_enter (uint8_t *p_nested); -void app_util_critical_region_exit (uint8_t nested); - /**@brief Macro for entering a critical region. * * @note Due to implementation details, there must exist one and only one call to * CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located * in the same scope. */ -#ifdef SOFTDEVICE_PRESENT -#define CRITICAL_REGION_ENTER() \ - { \ - uint8_t __CR_NESTED = 0; \ - app_util_critical_region_enter(&__CR_NESTED); -#else -#define CRITICAL_REGION_ENTER() app_util_critical_region_enter(NULL) -#endif +#define CRITICAL_REGION_ENTER sched_lock /**@brief Macro for leaving a critical region. * @@ -195,79 +67,7 @@ void app_util_critical_region_exit (uint8_t nested); * CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located * in the same scope. */ -#ifdef SOFTDEVICE_PRESENT -#define CRITICAL_REGION_EXIT() \ - app_util_critical_region_exit(__CR_NESTED); \ - } -#else -#define CRITICAL_REGION_EXIT() app_util_critical_region_exit(0) -#endif - -/* Workaround for Keil 4 */ -#ifndef IPSR_ISR_Msk -#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ -#endif - - - -/**@brief Macro to enable anonymous unions from a certain point in the code. - */ -#if defined(__CC_ARM) - #define ANON_UNIONS_ENABLE _Pragma("push") \ - _Pragma("anon_unions") \ - struct semicolon_swallower -#elif defined(__ICCARM__) - #define ANON_UNIONS_ENABLE _Pragma("language=extended") \ - struct semicolon_swallower -#else - #define ANON_UNIONS_ENABLE struct semicolon_swallower - // No action will be taken. - // For GCC anonymous unions are enabled by default. -#endif - -/**@brief Macro to disable anonymous unions from a certain point in the code. - * @note Call only after first calling @ref ANON_UNIONS_ENABLE. - */ -#if defined(__CC_ARM) - #define ANON_UNIONS_DISABLE _Pragma("pop") \ - struct semicolon_swallower -#elif defined(__ICCARM__) - #define ANON_UNIONS_DISABLE struct semicolon_swallower - // for IAR leave anonymous unions enabled -#else - #define ANON_UNIONS_DISABLE struct semicolon_swallower - // No action will be taken. - // For GCC anonymous unions are enabled by default. -#endif - -/**@brief Macro for adding pragma directive only for GCC. - */ -#ifdef __GNUC__ -#define GCC_PRAGMA(v) _Pragma(v) -#else -#define GCC_PRAGMA(v) -#endif - -/* Workaround for Keil 4 */ -#ifndef CONTROL_nPRIV_Msk -#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ -#endif - -/**@brief Function for finding the current interrupt level. - * - * @return Current interrupt level. See @ref app_irq_priority_t for values. - */ -uint8_t current_int_priority_get(void); - - -/**@brief Function for finding out the current privilege level. - * - * @return Current privilege level. - * @retval APP_LEVEL_UNPRIVILEGED We are running in unprivileged level. - * @retval APP_LEVEL_PRIVILEGED We are running in privileged level. - */ -uint8_t privilege_level_get(void); - +#define CRITICAL_REGION_EXIT sched_unlock #ifdef __cplusplus } diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h index 84ed1a4d3..8d96a5d74 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h @@ -56,10 +56,10 @@ #include "sdk_config.h" #include "nordic_common.h" #include "compiler_abstraction.h" -#include "sdk_os.h" +//#include "sdk_os.h" #include "sdk_errors.h" #include "app_util.h" -#include "sdk_macros.h" +//#include "sdk_macros.h" #ifdef __cplusplus extern "C" { diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c index e5f25f69e..b285952f5 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c @@ -37,127 +37,45 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +#include +#include +#include + #include "app_util_platform.h" #include "ser_app_hal.h" #include "nrf.h" -#include "nrf_gpio.h" +//#include "nrf_gpio.h" #include "nrf_soc.h" -#include "nrf_delay.h" -#include "nrf_nvmc.h" -#include "boards.h" +//#include "nrf_delay.h" +//#include "nrf_nvmc.h" +//#include "boards.h" #include "ser_phy.h" -#include "ser_phy_config_app.h" -#include "nrf_drv_clock.h" - -#define SOFTDEVICE_EVT_IRQ SD_EVT_IRQn /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */ -#define FLASH_WRITE_MAX_LENGTH ((uint16_t)NRF_FICR->CODEPAGESIZE) -#define BLE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE) /**< Size of one flash page. */ +//#include "ser_phy_config_app.h" +//#include "nrf_drv_clock.h" -static ser_app_hal_flash_op_done_handler_t m_flash_op_handler; +//static ser_app_hal_flash_op_done_handler_t m_flash_op_handler; uint32_t ser_app_hal_hw_init(ser_app_hal_flash_op_done_handler_t handler) { - nrf_gpio_cfg_output(CONN_CHIP_RESET_PIN_NO); - - if (NRF_SUCCESS != nrf_drv_clock_init()) - { - return NRF_ERROR_INTERNAL; - } - - nrf_drv_clock_lfclk_request(NULL); - nrf_drv_clock_hfclk_request(NULL); - - while (false == nrf_drv_clock_hfclk_is_running()); - while (false == nrf_drv_clock_lfclk_is_running()); - - m_flash_op_handler = handler; - return NRF_SUCCESS; } void ser_app_hal_delay(uint32_t ms) { - nrf_delay_ms(ms); -} - -void ser_app_hal_nrf_reset_pin_clear() -{ - nrf_gpio_pin_clear(CONN_CHIP_RESET_PIN_NO); -} - -void ser_app_hal_nrf_reset_pin_set() -{ - nrf_gpio_pin_set(CONN_CHIP_RESET_PIN_NO); -} - -void ser_app_hal_nrf_evt_irq_priority_set() -{ - NVIC_SetPriority(SOFTDEVICE_EVT_IRQ, APP_IRQ_PRIORITY_LOWEST); -} - -void ser_app_hal_nrf_evt_pending() -{ - NVIC_SetPendingIRQ(SOFTDEVICE_EVT_IRQ); + usleep(ms * 1000); } -uint32_t sd_ppi_channel_enable_get(uint32_t * p_channel_enable) +void ser_app_hal_nrf_reset_pin_clear(void) { - *p_channel_enable = NRF_PPI->CHEN; - return NRF_SUCCESS; } -uint32_t sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk) -{ - NRF_PPI->CHEN = channel_enable_set_msk; - return NRF_SUCCESS; -} - -uint32_t sd_ppi_channel_assign(uint8_t channel_num, - const volatile void * evt_endpoint, - const volatile void * task_endpoint) -{ - NRF_PPI->CH[channel_num].TEP = (uint32_t)task_endpoint; - NRF_PPI->CH[channel_num].EEP = (uint32_t)evt_endpoint; - return NRF_SUCCESS; -} -/** - * @brief Check if given address is in device FLASH range. - * - * @param[in] ptr Address to check. - * @retval true Given address is located in FLASH. - * @retval false Given address is not located in FLASH. - */ -__STATIC_INLINE bool addr_is_in_FLASH(void const * const ptr) +void ser_app_hal_nrf_reset_pin_set(void) { - return ((((uintptr_t)ptr) & 0xFF000000u) == 0x00000000u); } -uint32_t sd_flash_page_erase(uint32_t page_number) +void ser_app_hal_nrf_evt_irq_priority_set(void) { - uint32_t * p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_number); - - if (!addr_is_in_FLASH(p_page)) - { - return NRF_ERROR_INVALID_ADDR; - } - - nrf_nvmc_page_erase((uint32_t) p_page); - m_flash_op_handler(true); - return NRF_SUCCESS; } -uint32_t sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size) +void ser_app_hal_nrf_evt_pending(void) { - if (size > FLASH_WRITE_MAX_LENGTH) - { - return NRF_ERROR_INVALID_LENGTH; - } - - if (!addr_is_in_FLASH(p_dst)) - { - return NRF_ERROR_INVALID_ADDR; - } - - nrf_nvmc_write_words((uint32_t) p_dst, p_src, size); - m_flash_op_handler(true); - return NRF_SUCCESS; } diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c index 7d0a3a6bb..03b162b2c 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c @@ -55,8 +55,4 @@ bool ser_app_power_system_off_get(void) void ser_app_power_system_off_enter(void) { - NRF_POWER->SYSTEMOFF = POWER_SYSTEMOFF_SYSTEMOFF_Enter; - - /*Only for debugging purpose, will not be reached without connected debugger*/ - while (1); } diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c index 67efc317e..2eb8eb98a 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c @@ -45,12 +45,17 @@ #include "nrf_error.h" #include "app_error.h" #include "ble_serialization.h" -#include "ser_dbg_sd_str.h" +//#include "ser_dbg_sd_str.h" #include "ser_app_power_system_off.h" #include "app_util.h" -#define NRF_LOG_MODULE_NAME ser_xfer -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); + +#define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define NRF_LOG_DEBUG printf +#else +#define NRF_LOG_DEBUG(...) +#endif #ifdef BLE_STACK_SUPPORT_REQD /** SoftDevice event handler. */ @@ -83,6 +88,8 @@ static volatile bool m_rsp_wait = false; /** SoftDevice call return value decoded by user decoder handler. */ static uint32_t m_return_value; +extern volatile bool m_rsp_timeout; + /**@brief Function for handling the rx packets comming from hal_transport. * * @details @@ -133,7 +140,7 @@ static void ser_sd_transport_rx_packet_handler(uint8_t * p_data, uint16_t length #ifdef BLE_STACK_SUPPORT_REQD case SER_PKT_TYPE_EVT: /* It is ensured during opening that handler is not NULL. No check needed. */ - NRF_LOG_DEBUG("[EVT]: %s ", (uint32_t)ser_dbg_sd_evt_str_get(uint16_decode(&p_data[SER_EVT_ID_POS]))); // p_data points to EVT_ID + NRF_LOG_DEBUG("[EVT]: %s \n", "SER_PKT_TYPE_EVT"); // p_data points to EVT_ID m_ble_evt_handler(p_data, length); break; #endif // BLE_STACK_SUPPORT_REQD @@ -313,13 +320,20 @@ uint32_t ser_sd_transport_cmd_write(const uint8_t * p_buffer, } m_os_rsp_wait_handler(); - err_code = m_return_value; + if (m_rsp_timeout) { + m_rsp_wait = false; + NRF_LOG_DEBUG("Timeout\n"); + err_code = NRF_ERROR_TIMEOUT; + } else { + NRF_LOG_DEBUG("Wait END\n"); + err_code = m_return_value; + } } else { m_rsp_wait = false; } - NRF_LOG_DEBUG("[SD_CALL]:%s, err_code= 0x%X", (uint32_t)ser_dbg_sd_call_str_get(p_buffer[1]), err_code); + NRF_LOG_DEBUG("[SD_CALL]:%lx, err_code= 0x%lX", (uint32_t)p_buffer[1], err_code); return err_code; } diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c index f9fc1d5ea..b57464a58 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c @@ -39,8 +39,13 @@ */ #include #include +#include +#include +#include + #include "nrf_queue.h" -#include "app_scheduler.h" +//#include "app_scheduler.h" +#include "app_error.h" #include "nrf_sdh.h" #include "nrf_sdm.h" #include "ser_sd_transport.h" @@ -56,7 +61,25 @@ #include "ant_event.h" #endif +//#define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define NRF_LOG_DEBUG printf +#else +#define NRF_LOG_DEBUG(...) +#endif + #define SD_BLE_EVT_MAILBOX_QUEUE_SIZE 5 /**< Size of mailbox queue. */ +#define SD_BLE_RESPONSE_TIMEOUT 5000 +#define SD_BLE_RESPONSE_TIMEOUT_FLAG 0x01 +#define SD_BLE_EVENT_FLAG 0x10 + +static pthread_t g_rcv_tid; +static int g_rcv_loop; +static void *ble_rcv_evt_task(void *param); +static sem_t evt_sid; +static sem_t rsp_sid; +volatile bool m_rsp_timeout = false; /** @brief Structure used to pass packet details through mailbox. */ @@ -102,11 +125,11 @@ NRF_QUEUE_DEF(uint32_t, /** * @brief Function to be replaced by user implementation if needed. * - * Weak function - user can add different implementation of this function if application needs it. + * function - user can add different implementation of this function if application needs it. */ -__WEAK void os_rsp_set_handler(void) +void os_rsp_set_handler(void) { - + (void)sem_post(&rsp_sid); } static void connectivity_reset_low(void) @@ -144,6 +167,8 @@ static void ser_softdevice_ble_evt_handler(uint8_t * p_data, uint16_t length) APP_ERROR_CHECK(err_code); ser_app_hal_nrf_evt_pending(); + (void)sem_post(&evt_sid); + NRF_LOG_DEBUG("ser_softdevice_ble_evt_handler END\n"); } #endif @@ -183,13 +208,20 @@ void ser_softdevice_flash_operation_success_evt(bool success) */ static void ser_sd_rsp_wait(void) { - do - { - (void)sd_app_evt_wait(); + int ret = 0; + struct timespec time; - //intern_softdevice_events_execute(); + ret = clock_gettime(CLOCK_REALTIME, &time); + if (ret != 0) { + m_rsp_timeout = true; + return; + } + time.tv_sec += (SD_BLE_RESPONSE_TIMEOUT / 1000); + ret = sem_timedwait(&rsp_sid, &time); + if (ret != 0) { + m_rsp_timeout = true; + return; } - while (ser_sd_transport_is_busy()); } uint32_t sd_evt_get(uint32_t * p_evt_id) @@ -256,6 +288,17 @@ uint32_t sd_ble_evt_mailbox_length_get(uint32_t * p_mailbox_length) } #endif +static void *ble_rcv_evt_task(void *args) +{ + while(g_rcv_loop) + { + sem_wait(&evt_sid); + //usleep(100 * 1000); + nrf_sdh_evts_poll(); + } + return NULL; +} + #if (defined(S332) || defined(S212)) uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler, @@ -272,6 +315,8 @@ uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, if (err_code == NRF_SUCCESS) { connectivity_reset_low(); + connectivity_reset_high(); + m_rsp_timeout = false; nrf_queue_reset(&m_sd_soc_evt_mailbox); ser_sd_transport_evt_handler_t ble_evt_handler = NULL; @@ -292,20 +337,49 @@ uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, os_rsp_set_handler, NULL); - if (err_code == NRF_SUCCESS) + if (err_code) { - connectivity_reset_high(); + return err_code; } ser_app_hal_nrf_evt_irq_priority_set(); } + else + { + return err_code; + } - return err_code; + if (sem_init(&evt_sid, 0, 0)) { + return NRF_ERROR_SOFTDEVICE_NOT_ENABLED; + } + + if (sem_init(&rsp_sid, 0, 0)) { + (void)sem_destroy(&evt_sid); + return NRF_ERROR_SOFTDEVICE_NOT_ENABLED; + } + + g_rcv_loop = 1; + err_code = pthread_create(&g_rcv_tid, NULL, ble_rcv_evt_task, NULL); + if (err_code) + { + (void)sem_destroy(&evt_sid); + (void)sem_destroy(&rsp_sid); + return NRF_ERROR_SOFTDEVICE_NOT_ENABLED; + } + + return NRF_SUCCESS; } uint32_t sd_softdevice_disable(void) { + g_rcv_loop = 0; +#ifdef BLE_STACK_SUPPORT_REQD + (void)sem_post(&evt_sid); +#endif + (void)pthread_join(g_rcv_tid, NULL); + (void)sem_destroy(&evt_sid); + (void)sem_destroy(&rsp_sid); return ser_sd_transport_close(); } diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c index 03701c67e..55e835804 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c @@ -44,19 +44,16 @@ #include "ser_config.h" #include "ser_phy.h" #include "ser_hal_transport.h" -#if defined(APP_SCHEDULER_WITH_PAUSE) && APP_SCHEDULER_WITH_PAUSE -#include "app_scheduler.h" +#include "nrf_error.h" + +//#define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define NRF_LOG_INFO printf +#else +#define NRF_LOG_INFO(...) #endif -#define NRF_LOG_MODULE_NAME ser_hal_transport -#if SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - #define NRF_LOG_LEVEL SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - #define NRF_LOG_INFO_COLOR SER_HAL_TRANSPORT_CONFIG_INFO_COLOR - #define NRF_LOG_DEBUG_COLOR SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR -#else //SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - #define NRF_LOG_LEVEL 0 -#endif //SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); + /** * @brief States of the RX state machine. @@ -463,11 +460,15 @@ uint32_t ser_hal_transport_tx_pkt_send(const uint8_t * p_buffer, uint16_t num_of else if (HAL_TRANSP_TX_STATE_TX_ALLOCATED == m_tx_state) { ser_phy_interrupts_disable(); + m_tx_state = HAL_TRANSP_TX_STATE_TRANSMITTING; err_code = ser_phy_tx_pkt_send(p_buffer, num_of_bytes); if (NRF_SUCCESS == err_code) { - m_tx_state = HAL_TRANSP_TX_STATE_TRANSMITTING; + // phy_events_handler in callback_packet_sent is called + // before setting HAL_TRANSP_TX_STATE_TRANSMITTING when + // debug uart enable. + //m_tx_state = HAL_TRANSP_TX_STATE_TRANSMITTING; } else { diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c index ed9f384a0..c87885c4d 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c @@ -37,327 +37,538 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "sdk/config.h" + + #include "ser_phy.h" #include "ser_config.h" #ifdef SER_CONNECTIVITY #include "ser_phy_config_conn.h" #else - #include "ser_phy_config_app.h" +// #include "ser_phy_config_app.h" #endif -#include "nrf_drv_uart.h" +//#include "nrf_drv_uart.h" #include "app_error.h" #include "app_util.h" #include "app_util_platform.h" +#include "nrf_error.h" -#define UART_TRANSFER_MAX 255 - -static const nrf_drv_uart_t m_uart = NRF_DRV_UART_INSTANCE(0); -static const nrf_drv_uart_config_t m_uart_config = { - .pseltxd = SER_PHY_UART_TX, - .pselrxd = SER_PHY_UART_RX, - .pselrts = SER_PHY_UART_RTS, - .pselcts = SER_PHY_UART_CTS, - .p_context = NULL, - .interrupt_priority = UART_IRQ_PRIORITY, -#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART) - .use_easy_dma = true, +//#define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define NRF_LOG_DEBUG printf +#else +#define NRF_LOG_DEBUG(...) #endif - // These values are common for application and connectivity, they are - // defined in "ser_config.h". - .hwfc = SER_PHY_UART_FLOW_CTRL, - .parity = SER_PHY_UART_PARITY, - .baudrate = (nrf_uart_baudrate_t)SER_PHY_UART_BAUDRATE -}; -static bool volatile m_tx_in_progress; -static uint8_t m_tx_header_buf[SER_PHY_HEADER_SIZE]; -static uint16_t m_bytes_to_transmit; -static uint8_t const * mp_tx_buffer; +#define BLE_UART_FILE "/dev/ttyS2" -static uint8_t m_rx_header_buf[SER_PHY_HEADER_SIZE]; -static uint16_t m_bytes_to_receive; -static uint8_t m_rx_drop_buf[1]; +#define FD_SET_UART 0 +#define FD_SET_CTRL 1 -static ser_phy_events_handler_t m_ser_phy_event_handler; -static ser_phy_evt_t m_ser_phy_rx_event; +typedef enum { + CTL_IN = 0, + CTL_OUT, + CTL_MAX +} CTL_FD; +typedef enum { + CTL_CMD_EXIT = 0, + CTL_CMD_MAX +} CTL_CMD; -static void packet_sent_callback(void) +typedef struct { - static ser_phy_evt_t const event = { - .evt_type = SER_PHY_EVT_TX_PKT_SENT, - }; - m_ser_phy_event_handler(event); -} + int uart_fd; + int ctrl_fd[CTL_MAX]; +} UART_CONTEXT; + +static UART_CONTEXT g_ctx; +static pthread_t m_rx_tid = 0; +static uint8_t m_rx_loop = 0; + +static uint8_t * mp_tx_stream; /**< Pointer to Tx data */ +static uint16_t m_tx_stream_length; /**< Length of Tx data including SER_PHY header */ +static uint16_t m_tx_stream_index; /**< Byte index in Tx data */ +static uint8_t m_tx_length_buf[SER_PHY_HEADER_SIZE]; /**< Buffer for header of Tx packet */ + +static uint8_t * mp_rx_stream; /**< Pointer to Rx buffer */ +static uint16_t m_rx_stream_length; /**< Length of Rx data including SER_PHY header*/ +static uint16_t m_rx_stream_index; /**< Byte index in Rx data */ +static uint8_t m_rx_length_buf[SER_PHY_HEADER_SIZE]; /**< Buffer for header of Rx packet */ +static uint8_t m_rx_drop_buf[1]; /**< 1-byte buffer used to trash incoming data */ +static uint8_t m_rx_byte; /**< Rx byte passed from low-level driver */ + +static ser_phy_events_handler_t m_ser_phy_event_handler; /**< Event handler for upper layer */ +static ser_phy_evt_t m_ser_phy_rx_event; /**< Rx event for upper layer notification */ +static ser_phy_evt_t m_ser_phy_tx_event; /**< Tx event for upper layer notification */ -static void buffer_request_callback(uint16_t num_of_bytes) +/** + *@brief Callback for requesting from upper layer memory for an incomming packet. + */ +static __INLINE void callback_mem_request(void) { - m_ser_phy_rx_event.evt_type = SER_PHY_EVT_RX_BUF_REQUEST; - m_ser_phy_rx_event.evt_params.rx_buf_request.num_of_bytes = num_of_bytes; + m_rx_stream_length = uint16_decode(m_rx_length_buf) + SER_PHY_HEADER_SIZE; + m_ser_phy_rx_event.evt_type = SER_PHY_EVT_RX_BUF_REQUEST; + m_ser_phy_rx_event.evt_params.rx_buf_request.num_of_bytes = + m_rx_stream_length - SER_PHY_HEADER_SIZE; + + if (m_ser_phy_event_handler != NULL) + { m_ser_phy_event_handler(m_ser_phy_rx_event); + } } -static void packet_received_callback(void) +/** + *@brief Callback for notifying upper layer that either a packet was succesfully received or it was + * dropped. + */ +static __INLINE void callback_packet_received(void) { +// NRF_LOG_DEBUG("callback_packet_received\n"); + if (mp_rx_stream == m_rx_drop_buf) + { + m_ser_phy_rx_event.evt_type = SER_PHY_EVT_RX_PKT_DROPPED; + NRF_LOG_DEBUG("callback_packet_received : dropped\n"); + } + else + { + m_ser_phy_rx_event.evt_type = SER_PHY_EVT_RX_PKT_RECEIVED; + m_ser_phy_rx_event.evt_params.rx_pkt_received.num_of_bytes = + m_rx_stream_index - SER_PHY_HEADER_SIZE; + m_ser_phy_rx_event.evt_params.rx_pkt_received.p_buffer = + mp_rx_stream; + } + + mp_rx_stream = NULL; + m_rx_stream_length = 0; + m_rx_stream_index = 0; + + if (m_ser_phy_event_handler != NULL) + { m_ser_phy_event_handler(m_ser_phy_rx_event); + } + //NRF_LOG_DEBUG("callback_packet_received END\n"); } -static void packet_dropped_callback(void) +/** + *@brief Function for handling Rx procedure. + */ +static int ser_phy_uart_rx(uint8_t rx_byte) { - static ser_phy_evt_t const event = { - .evt_type = SER_PHY_EVT_RX_PKT_DROPPED, - }; - m_ser_phy_event_handler(event); + int ret = 0; +// NRF_LOG_DEBUG("ser_phy_uart_rx\n"); + + if (mp_rx_stream == NULL ) + { + //Receive length value and request rx buffer from higher layer + if (m_rx_stream_index < SER_PHY_HEADER_SIZE) + { + m_rx_length_buf[m_rx_stream_index++] = rx_byte; + + if (m_rx_stream_index == SER_PHY_HEADER_SIZE) + { + //Request rx buffer from upper layer + callback_mem_request(); + } + } + } + else if (m_rx_stream_index < m_rx_stream_length) + { + //Receive or drop payload + if (mp_rx_stream == m_rx_drop_buf) + { + //Drop incoming data to the one-element drop buffer + *mp_rx_stream = rx_byte; + m_rx_stream_index++; + } + else + { + mp_rx_stream[m_rx_stream_index - SER_PHY_HEADER_SIZE] = rx_byte; + m_rx_stream_index++; + } + } + + //Process RX packet, notify higher layer + if (m_rx_stream_index == m_rx_stream_length) + { + callback_packet_received(); + } +// NRF_LOG_DEBUG("ser_phy_uart_rx END\n"); + return ret; } -static void hardware_error_callback(uint32_t hw_error) +/** + *@brief Poll uart data + */ +static int ser_phy_poll_uart_receive(UART_CONTEXT *ctx) { - ser_phy_evt_t event = { - .evt_type = SER_PHY_EVT_HW_ERROR, - .evt_params.hw_error.error_code = hw_error, + int errcode = 0; + struct pollfd fdSet[] = { + {.fd = ctx->uart_fd, .events = POLLIN, .revents = 0}, + {.fd = ctx->ctrl_fd[CTL_IN], .events = POLLIN, .revents = 0} }; - m_ser_phy_event_handler(event); -} -static void packet_rx_start(void) -{ - APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, m_rx_header_buf, - SER_PHY_HEADER_SIZE)); + do { + errcode = 0; + if (poll(fdSet, (sizeof(fdSet) / sizeof(fdSet[0])), 10) < 0) { + errcode = errno; + NRF_LOG_DEBUG("ser_phy_poll_uart_receive: poll error: %d\n", errcode); + } + + if (fdSet[FD_SET_CTRL].revents & POLLIN) { + NRF_LOG_DEBUG("ctrl event : called\n"); + return 0; + } + if (fdSet[FD_SET_UART].revents & POLLIN) { + //NRF_LOG_DEBUG("event uart\n"); + return 1; + } + + /* Need sleep because this thread has higher priority */ + usleep(5000); + + } while ((EINTR == errcode) || (0 == errcode)); + + return -1; } -static void packet_byte_drop(void) +static int ser_phy_get_ctrl_cmd(UART_CONTEXT *ctx, CTL_CMD *cmd) { - APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, m_rx_drop_buf, 1)); + ssize_t rx_len = 0; + *cmd = CTL_CMD_MAX; + rx_len = read(ctx->ctrl_fd[CTL_IN], cmd, sizeof(CTL_CMD)); + if (rx_len <= 0) + { + NRF_LOG_DEBUG("ser_phy_get_ctrl_cmd: rx_len %d errno %d\n", rx_len, -errno); + return -1; + } + NRF_LOG_DEBUG("read exit value = %d\n", *cmd); + return NRF_SUCCESS; } -static void uart_event_handler(nrf_drv_uart_event_t * p_event, - void * p_context) +static void ser_phy_null_read(UART_CONTEXT *ctx) { - (void)p_context; - - switch (p_event->type) - { - case NRF_DRV_UART_EVT_ERROR: - // Process the error only if this is a parity or overrun error. - // Break and framing errors will always occur before the other - // side becomes active. - if (p_event->data.error.error_mask & - (NRF_UART_ERROR_PARITY_MASK | NRF_UART_ERROR_OVERRUN_MASK)) - { - // Pass error source to upper layer. - hardware_error_callback(p_event->data.error.error_mask); - } - - packet_rx_start(); - break; - - case NRF_DRV_UART_EVT_TX_DONE: - if (p_event->data.rxtx.p_data == m_tx_header_buf) - { -#if (SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE > UART_TRANSFER_MAX) - if (m_bytes_to_transmit > UART_TRANSFER_MAX) - { - APP_ERROR_CHECK(nrf_drv_uart_tx(&m_uart, mp_tx_buffer, - UART_TRANSFER_MAX)); - } - else -#endif // (SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE > UART_TRANSFER_MAX) - { - APP_ERROR_CHECK(nrf_drv_uart_tx(&m_uart, mp_tx_buffer, - m_bytes_to_transmit)); - } - } - else - { -#if (SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE > UART_TRANSFER_MAX) - ASSERT(p_event->data.rxtx.bytes <= m_bytes_to_transmit); - m_bytes_to_transmit -= p_event->data.rxtx.bytes; - if (m_bytes_to_transmit != 0) - { - APP_ERROR_CHECK(nrf_drv_uart_tx(&m_uart, - p_event->data.rxtx.p_data + p_event->data.rxtx.bytes, - m_bytes_to_transmit < UART_TRANSFER_MAX ? - m_bytes_to_transmit : UART_TRANSFER_MAX)); - } - else -#endif // (SER_HAL_TRANSPORT_TX_MAX_PKT_SIZE > UART_TRANSFER_MAX) - { - m_tx_in_progress = false; - packet_sent_callback(); - } - } - break; - - case NRF_DRV_UART_EVT_RX_DONE: - if (p_event->data.rxtx.p_data == m_rx_header_buf) - { - m_bytes_to_receive = uint16_decode(m_rx_header_buf); - buffer_request_callback(m_bytes_to_receive); - } - else if (p_event->data.rxtx.p_data == m_rx_drop_buf) - { - --m_bytes_to_receive; - if (m_bytes_to_receive != 0) - { - packet_byte_drop(); - } - else - { - packet_dropped_callback(); - - packet_rx_start(); - } - } - else - { -#if (SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE > UART_TRANSFER_MAX) - ASSERT(p_event->data.rxtx.bytes <= m_bytes_to_receive); - m_bytes_to_receive -= p_event->data.rxtx.bytes; - if (m_bytes_to_receive != 0) - { - APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, - p_event->data.rxtx.p_data + p_event->data.rxtx.bytes, - m_bytes_to_receive < UART_TRANSFER_MAX ? - m_bytes_to_receive : UART_TRANSFER_MAX)); - } - else -#endif // (SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE > UART_TRANSFER_MAX) - { - packet_received_callback(); - - packet_rx_start(); - } - } - break; - - default: - APP_ERROR_CHECK(NRF_ERROR_INTERNAL); + struct pollfd fdSet[] = { + {.fd = ctx->uart_fd, .events = POLLIN, .revents = 0} + }; + + while (poll(fdSet, (sizeof(fdSet) / sizeof(fdSet[0])), 10) > 0) { + if (fdSet[0].revents & POLLIN) { + read(ctx->uart_fd, &m_rx_byte, 1); + NRF_LOG_DEBUG("ser_phy_null_read: %02X\n", m_rx_byte); + continue; } + } } -/** API FUNCTIONS */ - -uint32_t ser_phy_open(ser_phy_events_handler_t events_handler) +static void *ser_phy_uart_receive(void *param) { - uint32_t err_code; - - if (events_handler == NULL) + ssize_t rx_len = 0; + UART_CONTEXT *ctx = &g_ctx; + int ret = 0; + CTL_CMD cmd; + + NRF_LOG_DEBUG("ser_phy_uart_receive: start\n"); + while (m_rx_loop) + { + ret = ser_phy_poll_uart_receive(ctx); + if (ret == 1) { - return NRF_ERROR_NULL; + rx_len = read(ctx->uart_fd, &m_rx_byte, 1); + if (rx_len <= 0) + + { + NRF_LOG_DEBUG("ser_phy_uart_receive: rx_len %d errno %d\n", rx_len, errno); + } + else + { + ser_phy_uart_rx(m_rx_byte); + } } - - // Check if function was not called before. - if (m_ser_phy_event_handler != NULL) - { - return NRF_ERROR_INVALID_STATE; + else if (ret == 0) { + ret = ser_phy_get_ctrl_cmd(ctx, &cmd); + if ((ret == NRF_SUCCESS) && (CTL_CMD_EXIT == cmd)) + { + NRF_LOG_DEBUG("close uart : %d\n", ctx->uart_fd); + ret = close(ctx->uart_fd); + if (ret) { + NRF_LOG_DEBUG("close uart failed\n"); + } + NRF_LOG_DEBUG("close pipe : %d/%d\n", ctx->ctrl_fd[CTL_IN], ctx->ctrl_fd[CTL_OUT]); + ret = close(ctx->ctrl_fd[CTL_IN]); + if (ret) { + NRF_LOG_DEBUG("close pipe ctrl_in failed\n"); + } + ret = close(ctx->ctrl_fd[CTL_OUT]); + if (ret) { + NRF_LOG_DEBUG("close pipe ctrl_out failed\n"); + } + m_ser_phy_event_handler = NULL; + m_rx_loop = 0; + memset(ctx, 0, sizeof(UART_CONTEXT)); + NRF_LOG_DEBUG("uart pthread exit\n"); + break; + } + else + { + NRF_LOG_DEBUG("uart pthread exit failed\n"); + } } - - err_code = nrf_drv_uart_init(&m_uart, &m_uart_config, uart_event_handler); - if (err_code != NRF_SUCCESS) + else { - return NRF_ERROR_INVALID_PARAM; + NRF_LOG_DEBUG("ser_phy_uart_receive: poll error\n"); } + } - m_ser_phy_event_handler = events_handler; + pthread_exit(0); + return NULL; +} - packet_rx_start(); - return err_code; -} +/** API FUNCTIONS */ -uint32_t ser_phy_tx_pkt_send(const uint8_t * p_buffer, uint16_t num_of_bytes) +uint32_t ser_phy_open(ser_phy_events_handler_t events_handler) { - if (p_buffer == NULL) - { - return NRF_ERROR_NULL; + int errcode = 0; + UART_CONTEXT *ctx = &g_ctx; + int ret = 0; + pthread_attr_t ser_attr; + struct sched_param ser_param; + int prio; + + if (events_handler == NULL) + { + return NRF_ERROR_NULL; + } + + //Check if function was not called before + if (m_ser_phy_event_handler != NULL) + { + return NRF_ERROR_INVALID_STATE; + } + + //Configure UART and register handler + //uart_evt_handler is used to handle events produced by low-level uart driver + m_ser_phy_event_handler = events_handler; + + mp_tx_stream = NULL; + m_tx_stream_length = 0; + m_tx_stream_index = 0; + + mp_rx_stream = NULL; + m_rx_stream_length = 0; + m_rx_stream_index = 0; + + NRF_LOG_DEBUG("ser_phy_open: %s\n", BLE_UART_FILE); + ctx->uart_fd = open(BLE_UART_FILE, O_RDWR); + if (ctx->uart_fd < 0) + { + NRF_LOG_DEBUG("ser_phy_open: open err %d\n", ctx->uart_fd); + return ctx->uart_fd; + } + ser_phy_null_read(ctx); + + ret = pipe(ctx->ctrl_fd); + if (ret) + { + errcode = errno; + NRF_LOG_DEBUG("ser_phy_open: pipe err %d\n", errcode); + (void)close(ctx->uart_fd); + return -errcode; + } + + m_rx_tid = 0; + m_rx_loop = 1; + ret = pthread_attr_init(&ser_attr); + if (!ret) { + ret = pthread_attr_getschedparam(&ser_attr, &ser_param); + } + if (!ret) { +#if defined(CONFIG_BLUETOOTH_NRF52_UART_PRIORITY) + prio = CONFIG_BLUETOOTH_NRF52_UART_PRIORITY; +#else + if (ser_param.sched_priority < sched_get_priority_max(SCHED_FIFO)) { + prio = ser_param.sched_priority + 1; } - else if (num_of_bytes == 0) - { - return NRF_ERROR_INVALID_PARAM; + else { + prio = ser_param.sched_priority; } +#endif + NRF_LOG_DEBUG("ser_phy_open: priority : %d->%d\n", ser_param.sched_priority, prio); + ser_param.sched_priority = prio; + ret = pthread_attr_setschedparam(&ser_attr, &ser_param); + } + if (!ret) { + ret = pthread_create(&m_rx_tid, &ser_attr, ser_phy_uart_receive, NULL); + } + if (ret) + { + errcode = errno; + NRF_LOG_DEBUG("ser_phy_open: pthread_create err %d\n", errcode); + (void)close(ctx->uart_fd); + (void)close(ctx->ctrl_fd[CTL_IN]); + (void)close(ctx->ctrl_fd[CTL_OUT]); + return -errcode; + } + + NRF_LOG_DEBUG("ser_phy_open: success\n"); + return NRF_SUCCESS; +} - bool busy; +/** + *@brief Callback for notifying upper layer that a packet was succesfully transmitted + */ +static __INLINE void callback_packet_sent(void) +{ + mp_tx_stream = NULL; + m_tx_stream_length = 0; + m_tx_stream_index = 0; - CRITICAL_REGION_ENTER(); - busy = m_tx_in_progress; - m_tx_in_progress = true; - CRITICAL_REGION_EXIT(); + m_ser_phy_tx_event.evt_type = SER_PHY_EVT_TX_PKT_SENT; - if (busy) - { - return NRF_ERROR_BUSY; - } + if (m_ser_phy_event_handler != NULL) + { + m_ser_phy_event_handler(m_ser_phy_tx_event); + } +} - (void)uint16_encode(num_of_bytes, m_tx_header_buf); - mp_tx_buffer = p_buffer; - m_bytes_to_transmit = num_of_bytes; - APP_ERROR_CHECK(nrf_drv_uart_tx(&m_uart, m_tx_header_buf, - SER_PHY_HEADER_SIZE)); +static int ser_phy_uart_send_char(uint8_t byte) +{ + ssize_t sent_len = 0; + //NRF_LOG_DEBUG("Send 0x%02x\n", byte); + + int errcode = 0; + UART_CONTEXT *ctx = &g_ctx; + + do + { + sent_len = write(ctx->uart_fd, &byte, 1); + } while (sent_len == 0); + if (sent_len < 0) + { + errcode = errno; + NRF_LOG_DEBUG("ser_phy_uart_send_char: write:err %d\n", errcode); + return -errcode; + } + return NRF_SUCCESS; +} - return NRF_SUCCESS; +static int ser_phy_uart_send(void* buf, int size) +{ + int ret = 0; + int index=0; + NRF_LOG_DEBUG("ser_phy_uart_send size %d\n", size); + + for(index=0; index UART_TRANSFER_MAX) - else if (m_bytes_to_receive > UART_TRANSFER_MAX) - { - APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, p_buffer, UART_TRANSFER_MAX)); - } -#endif // (SER_HAL_TRANSPORT_RX_MAX_PKT_SIZE > UART_TRANSFER_MAX) - else - { - APP_ERROR_CHECK(nrf_drv_uart_rx(&m_uart, p_buffer, m_bytes_to_receive)); - } - - return NRF_SUCCESS; + if (m_ser_phy_rx_event.evt_type != SER_PHY_EVT_RX_BUF_REQUEST) + { + return NRF_ERROR_INVALID_STATE; + } + + if (p_buffer != NULL) + { + mp_rx_stream = p_buffer; + } + else + { + mp_rx_stream = m_rx_drop_buf; + } + + return NRF_SUCCESS; } - void ser_phy_close(void) { - nrf_drv_uart_uninit(&m_uart); - m_ser_phy_event_handler = NULL; -} + UART_CONTEXT *ctx = &g_ctx; + CTL_CMD cmd_exit = CTL_CMD_EXIT; + ssize_t sent_len = 0; + int ret = 0; + + NRF_LOG_DEBUG("ser_phy_close: called\n"); + do + { + sent_len = write(ctx->ctrl_fd[CTL_OUT], &cmd_exit, sizeof(CTL_CMD)); + } while (sent_len == 0); + if (sent_len < 0) + { + NRF_LOG_DEBUG("ser_phy_close: writed err: %d\n", errno); + } + + if (m_rx_tid != 0) { + ret = pthread_join(m_rx_tid, NULL); + if (ret) + { + NRF_LOG_DEBUG("ser_phy_close: pthread_join err: %d\n", errno); + } + } + else { + NRF_LOG_DEBUG("ser_phy_close: pthread_join not created\n"); + } + NRF_LOG_DEBUG("ser_phy_close: end\n"); +} void ser_phy_interrupts_enable(void) { - IRQn_Type irqn; -#if defined(NRF_DRV_UART_WITH_UARTE) - irqn = nrfx_get_irq_number(m_uart.uarte.p_reg); -#else - irqn = nrfx_get_irq_number(m_uart.uart.p_reg); -#endif - NVIC_EnableIRQ(irqn); + /* not needed */ } - void ser_phy_interrupts_disable(void) { - IRQn_Type irqn; -#if defined(NRF_DRV_UART_WITH_UARTE) - irqn = nrfx_get_irq_number(m_uart.uarte.p_reg); -#else - irqn = nrfx_get_irq_number(m_uart.uart.p_reg); -#endif - NVIC_DisableIRQ(irqn); + /* not needed */ } diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c index aff3598ab..3847ca513 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c @@ -46,9 +46,12 @@ #include #include "nrf_sdm.h" -#include "nrf_nvic.h" +//#include "nrf_nvic.h" #include "sdk_config.h" #include "app_error.h" + +#ifndef NOT_USE_NRF_SECTION + #include "app_util_platform.h" @@ -88,11 +91,13 @@ NRF_SECTION_SET_DEF(sdh_state_observers, nrf_sdh_state_observer_t, NRF_SDH_STATE // Create section "sdh_stack_observers". NRF_SECTION_SET_DEF(sdh_stack_observers, nrf_sdh_stack_observer_t, NRF_SDH_STACK_OBSERVER_PRIO_LEVELS); +#endif// NOT_USE_NRF_SECTION static bool m_nrf_sdh_enabled; /**< Variable to indicate whether the SoftDevice is enabled. */ static bool m_nrf_sdh_suspended; /**< Variable to indicate whether this module is suspended. */ static bool m_nrf_sdh_continue; /**< Variable to indicate whether enable/disable process was started. */ +#ifndef NOT_USE_NRF_SECTION /**@brief Function for notifying request observers. * @@ -128,7 +133,6 @@ static ret_code_t sdh_request_observer_notify(nrf_sdh_req_evt_t req) return NRF_SUCCESS; } - /**@brief Function for stage request observers. * * @param[in] evt Type of stage event. @@ -177,6 +181,7 @@ static void softdevice_evt_irq_disable(void) #endif } +#endif// NOT_USE_NRF_SECTION ret_code_t nrf_sdh_enable_request(void) { @@ -189,48 +194,16 @@ ret_code_t nrf_sdh_enable_request(void) m_nrf_sdh_continue = true; - // Notify observers about SoftDevice enable request. - if (sdh_request_observer_notify(NRF_SDH_EVT_ENABLE_REQUEST) == NRF_ERROR_BUSY) - { - // Enable process was stopped. - return NRF_SUCCESS; - } - - // Notify observers about starting SoftDevice enable process. - sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLE_PREPARE); - - nrf_clock_lf_cfg_t const clock_lf_cfg = - { - .source = NRF_SDH_CLOCK_LF_SRC, - .rc_ctiv = NRF_SDH_CLOCK_LF_RC_CTIV, - .rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV, - .accuracy = NRF_SDH_CLOCK_LF_ACCURACY - }; - - CRITICAL_REGION_ENTER(); -#ifdef ANT_LICENSE_KEY - ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler, ANT_LICENSE_KEY); -#else - ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler); -#endif - m_nrf_sdh_enabled = (ret_code == NRF_SUCCESS); - CRITICAL_REGION_EXIT(); - + ret_code = sd_softdevice_enable(NULL, NULL); if (ret_code != NRF_SUCCESS) { return ret_code; } + m_nrf_sdh_enabled = true; m_nrf_sdh_continue = false; m_nrf_sdh_suspended = false; - // Enable event interrupt. - // Interrupt priority has already been set by the stack. - softdevices_evt_irq_enable(); - - // Notify observers about a finished SoftDevice enable process. - sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLED); - return NRF_SUCCESS; } @@ -246,33 +219,15 @@ ret_code_t nrf_sdh_disable_request(void) m_nrf_sdh_continue = true; - // Notify observers about SoftDevice disable request. - if (sdh_request_observer_notify(NRF_SDH_EVT_DISABLE_REQUEST) == NRF_ERROR_BUSY) - { - // Disable process was stopped. - return NRF_SUCCESS; - } - - // Notify observers about starting SoftDevice disable process. - sdh_state_observer_notify(NRF_SDH_EVT_STATE_DISABLE_PREPARE); - - CRITICAL_REGION_ENTER(); ret_code = sd_softdevice_disable(); - m_nrf_sdh_enabled = false; - CRITICAL_REGION_EXIT(); - if (ret_code != NRF_SUCCESS) { return ret_code; } + m_nrf_sdh_enabled = false; m_nrf_sdh_continue = false; - softdevice_evt_irq_disable(); - - // Notify observers about a finished SoftDevice enable process. - sdh_state_observer_notify(NRF_SDH_EVT_STATE_DISABLED); - return NRF_SUCCESS; } @@ -308,7 +263,6 @@ void nrf_sdh_suspend(void) return; } - softdevice_evt_irq_disable(); m_nrf_sdh_suspended = true; } @@ -320,16 +274,6 @@ void nrf_sdh_resume(void) return; } - // Force calling ISR again to make sure that events not previously pulled have been processed. -#ifdef SOFTDEVICE_PRESENT - ret_code_t ret_code = sd_nvic_SetPendingIRQ((IRQn_Type)SD_EVT_IRQn); - APP_ERROR_CHECK(ret_code); -#else - NVIC_SetPendingIRQ((IRQn_Type)SD_EVT_IRQn); -#endif - - softdevices_evt_irq_enable(); - m_nrf_sdh_suspended = false; } @@ -339,6 +283,7 @@ bool nrf_sdh_is_suspended(void) return (!m_nrf_sdh_enabled) || (m_nrf_sdh_suspended); } +#ifndef NOT_USE_NRF_SECTION void nrf_sdh_evts_poll(void) { @@ -359,44 +304,13 @@ void nrf_sdh_evts_poll(void) } } +#else -#if (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_INTERRUPT) - -void SD_EVT_IRQHandler(void) -{ - nrf_sdh_evts_poll(); -} - -#elif (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_APPSH) - -/**@brief Function for polling SoftDevice events. - * - * @note This function is compatible with @ref app_sched_event_handler_t. - * - * @param[in] p_event_data Pointer to the event data. - * @param[in] event_size Size of the event data. - */ -static void appsh_events_poll(void * p_event_data, uint16_t event_size) -{ - UNUSED_PARAMETER(p_event_data); - UNUSED_PARAMETER(event_size); - - nrf_sdh_evts_poll(); -} - - -void SD_EVT_IRQHandler(void) +extern void nrf_sdh_ble_evts_poll(void * p_context); +void nrf_sdh_evts_poll(void) { - ret_code_t ret_code = app_sched_event_put(NULL, 0, appsh_events_poll); - APP_ERROR_CHECK(ret_code); + nrf_sdh_ble_evts_poll(NULL); } - -#elif (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_POLLING) - -#else - -#error "Unknown SoftDevice handler dispatch model." - -#endif // NRF_SDH_DISPATCH_MODEL +#endif // NOT_USE_NRF_SECTION #endif // NRF_MODULE_ENABLED(NRF_SDH) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c index 30c81587c..4e2db2578 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c @@ -47,68 +47,31 @@ #include "app_error.h" #include "nrf_strerror.h" - -#define NRF_LOG_MODULE_NAME nrf_sdh_ble -#if NRF_SDH_BLE_LOG_ENABLED - #define NRF_LOG_LEVEL NRF_SDH_BLE_LOG_LEVEL - #define NRF_LOG_INFO_COLOR NRF_SDH_BLE_INFO_COLOR - #define NRF_LOG_DEBUG_COLOR NRF_SDH_BLE_DEBUG_COLOR +//#define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define NRF_LOG_ERROR printf +#define NRF_LOG_DEBUG printf #else - #define NRF_LOG_LEVEL 0 -#endif // NRF_SDH_BLE_LOG_ENABLED -#include "nrf_log.h" -NRF_LOG_MODULE_REGISTER(); - +#define NRF_LOG_ERROR(...) +#define NRF_LOG_DEBUG(...) +#endif +#ifndef NOT_USE_NRF_SECTION // Create section set "sdh_ble_observers". NRF_SECTION_SET_DEF(sdh_ble_observers, nrf_sdh_ble_evt_observer_t, NRF_SDH_BLE_OBSERVER_PRIO_LEVELS); - - -//lint -save -e10 -e19 -e40 -e27 Illegal character (0x24) -#if defined(__CC_ARM) - extern uint32_t Image$$RW_IRAM1$$Base; - uint32_t const * const m_ram_start = &Image$$RW_IRAM1$$Base; -#elif defined(__ICCARM__) - extern uint32_t __ICFEDIT_region_RAM_start__; - uint32_t const * const m_ram_start = &__ICFEDIT_region_RAM_start__; -#elif defined(__SES_ARM) - extern uint32_t __app_ram_start__; - uint32_t const * const m_ram_start = &__app_ram_start__; -#elif defined(__GNUC__) - extern uint32_t __data_start__; - uint32_t const * const m_ram_start = &__data_start__; #endif -//lint -restore - -#define RAM_START 0x20000000 -#define APP_RAM_START (uint32_t)m_ram_start static bool m_stack_is_enabled; -ret_code_t nrf_sdh_ble_app_ram_start_get(uint32_t * p_app_ram_start) -{ - if (p_app_ram_start == NULL) - { - return NRF_ERROR_NULL; - } - - *p_app_ram_start = APP_RAM_START; - - return NRF_SUCCESS; -} - - ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_start) { uint32_t ret_code; - ret_code = nrf_sdh_ble_app_ram_start_get(p_ram_start); - if (ret_code != NRF_SUCCESS) - { - return ret_code; - } + uint32_t ram_start =0; + p_ram_start = &ram_start; #if defined (S112) || defined(S312) STATIC_ASSERT(NRF_SDH_BLE_CENTRAL_LINK_COUNT == 0, "When using s112, NRF_SDH_BLE_CENTRAL_LINK_COUNT must be 0."); @@ -132,6 +95,7 @@ ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_st { NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GAP.", nrf_strerror_get(ret_code)); + return ret_code; } // Configure the connection roles. @@ -150,6 +114,7 @@ ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_st { NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_GAP_CFG_ROLE_COUNT.", nrf_strerror_get(ret_code)); + return ret_code; } // Configure the maximum ATT MTU. @@ -163,6 +128,7 @@ ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_st { NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GATT.", nrf_strerror_get(ret_code)); + return ret_code; } #endif // NRF_SDH_BLE_GATT_MAX_MTU_SIZE != 23 #endif // NRF_SDH_BLE_TOTAL_LINK_COUNT != 0 @@ -176,6 +142,7 @@ ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_st { NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_COMMON_CFG_VS_UUID.", nrf_strerror_get(ret_code)); + return ret_code; } // Configure the GATTS attribute table. @@ -198,55 +165,16 @@ ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_st { NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_GATTS_CFG_SERVICE_CHANGED.", nrf_strerror_get(ret_code)); + return ret_code; } return NRF_SUCCESS; } -/**@brief Function for finding the end address of the RAM. */ -static uint32_t ram_end_address_get(void) -{ - uint32_t ram_total_size; - -#ifdef NRF51 - uint32_t block_size = NRF_FICR->SIZERAMBLOCKS; - ram_total_size = block_size * NRF_FICR->NUMRAMBLOCK; -#else - ram_total_size = NRF_FICR->INFO.RAM * 1024; -#endif - - return RAM_START + ram_total_size; -} - - ret_code_t nrf_sdh_ble_enable(uint32_t * const p_app_ram_start) { - // Start of RAM, obtained from linker symbol. - uint32_t const app_ram_start_link = *p_app_ram_start; - ret_code_t ret_code = sd_ble_enable(p_app_ram_start); - if (*p_app_ram_start > app_ram_start_link) - { - NRF_LOG_WARNING("Insufficient RAM allocated for the SoftDevice."); - - NRF_LOG_WARNING("Change the RAM start location from 0x%x to 0x%x.", - app_ram_start_link, *p_app_ram_start); - NRF_LOG_WARNING("Maximum RAM size for application is 0x%x.", - ram_end_address_get() - (*p_app_ram_start)); - } - else - { - NRF_LOG_DEBUG("RAM starts at 0x%x", app_ram_start_link); - if (*p_app_ram_start != app_ram_start_link) - { - NRF_LOG_DEBUG("RAM start location can be adjusted to 0x%x.", *p_app_ram_start); - - NRF_LOG_DEBUG("RAM size for application can be adjusted to 0x%x.", - ram_end_address_get() - (*p_app_ram_start)); - } - } - if (ret_code == NRF_SUCCESS) { m_stack_is_enabled = true; @@ -264,7 +192,12 @@ ret_code_t nrf_sdh_ble_enable(uint32_t * const p_app_ram_start) * * @param[in] p_context Context of the observer. */ +#ifndef NOT_USE_NRF_SECTION static void nrf_sdh_ble_evts_poll(void * p_context) +#else +extern void bleEvtDispatch(ble_evt_t *pBleNrfEvt); +void nrf_sdh_ble_evts_poll(void * p_context) +#endif { UNUSED_VARIABLE(p_context); @@ -291,9 +224,8 @@ static void nrf_sdh_ble_evts_poll(void * p_context) } p_ble_evt = (ble_evt_t *)evt_buffer; - +#ifndef NOT_USE_NRF_SECTION NRF_LOG_DEBUG("BLE event: 0x%x.", p_ble_evt->header.evt_id); - // Forward the event to BLE observers. nrf_section_iter_t iter; for (nrf_section_iter_init(&iter, &sdh_ble_observers); @@ -305,9 +237,12 @@ static void nrf_sdh_ble_evts_poll(void * p_context) p_observer = (nrf_sdh_ble_evt_observer_t *)nrf_section_iter_get(&iter); handler = p_observer->handler; - + //NRF_LOG_DEBUG("nrf_sdh_ble_evts_poll handler 0x%x\n", handler); handler(p_ble_evt, p_observer->p_context); } +#else + bleEvtDispatch(p_ble_evt); +#endif } if (ret_code != NRF_ERROR_NOT_FOUND) @@ -316,11 +251,11 @@ static void nrf_sdh_ble_evts_poll(void * p_context) } } - +#ifndef NOT_USE_NRF_SECTION NRF_SDH_STACK_OBSERVER(m_nrf_sdh_ble_evts_poll, NRF_SDH_BLE_STACK_OBSERVER_PRIO) = { .handler = nrf_sdh_ble_evts_poll, .p_context = NULL, }; - +#endif #endif // NRF_MODULE_ENABLED(NRF_SDH_BLE) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h index a71b5e155..68538d44f 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h @@ -58,6 +58,8 @@ extern "C" { #endif +#define __STATIC_INLINE static __inline + /** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations * @{ */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h index 01c330dd0..08f36ec7b 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h @@ -42,12243 +42,14 @@ #ifndef SDK_CONFIG_H #define SDK_CONFIG_H -// <<< Use Configuration Wizard in Context Menu >>>\n -#ifdef USE_APP_CONFIG -#include "app_config.h" -#endif -// nRF_ANT - -//========================================================== -// ANTFS_ENABLED - ant_fs - ANT File Share module. -//========================================================== -#ifndef ANTFS_ENABLED -#define ANTFS_ENABLED 0 -#endif -// ANTFS_CONFIG_NETWORK_NUMBER - ANT-FS network number. -#ifndef ANTFS_CONFIG_NETWORK_NUMBER -#define ANTFS_CONFIG_NETWORK_NUMBER 0 -#endif - -// ANTFS_CONFIG_CHANNEL_NUMBER - ANT-FS channel number. -#ifndef ANTFS_CONFIG_CHANNEL_NUMBER -#define ANTFS_CONFIG_CHANNEL_NUMBER 0 -#endif - -// ANTFS_CONFIG_PAIRING_TIMEOUT - Pairing timeout - how long the UI will wait for a response to a pairing request before switching to the link layer, in seconds. -#ifndef ANTFS_CONFIG_PAIRING_TIMEOUT -#define ANTFS_CONFIG_PAIRING_TIMEOUT 120 -#endif - -// ANTFS_CONFIG_LINK_COMMAND_TIMEOUT - Command timeout - how long the client will wait without receiving any commands before switching to the link layer, in seconds. -#ifndef ANTFS_CONFIG_LINK_COMMAND_TIMEOUT -#define ANTFS_CONFIG_LINK_COMMAND_TIMEOUT 10 -#endif - -// ANTFS_CONFIG_TRANS_TYPE - ANT-FS Transmission Type. -#ifndef ANTFS_CONFIG_TRANS_TYPE -#define ANTFS_CONFIG_TRANS_TYPE 10 -#endif - -// ANTFS_CONFIG_DEVICE_TYPE - ANT device type for channel configuration. -#ifndef ANTFS_CONFIG_DEVICE_TYPE -#define ANTFS_CONFIG_DEVICE_TYPE 1 -#endif - -// ANTFS_CONFIG_BEACON_STATUS_PERIOD - ANT-FS Beacon Message Period. - -// <0=> 0.5 Hz -// <1=> 1 Hz -// <2=> 2 Hz -// <3=> 4 Hz -// <4=> 8 Hz - -#ifndef ANTFS_CONFIG_BEACON_STATUS_PERIOD -#define ANTFS_CONFIG_BEACON_STATUS_PERIOD 3 -#endif - -// ANTFS_CONFIG_TRANSMIT_POWER - ANT Transmit Power. - -// <0=> Lowest ANT Tx power level setting. (-20dBm) -// <1=> ANT Tx power > Lvl 0. (-12dBm) -// <2=> ANT Tx power > Lvl 1. (-4dBm) -// <3=> ANT Tx power > Lvl 2. Default tx power level. (0dBm) -// <4=> ANT Tx power > Lvl 3. (+4dBm) -// <128=> Custom tx power selection - -#ifndef ANTFS_CONFIG_TRANSMIT_POWER -#define ANTFS_CONFIG_TRANSMIT_POWER 3 -#endif - -// ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER - ANT Custom Transmit Power. -#ifndef ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER -#define ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER 0 -#endif - -// ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED - Use pairing and key exchange authentication. - - -#ifndef ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED -#define ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED 0 -#endif - -// ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED - Use passkey authentication. - - -#ifndef ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED -#define ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED 0 -#endif - -// ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED - Allow host to bypass authentication. - - -#ifndef ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED -#define ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED 0 -#endif - -// ANTFS_CONFIG_UPLOAD_ENABLED - Support upload operation. - - -#ifndef ANTFS_CONFIG_UPLOAD_ENABLED -#define ANTFS_CONFIG_UPLOAD_ENABLED 0 -#endif - -// ANTFS_CONFIG_DEBUG_LED_ENABLED - Enables LED debug in the module. - - -#ifndef ANTFS_CONFIG_DEBUG_LED_ENABLED -#define ANTFS_CONFIG_DEBUG_LED_ENABLED 0 -#endif - -// - -// ANT_BPWR_ENABLED - ant_bpwr - Bicycle Power Profile -//========================================================== -#ifndef ANT_BPWR_ENABLED -#define ANT_BPWR_ENABLED 0 -#endif -// ANT_BPWR_LOG_ENABLED - Enables general logging in the module. -//========================================================== -#ifndef ANT_BPWR_LOG_ENABLED -#define ANT_BPWR_LOG_ENABLED 0 -#endif -// ANT_BPWR_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_LOG_LEVEL -#define ANT_BPWR_LOG_LEVEL 3 -#endif - -// ANT_BPWR_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BPWR_INFO_COLOR -#define ANT_BPWR_INFO_COLOR 0 -#endif - -// - -// ANT_BPWR_COMMON_LOG_ENABLED - Enables logging of BPWR tracing common data. -//========================================================== -#ifndef ANT_BPWR_COMMON_LOG_ENABLED -#define ANT_BPWR_COMMON_LOG_ENABLED 0 -#endif -// ANT_BPWR_COMMON_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_COMMON_LOG_LEVEL -#define ANT_BPWR_COMMON_LOG_LEVEL 3 -#endif - -// ANT_BPWR_COMMON_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BPWR_COMMON_INFO_COLOR -#define ANT_BPWR_COMMON_INFO_COLOR 0 -#endif - -// - -// ANT_BPWR_PAGE_TORQUE_LOG_ENABLED - Enables logging of BPWR torque page in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_TORQUE_LOG_ENABLED -#define ANT_BPWR_PAGE_TORQUE_LOG_ENABLED 0 -#endif -// ANT_BPWR_PAGE_TORQUE_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_PAGE_TORQUE_LOG_LEVEL -#define ANT_BPWR_PAGE_TORQUE_LOG_LEVEL 3 -#endif - -// ANT_BPWR_PAGE_TORQUE_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BPWR_PAGE_TORQUE_INFO_COLOR -#define ANT_BPWR_PAGE_TORQUE_INFO_COLOR 0 -#endif - -// - -// ANT_BPWR_PAGE_1_LOG_ENABLED - Enables logging of BPWR page 1 in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_1_LOG_ENABLED -#define ANT_BPWR_PAGE_1_LOG_ENABLED 0 -#endif -// ANT_BPWR_PAGE_1_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_PAGE_1_LOG_LEVEL -#define ANT_BPWR_PAGE_1_LOG_LEVEL 3 -#endif - -// ANT_BPWR_PAGE_1_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BPWR_PAGE_1_INFO_COLOR -#define ANT_BPWR_PAGE_1_INFO_COLOR 0 -#endif - -// - -// ANT_BPWR_PAGE_16_LOG_ENABLED - Enables logging of BPWR page 16 in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_16_LOG_ENABLED -#define ANT_BPWR_PAGE_16_LOG_ENABLED 0 -#endif -// ANT_BPWR_PAGE_16_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_PAGE_16_LOG_LEVEL -#define ANT_BPWR_PAGE_16_LOG_LEVEL 3 -#endif - -// ANT_BPWR_PAGE_16_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BPWR_PAGE_16_INFO_COLOR -#define ANT_BPWR_PAGE_16_INFO_COLOR 0 -#endif - -// - -// ANT_BPWR_PAGE_17_LOG_ENABLED - Enables logging of BPWR page 17 in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_17_LOG_ENABLED -#define ANT_BPWR_PAGE_17_LOG_ENABLED 0 -#endif -// ANT_BPWR_PAGE_17_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_PAGE_17_LOG_LEVEL -#define ANT_BPWR_PAGE_17_LOG_LEVEL 3 -#endif - -// ANT_BPWR_PAGE_17_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BPWR_PAGE_17_INFO_COLOR -#define ANT_BPWR_PAGE_17_INFO_COLOR 0 -#endif - -// - -// ANT_BPWR_PAGE_18_LOG_ENABLED - Enables logging of BPWR page 18 in the module. -//========================================================== -#ifndef ANT_BPWR_PAGE_18_LOG_ENABLED -#define ANT_BPWR_PAGE_18_LOG_ENABLED 0 -#endif -// ANT_BPWR_PAGE_18_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BPWR_PAGE_18_LOG_LEVEL -#define ANT_BPWR_PAGE_18_LOG_LEVEL 3 -#endif - -// ANT_BPWR_PAGE_18_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BPWR_PAGE_18_INFO_COLOR -#define ANT_BPWR_PAGE_18_INFO_COLOR 0 -#endif - -// - -// - -// ANT_BSC_ENABLED - ant_bsc - Bicycle Speed and Cadence Profile -//========================================================== -#ifndef ANT_BSC_ENABLED -#define ANT_BSC_ENABLED 0 -#endif -// ANT_BSC_LOG_ENABLED - Enables general logging in the module. -//========================================================== -#ifndef ANT_BSC_LOG_ENABLED -#define ANT_BSC_LOG_ENABLED 0 -#endif -// ANT_BSC_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_LOG_LEVEL -#define ANT_BSC_LOG_LEVEL 3 -#endif - -// ANT_BSC_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BSC_INFO_COLOR -#define ANT_BSC_INFO_COLOR 0 -#endif - -// - -// ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED - Enables logging of BSC Combined page 0 in the module. -//========================================================== -#ifndef ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED -#define ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED 0 -#endif -// ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL -#define ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL 3 -#endif - -// ANT_BSC_COMBINED_PAGE_0_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BSC_COMBINED_PAGE_0_INFO_COLOR -#define ANT_BSC_COMBINED_PAGE_0_INFO_COLOR 0 -#endif - -// - -// ANT_BSC_PAGE_0_LOG_ENABLED - Enables logging of BSC page 0 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_0_LOG_ENABLED -#define ANT_BSC_PAGE_0_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_0_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_PAGE_0_LOG_LEVEL -#define ANT_BSC_PAGE_0_LOG_LEVEL 3 -#endif - -// ANT_BSC_PAGE_0_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BSC_PAGE_0_INFO_COLOR -#define ANT_BSC_PAGE_0_INFO_COLOR 0 -#endif - -// - -// ANT_BSC_PAGE_1_LOG_ENABLED - Enables logging of BSC page 1 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_1_LOG_ENABLED -#define ANT_BSC_PAGE_1_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_1_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_PAGE_1_LOG_LEVEL -#define ANT_BSC_PAGE_1_LOG_LEVEL 3 -#endif - -// ANT_BSC_PAGE_1_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BSC_PAGE_1_INFO_COLOR -#define ANT_BSC_PAGE_1_INFO_COLOR 0 -#endif - -// - -// ANT_BSC_PAGE_2_LOG_ENABLED - Enables logging of BSC page 2 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_2_LOG_ENABLED -#define ANT_BSC_PAGE_2_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_2_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_PAGE_2_LOG_LEVEL -#define ANT_BSC_PAGE_2_LOG_LEVEL 3 -#endif - -// ANT_BSC_PAGE_2_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BSC_PAGE_2_INFO_COLOR -#define ANT_BSC_PAGE_2_INFO_COLOR 0 -#endif - -// - -// ANT_BSC_PAGE_3_LOG_ENABLED - Enables logging of BSC page 3 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_3_LOG_ENABLED -#define ANT_BSC_PAGE_3_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_3_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_PAGE_3_LOG_LEVEL -#define ANT_BSC_PAGE_3_LOG_LEVEL 3 -#endif - -// ANT_BSC_PAGE_3_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BSC_PAGE_3_INFO_COLOR -#define ANT_BSC_PAGE_3_INFO_COLOR 0 -#endif - -// - -// ANT_BSC_PAGE_4_LOG_ENABLED - Enables logging of BSC page 4 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_4_LOG_ENABLED -#define ANT_BSC_PAGE_4_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_4_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_PAGE_4_LOG_LEVEL -#define ANT_BSC_PAGE_4_LOG_LEVEL 3 -#endif - -// ANT_BSC_PAGE_4_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BSC_PAGE_4_INFO_COLOR -#define ANT_BSC_PAGE_4_INFO_COLOR 0 -#endif - -// - -// ANT_BSC_PAGE_5_LOG_ENABLED - Enables logging of BSC page 5 in the module. -//========================================================== -#ifndef ANT_BSC_PAGE_5_LOG_ENABLED -#define ANT_BSC_PAGE_5_LOG_ENABLED 0 -#endif -// ANT_BSC_PAGE_5_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_BSC_PAGE_5_LOG_LEVEL -#define ANT_BSC_PAGE_5_LOG_LEVEL 3 -#endif - -// ANT_BSC_PAGE_5_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_BSC_PAGE_5_INFO_COLOR -#define ANT_BSC_PAGE_5_INFO_COLOR 0 -#endif - -// - -// - -// ANT_CHANNEL_CONFIG_ENABLED - ant_channel_config - ANT common channel configuration - - -#ifndef ANT_CHANNEL_CONFIG_ENABLED -#define ANT_CHANNEL_CONFIG_ENABLED 0 -#endif - -// ANT_COMMON_PAGE_70_ENABLED - ant_common_page_70 - ANT+ common page 70 -//========================================================== -#ifndef ANT_COMMON_PAGE_70_ENABLED -#define ANT_COMMON_PAGE_70_ENABLED 0 -#endif -// ANT_COMMON_PAGE_70_LOG_ENABLED - Enables logging of common page 70 in the module. -//========================================================== -#ifndef ANT_COMMON_PAGE_70_LOG_ENABLED -#define ANT_COMMON_PAGE_70_LOG_ENABLED 0 -#endif -// ANT_COMMON_PAGE_70_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_COMMON_PAGE_70_LOG_LEVEL -#define ANT_COMMON_PAGE_70_LOG_LEVEL 3 -#endif - -// ANT_COMMON_PAGE_70_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_COMMON_PAGE_70_INFO_COLOR -#define ANT_COMMON_PAGE_70_INFO_COLOR 0 -#endif - -// - -// - -// ANT_COMMON_PAGE_80_ENABLED - ant_common_page_80 - ANT+ common page 80 -//========================================================== -#ifndef ANT_COMMON_PAGE_80_ENABLED -#define ANT_COMMON_PAGE_80_ENABLED 0 -#endif -// ANT_COMMON_PAGE_80_LOG_ENABLED - Enables logging of common page 80 in the module. -//========================================================== -#ifndef ANT_COMMON_PAGE_80_LOG_ENABLED -#define ANT_COMMON_PAGE_80_LOG_ENABLED 0 -#endif -// ANT_COMMON_PAGE_80_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_COMMON_PAGE_80_LOG_LEVEL -#define ANT_COMMON_PAGE_80_LOG_LEVEL 3 -#endif - -// ANT_COMMON_PAGE_80_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_COMMON_PAGE_80_INFO_COLOR -#define ANT_COMMON_PAGE_80_INFO_COLOR 0 -#endif - -// - -// - -// ANT_COMMON_PAGE_81_ENABLED - ant_common_page_81 - ANT+ common page 81 -//========================================================== -#ifndef ANT_COMMON_PAGE_81_ENABLED -#define ANT_COMMON_PAGE_81_ENABLED 0 -#endif -// ANT_COMMON_PAGE_81_LOG_ENABLED - Enables logging of common page 81 in the module. -//========================================================== -#ifndef ANT_COMMON_PAGE_81_LOG_ENABLED -#define ANT_COMMON_PAGE_81_LOG_ENABLED 0 -#endif -// ANT_COMMON_PAGE_81_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_COMMON_PAGE_81_LOG_LEVEL -#define ANT_COMMON_PAGE_81_LOG_LEVEL 3 -#endif - -// ANT_COMMON_PAGE_81_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_COMMON_PAGE_81_INFO_COLOR -#define ANT_COMMON_PAGE_81_INFO_COLOR 0 -#endif - -// - -// - -// ANT_ENCRYPT_CONFIG_ENABLED - ant_encrypt_config - Cryptographic ANT stack configuration - - -#ifndef ANT_ENCRYPT_CONFIG_ENABLED -#define ANT_ENCRYPT_CONFIG_ENABLED 0 -#endif - -// ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED - ant_encrypt_negotiation_slave - Encryption negotiation for encrypted ANT slave channels - - -#ifndef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED -#define ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED 0 -#endif - -// ANT_HRM_ENABLED - ant_hrm - Heart Rate Monitor Profile -//========================================================== -#ifndef ANT_HRM_ENABLED -#define ANT_HRM_ENABLED 0 -#endif -// ANT_HRM_LOG_ENABLED - Enables general logging in the module. -//========================================================== -#ifndef ANT_HRM_LOG_ENABLED -#define ANT_HRM_LOG_ENABLED 0 -#endif -// ANT_HRM_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_HRM_LOG_LEVEL -#define ANT_HRM_LOG_LEVEL 3 -#endif - -// ANT_HRM_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_HRM_INFO_COLOR -#define ANT_HRM_INFO_COLOR 0 -#endif - -// - -// ANT_HRM_PAGE_0_LOG_ENABLED - Enables logging of HRM page 0 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_0_LOG_ENABLED -#define ANT_HRM_PAGE_0_LOG_ENABLED 0 -#endif -// ANT_HRM_PAGE_0_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_HRM_PAGE_0_LOG_LEVEL -#define ANT_HRM_PAGE_0_LOG_LEVEL 3 -#endif - -// ANT_HRM_PAGE_0_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_HRM_PAGE_0_INFO_COLOR -#define ANT_HRM_PAGE_0_INFO_COLOR 0 -#endif - -// - -// ANT_HRM_PAGE_1_LOG_ENABLED - Enables logging of HRM page 1 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_1_LOG_ENABLED -#define ANT_HRM_PAGE_1_LOG_ENABLED 0 -#endif -// ANT_HRM_PAGE_1_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_HRM_PAGE_1_LOG_LEVEL -#define ANT_HRM_PAGE_1_LOG_LEVEL 3 -#endif - -// ANT_HRM_PAGE_1_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_HRM_PAGE_1_INFO_COLOR -#define ANT_HRM_PAGE_1_INFO_COLOR 0 -#endif - -// - -// ANT_HRM_PAGE_2_LOG_ENABLED - Enables logging of HRM page 2 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_2_LOG_ENABLED -#define ANT_HRM_PAGE_2_LOG_ENABLED 0 -#endif -// ANT_HRM_PAGE_2_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_HRM_PAGE_2_LOG_LEVEL -#define ANT_HRM_PAGE_2_LOG_LEVEL 3 -#endif - -// ANT_HRM_PAGE_2_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_HRM_PAGE_2_INFO_COLOR -#define ANT_HRM_PAGE_2_INFO_COLOR 0 -#endif - -// - -// ANT_HRM_PAGE_3_LOG_ENABLED - Enables logging of HRM page 3 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_3_LOG_ENABLED -#define ANT_HRM_PAGE_3_LOG_ENABLED 0 -#endif -// ANT_HRM_PAGE_3_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_HRM_PAGE_3_LOG_LEVEL -#define ANT_HRM_PAGE_3_LOG_LEVEL 3 -#endif - -// ANT_HRM_PAGE_3_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_HRM_PAGE_3_INFO_COLOR -#define ANT_HRM_PAGE_3_INFO_COLOR 0 -#endif - -// - -// ANT_HRM_PAGE_4_LOG_ENABLED - Enables logging of HRM page 4 in the module. -//========================================================== -#ifndef ANT_HRM_PAGE_4_LOG_ENABLED -#define ANT_HRM_PAGE_4_LOG_ENABLED 0 -#endif -// ANT_HRM_PAGE_4_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_HRM_PAGE_4_LOG_LEVEL -#define ANT_HRM_PAGE_4_LOG_LEVEL 3 -#endif - -// ANT_HRM_PAGE_4_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_HRM_PAGE_4_INFO_COLOR -#define ANT_HRM_PAGE_4_INFO_COLOR 0 -#endif - -// - -// - -// ANT_KEY_MANAGER_ENABLED - ant_key_manager - Software Component - - -#ifndef ANT_KEY_MANAGER_ENABLED -#define ANT_KEY_MANAGER_ENABLED 0 -#endif - -// ANT_REQUEST_CONTROLLER_ENABLED - ant_request_controller - ANT+ request controller - - -#ifndef ANT_REQUEST_CONTROLLER_ENABLED -#define ANT_REQUEST_CONTROLLER_ENABLED 0 -#endif - -// ANT_SDM_ENABLED - ant_sdm - Stride Based Speed and Distance Monitor Profile -//========================================================== -#ifndef ANT_SDM_ENABLED -#define ANT_SDM_ENABLED 0 -#endif -// ANT_SDM_LOG_ENABLED - Enables general logging in the module. -//========================================================== -#ifndef ANT_SDM_LOG_ENABLED -#define ANT_SDM_LOG_ENABLED 0 -#endif -// ANT_SDM_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef ANT_SDM_LOG_LEVEL -#define ANT_SDM_LOG_LEVEL 3 -#endif - -// ANT_SDM_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef ANT_SDM_INFO_COLOR -#define ANT_SDM_INFO_COLOR 0 -#endif - -// - -// - -// ANT_SEARCH_CONFIG_ENABLED - ant_search_config - ANT common search configuration -//========================================================== -#ifndef ANT_SEARCH_CONFIG_ENABLED -#define ANT_SEARCH_CONFIG_ENABLED 0 -#endif -// ANT_DEFAULT_LOW_PRIORITY_TIMEOUT - Default low priority search time-out. <0-255> - - -#ifndef ANT_DEFAULT_LOW_PRIORITY_TIMEOUT -#define ANT_DEFAULT_LOW_PRIORITY_TIMEOUT 2 -#endif - -// ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT - Default high priority search time-out. <0-255> - - -#ifndef ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT -#define ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT 10 -#endif - -// - -// ANT_STATE_INDICATOR_ENABLED - ant_state_indicator - ANT state indicator using BSP -//========================================================== -#ifndef ANT_STATE_INDICATOR_ENABLED -#define ANT_STATE_INDICATOR_ENABLED 0 -#endif -// ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY - Shutdown observer priority. -#ifndef ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY -#define ANT_STATE_INDICATOR_CONFIG_SHUTDOWN_HANDLER_PRIORITY 1 -#endif - -// - -// -//========================================================== - -// nRF_BLE - -//========================================================== -// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module - - -#ifndef BLE_ADVERTISING_ENABLED -#define BLE_ADVERTISING_ENABLED 0 -#endif - -// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands -//========================================================== -#ifndef BLE_DTM_ENABLED -#define BLE_DTM_ENABLED 0 -#endif -// NRF_RADIO_ANTENNA_PIN_1 - Antenna 1 GPIO pin -#ifndef NRF_RADIO_ANTENNA_PIN_1 -#define NRF_RADIO_ANTENNA_PIN_1 21 -#endif - -// NRF_RADIO_ANTENNA_PIN_2 - Antenna 2 GPIO pin -#ifndef NRF_RADIO_ANTENNA_PIN_2 -#define NRF_RADIO_ANTENNA_PIN_2 23 -#endif - -// NRF_RADIO_ANTENNA_PIN_3 - Antenna 3 GPIO pin -#ifndef NRF_RADIO_ANTENNA_PIN_3 -#define NRF_RADIO_ANTENNA_PIN_3 26 -#endif - -// NRF_RADIO_ANTENNA_PIN_4 - Antenna 4 GPIO pin -#ifndef NRF_RADIO_ANTENNA_PIN_4 -#define NRF_RADIO_ANTENNA_PIN_4 27 -#endif - -// NRF_RADIO_ANTENNA_PIN_5 - Antenna 5 GPIO pin -#ifndef NRF_RADIO_ANTENNA_PIN_5 -#define NRF_RADIO_ANTENNA_PIN_5 28 -#endif - -// NRF_RADIO_ANTENNA_PIN_6 - Antenna 6 GPIO pin -#ifndef NRF_RADIO_ANTENNA_PIN_6 -#define NRF_RADIO_ANTENNA_PIN_6 29 -#endif - -// NRF_RADIO_ANTENNA_PIN_7 - Antenna 7 GPIO pin -#ifndef NRF_RADIO_ANTENNA_PIN_7 -#define NRF_RADIO_ANTENNA_PIN_7 30 -#endif - -// NRF_RADIO_ANTENNA_PIN_8 - Antenna 8 GPIO pin -#ifndef NRF_RADIO_ANTENNA_PIN_8 -#define NRF_RADIO_ANTENNA_PIN_8 31 -#endif - -// NRF_RADIO_ANTENNA_COUNT -#ifndef NRF_RADIO_ANTENNA_COUNT -#define NRF_RADIO_ANTENNA_COUNT 12 -#endif - -// DTM_RADIO_IRQ_PRIORITY - RADIO interrupt priority -#ifndef DTM_RADIO_IRQ_PRIORITY -#define DTM_RADIO_IRQ_PRIORITY 2 -#endif - -// DTM_TIMER_IRQ_PRIORITY - DTM timer interrupt priority -#ifndef DTM_TIMER_IRQ_PRIORITY -#define DTM_TIMER_IRQ_PRIORITY 3 -#endif - -// DTM_ANOMALY_172_TIMER_IRQ_PRIORITY - DTM anomaly 172 timer interrupt priority -#ifndef DTM_ANOMALY_172_TIMER_IRQ_PRIORITY -#define DTM_ANOMALY_172_TIMER_IRQ_PRIORITY 2 -#endif - -// NRF_DTM_TIMER_INSTANCE - DTM TIMER instance - -// <0=> TIMER0 -// <2=> TIMER2 -// <3=> TIMER3 -// <4=> TIMER4 - -#ifndef NRF_DTM_TIMER_INSTANCE -#define NRF_DTM_TIMER_INSTANCE 0 -#endif - -// - -// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library - - -#ifndef BLE_RACP_ENABLED -#define BLE_RACP_ENABLED 0 -#endif - -// NRF_BLE_QWR_ENABLED - nrf_ble_qwr - Queued writes support module (prepare/execute write) -//========================================================== -#ifndef NRF_BLE_QWR_ENABLED -#define NRF_BLE_QWR_ENABLED 0 -#endif -// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. -#ifndef NRF_BLE_QWR_MAX_ATTR -#define NRF_BLE_QWR_MAX_ATTR 0 -#endif - -// - -// PEER_MANAGER_ENABLED - peer_manager - Peer Manager -//========================================================== -#ifndef PEER_MANAGER_ENABLED -#define PEER_MANAGER_ENABLED 0 -#endif -// PM_MAX_REGISTRANTS - Number of event handlers that can be registered. -#ifndef PM_MAX_REGISTRANTS -#define PM_MAX_REGISTRANTS 3 -#endif - -// PM_FLASH_BUFFERS - Number of internal buffers for flash operations. -// Decrease this value to lower RAM usage. - -#ifndef PM_FLASH_BUFFERS -#define PM_FLASH_BUFFERS 4 -#endif - -// PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. - - -// Enable/disable central-specific Peer Manager functionality. - -#ifndef PM_CENTRAL_ENABLED -#define PM_CENTRAL_ENABLED 1 -#endif - -// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. - - -// If not using a GATT server, or using a server wihout a service changed characteristic, -// disable this to save code space. - -#ifndef PM_SERVICE_CHANGED_ENABLED -#define PM_SERVICE_CHANGED_ENABLED 1 -#endif - -// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. - - -// Set this to false to save code space if not using the peer rank API. - -#ifndef PM_PEER_RANKS_ENABLED -#define PM_PEER_RANKS_ENABLED 1 -#endif - -// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. - - -// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. - -#ifndef PM_LESC_ENABLED -#define PM_LESC_ENABLED 0 -#endif - -// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. -//========================================================== -#ifndef PM_RA_PROTECTION_ENABLED -#define PM_RA_PROTECTION_ENABLED 0 -#endif -// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. -#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM -#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 -#endif - -// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. -#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL -#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 -#endif - -// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. -#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL -#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 -#endif - -// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). -// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. - -#ifndef PM_RA_PROTECTION_REWARD_PERIOD -#define PM_RA_PROTECTION_REWARD_PERIOD 10000 -#endif - -// - -// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. -// This might be necessary for interoperability reasons, especially as peripheral. - -#ifndef PM_HANDLER_SEC_DELAY_MS -#define PM_HANDLER_SEC_DELAY_MS 0 -#endif - -// - -// -//========================================================== - -// nRF_BLE_Services - -//========================================================== -// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client - - -#ifndef BLE_ANCS_C_ENABLED -#define BLE_ANCS_C_ENABLED 0 -#endif - -// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client - - -#ifndef BLE_ANS_C_ENABLED -#define BLE_ANS_C_ENABLED 0 -#endif - -// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client - - -#ifndef BLE_BAS_C_ENABLED -#define BLE_BAS_C_ENABLED 0 -#endif - -// BLE_BAS_ENABLED - ble_bas - Battery Service -//========================================================== -#ifndef BLE_BAS_ENABLED -#define BLE_BAS_ENABLED 0 -#endif -// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef BLE_BAS_CONFIG_LOG_ENABLED -#define BLE_BAS_CONFIG_LOG_ENABLED 0 -#endif -// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef BLE_BAS_CONFIG_LOG_LEVEL -#define BLE_BAS_CONFIG_LOG_LEVEL 3 -#endif - -// BLE_BAS_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef BLE_BAS_CONFIG_INFO_COLOR -#define BLE_BAS_CONFIG_INFO_COLOR 0 -#endif - -// BLE_BAS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef BLE_BAS_CONFIG_DEBUG_COLOR -#define BLE_BAS_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service - - -#ifndef BLE_CSCS_ENABLED -#define BLE_CSCS_ENABLED 0 -#endif - -// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client - - -#ifndef BLE_CTS_C_ENABLED -#define BLE_CTS_C_ENABLED 0 -#endif - -// BLE_DIS_ENABLED - ble_dis - Device Information Service - - -#ifndef BLE_DIS_ENABLED -#define BLE_DIS_ENABLED 0 -#endif - -// BLE_GLS_ENABLED - ble_gls - Glucose Service - - -#ifndef BLE_GLS_ENABLED -#define BLE_GLS_ENABLED 0 -#endif - -// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service - - -#ifndef BLE_HIDS_ENABLED -#define BLE_HIDS_ENABLED 0 -#endif - -// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client - - -#ifndef BLE_HRS_C_ENABLED -#define BLE_HRS_C_ENABLED 0 -#endif - -// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service - - -#ifndef BLE_HRS_ENABLED -#define BLE_HRS_ENABLED 0 -#endif - -// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service - - -#ifndef BLE_HTS_ENABLED -#define BLE_HTS_ENABLED 0 -#endif - -// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client - - -#ifndef BLE_IAS_C_ENABLED -#define BLE_IAS_C_ENABLED 0 -#endif - -// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service -//========================================================== -#ifndef BLE_IAS_ENABLED -#define BLE_IAS_ENABLED 0 -#endif -// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef BLE_IAS_CONFIG_LOG_ENABLED -#define BLE_IAS_CONFIG_LOG_ENABLED 0 -#endif -// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef BLE_IAS_CONFIG_LOG_LEVEL -#define BLE_IAS_CONFIG_LOG_LEVEL 3 -#endif - -// BLE_IAS_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef BLE_IAS_CONFIG_INFO_COLOR -#define BLE_IAS_CONFIG_INFO_COLOR 0 -#endif - -// BLE_IAS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef BLE_IAS_CONFIG_DEBUG_COLOR -#define BLE_IAS_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client - - -#ifndef BLE_LBS_C_ENABLED -#define BLE_LBS_C_ENABLED 0 -#endif - -// BLE_LBS_ENABLED - ble_lbs - LED Button Service - - -#ifndef BLE_LBS_ENABLED -#define BLE_LBS_ENABLED 0 -#endif - -// BLE_LLS_ENABLED - ble_lls - Link Loss Service - - -#ifndef BLE_LLS_ENABLED -#define BLE_LLS_ENABLED 0 -#endif - -// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service - - -#ifndef BLE_NUS_C_ENABLED -#define BLE_NUS_C_ENABLED 0 -#endif - -// BLE_NUS_ENABLED - ble_nus - Nordic UART Service -//========================================================== -#ifndef BLE_NUS_ENABLED -#define BLE_NUS_ENABLED 0 -#endif -// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef BLE_NUS_CONFIG_LOG_ENABLED -#define BLE_NUS_CONFIG_LOG_ENABLED 0 -#endif -// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef BLE_NUS_CONFIG_LOG_LEVEL -#define BLE_NUS_CONFIG_LOG_LEVEL 3 -#endif - -// BLE_NUS_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef BLE_NUS_CONFIG_INFO_COLOR -#define BLE_NUS_CONFIG_INFO_COLOR 0 -#endif - -// BLE_NUS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef BLE_NUS_CONFIG_DEBUG_COLOR -#define BLE_NUS_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client - - -#ifndef BLE_RSCS_C_ENABLED -#define BLE_RSCS_C_ENABLED 0 -#endif - -// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service - - -#ifndef BLE_RSCS_ENABLED -#define BLE_RSCS_ENABLED 0 -#endif - -// BLE_TPS_ENABLED - ble_tps - TX Power Service - - -#ifndef BLE_TPS_ENABLED -#define BLE_TPS_ENABLED 0 -#endif - -// -//========================================================== - -// nRF_Core - -//========================================================== -// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU -//========================================================== -#ifndef NRF_MPU_LIB_ENABLED -#define NRF_MPU_LIB_ENABLED 0 -#endif -// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. - - -#ifndef NRF_MPU_LIB_CLI_CMDS -#define NRF_MPU_LIB_CLI_CMDS 0 -#endif - -// - -// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard -//========================================================== -#ifndef NRF_STACK_GUARD_ENABLED -#define NRF_STACK_GUARD_ENABLED 0 -#endif -// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. - -// <5=> 32 bytes -// <6=> 64 bytes -// <7=> 128 bytes -// <8=> 256 bytes -// <9=> 512 bytes -// <10=> 1024 bytes -// <11=> 2048 bytes -// <12=> 4096 bytes - -#ifndef NRF_STACK_GUARD_CONFIG_SIZE -#define NRF_STACK_GUARD_CONFIG_SIZE 7 -#endif - -// - -// -//========================================================== - -// nRF_Crypto - -//========================================================== -// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. -//========================================================== -#ifndef NRF_CRYPTO_ENABLED -#define NRF_CRYPTO_ENABLED 1 -#endif -// NRF_CRYPTO_ALLOCATOR - Memory allocator - - -// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. -// <0=> Default -// <1=> User macros -// <2=> On stack (alloca) -// <3=> C dynamic memory (malloc) -// <4=> SDK Memory Manager (nrf_malloc) - -#ifndef NRF_CRYPTO_ALLOCATOR -#define NRF_CRYPTO_ALLOCATOR 0 -#endif - -// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. - -// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 -#endif - -// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. - - -// CC310_BL backend implementation for hardware-accelerated SHA-256. - -#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation - - -// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - -#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 -#endif - -// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian -// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! - -#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE -#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 -#endif - -// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. - - -// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used - -#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. - -// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. - - -// CC310 backend implementation for hardware-accelerated SHA-256. - -#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality - - -// CC310 backend implementation for SHA-512 (in software). - -#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 - - -// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. - -#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 - - -// CC310 backend implementation for HMAC using SHA-512 (in software). - -#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. - - -#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. - - -// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used - -#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED -#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED -#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. - - -#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED -#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. - - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. - - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. - - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. - - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. - - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. - - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. - - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. - - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve - - -// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve - - -// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve - - -// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve - - -// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve - - -// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve - - -// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve - - -// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve - - -// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve - - -// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve - - -// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve - - -// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve - - -// Enable this setting if you need Curve25519 support using MBEDTLS - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. - - -// mbed TLS backend implementation for SHA-256. - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. - - -// mbed TLS backend implementation for SHA-512. - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. - - -// mbed TLS backend implementation for HMAC using SHA-256. - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. - - -// mbed TLS backend implementation for HMAC using SHA-512. - -#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED -#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED -#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve - - -// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc - -#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED -#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve - - -// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc - -#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED -#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve - - -// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc - -#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED -#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve - - -// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc - -#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED -#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. - -// The nRF HW backend provide access to RNG peripheral in nRF5x devices. -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED -#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. - - -// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. - -#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED -#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. - -// The nRF SW cryptography backend (only used in bootloader context). -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED -#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 - - -// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. - -#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED -#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend - -// The Oberon backend -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. - - -#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve - - -// Enable this setting if you need secp256r1 curve support using Oberon library - -#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH - - -// Enable this setting if you need Curve25519 ECDH support using Oberon library - -#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme - - -// Enable this setting if you need Ed25519 support using Oberon library - -#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality - - -// Oberon backend implementation for SHA-256. - -#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality - - -// Oberon backend implementation for SHA-512. - -#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 - - -// Oberon backend implementation for HMAC using SHA-256. - -#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 -#endif - -// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 - - -// Oberon backend implementation for HMAC using SHA-512. - -#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED -#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. - -// Enables the nrf_crypto backend for Optiga Trust X devices. -//========================================================== -#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED -#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 -#endif -// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG - - -// The Optiga backend provide external chip RNG. - -#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED -#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 -#endif - -// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 - - -// The Optiga backend provide external chip ECC using secp256r1. - -#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED -#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 -#endif - -// - -// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data - - -// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. - -#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED -#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 -#endif - -// - -// -//========================================================== - -// nRF_DFU - -//========================================================== -// ble_dfu - Device Firmware Update - -//========================================================== -// BLE_DFU_ENABLED - Enable DFU Service. - - -#ifndef BLE_DFU_ENABLED -#define BLE_DFU_ENABLED 0 -#endif - -// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. - - -#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS -#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 -#endif - -// -//========================================================== - -// -//========================================================== - -// nRF_Drivers - -//========================================================== -// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer -//========================================================== -#ifndef COMP_ENABLED -#define COMP_ENABLED 0 -#endif -// COMP_CONFIG_REF - Reference voltage - -// <0=> Internal 1.2V -// <1=> Internal 1.8V -// <2=> Internal 2.4V -// <4=> VDD -// <7=> ARef - -#ifndef COMP_CONFIG_REF -#define COMP_CONFIG_REF 1 -#endif - -// COMP_CONFIG_MAIN_MODE - Main mode - -// <0=> Single ended -// <1=> Differential - -#ifndef COMP_CONFIG_MAIN_MODE -#define COMP_CONFIG_MAIN_MODE 0 -#endif - -// COMP_CONFIG_SPEED_MODE - Speed mode - -// <0=> Low power -// <1=> Normal -// <2=> High speed - -#ifndef COMP_CONFIG_SPEED_MODE -#define COMP_CONFIG_SPEED_MODE 2 -#endif - -// COMP_CONFIG_HYST - Hystheresis - -// <0=> No -// <1=> 50mV - -#ifndef COMP_CONFIG_HYST -#define COMP_CONFIG_HYST 0 -#endif - -// COMP_CONFIG_ISOURCE - Current Source - -// <0=> Off -// <1=> 2.5 uA -// <2=> 5 uA -// <3=> 10 uA - -#ifndef COMP_CONFIG_ISOURCE -#define COMP_CONFIG_ISOURCE 0 -#endif - -// COMP_CONFIG_INPUT - Analog input - -// <0=> 0 -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef COMP_CONFIG_INPUT -#define COMP_CONFIG_INPUT 0 -#endif - -// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef COMP_CONFIG_IRQ_PRIORITY -#define COMP_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer - - -#ifndef EGU_ENABLED -#define EGU_ENABLED 0 -#endif - -// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer -//========================================================== -#ifndef GPIOTE_ENABLED -#define GPIOTE_ENABLED 0 -#endif -// GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins -#ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS -#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 -#endif - -// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef GPIOTE_CONFIG_IRQ_PRIORITY -#define GPIOTE_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer -//========================================================== -#ifndef I2S_ENABLED -#define I2S_ENABLED 0 -#endif -// I2S_CONFIG_SCK_PIN - SCK pin <0-31> - - -#ifndef I2S_CONFIG_SCK_PIN -#define I2S_CONFIG_SCK_PIN 31 -#endif - -// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> - - -#ifndef I2S_CONFIG_LRCK_PIN -#define I2S_CONFIG_LRCK_PIN 30 -#endif - -// I2S_CONFIG_MCK_PIN - MCK pin -#ifndef I2S_CONFIG_MCK_PIN -#define I2S_CONFIG_MCK_PIN 255 -#endif - -// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> - - -#ifndef I2S_CONFIG_SDOUT_PIN -#define I2S_CONFIG_SDOUT_PIN 29 -#endif - -// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> - - -#ifndef I2S_CONFIG_SDIN_PIN -#define I2S_CONFIG_SDIN_PIN 28 -#endif - -// I2S_CONFIG_MASTER - Mode - -// <0=> Master -// <1=> Slave - -#ifndef I2S_CONFIG_MASTER -#define I2S_CONFIG_MASTER 0 -#endif - -// I2S_CONFIG_FORMAT - Format - -// <0=> I2S -// <1=> Aligned - -#ifndef I2S_CONFIG_FORMAT -#define I2S_CONFIG_FORMAT 0 -#endif - -// I2S_CONFIG_ALIGN - Alignment - -// <0=> Left -// <1=> Right - -#ifndef I2S_CONFIG_ALIGN -#define I2S_CONFIG_ALIGN 0 -#endif - -// I2S_CONFIG_SWIDTH - Sample width (bits) - -// <0=> 8 -// <1=> 16 -// <2=> 24 - -#ifndef I2S_CONFIG_SWIDTH -#define I2S_CONFIG_SWIDTH 1 -#endif - -// I2S_CONFIG_CHANNELS - Channels - -// <0=> Stereo -// <1=> Left -// <2=> Right - -#ifndef I2S_CONFIG_CHANNELS -#define I2S_CONFIG_CHANNELS 1 -#endif - -// I2S_CONFIG_MCK_SETUP - MCK behavior - -// <0=> Disabled -// <2147483648=> 32MHz/2 -// <1342177280=> 32MHz/3 -// <1073741824=> 32MHz/4 -// <805306368=> 32MHz/5 -// <671088640=> 32MHz/6 -// <536870912=> 32MHz/8 -// <402653184=> 32MHz/10 -// <369098752=> 32MHz/11 -// <285212672=> 32MHz/15 -// <268435456=> 32MHz/16 -// <201326592=> 32MHz/21 -// <184549376=> 32MHz/23 -// <142606336=> 32MHz/30 -// <138412032=> 32MHz/31 -// <134217728=> 32MHz/32 -// <100663296=> 32MHz/42 -// <68157440=> 32MHz/63 -// <34340864=> 32MHz/125 - -#ifndef I2S_CONFIG_MCK_SETUP -#define I2S_CONFIG_MCK_SETUP 536870912 -#endif - -// I2S_CONFIG_RATIO - MCK/LRCK ratio - -// <0=> 32x -// <1=> 48x -// <2=> 64x -// <3=> 96x -// <4=> 128x -// <5=> 192x -// <6=> 256x -// <7=> 384x -// <8=> 512x - -#ifndef I2S_CONFIG_RATIO -#define I2S_CONFIG_RATIO 2000 -#endif - -// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef I2S_CONFIG_IRQ_PRIORITY -#define I2S_CONFIG_IRQ_PRIORITY 6 -#endif - -// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef I2S_CONFIG_LOG_ENABLED -#define I2S_CONFIG_LOG_ENABLED 0 -#endif -// I2S_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef I2S_CONFIG_LOG_LEVEL -#define I2S_CONFIG_LOG_LEVEL 3 -#endif - -// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef I2S_CONFIG_INFO_COLOR -#define I2S_CONFIG_INFO_COLOR 0 -#endif - -// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef I2S_CONFIG_DEBUG_COLOR -#define I2S_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer -//========================================================== -#ifndef LPCOMP_ENABLED -#define LPCOMP_ENABLED 0 -#endif -// LPCOMP_CONFIG_REFERENCE - Reference voltage - -// <0=> Supply 1/8 -// <1=> Supply 2/8 -// <2=> Supply 3/8 -// <3=> Supply 4/8 -// <4=> Supply 5/8 -// <5=> Supply 6/8 -// <6=> Supply 7/8 -// <8=> Supply 1/16 (nRF52) -// <9=> Supply 3/16 (nRF52) -// <10=> Supply 5/16 (nRF52) -// <11=> Supply 7/16 (nRF52) -// <12=> Supply 9/16 (nRF52) -// <13=> Supply 11/16 (nRF52) -// <14=> Supply 13/16 (nRF52) -// <15=> Supply 15/16 (nRF52) -// <7=> External Ref 0 -// <65543=> External Ref 1 - -#ifndef LPCOMP_CONFIG_REFERENCE -#define LPCOMP_CONFIG_REFERENCE 3 -#endif - -// LPCOMP_CONFIG_DETECTION - Detection - -// <0=> Crossing -// <1=> Up -// <2=> Down - -#ifndef LPCOMP_CONFIG_DETECTION -#define LPCOMP_CONFIG_DETECTION 2 -#endif - -// LPCOMP_CONFIG_INPUT - Analog input - -// <0=> 0 -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef LPCOMP_CONFIG_INPUT -#define LPCOMP_CONFIG_INPUT 0 -#endif - -// LPCOMP_CONFIG_HYST - Hysteresis - - -#ifndef LPCOMP_CONFIG_HYST -#define LPCOMP_CONFIG_HYST 0 -#endif - -// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef LPCOMP_CONFIG_IRQ_PRIORITY -#define LPCOMP_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver -//========================================================== -#ifndef NRFX_CLOCK_ENABLED -#define NRFX_CLOCK_ENABLED 0 -#endif -// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source - -// <0=> RC -// <1=> XTAL -// <2=> Synth -// <131073=> External Low Swing -// <196609=> External Full Swing - -#ifndef NRFX_CLOCK_CONFIG_LF_SRC -#define NRFX_CLOCK_CONFIG_LF_SRC 1 -#endif - -// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY -#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED -#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL -#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_CLOCK_CONFIG_INFO_COLOR -#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_CLOCK_CONFIG_DEBUG_COLOR -#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver -//========================================================== -#ifndef NRFX_COMP_ENABLED -#define NRFX_COMP_ENABLED 0 -#endif -// NRFX_COMP_CONFIG_REF - Reference voltage - -// <0=> Internal 1.2V -// <1=> Internal 1.8V -// <2=> Internal 2.4V -// <4=> VDD -// <7=> ARef - -#ifndef NRFX_COMP_CONFIG_REF -#define NRFX_COMP_CONFIG_REF 1 -#endif - -// NRFX_COMP_CONFIG_MAIN_MODE - Main mode - -// <0=> Single ended -// <1=> Differential - -#ifndef NRFX_COMP_CONFIG_MAIN_MODE -#define NRFX_COMP_CONFIG_MAIN_MODE 0 -#endif - -// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode - -// <0=> Low power -// <1=> Normal -// <2=> High speed - -#ifndef NRFX_COMP_CONFIG_SPEED_MODE -#define NRFX_COMP_CONFIG_SPEED_MODE 2 -#endif - -// NRFX_COMP_CONFIG_HYST - Hystheresis - -// <0=> No -// <1=> 50mV - -#ifndef NRFX_COMP_CONFIG_HYST -#define NRFX_COMP_CONFIG_HYST 0 -#endif - -// NRFX_COMP_CONFIG_ISOURCE - Current Source - -// <0=> Off -// <1=> 2.5 uA -// <2=> 5 uA -// <3=> 10 uA - -#ifndef NRFX_COMP_CONFIG_ISOURCE -#define NRFX_COMP_CONFIG_ISOURCE 0 -#endif - -// NRFX_COMP_CONFIG_INPUT - Analog input - -// <0=> 0 -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_COMP_CONFIG_INPUT -#define NRFX_COMP_CONFIG_INPUT 0 -#endif - -// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY -#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_COMP_CONFIG_LOG_ENABLED -#define NRFX_COMP_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_COMP_CONFIG_LOG_LEVEL -#define NRFX_COMP_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_COMP_CONFIG_INFO_COLOR -#define NRFX_COMP_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_COMP_CONFIG_DEBUG_COLOR -#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver -//========================================================== -#ifndef NRFX_GPIOTE_ENABLED -#define NRFX_GPIOTE_ENABLED 0 -#endif -// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins -#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS -#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 -#endif - -// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY -#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED -#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL -#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_GPIOTE_CONFIG_INFO_COLOR -#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_GPIOTE_CONFIG_DEBUG_COLOR -#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver -//========================================================== -#ifndef NRFX_I2S_ENABLED -#define NRFX_I2S_ENABLED 0 -#endif -// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> - - -#ifndef NRFX_I2S_CONFIG_SCK_PIN -#define NRFX_I2S_CONFIG_SCK_PIN 31 -#endif - -// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> - - -#ifndef NRFX_I2S_CONFIG_LRCK_PIN -#define NRFX_I2S_CONFIG_LRCK_PIN 30 -#endif - -// NRFX_I2S_CONFIG_MCK_PIN - MCK pin -#ifndef NRFX_I2S_CONFIG_MCK_PIN -#define NRFX_I2S_CONFIG_MCK_PIN 255 -#endif - -// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> - - -#ifndef NRFX_I2S_CONFIG_SDOUT_PIN -#define NRFX_I2S_CONFIG_SDOUT_PIN 29 -#endif - -// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> - - -#ifndef NRFX_I2S_CONFIG_SDIN_PIN -#define NRFX_I2S_CONFIG_SDIN_PIN 28 -#endif - -// NRFX_I2S_CONFIG_MASTER - Mode - -// <0=> Master -// <1=> Slave - -#ifndef NRFX_I2S_CONFIG_MASTER -#define NRFX_I2S_CONFIG_MASTER 0 -#endif - -// NRFX_I2S_CONFIG_FORMAT - Format - -// <0=> I2S -// <1=> Aligned - -#ifndef NRFX_I2S_CONFIG_FORMAT -#define NRFX_I2S_CONFIG_FORMAT 0 -#endif - -// NRFX_I2S_CONFIG_ALIGN - Alignment - -// <0=> Left -// <1=> Right - -#ifndef NRFX_I2S_CONFIG_ALIGN -#define NRFX_I2S_CONFIG_ALIGN 0 -#endif - -// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) - -// <0=> 8 -// <1=> 16 -// <2=> 24 - -#ifndef NRFX_I2S_CONFIG_SWIDTH -#define NRFX_I2S_CONFIG_SWIDTH 1 -#endif - -// NRFX_I2S_CONFIG_CHANNELS - Channels - -// <0=> Stereo -// <1=> Left -// <2=> Right - -#ifndef NRFX_I2S_CONFIG_CHANNELS -#define NRFX_I2S_CONFIG_CHANNELS 1 -#endif - -// NRFX_I2S_CONFIG_MCK_SETUP - MCK behavior - -// <0=> Disabled -// <2147483648=> 32MHz/2 -// <1342177280=> 32MHz/3 -// <1073741824=> 32MHz/4 -// <805306368=> 32MHz/5 -// <671088640=> 32MHz/6 -// <536870912=> 32MHz/8 -// <402653184=> 32MHz/10 -// <369098752=> 32MHz/11 -// <285212672=> 32MHz/15 -// <268435456=> 32MHz/16 -// <201326592=> 32MHz/21 -// <184549376=> 32MHz/23 -// <142606336=> 32MHz/30 -// <138412032=> 32MHz/31 -// <134217728=> 32MHz/32 -// <100663296=> 32MHz/42 -// <68157440=> 32MHz/63 -// <34340864=> 32MHz/125 - -#ifndef NRFX_I2S_CONFIG_MCK_SETUP -#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 -#endif - -// NRFX_I2S_CONFIG_RATIO - MCK/LRCK ratio - -// <0=> 32x -// <1=> 48x -// <2=> 64x -// <3=> 96x -// <4=> 128x -// <5=> 192x -// <6=> 256x -// <7=> 384x -// <8=> 512x - -#ifndef NRFX_I2S_CONFIG_RATIO -#define NRFX_I2S_CONFIG_RATIO 2000 -#endif - -// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY -#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_I2S_CONFIG_LOG_ENABLED -#define NRFX_I2S_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_I2S_CONFIG_LOG_LEVEL -#define NRFX_I2S_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_I2S_CONFIG_INFO_COLOR -#define NRFX_I2S_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_I2S_CONFIG_DEBUG_COLOR -#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver -//========================================================== -#ifndef NRFX_LPCOMP_ENABLED -#define NRFX_LPCOMP_ENABLED 0 -#endif -// NRFX_LPCOMP_CONFIG_REFERENCE - Reference voltage - -// <0=> Supply 1/8 -// <1=> Supply 2/8 -// <2=> Supply 3/8 -// <3=> Supply 4/8 -// <4=> Supply 5/8 -// <5=> Supply 6/8 -// <6=> Supply 7/8 -// <8=> Supply 1/16 (nRF52) -// <9=> Supply 3/16 (nRF52) -// <10=> Supply 5/16 (nRF52) -// <11=> Supply 7/16 (nRF52) -// <12=> Supply 9/16 (nRF52) -// <13=> Supply 11/16 (nRF52) -// <14=> Supply 13/16 (nRF52) -// <15=> Supply 15/16 (nRF52) -// <7=> External Ref 0 -// <65543=> External Ref 1 - -#ifndef NRFX_LPCOMP_CONFIG_REFERENCE -#define NRFX_LPCOMP_CONFIG_REFERENCE 3 -#endif - -// NRFX_LPCOMP_CONFIG_DETECTION - Detection - -// <0=> Crossing -// <1=> Up -// <2=> Down - -#ifndef NRFX_LPCOMP_CONFIG_DETECTION -#define NRFX_LPCOMP_CONFIG_DETECTION 2 -#endif - -// NRFX_LPCOMP_CONFIG_INPUT - Analog input - -// <0=> 0 -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_LPCOMP_CONFIG_INPUT -#define NRFX_LPCOMP_CONFIG_INPUT 0 -#endif - -// NRFX_LPCOMP_CONFIG_HYST - Hysteresis - - -#ifndef NRFX_LPCOMP_CONFIG_HYST -#define NRFX_LPCOMP_CONFIG_HYST 0 -#endif - -// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY -#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED -#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL -#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_LPCOMP_CONFIG_INFO_COLOR -#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_LPCOMP_CONFIG_DEBUG_COLOR -#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_NFCT_ENABLED - nrfx_nfct - NFCT peripheral driver -//========================================================== -#ifndef NRFX_NFCT_ENABLED -#define NRFX_NFCT_ENABLED 0 -#endif -// NRFX_NFCT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_NFCT_CONFIG_IRQ_PRIORITY -#define NRFX_NFCT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_NFCT_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_NFCT_CONFIG_LOG_ENABLED -#define NRFX_NFCT_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_NFCT_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_NFCT_CONFIG_LOG_LEVEL -#define NRFX_NFCT_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_NFCT_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_NFCT_CONFIG_INFO_COLOR -#define NRFX_NFCT_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_NFCT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_NFCT_CONFIG_DEBUG_COLOR -#define NRFX_NFCT_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver -//========================================================== -#ifndef NRFX_PDM_ENABLED -#define NRFX_PDM_ENABLED 0 -#endif -// NRFX_PDM_CONFIG_MODE - Mode - -// <0=> Stereo -// <1=> Mono - -#ifndef NRFX_PDM_CONFIG_MODE -#define NRFX_PDM_CONFIG_MODE 1 -#endif - -// NRFX_PDM_CONFIG_EDGE - Edge - -// <0=> Left falling -// <1=> Left rising - -#ifndef NRFX_PDM_CONFIG_EDGE -#define NRFX_PDM_CONFIG_EDGE 0 -#endif - -// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency - -// <134217728=> 1000k -// <138412032=> 1032k (default) -// <142606336=> 1067k - -#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ -#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 -#endif - -// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY -#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_PDM_CONFIG_LOG_ENABLED -#define NRFX_PDM_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_PDM_CONFIG_LOG_LEVEL -#define NRFX_PDM_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_PDM_CONFIG_INFO_COLOR -#define NRFX_PDM_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_PDM_CONFIG_DEBUG_COLOR -#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver -//========================================================== -#ifndef NRFX_POWER_ENABLED -#define NRFX_POWER_ENABLED 1 -#endif -// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY -#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator - - -// This settings means only that components for DCDC regulator are installed and it can be enabled. - -#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN -#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 -#endif - -// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator - - -// This settings means only that components for DCDC regulator are installed and it can be enabled. - -#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV -#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 -#endif - -// - -// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator -//========================================================== -#ifndef NRFX_PPI_ENABLED -#define NRFX_PPI_ENABLED 0 -#endif -// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_PPI_CONFIG_LOG_ENABLED -#define NRFX_PPI_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_PPI_CONFIG_LOG_LEVEL -#define NRFX_PPI_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_PPI_CONFIG_INFO_COLOR -#define NRFX_PPI_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_PPI_CONFIG_DEBUG_COLOR -#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver -//========================================================== -#ifndef NRFX_PWM_ENABLED -#define NRFX_PWM_ENABLED 0 -#endif -// NRFX_PWM0_ENABLED - Enable PWM0 instance - - -#ifndef NRFX_PWM0_ENABLED -#define NRFX_PWM0_ENABLED 0 -#endif - -// NRFX_PWM1_ENABLED - Enable PWM1 instance - - -#ifndef NRFX_PWM1_ENABLED -#define NRFX_PWM1_ENABLED 0 -#endif - -// NRFX_PWM2_ENABLED - Enable PWM2 instance - - -#ifndef NRFX_PWM2_ENABLED -#define NRFX_PWM2_ENABLED 0 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> - - -#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN -#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> - - -#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN -#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> - - -#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN -#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> - - -#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN -#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock - -// <0=> 16 MHz -// <1=> 8 MHz -// <2=> 4 MHz -// <3=> 2 MHz -// <4=> 1 MHz -// <5=> 500 kHz -// <6=> 250 kHz -// <7=> 125 kHz - -#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK -#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode - -// <0=> Up -// <1=> Up and Down - -#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE -#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value -#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE -#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode - -// <0=> Common -// <1=> Grouped -// <2=> Individual -// <3=> Waveform - -#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE -#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode - -// <0=> Auto -// <1=> Triggered - -#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE -#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 -#endif - -// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_PWM_CONFIG_LOG_ENABLED -#define NRFX_PWM_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_PWM_CONFIG_LOG_LEVEL -#define NRFX_PWM_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_PWM_CONFIG_INFO_COLOR -#define NRFX_PWM_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_PWM_CONFIG_DEBUG_COLOR -#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. - -// The workaround uses interrupts to wake up the CPU and ensure -// it is active when PWM is about to start a DMA transfer. For -// initial transfer, done when a playback is started via PPI, -// a specific EGU instance is used to generate the interrupt. -// During the playback, the PWM interrupt triggered on SEQEND -// event of a preceding sequence is used to protect the transfer -// done for the next sequence to be played. -//========================================================== -#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif -// NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE - EGU instance used by the nRF52 Anomaly 109 workaround for PWM. - -// <0=> EGU0 -// <1=> EGU1 -// <2=> EGU2 -// <3=> EGU3 -// <4=> EGU4 -// <5=> EGU5 - -#ifndef NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE -#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 -#endif - -// - -// - -// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver -//========================================================== -#ifndef NRFX_QDEC_ENABLED -#define NRFX_QDEC_ENABLED 0 -#endif -// NRFX_QDEC_CONFIG_REPORTPER - Report period - -// <0=> 10 Samples -// <1=> 40 Samples -// <2=> 80 Samples -// <3=> 120 Samples -// <4=> 160 Samples -// <5=> 200 Samples -// <6=> 240 Samples -// <7=> 280 Samples - -#ifndef NRFX_QDEC_CONFIG_REPORTPER -#define NRFX_QDEC_CONFIG_REPORTPER 0 -#endif - -// NRFX_QDEC_CONFIG_SAMPLEPER - Sample period - -// <0=> 128 us -// <1=> 256 us -// <2=> 512 us -// <3=> 1024 us -// <4=> 2048 us -// <5=> 4096 us -// <6=> 8192 us -// <7=> 16384 us - -#ifndef NRFX_QDEC_CONFIG_SAMPLEPER -#define NRFX_QDEC_CONFIG_SAMPLEPER 7 -#endif - -// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> - - -#ifndef NRFX_QDEC_CONFIG_PIO_A -#define NRFX_QDEC_CONFIG_PIO_A 31 -#endif - -// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> - - -#ifndef NRFX_QDEC_CONFIG_PIO_B -#define NRFX_QDEC_CONFIG_PIO_B 31 -#endif - -// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> - - -#ifndef NRFX_QDEC_CONFIG_PIO_LED -#define NRFX_QDEC_CONFIG_PIO_LED 31 -#endif - -// NRFX_QDEC_CONFIG_LEDPRE - LED pre -#ifndef NRFX_QDEC_CONFIG_LEDPRE -#define NRFX_QDEC_CONFIG_LEDPRE 511 -#endif - -// NRFX_QDEC_CONFIG_LEDPOL - LED polarity - -// <0=> Active low -// <1=> Active high - -#ifndef NRFX_QDEC_CONFIG_LEDPOL -#define NRFX_QDEC_CONFIG_LEDPOL 1 -#endif - -// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable - - -#ifndef NRFX_QDEC_CONFIG_DBFEN -#define NRFX_QDEC_CONFIG_DBFEN 0 -#endif - -// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable - - -#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN -#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 -#endif - -// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY -#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED -#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL -#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_QDEC_CONFIG_INFO_COLOR -#define NRFX_QDEC_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_QDEC_CONFIG_DEBUG_COLOR -#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver -//========================================================== -#ifndef NRFX_RNG_ENABLED -#define NRFX_RNG_ENABLED 0 -#endif -// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction - - -#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION -#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 -#endif - -// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY -#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_RNG_CONFIG_LOG_ENABLED -#define NRFX_RNG_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_RNG_CONFIG_LOG_LEVEL -#define NRFX_RNG_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_RNG_CONFIG_INFO_COLOR -#define NRFX_RNG_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_RNG_CONFIG_DEBUG_COLOR -#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver -//========================================================== -#ifndef NRFX_RTC_ENABLED -#define NRFX_RTC_ENABLED 0 -#endif -// NRFX_RTC0_ENABLED - Enable RTC0 instance - - -#ifndef NRFX_RTC0_ENABLED -#define NRFX_RTC0_ENABLED 0 -#endif - -// NRFX_RTC1_ENABLED - Enable RTC1 instance - - -#ifndef NRFX_RTC1_ENABLED -#define NRFX_RTC1_ENABLED 0 -#endif - -// NRFX_RTC2_ENABLED - Enable RTC2 instance - - -#ifndef NRFX_RTC2_ENABLED -#define NRFX_RTC2_ENABLED 0 -#endif - -// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt -#ifndef NRFX_RTC_MAXIMUM_LATENCY_US -#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 -#endif - -// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> - - -#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY -#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 -#endif - -// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering - - -#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE -#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 -#endif - -// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_RTC_CONFIG_LOG_ENABLED -#define NRFX_RTC_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_RTC_CONFIG_LOG_LEVEL -#define NRFX_RTC_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_RTC_CONFIG_INFO_COLOR -#define NRFX_RTC_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_RTC_CONFIG_DEBUG_COLOR -#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver -//========================================================== -#ifndef NRFX_SAADC_ENABLED -#define NRFX_SAADC_ENABLED 0 -#endif -// NRFX_SAADC_CONFIG_RESOLUTION - Resolution - -// <0=> 8 bit -// <1=> 10 bit -// <2=> 12 bit -// <3=> 14 bit - -#ifndef NRFX_SAADC_CONFIG_RESOLUTION -#define NRFX_SAADC_CONFIG_RESOLUTION 1 -#endif - -// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period - -// <0=> Disabled -// <1=> 2x -// <2=> 4x -// <3=> 8x -// <4=> 16x -// <5=> 32x -// <6=> 64x -// <7=> 128x -// <8=> 256x - -#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE -#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 -#endif - -// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode - - -#ifndef NRFX_SAADC_CONFIG_LP_MODE -#define NRFX_SAADC_CONFIG_LP_MODE 0 -#endif - -// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY -#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED -#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL -#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SAADC_CONFIG_INFO_COLOR -#define NRFX_SAADC_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SAADC_CONFIG_DEBUG_COLOR -#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver -//========================================================== -#ifndef NRFX_SPIM_ENABLED -#define NRFX_SPIM_ENABLED 0 -#endif -// NRFX_SPIM0_ENABLED - Enable SPIM0 instance - - -#ifndef NRFX_SPIM0_ENABLED -#define NRFX_SPIM0_ENABLED 0 -#endif - -// NRFX_SPIM1_ENABLED - Enable SPIM1 instance - - -#ifndef NRFX_SPIM1_ENABLED -#define NRFX_SPIM1_ENABLED 0 -#endif - -// NRFX_SPIM2_ENABLED - Enable SPIM2 instance - - -#ifndef NRFX_SPIM2_ENABLED -#define NRFX_SPIM2_ENABLED 0 -#endif - -// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. - -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP - -#ifndef NRFX_SPIM_MISO_PULL_CFG -#define NRFX_SPIM_MISO_PULL_CFG 1 -#endif - -// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED -#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL -#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_SPIM_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SPIM_CONFIG_INFO_COLOR -#define NRFX_SPIM_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_SPIM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SPIM_CONFIG_DEBUG_COLOR -#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. - - -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ - -#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif - -// - -// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver -//========================================================== -#ifndef NRFX_SPIS_ENABLED -#define NRFX_SPIS_ENABLED 0 -#endif -// NRFX_SPIS0_ENABLED - Enable SPIS0 instance - - -#ifndef NRFX_SPIS0_ENABLED -#define NRFX_SPIS0_ENABLED 0 -#endif - -// NRFX_SPIS1_ENABLED - Enable SPIS1 instance - - -#ifndef NRFX_SPIS1_ENABLED -#define NRFX_SPIS1_ENABLED 0 -#endif - -// NRFX_SPIS2_ENABLED - Enable SPIS2 instance - - -#ifndef NRFX_SPIS2_ENABLED -#define NRFX_SPIS2_ENABLED 0 -#endif - -// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> - - -#ifndef NRFX_SPIS_DEFAULT_DEF -#define NRFX_SPIS_DEFAULT_DEF 255 -#endif - -// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> - - -#ifndef NRFX_SPIS_DEFAULT_ORC -#define NRFX_SPIS_DEFAULT_ORC 255 -#endif - -// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED -#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL -#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SPIS_CONFIG_INFO_COLOR -#define NRFX_SPIS_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SPIS_CONFIG_DEBUG_COLOR -#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. - - -// The workaround uses a GPIOTE channel to generate interrupts -// on falling edges detected on the CSN line. This will make -// the CPU active for the moment when SPIS starts DMA transfers, -// and this way the transfers will be protected. -// This workaround uses GPIOTE driver, so this driver must be -// enabled as well. - -#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif - -// - -// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver -//========================================================== -#ifndef NRFX_SPI_ENABLED -#define NRFX_SPI_ENABLED 0 -#endif -// NRFX_SPI0_ENABLED - Enable SPI0 instance - - -#ifndef NRFX_SPI0_ENABLED -#define NRFX_SPI0_ENABLED 0 -#endif - -// NRFX_SPI1_ENABLED - Enable SPI1 instance - - -#ifndef NRFX_SPI1_ENABLED -#define NRFX_SPI1_ENABLED 0 -#endif - -// NRFX_SPI2_ENABLED - Enable SPI2 instance - - -#ifndef NRFX_SPI2_ENABLED -#define NRFX_SPI2_ENABLED 0 -#endif - -// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. - -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP - -#ifndef NRFX_SPI_MISO_PULL_CFG -#define NRFX_SPI_MISO_PULL_CFG 1 -#endif - -// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_SPI_CONFIG_LOG_ENABLED -#define NRFX_SPI_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_SPI_CONFIG_LOG_LEVEL -#define NRFX_SPI_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SPI_CONFIG_INFO_COLOR -#define NRFX_SPI_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SPI_CONFIG_DEBUG_COLOR -#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator -//========================================================== -#ifndef NRFX_SWI_ENABLED -#define NRFX_SWI_ENABLED 0 -#endif -// NRFX_EGU_ENABLED - Enable EGU support - - -#ifndef NRFX_EGU_ENABLED -#define NRFX_EGU_ENABLED 0 -#endif - -// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver - - -#ifndef NRFX_SWI0_DISABLED -#define NRFX_SWI0_DISABLED 0 -#endif - -// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver - - -#ifndef NRFX_SWI1_DISABLED -#define NRFX_SWI1_DISABLED 0 -#endif - -// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver - - -#ifndef NRFX_SWI2_DISABLED -#define NRFX_SWI2_DISABLED 0 -#endif - -// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver - - -#ifndef NRFX_SWI3_DISABLED -#define NRFX_SWI3_DISABLED 0 -#endif - -// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver - - -#ifndef NRFX_SWI4_DISABLED -#define NRFX_SWI4_DISABLED 0 -#endif - -// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver - - -#ifndef NRFX_SWI5_DISABLED -#define NRFX_SWI5_DISABLED 0 -#endif - -// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_SWI_CONFIG_LOG_ENABLED -#define NRFX_SWI_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_SWI_CONFIG_LOG_LEVEL -#define NRFX_SWI_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SWI_CONFIG_INFO_COLOR -#define NRFX_SWI_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_SWI_CONFIG_DEBUG_COLOR -#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver -//========================================================== -#ifndef NRFX_TIMER_ENABLED -#define NRFX_TIMER_ENABLED 0 -#endif -// NRFX_TIMER0_ENABLED - Enable TIMER0 instance - - -#ifndef NRFX_TIMER0_ENABLED -#define NRFX_TIMER0_ENABLED 0 -#endif - -// NRFX_TIMER1_ENABLED - Enable TIMER1 instance - - -#ifndef NRFX_TIMER1_ENABLED -#define NRFX_TIMER1_ENABLED 0 -#endif - -// NRFX_TIMER2_ENABLED - Enable TIMER2 instance - - -#ifndef NRFX_TIMER2_ENABLED -#define NRFX_TIMER2_ENABLED 0 -#endif - -// NRFX_TIMER3_ENABLED - Enable TIMER3 instance - - -#ifndef NRFX_TIMER3_ENABLED -#define NRFX_TIMER3_ENABLED 0 -#endif - -// NRFX_TIMER4_ENABLED - Enable TIMER4 instance - - -#ifndef NRFX_TIMER4_ENABLED -#define NRFX_TIMER4_ENABLED 0 -#endif - -// NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode - -// <0=> 16 MHz -// <1=> 8 MHz -// <2=> 4 MHz -// <3=> 2 MHz -// <4=> 1 MHz -// <5=> 500 kHz -// <6=> 250 kHz -// <7=> 125 kHz -// <8=> 62.5 kHz -// <9=> 31.25 kHz - -#ifndef NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY -#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 -#endif - -// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation - -// <0=> Timer -// <1=> Counter - -#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE -#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 -#endif - -// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width - -// <0=> 16 bit -// <1=> 8 bit -// <2=> 24 bit -// <3=> 32 bit - -#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH -#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 -#endif - -// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED -#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL -#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_TIMER_CONFIG_INFO_COLOR -#define NRFX_TIMER_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_TIMER_CONFIG_DEBUG_COLOR -#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver -//========================================================== -#ifndef NRFX_TWIM_ENABLED -#define NRFX_TWIM_ENABLED 0 -#endif -// NRFX_TWIM0_ENABLED - Enable TWIM0 instance - - -#ifndef NRFX_TWIM0_ENABLED -#define NRFX_TWIM0_ENABLED 0 -#endif - -// NRFX_TWIM1_ENABLED - Enable TWIM1 instance - - -#ifndef NRFX_TWIM1_ENABLED -#define NRFX_TWIM1_ENABLED 0 -#endif - -// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency - -// <26738688=> 100k -// <67108864=> 250k -// <104857600=> 400k - -#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY -#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 -#endif - -// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit - - -#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT -#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 -#endif - -// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED -#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL -#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_TWIM_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_TWIM_CONFIG_INFO_COLOR -#define NRFX_TWIM_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_TWIM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_TWIM_CONFIG_DEBUG_COLOR -#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. - - -// The workaround uses interrupts to wake up the CPU by catching -// the start event of zero-frequency transmission, clear the -// peripheral, set desired frequency, start the peripheral, and -// the proper transmission. See more in the Errata document or -// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ - -#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif - -// - -// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver -//========================================================== -#ifndef NRFX_TWIS_ENABLED -#define NRFX_TWIS_ENABLED 0 -#endif -// NRFX_TWIS0_ENABLED - Enable TWIS0 instance - - -#ifndef NRFX_TWIS0_ENABLED -#define NRFX_TWIS0_ENABLED 0 -#endif - -// NRFX_TWIS1_ENABLED - Enable TWIS1 instance - - -#ifndef NRFX_TWIS1_ENABLED -#define NRFX_TWIS1_ENABLED 0 -#endif - -// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once - - -// Optimization flag. Registers used by TWIS are shared by other peripherals. Normally, during initialization driver tries to clear all registers to known state before doing the initialization itself. This gives initialization safe procedure, no matter when it would be called. If you activate TWIS only once and do never uninitialize it - set this flag to 1 what gives more optimal code. - -#ifndef NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY -#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 -#endif - -// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode - - -// Synchronous mode would be used in specific situations. And it uses some additional code and data memory to safely process state machine by polling it in status functions. If this functionality is not required it may be disabled to free some resources. - -#ifndef NRFX_TWIS_NO_SYNC_MODE -#define NRFX_TWIS_NO_SYNC_MODE 0 -#endif - -// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 -#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 -#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 -#endif - -// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 -#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 -#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 -#endif - -// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration - -// <0=> Disabled -// <1=> Pull down -// <3=> Pull up - -#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL -#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 -#endif - -// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration - -// <0=> Disabled -// <1=> Pull down -// <3=> Pull up - -#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL -#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 -#endif - -// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED -#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL -#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_TWIS_CONFIG_INFO_COLOR -#define NRFX_TWIS_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_TWIS_CONFIG_DEBUG_COLOR -#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver -//========================================================== -#ifndef NRFX_TWI_ENABLED -#define NRFX_TWI_ENABLED 0 -#endif -// NRFX_TWI0_ENABLED - Enable TWI0 instance - - -#ifndef NRFX_TWI0_ENABLED -#define NRFX_TWI0_ENABLED 0 -#endif - -// NRFX_TWI1_ENABLED - Enable TWI1 instance - - -#ifndef NRFX_TWI1_ENABLED -#define NRFX_TWI1_ENABLED 0 -#endif - -// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency - -// <26738688=> 100k -// <67108864=> 250k -// <104857600=> 400k - -#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY -#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 -#endif - -// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit - - -#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT -#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 -#endif - -// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_TWI_CONFIG_LOG_ENABLED -#define NRFX_TWI_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_TWI_CONFIG_LOG_LEVEL -#define NRFX_TWI_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_TWI_CONFIG_INFO_COLOR -#define NRFX_TWI_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_TWI_CONFIG_DEBUG_COLOR -#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver -//========================================================== -#ifndef NRFX_UARTE_ENABLED -#define NRFX_UARTE_ENABLED 0 -#endif -// NRFX_UARTE0_ENABLED - Enable UARTE0 instance -#ifndef NRFX_UARTE0_ENABLED -#define NRFX_UARTE0_ENABLED 0 -#endif - -// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control - -// <0=> Disabled -// <1=> Enabled - -#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC -#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 -#endif - -// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity - -// <0=> Excluded -// <14=> Included - -#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY -#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 -#endif - -// NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE - Default Baudrate - -// <323584=> 1200 baud -// <643072=> 2400 baud -// <1290240=> 4800 baud -// <2576384=> 9600 baud -// <3862528=> 14400 baud -// <5152768=> 19200 baud -// <7716864=> 28800 baud -// <8388608=> 31250 baud -// <10289152=> 38400 baud -// <15007744=> 56000 baud -// <15400960=> 57600 baud -// <20615168=> 76800 baud -// <30801920=> 115200 baud -// <61865984=> 230400 baud -// <67108864=> 250000 baud -// <121634816=> 460800 baud -// <251658240=> 921600 baud -// <268435456=> 1000000 baud - -#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE -#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 -#endif - -// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED -#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL -#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_UARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_UARTE_CONFIG_INFO_COLOR -#define NRFX_UARTE_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_UARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_UARTE_CONFIG_DEBUG_COLOR -#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver -//========================================================== -#ifndef NRFX_UART_ENABLED -#define NRFX_UART_ENABLED 0 -#endif -// NRFX_UART0_ENABLED - Enable UART0 instance -#ifndef NRFX_UART0_ENABLED -#define NRFX_UART0_ENABLED 0 -#endif - -// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control - -// <0=> Disabled -// <1=> Enabled - -#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC -#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 -#endif - -// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity - -// <0=> Excluded -// <14=> Included - -#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY -#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 -#endif - -// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate - -// <323584=> 1200 baud -// <643072=> 2400 baud -// <1290240=> 4800 baud -// <2576384=> 9600 baud -// <3866624=> 14400 baud -// <5152768=> 19200 baud -// <7729152=> 28800 baud -// <8388608=> 31250 baud -// <10309632=> 38400 baud -// <15007744=> 56000 baud -// <15462400=> 57600 baud -// <20615168=> 76800 baud -// <30924800=> 115200 baud -// <61845504=> 230400 baud -// <67108864=> 250000 baud -// <123695104=> 460800 baud -// <247386112=> 921600 baud -// <268435456=> 1000000 baud - -#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE -#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 -#endif - -// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_UART_CONFIG_LOG_ENABLED -#define NRFX_UART_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_UART_CONFIG_LOG_LEVEL -#define NRFX_UART_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_UART_CONFIG_INFO_COLOR -#define NRFX_UART_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_UART_CONFIG_DEBUG_COLOR -#define NRFX_UART_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver -//========================================================== -#ifndef NRFX_WDT_ENABLED -#define NRFX_WDT_ENABLED 0 -#endif -// NRFX_WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode - -// <1=> Run in SLEEP, Pause in HALT -// <8=> Pause in SLEEP, Run in HALT -// <9=> Run in SLEEP and HALT -// <0=> Pause in SLEEP and HALT - -#ifndef NRFX_WDT_CONFIG_BEHAVIOUR -#define NRFX_WDT_CONFIG_BEHAVIOUR 1 -#endif - -// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value in ms <1-131072000> - - -#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE -#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 -#endif - -// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver - -// <0=> Include WDT IRQ handling -// <1=> Remove WDT IRQ handling - -#ifndef NRFX_WDT_CONFIG_NO_IRQ -#define NRFX_WDT_CONFIG_NO_IRQ 0 -#endif - -// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority - -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY -#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRFX_WDT_CONFIG_LOG_ENABLED -#define NRFX_WDT_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_WDT_CONFIG_LOG_LEVEL -#define NRFX_WDT_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_WDT_CONFIG_INFO_COLOR -#define NRFX_WDT_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_WDT_CONFIG_DEBUG_COLOR -#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// - -// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer -//========================================================== -#ifndef NRF_CLOCK_ENABLED -#define NRF_CLOCK_ENABLED 0 -#endif -// CLOCK_CONFIG_LF_SRC - LF Clock Source - -// <0=> RC -// <1=> XTAL -// <2=> Synth -// <131073=> External Low Swing -// <196609=> External Full Swing - -#ifndef CLOCK_CONFIG_LF_SRC -#define CLOCK_CONFIG_LF_SRC 1 -#endif - -// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source - - -#ifndef CLOCK_CONFIG_LF_CAL_ENABLED -#define CLOCK_CONFIG_LF_CAL_ENABLED 0 -#endif - -// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef CLOCK_CONFIG_IRQ_PRIORITY -#define CLOCK_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer -//========================================================== -#ifndef PDM_ENABLED -#define PDM_ENABLED 0 -#endif -// PDM_CONFIG_MODE - Mode - -// <0=> Stereo -// <1=> Mono - -#ifndef PDM_CONFIG_MODE -#define PDM_CONFIG_MODE 1 -#endif - -// PDM_CONFIG_EDGE - Edge - -// <0=> Left falling -// <1=> Left rising - -#ifndef PDM_CONFIG_EDGE -#define PDM_CONFIG_EDGE 0 -#endif - -// PDM_CONFIG_CLOCK_FREQ - Clock frequency - -// <134217728=> 1000k -// <138412032=> 1032k (default) -// <142606336=> 1067k - -#ifndef PDM_CONFIG_CLOCK_FREQ -#define PDM_CONFIG_CLOCK_FREQ 138412032 -#endif - -// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef PDM_CONFIG_IRQ_PRIORITY -#define PDM_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer -//========================================================== -#ifndef POWER_ENABLED -#define POWER_ENABLED 1 -#endif -// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef POWER_CONFIG_IRQ_PRIORITY -#define POWER_CONFIG_IRQ_PRIORITY 6 -#endif - -// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator - - -// This settings means only that components for DCDC regulator are installed and it can be enabled. - -#ifndef POWER_CONFIG_DEFAULT_DCDCEN -#define POWER_CONFIG_DEFAULT_DCDCEN 0 -#endif - -// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator - - -// This settings means only that components for DCDC regulator are installed and it can be enabled. - -#ifndef POWER_CONFIG_DEFAULT_DCDCENHV -#define POWER_CONFIG_DEFAULT_DCDCENHV 0 -#endif - -// - -// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer - - -#ifndef PPI_ENABLED -#define PPI_ENABLED 0 -#endif - -// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer -//========================================================== -#ifndef PWM_ENABLED -#define PWM_ENABLED 0 -#endif -// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> - - -#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN -#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 -#endif - -// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> - - -#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN -#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 -#endif - -// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> - - -#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN -#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 -#endif - -// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> - - -#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN -#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 -#endif - -// PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock - -// <0=> 16 MHz -// <1=> 8 MHz -// <2=> 4 MHz -// <3=> 2 MHz -// <4=> 1 MHz -// <5=> 500 kHz -// <6=> 250 kHz -// <7=> 125 kHz - -#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK -#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 -#endif - -// PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode - -// <0=> Up -// <1=> Up and Down - -#ifndef PWM_DEFAULT_CONFIG_COUNT_MODE -#define PWM_DEFAULT_CONFIG_COUNT_MODE 0 -#endif - -// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value -#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE -#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 -#endif - -// PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode - -// <0=> Common -// <1=> Grouped -// <2=> Individual -// <3=> Waveform - -#ifndef PWM_DEFAULT_CONFIG_LOAD_MODE -#define PWM_DEFAULT_CONFIG_LOAD_MODE 0 -#endif - -// PWM_DEFAULT_CONFIG_STEP_MODE - Step mode - -// <0=> Auto -// <1=> Triggered - -#ifndef PWM_DEFAULT_CONFIG_STEP_MODE -#define PWM_DEFAULT_CONFIG_STEP_MODE 0 -#endif - -// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef PWM_DEFAULT_CONFIG_IRQ_PRIORITY -#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// PWM0_ENABLED - Enable PWM0 instance - - -#ifndef PWM0_ENABLED -#define PWM0_ENABLED 0 -#endif - -// PWM1_ENABLED - Enable PWM1 instance - - -#ifndef PWM1_ENABLED -#define PWM1_ENABLED 0 -#endif - -// PWM2_ENABLED - Enable PWM2 instance - - -#ifndef PWM2_ENABLED -#define PWM2_ENABLED 0 -#endif - -// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. - -// The workaround uses interrupts to wake up the CPU and ensure -// it is active when PWM is about to start a DMA transfer. For -// initial transfer, done when a playback is started via PPI, -// a specific EGU instance is used to generate the interrupt. -// During the playback, the PWM interrupt triggered on SEQEND -// event of a preceding sequence is used to protect the transfer -// done for the next sequence to be played. -//========================================================== -#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif -// PWM_NRF52_ANOMALY_109_EGU_INSTANCE - EGU instance used by the nRF52 Anomaly 109 workaround for PWM. - -// <0=> EGU0 -// <1=> EGU1 -// <2=> EGU2 -// <3=> EGU3 -// <4=> EGU4 -// <5=> EGU5 - -#ifndef PWM_NRF52_ANOMALY_109_EGU_INSTANCE -#define PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 -#endif - -// - -// - -// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer -//========================================================== -#ifndef QDEC_ENABLED -#define QDEC_ENABLED 0 -#endif -// QDEC_CONFIG_REPORTPER - Report period - -// <0=> 10 Samples -// <1=> 40 Samples -// <2=> 80 Samples -// <3=> 120 Samples -// <4=> 160 Samples -// <5=> 200 Samples -// <6=> 240 Samples -// <7=> 280 Samples - -#ifndef QDEC_CONFIG_REPORTPER -#define QDEC_CONFIG_REPORTPER 0 -#endif - -// QDEC_CONFIG_SAMPLEPER - Sample period - -// <0=> 128 us -// <1=> 256 us -// <2=> 512 us -// <3=> 1024 us -// <4=> 2048 us -// <5=> 4096 us -// <6=> 8192 us -// <7=> 16384 us - -#ifndef QDEC_CONFIG_SAMPLEPER -#define QDEC_CONFIG_SAMPLEPER 7 -#endif - -// QDEC_CONFIG_PIO_A - A pin <0-31> - - -#ifndef QDEC_CONFIG_PIO_A -#define QDEC_CONFIG_PIO_A 31 -#endif - -// QDEC_CONFIG_PIO_B - B pin <0-31> - - -#ifndef QDEC_CONFIG_PIO_B -#define QDEC_CONFIG_PIO_B 31 -#endif - -// QDEC_CONFIG_PIO_LED - LED pin <0-31> - - -#ifndef QDEC_CONFIG_PIO_LED -#define QDEC_CONFIG_PIO_LED 31 -#endif - -// QDEC_CONFIG_LEDPRE - LED pre -#ifndef QDEC_CONFIG_LEDPRE -#define QDEC_CONFIG_LEDPRE 511 -#endif - -// QDEC_CONFIG_LEDPOL - LED polarity - -// <0=> Active low -// <1=> Active high - -#ifndef QDEC_CONFIG_LEDPOL -#define QDEC_CONFIG_LEDPOL 1 -#endif - -// QDEC_CONFIG_DBFEN - Debouncing enable - - -#ifndef QDEC_CONFIG_DBFEN -#define QDEC_CONFIG_DBFEN 0 -#endif - -// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable - - -#ifndef QDEC_CONFIG_SAMPLE_INTEN -#define QDEC_CONFIG_SAMPLE_INTEN 0 -#endif - -// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef QDEC_CONFIG_IRQ_PRIORITY -#define QDEC_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer -//========================================================== -#ifndef QSPI_ENABLED -#define QSPI_ENABLED 0 -#endif -// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> - - -#ifndef QSPI_CONFIG_SCK_DELAY -#define QSPI_CONFIG_SCK_DELAY 1 -#endif - -// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. -#ifndef QSPI_CONFIG_XIP_OFFSET -#define QSPI_CONFIG_XIP_OFFSET 0 -#endif - -// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. - -// <0=> FastRead -// <1=> Read2O -// <2=> Read2IO -// <3=> Read4O -// <4=> Read4IO - -#ifndef QSPI_CONFIG_READOC -#define QSPI_CONFIG_READOC 0 -#endif - -// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. - -// <0=> PP -// <1=> PP2O -// <2=> PP4O -// <3=> PP4IO - -#ifndef QSPI_CONFIG_WRITEOC -#define QSPI_CONFIG_WRITEOC 0 -#endif - -// QSPI_CONFIG_ADDRMODE - Addressing mode. - -// <0=> 24bit -// <1=> 32bit - -#ifndef QSPI_CONFIG_ADDRMODE -#define QSPI_CONFIG_ADDRMODE 0 -#endif - -// QSPI_CONFIG_MODE - SPI mode. - -// <0=> Mode 0 -// <1=> Mode 1 - -#ifndef QSPI_CONFIG_MODE -#define QSPI_CONFIG_MODE 0 -#endif - -// QSPI_CONFIG_FREQUENCY - Frequency divider. - -// <0=> 32MHz/1 -// <1=> 32MHz/2 -// <2=> 32MHz/3 -// <3=> 32MHz/4 -// <4=> 32MHz/5 -// <5=> 32MHz/6 -// <6=> 32MHz/7 -// <7=> 32MHz/8 -// <8=> 32MHz/9 -// <9=> 32MHz/10 -// <10=> 32MHz/11 -// <11=> 32MHz/12 -// <12=> 32MHz/13 -// <13=> 32MHz/14 -// <14=> 32MHz/15 -// <15=> 32MHz/16 - -#ifndef QSPI_CONFIG_FREQUENCY -#define QSPI_CONFIG_FREQUENCY 15 -#endif - -// QSPI_PIN_SCK - SCK pin value. -#ifndef QSPI_PIN_SCK -#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED -#endif - -// QSPI_PIN_CSN - CSN pin value. -#ifndef QSPI_PIN_CSN -#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED -#endif - -// QSPI_PIN_IO0 - IO0 pin value. -#ifndef QSPI_PIN_IO0 -#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED -#endif - -// QSPI_PIN_IO1 - IO1 pin value. -#ifndef QSPI_PIN_IO1 -#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED -#endif - -// QSPI_PIN_IO2 - IO2 pin value. -#ifndef QSPI_PIN_IO2 -#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED -#endif - -// QSPI_PIN_IO3 - IO3 pin value. -#ifndef QSPI_PIN_IO3 -#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED -#endif - -// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef QSPI_CONFIG_IRQ_PRIORITY -#define QSPI_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer -//========================================================== -#ifndef RNG_ENABLED -#define RNG_ENABLED 0 -#endif -// RNG_CONFIG_ERROR_CORRECTION - Error correction - - -#ifndef RNG_CONFIG_ERROR_CORRECTION -#define RNG_CONFIG_ERROR_CORRECTION 1 -#endif - -// RNG_CONFIG_POOL_SIZE - Pool size -#ifndef RNG_CONFIG_POOL_SIZE -#define RNG_CONFIG_POOL_SIZE 64 -#endif - -// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef RNG_CONFIG_IRQ_PRIORITY -#define RNG_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer -//========================================================== -#ifndef RTC_ENABLED -#define RTC_ENABLED 0 -#endif -// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> - - -#ifndef RTC_DEFAULT_CONFIG_FREQUENCY -#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 -#endif - -// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering - - -#ifndef RTC_DEFAULT_CONFIG_RELIABLE -#define RTC_DEFAULT_CONFIG_RELIABLE 0 -#endif - -// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY -#define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// RTC0_ENABLED - Enable RTC0 instance - - -#ifndef RTC0_ENABLED -#define RTC0_ENABLED 0 -#endif - -// RTC1_ENABLED - Enable RTC1 instance - - -#ifndef RTC1_ENABLED -#define RTC1_ENABLED 0 -#endif - -// RTC2_ENABLED - Enable RTC2 instance - - -#ifndef RTC2_ENABLED -#define RTC2_ENABLED 0 -#endif - -// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt -#ifndef NRF_MAXIMUM_LATENCY_US -#define NRF_MAXIMUM_LATENCY_US 2000 -#endif - -// - -// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer -//========================================================== -#ifndef SAADC_ENABLED -#define SAADC_ENABLED 0 -#endif -// SAADC_CONFIG_RESOLUTION - Resolution - -// <0=> 8 bit -// <1=> 10 bit -// <2=> 12 bit -// <3=> 14 bit - -#ifndef SAADC_CONFIG_RESOLUTION -#define SAADC_CONFIG_RESOLUTION 1 -#endif - -// SAADC_CONFIG_OVERSAMPLE - Sample period - -// <0=> Disabled -// <1=> 2x -// <2=> 4x -// <3=> 8x -// <4=> 16x -// <5=> 32x -// <6=> 64x -// <7=> 128x -// <8=> 256x - -#ifndef SAADC_CONFIG_OVERSAMPLE -#define SAADC_CONFIG_OVERSAMPLE 0 -#endif - -// SAADC_CONFIG_LP_MODE - Enabling low power mode - - -#ifndef SAADC_CONFIG_LP_MODE -#define SAADC_CONFIG_LP_MODE 0 -#endif - -// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef SAADC_CONFIG_IRQ_PRIORITY -#define SAADC_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer -//========================================================== -#ifndef SPIS_ENABLED -#define SPIS_ENABLED 0 -#endif -// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef SPIS_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// SPIS_DEFAULT_MODE - Mode - -// <0=> MODE_0 -// <1=> MODE_1 -// <2=> MODE_2 -// <3=> MODE_3 - -#ifndef SPIS_DEFAULT_MODE -#define SPIS_DEFAULT_MODE 0 -#endif - -// SPIS_DEFAULT_BIT_ORDER - SPIS default bit order - -// <0=> MSB first -// <1=> LSB first - -#ifndef SPIS_DEFAULT_BIT_ORDER -#define SPIS_DEFAULT_BIT_ORDER 0 -#endif - -// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> - - -#ifndef SPIS_DEFAULT_DEF -#define SPIS_DEFAULT_DEF 255 -#endif - -// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> - - -#ifndef SPIS_DEFAULT_ORC -#define SPIS_DEFAULT_ORC 255 -#endif - -// SPIS0_ENABLED - Enable SPIS0 instance - - -#ifndef SPIS0_ENABLED -#define SPIS0_ENABLED 0 -#endif - -// SPIS1_ENABLED - Enable SPIS1 instance - - -#ifndef SPIS1_ENABLED -#define SPIS1_ENABLED 0 -#endif - -// SPIS2_ENABLED - Enable SPIS2 instance - - -#ifndef SPIS2_ENABLED -#define SPIS2_ENABLED 0 -#endif - -// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. - - -// The workaround uses a GPIOTE channel to generate interrupts -// on falling edges detected on the CSN line. This will make -// the CPU active for the moment when SPIS starts DMA transfers, -// and this way the transfers will be protected. -// This workaround uses GPIOTE driver, so this driver must be -// enabled as well. - -#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif - -// - -// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer -//========================================================== -#ifndef SPI_ENABLED -#define SPI_ENABLED 0 -#endif -// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY -#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. - -// <0=> NRF_GPIO_PIN_NOPULL -// <1=> NRF_GPIO_PIN_PULLDOWN -// <3=> NRF_GPIO_PIN_PULLUP - -#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG -#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 -#endif - -// SPI0_ENABLED - Enable SPI0 instance -//========================================================== -#ifndef SPI0_ENABLED -#define SPI0_ENABLED 0 -#endif -// SPI0_USE_EASY_DMA - Use EasyDMA - - -#ifndef SPI0_USE_EASY_DMA -#define SPI0_USE_EASY_DMA 1 -#endif - -// - -// SPI1_ENABLED - Enable SPI1 instance -//========================================================== -#ifndef SPI1_ENABLED -#define SPI1_ENABLED 0 -#endif -// SPI1_USE_EASY_DMA - Use EasyDMA - - -#ifndef SPI1_USE_EASY_DMA -#define SPI1_USE_EASY_DMA 1 -#endif - -// - -// SPI2_ENABLED - Enable SPI2 instance -//========================================================== -#ifndef SPI2_ENABLED -#define SPI2_ENABLED 0 -#endif -// SPI2_USE_EASY_DMA - Use EasyDMA - - -#ifndef SPI2_USE_EASY_DMA -#define SPI2_USE_EASY_DMA 1 -#endif - -// - -// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. - - -// The workaround uses interrupts to wake up the CPU by catching -// a start event of zero-length transmission to start the clock. This -// ensures that the DMA transfer will be executed without issues and -// that the proper transfer will be started. See more in the Errata -// document or Anomaly 109 Addendum located at -// https://infocenter.nordicsemi.com/ - -#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif - -// - -// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer -//========================================================== -#ifndef TIMER_ENABLED -#define TIMER_ENABLED 0 -#endif -// TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode - -// <0=> 16 MHz -// <1=> 8 MHz -// <2=> 4 MHz -// <3=> 2 MHz -// <4=> 1 MHz -// <5=> 500 kHz -// <6=> 250 kHz -// <7=> 125 kHz -// <8=> 62.5 kHz -// <9=> 31.25 kHz - -#ifndef TIMER_DEFAULT_CONFIG_FREQUENCY -#define TIMER_DEFAULT_CONFIG_FREQUENCY 0 -#endif - -// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation - -// <0=> Timer -// <1=> Counter - -#ifndef TIMER_DEFAULT_CONFIG_MODE -#define TIMER_DEFAULT_CONFIG_MODE 0 -#endif - -// TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width - -// <0=> 16 bit -// <1=> 8 bit -// <2=> 24 bit -// <3=> 32 bit - -#ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH -#define TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 -#endif - -// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY -#define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// TIMER0_ENABLED - Enable TIMER0 instance - - -#ifndef TIMER0_ENABLED -#define TIMER0_ENABLED 0 -#endif - -// TIMER1_ENABLED - Enable TIMER1 instance - - -#ifndef TIMER1_ENABLED -#define TIMER1_ENABLED 0 -#endif - -// TIMER2_ENABLED - Enable TIMER2 instance - - -#ifndef TIMER2_ENABLED -#define TIMER2_ENABLED 0 -#endif - -// TIMER3_ENABLED - Enable TIMER3 instance - - -#ifndef TIMER3_ENABLED -#define TIMER3_ENABLED 0 -#endif - -// TIMER4_ENABLED - Enable TIMER4 instance - - -#ifndef TIMER4_ENABLED -#define TIMER4_ENABLED 0 -#endif - -// - -// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer -//========================================================== -#ifndef TWIS_ENABLED -#define TWIS_ENABLED 0 -#endif -// TWIS0_ENABLED - Enable TWIS0 instance - - -#ifndef TWIS0_ENABLED -#define TWIS0_ENABLED 0 -#endif - -// TWIS1_ENABLED - Enable TWIS1 instance - - -#ifndef TWIS1_ENABLED -#define TWIS1_ENABLED 0 -#endif - -// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once - - -// Optimization flag. Registers used by TWIS are shared by other peripherals. Normally, during initialization driver tries to clear all registers to known state before doing the initialization itself. This gives initialization safe procedure, no matter when it would be called. If you activate TWIS only once and do never uninitialize it - set this flag to 1 what gives more optimal code. - -#ifndef TWIS_ASSUME_INIT_AFTER_RESET_ONLY -#define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 -#endif - -// TWIS_NO_SYNC_MODE - Remove support for synchronous mode - - -// Synchronous mode would be used in specific situations. And it uses some additional code and data memory to safely process state machine by polling it in status functions. If this functionality is not required it may be disabled to free some resources. - -#ifndef TWIS_NO_SYNC_MODE -#define TWIS_NO_SYNC_MODE 0 -#endif - -// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 -#ifndef TWIS_DEFAULT_CONFIG_ADDR0 -#define TWIS_DEFAULT_CONFIG_ADDR0 0 -#endif - -// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 -#ifndef TWIS_DEFAULT_CONFIG_ADDR1 -#define TWIS_DEFAULT_CONFIG_ADDR1 0 -#endif - -// TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration - -// <0=> Disabled -// <1=> Pull down -// <3=> Pull up - -#ifndef TWIS_DEFAULT_CONFIG_SCL_PULL -#define TWIS_DEFAULT_CONFIG_SCL_PULL 0 -#endif - -// TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration - -// <0=> Disabled -// <1=> Pull down -// <3=> Pull up - -#ifndef TWIS_DEFAULT_CONFIG_SDA_PULL -#define TWIS_DEFAULT_CONFIG_SDA_PULL 0 -#endif - -// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef TWIS_DEFAULT_CONFIG_IRQ_PRIORITY -#define TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer -//========================================================== -#ifndef TWI_ENABLED -#define TWI_ENABLED 0 -#endif -// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency - -// <26738688=> 100k -// <67108864=> 250k -// <104857600=> 400k - -#ifndef TWI_DEFAULT_CONFIG_FREQUENCY -#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 -#endif - -// TWI_DEFAULT_CONFIG_CLR_BUS_INIT - Enables bus clearing procedure during init - - -#ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT -#define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0 -#endif - -// TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit - - -#ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT -#define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 -#endif - -// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY -#define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// TWI0_ENABLED - Enable TWI0 instance -//========================================================== -#ifndef TWI0_ENABLED -#define TWI0_ENABLED 0 -#endif -// TWI0_USE_EASY_DMA - Use EasyDMA (if present) - - -#ifndef TWI0_USE_EASY_DMA -#define TWI0_USE_EASY_DMA 0 -#endif - -// - -// TWI1_ENABLED - Enable TWI1 instance -//========================================================== -#ifndef TWI1_ENABLED -#define TWI1_ENABLED 0 -#endif -// TWI1_USE_EASY_DMA - Use EasyDMA (if present) - - -#ifndef TWI1_USE_EASY_DMA -#define TWI1_USE_EASY_DMA 0 -#endif - -// - -// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. - - -// The workaround uses interrupts to wake up the CPU by catching -// the start event of zero-frequency transmission, clear the -// peripheral, set desired frequency, start the peripheral, and -// the proper transmission. See more in the Errata document or -// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ - -#ifndef TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED -#define TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 -#endif - -// - -// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer -//========================================================== -#ifndef UART_ENABLED -#define UART_ENABLED 0 -#endif -// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control - -// <0=> Disabled -// <1=> Enabled - -#ifndef UART_DEFAULT_CONFIG_HWFC -#define UART_DEFAULT_CONFIG_HWFC 0 -#endif - -// UART_DEFAULT_CONFIG_PARITY - Parity - -// <0=> Excluded -// <14=> Included - -#ifndef UART_DEFAULT_CONFIG_PARITY -#define UART_DEFAULT_CONFIG_PARITY 0 -#endif - -// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate - -// <323584=> 1200 baud -// <643072=> 2400 baud -// <1290240=> 4800 baud -// <2576384=> 9600 baud -// <3862528=> 14400 baud -// <5152768=> 19200 baud -// <7716864=> 28800 baud -// <10289152=> 38400 baud -// <15400960=> 57600 baud -// <20615168=> 76800 baud -// <30801920=> 115200 baud -// <61865984=> 230400 baud -// <67108864=> 250000 baud -// <121634816=> 460800 baud -// <251658240=> 921600 baud -// <268435456=> 1000000 baud - -#ifndef UART_DEFAULT_CONFIG_BAUDRATE -#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 -#endif - -// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY -#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 -#endif - -// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA - - -#ifndef UART_EASY_DMA_SUPPORT -#define UART_EASY_DMA_SUPPORT 1 -#endif - -// UART_LEGACY_SUPPORT - Driver supporting Legacy mode - - -#ifndef UART_LEGACY_SUPPORT -#define UART_LEGACY_SUPPORT 1 -#endif - -// UART0_ENABLED - Enable UART0 instance -//========================================================== -#ifndef UART0_ENABLED -#define UART0_ENABLED 0 -#endif -// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA - - -#ifndef UART0_CONFIG_USE_EASY_DMA -#define UART0_CONFIG_USE_EASY_DMA 1 -#endif - -// - -// - -// USBD_ENABLED - nrf_drv_usbd - Software Component -//========================================================== -#ifndef USBD_ENABLED -#define USBD_ENABLED 0 -#endif -// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef USBD_CONFIG_IRQ_PRIORITY -#define USBD_CONFIG_IRQ_PRIORITY 6 -#endif - -// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme - -// <0=> Prioritized access -// <1=> Round Robin - -#ifndef USBD_CONFIG_DMASCHEDULER_MODE -#define USBD_CONFIG_DMASCHEDULER_MODE 0 -#endif - -// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers - - -// This option gives priority to isochronous transfers. -// Enabling it assures that isochronous transfers are always processed, -// even if multiple other transfers are pending. -// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm -// function is called, so the option is independent of the algorithm chosen. - -#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST -#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 -#endif - -// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready - - -// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. -// Else, there will be no response. -// NOTE: This option does not work on Engineering A chip. - -#ifndef USBD_CONFIG_ISO_IN_ZLP -#define USBD_CONFIG_ISO_IN_ZLP 0 -#endif - -// - -// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer -//========================================================== -#ifndef WDT_ENABLED -#define WDT_ENABLED 0 -#endif -// WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode - -// <1=> Run in SLEEP, Pause in HALT -// <8=> Pause in SLEEP, Run in HALT -// <9=> Run in SLEEP and HALT -// <0=> Pause in SLEEP and HALT - -#ifndef WDT_CONFIG_BEHAVIOUR -#define WDT_CONFIG_BEHAVIOUR 1 -#endif - -// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> - - -#ifndef WDT_CONFIG_RELOAD_VALUE -#define WDT_CONFIG_RELOAD_VALUE 2000 -#endif - -// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef WDT_CONFIG_IRQ_PRIORITY -#define WDT_CONFIG_IRQ_PRIORITY 6 -#endif - -// - -// nrfx_qspi - QSPI peripheral driver - -//========================================================== -// -//========================================================== - -// nrfx_usbd - USBD peripheral driver - -//========================================================== -// -//========================================================== - -// -//========================================================== - -// nRF_Drivers_External - -//========================================================== -// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module - - -#ifndef NRF_TWI_SENSOR_ENABLED -#define NRF_TWI_SENSOR_ENABLED 0 -#endif - -// -//========================================================== - -// nRF_Libraries - -//========================================================== -// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher - - -#ifndef APP_GPIOTE_ENABLED -#define APP_GPIOTE_ENABLED 0 -#endif - -// APP_PWM_ENABLED - app_pwm - PWM functionality - - -#ifndef APP_PWM_ENABLED -#define APP_PWM_ENABLED 0 -#endif - -// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler -//========================================================== -#ifndef APP_SCHEDULER_ENABLED -#define APP_SCHEDULER_ENABLED 0 -#endif -// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature - - -#ifndef APP_SCHEDULER_WITH_PAUSE -#define APP_SCHEDULER_WITH_PAUSE 0 -#endif - -// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling - - -#ifndef APP_SCHEDULER_WITH_PROFILER -#define APP_SCHEDULER_WITH_PROFILER 0 -#endif - -// - -// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI -//========================================================== -#ifndef APP_SDCARD_ENABLED -#define APP_SDCARD_ENABLED 0 -#endif -// APP_SDCARD_SPI_INSTANCE - SPI instance used - -// <0=> 0 -// <1=> 1 -// <2=> 2 - -#ifndef APP_SDCARD_SPI_INSTANCE -#define APP_SDCARD_SPI_INSTANCE 0 -#endif - -// APP_SDCARD_FREQ_INIT - SPI frequency - -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz - -#ifndef APP_SDCARD_FREQ_INIT -#define APP_SDCARD_FREQ_INIT 67108864 -#endif - -// APP_SDCARD_FREQ_DATA - SPI frequency - -// <33554432=> 125 kHz -// <67108864=> 250 kHz -// <134217728=> 500 kHz -// <268435456=> 1 MHz -// <536870912=> 2 MHz -// <1073741824=> 4 MHz -// <2147483648=> 8 MHz - -#ifndef APP_SDCARD_FREQ_DATA -#define APP_SDCARD_FREQ_DATA 1073741824 -#endif - -// - -// APP_TIMER_ENABLED - app_timer - Application timer functionality -//========================================================== -#ifndef APP_TIMER_ENABLED -#define APP_TIMER_ENABLED 0 -#endif -// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. - -// <0=> 32768 Hz -// <1=> 16384 Hz -// <3=> 8192 Hz -// <7=> 4096 Hz -// <15=> 2048 Hz -// <31=> 1024 Hz - -#ifndef APP_TIMER_CONFIG_RTC_FREQUENCY -#define APP_TIMER_CONFIG_RTC_FREQUENCY 1 -#endif - -// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority - - -// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice -// <0=> 0 (highest) -// <1=> 1 -// <2=> 2 -// <3=> 3 -// <4=> 4 -// <5=> 5 -// <6=> 6 -// <7=> 7 - -#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY -#define APP_TIMER_CONFIG_IRQ_PRIORITY 6 -#endif - -// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. -// Size of the queue depends on how many timers are used -// in the system, how often timers are started and overall -// system latency. If queue size is too small app_timer calls -// will fail. - -#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE -#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 -#endif - -// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler - - -#ifndef APP_TIMER_CONFIG_USE_SCHEDULER -#define APP_TIMER_CONFIG_USE_SCHEDULER 0 -#endif - -// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on - - -// If option is enabled RTC is kept running even if there is no active timers. -// This option can be used when app_timer is used for timestamping. - -#ifndef APP_TIMER_KEEPS_RTC_ACTIVE -#define APP_TIMER_KEEPS_RTC_ACTIVE 0 -#endif - -// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. -// Maximum possible timeout that can be set is reduced by safe window. -// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. -// Since RTC is not stopped when processor is halted in debugging session, this value -// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS -// without corrupting app_timer behavior. - -#ifndef APP_TIMER_SAFE_WINDOW_MS -#define APP_TIMER_SAFE_WINDOW_MS 300000 -#endif - -// App Timer Legacy configuration - Legacy configuration. - -//========================================================== -// APP_TIMER_WITH_PROFILER - Enable app_timer profiling - - -#ifndef APP_TIMER_WITH_PROFILER -#define APP_TIMER_WITH_PROFILER 0 -#endif - -// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. - - -#ifndef APP_TIMER_CONFIG_SWI_NUMBER -#define APP_TIMER_CONFIG_SWI_NUMBER 0 -#endif - -// -//========================================================== - -// - -// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class - - -#ifndef APP_USBD_AUDIO_ENABLED -#define APP_USBD_AUDIO_ENABLED 0 -#endif - -// APP_USBD_ENABLED - app_usbd - USB Device library -//========================================================== -#ifndef APP_USBD_ENABLED -#define APP_USBD_ENABLED 0 -#endif -// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> - - -// Note: This value is not editable in Configuration Wizard. -// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ - -#ifndef APP_USBD_VID -#define APP_USBD_VID 0 -#endif - -// APP_USBD_PID - Product ID. <0x0000-0xFFFF> - - -// Note: This value is not editable in Configuration Wizard. -// Selected Product ID - -#ifndef APP_USBD_PID -#define APP_USBD_PID 0 -#endif - -// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> - - -// Major device version, will be converted automatically to BCD notation. Use just decimal values. - -#ifndef APP_USBD_DEVICE_VER_MAJOR -#define APP_USBD_DEVICE_VER_MAJOR 1 -#endif - -// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> - - -// Minor device version, will be converted automatically to BCD notation. Use just decimal values. - -#ifndef APP_USBD_DEVICE_VER_MINOR -#define APP_USBD_DEVICE_VER_MINOR 0 -#endif - -// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> - - -// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. - -#ifndef APP_USBD_DEVICE_VER_SUB -#define APP_USBD_DEVICE_VER_SUB 0 -#endif - -// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. - - -#ifndef APP_USBD_CONFIG_SELF_POWERED -#define APP_USBD_CONFIG_SELF_POWERED 1 -#endif - -// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> - - -#ifndef APP_USBD_CONFIG_MAX_POWER -#define APP_USBD_CONFIG_MAX_POWER 100 -#endif - -// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. - - -// Enable processing power events in USB event handler. - -#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS -#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 -#endif - -// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. - -// This is the default configuration when all the events are placed into internal queue. -// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. -// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. -// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. -//========================================================== -#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE -#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 -#endif -// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> - - -// The size of the queue for the events that would be processed in the main loop. - -#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE -#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 -#endif - -// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. - - -// Normal queue - SOF events are pushed normally into the event queue. -// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. -// This prevents the queue from filling up with SOF events. -// Interrupt - SOF events are processed in interrupt. -// <0=> Normal queue -// <1=> Compress queue -// <2=> Interrupt - -#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE -#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 -#endif - -// - -// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. - - -// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. -// Use it when initializing the logger. -// SOF processing is always enabled when this configuration parameter is active. -// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. -// This means that it works even if the logging in this very module is disabled. - -#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE -#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 -#endif - -// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> - - -// 31 characters can be stored in the internal USB buffer used for transfers. -// Any value higher than 31 creates an additional buffer just for descriptor strings. - -#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE -#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 -#endif - -// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. - - -// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. - -#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED -#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 -#endif - -// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. - -// Note: This value is not editable in Configuration Wizard. -// Comma-separated list of supported languages. -#ifndef APP_USBD_STRINGS_LANGIDS -#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) -#endif - -// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. - -// Setting ID to 0 disables the string. -//========================================================== -#ifndef APP_USBD_STRING_ID_MANUFACTURER -#define APP_USBD_STRING_ID_MANUFACTURER 1 -#endif -// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. - - -#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN -#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 -#endif - -// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. - -// Note: This value is not editable in Configuration Wizard. -// Comma-separated list of manufacturer names for each defined language. -// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. -// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. -// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. -// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. -// Setting string to NULL disables that string. -// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. -#ifndef APP_USBD_STRINGS_MANUFACTURER -#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") -#endif - -// - -// APP_USBD_STRING_ID_PRODUCT - Define product string ID. - -// Setting ID to 0 disables the string. -//========================================================== -#ifndef APP_USBD_STRING_ID_PRODUCT -#define APP_USBD_STRING_ID_PRODUCT 2 -#endif -// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. - - -#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN -#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 -#endif - -// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. - -// Note: This value is not editable in Configuration Wizard. -// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. -#ifndef APP_USBD_STRINGS_PRODUCT -#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") -#endif - -// - -// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. - -// Setting ID to 0 disables the string. -//========================================================== -#ifndef APP_USBD_STRING_ID_SERIAL -#define APP_USBD_STRING_ID_SERIAL 3 -#endif -// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. - - -#ifndef APP_USBD_STRING_SERIAL_EXTERN -#define APP_USBD_STRING_SERIAL_EXTERN 0 -#endif - -// APP_USBD_STRING_SERIAL - String descriptor for the serial number. - -// Note: This value is not editable in Configuration Wizard. -// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. -#ifndef APP_USBD_STRING_SERIAL -#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") -#endif - -// - -// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. - -// Setting ID to 0 disables the string. -//========================================================== -#ifndef APP_USBD_STRING_ID_CONFIGURATION -#define APP_USBD_STRING_ID_CONFIGURATION 4 -#endif -// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. - - -#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN -#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 -#endif - -// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. - -// Note: This value is not editable in Configuration Wizard. -// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. -#ifndef APP_USBD_STRINGS_CONFIGURATION -#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") -#endif - -// - -// APP_USBD_STRINGS_USER - Default values for user strings. - -// Note: This value is not editable in Configuration Wizard. -// This value stores all application specific user strings with the default initialization. -// The setup is done by X-macros. -// Expected macro parameters: -// @code -// X(mnemonic, [=str_idx], ...) -// @endcode -// - @c mnemonic: Mnemonic of the string descriptor that would be added to -// @ref app_usbd_string_desc_idx_t enumerator. -// - @c str_idx : String index value, can be set or left empty. -// For example, WinUSB driver requires descriptor to be present on 0xEE index. -// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) -// - @c ... : List of string descriptors for each defined language. -#ifndef APP_USBD_STRINGS_USER -#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) -#endif - -// - -// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class -//========================================================== -#ifndef APP_USBD_HID_ENABLED -#define APP_USBD_HID_ENABLED 0 -#endif -// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> - - -// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. - -#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE -#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 -#endif - -// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> - - -// Must be higher than the highest report ID used. - -#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE -#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 -#endif - -// - -// APP_USBD_HID_GENERIC_ENABLED - app_usbd_hid_generic - USB HID generic - - -#ifndef APP_USBD_HID_GENERIC_ENABLED -#define APP_USBD_HID_GENERIC_ENABLED 0 -#endif - -// APP_USBD_HID_KBD_ENABLED - app_usbd_hid_kbd - USB HID keyboard - - -#ifndef APP_USBD_HID_KBD_ENABLED -#define APP_USBD_HID_KBD_ENABLED 0 -#endif - -// APP_USBD_HID_MOUSE_ENABLED - app_usbd_hid_mouse - USB HID mouse - - -#ifndef APP_USBD_HID_MOUSE_ENABLED -#define APP_USBD_HID_MOUSE_ENABLED 0 -#endif - -// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class - - -#ifndef APP_USBD_MSC_ENABLED -#define APP_USBD_MSC_ENABLED 0 -#endif - -// CRC16_ENABLED - crc16 - CRC16 calculation routines - - -#ifndef CRC16_ENABLED -#define CRC16_ENABLED 0 -#endif - -// CRC32_ENABLED - crc32 - CRC32 calculation routines - - -#ifndef CRC32_ENABLED -#define CRC32_ENABLED 0 -#endif - -// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library - - -#ifndef ECC_ENABLED -#define ECC_ENABLED 0 -#endif - -// FDS_ENABLED - fds - Flash data storage module -//========================================================== -#ifndef FDS_ENABLED -#define FDS_ENABLED 0 -#endif -// Pages - Virtual page settings - -// Configure the number of virtual pages to use and their size. -//========================================================== -// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. -// One of the virtual pages is reserved by the system for garbage collection. -// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. -// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. - -#ifndef FDS_VIRTUAL_PAGES -#define FDS_VIRTUAL_PAGES 3 -#endif - -// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. - - -// Expressed in number of 4-byte words. -// By default, a virtual page is the same size as a physical page. -// The size of a virtual page must be a multiple of the size of a physical page. -// <1024=> 1024 -// <2048=> 2048 - -#ifndef FDS_VIRTUAL_PAGE_SIZE -#define FDS_VIRTUAL_PAGE_SIZE 1024 -#endif - -// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. -// FDS module stores its data in the last pages of the flash memory. -// By setting this value, you can move flash end address used by the FDS. -// As a result the reserved space can be used by other modules. - -#ifndef FDS_VIRTUAL_PAGES_RESERVED -#define FDS_VIRTUAL_PAGES_RESERVED 0 -#endif - -// -//========================================================== - -// Backend - Backend configuration - -// Configure which nrf_fstorage backend is used by FDS to write to flash. -//========================================================== -// FDS_BACKEND - FDS flash backend. - - -// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. -// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. -// <1=> NRF_FSTORAGE_NVMC -// <2=> NRF_FSTORAGE_SD - -#ifndef FDS_BACKEND -#define FDS_BACKEND 2 -#endif - -// -//========================================================== - -// Queue - Queue settings - -//========================================================== -// FDS_OP_QUEUE_SIZE - Size of the internal queue. -// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. - -#ifndef FDS_OP_QUEUE_SIZE -#define FDS_OP_QUEUE_SIZE 4 -#endif - -// -//========================================================== - -// CRC - CRC functionality - -//========================================================== -// FDS_CRC_CHECK_ON_READ - Enable CRC checks. - -// Save a record's CRC when it is written to flash and check it when the record is opened. -// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. -// Additionally, they will not be garbage collected until they are deleted. -//========================================================== -#ifndef FDS_CRC_CHECK_ON_READ -#define FDS_CRC_CHECK_ON_READ 0 -#endif -// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. - - -// Perform a CRC check on newly written records. -// This setting can be used to make sure that the record data was not altered while being written to flash. -// <1=> Enabled -// <0=> Disabled - -#ifndef FDS_CRC_CHECK_ON_WRITE -#define FDS_CRC_CHECK_ON_WRITE 0 -#endif - -// - -// -//========================================================== - -// Users - Number of users - -//========================================================== -// FDS_MAX_USERS - Maximum number of callbacks that can be registered. -#ifndef FDS_MAX_USERS -#define FDS_MAX_USERS 4 -#endif - -// -//========================================================== - -// - -// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release - - -#ifndef HARDFAULT_HANDLER_ENABLED -#define HARDFAULT_HANDLER_ENABLED 0 -#endif - -// HCI_MEM_POOL_ENABLED - hci_mem_pool - memory pool implementation used by HCI -//========================================================== -#ifndef HCI_MEM_POOL_ENABLED -#define HCI_MEM_POOL_ENABLED 0 -#endif -// HCI_TX_BUF_SIZE - TX buffer size in bytes. -#ifndef HCI_TX_BUF_SIZE -#define HCI_TX_BUF_SIZE 600 -#endif - -// HCI_RX_BUF_SIZE - RX buffer size in bytes. -#ifndef HCI_RX_BUF_SIZE -#define HCI_RX_BUF_SIZE 600 -#endif - -// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. -#ifndef HCI_RX_BUF_QUEUE_SIZE -#define HCI_RX_BUF_QUEUE_SIZE 4 -#endif - -// - -// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI -//========================================================== -#ifndef HCI_SLIP_ENABLED -#define HCI_SLIP_ENABLED 0 -#endif -// HCI_UART_BAUDRATE - Default Baudrate - -// <323584=> 1200 baud -// <643072=> 2400 baud -// <1290240=> 4800 baud -// <2576384=> 9600 baud -// <3862528=> 14400 baud -// <5152768=> 19200 baud -// <7716864=> 28800 baud -// <10289152=> 38400 baud -// <15400960=> 57600 baud -// <20615168=> 76800 baud -// <30801920=> 115200 baud -// <61865984=> 230400 baud -// <67108864=> 250000 baud -// <121634816=> 460800 baud -// <251658240=> 921600 baud -// <268435456=> 1000000 baud - -#ifndef HCI_UART_BAUDRATE -#define HCI_UART_BAUDRATE 30801920 -#endif - -// HCI_UART_FLOW_CONTROL - Hardware Flow Control - -// <0=> Disabled -// <1=> Enabled - -#ifndef HCI_UART_FLOW_CONTROL -#define HCI_UART_FLOW_CONTROL 0 -#endif - -// HCI_UART_RX_PIN - UART RX pin -#ifndef HCI_UART_RX_PIN -#define HCI_UART_RX_PIN 31 -#endif - -// HCI_UART_TX_PIN - UART TX pin -#ifndef HCI_UART_TX_PIN -#define HCI_UART_TX_PIN 31 -#endif - -// HCI_UART_RTS_PIN - UART RTS pin -#ifndef HCI_UART_RTS_PIN -#define HCI_UART_RTS_PIN 31 -#endif - -// HCI_UART_CTS_PIN - UART CTS pin -#ifndef HCI_UART_CTS_PIN -#define HCI_UART_CTS_PIN 31 -#endif - -// - -// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport -//========================================================== -#ifndef HCI_TRANSPORT_ENABLED -#define HCI_TRANSPORT_ENABLED 0 -#endif -// HCI_MAX_PACKET_SIZE_IN_BITS - Maximum size of a single application packet in bits. -#ifndef HCI_MAX_PACKET_SIZE_IN_BITS -#define HCI_MAX_PACKET_SIZE_IN_BITS 8000 -#endif - -// - -// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module - - -#ifndef LED_SOFTBLINK_ENABLED -#define LED_SOFTBLINK_ENABLED 0 -#endif - -// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module - - -#ifndef LOW_POWER_PWM_ENABLED -#define LOW_POWER_PWM_ENABLED 0 -#endif - -// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator -//========================================================== -#ifndef MEM_MANAGER_ENABLED -#define MEM_MANAGER_ENABLED 0 -#endif -// MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block. <0-255> - - -#ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT -#define MEMORY_MANAGER_SMALL_BLOCK_COUNT 1 -#endif - -// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. -// Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized. - -#ifndef MEMORY_MANAGER_SMALL_BLOCK_SIZE -#define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32 -#endif - -// MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block. <0-255> - - -#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_COUNT -#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 0 -#endif - -// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. -// Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized. - -#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_SIZE -#define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256 -#endif - -// MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block. <0-255> - - -#ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT -#define MEMORY_MANAGER_LARGE_BLOCK_COUNT 0 -#endif - -// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. -// Size of each memory blocks identified as 'large' block. Memory block are recommended to be word-sized. - -#ifndef MEMORY_MANAGER_LARGE_BLOCK_SIZE -#define MEMORY_MANAGER_LARGE_BLOCK_SIZE 256 -#endif - -// MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block. <0-255> - - -#ifndef MEMORY_MANAGER_XLARGE_BLOCK_COUNT -#define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 0 -#endif - -// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. -// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. - -#ifndef MEMORY_MANAGER_XLARGE_BLOCK_SIZE -#define MEMORY_MANAGER_XLARGE_BLOCK_SIZE 1320 -#endif - -// MEMORY_MANAGER_XXLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra large' block. <0-255> - - -#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_COUNT -#define MEMORY_MANAGER_XXLARGE_BLOCK_COUNT 0 -#endif - -// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. -// Size of each memory blocks identified as 'extra extra large' block. Memory block are recommended to be word-sized. - -#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_SIZE -#define MEMORY_MANAGER_XXLARGE_BLOCK_SIZE 3444 -#endif - -// MEMORY_MANAGER_XSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra small' block. <0-255> - - -#ifndef MEMORY_MANAGER_XSMALL_BLOCK_COUNT -#define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 0 -#endif - -// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. -// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. - -#ifndef MEMORY_MANAGER_XSMALL_BLOCK_SIZE -#define MEMORY_MANAGER_XSMALL_BLOCK_SIZE 64 -#endif - -// MEMORY_MANAGER_XXSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra small' block. <0-255> - - -#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_COUNT -#define MEMORY_MANAGER_XXSMALL_BLOCK_COUNT 0 -#endif - -// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. -// Size of each memory blocks identified as 'extra extra small' block. Memory block are recommended to be word-sized. - -#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_SIZE -#define MEMORY_MANAGER_XXSMALL_BLOCK_SIZE 32 -#endif - -// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED -#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 -#endif -// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL -#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 -#endif - -// MEM_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef MEM_MANAGER_CONFIG_INFO_COLOR -#define MEM_MANAGER_CONFIG_INFO_COLOR 0 -#endif - -// MEM_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef MEM_MANAGER_CONFIG_DEBUG_COLOR -#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// MEM_MANAGER_DISABLE_API_PARAM_CHECK - Disable API parameter checks in the module. - - -#ifndef MEM_MANAGER_DISABLE_API_PARAM_CHECK -#define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0 -#endif - -// - -// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module -//========================================================== -#ifndef NRF_BALLOC_ENABLED -#define NRF_BALLOC_ENABLED 1 -#endif -// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED -#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 -#endif -// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> - - -#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS -#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 -#endif - -// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> - - -#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS -#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 -#endif - -// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. - - -#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED -#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 -#endif - -// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. - - -#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 -#endif - -// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. - - -#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED -#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 -#endif - -// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module - - -#ifndef NRF_BALLOC_CLI_CMDS -#define NRF_BALLOC_CLI_CMDS 0 -#endif - -// - -// - -// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module -//========================================================== -#ifndef NRF_CSENSE_ENABLED -#define NRF_CSENSE_ENABLED 0 -#endif -// NRF_CSENSE_PAD_HYSTERESIS - Minimum value of change required to determine that a pad was touched. -#ifndef NRF_CSENSE_PAD_HYSTERESIS -#define NRF_CSENSE_PAD_HYSTERESIS 15 -#endif - -// NRF_CSENSE_PAD_DEVIATION - Minimum value measured on a pad required to take it into account while calculating the step. -#ifndef NRF_CSENSE_PAD_DEVIATION -#define NRF_CSENSE_PAD_DEVIATION 70 -#endif - -// NRF_CSENSE_MIN_PAD_VALUE - Minimum normalized value on a pad required to take its value into account. -#ifndef NRF_CSENSE_MIN_PAD_VALUE -#define NRF_CSENSE_MIN_PAD_VALUE 20 -#endif - -// NRF_CSENSE_MAX_PADS_NUMBER - Maximum number of pads used for one instance. -#ifndef NRF_CSENSE_MAX_PADS_NUMBER -#define NRF_CSENSE_MAX_PADS_NUMBER 20 -#endif - -// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. -#ifndef NRF_CSENSE_MAX_VALUE -#define NRF_CSENSE_MAX_VALUE 1000 -#endif - -// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. -// This is used when capacitive sensor does not use COMP. - -#ifndef NRF_CSENSE_OUTPUT_PIN -#define NRF_CSENSE_OUTPUT_PIN 26 -#endif - -// - -// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module -//========================================================== -#ifndef NRF_DRV_CSENSE_ENABLED -#define NRF_DRV_CSENSE_ENABLED 0 -#endif -// USE_COMP - Use the comparator to implement the capacitive sensor driver. - -// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. -//========================================================== -#ifndef USE_COMP -#define USE_COMP 0 -#endif -// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). -#ifndef TIMER0_FOR_CSENSE -#define TIMER0_FOR_CSENSE 1 -#endif - -// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). -#ifndef TIMER1_FOR_CSENSE -#define TIMER1_FOR_CSENSE 2 -#endif - -// MEASUREMENT_PERIOD - Single measurement period. -// Time of a single measurement can be calculated as -// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). -// I_SOURCE, VUP, and VDOWN are values used to initialize COMP and C is the capacitance of the used pad. - -#ifndef MEASUREMENT_PERIOD -#define MEASUREMENT_PERIOD 20 -#endif - -// - -// - -// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library -//========================================================== -#ifndef NRF_FSTORAGE_ENABLED -#define NRF_FSTORAGE_ENABLED 0 -#endif -// nrf_fstorage - Common settings - -// Common settings to all fstorage implementations -//========================================================== -// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation - - -// If selected, use ASSERT to validate user input. -// This effectively removes user input validation in production code. -// Recommended setting: OFF, only enable this setting if size is a major concern. - -#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED -#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 -#endif - -// -//========================================================== - -// nrf_fstorage_sd - Implementation using the SoftDevice - -// Configuration options for the fstorage implementation using the SoftDevice -//========================================================== -// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations -// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. - -#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE -#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 -#endif - -// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy -// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. -// The SoftDevice might fail to schedule flash access due to high BLE activity. - -#ifndef NRF_FSTORAGE_SD_MAX_RETRIES -#define NRF_FSTORAGE_SD_MAX_RETRIES 8 -#endif - -// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation -// This value must be a multiple of four. -// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. -// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. -// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. - -#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE -#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 -#endif - -// -//========================================================== - -// - -// NRF_GFX_ENABLED - nrf_gfx - GFX module - - -#ifndef NRF_GFX_ENABLED -#define NRF_GFX_ENABLED 0 -#endif - -// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module - - -#ifndef NRF_MEMOBJ_ENABLED -#define NRF_MEMOBJ_ENABLED 1 -#endif - -// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module -//========================================================== -#ifndef NRF_PWR_MGMT_ENABLED -#define NRF_PWR_MGMT_ENABLED 0 -#endif -// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. - -// Selected pin will be set when CPU is in sleep mode. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED -#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 -#endif -// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number - -// <0=> 0 (P0.0) -// <1=> 1 (P0.1) -// <2=> 2 (P0.2) -// <3=> 3 (P0.3) -// <4=> 4 (P0.4) -// <5=> 5 (P0.5) -// <6=> 6 (P0.6) -// <7=> 7 (P0.7) -// <8=> 8 (P0.8) -// <9=> 9 (P0.9) -// <10=> 10 (P0.10) -// <11=> 11 (P0.11) -// <12=> 12 (P0.12) -// <13=> 13 (P0.13) -// <14=> 14 (P0.14) -// <15=> 15 (P0.15) -// <16=> 16 (P0.16) -// <17=> 17 (P0.17) -// <18=> 18 (P0.18) -// <19=> 19 (P0.19) -// <20=> 20 (P0.20) -// <21=> 21 (P0.21) -// <22=> 22 (P0.22) -// <23=> 23 (P0.23) -// <24=> 24 (P0.24) -// <25=> 25 (P0.25) -// <26=> 26 (P0.26) -// <27=> 27 (P0.27) -// <28=> 28 (P0.28) -// <29=> 29 (P0.29) -// <30=> 30 (P0.30) -// <31=> 31 (P0.31) -// <4294967295=> Not connected - -#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN -#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 -#endif - -// - -// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. - - -// Module will trace percentage of CPU usage in one second intervals. - -#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED -#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 -#endif - -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 -#endif -// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). -// Shutdown procedure will begin no earlier than after this number of seconds. - -#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S -#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 -#endif - -// - -// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. - - -#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED -#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 0 -#endif - -// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. - - -#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY -#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 -#endif - -// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. - - -#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER -#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 -#endif - -// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. -// The number of stages of the shutdown process. - -#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT -#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 -#endif - -// - -// NRF_QUEUE_ENABLED - nrf_queue - Queue module -//========================================================== -#ifndef NRF_QUEUE_ENABLED -#define NRF_QUEUE_ENABLED 0 -#endif -// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module - - -#ifndef NRF_QUEUE_CLI_CMDS -#define NRF_QUEUE_CLI_CMDS 0 -#endif - -// - -// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator - - -#ifndef NRF_SECTION_ITER_ENABLED -#define NRF_SECTION_ITER_ENABLED 1 -#endif - -// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list - - -#ifndef NRF_SORTLIST_ENABLED -#define NRF_SORTLIST_ENABLED 1 -#endif - -// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager - - -#ifndef NRF_SPI_MNGR_ENABLED -#define NRF_SPI_MNGR_ENABLED 0 -#endif - -// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. - - -#ifndef NRF_STRERROR_ENABLED -#define NRF_STRERROR_ENABLED 1 -#endif - -// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager - - -#ifndef NRF_TWI_MNGR_ENABLED -#define NRF_TWI_MNGR_ENABLED 0 -#endif - -// SLIP_ENABLED - slip - SLIP encoding and decoding - - -#ifndef SLIP_ENABLED -#define SLIP_ENABLED 0 -#endif - -// TASK_MANAGER_ENABLED - task_manager - Task manager. -//========================================================== -#ifndef TASK_MANAGER_ENABLED -#define TASK_MANAGER_ENABLED 0 -#endif -// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module - - -#ifndef TASK_MANAGER_CLI_CMDS -#define TASK_MANAGER_CLI_CMDS 0 -#endif - -// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created -#ifndef TASK_MANAGER_CONFIG_MAX_TASKS -#define TASK_MANAGER_CONFIG_MAX_TASKS 2 -#endif - -// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) -#ifndef TASK_MANAGER_CONFIG_STACK_SIZE -#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 -#endif - -// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. - - -#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED -#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 -#endif - -// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. - -// <0=> Disabled -// <4=> 32 bytes -// <5=> 64 bytes -// <6=> 128 bytes -// <7=> 256 bytes -// <8=> 512 bytes - -#ifndef TASK_MANAGER_CONFIG_STACK_GUARD -#define TASK_MANAGER_CONFIG_STACK_GUARD 7 -#endif - -// - -// app_button - buttons handling module - -//========================================================== -// BUTTON_ENABLED - Enables Button module - - -#ifndef BUTTON_ENABLED -#define BUTTON_ENABLED 0 -#endif - -// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons - - -#ifndef BUTTON_HIGH_ACCURACY_ENABLED -#define BUTTON_HIGH_ACCURACY_ENABLED 0 -#endif - -// -//========================================================== - -// app_usbd_cdc_acm - USB CDC ACM class - -//========================================================== -// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library - - -#ifndef APP_USBD_CDC_ACM_ENABLED -#define APP_USBD_CDC_ACM_ENABLED 0 -#endif - -// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint - - -// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. -// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. - -#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE -#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 -#endif - -// -//========================================================== - -// nrf_cli - Command line interface - -//========================================================== -// NRF_CLI_ENABLED - Enable/disable the CLI module. - - -#ifndef NRF_CLI_ENABLED -#define NRF_CLI_ENABLED 0 -#endif - -// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. -#ifndef NRF_CLI_ARGC_MAX -#define NRF_CLI_ARGC_MAX 12 -#endif - -// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. - - -#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED -#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 -#endif - -// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. -#ifndef NRF_CLI_CMD_BUFF_SIZE -#define NRF_CLI_CMD_BUFF_SIZE 128 -#endif - -// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. - - -#ifndef NRF_CLI_ECHO_STATUS -#define NRF_CLI_ECHO_STATUS 1 -#endif - -// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. - - -#ifndef NRF_CLI_WILDCARD_ENABLED -#define NRF_CLI_WILDCARD_ENABLED 0 -#endif - -// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u - - -#ifndef NRF_CLI_METAKEYS_ENABLED -#define NRF_CLI_METAKEYS_ENABLED 0 -#endif - -// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. -#ifndef NRF_CLI_PRINTF_BUFF_SIZE -#define NRF_CLI_PRINTF_BUFF_SIZE 23 -#endif - -// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. -//========================================================== -#ifndef NRF_CLI_HISTORY_ENABLED -#define NRF_CLI_HISTORY_ENABLED 1 -#endif -// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. -#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE -#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 -#endif - -// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. -#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT -#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 -#endif - -// - -// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. - - -#ifndef NRF_CLI_VT100_COLORS_ENABLED -#define NRF_CLI_VT100_COLORS_ENABLED 1 -#endif - -// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. - - -#ifndef NRF_CLI_STATISTICS_ENABLED -#define NRF_CLI_STATISTICS_ENABLED 1 -#endif - -// NRF_CLI_LOG_BACKEND - Enable logger backend interface. - - -#ifndef NRF_CLI_LOG_BACKEND -#define NRF_CLI_LOG_BACKEND 1 -#endif - -// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager - - -#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED -#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 -#endif - -// -//========================================================== - -// nrf_fprintf - fprintf function. - -//========================================================== -// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. - - -#ifndef NRF_FPRINTF_ENABLED -#define NRF_FPRINTF_ENABLED 1 -#endif - -// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. - - -#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED -#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1 -#endif - -// NRF_FPRINTF_DOUBLE_ENABLED - Enable IEEE-754 double precision formatting. - - -#ifndef NRF_FPRINTF_DOUBLE_ENABLED -#define NRF_FPRINTF_DOUBLE_ENABLED 0 -#endif - -// -//========================================================== - -// -//========================================================== - -// nRF_Log - -//========================================================== -// NRF_LOG_ENABLED - nrf_log - Logger -//========================================================== -#ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 0 -#endif -// Log message pool - Configuration of log message pool - -//========================================================== -// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. -// If a small value is set, then performance of logs processing -// is degraded because data is fragmented. Bigger value impacts -// RAM memory utilization. The size is set to fit a message with -// a timestamp and up to 2 arguments in a single memory object. - -#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE -#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 -#endif - -// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects -// If a small value is set, then it may lead to a deadlock -// in certain cases if backend has high latency and holds -// multiple messages for long time. Bigger value impacts -// RAM memory usage. - -#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT -#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 -#endif - -// -//========================================================== - -// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. - - -// If set then oldest logs are overwritten. Otherwise a -// marker is injected informing about overflow. - -#ifndef NRF_LOG_ALLOW_OVERFLOW -#define NRF_LOG_ALLOW_OVERFLOW 1 -#endif - -// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). - - -// Must be power of 2 and multiple of 4. -// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 -// <2048=> 2048 -// <4096=> 4096 -// <8192=> 8192 -// <16384=> 16384 - -#ifndef NRF_LOG_BUFSIZE -#define NRF_LOG_BUFSIZE 1024 -#endif - -// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. - - -#ifndef NRF_LOG_CLI_CMDS -#define NRF_LOG_CLI_CMDS 0 -#endif - -// NRF_LOG_DEFAULT_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_LOG_DEFAULT_LEVEL -#define NRF_LOG_DEFAULT_LEVEL 3 -#endif - -// NRF_LOG_DEFERRED - Enable deffered logger. - - -// Log data is buffered and can be processed in idle. - -#ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 -#endif - -// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. - - -#ifndef NRF_LOG_FILTERS_ENABLED -#define NRF_LOG_FILTERS_ENABLED 0 -#endif - -// NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED - Enable use of critical region for non deffered mode when flushing logs. - - -// When enabled NRF_LOG_FLUSH is called from critical section when non deffered mode is used. -// Log output will never be corrupted as access to the log backend is exclusive -// but system will spend significant amount of time in critical section - -#ifndef NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED -#define NRF_LOG_NON_DEFFERED_CRITICAL_REGION_ENABLED 0 -#endif - -// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. - -// <16=> 16 -// <32=> 32 -// <64=> 64 -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 - -#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE -#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 -#endif - -// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. - -// <16=> 16 -// <32=> 32 -// <64=> 64 -// <128=> 128 -// <256=> 256 -// <512=> 512 -// <1024=> 1024 - -#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE -#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 -#endif - -// NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string -//========================================================== -#ifndef NRF_LOG_USES_COLORS -#define NRF_LOG_USES_COLORS 0 -#endif -// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_LOG_COLOR_DEFAULT -#define NRF_LOG_COLOR_DEFAULT 0 -#endif - -// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_LOG_ERROR_COLOR -#define NRF_LOG_ERROR_COLOR 2 -#endif - -// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_LOG_WARNING_COLOR -#define NRF_LOG_WARNING_COLOR 4 -#endif - -// - -// NRF_LOG_USES_TIMESTAMP - Enable timestamping - -// Function for getting the timestamp is provided by the user -//========================================================== -#ifndef NRF_LOG_USES_TIMESTAMP -#define NRF_LOG_USES_TIMESTAMP 0 -#endif -// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. -#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY -#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 -#endif - -// - -// nrf_log module configuration - -//========================================================== -// nrf_log in nRF_Core - -//========================================================== -// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED -#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 -#endif -// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL -#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_MPU_LIB_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_MPU_LIB_CONFIG_INFO_COLOR -#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 -#endif - -// NRF_MPU_LIB_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_MPU_LIB_CONFIG_DEBUG_COLOR -#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED -#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 -#endif -// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL -#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR -#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 -#endif - -// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR -#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED -#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 -#endif -// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL -#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 -#endif - -// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef TASK_MANAGER_CONFIG_INFO_COLOR -#define TASK_MANAGER_CONFIG_INFO_COLOR 0 -#endif - -// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR -#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// -//========================================================== - -// nrf_log in nRF_Drivers - -//========================================================== -// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef CLOCK_CONFIG_LOG_ENABLED -#define CLOCK_CONFIG_LOG_ENABLED 0 -#endif -// CLOCK_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef CLOCK_CONFIG_LOG_LEVEL -#define CLOCK_CONFIG_LOG_LEVEL 3 -#endif - -// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef CLOCK_CONFIG_INFO_COLOR -#define CLOCK_CONFIG_INFO_COLOR 0 -#endif - -// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef CLOCK_CONFIG_DEBUG_COLOR -#define CLOCK_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef COMP_CONFIG_LOG_ENABLED -#define COMP_CONFIG_LOG_ENABLED 0 -#endif -// COMP_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef COMP_CONFIG_LOG_LEVEL -#define COMP_CONFIG_LOG_LEVEL 3 -#endif - -// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef COMP_CONFIG_INFO_COLOR -#define COMP_CONFIG_INFO_COLOR 0 -#endif - -// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef COMP_CONFIG_DEBUG_COLOR -#define COMP_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef GPIOTE_CONFIG_LOG_ENABLED -#define GPIOTE_CONFIG_LOG_ENABLED 0 -#endif -// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef GPIOTE_CONFIG_LOG_LEVEL -#define GPIOTE_CONFIG_LOG_LEVEL 3 -#endif - -// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef GPIOTE_CONFIG_INFO_COLOR -#define GPIOTE_CONFIG_INFO_COLOR 0 -#endif - -// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef GPIOTE_CONFIG_DEBUG_COLOR -#define GPIOTE_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef LPCOMP_CONFIG_LOG_ENABLED -#define LPCOMP_CONFIG_LOG_ENABLED 0 -#endif -// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef LPCOMP_CONFIG_LOG_LEVEL -#define LPCOMP_CONFIG_LOG_LEVEL 3 -#endif - -// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef LPCOMP_CONFIG_INFO_COLOR -#define LPCOMP_CONFIG_INFO_COLOR 0 -#endif - -// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef LPCOMP_CONFIG_DEBUG_COLOR -#define LPCOMP_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module -//========================================================== -#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED -#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 -#endif -// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL -#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 -#endif - -// MAX3421E_HOST_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR -#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 -#endif - -// MAX3421E_HOST_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR -#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module -//========================================================== -#ifndef NRFX_USBD_CONFIG_LOG_ENABLED -#define NRFX_USBD_CONFIG_LOG_ENABLED 0 -#endif -// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRFX_USBD_CONFIG_LOG_LEVEL -#define NRFX_USBD_CONFIG_LOG_LEVEL 3 -#endif - -// NRFX_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_USBD_CONFIG_INFO_COLOR -#define NRFX_USBD_CONFIG_INFO_COLOR 0 -#endif - -// NRFX_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR -#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef PDM_CONFIG_LOG_ENABLED -#define PDM_CONFIG_LOG_ENABLED 0 -#endif -// PDM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef PDM_CONFIG_LOG_LEVEL -#define PDM_CONFIG_LOG_LEVEL 3 -#endif - -// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef PDM_CONFIG_INFO_COLOR -#define PDM_CONFIG_INFO_COLOR 0 -#endif - -// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef PDM_CONFIG_DEBUG_COLOR -#define PDM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef PPI_CONFIG_LOG_ENABLED -#define PPI_CONFIG_LOG_ENABLED 0 -#endif -// PPI_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef PPI_CONFIG_LOG_LEVEL -#define PPI_CONFIG_LOG_LEVEL 3 -#endif - -// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef PPI_CONFIG_INFO_COLOR -#define PPI_CONFIG_INFO_COLOR 0 -#endif - -// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef PPI_CONFIG_DEBUG_COLOR -#define PPI_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef PWM_CONFIG_LOG_ENABLED -#define PWM_CONFIG_LOG_ENABLED 0 -#endif -// PWM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef PWM_CONFIG_LOG_LEVEL -#define PWM_CONFIG_LOG_LEVEL 3 -#endif - -// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef PWM_CONFIG_INFO_COLOR -#define PWM_CONFIG_INFO_COLOR 0 -#endif - -// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef PWM_CONFIG_DEBUG_COLOR -#define PWM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef QDEC_CONFIG_LOG_ENABLED -#define QDEC_CONFIG_LOG_ENABLED 0 -#endif -// QDEC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef QDEC_CONFIG_LOG_LEVEL -#define QDEC_CONFIG_LOG_LEVEL 3 -#endif - -// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef QDEC_CONFIG_INFO_COLOR -#define QDEC_CONFIG_INFO_COLOR 0 -#endif - -// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef QDEC_CONFIG_DEBUG_COLOR -#define QDEC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef RNG_CONFIG_LOG_ENABLED -#define RNG_CONFIG_LOG_ENABLED 0 -#endif -// RNG_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef RNG_CONFIG_LOG_LEVEL -#define RNG_CONFIG_LOG_LEVEL 3 -#endif - -// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef RNG_CONFIG_INFO_COLOR -#define RNG_CONFIG_INFO_COLOR 0 -#endif - -// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef RNG_CONFIG_DEBUG_COLOR -#define RNG_CONFIG_DEBUG_COLOR 0 -#endif - -// RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED - Enables logging of random numbers. - - -#ifndef RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED -#define RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED 0 -#endif - -// - -// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef RTC_CONFIG_LOG_ENABLED -#define RTC_CONFIG_LOG_ENABLED 0 -#endif -// RTC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef RTC_CONFIG_LOG_LEVEL -#define RTC_CONFIG_LOG_LEVEL 3 -#endif - -// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef RTC_CONFIG_INFO_COLOR -#define RTC_CONFIG_INFO_COLOR 0 -#endif - -// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef RTC_CONFIG_DEBUG_COLOR -#define RTC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SAADC_CONFIG_LOG_ENABLED -#define SAADC_CONFIG_LOG_ENABLED 0 -#endif -// SAADC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef SAADC_CONFIG_LOG_LEVEL -#define SAADC_CONFIG_LOG_LEVEL 3 -#endif - -// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef SAADC_CONFIG_INFO_COLOR -#define SAADC_CONFIG_INFO_COLOR 0 -#endif - -// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef SAADC_CONFIG_DEBUG_COLOR -#define SAADC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SPIS_CONFIG_LOG_ENABLED -#define SPIS_CONFIG_LOG_ENABLED 0 -#endif -// SPIS_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef SPIS_CONFIG_LOG_LEVEL -#define SPIS_CONFIG_LOG_LEVEL 3 -#endif - -// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef SPIS_CONFIG_INFO_COLOR -#define SPIS_CONFIG_INFO_COLOR 0 -#endif - -// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef SPIS_CONFIG_DEBUG_COLOR -#define SPIS_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SPI_CONFIG_LOG_ENABLED -#define SPI_CONFIG_LOG_ENABLED 0 -#endif -// SPI_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef SPI_CONFIG_LOG_LEVEL -#define SPI_CONFIG_LOG_LEVEL 3 -#endif - -// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef SPI_CONFIG_INFO_COLOR -#define SPI_CONFIG_INFO_COLOR 0 -#endif - -// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef SPI_CONFIG_DEBUG_COLOR -#define SPI_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TIMER_CONFIG_LOG_ENABLED -#define TIMER_CONFIG_LOG_ENABLED 0 -#endif -// TIMER_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef TIMER_CONFIG_LOG_LEVEL -#define TIMER_CONFIG_LOG_LEVEL 3 -#endif - -// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef TIMER_CONFIG_INFO_COLOR -#define TIMER_CONFIG_INFO_COLOR 0 -#endif - -// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef TIMER_CONFIG_DEBUG_COLOR -#define TIMER_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TWIS_CONFIG_LOG_ENABLED -#define TWIS_CONFIG_LOG_ENABLED 0 -#endif -// TWIS_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef TWIS_CONFIG_LOG_LEVEL -#define TWIS_CONFIG_LOG_LEVEL 3 -#endif - -// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef TWIS_CONFIG_INFO_COLOR -#define TWIS_CONFIG_INFO_COLOR 0 -#endif - -// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef TWIS_CONFIG_DEBUG_COLOR -#define TWIS_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef TWI_CONFIG_LOG_ENABLED -#define TWI_CONFIG_LOG_ENABLED 0 -#endif -// TWI_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef TWI_CONFIG_LOG_LEVEL -#define TWI_CONFIG_LOG_LEVEL 3 -#endif - -// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef TWI_CONFIG_INFO_COLOR -#define TWI_CONFIG_INFO_COLOR 0 -#endif - -// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef TWI_CONFIG_DEBUG_COLOR -#define TWI_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// UART_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef UART_CONFIG_LOG_ENABLED -#define UART_CONFIG_LOG_ENABLED 0 -#endif -// UART_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef UART_CONFIG_LOG_LEVEL -#define UART_CONFIG_LOG_LEVEL 3 -#endif - -// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef UART_CONFIG_INFO_COLOR -#define UART_CONFIG_INFO_COLOR 0 -#endif - -// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef UART_CONFIG_DEBUG_COLOR -#define UART_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// USBD_CONFIG_LOG_ENABLED - Enable logging in the module -//========================================================== -#ifndef USBD_CONFIG_LOG_ENABLED -#define USBD_CONFIG_LOG_ENABLED 0 -#endif -// USBD_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef USBD_CONFIG_LOG_LEVEL -#define USBD_CONFIG_LOG_LEVEL 3 -#endif - -// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef USBD_CONFIG_INFO_COLOR -#define USBD_CONFIG_INFO_COLOR 0 -#endif - -// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef USBD_CONFIG_DEBUG_COLOR -#define USBD_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef WDT_CONFIG_LOG_ENABLED -#define WDT_CONFIG_LOG_ENABLED 0 -#endif -// WDT_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef WDT_CONFIG_LOG_LEVEL -#define WDT_CONFIG_LOG_LEVEL 3 -#endif - -// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef WDT_CONFIG_INFO_COLOR -#define WDT_CONFIG_INFO_COLOR 0 -#endif - -// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef WDT_CONFIG_DEBUG_COLOR -#define WDT_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// -//========================================================== - -// nrf_log in nRF_Libraries - -//========================================================== -// APP_BUTTON_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_BUTTON_CONFIG_LOG_ENABLED -#define APP_BUTTON_CONFIG_LOG_ENABLED 0 -#endif -// APP_BUTTON_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_BUTTON_CONFIG_LOG_LEVEL -#define APP_BUTTON_CONFIG_LOG_LEVEL 3 -#endif - -// APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. - - -// If module generates a lot of logs, initial log level can -// be decreased to prevent flooding. Severity level can be -// increased on instance basis. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL -#define APP_BUTTON_CONFIG_INITIAL_LOG_LEVEL 3 -#endif - -// APP_BUTTON_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_BUTTON_CONFIG_INFO_COLOR -#define APP_BUTTON_CONFIG_INFO_COLOR 0 -#endif - -// APP_BUTTON_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_BUTTON_CONFIG_DEBUG_COLOR -#define APP_BUTTON_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_TIMER_CONFIG_LOG_ENABLED -#define APP_TIMER_CONFIG_LOG_ENABLED 0 -#endif -// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_TIMER_CONFIG_LOG_LEVEL -#define APP_TIMER_CONFIG_LOG_LEVEL 3 -#endif - -// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. - - -// If module generates a lot of logs, initial log level can -// be decreased to prevent flooding. Severity level can be -// increased on instance basis. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL -#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 -#endif - -// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_TIMER_CONFIG_INFO_COLOR -#define APP_TIMER_CONFIG_INFO_COLOR 0 -#endif - -// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_TIMER_CONFIG_DEBUG_COLOR -#define APP_TIMER_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED -#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 -#endif -// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL -#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 -#endif - -// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR -#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 -#endif - -// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR -#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. -//========================================================== -#ifndef APP_USBD_CONFIG_LOG_ENABLED -#define APP_USBD_CONFIG_LOG_ENABLED 0 -#endif -// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_USBD_CONFIG_LOG_LEVEL -#define APP_USBD_CONFIG_LOG_LEVEL 3 -#endif - -// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_CONFIG_INFO_COLOR -#define APP_USBD_CONFIG_INFO_COLOR 0 -#endif - -// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_CONFIG_DEBUG_COLOR -#define APP_USBD_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED -#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 -#endif -// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL -#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 -#endif - -// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR -#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 -#endif - -// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR -#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED -#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 -#endif -// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL -#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 -#endif - -// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR -#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 -#endif - -// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR -#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED -#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 -#endif -// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL -#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 -#endif - -// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR -#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 -#endif - -// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR -#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED -#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 -#endif -// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL -#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL -#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 -#endif - -// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR -#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 -#endif - -// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR -#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED -#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 -#endif -// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL -#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. - - -// If module generates a lot of logs, initial log level can -// be decreased to prevent flooding. Severity level can be -// increased on instance basis. -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL -#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 -#endif - -// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_BALLOC_CONFIG_INFO_COLOR -#define NRF_BALLOC_CONFIG_INFO_COLOR 0 -#endif - -// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR -#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED -#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 -#endif -// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL -#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL -#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 -#endif - -// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR -#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 -#endif - -// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR -#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED -#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 -#endif -// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL -#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL -#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 -#endif - -// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR -#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 -#endif - -// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR -#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED -#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 -#endif -// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL -#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL -#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 -#endif - -// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR -#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 -#endif - -// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR -#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 -#endif -// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR -#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 -#endif - -// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED -#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 -#endif -// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL -#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR -#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 -#endif - -// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR -#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED -#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 -#endif -// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL -#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR -#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 -#endif - -// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR -#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED -#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 -#endif -// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL -#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR -#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 -#endif - -// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR -#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED -#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 -#endif -// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL -#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_MEMOBJ_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_MEMOBJ_CONFIG_INFO_COLOR -#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 -#endif - -// NRF_MEMOBJ_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_MEMOBJ_CONFIG_DEBUG_COLOR -#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED -#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 -#endif -// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL -#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_PWR_MGMT_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_PWR_MGMT_CONFIG_INFO_COLOR -#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 -#endif - -// NRF_PWR_MGMT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_COLOR -#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED -#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 -#endif -// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL -#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL -#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 -#endif - -// NRF_QUEUE_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_QUEUE_CONFIG_INFO_COLOR -#define NRF_QUEUE_CONFIG_INFO_COLOR 0 -#endif - -// NRF_QUEUE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_QUEUE_CONFIG_DEBUG_COLOR -#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. -//========================================================== -#ifndef NRF_SDH_ANT_LOG_ENABLED -#define NRF_SDH_ANT_LOG_ENABLED 1 -#endif -// NRF_SDH_ANT_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SDH_ANT_LOG_LEVEL -#define NRF_SDH_ANT_LOG_LEVEL 3 -#endif - -// NRF_SDH_ANT_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SDH_ANT_INFO_COLOR -#define NRF_SDH_ANT_INFO_COLOR 0 -#endif - -// NRF_SDH_ANT_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SDH_ANT_DEBUG_COLOR -#define NRF_SDH_ANT_DEBUG_COLOR 0 -#endif - -// - -// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. -//========================================================== -#ifndef NRF_SDH_BLE_LOG_ENABLED -#define NRF_SDH_BLE_LOG_ENABLED 1 -#endif -// NRF_SDH_BLE_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SDH_BLE_LOG_LEVEL -#define NRF_SDH_BLE_LOG_LEVEL 3 -#endif - -// NRF_SDH_BLE_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SDH_BLE_INFO_COLOR -#define NRF_SDH_BLE_INFO_COLOR 0 -#endif - -// NRF_SDH_BLE_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SDH_BLE_DEBUG_COLOR -#define NRF_SDH_BLE_DEBUG_COLOR 0 -#endif - -// - -// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. -//========================================================== -#ifndef NRF_SDH_LOG_ENABLED -#define NRF_SDH_LOG_ENABLED 1 -#endif -// NRF_SDH_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SDH_LOG_LEVEL -#define NRF_SDH_LOG_LEVEL 3 -#endif - -// NRF_SDH_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SDH_INFO_COLOR -#define NRF_SDH_INFO_COLOR 0 -#endif - -// NRF_SDH_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SDH_DEBUG_COLOR -#define NRF_SDH_DEBUG_COLOR 0 -#endif - -// - -// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. -//========================================================== -#ifndef NRF_SDH_SOC_LOG_ENABLED -#define NRF_SDH_SOC_LOG_ENABLED 1 -#endif -// NRF_SDH_SOC_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SDH_SOC_LOG_LEVEL -#define NRF_SDH_SOC_LOG_LEVEL 3 -#endif - -// NRF_SDH_SOC_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SDH_SOC_INFO_COLOR -#define NRF_SDH_SOC_INFO_COLOR 0 -#endif - -// NRF_SDH_SOC_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SDH_SOC_DEBUG_COLOR -#define NRF_SDH_SOC_DEBUG_COLOR 0 -#endif - -// - -// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED -#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 -#endif -// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL -#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_SORTLIST_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SORTLIST_CONFIG_INFO_COLOR -#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 -#endif - -// NRF_SORTLIST_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_SORTLIST_CONFIG_DEBUG_COLOR -#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED -#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 -#endif -// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL -#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 -#endif - -// NRF_TWI_SENSOR_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_TWI_SENSOR_CONFIG_INFO_COLOR -#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 -#endif - -// NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR -#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. -//========================================================== -#ifndef PM_LOG_ENABLED -#define PM_LOG_ENABLED 1 -#endif -// PM_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef PM_LOG_LEVEL -#define PM_LOG_LEVEL 3 -#endif - -// PM_LOG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef PM_LOG_INFO_COLOR -#define PM_LOG_INFO_COLOR 0 -#endif - -// PM_LOG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef PM_LOG_DEBUG_COLOR -#define PM_LOG_DEBUG_COLOR 0 -#endif - -// - -// -//========================================================== - -// nrf_log in nRF_Serialization - -//========================================================== -// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED -#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 -#endif -// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL -#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 -#endif - -// SER_HAL_TRANSPORT_CONFIG_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef SER_HAL_TRANSPORT_CONFIG_INFO_COLOR -#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 -#endif - -// SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR -#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 -#endif - -// - -// -//========================================================== - -// -//========================================================== - -// - -// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter - - -#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED -#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 -#endif - -// -//========================================================== - -// nRF_NFC - -//========================================================== -// NFC_AC_REC_ENABLED - nfc_ac_rec - NFC NDEF Alternative Carrier record encoder - - -#ifndef NFC_AC_REC_ENABLED -#define NFC_AC_REC_ENABLED 0 -#endif - -// NFC_AC_REC_PARSER_ENABLED - nfc_ac_rec_parser - Alternative Carrier record parser - - -#ifndef NFC_AC_REC_PARSER_ENABLED -#define NFC_AC_REC_PARSER_ENABLED 0 -#endif - -// NFC_BLE_OOB_ADVDATA_ENABLED - nfc_ble_oob_advdata - AD data for OOB pairing encoder -//========================================================== -#ifndef NFC_BLE_OOB_ADVDATA_ENABLED -#define NFC_BLE_OOB_ADVDATA_ENABLED 0 -#endif -// ADVANCED_ADVDATA_SUPPORT - Non-mandatory AD types for BLE OOB pairing are encoded inside the NDEF message (e.g. service UUIDs) - -// <1=> Enabled -// <0=> Disabled - -#ifndef ADVANCED_ADVDATA_SUPPORT -#define ADVANCED_ADVDATA_SUPPORT 0 -#endif - -// - -// NFC_BLE_OOB_ADVDATA_PARSER_ENABLED - nfc_ble_oob_advdata_parser - BLE OOB pairing AD data parser - - -#ifndef NFC_BLE_OOB_ADVDATA_PARSER_ENABLED -#define NFC_BLE_OOB_ADVDATA_PARSER_ENABLED 0 -#endif - -// NFC_BLE_PAIR_LIB_ENABLED - nfc_ble_pair_lib - Library parameters -//========================================================== -#ifndef NFC_BLE_PAIR_LIB_ENABLED -#define NFC_BLE_PAIR_LIB_ENABLED 0 -#endif -// NFC_BLE_PAIR_LIB_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_BLE_PAIR_LIB_LOG_ENABLED -#define NFC_BLE_PAIR_LIB_LOG_ENABLED 0 -#endif -// NFC_BLE_PAIR_LIB_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_BLE_PAIR_LIB_LOG_LEVEL -#define NFC_BLE_PAIR_LIB_LOG_LEVEL 3 -#endif - -// NFC_BLE_PAIR_LIB_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_BLE_PAIR_LIB_INFO_COLOR -#define NFC_BLE_PAIR_LIB_INFO_COLOR 0 -#endif - -// NFC_BLE_PAIR_LIB_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_BLE_PAIR_LIB_DEBUG_COLOR -#define NFC_BLE_PAIR_LIB_DEBUG_COLOR 0 -#endif - -// - -// NFC_BLE_PAIR_LIB_SECURITY_PARAMETERS - Common Peer Manager security parameters. - -//========================================================== -// BLE_NFC_SEC_PARAM_BOND - Enables device bonding. - -// If bonding is enabled at least one of the BLE_NFC_SEC_PARAM_KDIST options must be enabled. -//========================================================== -#ifndef BLE_NFC_SEC_PARAM_BOND -#define BLE_NFC_SEC_PARAM_BOND 1 -#endif -// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. - - -#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC -#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 -#endif - -// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. - - -#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID -#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 -#endif - -// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. - - -#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC -#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 -#endif - -// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. - - -#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID -#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 -#endif - -// - -// BLE_NFC_SEC_PARAM_MIN_KEY_SIZE - Minimal size of a security key. - -// <7=> 7 -// <8=> 8 -// <9=> 9 -// <10=> 10 -// <11=> 11 -// <12=> 12 -// <13=> 13 -// <14=> 14 -// <15=> 15 -// <16=> 16 - -#ifndef BLE_NFC_SEC_PARAM_MIN_KEY_SIZE -#define BLE_NFC_SEC_PARAM_MIN_KEY_SIZE 7 -#endif - -// BLE_NFC_SEC_PARAM_MAX_KEY_SIZE - Maximal size of a security key. - -// <7=> 7 -// <8=> 8 -// <9=> 9 -// <10=> 10 -// <11=> 11 -// <12=> 12 -// <13=> 13 -// <14=> 14 -// <15=> 15 -// <16=> 16 - -#ifndef BLE_NFC_SEC_PARAM_MAX_KEY_SIZE -#define BLE_NFC_SEC_PARAM_MAX_KEY_SIZE 16 -#endif - -// -//========================================================== - -// - -// NFC_BLE_PAIR_MSG_ENABLED - nfc_ble_pair_msg - NDEF message for OOB pairing encoder - - -#ifndef NFC_BLE_PAIR_MSG_ENABLED -#define NFC_BLE_PAIR_MSG_ENABLED 0 -#endif - -// NFC_CH_COMMON_ENABLED - nfc_ble_pair_common - OOB pairing common data - - -#ifndef NFC_CH_COMMON_ENABLED -#define NFC_CH_COMMON_ENABLED 0 -#endif - -// NFC_EP_OOB_REC_ENABLED - nfc_ep_oob_rec - EP record for BLE pairing encoder - - -#ifndef NFC_EP_OOB_REC_ENABLED -#define NFC_EP_OOB_REC_ENABLED 0 -#endif - -// NFC_HS_REC_ENABLED - nfc_hs_rec - Handover Select NDEF record encoder - - -#ifndef NFC_HS_REC_ENABLED -#define NFC_HS_REC_ENABLED 0 -#endif - -// NFC_LE_OOB_REC_ENABLED - nfc_le_oob_rec - LE record for BLE pairing encoder - - -#ifndef NFC_LE_OOB_REC_ENABLED -#define NFC_LE_OOB_REC_ENABLED 0 -#endif - -// NFC_LE_OOB_REC_PARSER_ENABLED - nfc_le_oob_rec_parser - LE record parser - - -#ifndef NFC_LE_OOB_REC_PARSER_ENABLED -#define NFC_LE_OOB_REC_PARSER_ENABLED 0 -#endif - -// NFC_NDEF_LAUNCHAPP_MSG_ENABLED - nfc_launchapp_msg - Encoding data for NDEF Application Launching message for NFC Tag - - -#ifndef NFC_NDEF_LAUNCHAPP_MSG_ENABLED -#define NFC_NDEF_LAUNCHAPP_MSG_ENABLED 0 -#endif - -// NFC_NDEF_LAUNCHAPP_REC_ENABLED - nfc_launchapp_rec - Encoding data for NDEF Application Launching record for NFC Tag - - -#ifndef NFC_NDEF_LAUNCHAPP_REC_ENABLED -#define NFC_NDEF_LAUNCHAPP_REC_ENABLED 0 -#endif - -// NFC_NDEF_MSG_ENABLED - nfc_ndef_msg - NFC NDEF Message generator module -//========================================================== -#ifndef NFC_NDEF_MSG_ENABLED -#define NFC_NDEF_MSG_ENABLED 0 -#endif -// NFC_NDEF_MSG_TAG_TYPE - NFC Tag Type - -// <2=> Type 2 Tag -// <4=> Type 4 Tag - -#ifndef NFC_NDEF_MSG_TAG_TYPE -#define NFC_NDEF_MSG_TAG_TYPE 2 -#endif - -// - -// NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module -//========================================================== -#ifndef NFC_NDEF_MSG_PARSER_ENABLED -#define NFC_NDEF_MSG_PARSER_ENABLED 0 -#endif -// NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED -#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0 -#endif -// NFC_NDEF_MSG_PARSER_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL -#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3 -#endif - -// NFC_NDEF_MSG_PARSER_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_NDEF_MSG_PARSER_INFO_COLOR -#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0 -#endif - -// - -// - -// NFC_NDEF_RECORD_ENABLED - nfc_ndef_record - NFC NDEF Record generator module - - -#ifndef NFC_NDEF_RECORD_ENABLED -#define NFC_NDEF_RECORD_ENABLED 0 -#endif - -// NFC_NDEF_RECORD_PARSER_ENABLED - nfc_ndef_record_parser - NFC NDEF Record parser module -//========================================================== -#ifndef NFC_NDEF_RECORD_PARSER_ENABLED -#define NFC_NDEF_RECORD_PARSER_ENABLED 0 -#endif -// NFC_NDEF_RECORD_PARSER_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_NDEF_RECORD_PARSER_LOG_ENABLED -#define NFC_NDEF_RECORD_PARSER_LOG_ENABLED 0 -#endif -// NFC_NDEF_RECORD_PARSER_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_NDEF_RECORD_PARSER_LOG_LEVEL -#define NFC_NDEF_RECORD_PARSER_LOG_LEVEL 3 -#endif - -// NFC_NDEF_RECORD_PARSER_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_NDEF_RECORD_PARSER_INFO_COLOR -#define NFC_NDEF_RECORD_PARSER_INFO_COLOR 0 -#endif - -// - -// - -// NFC_NDEF_TEXT_RECORD_ENABLED - nfc_text_rec - Encoding data for a text record for NFC Tag - - -#ifndef NFC_NDEF_TEXT_RECORD_ENABLED -#define NFC_NDEF_TEXT_RECORD_ENABLED 0 -#endif - -// NFC_NDEF_URI_MSG_ENABLED - nfc_uri_msg - Encoding data for NDEF message with URI record for NFC Tag - - -#ifndef NFC_NDEF_URI_MSG_ENABLED -#define NFC_NDEF_URI_MSG_ENABLED 0 -#endif - -// NFC_NDEF_URI_REC_ENABLED - nfc_uri_rec - Encoding data for a URI record for NFC Tag - - -#ifndef NFC_NDEF_URI_REC_ENABLED -#define NFC_NDEF_URI_REC_ENABLED 0 -#endif - -// NFC_PLATFORM_ENABLED - nfc_platform - NFC platform module for Clock control. -//========================================================== -#ifndef NFC_PLATFORM_ENABLED -#define NFC_PLATFORM_ENABLED 0 -#endif -// NFC_PLATFORM_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_PLATFORM_LOG_ENABLED -#define NFC_PLATFORM_LOG_ENABLED 0 -#endif -// NFC_PLATFORM_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_PLATFORM_LOG_LEVEL -#define NFC_PLATFORM_LOG_LEVEL 3 -#endif - -// NFC_PLATFORM_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_PLATFORM_INFO_COLOR -#define NFC_PLATFORM_INFO_COLOR 0 -#endif - -// NFC_PLATFORM_DEBUG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_PLATFORM_DEBUG_COLOR -#define NFC_PLATFORM_DEBUG_COLOR 0 -#endif - -// - -// - -// NFC_T2T_PARSER_ENABLED - nfc_type_2_tag_parser - Parser for decoding Type 2 Tag data -//========================================================== -#ifndef NFC_T2T_PARSER_ENABLED -#define NFC_T2T_PARSER_ENABLED 0 -#endif -// NFC_T2T_PARSER_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_T2T_PARSER_LOG_ENABLED -#define NFC_T2T_PARSER_LOG_ENABLED 0 -#endif -// NFC_T2T_PARSER_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_T2T_PARSER_LOG_LEVEL -#define NFC_T2T_PARSER_LOG_LEVEL 3 -#endif - -// NFC_T2T_PARSER_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_T2T_PARSER_INFO_COLOR -#define NFC_T2T_PARSER_INFO_COLOR 0 -#endif - -// - -// - -// NFC_T4T_APDU_ENABLED - nfc_t4t_apdu - APDU encoder/decoder for Type 4 Tag -//========================================================== -#ifndef NFC_T4T_APDU_ENABLED -#define NFC_T4T_APDU_ENABLED 0 -#endif -// NFC_T4T_APDU_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_T4T_APDU_LOG_ENABLED -#define NFC_T4T_APDU_LOG_ENABLED 0 -#endif -// NFC_T4T_APDU_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_T4T_APDU_LOG_LEVEL -#define NFC_T4T_APDU_LOG_LEVEL 3 -#endif - -// NFC_T4T_APDU_LOG_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_T4T_APDU_LOG_COLOR -#define NFC_T4T_APDU_LOG_COLOR 0 -#endif - -// - -// - -// NFC_T4T_CC_FILE_PARSER_ENABLED - nfc_t4t_cc_file - Capability Container file for Type 4 Tag -//========================================================== -#ifndef NFC_T4T_CC_FILE_PARSER_ENABLED -#define NFC_T4T_CC_FILE_PARSER_ENABLED 0 -#endif -// NFC_T4T_CC_FILE_PARSER_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_T4T_CC_FILE_PARSER_LOG_ENABLED -#define NFC_T4T_CC_FILE_PARSER_LOG_ENABLED 0 -#endif -// NFC_T4T_CC_FILE_PARSER_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_T4T_CC_FILE_PARSER_LOG_LEVEL -#define NFC_T4T_CC_FILE_PARSER_LOG_LEVEL 3 -#endif - -// NFC_T4T_CC_FILE_PARSER_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_T4T_CC_FILE_PARSER_INFO_COLOR -#define NFC_T4T_CC_FILE_PARSER_INFO_COLOR 0 -#endif - -// - -// - -// NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED - nfc_t4t_hl_detection_procedures - NDEF Detection Procedure for Type 4 Tag -//========================================================== -#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED -#define NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED 0 -#endif -// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED -#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED 0 -#endif -// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL -#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL 3 -#endif - -// NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR -#define NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR 0 -#endif - -// - -// APDU_BUFF_SIZE - Size (in bytes) of the buffer for APDU storage -#ifndef APDU_BUFF_SIZE -#define APDU_BUFF_SIZE 250 -#endif - -// CC_STORAGE_BUFF_SIZE - Size (in bytes) of the buffer for CC file storage -#ifndef CC_STORAGE_BUFF_SIZE -#define CC_STORAGE_BUFF_SIZE 64 -#endif - -// - -// NFC_T4T_TLV_BLOCK_PARSER_ENABLED - nfc_t4t_tlv_block - TLV block for Type 4 Tag -//========================================================== -#ifndef NFC_T4T_TLV_BLOCK_PARSER_ENABLED -#define NFC_T4T_TLV_BLOCK_PARSER_ENABLED 0 -#endif -// NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED - Enables logging in the module. -//========================================================== -#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED -#define NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED 0 -#endif -// NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL - Default Severity level - -// <0=> Off -// <1=> Error -// <2=> Warning -// <3=> Info -// <4=> Debug - -#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL -#define NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL 3 -#endif - -// NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR - ANSI escape code prefix. - -// <0=> Default -// <1=> Black -// <2=> Red -// <3=> Green -// <4=> Yellow -// <5=> Blue -// <6=> Magenta -// <7=> Cyan -// <8=> White - -#ifndef NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR -#define NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR 0 -#endif - -// - -// - -// -//========================================================== - -// nRF_SoftDevice - -//========================================================== -// NRF_SDH_ANT_ENABLED - nrf_sdh_ant - SoftDevice ANT event handler -//========================================================== -#ifndef NRF_SDH_ANT_ENABLED -#define NRF_SDH_ANT_ENABLED 0 -#endif -// ANT Channels - -//========================================================== -// NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED - Allocated ANT channels. -#ifndef NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED -#define NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED 0 -#endif - -// NRF_SDH_ANT_ENCRYPTED_CHANNELS - Encrypted ANT channels. -#ifndef NRF_SDH_ANT_ENCRYPTED_CHANNELS -#define NRF_SDH_ANT_ENCRYPTED_CHANNELS 0 -#endif - -// -//========================================================== - -// ANT Queues - -//========================================================== -// NRF_SDH_ANT_EVENT_QUEUE_SIZE - Event queue size. -#ifndef NRF_SDH_ANT_EVENT_QUEUE_SIZE -#define NRF_SDH_ANT_EVENT_QUEUE_SIZE 32 -#endif - -// NRF_SDH_ANT_BURST_QUEUE_SIZE - ANT burst queue size. -#ifndef NRF_SDH_ANT_BURST_QUEUE_SIZE -#define NRF_SDH_ANT_BURST_QUEUE_SIZE 128 -#endif -// -//========================================================== - -// ANT Observers - Observers and priority levels - -//========================================================== -// NRF_SDH_ANT_OBSERVER_PRIO_LEVELS - Total number of priority levels for ANT observers. -// This setting configures the number of priority levels available for the ANT event handlers. -// The priority level of a handler determines the order in which it receives events, with respect to other handlers. - -#ifndef NRF_SDH_ANT_OBSERVER_PRIO_LEVELS -#define NRF_SDH_ANT_OBSERVER_PRIO_LEVELS 2 -#endif - -// ANT Observers priorities - Invididual priorities - -//========================================================== -// ANT_BPWR_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Bicycle Power Profile. - -#ifndef ANT_BPWR_ANT_OBSERVER_PRIO -#define ANT_BPWR_ANT_OBSERVER_PRIO 1 -#endif - -// ANT_BSC_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Bicycle Speed and Cadence Profile. - -#ifndef ANT_BSC_ANT_OBSERVER_PRIO -#define ANT_BSC_ANT_OBSERVER_PRIO 1 -#endif - -// ANT_ENCRYPT_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Cryptographic ANT stack configuration module. - -#ifndef ANT_ENCRYPT_ANT_OBSERVER_PRIO -#define ANT_ENCRYPT_ANT_OBSERVER_PRIO 1 -#endif - -// ANT_HRM_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Heart Rate Monitor. - -#ifndef ANT_HRM_ANT_OBSERVER_PRIO -#define ANT_HRM_ANT_OBSERVER_PRIO 1 -#endif - -// ANT_SDM_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Stride Based Speed and Distance Monitor Profile. - -#ifndef ANT_SDM_ANT_OBSERVER_PRIO -#define ANT_SDM_ANT_OBSERVER_PRIO 1 -#endif - -// ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the ANT state indicator module. - -#ifndef ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO -#define ANT_STATE_INDICATOR_ANT_OBSERVER_PRIO 1 -#endif - -// BSP_BTN_ANT_OBSERVER_PRIO -// Priority with which ANT events are dispatched to the Button Control module. - -#ifndef BSP_BTN_ANT_OBSERVER_PRIO -#define BSP_BTN_ANT_OBSERVER_PRIO 1 -#endif - -// NRF_DFU_ANT_EVT_HANDLER_PRIO - DFU ANT event handling priority. -// Priority used to register the ANT event handler for DFU purposes. Change this if there is other ANT event handlers that should be higher priority. - -#ifndef NRF_DFU_ANT_EVT_HANDLER_PRIO -#define NRF_DFU_ANT_EVT_HANDLER_PRIO 1 -#endif - -// -//========================================================== +// nRF_SoftDevice -// //========================================================== - - -// - // NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler //========================================================== #ifndef NRF_SDH_BLE_ENABLED -#define NRF_SDH_BLE_ENABLED 0 +#define NRF_SDH_BLE_ENABLED 1 #endif // BLE Stack configuration - Stack configuration parameters @@ -12290,25 +61,25 @@ // Requested BLE GAP data length to be negotiated. -#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH -#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 -#endif +//#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +//#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +//#endif // NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. #ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT -#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 0 +#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 5 //TBD #endif // NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. #ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT -#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 +#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 15 //TBD #endif // NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. // Maximum number of total concurrent connections using the default configuration. #ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT -#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 +#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 //TBD #endif // NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. @@ -12320,7 +91,7 @@ // NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. #ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE -#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23 +#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247 #endif // NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. @@ -12330,7 +101,7 @@ // NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs. #ifndef NRF_SDH_BLE_VS_UUID_COUNT -#define NRF_SDH_BLE_VS_UUID_COUNT 0 +#define NRF_SDH_BLE_VS_UUID_COUNT 20 #endif // NRF_SDH_BLE_SERVICE_CHANGED - Include the Service Changed characteristic in the Attribute Table. @@ -12340,7 +111,7 @@ #define NRF_SDH_BLE_SERVICE_CHANGED 0 #endif -// +// //========================================================== // BLE Observers - Observers and priority levels @@ -12353,394 +124,47 @@ #ifndef NRF_SDH_BLE_OBSERVER_PRIO_LEVELS #define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4 #endif - -// BLE Observers priorities - Invididual priorities - -//========================================================== -// BLE_ADV_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Advertising module. - -#ifndef BLE_ADV_BLE_OBSERVER_PRIO -#define BLE_ADV_BLE_OBSERVER_PRIO 1 -#endif - -// BLE_ANCS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Apple Notification Service Client. - -#ifndef BLE_ANCS_C_BLE_OBSERVER_PRIO -#define BLE_ANCS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_ANS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Alert Notification Service Client. - -#ifndef BLE_ANS_C_BLE_OBSERVER_PRIO -#define BLE_ANS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_BAS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Battery Service. - -#ifndef BLE_BAS_BLE_OBSERVER_PRIO -#define BLE_BAS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_BAS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Battery Service Client. - -#ifndef BLE_BAS_C_BLE_OBSERVER_PRIO -#define BLE_BAS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_BPS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Blood Pressure Service. - -#ifndef BLE_BPS_BLE_OBSERVER_PRIO -#define BLE_BPS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_CONN_PARAMS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Connection parameters module. - -#ifndef BLE_CONN_PARAMS_BLE_OBSERVER_PRIO -#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 1 -#endif - -// BLE_CONN_STATE_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Connection State module. - -#ifndef BLE_CONN_STATE_BLE_OBSERVER_PRIO -#define BLE_CONN_STATE_BLE_OBSERVER_PRIO 0 -#endif - -// BLE_CSCS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Cycling Speed and Cadence Service. - -#ifndef BLE_CSCS_BLE_OBSERVER_PRIO -#define BLE_CSCS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_CTS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Current Time Service Client. - -#ifndef BLE_CTS_C_BLE_OBSERVER_PRIO -#define BLE_CTS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_DB_DISC_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Database Discovery module. - -#ifndef BLE_DB_DISC_BLE_OBSERVER_PRIO -#define BLE_DB_DISC_BLE_OBSERVER_PRIO 1 -#endif - -// BLE_DFU_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the DFU Service. - -#ifndef BLE_DFU_BLE_OBSERVER_PRIO -#define BLE_DFU_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_DIS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Device Information Client. - -#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO -#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_GLS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Glucose Service. - -#ifndef BLE_GLS_BLE_OBSERVER_PRIO -#define BLE_GLS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_HIDS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Human Interface Device Service. - -#ifndef BLE_HIDS_BLE_OBSERVER_PRIO -#define BLE_HIDS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_HRS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Heart Rate Service. - -#ifndef BLE_HRS_BLE_OBSERVER_PRIO -#define BLE_HRS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_HRS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Heart Rate Service Client. - -#ifndef BLE_HRS_C_BLE_OBSERVER_PRIO -#define BLE_HRS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_HTS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Health Thermometer Service. - -#ifndef BLE_HTS_BLE_OBSERVER_PRIO -#define BLE_HTS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_IAS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Immediate Alert Service. - -#ifndef BLE_IAS_BLE_OBSERVER_PRIO -#define BLE_IAS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_IAS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Immediate Alert Service Client. - -#ifndef BLE_IAS_C_BLE_OBSERVER_PRIO -#define BLE_IAS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_LBS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the LED Button Service. - -#ifndef BLE_LBS_BLE_OBSERVER_PRIO -#define BLE_LBS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_LBS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the LED Button Service Client. - -#ifndef BLE_LBS_C_BLE_OBSERVER_PRIO -#define BLE_LBS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_LLS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Link Loss Service. - -#ifndef BLE_LLS_BLE_OBSERVER_PRIO -#define BLE_LLS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_LNS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Location Navigation Service. - -#ifndef BLE_LNS_BLE_OBSERVER_PRIO -#define BLE_LNS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_NUS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the UART Service. - -#ifndef BLE_NUS_BLE_OBSERVER_PRIO -#define BLE_NUS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_NUS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the UART Central Service. - -#ifndef BLE_NUS_C_BLE_OBSERVER_PRIO -#define BLE_NUS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_OTS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Object transfer service. - -#ifndef BLE_OTS_BLE_OBSERVER_PRIO -#define BLE_OTS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_OTS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Object transfer service client. - -#ifndef BLE_OTS_C_BLE_OBSERVER_PRIO -#define BLE_OTS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_RSCS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Running Speed and Cadence Service. - -#ifndef BLE_RSCS_BLE_OBSERVER_PRIO -#define BLE_RSCS_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_RSCS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Running Speed and Cadence Client. - -#ifndef BLE_RSCS_C_BLE_OBSERVER_PRIO -#define BLE_RSCS_C_BLE_OBSERVER_PRIO 2 -#endif - -// BLE_TPS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the TX Power Service. - -#ifndef BLE_TPS_BLE_OBSERVER_PRIO -#define BLE_TPS_BLE_OBSERVER_PRIO 2 -#endif - -// BSP_BTN_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Button Control module. - -#ifndef BSP_BTN_BLE_OBSERVER_PRIO -#define BSP_BTN_BLE_OBSERVER_PRIO 1 -#endif - -// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the NFC pairing library. - -#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO -#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 -#endif - -// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the NFC pairing library. - -#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO -#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 -#endif - -// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the NFC pairing library. - -#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO -#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 -#endif - -// NRF_BLE_BMS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Bond Management Service. - -#ifndef NRF_BLE_BMS_BLE_OBSERVER_PRIO -#define NRF_BLE_BMS_BLE_OBSERVER_PRIO 2 -#endif - -// NRF_BLE_CGMS_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Contiuon Glucose Monitoring Service. - -#ifndef NRF_BLE_CGMS_BLE_OBSERVER_PRIO -#define NRF_BLE_CGMS_BLE_OBSERVER_PRIO 2 -#endif - -// NRF_BLE_ES_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Eddystone module. - -#ifndef NRF_BLE_ES_BLE_OBSERVER_PRIO -#define NRF_BLE_ES_BLE_OBSERVER_PRIO 2 -#endif - -// NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the GATT Service Client. - -#ifndef NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO -#define NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO 2 -#endif - -// NRF_BLE_GATT_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the GATT module. - -#ifndef NRF_BLE_GATT_BLE_OBSERVER_PRIO -#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 -#endif - -// NRF_BLE_GQ_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the GATT Queue module. - -#ifndef NRF_BLE_GQ_BLE_OBSERVER_PRIO -#define NRF_BLE_GQ_BLE_OBSERVER_PRIO 1 -#endif - -// NRF_BLE_QWR_BLE_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the Queued writes module. - -#ifndef NRF_BLE_QWR_BLE_OBSERVER_PRIO -#define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 -#endif - -// NRF_BLE_SCAN_OBSERVER_PRIO -// Priority for dispatching the BLE events to the Scanning Module. - -#ifndef NRF_BLE_SCAN_OBSERVER_PRIO -#define NRF_BLE_SCAN_OBSERVER_PRIO 1 -#endif - -// PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. -#ifndef PM_BLE_OBSERVER_PRIO -#define PM_BLE_OBSERVER_PRIO 1 -#endif - -// //========================================================== -// +// //========================================================== - // // NRF_SDH_ENABLED - nrf_sdh - SoftDevice handler //========================================================== #ifndef NRF_SDH_ENABLED -#define NRF_SDH_ENABLED 0 +#define NRF_SDH_ENABLED 1 #endif -// Dispatch model -// This setting configures how Stack events are dispatched to the application. -//========================================================== -// NRF_SDH_DISPATCH_MODEL - +// -// NRF_SDH_DISPATCH_MODEL_INTERRUPT: SoftDevice events are passed to the application from the interrupt context. -// NRF_SDH_DISPATCH_MODEL_APPSH: SoftDevice events are scheduled using @ref app_scheduler. -// NRF_SDH_DISPATCH_MODEL_POLLING: SoftDevice events are to be fetched manually. -// <0=> NRF_SDH_DISPATCH_MODEL_INTERRUPT -// <1=> NRF_SDH_DISPATCH_MODEL_APPSH -// <2=> NRF_SDH_DISPATCH_MODEL_POLLING +// NRF_QUEUE_ENABLED - nrf_queue - Queue module -#ifndef NRF_SDH_DISPATCH_MODEL -#define NRF_SDH_DISPATCH_MODEL 0 +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 1 #endif -// -//========================================================== - -// Clock - SoftDevice clock configuration - -//========================================================== -// NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source. - -// <0=> NRF_CLOCK_LF_SRC_RC -// <1=> NRF_CLOCK_LF_SRC_XTAL -// <2=> NRF_CLOCK_LF_SRC_SYNTH +// Build warnings -#ifndef NRF_SDH_CLOCK_LF_SRC -#define NRF_SDH_CLOCK_LF_SRC 1 +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 0 #endif -// NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. -#ifndef NRF_SDH_CLOCK_LF_RC_CTIV -#define NRF_SDH_CLOCK_LF_RC_CTIV 0 +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 #endif -// NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. -// How often (in number of calibration intervals) the RC oscillator shall be calibrated -// if the temperature has not changed. - -#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV -#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 #endif -// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator -// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM -// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM -// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM -// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM -// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM -// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM -// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM -// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM -// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM -// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM -// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM -// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM -#ifndef NRF_SDH_CLOCK_LF_ACCURACY -#define NRF_SDH_CLOCK_LF_ACCURACY 7 +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 #endif // @@ -12773,32 +197,6 @@ #define NRF_SDH_STACK_OBSERVER_PRIO_LEVELS 2 #endif - -// State Observers priorities - Invididual priorities - -//========================================================== -// CLOCK_CONFIG_STATE_OBSERVER_PRIO -// Priority with which state events are dispatched to the Clock driver. - -#ifndef CLOCK_CONFIG_STATE_OBSERVER_PRIO -#define CLOCK_CONFIG_STATE_OBSERVER_PRIO 0 -#endif - -// POWER_CONFIG_STATE_OBSERVER_PRIO -// Priority with which state events are dispatched to the Power driver. - -#ifndef POWER_CONFIG_STATE_OBSERVER_PRIO -#define POWER_CONFIG_STATE_OBSERVER_PRIO 0 -#endif - -// RNG_CONFIG_STATE_OBSERVER_PRIO -// Priority with which state events are dispatched to this module. - -#ifndef RNG_CONFIG_STATE_OBSERVER_PRIO -#define RNG_CONFIG_STATE_OBSERVER_PRIO 0 -#endif - -// //========================================================== // Stack Event Observers priorities - Invididual priorities @@ -12831,67 +229,6 @@ #define NRF_SDH_SOC_STACK_OBSERVER_PRIO 0 #endif -// -//========================================================== - -// -//========================================================== - - -// - -// NRF_SDH_SOC_ENABLED - nrf_sdh_soc - SoftDevice SoC event handler -//========================================================== -#ifndef NRF_SDH_SOC_ENABLED -#define NRF_SDH_SOC_ENABLED 0 -#endif -// SoC Observers - Observers and priority levels - -//========================================================== -// NRF_SDH_SOC_OBSERVER_PRIO_LEVELS - Total number of priority levels for SoC observers. -// This setting configures the number of priority levels available for the SoC event handlers. -// The priority level of a handler determines the order in which it receives events, with respect to other handlers. - -#ifndef NRF_SDH_SOC_OBSERVER_PRIO_LEVELS -#define NRF_SDH_SOC_OBSERVER_PRIO_LEVELS 2 -#endif - -// SoC Observers priorities - Invididual priorities - -//========================================================== -// BLE_DFU_SOC_OBSERVER_PRIO -// Priority with which BLE events are dispatched to the DFU Service. - -#ifndef BLE_DFU_SOC_OBSERVER_PRIO -#define BLE_DFU_SOC_OBSERVER_PRIO 1 -#endif - -// CLOCK_CONFIG_SOC_OBSERVER_PRIO -// Priority with which SoC events are dispatched to the Clock driver. - -#ifndef CLOCK_CONFIG_SOC_OBSERVER_PRIO -#define CLOCK_CONFIG_SOC_OBSERVER_PRIO 0 -#endif - -// POWER_CONFIG_SOC_OBSERVER_PRIO -// Priority with which SoC events are dispatched to the Power driver. - -#ifndef POWER_CONFIG_SOC_OBSERVER_PRIO -#define POWER_CONFIG_SOC_OBSERVER_PRIO 0 -#endif - -// -//========================================================== - -// -//========================================================== - - -// - -// -//========================================================== - // <<< end of configuration section >>> #endif //SDK_CONFIG_H diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h index 7c21b14fd..1574c3a8b 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h @@ -189,7 +189,7 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "nrf9160_name_change.h" #else - #error "Device must be defined. See nrf.h." +// #error "Device must be defined. See nrf.h." #endif /* NRF51, NRF52805_XXAA, NRF52810_XXAA, NRF52811_XXAA, NRF52820_XXAA, NRF52832_XXAA, NRF52832_XXAB, NRF52833_XXAA, NRF52840_XXAA, NRF5340_XXAA_APPLICATION, NRF5340_XXAA_NETWORK, NRF9160_XXAA */ #include "compiler_abstraction.h" diff --git a/sdk/configs/device/nrf52/defconfig b/sdk/configs/device/nrf52/defconfig new file mode 100644 index 000000000..f0e3e95ee --- /dev/null +++ b/sdk/configs/device/nrf52/defconfig @@ -0,0 +1,4 @@ ++BLUETOOTH=y ++EXTERNALS_NRF52=y ++BLUETOOTH_NRF52=y ++UART2_PARITY=2 diff --git a/sdk/configs/examples/ble_peripheral/defconfig b/sdk/configs/examples/ble_peripheral/defconfig index 2234f85dd..80e5fe1c5 100644 --- a/sdk/configs/examples/ble_peripheral/defconfig +++ b/sdk/configs/examples/ble_peripheral/defconfig @@ -1,3 +1,2 @@ -+BCM20706=y +BLUETOOTH=y +EXAMPLES_BLUETOOTH_LE_PERIPHERAL=y diff --git a/sdk/modules/bluetooth/Makefile b/sdk/modules/bluetooth/Makefile index df575c248..fdd936314 100644 --- a/sdk/modules/bluetooth/Makefile +++ b/sdk/modules/bluetooth/Makefile @@ -59,4 +59,8 @@ ifeq ($(CONFIG_BCM20706),y) include hal/bcm20706/Make.defs endif +ifeq ($(CONFIG_BLUETOOTH_NRF52),y) +include hal/nrf52/Make.defs +endif + include $(SDKDIR)/modules/Module.mk diff --git a/sdk/modules/bluetooth/bluetooth_hal_init.c b/sdk/modules/bluetooth/bluetooth_hal_init.c index 6384356f6..e54b11e4f 100644 --- a/sdk/modules/bluetooth/bluetooth_hal_init.c +++ b/sdk/modules/bluetooth/bluetooth_hal_init.c @@ -45,6 +45,8 @@ #ifdef CONFIG_BCM20706 extern int bcm20706_probe(void); +#elif defined CONFIG_BLUETOOTH_NRF52 +extern int nrf52_probe(void); #endif /**************************************************************************** @@ -66,6 +68,8 @@ int bt_hal_init(void) #ifdef CONFIG_BCM20706 ret = bcm20706_probe(); +#elif defined CONFIG_BLUETOOTH_NRF52 + ret = nrf52_probe(); #endif return ret; diff --git a/sdk/modules/bluetooth/hal/Kconfig b/sdk/modules/bluetooth/hal/Kconfig index 474e26fc6..b3faaa6da 100644 --- a/sdk/modules/bluetooth/hal/Kconfig +++ b/sdk/modules/bluetooth/hal/Kconfig @@ -5,5 +5,6 @@ menu "Device support" source "$APPSDIR/../modules/bluetooth/hal/bcm20706/Kconfig" +source "$APPSDIR/../modules/bluetooth/hal/nrf52/Kconfig" endmenu diff --git a/sdk/modules/bluetooth/hal/nrf52/Kconfig b/sdk/modules/bluetooth/hal/nrf52/Kconfig new file mode 100644 index 000000000..35d441abc --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/Kconfig @@ -0,0 +1,30 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + + +config BLUETOOTH_NRF52 + bool "Nordic nRF52 series" + default n + ---help--- + Nordic nRF52 provides BLE interfaces for application. + +if BLUETOOTH_NRF52 + +config NRF52_LE + bool + default BLUETOOTH_LE + ---help--- + This option enabling Cypress NRF52 Low Energy HAL. + +if NRF52_LE +config NRF52_LE_GATT + bool + default BLUETOOTH_LE_GATT + ---help--- + This option enabling Cypress NRF52 LE GATT HAL. + +endif # NRF52_LE + +endif # BLUETOOTH_NRF52 diff --git a/sdk/modules/bluetooth/hal/nrf52/Make.defs b/sdk/modules/bluetooth/hal/nrf52/Make.defs new file mode 100644 index 000000000..58e8734e6 --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/Make.defs @@ -0,0 +1,65 @@ +############################################################################ +# bluetooth/hal/nrf52/Make.defs +# +# Copyright 2021 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Corporation nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +BLEDIR := $(SDKDIR)$(DELIM)modules$(DELIM)bluetooth$(DELIM)hal$(DELIM)nrf52 +ifeq ($(CONFIG_BLUETOOTH_NRF52_S132),y) +BLE_IGNORE_DIR := "*s140*" +BLE_API_VERSION := 7 +else +BLE_IGNORE_DIR := "*s132*" +BLE_API_VERSION := 7 +endif + +# SOURCES +BLE_C_FILES := $(shell find $(BLEDIR) -name "*.c" -printf '%f ') +BLE_C_DIRS := $(sort $(dir $(shell find $(BLEDIR) -name "*.c"))) +# INCLUDES +BLE_H_DIRS := $(sort $(dir $(shell find $(BLEDIR) -name "*.h" -not -path $(BLE_IGNORE_DIR)))) +BLE_INCLUDES := $(addprefix -I, $(BLE_H_DIRS)) + +ifeq ($(WINTOOL),y) +INCLUDES += -I"${shell cygpath -w $(BLEDIR)/include}" +else +INCLUDES += -I$(BLEDIR)/include +endif + +CFLAGS += $(INCLUDES) $(BLE_INCLUDES) +CFLAGS += -DBLE_STACK_SUPPORT_REQD -DNRF_SD_BLE_API_VERSION=$(BLE_API_VERSION) -DSVCALL_AS_NORMAL_FUNCTION -DBLE_SUPPORT_BLE5 -std=c99 +CFLAGS += -DBLE_ENABLE_NORDIC_ORIGINAL + +CSRCS += $(BLE_C_FILES) + +DEPPATH += --dep-path ". $(BLE_C_DIRS)" +VPATH += $(BLE_C_DIRS) + diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_comm.c b/sdk/modules/bluetooth/hal/nrf52/ble_comm.c new file mode 100644 index 000000000..ae510c8f1 --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/ble_comm.c @@ -0,0 +1,2733 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/ble_comm.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include "ble_storage_operations.h" +#include "ble_comm_internal.h" +#include "nrf_sdh.h" +#include "nrf_sdh_ble.h" +#include +#include + +/****************************************************************************** + * externs + *****************************************************************************/ +extern bleGapMem *bleGetGapMem(void); +extern void bleMngEvtDispatch(ble_evt_t *nrfEvt); +extern void board_nrf52_initialize(void); +extern void board_nrf52_reset(bool en); + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +// #define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define BLE_PRT printf +#define BLE_PRT2(...) +#define BLE_ERR printf +#else +#define BLE_PRT(...) +#define BLE_PRT2(...) +#define BLE_ERR(...) +#endif + + /****************************************************************************** + * Structure define + *****************************************************************************/ + + /****************************************************************************** + * Function prototype declaration + *****************************************************************************/ +static int blePowerOn(void); +static int bleStackInit(void); +static int bleStackFin(void); +#ifdef BLE_USE_SECTION +static void bleEvtDispatch(ble_evt_t *pBleNrfEvt); +#endif +#if NRF_SD_BLE_API_VERSION > 5 +static void onAdvSetTerminate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +#endif +static void onScanReqReport(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onPhyUpdateReq(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onPhyUpdate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onDataLengthUpdateRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onDataLengthUpdate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onExchangeMtuRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onTxComplete(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onConnect(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onConnParamUpdate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onConnParamUpdateRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onDisconnect(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onSecParamsRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onAuthStatus(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onDispPasskey(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onAdvReport(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onAuthKeyRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onConnSecUpdate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onSecInfoRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onTimeout(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onGattsTimeout(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onRssiChanged(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onGattsWrite(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onGattsIndConfirm(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onPrimarySrvDiscoveryRsp(bleGattcDb *gattcDbDiscovery, BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onCharacteristicDiscoveryRsp(bleGattcDb *const gattcDbDiscovery, BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onDescriptorDiscoveryRsp(bleGattcDb *const gattcDbDiscovery, BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onHvx(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onSysAttrMissing(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onReadRsp(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onWriteRsp(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt); +static void onSrvDiscCompletion(BLE_Evt *pBleEvent, bleGattcDb *gattcDbDiscovery); +static int characteristicsDiscover(BLE_Evt *pBleEvent, bleGattcDb *const gattcDbDiscovery); +static bool isCharDiscoveryReqd(bleGattcDb *const gattcDbDiscovery, BLE_GattcChar *afterChar); +static bool isDescDiscoveryReqd(bleGattcDb *gattcDbDiscovery, BLE_GattcDbDiscChar *currChar, BLE_GattcDbDiscChar *nextChar, BLE_GattcHandleRange *handleRange); +static int descriptorsDiscover(BLE_Evt *pBleEvent, bleGattcDb *const gattcDbDiscovery, bool *raiseDiscovComplete); + +static int nrf52_ble_set_dev_addr(BT_ADDR *addr); +static int nrf52_bt_init(void); +static int nrf52_bt_finalize(void); +static int nrf52_bt_enable(bool enable); +static int nrf52_bt_set_device_addr(BT_ADDR *addr); +static int nrf52_bt_get_device_addr(BT_ADDR *addr); +static int nrf52_bt_set_device_name(char *name); +static int nrf52_bt_get_device_name(char *name); +static int nrf52_bt_paring_enable(bool enable); +static int nrf52_bt_get_bond_list(BT_ADDR *addrs, int *num); +static int nrf52_bt_un_bond(BT_ADDR *addr); +static int nrf52_bt_set_visibility(BT_VISIBILITY visibility); +static int nrf52_bt_inquiry_start(void); +static int nrf52_bt_inquiry_cancel(void); + +/****************************************************************************** + * Private Data + *****************************************************************************/ +bleCommMem commMem = {0}; +bleGapWrapperBondInfo BondInfoInFlash[BLE_SAVE_BOND_DEVICE_MAX_NUM] = {{0}}; +uint32_t bleBondEnableList = 0; +bleBondInfoKey bleKey = {0}; +struct bt_common_context_s bt_common_context = {0}; + +#define BUF_LEN_MAX 32 + +#ifndef CONFIG_NRF51822 +#define READ_BUFF_LEN 512 +#else +#define READ_BUFF_LEN 20 +#endif + +#define WAIT_TIME (100*1000) +#define LOG_OUT printf +#define AUTH_KEY_SIZE 6 +static BLE_GattcDbDiscovery gattc_db_discovery = {0}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int blePowerOff(void) +{ + int ret = 0; + +// for support reset pin. (Will be valid later) +// board_nrf52_reset(true); + ret = board_power_control(POWER_BTBLE, false); + if (ret) + { + BLE_PRT("board_power_control(off): NG %d\n", ret); + return ret; + } + BLE_PRT("Power off BLE!!\n"); + return BLE_SUCCESS; +} + +static void bleInitBondInfoKey(void) +{ + bleKey.enable_key = BSO_GenerateRegistryKey(BOND_ENABLE_KEY_NAME, 0); + bleKey.info_key[0] = BSO_GenerateRegistryKey(BOND_INFO_1_KEY_NAME, 0); + bleKey.info_key[1] = BSO_GenerateRegistryKey(BOND_INFO_2_KEY_NAME, 0); + bleKey.info_key[2] = BSO_GenerateRegistryKey(BOND_INFO_3_KEY_NAME, 0); + bleKey.info_key[3] = BSO_GenerateRegistryKey(BOND_INFO_4_KEY_NAME, 0); + bleKey.info_key[4] = BSO_GenerateRegistryKey(BOND_INFO_5_KEY_NAME, 0); + bleKey.info_key[5] = BSO_GenerateRegistryKey(BOND_INFO_6_KEY_NAME, 0); + bleKey.info_key[6] = BSO_GenerateRegistryKey(BOND_INFO_7_KEY_NAME, 0); + bleKey.info_key[7] = BSO_GenerateRegistryKey(BOND_INFO_8_KEY_NAME, 0); +#ifdef BLE_DBGPRT_ENABLE + BLE_PRT("bleInitBondInfoKey: enable_key 0x%lx\n", bleKey.enable_key); + for (int i=0; irole; + ret = BSO_Init(NULL); + if (ret) + { + BLE_PRT("BSO_Init failed\n"); + return ret; + } + ret = bleGetBondInfo(); + if (ret) + { + BLE_PRT("bleGetBondInfo: NG %d\n", ret); + return ret; + } + switch (role) + { + case BLE_ROLE_PERIPHERAL: + case BLE_ROLE_CENTRAL: + case BLE_ROLE_PERIPHERAL_AND_CENTRAL: + ret = blePowerOn(); + if (ret) + { + goto errPower; + } + ret = bleStackInit(); + if (ret) + { + BLE_PRT("bleStackInit: NG %d\n", ret); + goto errInit; + } + else + { + commMem.stackInited = true; + } + break; + default: + ret = -EINVAL; + break; + } + return ret; +errInit: + bleStackFin(); + blePowerOff(); +errPower: + return ret; + +} + +int BLE_CommonSetBleEvtCallback(BLE_EfCb funcCb, BLE_EvtCtx *ctx) +{ + if (ctx == NULL) + { + return -EINVAL; + } + if (commMem.managerCbFlag) + { + return -EPERM; + } + + commMem.cbId = funcCb; + commMem.bleEvtCtx = ctx; + commMem.callbackFlag = 1; + BLE_PRT("%s:commMem.callbackFlag=%d\n", __func__, commMem.callbackFlag); + return BLE_SUCCESS; +} + +int BLE_CommonFinalizeStack(void) +{ + int ret = BLE_SUCCESS; + if (!commMem.stackInited) + { + return ret; + } + commMem.callbackFlag = 0; + commMem.gapMem = NULL; + if (bleStackFin()) + { + ret = -EPERM; + } + if (blePowerOff()) + { + ret = -EPERM; + } + commMem.stackInited = false; + return ret; +} + +static +int blePowerOn(void) +{ + int ret = 0; + ret = board_power_control(POWER_BTBLE, true); + if (ret) + { + BLE_PRT("board_power_control(on): NG %d\n", ret); + goto errPower; + } +// for support reset pin. (Will be valid later) +// board_nrf52_reset(false); + BLE_PRT("Power on BLE!!\n"); + return BLE_SUCCESS; +errPower: + (void)board_power_control(POWER_BTBLE, false); + return ret; + +} + +int bleConvertErrorCode(uint32_t errCode) +{ + int ret = 0; + switch (errCode) + { + case NRF_SUCCESS: + ret = BLE_SUCCESS; + break; + case NRF_ERROR_INVALID_PARAM: + BLE_ERR("errno: 0x%lx, Invalid parameter.\n", errCode); + ret = -EINVAL; + break; + case NRF_ERROR_INVALID_STATE: + BLE_ERR("errno: 0x%lx, Invalid state.\n", errCode); + ret = -EINVAL; + break; + case NRF_ERROR_INVALID_ADDR: + BLE_ERR("errno: 0x%lx, Bad Memory Address.\n", errCode); + ret = -EINVAL; + break; + case NRF_ERROR_INVALID_FLAGS: + BLE_ERR("errno: 0x%lx, Invalid flags.\n", errCode); + ret = -EINVAL; + break; + case NRF_ERROR_INVALID_DATA: + BLE_ERR("errno: 0x%lx, Invalid data.\n", errCode); + ret = -EINVAL; + break; + case NRF_ERROR_DATA_SIZE: + BLE_ERR("errno: 0x%lx, Data size exceeds limit.\n", errCode); + ret = -EINVAL; + break; + case NRF_ERROR_INVALID_LENGTH: + BLE_ERR("errno: 0x%lx, Invalid length.\n", errCode); + ret = -EINVAL; + break; + case NRF_ERROR_NOT_SUPPORTED: + BLE_ERR("errno: 0x%lx, Not supported.\n", errCode); + ret = -EINVAL; + break; + case NRF_ERROR_BUSY: + BLE_ERR("errno: 0x%lx, Busy.\n", errCode); + ret = -EPERM; + break; + case NRF_ERROR_NO_MEM: + BLE_ERR("errno: 0x%lx, No Memory for operation.\n", errCode); + ret = -EPERM; + break; + case NRF_ERROR_FORBIDDEN: + BLE_ERR("errno: 0x%lx, Forbidden Operation.\n", errCode); + ret = -EPERM; + break; + case BLE_ERROR_INVALID_CONN_HANDLE: + BLE_ERR("errno: 0x%lx, Invalid connection handler.\n", errCode); + ret = -EPERM; + break; + case BLE_ERROR_GAP_UUID_LIST_MISMATCH: + BLE_ERR("errno: 0x%lx, BLE_ERROR_GAP_UUID_LIST_MISMATCH.\n", errCode); + ret = -EINVAL; + break; + case BLE_ERROR_GAP_INVALID_BLE_ADDR: + BLE_ERR("errno: 0x%lx, BLE_ERROR_GAP_INVALID_BLE_ADDR.\n", errCode); + ret = -EPERM; + break; + case BLE_ERROR_GAP_WHITELIST_IN_USE: + BLE_ERR("errno: 0x%lx, BLE_ERROR_GAP_WHITELIST_IN_USE.\n", errCode); + ret = -EPERM; + break; + case BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST: + BLE_ERR("errno: 0x%lx, BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST.\n", errCode); + ret = -EPERM; + break; + case NRF_ERROR_TIMEOUT: + BLE_ERR("errno: 0x%lx, NRF_ERROR_TIMEOUT.\n", errCode); + ret = -ETIMEDOUT; + break; + default: + if (errCode > 0) + { + BLE_ERR("errno: 0x%lx, Stack error.\n", errCode); + ret = -EPERM; + } + break; + } + return ret; +} + +static +int bleStackInit(void) +{ + int ret; + BLE_PRT("nrf_sdh_enable_request\n"); + ret = nrf_sdh_enable_request(); + if (ret) + { + return bleConvertErrorCode(ret); + } + // Configure the BLE stack using the default settings. + // Fetch the start address of the application RAM. + BLE_PRT("nrf_sdh_ble_default_cfg_set\n"); + ret = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, NULL); + if (ret) + { + goto err; + } + // Enable BLE stack. + BLE_PRT("nrf_sdh_ble_enable\n"); + ret = nrf_sdh_ble_enable(NULL); + if (ret) + { + goto err; + } + // Register a handler for BLE events. +#ifdef BLE_USE_SECTION + BLE_PRT("NRF_SDH_BLE_OBSERVER\n"); + NRF_SDH_BLE_OBSERVER(m_ble_observer, 0, (void *)bleEvtDispatch, NULL); +#endif + return ret; +err: + nrf_sdh_disable_request(); + return bleConvertErrorCode(ret); +} + +static +int bleStackFin(void) +{ + int ret = 0; + ret = nrf_sdh_disable_request(); + return bleConvertErrorCode(ret); +} + +void bleNrfEvtHandler(BLE_Evt *bleEvent, ble_evt_t *pBleNrfEvt) +{ + BLE_PRT("bleNrfEvtHandler 0x%x\n", pBleNrfEvt->header.evt_id); + memset(bleEvent, 0x00, sizeof(BLE_Evt)); + switch(pBleNrfEvt->header.evt_id) + { + case BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE: + case BLE_GATTS_EVT_HVN_TX_COMPLETE: + onTxComplete(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_CONNECTED: + onConnect(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_CONN_PARAM_UPDATE: + onConnParamUpdate(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: + onConnParamUpdateRequest(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_DISCONNECTED: + onDisconnect(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: + onSecParamsRequest(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_AUTH_STATUS: + onAuthStatus(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_PASSKEY_DISPLAY: + onDispPasskey(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_ADV_REPORT: + onAdvReport(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_AUTH_KEY_REQUEST: + onAuthKeyRequest(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_SEC_INFO_REQUEST: + onSecInfoRequest(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_RSSI_CHANGED: + onRssiChanged(bleEvent, pBleNrfEvt); + break; + case BLE_GATTS_EVT_WRITE: + onGattsWrite(bleEvent, pBleNrfEvt); + break; + case BLE_GATTS_EVT_HVC: + onGattsIndConfirm(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_CONN_SEC_UPDATE: + onConnSecUpdate(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_TIMEOUT: + onTimeout(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: + onDataLengthUpdateRequest(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_DATA_LENGTH_UPDATE: + onDataLengthUpdate(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_SCAN_REQ_REPORT: + onScanReqReport(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_PHY_UPDATE_REQUEST: + onPhyUpdateReq(bleEvent, pBleNrfEvt); + break; + case BLE_GAP_EVT_PHY_UPDATE: + onPhyUpdate(bleEvent, pBleNrfEvt); + break; + case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: + onPrimarySrvDiscoveryRsp(&commMem.gattcDb, bleEvent, pBleNrfEvt); + break; + case BLE_GATTC_EVT_CHAR_DISC_RSP: + onCharacteristicDiscoveryRsp(&commMem.gattcDb, bleEvent, pBleNrfEvt); + break; + case BLE_GATTC_EVT_DESC_DISC_RSP: + onDescriptorDiscoveryRsp(&commMem.gattcDb, bleEvent, pBleNrfEvt); + break; + case BLE_GATTC_EVT_READ_RSP: + onReadRsp(bleEvent, pBleNrfEvt); + break; + case BLE_GATTC_EVT_WRITE_RSP: + onWriteRsp(bleEvent, pBleNrfEvt); + break; + case BLE_GATTC_EVT_HVX: + onHvx(bleEvent, pBleNrfEvt); + break; + case BLE_GATTS_EVT_SYS_ATTR_MISSING: + onSysAttrMissing(bleEvent, pBleNrfEvt); + break; + case BLE_GATTS_EVT_TIMEOUT: + onGattsTimeout(bleEvent, pBleNrfEvt); + break; + case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: + onExchangeMtuRequest(bleEvent, pBleNrfEvt); + break; + #if NRF_SD_BLE_API_VERSION > 5 + case BLE_GAP_EVT_ADV_SET_TERMINATED: + onAdvSetTerminate(bleEvent, pBleNrfEvt); + break; + #endif + default: + bleEvent->evtHeader = (BLE_EventTypes)pBleNrfEvt->header.evt_id; + BLE_ERR("Unknown event 0x%x\n", bleEvent->evtHeader); + break; + } +} + +static void ble_advertise(int mode) +{ + int ret = 0; + + if (mode == 2) + { + LOG_OUT("ble_peripheral: Long range\n"); + BLE_GapAdvParams p = {0x40, 0, BLE_GAP_PHY_CODED, 0}; + ret = BLE_GapStartAdvExt(&p); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("ble enable advertise failed, ret=%d\n", ret); + } + } + else if (mode == 1) + { + ret = BLE_GapStartAdv(); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("ble enable advertise failed, ret=%d\n", ret); + } + } + else + { + ret = BLE_GapStopAdv(); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("ble disable advertise failed, ret=%d\n", ret); + } + } +} + +static void on_connected(const BLE_EvtConnected* evt) +{ + int ret = 0; + LOG_OUT("Connected: handle %d, role %d\n", evt->handle, evt->role); + g_ble_context.ble_srv_sds.conn_handle = evt->handle; + g_ble_context.ble_conn_handle = evt->handle; + g_ble_context.ble_role = evt->role; + + struct ble_event_conn_stat_t conn_stat_evt; + conn_stat_evt.connected = true; + conn_stat_evt.handle = evt->handle; + conn_stat_evt.group_id = BLE_GROUP_COMMON; + conn_stat_evt.event_id = BLE_COMMON_EVENT_CONN_STAT_CHANGE; + + ble_common_event_handler((struct bt_event_t *) &conn_stat_evt); + + if (evt->role != BLE_ROLE_CENTRAL) + { + return; + } + + /* TODO BLE device needs to configure the MTU after connection, + * wait for the finish of configuring. + */ + + usleep(500 * 1000); + + ret = BLE_GattcStartDbDiscovery(g_ble_context.ble_conn_handle); + if (BLE_SUCCESS == ret) + { + LOG_OUT("[BLE][SUCCESS]BLE_GattcStartDbDiscovery\n"); + } + else + { + LOG_OUT("[BLE][ERROR]BLE_GattcStartDbDiscovery\n"); + LOG_OUT("[BLE][ERROR]Error number = %d\n", ret); + } +} + +static void on_disconnected(const BLE_EvtDisconnected* evt) +{ + LOG_OUT("Disconnected: HCI status 0x%x\n", evt->reason); + g_ble_context.ble_conn_handle = CONN_HANDLE_INVALED; + struct ble_event_conn_stat_t conn_stat_evt; + + conn_stat_evt.connected = false; + + conn_stat_evt.group_id = BLE_GROUP_COMMON; + conn_stat_evt.event_id = BLE_COMMON_EVENT_CONN_STAT_CHANGE; + + ble_common_event_handler((struct bt_event_t *) &conn_stat_evt); + if (g_ble_context.ble_role == BLE_ROLE_PERIPHERAL) + { + int ret; + g_ble_context.ble_srv_sds.notify_enabled = 0; + LOG_OUT("Advertising restart !!\n"); + ret = BLE_GapStartAdv(); + if (BLE_SUCCESS != ret) + { + LOG_OUT("BLE_GapStartAdv failed, ret=%d\n", ret); + } + } +} + +static uint8_t wait_on_read_rsp_flag = 0; + +static void on_db_discovery(BLE_EvtGattcDbDiscovery *db_discovery) +{ + if (db_discovery->result != BLE_GATTC_RESULT_SUCCESS) + { + LOG_OUT("[BLE][ERROR]DB Discovery Failed\n"); + } + else + { + LOG_OUT("[BLE][SUCCESS]DB Discovery Success.service count= %d\n", + db_discovery->params.dbDiscovery.srvCount); + memcpy(&gattc_db_discovery, &db_discovery->params.dbDiscovery, + sizeof(BLE_GattcDbDiscovery)); + } +} + +static void on_read_rsp(BLE_EvtGattcRead *readRsp) +{ + LOG_OUT("read peer device name:%s\n", readRsp->charValData); + wait_on_read_rsp_flag = 0; +} + +static void on_exchange_feature(const BLE_EvtExchangeFeature* exchange_feature) +{ + BLE_GapPairingFeature* pf = &g_ble_context.pairing_feature; + int ret = BLE_GapExchangePairingFeature(exchange_feature->handle, pf); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("exchange pairing feature failed, ret=%d\n", ret); + } + else + { + LOG_OUT("exchange pairing feature success\n"); + } +} + +static void on_rssi_changed(const BLE_EvtRssiChanged* evt) +{ + LOG_OUT("[BLE][LOG]RSSI changed, value: %d\n", evt->rssi); +} + +static void on_gatts_evt_write(BLE_EvtGattsWrite* gatts_write) +{ + BLE_SrvSds* srv_sds = &g_ble_context.ble_srv_sds; + LOG_OUT("gatts_write->data:%.*s\n",gatts_write->dataLen, gatts_write->data); + LOG_OUT("gatts_write->handle:%x\n",gatts_write->handle); + LOG_OUT("srv_sds->char_ri_handle.dprHandle.cccdHandle:%x\n",srv_sds->char_ri_handle.dprHandle.cccdHandle); + LOG_OUT("gatts_write->data[0] & 0x01:%d\n",gatts_write->data[0] & 0x01); + if (gatts_write->handle == srv_sds->char_ri_handle.dprHandle.cccdHandle) + { + /* client characteristic configuration.bit 0: Notification bit 1: Indication.other reserved. + see core spec 4.1 Vol3,PartG,3,3,3,3 client characteristic + configuration.Table 3.11 + */ + srv_sds->notify_enabled = (bool)gatts_write->data[0] & 0x01; + if (srv_sds->notify_enabled) + { + LOG_OUT("notification enabled!\n"); + } + else + { + LOG_OUT("notification disabled!\n"); + } + } +#if 0 + else { + if (CHAR_BUF_MAX >= gatts_write->dataLen) { + /* TODO: blocking wait */ + /* TODO: protect multi-thread accessing */ + while (0 != srv_sds->char_rw_curr_idx) { + usleep(WAIT_TIME); + } + + (void)sem_wait(&srv_sds->char_rw_buf_sem); + memcpy(srv_sds->char_rw_buf, gatts_write->data, gatts_write->dataLen); + srv_sds->char_rw_curr_idx = gatts_write->dataLen; + (void)sem_post(&srv_sds->char_rw_buf_sem); + } + else { + LOG_OUT("incoming data exceeds buffer length\n"); + } + } +#endif +} + +static void on_disp_passkey(BLE_EvtDisplayPasskey* disp_passkey) +{ + LOG_OUT("[BLE][LOG]Passkey: %s\n", disp_passkey->passkey); +} + +static void on_auth_status(BLE_EvtAuthStatus* auth_status) +{ + int ret = BLE_SUCCESS; + int index = 0; + BLE_GapBondInfoList bond_id = {0}; + if (auth_status->status != BLE_GAP_SM_STATUS_SUCCESS) + { + LOG_OUT("[BLE][LOG]Pairing failed! ErrCode: %x\n", auth_status->status); + return; + } + else + { + LOG_OUT("[BLE][LOG]Pairing success!\n"); + } + LOG_OUT("[BLE][LOG]save bond address:%02X:%02X:%02X:%02X:%02X:%02X\n",\ + auth_status->bondInfo.addr[5],\ + auth_status->bondInfo.addr[4],\ + auth_status->bondInfo.addr[3],\ + auth_status->bondInfo.addr[2],\ + auth_status->bondInfo.addr[1],\ + auth_status->bondInfo.addr[0]); + ret = BLE_GapSaveBondInfo(&auth_status->bondInfo); + if (BLE_SUCCESS == ret) + { + LOG_OUT("[BLE][SUCCESS]BLE_GapSaveBondInfo\n"); + } + else + { + LOG_OUT("[BLE][ERROR]BLE_GapSaveBondInfo\n"); + LOG_OUT("[BLE][ERROR]Error number = %d\n", ret); + } + + ret = BLE_GapGetBondInfoIdList(&bond_id); + if (BLE_SUCCESS == ret) + { + LOG_OUT("[BLE][SUCCESS]BLE_GapGetBondInfoIdList\n"); + } + else + { + LOG_OUT("[BLE][ERROR]BLE_GapGetBondInfoIdList\n"); + LOG_OUT("[BLE][ERROR]Error number = %d\n", ret); + } + + LOG_OUT("[BLE][LOG]bond_id.bondNum = %ld\n", bond_id.bondNum); + + for(index=0; indextimeoutSrc) + { + case BLE_GAP_TIMEOUT_ADVERTISING: + LOG_OUT("[BLE][LOG]Timeout reason: Advertising timeout!\n"); + LOG_OUT("[BLE][LOG]Start advertise\n"); + ble_advertise(1); + break; + case BLE_GAP_TIMEOUT_SECURITY_REQUEST: + LOG_OUT("[BLE][LOG]Timeout reason: Security request timeout!\n"); + break; + case BLE_GAP_TIMEOUT_SCAN: + LOG_OUT("[BLE][LOG]Timeout reason: Scanning timeout!\n"); + ret = BLE_GapStartScan(); + if (BLE_SUCCESS == ret) + { + LOG_OUT("[BLE][SUCCESS]BLE_GapStartScan\n"); + } + else + { + LOG_OUT("[BLE][ERROR]BLE_GapStartScan\n"); + LOG_OUT("[BLE][ERROR]Error number = %d\n", ret); + } + break; + case BLE_GAP_TIMEOUT_CONN: + LOG_OUT("[BLE][LOG]Timeout reason: Connection timeout!\n"); + break; + default: + LOG_OUT("[BLE][LOG]Timeout reason: Error\n"); + break; + } +} + +static int input_passkey(uint8_t *key) +{ + LOG_OUT("Please enter passkey:\n"); + const char* name = "passkey_input"; + int len = 0; + + LOG_OUT("%s> ", name); + fflush(stdout); + len = readline((char*)key, AUTH_KEY_SIZE, stdin, stdout); + if (len < 1) + { + LOG_OUT("readpasskey error, ret:%d\n", len); + return -1; + } + key[AUTH_KEY_SIZE] = '\0'; + LOG_OUT("passkey = %s", key); + return BLE_SUCCESS; +} + +static void on_auth_key_request(BLE_EvtAuthKey *auth_key) +{ + int ret = BLE_SUCCESS; + uint8_t key[AUTH_KEY_SIZE + 1] = {0}; + BLE_GapAuthKey key_data = {0}; + + if (BLE_GAP_AUTH_KEY_TYPE_PASSKEY != auth_key->keyType) + { + LOG_OUT("[BLE][LOG]Authentication key type is not BLE_GAP_AUTH_KEY_TYPE_PASSKEY!!!\n"); + LOG_OUT("[BLE][LOG]Key type number = %d\n", auth_key->keyType); + return; + } + ret = input_passkey((uint8_t*)key); + if (BLE_SUCCESS == ret) + { + LOG_OUT("[BLE][SUCCESS]input_passkey\n"); + } + else + { + LOG_OUT("[BLE][ERROR]input_passkey\n"); + LOG_OUT("[BLE][ERROR]Error number = %d\n", ret); + } + + key_data.handle = auth_key->handle; + key_data.keyType = BLE_GAP_AUTH_KEY_TYPE_PASSKEY; + key_data.keyLen = AUTH_KEY_SIZE; + key_data.key = key; + ret = BLE_GapReplyAuthKey(&key_data); + + if (BLE_SUCCESS == ret) + { + LOG_OUT("[BLE][SUCCESS]BLE_GapReplyAuthKey\n"); + } + else + { + LOG_OUT("[BLE][ERROR]BLE_GapReplyAuthKey\n"); + LOG_OUT("[BLE][ERROR]Error number = %d\n", ret); + } +} + +static void on_conn_params_update(BLE_EvtConnParamUpdate* param) +{ + LOG_OUT("[BLE][LOG]Connection parameters updated\n"); + LOG_OUT("[BLE][LOG]Status: %d\n", param->status); + LOG_OUT("[BLE][LOG]Minimum interval: %d\n", param->connParams.minConnInterval); + LOG_OUT("[BLE][LOG]Maximum interval: %d\n", param->connParams.maxConnInterval); + LOG_OUT("[BLE][LOG]Latency: %d\n", param->connParams.slaveLatency); + LOG_OUT("[BLE][LOG]Timeout: %d\n", param->connParams.connSupTimeout); +} + +typedef struct +{ + uint8_t *data; + uint16_t data_len; +} data_t; + +static int adv_report_parse(uint8_t type, data_t *adv_data, data_t *type_data) +{ + uint16_t index = 0; + uint8_t *data = adv_data->data; + + while (index < adv_data->data_len) + { + uint8_t field_length = data[index]; + uint8_t field_type = data[index+1]; + + if (field_type == type) + { + type_data->data = &data[index+2]; + type_data->data_len = field_length-1; + type_data->data[type_data->data_len] = '\0'; + return 0; + } + + index += field_length + 1; + } + + return -1; +} + +static void on_adv_report(BLE_EvtAdvReportData *adv_report) +{ + data_t advReport = {adv_report->data, adv_report->dlen}; + data_t localName; + uint8_t localNameData[32] = {0}; + localName.data = localNameData; + localName.data_len = 0; + int ret; + + if (adv_report_parse(0x09 /* COMPLETE_LOCAL_NAME */, &advReport, &localName) || + strncmp((const char *)localName.data, "SONY", strlen("SONY"))) + { + return; + } + + LOG_OUT("[BLE][LOG]Peer RSSI:%d Name:%s\n", adv_report->rssi, localName.data); + + ret = BLE_GapStopScan(); + if (BLE_SUCCESS != ret) + { + LOG_OUT("BLE_GapStopScan failed, ret=%d\n", ret); + } + + /* If immediatey disconnect, change slave_latency. */ + + ret = BLE_GapConnect(&adv_report->addr); + if (BLE_SUCCESS != ret) + { + LOG_OUT("BLE_GapConnect failed, ret=%d\n", ret); + } +} + +static void on_phy_update_request(BLE_EvtPhyUpdate *phy_update) +{ + LOG_OUT("PHY update request: txPhy 0x%x, rxPhy 0x%x\n", + phy_update->txPhy, phy_update->rxPhy); + + BLE_GapPhys phy = {phy_update->txPhy, phy_update->rxPhy}; + int ret = BLE_GapPhyUpdate(g_ble_context.ble_conn_handle, &phy); + if (BLE_SUCCESS != ret) + { + LOG_OUT("BLE_GapPhyUpdate failed, ret=%d\n", ret); + } +} + +static void on_phy_update(BLE_EvtPhyUpdate *phy_update) +{ + LOG_OUT("PHY updated: txPhy 0x%x, rxPhy 0x%x\n", + phy_update->txPhy, phy_update->rxPhy); +} + +static void on_data_len_update(BLE_EvtDataLengthUpdate *data_len) +{ + LOG_OUT("Data length updated: maxTx %d, maxRx %d, maxTxTime %d ms, maxRxTime %d ms\n", + data_len->maxTx, data_len->maxRx, data_len->maxTxTime, data_len->maxRxTime); +} + +static +void bleCommEvtDispatch(ble_evt_t *pBleNrfEvt) +{ + BLE_Evt *bleEvent = &commMem.bleEvtCtx->evt; + bleNrfEvtHandler(bleEvent, pBleNrfEvt); +} + +#ifdef BLE_USE_SECTION +static +#endif +void bleEvtDispatch(ble_evt_t *pBleNrfEvt) +{ + BLE_PRT("bleEvtDispatch callbackFlag %d managerCbFlag %d\n", + commMem.callbackFlag, commMem.managerCbFlag); + if (commMem.callbackFlag) + { + bleCommEvtDispatch(pBleNrfEvt); + } + if (commMem.managerCbFlag) + { + commMem.managerCb(pBleNrfEvt); + } +} + +#if NRF_SD_BLE_API_VERSION > 5 +static +void onAdvSetTerminate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ +#ifdef BLE_DBGPRT_ENABLE + ble_gap_evt_adv_set_terminated_t *set = &pBleNrfEvt->evt.gap_evt.params.adv_set_terminated; + BLE_PRT("onAdvSetTerminate reason=%d handle=%d num=%d\n", + set->reason, set->adv_handle, set->num_completed_adv_events); +#endif + pBleNrfEvt->evt.gap_evt.params.timeout.src = BLE_GAP_TIMEOUT_ADVERTISING; + onTimeout(pBleEvent, pBleNrfEvt); +} +#endif + +static +void onScanReqReport(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + BLE_PRT("onScanReqReort\n"); +} + +static +void onPhyUpdateReq(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_PHY_UPDATE_REQUEST; + ble_gap_phys_t *phys = &pBleNrfEvt->evt.gap_evt.params.phy_update_request.peer_preferred_phys; + BLE_PRT("onPhyUpdateReq tx_phy %d rx_phy %d\n", phys->tx_phys, phys->rx_phys); + commMem.phyUpdate.txPhy = phys->tx_phys; + commMem.phyUpdate.rxPhy = phys->rx_phys; + commMem.phyUpdate.status = 0; + pBleEvent->evtDataSize = sizeof(BLE_EvtPhyUpdate); + memcpy(pBleEvent->evtData, &commMem.phyUpdate, pBleEvent->evtDataSize); + + on_phy_update_request((BLE_EvtPhyUpdate *)pBleEvent->evtData); +} + +static +void onPhyUpdate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_PHY_UPDATE; + ble_gap_evt_phy_update_t *phys = &pBleNrfEvt->evt.gap_evt.params.phy_update; + BLE_PRT("onPhyUpdate stat %d tx_phy %d rx_phy %d\n", phys->status, phys->tx_phy, phys->rx_phy); + commMem.phyUpdate.txPhy = phys->tx_phy; + commMem.phyUpdate.rxPhy = phys->rx_phy; + commMem.phyUpdate.status = phys->status; + pBleEvent->evtDataSize = sizeof(BLE_EvtPhyUpdate); + memcpy(pBleEvent->evtData, &commMem.phyUpdate, pBleEvent->evtDataSize); + + on_phy_update((BLE_EvtPhyUpdate *)pBleEvent->evtData); +} + +static +void onDataLengthUpdateRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + int ret = 0; +#ifdef BLE_DBGPRT_ENABLE + ble_gap_data_length_params_t *req = &pBleNrfEvt->evt.gap_evt.params.data_length_update_request.peer_params; + BLE_PRT("onLenUpReq: max_tx=%d\n", req->max_tx_octets); + BLE_PRT("onLenUpReq: max_rx=%d\n", req->max_rx_octets); + BLE_PRT("onLenUpReq: tx_time=%d\n", req->max_tx_time_us); + BLE_PRT("onLenUpReq: rx_time=%d\n", req->max_rx_time_us); +#endif + ret = sd_ble_gap_data_length_update(pBleNrfEvt->evt.gap_evt.conn_handle, NULL, NULL); + if (ret) + { + BLE_ERR("onLenUp: sd_ble_gap_data_length_update %d\n", ret); + } +} + +static +void onDataLengthUpdate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_DATA_LENGTH_UPDATE; + ble_gap_data_length_params_t *datalen = &pBleNrfEvt->evt.gap_evt.params.data_length_update.effective_params; + BLE_PRT("onLenUp: max_tx=%d\n", datalen->max_tx_octets); + BLE_PRT("onLenUp: max_rx=%d\n", datalen->max_rx_octets); + BLE_PRT("onLenUp: tx_time=%d\n", datalen->max_tx_time_us); + BLE_PRT("onLenUp: rx_time=%d\n", datalen->max_rx_time_us); + commMem.dataLen = *(BLE_EvtDataLengthUpdate *)datalen; + pBleEvent->evtDataSize = sizeof(BLE_EvtDataLengthUpdate); + memcpy(pBleEvent->evtData, &commMem.dataLen, pBleEvent->evtDataSize); + + on_data_len_update((BLE_EvtDataLengthUpdate *)pBleEvent->evtData); +} + +static +void onExchangeMtuRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + int ret = 0; + ble_gatts_evt_exchange_mtu_request_t *req = &pBleNrfEvt->evt.gatts_evt.params.exchange_mtu_request; + BLE_PRT("onMtuReq: mtu=%d\n", req->client_rx_mtu); + if (NRF_SDH_BLE_GATT_MAX_MTU_SIZE > req->client_rx_mtu) + { + commMem.client_rx_mtu = req->client_rx_mtu; + } + else + { + commMem.client_rx_mtu = NRF_SDH_BLE_GATT_MAX_MTU_SIZE; + } + ret = sd_ble_gatts_exchange_mtu_reply(pBleNrfEvt->evt.gatts_evt.conn_handle, commMem.client_rx_mtu); + if (ret) + { + BLE_ERR("onLenUp: sd_ble_gatts_exchange_mtu_reply %d\n", ret); + } + + pBleEvent->evtHeader = BLE_GATTS_EVENT_EXCHANGE_MTU; + commMem.gattsExchangeMTU.connHandle = pBleNrfEvt->evt.gatts_evt.conn_handle; + commMem.gattsExchangeMTU.client_rx_mtu = req->client_rx_mtu; + pBleEvent->evtDataSize = sizeof(BLE_EvtGattsExchangeMTU); + memcpy(pBleEvent->evtData, &commMem.gattsExchangeMTU, pBleEvent->evtDataSize); +} + +static +void onTxComplete(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_EVENT_TX_COMPLETE; + if (pBleNrfEvt->header.evt_id == BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE) + { + commMem.txCompleteData.connHandle = pBleNrfEvt->evt.gattc_evt.conn_handle; + commMem.txCompleteData.count = pBleNrfEvt->evt.gattc_evt.params.write_cmd_tx_complete.count; + commMem.txCompleteData.role = BLE_ROLE_CENTRAL; + } + else + { + commMem.txCompleteData.connHandle = pBleNrfEvt->evt.gattc_evt.conn_handle; + commMem.txCompleteData.count = pBleNrfEvt->evt.gattc_evt.params.write_cmd_tx_complete.count; + commMem.txCompleteData.role = BLE_ROLE_PERIPHERAL; + } + pBleEvent->evtDataSize = sizeof(BLE_EvtTxComplete); + memcpy(pBleEvent->evtData, &commMem.txCompleteData, pBleEvent->evtDataSize); +} + +static void onConnect_hal(void) +{ + struct bt_event_conn_stat_t con_stat_evt; + + #ifdef BLE_DBGPRT_ENABLE + uint8_t connect = 0; + uint8_t type = 0; + uint8_t reason = 0; + #endif + /* Copy device address */ + + memcpy(&con_stat_evt.addr, commMem.connectData.addr.addr, sizeof(BT_ADDR)); + + /* Copy connect status */ + + con_stat_evt.connected = true; + + /* Copy type */ +// type = commMem.connectData.addr.type; +// con_stat_evt.status = reason; + + con_stat_evt.group_id = BT_GROUP_COMMON; + con_stat_evt.event_id = BT_COMMON_EVENT_CONN_STAT_CHANGE; + + BLE_PRT("addr: %02x.%02x.%02x.%02x.%02x,%02x is connect:%d," + "transport type: %x, disconnect reason: %x.\n", + con_stat_evt.addr.address[0], con_stat_evt.addr.address[1], + con_stat_evt.addr.address[2], con_stat_evt.addr.address[3], + con_stat_evt.addr.address[4], con_stat_evt.addr.address[5], + connect, type, reason); + + bt_common_event_handler((struct bt_event_t *) &con_stat_evt); +} + +static +void onConnect(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_CONNECTED; + ble_gap_evt_connected_t *connected = &pBleNrfEvt->evt.gap_evt.params.connected; + commMem.connectData.handle = pBleNrfEvt->evt.gap_evt.conn_handle; + commMem.connectData.addr.type = connected->peer_addr.addr_type; + memcpy(commMem.connectData.addr.addr, connected->peer_addr.addr, BLE_GAP_ADDR_LENGTH); + if (connected->role == BLE_GAP_ROLE_PERIPH ) + { + commMem.connectData.role = BLE_ROLE_PERIPHERAL; + } + else if (connected->role == BLE_GAP_ROLE_CENTRAL) + { + commMem.connectData.role = BLE_ROLE_CENTRAL; + } + commMem.gapMem->connParams = *(ble_gap_conn_params_t *)&connected->conn_params; +#ifdef BLE_DBGPRT_ENABLE + BLE_PRT("onConnect: handle=%d\n", commMem.connectData.handle); + BLE_PRT("onConnect: role=%d\n", commMem.connectData.role); + BLE_PRT("onConnect: type=%d\n", commMem.connectData.addr.type); + BLE_PRT("onConnect: addr=0x"); + for (int i=0; i<6; i++) { + BLE_PRT("%02x", commMem.connectData.addr.addr[i]); + } + BLE_PRT("\n"); + BLE_PRT("onConnect: minConnInterval=%d\n", commMem.gapMem->connParams.min_conn_interval); + BLE_PRT("onConnect: maxConnInterval=%d\n", commMem.gapMem->connParams.max_conn_interval); + BLE_PRT("onConnect: slaveLatency=%d\n", commMem.gapMem->connParams.slave_latency); + BLE_PRT("onConnect: connSupTimeout=%d\n", commMem.gapMem->connParams.conn_sup_timeout); +#endif + commMem.gapMem->wrapperBondInfo.connHandle = pBleNrfEvt->evt.gap_evt.conn_handle; + commMem.gapMem->wrapperBondInfo.bondInfo.addrType = connected->peer_addr.addr_type; + memcpy(commMem.gapMem->wrapperBondInfo.bondInfo.addr, connected->peer_addr.addr, BLE_GAP_ADDR_LENGTH); + pBleEvent->evtDataSize = sizeof(BLE_EvtConnected); + memcpy(pBleEvent->evtData, &commMem.connectData, pBleEvent->evtDataSize); + + //notify to hal layer + onConnect_hal(); + + on_connected((BLE_EvtConnected*)pBleEvent->evtData); +} + +static +void onConnParamUpdate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_CONN_PARAM_UPDATE; + ble_gap_conn_params_t *params = &pBleNrfEvt->evt.gap_evt.params.conn_param_update.conn_params; + commMem.connParams.connParams.minConnInterval = params->min_conn_interval; + commMem.connParams.connParams.maxConnInterval = params->max_conn_interval; + commMem.connParams.connParams.slaveLatency = params->slave_latency; + commMem.connParams.connParams.connSupTimeout = params->conn_sup_timeout; + commMem.gapMem->connParams = *(ble_gap_conn_params_t *)params; + pBleEvent->evtDataSize = sizeof(BLE_EvtConnParamUpdate); + memcpy(pBleEvent->evtData, &commMem.connParams, pBleEvent->evtDataSize); + + on_conn_params_update((BLE_EvtConnParamUpdate*)pBleEvent->evtData); +} + +static +void onConnParamUpdateRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_CONN_PARAM_UPDATE_REQUEST; + ble_gap_conn_params_t *params = &pBleNrfEvt->evt.gap_evt.params.conn_param_update_request.conn_params; + commMem.connParams.connParams.minConnInterval = params->min_conn_interval; + commMem.connParams.connParams.maxConnInterval = params->max_conn_interval; + commMem.connParams.connParams.slaveLatency = params->slave_latency; + commMem.connParams.connParams.connSupTimeout = params->conn_sup_timeout; + commMem.gapMem->connParams = *(ble_gap_conn_params_t *)params; + pBleEvent->evtDataSize = sizeof(BLE_EvtConnParamUpdate); + memcpy(pBleEvent->evtData, &commMem.connParams, pBleEvent->evtDataSize); +} + +static +void onDisconnect(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_DISCONNECTED; + commMem.disconnectData.handle = pBleNrfEvt->evt.gap_evt.conn_handle; + commMem.disconnectData.reason = pBleNrfEvt->evt.gap_evt.params.disconnected.reason; + BLE_PRT("onDisconnect: reason=%d\n", pBleNrfEvt->evt.gap_evt.params.disconnected.reason); + pBleEvent->evtDataSize = sizeof(BLE_EvtDisconnected); + memcpy(pBleEvent->evtData, &commMem.disconnectData, pBleEvent->evtDataSize); + commMem.gapMem->is_connected = false; + + on_disconnected((BLE_EvtDisconnected*)pBleEvent->evtData); +} + +static +void onSecParamsRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + ble_gap_evt_sec_params_request_t *secParamReq = &pBleNrfEvt->evt.gap_evt.params.sec_params_request; + pBleEvent->evtHeader = BLE_GAP_EVENT_EXCHANGE_FEATURE; + commMem.exchangeFeatureData.handle = pBleNrfEvt->evt.gap_evt.conn_handle; + commMem.exchangeFeatureData.peerFeature.oob = (BLE_GapOOB)secParamReq->peer_params.oob; + commMem.exchangeFeatureData.peerFeature.ioCap = (BLE_GAP_IO_CAP)secParamReq->peer_params.io_caps; + commMem.exchangeFeatureData.peerFeature.authReq = (BLE_GapAuth)((secParamReq->peer_params.mitm)<<1 |(secParamReq->peer_params.bond)); + commMem.exchangeFeatureData.peerFeature.maxKeySize = secParamReq->peer_params.max_key_size; + commMem.exchangeFeatureData.peerFeature.minKeySize = secParamReq->peer_params.min_key_size; + pBleEvent->evtDataSize = sizeof(BLE_EvtExchangeFeature); + memcpy(pBleEvent->evtData, &commMem.exchangeFeatureData, pBleEvent->evtDataSize); + + on_exchange_feature((BLE_EvtExchangeFeature*)pBleEvent->evtData); +} + +static +void onAuthStatus(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_AUTH_STATUS; + ble_gap_evt_auth_status_t *authStatus = &pBleNrfEvt->evt.gap_evt.params.auth_status; + commMem.authStatusData.handle = pBleNrfEvt->evt.gap_evt.conn_handle; +#ifdef BLE_DBGPRT_ENABLE + BLE_PRT("onAuthStatus: handle=%d\n", pBleNrfEvt->evt.gap_evt.conn_handle); + BLE_PRT("onAuthStatus: auth_status=%d\n", authStatus->auth_status); + BLE_PRT("onAuthStatus: error_src=%d\n", authStatus->error_src); + BLE_PRT("onAuthStatus: bonded=%d\n", authStatus->bonded); + BLE_PRT("onAuthStatus: lesc=%d\n", authStatus->lesc); + BLE_PRT("onAuthStatus: sm1_levels_lv1=%d\n", authStatus->sm1_levels.lv1); + BLE_PRT("onAuthStatus: sm1_levels_lv2=%d\n", authStatus->sm1_levels.lv2); + BLE_PRT("onAuthStatus: sm1_levels_lv3=%d\n", authStatus->sm1_levels.lv3); + BLE_PRT("onAuthStatus: sm2_levels_lv1=%d\n", authStatus->sm2_levels.lv1); + BLE_PRT("onAuthStatus: sm2_levels_lv2=%d\n", authStatus->sm2_levels.lv2); + BLE_PRT("onAuthStatus: sm2_levels_lv3=%d\n", authStatus->sm2_levels.lv3); + BLE_PRT("onAuthStatus: own.enc=%d\n", authStatus->kdist_own.enc); + BLE_PRT("onAuthStatus: own.id=%d\n", authStatus->kdist_own.id); + BLE_PRT("onAuthStatus: own.sign=%d\n", authStatus->kdist_own.sign); + BLE_PRT("onAuthStatus: own.link=%d\n", authStatus->kdist_own.link); + BLE_PRT("onAuthStatus: peer.enc=%d\n", authStatus->kdist_peer.enc); + BLE_PRT("onAuthStatus: peer.id=%d\n", authStatus->kdist_peer.id); + BLE_PRT("onAuthStatus: peer.sign=%d\n", authStatus->kdist_peer.sign); + BLE_PRT("onAuthStatus: peer.link=%d\n", authStatus->kdist_peer.link); +#if 0 + // own + BLE_PRT("onAuthStatus: own id_irk=0x"); + for (int i=0; i<16; i++) { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.ownIdKey.id_info.irk[i]); + } + BLE_PRT("\n"); + BLE_PRT("onAuthStatus: own id_addr_type=%d\n", commMem.gapMem->wrapperBondInfo.ownIdKey.id_addr_info.addr_type); + BLE_PRT("onAuthStatus: own id_addr=0x"); + for (int i=0; i<6; i++) { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.ownIdKey.id_addr_info.addr[i]); + } + BLE_PRT("\n"); + BLE_PRT("onAuthStatus: own master_id_ediv=%d\n", commMem.gapMem->wrapperBondInfo.ownEncKey.master_id.ediv); + BLE_PRT("onAuthStatus: own master_id_rand=0x"); + for (int i=0; i<8; i++) { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.ownEncKey.master_id.rand[i]); + } + BLE_PRT("\n"); + BLE_PRT("onAuthStatus: own enc_info_auth=%d\n", commMem.gapMem->wrapperBondInfo.ownEncKey.enc_info.auth); + if (commMem.gapMem->wrapperBondInfo.ownEncKey.enc_info.ltk_len) { + BLE_PRT("onAuthStatus: own enc_info_ltk=0x"); + for (int i=0; iwrapperBondInfo.ownEncKey.enc_info.ltk_len; i++) { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.ownEncKey.enc_info.ltk[i]); + } + BLE_PRT("\n"); + } else { + BLE_PRT("onAuthStatus: own enc_info_ltk=%d\n", commMem.gapMem->wrapperBondInfo.ownEncKey.enc_info.ltk_len); + } +#endif + // peer + BLE_PRT("onAuthStatus: peer id_irk=0x"); + for (int i=0; i<16; i++) + { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.peerIdKey.id_info.irk[i]); + } + BLE_PRT("\n"); + BLE_PRT("onAuthStatus: peer id_addr_type=%d\n", commMem.gapMem->wrapperBondInfo.peerIdKey.id_addr_info.addr_type); + BLE_PRT("onAuthStatus: peer id_addr=0x"); + for (int i=0; i<6; i++) + { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.peerIdKey.id_addr_info.addr[i]); + } + BLE_PRT("\n"); + + BLE_PRT("onAuthStatus: peer master_id_ediv=%d\n", commMem.gapMem->wrapperBondInfo.peerEncKey.master_id.ediv); + BLE_PRT("onAuthStatus: peer master_id_rand=0x"); + for (int i=0; i<8; i++) + { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.peerEncKey.master_id.rand[i]); + } + BLE_PRT("\n"); + BLE_PRT("onAuthStatus: peer enc_info_auth=%d\n", commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.auth); + if (commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.ltk_len) + { + BLE_PRT("onAuthStatus: peer enc_info_ltk=0x"); + for (int i=0; iwrapperBondInfo.peerEncKey.enc_info.ltk_len; i++) + { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.ltk[i]); + } + BLE_PRT("\n"); + } + else + { + BLE_PRT("onAuthStatus: peer enc_info_ltk=%d\n", commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.ltk_len); + } +#endif + //Auth status code. + if ( authStatus->auth_status < BLE_GAP_SEC_STATUS_PDU_INVALID ) + { + commMem.authStatusData.status = authStatus->auth_status; + } + else if ((authStatus->auth_status > BLE_GAP_SEC_STATUS_RFU_RANGE1_END) && (authStatus->auth_status != BLE_GAP_SEC_STATUS_RFU_RANGE2_END)) + { + commMem.authStatusData.status = authStatus->auth_status -(BLE_GAP_SEC_STATUS_RFU_RANGE1_END - BLE_GAP_SM_STATUS_RESERVED); + } + else + { + commMem.authStatusData.status = BLE_GAP_SM_STATUS_RESERVED; + } +#if 1 + if (authStatus->kdist_peer.id) + { + BLE_PRT("update bondinfo\n"); + commMem.gapMem->wrapperBondInfo.bondInfo.addrType = commMem.gapMem->wrapperBondInfo.peerIdKey.id_addr_info.addr_type; + memcpy(commMem.gapMem->wrapperBondInfo.bondInfo.addr, commMem.gapMem->wrapperBondInfo.peerIdKey.id_addr_info.addr, BLE_GAP_ADDR_LENGTH); + } +#endif + memcpy(&commMem.authStatusData.bondInfo, &commMem.gapMem->wrapperBondInfo.bondInfo, sizeof(BLE_GapBondInfo)); + pBleEvent->evtDataSize = sizeof(BLE_EvtAuthStatus); + memcpy(pBleEvent->evtData, &commMem.authStatusData, pBleEvent->evtDataSize); + + on_auth_status((BLE_EvtAuthStatus*)pBleEvent->evtData); +} + +static +void onDispPasskey(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_DISPLAY_PASSKEY; + ble_gap_evt_passkey_display_t *dispPasskey = &pBleNrfEvt->evt.gap_evt.params.passkey_display; + commMem.dispPasskeyData.handle = pBleNrfEvt->evt.gap_evt.conn_handle; + memcpy(commMem.dispPasskeyData.passkey,dispPasskey->passkey,BLE_GAP_PASSKEY_LEN); + commMem.dispPasskeyData.passkey[BLE_GAP_PASSKEY_LEN] = '\0'; + pBleEvent->evtDataSize = sizeof(BLE_EvtDisplayPasskey); + memcpy(pBleEvent->evtData, &commMem.dispPasskeyData, pBleEvent->evtDataSize); + + on_disp_passkey((BLE_EvtDisplayPasskey*)pBleEvent->evtData); +} + +#if NRF_SD_BLE_API_VERSION > 5 +extern uint8_t bleAdvReportBuffer[BLE_GAP_SCAN_BUFFER_EXTENDED_MIN]; +#endif + +static +void onAdvReport(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_ADV_REPORT; + ble_gap_evt_adv_report_t *advReport = &pBleNrfEvt->evt.gap_evt.params.adv_report; +#if NRF_SD_BLE_API_VERSION > 5 + BLE_PRT("onAdvReport: rssi=%d scan_rsp=%d type=%d dlen=%d\n", + advReport->rssi, advReport->type.scan_response, advReport->type.status, advReport->data.len); + BLE_PRT(" connectable=%d scannable=%d directed=%d ext_pdu=%d set=%d dat=%d\n", + advReport->type.connectable, advReport->type.scannable, advReport->type.directed, + advReport->type.extended_pdu, advReport->set_id, advReport->data_id); + + if (advReport->type.status == BLE_GAP_ADV_DATA_STATUS_COMPLETE) + { + commMem.advReportData.dlen = advReport->data.len; + memcpy(commMem.advReportData.data, advReport->data.p_data, advReport->data.len); + } + + commMem.advReportData.scan_rsp = advReport->type.scan_response; + commMem.advReportData.dlen = advReport->data.len; + memcpy(commMem.advReportData.data, advReport->data.p_data, advReport->data.len); + commMem.advReportData.rssi = advReport->rssi; + memcpy(commMem.advReportData.addr.addr, advReport->peer_addr.addr, BLE_GAP_ADDR_LENGTH); + commMem.advReportData.addr.type = advReport->peer_addr.addr_type; + pBleEvent->evtDataSize = sizeof(BLE_EvtAdvReportData); + memcpy(pBleEvent->evtData, &commMem.advReportData, pBleEvent->evtDataSize); + ble_data_t bleAdvReport = {bleAdvReportBuffer, BLE_GAP_SCAN_BUFFER_EXTENDED_MIN}; + if (sd_ble_gap_scan_start(NULL, &bleAdvReport)) + { + BLE_ERR("sd_ble_gap_scan_start failed.\n"); + } +#else + BLE_PRT("onAdvReport: rssi=%d scan_rsp=%d type=%d dlen=%d\n", + advReport->rssi, advReport->scan_rsp, advReport->type, advReport->dlen); + commMem.advReportData.scan_rsp = advReport->scan_rsp; + commMem.advReportData.dlen = advReport->dlen; + memcpy(commMem.advReportData.data, advReport->data, BLE_GAP_ADV_MAX_SIZE); + commMem.advReportData.rssi = advReport->rssi; + memcpy(commMem.advReportData.addr.addr, advReport->peer_addr.addr, BLE_GAP_ADDR_LENGTH); + commMem.advReportData.addr.type = advReport->peer_addr.addr_type; + pBleEvent->evtDataSize = sizeof(BLE_EvtAdvReportData); + memcpy(pBleEvent->evtData, &commMem.advReportData, pBleEvent->evtDataSize); +#endif + + on_adv_report((BLE_EvtAdvReportData *)pBleEvent->evtData); +} + +static +void onAuthKeyRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_AUTH_KEY_REQUEST; + ble_gap_evt_auth_key_request_t *authKey = &pBleNrfEvt->evt.gap_evt.params.auth_key_request; + commMem.authKeyData.handle = pBleNrfEvt->evt.gap_evt.conn_handle; + commMem.authKeyData.keyType = authKey->key_type; + pBleEvent->evtDataSize = sizeof(BLE_EvtAuthKey); + memcpy(pBleEvent->evtData, &commMem.authKeyData, pBleEvent->evtDataSize); + + on_auth_key_request((BLE_EvtAuthKey *)pBleEvent->evtData); +} + +static +void onConnSecUpdate(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_CONN_SEC_UPDATE; + pBleEvent->evtDataSize = 0; +#ifdef BLE_DBGPRT_ENABLE + ble_gap_evt_conn_sec_update_t *sec = &pBleNrfEvt->evt.gap_evt.params.conn_sec_update; + BLE_PRT("onConnSecUpdate: keysize=%d sm=%d lv=%d\n", sec->conn_sec.encr_key_size, + sec->conn_sec.sec_mode.sm, sec->conn_sec.sec_mode.lv); +#endif +} + +static +void onSecInfoRequest(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + ble_gap_enc_info_t *enc_info = NULL; + ble_gap_irk_t *id_info = NULL; + ble_gap_sign_info_t *sign_info = NULL; + ble_gap_evt_sec_info_request_t *secinfo = &pBleNrfEvt->evt.gap_evt.params.sec_info_request; +#ifdef BLE_DBGPRT_ENABLE + BLE_PRT("onSecInfoRequest: handle=%d\n", pBleNrfEvt->evt.gap_evt.conn_handle); + BLE_PRT("onSecInfoRequest: addr_type=%d\n", secinfo->peer_addr.addr_type); + BLE_PRT("onSecInfoRequest: peer_addr=0x"); + for (int i=0; i<6; i++) + { + BLE_PRT("%02x", secinfo->peer_addr.addr[i]); + } + BLE_PRT("\n"); + BLE_PRT("onSecInfoRequest: master_id_ediv=%d\n", secinfo->master_id.ediv); + BLE_PRT("onSecInfoRequest: master_id_rand=0x"); + for (int i=0; i<8; i++) + { + BLE_PRT("%02x", secinfo->master_id.rand[i]); + } + BLE_PRT("\n"); + BLE_PRT("onSecInfoRequest: enc_info=%d\n", secinfo->enc_info); + BLE_PRT("onSecInfoRequest: id_info=%d\n", secinfo->id_info); + BLE_PRT("onSecInfoRequest: sign_info=%d\n", secinfo->sign_info); +#if 0 + // own + BLE_PRT("onSecInfoRequest: own id_irk=0x"); + for (int i=0; i<16; i++) { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.ownIdKey.id_info.irk[i]); + } + BLE_PRT("\n"); + BLE_PRT("onSecInfoRequest: own id_addr_type=%d\n", commMem.gapMem->wrapperBondInfo.ownIdKey.id_addr_info.addr_type); + BLE_PRT("onSecInfoRequest: own id_addr=0x"); + for (int i=0; i<6; i++) { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.ownIdKey.id_addr_info.addr[i]); + } + BLE_PRT("\n"); + BLE_PRT("onSecInfoRequest: own master_id_ediv=%d\n", commMem.gapMem->wrapperBondInfo.ownEncKey.master_id.ediv); + BLE_PRT("onSecInfoRequest: own master_id_rand=0x"); + for (int i=0; i<8; i++) { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.ownEncKey.master_id.rand[i]); + } + BLE_PRT("\n"); + BLE_PRT("onSecInfoRequest: own enc_info_auth=%d\n", commMem.gapMem->wrapperBondInfo.ownEncKey.enc_info.auth); + if (commMem.gapMem->wrapperBondInfo.ownEncKey.enc_info.ltk_len) { + BLE_PRT("onSecInfoRequest: own enc_info_ltk=0x"); + for (int i=0; iwrapperBondInfo.ownEncKey.enc_info.ltk_len; i++) { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.ownEncKey.enc_info.ltk[i]); + } + BLE_PRT("\n"); + } else { + BLE_PRT("onSecInfoRequest: own enc_info_ltk=%d\n", commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.ltk_len); + } +#endif + // peer + BLE_PRT("onSecInfoRequest: peer id_irk=0x"); + for (int i=0; i<16; i++) + { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.peerIdKey.id_info.irk[i]); + } + BLE_PRT("\n"); + BLE_PRT("onSecInfoRequest: peer id_addr_type=%d\n", commMem.gapMem->wrapperBondInfo.peerIdKey.id_addr_info.addr_type); + BLE_PRT("onSecInfoRequest: peer id_addr=0x"); + for (int i=0; i<6; i++) + { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.peerIdKey.id_addr_info.addr[i]); + } + BLE_PRT("\n"); + BLE_PRT("onSecInfoRequest: peer master_id_ediv=%d\n", commMem.gapMem->wrapperBondInfo.peerEncKey.master_id.ediv); + BLE_PRT("onSecInfoRequest: peer master_id_rand=0x"); + for (int i=0; i<8; i++) + { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.peerEncKey.master_id.rand[i]); + } + BLE_PRT("\n"); + BLE_PRT("onSecInfoRequest: peer enc_info_auth=%d\n", commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.auth); + if (commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.ltk_len) + { + BLE_PRT("onSecInfoRequest: peer enc_info_ltk=0x"); + for (int i=0; iwrapperBondInfo.peerEncKey.enc_info.ltk_len; i++) + { + BLE_PRT("%02x", commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.ltk[i]); + } + BLE_PRT("\n"); + } + else + { + BLE_PRT("onSecInfoRequest: peer enc_info_ltk=%d\n", commMem.gapMem->wrapperBondInfo.peerEncKey.enc_info.ltk_len); + } +#endif + uint32_t list = bleBondEnableList; + for(int index = 0; index < BLE_SAVE_BOND_DEVICE_MAX_NUM; index++, list >>= 1) + { + if (!(list & 1)) + { + continue; + } + if(!memcmp(BondInfoInFlash[index].peerEncKey.master_id.rand, secinfo->master_id.rand, BLE_GAP_SEC_RAND_LEN)) + { + BLE_PRT("onSecInfoRequest: master_id exitsting index %d\n", index); + enc_info = &BondInfoInFlash[index].peerEncKey.enc_info; + id_info = &BondInfoInFlash[index].peerIdKey.id_info; + break; + } + } + sd_ble_gap_sec_info_reply(pBleNrfEvt->evt.gap_evt.conn_handle, enc_info, id_info, sign_info); +} + +static +void onTimeout(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_TIMEOUT; + ble_gap_evt_timeout_t *timeout = &pBleNrfEvt->evt.gap_evt.params.timeout; + commMem.timeoutData.handle = pBleNrfEvt->evt.gap_evt.conn_handle; + commMem.timeoutData.timeoutSrc = timeout->src; + pBleEvent->evtDataSize = sizeof(BLE_EvtTimeout); + memcpy(pBleEvent->evtData, &commMem.timeoutData, pBleEvent->evtDataSize); + + on_timeout((BLE_EvtTimeout *)pBleEvent->evtData); +} + +static +void onGattsTimeout(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GATTS_EVENT_TIMEOUT; + commMem.timeoutData.handle = pBleNrfEvt->evt.gatts_evt.conn_handle; + commMem.timeoutData.timeoutSrc = BLE_GATT_TIMEOUT_PROTOCOL; + pBleEvent->evtDataSize = sizeof(BLE_EvtTimeout); + memcpy(pBleEvent->evtData, &commMem.timeoutData, pBleEvent->evtDataSize); +} + +static +void onRssiChanged(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GAP_EVENT_RSSI_CHANGED; + ble_gap_evt_rssi_changed_t *rssiChanged = &pBleNrfEvt->evt.gap_evt.params.rssi_changed; + commMem.rssiChangeData.handle = pBleNrfEvt->evt.gap_evt.conn_handle; + commMem.rssiChangeData.rssi = rssiChanged->rssi; + commMem.gapMem->peerRssi = rssiChanged->rssi; + pBleEvent->evtDataSize = sizeof(BLE_EvtRssiChanged); + memcpy(pBleEvent->evtData, &commMem.rssiChangeData, pBleEvent->evtDataSize); + + on_rssi_changed((BLE_EvtRssiChanged*)pBleEvent->evtData); +} + +static +void onGattsWrite(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GATTS_EVENT_WRITE; + ble_gatts_evt_write_t * gattsWrite = &pBleNrfEvt->evt.gatts_evt.params.write; + commMem.gattsWriteData.connHandle = pBleNrfEvt->evt.gatts_evt.conn_handle; + commMem.gattsWriteData.handle = gattsWrite->handle; //attribute handle + commMem.gattsWriteData.dataLen = gattsWrite->len; + commMem.gattsWriteData.offset = gattsWrite->offset; + memcpy(commMem.gattsWriteData.data, gattsWrite->data, MAX_RCV_DATA_LENGTH); + pBleEvent->evtDataSize = sizeof(BLE_EvtGattsWrite); + memcpy(pBleEvent->evtData, &commMem.gattsWriteData, pBleEvent->evtDataSize); + + on_gatts_evt_write((BLE_EvtGattsWrite*)pBleEvent->evtData); +} + +static +void onGattsIndConfirm(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GATTS_EVENT_CFM; + ble_gatts_evt_hvc_t * gattsConfirm = &pBleNrfEvt->evt.gatts_evt.params.hvc; + commMem.gattsIndConfirmData.connHandle = pBleNrfEvt->evt.gatts_evt.conn_handle; + commMem.gattsIndConfirmData.handle = gattsConfirm->handle; + pBleEvent->evtDataSize = sizeof(BLE_EvtGattsIndConfirm); + memcpy(pBleEvent->evtData, &commMem.gattsIndConfirmData, pBleEvent->evtDataSize); +} + +static void onReadRsp(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GATTC_EVENT_READ; + ble_gattc_evt_t *bleGattcEvt = &(pBleNrfEvt->evt.gattc_evt); + const ble_gattc_evt_read_rsp_t *bleGattcEvtReadRsp = &(bleGattcEvt->params.read_rsp); + commMem.gattcReadData.connHandle = pBleNrfEvt->evt.gattc_evt.conn_handle; + commMem.gattcReadData.charValHandle = bleGattcEvtReadRsp->handle; + commMem.gattcReadData.charValLen = bleGattcEvtReadRsp->len; + memcpy(commMem.gattcReadData.charValData, bleGattcEvtReadRsp->data, MAX_VAL_DATA_LENGTH); + pBleEvent->evtDataSize = sizeof(BLE_EvtGattcRead); + memcpy(pBleEvent->evtData, &commMem.gattcReadData, pBleEvent->evtDataSize); + + on_read_rsp((BLE_EvtGattcRead *)pBleEvent->evtData); +} + +static void onWriteRsp(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GATTC_EVENT_WRITE_RSP; + pBleEvent->evtDataSize = sizeof(BLE_EvtGattcWriteRsp); + + BLE_EvtGattcWriteRsp* wrRsp = (BLE_EvtGattcWriteRsp*)pBleEvent->evtData; + ble_gattc_evt_t *bleGattcEvt = &(pBleNrfEvt->evt.gattc_evt); + const ble_gattc_evt_read_rsp_t *bleGattcEvtReadRsp = &(bleGattcEvt->params.read_rsp); + + wrRsp->connHandle = bleGattcEvt->conn_handle; + wrRsp->charValHandle = bleGattcEvtReadRsp->handle; + wrRsp->status = bleGattcEvt->gatt_status; +} + +static +void onHvx(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + pBleEvent->evtHeader = BLE_GATTC_EVENT_NTFIND; + ble_gattc_evt_t *bleGattcEvt = &(pBleNrfEvt->evt.gattc_evt); + const ble_gattc_evt_hvx_t *bleGattcEvtHvx = &(bleGattcEvt->params.hvx); + commMem.gattcNtfIndData.connHandle = pBleNrfEvt->evt.gattc_evt.conn_handle; + commMem.gattcNtfIndData.attrHandle = bleGattcEvtHvx->handle; + commMem.gattcNtfIndData.type = (BLE_GattNtyIndType)bleGattcEvtHvx->type; + commMem.gattcNtfIndData.attrValLen = bleGattcEvtHvx->len; + memcpy(commMem.gattcNtfIndData.attrValData, bleGattcEvtHvx->data, MAX_VAL_DATA_LENGTH); + pBleEvent->evtDataSize = sizeof(BLE_EvtGattcNtfInd); + memcpy(pBleEvent->evtData, &commMem.gattcNtfIndData, pBleEvent->evtDataSize); +} + +static +void onSysAttrMissing(BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + int ret = BLE_SUCCESS; + ret = sd_ble_gatts_sys_attr_set(commMem.connectData.handle, NULL, 0, 0); + if (ret) { + pBleEvent->evtHeader = BLE_GATTS_EVENT_SYS_ATTR_MISSING; + } +} + +static +void setDbDiscoveryEvent(BLE_Evt *pBleEvent, uint16_t connHandle, int result, int reason) +{ + commMem.gattcDbDiscoveryData.connHandle = connHandle; + commMem.gattcDbDiscoveryData.result = result; + commMem.gattcDbDiscoveryData.params.reason = reason; + if (result == BLE_GATTC_RESULT_SUCCESS) { + commMem.gattcDb.dbDiscovery.srvCount = commMem.gattcDb.currSrvInd; + memcpy(&commMem.gattcDbDiscoveryData.params.dbDiscovery, &commMem.gattcDb.dbDiscovery, sizeof(BLE_GattcDbDiscovery)); + } + pBleEvent->evtHeader = BLE_GATTC_EVENT_DBDISCOVERY; + pBleEvent->evtDataSize = sizeof(BLE_EvtGattcDbDiscovery); + memcpy(pBleEvent->evtData, &commMem.gattcDbDiscoveryData, pBleEvent->evtDataSize); + commMem.gattcDb.currCharInd = 0; + commMem.gattcDb.currSrvInd = 0; + + on_db_discovery((BLE_EvtGattcDbDiscovery *)pBleEvent->evtData); + return; +} + +static +void onPrimarySrvDiscoveryRsp(bleGattcDb *gattcDbDiscovery, BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + uint16_t connHandle = 0; + ble_gattc_evt_t *bleGattcEvt = NULL; + BLE_GattcDbDiscSrv *srvBeingDiscovered = NULL; + + bleGattcEvt = &(pBleNrfEvt->evt.gattc_evt); + connHandle = bleGattcEvt->conn_handle; + BLE_PRT2("onPrimary start ind %d\n", gattcDbDiscovery->currSrvInd); + if (bleGattcEvt->gatt_status == BLE_GATT_STATUS_SUCCESS) + { + if (gattcDbDiscovery->currSrvInd >= BLE_DB_DISCOVERY_MAX_SRV) + { + gattcDbDiscovery->discoveryInProgress = false; + BLE_ERR("onPrimary MAX_SRV\n"); + setDbDiscoveryEvent(pBleEvent, connHandle, BLE_GATTC_RESULT_FAILED, BLE_GATTC_REASON_SERVICE); + return; + } + gattcDbDiscovery->dbDiscovery.connHandle = connHandle; + srvBeingDiscovered = &(gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd]); + + const ble_gattc_evt_prim_srvc_disc_rsp_t *primSrvcDiscRspEvt = &(bleGattcEvt->params.prim_srvc_disc_rsp); + srvBeingDiscovered->srvUuid.value.baseAlias.uuidAlias = primSrvcDiscRspEvt->services[0].uuid.uuid; //BLE_ENABLE_NORDIC_ORIGINAL + srvBeingDiscovered->srvUuid.type = (BLE_GATT_UUID_TYPE)primSrvcDiscRspEvt->services[0].uuid.type; //BLE_ENABLE_NORDIC_ORIGINAL + srvBeingDiscovered->srvHandleRange.startHandle = primSrvcDiscRspEvt->services[0].handle_range.start_handle; + srvBeingDiscovered->srvHandleRange.endHandle = primSrvcDiscRspEvt->services[0].handle_range.end_handle; + BLE_PRT2("onPrimary cnt %d type %d uuid 0x%04X sHdl %d eHdl %d\n", + primSrvcDiscRspEvt->count, + primSrvcDiscRspEvt->services[0].uuid.type, + primSrvcDiscRspEvt->services[0].uuid.uuid, + primSrvcDiscRspEvt->services[0].handle_range.start_handle, + primSrvcDiscRspEvt->services[0].handle_range.end_handle); + //get current service info finished. characteristic discovery which belongs to this service. + (void)characteristicsDiscover(pBleEvent, gattcDbDiscovery); + } + else if (bleGattcEvt->gatt_status == BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND) + { + //db discovery complete.send success event to application + gattcDbDiscovery->discoveryInProgress = true; + setDbDiscoveryEvent(pBleEvent, connHandle, BLE_GATTC_RESULT_SUCCESS, 0); + } + else + { + //db discovery error.send event to application + gattcDbDiscovery->discoveryInProgress = false; + BLE_ERR("onPrimary Status error %d\n", bleGattcEvt->gatt_status); + setDbDiscoveryEvent(pBleEvent, connHandle, BLE_GATTC_RESULT_FAILED, BLE_GATTC_REASON_SERVICE); + } +} + +static +void onCharacteristicDiscoveryRsp(bleGattcDb *const gattcDbDiscovery, BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + uint8_t numCharsPrevDisc = 0; + uint8_t numCharsCurrDisc = 0; + uint16_t connHandle = 0; + uint32_t i = 0; + uint32_t j = 0; + bool performDescDiscov = false; + bool raiseDiscovComplete = false; + ble_gattc_evt_t *bleGattcEvt = &(pBleNrfEvt->evt.gattc_evt); + BLE_GattcDbDiscSrv *srvBeingDiscovered = &(gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd]); + BLE_GattcChar *lastKnownChar = NULL; + + connHandle = bleGattcEvt->conn_handle; + if (gattcDbDiscovery->currSrvInd >= BLE_DB_DISCOVERY_MAX_SRV) + { + BLE_ERR("onChar ind NG\n"); + gattcDbDiscovery->discoveryInProgress = false; + setDbDiscoveryEvent(pBleEvent, connHandle, BLE_GATTC_RESULT_FAILED, BLE_GATTC_REASON_CHARACTERISTIC); + return; + } + if (bleGattcEvt->gatt_status == BLE_GATT_STATUS_SUCCESS) + { + const ble_gattc_evt_char_disc_rsp_t * charDiscRspEvt; + + charDiscRspEvt = &(bleGattcEvt->params.char_disc_rsp); + + numCharsPrevDisc = srvBeingDiscovered->charCount; + numCharsCurrDisc = charDiscRspEvt->count; + BLE_PRT2("onChar preCnt %d curCnt %d\n", numCharsPrevDisc, numCharsCurrDisc); + // Check if the total number of discovered characteristics are supported + if ((numCharsPrevDisc + numCharsCurrDisc) <= BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV) + { + // Update the characteristics count. + srvBeingDiscovered->charCount += numCharsCurrDisc; + } + else + { + // The number of characteristics discovered at the peer is more than the supported maximum. + srvBeingDiscovered->charCount = BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV; + } + + for (i = numCharsPrevDisc, j = 0; i < srvBeingDiscovered->charCount; i++, j++) + { + memcpy(&srvBeingDiscovered->characteristics[i].characteristic.charPrope, &charDiscRspEvt->chars[j].char_props, sizeof(BLE_CharPrope)); + srvBeingDiscovered->characteristics[i].characteristic.charDeclhandle = charDiscRspEvt->chars[j].handle_decl; + srvBeingDiscovered->characteristics[i].characteristic.charValhandle = charDiscRspEvt->chars[j].handle_value; + srvBeingDiscovered->characteristics[i].characteristic.charValUuid.type = (BLE_GATT_UUID_TYPE)charDiscRspEvt->chars[j].uuid.type; //BLE_ENABLE_NORDIC_ORIGINAL + srvBeingDiscovered->characteristics[i].characteristic.charValUuid.value.baseAlias.uuidAlias = charDiscRspEvt->chars[j].uuid.uuid; //BLE_ENABLE_NORDIC_ORIGINAL + srvBeingDiscovered->characteristics[i].cccdHandle = BLE_GATT_HANDLE_INVALID; + + BLE_PRT2("onChar type %d uuid 0x%04X ValHdl %d DecHdl %d\n", + charDiscRspEvt->chars[j].uuid.type, + charDiscRspEvt->chars[j].uuid.uuid, + charDiscRspEvt->chars[j].handle_value, + charDiscRspEvt->chars[j].handle_decl); + } + + lastKnownChar = &(srvBeingDiscovered->characteristics[i - 1].characteristic); + + // If no more characteristic discovery is required, or if the maximum number of supported + // characteristic per service has been reached, descriptor discovery will be performed. + if (!isCharDiscoveryReqd(gattcDbDiscovery, lastKnownChar) || + (srvBeingDiscovered->charCount == BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV)) + { + performDescDiscov = true; + } + else + { + // Update the current characteristic index. + gattcDbDiscovery->currCharInd = srvBeingDiscovered->charCount; + // Perform another round of characteristic discovery. + BLE_PRT2("onChar charDiscover\n"); + (void)characteristicsDiscover(pBleEvent, gattcDbDiscovery); + } + } + else + { + // The previous characteristic discovery resulted in no characteristics. + // descriptor discovery should be performed. + performDescDiscov = true; + } + + if (performDescDiscov) + { + gattcDbDiscovery->currCharInd = 0; + BLE_PRT2("onChar charDiscover\n"); + (void)descriptorsDiscover(pBleEvent, gattcDbDiscovery, &raiseDiscovComplete); + if (raiseDiscovComplete) + { + BLE_PRT2("onChar onSrvDiscCompletion\n"); + onSrvDiscCompletion(pBleEvent, gattcDbDiscovery); + } + } +} + +static +void onDescriptorDiscoveryRsp(bleGattcDb *const gattcDbDiscovery, BLE_Evt *pBleEvent, ble_evt_t *pBleNrfEvt) +{ + uint32_t i = 0; + uint16_t connHandle = 0; + bool raiseDiscovComplete = false; + BLE_GattcDbDiscSrv *srvBeingDiscovered = NULL; + ble_gattc_evt_t *bleGattcEvt = NULL; + bleGattcEvt = &(pBleNrfEvt->evt.gattc_evt); + BLE_PRT2("onDesc srvInd %d charInd %d\n", + gattcDbDiscovery->currSrvInd, gattcDbDiscovery->currCharInd); + srvBeingDiscovered = &(gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd]); + const ble_gattc_evt_desc_disc_rsp_t * descDiscRspEvt = &(bleGattcEvt->params.desc_disc_rsp); + BLE_GattcDbDiscChar * charBeingDiscovered = &(srvBeingDiscovered->characteristics[gattcDbDiscovery->currCharInd]); + + connHandle = bleGattcEvt->conn_handle; + if ((gattcDbDiscovery->currSrvInd >= BLE_DB_DISCOVERY_MAX_SRV) || + (gattcDbDiscovery->currCharInd >= BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV)) + { + BLE_ERR("onDesc ind NG\n"); + gattcDbDiscovery->discoveryInProgress = false; + setDbDiscoveryEvent(pBleEvent, connHandle, BLE_GATTC_RESULT_FAILED, BLE_GATTC_REASON_DESCRIPTOR); + return; + } + if (bleGattcEvt->gatt_status == BLE_GATT_STATUS_SUCCESS) + { + // The descriptor was found at the peer. + // If the descriptor was a Client Characteristic Configuration Descriptor, then the cccdHandle needs to be populated. + // Loop through all the descriptors to find the Client Characteristic Configuration Descriptor. + for (i = 0; i < descDiscRspEvt->count; i++) + { + if (descDiscRspEvt->descs[i].uuid.uuid == BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG) + { + charBeingDiscovered->cccdHandle = descDiscRspEvt->descs[i].handle; + BLE_PRT2("onDesc ccc %d\n", descDiscRspEvt->descs[i].handle); + break; + } + } + } + + if ((gattcDbDiscovery->currCharInd + 1) == srvBeingDiscovered->charCount) + { + // No more characteristics and descriptors need to be discovered. Discovery is complete. + raiseDiscovComplete = true; + } + else + { + BLE_PRT2("onDesc retry descriptorsDiscover\n"); + // Begin discovery of descriptors for the next characteristic. + gattcDbDiscovery->currCharInd++; + (void)descriptorsDiscover(pBleEvent, gattcDbDiscovery, &raiseDiscovComplete); + } + if (raiseDiscovComplete) + { + BLE_PRT2("onDesc onSrvDiscCompletion\n"); + onSrvDiscCompletion(pBleEvent, gattcDbDiscovery); + } +} + +static +void onSrvDiscCompletion(BLE_Evt *pBleEvent, bleGattcDb *gattcDbDiscovery) +{ + int ret = BLE_SUCCESS; + uint16_t nextHandleStart = 0; + BLE_GattcDbDiscSrv *srvBeingDiscovered = NULL; + BLE_GattcDbDiscSrv *srvPrevDiscovered = NULL; + + // Reset the current characteristic index since a new service discovery is about to start. + gattcDbDiscovery->currCharInd = 0; + srvPrevDiscovered = &(gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd]); + + gattcDbDiscovery->currSrvInd++; + if (gattcDbDiscovery->currSrvInd > BLE_DB_DISCOVERY_MAX_SRV) + { + BLE_ERR("onCompletion ind NG\n"); + goto err; + } + else + { + // Initiate discovery of the next service. + if (gattcDbDiscovery->currSrvInd < BLE_DB_DISCOVERY_MAX_SRV) + { + srvBeingDiscovered = &(gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd]); + // Reset the characteristic count in the current service to zero since a new service + // discovery is about to start. + srvBeingDiscovered->charCount = 0; + } + } + if (srvPrevDiscovered->srvHandleRange.endHandle != BLE_GATTC_HANDLE_END) + { + nextHandleStart = srvPrevDiscovered->srvHandleRange.endHandle + 1; + } + else + { + nextHandleStart = BLE_GATTC_HANDLE_END; + } + BLE_PRT2("onCompletion nextHandle %d\n", nextHandleStart); + ret = sd_ble_gattc_primary_services_discover(gattcDbDiscovery->dbDiscovery.connHandle, nextHandleStart, NULL); + if (ret != NRF_SUCCESS) + { + BLE_ERR("sd_ble_gattc_primary_sd NG %d\n", ret); + goto err; + } + return; +err: + gattcDbDiscovery->discoveryInProgress = false; + setDbDiscoveryEvent(pBleEvent, gattcDbDiscovery->dbDiscovery.connHandle, + BLE_GATTC_RESULT_FAILED, BLE_GATTC_REASON_SERVICE); + return; +} + +static +int characteristicsDiscover(BLE_Evt *pBleEvent, bleGattcDb *const gattcDbDiscovery) +{ + int ret = 0; + uint8_t prevCharInd = 0; + BLE_GattcChar *prevChar = NULL; + BLE_GattcDbDiscSrv *srvBeingDiscovered = NULL; + BLE_GattcHandleRange handleRange = {0}; + BLE_PRT2("charDiscover start srvInd %d charInd %d\n", + gattcDbDiscovery->currSrvInd, gattcDbDiscovery->currCharInd); + if (gattcDbDiscovery->currSrvInd >= BLE_DB_DISCOVERY_MAX_SRV) + { + BLE_ERR("charDiscover NG %d\n", NRF_ERROR_FORBIDDEN); + goto err; + } + srvBeingDiscovered = &(gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd]); + if (gattcDbDiscovery->currCharInd != 0) + { + // This is not the first characteristic being discovered. Hence the 'start handle' to be + // used must be computed using the charValhandle of the previous characteristic. + + prevCharInd = gattcDbDiscovery->currCharInd - 1; + + srvBeingDiscovered = &(gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd]); + prevChar = &(srvBeingDiscovered->characteristics[prevCharInd].characteristic); + handleRange.startHandle = prevChar->charValhandle + 1; + } + else + { + // This is the first characteristic of this service being discovered. + handleRange.startHandle = srvBeingDiscovered->srvHandleRange.startHandle; + } + + handleRange.endHandle = srvBeingDiscovered->srvHandleRange.endHandle; + BLE_PRT2("charDiscover sHdl %d eHdl %d\n", + handleRange.startHandle, handleRange.endHandle); + ret = sd_ble_gattc_characteristics_discover(gattcDbDiscovery->dbDiscovery.connHandle, + (ble_gattc_handle_range_t *)&handleRange); + if (ret) + { + BLE_ERR("sd_ble_gattc_cdr NG %d\n", ret); + goto err; + } + return 0; +err: + gattcDbDiscovery->discoveryInProgress = false; + setDbDiscoveryEvent(pBleEvent, gattcDbDiscovery->dbDiscovery.connHandle, + BLE_GATTC_RESULT_FAILED, BLE_GATTC_REASON_CHARACTERISTIC); + return -1; +} + +static +bool isCharDiscoveryReqd(bleGattcDb *const gattcDbDiscovery, + BLE_GattcChar *afterChar) +{ + BLE_PRT2("isChar charEndHdl %d srvEndHdl %d\n", afterChar->charValhandle, + gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd].srvHandleRange.endHandle); + if (gattcDbDiscovery->currSrvInd >= BLE_DB_DISCOVERY_MAX_SRV) + { + return false; + } + if (afterChar->charValhandle < + gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd].srvHandleRange.endHandle) + { + // Handle value of the characteristic being discovered is less than the end handle of + // the service being discovered. There is a possibility of more characteristics being + // present. Hence a characteristic discovery is required. + return true; + } + return false; +} + +static +bool isDescDiscoveryReqd(bleGattcDb *gattcDbDiscovery, + BLE_GattcDbDiscChar *currChar, + BLE_GattcDbDiscChar *nextChar, + BLE_GattcHandleRange *handleRange) +{ + BLE_PRT2("isDesc charValHdl %d srvEndHdl %d\n", + currChar->characteristic.charValhandle, + gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd].srvHandleRange.endHandle); + + if (gattcDbDiscovery->currSrvInd >= BLE_DB_DISCOVERY_MAX_SRV) + { + return false; + } + if (nextChar == NULL) + { + // Current characteristic is the last characteristic in the service. Check if the value + // handle of the current characteristic is equal to the service end handle. + if (currChar->characteristic.charValhandle == + gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd].srvHandleRange.endHandle + ) + { + // No descriptors can be present for the current characteristic. currChar is the last + // characteristic with no descriptors. + return false; + } + + handleRange->startHandle = currChar->characteristic.charValhandle + 1; + + // Since the current characteristic is the last characteristic in the service, the end + // handle should be the end handle of the service. + handleRange->endHandle = gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd].srvHandleRange.endHandle; + BLE_PRT2("isDesc start %d end %d\n", handleRange->startHandle, handleRange->endHandle); + return true; + } + + // nextChar != NULL. Check for existence of descriptors between the current and the next + // characteristic. + if ((currChar->characteristic.charValhandle + 1) == nextChar->characteristic.charDeclhandle) + { + // No descriptors can exist between the two characteristic. + return false; + } + + handleRange->startHandle = currChar->characteristic.charValhandle + 1; + handleRange->endHandle = nextChar->characteristic.charDeclhandle - 1; + BLE_PRT2("isDesc start %d end %d\n", handleRange->startHandle, handleRange->endHandle); + return true; +} +static +int descriptorsDiscover(BLE_Evt *pBleEvent, bleGattcDb *const gattcDbDiscovery, bool *raiseDiscovComplete) +{ + uint8_t i = 0; + int ret = BLE_SUCCESS; + BLE_GattcHandleRange handleRange = {0}; + BLE_GattcDbDiscChar *currCharBeingDiscovered = NULL; + BLE_GattcDbDiscSrv *srvBeingDiscovered = NULL; + BLE_GattcDbDiscChar *nextChar = NULL; + bool isDiscoveryReqd = false; + + *raiseDiscovComplete = false; + BLE_PRT2("descDiscover SrvInd %d CharInd %d\n", + gattcDbDiscovery->currSrvInd, gattcDbDiscovery->currCharInd); + if ((gattcDbDiscovery->currSrvInd >= BLE_DB_DISCOVERY_MAX_SRV) || (gattcDbDiscovery->currCharInd >= BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV)) + { + BLE_ERR("descDiscover NG %d\n", NRF_ERROR_FORBIDDEN); + goto err; + } + + srvBeingDiscovered = &(gattcDbDiscovery->dbDiscovery.services[gattcDbDiscovery->currSrvInd]); + currCharBeingDiscovered = &(srvBeingDiscovered->characteristics[gattcDbDiscovery->currCharInd]); + + if ((gattcDbDiscovery->currCharInd + 1) == srvBeingDiscovered->charCount) + { + // This is the last characteristic of this service. + isDiscoveryReqd = isDescDiscoveryReqd(gattcDbDiscovery, currCharBeingDiscovered, NULL, &handleRange); + } + else + { + for (i = gattcDbDiscovery->currCharInd; i < srvBeingDiscovered->charCount; i++) + { + if (i == (srvBeingDiscovered->charCount - 1)) + { + // The current characteristic is the last characteristic in the service. + nextChar = NULL; + } + else + { + nextChar = &(srvBeingDiscovered->characteristics[i + 1]); + } + + // Check if it is possible for the current characteristic to have a descriptor. + if (isDescDiscoveryReqd(gattcDbDiscovery, currCharBeingDiscovered, nextChar, &handleRange)) + { + isDiscoveryReqd = true; + break; + } + else + { + // No descriptors can exist. + currCharBeingDiscovered = nextChar; + gattcDbDiscovery->currCharInd++; + } + } + } + + if (!isDiscoveryReqd) + { + // No more descriptor discovery required. Discovery is complete. + *raiseDiscovComplete = true; + return NRF_SUCCESS; + } + + BLE_PRT2("descDiscover sHdl %d eHdl %d\n", handleRange.startHandle, handleRange.endHandle); + ret = sd_ble_gattc_descriptors_discover(gattcDbDiscovery->dbDiscovery.connHandle, (ble_gattc_handle_range_t *)&handleRange); + if (ret) + { + BLE_ERR("sd_ble_gattc_dd NG %d\n", ret); + goto err; + } + return 0; +err: + gattcDbDiscovery->discoveryInProgress = false; + setDbDiscoveryEvent(pBleEvent, gattcDbDiscovery->dbDiscovery.connHandle, + BLE_GATTC_RESULT_FAILED, BLE_GATTC_REASON_DESCRIPTOR); + return -1; +} + +/**************************************************************************** + * For HAL I/F + ****************************************************************************/ + +static int32_t set_adv_data(void) +{ +#define BLE_TX_POWER_LEVEL 0 + int ret = 0; + int8_t tx_power = BLE_TX_POWER_LEVEL; + BLE_GapAdvData adv_data = {0}; + + adv_data.flags = BLE_GAP_ADV_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_BR_EDR_NOT_SUPPORTED; + adv_data.txPower = tx_power; + adv_data.complete32Uuid = 0; + adv_data.completeLocalName.advData = (uint8_t*) bt_common_context.ble_name; + adv_data.completeLocalName.advLength = + strnlen((char*)adv_data.completeLocalName.advData, BUF_LEN_MAX); + ret = BLE_GapSetAdvData(&adv_data); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("set ble adv data failed, ret=%d\n", ret); + } + + return ret; +} + +static int32_t init_pairing_mode(BLE_GAP_IO_CAP io_cap) +{ + BLE_GapPairingFeature* pf = &g_ble_context.pairing_feature; + int ret = 0; + BLE_GapOOB oob = BLE_GAP_OOB_AUTH_DATA_NOT_PRESENT; + BLE_GapAuth auth = BLE_GAP_AUTH_REQ_NO_MITM_BOND; + pf->oob = oob; + pf->ioCap = io_cap; + pf->authReq = auth; + pf->minKeySize = BLE_GAP_MIN_KEY_SIZE; + pf->maxKeySize = BLE_GAP_MAX_KEY_SIZE; + + return ret; +} + + +static int ble_start(void) +{ + BLE_InitializeParams params = {0}; + int ret = 0; + + ret = sem_init(&g_ble_context.ble_srv_sds.char_rw_buf_sem, 0, 1); + if (ret) + { + LOG_OUT("service in semaphore init failed.\n"); + return ret; + } + + params.role = BLE_ROLE_PERIPHERAL; + + ret = BLE_CommonInitializeStack(¶ms); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("ble stack init failed, ret=%d\n", ret); + } + + return ((BLE_SUCCESS == ret) ? 0 : -1); +} + +static int ble_stop(void) +{ + int ret = BLE_CommonFinalizeStack(); + if (BLE_SUCCESS != ret) + { + LOG_OUT("ble stack fina failed, ret=%d\n", ret); + } + + ret = sem_destroy(&g_ble_context.ble_srv_sds.char_rw_buf_sem); + if (ret) + { + LOG_OUT("service in semaphore init failed.\n"); + } + return ret; +} + + +/**************************************************************************** + * Name: nrf52_ble_scan + * + * Description: + * Bluetooth LE start/stop scan. + * Start/Stop scan. + * + ****************************************************************************/ + +static int nrf52_ble_scan(bool enable) +{ + int ret = BT_SUCCESS; + if( true == enable) + { + ret = BLE_GapStartScan(); + } + else + { + ret = BLE_GapStopScan(); + } + + return ret; +} + +/**************************************************************************** + * Name: nrf52_ble_connect + * + * Description: + * Bluetooth LE connect to target device + * + ****************************************************************************/ + +static int nrf52_ble_connect(const BT_ADDR *addr) +{ + int ret = BT_SUCCESS; + BLE_GapAddr gap_addr = {0}; + + memcpy(gap_addr.addr, addr->address, sizeof(gap_addr.addr)); + + ret = BLE_GapConnect(&gap_addr); + + return ret; +} + +/**************************************************************************** + * Name: nrf52_ble_disconnect + * + * Description: + * Bluetooth LE disconnect link to target device + * + ****************************************************************************/ + +static int nrf52_ble_disconnect(const uint16_t conn_handle) +{ + int ret = BT_SUCCESS; + BLE_GapConnHandle handle = conn_handle; + + ret = BLE_GapDisconnectLink(handle); + + return ret; +} + +static int nrf52_ble_advertise(bool enable) +{ + int ret = 0; + if (true == enable) + { + ret = set_adv_data(); + + ret = BLE_GapStartAdv(); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("ble enable advertise failed, ret=%d\n", ret); + } + } + else + { + ret = BLE_GapStopAdv(); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("ble disable advertise failed, ret=%d\n", ret); + } + } + return ret; +} + +static int nrf52_ble_set_dev_addr(BT_ADDR *addr) +{ + int ret = BT_SUCCESS; + return ret; +} + +static int nrf52_ble_set_dev_name(char *name) +{ + int ret = BT_SUCCESS; + size_t nameSize = 0; + + /* Get name length */ + + nameSize = strlen(name); + + /* If invalid size, retrun NG */ + + if (!name || nameSize > BT_MAX_NAME_LEN) + { + return -EINVAL; + } + + /* Copy device name to local name */ + + strncpy(bt_common_context.ble_name, name, nameSize); + + /* Send device name to chip */ + + return ret; +} + +static int nrf52_ble_set_appearance(BLE_APPEARANCE appearance) +{ + int ret = BT_SUCCESS; + return ret; +} + +static int nrf52_ble_set_ppcp(BLE_CONN_PARAMS ppcp) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Public Data + ****************************************************************************/ +BLE_Context g_ble_context; + +struct ble_hal_common_ops_s ble_hal_common_ops = +{ + .setDevAddr = nrf52_ble_set_dev_addr, + .setDevName = nrf52_ble_set_dev_name, + .setAppearance = nrf52_ble_set_appearance, + .setPPCP = nrf52_ble_set_ppcp, + .advertise = nrf52_ble_advertise, + .scan = nrf52_ble_scan, + .connect = nrf52_ble_connect, + .disconnect = nrf52_ble_disconnect +}; + +struct bt_hal_common_ops_s bt_hal_common_ops = +{ + .init = nrf52_bt_init, + .finalize = nrf52_bt_finalize, + .enable = nrf52_bt_enable, + .setDevAddr = nrf52_bt_set_device_addr, + .getDevAddr = nrf52_bt_get_device_addr, + .setDevName = nrf52_bt_set_device_name, + .getDevName = nrf52_bt_get_device_name, + .paringEnable = nrf52_bt_paring_enable, + .getBondList = nrf52_bt_get_bond_list, + .unBond = nrf52_bt_un_bond, + .setVisibility = nrf52_bt_set_visibility, + .inquiryStart = nrf52_bt_inquiry_start, + .inquiryCancel = nrf52_bt_inquiry_cancel +}; + +/**************************************************************************** + * BT Dummy + ****************************************************************************/ + + +/**************************************************************************** + * Name: nrf52_bt_init + * + * Description: + * Bluetooth Initialize + * Prepare NV storage etc for non power item initialize. + * + ****************************************************************************/ + +static int nrf52_bt_init(void) +{ + int ret = BT_SUCCESS; + + ret = BLE_CommonSetBleEvtCallback((BLE_EfCb)NULL, &g_ble_context.ble_evt_ctx); + + if (BLE_SUCCESS != ret) + { + LOG_OUT("set ble evt callback failed, ret=%d\n", ret); + } + init_pairing_mode(BLE_GAP_IO_CAP_NO_INPUT_NO_OUTPUT); + return (BLE_SUCCESS == ret) ? 0 : -1; +} + +/**************************************************************************** + * Name: nrf52_bt_finalize + * + * Description: + * Bluetooth Finalize + * Release NV etc. + * + ****************************************************************************/ + +static int nrf52_bt_finalize(void) +{ + int ret = BT_SUCCESS; + + ret = BSO_Finalize(NULL); + if (ret) + { + ret = -ENXIO; + BLE_PRT("BSO_Finalize failed\n"); + } + + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_enable + * + * Description: + * Bluetooth Enable + * Turn ON/OFF bluetooth and operate UART and Receive thread. + * + ****************************************************************************/ + +static int nrf52_bt_enable(bool enable) +{ + int ret = BT_SUCCESS; + + if (enable == true) + { + ret = ble_start(); + } + else + { + ret = ble_stop(); + } + + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_set_device_addr + * + * Description: + * Bluetooth set device address + * Set device address to chip and store local address. + * + ****************************************************************************/ + +static int nrf52_bt_set_device_addr(BT_ADDR *addr) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_get_device_addr + * + * Description: + * Bluetooth get device address + * Get device address from local address. + * + ****************************************************************************/ + +static int nrf52_bt_get_device_addr(BT_ADDR *addr) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_set_device_name + * + * Description: + * Bluetooth set device name + * Set device name to chip and store local name. + * + ****************************************************************************/ + +static int nrf52_bt_set_device_name(char *name) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_get_device_name + * + * Description: + * Bluetooth get device name + * Get device name from local name. + * + ****************************************************************************/ + +static int nrf52_bt_get_device_name(char *name) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_paring_enable + * + * Description: + * Bluetooth pairing mode enable/disable + * Set pairing mode and enable/disable. + * + ****************************************************************************/ + +static int nrf52_bt_paring_enable(bool enable) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_get_bond_list + * + * Description: + * Bluetooth get bondling address list. + * Get bonding address list. + * + ****************************************************************************/ + +static int nrf52_bt_get_bond_list(BT_ADDR *addrs, int *num) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_un_bond + * + * Description: + * Bluetooth unbond by BT_ADDR. + * Remove bondling information by BT_ADDR. + * + ****************************************************************************/ + +static int nrf52_bt_un_bond(BT_ADDR *addr) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_set_visibility + * + * Description: + * Bluetooth set visibility. + * Set visibility from other device. + * + ****************************************************************************/ + +static int nrf52_bt_set_visibility(BT_VISIBILITY visibility) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_inquiry_start + * + * Description: + * Bluetooth start inquiry. + * Start inquiry for search near devices. + * + ****************************************************************************/ + +static int nrf52_bt_inquiry_start(void) +{ + int ret = BT_SUCCESS; + return ret; +} + +/**************************************************************************** + * Name: nrf52_bt_inquiry_cancel + * + * Description: + * Bluetooth cancel inquiry. + * Cancel inquiry to stop search. + * + ****************************************************************************/ + +static int nrf52_bt_inquiry_cancel(void) +{ + int ret = BT_SUCCESS; + return ret; +} + diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_comm_internal.h b/sdk/modules/bluetooth/hal/nrf52/ble_comm_internal.h new file mode 100644 index 000000000..d69b4133c --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/ble_comm_internal.h @@ -0,0 +1,203 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/ble_comm_internal.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file ble_common_internal.h + * @brief Sharing common data structures between ble_xxx.c internally. + * @attention + */ +#ifndef __MODULES_BLUETOOTH_HAL_NRF52_BLE_COMM_INTERNAL_H +#define __MODULES_BLUETOOTH_HAL_NRF52_BLE_COMM_INTERNAL_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include "ble.h" +#include "ble_gap.h" +#include "ble_hci.h" +#include "app_util.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define BOND_SIZE_KEY_NAME "0000" +#define BOND_INFO_KEY_NAME "0001" +#define BOND_ENABLE_KEY_NAME "1000" +#define BOND_INFO_1_KEY_NAME "1001" +#define BOND_INFO_2_KEY_NAME "1002" +#define BOND_INFO_3_KEY_NAME "1003" +#define BOND_INFO_4_KEY_NAME "1004" +#define BOND_INFO_5_KEY_NAME "1005" +#define BOND_INFO_6_KEY_NAME "1006" +#define BOND_INFO_7_KEY_NAME "1007" +#define BOND_INFO_8_KEY_NAME "1008" + +#define BLE_GATTC_HANDLE_END 0xFFFF +#define APP_BLE_CONN_CFG_TAG 1 +#define CONN_HANDLE_INVALED 0xffff +#ifndef BLE_USE_SECTION +extern void bleEvtDispatch(ble_evt_t *pBleNrfEvt); +#endif + +typedef struct{ + uint32_t enable_key; + uint32_t info_key[BLE_SAVE_BOND_DEVICE_MAX_NUM]; +}bleBondInfoKey; + +typedef struct +{ + BLE_GapConnHandle connHandle; + BLE_GapBondInfo bondInfo; + //ble_gap_id_key_t ownIdKey; + //ble_gap_enc_key_t ownEncKey; + ble_gap_id_key_t peerIdKey; + ble_gap_enc_key_t peerEncKey; +} bleGapWrapperBondInfo; + +/**@brief A collection of variables of gap. */ +typedef struct +{ + bleGapWrapperBondInfo wrapperBondInfo; + uint8_t advHandle; + uint8_t gapAdvData[BLE_GAP_ADV_MAX_SIZE]; + uint16_t gapAdvLen; + ble_gap_scan_params_t scanParams; + ble_gap_conn_params_t connParams; + ble_gap_sec_keyset_t keySet; + uint8_t is_connected; + int8_t peerRssi; + uint8_t startRssi; +} bleGapMem; + +typedef struct +{ + uint8_t currCharInd; + uint8_t currSrvInd; + bool discoveryInProgress; + uint8_t reserve; + BLE_GattcDbDiscovery dbDiscovery; +} bleGattcDb; + +/**@brief A collection of variables of common. */ + typedef struct +{ + uint8_t callbackFlag; + uint8_t managerCbFlag; + void (*managerCb)(ble_evt_t *nrfEvt); + BLE_EfCb cbId; + uint32_t bondInfoId; + BLE_EvtCtx *bleEvtCtx; + BLE_EvtTxComplete txCompleteData; + BLE_EvtConnected connectData; + BLE_EvtConnParamUpdate connParams; + BLE_EvtDisconnected disconnectData; + BLE_EvtExchangeFeature exchangeFeatureData; + BLE_EvtAuthStatus authStatusData; + BLE_EvtDisplayPasskey dispPasskeyData; + BLE_EvtAdvReportData advReportData; + BLE_EvtAuthKey authKeyData; + BLE_EvtTimeout timeoutData; + BLE_EvtDataLengthUpdate dataLen; + BLE_EvtRssiChanged rssiChangeData; + BLE_EvtGattsWrite gattsWriteData; + BLE_EvtGattsIndConfirm gattsIndConfirmData; + BLE_EvtGattsExchangeMTU gattsExchangeMTU; + BLE_EvtGattcRead gattcReadData; + BLE_EvtGattcNtfInd gattcNtfIndData; + BLE_EvtGattcDbDiscovery gattcDbDiscoveryData; + bleGattcDb gattcDb; + bleGapMem *gapMem; + uint8_t stackInited; + uint16_t client_rx_mtu; + BLE_EvtPhyUpdate phyUpdate; +} bleCommMem; + +typedef struct ble_srv_sds +{ + bool notify_enabled; + BLE_GapConnHandle conn_handle; + uint16_t srv_handle; + uint8_t char_rw_buf[MAX_RCV_DATA_LENGTH]; /* read / write */ + BLE_GattsCharHandles char_rw_handle; + int32_t char_rw_curr_idx; /* current data length index */ + sem_t char_rw_buf_sem; + uint8_t char_ri_buf[MAX_RCV_DATA_LENGTH]; /* read / indication */ + BLE_GattsCharHandles char_ri_handle; +} BLE_SrvSds; + +typedef struct ble_context +{ + BLE_EvtCtx ble_evt_ctx; + BLE_GapAddr ble_addr; + BLE_GapDeviceConfig ble_dev_cfg; + BLE_GapName ble_name; + BLE_GapConnHandle ble_conn_handle; + uint8_t ble_role; + BLE_SrvSds ble_srv_sds; + BLE_GapPairingFeature pairing_feature; +} BLE_Context; + +extern BLE_Context g_ble_context; + +struct bt_common_context_s +{ + BT_ADDR bt_addr; /* Common address for BT/BLE */ + char bt_name[BT_NAME_LEN]; + char ble_name[BT_NAME_LEN]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +extern struct bt_common_context_s bt_common_context; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @} ble_struct */ +#endif /* __MODULES_BLUETOOTH_HAL_NRF52_BLE_COMM_INTERNAL_H */ + diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_gap.c b/sdk/modules/bluetooth/hal/nrf52/ble_gap.c new file mode 100644 index 000000000..81f1d8900 --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/ble_gap.c @@ -0,0 +1,1092 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/ble_gap.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/****************************************************************************** + * Include + *****************************************************************************/ + +#include +#include +#include +#include +#include "ble_comm_internal.h" +#include "ble_storage_operations.h" + +/****************************************************************************** + * externs + *****************************************************************************/ +extern int bleConvertErrorCode(uint32_t errCode); + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define ADV_DATA_TYPE_FLAGS_SIZE 0x02 +#define ADV_DATA_TYPE_COMPLETE_16_UUIDS_SIZE 0x03 +#define ADV_DATA_TYPE_COMPLETE_32_UUIDS_SIZE 0x05 +#define ADV_DATA_TYPE_COMPLETE_128_UUIDS_SIZE 17 + +#define ADV_DEFAULT_INTERVAL 50 +#if NRF_SD_BLE_API_VERSION > 5 +#define ADV_DEFAULT_TIMEOUT 18000 // 10ms units +#else +#define ADV_DEFAULT_TIMEOUT 180 +#endif + +#define SCAN_INTERVAL 0x0200 +#define SCAN_WINDOW 0x0020 +#if NRF_SD_BLE_API_VERSION > 5 +#define SCAN_TIMEOUT 6000 // 10ms units +#else +#define SCAN_TIMEOUT 60 +#endif +#define MIN_SCAN_INTERVAL 0x0004 +#define MAX_SCAN_INTERVAL 0x4000 +#define MIN_SCAN_WINDOW 0x0004 +#define MAX_SCAN_WINDOW 0x4000 +#define MIN_SCAN_TIMEOUT 0x0000 +#define MAX_SCAN_TIMEOUT 0xFFFF + +#define MIN_CONNECTION_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS) +#define MAX_CONNECTION_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS) +#define SLAVE_LATENCY 0 +#define SUPERVISION_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) + +/* Flash handle key name size */ +#define FLASH_KEY_NAME_SIZE 4 +#define FLASH_KEY_NAME_2 2 +#define FLASH_KEY_NAME_3 3 +#define BLE_GAP_ADDR_LENGTH_4 4 +#define BLE_GAP_ADDR_LENGTH_5 5 +#define BLE_KEY_MASK 0x7F + +// #define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define BLE_PRT printf +#else +#define BLE_PRT(...) +#endif + + /****************************************************************************** + * Structre define + *****************************************************************************/ + + /****************************************************************************** + * Function prototype declaration + *****************************************************************************/ +bleGapMem *bleGetGapMem(void); +static int getAddress(BLE_GapAddr *addr); +static int setAddress(BLE_GapAddr *addr); +static int getName(BLE_GapName *name); +static int setName(BLE_GapName *name); +static int setCustomBaseuuid(uint8_t uuid[]); + +/****************************************************************************** + * Variable + *****************************************************************************/ +static bleGapMem gapMem = {{0}}; + +extern bleGapWrapperBondInfo BondInfoInFlash[BLE_SAVE_BOND_DEVICE_MAX_NUM]; +extern uint32_t bleBondEnableList; +extern bleBondInfoKey bleKey; + +/****************************************************************************** + * Function + *****************************************************************************/ +bleGapMem *bleGetGapMem(void) +{ + return &gapMem; +} + +int BLE_GapGetDeviceConfig(BLE_GapDeviceConfig *deviceConfig) +{ + int type = 0; + int ret = BLE_SUCCESS; + + if((deviceConfig == NULL) || (deviceConfig->data == NULL)) { + return -EINVAL; + } + + type = deviceConfig->type; + switch( type ) { + case BLE_GAP_DEVICE_CONFIG_ADDR: + ret = getAddress((BLE_GapAddr *)deviceConfig->data); + break; + case BLE_GAP_DEVICE_CONFIG_NAME: + ret = getName((BLE_GapName *)deviceConfig->data); + break; + default: + ret = -EINVAL; + break; + } + return ret; +} + +int BLE_GapSetDeviceConfig(BLE_GapDeviceConfig *deviceConfig) +{ + int type = 0; + int ret = BLE_SUCCESS; + + if((deviceConfig == NULL) || (deviceConfig->data == NULL)) { + return -EINVAL; + } + + type = deviceConfig->type; + switch( type ) { + case BLE_GAP_DEVICE_CONFIG_ADDR: + ret = setAddress((BLE_GapAddr *)deviceConfig->data); + break; + case BLE_GAP_DEVICE_CONFIG_NAME: + ret = setName((BLE_GapName *)deviceConfig->data); + break; + case BLE_GAP_DEVICE_CONFIG_UUID: + ret = setCustomBaseuuid((uint8_t *)deviceConfig->data); + break; + case BLE_GAP_DEVICE_CONFIG_SERV_CHNG_ENABLE: + /* TODO */ + break; + case BLE_GAP_DEVICE_CONFIG_APPR_VALUE: + /* TODO */ + break; + case BLE_GAP_DEVICE_CONFIG_PPCP_VALUE: + /* TODO */ + break; + default: + ret = -EINVAL; + break; + } + return ret; +} + +int BLE_GapSetAdvData(BLE_GapAdvData *advData) +{ + int errCode = BLE_SUCCESS, ret = BLE_SUCCESS; + uint8_t index = 0; + uint8_t advLen = 0; + uint8_t *data = NULL; + + if(advData == NULL) { + return -EINVAL; + } + + if(advData->flags != 0) { + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_FLAGS_SIZE; + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_FLAGS; + gapMem.gapAdvData[index++] = advData->flags; + } + if(advData->complete16Uuid != 0) { + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_COMPLETE_16_UUIDS_SIZE; + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_COMPLETE_16_UUIDS; + gapMem.gapAdvData[index++] = (uint8_t)(advData->complete16Uuid >> 0); + gapMem.gapAdvData[index++] = (uint8_t)(advData->complete16Uuid >> 8); + } + if(advData->complete32Uuid != 0) { + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_COMPLETE_32_UUIDS_SIZE; + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_COMPLETE_32_UUIDS; + gapMem.gapAdvData[index++] = (uint8_t)(advData->complete32Uuid >> 0); + gapMem.gapAdvData[index++] = (uint8_t)(advData->complete32Uuid >> 8); + gapMem.gapAdvData[index++] = (uint8_t)(advData->complete32Uuid >> 16); + gapMem.gapAdvData[index++] = (uint8_t)(advData->complete32Uuid >> 24); + } + if(advData->complete128Uuid != 0) { + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_COMPLETE_128_UUIDS_SIZE; + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_COMPLETE_128_UUIDS; + memcpy(&gapMem.gapAdvData[index], advData->complete128Uuid, 16); + index += 16; + } + advLen = advData->completeLocalName.advLength; + data = advData->completeLocalName.advData; + if((advLen != 0)&&(data != NULL)) { + gapMem.gapAdvData[index++] = advLen+1; + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_COMPLETE_LOCAL_NAME; + memcpy(&gapMem.gapAdvData[index], data, advLen); + index += advLen; + } + advLen = advData->manufacturerSpecificData.advLength; + data = advData->manufacturerSpecificData.advData; + if((advLen != 0)&&(data != NULL)) { + gapMem.gapAdvData[index++] = advLen+1; + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_MANUFACTURER_SPECIFIC_DATA; + memcpy(&gapMem.gapAdvData[index], data, advLen); + index += advLen; + } + if ((advData->serviceDataCount != 0) && (advData->serviceData != NULL)) { + int i; + + for (i = 0; i < advData->serviceDataCount; i++) { + BLE_GapAdvStructure *pServiceData = &(advData->serviceData[i]); + + advLen = pServiceData->advLength; + data = pServiceData->advData; + if ((advLen != 0) && (data != NULL)) { + gapMem.gapAdvData[index++] = advLen + 1; + gapMem.gapAdvData[index++] = ADV_DATA_TYPE_SERVICE_DATA; + memcpy(&gapMem.gapAdvData[index], data, advLen); + index += advLen; + } + } + } + gapMem.gapAdvLen = index+1; + if(gapMem.gapAdvLen > BLE_GAP_ADV_MAX_SIZE) { + return -EINVAL; + } +#if NRF_SD_BLE_API_VERSION > 5 + // Configure a initial advertising configuration. The advertising data and and advertising + // parameters will be changed later when we call @ref ble_advertising_start, but must be set + // to legal values here to define an advertising handle. + ble_gap_adv_params_t advParams = {0}; + advParams.primary_phy = BLE_GAP_PHY_1MBPS; + advParams.duration = ADV_DEFAULT_TIMEOUT; + advParams.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; + advParams.p_peer_addr = NULL; + advParams.filter_policy = BLE_GAP_ADV_FP_ANY; + advParams.interval = ADV_DEFAULT_INTERVAL; + errCode = sd_ble_gap_adv_set_configure(&gapMem.advHandle, NULL, &advParams); + if (errCode) { + BLE_PRT("BLE_GapSetAdvData:sd_ble_gap_adv_set_configure fail 0x%x\n", errCode); + goto end; + } + errCode = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, gapMem.advHandle, advData->txPower); + if (errCode) { + BLE_PRT("BLE_GapStartAdv:sd_ble_gap_tx_power_set fail 0x%x\n", errCode); + } +end: +#else + errCode = sd_ble_gap_adv_data_set(gapMem.gapAdvData, gapMem.gapAdvLen, NULL, 0); +#endif + ret = bleConvertErrorCode((uint32_t)errCode); + + return ret; +} + +int BLE_GapStartAdvExt(BLE_GapAdvParams *advParams) +{ + int errCode = BLE_SUCCESS, ret = BLE_SUCCESS; + +#if NRF_SD_BLE_API_VERSION > 5 + if (!((advParams->primary_phy == BLE_GAP_PHY_1MBPS) || (advParams->primary_phy == BLE_GAP_PHY_CODED))) { + return -EINVAL; + } + + ble_gap_adv_data_t advData = {0}; + advData.adv_data.p_data = gapMem.gapAdvData; + advData.adv_data.len = gapMem.gapAdvLen; + + ble_gap_adv_params_t params = {0}; + params.interval = advParams->interval; + params.duration = advParams->duration; + params.primary_phy = advParams->primary_phy; + params.secondary_phy = advParams->primary_phy; + params.p_peer_addr = NULL; + params.filter_policy = BLE_GAP_ADV_FP_ANY; + if (params.primary_phy == BLE_GAP_PHY_1MBPS) { + params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; + } + else { + params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED; + } + + errCode = sd_ble_gap_adv_set_configure(&gapMem.advHandle, &advData, ¶ms); + if (errCode) { + BLE_PRT("BLE_GapStartAdv:sd_ble_gap_adv_set_configure fail 0x%x\n", errCode); + goto end; + } + errCode = sd_ble_gap_adv_start(gapMem.advHandle, APP_BLE_CONN_CFG_TAG); +end: +#else + errCode = NRF_ERROR_NOT_SUPPORTED; +#endif + ret = bleConvertErrorCode((uint32_t)errCode); + + return ret; +} + +int BLE_GapStartAdv(void) +{ + int errCode = BLE_SUCCESS, ret = BLE_SUCCESS; + ble_gap_adv_params_t advParams = {0}; + +#if NRF_SD_BLE_API_VERSION > 5 + ble_gap_adv_data_t advData = {0}; + advData.adv_data.p_data = gapMem.gapAdvData; + advData.adv_data.len = gapMem.gapAdvLen; + + advParams.primary_phy = BLE_GAP_PHY_1MBPS; + advParams.duration = ADV_DEFAULT_TIMEOUT; + advParams.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; + advParams.p_peer_addr = NULL; + advParams.filter_policy = BLE_GAP_ADV_FP_ANY; + advParams.interval = ADV_DEFAULT_INTERVAL; + errCode = sd_ble_gap_adv_set_configure(&gapMem.advHandle, &advData, &advParams); + if (errCode) { + BLE_PRT("BLE_GapStartAdv:sd_ble_gap_adv_set_configure fail 0x%x\n", errCode); + goto end; + } + errCode = sd_ble_gap_adv_start(gapMem.advHandle, APP_BLE_CONN_CFG_TAG); +end: +#else + advParams.type = BLE_GAP_ADV_TYPE_ADV_IND; + advParams.p_peer_addr = NULL; + advParams.fp = BLE_GAP_ADV_FP_ANY; + advParams.interval = ADV_DEFAULT_INTERVAL; + advParams.timeout = ADV_DEFAULT_TIMEOUT; + errCode = sd_ble_gap_adv_start(&advParams, APP_BLE_CONN_CFG_TAG); +#endif + ret = bleConvertErrorCode((uint32_t)errCode); + + return ret; +} + +int BLE_GapStopAdv(void) +{ + int errCode = BLE_SUCCESS; +#if NRF_SD_BLE_API_VERSION > 5 + // arg is tentative. + errCode = sd_ble_gap_adv_stop(gapMem.advHandle); +#else + errCode = sd_ble_gap_adv_stop(); +#endif + return bleConvertErrorCode((uint32_t)errCode); +} + +int BLE_GapSetSecParam(BLE_GapSecCfg *param) +{ + int errCode = 0; + int ret = BLE_SUCCESS; + BLE_GapSecCfgPasskey *pkey = NULL; + ble_opt_t bleOpt = {0}; + + if((param == NULL) || (param->data == NULL)) + { + return -EINVAL; + } + memset(&bleOpt,0x00,sizeof(bleOpt)); + switch(param->type) + { + case SEC_CFG_PASSKEY: + { + pkey = (BLE_GapSecCfgPasskey *)param->data; + bleOpt.gap_opt.passkey.p_passkey = (uint8_t*)(pkey->passkey); + errCode = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &bleOpt); + ret = bleConvertErrorCode((uint32_t)errCode); + break; + } + + default: + ret = -EINVAL; + break; + } + return ret; +} + +int BLE_GapExchangePairingFeature(BLE_GapConnHandle connHandle, BLE_GapPairingFeature *pairingFeature) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + ble_gap_sec_params_t secParams = {0}; + ble_gap_sec_keyset_t keysExchanged = {{0}}; + + if(pairingFeature == NULL) { + BLE_PRT("pairingFeature is NULL!!!\n"); + return -EINVAL; + } + if((pairingFeature->oob > BLE_GAP_OOB_AUTH_DATA_PRESENT) || (pairingFeature->oob < BLE_GAP_OOB_AUTH_DATA_NOT_PRESENT)) { + BLE_PRT("pairingFeature->oob=%d\n", pairingFeature->oob); + return -EINVAL; + } + if((pairingFeature->maxKeySize < pairingFeature->minKeySize) || + (pairingFeature->maxKeySize > BLE_GAP_MAX_KEY_SIZE) || + (pairingFeature->minKeySize < BLE_GAP_MIN_KEY_SIZE)) { + BLE_PRT("pairingFeature->maxKeySize=%d, pairingFeature->minKeySize=%d\n", pairingFeature->maxKeySize, pairingFeature->minKeySize); + return -EINVAL; + } + + memset(&secParams,0,sizeof(secParams)); + memset(&keysExchanged,0,sizeof(keysExchanged)); + + //memset(&gapMem.wrapperBondInfo.ownEncKey,0,sizeof(gapMem.wrapperBondInfo.ownEncKey)); + //memset(&gapMem.wrapperBondInfo.ownIdKey,0,sizeof(gapMem.wrapperBondInfo.ownIdKey)); + memset(&gapMem.wrapperBondInfo.peerEncKey,0,sizeof(gapMem.wrapperBondInfo.peerEncKey)); + memset(&gapMem.wrapperBondInfo.peerIdKey,0,sizeof(gapMem.wrapperBondInfo.peerIdKey)); + + secParams.oob = pairingFeature->oob; + secParams.io_caps = pairingFeature->ioCap; + secParams.max_key_size = pairingFeature->maxKeySize; + secParams.min_key_size = pairingFeature->minKeySize; + secParams.mitm = (pairingFeature->authReq & BLE_GAP_AUTH_MITM) >> 1; + secParams.bond = (pairingFeature->authReq & BLE_GAP_AUTH_BOND) >> 0; + + //secParams.kdist_own.enc = 1; + //secParams.kdist_own.id = 1; + secParams.kdist_peer.enc = 1; + secParams.kdist_peer.id = 1; + + //keysExchanged.keys_own.p_enc_key = &gapMem.wrapperBondInfo.ownEncKey; + //keysExchanged.keys_own.p_id_key = &gapMem.wrapperBondInfo.ownIdKey; + keysExchanged.keys_peer.p_enc_key = &gapMem.wrapperBondInfo.peerEncKey; + keysExchanged.keys_peer.p_id_key = &gapMem.wrapperBondInfo.peerIdKey; + + errCode = sd_ble_gap_sec_params_reply(connHandle, BLE_GAP_SEC_STATUS_SUCCESS, &secParams, &keysExchanged); + ret = bleConvertErrorCode((uint32_t)errCode); + memcpy(&gapMem.keySet, &keysExchanged, sizeof(ble_gap_sec_keyset_t)); +#ifdef BLE_DBGPRT_ENABLE +#if 0 + // own + BLE_PRT("ExchangePairing: own id_irk=0x"); + for (int i=0; i<16; i++) { + BLE_PRT("%02x", gapMem.wrapperBondInfo.ownIdKey.id_info.irk[i]); + } + BLE_PRT("\n"); + BLE_PRT("ExchangePairing: own id_addr_type=%d\n", gapMem.wrapperBondInfo.ownIdKey.id_addr_info.addr_type); + BLE_PRT("ExchangePairing: own id_addr=0x"); + for (int i=0; i<6; i++) { + BLE_PRT("%02x", gapMem.wrapperBondInfo.ownIdKey.id_addr_info.addr[i]); + } + BLE_PRT("\n"); + BLE_PRT("ExchangePairing: own master_id_ediv=%d\n", gapMem.wrapperBondInfo.ownEncKey.master_id.ediv); + BLE_PRT("ExchangePairing: own master_id_rand=0x"); + for (int i=0; i<8; i++) { + BLE_PRT("%02x", gapMem.wrapperBondInfo.ownEncKey.master_id.rand[i]); + } + BLE_PRT("\n"); + BLE_PRT("ExchangePairing: own enc_info_auth=%d\n", gapMem.wrapperBondInfo.ownEncKey.enc_info.auth); + if (gapMem.wrapperBondInfo.ownEncKey.enc_info.ltk_len) { + BLE_PRT("ExchangePairing: own enc_info_ltk=0x"); + for (int i=0; i 5 +static int8_t ble_gap_scan_tx_power = 0; +uint8_t bleAdvReportBuffer[BLE_GAP_SCAN_BUFFER_EXTENDED_MIN]; +#endif + +int BLE_GapSetScanParam(BLE_GapScanParams *scanParam) +{ + if(scanParam == NULL) { + return -EINVAL; + } + if (!(scanParam->interval > MAX_SCAN_INTERVAL || + scanParam->interval < MIN_SCAN_INTERVAL || + scanParam->window > MAX_SCAN_WINDOW || + scanParam->window < MIN_SCAN_WINDOW || + scanParam->timeout > MAX_SCAN_TIMEOUT || + scanParam->timeout < MIN_SCAN_TIMEOUT)) { + gapMem.scanParams.active = scanParam->active; + //gapMem.scanParams.selective = 0; + gapMem.scanParams.interval = scanParam->interval; + gapMem.scanParams.window = scanParam->window; + //gapMem.scanParams.p_whitelist = NULL; + gapMem.scanParams.timeout = scanParam->timeout; + } + else { + return -EINVAL; + } +#if NRF_SD_BLE_API_VERSION > 5 + gapMem.scanParams.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL; + gapMem.scanParams.scan_phys = scanParam->scan_phys; + if (gapMem.scanParams.scan_phys == BLE_GAP_PHY_CODED) { + gapMem.scanParams.extended = 1; + } + else { + gapMem.scanParams.extended = 0; + } + ble_gap_scan_tx_power = scanParam->tx_power; +#endif + return 0; +} + +int BLE_GapStartScan(void) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + if ((gapMem.scanParams.interval > MAX_SCAN_INTERVAL || + gapMem.scanParams.interval < MIN_SCAN_INTERVAL || + gapMem.scanParams.window > MAX_SCAN_WINDOW || + gapMem.scanParams.window < MIN_SCAN_WINDOW || + gapMem.scanParams.timeout > MAX_SCAN_TIMEOUT || + gapMem.scanParams.timeout < MIN_SCAN_TIMEOUT)) { + // default + gapMem.scanParams.active = 0; + gapMem.scanParams.interval = SCAN_INTERVAL; + gapMem.scanParams.window = SCAN_WINDOW; + gapMem.scanParams.timeout = SCAN_TIMEOUT; +#if NRF_SD_BLE_API_VERSION > 5 + gapMem.scanParams.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL; + gapMem.scanParams.scan_phys = BLE_GAP_PHY_1MBPS; + gapMem.scanParams.extended = 0; + ble_gap_scan_tx_power = 0; +#endif + } +#if NRF_SD_BLE_API_VERSION > 5 + errCode = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_SCAN_INIT, 0, + ble_gap_scan_tx_power); + if (errCode) { + BLE_PRT("sd_ble_gap_tx_power_set fail 0x%x\n", errCode); + goto end; + } + + ble_data_t reportBuf = {0}; + reportBuf.p_data = bleAdvReportBuffer; + reportBuf.len = BLE_GAP_SCAN_BUFFER_EXTENDED_MIN; + errCode = sd_ble_gap_scan_start(&gapMem.scanParams, &reportBuf); +end: +#else + errCode = sd_ble_gap_scan_start(&gapMem.scanParams); +#endif + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GapStartScanExt(BLE_GapScanParams *scanparams) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + if(scanparams == NULL) { + return -EINVAL; + } + + ble_gap_scan_params_t p = {0}; + p.active = scanparams->active; + p.interval = scanparams->interval; + p.window = scanparams->window; + p.timeout = scanparams->timeout; +#if NRF_SD_BLE_API_VERSION > 5 + p.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL; + p.scan_phys = scanparams->scan_phys; + if (p.scan_phys == BLE_GAP_PHY_CODED) { + p.extended = 1; + } + gapMem.scanParams = p; + + ble_gap_scan_tx_power = scanparams->tx_power; + errCode = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_SCAN_INIT, 0, + ble_gap_scan_tx_power); + if (errCode) { + BLE_PRT("sd_ble_gap_tx_power_set fail 0x%x\n", errCode); + goto end; + } + + ble_data_t reportBuf = {0}; + reportBuf.p_data = bleAdvReportBuffer; + reportBuf.len = BLE_GAP_SCAN_BUFFER_EXTENDED_MIN; + errCode = sd_ble_gap_scan_start(&gapMem.scanParams, &reportBuf); +end: +#else + gapMem.scanParams = p; + errCode = sd_ble_gap_scan_start(&gapMem.scanParams); +#endif + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GapStopScan(void) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + errCode = sd_ble_gap_scan_stop(); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GapConnect(BLE_GapAddr *addr) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + ble_gap_addr_t peerAddr = {0}; + + if(addr == NULL) { + return -EINVAL; + } + + gapMem.connParams.min_conn_interval = MIN_CONNECTION_INTERVAL; + gapMem.connParams.max_conn_interval = MAX_CONNECTION_INTERVAL; + gapMem.connParams.slave_latency = SLAVE_LATENCY; + gapMem.connParams.conn_sup_timeout = SUPERVISION_TIMEOUT; + peerAddr.addr_type = addr->type; + memcpy(peerAddr.addr, addr->addr, BLE_GAP_ADDR_LENGTH); + errCode = sd_ble_gap_connect(&peerAddr, + &gapMem.scanParams, + &gapMem.connParams, + APP_BLE_CONN_CFG_TAG); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GapUpdateConnectionParams(BLE_GapConnHandle connHandle, BLE_GapConnParams *connParams) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + if(connParams == NULL) + { + return -EINVAL; + } + + gapMem.connParams = *(ble_gap_conn_params_t *)connParams; + errCode = sd_ble_gap_conn_param_update(connHandle, &gapMem.connParams); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GapCancelConnecting(void) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + errCode = sd_ble_gap_connect_cancel(); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GapDisconnectLink(BLE_GapConnHandle connHandle) +{ + int errCode = sd_ble_gap_disconnect((uint16_t)connHandle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE); + return bleConvertErrorCode((uint32_t)errCode); +} + +int BLE_GapAuthenticate(BLE_GapConnHandle connHandle, BLE_GapPairingFeature *pairingFeature) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + ble_gap_sec_params_t secParams = {0}; + + if(pairingFeature == NULL) { + return -EINVAL; + } + + secParams.oob = pairingFeature->oob; + secParams.io_caps = pairingFeature->ioCap; + secParams.max_key_size = pairingFeature->maxKeySize; + secParams.min_key_size = pairingFeature->minKeySize; + secParams.mitm = (pairingFeature->authReq & BLE_GAP_AUTH_MITM) >> 1; + secParams.bond = (pairingFeature->authReq & BLE_GAP_AUTH_BOND) >> 0; + secParams.kdist_peer.enc = 1; + secParams.kdist_peer.id = 1; + errCode = sd_ble_gap_authenticate(connHandle, &secParams); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GapReplyPairingFeature(BLE_GapConnHandle connHandle) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + ble_gap_sec_keyset_t secKeyset = {{0}}; + + secKeyset.keys_peer.p_enc_key = &gapMem.wrapperBondInfo.peerEncKey; + secKeyset.keys_peer.p_id_key = &gapMem.wrapperBondInfo.peerIdKey; + + errCode = sd_ble_gap_sec_params_reply(connHandle, BLE_GAP_SEC_STATUS_SUCCESS, NULL, &secKeyset); + ret = bleConvertErrorCode((uint32_t)errCode); + memcpy(&gapMem.keySet, &secKeyset, sizeof(ble_gap_sec_keyset_t)); + return ret; +} + + +int BLE_GapReplyAuthKey(BLE_GapAuthKey *authKey) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + if((authKey == NULL) || (authKey->key == NULL)) { + return -EINVAL; + } + + errCode = sd_ble_gap_auth_key_reply(authKey->handle, authKey->keyType, authKey->key); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GapSaveBondInfo(BLE_GapBondInfo *info) +{ + int ret = 0; + int index; + BLE_GapBondInfo checkInfo={0}; + + if (info == NULL) + { + return -EINVAL; + } + + if ((gapMem.wrapperBondInfo.bondInfo.addrType != info->addrType) || + memcmp(gapMem.wrapperBondInfo.bondInfo.addr, info->addr, BLE_GAP_ADDR_LENGTH) || + !memcmp(checkInfo.addr, info->addr, BLE_GAP_ADDR_LENGTH)) + { + ret = -EINVAL; + BLE_PRT("BLE_GapSaveBondInfo: Not finished Authenticate %d\n", ret); + return ret; + } + uint32_t list = bleBondEnableList; + if (bleBondEnableList == 0xFF) + { + ret = -ENOMEM; + BLE_PRT("BLE_GapSaveBondInfo: BondInfo full %d\n", ret); + return ret; + } + if(bleBondEnableList) { + for(index = 0; index < BLE_SAVE_BOND_DEVICE_MAX_NUM; index++, list >>= 1) { + if (!(list & 1)) { + continue; + } + if(!memcmp(BondInfoInFlash[index].bondInfo.addr, info->addr, BLE_GAP_ADDR_LENGTH)) { + BLE_PRT("BLE_GapSaveBondInfo: Exsiting addr\n"); + BondInfoInFlash[index] = gapMem.wrapperBondInfo; + goto save; + } + } + } + list = bleBondEnableList; + for(index = 0; index < BLE_SAVE_BOND_DEVICE_MAX_NUM; index++, list >>= 1) { + if (list & 1) { + continue; + } + BondInfoInFlash[index] = gapMem.wrapperBondInfo; + bleBondEnableList |= (1 << index); + break; + } + BLE_PRT("BLE_GapSaveBondInfo: bleBondEnableList 0x%lx\n", bleBondEnableList); + if (index == BLE_SAVE_BOND_DEVICE_MAX_NUM) { + ret = -ENOMEM; + BLE_PRT("BLE_GapSaveBondInfo: BondInfo full ?? %d\n", ret); + return ret; + } +save: + ret = BSO_SetRegistryValue(bleKey.info_key[index], + (const void*)&BondInfoInFlash[index], sizeof(bleGapWrapperBondInfo)); + if(0 != ret) { + BLE_PRT("BLE_GapSaveBondInfo: Set info_key NG %d size %d\n", ret, sizeof(bleGapWrapperBondInfo)); + return ret; + } + ret = BSO_SetRegistryValue(bleKey.enable_key, (const void*)&bleBondEnableList, sizeof(uint32_t)); + if(0 != ret) { + BLE_PRT("BLE_GapSaveBondInfo: Set enable_key NG %d\n", ret); + return ret; + } + BSO_Sync(); + return 0; +} + +int BLE_GapClearBondInfo(BLE_GapBondInfo *info) +{ + int ret = BLE_SUCCESS; + int index; + uint32_t list = bleBondEnableList; + + if (info == NULL) + { + return -EINVAL; + } + if (!bleBondEnableList) + { + ret = -ENOENT; + BLE_PRT("BLE_GapClearBondInfo: BondInfo empty %d\n", ret); + return ret; + } + + for(index = 0; index < BLE_SAVE_BOND_DEVICE_MAX_NUM; index++, list >>= 1) { + if (!(list & 1)) { + continue; + } + if(!memcmp(BondInfoInFlash[index].bondInfo.addr, info->addr, BLE_GAP_ADDR_LENGTH)) { + bleBondEnableList &= ~(1 << index); + break; + } + BLE_PRT("BLE_GapClearBondInfo: Type:%d Addr[%d]:%02X:%02X:%02X:%02X:%02X:%02X\n", + BondInfoInFlash[index].bondInfo.addrType, + index, + BondInfoInFlash[index].bondInfo.addr[5], + BondInfoInFlash[index].bondInfo.addr[4], + BondInfoInFlash[index].bondInfo.addr[3], + BondInfoInFlash[index].bondInfo.addr[2], + BondInfoInFlash[index].bondInfo.addr[1], + BondInfoInFlash[index].bondInfo.addr[0]); + } + BLE_PRT("BLE_GapClearBondInfo: new bleBondEnableList 0x%lx\n", bleBondEnableList); + if (index == BLE_SAVE_BOND_DEVICE_MAX_NUM) { + ret = -ENOENT; + BLE_PRT("BLE_GapSaveBondInfo: Not entry %d\n", ret); + return ret; + } + //BLE_PRT("BLE_GapClearBondInfo: enable_key 0x%x\n", bleKey.enable_key); + ret = BSO_SetRegistryValue(bleKey.enable_key, (const void*)&bleBondEnableList, sizeof(uint32_t)); + if(0 != ret) { + BLE_PRT("BLE_GapClearBondInfo: Set enable_key index %d NG %d\n", index, ret); + return ret; + } + BSO_Sync(); + return ret; +} + +int BLE_GapGetBondInfoIdList(BLE_GapBondInfoList *bondInfo) +{ + uint32_t list = bleBondEnableList; + + if (bondInfo == NULL) + { + return -EINVAL; + } + + bondInfo->bondNum = 0; + for(int index = 0; index < BLE_SAVE_BOND_DEVICE_MAX_NUM; index++, list >>= 1) + { + if (list & 1) + { + BLE_PRT("BLE_GapGetBondInfoIdList: exist index %d\n", index); + memcpy(bondInfo->bondInfoId[bondInfo->bondNum], + BondInfoInFlash[index].bondInfo.addr, BLE_GAP_ADDR_LENGTH); + bondInfo->bondNum++; + } + } + return 0; +} + +int BLE_GapEncrypt(BLE_GapConnHandle connHandle) +{ + int index; + uint32_t list = bleBondEnableList; + int errCode = 0; + if (gapMem.is_connected) { + for(index = 0; index < BLE_SAVE_BOND_DEVICE_MAX_NUM; index++, list >>= 1) { + if (!(list & 1)) { + continue; + } + if (BondInfoInFlash[index].bondInfo.addrType != gapMem.wrapperBondInfo.bondInfo.addrType) { + continue; + } + if(!memcmp(BondInfoInFlash[index].bondInfo.addr, + gapMem.wrapperBondInfo.bondInfo.addr, BLE_GAP_ADDR_LENGTH)) { + gapMem.wrapperBondInfo = BondInfoInFlash[index]; + break; + } + } + } + errCode = sd_ble_gap_encrypt(connHandle, + &gapMem.wrapperBondInfo.peerEncKey.master_id, &gapMem.wrapperBondInfo.peerEncKey.enc_info); + return bleConvertErrorCode((uint32_t)errCode); +} + +int BLE_GapStartRssi(BLE_GapConnHandle connHandle, uint8_t thresholdDbm, uint8_t skipCount) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + errCode = sd_ble_gap_rssi_start(connHandle, thresholdDbm, skipCount); + ret = bleConvertErrorCode((uint32_t)errCode); + if (ret == BLE_SUCCESS) { + gapMem.startRssi = true; + } + return ret; +} + +int BLE_GapStopRssi(BLE_GapConnHandle connHandle) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + errCode = sd_ble_gap_rssi_stop(connHandle); + ret = bleConvertErrorCode((uint32_t)errCode); + if (ret == BLE_SUCCESS) { + gapMem.startRssi = false; + } + return ret; +} + +int BLE_GapGetRssi(BLE_GapConnHandle connHandle, int8_t *rssi) +{ + int ret = BLE_SUCCESS; + + if (rssi == NULL) { + return -EINVAL; + } + if (gapMem.peerRssi == 0) { + return -EPERM; + } + if (gapMem.startRssi == false) { + return -EINVAL; + } + *rssi = gapMem.peerRssi; + return ret; +} + +int BLE_GapPhyUpdate(BLE_GapConnHandle connHandle, BLE_GapPhys *gapPhys) +{ + int ret = 0; + + if(gapPhys == NULL) { + return -EINVAL; + } + + ble_gap_phys_t phys; + phys.tx_phys = gapPhys->txPhy; + phys.rx_phys = gapPhys->rxPhy; + ret = sd_ble_gap_phy_update(connHandle, &phys); + return bleConvertErrorCode((uint32_t)ret); +} + +static +int getAddress(BLE_GapAddr *addr) +{ + int errCode = BLE_SUCCESS, ret = BLE_SUCCESS; + ble_gap_addr_t bleGapAddr = {0}; + + if(addr == NULL) { + return -EINVAL; + } + + errCode = sd_ble_gap_addr_get(&bleGapAddr); + ret = bleConvertErrorCode((uint32_t)errCode); + memcpy(addr->addr, bleGapAddr.addr, BLE_GAP_ADDR_LENGTH); + + return ret; +} + +static +int setAddress(BLE_GapAddr *addr) +{ + int errCode = 0, ret = 0; + ble_gap_addr_t bleGapAddr = {0}; + ble_gap_privacy_params_t privacy = {0}; + + if(addr == NULL) { + return -EINVAL; + } + switch( addr->type ) { + case BLE_GAP_ADDR_TYPE_PUBLIC: + bleGapAddr.addr_type = addr->type; + memcpy(bleGapAddr.addr, addr->addr, BLE_GAP_ADDR_LENGTH); + errCode = sd_ble_gap_addr_set(&bleGapAddr); + break; + case BLE_GAP_ADDR_TYPE_RANDOM_STATIC: + //default + break; + case BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE: + case BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE: + privacy.privacy_mode = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY; + privacy.private_addr_type = addr->type; + privacy.private_addr_cycle_s = 900; //sec + privacy.p_device_irk = NULL; + errCode = sd_ble_gap_privacy_set(&privacy); + break; + default: + return -EINVAL; + } + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +static +int getName(BLE_GapName *name) +{ + int errCode = BLE_SUCCESS, ret = BLE_SUCCESS; + + if(name == NULL) { + return -EINVAL; + } + errCode = sd_ble_gap_device_name_get(name->name, &name->size); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +static +int setName(BLE_GapName *name) +{ + int errCode = BLE_SUCCESS, ret = BLE_SUCCESS; + + if(name == NULL) { + return -EINVAL; + } + ble_gap_conn_sec_mode_t secMode = {0}; + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&secMode); + errCode = sd_ble_gap_device_name_set(&secMode, name->name, name->size); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +static +int setCustomBaseuuid(uint8_t uuid[]) +{ + int errCode = BLE_SUCCESS, ret = BLE_SUCCESS; + ble_uuid128_t *sdsBaseuuid = (ble_uuid128_t *)uuid; + uint8_t uuidType; + + if(uuid == NULL) { + return -EINVAL; + } + BLE_PRT("sd_ble_uuid_vs_add\n"); + errCode = sd_ble_uuid_vs_add(sdsBaseuuid, &uuidType); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_gattc.c b/sdk/modules/bluetooth/hal/nrf52/ble_gattc.c new file mode 100644 index 000000000..92bc7fe4b --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/ble_gattc.c @@ -0,0 +1,459 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/ble_gattc.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "ble.h" +#include "ble_err.h" +#include "ble_comm_internal.h" + +// #define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define BLE_PRT printf +#else +#define BLE_PRT(...) +#endif + +/****************************************************************************** + * externs + *****************************************************************************/ +extern int bleConvertErrorCode(uint32_t errCode); +extern bleCommMem commMem; +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +#define SRV_DISC_START_HANDLE 0x0001 + +/****************************************************************************** + * Private Function + *****************************************************************************/ + + +static int nrf52_ble_copy_uuid(BLE_Uuid *dest_uuid, BLE_UUID *src_uuid) +{ + int ret = BT_SUCCESS; + + if (!dest_uuid || !src_uuid) + { + BLE_PRT("UUID not allocated."); + return BT_FAIL; + } + + /* Create UUID for cypress HAL */ + + dest_uuid->type = src_uuid->type; + + switch (dest_uuid->type) + { + case BLE_UUID_TYPE_BASEALIAS_BTSIG: + case BLE_UUID_TYPE_BASEALIAS_VENDOR: + memcpy(&dest_uuid->value.baseAlias, &src_uuid->value.alias, sizeof(BLE_UUID_ALIAS)); + break; + + case BLE_UUID_TYPE_UUID128: + memcpy(&dest_uuid->value.uuid128, &src_uuid->value.uuid128, sizeof(BLE_UUID128)); + break; + + default: + BLE_PRT("UUID not specified."); + return BT_FAIL; + } + + return ret; +} + +/**************************************************************************** + * Name: nrf52_ble_add_service + * + * Description: + * Bluetooth LE GATT add service. + * Add service and get service handle ID. + * + ****************************************************************************/ + +static int nrf52_ble_add_service(struct ble_gatt_service_s *ble_gatt_service) +{ + int ret = BT_SUCCESS; + BLE_Uuid uuid; + + ret = nrf52_ble_copy_uuid(&uuid, &ble_gatt_service->uuid); + + if (ret != BT_SUCCESS) + { + BLE_PRT("Copy UUID failed."); + return BT_FAIL; + } + + /* Add service to cypress HAL */ + + ret = BLE_GattsAddService(BLE_GATTS_SRVTYP_PRIMARY, &uuid, &ble_gatt_service->handle); + + return ret; +} + +/**************************************************************************** + * Name: nrf52_ble_add_characteristic + * + * Description: + * Bluetooth LE GATT add characteristic.. + * Add characteristic to setvice and get handle ID. + * + ****************************************************************************/ + +static int nrf52_ble_add_characteristic(uint16_t serv_handle, struct ble_gatt_char_s *ble_gatt_char) +{ + int ret = BT_SUCCESS; + BLE_CharMeta char_meta; + BLE_GattsAttr char_value; + + BLE_SrvSds* srv_sds = &g_ble_context.ble_srv_sds; + BLE_GattsCharHandles *char_handle = &(srv_sds->char_ri_handle); + + + /* Setup char meta data */ + + memset(&char_meta, 0, sizeof(BLE_CharMeta)); + + memcpy(&char_meta.charPrope, &ble_gatt_char->property, sizeof(BLE_CHAR_PROP)); + + /* Setup char value data */ + + memset(&char_value, 0, sizeof(BLE_GattsAttr)); + + /* Setup char handle */ + + memset(char_handle, 0, sizeof(BLE_GattsCharHandles)); + + ret = nrf52_ble_copy_uuid(&char_value.valueUuid, &ble_gatt_char->uuid); + + if (ret != BT_SUCCESS) + { + BLE_PRT("Copy UUID failed."); + return BT_FAIL; + } + + char_value.attrValue = ble_gatt_char->value.data; + char_value.valueLen = ble_gatt_char->value.length; + char_value.attrPerm.readPerm = ble_gatt_char->value.attrPerm.readPerm; + char_value.attrPerm.writePerm = ble_gatt_char->value.attrPerm.writePerm; + + /* Add characteristic to cypress HAL */ + + ret = BLE_GattsAddCharacteristic(serv_handle, &char_meta, &char_value, char_handle); + + /* Copy handle ID to characteristic context */ + + ble_gatt_char->handle = char_handle->charHandle; + + return ret; +} + +/**************************************************************************** + * Name: nrf52_ble_write + * + * Description: + * Bluetooth LE GATT write response. + * Reply write request from client. + * + ****************************************************************************/ + +static int nrf52_ble_gatts_write(struct ble_gatt_char_s *ble_gatt_char, uint16_t handle) +{ + int ret = BT_SUCCESS; + + /* No operation (firmware will do) */ + + return ret; +} + +/**************************************************************************** + * Name: nrf52_ble_read + * + * Description: + * Bluetooth LE GATT read response. + * Reply read request from client. + * + ****************************************************************************/ + +static int nrf52_ble_gatts_read(struct ble_gatt_char_s *ble_gatt_char, uint16_t handle) +{ + int ret = BT_SUCCESS; + + /* No operation (firmware will do) */ + + return ret; +} + +/**************************************************************************** + * Name: nrf52_ble_notify + * + * Description: + * Bluetooth LE GATT notify response. + * Reply notify request from client. + * + ****************************************************************************/ + +static int nrf52_ble_notify(struct ble_gatt_char_s *ble_gatt_char, uint16_t handle) +{ + int ret = BT_SUCCESS; + BLE_GattsHandleValueNfyIndParams param = {0}; + int32_t size = (int32_t) ble_gatt_char->value.length; + + if (BLE_MAX_CHAR_SIZE >= size) + { + BLE_PRT("size=%ld\n",size); + BLE_PRT("ble_gatt_char->handle=%d\n", ble_gatt_char->handle); + BLE_PRT("ble_gatt_char->value.data=%.*s\n", size, ble_gatt_char->value.data); + param.type = BLE_GATT_NOTIFICATION; + param.attrHandle = ble_gatt_char->handle; + param.attrValData = ble_gatt_char->value.data; + param.attrValLen = size; + + ret = BLE_GattsHandleValueNfyInd(handle, ¶m); + + if (ret) + { + BLE_PRT("gatts handle value nfy/ind failed, ret=%d\n", ret); + } + } + else + { + BLE_PRT("outcoming data exceeds buffer length\n"); + } + + return ret; +} + +/**************************************************************************** + * Name: nrf52_ble_start_db_discovery + * + * Description: + * Bluetooth LE GATT client start attribute database discovery + * + ****************************************************************************/ + +static int nrf52_ble_start_db_discovery(uint16_t conn_handle) +{ + return BLE_GattcStartDbDiscovery(conn_handle); +} + +/**************************************************************************** + * Name: nrf52_ble_continue_db_discovery + * + * Description: + * Bluetooth LE GATT client continue attribute database discovery + * Continue discovery from start_handle + * + ****************************************************************************/ + +static int nrf52_ble_continue_db_discovery(uint16_t start_handle, uint16_t conn_handle) +{ + return BLE_GattcContinueDbDiscovery(conn_handle, start_handle); +} + +/**************************************************************************** + * Name: nrf52_ble_write + * + * Description: + * Bluetooth LE GATT client write request. + * Request GATT server to write attributes. + * + ****************************************************************************/ + +static int nrf52_ble_gattc_write(struct ble_gatt_char_s *ble_gatt_char, uint16_t handle) +{ + BLE_GattcWriteParams param = {0}; + + param.writeOp = (ble_gatt_char->property.writeWoResp ? BLE_GATTC_WRITE_CMD : BLE_GATTC_WRITE_REQ); + param.charValHandle = ble_gatt_char->handle; + param.charValLen = ble_gatt_char->value.length; + param.charValData = ble_gatt_char->value.data; + + return BLE_GattcWrite(handle, ¶m); +} + +/**************************************************************************** + * Name: nrf52_ble_read + * + * Description: + * Bluetooth LE GATT client read request. + * Request GATT server to read attributes. + * + ****************************************************************************/ + +static int nrf52_ble_gattc_read(struct ble_gatt_char_s *ble_gatt_char, uint16_t handle) +{ + BLE_GattcReadParams param = {0}; + + param.charValHandle = ble_gatt_char->handle; + + return BLE_GattcRead(handle, ¶m); +} + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +struct ble_hal_gatt_ops_s ble_hal_gatt_ops = +{ + .gatts.addService = nrf52_ble_add_service, + .gatts.addChar = nrf52_ble_add_characteristic, + .gatts.write = nrf52_ble_gatts_write, + .gatts.read = nrf52_ble_gatts_read, + .gatts.notify = nrf52_ble_notify, + .gattc.startDbDiscovery = nrf52_ble_start_db_discovery, + .gattc.continueDbDiscovery = nrf52_ble_continue_db_discovery, + .gattc.write = nrf52_ble_gattc_write, + .gattc.read = nrf52_ble_gattc_read +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + + +int BLE_GattcStartDbDiscovery(uint16_t connHandle) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + errCode = sd_ble_gattc_primary_services_discover(connHandle,SRV_DISC_START_HANDLE,NULL); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GattcContinueDbDiscovery(uint16_t connHandle, uint16_t startHandle) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + errCode = sd_ble_gattc_primary_services_discover(connHandle,startHandle,NULL); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +int BLE_GattcRead(uint16_t connHandle, BLE_GattcReadParams const *readParams) +{ +#define BLE_GATTC_READ_BUSY_CHECK_MAX 5 + int ret = BLE_SUCCESS; + int errCode = 0; + + if (readParams == NULL) { + return -EINVAL; + } + + for (int i=0; icharValHandle, 0); + if (errCode != NRF_ERROR_BUSY) { + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; + } + int msec = (commMem.gapMem->connParams.max_conn_interval * 1250 + (1000 - 1)) / 1000; + BLE_PRT("BLE_GattcRead: delay %d\n", msec); + usleep(msec * 1000); + } + return -EBUSY; +} + +int BLE_GattcWrite(uint16_t connHandle, BLE_GattcWriteParams const *writeParams) +{ +#define BLE_GATTC_TX_BUFFER_CHECK_MAX 5 + int ret = BLE_SUCCESS; + int errCode = 0; + ble_gattc_write_params_t gattcWriteParams = {0}; + + if (writeParams == NULL) { + return -EINVAL; + } + + memset(&gattcWriteParams,0,sizeof(gattcWriteParams)); + gattcWriteParams.handle = writeParams->charValHandle; + gattcWriteParams.len = writeParams->charValLen; + gattcWriteParams.p_value = writeParams->charValData; + gattcWriteParams.offset = 0; + if (writeParams->writeOp == BLE_GATTC_WRITE_CMD) { + gattcWriteParams.write_op = BLE_GATT_OP_WRITE_CMD; + } + else if (writeParams->writeOp == BLE_GATTC_WRITE_REQ) { + gattcWriteParams.write_op = BLE_GATT_OP_WRITE_REQ; + } + else { + return -EINVAL; + } + gattcWriteParams.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL; + for (int i=0; iconnParams.max_conn_interval * 1250 + (1000 - 1)) / 1000; + BLE_PRT("BLE_GattcWrite: delay %d\n", msec); + usleep(msec * 1000); + } + return -EBUSY; + +} + +int BLE_GattcConfirm(uint16_t connHandle, uint16_t attrHandle) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + + errCode = sd_ble_gattc_hv_confirm(connHandle, attrHandle); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} + +#ifdef BLE_ENABLE_NORDIC_ORIGINAL +int BLE_GattcRegisterUuid128(BLE_Uuid128* uuidBase, uint8_t* type) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + *type = BLE_UUID_TYPE_VENDOR_BEGIN; + errCode = sd_ble_uuid_vs_add((ble_uuid128_t *)uuidBase, type); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} +#endif diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_gatts.c b/sdk/modules/bluetooth/hal/nrf52/ble_gatts.c new file mode 100644 index 000000000..c792539ac --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/ble_gatts.c @@ -0,0 +1,328 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/ble_gatts.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "ble.h" +#include "ble_comm_internal.h" +#include + +// #define BLE_DBGPRT_ENABLE +#ifdef BLE_DBGPRT_ENABLE +#include +#define BLE_PRT printf +#else +#define BLE_PRT(...) +#endif + +/****************************************************************************** + * externs + *****************************************************************************/ +extern int bleConvertErrorCode(uint32_t errCode); +extern bleCommMem commMem; +/****************************************************************************** + * Define + *****************************************************************************/ + + /****************************************************************************** + * Structre define + *****************************************************************************/ + + /****************************************************************************** + * Function prototype declaration + *****************************************************************************/ + +/****************************************************************************** + * Function + *****************************************************************************/ +static int setPermission(ble_gap_conn_sec_mode_t *perm, BLE_SEC_MODE secMode) +{ + int ret = 0; + switch( secMode ) { + case BLE_SEC_MODE_NO_ACCESS: + BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(perm); + break; + case BLE_SEC_MODE1LV1_NO_SEC: + BLE_GAP_CONN_SEC_MODE_SET_OPEN(perm); + break; + case BLE_SEC_MODE1LV2_NO_MITM_ENC: + BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(perm); + break; + case BLE_SEC_MODE1LV3_MITM_ENC: + BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(perm); + break; + case BLE_SEC_MODE2LV1_NO_MITM_DATA_SGN: + BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(perm); + break; + case BLE_SEC_MODE2LV2__MITM_DATA_SGN: + BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(perm); + break; + default: + ret = -EINVAL; + break; + } + return ret; +} + +int BLE_GattsAddService(BLE_GATT_TYPE type, BLE_Uuid const* uuid, uint16_t* serviceHandle) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + ble_uuid_t uuidBaseAlias = {0}; + ble_uuid128_t *uuidBase = NULL; + uint8_t uuid16[2] = {0,0}; + + if((uuid == NULL) || (serviceHandle == NULL)) { + return -EINVAL; + } + + memset(&uuidBaseAlias, 0, sizeof(ble_uuid_t)); + switch( uuid->type ) { + case BLE_UUID_TYPE_BASEALIAS_BTSIG: + { + uuidBaseAlias.type = BLE_UUID_TYPE_BLE; + uuidBaseAlias.uuid = uuid->value.baseAlias.uuidAlias; + break; + } + case BLE_UUID_TYPE_BASEALIAS_VENDOR: + { + uuidBaseAlias.type = BLE_UUID_TYPE_VENDOR_BEGIN; + uuidBaseAlias.uuid = uuid->value.baseAlias.uuidAlias; + uuidBase = (ble_uuid128_t*)&uuid->value.baseAlias.uuidBase; + break; + } + case BLE_UUID_TYPE_UUID128: + { + uuidBaseAlias.type = BLE_UUID_TYPE_VENDOR_BEGIN; + //octecs 12-13 of 128-bit UUID,16bits + memcpy(uuid16, (uuid->value.uuid128.uuid128 + 12), sizeof(uuid16)); + uuidBaseAlias.uuid = (uuid16[1]<<8)|uuid16[0]; + uuidBase = (ble_uuid128_t*)&uuid->value.uuid128; + break; + } + default: + break; + } + if(uuidBase != NULL) { + errCode = sd_ble_uuid_vs_add(uuidBase, &uuidBaseAlias.type); + ret = bleConvertErrorCode((uint32_t)errCode); + if(ret) { + BLE_PRT("sd_ble_uuid_vs_add NG %d\n", ret); + return ret; + } + } + // Add the service. + errCode = sd_ble_gatts_service_add(type, &uuidBaseAlias, serviceHandle); + ret = bleConvertErrorCode((uint32_t)errCode); + if(ret) { + BLE_PRT("sd_ble_gatts_service_add NG %d\n", ret); + } + return ret; +} + +int BLE_GattsAddCharacteristic(uint16_t serviceHandle, BLE_CharMeta const* charMeta, BLE_GattsAttr const* attrCharValue, BLE_GattsCharHandles* handles) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + uint8_t uuid16[2] = {0,0}; + ble_uuid_t uuidBaseAlias = {0}; + ble_uuid128_t *uuidBase = NULL; + ble_gatts_char_md_t charMd = {0}; + ble_gatts_attr_t localAttrCharValue = {0}; + ble_uuid_t bleUuid = {0}; + ble_gatts_attr_md_t attrMd = {0}; + ble_gatts_attr_md_t cccdMd = {0}; + ble_gatts_attr_md_t sccdMd = {0}; + BLE_SEC_MODE noAccessMode = BLE_SEC_MODE_NO_ACCESS; + ble_gatts_char_handles_t charHandles = {0}; + + if( (charMeta == NULL) || (attrCharValue == NULL) || (attrCharValue->attrValue == NULL)) { + return -EINVAL; + } + + memset(&uuidBaseAlias, 0, sizeof(ble_uuid_t)); + memset(&cccdMd, 0, sizeof(cccdMd)); + memset(&sccdMd, 0, sizeof(sccdMd)); + memset(&attrMd, 0, sizeof(attrMd)); + memset(&charMd, 0, sizeof(charMd)); + memset(&localAttrCharValue, 0, sizeof(localAttrCharValue)); + memset(&bleUuid, 0, sizeof(bleUuid)); + memcpy(&charMd.char_props, &charMeta->charPrope, sizeof(ble_gatt_char_props_t)); + + charMd.p_sccd_md = NULL; + charMd.p_char_pf = NULL; + charMd.p_sccd_md = NULL; + charMd.p_char_user_desc = NULL; + charMd.p_user_desc_md = NULL; + + //to be tested readPerm not like sm lv + if((charMeta->clientCharCfgDpr.readPerm == noAccessMode )||(charMeta->clientCharCfgDpr.writePerm == noAccessMode )){ + charMd.p_cccd_md = NULL; + } else { + ret = setPermission(&cccdMd.read_perm, charMeta->clientCharCfgDpr.readPerm); + if (ret) { + return ret; + } + ret = setPermission(&cccdMd.write_perm, charMeta->clientCharCfgDpr.writePerm); + if (ret) { + return ret; + } + cccdMd.vloc = BLE_GATTS_VLOC_STACK; + charMd.p_cccd_md = &cccdMd; + } + + attrMd.rd_auth = 0; + attrMd.vlen = 1; + attrMd.vloc = BLE_GATTS_VLOC_STACK; + ret = setPermission(&attrMd.read_perm, attrCharValue->attrPerm.readPerm); + if (ret) { + return ret; + } + ret = setPermission(&attrMd.write_perm, attrCharValue->attrPerm.writePerm); + if (ret) { + return ret; + } + + localAttrCharValue.p_value = attrCharValue->attrValue; + localAttrCharValue.init_len = attrCharValue->valueLen; + localAttrCharValue.max_len = attrCharValue->valueLen; + localAttrCharValue.init_offs = 0; + localAttrCharValue.p_attr_md = &attrMd; + switch(attrCharValue->valueUuid.type){ + case BLE_UUID_TYPE_BASEALIAS_BTSIG: + { + uuidBaseAlias.type = BLE_UUID_TYPE_BLE; + uuidBaseAlias.uuid = attrCharValue->valueUuid.value.baseAlias.uuidAlias; + break; + } + case BLE_UUID_TYPE_BASEALIAS_VENDOR: + { + uuidBaseAlias.type = BLE_UUID_TYPE_VENDOR_BEGIN; + uuidBaseAlias.uuid = attrCharValue->valueUuid.value.baseAlias.uuidAlias; + uuidBase = (ble_uuid128_t*)&attrCharValue->valueUuid.value.baseAlias.uuidBase; + break; + } + case BLE_UUID_TYPE_UUID128: + { + uuidBaseAlias.type = BLE_UUID_TYPE_VENDOR_BEGIN; + //octecs 12-13 of 128-bit UUID,16bits + memcpy(uuid16,(attrCharValue->valueUuid.value.uuid128.uuid128+12),sizeof(uuid16)); + uuidBaseAlias.uuid = (uuid16[1]<<8)|uuid16[0]; + uuidBase = (ble_uuid128_t*)&attrCharValue->valueUuid.value.uuid128; + break; + } + default: + break; + } + if(uuidBase != NULL) { + errCode = sd_ble_uuid_vs_add(uuidBase, &uuidBaseAlias.type); + ret = bleConvertErrorCode((uint32_t)errCode); + } + if(ret != BLE_SUCCESS) { + return ret; + } + localAttrCharValue.p_uuid = &uuidBaseAlias; + errCode = sd_ble_gatts_characteristic_add(serviceHandle, &charMd, &localAttrCharValue, &charHandles); + ret = bleConvertErrorCode((uint32_t)errCode); + if(ret == BLE_SUCCESS) + { + handles->charHandle = charHandles.value_handle; + handles->dprHandle.cccdHandle = charHandles.cccd_handle; + handles->dprHandle.sccdHandle = charHandles.sccd_handle; + handles->dprHandle.userDescHandle = charHandles.user_desc_handle; + } + return ret; +} + +int BLE_GattsHandleValueNfyInd(uint16_t connHandle, BLE_GattsHandleValueNfyIndParams const* handleValueNfyInd) +{ +#define BLE_GATTS_TX_BUFFER_CHECK_MAX 5 + int ret = BLE_SUCCESS; + int errCode = 0; + uint16_t len = 0; + ble_gatts_hvx_params_t hvxParams = {0}; + + BLE_PRT("%s:connHandle :%d.\n", __func__, connHandle); + if( handleValueNfyInd == NULL) { + BLE_PRT("%s:handleValueNfyInd null.\n", __func__); + return -EINVAL; + } + + memset(&hvxParams, 0, sizeof(hvxParams)); + len = handleValueNfyInd->attrValLen; + hvxParams.handle = handleValueNfyInd->attrHandle; + hvxParams.type = handleValueNfyInd->type; + hvxParams.p_len = &len; + hvxParams.p_data = handleValueNfyInd->attrValData; + for (int i=0; iconnParams.max_conn_interval * 1250 + (1000 - 1)) / 1000; + BLE_PRT("BLE_GattsHandleValueNfyInd: delay %d\n", msec); + usleep(msec * 1000); + } + return -EBUSY; +} + +int BLE_GattsUpdateAttrValue(BLE_GattsAttrValueParam *attrValueParam) +{ + int ret = BLE_SUCCESS; + int errCode = 0; + ble_gatts_value_t gattsValue = {0}; + + if( attrValueParam == NULL) { + return -EINVAL; + } + + memset(&gattsValue, 0, sizeof(gattsValue)); + gattsValue.offset = 0; + gattsValue.len = attrValueParam->attrValLen; + gattsValue.p_value = attrValueParam->attrValData; + + errCode = sd_ble_gatts_value_set(attrValueParam->connHandle, attrValueParam->attrHandle, &gattsValue); + ret = bleConvertErrorCode((uint32_t)errCode); + return ret; +} diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.c b/sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.c new file mode 100644 index 000000000..c63f47a45 --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.c @@ -0,0 +1,403 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/bt_storage_manager.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include "queue.h" /* TODO: replace to nuttx/include/queue.h */ +#include "ble_storage_operations.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* +#define BSO_FILE_PATH "/var/hostif" + +#define BSO_FILE_PATH_NAME BSO_FILE_PATH"/%s" +#define BSO_REGISTRY_DB "bso_registry_db" +*/ +#define REGDB_VALUE_MAX 60 +#define REGDB_KEY_NAME_MAX 4 +/* +#define BSO_FILE_NAME_MAX 64 +#define BSO_FILE_PATH_MAX 128 +*/ +#define BITS_PER_BYTE 8 + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +#define FLAG_INITIALIZED (1ul << 0) + +#define BSO_REG_KEY_READONLY (1u << 15) +#define BSO_REG_KEY_ATTR_MASK (BSO_REG_KEY_READONLY) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +typedef struct BSO_REGDB_RECORD_Tag +{ + uint32_t key; + uint8_t value[REGDB_VALUE_MAX]; +} BSO_REGDB_RECORD; + +typedef struct BSO_REGDB_ENTRY +{ + TAILQ_ENTRY(BSO_REGDB_ENTRY) entry; + BSO_REGDB_RECORD record; +} BSO_REGDB_ENTRY; + +typedef struct BSO_CONTEXT_Tag +{ + uint32_t flags; + TAILQ_HEAD(, BSO_REGDB_ENTRY) regDbHead; +} BSO_CONTEXT; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static BSO_CONTEXT gBsoContext; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ +static int initRegistryDatabase(BSO_CONTEXT* ctx) +{ + TAILQ_INIT(&ctx->regDbHead); + + return 0; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: BSO_Init + * + * Description: + * Bluetooth Storage Operation Initialize. + * Open a bluetooth database file and check. + * + ****************************************************************************/ + + +int BSO_Init(void* data) +{ + (void)data; + int ret = 0; + BSO_CONTEXT* ctx = &gBsoContext; + + if (ctx->flags & FLAG_INITIALIZED) + { + return 0; + } + + ret = initRegistryDatabase(ctx); + + if (!ret) + { + ctx->flags |= FLAG_INITIALIZED; + } + + return ret; +} + +/**************************************************************************** + * Name: BSO_Sync + * + * Description: + * Bluetooth Storage Operation Sync. + * Sync a bluetooth database file between file and program. + * + ****************************************************************************/ + +void BSO_Sync(void) +{ + /* TODO: impl after persistent storage is ready */ +} + +/**************************************************************************** + * Name: BSO_Finalize + * + * Description: + * Bluetooth Storage Operation Finalize. + * Finalize a bluetooth database file operation. + * + ****************************************************************************/ + +int BSO_Finalize(void* data) +{ + (void)data; + int ret = 0; + + BSO_CONTEXT* ctx = &gBsoContext; + + if (!(ctx->flags & FLAG_INITIALIZED)) + { + return 0; + } + + ret = BSO_CleanRegistry(); + + ctx->flags = 0; + + return ret; +} + +/**************************************************************************** + * Name: BSO_GetRegistryValue + * + * Description: + * Bluetooth Storage Operation Get registoty value. + * Get a registry value by key. + * + ****************************************************************************/ + +int BSO_GetRegistryValue(uint32_t key, void* value, uint32_t size) +{ + BSO_CONTEXT* ctx = &gBsoContext; + BSO_REGDB_ENTRY* entry = NULL; + + if (!(ctx->flags & FLAG_INITIALIZED)) + { + return -ENXIO; + } + + if (size > REGDB_VALUE_MAX) + { + return -EINVAL; + } + + TAILQ_FOREACH(entry, &ctx->regDbHead, entry) + { + if (key == entry->record.key) + { + memcpy(value, entry->record.value, MIN(size, REGDB_VALUE_MAX)); + return 0; + } + } + + return -ENOENT; +} + +/**************************************************************************** + * Name: BSO_SetRegistryValueList + * + * Description: + * Bluetooth Storage Operation Set registoty value list. + * Set a registry value by list of key. + * + ****************************************************************************/ + +int BSO_SetRegistryValueList(BSO_KeyPair* list, uint32_t pairsNum) +{ + BSO_CONTEXT* ctx = &gBsoContext; + BSO_REGDB_ENTRY* entry = NULL; + uint32_t i = 0; + + if (!(ctx->flags & FLAG_INITIALIZED)) + { + return -ENXIO; + } + + if (!list) + { + return -EINVAL; + } + + for (i = 0; i < pairsNum; ++i, ++list) + { + if (list->size > REGDB_VALUE_MAX) + { + return -EINVAL; + } + + TAILQ_FOREACH(entry, &ctx->regDbHead, entry) + { + if (list->key == entry->record.key) + { + if (list->key & BSO_REG_KEY_READONLY) + { + return -EACCES; + } + + memcpy(entry->record.value, list->value, MIN(list->size, REGDB_VALUE_MAX)); + + break; + } + } + + if (!entry) + { + entry = (BSO_REGDB_ENTRY*)malloc(sizeof(BSO_REGDB_ENTRY)); + + if (!entry) + { + return -ENOSPC; + } + + memset(entry, 0, sizeof(BSO_REGDB_ENTRY)); + entry->record.key = list->key; + memcpy(entry->record.value, list->value, MIN(list->size, REGDB_VALUE_MAX)); + TAILQ_INSERT_TAIL(&ctx->regDbHead, entry, entry); + } + } + + return 0; +} + +/**************************************************************************** + * Name: BSO_SetRegistryValue + * + * Description: + * Bluetooth Storage Operation Set registoty value. + * Set a registry value by key. + * + ****************************************************************************/ + +int BSO_SetRegistryValue(uint32_t key, const void* value, uint32_t size) +{ + BSO_KeyPair kp = {key, value, size}; + return BSO_SetRegistryValueList(&kp, 1); +} + +/**************************************************************************** + * Name: BSO_DeleteRegistryKey + * + * Description: + * Bluetooth Storage Operation Delete registoty value. + * Delete a registry value by key. + * + ****************************************************************************/ + +int BSO_DeleteRegistryKey(uint32_t key) +{ + BSO_CONTEXT* ctx = &gBsoContext; + BSO_REGDB_ENTRY* entry = NULL; + + if (!(ctx->flags & FLAG_INITIALIZED)) + { + return -ENXIO; + } + + TAILQ_FOREACH(entry, &ctx->regDbHead, entry) + { + if (key == entry->record.key) + { + break; + } + } + + if (entry) + { + TAILQ_REMOVE(&ctx->regDbHead, entry, entry); + free(entry); + entry = NULL; + } + else + { + return -ENOENT; + } + + return 0; +} + +/**************************************************************************** + * Name: BSO_CleanRegistry + * + * Description: + * Bluetooth Storage Operation cleanup. + * Clean up a registry value. + * + ****************************************************************************/ + +int BSO_CleanRegistry(void) +{ + BSO_CONTEXT* ctx = &gBsoContext; + BSO_REGDB_ENTRY* entry = NULL; + + if (!(ctx->flags & FLAG_INITIALIZED)) + { + return -ENXIO; + } + + while (!TAILQ_EMPTY(&ctx->regDbHead)) + { + entry = TAILQ_FIRST(&ctx->regDbHead); + TAILQ_REMOVE(&ctx->regDbHead, entry, entry); + + free(entry); + entry = NULL; + } + + return 0; +} + +/**************************************************************************** + * Name: BSO_GenerateRegistryKey + * + * Description: + * Bluetooth Storage Operation generate registration key. + * Generate a registry key for set value. + * + ****************************************************************************/ + +uint32_t BSO_GenerateRegistryKey(const char* keyName, uint32_t attr) +{ + uint32_t key = 0; + uint32_t len = strnlen(keyName, REGDB_KEY_NAME_MAX); + uint32_t i = 0; + + for (i = 0; i < len; ++i) + { + key |= ((uint32_t)keyName[i] << (i * BITS_PER_BYTE)); + } + + key |= (attr & BSO_REG_KEY_ATTR_MASK); + + return key; +} diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.h b/sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.h new file mode 100644 index 000000000..03150b49d --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/ble_storage_operations.h @@ -0,0 +1,159 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/ble_storage_operations.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __MODULES_BLUETOOTH_HAL_NRF52_BT_STORAGE_OPERATION_H +#define __MODULES_BLUETOOTH_HAL_NRF52_BT_STORAGE_OPERATION_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +/**************************************************************************** + * Public Types + ****************************************************************************/ + +typedef struct BSO_KeyPair_Tag +{ + uint32_t key; + const void* value; + uint32_t size; +} BSO_KeyPair; + +// APIs should be called in a single thread, not thread safe +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: BSO_Init + * + * Description: + * Bluetooth Storage Operation Initialize. + * Open a bluetooth database file and check. + * + ****************************************************************************/ + +int BSO_Init(void* data); + +/**************************************************************************** + * Name: BSO_Sync + * + * Description: + * Bluetooth Storage Operation Sync. + * Sync a bluetooth database file between file and program. + * + ****************************************************************************/ + +void BSO_Sync(void); + +/**************************************************************************** + * Name: BSO_Finalize + * + * Description: + * Bluetooth Storage Operation Finalize. + * Finalize a bluetooth database file operation. + * + ****************************************************************************/ + +int BSO_Finalize(void* data); + +/**************************************************************************** + * Name: BSO_GetRegistryValue + * + * Description: + * Bluetooth Storage Operation Get registoty value. + * Get a registry value by key. + * + ****************************************************************************/ + +int BSO_GetRegistryValue(uint32_t key, void* value, uint32_t size); + +/**************************************************************************** + * Name: BSO_SetRegistryValueList + * + * Description: + * Bluetooth Storage Operation Set registoty value list. + * Set a registry value by list of key. + * + ****************************************************************************/ + +int BSO_SetRegistryValueList(BSO_KeyPair* list, uint32_t pairsNum); + +/**************************************************************************** + * Name: BSO_SetRegistryValue + * + * Description: + * Bluetooth Storage Operation Set registoty value. + * Set a registry value by key. + * + ****************************************************************************/ + +int BSO_SetRegistryValue(uint32_t key, const void* value, uint32_t size); + +/**************************************************************************** + * Name: BSO_DeleteRegistryKey + * + * Description: + * Bluetooth Storage Operation Delete registoty value. + * Delete a registry value by key. + * + ****************************************************************************/ + +int BSO_DeleteRegistryKey(uint32_t key); + +/**************************************************************************** + * Name: BSO_CleanRegistry + * + * Description: + * Bluetooth Storage Operation cleanup. + * Clean up a registry value. + * + ****************************************************************************/ + +int BSO_CleanRegistry(void); + +/**************************************************************************** + * Name: BSO_GenerateRegistryKey + * + * Description: + * Bluetooth Storage Operation generate registration key. + * Generate a registry key for set value. + * + ****************************************************************************/ + +uint32_t BSO_GenerateRegistryKey(const char* keyName, uint32_t attr); + +#endif /* __MODULES_BLUETOOTH_HAL_NRF52_BT_STORAGE_OPERATION_H */ diff --git a/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_comm.h b/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_comm.h new file mode 100644 index 000000000..f9a49ca9b --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_comm.h @@ -0,0 +1,266 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/include/ble/ble_comm.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file ble_comm.h + */ + +#ifndef __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_COMM_H +#define __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_COMM_H + +/** + * @defgroup BLE Bluetooth LE + * + * #include + * + * @{ + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/** + * @defgroup ble_defs Defines + * @{ + */ + +/** + *@name BLE firmware + *@{ + */ +#define FIRMWARE_NAME_BLE "bcm20706fw" /**< Firmware name for BLE*/ +/** @} */ + +/** + *@name BLE Work Role + *@{ + */ +#define BLE_ROLE_PERIPHERAL 0x00 /**< Peripheral role */ +#define BLE_ROLE_CENTRAL 0x01 /**< Central role */ +#define BLE_ROLE_PERIPHERAL_AND_CENTRAL 0x02 /**< Peripheral and Central role */ +/** @} */ + +/** + *@name Error Codes + *@{ + */ +#define BLE_SUCCESS 0x0000 /**< Successful command */ +/** @} */ + +/** + *@name BLE Event Base Number + *@{ + */ +#define BLE_EVENT_BASE 0x10 /**< Common BLE event base. */ +#define BLE_GAP_EVENT_BASE 0x30 /**< GAP BLE event base */ +#define BLE_GATTS_EVENT_BASE 0x60 /**< GATTS BLE event base */ +#define BLE_GATTC_EVENT_BASE 0x90 /**< GATTC BLE event base */ +/** @} */ + +/** + * @name DB Discovery Event Data size compensate value + * @{ + */ +/** + * A value to compensate for the event data size of the DB Discovery event + * exceeding the size of the data storage area of the evtData(in BLE_Evt structure) + * when the max value of service number is corrected from 3 to 7 + */ +#define BLE_GATTC_DB_DISCOVERY_EVT_SIZE_COMPENSATE 50 +/** @} */ + +/** + *@name Maximum Event Data Size + *@{ + */ +#define BLE_EVT_DAT_SIZE_MAX (BT_EVT_DATA_LEN + BLE_GATTC_DB_DISCOVERY_EVT_SIZE_COMPENSATE - 6) /**< Event max data size */ +/** @} */ + +/** @} ble_defs */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ +/** + * @defgroup ble_datatypes Data types + * @{ + */ + +/**@brief BLE event types + */ +typedef enum BLE_EventTypes_t +{ + BLE_EVENT_TX_COMPLETE = BLE_EVENT_BASE, /**< Transmission Complete. */ + BLE_GAP_EVENT_CONNECTED = BLE_GAP_EVENT_BASE, /**< Connection established, see @ref BLE_EvtConnected */ + BLE_GAP_EVENT_CONN_PARAM_UPDATE, /**< Connection parameters updated, see @ref BLE_EvtConnParamUpdate */ + BLE_GAP_EVENT_CONN_PARAM_UPDATE_REQUEST, /**< Connection Parameter Update Request, see @ref BLE_EvtConnParamUpdate */ + BLE_GAP_EVENT_DISCONNECTED, /**< Disconnected from peer, see @ref BLE_EvtDisconnected */ + BLE_GAP_EVENT_EXCHANGE_FEATURE, /**< Exchange pairing feature, see @ref BLE_EvtExchangeFeature */ + BLE_GAP_EVENT_DISPLAY_PASSKEY, /**< Display a passkey to user, see @ref BLE_EvtDisplayPasskey */ + BLE_GAP_EVENT_AUTH_STATUS, /**< Authentication procedure completed with status, see @ref BLE_EvtAuthStatus */ + BLE_GAP_EVENT_ADV_REPORT, /**< Advertising report, see @ref BLE_EvtAdvReportData */ + BLE_GAP_EVENT_AUTH_KEY_REQUEST, /**< Request to provide an authentication key, see @ref BLE_EvtAuthKey */ + BLE_GAP_EVENT_CONN_SEC_UPDATE, /**< Connection security updated */ + BLE_GAP_EVENT_TIMEOUT, /**< Operation is timeout, see @ref BLE_EvtTimeout */ + BLE_GAP_EVENT_RSSI_CHANGED, /**< RSSI report, see @ref BLE_EvtRssiChanged */ + BLE_GAP_EVENT_DATA_LENGTH_UPDATE, /**< Data Length Update. see @ref BLE_EvtDataLengthUpdate */ + BLE_GAP_EVENT_PHY_UPDATE_REQUEST, /**< PHY Update Request. Reply with @ref BLE_GapPhyUpdate. See @ref BLE_EvtPhyUpdate. */ + BLE_GAP_EVENT_PHY_UPDATE, /**< PHY Update Procedure is complete. See @ref BLE_EvtPhyUpdate. */ + BLE_GATTS_EVENT_WRITE = BLE_GATTS_EVENT_BASE, /**< Write operation performed for peer, see @ref BLE_EvtGattsWrite */ + BLE_GATTS_EVENT_CFM, /**< Confirmation event of indication operation, see @ref BLE_EvtGattsIndConfirm */ + BLE_GATTS_EVENT_SYS_ATTR_MISSING, /**< A persistent system attribute access is fail. Delete peer's bond info in GATT client and re-connect */ + BLE_GATTS_EVENT_TIMEOUT, /**< Timeout. see @ref BLE_EvtTimeout */ + BLE_GATTS_EVENT_EXCHANGE_MTU, /**< Exchange MTU request received, see @ref BLE_EvtGattsExchangeMTU */ + BLE_GATTC_EVENT_DBDISCOVERY = BLE_GATTC_EVENT_BASE, /**< Attribute database discovery event, see @ref BLE_EvtGattcDbDiscovery */ + BLE_GATTC_EVENT_READ, /**< Read characteristic response event, see @ref BLE_EvtGattcRead */ + BLE_GATTC_EVENT_WRITE_RSP, /**< Write characteristic response event, see @ref BLE_EvtGattcWriteRsp */ + BLE_GATTC_EVENT_NTFIND, /**< Notification/Indication event from GATT server, see @ref BLE_EvtGattcNtfInd */ +} BLE_EventTypes; + +/**@brief BLE initialize parameter + */ +typedef struct BLE_InitializeParams_t +{ + uint8_t role; /**< BLE device work role. Peripheral, central or peripheral & central. @ref BLE_ROLE_PERIPHERAL, @ref BLE_ROLE_CENTRAL, @ref BLE_ROLE_PERIPHERAL_AND_CENTRAL*/ + BT_FIRMWARE_INFO info; +} BLE_InitializeParams; + +/**@brief Event callback structure + */ +typedef struct BLE_Evt_t +{ + uint8_t opcode; + uint8_t group; + BLE_EventTypes evtHeader; /**< Event header */ + uint32_t evtDataSize; /**< Event data size */ + uint8_t evtData[BLE_EVT_DAT_SIZE_MAX]; /**< Event data */ +} BLE_Evt; + +typedef struct BLE_EvtTxComplete_t +{ + uint16_t connHandle; /**< Connection handle */ + uint8_t count; /**< Number of packets transmitted. */ + uint8_t role; /** + * + * @{ + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/** + * @defgroup ble_defs Defines + * @{ + */ + +#define BLE_GAP_ADDR_LENGTH 6 /**< BLE address length */ +#undef BLE_GAP_ADV_MAX_SIZE +#define BLE_GAP_ADV_MAX_SIZE 31 /**< Maximum size of advertising data in octets */ +#define BLE_GAP_SEC_KEY_LEN 16 /**< GAP Security Key Length */ +#define BLE_GAP_SEC_RAND_LEN 8 /**< GAP Security Random Number Length. */ +#define BLE_SAVE_BOND_DEVICE_MAX_NUM 8 /**< The maximum size of bonded devices. */ +#define BLE_CONN_HANDLE_INVALID 0xFFFF /**< The invalid connection handle value. */ + +/** + * @name Device Config Type + * @{ + */ +#define BLE_GAP_DEVICE_CONFIG_ADDR 1 /**< Config addr index, @ref BLE_GapAddr */ +#define BLE_GAP_DEVICE_CONFIG_NAME 2 /**< Config name index, @ref BLE_GapName */ +#define BLE_GAP_DEVICE_CONFIG_UUID 3 /**< Config UUID index (Not supported) */ +#define BLE_GAP_DEVICE_CONFIG_SERV_CHNG_ENABLE 4 /**< Config service change enable index */ +#define BLE_GAP_DEVICE_CONFIG_APPR_VALUE 5 /**< Config appearance value index, @ref BLE_GAP_APPEARANCE */ +#define BLE_GAP_DEVICE_CONFIG_PPCP_VALUE 6 /**< Config PPCP value index, @ref BLE_GapConnParams*/ +/** @} */ + +/** + * @name Address Mode + * @{ + */ +#define BLE_GAP_ADDR_MODE_MANUAL 0 /**< Address manual mode */ +#define BLE_GAP_ADDR_MODE_AUTO 1 /**< Address auto mode */ +/** @} */ + +/** + * @name Advertising Data Type + * @{ + */ +#define BLE_GAP_ADV_LE_LIMITED_DISC_MODE 0x01 /**< LE Limited Discoverable Mode */ +#define BLE_GAP_ADV_LE_GENERAL_DISC_MODE 0x02 /**< LE General Discoverable Mode */ +#define BLE_GAP_ADV_BR_EDR_NOT_SUPPORTED 0x04 /**< BR/EDR not supported */ +#define BLE_GAP_ADV_LE_BR_EDR_CONTROLLER 0x08 /**< Simultaneous LE and BR/EDR, Controller */ +#define BLE_GAP_ADV_LE_BR_EDR_HOST 0x10 /**< Simultaneous LE and BR/EDR, Host */ +/** @} */ + +/** + * @name Authentication Key Type + * @{ + */ +#define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key */ +#define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey */ +#define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data */ +/** @} */ + +/** + * @name Source of Timeout Event + * @{ + */ +#define BLE_GAP_TIMEOUT_ADVERTISING 0x00 /**< Advertising timeout */ +#define BLE_GAP_TIMEOUT_SECURITY_REQUEST 0x01 /**< Security request timeout */ +#define BLE_GAP_TIMEOUT_SCAN 0x02 /**< Scanning timeout */ +#define BLE_GAP_TIMEOUT_CONN 0x03 /**< Connection timeout */ +#define BLE_GATT_TIMEOUT_PROTOCOL 0x04 /**< ATT Protocol timeout. */ +/** @} */ + +/** + * @name Disconnction Reason + * @defgroup BLE_HCI_STATUS_CODES Bluetooth status codes + * @{ + */ +#define BLE_HCI_STATUS_CODE_SUCCESS 0x00 /**< Success */ +#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01 /**< Unknown BLE Command */ +#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02 /**< Unknown Connection Identifier */ +#define BLE_HCI_AUTHENTICATION_FAILURE 0x05 /**< Authentication Failure */ +#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06 /**< Pin or Key missing */ +#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07 /**< Memory Capacity Exceeded */ +#define BLE_HCI_CONNECTION_TIMEOUT 0x08 /**< Connection Timeout */ +#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C /**< Command Disallowed */ +#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12 /**< Invalid BLE Command Parameters */ +#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 /**< Remote User Terminated Connection */ +#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14 /**< Remote Device Terminated Connection due to low resources */ +#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15 /**< Remote Device Terminated Connection due to power off */ +#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16 /**< Local Host Terminated Connection */ +#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A /**< Unsupported Remote Feature */ +#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E /**< Invalid LMP Parameters */ +#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F /**< Unspecified Error */ +#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22 /**< LMP Response Timeout */ +#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24 /**< LMP PDU Not Allowed */ +#define BLE_HCI_INSTANT_PASSED 0x28 /**< Instant Passed */ +#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29 /**< Pairing with Unit Key Unsupported */ +#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A /**< Different Transaction Collision */ +#define BLE_HCI_CONTROLLER_BUSY 0x3A /**< Controller Busy */ +#define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B /**< Connection Interval Unacceptable */ +#define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C /**< Directed Adverisement Timeout */ +#define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D /**< Connection Terminated due to MIC Failure */ +#define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E /**< Connection Failed to be Established */ +/** @} */ + +/** + * @name Pairing Result Status Code + * @sa @ref BLE_GAP_EVENT_AUTH_STATUS + * @{ + */ +#define BLE_GAP_SM_STATUS_SUCCESS 0x00 /**< Procedure completed with success */ +#define BLE_GAP_SM_STATUS_TIMEOUT 0x01 /**< Procedure timed out */ +#define BLE_GAP_SM_STATUS_RESERVED 0x20 /**< Reserved */ +#define BLE_GAP_SM_STATUS_PASSKEY_ENTRY_FAILED 0x21 /**< Passkey entry failed */ +#define BLE_GAP_SM_STATUS_OOB_NOT_AVAILABLE 0x22 /**< Out of Band Key not available */ +#define BLE_GAP_SM_STATUS_AUTH_REQ 0x23 /**< Authentication requirements not met */ +#define BLE_GAP_SM_STATUS_CONFIRM_VALUE 0x24 /**< Confirm value failed */ +#define BLE_GAP_SM_STATUS_PAIRING_NOT_SUPP 0x25 /**< Pairing not supported */ +#define BLE_GAP_SM_STATUS_ENC_KEY_SIZE 0x26 /**< Encryption key size */ +#define BLE_GAP_SM_STATUS_CMD_NOT_SUPPORTED 0x27 /**< Unsupported SMP command */ +#define BLE_GAP_SM_STATUS_UNSPECIFIED_REASON 0x28 /**< Unspecified reason */ +#define BLE_GAP_SM_STATUS_REPEATED_ATTEMPTS 0x29 /**< Too little time elapsed since last attempt */ +#define BLE_GAP_SM_STATUS_INVALID_PARAMS 0x2A /**< Invalid parameters */ +/** @} */ + +/** + * @name Security Config Type Base + * @{ + */ +#define TYPE_SEC_CFG_BASE 0x60 /**< Define Security config type base */ +/** @} */ + +/** + * @name Encryption Key Size + * @{ + */ +#define BLE_GAP_MIN_KEY_SIZE 7 /**< Minimum encryption key size */ +#define BLE_GAP_MAX_KEY_SIZE 16 /**< Maximum encryption key size */ +/** @} */ + +/** + * @name Passkey Length + * @{ + */ +#define BLE_GAP_PASSKEY_LEN 6 /**< Passkey length 6 digits */ +/** @} */ + +/** + * @name Passkey Length + * @{ + */ +#define BLE_DID_INFO_LEN 4 /**< BLE DID info length */ +/** @} */ + +/** + * @name Advertising Type + * @{ + */ +#define ADV_DATA_TYPE_FLAGS 0x01 /**< Flags */ +#define ADV_DATA_TYPE_COMPLETE_16_UUIDS 0x03 /**< Complete List of 16-bit Service Class UUIDs */ +#define ADV_DATA_TYPE_COMPLETE_32_UUIDS 0x05 /**< Complete List of 32-bit Service Class UUIDs */ +#define ADV_DATA_TYPE_COMPLETE_128_UUIDS 0x07 /**< Complete List of 128-bit Service Class UUIDs */ +#define ADV_DATA_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete Local Name */ +#define ADV_DATA_TYPE_TX_POWER 0x0a /**< Tx power level */ +#define ADV_DATA_TYPE_SERVICE_DATA 0x16 /**< Service Data - 16-bit UUID */ +#define ADV_DATA_TYPE_MANUFACTURER_SPECIFIC_DATA 0xff /**< Manufacturer Specific Data */ +/** @} */ + +/** + * @name Tx power invalid value + * @{ + */ +#define ADV_DATA_TX_POWER_INVILID_VALUE 127 /**< Invalid value of tx power */ +/** @} */ + +/**@defgroup BLE_GAP_ADDR_TYPES GAP Address types + * @{ */ +#define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random Static address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Private Resolvable address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Private Non-Resolvable address. */ +/**@} */ + +/**@defgroup BLE_GAP_PHYS GAP PHYs + * @{ */ +#define BLE_GAP_PHY_AUTO 0x00 /**< Automatic PHY selection. */ +#define BLE_GAP_PHY_1MBPS 0x01 /**< 1 Mbps PHY. */ +#define BLE_GAP_PHY_2MBPS 0x02 /**< 2 Mbps PHY. */ +#define BLE_GAP_PHY_CODED 0x04 /**< Coded PHY. */ +/**@} */ + +/** @} ble_defs */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ +/** + * @defgroup ble_datatypes Data types + * @{ + */ + +/**@brief Passkey configure */ +enum +{ + SEC_CFG_PASSKEY = TYPE_SEC_CFG_BASE, /**< Security configura type passkey */ +}; + +/**@brief Out Of Band information*/ +typedef enum +{ + BLE_GAP_OOB_AUTH_DATA_NOT_PRESENT = 0, /**< Out of band not present */ + BLE_GAP_OOB_AUTH_DATA_PRESENT, /**< Out of band present */ +} BLE_GapOOB; + +/**@brief Authentication masks */ +enum BLE_GapAuthMask +{ + BLE_GAP_AUTH_NONE = 0, /**< Auth none */ + BLE_GAP_AUTH_BOND = (1 << 0), /**< Auth bond */ + BLE_GAP_AUTH_MITM = (1 << 1), /**< Auth mitm */ +}; + +/**@brief Authentication requirements */ +typedef enum +{ + BLE_GAP_AUTH_REQ_NO_MITM_NO_BOND = (BLE_GAP_AUTH_NONE), /**< No MITM No Bonding */ + BLE_GAP_AUTH_REQ_NO_MITM_BOND = (BLE_GAP_AUTH_BOND), /**< No MITM Bonding */ + BLE_GAP_AUTH_REQ_MITM_NO_BOND = (BLE_GAP_AUTH_MITM), /**< MITM No Bonding */ + BLE_GAP_AUTH_REQ_MITM_BOND = (BLE_GAP_AUTH_MITM | BLE_GAP_AUTH_BOND), /**< MITM and Bonding */ +} BLE_GapAuth; + +/**@brief GATT appearance definitions */ +typedef enum +{ + APPEARANCE_GENERIC_PHONE = 64, + APPEARANCE_GENERIC_COMPUTER = 128, + APPEARANCE_GENERIC_WATCH = 192, + APPEARANCE_WATCH_SPORTS = 193, + APPEARANCE_GENERIC_CLOCK = 256, + APPEARANCE_GENERIC_DISPLAY = 320, + APPEARANCE_GENERIC_REMOTE_CONTROL = 384, + APPEARANCE_GENERIC_EYE_GLASSES = 448, + APPEARANCE_GENERIC_TAG = 512, + APPEARANCE_GENERIC_KEYRING = 576, + APPEARANCE_GENERIC_MEDIA_PLAYER = 640, + APPEARANCE_GENERIC_BARCODE_SCANNER = 704, + APPEARANCE_GENERIC_THERMOMETER = 768, + APPEARANCE_THERMOMETER_EAR = 769, + APPEARANCE_GENERIC_HEART_RATE_SENSOR = 832, + APPEARANCE_HEART_RATE_BELT = 833, + APPEARANCE_GENERIC_BLOOD_PRESSURE = 896, + APPEARANCE_BLOOD_PRESSURE_ARM = 897, + APPEARANCE_BLOOD_PRESSURE_WRIST = 898, + APPEARANCE_GENERIC_HID_DEVICE = 960, + APPEARANCE_HID_KEYBOARD = 961, + APPEARANCE_HID_MOUSE = 962, + APPEARANCE_HID_JOYSTICK = 963, + APPEARANCE_HID_GAMEPAD = 964, + APPEARANCE_HID_DIGITIZER_TABLET = 965, + APPEARANCE_HID_CARD_READER = 966, + APPEARANCE_HID_DIGITAL_PEN = 967, + APPEARANCE_HID_BARCODE_SCANNER = 968, + APPEARANCE_GENERIC_GLUCOSE_METER = 1024, + APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR = 1088, + APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE = 1089, + APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE = 1090, + APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP = 1091, + APPEARANCE_GENERIC_CYCLING = 1152, + APPEARANCE_CYCLING_COMPUTER = 1153, + APPEARANCE_CYCLING_SPEED_SENSOR = 1154, + APPEARANCE_CYCLING_CADENCE_SENSOR = 1155, + APPEARANCE_CYCLING_POWER_SENSOR = 1156, + APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, +} BLE_GAP_APPEARANCE; + +/**@brief GAP set/get gap address paramters. */ +typedef struct BLE_GapAddr_t +{ + uint8_t mode; /**< Address mode (Not supported when you use nrf52 BLE chip module) */ + uint8_t type; /**< Address type, See @ref BLE_GAP_ADDR_TYPES. */ + uint8_t reserve[2]; /**< Reserve */ + uint8_t addr[BLE_GAP_ADDR_LENGTH]; /**< Address data, the size of the address is 48 bits */ +} BLE_GapAddr; + +/**@brief GAP set/get gap name parameters.*/ +typedef struct BLE_GapName_t +{ + uint16_t size; /**< The size of the gap name */ + uint8_t reserve[2]; /**< Reserve */ + uint8_t *name; /**< Pointer to gap name data */ + BLE_SEC_MODE pNameWritePerm; /**< Permission of name writable */ +} BLE_GapName; + +/**@brief GAP set/get device configuration information. */ +typedef struct BLE_GapDeviceConfig_t +{ + uint8_t type; /**< Types of configuration information, @ref Device Config Type */ + uint8_t reserve[3]; /**< Reserve */ + void *data; /**< Configuration data, @ref Device Config Type */ +} BLE_GapDeviceConfig; + +/**@brief Connection handler */ +typedef uint16_t BLE_GapConnHandle; + +/**@brief Advertising structure */ +typedef struct BLE_GapAdvStructure_t +{ + uint8_t advLength; /**< The size of the advertising structure */ + uint8_t reserve[3]; /**< Reserve */ + uint8_t *advData; /**< advertising structure data */ +} BLE_GapAdvStructure; + +/**@brief Advertising data structure */ +typedef struct BLE_GapAdvData_t +{ + uint8_t flags; /**< Flags */ + int8_t txPower; /**< Range -127 ~ 127 dBm, the tx power isn't added into advertise data when value is ADV_DATA_TX_POWER_INVILID_VALUE */ + uint16_t complete16Uuid; /**< Complete List of 16-bit Service Class UUIDs */ + uint32_t complete32Uuid; /**< Complete List of 32-bit Service Class UUIDs */ + uint8_t *complete128Uuid; /**< Complete List of 128-bit Service Class UUIDs */ + BLE_GapAdvStructure completeLocalName; /**< Complete Local Name */ + BLE_GapAdvStructure manufacturerSpecificData; /**< Manufacturer Specific Data */ + BLE_GapAdvStructure* serviceData; /**< Array of Service data structures. */ + uint8_t serviceDataCount; /**< Number of Service data structures. */ +} BLE_GapAdvData; + +/**@brief Advertising parameters */ +typedef struct BLE_GapAdvParams_t +{ + uint32_t interval; /**< Advertising interval in 625 us units. (0x000020 ~ 0x004000) */ + uint16_t duration; /**< Advertising duration in 10 ms units. */ + uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising channel packets are transmitted. The PHY is @ref BLE_GAP_PHYS. */ + uint8_t reserve; /**< Reserve */ +} BLE_GapAdvParams; + +/**@brief Scan parameters */ +typedef struct +{ + uint8_t active; /**< If 1, perform active scanning (scan requests). */ + uint16_t interval; /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s), return error if out of range. */ + uint16_t window; /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s), return error if out of range. */ + uint16_t timeout; /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout, return error if out of range. */ + uint8_t scan_phys; /**< Indicates the PHYs to scan on. The PHY is @ref BLE_GAP_PHYS. */ + int8_t tx_power; /**< Radio transmit power in dBm. */ +} BLE_GapScanParams; + +/**@brief Passkey configure, Config Type: @ref SEC_CFG_PASSKEY + */ +typedef struct +{ + char *passkey; /**< Pointer to passkey. The passkey is numeric value. Valid values are decimal 000000 - 999999.*/ +} BLE_GapSecCfgPasskey; + +/**@brief Security configure type */ +typedef struct +{ + uint32_t type; /**< The type of security configuration */ + void *data; /**< Security configure data, the following data structure is supported now: @ref BLE_GapSecCfgPasskey */ +} BLE_GapSecCfg; + +/**@brief Pairing Feature structure */ +typedef struct +{ + BLE_GAP_IO_CAP ioCap; /**< IO capabilities */ + BLE_GapOOB oob; /**< Out Of Band information */ + BLE_GapAuth authReq; /**< Authentication requirements */ + uint8_t minKeySize; /**< Minimum encryption key size in octets between 7 and 16 */ + uint8_t maxKeySize; /**< Maximum encryption key size in octets between min_key_size and 16 */ +} BLE_GapPairingFeature; + +/**@brief Authentication key structure */ +typedef struct +{ + BLE_GapConnHandle handle; /**< Connection handle */ + uint8_t keyType; /**< Authentication key type, the following three GAP authentication key types are supported: @ref BLE_GAP_AUTH_KEY_TYPE_NONE, @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY, @ref BLE_GAP_AUTH_KEY_TYPE_OOB */ + uint8_t keyLen; /**< The size of authentication key */ + uint8_t *key; /**< Authentication key */ +} BLE_GapAuthKey; + +/**@brief Bond information. */ +typedef struct +{ + uint8_t addrType; /**< See @ref BLE_GAP_ADDR_TYPES. */ + uint8_t addr[BLE_GAP_ADDR_LENGTH]; /**< 48-bit address, LSB format. */ +} BLE_GapBondInfo; + +/**@brief Bonded information list structure. */ +typedef struct +{ + uint32_t bondNum; + uint8_t bondInfoId[BLE_SAVE_BOND_DEVICE_MAX_NUM][BLE_GAP_ADDR_LENGTH]; + uint8_t didInfo[BLE_SAVE_BOND_DEVICE_MAX_NUM][BLE_DID_INFO_LEN]; /**< BLE DID information, please ref@ BT_DID_VendorInfo*/ +} BLE_GapBondInfoList; + +/**@brief Connection parameters */ +typedef struct +{ + uint16_t minConnInterval; /**< Minimum Connection Interval in 1.25 ms units. (7.5ms - 4s) */ + uint16_t maxConnInterval; /**< Maximum Connection Interval in 1.25 ms units. (7.5ms - 4s) */ + uint16_t slaveLatency; /**< Slave Latency in number of connection events. (max 499) */ + uint16_t connSupTimeout; /**< Connection Supervision Timeout in 10 ms unit. (100ms - 32s) */ +} BLE_GapConnParams; + +typedef struct +{ + uint8_t txPhy; /**< Preferred transmit PHYs, see @ref BLE_GAP_PHYS. */ + uint8_t rxPhy; /**< Preferred receive PHYs, see @ref BLE_GAP_PHYS. */ +} BLE_GapPhys; + +/**@brief Connection established + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_CONNECTED, and the member evtData is point to @ref BLE_EvtGapConnected_t structure. + */ +typedef struct BLE_EvtGapConnected_t +{ + BLE_GapConnHandle handle; /**< Connection handle */ + BLE_GapAddr addr; /**< Bluetooth address of the peer device */ + uint8_t role; /**< BLE role for this connection */ +} BLE_EvtConnected; + +/**@brief Connection parameters updated + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_CONN_PARAM_UPDATE, and the member evtData is point to @ref BLE_EvtConnParamUpdate structure. + */ +typedef struct +{ + uint8_t status; /**< Connection parameters update status */ + BLE_GapConnParams connParams; /**< Connection parameters */ +} BLE_EvtConnParamUpdate; + +/**@brief peer device MTU event, + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_CONN_PEER_MTU, and the member evtData is point to @ref BLE_EvtPeerMtu structure. + */ + +/**@brief Disconnected from peer + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_DISCONNECTED, and the member evtData is point to @ref BLE_EvtGapDisconnected_t structure. + */ +typedef struct BLE_EvtGapDisconnected_t +{ + BLE_GapConnHandle handle; /**< Connection handle */ + uint8_t reason; /**< Disconnected reason */ +} BLE_EvtDisconnected; + +/**@brief Exchange pairing feature event, it contains peer device’s pairing feature. + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_EXCHANGE_FEATURE, and the member evtData is point to @ref BLE_EvtExchangeFeature structure. + */ +typedef struct +{ + BLE_GapConnHandle handle; /**< Connection handle */ + BLE_GapPairingFeature peerFeature; /**< Pairing feature */ +} BLE_EvtExchangeFeature; + +/**@brief Pairing result event. + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_AUTH_STATUS, and the member evtData is point to @ref BLE_EvtAuthStatus structure. + */ +typedef struct +{ + BLE_GapConnHandle handle; /**< Connection handle */ + uint8_t status; /**< Pairing result event */ + uint8_t reserve; /**< Reserver */ + BLE_GapBondInfo bondInfo; /**< Bond information */ +} BLE_EvtAuthStatus; + +/**@brief Display passkey event structure + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_DISPLAY_PASSKEY, and the member evtData is point to @ref BLE_EvtDisplayPasskey structure. + */ +typedef struct +{ + BLE_GapConnHandle handle; /**< Connection handle */ + uint8_t passkey[BLE_GAP_PASSKEY_LEN+1]; /**< 6-digit passkey ASCII 000000~999999 + 0x00 */ +} BLE_EvtDisplayPasskey; + +/**@brief Advertising report event structure + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_ADV_REPORT, and the member evtData is point to @ref BLE_EvtAdvReportData structure. + */ +typedef struct +{ + int8_t rssi; /**< Received Signal Strength Indication in dBm. */ + uint8_t scan_rsp; /**< If 1, the report corresponds to a scan response */ + uint8_t dlen; /**< Scan response data length */ + uint8_t data[BLE_GAP_ADV_MAX_SIZE]; /**< Scan response data */ + BLE_GapAddr addr; /**< Bluetooth address of the peer device */ +} BLE_EvtAdvReportData; + +/**@brief Request to provide an authentication key event structure + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_AUTH_KEY_REQUEST, and the member evtData is point to @ref BLE_EvtAuthKey structure. + */ +typedef struct +{ + BLE_GapConnHandle handle; /**< Connection handle */ + uint8_t keyType; /**< GAP authentication key types */ + uint8_t reserve; /**< Reserver */ +} BLE_EvtAuthKey; + +/**@brief Event structure for @ref BLE_GAP_EVENT_TIMEOUT + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_TIMEOUT, and the member evtData is point to @ref BLE_EvtTimeout structure. + */ +typedef struct +{ + BLE_GapConnHandle handle; /**< Connection handle */ + uint8_t timeoutSrc; /**< Timeout reason, The following four timeout reasons are supported: @ref BLE_GAP_TIMEOUT_ADVERTISING, @ref BLE_GAP_TIMEOUT_SECURITY_REQUEST, @ref BLE_GAP_TIMEOUT_SCAN, @ref BLE_GAP_TIMEOUT_CONN */ + uint8_t reserve; /**< Reserver */ +} BLE_EvtTimeout; + +/**@brief RSSI change report event structure + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_RSSI_CHANGED, and the member evtData is point to @ref BLE_EvtRssiChanged structure. + */ +typedef struct +{ + BLE_GapConnHandle handle; /**< Connection handle */ + int8_t rssi; /**< Received Signal Strength Indication in dBm. */ +} BLE_EvtRssiChanged; + +/**@brief Event structure for @ref BLE_GAP_EVENT_DATA_LENGTH_UPDATE + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_DATA_LENGTH_UPDATE, and the member evtData is point to @ref BLE_EvtDataLengthUpdate structure. + */ +typedef struct +{ + uint16_t maxTx; /**< Maximum number of payload octets that a Controller supports for transmission of a single Link Layer Data Channel PDU. */ + uint16_t maxRx; /**< Maximum number of payload octets that a Controller supports for reception of a single Link Layer Data Channel PDU. */ + uint16_t maxTxTime; /**< Maximum time, in microseconds, that a Controller supports for transmission of a single Link Layer Data Channel PDU. */ + uint16_t maxRxTime; /**< Maximum time, in microseconds, that a Controller supports for reception of a single Link Layer Data Channel PDU. */ +} BLE_EvtDataLengthUpdate; + +/**@brief Event Structure for @ref BLE_GAP_EVENT_PHY_UPDATE_REQEST and @ref BLE_GAP_EVENT_PHY_UPDATE + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GAP_EVENT_PHY_UPDATE_REQEST and @ref BLE_GAP_EVENT_PHY_UPDATE, and the member evtData is point to @ref BLE_EvtPhyUpdate structure. +*/ +typedef struct +{ + uint8_t status; /**< Status of the procedure, see @ref BLE_HCI_STATUS_CODES.*/ + uint8_t txPhy; /**< TX PHY for this connection, see @ref BLE_GAP_PHYS. */ + uint8_t rxPhy; /**< RX PHY for this connection, see @ref BLE_GAP_PHYS. */ +}BLE_EvtPhyUpdate; + + + +/** @} ble_datatypes */ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/** + * @defgroup ble_funcs Functions + * @{ + */ + +/**@brief Get device configuration information + * @details This call allows the application to get the device information. + * + * @param[out] deviceConfig: Pointer to device config structure to be filled in, UUID type is not supported. + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapGetDeviceConfig(BLE_GapDeviceConfig *deviceConfig); + +/**@brief Set device configuration information. + * @details This call allows the application to set device configuration information. + * + * @param[in] deviceConfig: Pointer to config structure + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapSetDeviceConfig(BLE_GapDeviceConfig *deviceConfig); + +/**@brief Set, clear or update advertising data + * @details This call allows the application to set, clear or update advertising data. + * Invalid data is not set or updated. + * + * @param[in] advData: Raw data to be placed in advertising packet + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * @note This function should be called before @ref BLE_GapStartAdv(). + */ +int BLE_GapSetAdvData(BLE_GapAdvData *advData); + +/**@brief Start advertising + * @details This call allows the application to start advertising, must be called after @ref BLE_GapSetAdvData(), when first call this function. The advertisement timeout interval is 180 seconds. + * + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapStartAdv(void); + +/**@brief Start advertising + * @details This call allows the application to start advertising, must be called after @ref BLE_GapSetAdvData(), when first call this function. + * + * @param[in] advParams: Advertising parameters. + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapStartAdvExt(BLE_GapAdvParams *advParams); + +/**@brief Stop advertising + * @details This call allows the application to stop advertising (GAP discoverable, connectable modes, broadcast procedure). + * + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapStopAdv(void); + +/**@brief Disconnect(GAP link termination) + * @details This call initiates the disconnection procedure. The following events may be triggered: @ref BLE_GAP_EVENT_DISCONNECTED. + * @param[in] connHandle: Connection handle + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapDisconnectLink(BLE_GapConnHandle connHandle); + +/**@brief Set Security Configure Parameter + * + * @param[in] param: Security related configure parameter + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapSetSecParam(BLE_GapSecCfg *param); + +/**@brief Exchange pairing feature + * @details This call exchanges the pairing feature between pairing initiator and responder.The following events may be triggered: @ref BLE_GAP_EVENT_DISPLAY_PASSKEY, @ref BLE_GAP_EVENT_AUTH_STATUS. + * + * @param[in] connHandle: Connection handle + * @param[in] pairingFeature: Pairing feature exchanged in pairing phase 1 + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapExchangePairingFeature(BLE_GapConnHandle connHandle, BLE_GapPairingFeature *pairingFeature); + +/**@brief Set scan parameter + * @details This call allows the application to set scan paramter, use the default scan parameter + * (interval:200, window:20, timeout:60) if the call of this API is failed or not call this API. + * This call shall be called before API BLE_CommonInitializeStack() + * + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapSetScanParam(BLE_GapScanParams *scanParam); + +/**@brief Start scanning + * @details This call allows the application to start scanning. The scanning timeout interval is 60 seconds.The following events may be triggered: @ref BLE_GAP_EVENT_TIMEOUT, @ref BLE_GAP_EVENT_ADV_REPORT. + * + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapStartScan(void); + +/**@brief Start scanning + * @details This call allows the application to start scanning. The following events may be triggered: @ref BLE_GAP_EVENT_TIMEOUT, @ref BLE_GAP_EVENT_ADV_REPORT. + * @param[in] scanParam: Pointer to scan parameters + * + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapStartScanExt(BLE_GapScanParams *scanparams); + +/**@brief Stop scanning + * + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapStopScan(void); + +/**@brief Create a connection + * @details This call allows the application to create a connection. The following events may be triggered: @ref BLE_GAP_EVENT_CONNECTED. + * @param[in] addr: Pointer to peer address + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapConnect(BLE_GapAddr *addr); + +/**@brief Update connection paramters + * @details This call allows to update connection parameters. The following events may be triggered: @ref BLE_GAP_EVENT_CONNECTED. + * @param[in] connHandle: Connection handle + * @param[in] connParam: Pointer to connection parameters + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapUpdateConnectionParams(BLE_GapConnHandle connHandle, BLE_GapConnParams *connParams); + +/**@brief Cancel a connection establishment + * + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapCancelConnecting(void); + +/**@brief Initiate the GAP authentication procedure + * @details This call allows the application to send a SMP Pairing Request.The following events may be triggered: @ref BLE_GAP_EVENT_EXCHANGE_FEATURE. + * + * @param[in] connHandle: Connection handle + * @param[in] pairingFeature: Pointer to authenticate parameters + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapAuthenticate(BLE_GapConnHandle connHandle, BLE_GapPairingFeature *pairingFeature); + +/**@brief Reply with GAP security parameters + * @details This call allows the application to reply security parameters. The following events may be triggered: @ref BLE_GAP_EVENT_AUTH_KEY_REQUEST, @ref BLE_GAP_EVENT_CONN_SEC_UPDATE, @ref BLE_GAP_EVENT_AUTH_STATUS. + * + * @param[in] connHandle: Connection handle + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapReplyPairingFeature(BLE_GapConnHandle connHandle); + +/**@brief Reply with an authentication key + * @details This call allows the application to reply with an authentication key.The following events may be triggered: @ref BLE_GAP_EVENT_AUTH_KEY_REQUEST, @ref BLE_GAP_EVENT_CONN_SEC_UPDATE, @ref BLE_GAP_EVENT_AUTH_STATUS. User must make sure that the value of keyType in param--authKey is the same with the value which is passed by event handler when event--BLE_GAP_EVNET_AUTH_KEY_REQUEST happens. + * + * @param[in] authKey: Pointer to authentication key data + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapReplyAuthKey(BLE_GapAuthKey *authKey); + +/**@brief Save the boned peer device information + * @details This call allows the application to save the bonded information of peer device. + * + * @param[in] info: Bonded information + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * @note This function should be called after @ref BLE_GAP_EVENT_AUTH_STATUS. By the event, user can get bonded imformation. + */ +int BLE_GapSaveBondInfo(BLE_GapBondInfo *info); + +/**@brief Clear the boned peer device information + * @details This call allows the application to clear the bonded information of peer device. + * + * @param[in] info: Bonded information, must be existing bond info. + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapClearBondInfo(BLE_GapBondInfo *info); + +/**@brief Get bond information ID list + * @details This call allows the application to get bond information ID list. + * + * @param[out] bondInfo: Bonded information list structure + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapGetBondInfoIdList(BLE_GapBondInfoList *bondInfo); + +/**@brief Encrypt connection link + * @details This call allows the application to encrypt link.The following events may be triggered: @ref BLE_GAP_EVENT_CONN_SEC_UPDATE, @ref BLE_GAP_EVENT_DISCONNECTED. Before calling this API, user must make sure that the key value, which generated by BLE_GapSaveBondInfo, have been stored in flash. + * + * @param[in] connHandle: Connection handle + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapEncrypt(BLE_GapConnHandle connHandle); + +/**@brief Start reporting the received signal strength + * @details This call allows the application to start reporting RSSI.The following events may be triggered: @ref BLE_GAP_EVENT_RSSI_CHANGED. + * + * @param[in] connHandle: Connection handle + * @param[in] thresholdDbm: Minimum change in dBm before triggering @ref BLE_GAP_EVENT_RSSI_CHANGED + * @param[in] skipCount: Number of RSSI samples with a change of thresholdDbm or more before sending a new @ref BLE_GAP_EVENT_RSSI_CHANGED event + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapStartRssi(BLE_GapConnHandle connHandle, uint8_t thresholdDbm, uint8_t skipCount); + +/**@brief Stop reporting the received signal strength + * @details This call allows the application to stop reporting RSSI. + * + * @param[in] connHandle: Connection handle + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapStopRssi(BLE_GapConnHandle connHandle); + +/**@brief Get signal strength + * @details This call allows the application to get the received signal strength for the last connection event. @ref BLE_GapStartRssi must be called to start reporting RSSI before using this function. + * + * @param[in] connHandle: Connection handle + * @param[out] rssi: Pointer to the location where the RSSI measurement shall be stored + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapGetRssi(BLE_GapConnHandle connHandle, int8_t *rssi); + +/**@brief Initiate or respond to a PHY Update Procedure + * @details This function only is supported when you use nrf52 BLE chip module. + * @details This function is used to initiate or respond to a PHY Update Procedure. It will always generate a @ref BLE_GAP_EVENT_PHY_UPDATE event if successfully executed. + * + * @param[in] connHandle: Connection handle + * @param[in] gapPhys: Phy update paramters + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GapPhyUpdate(BLE_GapConnHandle connHandle, BLE_GapPhys *gapPhys); + +/** @} ble_funcs */ + +/** @} ble_gap */ +#endif /* __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_GAP_H */ diff --git a/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gattc.h b/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gattc.h new file mode 100644 index 000000000..130479b6f --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gattc.h @@ -0,0 +1,338 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/include/ble/ble_gattc.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file ble_gattc.h + */ + +#ifndef __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_GATTC_H +#define __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_GATTC_H + +/** + * @defgroup BLE Bluetooth LE GATT client + * + * #include + * + * @{ + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/** + * @defgroup ble_defs Defines + * @{ + */ + +// #define BLE_DB_DISCOVERY_MAX_SRV 10 /**< Support Max services */ +#define BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV 4 /**< Support Max characteristics per service */ +#ifdef CONFIG_BCM20707 +#define MAX_VAL_DATA_LENGTH 512 /**< Max value data length. */ +#elif defined(CONFIG_BLUETOOTH_NRF52) +#define MAX_VAL_DATA_LENGTH 247 /**< Max receive data length. */ +#else +#define MAX_VAL_DATA_LENGTH 20 /**< Max value data length. */ +#endif + +/** + * @name GATT Client DB Discovery Result Code + * @{ + * @sa @ref BLE_GATTC_EVENT_DBDISCOVERY + */ +#define BLE_GATTC_RESULT_SUCCESS 0x00 /**< GATTC attribute database discovery success */ +#define BLE_GATTC_RESULT_FAILED 0x01 /**< GATTC attribute database discovery failed */ +/** @} */ + +/** + * @name GATT Client DB Discovery Reason Code + * @{ + * @sa @ref BLE_GATTC_EVENT_DBDISCOVERY + */ +#define BLE_GATTC_REASON_SERVICE 0x01 /**< GATTC db discovery failed reason: service discovery failed */ +#define BLE_GATTC_REASON_CHARACTERISTIC 0x02 /**< GATTC db discovery failed reason: characteristic discovery failed */ +#define BLE_GATTC_REASON_DESCRIPTOR 0x03 /**< GATTC db discovery failed reason: descriptor discovery failed */ +/** @} */ + +/** @} ble_defs */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ +/** + * @defgroup ble_datatypes Data types + * @{ + */ + +/**@brief BLE write operation */ +typedef enum +{ + BLE_GATTC_WRITE_CMD = 0, + BLE_GATTC_WRITE_REQ +} BLE_GATTC_WRITE_OP; + +/**@brief GATTC handle range structure*/ +typedef struct +{ + uint16_t startHandle; /**< Start handle */ + uint16_t endHandle; /**< End handle */ +} BLE_GattcHandleRange; + +/**@brief GATTC characteristic structure*/ +typedef struct +{ + BLE_CHAR_PROP charPrope; /**< Characteristic property */ + uint8_t reserve; /**< Reserve */ + uint16_t charValhandle; /**< Characteristic value handle */ + uint16_t charDeclhandle; /**< Characteristic declaration handle */ + BLE_Uuid charValUuid; /**< Characteristic value uuid */ +} BLE_GattcChar; + +/**@brief GATTC discovered characteristic data structure + */ +typedef struct +{ + uint16_t cccdHandle; /**< Handle of client configuration characteristic descriptor in characteristic */ + uint8_t reserve[2]; /**< Reserve */ + BLE_GattcChar characteristic; /**< Characteristic information */ +} BLE_GattcDbDiscChar; + +/**@brief GATTC discovered service data structure + */ +typedef struct +{ + uint8_t charCount; /**< Discovered characteristic count in service */ + uint8_t reserve[3]; /**< Reserve */ + BLE_GattcHandleRange srvHandleRange; /**< The handle range of this service */ + BLE_GattcDbDiscChar characteristics[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV]; /**< Discovered characteristics in this service */ + BLE_Uuid srvUuid; /**< UUID of discovered service */ +} BLE_GattcDbDiscSrv; + +/**@brief GATTC discovered attribute database data structure + */ +typedef struct +{ + uint8_t srvCount; /**< Discovered services count */ + uint8_t reserve; /**< Reserve */ + uint16_t connHandle; /**< Connection handle */ + BLE_GattcDbDiscSrv services[BLE_DB_DISCOVERY_MAX_SRV]; /**< Discovered services in attribute database */ +} BLE_GattcDbDiscovery; + +/**@brief GATTC read parameters */ +typedef struct +{ + uint16_t charValHandle; /**< Characteristic value handle */ +} BLE_GattcReadParams; + +/**@brief GATTC write parameters */ +typedef struct +{ + BLE_GATTC_WRITE_OP writeOp; /**< Write operation */ + uint16_t charValHandle; /**< Characteristic value handle */ + uint16_t charValLen; /**< Characteristic value data length */ + uint8_t *charValData; /**< Characteristic value data content */ +} BLE_GattcWriteParams; + + +/**@brief GATTC attribute database discovery event structure + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GATTC_EVENT_DBDISCOVERY, and the member evtData is point to @ref BLE_EvtGattcDbDiscovery structure. + */ +typedef struct +{ + uint8_t result; /**< GATTC attribute database discovery result*/ + uint8_t reserve; /**< Reserve */ + uint16_t connHandle; /**< Connection handle */ + union + { + uint32_t reason; /**< Indicate db discovery failed reason */ + BLE_GattcDbDiscovery dbDiscovery; /**< Discovered db information */ + } params; /**< params union */ +} BLE_EvtGattcDbDiscovery; + +/**@brief GATTC read characteristic response event structure + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GATTC_EVENT_READ, and the member evtData is point to @ref BLE_EvtGattcRead structure. + * */ +typedef struct +{ + uint16_t connHandle; /**< Connection handle */ + uint16_t charValHandle; /**< Characteristic value handle */ + uint16_t charValLen; /**< Characteristic value data length */ + uint8_t charValData[MAX_VAL_DATA_LENGTH]; /**< Characteristic value data content */ +} BLE_EvtGattcRead; + +/**@brief GATTC read characteristic response event structure + */ +typedef struct +{ + uint16_t connHandle; /**< Connection handle */ + uint16_t charValHandle; /**< Characteristic value handle */ + uint8_t status; /**< 0 success, other failed */ +} BLE_EvtGattcWriteRsp; + +/**@brief GATTC notification/indication event structure + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GATTC_EVENT_NTFIND, and the member evtData is point to @ref BLE_EvtGattcNtfInd structure. + */ +typedef struct +{ + uint16_t connHandle; /**< Connection handle */ + BLE_GattNtyIndType type; /**< Indication or notification */ + uint16_t attrHandle; /**< Attribute value data length */ + uint16_t attrValLen; /**< Attribute value data length */ + uint8_t attrValData[MAX_VAL_DATA_LENGTH]; /**< Attribute value data content */ +} BLE_EvtGattcNtfInd; + +/** @} ble_datatypes */ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/** + * @defgroup ble_funcs Functions + * @{ + */ + +/**@brief GATT client start attribute database discovery + * @details This call allows the application to start attribute database discovery.The following events may be triggered: @ref BLE_GATTC_EVENT_DBDISCOVERY, @ref BLE_GATTC_EVENT_NTFIND. + * @param[in] connHandle: Connection handle + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GattcStartDbDiscovery(uint16_t connHandle); + +/** + * @defgroup ble_funcs Functions + * @{ + */ + +/**@brief GATT client continue attribute database discovery + * @details This call allows the application to start attribute database discovery.The following events may be triggered: @ref BLE_GATTC_EVENT_DBDISCOVERY, @ref BLE_GATTC_EVENT_NTFIND. + * @param[in] connHandle: Connection handle + * @param[in] startHandle: start handle of discover + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GattcContinueDbDiscovery(uint16_t connHandle, uint16_t startHandle); + +/**@brief GATT client read characteristic + * @details This call allows the application to read a characteristic. The following events may be triggered: @ref BLE_GATTC_EVENT_READ. + * @param[in] connHandle: Connection handle + * @param[in] readParams: Parameter of read operation + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + * @note Wait a bit and retry if the return value is -EBUSY. + */ +int BLE_GattcRead(uint16_t connHandle, BLE_GattcReadParams const *readParams); + +/**@brief GATT client write characteristic + * + * @param[in] connHandle: Connection handle + * @param[in] writeParams: Parameter of write operation + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + * @note Wait a bit and retry if the return value is -EBUSY. + */ +int BLE_GattcWrite(uint16_t connHandle, BLE_GattcWriteParams const *writeParams); + +/**@brief GATT client handle value confirmation of indication + * @details This call allows the application to send confirmation of an indication. + * + * @param[in] connHandle: Connection handle + * @param[in] attrHandle: Attribute handle + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GattcConfirm(uint16_t connHandle, uint16_t attrHandle); + +#ifdef BLE_ENABLE_NORDIC_ORIGINAL +/**@brief GATT client register uuid128 + * @details User can get the type of uuid128(e.g. characteristic.charValUuid.type) when @BLE_GATTC_EVENT_DBDISCOVERY if registered. And user can get bytes 12 and 13(e.g. characteristic.charValUuid.value) of uuid128 when @BLE_GATTC_EVENT_DBDISCOVERY if registered. + * + * @param[in] uuid128: A little endian Vendor Specific UUID disregarding bytes 12 and 13. + * @param[out] type: Index number of the Vendor Specific UUID + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GattcRegisterUuid128(BLE_Uuid128* uuid128, uint8_t* type); +#endif + +/** @} ble_funcs */ + +/** @} ble_gattc */ +#endif /* __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_GATTC_H */ diff --git a/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gatts.h b/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gatts.h new file mode 100644 index 000000000..c623ea543 --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/include/ble/ble_gatts.h @@ -0,0 +1,320 @@ +/**************************************************************************** + * modules/bluetooth/hal/nrf52/include/ble/ble_gatts.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ +/** + * @file ble_gatts.h + */ + +#ifndef __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_GATTS_H +#define __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_GATTS_H + +/** + * @defgroup BLE Bluetooth LE GATT server + * + * #include + * + * @{ + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/** + * @defgroup ble_defs Defines + * @{ + */ + +#define UUID_128BIT_LENGTH 16 /**< 16 bytes of 128 bit UUID length */ +#if defined(CONFIG_BCM20707) +#define MAX_RCV_DATA_LENGTH 512 /**< Max receive data length. */ +#elif defined(CONFIG_BLUETOOTH_NRF52) +#define MAX_RCV_DATA_LENGTH 247 /**< Max receive data length. */ +#else +#define MAX_RCV_DATA_LENGTH 20 /**< Max receive data length. */ +#endif + +/** @} ble_defs */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ +/** + * @defgroup ble_datatypes Data types + * @{ + */ + +/**@brief Gatts write event structure + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GATTS_EVENT_WRITE, and the member evtData is point to @ref BLE_EvtGattsWrite structure. + */ +typedef struct +{ + uint16_t connHandle; /**< Connection handle */ + uint16_t handle; /**< Attribute handle */ + uint16_t offset; /**< Offset for the write operation */ + uint16_t dataLen; /**< Length of the received data */ + uint8_t reserve[2]; /**< Reserve */ + uint8_t data[MAX_RCV_DATA_LENGTH]; /**< Received data */ +} BLE_EvtGattsWrite; + +/**@brief Indication confirm event + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GATTS_EVENT_CFM, and the member evtData is point to @ref BLE_EvtGattsIndConfirm structure. + */ +typedef struct +{ + uint16_t connHandle; /**< Connection handle */ + uint16_t handle; /**< Attribute handle */ +} BLE_EvtGattsIndConfirm; + +/**@brief Exchange MTU event + * @details When the event coming from the stack to the application, the @ref BLE_Evt structure member evtHeader is set to @ref BLE_GATTS_EVENT_EXCHANGE_MTU, and the member evtData is point to @ref BLE_EvtGattsExchangeMTU structure. + */ +typedef struct +{ + uint16_t connHandle; /**< Connection handle */ + uint16_t client_rx_mtu; +} BLE_EvtGattsExchangeMTU; + +/**@brief 128-bit UUID structure + */ +typedef struct +{ + uint8_t uuid128[UUID_128BIT_LENGTH]; /**< 128-bit UUID */ +} BLE_Uuid128; + +/**@brief UUID base alias structure + */ +typedef struct +{ + BLE_Uuid128 uuidBase; /**< 128-bit UUID */ + uint16_t uuidAlias; /**< UUID alias */ +} BLE_uuidBaseAlias; + +/**@brief BLE UUID structure + */ +typedef struct +{ + BLE_GATT_UUID_TYPE type; /**< UUID type */ + union + { + BLE_UUID128 uuid128; /**< 128-bit UUID */ + BLE_UUID_ALIAS baseAlias; /**< UUID base alias */ + }value; /**< value union */ +} BLE_Uuid; + +/**@brief Characteristic standard properties + * @details According to ble core spec 4.1 vol3;Part G 3.3.1.1, Current version support read, write, notify properties. + */ +typedef struct +{ + uint8_t broadcast :1; /**< Broadcasting of the value permitted. */ + uint8_t read :1; /**< Reading the value permitted. */ + uint8_t writeWoResp :1; /**< Writing the value with Write Command permitted. */ + uint8_t write :1; /**< Writing the value with Write Request permitted. */ + uint8_t notify :1; /**< Notification of the value permitted. */ + uint8_t indicate :1; /**< Indication of the value permitted. */ + uint8_t authSignedWr :1; /**< Writing the value with Signed Write Command permitted. */ + uint8_t reserve :1; /**< Reserve */ +} BLE_CharPrope; + +/**@brief Attribute permission structure + */ +typedef struct +{ + BLE_SEC_MODE readPerm; /**< Read permissions. */ + BLE_SEC_MODE writePerm; /**< Write permissions. */ +} BLE_AttrPerm; + +/**@brief Characteristic meta datastructure + */ +typedef struct +{ + BLE_CHAR_PROP charPrope; /**< Characteristic Properties */ + uint8_t reserve; /**< Reserve */ + uint16_t charUserDescSize; /**< The size of the user description */ + uint8_t *charUserDesc; /**< Pointer to a UTF-8 encoded string */ + BLE_ATTR_PERM userDescDpr; /**< User Description descriptor, not supported now */ + BLE_ATTR_PERM clientCharCfgDpr; /**< Client Characteristic Configuration Descriptor */ + BLE_ATTR_PERM serverCharCfgDpr; /**< Server Characteristic Configuration Descriptor, not supported now */ +} BLE_CharMeta; + +/**@brief the GATTS descriptor structure + */ +typedef struct +{ + uint16_t userDescHandle; /**< Handle to the User Description descriptor */ + uint16_t cccdHandle; /**< Handle to the Client Characteristic Configuration Descriptor */ + uint16_t sccdHandle; /**< Handle to the Server Characteristic Configuration Descriptor */ +} BLE_GattsDprHandles; + +/**@brief GATT Characteristic Definition Handles + */ +typedef struct +{ + uint16_t charHandle; /**< Handle to the characteristic value */ + BLE_GattsDprHandles dprHandle; /**< Handle to the descriptor structure belongs to characteristic */ +} BLE_GattsCharHandles; + +/**@brief characteristic value attribute structure + */ +typedef struct BLE_GattsAttr_t +{ + BLE_Uuid valueUuid; /**< Attribute value UUID */ + BLE_ATTR_PERM attrPerm; /**< Attribute permission structure */ + uint8_t *attrValue; /**< Pointer to attribute value */ + uint16_t valueLen; /**< Attribute value length */ +} BLE_GattsAttr; + +/**@brief Notification or Indication Type + * @sa @ref BLE_EvtGattcNtfInd + */ +typedef enum +{ + BLE_GATT_NOTIFICATION = 0x01, /**< GATT type notification */ + BLE_GATT_INDICATION, /**< GATT type indication */ +} BLE_GattNtyIndType; + +/**@brief GATTS handle value notification or indication parameters structure + */ +typedef struct +{ + BLE_GattNtyIndType type; /**< Indication or notification */ + uint8_t reserve; /**< Reserve */ + uint8_t *attrValData; /**< Attribute value data content */ + uint16_t attrValLen; /**< Attribute value length in bytes */ + uint16_t attrHandle; /**< Attribute handle */ +} BLE_GattsHandleValueNfyIndParams; + + +/**@brief GATTS Attribute value parameters structure + */ +typedef struct +{ + uint16_t connHandle; /**< Connection handle */ + uint16_t attrHandle; /**< Attribute handle */ + uint16_t attrValLen; /**< Attribute value length */ + uint16_t reserve; /**< Reserve */ + uint8_t *attrValData; /**< Attribute value data */ +} BLE_GattsAttrValueParam; + +/** @} ble_datatypes */ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/** + * @defgroup ble_funcs Functions + * @{ + */ + +/**@brief GATT server add service + * @details Add a service declaration to the attribute table. There is not a maximum number of services. The number is varied depending on number of attributes in each service and its size. So user could add services until space runs out and no more can be added. + * + * @param[in] type: Primary or secondary service + * @param[in] uuid: Pointer to service UUID + * @param[out] serviceHandle: Pointer to a 16-bit word where the assigned handle will be stored + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GattsAddService(BLE_GATT_TYPE type, BLE_Uuid const* uuid, uint16_t* serviceHandle); + +/**@brief GATT server add characteristic + * @details Add a characteristic declaration. This call allows the application to add a characteristic declaration, a characteristic value declaration and option characteristic descriptor declarations to the attribute table. There is not a maximum number of characteristic, it depends on the available resources. + * + * @param[in] serviceHandle: Service handle that the characteristic to be added belongs to + * @param[in] charMeta: Characteristic meta data + * @param[in] charValue: Characteristic value structure + * @param[out] handles: Handles of added characteristic + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GattsAddCharacteristic(uint16_t serviceHandle, BLE_CharMeta const* charMeta, BLE_GattsAttr const* charValue, BLE_GattsCharHandles* handles); + +/**@brief GATT server handle value notification/indication + * @details Handle an attribute value notification or indication. + * + * @param[in] connHandle: Connection handle + * @param[in] handleValueNfyInd: Characteristic meta data pointer to an handle value notify or indicate parameters structure + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + */ +int BLE_GattsHandleValueNfyInd(uint16_t connHandle, BLE_GattsHandleValueNfyIndParams const* handleValueNfyInd); + +/**@brief GATT server update attribute value + * @details This call allows the application to update an attribute value. for example, if you want to update your characteristic value(an attribute), you can use this call with attribute handle set to characteristic value handle. + * + * @param[in] attrValueParam: Attribute value, must be existing connHandle and attrHandle. + * @return 0: success + * + * @par Blocking + * Yes + * @par Context + * Task + * @par Reentrant + * No + * + * @note Wait a bit and retry this if the return value is -EBUSY. + */ +int BLE_GattsUpdateAttrValue(BLE_GattsAttrValueParam *attrValueParam); + +/** @} ble_funcs */ + +/** @} ble_gatts */ +#endif /* __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BLE_BLE_GATTS_H */ diff --git a/sdk/modules/bluetooth/hal/nrf52/include/bt/bt_comm.h b/sdk/modules/bluetooth/hal/nrf52/include/bt/bt_comm.h new file mode 100644 index 000000000..4d8b8f65a --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/include/bt/bt_comm.h @@ -0,0 +1,1004 @@ +/**************************************************************************** + * apps/include/bt/bt_comm.h + * + * Copyright (C) 2016 Sony Corporation. All rights reserved. + * Author: Yuchi.Wen + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor Sony nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ +/** + * @file bt_comm.h + */ + +#ifndef BT_COMM_H +#define BT_COMM_H + +/** + * @defgroup BT + * @{ + */ + +/*----------------------------------------------------------------------------- + * include files + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/** + * @defgroup bt_defs Defines + * @{ + */ + +/** + *@name Error Codes + *@{ + */ +// #define BT_SUCCESS 0x00 +/** @} */ + +/** + *@name BT Address Length + *@{ + */ +// #define BT_ADDR_LEN (6) +/** @} */ + +/** + *@name BT DID information length + *@{ + */ +#define BT_DID_INFO_LEN 4 +/** @} */ + +/** + *@name BT save bond device max num + *@{ + */ +#define BT_SAVE_BOND_DEVICE_MAX_NUM 8 +/** @} */ + +/** + *@name BT Name Length + *@{ + */ +#define BT_MAX_NAME_LEN 28 +/** @} */ + +/** + *@name BT Class Length + *@{ + */ +#define BT_CLASS_LEN (3) +/** @} */ + +/** + * @name Device Event Group Type + * @{ + */ +#define BT_CONTROL_GROUP_DEVICE 0x00 /**< General control of BCM20706 management and Bluetooth functionality*/ +#define BT_CONTROL_GROUP_LE 0x01 /**< LE device-related commands*/ +#define BT_CONTROL_GROUP_GATT 0x02 /**< GATT commands*/ +#define BT_CONTROL_GROUP_HF 0x03 /**< Hands-free profile HF commands*/ +#define BT_CONTROL_GROUP_SPP 0x04 /**< Serial port profile commands*/ +#define BT_CONTROL_GROUP_A2DP_SRC 0x05 /**< Audio/video (AV) commands*/ +#define BT_CONTROL_GROUP_HIDD 0x06 /**< HID device (HIDD) commands*/ +#define BT_CONTROL_GROUP_AVRC_TARGET 0x07 /**< AV remote control (AVRC) target commands*/ +#define BT_CONTROL_GROUP_AG 0x0e /**< Hands-free profile AG commands*/ +#define BT_CONTROL_GROUP_AVRC_CONTROLLER 0x11 /**< AV remote control (AVRC) controller commands*/ +#define BT_CONTROL_GROUP_A2DP_SINK 0x13 /**< a2dp sink commands*/ +#define BT_CONTROL_GROUP_AUDIO_SINK 0x14 /**< audio sink commands*/ +/** @} */ + +/** + * @name Device Group Event Opcode Type + * @{ + */ +#define BT_EVT_DEV_COMMAND_STATUS 0x01 /**< Command status event for the requested operation */ +#define BT_EVT_DEV_BOND_INFO 0x04 /**< Request to MCU to save bond info */ +#define BT_EVT_DEV_INQUIRY_RESULT 0x06 /**< Inquiry result */ +#define BT_EVT_DEV_INQUIRY_COMPLETE 0x07 /**< Inquiry completed event */ +#define BT_EVT_DEV_PAIRING_COMPLETE 0x08 /**< Pairing Completed */ +#define BT_EVT_DEV_ENCRYPTION_CHANGED 0x09 /**< Encryption changed event */ +#define BT_EVT_DEV_CONNECTED_DEVICE_NAME 0x0A /**< Remote connected device name */ +#define BT_EVT_DEV_CONFIRMATION_REQUEST 0x0B /**< Confirmation request during pairing */ +#define BT_EVT_DEV_PASSKEY_REQUEST 0x17 /**< Passkey request during pairing */ +#define BT_EVT_DEV_PMGR_STATUS 0x20 /**< power manager status and value */ +#define BT_EVT_DEV_BAUDRATE_RESPONSE 0x21 /**< baud rate response */ +#define BT_EVT_DEV_I2S_ROLE_RESPONSE 0x22 /**< i2s role response */ +#define BT_EVT_DEV_REPLY_VENDORID 0x23 /**< reply vendor id event */ +#define BT_EVT_DEV_REPLY_BT_VERSION 0x24 /**< reply the bt version */ +#define BT_EVT_DEV_ACL_CONNECTION_STATUS 0x27 /**< Acl connection/disconnection status */ +/** @} */ + +/** + * @name BT/BLE transport type + * @{ + */ +#define BT_TRANSPORT_BR_EDR 1 +#define BT_TRANSPORT_LE 2 +/** @} */ + +/** + * @name Acl disconnection type + * @{ + */ +#define BT_CONNECTION_TIMEOUT 0x08 /**< BT disconnection because of time out */ +#define BT_REMOTE_USER_TERM_CONN 0x13 /**< Remote user terminate the connection */ +#define BT_LOCAL_HOST_TERM_CONN 0x16 /**< Local host terminate the connection */ +/** @} */ + +/** + * @name Event Data length + * @{ + */ +#define BT_EVT_DATA_LEN 1000 /**< BT event data max length */ +#define BT_EVT_EIR_LEN (BT_EVT_DATA_LEN - 30) +#define BT_EVT_AUDIO_DATA_LEN (BT_EVT_DATA_LEN - 10) +/** @} */ + +/** @} bt_defs */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ +/** + * @defgroup bt_datatypes Data types + * @{ + */ + +/**@brief BT initialize parameter + */ +typedef struct { + int reverse; +} BT_INIT_PARAM; + +/**@brief BT address structure + */ +// typedef struct +// { +// uint8_t address[BT_ADDR_LEN]; +// } BT_ADDR; + +/**@brief BT Class structure + */ +typedef struct +{ + uint8_t btClass[BT_CLASS_LEN]; +}BT_CLASS; + +typedef enum +{ + BT_IO_NO_INPUT_NO_OUTPUT = 0, + BT_IO_INPUT_ONLY, + BT_IO_OUTPUT_ONLY, + BT_INPUT_OUTPUT, +}BT_IO_CAP; + +/**@brief BT visibility param structure + */ +typedef struct +{ + uint16_t discWindow; /** +#include + +/**************************************************************************** + * Public Datas + ****************************************************************************/ + +/* BT Common HAL I/F */ + +struct bt_hal_common_ops_s bt_hal_common_ops; + +#ifdef CONFIG_NRF52_A2DP +/* BT A2DP HAL I/F */ + +struct bt_hal_a2dp_ops_s bt_hal_a2dp_ops; +#endif + +#ifdef CONFIG_NRF52_AVRCP +/* BT AVRCP HAL I/F */ + +struct bt_hal_avrcp_ops_s bt_hal_avrcp_ops; +#endif + +#ifdef CONFIG_NRF52_HFP +/* BT HFP HAL I/F */ + +struct bt_hal_hfp_ops_s bt_hal_hfp_ops; +#endif + +#ifdef CONFIG_NRF52_SPP +/* BT SPP HAL I/F */ + +struct bt_hal_spp_ops_s bt_hal_spp_ops; +#endif + +#ifdef CONFIG_NRF52_LE +/* BT SPP HAL I/F */ + +struct ble_hal_common_ops_s ble_hal_common_ops; + +#ifdef CONFIG_NRF52_LE_GATT +/* BT SPP HAL I/F */ + +struct ble_hal_gatt_ops_s ble_hal_gatt_ops; +#endif +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int nrf52_probe(void) +{ + int ret = 0; + + /* Register BT common HAL */ + + ret = bt_common_register_hal(&bt_hal_common_ops); + +#ifdef CONFIG_NRF52_A2DP + /* Register BT A2DP HAL */ + + ret = bt_a2dp_register_hal(&bt_hal_a2dp_ops); +#endif + +#ifdef CONFIG_NRF52_AVRCP + /* Register BT AVRCP HAL */ + + ret = bt_avrcp_register_hal(&bt_hal_avrcp_ops); +#endif + +#ifdef CONFIG_NRF52_HFP + /* Register BT HFP HAL */ + + ret = bt_hfp_register_hal(&bt_hal_hfp_ops); +#endif + +#ifdef CONFIG_NRF52_SPP + /* Register BT SPP HAL */ + + ret = bt_spp_register_hal(&bt_hal_spp_ops); +#endif + +#ifdef CONFIG_NRF52_LE + /* Register BLE common HAL */ + + ret = ble_common_register_hal(&ble_hal_common_ops); + +#ifdef CONFIG_NRF52_LE_GATT + /* Register BLE GATT HAL */ + + ret = ble_gatt_register_hal(&ble_hal_gatt_ops); +#endif +#endif + + return ret; +} diff --git a/sdk/modules/bluetooth/hal/nrf52/queue.h b/sdk/modules/bluetooth/hal/nrf52/queue.h new file mode 100644 index 000000000..37bd61924 --- /dev/null +++ b/sdk/modules/bluetooth/hal/nrf52/queue.h @@ -0,0 +1,851 @@ +/* $NetBSD: queue.h,v 1.68 2014/11/19 08:10:01 uebayasi Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues, and circular queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * A circle queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the list. + * A circle queue may be traversed in either direction, but has a more + * complex end of list detection. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +/* + * Include the definition of NULL only on NetBSD because sys/null.h + * is not available elsewhere. This conditional makes the header + * portable and it can simply be dropped verbatim into any system. + * The caveat is that on other systems some other header + * must provide NULL before the macros can be used. + */ +#ifdef __NetBSD__ +#include +#endif + +#if defined(QUEUEDEBUG) +# if defined(_KERNEL) +# define QUEUEDEBUG_ABORT(...) panic(__VA_ARGS__) +# else +# include +# define QUEUEDEBUG_ABORT(...) err(1, __VA_ARGS__) +# endif +#endif + +/* + * Singly-linked List definitions. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List access methods. + */ +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_END(head) NULL +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +#define SLIST_FOREACH(var, head, field) \ + for((var) = (head)->slh_first; \ + (var) != SLIST_END(head); \ + (var) = (var)->field.sle_next) + +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SLIST_FIRST((head)); \ + (var) != SLIST_END(head) && \ + ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked List functions. + */ +#define SLIST_INIT(head) do { \ + (head)->slh_first = SLIST_END(head); \ +} while (/*CONSTCOND*/0) + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE_AFTER(slistelm, field) do { \ + (slistelm)->field.sle_next = \ + SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE(head, elm, type, field) do { \ + if ((head)->slh_first == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->slh_first; \ + while(curelm->field.sle_next != (elm)) \ + curelm = curelm->field.sle_next; \ + curelm->field.sle_next = \ + curelm->field.sle_next->field.sle_next; \ + } \ +} while (/*CONSTCOND*/0) + + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List access methods. + */ +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_END(head) NULL +#define LIST_EMPTY(head) ((head)->lh_first == LIST_END(head)) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); \ + (var) != LIST_END(head); \ + (var) = ((var)->field.le_next)) + +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)); \ + (var) != LIST_END(head) && \ + ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define LIST_MOVE(head1, head2) do { \ + LIST_INIT((head2)); \ + if (!LIST_EMPTY((head1))) { \ + (head2)->lh_first = (head1)->lh_first; \ + LIST_INIT((head1)); \ + } \ +} while (/*CONSTCOND*/0) + +/* + * List functions. + */ +#if defined(QUEUEDEBUG) +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ + if ((head)->lh_first && \ + (head)->lh_first->field.le_prev != &(head)->lh_first) \ + QUEUEDEBUG_ABORT("LIST_INSERT_HEAD %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_OP(elm, field) \ + if ((elm)->field.le_next && \ + (elm)->field.le_next->field.le_prev != \ + &(elm)->field.le_next) \ + QUEUEDEBUG_ABORT("LIST_* forw %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + if (*(elm)->field.le_prev != (elm)) \ + QUEUEDEBUG_ABORT("LIST_* back %p %s:%d", (elm), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ + (elm)->field.le_next = (void *)1L; \ + (elm)->field.le_prev = (void *)1L; +#else +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_LIST_OP(elm, field) +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) +#endif + +#define LIST_INIT(head) do { \ + (head)->lh_first = LIST_END(head); \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + if (((elm)->field.le_next = (listelm)->field.le_next) != \ + LIST_END(head)) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.le_next = (head)->lh_first) != LIST_END(head))\ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (/*CONSTCOND*/0) + +#define LIST_REMOVE(elm, field) do { \ + QUEUEDEBUG_LIST_OP((elm), field) \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +#define LIST_REPLACE(elm, elm2, field) do { \ + if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ + (elm2)->field.le_next->field.le_prev = \ + &(elm2)->field.le_next; \ + (elm2)->field.le_prev = (elm)->field.le_prev; \ + *(elm2)->field.le_prev = (elm2); \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head)) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var) != SIMPLEQ_END(head); \ + (var) = ((var)->field.sqe_next)) + +#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->sqh_first); \ + (var) != SIMPLEQ_END(head) && \ + ((next = ((var)->field.sqe_next)), 1); \ + (var) = (next)) + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ + if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \ + == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + SIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_CONCAT(head1, head2) do { \ + if (!SIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + SIMPLEQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_LAST(head, type, field) \ + (SIMPLEQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->sqh_last) - offsetof(struct type, field)))) + +/* + * Tail queue definitions. + */ +#define _TAILQ_HEAD(name, type, qual) \ +struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ +} +#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) + +#define TAILQ_HEAD_INITIALIZER(head) \ + { TAILQ_END(head), &(head).tqh_first } + +#define _TAILQ_ENTRY(type, qual) \ +struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */\ +} +#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) + +/* + * Tail queue access methods. + */ +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_END(head) (NULL) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_EMPTY(head) (TAILQ_FIRST(head) == TAILQ_END(head)) + + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var) != TAILQ_END(head); \ + (var) = ((var)->field.tqe_next)) + +#define TAILQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->tqh_first); \ + (var) != TAILQ_END(head) && \ + ((next) = TAILQ_NEXT(var, field), 1); (var) = (next)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));\ + (var) != TAILQ_END(head); \ + (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) + +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) != TAILQ_END(head) && \ + ((prev) = TAILQ_PREV((var), headname, field), 1); (var) = (prev)) + +/* + * Tail queue functions. + */ +#if defined(QUEUEDEBUG) +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ + if ((head)->tqh_first && \ + (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ + QUEUEDEBUG_ABORT("TAILQ_INSERT_HEAD %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ + if (*(head)->tqh_last != NULL) \ + QUEUEDEBUG_ABORT("TAILQ_INSERT_TAIL %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_OP(elm, field) \ + if ((elm)->field.tqe_next && \ + (elm)->field.tqe_next->field.tqe_prev != \ + &(elm)->field.tqe_next) \ + QUEUEDEBUG_ABORT("TAILQ_* forw %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + if (*(elm)->field.tqe_prev != (elm)) \ + QUEUEDEBUG_ABORT("TAILQ_* back %p %s:%d", (elm), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ + if ((elm)->field.tqe_next == NULL && \ + (head)->tqh_last != &(elm)->field.tqe_next) \ + QUEUEDEBUG_ABORT("TAILQ_PREREMOVE head %p elm %p %s:%d",\ + (head), (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ + (elm)->field.tqe_next = (void *)1L; \ + (elm)->field.tqe_prev = (void *)1L; +#else +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) +#define QUEUEDEBUG_TAILQ_OP(elm, field) +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) +#endif + +#define TAILQ_INIT(head) do { \ + (head)->tqh_first = TAILQ_END(head); \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.tqe_next = (head)->tqh_first) != TAILQ_END(head))\ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ + (elm)->field.tqe_next = TAILQ_END(head); \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != \ + TAILQ_END(head)) \ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ + QUEUEDEBUG_TAILQ_OP((elm), field) \ + if (((elm)->field.tqe_next) != TAILQ_END(head)) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ +} while (/*CONSTCOND*/0) + +#define TAILQ_REPLACE(head, elm, elm2, field) do { \ + if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != \ + TAILQ_END(head)) \ + (elm2)->field.tqe_next->field.tqe_prev = \ + &(elm2)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm2)->field.tqe_next; \ + (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ + *(elm2)->field.tqe_prev = (elm2); \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ +} while (/*CONSTCOND*/0) + +#define TAILQ_CONCAT(head1, head2, field) do { \ + if (!TAILQ_EMPTY(head2)) { \ + *(head1)->tqh_last = (head2)->tqh_first; \ + (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +/* + * Singly-linked Tail queue declarations. + */ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first; /* first element */ \ + struct type **stqh_last; /* addr of last next element */ \ +} + +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue access methods. + */ +#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_END(head) NULL +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) +#define STAILQ_EMPTY(head) (STAILQ_FIRST(head) == STAILQ_END(head)) + +/* + * Singly-linked Tail queue functions. + */ +#define STAILQ_INIT(head) do { \ + (head)->stqh_first = NULL; \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (head)->stqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.stqe_next = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (listelm)->field.stqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE(head, elm, type, field) do { \ + if ((head)->stqh_first == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->stqh_first; \ + while (curelm->field.stqe_next != (elm)) \ + curelm = curelm->field.stqe_next; \ + if ((curelm->field.stqe_next = \ + curelm->field.stqe_next->field.stqe_next) == NULL) \ + (head)->stqh_last = &(curelm)->field.stqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define STAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->stqh_first); \ + (var); \ + (var) = ((var)->field.stqe_next)) + +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST((head)); \ + (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define STAILQ_CONCAT(head1, head2) do { \ + if (!STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last = (head2)->stqh_first; \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define STAILQ_LAST(head, type, field) \ + (STAILQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->stqh_last) - offsetof(struct type, field)))) + + +#ifndef _KERNEL +/* + * Circular queue definitions. Do not use. We still keep the macros + * for compatibility but because of pointer aliasing issues their use + * is discouraged! + */ + +/* + * __launder_type(): We use this ugly hack to work around the the compiler + * noticing that two types may not alias each other and elide tests in code. + * We hit this in the CIRCLEQ macros when comparing 'struct name *' and + * 'struct type *' (see CIRCLEQ_HEAD()). Modern compilers (such as GCC + * 4.8) declare these comparisons as always false, causing the code to + * not run as designed. + * + * This hack is only to be used for comparisons and thus can be fully const. + * Do not use for assignment. + * + * If we ever choose to change the ABI of the CIRCLEQ macros, we could fix + * this by changing the head/tail sentinal values, but see the note above + * this one. + */ + +#if defined(__GNUC__) && !defined(__CC_ARM) +static __inline const void * __launder_type(const void *); +static __inline const void * +__launder_type(const void *__x) +{ + __asm __volatile("" : "+r" (__x)); + return __x; +} +#else /* defined(__GNUC__) && !defined(__CC_ARM) */ +#define __launder_type(arg) (arg) +#endif /* defined(__GNUC__) && !defined(__CC_ARM) */ + +#if defined(QUEUEDEBUG) +#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \ + if ((head)->cqh_first != CIRCLEQ_ENDC(head) && \ + (head)->cqh_first->field.cqe_prev != CIRCLEQ_ENDC(head)) \ + QUEUEDEBUG_ABORT("CIRCLEQ head forw %p %s:%d", (head), \ + __FILE__, __LINE__); \ + if ((head)->cqh_last != CIRCLEQ_ENDC(head) && \ + (head)->cqh_last->field.cqe_next != CIRCLEQ_ENDC(head)) \ + QUEUEDEBUG_ABORT("CIRCLEQ head back %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \ + if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) { \ + if ((head)->cqh_last != (elm)) \ + QUEUEDEBUG_ABORT("CIRCLEQ elm last %p %s:%d", \ + (elm), __FILE__, __LINE__); \ + } else { \ + if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \ + QUEUEDEBUG_ABORT("CIRCLEQ elm forw %p %s:%d", \ + (elm), __FILE__, __LINE__); \ + } \ + if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) { \ + if ((head)->cqh_first != (elm)) \ + QUEUEDEBUG_ABORT("CIRCLEQ elm first %p %s:%d", \ + (elm), __FILE__, __LINE__); \ + } else { \ + if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \ + QUEUEDEBUG_ABORT("CIRCLEQ elm prev %p %s:%d", \ + (elm), __FILE__, __LINE__); \ + } +#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \ + (elm)->field.cqe_next = (void *)1L; \ + (elm)->field.cqe_prev = (void *)1L; +#else +#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) +#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) +#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) +#endif + +#define CIRCLEQ_HEAD(name, type) \ +struct name { \ + struct type *cqh_first; /* first element */ \ + struct type *cqh_last; /* last element */ \ +} + +#define CIRCLEQ_HEAD_INITIALIZER(head) \ + { CIRCLEQ_END(&head), CIRCLEQ_END(&head) } + +#define CIRCLEQ_ENTRY(type) \ +struct { \ + struct type *cqe_next; /* next element */ \ + struct type *cqe_prev; /* previous element */ \ +} + +/* + * Circular queue functions. + */ +#define CIRCLEQ_INIT(head) do { \ + (head)->cqh_first = CIRCLEQ_END(head); \ + (head)->cqh_last = CIRCLEQ_END(head); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ + (elm)->field.cqe_next = (listelm)->field.cqe_next; \ + (elm)->field.cqe_prev = (listelm); \ + if ((listelm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ + (head)->cqh_last = (elm); \ + else \ + (listelm)->field.cqe_next->field.cqe_prev = (elm); \ + (listelm)->field.cqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ + (elm)->field.cqe_next = (listelm); \ + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ + if ((listelm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ + (head)->cqh_first = (elm); \ + else \ + (listelm)->field.cqe_prev->field.cqe_next = (elm); \ + (listelm)->field.cqe_prev = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + (elm)->field.cqe_next = (head)->cqh_first; \ + (elm)->field.cqe_prev = CIRCLEQ_END(head); \ + if ((head)->cqh_last == CIRCLEQ_ENDC(head)) \ + (head)->cqh_last = (elm); \ + else \ + (head)->cqh_first->field.cqe_prev = (elm); \ + (head)->cqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + (elm)->field.cqe_next = CIRCLEQ_END(head); \ + (elm)->field.cqe_prev = (head)->cqh_last; \ + if ((head)->cqh_first == CIRCLEQ_ENDC(head)) \ + (head)->cqh_first = (elm); \ + else \ + (head)->cqh_last->field.cqe_next = (elm); \ + (head)->cqh_last = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_REMOVE(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \ + if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ + (head)->cqh_last = (elm)->field.cqe_prev; \ + else \ + (elm)->field.cqe_next->field.cqe_prev = \ + (elm)->field.cqe_prev; \ + if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ + (head)->cqh_first = (elm)->field.cqe_next; \ + else \ + (elm)->field.cqe_prev->field.cqe_next = \ + (elm)->field.cqe_next; \ + QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->cqh_first); \ + (var) != CIRCLEQ_ENDC(head); \ + (var) = ((var)->field.cqe_next)) + +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ + for ((var) = ((head)->cqh_last); \ + (var) != CIRCLEQ_ENDC(head); \ + (var) = ((var)->field.cqe_prev)) + +/* + * Circular queue access methods. + */ +#define CIRCLEQ_FIRST(head) ((head)->cqh_first) +#define CIRCLEQ_LAST(head) ((head)->cqh_last) +/* For comparisons */ +#define CIRCLEQ_ENDC(head) (__launder_type(head)) +/* For assignments */ +#define CIRCLEQ_END(head) ((void *)(head)) +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) +#define CIRCLEQ_EMPTY(head) \ + (CIRCLEQ_FIRST(head) == CIRCLEQ_ENDC(head)) + +#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ + (((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ + ? ((head)->cqh_first) \ + : (elm->field.cqe_next)) +#define CIRCLEQ_LOOP_PREV(head, elm, field) \ + (((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ + ? ((head)->cqh_last) \ + : (elm->field.cqe_prev)) +#endif /* !_KERNEL */ + +#endif /* !_SYS_QUEUE_H_ */ diff --git a/sdk/modules/include/bluetooth/bluetooth.h b/sdk/modules/include/bluetooth/bluetooth.h index c189c6ce8..5f8f1a751 100644 --- a/sdk/modules/include/bluetooth/bluetooth.h +++ b/sdk/modules/include/bluetooth/bluetooth.h @@ -204,6 +204,10 @@ typedef enum BT_VIS_DISCOVERY_CONNECTABLE = 3 /**< Discoverable and connectable */ } BT_VISIBILITY; +#ifdef EXTERNALS_NRF52 +#include "ble_types.h" +typedef int BLE_APPEARANCE +#else /** * @enum BLE_APPEARANCE * @brief BLE appearance ID @@ -250,6 +254,7 @@ typedef enum BLE_APPEARANCE_CYCLING_POWER_SENSOR = 1156, BLE_APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, } BLE_APPEARANCE; +#endif /** * @enum BLE_GAP_IO_CAP From bc33c99c97ce01ad6d1f267d8c79d73093189e77 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 20 Jul 2022 07:27:16 +0900 Subject: [PATCH 09/52] Update Submodules for develop at 2022/07/20 07:27:16 --- nuttx | 2 +- sdk/apps | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuttx b/nuttx index 4682f2e9d..795fb02a5 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit 4682f2e9d37a45ddca44018b67557395942c92e5 +Subproject commit 795fb02a542c6629e53b97f35ce98a111222dd2d diff --git a/sdk/apps b/sdk/apps index 6f97d735d..131e803c3 160000 --- a/sdk/apps +++ b/sdk/apps @@ -1 +1 @@ -Subproject commit 6f97d735ddb245be4e97ee041acd13d6f8fe48a8 +Subproject commit 131e803c395be7a56d4692a9fc482191cda45272 From 711e5dcf8d593730d312b55f83f3c20cf079ab4f Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Fri, 1 Jul 2022 15:08:38 +0900 Subject: [PATCH 10/52] externals/nrf52: Fix build warning Add header include to fix build warning --- .../components/libraries/util/app_util_platform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h index 88bdef0bc..3565f7cd6 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h @@ -49,6 +49,8 @@ #ifndef APP_UTIL_PLATFORM_H__ #define APP_UTIL_PLATFORM_H__ +#include + #ifdef __cplusplus extern "C" { #endif From b7b270d7d1f08561e55d40f5dc93b699a121c79c Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 4 Jul 2022 08:41:38 +0900 Subject: [PATCH 11/52] externals/nrf52: Simplify UART writing Write multi-bytes togetter instead of writing only one byte at a time. --- .../common/transport/ser_phy/ser_phy_uart.c | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c index c87885c4d..949ff145a 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c @@ -441,39 +441,28 @@ static __INLINE void callback_packet_sent(void) } } -static int ser_phy_uart_send_char(uint8_t byte) -{ - ssize_t sent_len = 0; - //NRF_LOG_DEBUG("Send 0x%02x\n", byte); - - int errcode = 0; - UART_CONTEXT *ctx = &g_ctx; - - do - { - sent_len = write(ctx->uart_fd, &byte, 1); - } while (sent_len == 0); - if (sent_len < 0) - { - errcode = errno; - NRF_LOG_DEBUG("ser_phy_uart_send_char: write:err %d\n", errcode); - return -errcode; - } - return NRF_SUCCESS; -} - static int ser_phy_uart_send(void* buf, int size) { int ret = 0; - int index=0; + size_t sz; + size_t rem_sz = size; + uint8_t *addr = buf; NRF_LOG_DEBUG("ser_phy_uart_send size %d\n", size); - for(index=0; index 0) + { + sz = write(g_ctx.uart_fd, addr, rem_sz); + if (sz < 0) + { + ret = errno; + NRF_LOG_DEBUG("ser_phy_uart_send: write:err %d\n", ret); + return -ret; + } + + addr += sz; + rem_sz -= sz; + } + return NRF_SUCCESS; } From 9d66db85520a35d800d7fa492579fc121ecced08 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 7 Jul 2022 20:03:26 +0900 Subject: [PATCH 12/52] externals/nrf52: Add system sleep In original nRF52 library, ser_app_power_system_off_enter() execute system sleep. In SPRESENSE, execute deep sleep. --- .../serialization/application/hal/ser_app_power_system_off.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c index 03b162b2c..cef10d2ad 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c @@ -37,6 +37,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +#include #include "nrf.h" #include "ser_app_power_system_off.h" @@ -55,4 +56,8 @@ bool ser_app_power_system_off_get(void) void ser_app_power_system_off_enter(void) { + boardctl(BOARDIOC_POWEROFF, 0); + + /*Only for debugging purpose, will not be reached without connected debugger*/ + while (1); } From 686de10da762dc4377a2a93ad8cccd206a3382b8 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 4 Jul 2022 15:01:27 +0900 Subject: [PATCH 13/52] externals/nrf52: Revert header files for log output Revert the following header files for log output: - components/library/log/ - config/nrf52832/config/sdk_config.h --- .../components/libraries/log/nrf_log.h | 296 ++++++++++ .../libraries/log/src/nrf_log_internal.h | 516 ++++++++++++++++++ .../config/nrf52832/config/sdk_config.h | 178 ++++++ 3 files changed, 990 insertions(+) create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h new file mode 100644 index 000000000..34a97450e --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h @@ -0,0 +1,296 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/**@file + * + * @defgroup nrf_log Logger module + * @{ + * @ingroup app_common + * + * @brief The nrf_log module interface. + */ + +#ifndef NRF_LOG_H_ +#define NRF_LOG_H_ + +#include "sdk_common.h" +#include "nrf_section.h" +#if NRF_MODULE_ENABLED(NRF_LOG) +#include "nrf_strerror.h" +#define NRF_LOG_ERROR_STRING_GET(code) nrf_strerror_get(code) +#else +#define NRF_LOG_ERROR_STRING_GET(code) "" +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Severity level for the module. + * + * The severity level can be defined in a module to override the default. + */ +#ifndef NRF_LOG_LEVEL + #define NRF_LOG_LEVEL NRF_LOG_DEFAULT_LEVEL +#endif + +/** @brief Initial severity if filtering is enabled. + */ +#ifndef NRF_LOG_INITIAL_LEVEL + #define NRF_LOG_INITIAL_LEVEL NRF_LOG_LEVEL +#endif + + +#include "nrf_log_internal.h" + +/** @def NRF_LOG_ERROR + * @brief Macro for logging error messages. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ + +/** @def NRF_LOG_WARNING + * @brief Macro for logging error messages. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes warning logs. + */ + +/** @def NRF_LOG_INFO + * @brief Macro for logging error messages. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes info logs. + */ + +/** @def NRF_LOG_DEBUG + * @brief Macro for logging error messages. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes debug logs. + */ + +#define NRF_LOG_ERROR(...) NRF_LOG_INTERNAL_ERROR(__VA_ARGS__) +#define NRF_LOG_WARNING(...) NRF_LOG_INTERNAL_WARNING( __VA_ARGS__) +#define NRF_LOG_INFO(...) NRF_LOG_INTERNAL_INFO( __VA_ARGS__) +#define NRF_LOG_DEBUG(...) NRF_LOG_INTERNAL_DEBUG( __VA_ARGS__) + +/** @def NRF_LOG_INST_ERROR + * @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @param p_inst Pointer to the instance with logging support. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ + +/** @def NRF_LOG_INST_WARNING + * @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @param p_inst Pointer to the instance with logging support. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ + +/** @def NRF_LOG_INST_INFO + * @brief Macro for logging error messages for a given module instance. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @param p_inst Pointer to the instance with logging support. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ + +/** @def NRF_LOG_INST_DEBUG + * @brief Macro for logging error messages for given module instance. It takes a printf-like, formatted + * string with up to seven arguments. + * + * @param p_inst Pointer to the instance with logging support. + * + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + */ +#define NRF_LOG_INST_ERROR(p_inst,...) NRF_LOG_INTERNAL_INST_ERROR(p_inst,__VA_ARGS__) +#define NRF_LOG_INST_WARNING(p_inst,...) NRF_LOG_INTERNAL_INST_WARNING(p_inst,__VA_ARGS__) +#define NRF_LOG_INST_INFO(p_inst,...) NRF_LOG_INTERNAL_INST_INFO(p_inst, __VA_ARGS__) +#define NRF_LOG_INST_DEBUG(p_inst,...) NRF_LOG_INTERNAL_INST_DEBUG(p_inst, __VA_ARGS__) + +/** + * @brief Macro for logging a formatted string without any prefix or timestamp. + */ +#define NRF_LOG_RAW_INFO(...) NRF_LOG_INTERNAL_RAW_INFO( __VA_ARGS__) + +/** @def NRF_LOG_HEXDUMP_ERROR + * @brief Macro for logging raw bytes. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_WARNING + * @brief Macro for logging raw bytes. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes warning logs. + * + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_INFO + * @brief Macro for logging raw bytes. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes info logs. + * + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_DEBUG + * @brief Macro for logging raw bytes. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes debug logs. + * + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +#define NRF_LOG_HEXDUMP_ERROR(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_ERROR(p_data, len) +#define NRF_LOG_HEXDUMP_WARNING(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_WARNING(p_data, len) +#define NRF_LOG_HEXDUMP_INFO(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INFO(p_data, len) +#define NRF_LOG_HEXDUMP_DEBUG(p_data, len) NRF_LOG_INTERNAL_HEXDUMP_DEBUG(p_data, len) + +/** @def NRF_LOG_HEXDUMP_INST_ERROR + * @brief Macro for logging raw bytes for a specific module instance. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_inst Pointer to the instance with logging support. + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_INST_WARNING + * @brief Macro for logging raw bytes for a specific module instance. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_inst Pointer to the instance with logging support. + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_INST_INFO + * @brief Macro for logging raw bytes for a specific module instance. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_inst Pointer to the instance with logging support. + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +/** @def NRF_LOG_HEXDUMP_INST_DEBUG + * @brief Macro for logging raw bytes for a specific module instance. + * @details This macro is compiled only if @ref NRF_LOG_LEVEL includes error logs. + * + * @param p_inst Pointer to the instance with logging support. + * @param p_data Pointer to data. + * @param len Data length in bytes. + */ +#define NRF_LOG_HEXDUMP_INST_ERROR(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_ERROR(p_inst, p_data, len) +#define NRF_LOG_HEXDUMP_INST_WARNING(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_WARNING(p_inst, p_data, len) +#define NRF_LOG_HEXDUMP_INST_INFO(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_INFO(p_inst, p_data, len) +#define NRF_LOG_HEXDUMP_INST_DEBUG(p_inst, p_data, len) NRF_LOG_INTERNAL_HEXDUMP_INST_DEBUG(p_inst, p_data, len) + +/** + * @brief Macro for logging hexdump without any prefix or timestamp. + */ +#define NRF_LOG_RAW_HEXDUMP_INFO(p_data, len) NRF_LOG_INTERNAL_RAW_HEXDUMP_INFO(p_data, len) + + +/** + * @brief Macro for copying a string to internal logger buffer if logs are deferred. + * + * @param _str String. + */ +#define NRF_LOG_PUSH(_str) NRF_LOG_INTERNAL_LOG_PUSH(_str) + +/** + * @brief Function for copying a string to the internal logger buffer if logs are deferred. + * + * Use this function to store a string that is volatile (for example allocated + * on stack) or that may change before the deferred logs are processed. Such string is copied + * into the internal logger buffer (see @ref NRF_LOG_STR_PUSH_BUFFER_SIZE). + * + * @note String storing is not reliable. It means that string is copied to the buffer but there is + * no indication when it was used and could be freed. String may be overwritten by another + * @ref nrf_log_push call before being processed. For reliable data dumping use + * hexdump macros (e.g. @ref NRF_LOG_HEXDUMP_INFO). + * + * @note If the logs are not deferred, then this function returns the input parameter. + * + * @param p_str Pointer to the user string. + * + * @return Address to the location where the string is stored in the internal logger buffer. + */ +char const * nrf_log_push(char * const p_str); + +/** + * @brief Macro to be used in a formatted string to a pass float number to the log. + * + * Use this macro in a formatted string instead of the %f specifier together with + * @ref NRF_LOG_FLOAT macro. + * Example: NRF_LOG_INFO("My float number" NRF_LOG_FLOAT_MARKER "\r\n", NRF_LOG_FLOAT(f))) + */ +#define NRF_LOG_FLOAT_MARKER "%s%d.%02d" + +/** + * @brief Macro for dissecting a float number into two numbers (integer and residuum). + */ +#define NRF_LOG_FLOAT(val) (uint32_t)(((val) < 0 && (val) > -1.0) ? "-" : ""), \ + (int32_t)(val), \ + (int32_t)((((val) > 0) ? (val) - (int32_t)(val) \ + : (int32_t)(val) - (val))*100) + + +/** + * @brief Macro for registering an independent module. + * + * Registration creates set of dynamic (RAM) and constant variables associated with the module. + */ +#define NRF_LOG_MODULE_REGISTER() NRF_LOG_INTERNAL_MODULE_REGISTER() + + +#ifdef __cplusplus +} +#endif + +#endif // NRF_LOG_H_ + +/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h new file mode 100644 index 000000000..33442b4f4 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h @@ -0,0 +1,516 @@ +/** + * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef NRF_LOG_INTERNAL_H__ +#define NRF_LOG_INTERNAL_H__ +#include "sdk_common.h" +#include "nrf.h" +#include "nrf_error.h" +#include "app_util.h" +#include +#include +#include "nrf_log_instance.h" +#include "nrf_log_types.h" + +#ifndef NRF_LOG_ERROR_COLOR + #define NRF_LOG_ERROR_COLOR NRF_LOG_COLOR_DEFAULT +#endif + +#ifndef NRF_LOG_WARNING_COLOR + #define NRF_LOG_WARNING_COLOR NRF_LOG_COLOR_DEFAULT +#endif + +#ifndef NRF_LOG_INFO_COLOR + #define NRF_LOG_INFO_COLOR NRF_LOG_COLOR_DEFAULT +#endif + +#ifndef NRF_LOG_DEBUG_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_LOG_COLOR_DEFAULT +#endif + + +#ifndef NRF_LOG_COLOR_DEFAULT +#define NRF_LOG_COLOR_DEFAULT 0 +#endif + +#ifndef NRF_LOG_DEFAULT_LEVEL +#define NRF_LOG_DEFAULT_LEVEL 0 +#endif + +#ifndef NRF_LOG_USES_COLORS +#define NRF_LOG_USES_COLORS 0 +#endif + +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +#ifndef NRF_LOG_MODULE_NAME + #define NRF_LOG_MODULE_NAME app +#endif + +#define NRF_LOG_LEVEL_BITS 3 +#define NRF_LOG_LEVEL_MASK ((1UL << NRF_LOG_LEVEL_BITS) - 1) +#define NRF_LOG_MODULE_ID_BITS 16 +#define NRF_LOG_MODULE_ID_POS 16 + + +#define NRF_LOG_MAX_NUM_OF_ARGS 6 + + +#if NRF_LOG_FILTERS_ENABLED && NRF_LOG_ENABLED + #define NRF_LOG_FILTER NRF_LOG_ITEM_DATA_DYNAMIC(NRF_LOG_MODULE_NAME).filter + #define NRF_LOG_INST_FILTER(p_inst) (p_inst)->filter +#else + #undef NRF_LOG_FILTER + #define NRF_LOG_FILTER NRF_LOG_SEVERITY_DEBUG + #define NRF_LOG_INST_FILTER(p_inst) NRF_LOG_SEVERITY_DEBUG +#endif + +/** + * @brief Macro for calculating module id based on address and section start address + */ +#define NRF_LOG_MODULE_ID_GET_CONST(addr) (((uint32_t)(addr) - \ + (uint32_t)NRF_SECTION_START_ADDR(log_const_data)) / \ + sizeof(nrf_log_module_const_data_t)) +/** + * @brief Macro for calculating module id based on address and section start address + */ +#define NRF_LOG_MODULE_ID_GET_DYNAMIC(addr) (((uint32_t)(addr) - \ + (uint32_t)NRF_SECTION_START_ADDR(log_dynamic_data)) / \ + sizeof(nrf_log_module_dynamic_data_t)) + + +#if NRF_LOG_ENABLED +#define NRF_LOG_MODULE_ID NRF_LOG_MODULE_ID_GET_CONST(&NRF_LOG_ITEM_DATA_CONST(NRF_LOG_MODULE_NAME)) +#if NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_INST_ID(p_inst) NRF_LOG_MODULE_ID_GET_DYNAMIC(p_inst) +#else +#define NRF_LOG_INST_ID(p_inst) NRF_LOG_MODULE_ID +#endif +#else +#define NRF_LOG_MODULE_ID 0 +#define NRF_LOG_INST_ID(p_inst) 0 +#endif + + +#define LOG_INTERNAL_X(N, ...) CONCAT_2(LOG_INTERNAL_, N) (__VA_ARGS__) +#define LOG_INTERNAL(type, ...) LOG_INTERNAL_X(NUM_VA_ARGS_LESS_1( \ + __VA_ARGS__), type, __VA_ARGS__) +#if NRF_LOG_ENABLED +#define NRF_LOG_INTERNAL_LOG_PUSH(_str) nrf_log_push(_str) +#define LOG_INTERNAL_0(type, str) \ + nrf_log_frontend_std_0(type, str) +#define LOG_INTERNAL_1(type, str, arg0) \ + /*lint -save -e571*/nrf_log_frontend_std_1(type, str, (uint32_t)(arg0))/*lint -restore*/ +#define LOG_INTERNAL_2(type, str, arg0, arg1) \ + /*lint -save -e571*/nrf_log_frontend_std_2(type, str, (uint32_t)(arg0), \ + (uint32_t)(arg1))/*lint -restore*/ +#define LOG_INTERNAL_3(type, str, arg0, arg1, arg2) \ + /*lint -save -e571*/nrf_log_frontend_std_3(type, str, (uint32_t)(arg0), \ + (uint32_t)(arg1), (uint32_t)(arg2))/*lint -restore*/ +#define LOG_INTERNAL_4(type, str, arg0, arg1, arg2, arg3) \ + /*lint -save -e571*/nrf_log_frontend_std_4(type, str, (uint32_t)(arg0), \ + (uint32_t)(arg1), (uint32_t)(arg2), (uint32_t)(arg3))/*lint -restore*/ +#define LOG_INTERNAL_5(type, str, arg0, arg1, arg2, arg3, arg4) \ + /*lint -save -e571*/nrf_log_frontend_std_5(type, str, (uint32_t)(arg0), \ + (uint32_t)(arg1), (uint32_t)(arg2), (uint32_t)(arg3), (uint32_t)(arg4))/*lint -restore*/ +#define LOG_INTERNAL_6(type, str, arg0, arg1, arg2, arg3, arg4, arg5) \ + /*lint -save -e571*/nrf_log_frontend_std_6(type, str, (uint32_t)(arg0), \ + (uint32_t)(arg1), (uint32_t)(arg2), (uint32_t)(arg3), (uint32_t)(arg4), (uint32_t)(arg5))/*lint -restore*/ + + +#else //NRF_LOG_ENABLED +#define NRF_LOG_INTERNAL_LOG_PUSH(_str) (void)(_str) +#define LOG_INTERNAL_0(_type, _str) \ + (void)(_type); (void)(_str) +#define LOG_INTERNAL_1(_type, _str, _arg0) \ + (void)(_type); (void)(_str); (void)(_arg0) +#define LOG_INTERNAL_2(_type, _str, _arg0, _arg1) \ + (void)(_type); (void)(_str); (void)(_arg0); (void)(_arg1) +#define LOG_INTERNAL_3(_type, _str, _arg0, _arg1, _arg2) \ + (void)(_type); (void)(_str); (void)(_arg0); (void)(_arg1); (void)(_arg2) +#define LOG_INTERNAL_4(_type, _str, _arg0, _arg1, _arg2, _arg3) \ + (void)(_type); (void)(_str); (void)(_arg0); (void)(_arg1); (void)(_arg2); (void)(_arg3) +#define LOG_INTERNAL_5(_type, _str, _arg0, _arg1, _arg2, _arg3, _arg4) \ + (void)(_type); (void)(_str); (void)(_arg0); (void)(_arg1); (void)(_arg2); (void)(_arg3); (void)(_arg4) +#define LOG_INTERNAL_6(_type, _str, _arg0, _arg1, _arg2, _arg3, _arg4, _arg5) \ + (void)(_type); (void)(_str); (void)(_arg0); (void)(_arg1); (void)(_arg2); (void)(_arg3); (void)(_arg4); (void)(_arg5) +#endif //NRF_LOG_ENABLED + +#define LOG_SEVERITY_MOD_ID(severity) ((severity) | NRF_LOG_MODULE_ID << NRF_LOG_MODULE_ID_POS) +#define LOG_SEVERITY_INST_ID(severity,p_inst) ((severity) | NRF_LOG_INST_ID(p_inst) << NRF_LOG_MODULE_ID_POS) + +#if NRF_LOG_ENABLED +#define LOG_HEXDUMP(_severity, _p_data, _length) \ + nrf_log_frontend_hexdump((_severity), (_p_data), (_length)) +#else +#define LOG_HEXDUMP(_severity, _p_data, _length) \ + (void)(_severity); (void)(_p_data); (void)_length +#endif + +#define NRF_LOG_INTERNAL_INST(level, level_id, p_inst, ...) \ + if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) && \ + (level <= NRF_LOG_DEFAULT_LEVEL)) \ + { \ + if (NRF_LOG_INST_FILTER(p_inst) >= level) \ + { \ + LOG_INTERNAL(LOG_SEVERITY_INST_ID(level_id, p_inst), __VA_ARGS__); \ + } \ + } + +#define NRF_LOG_INTERNAL_MODULE(level, level_id, ...) \ + if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) && \ + (level <= NRF_LOG_DEFAULT_LEVEL)) \ + { \ + if (NRF_LOG_FILTER >= level) \ + { \ + LOG_INTERNAL(LOG_SEVERITY_MOD_ID(level_id), __VA_ARGS__); \ + } \ + } + +#define NRF_LOG_INTERNAL_HEXDUMP_INST(level, level_id, p_inst, p_data, len) \ + if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) && \ + (level <= NRF_LOG_DEFAULT_LEVEL)) \ + { \ + if (NRF_LOG_INST_FILTER(p_inst) >= level) \ + { \ + LOG_HEXDUMP(LOG_SEVERITY_INST_ID(level_id, p_inst), \ + (p_data), (len)); \ + } \ + } + +#define NRF_LOG_INTERNAL_HEXDUMP_MODULE(level, level_id, p_data, len) \ + if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) && \ + (level <= NRF_LOG_DEFAULT_LEVEL)) \ + { \ + if (NRF_LOG_FILTER >= level) \ + { \ + LOG_HEXDUMP(LOG_SEVERITY_MOD_ID(level_id), \ + (p_data), (len)); \ + } \ + } + +#define NRF_LOG_INTERNAL_INST_ERROR(p_inst, ...) \ + NRF_LOG_INTERNAL_INST(NRF_LOG_SEVERITY_ERROR, NRF_LOG_SEVERITY_ERROR, p_inst, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_ERROR(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_ERROR, NRF_LOG_SEVERITY_ERROR,__VA_ARGS__) + +#define NRF_LOG_INTERNAL_HEXDUMP_INST_ERROR(p_inst, p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_INST(NRF_LOG_SEVERITY_ERROR, NRF_LOG_SEVERITY_ERROR, p_inst, p_data, len) + +#define NRF_LOG_INTERNAL_HEXDUMP_ERROR(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_ERROR, NRF_LOG_SEVERITY_ERROR, p_data, len) + +#define NRF_LOG_INTERNAL_INST_WARNING(p_inst, ...) \ + NRF_LOG_INTERNAL_INST(NRF_LOG_SEVERITY_WARNING, NRF_LOG_SEVERITY_WARNING, p_inst, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_WARNING(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_WARNING, NRF_LOG_SEVERITY_WARNING,__VA_ARGS__) + +#define NRF_LOG_INTERNAL_HEXDUMP_INST_WARNING(p_inst, p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_INST(NRF_LOG_SEVERITY_WARNING, NRF_LOG_SEVERITY_WARNING, p_inst, p_data, len) + +#define NRF_LOG_INTERNAL_HEXDUMP_WARNING(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_WARNING, NRF_LOG_SEVERITY_WARNING, p_data, len) + +#define NRF_LOG_INTERNAL_INST_INFO(p_inst, ...) \ + NRF_LOG_INTERNAL_INST(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO, p_inst, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_INFO(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_HEXDUMP_INST_INFO(p_inst, p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_INST(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO, p_inst, p_data, len) + +#define NRF_LOG_INTERNAL_HEXDUMP_INFO(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO, p_data, len) + +#define NRF_LOG_INTERNAL_RAW_INFO(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO_RAW, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_RAW_HEXDUMP_INFO(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_INFO, NRF_LOG_SEVERITY_INFO_RAW, p_data, len) + +#define NRF_LOG_INTERNAL_INST_DEBUG(p_inst, ...) \ + NRF_LOG_INTERNAL_INST(NRF_LOG_SEVERITY_DEBUG, NRF_LOG_SEVERITY_DEBUG, p_inst, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_DEBUG(...) \ + NRF_LOG_INTERNAL_MODULE(NRF_LOG_SEVERITY_DEBUG, NRF_LOG_SEVERITY_DEBUG, __VA_ARGS__) + +#define NRF_LOG_INTERNAL_HEXDUMP_INST_DEBUG(p_inst, p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_INST(NRF_LOG_SEVERITY_DEBUG, NRF_LOG_SEVERITY_DEBUG, p_inst, p_data, len) + +#define NRF_LOG_INTERNAL_HEXDUMP_DEBUG(p_data, len) \ + NRF_LOG_INTERNAL_HEXDUMP_MODULE(NRF_LOG_SEVERITY_DEBUG, NRF_LOG_SEVERITY_DEBUG, p_data, len) + + +#if NRF_LOG_ENABLED + +#ifdef UNIT_TEST +#define COMPILED_LOG_LEVEL 4 +#else +#define COMPILED_LOG_LEVEL NRF_LOG_LEVEL +#endif + + +#define NRF_LOG_INTERNAL_MODULE_REGISTER() \ + NRF_LOG_INTERNAL_ITEM_REGISTER(NRF_LOG_MODULE_NAME, \ + STRINGIFY(NRF_LOG_MODULE_NAME), \ + NRF_LOG_INFO_COLOR, \ + NRF_LOG_DEBUG_COLOR, \ + NRF_LOG_INITIAL_LEVEL, \ + COMPILED_LOG_LEVEL) + +#else +#define NRF_LOG_INTERNAL_MODULE_REGISTER() /*lint -save -e19*/ /*lint -restore*/ +#endif + +extern nrf_log_module_dynamic_data_t NRF_LOG_ITEM_DATA_DYNAMIC(NRF_LOG_MODULE_NAME); +extern _CONST nrf_log_module_const_data_t NRF_LOG_ITEM_DATA_CONST(NRF_LOG_MODULE_NAME); + +/** + * Set of macros for encoding and decoding header for log entries. + * There are 2 types of entries: + * 1. Standard entry (STD) + * An entry consists of header, pointer to string and values. Header contains + * severity leveland determines number of arguments and thus size of the entry. + * Since flash address space starts from 0x00000000 and is limited to kB rather + * than MB 22 bits are used to store the address (4MB). It is used that way to + * save one RAM memory. + * + * -------------------------------- + * |TYPE|SEVERITY|NARGS| P_STR | + * |------------------------------| + * | Module_ID (optional) | + * |------------------------------| + * | TIMESTAMP (optional) | + * |------------------------------| + * | ARG0 | + * |------------------------------| + * | .... | + * |------------------------------| + * | ARG(nargs-1) | + * -------------------------------- + * + * 2. Hexdump entry (HEXDUMP) is used for dumping raw data. An entry consists of + * header, optional timestamp, pointer to string and data. A header contains + * length (10bit) and offset which is updated after backend processes part of + * data. + * + * -------------------------------- + * |TYPE|SEVERITY|NARGS|OFFSET|LEN| + * |------------------------------| + * | Module_ID (optional) | + * |------------------------------| + * | TIMESTAMP (optional) | + * |------------------------------| + * | P_STR | + * |------------------------------| + * | data | + * |------------------------------| + * | data | dummy | + * -------------------------------- + * + */ + +#define STD_ADDR_MASK ((uint32_t)(1U << 22) - 1U) +#define HEADER_TYPE_STD 1U +#define HEADER_TYPE_HEXDUMP 2U +#define HEADER_TYPE_INVALID 3U + +typedef struct +{ + uint32_t type : 2; + uint32_t in_progress: 1; + uint32_t data : 29; +} nrf_log_generic_header_t; + +typedef struct +{ + uint32_t type : 2; + uint32_t in_progress: 1; + uint32_t severity : 3; + uint32_t nargs : 4; + uint32_t addr : 22; +} nrf_log_std_header_t; + +typedef struct +{ + uint32_t type : 2; + uint32_t in_progress: 1; + uint32_t severity : 3; + uint32_t offset : 10; + uint32_t reserved : 6; + uint32_t len : 10; +} nrf_log_hexdump_header_t; + +typedef union +{ + nrf_log_generic_header_t generic; + nrf_log_std_header_t std; + nrf_log_hexdump_header_t hexdump; + uint32_t raw; +} nrf_log_main_header_t; + +typedef struct +{ + nrf_log_main_header_t base; + uint16_t module_id; + uint16_t dropped; + uint32_t timestamp; +} nrf_log_header_t; + +#define HEADER_SIZE (sizeof(nrf_log_header_t)/sizeof(uint32_t) - \ + (NRF_LOG_USES_TIMESTAMP ? 0 : 1)) + +/** + * @brief A function for logging raw string. + * + * @param severity_mid Severity. + * @param p_str A pointer to a string. + */ +void nrf_log_frontend_std_0(uint32_t severity_mid, char const * const p_str); + +/** + * @brief A function for logging a formatted string with one argument. + * + * @param severity_mid Severity. + * @param p_str A pointer to a formatted string. + * @param val0 An argument. + */ +void nrf_log_frontend_std_1(uint32_t severity_mid, + char const * const p_str, + uint32_t val0); + +/** + * @brief A function for logging a formatted string with 2 arguments. + * + * @param severity_mid Severity. + * @param p_str A pointer to a formatted string. + * @param val0, val1 Arguments for formatting string. + */ +void nrf_log_frontend_std_2(uint32_t severity_mid, + char const * const p_str, + uint32_t val0, + uint32_t val1); + +/** + * @brief A function for logging a formatted string with 3 arguments. + * + * @param severity_mid Severity. + * @param p_str A pointer to a formatted string. + * @param val0, val1, val2 Arguments for formatting string. + */ +void nrf_log_frontend_std_3(uint32_t severity_mid, + char const * const p_str, + uint32_t val0, + uint32_t val1, + uint32_t val2); + +/** + * @brief A function for logging a formatted string with 4 arguments. + * + * @param severity_mid Severity. + * @param p_str A pointer to a formatted string. + * @param val0, val1, val2, val3 Arguments for formatting string. + */ +void nrf_log_frontend_std_4(uint32_t severity_mid, + char const * const p_str, + uint32_t val0, + uint32_t val1, + uint32_t val2, + uint32_t val3); + +/** + * @brief A function for logging a formatted string with 5 arguments. + * + * @param severity_mid Severity. + * @param p_str A pointer to a formatted string. + * @param val0, val1, val2, val3, val4 Arguments for formatting string. + */ +void nrf_log_frontend_std_5(uint32_t severity_mid, + char const * const p_str, + uint32_t val0, + uint32_t val1, + uint32_t val2, + uint32_t val3, + uint32_t val4); + +/** + * @brief A function for logging a formatted string with 6 arguments. + * + * @param severity_mid Severity. + * @param p_str A pointer to a formatted string. + * @param val0, val1, val2, val3, val4, val5 Arguments for formatting string. + */ +void nrf_log_frontend_std_6(uint32_t severity_mid, + char const * const p_str, + uint32_t val0, + uint32_t val1, + uint32_t val2, + uint32_t val3, + uint32_t val4, + uint32_t val5); + +/** + * @brief A function for logging raw data. + * + * @param severity_mid Severity. + * @param p_str A pointer to a string which is prefixing the data. + * @param p_data A pointer to data to be dumped. + * @param length Length of data (in bytes). + * + */ +void nrf_log_frontend_hexdump(uint32_t severity_mid, + const void * const p_data, + uint16_t length); + +/** + * @brief A function for reading a byte from log backend. + * + * @return Byte. + */ +uint8_t nrf_log_getchar(void); +#endif // NRF_LOG_INTERNAL_H__ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h index 08f36ec7b..70cd32062 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h @@ -43,6 +43,12 @@ #ifndef SDK_CONFIG_H #define SDK_CONFIG_H +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + // nRF_SoftDevice //========================================================== @@ -167,6 +173,178 @@ #define NRF_SECTION_ITER_ENABLED 1 #endif +// NRF_LOG_DEFAULT_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LOG_DEFAULT_LEVEL +#define NRF_LOG_DEFAULT_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +//========================================================== +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 +#endif +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 +#endif + +// NRF_SDH_BLE_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 +#endif + +// NRF_SDH_BLE_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 +#endif + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + // //========================================================== From 5e1c599828ee21935331a1f9722535524d83d1e6 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 4 Jul 2022 20:29:09 +0900 Subject: [PATCH 14/52] externals/nrf52: Modify log output codes for spresense Modify for spresense to output logs to standard output. --- .../libraries/log/src/nrf_log_internal.h | 15 ++++-- .../components/libraries/queue/nrf_queue.c | 32 +++++------ .../application/transport/ser_sd_transport.c | 13 ++--- .../transport/ser_softdevice_handler.c | 13 ++--- .../common/transport/ser_hal_transport.c | 20 +++---- .../common/transport/ser_phy/ser_phy_uart.c | 14 ++--- .../softdevice/common/nrf_sdh_ble.c | 18 ++++--- .../config/nrf52832/config/sdk_config.h | 54 +++++++++++++++++++ 8 files changed, 124 insertions(+), 55 deletions(-) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h index 33442b4f4..efc8c636a 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h @@ -45,6 +45,7 @@ #include "app_util.h" #include #include +#include #include "nrf_log_instance.h" #include "nrf_log_types.h" @@ -134,9 +135,13 @@ #endif -#define LOG_INTERNAL_X(N, ...) CONCAT_2(LOG_INTERNAL_, N) (__VA_ARGS__) -#define LOG_INTERNAL(type, ...) LOG_INTERNAL_X(NUM_VA_ARGS_LESS_1( \ - __VA_ARGS__), type, __VA_ARGS__) +#define stringify(x) #x +#define MODULE_NAME(x) stringify(x) +#define LOG_INTERNAL(level, ...) \ + printf("[" #level "][%s] ", MODULE_NAME(NRF_LOG_MODULE_NAME)); \ + printf(__VA_ARGS__); \ + printf("\n"); + #if NRF_LOG_ENABLED #define NRF_LOG_INTERNAL_LOG_PUSH(_str) nrf_log_push(_str) #define LOG_INTERNAL_0(type, str) \ @@ -195,7 +200,7 @@ { \ if (NRF_LOG_INST_FILTER(p_inst) >= level) \ { \ - LOG_INTERNAL(LOG_SEVERITY_INST_ID(level_id, p_inst), __VA_ARGS__); \ + LOG_INTERNAL(level, __VA_ARGS__); \ } \ } @@ -205,7 +210,7 @@ { \ if (NRF_LOG_FILTER >= level) \ { \ - LOG_INTERNAL(LOG_SEVERITY_MOD_ID(level_id), __VA_ARGS__); \ + LOG_INTERNAL(level, __VA_ARGS__); \ } \ } diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c index e6e490ff8..2c0e39b1e 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c @@ -42,15 +42,15 @@ #include "nrf_queue.h" #include "app_util_platform.h" -//#define BLE_DBGPRT_ENABLE -#ifdef BLE_DBGPRT_ENABLE -#include -#define NRF_LOG_INST_WARNING printf -#define NRF_LOG_INST_DEBUG(...) +#if NRF_QUEUE_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL NRF_QUEUE_CONFIG_LOG_LEVEL + #define NRF_LOG_INIT_FILTER_LEVEL NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL + #define NRF_LOG_INFO_COLOR NRF_QUEUE_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_QUEUE_CONFIG_DEBUG_COLOR #else -#define NRF_LOG_INST_WARNING(...) -#define NRF_LOG_INST_DEBUG(...) -#endif + #define NRF_LOG_LEVEL 0 +#endif // NRF_QUEUE_CONFIG_LOG_ENABLED +#include "nrf_log.h" #define __STATIC_INLINE static __inline @@ -221,7 +221,7 @@ ret_code_t nrf_queue_push(nrf_queue_t const * p_queue, void const * p_element) CRITICAL_REGION_EXIT(); - NRF_LOG_INST_DEBUG(p_queue->p_log, "pushed element 0x%08X, status:%d", p_element, status); + NRF_LOG_INST_DEBUG(p_queue->p_log, "pushed element 0x%p, status:%ld", p_element, status); return status; } @@ -279,7 +279,7 @@ ret_code_t nrf_queue_generic_pop(nrf_queue_t const * p_queue, } CRITICAL_REGION_EXIT(); - NRF_LOG_INST_DEBUG(p_queue->p_log, "%s element 0x%08X, status:%d", + NRF_LOG_INST_DEBUG(p_queue->p_log, "%s element 0x%p, status:%ld", just_peek ? "peeked" : "popped", p_element, status); return status; } @@ -384,7 +384,7 @@ ret_code_t nrf_queue_write(nrf_queue_t const * p_queue, CRITICAL_REGION_EXIT(); - NRF_LOG_INST_DEBUG(p_queue->p_log, "Write %d elements (start address: 0x%08X), status:%d", + NRF_LOG_INST_DEBUG(p_queue->p_log, "Write %d elements (start address: 0x%p), status:%ld", element_count, p_data, status); return status; } @@ -397,6 +397,8 @@ size_t nrf_queue_in(nrf_queue_t const * p_queue, ASSERT(p_queue != NULL); ASSERT(p_data != NULL); + size_t req_element_count = element_count; + if (element_count == 0) { return 0; @@ -418,7 +420,7 @@ size_t nrf_queue_in(nrf_queue_t const * p_queue, CRITICAL_REGION_EXIT(); - NRF_LOG_INST_DEBUG(p_queue->p_log, "Put in %d elements (start address: 0x%08X), requested :%d", + NRF_LOG_INST_DEBUG(p_queue->p_log, "Put in %d elements (start address: 0x%p), requested :%d", element_count, p_data, req_element_count); return element_count; @@ -491,7 +493,7 @@ ret_code_t nrf_queue_read(nrf_queue_t const * p_queue, CRITICAL_REGION_EXIT(); - NRF_LOG_INST_DEBUG(p_queue->p_log, "Read %d elements (start address: 0x%08X), status :%d", + NRF_LOG_INST_DEBUG(p_queue->p_log, "Read %d elements (start address: 0x%p), status :%ld", element_count, p_data, status); return status; } @@ -503,7 +505,7 @@ size_t nrf_queue_out(nrf_queue_t const * p_queue, ASSERT(p_queue != NULL); ASSERT(p_data != NULL); - //size_t req_element_count = element_count; + size_t req_element_count = element_count; if (element_count == 0) { @@ -519,7 +521,7 @@ size_t nrf_queue_out(nrf_queue_t const * p_queue, CRITICAL_REGION_EXIT(); - NRF_LOG_INST_DEBUG(p_queue->p_log, "Out %d elements (start address: 0x%08X), requested :%d", + NRF_LOG_INST_DEBUG(p_queue->p_log, "Out %d elements (start address: 0x%p), requested :%d", element_count, p_data, req_element_count); return element_count; } diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c index 2eb8eb98a..84831af31 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c @@ -48,14 +48,15 @@ //#include "ser_dbg_sd_str.h" #include "ser_app_power_system_off.h" #include "app_util.h" - -#define BLE_DBGPRT_ENABLE -#ifdef BLE_DBGPRT_ENABLE -#include -#define NRF_LOG_DEBUG printf +#include "sdk_config.h" +#define NRF_LOG_MODULE_NAME ser_sd_transport +#if SER_SD_TRANSPORT_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL SER_SD_TRANSPORT_CONFIG_LOG_LEVEL #else -#define NRF_LOG_DEBUG(...) + #define NRF_LOG_LEVEL 0 #endif +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #ifdef BLE_STACK_SUPPORT_REQD /** SoftDevice event handler. */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c index b57464a58..14ad39a38 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c @@ -61,13 +61,14 @@ #include "ant_event.h" #endif -//#define BLE_DBGPRT_ENABLE -#ifdef BLE_DBGPRT_ENABLE -#include -#define NRF_LOG_DEBUG printf -#else -#define NRF_LOG_DEBUG(...) +#define NRF_LOG_MODULE_NAME ser_sd_handler +#if SER_SD_HANDLER_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL SER_SD_HANDLER_CONFIG_LOG_LEVEL +#else + #define NRF_LOG_LEVEL 0 #endif +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #define SD_BLE_EVT_MAILBOX_QUEUE_SIZE 5 /**< Size of mailbox queue. */ #define SD_BLE_RESPONSE_TIMEOUT 5000 diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c index 55e835804..2f923e80f 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c @@ -46,14 +46,16 @@ #include "ser_hal_transport.h" #include "nrf_error.h" -//#define BLE_DBGPRT_ENABLE -#ifdef BLE_DBGPRT_ENABLE -#include -#define NRF_LOG_INFO printf -#else -#define NRF_LOG_INFO(...) -#endif - +#define NRF_LOG_MODULE_NAME ser_hal_transport +#if SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL + #define NRF_LOG_INFO_COLOR SER_HAL_TRANSPORT_CONFIG_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#else //SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL 0 +#endif //SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); /** * @brief States of the RX state machine. @@ -363,7 +365,7 @@ void ser_hal_transport_close(void) uint32_t ser_hal_transport_rx_pkt_free(uint8_t * p_buffer) { - NRF_LOG_INFO("rx pkt free:%d", p_buffer); + NRF_LOG_INFO("rx pkt free:%p", p_buffer); uint32_t err_code = NRF_SUCCESS; ser_phy_interrupts_disable(); diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c index 949ff145a..e8abdf765 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c @@ -60,14 +60,16 @@ #include "app_util.h" #include "app_util_platform.h" #include "nrf_error.h" +#include "sdk_config.h" -//#define BLE_DBGPRT_ENABLE -#ifdef BLE_DBGPRT_ENABLE -#include -#define NRF_LOG_DEBUG printf +#define NRF_LOG_MODULE_NAME ser_phy_uart +#if SER_PHY_UART_CONFIG_LOG_ENABLED + #define NRF_LOG_LEVEL SER_PHY_UART_CONFIG_LOG_LEVEL #else -#define NRF_LOG_DEBUG(...) -#endif + #define NRF_LOG_LEVEL 0 +#endif +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #define BLE_UART_FILE "/dev/ttyS2" diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c index 4e2db2578..8806634fa 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c @@ -47,15 +47,17 @@ #include "app_error.h" #include "nrf_strerror.h" -//#define BLE_DBGPRT_ENABLE -#ifdef BLE_DBGPRT_ENABLE -#include -#define NRF_LOG_ERROR printf -#define NRF_LOG_DEBUG printf + +#define NRF_LOG_MODULE_NAME nrf_sdh_ble +#if NRF_SDH_BLE_LOG_ENABLED + #define NRF_LOG_LEVEL NRF_SDH_BLE_LOG_LEVEL + #define NRF_LOG_INFO_COLOR NRF_SDH_BLE_INFO_COLOR + #define NRF_LOG_DEBUG_COLOR NRF_SDH_BLE_DEBUG_COLOR #else -#define NRF_LOG_ERROR(...) -#define NRF_LOG_DEBUG(...) -#endif + #define NRF_LOG_LEVEL 0 +#endif // NRF_SDH_BLE_LOG_ENABLED +#include "nrf_log.h" +NRF_LOG_MODULE_REGISTER(); #ifndef NOT_USE_NRF_SECTION // Create section set "sdh_ble_observers". diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h index 70cd32062..4a5ed60ff 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h @@ -345,6 +345,60 @@ #define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 #endif +//========================================================== +// SER_SD_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_SD_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_SD_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_SD_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_SD_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_SD_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +//========================================================== +// SER_SD_HANDLER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_SD_HANDLER_CONFIG_LOG_ENABLED +#define SER_SD_HANDLER_CONFIG_LOG_ENABLED 0 +#endif +// SER_SD_HANDLER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_SD_HANDLER_CONFIG_LOG_LEVEL +#define SER_SD_HANDLER_CONFIG_LOG_LEVEL 3 +#endif + +//========================================================== +// SER_SD_HANDLER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_PHY_UART_CONFIG_LOG_ENABLED +#define SER_PHY_UART_CONFIG_LOG_ENABLED 0 +#endif +// SER_PHY_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_PHY_UART_CONFIG_LOG_LEVEL +#define SER_PHY_UART_CONFIG_LOG_LEVEL 3 +#endif + // //========================================================== From b0edb13f4eb55835a120c6d73fc21859e2419b56 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 5 Jul 2022 21:00:03 +0900 Subject: [PATCH 15/52] externals/nrf52: Add configuration for log output Add configuration for log output and porting header file which converts Kconfig values to nRF library configuration values. --- externals/nrf52/Kconfig | 68 +++++++++++ .../config/nrf52832/config/nrf_porting.h | 115 ++++++++++++++++++ .../config/nrf52832/config/sdk_config.h | 2 + 3 files changed, 185 insertions(+) create mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h diff --git a/externals/nrf52/Kconfig b/externals/nrf52/Kconfig index 8905f268b..53fb4d1c4 100644 --- a/externals/nrf52/Kconfig +++ b/externals/nrf52/Kconfig @@ -23,5 +23,73 @@ config EXTERNALS_NRF52_S132 endchoice +config EXTERNALS_NRF52_OUTPUT_LOG_LEVEL + int "Output log level" + default 2 + range 0 4 + ---help--- + Set output log level, whose value means the following: + - 0: off + - 1: error + - 2: warning + - 3: information + - 4: debug + The log levels of each components can be adjusted by the following + configurations: + - EXTERNALS_NRF52_NRF_QUEUE_LOG_LEVEL + - EXTERNALS_NRF52_NRF_SDH_BLE_LOG_LEVEL + - EXTERNALS_NRF52_SER_HAL_TRANSPORT_LOG_LEVEL + - EXTERNALS_NRF52_SER_SD_TRANPORT_LOG_LEVEL + - EXTERNALS_NRF52_SER_SD_HANDLER_LOG_LEVEL + - EXTERNALS_NRF52_SER_PHY_UART_LOG_LEVEL + The log levels of each components are valid only if they are + EXTERNALS_NRF52_OUTPUT_LOG_LEVEL value or less. + Therefore, EXTERNALS_NRF52_OUTPUT_LOG_LEVEL needs to be set to more detailed + setting, when more detailed log of each components is needed. + +if EXTERNALS_NRF52_OUTPUT_LOG_LEVEL > 0 +config EXTERNALS_NRF52_NRF_QUEUE_LOG_LEVEL + int "Log level of nrf_queue component" + default 4 + range 0 4 + ---help--- + Set log level of nrf_queue component. + +config EXTERNALS_NRF52_NRF_SDH_BLE_LOG_LEVEL + int "Log level of nrf_sdh_ble component" + default 4 + range 0 4 + ---help--- + Set log level of nrf_sdh_ble component. + +config EXTERNALS_NRF52_SER_HAL_TRANSPORT_LOG_LEVEL + int "Log level of ser_hal_transport component" + default 4 + range 0 4 + ---help--- + Set log level of ser_hal_transport component. + +config EXTERNALS_NRF52_SER_SD_TRANSPORT_LOG_LEVEL + int "Log level of ser_sd_transport component" + default 4 + range 0 4 + ---help--- + Set log level of ser_sd_transport component. + +config EXTERNALS_NRF52_SER_SD_HANDLER_LOG_LEVEL + int "Log level of ser_sd_handler component" + default 4 + range 0 4 + ---help--- + Set log level of ser_sd_handler component. + +config EXTERNALS_NRF52_SER_PHY_UART_LOG_LEVEL + int "Log level of ser_phy_uart component" + default 4 + range 0 4 + ---help--- + Set log level of ser_phy_uart component. + +endif # EXTERNALS_NRF52_OUTPUT_LOG_LEVEL > 0 endif # EXTERNALS_NRF52 diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h new file mode 100644 index 000000000..1372ef563 --- /dev/null +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h @@ -0,0 +1,115 @@ +/**************************************************************************** + * nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef NRF_PORTING_H +#define NRF_PORTING_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_EXTERNALS_NRF52_OUTPUT_LOG_LEVEL +# if CONFIG_EXTERNALS_NRF52_OUTPUT_LOG_LEVEL > 0 +# define NRF_LOG_ENABLED 1 +# define NRF_LOG_DEFAULT_LEVEL CONFIG_EXTERNALS_NRF52_OUTPUT_LOG_LEVEL + +/* configuration for nrf_queue component */ + +# ifdef CONFIG_EXTERNALS_NRF52_NRF_QUEUE_LOG_LEVEL +# define NRF_QUEUE_CONFIG_LOG_LEVEL \ + CONFIG_EXTERNALS_NRF52_NRF_QUEUE_LOG_LEVEL +# if NRF_QUEUE_CONFIG_LOG_LEVEL > 0 +# define NRF_QUEUE_CONFIG_LOG_ENABLED 1 +# endif /* NRF_QUEUE_CONFIG_LOG_LEVEL > 0 */ +# endif /* CONFIG_EXTERNALS_NRF52_NRF_QUEUE_LOG_LEVEL */ + +/* configuration for nrf_sdh_ble component */ + +# ifdef CONFIG_EXTERNALS_NRF52_NRF_SDH_BLE_LOG_LEVEL +# define NRF_SDH_BLE_CONFIG_LOG_LEVEL \ + CONFIG_EXTERNALS_NRF52_NRF_SDH_BLE_LOG_LEVEL +# if NRF_SDH_BLE_CONFIG_LOG_LEVEL!=0 +# define NRF_SDH_BLE_CONFIG_LOG_ENABLED 1 +# endif /* NRF_SDH_BLE_CONFIG_LOG_LEVEL > 0 */ +# endif /* CONFIG_EXTERNALS_NRF52_NRF_SDH_BLE_LOG_LEVEL */ + +/* configuration for ser_hal_transport component */ + +# ifdef CONFIG_EXTERNALS_NRF52_SER_HAL_TRANSPORT_LOG_LEVEL +# define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL \ + CONFIG_EXTERNALS_NRF52_SER_HAL_TRANSPORT_LOG_LEVEL +# if SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL > 0 +# define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 1 +# endif /* SER_HAL_TRANSPORT_CONFIG_LOG_LEVELi > 0 */ +# endif /* CONFIG_EXTERNALS_NRF52_SER_HAL_TRANSPORT_LOG_LEVEL */ + +/* configuration for ser_sd_transport component */ + +# ifdef CONFIG_EXTERNALS_NRF52_SER_SD_TRANSPORT_LOG_LEVEL +# define SER_SD_TRANSPORT_CONFIG_LOG_LEVEL \ + CONFIG_EXTERNALS_NRF52_SER_SD_TRANSPORT_LOG_LEVEL +# if SER_SD_TRANSPORT_CONFIG_LOG_LEVEL > 0 +# define SER_SD_TRANSPORT_CONFIG_LOG_ENABLED 1 +# endif /* SER_SD_TRANSPORT_CONFIG_LOG_LEVEL > 0 */ +# endif /* CONFIG_EXTERNALS_NRF52_SER_SD_TRANSPORT_LOG_LEVEL */ + +/* configuration for ser_sd_handler component */ + +# ifdef CONFIG_EXTERNALS_NRF52_SER_SD_HANDLER_LOG_LEVEL +# define SER_SD_HANDLER_CONFIG_LOG_LEVEL \ + CONFIG_EXTERNALS_NRF52_SER_SD_HANDLER_LOG_LEVEL +# if SER_SD_HANDLER_CONFIG_LOG_LEVEL > 0 +# define SER_SD_HANDLER_CONFIG_LOG_ENABLED 1 +# endif /* SER_SD_HANDLER_CONFIG_LOG_LEVEL > 0 */ +# endif /* CONFIG_EXTERNALS_NRF52_SER_SD_HANDLER_LOG_LEVEL */ + +/* configuration for ser_phy_uart component */ + +# ifdef CONFIG_EXTERNALS_NRF52_SER_PHY_UART_LOG_LEVEL +# define SER_PHY_UART_CONFIG_LOG_LEVEL \ + CONFIG_EXTERNALS_NRF52_SER_PHY_UART_LOG_LEVEL +# if SER_PHY_UART_CONFIG_LOG_LEVEL > 0 +# define SER_PHY_UART_CONFIG_LOG_ENABLED 1 +# endif /* SER_PHY_UART_CONFIG_LOG_LEVEL > 0 */ +# endif /* CONFIG_EXTERNALS_NRF52_SER_PHY_UART_LOG_LEVEL */ +# endif /* CONFIG_EXTERNALS_NRF52_OUTPUT_LOG_LEVEL > 0 */ +#endif /* CONFIG_EXTERNALS_NRF52_OUTPUT_LOG_LEVEL */ +#endif /* NRF_PORTING_H */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h index 4a5ed60ff..a6ab3ba46 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h @@ -43,6 +43,8 @@ #ifndef SDK_CONFIG_H #define SDK_CONFIG_H +#include "nrf_porting.h" + // NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. #ifndef NRF_STRERROR_ENABLED From c8d1e07a5b6b6fb69df5ccfad500259754720ee2 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 5 Jul 2022 21:16:38 +0900 Subject: [PATCH 16/52] externals/nrf52: Move STATIC_INLINE definition Define STATIC_INLINE macro in porting header file so that the same definition does not exist in multiple places. --- .../components/libraries/queue/nrf_queue.c | 4 +--- .../components/softdevice/s132/headers/ble_gattc.h | 3 +-- .../config/nrf52832/config/nrf_porting.h | 2 ++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c index 2c0e39b1e..f806227e1 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c @@ -41,6 +41,7 @@ #if NRF_MODULE_ENABLED(NRF_QUEUE) #include "nrf_queue.h" #include "app_util_platform.h" +#include "nrf_porting.h" #if NRF_QUEUE_CONFIG_LOG_ENABLED #define NRF_LOG_LEVEL NRF_QUEUE_CONFIG_LOG_LEVEL @@ -52,9 +53,6 @@ #endif // NRF_QUEUE_CONFIG_LOG_ENABLED #include "nrf_log.h" -#define __STATIC_INLINE static __inline - - NRF_SECTION_DEF(nrf_queue, nrf_queue_t); #if NRF_QUEUE_CLI_CMDS && NRF_CLI_ENABLED diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h index 68538d44f..2c280c9b2 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h @@ -53,13 +53,12 @@ #include "ble_types.h" #include "ble_err.h" #include "ble_gatt.h" +#include "nrf_porting.h" #ifdef __cplusplus extern "C" { #endif -#define __STATIC_INLINE static __inline - /** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations * @{ */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h index 1372ef563..e80d64d53 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/nrf_porting.h @@ -46,6 +46,8 @@ * Pre-processor Definitions ****************************************************************************/ +#define __STATIC_INLINE static __inline + #ifdef CONFIG_EXTERNALS_NRF52_OUTPUT_LOG_LEVEL # if CONFIG_EXTERNALS_NRF52_OUTPUT_LOG_LEVEL > 0 # define NRF_LOG_ENABLED 1 From 85c9ff71f4f31e7603c6412216ff8cfe276796ec Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 19 Jul 2022 12:34:36 +0900 Subject: [PATCH 17/52] mkversion.sh: Update SDK version to SDK2.6.0 Update SDK version number for next release. --- sdk/tools/mkversion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/tools/mkversion.sh b/sdk/tools/mkversion.sh index ea921b9ea..a93816e90 100755 --- a/sdk/tools/mkversion.sh +++ b/sdk/tools/mkversion.sh @@ -42,7 +42,7 @@ if [ "X${TOPDIR}" = "X" ]; then fi APP_VERSION="0.0.0" -SDK_VERSION="SDK2.5.1" +SDK_VERSION="SDK2.6.0" if [ -r sdk_version ]; then SDK_VERSION="SDK`cat sdk_version`" fi From 52d03814bd13b737d98a25444b245de1cb6f2b3d Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 13 Jul 2022 09:00:15 +0900 Subject: [PATCH 18/52] bluetooth/hal/nrf52: Fix typo of Kconfig --- sdk/modules/bluetooth/hal/nrf52/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/modules/bluetooth/hal/nrf52/Kconfig b/sdk/modules/bluetooth/hal/nrf52/Kconfig index 35d441abc..6e611c6ee 100644 --- a/sdk/modules/bluetooth/hal/nrf52/Kconfig +++ b/sdk/modules/bluetooth/hal/nrf52/Kconfig @@ -16,14 +16,14 @@ config NRF52_LE bool default BLUETOOTH_LE ---help--- - This option enabling Cypress NRF52 Low Energy HAL. + This option enabling Nordic nRF52 Low Energy HAL. if NRF52_LE config NRF52_LE_GATT bool default BLUETOOTH_LE_GATT ---help--- - This option enabling Cypress NRF52 LE GATT HAL. + This option enabling Nordic nRF52 LE GATT HAL. endif # NRF52_LE From 27a7b00a550530cfa4d26c6c071823c385a24468 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:38:19 +0900 Subject: [PATCH 19/52] bluetooth/hal/nrf52: Fix error code conversion Fix the conversion from nRF52 library codes to errno. --- sdk/modules/bluetooth/hal/nrf52/ble_comm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_comm.c b/sdk/modules/bluetooth/hal/nrf52/ble_comm.c index ae510c8f1..fcefe2462 100644 --- a/sdk/modules/bluetooth/hal/nrf52/ble_comm.c +++ b/sdk/modules/bluetooth/hal/nrf52/ble_comm.c @@ -379,7 +379,7 @@ int bleConvertErrorCode(uint32_t errCode) break; case NRF_ERROR_INVALID_STATE: BLE_ERR("errno: 0x%lx, Invalid state.\n", errCode); - ret = -EINVAL; + ret = -EPERM; break; case NRF_ERROR_INVALID_ADDR: BLE_ERR("errno: 0x%lx, Bad Memory Address.\n", errCode); @@ -403,15 +403,15 @@ int bleConvertErrorCode(uint32_t errCode) break; case NRF_ERROR_NOT_SUPPORTED: BLE_ERR("errno: 0x%lx, Not supported.\n", errCode); - ret = -EINVAL; + ret = -ENOTSUP; break; case NRF_ERROR_BUSY: BLE_ERR("errno: 0x%lx, Busy.\n", errCode); - ret = -EPERM; + ret = -EBUSY; break; case NRF_ERROR_NO_MEM: BLE_ERR("errno: 0x%lx, No Memory for operation.\n", errCode); - ret = -EPERM; + ret = -ENOMEM; break; case NRF_ERROR_FORBIDDEN: BLE_ERR("errno: 0x%lx, Forbidden Operation.\n", errCode); From 4afbc8562a48a1f2384eb68803d0c160458dbd78 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Fri, 8 Jul 2022 08:09:38 +0900 Subject: [PATCH 20/52] externals/nrf52: Set UART2 parity = even dynamically Set even parity in UART2 open without defconfig. --- .../common/transport/ser_phy/ser_phy_uart.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c index e8abdf765..34cf473d4 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c @@ -45,6 +45,10 @@ #include #include #include +#include +#include +#include +#include #include "sdk/config.h" @@ -272,6 +276,30 @@ static void ser_phy_null_read(UART_CONTEXT *ctx) } } +static int ser_phy_even_parity_set(int fd) +{ + int ret; + struct termios prm; + + ret = ioctl(fd, TCGETS, &prm); + if (ret != 0) + { + return ret; + } + + prm.c_cflag |= PARENB; + prm.c_cflag &= ~PARODD; + + ret = ioctl(fd, TCSETS, &prm); + if (ret != 0) + { + return ret; + } + + ret = ioctl(fd, TCFLSH, NULL); + return ret; +} + static void *ser_phy_uart_receive(void *param) { ssize_t rx_len = 0; @@ -377,6 +405,15 @@ uint32_t ser_phy_open(ser_phy_events_handler_t events_handler) NRF_LOG_DEBUG("ser_phy_open: open err %d\n", ctx->uart_fd); return ctx->uart_fd; } + ret = ser_phy_even_parity_set(ctx->uart_fd); + if (ret != 0) + { + errcode = errno; + NRF_LOG_ERROR("ser_phy_open: UART even parity set err %d\n", errcode); + (void)close(ctx->uart_fd); + return -errno; + } + ser_phy_null_read(ctx); ret = pipe(ctx->ctrl_fd); From dea7eca43fc1cb05c45bb050b45e38b3070395ac Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Fri, 8 Jul 2022 08:12:59 +0900 Subject: [PATCH 21/52] configs/device/nrf52: Delete UART2_PARITY setting from defconfig The parity is set in UART2 open. --- sdk/configs/device/nrf52/defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/configs/device/nrf52/defconfig b/sdk/configs/device/nrf52/defconfig index f0e3e95ee..e16e92c09 100644 --- a/sdk/configs/device/nrf52/defconfig +++ b/sdk/configs/device/nrf52/defconfig @@ -1,4 +1,3 @@ +BLUETOOTH=y +EXTERNALS_NRF52=y +BLUETOOTH_NRF52=y -+UART2_PARITY=2 From 42be29700dc363de076399e01686edd9c9285eb8 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 5 Jul 2022 15:16:42 +0900 Subject: [PATCH 22/52] modules/bluetooth: Support BLE only device Except enable, bt_hal_common_ops is not used for BLE only device. So, allow to not register BT hal operation functions. --- sdk/modules/bluetooth/bluetooth_common.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/sdk/modules/bluetooth/bluetooth_common.c b/sdk/modules/bluetooth/bluetooth_common.c index 9fb8208cf..5500be659 100644 --- a/sdk/modules/bluetooth/bluetooth_common.c +++ b/sdk/modules/bluetooth/bluetooth_common.c @@ -324,11 +324,6 @@ int bt_init(void) { ret = bt_hal_common_ops->init(); } - else - { - _err("%s [BT][Common] Initialization failed(HAL not registered).\n", __func__); - return BT_FAIL; - } return ret; } @@ -350,11 +345,6 @@ int bt_finalize(void) { ret = bt_hal_common_ops->finalize(); } - else - { - _err("%s [BT][Common] Connect failed(HAL not registered).\n", __func__); - return BT_FAIL; - } return ret; } @@ -500,21 +490,11 @@ int bt_enable(void) { ret = bt_hal_common_ops->setDevAddr(&g_bt_common_state.bt_addr); } - else - { - _err("%s [BT][Common] Set local address failed(HAL not registered).\n", __func__); - return BT_FAIL; - } if (bt_hal_common_ops && bt_hal_common_ops->setDevName) { ret = bt_hal_common_ops->setDevName(g_bt_common_state.bt_name); } - else - { - _err("%s [BT][Common] Set local name failed(HAL not registered).\n", __func__); - return BT_FAIL; - } return ret; } From 7964e6505acaae30c87023c2cf629004d5a1b9d2 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 5 Jul 2022 15:19:23 +0900 Subject: [PATCH 23/52] examples/ble_peripheral: Remove BT classic related code This sample is just for BLE device, so no need to add BT classic specific code. --- .../bluetooth_le_peripheral_main.c | 122 ++---------------- 1 file changed, 8 insertions(+), 114 deletions(-) diff --git a/examples/bluetooth_le_peripheral/bluetooth_le_peripheral_main.c b/examples/bluetooth_le_peripheral/bluetooth_le_peripheral_main.c index 4211064aa..aeb40bcee 100644 --- a/examples/bluetooth_le_peripheral/bluetooth_le_peripheral_main.c +++ b/examples/bluetooth_le_peripheral/bluetooth_le_peripheral_main.c @@ -56,17 +56,6 @@ * Private Function Prototypes ****************************************************************************/ -/* BT common callbacks */ - -static void onCommandStatus(BT_CMD_STATUS status); /**< Command status */ -static void onPairingComplete(BT_ADDR addr, BT_PAIR_STATUS status); /**< Pairing complete */ -static void onInquiryResult(BT_ADDR addr, char *name); /**< Inquiry data result */ -static void onInquiryComplete(void); /**< Coplete inquiry */ -static void onConnectStatusChanged(struct bt_acl_state_s *bt_acl_state, - bool connected, int status); /**< Connection status change */ -static void onConnectedDeviceName(const char *name); /**< Device name change */ -static void onBondInfo(BT_ADDR addr); /**< Bonding information */ - /* BLE common callbacks */ static void onLeConnectStatusChanged(struct ble_state_s *ble_state, @@ -84,17 +73,6 @@ static void onNotify(struct ble_gatt_char_s *ble_gatt_char, bool enable); /**< N * Private Data ****************************************************************************/ -static struct bt_common_ops_s bt_common_ops = - { - .command_status = onCommandStatus, - .pairing_complete = onPairingComplete, - .inquiry_result = onInquiryResult, - .inquiry_complete = onInquiryComplete, - .connect_status_changed = onConnectStatusChanged, - .connected_device_name = onConnectedDeviceName, - .bond_info = onBondInfo - }; - static struct ble_common_ops_s ble_common_ops = { .connect_status_changed = onLeConnectStatusChanged, @@ -111,10 +89,9 @@ static struct ble_gatt_peripheral_ops_s ble_gatt_peripheral_ops = static BT_ADDR local_addr = {{0x19, 0x84, 0x06, 0x14, 0xAB, 0xCD}}; -static char local_bt_name[BT_NAME_LEN] = "SONY_BT"; static char local_ble_name[BT_NAME_LEN] = "SONY_BLE"; -static struct bt_acl_state_s *s_bt_acl_state = NULL; +static bool ble_is_connected = false; static struct ble_gatt_service_s *g_ble_gatt_service; @@ -158,68 +135,6 @@ static struct ble_gatt_char_s g_ble_gatt_char = * Private Functions ****************************************************************************/ -static void onCommandStatus(BT_CMD_STATUS status) -{ - /* If receive command status event, this function will call. */ - - printf("%s [BT] Command status = %d\n", __func__, status); -} - -static void onPairingComplete(BT_ADDR addr, BT_PAIR_STATUS status) -{ - /* If pairing task complete, this function will call. - * Print receive event data. - */ - - printf("[BT] Pairing complete ADDR:%02X:%02X:%02X:%02X:%02X:%02X, status=%d\n", - addr.address[0], addr.address[1], addr.address[2], - addr.address[3], addr.address[4], addr.address[5], - status); -} - -static void onInquiryResult(BT_ADDR addr, char *name) -{ - /* If receive inquiry search result, this function will call. */ - - printf("[BT] Inquiry result ADDR:%02X:%02X:%02X:%02X:%02X:%02X, name:%s\n", - addr.address[0], addr.address[1], addr.address[2], - addr.address[3], addr.address[4], addr.address[5], - name); -} - -static void onInquiryComplete(void) -{ - /* If receive inquiry complete event, this function will call. */ - - printf("%s [BT] Inquiry complete\n", __func__); -} - -static void onConnectStatusChanged(struct bt_acl_state_s *bt_acl_state, - bool connected, int status) -{ - /* If ACL is connected, SPP can start connect */ - - s_bt_acl_state = bt_acl_state; -} - -static void onConnectedDeviceName(const char *name) -{ - /* If receive connected device name data, this function will call. */ - - printf("%s [BT] Receive connected device name = %s\n", __func__, name); -} - -static void onBondInfo(BT_ADDR addr) -{ - /* If new bonding is comming, this function will call. - * Print new bonding information. - */ - - printf("[BLE_GATT] Bonding information ADDR:%02X:%02X:%02X:%02X:%02X:%02X\n", - addr.address[0], addr.address[1], addr.address[2], - addr.address[3], addr.address[4], addr.address[5]); -} - static void onLeConnectStatusChanged(struct ble_state_s *ble_state, bool connected) { @@ -231,6 +146,8 @@ static void onLeConnectStatusChanged(struct ble_state_s *ble_state, addr.address[0], addr.address[1], addr.address[2], addr.address[3], addr.address[4], addr.address[5], connected ? "Connected" : "Disconnected"); + + ble_is_connected = connected; } static void onConnectedDeviceNameResp(const char *name) @@ -278,6 +195,10 @@ static void ble_peripheral_exit(void) { int ret; + /* Update connection status */ + + ble_is_connected = false; + /* Turn OFF BT */ ret = bt_disable(); @@ -311,15 +232,6 @@ int main(int argc, FAR char *argv[]) BLE_UUID *s_uuid; BLE_UUID *c_uuid; - /* Register BT event callback function */ - - ret = bt_register_common_cb(&bt_common_ops); - if (ret != BT_SUCCESS) - { - printf("%s [BT] Register common call back failed. ret = %d\n", __func__, ret); - goto error; - } - /* Initialize BT HAL */ ret = bt_init(); @@ -329,24 +241,6 @@ int main(int argc, FAR char *argv[]) goto error; } - /* Set local device address */ - - ret = bt_set_address(&local_addr); - if (ret != BT_SUCCESS) - { - printf("%s [BT] Set local address failed. ret = %d\n", __func__, ret); - goto error; - } - - /* Set local device name */ - - ret = bt_set_name(local_bt_name); - if (ret != BT_SUCCESS) - { - printf("%s [BT] Set local name failed. ret = %d\n", __func__, ret); - goto error; - } - /* Turn ON BT */ ret = bt_enable(); @@ -477,7 +371,7 @@ int main(int argc, FAR char *argv[]) len = readline(buffer, sizeof(buffer) - 1, stdin, stdout); - if (s_bt_acl_state && s_bt_acl_state->bt_acl_connection == BT_CONNECTED) + if (ble_is_connected) { ret = ble_characteristic_notify(&g_ble_gatt_char, (uint8_t *) buffer, len); if (ret != BT_SUCCESS) From 3272a5de448fbf54d588f61755d84f94a97db0e8 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 5 Jul 2022 15:20:36 +0900 Subject: [PATCH 24/52] examples/ble_central: Remove BT classic related code This sample is just for BLE device, so no need to add BT classic specific code. --- .../bluetooth_le_central_main.c | 112 ------------------ 1 file changed, 112 deletions(-) diff --git a/examples/bluetooth_le_central/bluetooth_le_central_main.c b/examples/bluetooth_le_central/bluetooth_le_central_main.c index f8e45c051..1ee2ed202 100644 --- a/examples/bluetooth_le_central/bluetooth_le_central_main.c +++ b/examples/bluetooth_le_central/bluetooth_le_central_main.c @@ -56,17 +56,6 @@ * Private Function Prototypes ****************************************************************************/ -/* BT common callbacks */ - -static void on_command_status(BT_CMD_STATUS status); /**< Command status */ -static void on_pairing_complete(BT_ADDR addr, BT_PAIR_STATUS status); /**< Pairing complete */ -static void on_inquiry_result(BT_ADDR addr, char *name); /**< Inquiry data result */ -static void on_inquiry_complete(void); /**< Coplete inquiry */ -static void on_connect_status_changed(struct bt_acl_state_s *bt_acl_state, - bool connected, int status); /**< Connection status change */ -static void on_connected_device_name(const char *name); /**< Device name change */ -static void on_bond_info(BT_ADDR addr); /**< Bonding information */ - /* BLE common callbacks */ static void on_le_connect_status_change(struct ble_state_s *ble_state, @@ -85,17 +74,6 @@ static void on_db_discovery(struct ble_gatt_event_db_discovery_t *db_disc); /**< * Private Data ****************************************************************************/ -static struct bt_common_ops_s bt_common_ops = - { - .command_status = on_command_status, - .pairing_complete = on_pairing_complete, - .inquiry_result = on_inquiry_result, - .inquiry_complete = on_inquiry_complete, - .connect_status_changed = on_connect_status_changed, - .connected_device_name = on_connected_device_name, - .bond_info = on_bond_info - }; - static struct ble_common_ops_s ble_common_ops = { .connect_status_changed = on_le_connect_status_change, @@ -113,7 +91,6 @@ static struct ble_gatt_central_ops_s ble_gatt_central_ops = static BT_ADDR local_addr = {{0x19, 0x84, 0x06, 0x14, 0xAB, 0xCD}}; -static char local_bt_name[BT_NAME_LEN] = "SONY_BT"; static char local_ble_name[BT_NAME_LEN] = "SONY_BLE"; static struct ble_state_s *s_ble_state = NULL; #if 0 @@ -166,68 +143,6 @@ static void ble_state_add_bt_addr(struct ble_state_s *state, BT_ADDR *addr) memcpy(&state->bt_target_addr, addr, sizeof(state->bt_target_addr)); } -static void on_command_status(BT_CMD_STATUS status) -{ - /* If receive command status event, this function will call. */ - - printf("%s [BT] Command status = %d\n", __func__, status); -} - -static void on_pairing_complete(BT_ADDR addr, BT_PAIR_STATUS status) -{ - /* If pairing task complete, this function will call. - * Print receive event data. - */ - - printf("[BT] Pairing complete ADDR:%02X:%02X:%02X:%02X:%02X:%02X, status=%d\n", - addr.address[0], addr.address[1], addr.address[2], - addr.address[3], addr.address[4], addr.address[5], - status); -} - -static void on_inquiry_result(BT_ADDR addr, char *name) -{ - /* If receive inquiry search result, this function will call. */ - - printf("[BT] Inquiry result ADDR:%02X:%02X:%02X:%02X:%02X:%02X, name:%s\n", - addr.address[0], addr.address[1], addr.address[2], - addr.address[3], addr.address[4], addr.address[5], - name); -} - -static void on_inquiry_complete(void) -{ - /* If receive inquiry complete event, this function will call. */ - - printf("%s [BT] Inquiry complete\n", __func__); -} - -static void on_connect_status_changed(struct bt_acl_state_s *bt_acl_state, - bool connected, int status) -{ - /* If conection status changed, this function will call. */ - - printf("%s [BT] Connect status changed\n", __func__); -} - -static void on_connected_device_name(const char *name) -{ - /* If receive connected device name data, this function will call. */ - - printf("%s [BT] Receive connected device name = %s\n", __func__, name); -} - -static void on_bond_info(BT_ADDR addr) -{ - /* If new bonding is comming, this function will call. - * Print new bonding information. - */ - - printf("[BLE_GATT] Bonding information ADDR:%02X:%02X:%02X:%02X:%02X:%02X\n", - addr.address[0], addr.address[1], addr.address[2], - addr.address[3], addr.address[4], addr.address[5]); -} - static void on_le_connect_status_change(struct ble_state_s *ble_state, bool connected) { @@ -372,15 +287,6 @@ int main(int argc, FAR char *argv[]) { int ret = 0; - /* Register BT event callback function */ - - ret = bt_register_common_cb(&bt_common_ops); - if (ret != BT_SUCCESS) - { - printf("%s [BT] Register common call back failed. ret = %d\n", __func__, ret); - goto error; - } - /* Initialize BT HAL */ ret = bt_init(); @@ -390,24 +296,6 @@ int main(int argc, FAR char *argv[]) goto error; } - /* Set local device address */ - - ret = bt_set_address(&local_addr); - if (ret != BT_SUCCESS) - { - printf("%s [BT] Set local address failed. ret = %d\n", __func__, ret); - goto error; - } - - /* Set local device name */ - - ret = bt_set_name(local_bt_name); - if (ret != BT_SUCCESS) - { - printf("%s [BT] Set local name failed. ret = %d\n", __func__, ret); - goto error; - } - /* Turn ON BT */ ret = bt_enable(); From 123c7c413c142d1f1f15b6171067c1f12be971c5 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Fri, 8 Jul 2022 16:02:43 +0900 Subject: [PATCH 25/52] bluetooth/hal/nrf52: Delete unnecessary BT codes BT codes other than init() and enable() I/Fs are not needed. --- sdk/modules/bluetooth/hal/nrf52/ble_comm.c | 180 +--- .../bluetooth/hal/nrf52/include/bt/bt_comm.h | 926 +----------------- sdk/modules/bluetooth/hal/nrf52/nrf52_hal.c | 52 +- 3 files changed, 21 insertions(+), 1137 deletions(-) diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_comm.c b/sdk/modules/bluetooth/hal/nrf52/ble_comm.c index fcefe2462..0fdace00c 100644 --- a/sdk/modules/bluetooth/hal/nrf52/ble_comm.c +++ b/sdk/modules/bluetooth/hal/nrf52/ble_comm.c @@ -131,16 +131,6 @@ static int nrf52_ble_set_dev_addr(BT_ADDR *addr); static int nrf52_bt_init(void); static int nrf52_bt_finalize(void); static int nrf52_bt_enable(bool enable); -static int nrf52_bt_set_device_addr(BT_ADDR *addr); -static int nrf52_bt_get_device_addr(BT_ADDR *addr); -static int nrf52_bt_set_device_name(char *name); -static int nrf52_bt_get_device_name(char *name); -static int nrf52_bt_paring_enable(bool enable); -static int nrf52_bt_get_bond_list(BT_ADDR *addrs, int *num); -static int nrf52_bt_un_bond(BT_ADDR *addr); -static int nrf52_bt_set_visibility(BT_VISIBILITY visibility); -static int nrf52_bt_inquiry_start(void); -static int nrf52_bt_inquiry_cancel(void); /****************************************************************************** * Private Data @@ -2493,16 +2483,16 @@ struct bt_hal_common_ops_s bt_hal_common_ops = .init = nrf52_bt_init, .finalize = nrf52_bt_finalize, .enable = nrf52_bt_enable, - .setDevAddr = nrf52_bt_set_device_addr, - .getDevAddr = nrf52_bt_get_device_addr, - .setDevName = nrf52_bt_set_device_name, - .getDevName = nrf52_bt_get_device_name, - .paringEnable = nrf52_bt_paring_enable, - .getBondList = nrf52_bt_get_bond_list, - .unBond = nrf52_bt_un_bond, - .setVisibility = nrf52_bt_set_visibility, - .inquiryStart = nrf52_bt_inquiry_start, - .inquiryCancel = nrf52_bt_inquiry_cancel + .setDevAddr = NULL, + .getDevAddr = NULL, + .setDevName = NULL, + .getDevName = NULL, + .paringEnable = NULL, + .getBondList = NULL, + .unBond = NULL, + .setVisibility = NULL, + .inquiryStart = NULL, + .inquiryCancel = NULL }; /**************************************************************************** @@ -2581,153 +2571,3 @@ static int nrf52_bt_enable(bool enable) return ret; } -/**************************************************************************** - * Name: nrf52_bt_set_device_addr - * - * Description: - * Bluetooth set device address - * Set device address to chip and store local address. - * - ****************************************************************************/ - -static int nrf52_bt_set_device_addr(BT_ADDR *addr) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_get_device_addr - * - * Description: - * Bluetooth get device address - * Get device address from local address. - * - ****************************************************************************/ - -static int nrf52_bt_get_device_addr(BT_ADDR *addr) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_set_device_name - * - * Description: - * Bluetooth set device name - * Set device name to chip and store local name. - * - ****************************************************************************/ - -static int nrf52_bt_set_device_name(char *name) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_get_device_name - * - * Description: - * Bluetooth get device name - * Get device name from local name. - * - ****************************************************************************/ - -static int nrf52_bt_get_device_name(char *name) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_paring_enable - * - * Description: - * Bluetooth pairing mode enable/disable - * Set pairing mode and enable/disable. - * - ****************************************************************************/ - -static int nrf52_bt_paring_enable(bool enable) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_get_bond_list - * - * Description: - * Bluetooth get bondling address list. - * Get bonding address list. - * - ****************************************************************************/ - -static int nrf52_bt_get_bond_list(BT_ADDR *addrs, int *num) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_un_bond - * - * Description: - * Bluetooth unbond by BT_ADDR. - * Remove bondling information by BT_ADDR. - * - ****************************************************************************/ - -static int nrf52_bt_un_bond(BT_ADDR *addr) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_set_visibility - * - * Description: - * Bluetooth set visibility. - * Set visibility from other device. - * - ****************************************************************************/ - -static int nrf52_bt_set_visibility(BT_VISIBILITY visibility) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_inquiry_start - * - * Description: - * Bluetooth start inquiry. - * Start inquiry for search near devices. - * - ****************************************************************************/ - -static int nrf52_bt_inquiry_start(void) -{ - int ret = BT_SUCCESS; - return ret; -} - -/**************************************************************************** - * Name: nrf52_bt_inquiry_cancel - * - * Description: - * Bluetooth cancel inquiry. - * Cancel inquiry to stop search. - * - ****************************************************************************/ - -static int nrf52_bt_inquiry_cancel(void) -{ - int ret = BT_SUCCESS; - return ret; -} - diff --git a/sdk/modules/bluetooth/hal/nrf52/include/bt/bt_comm.h b/sdk/modules/bluetooth/hal/nrf52/include/bt/bt_comm.h index 4d8b8f65a..9286837a4 100644 --- a/sdk/modules/bluetooth/hal/nrf52/include/bt/bt_comm.h +++ b/sdk/modules/bluetooth/hal/nrf52/include/bt/bt_comm.h @@ -1,8 +1,7 @@ /**************************************************************************** - * apps/include/bt/bt_comm.h + * modules/bluetooth/hal/nrf52/include/bt/bt_comm.h * - * Copyright (C) 2016 Sony Corporation. All rights reserved. - * Author: Yuchi.Wen + * Copyright 2022 Sony Semiconductor Solutions Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -14,9 +13,10 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name NuttX nor Sony nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -36,8 +36,8 @@ * @file bt_comm.h */ -#ifndef BT_COMM_H -#define BT_COMM_H +#ifndef __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BT_BT_COMM_H +#define __MODULES_BLUETOOTH_HAL_NRF52_INCLUDE_BT_BT_COMM_H /** * @defgroup BT @@ -48,10 +48,6 @@ * include files *---------------------------------------------------------------------------*/ -#include -#include -#include -#include #include @@ -63,34 +59,6 @@ * @{ */ -/** - *@name Error Codes - *@{ - */ -// #define BT_SUCCESS 0x00 -/** @} */ - -/** - *@name BT Address Length - *@{ - */ -// #define BT_ADDR_LEN (6) -/** @} */ - -/** - *@name BT DID information length - *@{ - */ -#define BT_DID_INFO_LEN 4 -/** @} */ - -/** - *@name BT save bond device max num - *@{ - */ -#define BT_SAVE_BOND_DEVICE_MAX_NUM 8 -/** @} */ - /** *@name BT Name Length *@{ @@ -98,76 +66,11 @@ #define BT_MAX_NAME_LEN 28 /** @} */ -/** - *@name BT Class Length - *@{ - */ -#define BT_CLASS_LEN (3) -/** @} */ - -/** - * @name Device Event Group Type - * @{ - */ -#define BT_CONTROL_GROUP_DEVICE 0x00 /**< General control of BCM20706 management and Bluetooth functionality*/ -#define BT_CONTROL_GROUP_LE 0x01 /**< LE device-related commands*/ -#define BT_CONTROL_GROUP_GATT 0x02 /**< GATT commands*/ -#define BT_CONTROL_GROUP_HF 0x03 /**< Hands-free profile HF commands*/ -#define BT_CONTROL_GROUP_SPP 0x04 /**< Serial port profile commands*/ -#define BT_CONTROL_GROUP_A2DP_SRC 0x05 /**< Audio/video (AV) commands*/ -#define BT_CONTROL_GROUP_HIDD 0x06 /**< HID device (HIDD) commands*/ -#define BT_CONTROL_GROUP_AVRC_TARGET 0x07 /**< AV remote control (AVRC) target commands*/ -#define BT_CONTROL_GROUP_AG 0x0e /**< Hands-free profile AG commands*/ -#define BT_CONTROL_GROUP_AVRC_CONTROLLER 0x11 /**< AV remote control (AVRC) controller commands*/ -#define BT_CONTROL_GROUP_A2DP_SINK 0x13 /**< a2dp sink commands*/ -#define BT_CONTROL_GROUP_AUDIO_SINK 0x14 /**< audio sink commands*/ -/** @} */ - -/** - * @name Device Group Event Opcode Type - * @{ - */ -#define BT_EVT_DEV_COMMAND_STATUS 0x01 /**< Command status event for the requested operation */ -#define BT_EVT_DEV_BOND_INFO 0x04 /**< Request to MCU to save bond info */ -#define BT_EVT_DEV_INQUIRY_RESULT 0x06 /**< Inquiry result */ -#define BT_EVT_DEV_INQUIRY_COMPLETE 0x07 /**< Inquiry completed event */ -#define BT_EVT_DEV_PAIRING_COMPLETE 0x08 /**< Pairing Completed */ -#define BT_EVT_DEV_ENCRYPTION_CHANGED 0x09 /**< Encryption changed event */ -#define BT_EVT_DEV_CONNECTED_DEVICE_NAME 0x0A /**< Remote connected device name */ -#define BT_EVT_DEV_CONFIRMATION_REQUEST 0x0B /**< Confirmation request during pairing */ -#define BT_EVT_DEV_PASSKEY_REQUEST 0x17 /**< Passkey request during pairing */ -#define BT_EVT_DEV_PMGR_STATUS 0x20 /**< power manager status and value */ -#define BT_EVT_DEV_BAUDRATE_RESPONSE 0x21 /**< baud rate response */ -#define BT_EVT_DEV_I2S_ROLE_RESPONSE 0x22 /**< i2s role response */ -#define BT_EVT_DEV_REPLY_VENDORID 0x23 /**< reply vendor id event */ -#define BT_EVT_DEV_REPLY_BT_VERSION 0x24 /**< reply the bt version */ -#define BT_EVT_DEV_ACL_CONNECTION_STATUS 0x27 /**< Acl connection/disconnection status */ -/** @} */ - -/** - * @name BT/BLE transport type - * @{ - */ -#define BT_TRANSPORT_BR_EDR 1 -#define BT_TRANSPORT_LE 2 -/** @} */ - -/** - * @name Acl disconnection type - * @{ - */ -#define BT_CONNECTION_TIMEOUT 0x08 /**< BT disconnection because of time out */ -#define BT_REMOTE_USER_TERM_CONN 0x13 /**< Remote user terminate the connection */ -#define BT_LOCAL_HOST_TERM_CONN 0x16 /**< Local host terminate the connection */ -/** @} */ - /** * @name Event Data length * @{ */ #define BT_EVT_DATA_LEN 1000 /**< BT event data max length */ -#define BT_EVT_EIR_LEN (BT_EVT_DATA_LEN - 30) -#define BT_EVT_AUDIO_DATA_LEN (BT_EVT_DATA_LEN - 10) /** @} */ /** @} bt_defs */ @@ -180,82 +83,6 @@ * @{ */ -/**@brief BT initialize parameter - */ -typedef struct { - int reverse; -} BT_INIT_PARAM; - -/**@brief BT address structure - */ -// typedef struct -// { -// uint8_t address[BT_ADDR_LEN]; -// } BT_ADDR; - -/**@brief BT Class structure - */ -typedef struct -{ - uint8_t btClass[BT_CLASS_LEN]; -}BT_CLASS; - -typedef enum -{ - BT_IO_NO_INPUT_NO_OUTPUT = 0, - BT_IO_INPUT_ONLY, - BT_IO_OUTPUT_ONLY, - BT_INPUT_OUTPUT, -}BT_IO_CAP; - -/**@brief BT visibility param structure - */ -typedef struct -{ - uint16_t discWindow; /** Date: Wed, 20 Jul 2022 17:29:16 +0900 Subject: [PATCH 26/52] examples/lte_fwupdate: Fix bug that unintentionally reset the modem Fix a bug that unintentionally reset the modem while performing an firmware update. --- examples/lte_fwupdate/lte_fwupdate_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/lte_fwupdate/lte_fwupdate_main.c b/examples/lte_fwupdate/lte_fwupdate_main.c index 494c2315c..36d128085 100644 --- a/examples/lte_fwupdate/lte_fwupdate_main.c +++ b/examples/lte_fwupdate/lte_fwupdate_main.c @@ -349,10 +349,17 @@ int main(int argc, FAR char *argv[]) } modem_restarted = false; + + /* During the update run, the modem must be woken up using + * lte_acquire_wakelock() to safely update the modem. + */ + + lte_acquire_wakelock(); ret = ltefwupdate_execute(); if (ret < 0) { printf("Execution is failed.. : %d\n", ret); + lte_release_wakelock(); lte_finalize(); return -1; } @@ -363,6 +370,7 @@ int main(int argc, FAR char *argv[]) "Please wait.\n"); wait_for_modem_restart(); + lte_release_wakelock(); printf("\nNow the modem is rebooted.\n" "Check updated status\n"); From 6c7d1624cd8ba9330755bf2757e7361ce5216d9e Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 21 Jul 2022 11:07:38 +0900 Subject: [PATCH 27/52] examples/sms_send: Fix buffer overrun Fix buffer overrun. Detected by Codesonar 1215977 --- examples/sms_send/sms_send_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/sms_send/sms_send_main.c b/examples/sms_send/sms_send_main.c index 48eb8448e..52f9ac46d 100644 --- a/examples/sms_send/sms_send_main.c +++ b/examples/sms_send/sms_send_main.c @@ -159,7 +159,8 @@ static int send_sms(FAR char *phone_number, FAR char *text_msg, ioctl(sms_sock, SIOCSMSGREFID, &smsreq); - for (i = 0; i < smsreq.smsru.refid.nrefid; i++) + for (i = 0; (i < smsreq.smsru.refid.nrefid) && + (i < SMS_CONCATENATE_MAX); i++) { printf("Get reference id[%d] = %d\n", i, smsreq.smsru.refid.refid[i]); From a314a9a12fe463000b451834214336b184a2136f Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 7 Jul 2022 14:34:35 +0900 Subject: [PATCH 28/52] externals/nrf52: Delete unnecessary codes Delete ser_app_hal_nrf5x.c codes. --- .../application/hal/ser_app_hal.h | 116 ------------------ .../application/hal/ser_app_hal_nrf5x.c | 81 ------------ .../transport/ser_softdevice_handler.c | 20 +-- 3 files changed, 1 insertion(+), 216 deletions(-) delete mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal.h delete mode 100644 externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal.h deleted file mode 100644 index a44da2571..000000000 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form, except as embedded into a Nordic - * Semiconductor ASA integrated circuit in a product or a software update for - * such product, must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * 3. Neither the name of Nordic Semiconductor ASA nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * 4. This software, with or without modification, must only be used with a - * Nordic Semiconductor ASA integrated circuit. - * - * 5. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/**@file - * - * @defgroup ser_app_hal Serialization Application Hardware Abstraction Layer (HAL) - * @{ - * @ingroup ble_sdk_lib_serialization - * - * @brief Functions that set up hardware on Application Board and perform the reset of the Connectivity Board. - */ - -#ifndef SER_APP_HAL_H_ -#define SER_APP_HAL_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif -typedef void (*ser_app_hal_flash_op_done_handler_t)(bool success); -/**@brief Function for initializing hardware modules. - * - * @details Function can initialize hardware modules on the Application Chip. It is optional to - * implement. It is called once the Connectivity Chip is initialized. - * - * @param handler Flash operation event handler. - * - * @return @ref NRF_SUCCESS HAL initialized successfully. - * @return @ref nrf_error "NRF_ERROR_..." HAL initialization failed. - * - */ -uint32_t ser_app_hal_hw_init(ser_app_hal_flash_op_done_handler_t handler); - -/**@brief Function for waiting for a given amount of time. - * - * @param[in] ms Number of milliseconds to wait. - * - */ -void ser_app_hal_delay(uint32_t ms); - -/**@brief Function for clearing the Connectivity Chip reset pin. - * - */ -void ser_app_hal_nrf_reset_pin_clear(void); - -/**@brief Function for setting the Connectivity Chip reset pin. - * - */ -void ser_app_hal_nrf_reset_pin_set(void); - - -/**@brief Function for setting the SoftDevice event interrupt priority that serves the events incoming - * from the Connectivity Chip. - * - * @note Serialization solution on the application side mimics a SoC solution where events are handled in - * the interrupt context in two ways: either directly in the interrupt context or with a message being posted to - * the scheduler. However, it is possible that the Application Chip does not use a dedicated interrupt - * for connectivity events. In that case, this function can be left empty and - * \ref ser_app_hal_nrf_evt_pending will directly call an interrupt handler function. - */ -void ser_app_hal_nrf_evt_irq_priority_set(void); - -/**@brief Function for setting a pending interrupt for serving events incoming from the Connectivity Chip. - * - * @note The interrupt used for event from the Connectivity Chip mimics behavior of SoC and it is not - * intended to be triggered by any hardware event. This function should be the only source of - * interrupt triggering. - */ -void ser_app_hal_nrf_evt_pending(void); - - - -#ifdef __cplusplus -} -#endif - -#endif /* SER_APP_HAL_H_ */ -/** @} */ diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c deleted file mode 100644 index b285952f5..000000000 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_hal_nrf5x.c +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form, except as embedded into a Nordic - * Semiconductor ASA integrated circuit in a product or a software update for - * such product, must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * 3. Neither the name of Nordic Semiconductor ASA nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * 4. This software, with or without modification, must only be used with a - * Nordic Semiconductor ASA integrated circuit. - * - * 5. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#include -#include -#include - -#include "app_util_platform.h" -#include "ser_app_hal.h" -#include "nrf.h" -//#include "nrf_gpio.h" -#include "nrf_soc.h" -//#include "nrf_delay.h" -//#include "nrf_nvmc.h" -//#include "boards.h" -#include "ser_phy.h" -//#include "ser_phy_config_app.h" -//#include "nrf_drv_clock.h" - -//static ser_app_hal_flash_op_done_handler_t m_flash_op_handler; -uint32_t ser_app_hal_hw_init(ser_app_hal_flash_op_done_handler_t handler) -{ - return NRF_SUCCESS; -} - -void ser_app_hal_delay(uint32_t ms) -{ - usleep(ms * 1000); -} - -void ser_app_hal_nrf_reset_pin_clear(void) -{ -} - -void ser_app_hal_nrf_reset_pin_set(void) -{ -} - -void ser_app_hal_nrf_evt_irq_priority_set(void) -{ -} - -void ser_app_hal_nrf_evt_pending(void) -{ -} diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c index 14ad39a38..63b28b0e6 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c @@ -49,7 +49,6 @@ #include "nrf_sdh.h" #include "nrf_sdm.h" #include "ser_sd_transport.h" -#include "ser_app_hal.h" #include "ser_config.h" #include "nrf_soc.h" #include "ble_serialization.h" @@ -135,20 +134,10 @@ void os_rsp_set_handler(void) static void connectivity_reset_low(void) { - //Signal a reset to the connectivity chip by setting the reset pin low. - ser_app_hal_nrf_reset_pin_clear(); - ser_app_hal_delay(CONN_CHIP_RESET_TIME); - } static void connectivity_reset_high(void) { - - //Set the reset level to high again. - ser_app_hal_nrf_reset_pin_set(); - - //Wait for connectivity chip to be ready. - ser_app_hal_delay(CONN_CHIP_WAKEUP_TIME); } #if defined(BLE_STACK_SUPPORT_REQD) @@ -167,7 +156,6 @@ static void ser_softdevice_ble_evt_handler(uint8_t * p_data, uint16_t length) err_code = nrf_queue_push(&m_sd_ble_evt_mailbox, &item); APP_ERROR_CHECK(err_code); - ser_app_hal_nrf_evt_pending(); (void)sem_post(&evt_sid); NRF_LOG_DEBUG("ser_softdevice_ble_evt_handler END\n"); } @@ -188,8 +176,6 @@ static void ser_softdevice_ant_evt_handler(uint8_t * p_data, uint16_t length) err_code = nrf_queue_push(&m_sd_ant_evt_mailbox, &item); APP_ERROR_CHECK(err_code); - - ser_app_hal_nrf_evt_pending(); } #endif @@ -200,8 +186,6 @@ void ser_softdevice_flash_operation_success_evt(bool success) uint32_t err_code = nrf_queue_push(&m_sd_soc_evt_mailbox, &evt_type); APP_ERROR_CHECK(err_code); - - ser_app_hal_nrf_evt_pending(); } /** @@ -311,7 +295,7 @@ uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, { uint32_t err_code; - err_code = ser_app_hal_hw_init(ser_softdevice_flash_operation_success_evt); + err_code = NRF_SUCCESS; if (err_code == NRF_SUCCESS) { @@ -342,8 +326,6 @@ uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, { return err_code; } - - ser_app_hal_nrf_evt_irq_priority_set(); } else { From afb9ddbb6966d74defe0db3b648f2061c650f8c9 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Sat, 23 Jul 2022 07:27:21 +0900 Subject: [PATCH 29/52] Update Submodules for develop at 2022/07/23 07:27:21 --- sdk/apps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/apps b/sdk/apps index 131e803c3..d095239f4 160000 --- a/sdk/apps +++ b/sdk/apps @@ -1 +1 @@ -Subproject commit 131e803c395be7a56d4692a9fc482191cda45272 +Subproject commit d095239f4253d216b6e3bdac6e7f6ae3b34fd253 From 17c6407e3d22967a788b90c147226198736af488 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 21 Jul 2022 20:27:26 +0900 Subject: [PATCH 30/52] examples/websocket_bitbank: Fix buffer overrun Fix buffer overrun issue. Detected by Codesonar 1216005 --- examples/websocket_bitbank/websocket_bitbank_main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/websocket_bitbank/websocket_bitbank_main.c b/examples/websocket_bitbank/websocket_bitbank_main.c index 95b1d1411..2f7c4cc29 100644 --- a/examples/websocket_bitbank/websocket_bitbank_main.c +++ b/examples/websocket_bitbank/websocket_bitbank_main.c @@ -81,7 +81,7 @@ enum wss_state struct wss_command { - char symbol[WSS_BITBANK_SYMBOL_SIZE]; + char symbol[WSS_BITBANK_SYMBOL_SIZE + 1]; }; /**************************************************************************** @@ -341,10 +341,9 @@ int main(int argc, FAR char *argv[]) /* set new command */ - memset(new_command.symbol, 0, WSS_BITBANK_SYMBOL_SIZE); - strncpy(new_command.symbol, argv[1], WSS_BITBANK_SYMBOL_SIZE); - strncat(new_command.symbol, "_", WSS_BITBANK_SYMBOL_SIZE); - strncat(new_command.symbol, argv[2], WSS_BITBANK_SYMBOL_SIZE); + memset(new_command.symbol, 0, sizeof(new_command.symbol)); + snprintf(new_command.symbol, sizeof(new_command.symbol), + "%s_%s", argv[1], argv[2]); } else if ((argc > 1) && (strncmp(argv[1], "quit", 4) == 0)) From 4648b319b06c5ef14649699af601e7fe3224c2de Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 21 Jul 2022 20:44:24 +0900 Subject: [PATCH 31/52] examples/websocket_gmocoin: Fix buffer overrun Fix buffer overrun issue. Detected by Codesonar 1215991 --- examples/websocket_gmocoin/websocket_gmocoin_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/websocket_gmocoin/websocket_gmocoin_main.c b/examples/websocket_gmocoin/websocket_gmocoin_main.c index eb51b8d20..c2bd988a9 100644 --- a/examples/websocket_gmocoin/websocket_gmocoin_main.c +++ b/examples/websocket_gmocoin/websocket_gmocoin_main.c @@ -86,7 +86,7 @@ enum gmo_command struct wss_command { enum gmo_command command; - char symbol[WSS_GMOCOIN_SYMBOL_SIZE]; + char symbol[WSS_GMOCOIN_SYMBOL_SIZE + 1]; }; /**************************************************************************** @@ -321,7 +321,7 @@ int main(int argc, FAR char *argv[]) /* set new command */ - memset(new_command.symbol, 0, WSS_GMOCOIN_SYMBOL_SIZE); + memset(new_command.symbol, 0, sizeof(new_command.symbol)); if (strncmp(argv[1], "subscribe", 3) == 0) { strncpy(new_command.symbol, argv[2], WSS_GMOCOIN_SYMBOL_SIZE); From 979202e163996e3001e3f2edae757dd86cc05319 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 26 Jul 2022 07:27:12 +0900 Subject: [PATCH 32/52] Update Submodules for develop at 2022/07/26 07:27:12 --- nuttx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuttx b/nuttx index 795fb02a5..e6c3072fd 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit 795fb02a542c6629e53b97f35ce98a111222dd2d +Subproject commit e6c3072fd4a69afdced8a2c559bead0b909a8095 From 347789d850f65cb619f832d0616eae405c076341 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 20 Jul 2022 14:27:16 -0700 Subject: [PATCH 33/52] examples/multi_webcamera: Fix stuck the app Re-create server socket when accept() returned error. When the error occurred, the application appeared to be stuck. This situation could occur sometime. (e.g. when WiFi connection was disassociated). --- examples/multi_webcamera/multiwebcam_main.c | 6 ++++++ examples/multi_webcamera/multiwebcam_server.c | 8 +------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/multi_webcamera/multiwebcam_main.c b/examples/multi_webcamera/multiwebcam_main.c index 130e13f45..45bfce0d3 100644 --- a/examples/multi_webcamera/multiwebcam_main.c +++ b/examples/multi_webcamera/multiwebcam_main.c @@ -126,6 +126,12 @@ int main(int argc, FAR char *argv[]) printf("Finish Jpeg thread.\n"); wsock = 0; } + else + { + printf("Accept is failed. Re-create server socket\n"); + rsock = multiwebcam_initserver(MULTIWEBCAM_PORT_NO); + } + sleep(1); } diff --git a/examples/multi_webcamera/multiwebcam_server.c b/examples/multi_webcamera/multiwebcam_server.c index f3a9bcd4d..e1d56c6ce 100644 --- a/examples/multi_webcamera/multiwebcam_server.c +++ b/examples/multi_webcamera/multiwebcam_server.c @@ -62,13 +62,7 @@ static int send_binary(int s, const char *data, int len) if (ret == 0) { - /* It may fail to write when the host browser is stopped due to - * network error. In this case, it returns an error to terminate - * this thread and waits for new socket reconnection. - */ - - printf("Error. Cannot send socket.\n"); - return -1; + printf("Send 0 byte. Maybe poor reception..\n"); } if (ret < 0) From 2415c8cfc0aa4a94ead2642d56a002327fdf4f0e Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 13 Jul 2022 16:27:23 +0900 Subject: [PATCH 34/52] examles/lte_lwm2mstub: Add LwM2M Stub example Add an example to show how to use LTE LwM2M stub APIs. --- examples/lte_lwm2mstub/Kconfig | 26 + examples/lte_lwm2mstub/Make.defs | 38 ++ examples/lte_lwm2mstub/Makefile | 53 ++ examples/lte_lwm2mstub/app_eventtimer.c | 181 +++++++ examples/lte_lwm2mstub/app_eventtimer.h | 52 ++ examples/lte_lwm2mstub/app_lte_util.c | 207 +++++++ examples/lte_lwm2mstub/app_lte_util.h | 52 ++ examples/lte_lwm2mstub/app_lwm2m_util.c | 371 +++++++++++++ examples/lte_lwm2mstub/app_lwm2m_util.h | 54 ++ examples/lte_lwm2mstub/app_message.c | 118 ++++ examples/lte_lwm2mstub/app_message.h | 53 ++ examples/lte_lwm2mstub/app_parameter.c | 338 ++++++++++++ examples/lte_lwm2mstub/app_parameter.h | 110 ++++ examples/lte_lwm2mstub/lte_lwm2mstub_main.c | 565 ++++++++++++++++++++ examples/lte_lwm2mstub/lwm2m.ini | 43 ++ 15 files changed, 2261 insertions(+) create mode 100644 examples/lte_lwm2mstub/Kconfig create mode 100644 examples/lte_lwm2mstub/Make.defs create mode 100644 examples/lte_lwm2mstub/Makefile create mode 100644 examples/lte_lwm2mstub/app_eventtimer.c create mode 100644 examples/lte_lwm2mstub/app_eventtimer.h create mode 100644 examples/lte_lwm2mstub/app_lte_util.c create mode 100644 examples/lte_lwm2mstub/app_lte_util.h create mode 100644 examples/lte_lwm2mstub/app_lwm2m_util.c create mode 100644 examples/lte_lwm2mstub/app_lwm2m_util.h create mode 100644 examples/lte_lwm2mstub/app_message.c create mode 100644 examples/lte_lwm2mstub/app_message.h create mode 100644 examples/lte_lwm2mstub/app_parameter.c create mode 100644 examples/lte_lwm2mstub/app_parameter.h create mode 100644 examples/lte_lwm2mstub/lte_lwm2mstub_main.c create mode 100644 examples/lte_lwm2mstub/lwm2m.ini diff --git a/examples/lte_lwm2mstub/Kconfig b/examples/lte_lwm2mstub/Kconfig new file mode 100644 index 000000000..0a00ed9a7 --- /dev/null +++ b/examples/lte_lwm2mstub/Kconfig @@ -0,0 +1,26 @@ + +config EXAMPLES_LTE_LWM2MSTUB + tristate "LwM2M stub API example" + default n + ---help--- + Enable the lte_lwm2mstub app. This example shows how to use LwM2M stub APIs. + Those APIs uses LwM2M functionality on Alt1250 modem. + +if EXAMPLES_LTE_LWM2MSTUB + +config EXAMPLES_LTE_LWM2MSTUB_PROGNAME + string "Program name" + default "lte_lwm2mstub" + ---help--- + This is the name of the program that will be use when the NSH ELF + program is installed. + +config EXAMPLES_LTE_LWM2MSTUB_PRIORITY + int "lte_lwm2mstub task priority" + default 100 + +config EXAMPLES_LTE_LWM2MSTUB_STACKSIZE + int "lte_lwm2mstub stack size" + default 2048 + +endif diff --git a/examples/lte_lwm2mstub/Make.defs b/examples/lte_lwm2mstub/Make.defs new file mode 100644 index 000000000..da8f75997 --- /dev/null +++ b/examples/lte_lwm2mstub/Make.defs @@ -0,0 +1,38 @@ +############################################################################ +# examples/lte_lwm2mstub/Make.defs +# +# Copyright 2022 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Semiconductor Solutions Corporation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifneq ($(CONFIG_EXAMPLES_LTE_LWM2MSTUB),) +CONFIGURED_APPS += lte_lwm2mstub +endif diff --git a/examples/lte_lwm2mstub/Makefile b/examples/lte_lwm2mstub/Makefile new file mode 100644 index 000000000..7d325321a --- /dev/null +++ b/examples/lte_lwm2mstub/Makefile @@ -0,0 +1,53 @@ +############################################################################ +# examples/lte_lwm2mstub/Makefile +# +# Copyright 2022 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of Sony Semiconductor Solutions Corporation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include $(APPDIR)/Make.defs +include $(SDKDIR)/Make.defs + +PROGNAME = $(CONFIG_EXAMPLES_LTE_LWM2MSTUB_PROGNAME) +PRIORITY = $(CONFIG_EXAMPLES_LTE_LWM2MSTUB_PRIORITY) +STACKSIZE = $(CONFIG_EXAMPLES_LTE_LWM2MSTUB_STACKSIZE) +MODULE = $(CONFIG_EXAMPLES_LTE_LWM2MSTUB) + +ASRCS = +CSRCS = app_eventtimer.c +CSRCS += app_lte_util.c +CSRCS += app_lwm2m_util.c +CSRCS += app_message.c +CSRCS += app_parameter.c + +MAINSRC = lte_lwm2mstub_main.c + +include $(APPDIR)/Application.mk diff --git a/examples/lte_lwm2mstub/app_eventtimer.c b/examples/lte_lwm2mstub/app_eventtimer.c new file mode 100644 index 000000000..8dcef70ae --- /dev/null +++ b/examples/lte_lwm2mstub/app_eventtimer.c @@ -0,0 +1,181 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_eventtimer.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +#include "app_parameter.h" + +extern void increment_value(void); /* from lte_lwm2mstub_main.c */ + +/**************************************************************************** + * Private Definitions + ****************************************************************************/ + +#define MY_TIMER_SIGNAL 17 +#define SIGVALUE_INT 42 + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static sem_t sem; +static volatile bool is_running = false; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * name: timer_exriration + ****************************************************************************/ + +static void timer_expiration(int signo, siginfo_t *info, void *ucontext) +{ + increment_value(); +} + +/**************************************************************************** + * name: timer_task + ****************************************************************************/ + +static int timer_task(int argc, char *argv[]) +{ + sigset_t set; + struct sigaction act; + struct sigaction oact; + struct sigevent notify; + struct itimerspec timer; + timer_t timerid; + struct app_parameter_s *param; + + param = get_appparam(); + + sem_init(&sem, 0, 0); + + /* Start waiter thread */ + + sigemptyset(&set); + sigaddset(&set, MY_TIMER_SIGNAL); + sigprocmask(SIG_UNBLOCK, &set, NULL); + + act.sa_sigaction = timer_expiration; + act.sa_flags = SA_SIGINFO; + + sigfillset(&act.sa_mask); + sigdelset(&act.sa_mask, MY_TIMER_SIGNAL); + + sigaction(MY_TIMER_SIGNAL, &act, &oact); + + /* Create the POSIX timer */ + + notify.sigev_notify = SIGEV_SIGNAL; + notify.sigev_signo = MY_TIMER_SIGNAL; + notify.sigev_value.sival_int = SIGVALUE_INT; + + timer_create(CLOCK_REALTIME, ¬ify, &timerid); + + /* Start the POSIX timer */ + + timer.it_value.tv_sec = param->time_period; + timer.it_value.tv_nsec = 0; + timer.it_interval.tv_sec = param->time_period; + timer.it_interval.tv_nsec = 0; + + timer_settime(timerid, 0, &timer, NULL); + + /* Take the semaphore */ + + while (is_running) + { + sem_wait(&sem); + } + + sem_destroy(&sem); + + /* Then delete the timer */ + + timer_delete(timerid); + + /* Detach the signal handler */ + + act.sa_handler = SIG_DFL; + sigaction(MY_TIMER_SIGNAL, &act, &oact); + + return 0; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * name: timer_setup + ****************************************************************************/ + +int timer_setup(struct app_parameter_s *param) +{ + int ret = OK; + + if (!is_running && param->time_period > 0) + { + printf("Timer will start\n"); + is_running = true; + ret = task_create("lwm2m_tmtask", 100, 2048, timer_task, NULL); + ret = ret < 0 ? ERROR : OK; + } + + return ret; +} + +/**************************************************************************** + * name: timer_unset + ****************************************************************************/ + +int timer_unset(void) +{ + is_running = false; + return OK; +} diff --git a/examples/lte_lwm2mstub/app_eventtimer.h b/examples/lte_lwm2mstub/app_eventtimer.h new file mode 100644 index 000000000..0272f74fd --- /dev/null +++ b/examples/lte_lwm2mstub/app_eventtimer.h @@ -0,0 +1,52 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_eventtimer.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __EXAMPLES_LTE_LWM2MSTUB_APP_EVENTTIMER_H +#define __EXAMPLES_LTE_LWM2MSTUB_APP_EVENTTIMER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "app_parameter.h" + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int timer_setup(struct app_parameter_s *param); +int timer_unset(void); + +#endif /* __EXAMPLES_LTE_LWM2MSTUB_APP_EVENTTIMER_H */ diff --git a/examples/lte_lwm2mstub/app_lte_util.c b/examples/lte_lwm2mstub/app_lte_util.c new file mode 100644 index 000000000..06c15ba45 --- /dev/null +++ b/examples/lte_lwm2mstub/app_lte_util.c @@ -0,0 +1,207 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_lte_util.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#include + +#include "app_message.h" +#include "app_parameter.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lte_restart_cb + ****************************************************************************/ + +static void lte_restart_cb(uint32_t reason) +{ + struct app_message_s msg; + switch (reason) + { + case LTE_RESTART_USER_INITIATED: + case LTE_RESTART_MODEM_INITIATED: + msg.msgid = MESSAGE_ID_LTE_RESTARTED; + msg.arg.code = reason; + send_message(MESSAGE_QUEUE_NAME, &msg); + break; + + default: + break; + } +} + +/**************************************************************************** + * Name: wait_for_lterestart + ****************************************************************************/ + +static int wait_for_lterestart(void) +{ + struct app_message_s msg; + if (receive_message(MESSAGE_QUEUE_NAME, &msg) == OK) + { + if (msg.msgid == MESSAGE_ID_LTE_RESTARTED && + msg.arg.code == LTE_RESTART_USER_INITIATED) + { + return OK; + } + } + + return ERROR; +} + +/**************************************************************************** + * Name: localtime_cb + ****************************************************************************/ + +static void localtime_cb(lte_localtime_t *localtm) +{ + struct tm tmtime; + struct timespec cur_time; + + memset(&cur_time, 0, sizeof(cur_time)); + + tmtime.tm_year = localtm->year + 100; + tmtime.tm_mon = localtm->mon - 1; + tmtime.tm_mday = localtm->mday; + tmtime.tm_hour = localtm->hour; + tmtime.tm_min = localtm->min; + tmtime.tm_sec = localtm->sec; + + cur_time.tv_sec = mktime(&tmtime); + + clock_settime(CLOCK_REALTIME, &cur_time); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: power_on_ltemodem + ****************************************************************************/ + +int power_on_ltemodem(struct app_parameter_s *param) +{ + int ret; + + ret = lte_initialize(); + if ((ret < 0) && (ret != -EALREADY)) + { + printf("lte_initialize() returned error : %d\n", ret); + return ERROR; + } + + lte_set_report_restart(lte_restart_cb); + + ret = lte_power_on(); + if (ret >= 0) + { + if (wait_for_lterestart() != OK) + { + printf("Waiting restart error\n"); + lte_finalize(); + return ERROR; + } + } + else if (ret != -EALREADY) + { + printf("lte_power_on() returned error : %d\n", ret); + lte_finalize(); + return ERROR; + } + + return OK; +} + +/**************************************************************************** + * Name: connect_to_ltenetwork + ****************************************************************************/ + +int connect_to_ltenetwork(struct app_parameter_s *param) +{ + int ret; + int i; + lte_pdn_t pdn; + lte_apn_setting_t apnsetting; + + ret = lte_radio_on_sync(); + if (ret < 0) + { + printf("Radio on error:%d\n", ret); + return ERROR; + } + + lte_set_report_localtime(localtime_cb); + + lte_set_rat_sync(param->rat, LTE_DISABLE); + + apnsetting.apn = param->apn_name; + apnsetting.apn_type = LTE_APN_TYPE_DEFAULT | LTE_APN_TYPE_IA; + apnsetting.ip_type = param->ip_type; + apnsetting.auth_type = param->auth_type; + apnsetting.user_name = param->user_name; + apnsetting.password = param->passwd; + + if (lte_activate_pdn_sync(&apnsetting, &pdn) < 0) + { + printf("lte_activate_pdn_sync() returned error\n"); + return ERROR; + } + + printf("LTE PDN session ID : %d\n", pdn.session_id); + if (pdn.ipaddr_num > 0) + { + for (i = 0; i < pdn.ipaddr_num; i++) + { + printf(" IP Addr[%d] : %s\n", i, pdn.address[i].address); + } + } + else + { + printf(" IP Addr : Nothing...\n"); + } + + return OK; +} diff --git a/examples/lte_lwm2mstub/app_lte_util.h b/examples/lte_lwm2mstub/app_lte_util.h new file mode 100644 index 000000000..2e78e0773 --- /dev/null +++ b/examples/lte_lwm2mstub/app_lte_util.h @@ -0,0 +1,52 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_lte_util.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __EXAMPLES_LTE_LWM2MSTUP_APP_LTE_UTIL_H +#define __EXAMPLES_LTE_LWM2MSTUP_APP_LTE_UTIL_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "app_parameter.h" + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int power_on_ltemodem(struct app_parameter_s *param); +int connect_to_ltenetwork(struct app_parameter_s *param); + +#endif /* __EXAMPLES_LTE_LWM2MSTUP_APP_LTE_UTIL_H */ diff --git a/examples/lte_lwm2mstub/app_lwm2m_util.c b/examples/lte_lwm2mstub/app_lwm2m_util.c new file mode 100644 index 000000000..ec09c66cf --- /dev/null +++ b/examples/lte_lwm2mstub/app_lwm2m_util.c @@ -0,0 +1,371 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_lwm2m_util.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include "app_lwm2m_util.h" + +/**************************************************************************** + * Private data + ****************************************************************************/ + +static char tmp_buff[256]; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: state_string + ****************************************************************************/ + +static const char *state_string(int state) +{ + switch (state) + { + case LWM2MSTUB_STATE_NOTREGISTERD : + return "Not registerd"; + case LWM2MSTUB_STATE_REGISTPENDING : + return "Pending registration"; + case LWM2MSTUB_STATE_REGISTERD : + return "Registerd"; + case LWM2MSTUB_STATE_REGISTERFAILED : + return "Register failed"; + case LWM2MSTUB_STATE_UPDATEPENDING : + return "Re-Registration pending"; + case LWM2MSTUB_STATE_DEREGISTPENDING : + return "De-register pending"; + case LWM2MSTUB_STATE_BSHOLDOFF : + return " Bootstrap hold time out"; + case LWM2MSTUB_STATE_BSREQUESTED : + return "Bootstrap requested"; + case LWM2MSTUB_STATE_BSONGOING : + return "Bootstrap on going"; + case LWM2MSTUB_STATE_BSDONE : + return "Bootstrap is done"; + case LWM2MSTUB_STATE_BSFAILED : + return "Bootstrap failed"; + default : + break; + } + + return "Unknown"; +} + +/**************************************************************************** + * Name: secmode_string + ****************************************************************************/ + +static const char *secmode_string(int mode) +{ + switch (mode) + { + case LWM2MSTUB_SECUREMODE_PSK : + return "PSK"; + case LWM2MSTUB_SECUREMODE_RPK : + return "RPK"; + case LWM2MSTUB_SECUREMODE_CERT : + return "Certificate"; + case LWM2MSTUB_SECUREMODE_NOSEC : + return "Non Secure"; + case LWM2MSTUB_SECUREMODE_CERTEST : + return "Certificate with EST"; + default: + break; + } + + return "Unknown"; +} + +/**************************************************************************** + * Name: objop_string + ****************************************************************************/ + +static const char *objop_string(int op) +{ + switch (op) + { + case LWM2MSTUB_RESOP_READ : + return "READ "; + case LWM2MSTUB_RESOP_WRITE : + return "WRITE"; + case LWM2MSTUB_RESOP_RW : + return "RDWT "; + case LWM2MSTUB_RESOP_EXEC : + return "EXEC "; + default: + break; + } + + return "Unknown"; +} + +/**************************************************************************** + * Name: objdata_string + ****************************************************************************/ + +static const char *objdata_string(int type) +{ + switch (type) + { + case LWM2MSTUB_RESDATA_NONE: + return "None"; + case LWM2MSTUB_RESDATA_STRING: + return "String"; + case LWM2MSTUB_RESDATA_INT: + return "Integer"; + case LWM2MSTUB_RESDATA_UNSIGNED: + return "U-Integer"; + case LWM2MSTUB_RESDATA_FLOAT: + return "Float"; + case LWM2MSTUB_RESDATA_BOOL: + return "Boolean"; + case LWM2MSTUB_RESDATA_OPAQUE: + return "Opaque"; + case LWM2MSTUB_RESDATA_TIME: + return "Time"; + case LWM2MSTUB_RESDATA_OBJLINK: + return "Object-Link"; + default: + break; + } + + return "TypeError"; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: dump_opevent + ****************************************************************************/ + +void dump_opevent(int event) +{ + switch (event) + { + case LWM2MSTUB_OP_WRITE: + printf("Write operation received.\n"); + break; + case LWM2MSTUB_OP_EXEC: + printf("Execution operation received.\n"); + break; + case LWM2MSTUB_OP_WATTR: + printf("Write attribute operation received.\n"); + break; + case LWM2MSTUB_OP_DISCOVER: + printf("Discover operation received.\n"); + break; + case LWM2MSTUB_OP_READ: + printf("Read operation received.\n"); + break; + case LWM2MSTUB_OP_OBSERVE: + printf("Observe START operation received.\n"); + break; + case LWM2MSTUB_OP_CANCELOBS: + printf("Observe STOP operation received.\n"); + break; + case LWM2MSTUB_OP_OFFLINE: + printf("Client is Off-line.\n"); + break; + case LWM2MSTUB_OP_ONLINE: + printf("Client is On-line.\n"); + break; + case LWM2MSTUB_OP_SENDNOTICE: + printf("Notification is sent to server.\n"); + break; + case LWM2MSTUB_OP_RCVWUP: + printf("SMS wake up received.\n"); + break; + case LWM2MSTUB_OP_RCVOBSACK: + printf("Notification ack is received.\n"); + break; + case LWM2MSTUB_OP_CLIENTON: + printf("Client is on.\n"); + break; + case LWM2MSTUB_OP_CLIENTOFF: + printf("Client is off.\n"); + break; + case LWM2MSTUB_OP_FAILNOTIFY: + printf("Notification confirmation failed.\n"); + break; + case LWM2MSTUB_OP_BSFINISH: + printf("Bootstrap is done.\n"); + break; + case LWM2MSTUB_OP_REGSUCCESS: + printf("Register is successed.\n"); + break; + case LWM2MSTUB_OP_REGUPDATED: + printf("Re-register is successed.\n"); + break; + case LWM2MSTUB_OP_DEREGSUCCESS: + printf("De-Register is successed.\n"); + break; + case LWM2MSTUB_OP_NOSENDNOTICE: + printf("Notification is not sent to server.\n"); + break; + default: + printf("Unknown...\n"); + break; + } +} + +/**************************************************************************** + * Name: dump_fwevent + ****************************************************************************/ + +void dump_fwevent(int event) +{ + switch (event) + { + case LWM2MSTUB_FWUP_PEND_DL: + printf("FW update image donwload pending..\n"); + break; + case LWM2MSTUB_FWUP_PEND_UPD: + printf("FW update is pending..\n"); + break; + case LWM2MSTUB_FWUP_COMP_DL: + printf("FW update image download is done.\n"); + break; + case LWM2MSTUB_FWUP_FAIL_DL: + printf("FW update image donwload is failed.\n"); + break; + case LWM2MSTUB_FWUP_CANCELED: + printf("FW update is canceld by a server.\n"); + break; + default: + printf("Unknown...\n"); + break; + } +} + +/**************************************************************************** + * Name: dump_servinfo + ****************************************************************************/ + +void dump_servinfo(void) +{ + struct lwm2mstub_serverinfo_s info; + char *cc; + + printf("Getting server information\n"); + if (lte_getm2m_serverinfo(&info, 0) >= 0) + { + printf("=== Server information ===\n"); + + lte_getm2m_endpointname(tmp_buff, sizeof(tmp_buff)); + printf("Endpoint name : %s\n", tmp_buff); + + printf(" Instno : %d\n", info.object_inst); + printf(" Status : %s\n", state_string(info.state)); + printf(" BootStrap : %s\n", info.bootstrap ? "Yes" : "No"); + printf(" Non-IP : %s\n", info.nonip ? "Yes" : "No"); + printf(" Secur Mode : %s\n", secmode_string(info.security_mode)); + printf(" Server URI : %s\n", info.server_uri); + printf(" Device ID : "); + + for (cc = info.device_id; *cc; cc++) + { + /* lte_getm2m_endpointname() can not get device_id. + * So this should be empty. + */ + + printf("%02x", *cc); + } + + printf("\n"); + + printf("SecurityKey : "); + for (cc = info.security_key; *cc; cc++) + { + /* lte_getm2m_endpointname() can not get security_key. + * So this should be empty. + */ + + printf("%02x", *cc); + } + + printf("\n\n"); + } + else + { + printf("Error on lte_getm2m_serverinfo()\n"); + } +} + +/**************************************************************************** + * Name: dump_objinfo + ****************************************************************************/ + +void dump_objinfo(uint16_t objid) +{ + int i; + int resnum; + struct lwm2mstub_resource_s *reses; + + resnum = lte_getm2m_objresourcenum(objid); + printf("Object %d has %d resources.\n", objid, resnum); + + if (resnum > 0) + { + reses = (struct lwm2mstub_resource_s *) + malloc(sizeof(struct lwm2mstub_resource_s) * resnum); + if (reses) + { + if (lte_getm2m_objresourceinfo(objid, resnum, reses) >= 0) + { + for (i = 0; i < resnum; i++) + { + printf(" ID %d : %s, %s, %s\n", reses[i].res_id, + reses[i].inst_type == LWM2MSTUB_RESINST_SINGLE + ? "Single" : "Multi ", + objop_string(reses[i].operation), + objdata_string(reses[i].data_type)); + } + + printf("\n"); + } + + free(reses); + } + } +} diff --git a/examples/lte_lwm2mstub/app_lwm2m_util.h b/examples/lte_lwm2mstub/app_lwm2m_util.h new file mode 100644 index 000000000..f8d7b7e33 --- /dev/null +++ b/examples/lte_lwm2mstub/app_lwm2m_util.h @@ -0,0 +1,54 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_lwm2m_util.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __EXAMPLES_LTE_LWM2MSTUP_APP_LWM2M_UTIL_H +#define __EXAMPLES_LTE_LWM2MSTUP_APP_LWM2M_UTIL_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +void dump_opevent(int event); +void dump_fwevent(int event); +void dump_servinfo(void); +void dump_objinfo(uint16_t objid); + +#endif /* __EXAMPLES_LTE_LWM2MSTUP_APP_LWM2M_UTIL_H */ diff --git a/examples/lte_lwm2mstub/app_message.c b/examples/lte_lwm2mstub/app_message.c new file mode 100644 index 000000000..c0b2c2666 --- /dev/null +++ b/examples/lte_lwm2mstub/app_message.c @@ -0,0 +1,118 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_message.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#include "app_parameter.h" +#include "app_message.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: create_msgqueue + ****************************************************************************/ + +int create_msgqueue(const char *qname) +{ + mqd_t mq; + struct mq_attr attr; + + attr.mq_maxmsg = MESSAGE_QUEUE_MAX; + attr.mq_msgsize = sizeof(struct app_message_s); + attr.mq_flags = 0; + + mq = mq_open(qname, O_CREAT, 0666, &attr); + if (mq == (mqd_t)-1) + { + printf("Message queue open error:%d\n", errno); + return ERROR; + } + + mq_close(mq); + return OK; +} + +/**************************************************************************** + * Name: send_message + ****************************************************************************/ + +int send_message(const char *qname, struct app_message_s *msg) +{ + int ret = ERROR; + mqd_t mq; + + mq = mq_open(qname, O_WRONLY); + if (mq != (mqd_t)-1) + { + mq_send(mq, (const char *)msg, sizeof(struct app_message_s), 0); + mq_close(mq); + ret = OK; + } + + return ret; +} + +/**************************************************************************** + * Name: receive_message + ****************************************************************************/ + +int receive_message(const char *qname, struct app_message_s *msg) +{ + int ret = ERROR; + mqd_t mq; + + mq = mq_open(qname, O_RDONLY); + if (mq != (mqd_t)-1) + { + ret = mq_receive(mq, (char *)msg, sizeof(struct app_message_s), 0); + if (ret == sizeof(struct app_message_s)) + { + ret = OK; + } + + mq_close(mq); + } + + return ret; +} diff --git a/examples/lte_lwm2mstub/app_message.h b/examples/lte_lwm2mstub/app_message.h new file mode 100644 index 000000000..c6e16da01 --- /dev/null +++ b/examples/lte_lwm2mstub/app_message.h @@ -0,0 +1,53 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_message.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __EXAMPLES_LTE_LWM2MSTUP_APP_MESSAGE_H +#define __EXAMPLES_LTE_LWM2MSTUP_APP_MESSAGE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "app_parameter.h" + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int create_msgqueue(const char *qname); +int send_message(const char *qname, struct app_message_s *msg); +int receive_message(const char *qname, struct app_message_s *msg); + +#endif /* __EXAMPLES_LTE_LWM2MSTUP_APP_MESSAGE_H */ diff --git a/examples/lte_lwm2mstub/app_parameter.c b/examples/lte_lwm2mstub/app_parameter.c new file mode 100644 index 000000000..39b2dd5b5 --- /dev/null +++ b/examples/lte_lwm2mstub/app_parameter.c @@ -0,0 +1,338 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_parameter.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#include +#include + +#include "app_parameter.h" + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct param_value_s +{ + const char *param; + int value; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct param_value_s authtype_param[] = +{ + {"NONE", LTE_APN_AUTHTYPE_NONE}, + {"PAP", LTE_APN_AUTHTYPE_PAP}, + {"CHAP", LTE_APN_AUTHTYPE_CHAP}, + {NULL, -1}, +}; + +static struct param_value_s iptype_param[] = +{ + {"V4", LTE_IPTYPE_V4}, + {"V6", LTE_IPTYPE_V6}, + {"V4V6", LTE_IPTYPE_V4V6}, + {"NONIP", LTE_IPTYPE_NON}, + {NULL, -1}, +}; + +static struct param_value_s truefalse_param[] = +{ + {"true", 1}, + {"false", 0}, + {NULL, -1}, +}; + +static struct param_value_s rat_param[] = +{ + {"CATM", LTE_RAT_CATM}, + {"NB", LTE_RAT_NBIOT}, + {NULL, -1}, +}; + +static struct param_value_s secmode_param[] = +{ + {"PSK", LWM2MSTUB_SECUREMODE_PSK}, + {"NONE", LWM2MSTUB_SECUREMODE_NOSEC}, + {NULL, -1}, +}; + +static struct app_parameter_s app_param; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: selectable_paramparse + ****************************************************************************/ + +static int selectable_paramparse(const char *value, + struct param_value_s *tbl) +{ + for (; tbl->param; tbl++) + { + if (!strcmp(value, tbl->param)) + { + return tbl->value; + } + } + + return -1; +} + +/**************************************************************************** + * Name: setup_parsedvalue + ****************************************************************************/ + +static int setup_parsedvalue(void *user, const char *section, + const char *name, const char *value) +{ + struct app_parameter_s *param = (struct app_parameter_s *)user; + int parsed_param; + + /* Settings of this application is informed by INI file. + * The INI file needs to contain below items. + * + * [LTE] + * apn_name = ;Set APN name according to your SIM + * rat = ;Select RAT from CATM or NB + * auth_type = ;Select authentication type from + * ; PAP, CHAP or NONE + * ip_type = ;Select IP type from V4, V6, V4V6, NONIP + * user_name = ;Set user name according to your SIM + * passwd = ;Set password according to your SIM + * + * [LwM2M] + * server_uri = ; LwM2M Server URL to connect + * bootstrap = ;Set "true" when you use BootStrap server + * security_mode = ; Select Secure mode from NONE or PSK + * deviceid = ; Set Device ID + * security_key = ; Set security key + * + */ + + if (!strcmp(section, "LTE") && !strcmp(name, "apn_name")) + { + strncpy(param->apn_name, value, sizeof(param->apn_name)); + } + else if (!strcmp(section, "LTE") && !strcmp(name, "rat")) + { + param->rat = selectable_paramparse(value, rat_param); + if (param->rat < 0) + { + printf("Unknown RAT selection %s:%s = %s\n", + section, name, value); + + /* return 0 means error */ + + return 0; + } + } + else if (!strcmp(section, "LTE") && !strcmp(name, "auth_type")) + { + param->auth_type = selectable_paramparse(value, authtype_param); + if (param->auth_type < 0) + { + printf("Unknown Authentication type %s:%s = %s\n", + section, name, value); + + /* return 0 means error */ + + return 0; + } + } + else if (!strcmp(section, "LTE") && !strcmp(name, "ip_type")) + { + param->ip_type = selectable_paramparse(value, iptype_param); + if (param->ip_type < 0) + { + printf("Unknown IP type %s:%s = %s\n", + section, name, value); + + /* return 0 means error */ + + return 0; + } + } + else if (!strcmp(section, "LTE") && !strcmp(name, "user_name")) + { + strncpy(param->user_name, value, sizeof(param->user_name)); + } + else if (!strcmp(section, "LTE") && !strcmp(name, "passwd")) + { + strncpy(param->passwd, value, sizeof(param->passwd)); + } + else if (!strcmp(section, "LwM2M") && !strcmp(name, "epname")) + { + strncpy(param->epname, value, sizeof(param->epname)); + } + else if (!strcmp(section, "LwM2M") && !strcmp(name, "server_uri")) + { + strncpy(param->server_uri, value, sizeof(param->server_uri)); + } + else if (!strcmp(section, "LwM2M") && !strcmp(name, "bootstrap")) + { + parsed_param = selectable_paramparse(value, truefalse_param); + if (parsed_param < 0) + { + printf("Unknown bootstrap parameter %s:%s = %s\n", + section, name, value); + + /* return 0 means error */ + + return 0; + } + + param->bootstrap = parsed_param ? true : false; + } + else if (!strcmp(section, "LwM2M") && !strcmp(name, "security_mode")) + { + param->security_mode = selectable_paramparse(value, secmode_param); + if (param->security_mode < 0) + { + printf("Unknown security_mode parameter %s:%s = %s\n", + section, name, value); + + /* return 0 means error */ + + return 0; + } + } + else if (!strcmp(section, "LwM2M") && !strcmp(name, "deviceid")) + { + strncpy(param->device_id, value, sizeof(param->device_id)); + } + else if (!strcmp(section, "LwM2M") && !strcmp(name, "security_key")) + { + strncpy(param->security_key, value, sizeof(param->security_key)); + } + else if (!strcmp(section, "LwM2M") && !strcmp(name, "time_period")) + { + printf("Time period.\n"); + param->time_period = atoi(value); + } + + /* return 1 means OK (no error) */ + + return 1; +} + +/**************************************************************************** + * Name: dump_params + ****************************************************************************/ + +static void dump_params(struct app_parameter_s *param) +{ + printf("=== Setting parameters from INI file ===\n"); + printf("\n"); + printf(" apn_name = %s\n", param->apn_name); + printf(" rat = %d\n", param->rat); + printf(" auth_type = %d\n", param->auth_type); + printf(" ip_type = %d\n", param->ip_type); + printf(" user_name = %s\n", param->user_name); + printf(" password = %s\n", param->passwd); + printf("\n"); + printf(" server_uri = %s\n", param->server_uri); + printf(" bootstrap = %s\n", param->bootstrap ? "TRUE" : "FALSE"); + printf(" security_mode = %d\n", param->security_mode); + printf(" device_id = %s\n", param->device_id); + printf(" security_key = %s\n\n", param->security_key); + printf(" time_period = %d\n\n", param->time_period); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: createparam_from_ini + ****************************************************************************/ + +struct app_parameter_s *createparam_from_ini(const char *filename) +{ + int ret; + memset(&app_param, 0, sizeof(app_param)); + + ret = ini_parse(filename, setup_parsedvalue, &app_param); + if (ret != 0) + { + printf("ini_parse ret = %d\n", ret); + if (ret < 0) + { + printf("Couldn't open : %s\n", filename); + } + + return NULL; + } + + /* Check parameters for discrepancies */ + + if (app_param.security_mode == LWM2MSTUB_SECUREMODE_PSK && + (app_param.device_id[0] == '\0' || app_param.security_key[0] == '\0')) + { + printf("Enabled PSK security, but no device ID or security key\n"); + return NULL; + } + + if (app_param.ip_type == LTE_IPTYPE_NON && app_param.rat != LTE_RAT_NBIOT) + { + printf("IP Type is NON-IP, but RAT is not NB-IOT\n"); + return NULL; + } + + dump_params(&app_param); + + return &app_param; +} + +/**************************************************************************** + * Name: get_appparam + ****************************************************************************/ + +struct app_parameter_s *get_appparam(void) +{ + return &app_param; +} diff --git a/examples/lte_lwm2mstub/app_parameter.h b/examples/lte_lwm2mstub/app_parameter.h new file mode 100644 index 000000000..b84421a5a --- /dev/null +++ b/examples/lte_lwm2mstub/app_parameter.h @@ -0,0 +1,110 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/app_parameter.h + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __EXAMPLES_LTE_LWM2MSTUB_APP_PARAMETER_H +#define __EXAMPLES_LTE_LWM2MSTUB_APP_PARAMETER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define APP_MAXPARAMLEN (54) + +#define MESSAGE_QUEUE_NAME "m2mstub_mq" +#define MESSAGE_QUEUE_MAX (1) + +#define MESSAGE_ID_LTE_RESTARTED (1) +#define MESSAGE_ID_LWM2M_OPERATE (2) +#define MESSAGE_ID_LWM2M_FWUPDATE (3) +#define MESSAGE_ID_LWM2M_OVSTART (4) +#define MESSAGE_ID_LWM2M_OVSTOP (5) +#define MESSAGE_ID_LWM2M_VALUE (6) +#define MESSAGE_ID_ENDAPP (7) +#define MESSAGE_ID_LWM2M_ACTION (8) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct app_parameter_s +{ + /* LTE setting */ + + char apn_name[APP_MAXPARAMLEN]; + int auth_type; + int ip_type; + char user_name[APP_MAXPARAMLEN]; + char passwd[APP_MAXPARAMLEN]; + int rat; + + /* LeM2M setting */ + + char epname[128]; + char server_uri[LWM2MSTUB_MAX_SERVER_NAME]; + char device_id[LWM2MSTUB_MAX_DEVID]; + char security_key[LWM2MSTUB_MAX_SEQKEY]; + bool bootstrap; + int security_mode; + + int time_period; +}; + +struct app_message_s +{ + int msgid; + union + { + int code; + char token[LWM2MSTUB_MAX_TOKEN_SIZE]; + } arg; +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +struct app_parameter_s *createparam_from_ini(const char *filename); +struct app_parameter_s *get_appparam(void); + +#endif /* __EXAMPLES_LTE_LWM2MSTUB_APP_PARAMETER_H */ diff --git a/examples/lte_lwm2mstub/lte_lwm2mstub_main.c b/examples/lte_lwm2mstub/lte_lwm2mstub_main.c new file mode 100644 index 000000000..42b4e1b91 --- /dev/null +++ b/examples/lte_lwm2mstub/lte_lwm2mstub_main.c @@ -0,0 +1,565 @@ +/**************************************************************************** + * examples/lte_lwm2mstub/lte_lwm2mstub_main.c + * + * Copyright 2022 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "app_parameter.h" +#include "app_lte_util.h" +#include "app_lwm2m_util.h" +#include "app_message.h" +#include "app_eventtimer.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define APP_INIFILE "/mnt/spif/lwm2m.ini" + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static char tmp_buff[256]; +static uint16_t enableobjs[6] = +{ + 1, 2, 3, 4, 5, 19 +}; + +static volatile int periodic_value = 1234; +static int dummy_value_01 = 0x1122aabb; +static int dummy_value_02 = 0xdeadbeef; + +static bool is_observing = false; +static char ov_token[LWM2MSTUB_MAX_TOKEN_SIZE]; + +static volatile bool is_task_running = false; +static bool is_registerd_once = false; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* LwM2M callbacks */ + +/**************************************************************************** + * Name: write_cb + ****************************************************************************/ + +static void write_cb(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst, char *value, int len) +{ + struct app_message_s msg; + + printf("[CB] Write /%d/%d/%d request value >>%s<<\n", + inst->object_id, inst->object_inst, inst->res_id, value); + + if (inst->object_id == 19 && inst->res_id == 0) + { + if (!strcmp(value, "01")) + { + msg.msgid = MESSAGE_ID_LWM2M_ACTION; + msg.arg.code = 1; + send_message(MESSAGE_QUEUE_NAME, &msg); + } + else if (!strcmp(value, "02")) + { + msg.msgid = MESSAGE_ID_LWM2M_ACTION; + msg.arg.code = 2; + send_message(MESSAGE_QUEUE_NAME, &msg); + } + + lte_m2m_writeresponse(seq_no, inst, LWM2MSTUB_RESP_CHANGED); + } + else + { + lte_m2m_writeresponse(seq_no, inst, LWM2MSTUB_RESP_NOTALLOW); + } +} + +/**************************************************************************** + * Name: read_cb + ****************************************************************************/ + +static void read_cb(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst) +{ + int len; + + printf("[CB] Read /%d/%d/%d request\n", + inst->object_id, inst->object_inst, inst->res_id); + + if (inst->object_id == 19 && inst->res_id == 0) + { + len = sprintf(tmp_buff, "%08x", periodic_value); + lte_m2m_readresponse(seq_no, inst, + LWM2MSTUB_RESP_CONTENT, tmp_buff, len); + } + else + { + lte_m2m_readresponse(seq_no, inst, + LWM2MSTUB_RESP_NOTALLOW, tmp_buff, 0); + } +} + +/**************************************************************************** + * Name: exec_cb + ****************************************************************************/ + +static void exec_cb(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst) +{ + printf("[CB] Exec /%d/%d/%d request\n", + inst->object_id, inst->object_inst, inst->res_id); + + lte_m2m_executeresp(seq_no, inst, LWM2MSTUB_RESP_NOTACCEPT); +} + +/**************************************************************************** + * Name: ovstart_cb + ****************************************************************************/ + +static void ovstart_cb(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst, char *token, + struct lwm2mstub_ovcondition_s *cond) +{ + struct app_message_s msg; + + printf("[CB] Observe Start /%d/%d/%d request: token=%s\n", + inst->object_id, inst->object_inst, inst->res_id, token); + + if (inst->object_id == 19) + { + msg.msgid = MESSAGE_ID_LWM2M_OVSTART; + memcpy(msg.arg.token, token, LWM2MSTUB_MAX_TOKEN_SIZE); + send_message(MESSAGE_QUEUE_NAME, &msg); + lte_m2m_observeresp(seq_no, LWM2MSTUB_RESP_CONTENT); + } + else + { + lte_m2m_observeresp(seq_no, LWM2MSTUB_RESP_UNAUTH); + } +} + +/**************************************************************************** + * Name: ovstop_cb + ****************************************************************************/ + +static void ovstop_cb(int seq_no, int srv_id, + struct lwm2mstub_instance_s *inst, char *token) +{ + struct app_message_s msg; + + printf("[CB] Observe Stop /%d/%d/%d request: token=%s\n", + inst->object_id, inst->object_inst, inst->res_id, token); + + if (inst->object_id == 19) + { + msg.msgid = MESSAGE_ID_LWM2M_OVSTOP; + send_message(MESSAGE_QUEUE_NAME, &msg); + } + + lte_m2m_observeresp(seq_no, LWM2MSTUB_RESP_CONTENT); +} + +/**************************************************************************** + * Name: serverop_cb + ****************************************************************************/ + +static void serverop_cb(int event) +{ + struct app_message_s msg; + + printf("Operation : %d ", event); + dump_opevent(event); + + if (event == LWM2MSTUB_OP_REGSUCCESS) + { + is_registerd_once = true; + } + + if (is_registerd_once && event == LWM2MSTUB_OP_OFFLINE) + { + msg.msgid = MESSAGE_ID_LWM2M_OPERATE; + msg.arg.code = event; + send_message(MESSAGE_QUEUE_NAME, &msg); + } +} + +/**************************************************************************** + * Name: fwupdate_cb + ****************************************************************************/ + +static void fwupstate_cb(int event) +{ + printf("FW Update state : %d ", event); + dump_fwevent(event); +} + +/**************************************************************************** + * Name: lwm2m_setup + ****************************************************************************/ + +static int lwm2m_setup(struct app_parameter_s *param) +{ + int ret; + struct lwm2mstub_serverinfo_s info; + + /* Setup server information */ + + info.device_id[0] = '\0'; + info.security_key[0] = '\0'; + + strncpy(info.server_uri, param->server_uri, sizeof(info.server_uri)); + strncpy(info.device_id, param->device_id, sizeof(info.device_id)); + strncpy(info.security_key, param->security_key, + sizeof(info.security_key)); + + info.bootstrap = param->bootstrap; + info.security_mode = param->security_mode; + info.nonip = (param->ip_type == LTE_IPTYPE_NON) ? true : false; + printf("nonip = %s\n", info.nonip ? "YES" : "NO"); + + ret = lte_setm2m_serverinfo(&info, 0); + if (ret < 0) + { + printf("lte_setm2m_serverinfo() failed:%d\n", ret); + return ERROR; + } + + usleep(100 * 1000); /* Wait for update stable */ + + /* Setup endpoint name */ + + lte_setm2m_endpointname(param->epname); + usleep(100 * 1000); /* Wait for update stable */ + + /* Enable objects */ + + lte_enablem2m_objects(enableobjs, + sizeof(enableobjs) / sizeof(enableobjs[0])); + usleep(100 * 1000); /* Wait for update stable */ + + /* Apply setting */ + + lte_apply_m2msetting(); + usleep(500 * 1000); /* Wait for modem is ready */ + + return OK; +} + +/**************************************************************************** + * Name: connect_to_lwm2mserver + ****************************************************************************/ + +static int connect_to_lwm2mserver(struct app_parameter_s *param) +{ + int ret; + int cmd; + + lte_set_report_m2mwrite(write_cb); + lte_set_report_m2mread(read_cb); + lte_set_report_m2mexec(exec_cb); + lte_set_report_m2movstart(ovstart_cb); + lte_set_report_m2movstop(ovstop_cb); + lte_set_report_m2moperation(serverop_cb); + lte_set_report_m2mfwupdate(fwupstate_cb); + + ret = lte_m2m_connection(LWM2MSTUB_CONNECT_REGISTER); + if (ret != OK) + { + printf("lwm2m register failed:%d\n", ret); + return ERROR; + } + + return OK; +} + +/**************************************************************************** + * Name: notify_value + ****************************************************************************/ + +static void notify_value(int value) +{ + int len; + struct lwm2mstub_instance_s inst; + + inst.object_id = 19; + inst.object_inst = 0; + inst.res_id = 0; + inst.res_inst = -1; + + len = sprintf(tmp_buff, "%08x", value); + printf("Update value as : token: %s, /19/0/0 %s\n", ov_token, tmp_buff); + printf("observe update : %d\n", + lte_m2m_observeupdate(ov_token, &inst, tmp_buff, len)); +} + +/**************************************************************************** + * Name: handle_message + ****************************************************************************/ + +static bool handle_message(struct app_message_s *msg) +{ + bool ret = true; + int *tgt; + + switch (msg->msgid) + { + case MESSAGE_ID_LWM2M_VALUE: + periodic_value = msg->arg.code; + printf("periodic_value = %d\n", periodic_value); + if (is_observing) + { + notify_value(periodic_value); + } + + break; + + case MESSAGE_ID_LWM2M_ACTION: + tgt = NULL; + switch (msg->arg.code) + { + case 1: + tgt = &dummy_value_01; + break; + case 2: + tgt = &dummy_value_02; + break; + } + + if (is_observing && tgt) + { + notify_value(*tgt); + } + + break; + + case MESSAGE_ID_LWM2M_OPERATE: + printf("Client is OFF so update register now.\n"); + lte_m2m_connection(LWM2MSTUB_CONNECT_REREGISTER); + break; + + case MESSAGE_ID_LWM2M_OVSTART: + is_observing = true; + memcpy(ov_token, msg->arg.token, sizeof(ov_token)); + printf("Observe Started. token:%s\n", ov_token); + break; + + case MESSAGE_ID_LWM2M_OVSTOP: + is_observing = false; + break; + + case MESSAGE_ID_ENDAPP: + ret = false; + break; + } + + return ret; +} + +/**************************************************************************** + * Name: lwm2m_task + ****************************************************************************/ + +static int lwm2m_task(int argc, char *argv[]) +{ + int ret; + bool is_running = true; + struct app_parameter_s *param; + struct app_message_s msg; + + /* Initializing */ + + param = createparam_from_ini(APP_INIFILE); + if (!param) + { + goto error_label_initial; + } + + if (create_msgqueue(MESSAGE_QUEUE_NAME) != OK) + { + printf("Message creation error\n"); + goto error_label_initial; + } + + if (power_on_ltemodem(param) != OK) + { + printf("LTE Poower On error\n"); + goto error_label_queue_unlink; + } + + printf("Setup LTE Server\n"); + if (lwm2m_setup(param) != OK) + { + printf("LwM2M setup error\n"); + goto error_label_lte_finalize; + } + + printf("Connection LTE network\n"); + if (connect_to_ltenetwork(param) != OK) + { + printf("LTE network connection failed\n"); + goto error_label_lte_finalize; + } + + printf("Connect to LwM2M Server\n"); + if (connect_to_lwm2mserver(param) != OK) + { + printf("Connection to LwM2M server failed\n"); + goto error_label_lte_finalize; + } + + if (timer_setup(param) != OK) + { + printf("Timer setup failed.\n"); + goto error_label_lwm2m_disconnect; + } + + lte_acquire_wakelock(); + + /* Main loop for waiting message and handle it */ + + while (is_running) + { + printf("Wait for next event\n"); + ret = receive_message(MESSAGE_QUEUE_NAME, &msg); + if (ret == OK) + { + is_running = handle_message(&msg); + } + } + + lte_release_wakelock(); + + timer_unset(); + +error_label_lwm2m_disconnect: + lte_m2m_connection(LWM2MSTUB_CONNECT_DEREGISTER); + +error_label_lte_finalize: + printf("LTE Finalize\n"); + lte_finalize(); + +error_label_queue_unlink: + printf("Unlink mqueue\n"); + mq_unlink(MESSAGE_QUEUE_NAME); + +error_label_initial: + printf("End this app.\n"); + is_task_running = false; + + return 0; +} + +/**************************************************************************** + * Name: m2mapp_update_value + ****************************************************************************/ + +static void m2mapp_update_value(int v) +{ + struct app_message_s msg; + + if (v >= 0) + { + msg.msgid = MESSAGE_ID_LWM2M_VALUE; + msg.arg.code = v; + send_message(MESSAGE_QUEUE_NAME, &msg); + } + else + { + msg.msgid = MESSAGE_ID_ENDAPP; + send_message(MESSAGE_QUEUE_NAME, &msg); + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: main + ****************************************************************************/ + +int main(int argc, char **argv) +{ + int ret; + + if (!is_task_running) + { + printf("Launching lwm2m_task...\n"); + ret = task_create("lwm2m_task", 100, 2048, lwm2m_task, NULL); + if (ret < 0) + { + printf("Could not create lwm2m task : [%d]\n", errno); + return -1; + } + + printf("Done.\n"); + is_task_running = true; + } + else if (argc == 2) + { + printf("Updating value : %s\n", argv[1]); + m2mapp_update_value(atoi(argv[1])); + } + + return 0; +} + +/**************************************************************************** + * Name: increment_value + ****************************************************************************/ + +void increment_value(void) +{ + m2mapp_update_value(periodic_value + 1); +} diff --git a/examples/lte_lwm2mstub/lwm2m.ini b/examples/lte_lwm2mstub/lwm2m.ini new file mode 100644 index 000000000..895018ba7 --- /dev/null +++ b/examples/lte_lwm2mstub/lwm2m.ini @@ -0,0 +1,43 @@ +[LTE] + +; Set APN name according to your SIM +apn_name = + +; Set user name according to your SIM +user_name = + +; Set password according to your SIM +passwd = + +; Select RAT from CATM or NB +rat = CATM + +; Select authentication type from PAP, CHAP or NONE +auth_type = CHAP + +; Select IP type from V4, V6, V4V6, NONIP +ip_type = V4 + +[LwM2M] + +; Endpoint name +epname = + +; LwM2M Server URL to connect like coap://leshan.eclipseprojects.io:5683 +server_uri = + +; Set "true" when you use BootStrap server +bootstrap = false + +; Select Secure mode from NONE or PSK +security_mode = NONE + +; Set Device ID +deviceid = + +; Set security key +security_key = + +; Timer period in secounds to notice when observation is started. +; Set zero makes no periodic update. +time_period = 10 From af2b9f93debbf808d9d21e217b54551f5b11a7a3 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 14 Jul 2022 09:46:52 +0900 Subject: [PATCH 35/52] examles/lte_lwm2mstub: Add sample defconfig Add the defconfig of lte_lwm2mstub --- sdk/configs/examples/lte_lwm2mstub/README.txt | 4 +++ sdk/configs/examples/lte_lwm2mstub/defconfig | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 sdk/configs/examples/lte_lwm2mstub/README.txt create mode 100644 sdk/configs/examples/lte_lwm2mstub/defconfig diff --git a/sdk/configs/examples/lte_lwm2mstub/README.txt b/sdk/configs/examples/lte_lwm2mstub/README.txt new file mode 100644 index 000000000..8cf25ef20 --- /dev/null +++ b/sdk/configs/examples/lte_lwm2mstub/README.txt @@ -0,0 +1,4 @@ +This configuration contains required options to use lte_lwm2mstub example. + +[Source path] +examples/lte_lwm2mstub diff --git a/sdk/configs/examples/lte_lwm2mstub/defconfig b/sdk/configs/examples/lte_lwm2mstub/defconfig new file mode 100644 index 000000000..7e462c94f --- /dev/null +++ b/sdk/configs/examples/lte_lwm2mstub/defconfig @@ -0,0 +1,28 @@ +-LIBC_IPv4_ADDRCONV=y +-LIBC_IPv6_ADDRCONV=y +-NET=y +-NETDEV_LATEINIT=y +-NET_IPv4=n +-NET_SOCKOPTS=y +-NET_USRSOCK_TCP=y +-PIPES=y +-SPI=y ++CXD56_DMAC_SPI4_RX_MAXSIZE=2064 ++CXD56_DMAC_SPI4_TX_MAXSIZE=2064 ++CXD56_LTE=y ++EXTERNALS_MBEDTLS=y ++FSUTILS_INIH=y ++LTE_ALT1250=y ++LTE_LAPI=y ++LTE_SYSCTL=y ++MODEM=y ++MODEM_ALT1250=y ++NETDB_DNSCLIENT=y ++NETDB_DNSCLIENT_NAMESIZE=255 ++NETDB_DNSSERVER_IPv4ADDR=0x8080808 ++NETUTILS_WEBCLIENT=y ++NET_IPv6=y ++NSH_CUSTOMROMFS=y ++NSH_CUSTOMROMFS_HEADER="../../system/startup_script/nsh_romfsimg.h" ++SYSTEM_STARTUP_SCRIPT=y ++SYSTEM_VI=y From ae666828cbbc4cb8ff433c8e70a87d2b4e87db81 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 18 Jul 2022 19:30:18 -0700 Subject: [PATCH 36/52] examples/lte_lwm2mstub: Remove unused variable Remove unused variable in lte_lwm2mstub_main.c. --- examples/lte_lwm2mstub/lte_lwm2mstub_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/lte_lwm2mstub/lte_lwm2mstub_main.c b/examples/lte_lwm2mstub/lte_lwm2mstub_main.c index 42b4e1b91..9eb913be8 100644 --- a/examples/lte_lwm2mstub/lte_lwm2mstub_main.c +++ b/examples/lte_lwm2mstub/lte_lwm2mstub_main.c @@ -303,7 +303,6 @@ static int lwm2m_setup(struct app_parameter_s *param) static int connect_to_lwm2mserver(struct app_parameter_s *param) { int ret; - int cmd; lte_set_report_m2mwrite(write_cb); lte_set_report_m2mread(read_cb); From b3e8cdc2450219a2d0d27eb226a03b53f027813e Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 18 Jul 2022 19:33:02 -0700 Subject: [PATCH 37/52] examples/lte_lwm2mstub: Add config param in defconfig The key example config parameter was not included in the defconfig. So it was added. --- sdk/configs/examples/lte_lwm2mstub/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/configs/examples/lte_lwm2mstub/defconfig b/sdk/configs/examples/lte_lwm2mstub/defconfig index 7e462c94f..8804c8aea 100644 --- a/sdk/configs/examples/lte_lwm2mstub/defconfig +++ b/sdk/configs/examples/lte_lwm2mstub/defconfig @@ -10,6 +10,7 @@ +CXD56_DMAC_SPI4_RX_MAXSIZE=2064 +CXD56_DMAC_SPI4_TX_MAXSIZE=2064 +CXD56_LTE=y ++EXAMPLES_LTE_LWM2MSTUB=y +EXTERNALS_MBEDTLS=y +FSUTILS_INIH=y +LTE_ALT1250=y From c207a8e0f12c4938b91ead03b0d701a9930a9ed3 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 26 Jul 2022 14:46:44 +0000 Subject: [PATCH 38/52] examples/multi_webcamera: Revert removing fail safe On last commit, fail safe code was removed. However, there was still a risk of freezing, so it is re-inserted and the insertion can be controlled by Kconfig option. --- examples/multi_webcamera/Kconfig | 7 +++++++ examples/multi_webcamera/multiwebcam_server.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/examples/multi_webcamera/Kconfig b/examples/multi_webcamera/Kconfig index eb6571de9..9f0fc7d08 100644 --- a/examples/multi_webcamera/Kconfig +++ b/examples/multi_webcamera/Kconfig @@ -66,4 +66,11 @@ config EXAMPLES_MULTIWEBCAM_PERF ---help--- Enable displaying performance information of multiwebcam. +config EXAMPLES_MULTIWEBCAM_FAILSAFE + bool "Enable fail-safe when 0 byte send" + default y + ---help--- + Connection will be destroyed when data size was zero on sending + image data to a client. + endif diff --git a/examples/multi_webcamera/multiwebcam_server.c b/examples/multi_webcamera/multiwebcam_server.c index e1d56c6ce..40fccf5be 100644 --- a/examples/multi_webcamera/multiwebcam_server.c +++ b/examples/multi_webcamera/multiwebcam_server.c @@ -63,6 +63,12 @@ static int send_binary(int s, const char *data, int len) if (ret == 0) { printf("Send 0 byte. Maybe poor reception..\n"); + +#ifdef CONFIG_EXAMPLES_MULTIWEBCAM_FAILSAFE + printf("Behave as an error for fail safe.\n"); + return -1; +#endif + } if (ret < 0) From 6a4cc18c73544c587c79ad254a594ce4b837d392 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 19 Jul 2022 13:29:23 +0900 Subject: [PATCH 39/52] externals/nrf52: Fix bug that multiple API executions do not work well APIs are executed in multi-thread and the timings match, the late API thread keep running forever and the preceding API tasks freezes. Fix the bug by introducing lock and unlock with mutex and condition variable of pthread. --- .../application/transport/ser_sd_transport.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c index 84831af31..2bbbff481 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "ser_sd_transport.h" #include "ser_hal_transport.h" #include "nrf_error.h" @@ -85,6 +86,8 @@ static ser_sd_transport_rsp_handler_t m_rsp_dec_handler = NULL; /** Flag indicated whether module is waiting for response packet. */ static volatile bool m_rsp_wait = false; +static pthread_mutex_t m_mutex_rsp_wait; +static pthread_cond_t m_cond_rsp_wait; /** SoftDevice call return value decoded by user decoder handler. */ static uint32_t m_return_value; @@ -213,6 +216,9 @@ uint32_t ser_sd_transport_open(ser_sd_transport_evt_handler_t ble_ev ser_sd_transport_rsp_set_handler_t os_rsp_set_handler, ser_sd_transport_rx_notification_handler_t rx_not_handler) { + pthread_mutex_init(&m_mutex_rsp_wait, NULL); + pthread_cond_init(&m_cond_rsp_wait, NULL); + m_os_rsp_wait_handler = os_rsp_wait_handler; m_os_rsp_set_handler = os_rsp_set_handler; m_rx_notify_handler = rx_not_handler; @@ -259,6 +265,9 @@ uint32_t ser_sd_transport_close(void) ser_hal_transport_close(); + pthread_cond_destroy(&m_cond_rsp_wait); + pthread_mutex_destroy(&m_mutex_rsp_wait); + return NRF_SUCCESS; } @@ -278,6 +287,8 @@ uint32_t ser_sd_transport_tx_alloc(uint8_t * * pp_data, uint16_t * p_len) { uint32_t err_code; + pthread_mutex_lock(&m_mutex_rsp_wait); + if (m_rsp_wait) { err_code = NRF_ERROR_BUSY; @@ -286,6 +297,13 @@ uint32_t ser_sd_transport_tx_alloc(uint8_t * * pp_data, uint16_t * p_len) { err_code = ser_hal_transport_tx_pkt_alloc(pp_data, p_len); } + + if ((err_code == NRF_ERROR_BUSY) || (err_code == NRF_ERROR_NO_MEM)) + { + pthread_cond_wait(&m_cond_rsp_wait, &m_mutex_rsp_wait); + } + + pthread_mutex_unlock(&m_mutex_rsp_wait); return err_code; } @@ -306,6 +324,7 @@ uint32_t ser_sd_transport_cmd_write(const uint8_t * p_buffer, { uint32_t err_code = NRF_SUCCESS; + pthread_mutex_lock(&m_mutex_rsp_wait); m_rsp_wait = true; m_rsp_dec_handler = cmd_rsp_decode_callback; err_code = ser_hal_transport_tx_pkt_send(p_buffer, length); @@ -335,6 +354,9 @@ uint32_t ser_sd_transport_cmd_write(const uint8_t * p_buffer, m_rsp_wait = false; } + pthread_cond_signal(&m_cond_rsp_wait); + pthread_mutex_unlock(&m_mutex_rsp_wait); + NRF_LOG_DEBUG("[SD_CALL]:%lx, err_code= 0x%lX", (uint32_t)p_buffer[1], err_code); return err_code; } From 12a05fd4f95cd53cd6dfc4a9012aacaeb67aaa38 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 28 Jul 2022 10:39:15 +0900 Subject: [PATCH 40/52] sdk/modules/bluetooth: Modify BT_FAIL definition Old BT_FAIL definition is -127, and bluetooth API return 0 or -127 or negated error number. This I/F may confuse users. Modify BT_FAIL to -1 so as not to confuse users. --- sdk/modules/include/bluetooth/bluetooth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/modules/include/bluetooth/bluetooth.h b/sdk/modules/include/bluetooth/bluetooth.h index 5f8f1a751..4bf48c3a9 100644 --- a/sdk/modules/include/bluetooth/bluetooth.h +++ b/sdk/modules/include/bluetooth/bluetooth.h @@ -85,7 +85,7 @@ *@name BT fail code *@{ */ -#define BT_FAIL -127 +#define BT_FAIL -1 /** @} */ /** From d890c77bbea6a32488683d93df4a25ba1fbdaa74 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 28 Jul 2022 15:48:31 +0900 Subject: [PATCH 41/52] externals/nrf52: Fix type of size variables The size variables, that is used as returned value of write(), should have signed type. Detected by Codesonar 1215830. --- .../serialization/common/transport/ser_phy/ser_phy_uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c index 34cf473d4..af667ee9e 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c @@ -483,8 +483,8 @@ static __INLINE void callback_packet_sent(void) static int ser_phy_uart_send(void* buf, int size) { int ret = 0; - size_t sz; - size_t rem_sz = size; + ssize_t sz; + ssize_t rem_sz = size; uint8_t *addr = buf; NRF_LOG_DEBUG("ser_phy_uart_send size %d\n", size); From 51f157640ec94fe8ab3f5c75770760235b2fb8f4 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 28 Jul 2022 16:32:02 +0900 Subject: [PATCH 42/52] modules/bluetooth: nrf52: Fix value validation of enumerate variable Fix value validation of enumerate variable. Detected by Codesonar 1215827. --- sdk/modules/bluetooth/hal/nrf52/ble_gap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/modules/bluetooth/hal/nrf52/ble_gap.c b/sdk/modules/bluetooth/hal/nrf52/ble_gap.c index 81f1d8900..af4b78abd 100644 --- a/sdk/modules/bluetooth/hal/nrf52/ble_gap.c +++ b/sdk/modules/bluetooth/hal/nrf52/ble_gap.c @@ -423,7 +423,8 @@ int BLE_GapExchangePairingFeature(BLE_GapConnHandle connHandle, BLE_GapPairingFe BLE_PRT("pairingFeature is NULL!!!\n"); return -EINVAL; } - if((pairingFeature->oob > BLE_GAP_OOB_AUTH_DATA_PRESENT) || (pairingFeature->oob < BLE_GAP_OOB_AUTH_DATA_NOT_PRESENT)) { + if((pairingFeature->oob != BLE_GAP_OOB_AUTH_DATA_PRESENT) && + (pairingFeature->oob != BLE_GAP_OOB_AUTH_DATA_NOT_PRESENT)) { BLE_PRT("pairingFeature->oob=%d\n", pairingFeature->oob); return -EINVAL; } From 7e7f258c246ae9660e29152ceeeef499f3cc6492 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 28 Jul 2022 12:11:00 +0900 Subject: [PATCH 43/52] externals/nrf52: Fix copyright description Add Sony Semiconductor Solutions Corporation to copyright description of modified files. --- .../nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h | 1 + .../components/libraries/log/src/nrf_log_internal.h | 1 + .../components/libraries/queue/nrf_queue.c | 1 + .../components/libraries/queue/nrf_queue.h | 1 + .../components/libraries/util/app_error.h | 1 + .../nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h | 1 + .../components/libraries/util/app_util_platform.h | 1 + .../components/libraries/util/sdk_common.h | 1 + .../serialization/application/hal/ser_app_power_system_off.c | 1 + .../serialization/application/transport/ser_sd_transport.c | 1 + .../serialization/application/transport/ser_softdevice_handler.c | 1 + .../serialization/common/transport/ser_hal_transport.c | 1 + .../serialization/common/transport/ser_phy/ser_phy_uart.c | 1 + .../components/softdevice/common/nrf_sdh.c | 1 + .../components/softdevice/common/nrf_sdh_ble.c | 1 + .../components/softdevice/s132/headers/ble_gattc.h | 1 + .../nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h | 1 + externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h | 1 + 18 files changed, 18 insertions(+) diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h index 34a97450e..bdc744e37 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/nrf_log.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h index efc8c636a..3d6a91498 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log/src/nrf_log_internal.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c index f806227e1..186223d03 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h index 8c5962606..77743f779 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue/nrf_queue.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2016 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h index c4d54373d..6a28b6034 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_error.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h index 201d24587..6ff21098f 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2012 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h index 3565f7cd6..55be38296 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/app_util_platform.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h index 8d96a5d74..12d73531f 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util/sdk_common.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2013 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c index cef10d2ad..cc316e903 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/hal/ser_app_power_system_off.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c index 2bbbff481..ecbec26e6 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_sd_transport.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c index 63b28b0e6..66fb187dd 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/application/transport/ser_softdevice_handler.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c index 2f923e80f..f6979a7f4 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_hal_transport.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c index af667ee9e..85a83eb99 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/serialization/common/transport/ser_phy/ser_phy_uart.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c index 3847ca513..76b241d14 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c index 8806634fa..2d0298e21 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common/nrf_sdh_ble.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h index 2c280c9b2..5ea4a50dc 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers/ble_gattc.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2011 - 2020, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h index a6ab3ba46..83ad0106c 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config/sdk_config.h @@ -1,5 +1,6 @@ /** * Copyright (c) 2017 - 2021, Nordic Semiconductor ASA + * Copyright 2022 Sony Semiconductor Solutions Corporation * * All rights reserved. * diff --git a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h index 1574c3a8b..207732d77 100644 --- a/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h +++ b/externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk/nrf.h @@ -1,6 +1,7 @@ /* Copyright (c) 2010 - 2021, Nordic Semiconductor ASA +Copyright 2022 Sony Semiconductor Solutions Corporation All rights reserved. From cc0801ffc1dceaa77f376bf6f462b7cf8ed682ef Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Sat, 30 Jul 2022 07:27:19 +0900 Subject: [PATCH 44/52] Update Submodules for develop at 2022/07/30 07:27:19 --- nuttx | 2 +- sdk/apps | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuttx b/nuttx index e6c3072fd..9f5ccaba6 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit e6c3072fd4a69afdced8a2c559bead0b909a8095 +Subproject commit 9f5ccaba66cf63bcb8ed7a57e98c25ac47b22718 diff --git a/sdk/apps b/sdk/apps index d095239f4..75a788af8 160000 --- a/sdk/apps +++ b/sdk/apps @@ -1 +1 @@ -Subproject commit d095239f4253d216b6e3bdac6e7f6ae3b34fd253 +Subproject commit 75a788af881f4940df5c8fdb51d5846bae5837eb From b10c41e8ea33ee5f350192dc774d4fc314e1019a Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 26 Jul 2022 23:02:51 +0000 Subject: [PATCH 45/52] examples/lte_lwm2mstub: Add object19 setup This sample is using object19. To use it on alt1250, the object must be defined in a modem. Add code for making sure the object is define and if not, define it. --- examples/lte_lwm2mstub/lte_lwm2mstub_main.c | 81 ++++++++++++++++++--- 1 file changed, 71 insertions(+), 10 deletions(-) diff --git a/examples/lte_lwm2mstub/lte_lwm2mstub_main.c b/examples/lte_lwm2mstub/lte_lwm2mstub_main.c index 9eb913be8..969d24c13 100644 --- a/examples/lte_lwm2mstub/lte_lwm2mstub_main.c +++ b/examples/lte_lwm2mstub/lte_lwm2mstub_main.c @@ -62,6 +62,7 @@ * Pre-processor Definitions ****************************************************************************/ +#define OBJID_DATACONTAINER (19) #define APP_INIFILE "/mnt/spif/lwm2m.ini" /**************************************************************************** @@ -71,9 +72,23 @@ static char tmp_buff[256]; static uint16_t enableobjs[6] = { - 1, 2, 3, 4, 5, 19 + 1, 2, 3, 4, 5, OBJID_DATACONTAINER }; +static struct lwm2mstub_resource_s datacontainer_res[] = +{ + { + .res_id = 0, + .operation = LWM2MSTUB_RESOP_RW, + .inst_type = LWM2MSTUB_RESINST_SINGLE, + .data_type = LWM2MSTUB_RESDATA_OPAQUE, + .handl = LWM2MSTUB_RESOURCE_HANDLENOCARE + }, +}; + +#define DATACONTAINER_OBJRESNUM \ + (sizeof(datacontainer_res) / sizeof(datacontainer_res[0])) + static volatile int periodic_value = 1234; static int dummy_value_01 = 0x1122aabb; static int dummy_value_02 = 0xdeadbeef; @@ -99,10 +114,10 @@ static void write_cb(int seq_no, int srv_id, { struct app_message_s msg; - printf("[CB] Write /%d/%d/%d request value >>%s<<\n", - inst->object_id, inst->object_inst, inst->res_id, value); + printf("[CB] Write /%d/%d/%d request size=%d value >>%s<<\n", + inst->object_id, inst->object_inst, inst->res_id, len, value); - if (inst->object_id == 19 && inst->res_id == 0) + if (inst->object_id == OBJID_DATACONTAINER && inst->res_id == 0) { if (!strcmp(value, "01")) { @@ -137,7 +152,7 @@ static void read_cb(int seq_no, int srv_id, printf("[CB] Read /%d/%d/%d request\n", inst->object_id, inst->object_inst, inst->res_id); - if (inst->object_id == 19 && inst->res_id == 0) + if (inst->object_id == OBJID_DATACONTAINER && inst->res_id == 0) { len = sprintf(tmp_buff, "%08x", periodic_value); lte_m2m_readresponse(seq_no, inst, @@ -176,7 +191,7 @@ static void ovstart_cb(int seq_no, int srv_id, printf("[CB] Observe Start /%d/%d/%d request: token=%s\n", inst->object_id, inst->object_inst, inst->res_id, token); - if (inst->object_id == 19) + if (inst->object_id == OBJID_DATACONTAINER) { msg.msgid = MESSAGE_ID_LWM2M_OVSTART; memcpy(msg.arg.token, token, LWM2MSTUB_MAX_TOKEN_SIZE); @@ -201,7 +216,7 @@ static void ovstop_cb(int seq_no, int srv_id, printf("[CB] Observe Stop /%d/%d/%d request: token=%s\n", inst->object_id, inst->object_inst, inst->res_id, token); - if (inst->object_id == 19) + if (inst->object_id == OBJID_DATACONTAINER) { msg.msgid = MESSAGE_ID_LWM2M_OVSTOP; send_message(MESSAGE_QUEUE_NAME, &msg); @@ -244,6 +259,48 @@ static void fwupstate_cb(int event) dump_fwevent(event); } +/**************************************************************************** + * Name: is_the_object_same + ****************************************************************************/ + +static bool is_the_object_same(void) +{ + struct lwm2mstub_resource_s res; + + if (lte_getm2m_objresourceinfo(OBJID_DATACONTAINER, 1, &res) >= 0) + { + if (res.res_id == datacontainer_res[0].res_id && + res.operation == datacontainer_res[0].operation && + res.inst_type == datacontainer_res[0].inst_type && + res.data_type == datacontainer_res[0].data_type ) + { + return true; + } + } + + return false; +} + +/**************************************************************************** + * Name: object_datacontainer_setup + ****************************************************************************/ + +static void object_datacontainer_setup(void) +{ + int resnum; + + resnum = lte_getm2m_objresourcenum(OBJID_DATACONTAINER); + if (resnum != DATACONTAINER_OBJRESNUM || !is_the_object_same()) + { + printf("Setup object %d\n", OBJID_DATACONTAINER); + lte_setm2m_objectdefinition(OBJID_DATACONTAINER, + DATACONTAINER_OBJRESNUM, datacontainer_res); + usleep(100 * 1000); /* Wait for update stable */ + } + + dump_objinfo(OBJID_DATACONTAINER); +} + /**************************************************************************** * Name: lwm2m_setup ****************************************************************************/ @@ -266,7 +323,6 @@ static int lwm2m_setup(struct app_parameter_s *param) info.bootstrap = param->bootstrap; info.security_mode = param->security_mode; info.nonip = (param->ip_type == LTE_IPTYPE_NON) ? true : false; - printf("nonip = %s\n", info.nonip ? "YES" : "NO"); ret = lte_setm2m_serverinfo(&info, 0); if (ret < 0) @@ -277,6 +333,10 @@ static int lwm2m_setup(struct app_parameter_s *param) usleep(100 * 1000); /* Wait for update stable */ + /* Setup Binary App Data Container object (ID:19) */ + + object_datacontainer_setup(); + /* Setup endpoint name */ lte_setm2m_endpointname(param->epname); @@ -331,13 +391,14 @@ static void notify_value(int value) int len; struct lwm2mstub_instance_s inst; - inst.object_id = 19; + inst.object_id = OBJID_DATACONTAINER; inst.object_inst = 0; inst.res_id = 0; inst.res_inst = -1; len = sprintf(tmp_buff, "%08x", value); - printf("Update value as : token: %s, /19/0/0 %s\n", ov_token, tmp_buff); + printf("Update value as : token: %s, /%d/0/0 %s\n", + ov_token, OBJID_DATACONTAINER, tmp_buff); printf("observe update : %d\n", lte_m2m_observeupdate(ov_token, &inst, tmp_buff, len)); } From 3fd993a565c0149aa258e528a2cef740a2072282 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 1 Aug 2022 22:37:15 +0900 Subject: [PATCH 46/52] Update Submodules for develop at 2022/08/01 22:37:15 --- nuttx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuttx b/nuttx index 9f5ccaba6..65d6eddf6 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit 9f5ccaba66cf63bcb8ed7a57e98c25ac47b22718 +Subproject commit 65d6eddf649a5e8488d11ad9f62250e677616c95 From 306872fc7293f5a865afb817f20ad493e82fdf50 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 1 Aug 2022 14:38:09 +0900 Subject: [PATCH 47/52] Update the LICENSE for SDK v2.6.0 with Nordic nRF5 SDK --- LICENSE | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/LICENSE b/LICENSE index 0b986d888..4d3194aa8 100644 --- a/LICENSE +++ b/LICENSE @@ -1623,3 +1623,30 @@ This software includes open source software subject to the licensing described in the following file: externals/websocket/cwebsocket/LICENSE + +======================================================================== + + +14. License of nRF52 + +======================================================================== +externals/nrf52/nRF5_SDK17.1.0_ddde560 + +This software includes open source software subject to the licensing +described in the following file: + + externals/nrf52/nRF5_SDK17.1.0_ddde560/nRF5_Nordic_license.txt + + +The original codes can be downloaded as a zip file from the following site: + +Download: +https://www.nordicsemi.com/Products/Development-software/nRF5-SDK/Download +Version: 17.1.0 +SoftDevice: SI32 +Target: nRF52840 +File name: nRF5_SDK_17.1.0_ddde560.zip + +Notice: +The software under the nRF5_Nordic_licence here must only be used with +a Noridic Semiconductor ASA integrated circuit. From 92c894a90523701452d96c8826027e9923a85be7 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Mon, 1 Aug 2022 16:58:06 +0900 Subject: [PATCH 48/52] externals/nrf52: Add a README to show the download location for nRF5 The original archive file can be downloaded as a zip on the site. --- externals/nrf52/README | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 externals/nrf52/README diff --git a/externals/nrf52/README b/externals/nrf52/README new file mode 100644 index 000000000..4f3588e1f --- /dev/null +++ b/externals/nrf52/README @@ -0,0 +1,11 @@ +# Original Code Location + +The original codes of nRF5_SDK_17.1.0_ddde560 can be downloaded as a zip file +from the following site: + +Download: +https://www.nordicsemi.com/Products/Development-software/nRF5-SDK/Download +Version: 17.1.0 +SoftDevice: SI32 +Target: nRF52840 +File name: nRF5_SDK_17.1.0_ddde560.zip From f7655855d481f8c7abc04fe697c5390bceb2bcee Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 28 Jul 2022 22:44:35 -0700 Subject: [PATCH 49/52] examples/multi_webcamera: Reinforce fail safe To reinforce fail safe, re-create server socket after finishing the client connection. --- examples/multi_webcamera/multiwebcam_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/multi_webcamera/multiwebcam_main.c b/examples/multi_webcamera/multiwebcam_main.c index 45bfce0d3..52fa726a6 100644 --- a/examples/multi_webcamera/multiwebcam_main.c +++ b/examples/multi_webcamera/multiwebcam_main.c @@ -126,9 +126,12 @@ int main(int argc, FAR char *argv[]) printf("Finish Jpeg thread.\n"); wsock = 0; } +#ifndef CONFIG_EXAMPLES_MULTIWEBCAM_FAILSAFE else +#endif { - printf("Accept is failed. Re-create server socket\n"); + printf("Re-create server socket\n"); + close(rsock); rsock = multiwebcam_initserver(MULTIWEBCAM_PORT_NO); } From f4a345eae907c77b401c414938e27461db8cb932 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Sun, 31 Jul 2022 23:33:45 +0000 Subject: [PATCH 50/52] examples/multi_webcamera: Keep accepting for avoiding multi connection Some browsers attempt multiple connections. But this app allows only one connection. In case of using GS2200M, the driver accepts all socket without accept() API call. And accept socket remains in the driver. This has a negative impact for next connection. So app keeps accepting and close the accepted socket when the streaming is already started. --- examples/multi_webcamera/multiwebcam_main.c | 31 ++++++++++++------- .../multi_webcamera/multiwebcam_threads.c | 19 ++++++++++++ .../multi_webcamera/multiwebcam_threads.h | 2 ++ 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/examples/multi_webcamera/multiwebcam_main.c b/examples/multi_webcamera/multiwebcam_main.c index 52fa726a6..50a73ec07 100644 --- a/examples/multi_webcamera/multiwebcam_main.c +++ b/examples/multi_webcamera/multiwebcam_main.c @@ -69,8 +69,8 @@ int main(int argc, FAR char *argv[]) int rsock; int wsock; struct sockaddr_in client; - pthread_t cam_thd; - pthread_t jpeg_thd; + pthread_t cam_thd = -1; + pthread_t jpeg_thd = -1; int v_fd; struct v_buffer *vbuffs; @@ -120,19 +120,28 @@ int main(int argc, FAR char *argv[]) if (wsock > 0) { - printf("Start Jpeg thread.\n"); - jpeg_thd = multiwebcam_start_jpegsender(wsock); - pthread_join(jpeg_thd, NULL); - printf("Finish Jpeg thread.\n"); - wsock = 0; + if (multiwebcam_isstarted_jpegsender(jpeg_thd)) + { + close(wsock); + printf("Already started..\n" + "Destroy the new accepted socket, " + "because only single connection is acceptable.\n"); + } + else + { + jpeg_thd = multiwebcam_start_jpegsender(wsock); + } } -#ifndef CONFIG_EXAMPLES_MULTIWEBCAM_FAILSAFE else -#endif { - printf("Re-create server socket\n"); close(rsock); - rsock = multiwebcam_initserver(MULTIWEBCAM_PORT_NO); + rsock = -1; + printf("Accept is failed. Re-create server socket\n"); + while (rsock <= 0) + { + rsock = multiwebcam_initserver(MULTIWEBCAM_PORT_NO); + } + printf("Server sofket is created : %d\n", rsock); } sleep(1); diff --git a/examples/multi_webcamera/multiwebcam_threads.c b/examples/multi_webcamera/multiwebcam_threads.c index 845721dda..9265626a2 100644 --- a/examples/multi_webcamera/multiwebcam_threads.c +++ b/examples/multi_webcamera/multiwebcam_threads.c @@ -41,6 +41,7 @@ #include "multiwebcam_util.h" #include "multiwebcam_server.h" +static volatile bool is_jpegsender_running; static pthread_cond_t queue_cond; static pthread_mutex_t queue_mutex; @@ -181,15 +182,33 @@ static void *jpeg_sender(void *param) } } + printf("-- Finish JPEG thread --\n"); + is_jpegsender_running = false; return NULL; } +bool multiwebcam_isstarted_jpegsender(pthread_t thd) +{ + if (is_jpegsender_running) + { + return true; + } + else + { + /* Just in case, make sure the thread is exit */ + + pthread_join(thd, NULL); + return false; + } +} + pthread_t multiwebcam_start_jpegsender(int sock) { pthread_t thd; pthread_attr_t attr; struct sched_param sparam; + is_jpegsender_running = true; pthread_attr_init(&attr); sparam.sched_priority = 101; pthread_attr_setschedparam(&attr,&sparam); diff --git a/examples/multi_webcamera/multiwebcam_threads.h b/examples/multi_webcamera/multiwebcam_threads.h index 6474a487e..e87501260 100644 --- a/examples/multi_webcamera/multiwebcam_threads.h +++ b/examples/multi_webcamera/multiwebcam_threads.h @@ -36,9 +36,11 @@ #ifndef __EXAMPLES_MULTIWEBCAM_THREADS_H__ #define __EXAMPLES_MULTIWEBCAM_THREADS_H__ +#include #include pthread_t multiwebcam_start_camerathread(int v_fd); pthread_t multiwebcam_start_jpegsender(int sock); +bool multiwebcam_isstarted_jpegsender(pthread_t thd); #endif /* __EXAMPLES_MULTIWEBCAM_THREADS_H__ */ From a67f5eefbcdbabea6e681f384611cefa1d966d47 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 3 Aug 2022 05:41:44 +0900 Subject: [PATCH 51/52] Update Submodules for develop at 2022/08/03 05:41:43 --- nuttx | 2 +- sdk/apps | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuttx b/nuttx index 65d6eddf6..099691fca 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit 65d6eddf649a5e8488d11ad9f62250e677616c95 +Subproject commit 099691fcaf1c4e06197dede5a00571cbadb6e31a diff --git a/sdk/apps b/sdk/apps index 75a788af8..d14564630 160000 --- a/sdk/apps +++ b/sdk/apps @@ -1 +1 @@ -Subproject commit 75a788af881f4940df5c8fdb51d5846bae5837eb +Subproject commit d145646301aff40972194787d43847953a91f610 From aab07fb7bab491c5e7045705b0c8fa4027127d9a Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Fri, 5 Aug 2022 10:52:27 +0900 Subject: [PATCH 52/52] Update Submodules for v2.6.0 release --- nuttx | 2 +- sdk/apps | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuttx b/nuttx index 099691fca..70eb038a2 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit 099691fcaf1c4e06197dede5a00571cbadb6e31a +Subproject commit 70eb038a2e23def3599b7c407e5a1a23b32bd5bd diff --git a/sdk/apps b/sdk/apps index d14564630..1c5a6d9c4 160000 --- a/sdk/apps +++ b/sdk/apps @@ -1 +1 @@ -Subproject commit d145646301aff40972194787d43847953a91f610 +Subproject commit 1c5a6d9c4fd008877205baa1aa64240afcb1f0c9