diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index df782938d..890ddefa1 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -5,69 +5,7 @@ # SPDX-License-Identifier: Apache-2.0 if(CONFIG_HAS_STM32LIB) - if(CONFIG_BT_STM32_IPM) - zephyr_include_directories(stm32wb/hci) - - zephyr_sources(stm32wb/hci/hw_ipcc.c) - zephyr_sources(stm32wb/hci/shci.c) - zephyr_sources(stm32wb/hci/shci_tl.c) - zephyr_sources(stm32wb/hci/shci_tl_if.c) - zephyr_sources(stm32wb/hci/stm_list.c) - zephyr_sources(stm32wb/hci/tl_mbox.c) - - endif() - - if(CONFIG_BT_STM32WBA) - - if(DEFINED CONFIG_BOARD_NUCLEO_WBA52CG) - message(FATAL_ERROR "BLE library is not compatible with nucleo_wba52cg") - endif() - - zephyr_compile_definitions( -DBLE ) - - zephyr_include_directories(stm32wba/hci) - zephyr_include_directories(stm32wba/hci/ll) - - zephyr_sources(stm32wba/hci/ll_sys_cs.c) - zephyr_sources(stm32wba/hci/ll_sys_intf.c) - zephyr_sources(stm32wba/hci/ll_sys_dp_slp.c) - zephyr_sources(stm32wba/hci/ll_sys_startup.c) - zephyr_sources(stm32wba/hci/RTDebug.c) - zephyr_sources(stm32wba/hci/hw_pka.c) - zephyr_sources(stm32wba/hci/pka_p256.c) - zephyr_sources(stm32wba/hci/bpka.c) - zephyr_sources(stm32wba/hci/power_table.c) - zephyr_sources(stm32wba/hci/scm.c) - zephyr_sources(stm32wba/hci/log_module.c) - if(CONFIG_FLASH) - zephyr_sources(stm32wba/hci/flash_manager.c) - zephyr_sources(stm32wba/hci/flash_driver.c) - zephyr_sources(stm32wba/hci/stm_list.c) - zephyr_sources(stm32wba/hci/rf_timing_synchro.c) - endif() - - set(STM32WBA_BLE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../zephyr/blobs/stm32wba/lib) - set(STM32WBA_BLE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/stm32wba/hci) - - add_library(stm32wba_ble_lib STATIC IMPORTED GLOBAL) - add_library(stm32wba_ll_lib STATIC IMPORTED GLOBAL) - - add_dependencies( - stm32wba_ble_lib - stm32wba_ll_lib - ) - set_target_properties( - stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/stm32wba_ble_stack_llo.a - ) - set_target_properties( - stm32wba_ll_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/LinkLayer_BLE_Full_lib.a - ) - - set_target_properties(stm32wba_ble_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_INCLUDE_DIR}) - set_target_properties(stm32wba_ll_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_INCLUDE_DIR}) - - target_link_libraries(app PUBLIC stm32wba_ble_lib) - target_link_libraries(app PUBLIC stm32wba_ll_lib) - - endif() + add_subdirectory_ifdef(CONFIG_BT_STM32_IPM stm32wb) + add_subdirectory_ifdef(CONFIG_BT_STM32WBA stm32wba) + add_subdirectory_ifdef(CONFIG_BT_STM32WB0 stm32wb0) endif() diff --git a/lib/stm32wb/CMakeLists.txt b/lib/stm32wb/CMakeLists.txt new file mode 100644 index 000000000..a875149e6 --- /dev/null +++ b/lib/stm32wb/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) 2024 STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 + +zephyr_include_directories(hci) + +zephyr_sources(hci/hw_ipcc.c) +zephyr_sources(hci/shci.c) +zephyr_sources(hci/shci_tl.c) +zephyr_sources(hci/shci_tl_if.c) +zephyr_sources(hci/stm_list.c) +zephyr_sources(hci/tl_mbox.c) diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_common.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_common.h new file mode 100644 index 000000000..9fed1fbea --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_common.h @@ -0,0 +1,130 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file app_common.h + * @author MCD Application Team + * @brief App Common application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_COMMON_H +#define APP_COMMON_H + +#ifdef __cplusplus +extern "C"{ +#endif + +#include +#include +#include +#include +#include + +#include "app_conf.h" + +/* -------------------------------- * + * Basic definitions * + * -------------------------------- */ +#undef NULL +#define NULL 0 + +#undef FALSE +#define FALSE 0 + +#undef TRUE +#define TRUE (!0) + +/* -------------------------------- * + * Critical Section definition * + * -------------------------------- */ +#define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \ + __disable_irq(); +/* Must be called in the same or in a lower scope of ATOMIC_SECTION_BEGIN */ +#define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit) + +/* -------------------------------- * + * Macro delimiters * + * -------------------------------- */ +#define M_BEGIN do { + +#define M_END } while(0) + +/* -------------------------------- * + * Some useful macro definitions * + * -------------------------------- */ +#ifndef MAX +#define MAX( x, y ) (((x)>(y))?(x):(y)) +#endif + +#ifndef MIN +#define MIN( x, y ) (((x)<(y))?(x):(y)) +#endif + +#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END + +#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END + +#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END + +#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m ) + +#define PAUSE( t ) M_BEGIN \ + __IO int _i; \ + for ( _i = t; _i > 0; _i -- ); \ + M_END + +#define DIVF( x, y ) ((x)/(y)) + +#define DIVC( x, y ) (((x)+(y)-1)/(y)) + +#define DIVR( x, y ) (((x)+((y)/2))/(y)) + +#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1) + +#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1) + +#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END + +#define INT(x) ((int)(x)) + +#define FRACTIONAL_1DIGIT(x) (x>0)? ((int) (((x) - INT(x)) * 10)) : ((int) ((INT(x) - (x)) * 10)) + +#define FRACTIONAL_2DIGITS(x) (x>0)? ((int) (((x) - INT(x)) * 100)) : ((int) ((INT(x) - (x)) * 100)) + +#define FRACTIONAL_3DIGITS(x) (x>0)? ((int) (((x) - INT(x)) * 1000)) : ((int) ((INT(x) - (x)) * 1000)) + +/** @brief Macro that returns a 16-bit value from a buffer where the value is stored in Little Endian Format */ +#define LE_TO_HOST_16(ptr) (uint16_t) ( ((uint16_t)*((uint8_t *)(ptr))) | \ + ((uint16_t)*((uint8_t *)(ptr) + 1) << 8) ) + +/** @brief Macro that stores a 16-bit value into a buffer in Little Endian Format (2 bytes) */ +#define HOST_TO_LE_16(buf, val) ( ((buf)[0] = (uint8_t) (val) ) , \ + ((buf)[1] = (uint8_t) ((val)>>8) ) ) + +/** @brief Macro that returns a 32-bit value from a buffer where the value is stored in Little Endian Format */ +#define LE_TO_HOST_32(ptr) (uint32_t) ( ((uint32_t)*((uint8_t *)(ptr))) | \ + ((uint32_t)*((uint8_t *)(ptr) + 1) << 8) | \ + ((uint32_t)*((uint8_t *)(ptr) + 2) << 16) | \ + ((uint32_t)*((uint8_t *)(ptr) + 3) << 24) ) + +/* -------------------------------- * + * Compiler * + * -------------------------------- */ +#define PLACE_IN_SECTION( __x__ ) __attribute__((used, section (__x__))) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*APP_COMMON_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h new file mode 100644 index 000000000..587bf92c6 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h @@ -0,0 +1,467 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file app_conf.h + * @author MCD Application Team + * @brief Application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_CONF_H +#define APP_CONF_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wb0x.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/** + * Define to 1 if LSE is used, otherwise set it to 0. + */ +#define CFG_LSCLK_LSE (1) + +/****************************************************************************** + * Application Config + ******************************************************************************/ +/**< generic parameters ******************************************************/ + +/* USER CODE BEGIN Generic_Parameters */ + +/* USER CODE END Generic_Parameters */ + +/**< specific parameters */ +/*****************************************************/ + +/* USER CODE BEGIN Specific_Parameters */ + +/* USER CODE END Specific_Parameters */ + +/****************************************************************************** + * BLE Stack initialization parameters + ******************************************************************************/ + +/** + * Maximum number of simultaneous radio tasks. Radio controller supports up to + * 128 simultaneous radio tasks, but actual usable max value depends on the + * available RAM. + */ +#ifndef __ZEPHYR__ +/* It is handled by CMakeLists.txt */ +#define CFG_BLE_NUM_RADIO_TASKS (CFG_NUM_RADIO_TASKS) +#endif + +/** + * Maximum number of Attributes that can be stored in the GATT database. + */ +#define CFG_BLE_NUM_GATT_ATTRIBUTES (60) + +/** + * Maximum number of concurrent Client's Procedures. This value must be less + * than or equal to the maximum number of supported links (CFG_BLE_NUM_RADIO_TASKS). + */ +#define CFG_BLE_NUM_OF_CONCURRENT_GATT_CLIENT_PROC (8) + +/** + * Maximum supported ATT MTU size [23-1020]. + */ +#define CFG_BLE_ATT_MTU_MAX (247) + +/** + * Maximum duration of the connection event in system time units (625/256 us =~ + * 2.44 us) when the device is in Peripheral role [0-0xFFFFFFFF]. + */ +#define CFG_BLE_CONN_EVENT_LENGTH_MAX (0xFFFFFFFF) + +/** + * Sleep clock accuracy (ppm). + */ +#if CFG_LSCLK_LSE +/* Change this value according to accuracy of low speed crystal (ppm). */ +#define CFG_BLE_SLEEP_CLOCK_ACCURACY (100) +#else +/* This value should be kept to 500 ppm when using LSI. */ +#define CFG_BLE_SLEEP_CLOCK_ACCURACY (500) +#endif + +/** + * Number of extra memory blocks, in addition to the minimum required for the + * supported links. + */ +#define CFG_BLE_MBLOCK_COUNT_MARGIN (0) + +/** + * Maximum number of simultaneous EATT active channels. It must be less than or + * equal to CFG_BLE_COC_NBR_MAX. + */ +#ifndef __ZEPHYR__ +#define CFG_BLE_NUM_EATT_CHANNELS (6) +#endif + +/** + * Maximum number of channels in LE Credit Based Flow Control mode [0-255]. + * This number must be greater than or equal to CFG_BLE_NUM_EATT_CHANNELS. + */ +#define CFG_BLE_COC_NBR_MAX (8) + +/** + * The maximum size of payload data in octets that the L2CAP layer entity is + * capable of accepting [0-1024]. + */ +#define CFG_BLE_COC_MPS_MAX (247) + +/** + * Maximum number of Advertising Data Sets, if Advertising Extension Feature is + * enabled. + */ +#ifndef __ZEPHYR__ +/* It is handled by CMakeLists.txt */ +#define CFG_BLE_NUM_ADV_SETS (2) +#endif + +/** + * Maximum number of Periodic Advertising with Responses subevents. + */ +#define CFG_BLE_NUM_PAWR_SUBEVENTS (16) + +/** + * Maximum number of subevent data that can be queued in the controller. + */ +#define CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX (8U) + +/** + * Maximum number of slots for scanning on the secondary advertising channel, + * if Advertising Extension Feature is enabled. + */ +#ifndef __ZEPHYR__ +#define CFG_BLE_NUM_AUX_SCAN_SLOTS (4) +#endif +/** + * Maximum number of slots for synchronizing to a periodic advertising train, + * if Periodic Advertising and Synchronizing Feature is enabled. + */ +#ifndef __ZEPHYR__ +/* It is handled by CMakeLists.txt */ +#define CFG_BLE_NUM_SYNC_SLOTS (2) +#endif + +/** + * Two's logarithm of Filter Accept, Resolving and Advertiser list size. + */ +#define CFG_BLE_FILTER_ACCEPT_LIST_SIZE_LOG2 (4) + +/** + * Maximum number of Antenna IDs in the antenna pattern used in CTE connection + * oriented mode. + */ +#define CFG_BLE_NUM_CTE_ANTENNA_IDS_MAX (8) + +/** + * Maximum number of IQ samples in the buffer used in CTE connection oriented mode. + */ +#define CFG_BLE_NUM_CTE_IQ_SAMPLES_MAX (82) + +/** + * Maximum number of slots for synchronizing to a Broadcast Isochronous Group. + */ +#ifndef __ZEPHYR__ +#define CFG_BLE_NUM_SYNC_BIG_MAX (1U) + +/** + * Maximum number of slots for synchronizing to a Broadcast Isochronous Stream. + */ +#define CFG_BLE_NUM_SYNC_BIS_MAX (2U) + +/** + * Maximum number of slots for broadcasting a Broadcast Isochronous Group. + */ +#define CFG_BLE_NUM_BRC_BIG_MAX (1U) + +/** + * Maximum number of slots for broadcasting a Broadcast Isochronous Stream. + */ +#define CFG_BLE_NUM_BRC_BIS_MAX (2U) + +/** + * Maximum number of Connected Isochronous Groups. + */ +#define CFG_BLE_NUM_CIG_MAX (2U) + +/** + * Maximum number of Connected Isochronous Streams. + */ +#define CFG_BLE_NUM_CIS_MAX (2U) +#endif /* __ZEPHYR__ */ + +/** + * Size of the internal FIFO used for critical controller events produced by the + * ISR (e.g. rx data packets). + */ +#define CFG_BLE_ISR0_FIFO_SIZE (256) + +/** + * Size of the internal FIFO used for non-critical controller events produced by + * the ISR (e.g. advertising or IQ sampling reports). + */ +#define CFG_BLE_ISR1_FIFO_SIZE (768) + +/** + * Size of the internal FIFO used for controller and host events produced + * outside the ISR. + */ +#define CFG_BLE_USER_FIFO_SIZE (1024) + +/** + * Number of allocated memory blocks used for packet allocation. + * The use of BLE_STACK_MBLOCKS_CALC macro is suggested to calculate the minimum + * number of memory blocks for a given number of supported links and ATT MTU. + */ +#define CFG_BLE_MBLOCKS_COUNT (BLE_STACK_MBLOCKS_CALC(CFG_BLE_ATT_MTU_MAX, CFG_BLE_NUM_RADIO_TASKS, CFG_BLE_NUM_EATT_CHANNELS) + CFG_BLE_MBLOCK_COUNT_MARGIN) + +/** + * Macro to calculate the RAM needed by the stack according the number of links, + * memory blocks, advertising data sets and all the other initialization + * parameters. + */ +#define BLE_DYN_ALLOC_SIZE (BLE_STACK_TOTAL_BUFFER_SIZE(CFG_BLE_NUM_RADIO_TASKS,\ + CFG_BLE_NUM_EATT_CHANNELS,\ + CFG_BLE_NUM_GATT_ATTRIBUTES,\ + CFG_BLE_NUM_OF_CONCURRENT_GATT_CLIENT_PROC,\ + CFG_BLE_MBLOCKS_COUNT,\ + CFG_BLE_NUM_ADV_SETS,\ + CFG_BLE_NUM_PAWR_SUBEVENTS,\ + CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX,\ + CFG_BLE_NUM_AUX_SCAN_SLOTS,\ + CFG_BLE_FILTER_ACCEPT_LIST_SIZE_LOG2,\ + CFG_BLE_COC_NBR_MAX,\ + CFG_BLE_NUM_SYNC_SLOTS,\ + CFG_BLE_NUM_CTE_ANTENNA_IDS_MAX,\ + CFG_BLE_NUM_CTE_IQ_SAMPLES_MAX,\ + CFG_BLE_NUM_SYNC_BIG_MAX,\ + CFG_BLE_NUM_BRC_BIG_MAX,\ + CFG_BLE_NUM_SYNC_BIS_MAX,\ + CFG_BLE_NUM_BRC_BIS_MAX,\ + CFG_BLE_NUM_CIG_MAX,\ + CFG_BLE_NUM_CIS_MAX,\ + CFG_BLE_ISR0_FIFO_SIZE,\ + CFG_BLE_ISR1_FIFO_SIZE,\ + CFG_BLE_USER_FIFO_SIZE)) + +/* USER CODE BEGIN BLE_Stack */ + +/* USER CODE END BLE_Stack */ + +/****************************************************************************** + * Initialization parameters used in Network Processor mode + ******************************************************************************/ +/** + * Size of buffer used for ATT queued writes + */ +#define CFG_BLE_ATT_QUEUED_WRITE_SIZE (512) + +/** + * Amount of RAM used to store GATT services (bytes) + */ + #define CFG_BLE_GATT_NWK_BUFFER_SIZE (3072) + +/** + * Amount of RAM used to store advertising data (bytes) + */ + #define CFG_BLE_ADV_NWK_BUFFER_SIZE (1660) + +/** + * Size of buffer shared between GATT_NWK library (used for GATT database and client + * write procedures) and ADV_NWK library (used for advertising buffers). + */ +#define CFG_BLE_GATT_ADV_NWK_BUFFER_SIZE (CFG_BLE_GATT_NWK_BUFFER_SIZE + CFG_BLE_ADV_NWK_BUFFER_SIZE + CFG_BLE_ATT_QUEUED_WRITE_SIZE) + +/****************************************************************************** + * BLE Stack modularity options + ******************************************************************************/ +#ifndef __ZEPHYR__ +/* It is handled by CMakeLists.txt */ +#define CFG_BLE_CONTROLLER_SCAN_ENABLED (1U) +#define CFG_BLE_CONTROLLER_PRIVACY_ENABLED (1U) +#define CFG_BLE_SECURE_CONNECTIONS_ENABLED (1U) +#define CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED (1U) +#define CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED (1U) +#define CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED (1U) +#define CFG_BLE_L2CAP_COS_ENABLED (1U) +#define CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED (1U) +#define CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED (1U) +#define CFG_BLE_CONTROLLER_CTE_ENABLED (1U) +#define CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED (1U) +#define CFG_BLE_CONNECTION_ENABLED (1U) +#define CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED (1U) +#define CFG_BLE_CONTROLLER_BIS_ENABLED (1U) +#define CFG_BLE_CONNECTION_SUBRATING_ENABLED (1U) +#define CFG_BLE_CONTROLLER_CIS_ENABLED (1U) +#endif + +/****************************************************************************** + * Low Power + * + * When CFG_FULL_LOW_POWER is set to 1, the system is configured in full + * low power mode. It means that all what can have an impact on the consumptions + * are powered down.(For instance LED, Access to Debugger, Etc.) + * + ******************************************************************************/ + +#define CFG_FULL_LOW_POWER (0) + +#define CFG_LPM_SUPPORTED (1) + +/** + * Low Power configuration + */ +#if (CFG_FULL_LOW_POWER == 1) + #undef CFG_LPM_SUPPORTED + #define CFG_LPM_SUPPORTED (1) +#endif /* CFG_FULL_LOW_POWER */ + +/* USER CODE BEGIN Low_Power 0 */ + +/* USER CODE END Low_Power 0 */ + +/** + * Supported requester to the MCU Low Power Manager - can be increased up to 32 + * It list a bit mapping of all user of the Low Power Manager + */ +typedef enum +{ + CFG_LPM_APP, + /* USER CODE BEGIN CFG_LPM_Id_t */ + + /* USER CODE END CFG_LPM_Id_t */ +} CFG_LPM_Id_t; + +/* USER CODE BEGIN Low_Power 1 */ + +/* USER CODE END Low_Power 1 */ + +/***************************************************************************** + * Traces + * Enable or Disable traces in application + * When CFG_DEBUG_TRACE is set, traces are activated + * + * Note : Refer to utilities_conf.h file in order to details + * the level of traces : CFG_DEBUG_TRACE_FULL or CFG_DEBUG_TRACE_LIGHT + *****************************************************************************/ +/** + * Enable or disable debug prints. + */ +#define CFG_DEBUG_APP_TRACE (0) + +/** + * Use or not advanced trace module. UART interrupts to be enabled. + */ +#define CFG_DEBUG_APP_ADV_TRACE (0) + +#define ADV_TRACE_TIMESTAMP_ENABLE (0) + +#if (CFG_DEBUG_APP_TRACE == 0) +#undef CFG_DEBUG_APP_ADV_TRACE +#define CFG_DEBUG_APP_ADV_TRACE (0) +#endif + +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + +#include "stm32_adv_trace.h" + +#define APP_DBG(...) \ +{ \ + UTIL_ADV_TRACE_COND_FSend(VLEVEL_L, ~0x0, ADV_TRACE_TIMESTAMP_ENABLE, __VA_ARGS__); \ +} +#else +#define APP_DBG(...) printf(__VA_ARGS__) +#endif + +#if (CFG_DEBUG_APP_TRACE != 0) +#include +#define APP_DBG_MSG APP_DBG +#else +#define APP_DBG_MSG(...) +#endif + +/* USER CODE BEGIN Traces */ + +/* USER CODE END Traces */ + +/****************************************************************************** + * Sequencer + ******************************************************************************/ + +/** + * These are the lists of task id registered to the sequencer + * Each task id shall be in the range [0:31] + */ +typedef enum +{ + CFG_TASK_BLE_STACK, + CFG_TASK_VTIMER, + CFG_TASK_NVM, + CFG_TASK_TM, + CFG_TASK_BURST, + /* USER CODE BEGIN CFG_Task_Id_t */ + + /* USER CODE END CFG_Task_Id_t */ + CFG_TASK_NBR, /**< Shall be LAST in the list */ +} CFG_Task_Id_t; + +/* USER CODE BEGIN DEFINE_TASK */ + +/* USER CODE END DEFINE_TASK */ + +/** + * This is the list of priority required by the application + * Each Id shall be in the range 0..31 + */ +typedef enum +{ + CFG_SEQ_PRIO_0, + CFG_SEQ_PRIO_1, + /* USER CODE BEGIN CFG_SEQ_Prio_Id_t */ + + /* USER CODE END CFG_SEQ_Prio_Id_t */ + CFG_SEQ_PRIO_NBR +} CFG_SEQ_Prio_Id_t; + +/****************************************************************************** + * RT GPIO debug module configuration + ******************************************************************************/ + +#define RT_DEBUG_GPIO_MODULE (0) + +/* USER CODE BEGIN Defines */ +/** + * User interaction + * When CFG_LED_SUPPORTED is set, LEDS are activated if requested + * When CFG_BUTTON_SUPPORTED is set, the push button are activated if requested + */ + +#define CFG_LED_SUPPORTED (1) +#define CFG_BUTTON_SUPPORTED (0) + +/** + * If CFG_FULL_LOW_POWER is requested, make sure LED and debugger are disabled + */ +#if (CFG_FULL_LOW_POWER == 1) + #undef CFG_LED_SUPPORTED + #define CFG_LED_SUPPORTED (0) +#endif /* CFG_FULL_LOW_POWER */ + +/* USER CODE END Defines */ + +#endif /*APP_CONF_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_entry.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_entry.h new file mode 100644 index 000000000..58e78aca5 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_entry.h @@ -0,0 +1,70 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file app_entry.h + * @author MCD Application Team + * @brief Interface to the application + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_ENTRY_H +#define APP_ENTRY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "app_conf.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ + +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported variables --------------------------------------------------------*/ +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Exported macros ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions ---------------------------------------------*/ +void MX_APPE_Config(void); +uint32_t MX_APPE_Init(void *p_param); +void MX_APPE_Process(void); + +/* USER CODE BEGIN EF */ + +/* USER CODE END EF */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*APP_ENTRY_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/main.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/main.h new file mode 100644 index 000000000..b81d29c68 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/main.h @@ -0,0 +1,73 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wb0x_hal.h" +#include "app_entry.h" +#include "app_common.h" +#include "app_debug.h" +#include "compiler.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +#include "stm32wb0x_nucleo.h" +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ + +/* USER CODE BEGIN Private defines */ + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32_assert.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32_assert.h new file mode 100644 index 000000000..060658bd6 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32_assert.h @@ -0,0 +1,53 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32_assert.h + * @brief STM32 assert file. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32_ASSERT_H +#define __STM32_ASSERT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Includes ------------------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32_ASSERT_H */ + diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_hal_conf.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_hal_conf.h new file mode 100644 index 000000000..c039662cf --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_hal_conf.h @@ -0,0 +1,302 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32wb0x_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32WB0x_HAL_CONF_H +#define STM32WB0x_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +/*#define HAL_ADC_MODULE_ENABLED */ +/*#define HAL_CRC_MODULE_ENABLED */ +/*#define HAL_I2C_MODULE_ENABLED */ +/*#define HAL_I2S_MODULE_ENABLED */ +/*#define HAL_IRDA_MODULE_ENABLED */ +/*#define HAL_IWDG_MODULE_ENABLED */ +#define HAL_PKA_MODULE_ENABLED +#define HAL_RADIO_MODULE_ENABLED +#define HAL_RADIO_TIMER_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +/*#define HAL_RTC_MODULE_ENABLED */ +/*#define HAL_SMARTCARD_MODULE_ENABLED */ +/*#define HAL_SMBUS_MODULE_ENABLED */ +/*#define HAL_SPI_MODULE_ENABLED */ +/*#define HAL_TIM_MODULE_ENABLED */ +#define HAL_UART_MODULE_ENABLED +/*#define HAL_USART_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0u +#define USE_HAL_I2C_REGISTER_CALLBACKS 0u +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0u +#define USE_HAL_PKA_REGISTER_CALLBACKS 0u +#define USE_HAL_RNG_REGISTER_CALLBACKS 0u +#define USE_HAL_RTC_REGISTER_CALLBACKS 0u +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0u +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0u +#define USE_HAL_SPI_REGISTER_CALLBACKS 0u +#define USE_HAL_TIM_REGISTER_CALLBACKS 0u +#define USE_HAL_UART_REGISTER_CALLBACKS 0u +#define USE_HAL_USART_REGISTER_CALLBACKS 0u + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ + +#if !defined (HSE_VALUE) + #define HSE_VALUE (32000000UL) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (64000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768UL) /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +/** + * @brief 64 MHz PLL clock default value. + * This value is the default RC64M_PLL value after Reset. + */ +#if !defined (RC64MPLL_VALUE) + #define RC64MPLL_VALUE (64000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* RC64MPLL_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (100UL) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +#if !defined (LSE_DRIVE_LEVEL) +#define LSE_DRIVE_LEVEL RCC_LSEDRIVE_MEDIUMLOW /*!< Drive level for LSE oscillator. */ +#endif /* LSE_DRIVE_LEVEL */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (3UL) /*!< tick interrupt priority */ +#define USE_RTOS 0U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 0U + +/* ################ HSE Capacitor tuning configuration ###################### */ +/** + * @brief Default value of the HSE capacitor tuning. + */ +#if !defined(CFG_HW_RCC_HSE_CAPACITOR_TUNE) +#define CFG_HW_RCC_HSE_CAPACITOR_TUNE 32 +#endif + +/* #################### BLE number of link Configuration #################### */ +/** + * @brief This is the BLE number of link configuration section + * Maximum number of simultaneous radio tasks. Radio controller supports up to + * 128 simultaneous radio tasks, but actual usable max value depends on the + * available RAM. + */ +#if !defined (CFG_NUM_RADIO_TASKS) +#define CFG_NUM_RADIO_TASKS (8) +#endif /* CFG_NUM_RADIO_TASKS */ + +/* ########################### Radio Configuration ######################### */ +/** + * @brief This macro must be set to 0 when BLE stack is used. Set to 1 to use + * radio proprietary protocol with action packets. + */ +#if !defined (USE_RADIO_PROPRIETARY_DRIVER) +#define USE_RADIO_PROPRIETARY_DRIVER 0U +#endif /* USE_RADIO_PROPRIETARY_DRIVER */ + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32wb0x_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32wb0x_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32wb0x_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32wb0x_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32wb0x_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32wb0x_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32wb0x_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32wb0x_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32wb0x_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32wb0x_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_PKA_MODULE_ENABLED + #include "stm32wb0x_hal_pka.h" +#endif /* HAL_PKA_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32wb0x_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RADIO_MODULE_ENABLED + #include "stm32wb0x_hal_radio.h" +#endif /* HAL_RADIO_MODULE_ENABLED */ + +#ifdef HAL_RADIO_TIMER_MODULE_ENABLED + #include "stm32wb0x_hal_radio_timer.h" +#endif /* HAL_RADIO_TIMER_MODULE_ENABLED */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32wb0x_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32wb0x_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32wb0x_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32wb0x_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32wb0x_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32wb0x_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32wb0x_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32wb0x_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32wb0x_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32WB0x_HAL_CONF_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_it.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_it.h new file mode 100644 index 000000000..bc0b4e9df --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_it.h @@ -0,0 +1,70 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32wb0x_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32WB0x_IT_H +#define __STM32WB0x_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void NMI_Handler(void); +void HardFault_Handler(void); +void SVC_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); +void USART1_IRQHandler(void); +void PKA_IRQHandler(void); +void DMA_IRQHandler(void); +void RADIO_TIMER_CPU_WKUP_IRQHandler(void); +void RADIO_TIMER_ERROR_IRQHandler(void); +void RADIO_TXRX_IRQHandler(void); +void RADIO_TXRX_SEQ_IRQHandler(void); +/* USER CODE BEGIN EFP */ +void GPIOB_IRQHandler(void); +void GPIOA_IRQHandler(void); +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32WB0x_IT_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_nucleo_conf.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_nucleo_conf.h new file mode 100644 index 000000000..2707ff81b --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/stm32wb0x_nucleo_conf.h @@ -0,0 +1,48 @@ +/** + ****************************************************************************** + * @file stm32wb0x_nucleo_conf.h + * @author MCD Application Team + * @brief STM32WB0X nucleo board configuration file. + * This file should be copied to the application folder and renamed + * to stm32wb0x_nucleo_conf.h . + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32WB0X_NUCLEO_CONF_H +#define STM32WB0X_NUCLEO_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wb0x_hal.h" + +/* Usage of nucleo board */ +#define USE_NUCLEO_64 1U + +/* Usage of COM feature */ +#define USE_BSP_COM_FEATURE 1U +#define USE_COM_LOG 1U + +/* Button interrupt priorities */ +#define BSP_B1_IT_PRIORITY 0x0FUL /* Default is lowest priority level */ +#define BSP_B2_IT_PRIORITY 0x0FUL /* Default is lowest priority level */ +#define BSP_B3_IT_PRIORITY 0x0FUL /* Default is lowest priority level */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32WB0X_NUCLEO_CONF_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/utilities_conf.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/utilities_conf.h new file mode 100644 index 000000000..c47445bd8 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/utilities_conf.h @@ -0,0 +1,161 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file utilities_conf.h + * @author MCD Application Team + * @brief Header for configuration file for STM32 Utilities. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UTILITIES_CONF_H +#define UTILITIES_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "cmsis_compiler.h" + +/* definitions to be provided to "sequencer" utility */ +#include "stm32_mem.h" + +/* definition of NULL */ +#include "app_common.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ + +#define VLEVEL_OFF 0 /*!< used to set UTIL_ADV_TRACE_SetVerboseLevel() (not as message param) */ +#define VLEVEL_ALWAYS 0 /*!< used as message params, if this level is given + trace will be printed even when UTIL_ADV_TRACE_SetVerboseLevel(OFF) */ +#define VLEVEL_L 1 /*!< just essential traces */ +#define VLEVEL_M 2 /*!< functional traces */ +#define VLEVEL_H 3 /*!< all traces */ + +#define TS_OFF 0 /*!< Log without TimeStamp */ +#define TS_ON 1 /*!< Log with TimeStamp */ + +#define T_REG_OFF 0 /*!< Log without bitmask */ + +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ +/* External variables --------------------------------------------------------*/ +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Exported macros -----------------------------------------------------------*/ +/** + * @brief Memory placement macro + */ +#if defined(__CC_ARM) +#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__), zero_init)) +#elif defined(__ICCARM__) +#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__))) +#else /* __GNUC__ */ +#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__))) +#endif /* __CC_ARM | __ICCARM__ | __GNUC__ */ + +/** + * @brief macro used to initialize the critical section + */ +#define UTIL_SEQ_INIT_CRITICAL_SECTION( ) UTILS_INIT_CRITICAL_SECTION() + +/** + * @brief macro used to enter the critical section + */ +#define UTIL_SEQ_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION() + +/** + * @brief macro used to exit the critical section + */ +#define UTIL_SEQ_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION() + +/** + * @brief Memset utilities interface to application + */ +#define UTIL_SEQ_MEMSET8( dest, value, size ) UTIL_MEM_set_8( dest, value, size ) + +/** + * @brief macro used to initialize the critical section + */ +#define UTILS_INIT_CRITICAL_SECTION() + +/** + * @brief macro used to enter the critical section + */ +#define UTILS_ENTER_CRITICAL_SECTION() uint32_t primask_bit= __get_PRIMASK();\ + __disable_irq() + +/** + * @brief macro used to exit the critical section + */ +#define UTILS_EXIT_CRITICAL_SECTION() __set_PRIMASK(primask_bit) + +/** + * @brief macro used to enter the critical section + */ +#define UTILS_ENTER_LIMITED_CRITICAL_SECTION(x) uint32_t basepri_value= __get_BASEPRI();\ + __set_BASEPRI_MAX(x) + +/** + * @brief macro used to exit the critical section + */ +#define UTILS_EXIT_LIMITED_CRITICAL_SECTION() __set_BASEPRI(basepri_value) + +/****************************************************************************** + * trace\advanced + * the define option + * UTIL_ADV_TRACE_CONDITIONNAL shall be defined if you want use conditional function + * UTIL_ADV_TRACE_UNCHUNK_MODE shall be defined if you want use the unchunk mode + * + ******************************************************************************/ + +#define UTIL_ADV_TRACE_CONDITIONNAL /*!< not used */ +#define UTIL_ADV_TRACE_UNCHUNK_MODE /*!< not used */ +#define UTIL_ADV_TRACE_DEBUG(...) /*!< not used */ +#define UTIL_ADV_TRACE_INIT_CRITICAL_SECTION( ) UTILS_INIT_CRITICAL_SECTION() /*!< init the critical section in trace feature */ +#define UTIL_ADV_TRACE_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION() /*!< enter the critical section in trace feature */ +#define UTIL_ADV_TRACE_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION() /*!< exit the critical section in trace feature */ +#define UTIL_ADV_TRACE_TMP_BUF_SIZE (256U) /*!< default trace buffer size */ +#define UTIL_ADV_TRACE_TMP_MAX_TIMESTMAP_SIZE (15U) /*!< default trace timestamp size */ +#define UTIL_ADV_TRACE_FIFO_SIZE (4096U) /*!< default trace fifo size */ +#define UTIL_ADV_TRACE_MEMSET8( dest, value, size) UTIL_MEM_set_8((dest),(value),(size)) /*!< memset utilities interface to trace feature */ +#define UTIL_ADV_TRACE_VSNPRINTF(...) vsnprintf(__VA_ARGS__) /*!< vsnprintf utilities interface to trace feature */ + +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /*UTILITIES_CONF_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Src/app_entry.c b/lib/stm32wb0/BLE_TransparentMode/Core/Src/app_entry.c new file mode 100644 index 000000000..8631bbc3d --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Src/app_entry.c @@ -0,0 +1,430 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file app_entry.c + * @author GPM WBL Application Team + * @brief Entry point of the application + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "app_common.h" +#include "main.h" +#include "stm32_seq.h" +#include "app_ble.h" +#include "hw_rng.h" +#include "hw_aes.h" +#include "hw_pka.h" +#include "stm32wb0x.h" +#include "stm32wb0x_ll_usart.h" +#include "ble_stack.h" +#if (CFG_LPM_SUPPORTED == 1) +#include "stm32_lpm.h" +#endif /* CFG_LPM_SUPPORTED */ +#include "app_debug.h" + +/* Private includes -----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ + +/* USER CODE BEGIN PTD */ +#if (CFG_BUTTON_SUPPORTED == 1) +typedef struct +{ + Button_TypeDef button; + VTIMER_HandleType longTimerId; + uint8_t longPressed; +} ButtonDesc_t; +#endif /* (CFG_BUTTON_SUPPORTED == 1) */ +/* USER CODE END PTD */ + +/* Private defines -----------------------------------------------------------*/ + +/* USER CODE BEGIN PD */ +#if (CFG_BUTTON_SUPPORTED == 1) +#define BUTTON_LONG_PRESS_THRESHOLD_MS (500u) +#define BUTTON_NB_MAX (B3 + 1u) +#endif +/* USER CODE END PD */ + +/* Private macros ------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +#if (CFG_BUTTON_SUPPORTED == 1) +/* Button management */ +static ButtonDesc_t buttonDesc[BUTTON_NB_MAX]; +#endif +/* USER CODE END PV */ + +/* Global variables ----------------------------------------------------------*/ + +/* USER CODE BEGIN GV */ + +/* USER CODE END GV */ + +/* Private functions prototypes-----------------------------------------------*/ + +/* USER CODE BEGIN PFP */ +#if (CFG_LED_SUPPORTED == 1) +static void Led_Init(void); +#endif +#if (CFG_BUTTON_SUPPORTED == 1) +static void Button_Init(void); +static void Button_TriggerActions(void *arg); +#endif +/* USER CODE END PFP */ + +/* External variables --------------------------------------------------------*/ + +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Functions Definition ------------------------------------------------------*/ + +uint32_t MX_APPE_Init(void *p_param) +{ + + UNUSED(p_param); + + APP_DEBUG_SIGNAL_SET(APP_APPE_INIT); + +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + UTIL_ADV_TRACE_Init(); + UTIL_ADV_TRACE_SetVerboseLevel(VLEVEL_L); /* functional traces*/ + UTIL_ADV_TRACE_SetRegion(~0x0); +#endif + + /* USER CODE BEGIN APPE_Init_1 */ +#if (CFG_LED_SUPPORTED == 1) + Led_Init(); +#endif +#if (CFG_BUTTON_SUPPORTED == 1) + Button_Init(); +#endif + + /* USER CODE END APPE_Init_1 */ + + if (HW_RNG_Init() != HW_RNG_SUCCESS) + { + Error_Handler(); + } + + /* Init the AES block */ + HW_AES_Init(); + HW_PKA_Init(); + APP_BLE_Init(); + +#if (CFG_LPM_SUPPORTED == 1) + /* Low Power Manager Init */ + UTIL_LPM_Init(); +#endif /* CFG_LPM_SUPPORTED */ +/* USER CODE BEGIN APPE_Init_2 */ + +/* USER CODE END APPE_Init_2 */ + APP_DEBUG_SIGNAL_RESET(APP_APPE_INIT); + return BLE_STATUS_SUCCESS; +} + +/* USER CODE BEGIN FD */ +#if (CFG_BUTTON_SUPPORTED == 1) +/** + * @brief Indicate if the selected button was pressedn during a 'long time' or not. + * + * @param btnIdx Button to test, listed in enum Button_TypeDef + * @return '1' if pressed during a 'long time', else '0'. + */ +uint8_t APPE_ButtonIsLongPressed(uint16_t btnIdx) +{ + uint8_t pressStatus; + + if ( btnIdx < BUTTON_NB_MAX ) + { + pressStatus = buttonDesc[btnIdx].longPressed; + } + else + { + pressStatus = 0; + } + + return pressStatus; +} + +/** + * @brief Action of button 1 when pressed, to be implemented by user. + * @param None + * @retval None + */ +__WEAK void APPE_Button1Action(void) +{ +} + +/** + * @brief Action of button 2 when pressed, to be implemented by user. + * @param None + * @retval None + */ +__WEAK void APPE_Button2Action(void) +{ +} + +/** + * @brief Action of button 3 when pressed, to be implemented by user. + * @param None + * @retval None + */ +__WEAK void APPE_Button3Action(void) +{ +} +#endif + +/* USER CODE END FD */ + +/************************************************************* + * + * LOCAL FUNCTIONS + * + *************************************************************/ +#if (CFG_LPM_SUPPORTED == 1) +static PowerSaveLevels App_PowerSaveLevel_Check(void) +{ + PowerSaveLevels output_level = POWER_SAVE_LEVEL_STOP; + /* USER CODE BEGIN App_PowerSaveLevel_Check_1 */ + + output_level = POWER_SAVE_LEVEL_CPU_HALT; + + /* USER CODE END App_PowerSaveLevel_Check_1 */ + + return output_level; +} +#endif + +/* USER CODE BEGIN FD_LOCAL_FUNCTIONS */ +#if (CFG_LED_SUPPORTED == 1) +static void Led_Init( void ) +{ + /* Leds Initialization */ + BSP_LED_Init(LED_BLUE); + BSP_LED_Init(LED_GREEN); + BSP_LED_Init(LED_RED); + + BSP_LED_On(LED_GREEN); + + return; +} +#endif + +#if (CFG_BUTTON_SUPPORTED == 1) +static void Button_Init( void ) +{ + /* Button Initialization */ + buttonDesc[B1].button = B1; + buttonDesc[B2].button = B2; + buttonDesc[B3].button = B3; + BSP_PB_Init(B1, BUTTON_MODE_EXTI); + BSP_PB_Init(B2, BUTTON_MODE_EXTI); + BSP_PB_Init(B3, BUTTON_MODE_EXTI); + +#if (CFG_LPM_SUPPORTED == 1) + HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PA0, PWR_WUP_RISIEDG); + HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PB5, PWR_WUP_RISIEDG); +#if defined(STM32WB06) || defined(STM32WB07) + HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PB9, PWR_WUP_RISIEDG); +#else + HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PB14, PWR_WUP_RISIEDG); +#endif +#endif + + /* Register tasks associated to buttons */ + UTIL_SEQ_RegTask(1U << TASK_BUTTON_1, UTIL_SEQ_RFU, APPE_Button1Action); + UTIL_SEQ_RegTask(1U << TASK_BUTTON_2, UTIL_SEQ_RFU, APPE_Button2Action); + UTIL_SEQ_RegTask(1U << TASK_BUTTON_3, UTIL_SEQ_RFU, APPE_Button3Action); + + /* Create timers to detect button long press (one for each button) */ + Button_TypeDef buttonIndex; + for ( buttonIndex = B1; buttonIndex < BUTTON_NB_MAX; buttonIndex++ ) + { + buttonDesc[buttonIndex].longTimerId.callback = Button_TriggerActions; + buttonDesc[buttonIndex].longTimerId.userData = &buttonDesc[buttonIndex]; + } + + return; +} + +static void Button_TriggerActions(void *arg) +{ + ButtonDesc_t *p_buttonDesc = ((VTIMER_HandleType *)arg)->userData; + + p_buttonDesc->longPressed = BSP_PB_GetState(p_buttonDesc->button); + + APP_DBG_MSG("Button %d pressed\n", (p_buttonDesc->button + 1)); + switch (p_buttonDesc->button) + { + case B1: + UTIL_SEQ_SetTask(1U << TASK_BUTTON_1, CFG_SEQ_PRIO_0); + break; + case B2: + UTIL_SEQ_SetTask(1U << TASK_BUTTON_2, CFG_SEQ_PRIO_0); + break; + case B3: + UTIL_SEQ_SetTask(1U << TASK_BUTTON_3, CFG_SEQ_PRIO_0); + break; + default: + break; + } + + return; +} + +#endif +/* USER CODE END FD_LOCAL_FUNCTIONS */ + +/************************************************************* + * + * WRAP FUNCTIONS + * + *************************************************************/ +void MX_APPE_Process(void) +{ + /* USER CODE BEGIN MX_APPE_Process_1 */ + + /* USER CODE END MX_APPE_Process_1 */ + UTIL_SEQ_Run(UTIL_SEQ_DEFAULT); + /* USER CODE BEGIN MX_APPE_Process_2 */ + + /* USER CODE END MX_APPE_Process_2 */ +} + +void UTIL_SEQ_PreIdle( void ) +{ +#if (CFG_LPM_SUPPORTED == 1) + /* USER CODE BEGIN UTIL_SEQ_PREIDLE */ + + /* USER CODE END UTIL_SEQ_PREIDLE */ +#endif /* CFG_LPM_SUPPORTED */ + return; +} + +void UTIL_SEQ_Idle( void ) +{ +#if (CFG_LPM_SUPPORTED == 1) + PowerSaveLevels app_powerSave_level, vtimer_powerSave_level, final_level, pka_level; + + if ((BLE_STACK_SleepCheck() != POWER_SAVE_LEVEL_RUNNING) && + ((app_powerSave_level = App_PowerSaveLevel_Check()) != POWER_SAVE_LEVEL_RUNNING)) + { + vtimer_powerSave_level = HAL_RADIO_TIMER_PowerSaveLevelCheck(); + pka_level = (PowerSaveLevels) HW_PKA_PowerSaveLevelCheck(); + final_level = (PowerSaveLevels)MIN(vtimer_powerSave_level, app_powerSave_level); + final_level = (PowerSaveLevels)MIN(pka_level, final_level); + + switch(final_level) + { + case POWER_SAVE_LEVEL_RUNNING: + /* Not Power Save device is busy */ + return; + break; + case POWER_SAVE_LEVEL_CPU_HALT: + UTIL_LPM_SetStopMode(1 << CFG_LPM_APP, UTIL_LPM_DISABLE); + UTIL_LPM_SetOffMode(1 << CFG_LPM_APP, UTIL_LPM_DISABLE); + break; + case POWER_SAVE_LEVEL_STOP_LS_CLOCK_ON: + UTIL_LPM_SetStopMode(1 << CFG_LPM_APP, UTIL_LPM_ENABLE); + UTIL_LPM_SetOffMode(1 << CFG_LPM_APP, UTIL_LPM_DISABLE); + break; + case POWER_SAVE_LEVEL_STOP: + UTIL_LPM_SetStopMode(1 << CFG_LPM_APP, UTIL_LPM_ENABLE); + UTIL_LPM_SetOffMode(1 << CFG_LPM_APP, UTIL_LPM_ENABLE); + break; + } + + /* USER CODE BEGIN UTIL_SEQ_IDLE_BEGIN */ + + /* USER CODE END UTIL_SEQ_IDLE_BEGIN */ + + UTIL_LPM_EnterLowPower(); + + /* USER CODE BEGIN UTIL_SEQ_IDLE_END */ + + /* USER CODE END UTIL_SEQ_IDLE_END */ + } +#endif /* CFG_LPM_SUPPORTED */ +} + +/* USER CODE BEGIN FD_WRAP_FUNCTIONS */ +#if (CFG_BUTTON_SUPPORTED == 1) +void BSP_PB_Callback(Button_TypeDef Button) +{ + buttonDesc[Button].longPressed = 0; + HAL_RADIO_TIMER_StartVirtualTimer(&buttonDesc[Button].longTimerId, BUTTON_LONG_PRESS_THRESHOLD_MS); + + return; +} + +#if (CFG_LPM_SUPPORTED == 1) +void HAL_PWR_WKUPx_Callback(uint32_t wakeupIOs) +{ + if (wakeupIOs == PWR_WAKEUP_PA0) + { + BSP_PB_Callback(B1); + } + if (wakeupIOs == PWR_WAKEUP_PB5) + { + BSP_PB_Callback(B2); + } + +#if defined(STM32WB06) || defined(STM32WB07) + if (wakeupIOs == PWR_WAKEUP_PB9) + { + BSP_PB_Callback(B3); + } +#else + if (wakeupIOs == PWR_WAKEUP_PB14) + { + BSP_PB_Callback(B3); + } +#endif + +} +#endif + +void HAL_GPIO_EXTI_Callback(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) +{ + if (GPIO_Pin == B1_PIN) + { + BSP_PB_Callback(B1); + } + else if (GPIO_Pin == B2_PIN) + { + BSP_PB_Callback(B2); + } + else if (GPIO_Pin == B3_PIN) + { + BSP_PB_Callback(B3); + } + + return; +} + +#endif /* (CFG_BUTTON_SUPPORTED == 1) */ + +/* USER CODE END FD_WRAP_FUNCTIONS */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Src/main.c b/lib/stm32wb0/BLE_TransparentMode/Core/Src/main.c new file mode 100644 index 000000000..bd89092d9 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Src/main.c @@ -0,0 +1,398 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ + +PKA_HandleTypeDef hpka; + +UART_HandleTypeDef huart1; +DMA_HandleTypeDef hdma_usart1_tx; +DMA_HandleTypeDef hdma_usart1_rx; + +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +void PeriphCommonClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_RADIO_Init(void); +static void MX_RADIO_TIMER_Init(void); +static void MX_USART1_UART_Init(void); +static void MX_PKA_Init(void); +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + + /* USER CODE BEGIN 1 */ + + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_RADIO_Init(); + MX_RADIO_TIMER_Init(); + MX_USART1_UART_Init(); + MX_PKA_Init(); + /* USER CODE BEGIN 2 */ + + /* USER CODE END 2 */ + + /* Init code for STM32_BLE */ + MX_APPE_Init(NULL); + + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + MX_APPE_Process(); + + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.LSEState = RCC_LSE_ON; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /** Configure the SYSCLKSource and SYSCLKDivider + */ + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_RC64MPLL; + RCC_ClkInitStruct.SYSCLKDivider = RCC_RC64MPLL_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_WAIT_STATES_1) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SMPS; + PeriphClkInitStruct.SmpsDivSelection = RCC_SMPSCLK_DIV4; + + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief PKA Initialization Function + * @param None + * @retval None + */ +static void MX_PKA_Init(void) +{ + + /* USER CODE BEGIN PKA_Init 0 */ + + /* USER CODE END PKA_Init 0 */ + + /* USER CODE BEGIN PKA_Init 1 */ + + /* USER CODE END PKA_Init 1 */ + hpka.Instance = PKA; + if (HAL_PKA_Init(&hpka) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN PKA_Init 2 */ + + /* USER CODE END PKA_Init 2 */ + +} + +/** + * @brief RADIO Initialization Function + * @param None + * @retval None + */ +static void MX_RADIO_Init(void) +{ + + /* USER CODE BEGIN RADIO_Init 0 */ + + /* USER CODE END RADIO_Init 0 */ + + RADIO_HandleTypeDef hradio = {0}; + + /* USER CODE BEGIN RADIO_Init 1 */ + + /* USER CODE END RADIO_Init 1 */ + + if (__HAL_RCC_RADIO_IS_CLK_DISABLED()) + { + /* Radio Peripheral reset */ + __HAL_RCC_RADIO_FORCE_RESET(); + __HAL_RCC_RADIO_RELEASE_RESET(); + + /* Enable Radio peripheral clock */ + __HAL_RCC_RADIO_CLK_ENABLE(); + } + hradio.Instance = RADIO; + HAL_RADIO_Init(&hradio); + /* USER CODE BEGIN RADIO_Init 2 */ + + /* USER CODE END RADIO_Init 2 */ + +} + +/** + * @brief RADIO_TIMER Initialization Function + * @param None + * @retval None + */ +static void MX_RADIO_TIMER_Init(void) +{ + + /* USER CODE BEGIN RADIO_TIMER_Init 0 */ + + /* USER CODE END RADIO_TIMER_Init 0 */ + + RADIO_TIMER_InitTypeDef RADIO_TIMER_InitStruct = {0}; + + /* USER CODE BEGIN RADIO_TIMER_Init 1 */ + + /* USER CODE END RADIO_TIMER_Init 1 */ + + if (__HAL_RCC_RADIO_IS_CLK_DISABLED()) + { + /* Radio Peripheral reset */ + __HAL_RCC_RADIO_FORCE_RESET(); + __HAL_RCC_RADIO_RELEASE_RESET(); + + /* Enable Radio peripheral clock */ + __HAL_RCC_RADIO_CLK_ENABLE(); + } + /* Wait to be sure that the Radio Timer is active */ + while(LL_RADIO_TIMER_GetAbsoluteTime(WAKEUP) < 0x10); + RADIO_TIMER_InitStruct.XTAL_StartupTime = 320; + RADIO_TIMER_InitStruct.enableInitialCalibration = FALSE; + RADIO_TIMER_InitStruct.periodicCalibrationInterval = 0; + HAL_RADIO_TIMER_Init(&RADIO_TIMER_InitStruct); + /* USER CODE BEGIN RADIO_TIMER_Init 2 */ + + /* USER CODE END RADIO_TIMER_Init 2 */ + +} + +/** + * @brief USART1 Initialization Function + * @param None + * @retval None + */ +static void MX_USART1_UART_Init(void) +{ + + /* USER CODE BEGIN USART1_Init 0 */ + + /* USER CODE END USART1_Init 0 */ + + /* USER CODE BEGIN USART1_Init 1 */ + + /* USER CODE END USART1_Init 1 */ + huart1.Instance = USART1; + huart1.Init.BaudRate = 921600; + huart1.Init.WordLength = UART_WORDLENGTH_8B; + huart1.Init.StopBits = UART_STOPBITS_1; + huart1.Init.Parity = UART_PARITY_NONE; + huart1.Init.Mode = UART_MODE_TX_RX; + huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart1.Init.OverSampling = UART_OVERSAMPLING_16; + huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart1) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_EnableFifoMode(&huart1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USART1_Init 2 */ + + /* USER CODE END USART1_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA_IRQn, 1, 0); + HAL_NVIC_EnableIRQ(DMA_IRQn); + +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ +/* USER CODE BEGIN MX_GPIO_Init_1 */ +/* USER CODE END MX_GPIO_Init_1 */ + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + + /*RT DEBUG GPIO_Init */ + RT_DEBUG_GPIO_Init(); + +/* USER CODE BEGIN MX_GPIO_Init_2 */ +/* USER CODE END MX_GPIO_Init_2 */ +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ + /* User can add his own implementation to report the HAL error return state */ + __disable_irq(); + while (1) + { + } + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + Error_Handler(); + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c b/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c new file mode 100644 index 000000000..33f13d4ee --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c @@ -0,0 +1,369 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32wb0x_hal_msp.c + * @brief This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wb0x_hal.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_usart1_tx; + +extern DMA_HandleTypeDef hdma_usart1_rx; + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ +static void lowPowerIOSetup(void); + +static void Error_Handler(void) { + while(1) { + } +} +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ +/** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + + /* USER CODE BEGIN MspInit 0 */ + lowPowerIOSetup(); + + /* USER CODE END MspInit 0 */ + + /* System interrupt init*/ + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief PKA MSP Initialization +* This function configures the hardware resources used in this example +* @param hpka: PKA handle pointer +* @retval None +*/ +void HAL_PKA_MspInit(PKA_HandleTypeDef* hpka) +{ + if(hpka->Instance==PKA) + { + /* USER CODE BEGIN PKA_MspInit 0 */ + + /* USER CODE END PKA_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_PKA_CLK_ENABLE(); + /* PKA interrupt Init */ + HAL_NVIC_SetPriority(PKA_IRQn, 1, 0); + HAL_NVIC_EnableIRQ(PKA_IRQn); + /* USER CODE BEGIN PKA_MspInit 1 */ + + /* USER CODE END PKA_MspInit 1 */ + } + +} + +/** +* @brief PKA MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hpka: PKA handle pointer +* @retval None +*/ +void HAL_PKA_MspDeInit(PKA_HandleTypeDef* hpka) +{ + if(hpka->Instance==PKA) + { + /* USER CODE BEGIN PKA_MspDeInit 0 */ + + /* USER CODE END PKA_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_PKA_CLK_DISABLE(); + + /* PKA interrupt DeInit */ + HAL_NVIC_DisableIRQ(PKA_IRQn); + /* USER CODE BEGIN PKA_MspDeInit 1 */ + + /* USER CODE END PKA_MspDeInit 1 */ + } + +} + +/** +* @brief RADIO MSP Initialization +* This function configures the hardware resources used in this example +* @param hradio: RADIO handle pointer +* @retval None +*/ +void HAL_RADIO_MspInit(RADIO_HandleTypeDef* hradio) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hradio->Instance==RADIO) + { + /* USER CODE BEGIN RADIO_MspInit 0 */ + + /* USER CODE END RADIO_MspInit 0 */ + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RF; + PeriphClkInitStruct.RFClockSelection = RCC_RF_CLK_16M; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + if (__HAL_RCC_RADIO_IS_CLK_DISABLED()) + { + /* Radio reset */ + __HAL_RCC_RADIO_FORCE_RESET(); + __HAL_RCC_RADIO_RELEASE_RESET(); + + /* Enable Radio peripheral clock */ + __HAL_RCC_RADIO_CLK_ENABLE(); + } + + /* RADIO interrupt Init */ + HAL_NVIC_SetPriority(RADIO_TXRX_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(RADIO_TXRX_IRQn); + HAL_NVIC_SetPriority(RADIO_TXRX_SEQ_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(RADIO_TXRX_SEQ_IRQn); + /* USER CODE BEGIN RADIO_MspInit 1 */ + + /* USER CODE END RADIO_MspInit 1 */ + } + +} + +/** +* @brief RADIO MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hradio: RADIO handle pointer +* @retval None +*/ +void HAL_RADIO_MspDeInit(RADIO_HandleTypeDef* hradio) +{ + if(hradio->Instance==RADIO) + { + /* USER CODE BEGIN RADIO_MspDeInit 0 */ + + /* USER CODE END RADIO_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_RADIO_CLK_DISABLE(); + __HAL_RCC_RADIO_FORCE_RESET(); + __HAL_RCC_RADIO_RELEASE_RESET(); + + /* RADIO interrupt DeInit */ + HAL_NVIC_DisableIRQ(RADIO_TXRX_IRQn); + HAL_NVIC_DisableIRQ(RADIO_TXRX_SEQ_IRQn); + /* USER CODE BEGIN RADIO_MspDeInit 1 */ + + /* USER CODE END RADIO_MspDeInit 1 */ + } + +} + +/** +* @brief UART MSP Initialization +* This function configures the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspInit(UART_HandleTypeDef* huart) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(huart->Instance==USART1) + { + /* USER CODE BEGIN USART1_MspInit 0 */ + + /* USER CODE END USART1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_USART1_CLK_ENABLE(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USART1 GPIO Configuration + PB0 ------> USART1_RX + PA1 ------> USART1_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF0_USART1; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_USART1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USART1 DMA Init */ + /* USART1_TX Init */ + hdma_usart1_tx.Instance = DMA1_Channel1; + hdma_usart1_tx.Init.Request = DMA_REQUEST_USART1_TX; + hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_usart1_tx.Init.MemInc = DMA_MINC_ENABLE; + hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_usart1_tx.Init.Mode = DMA_NORMAL; + hdma_usart1_tx.Init.Priority = DMA_PRIORITY_HIGH; + if (HAL_DMA_Init(&hdma_usart1_tx) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(huart,hdmatx,hdma_usart1_tx); + + /* USART1_RX Init */ + hdma_usart1_rx.Instance = DMA1_Channel2; + hdma_usart1_rx.Init.Request = DMA_REQUEST_USART1_RX; + hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE; + hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_usart1_rx.Init.Mode = DMA_CIRCULAR; + hdma_usart1_rx.Init.Priority = DMA_PRIORITY_HIGH; + if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(huart,hdmarx,hdma_usart1_rx); + + /* USART1 interrupt Init */ + HAL_NVIC_SetPriority(USART1_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(USART1_IRQn); + /* USER CODE BEGIN USART1_MspInit 1 */ + + /* USER CODE END USART1_MspInit 1 */ + } + +} + +/** +* @brief UART MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +{ + if(huart->Instance==USART1) + { + /* USER CODE BEGIN USART1_MspDeInit 0 */ + + /* USER CODE END USART1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USART1_CLK_DISABLE(); + + /**USART1 GPIO Configuration + PB0 ------> USART1_RX + PA1 ------> USART1_TX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1); + + /* USART1 DMA DeInit */ + HAL_DMA_DeInit(huart->hdmatx); + HAL_DMA_DeInit(huart->hdmarx); + + /* USART1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(USART1_IRQn); + /* USER CODE BEGIN USART1_MspDeInit 1 */ + + /* USER CODE END USART1_MspDeInit 1 */ + } + +} + +/* USER CODE BEGIN 1 */ + +/** + * @brief Configures the IOs pull resistors to have the optimized power consumption. + * @param None + * @retval None + */ +static void lowPowerIOSetup(void) +{ + + HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_A, + PWR_GPIO_BIT_0| + PWR_GPIO_BIT_1| + PWR_GPIO_BIT_2| + PWR_GPIO_BIT_3); + + HAL_PWREx_EnableGPIOPullDown(PWR_GPIO_A, + PWR_GPIO_BIT_8| + PWR_GPIO_BIT_9| + PWR_GPIO_BIT_10| + PWR_GPIO_BIT_11); + + HAL_PWREx_EnableGPIOPullDown(PWR_GPIO_B, + PWR_GPIO_BIT_0| + PWR_GPIO_BIT_3| + PWR_GPIO_BIT_6| + PWR_GPIO_BIT_7| + PWR_GPIO_BIT_12| + PWR_GPIO_BIT_13); + + HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_B, + PWR_GPIO_BIT_1| + PWR_GPIO_BIT_2| + PWR_GPIO_BIT_4| + PWR_GPIO_BIT_5| + PWR_GPIO_BIT_14| + PWR_GPIO_BIT_15); +} + +/* USER CODE END 1 */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_it.c b/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_it.c new file mode 100644 index 000000000..da05e5c8a --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_it.c @@ -0,0 +1,260 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32wb0x_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32wb0x_it.h" +#include "hw_pka.h" +#include "ble_stack.h" +#include "miscutil.h" +#include "stm32wb0x_ll_usart.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern PKA_HandleTypeDef hpka; +extern DMA_HandleTypeDef hdma_usart1_tx; +extern DMA_HandleTypeDef hdma_usart1_rx; +extern UART_HandleTypeDef huart1; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + while (1) + { + } + /* USER CODE END NonMaskableInt_IRQn 1 */ +} + +/** + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } +} + +/** + * @brief This function handles System service call via SWI instruction. + */ +void SVC_Handler(void) +{ + /* USER CODE BEGIN SVCall_IRQn 0 */ + + /* USER CODE END SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 1 */ + + /* USER CODE END SVCall_IRQn 1 */ +} + +/** + * @brief This function handles Pendable request for system service. + */ +void PendSV_Handler(void) +{ + /* USER CODE BEGIN PendSV_IRQn 0 */ + + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ + + /* USER CODE END PendSV_IRQn 1 */ +} + +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32WB0x Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32wb0x.s). */ +/******************************************************************************/ + +/** + * @brief This function handles USART1 Interrupt. + */ +void USART1_IRQHandler(void) +{ + /* USER CODE BEGIN USART1_IRQn 0 */ + + /* USER CODE END USART1_IRQn 0 */ + HAL_UART_IRQHandler(&huart1); + /* USER CODE BEGIN USART1_IRQn 1 */ + + /* USER CODE END USART1_IRQn 1 */ +} + +/** + * @brief This function handles PKA global interrupt. + */ +void PKA_IRQHandler(void) +{ + /* USER CODE BEGIN PKA_IRQn 0 */ + + /* USER CODE END PKA_IRQn 0 */ + HAL_PKA_IRQHandler(&hpka); + /* USER CODE BEGIN PKA_IRQn 1 */ + + /* USER CODE END PKA_IRQn 1 */ +} + +/** + * @brief This function handles DMA global interrupt. + */ +void DMA_IRQHandler(void) +{ + /* USER CODE BEGIN DMA_IRQn 0 */ + + /* USER CODE END DMA_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_usart1_tx); + HAL_DMA_IRQHandler(&hdma_usart1_rx); + /* USER CODE BEGIN DMA_IRQn 1 */ + + /* USER CODE END DMA_IRQn 1 */ +} + +/** + * @brief This function handles RADIO_TIMER_CPU_WKUP global interrupt. + */ +void RADIO_TIMER_CPU_WKUP_IRQHandler(void) +{ + /* USER CODE BEGIN RADIO_TIMER_CPU_WKUP_IRQn 0 */ + + /* USER CODE END RADIO_TIMER_CPU_WKUP_IRQn 0 */ + HAL_RADIO_TIMER_CPU_WKUP_IRQHandler(); + /* USER CODE BEGIN RADIO_TIMER_CPU_WKUP_IRQn 1 */ + + /* USER CODE END RADIO_TIMER_CPU_WKUP_IRQn 1 */ +} + +/** + * @brief This function handles RADIO_TIMER_ERROR global interrupt. + */ +void RADIO_TIMER_ERROR_IRQHandler(void) +{ + /* USER CODE BEGIN RADIO_TIMER_ERROR_IRQn 0 */ + + /* USER CODE END RADIO_TIMER_ERROR_IRQn 0 */ + HAL_RADIO_TIMER_ERROR_IRQHandler(); + /* USER CODE BEGIN RADIO_TIMER_ERROR_IRQn 1 */ + + /* USER CODE END RADIO_TIMER_ERROR_IRQn 1 */ +} + +/** + * @brief This function handles RADIO_TXRX global interrupt. + */ +void RADIO_TXRX_IRQHandler(void) +{ + /* USER CODE BEGIN RADIO_TXRX_IRQn 0 */ + + /* USER CODE END RADIO_TXRX_IRQn 0 */ + HAL_RADIO_TXRX_IRQHandler(); + /* USER CODE BEGIN RADIO_TXRX_IRQn 1 */ + + /* USER CODE END RADIO_TXRX_IRQn 1 */ +} + +/** + * @brief This function handles RADIO_TXRX_SEQ global interrupt. + */ +void RADIO_TXRX_SEQ_IRQHandler(void) +{ + /* USER CODE BEGIN RADIO_TXRX_SEQ_IRQn 0 */ + + /* USER CODE END RADIO_TXRX_SEQ_IRQn 0 */ + HAL_RADIO_TXRX_SEQ_IRQHandler(); + /* USER CODE BEGIN RADIO_TXRX_SEQ_IRQn 1 */ + + /* USER CODE END RADIO_TXRX_SEQ_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ +void GPIOA_IRQHandler(void) +{ + BSP_PB_IRQHandler(B1_GPIO_PORT, B1_PIN); +} + +void GPIOB_IRQHandler(void) +{ + BSP_PB_IRQHandler(B2_GPIO_PORT, B2_PIN); + BSP_PB_IRQHandler(B3_GPIO_PORT, B3_PIN); +} +/* USER CODE END 1 */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Src/system_stm32wb0x.c b/lib/stm32wb0/BLE_TransparentMode/Core/Src/system_stm32wb0x.c new file mode 100644 index 000000000..8295afec9 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Src/system_stm32wb0x.c @@ -0,0 +1,362 @@ + +/** + ****************************************************************************** + * @file system_stm32wb0x.c + * @author GPM WBL Application Team + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Source File + * + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32wb0x.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * After each device reset the HSI (64 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32wb0x.s" file, to + * configure the system clock before to branch to main program. + * + * This file configures the system clock as follows: + *============================================================================= + *----------------------------------------------------------------------------- + * System Clock source | HSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + *============================================================================= + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup STM32WB0x_system + * @{ + */ + +/** @addtogroup STM32WB0x_System_Private_Includes + * @{ + */ + +#include "stm32wb0x.h" + +/** + * @} + */ + +/** @addtogroup STM32WB0x_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32WB0x_System_Private_Defines + * @{ + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE (32000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) +#define HSI_VALUE (64000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/* Note: Following vector table addresses must be defined in line with linker + configuration. */ +/*!< Uncomment the following line if you need to relocate the vector table + anywhere in Flash or Sram, else the vector table is kept at the automatic + remap of boot address selected */ +/* #define USER_VECT_TAB_ADDRESS */ + +#if defined(USER_VECT_TAB_ADDRESS) +/*!< Uncomment the following line if you need to relocate your vector Table + in SRAM else user remap will be done in FLASH. */ +/* #define VECT_TAB_SRAM */ +#if defined(VECT_TAB_SRAM) +#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. + This value must be a multiple of 0x100. */ +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. + This value must be a multiple of 0x100. */ +#else +#define VECT_TAB_BASE_ADDRESS NVM_BASE /*!< Vector Table base address field. + This value must be a multiple of 0x100. */ +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. + This value must be a multiple of 0x100. */ +#endif /* VECT_TAB_SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ + +/******************************************************************************/ + +/*!< HW TRIMMING Defines */ +#define VALIDITY_TAG 0xFCBCECCC /*!< TAG to validate the content of the + trimming area content. */ +#define VALIDITY_LOCATION 0x10001EF8 /*!< ROM address of the the validity trimming values content. */ + +/*!< SMPS Configuration Defines */ +#if !defined(CFG_HW_SMPS) +#define CFG_HW_SMPS SMPS_ON +#endif + +#if !defined(CFG_HW_SMPS_BOM) +#define CFG_HW_SMPS_BOM SMPS_BOM3 /*!< SMPS Inductor 10uH */ +#endif + +#if !defined(CFG_HW_SMPS_LOW_POWER) +#define CFG_HW_SMPS_LOW_POWER SMPS_LOW_POWER_OPEN +#endif + +/** + * @} + */ + +/** @addtogroup STM32WB0x_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32WB0x_System_Private_Variables + * @{ + */ + /* The SystemCoreClock variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 16000000U; /* The HSI (64MHz) is used as system clock source after startup from reset, configured at 16 MHz. */ + + /* The RAM_VR variable is a mirroring in RAM of some registers information. + It is a sort of virtual register in RAM. + */ +#if defined ( __ICCARM__ ) + #pragma location=".ram_vr" + __root __no_init RAM_VR_TypeDef RAM_VR; +#else +#if defined ( __ARMCC_VERSION ) + __attribute__((section(".bss" ".ram_vr"))) +#elif defined ( __GNUC__ ) + __attribute__((section(".ram_vr"))) +#endif + RAM_VR_TypeDef RAM_VR __attribute__((used)); +#endif +/** + * @} + */ + +/** @addtogroup STM32WB0x_System_Private_FunctionPrototypes + * @{ + */ + +void CPUcontextRestore(void); + +/** + * @} + */ + +/** @addtogroup STM32WB0x_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * @param None + * @retval None + */ + +void SystemInit(void) +{ + uint32_t mainRegulator, smpsOutVoltage, hsiCalib; +#if defined(STM32WB06) || defined(STM32WB07) + uint32_t lsiLpmu; +#else + uint32_t lsiBw; +#endif + uint8_t i; + + /* If the reset reason is a wakeup from power save restore the context */ + if ((RCC->CSR == 0) && ((PWR->SR1 != 0)||(PWR->SR3 != 0))) { + RAM_VR.WakeupFromSleepFlag = 1; /* A wakeup from power save occurred */ + CPUcontextRestore(); /* Restore the context */ + /* if the context restore worked properly, we should never return here */ + while(1) { + NVIC_SystemReset(); + } + } + + /* Configure the Vector Table location */ +#if defined(USER_VECT_TAB_ADDRESS) + SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation */ +#else + SCB->VTOR = (uint32_t) (__vector_table); +#endif /* USER_VECT_TAB_ADDRESS */ + + /* Store in RAM the AppBase information */ + RAM_VR.AppBase = (uint32_t) SCB->VTOR; + + /* Enable all the RAM banks in retention during power save */ +#if defined(PWR_CR2_RAMRET1) + SET_BIT(PWR->CR2, PWR_CR2_RAMRET1); +#endif /* PWR_CR2_RAMRET1 */ + +#if defined(PWR_CR2_RAMRET2) + SET_BIT(PWR->CR2, PWR_CR2_RAMRET2); +#endif /* PWR_CR2_RAMRET2 */ + +#if defined(PWR_CR2_RAMRET2) + SET_BIT(PWR->CR2, PWR_CR2_RAMRET3); +#endif /* PWR_CR2_RAMRET3 */ + + /* Disable the GPIO retention in power save configuration */ +#if defined(PWR_CR2_GPIORET) + CLEAR_BIT(PWR->CR2, PWR_CR2_GPIORET); +#endif /* PWR_CR2_GPIORET */ + + /* SMPS setup */ + if ((CFG_HW_SMPS == SMPS_ON) || (CFG_HW_SMPS == SMPS_BYPAPSS)) + { + while(READ_BIT(PWR->SR2, PWR_SR2_SMPSRDY) != PWR_SR2_SMPSRDY); // Wait until SMPS is ready + MODIFY_REG(PWR->CR5, PWR_CR5_SMPSBOMSEL, (CFG_HW_SMPS_BOM<CR5, PWR_CR5_NOSMPS, (CFG_HW_SMPS<CR5, PWR_CR5_SMPSFBYP, (1<CR5, PWR_CR5_SMPSLPOPEN, (CFG_HW_SMPS_LOW_POWER<ENGTRIM, PWR_ENGTRIM_TRIM_LSI_LPMU, ((lsiLpmu << PWR_ENGTRIM_TRIM_LSI_LPMU_Pos) & PWR_ENGTRIM_TRIM_LSI_LPMU)); + SET_BIT(PWR->ENGTRIM, PWR_ENGTRIM_TRIMLSILPMUEN); +#else + hsiCalib = 0x1F; + lsiBw = 8; + mainRegulator = 0x0A; + smpsOutVoltage = 0x03; + + /* Low speed internal RC trimming value set by software */ + MODIFY_REG(RCC->CSSWCR, RCC_CSSWCR_LSISWBW, lsiBw << RCC_CSSWCR_LSISWBW_Pos); + SET_BIT(RCC->CSSWCR, RCC_CSSWCR_LSISWTRIMEN); +#endif + + /* Set HSI Calibration Trimming value */ + MODIFY_REG(RCC->CSSWCR, RCC_CSSWCR_HSITRIMSW, hsiCalib << RCC_CSSWCR_HSITRIMSW_Pos); + SET_BIT(RCC->CSSWCR, RCC_CSSWCR_HSISWTRIMEN); + + /* Set Main Regulator voltage Trimming value */ + MODIFY_REG(PWR->ENGTRIM, PWR_ENGTRIM_TRIM_MR, ((mainRegulator << PWR_ENGTRIM_TRIM_MR_Pos) & PWR_ENGTRIM_TRIM_MR)); + SET_BIT(PWR->ENGTRIM, PWR_ENGTRIM_TRIMMREN); + + /* Set SMPS output voltage Trimming value */ + MODIFY_REG(PWR->ENGTRIM, PWR_ENGTRIM_SMPS_TRIM, ((smpsOutVoltage << PWR_ENGTRIM_SMPS_TRIM_Pos) & PWR_ENGTRIM_SMPS_TRIM)); + SET_BIT(PWR->ENGTRIM, PWR_ENGTRIM_SMPSTRIMEN); + } + + /* Set all the interrupt with low priprity */ + for (i=0; i<32; i++) + { + NVIC_SetPriority((IRQn_Type)i, IRQ_LOW_PRIORITY); + } + + /* Enable all the irqs */ + __enable_irq(); +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint8_t directHSE_enabled; + uint8_t divPrescaler; + + /* Get SYSCLK source HSE or HSI+PLL64MHz */ + directHSE_enabled = (RCC->CFGR & RCC_CFGR_HSESEL) >> RCC_CFGR_HSESEL_Pos; + +#if defined(STM32WB06) || defined(STM32WB07) + /* Get the clock divider */ + divPrescaler = (RCC->CFGR & RCC_CFGR_CLKSYSDIV) >> RCC_CFGR_CLKSYSDIV_Pos; +#else + /* Get the clock divider */ + divPrescaler = (RCC->CFGR & RCC_CFGR_CLKSYSDIV_STATUS) >> RCC_CFGR_CLKSYSDIV_STATUS_Pos; +#endif + + if (directHSE_enabled) + { + SystemCoreClock = HSE_VALUE >> (divPrescaler - 1U); + } + else + { + SystemCoreClock = HSI_VALUE >> divPrescaler; + } +} + +/** + * @brief Restores the saved CPU state before to enter in power save + * by popping it from the stack + * @param None + * @retval None + */ +__WEAK void CPUcontextRestore(void) +{ +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c new file mode 100644 index 000000000..903ffd282 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c @@ -0,0 +1,803 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file aci_adv_nwk.c + * @author MCD Application Team + * @brief Adaptation layer from stack native advertising interface + * to network interface. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include +#include "aci_adv_nwk.h" +#include "app_common.h" +#include "adv_buff_alloc.h" +#include "adv_buff_alloc_tiny.h" +#include "pawr_buff_alloc.h" +#include "ble.h" + +#define LEGACY_ADV_HANDLE 0xFE +#define MEM_ALLOC_OVERHEAD 8 +#define MAX_ADV_DATA_LENGTH MIN(CFG_BLE_GATT_ADV_NWK_BUFFER_SIZE - CFG_BLE_ATT_QUEUED_WRITE_SIZE - MEM_ALLOC_OVERHEAD, 1650) + +/** @name Operation codes for setting advertising data + * @{ + */ +#define INTERMEDIATE_FRAGMENT 0 +#define FIRST_FRAGMENT 1 +#define LAST_FRAGMENT 2 +#define COMPLETE_DATA 3 +#define UNCHANGED_DATA 4 +/** + * @} + */ + +/** @name Options for layer parameter of set_legacy_adv_scan_data + * @{ + */ +#define LL 0 +#define GAP 1 +/** + * @} + */ + +#if (CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED == 0) + +static tBleStatus allocate_and_set_data_legacy(uint8_t Advertising_Handle, uint8_t Operation, + uint8_t Data_Length, uint8_t *Data, uint8_t adv_scan_resp, uint8_t layer); + +static tBleStatus set_legacy_data_ptr(uint16_t Data_Length, uint8_t *Data, uint8_t adv_scan_resp, uint8_t layer); + +void aci_adv_nwk_init(void) +{ + adv_tiny_buff_init(); +} + +static tBleStatus allocate_and_set_data(uint8_t Advertising_Handle, uint8_t Operation, uint8_t Data_Length, uint8_t *Data, uint8_t adv_scan_resp, uint8_t layer) +{ + return allocate_and_set_data_legacy(Advertising_Handle, Operation, Data_Length, Data, adv_scan_resp, layer); +} + +/* Event raised by the stack when a new data pointer becomes active. + The function will free the the memory pointed by the old pointer. +*/ +int aci_hal_adv_scan_resp_data_update_event_preprocess(void *old_pointer, void *new_pointer) +{ + if (new_pointer != old_pointer) + { + adv_tiny_buff_free(old_pointer); + } + + return 1; +} + +// Advertising_Handle is actually not used +static tBleStatus allocate_and_set_data_legacy(uint8_t Advertising_Handle, uint8_t Operation, uint8_t Data_Length, uint8_t *Data, uint8_t adv_scan_resp, uint8_t layer) +{ + tBleStatus ret; + uint8_t *adv_buffer; + + if(Operation != COMPLETE_DATA || Data_Length > 31) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + adv_buffer = adv_tiny_buff_alloc(); + + if(adv_buffer == NULL) + return BLE_ERROR_CONTROLLER_BUSY; + + memcpy(adv_buffer, Data, Data_Length); + + ret = set_legacy_data_ptr(Data_Length, adv_buffer, adv_scan_resp, layer); + + if(ret) + { + adv_tiny_buff_free(adv_buffer); + } + + return ret; +} + +static tBleStatus set_legacy_data_ptr(uint16_t Data_Length, uint8_t *Data, uint8_t adv_scan_resp, uint8_t layer) +{ + if(adv_scan_resp == ADV_DATA){ + // Advertising Data +#if (BLESTACK_CONTROLLER_ONLY == 0) + if(layer == GAP) + return aci_gap_set_advertising_data(0, COMPLETE_DATA, Data_Length, Data); + else +#endif + return ll_set_legacy_advertising_data_ptr(Data_Length, Data); + } + else{ + // Scan Response +#if (BLESTACK_CONTROLLER_ONLY == 0) + if(layer == GAP) + return aci_gap_set_scan_response_data(0, Data_Length, Data); + else +#endif + return ll_set_legacy_scan_reponse_data_ptr(Data_Length, Data); + } +} + +tBleStatus aci_gap_set_advertising_enable_preprocess(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]) +{ + return BLE_STATUS_SUCCESS; +} + +#else /* (CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +tBleStatus hci_le_read_maximum_advertising_data_length(uint16_t *Maximum_Advertising_Data_Length) +{ + *Maximum_Advertising_Data_Length = MAX_ADV_DATA_LENGTH; + + return BLE_STATUS_SUCCESS; +} + +static tBleStatus allocate_and_set_data_ext(uint8_t Advertising_Handle, + uint8_t Operation, uint8_t Data_Length, uint8_t *Data, uint8_t data_type, uint8_t layer); + +void aci_adv_nwk_init(void) +{ + adv_buff_init(); +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) + pawr_buff_init(); +#endif +} + +static tBleStatus allocate_and_set_data(uint8_t Advertising_Handle, uint8_t Operation, uint8_t Data_Length, uint8_t *Data, uint8_t data_type, uint8_t layer) +{ + return allocate_and_set_data_ext(Advertising_Handle, Operation, Data_Length, Data, data_type, layer); +} + +tBleStatus hci_le_set_extended_advertising_data(uint8_t Advertising_Handle, uint8_t Operation, + uint8_t Fragment_Preference, + uint8_t Advertising_Data_Length, uint8_t *Advertising_Data) +{ + return allocate_and_set_data(Advertising_Handle, + Operation, Advertising_Data_Length, Advertising_Data, ADV_DATA, LL); + +} + +tBleStatus hci_le_set_extended_scan_response_data(uint8_t Advertising_Handle, uint8_t Operation, + uint8_t Fragment_Preference, + uint8_t Scan_Response_Data_Length, uint8_t *Scan_Response_Data) +{ + return allocate_and_set_data(Advertising_Handle, + Operation, Scan_Response_Data_Length, Scan_Response_Data, SCAN_RESP_DATA, LL); +} + +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED == 1) +tBleStatus hci_le_set_periodic_advertising_data(uint8_t Advertising_Handle, uint8_t Operation, + uint8_t Advertising_Data_Length, uint8_t *Advertising_Data) +{ + return allocate_and_set_data(Advertising_Handle, + Operation, Advertising_Data_Length, Advertising_Data, PERIODIC_ADV_DATA, LL); +} + +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) + +tBleStatus hci_le_set_periodic_advertising_subevent_data(uint8_t Advertising_Handle, + uint8_t Num_Subevents, + Subevent_Data_Parameters_t Subevent_Data_Parameters[]) +{ + tBleStatus ret; + uint8_t i; + void * p; + Subevent_Data_Ptr_Parameters_t Subevent_Data_Ptr_Parameters[CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX] = {0}; + uint16_t adv_event_prop; + uint8_t adv_enabled, periodic_adv_configured, periodic_adv_enabled; + + if (Advertising_Handle > 0xEF) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + /* Check if advertising set exists, so that error 0x42 will be returned. */ + ret = ll_get_advertising_info(Advertising_Handle, &adv_enabled, &periodic_adv_configured, &periodic_adv_enabled, &adv_event_prop); + if(ret!=0) + { + return BLE_ERROR_UNKNOWN_ADVERTISING_IDENTIFIER; + } + + if(pawr_buff_subevent_num_available() < Num_Subevents) + { + /* This happens is host has given more data than what requested by the Controller. */ + return BLE_ERROR_COMMAND_DISALLOWED; + } + + for(i = 0; i < Num_Subevents; i++) + { + if(Subevent_Data_Parameters[i].Subevent_Data_Length > MAX_PAWR_SUBEVENT_DATA_SIZE) + { + /* This should never happen as long as MAX_PAWR_SUBEVENT_DATA_SIZE >= 249. */ + ret = BLE_ERROR_MEMORY_CAPACITY_EXCEEDED; + goto fail; + } + + p = pawr_buff_subevent_alloc(); + + if(p != NULL) + { + Subevent_Data_Ptr_Parameters[i].Subevent = Subevent_Data_Parameters[i].Subevent; + Subevent_Data_Ptr_Parameters[i].Response_Slot_Start = Subevent_Data_Parameters[i].Response_Slot_Start; + Subevent_Data_Ptr_Parameters[i].Response_Slot_Count = Subevent_Data_Parameters[i].Response_Slot_Count; + Subevent_Data_Ptr_Parameters[i].Subevent_Data_Length = Subevent_Data_Parameters[i].Subevent_Data_Length; + memcpy(p, Subevent_Data_Parameters[i].Subevent_Data, Subevent_Data_Parameters[i].Subevent_Data_Length); + Subevent_Data_Ptr_Parameters[i].Subevent_Data = p; + } + else + { + /* This should never happen since we checked num of available buffers before. */ + goto fail; + } + } + + ret = ll_set_periodic_advertising_subevent_data_ptr(Advertising_Handle, + Num_Subevents, + Subevent_Data_Ptr_Parameters); + + if(ret == BLE_STATUS_SUCCESS) + return ret; + +fail: + + /* Free allocated buffers */ + for(i = 0; i < Num_Subevents; i++) + { + pawr_buff_free(Subevent_Data_Ptr_Parameters[i].Subevent_Data, HAL_PAWR_DATA_TYPE_SUBEVENT); + } + return ret; +} + +tBleStatus hci_le_set_periodic_advertising_response_data(uint16_t Sync_Handle, + uint16_t Request_Event, + uint8_t Request_Subevent, + uint8_t Response_Subevent, + uint8_t Response_Slot, + uint8_t Response_Data_Length, + uint8_t Response_Data[]) +{ + tBleStatus ret; + void * p; + + if(Response_Data_Length > MAX_PAWR_RESPONSE_DATA_SIZE) + { + /* This should never happen as long as MAX_PAWR_RESPONSE_DATA_SIZE >= 247. */ + return BLE_ERROR_MEMORY_CAPACITY_EXCEEDED; + } + + p = pawr_buff_resp_alloc(); + + if(p == NULL) + { + return BLE_ERROR_MEMORY_CAPACITY_EXCEEDED; + } + + memcpy(p, Response_Data, Response_Data_Length); + + ret = ll_set_periodic_advertising_response_data_ptr(Sync_Handle, Request_Event, + Request_Subevent, Response_Subevent, + Response_Slot, Response_Data_Length, + p); + + if(ret != BLE_STATUS_SUCCESS) + { + pawr_buff_free(p, HAL_PAWR_DATA_TYPE_RESPONSE); + } + + return ret; +} + +#endif /* (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) */ +#endif /* (CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED == 1) */ + +int aci_hal_adv_scan_resp_data_update_event_preprocess(void *old_pointer, void *new_pointer) +{ + if (new_pointer != old_pointer) + { + adv_buff_free_old(old_pointer); + } + + /* Do not forward the event. */ + return 1; +} + +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) +int aci_hal_pawr_data_free_event_preprocess(void *buffer, uint8_t type) +{ + pawr_buff_free(buffer, type); + + /* Do not forward the event. */ + return 1; +} +#endif + +static uint8_t adv_data_check_param(uint8_t Advertising_Handle, uint8_t Operation, uint8_t Advertising_Data_Length, uint8_t *adv_enabled) +{ + uint16_t adv_event_prop; + uint8_t ret; + uint8_t periodic_adv_configured; + uint8_t periodic_adv_enabled; + + if(Advertising_Handle == LEGACY_ADV_HANDLE){ + + *adv_enabled = TRUE; + + if(Operation != COMPLETE_DATA || Advertising_Data_Length > 31) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + return BLE_STATUS_SUCCESS; + } + + if(Advertising_Handle > 0xEF || Operation > UNCHANGED_DATA) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + ret = ll_get_advertising_info(Advertising_Handle, adv_enabled, &periodic_adv_configured, &periodic_adv_enabled, &adv_event_prop); + + /* "If the advertising set corresponding to the Advertising_Handle parameter does + not exist, then the Controller shall return the error code Unknown Advertising + Identifier (0x42)." */ + if(ret!=0) // Advertising set does not exist. + return BLE_ERROR_UNKNOWN_ADVERTISING_IDENTIFIER; + + /* "If the advertising set specifies a type that does not support advertising data, the + Controller shall return the error code Invalid HCI Command Parameters (0x12)." */ + if((adv_event_prop & HCI_ADV_EVENT_PROP_LEGACY && adv_event_prop & HCI_ADV_EVENT_PROP_DIRECTED) || // Legacy, directed advertising + (adv_event_prop & HCI_ADV_EVENT_PROP_SCANNABLE && !(adv_event_prop & HCI_ADV_EVENT_PROP_LEGACY))) // Scannable, non-legacy + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + /* "If the advertising set uses legacy advertising PDUs that support advertising + data and either Operation is not 0x03 or the Advertising_Data_Length + parameter exceeds 31 octets, the Controller shall return the error code Invalid + HCI Command Parameters (0x12)." */ + if(adv_event_prop & HCI_ADV_EVENT_PROP_LEGACY && (Operation != COMPLETE_DATA || Advertising_Data_Length > 31)) // Legacy advertising + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + /* "If Operation is not 0x03 or 0x04 and Advertising_Data_Length is zero, the + Controller shall return the error code Invalid HCI Command Parameters (0x12)." */ + if(Operation != COMPLETE_DATA && Operation != UNCHANGED_DATA && Advertising_Data_Length == 0) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + /* "If advertising is currently enabled for the specified advertising set and + Operation does not have the value 0x03 or 0x04, the Controller shall return the + error code Command Disallowed (0x0C)." */ + if(*adv_enabled && Operation != COMPLETE_DATA && Operation != UNCHANGED_DATA) + return BLE_ERROR_COMMAND_DISALLOWED; + + return BLE_STATUS_SUCCESS; +} + +static uint8_t scan_resp_data_check_param(uint8_t Advertising_Handle, uint8_t Operation, uint8_t Scan_Resp_Data_Length, uint8_t *adv_enabled) +{ + uint16_t adv_event_prop; + uint8_t ret; + uint8_t periodic_adv_configured; + uint8_t periodic_adv_enabled; + + if(Advertising_Handle == LEGACY_ADV_HANDLE){ + + /* Assume advertising is always enabled, even if this is not true. + In this way the old buffer cannot be freed even if the advertising is not enabled. */ + *adv_enabled = TRUE; + + if(Operation != COMPLETE_DATA || Scan_Resp_Data_Length > 31) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + return BLE_STATUS_SUCCESS; + } + + if(Operation > COMPLETE_DATA) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + ret = ll_get_advertising_info(Advertising_Handle, adv_enabled, &periodic_adv_configured, &periodic_adv_enabled, &adv_event_prop); + + /* "If the advertising set corresponding to the Advertising_Handle parameter does + not exist, then the Controller shall return the error code Unknown Advertising + Identifier (0x42)." */ + if(ret!=0) // Advertising set does not exist. + return BLE_ERROR_UNKNOWN_ADVERTISING_IDENTIFIER; + + /* "If the advertising set is non-scannable and the Host uses this command other + than to discard existing data, the Controller shall return the error code Invalid + HCI Command Parameters (0x12)." */ + if((!(adv_event_prop & HCI_ADV_EVENT_PROP_SCANNABLE) && Scan_Resp_Data_Length != 0)) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + /* If the advertising set uses scannable legacy advertising PDUs and either + Operation is not 0x03 or the Scan_Response_Data_Length parameter exceeds + 31 octets, the Controller shall return the error code Invalid HCI Command + Parameters (0x12). */ + if(adv_event_prop & HCI_ADV_EVENT_PROP_LEGACY && adv_event_prop & HCI_ADV_EVENT_PROP_SCANNABLE + && (Operation != COMPLETE_DATA || Scan_Resp_Data_Length > 31)) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + /* "If Operation is not 0x03 and Scan_Response_Data_Length is zero, the + Controller shall return the error code Invalid HCl Command Parameters (0x12)." */ + if(Operation != COMPLETE_DATA && Scan_Resp_Data_Length == 0) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + /* "If advertising is currently enabled for the specified advertising set and + Operation does not have the value 0x03, the Controller shall return the error + code Command Disallowed (0x0C)." */ + if(*adv_enabled && Operation != COMPLETE_DATA) + return BLE_ERROR_COMMAND_DISALLOWED; + + return BLE_STATUS_SUCCESS; +} + +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED == 1) +static uint8_t periodic_adv_data_check_param(uint8_t Advertising_Handle, uint8_t Operation, uint8_t Advertising_Data_Length, uint8_t *adv_enabled, uint8_t *periodic_adv_enabled) +{ + uint16_t adv_event_prop; + uint8_t periodic_adv_configured; + uint8_t ret; + + if(Operation > UNCHANGED_DATA) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + ret = ll_get_advertising_info(Advertising_Handle, adv_enabled, &periodic_adv_configured, periodic_adv_enabled, &adv_event_prop); + + /* "If the advertising set corresponding to the Advertising_Handle parameter does + not exist, then the Controller shall return the error code Unknown Advertising + Identifier (0x42)." */ + if(ret!=0) // Advertising set does not exist. + return BLE_ERROR_UNKNOWN_ADVERTISING_IDENTIFIER; + + /* "If the advertising set has not been configured for periodic advertising, + then the Controller shall return the error code Command Disallowed (0x0C)." */ + if(!periodic_adv_configured) + return BLE_ERROR_COMMAND_DISALLOWED; + + if(Advertising_Data_Length > 252) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + + if ((Operation != COMPLETE_DATA) && (Operation != UNCHANGED_DATA)) + { + /* "If periodic advertising is currently enabled for the specified advertising set and + Operation does not have the value 0x03 or 0x04, then the Controller shall + return the error code Command Disallowed (0x0C)." */ + if(*periodic_adv_enabled) + return BLE_ERROR_COMMAND_DISALLOWED; + + if(Advertising_Data_Length == 0U) + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + return BLE_STATUS_SUCCESS; +} +#endif + +static tBleStatus set_data_ptr(uint8_t Advertising_Handle, + uint8_t Operation, uint16_t Data_Length, uint8_t *Data, uint8_t data_type, uint8_t gap) +{ + if(data_type == ADV_DATA) + { + // Advertising Data +#if (BLESTACK_CONTROLLER_ONLY == 0) + if(gap) + { + return aci_gap_set_advertising_data(Advertising_Handle, Operation, + Data_Length, Data); + } + else +#endif + { + if(Advertising_Handle == LEGACY_ADV_HANDLE) + { + return ll_set_legacy_advertising_data_ptr(Data_Length, Data); + } + else + { + return ll_set_advertising_data_ptr(Advertising_Handle, Operation, Data_Length, Data); + } + } + } + else if (data_type == SCAN_RESP_DATA) + { + // Scan Response +#if (BLESTACK_CONTROLLER_ONLY == 0) + if(gap) + { + return aci_gap_set_scan_response_data(Advertising_Handle, + Data_Length, Data); + } + else +#endif + { + if(Advertising_Handle == LEGACY_ADV_HANDLE) + { + return ll_set_legacy_scan_reponse_data_ptr(Data_Length, Data); + } + else + { + return ll_set_scan_reponse_data_ptr(Advertising_Handle, Data_Length, Data); + } + } + } +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED == 1) + else + { /* data_type == PERIODIC_ADV_DATA */ + return ll_set_periodic_advertising_data_ptr(Advertising_Handle, Operation, Data_Length, Data); + } +#else + return BLE_ERROR_UNKNOWN_HCI_COMMAND; +#endif +} + +static tBleStatus allocate_and_set_data_ext(uint8_t Advertising_Handle, + uint8_t Operation, uint8_t Data_Length, uint8_t *Data, uint8_t data_type, uint8_t layer) +{ + uint8_t *buffer; + uint16_t buff_len; + uint8_t adv_enabled; +#if CONTROLLER_PERIODIC_ADV_ENABLED + uint8_t periodic_adv_enabled; +#endif + uint8_t status = BLE_ERROR_UNKNOWN_HCI_COMMAND; + uint16_t old_buff_len; + uint8_t extend = FALSE; + + if(Advertising_Handle == LEGACY_ADV_HANDLE && layer != LL){ + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; // This should not happen + } + + if(data_type == ADV_DATA){ + status = adv_data_check_param(Advertising_Handle, Operation, Data_Length, &adv_enabled); + } + else if(data_type == SCAN_RESP_DATA){ + status = scan_resp_data_check_param(Advertising_Handle, Operation, Data_Length, &adv_enabled); + } +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED == 1) + else { /* PERIODIC_ADV_DATA */ + status = periodic_adv_data_check_param(Advertising_Handle, Operation, Data_Length, &adv_enabled, &periodic_adv_enabled); + } +#endif + + if(status) + return status; + + /* Allocate the buffer */ + switch(Operation){ + + case UNCHANGED_DATA: + return set_data_ptr(Advertising_Handle, Operation, Data_Length, Data, data_type, layer); + + case FIRST_FRAGMENT: + case COMPLETE_DATA: + extend = FALSE; + adv_buff_free_next(Advertising_Handle, data_type); + break; + + case INTERMEDIATE_FRAGMENT: + case LAST_FRAGMENT: + extend = TRUE; + break; + + } + + buffer = adv_buff_alloc(Advertising_Handle, Data_Length, extend, &old_buff_len, data_type); + if((buffer == NULL && Data_Length != 0) || (old_buff_len + Data_Length > MAX_ADV_DATA_LENGTH)){ + // Tell the stack that current advertising data has to be cancelled. + set_data_ptr(Advertising_Handle, COMPLETE_DATA, 0, NULL, data_type, layer); + adv_buff_deactivate_current(Advertising_Handle, data_type); + adv_buff_free_next(Advertising_Handle, data_type); + + return BLE_ERROR_MEMORY_CAPACITY_EXCEEDED; + } + + memcpy(buffer + old_buff_len, Data, Data_Length); + + buff_len = old_buff_len + Data_Length; + + if(Operation == LAST_FRAGMENT || Operation == COMPLETE_DATA){ + status = set_data_ptr(Advertising_Handle, COMPLETE_DATA, buff_len, buffer, data_type, layer); + if(status == BLE_STATUS_SUCCESS){ + adv_buff_deactivate_current(Advertising_Handle, data_type); + adv_buff_activate_next(Advertising_Handle, data_type); + } + else{ + // Free what has been allocated so far for this advertising handle + adv_buff_free_next(Advertising_Handle, data_type); + } + } + else if(Operation == FIRST_FRAGMENT){ + // Discard any existing partial or complete advertising data. + set_data_ptr(Advertising_Handle, COMPLETE_DATA, 0, NULL, data_type, layer); + adv_buff_deactivate_current(Advertising_Handle, data_type); + } + + return status; +} + +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED == 1) +tBleStatus hci_le_set_periodic_advertising_enable_preprocess(uint8_t Enable, + uint8_t Advertising_Handle) +{ + /* If bit 0 of Enable in the HCI_LE_Set_Periodic_Advertising_Enable command is set to 1 + (periodic advertising is enabled) and the advertising set contains partial periodic + advertising data, the Status value in the response to the command shall be + Command Disallowed (0x0C). */ + if(((Enable & 0x01U) == 0x01U) && (new_buff_pending(Advertising_Handle, PERIODIC_ADV_DATA) == TRUE)) + return BLE_ERROR_COMMAND_DISALLOWED; + + return BLE_STATUS_SUCCESS; +} +#endif + +tBleStatus hci_le_set_extended_advertising_enable_preprocess(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]) +{ + /* The remainder of this section only applies if Enable is set to 0x01. + If the advertising data or scan response data in the advertising set is not + complete, the Controller shall return the error code Command Disallowed + (0x0C). */ + if(Enable == 0x01){ + + for(int i = 0; i < Number_of_Sets; i++){ + if(new_buff_pending(Advertising_Set_Parameters[i].Advertising_Handle, ADV_DATA) == TRUE || + new_buff_pending(Advertising_Set_Parameters[i].Advertising_Handle, SCAN_RESP_DATA) == TRUE) + return BLE_ERROR_COMMAND_DISALLOWED; + } + + } + + return BLE_STATUS_SUCCESS; +} + +tBleStatus aci_gap_set_advertising_enable_preprocess(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]) +{ + return hci_le_set_extended_advertising_enable_preprocess(Enable, Number_of_Sets, Advertising_Set_Parameters); +} + +#endif /* CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED == 0 */ + +tBleStatus hci_le_set_advertising_data(uint8_t Advertising_Data_Length, + uint8_t Advertising_Data[31]) +{ + return allocate_and_set_data(LEGACY_ADV_HANDLE, COMPLETE_DATA, Advertising_Data_Length, Advertising_Data, ADV_DATA, LL); +} + +tBleStatus hci_le_set_scan_response_data(uint8_t Scan_Response_Data_Length, + uint8_t Scan_Response_Data[31]) +{ + return allocate_and_set_data(LEGACY_ADV_HANDLE, COMPLETE_DATA, Scan_Response_Data_Length, Scan_Response_Data, SCAN_RESP_DATA, LL); +} + +tBleStatus aci_gap_set_advertising_data_nwk(uint8_t Advertising_Handle, + uint8_t Operation, uint8_t Advertising_Data_Length, uint8_t *Advertising_Data) +{ + return allocate_and_set_data(Advertising_Handle, + Operation, Advertising_Data_Length, Advertising_Data, ADV_DATA, GAP); +} + +tBleStatus aci_gap_set_scan_response_data_nwk(uint8_t Advertising_Handle, + uint8_t Operation, uint8_t Scan_Response_Data_Length, uint8_t *Scan_Response_Data) +{ + return allocate_and_set_data(Advertising_Handle, + Operation, Scan_Response_Data_Length, Scan_Response_Data, SCAN_RESP_DATA, GAP); +} + +/* --------------------- E A D --------------------- */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) + +extern void char_copy(volatile uint8_t *from, volatile uint8_t *q, size_t n); + +#define ACI_EAD_PAYLOAD_CLEAR_DATA_LEN_MAX (241U) +#define ACI_EAD_PAYLOAD_ENCRY_DATA_LEN_MAX (254U) +/* the overhead for Encrypted data is given by the leading Randomizer field (5 octets) + * and by the trailing MIC field (4 octes) */ +#define ACI_EAD_PAYLOAD_OVERHEAD_SIZE (9U) + +tBleStatus aci_gap_encrypt_adv_data_nwk(uint8_t session_key[16], + uint8_t iv[8], + uint8_t adv_payload_data_clear_len, + uint8_t adv_payload_data_clear[], + uint8_t *adv_payload_data_encrypted_len, + uint8_t adv_payload_data_encrypted[]) +{ + uint8_t Status; + + /* Check that length of adv_payload_data_clear (declared in adv_payload_data_clear_len) + * does not exceed 241 octets, that is an upper bound deriving from the maximum allowed length + * of adv_payload_data_encrypted that will be returned into the HCI_Command_Complete event - + * that has an overhead of 3+2 octets - thus with a remaining net data payload of 255 - (3+2) = 250 octets; + * hence, considering that adv_payload_data_encrypted will carry also 2 extra fields + * accounting for total 5+4=9 octets, then the maximum allowed length for adv_payload_data_clear is + * 255 - (3+2) - (5+4) = 241 octets. + */ + if ((adv_payload_data_clear_len == 0) || + (adv_payload_data_clear_len > ACI_EAD_PAYLOAD_CLEAR_DATA_LEN_MAX)) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + uint32_t clear_data_aligned[((ACI_EAD_PAYLOAD_CLEAR_DATA_LEN_MAX - 1) / sizeof(uint32_t))+1] = { 0U }; + char_copy((uint8_t *)adv_payload_data_clear, (uint8_t *)clear_data_aligned, adv_payload_data_clear_len); + + Status = aci_gap_encrypt_adv_data(session_key /* 16 */, + iv /* 8 */, + adv_payload_data_clear_len, + clear_data_aligned, + adv_payload_data_encrypted); + + if (Status == BLE_STATUS_SUCCESS) + { + /* the size of returned field adv_payload_data_encrypted is 9 octets longer + * w.r.t. adv_payload_data_clear since it contains 2 more fields: + * - the Randomizer (5 octets in front of payload), and + * - the MIC (4 octets appended as a footer). + */ + *adv_payload_data_encrypted_len = adv_payload_data_clear_len + 9U; + } + else + { + *adv_payload_data_encrypted_len = 0U; + } + + return Status; +} + +tBleStatus aci_gap_decrypt_adv_data_nwk(uint8_t session_key[16], + uint8_t iv[8], + uint8_t adv_payload_data_encrypted_len, + uint8_t adv_payload_data_encrypted[], + uint8_t *adv_payload_data_clear_len, + uint8_t adv_payload_data_clear[]) +{ + uint8_t Status; + + /* Check that length of adv_payload_data_encrypted (declared in adv_payload_data_encrypted_len) + * does not exceed 254 octets, that is an upper bound deriving from the Core Spec v.5.x, Part C, Sec. 11, + * where the Length field in the ADV header has a size of 1 octet. + */ + if (adv_payload_data_encrypted_len > ACI_EAD_PAYLOAD_ENCRY_DATA_LEN_MAX) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + uint32_t clear_data_aligned[((ACI_EAD_PAYLOAD_ENCRY_DATA_LEN_MAX - ACI_EAD_PAYLOAD_OVERHEAD_SIZE -1) / sizeof(uint32_t))+1] = { 0U }; + + Status = aci_gap_decrypt_adv_data(session_key, + iv, + adv_payload_data_encrypted_len, + adv_payload_data_encrypted, + clear_data_aligned); + + if (Status == BLE_STATUS_SUCCESS) + { + /* returned adv_payload_data_clear is 9 octets shorter w.r.t. adv_payload_data_encrypted + * since it doesn't contain the 2 extra fields attached to encryped data, i.e.: + * - the Randomizer (5 octets in front of payload), and + * - the MIC (4 octets appended as a footer). + */ + *adv_payload_data_clear_len = adv_payload_data_encrypted_len - ACI_EAD_PAYLOAD_OVERHEAD_SIZE; + char_copy((uint8_t *)clear_data_aligned, (uint8_t *)adv_payload_data_clear, (*adv_payload_data_clear_len)); + } + else + { + *adv_payload_data_clear_len = 0U; + } + + return Status; +} + +#endif + +/******************* (C) COPYRIGHT 2020 STMicroelectronics *****END OF FILE****/ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.h new file mode 100644 index 000000000..65c73c5e7 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.h @@ -0,0 +1,111 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file aci_adv_nwk.h + * @author MCD Application Team + * @brief Adaptation layer from stack native advertising interface + * to network interface. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef ACI_ADV_NWK_H +#define ACI_ADV_NWK_H + +#include "ble.h" + +/** Documentation for C struct Subevent_Data_Parameters_t */ +typedef struct Subevent_Data_Parameters_t_s { + /** The subevent index of the data. + * Values: + * - 0x00 ... 0x7F + */ + uint8_t Subevent; + /** The first response slots to be used in this subevent. + */ + uint8_t Response_Slot_Start; + /** The number of response slots to be used. + */ + uint8_t Response_Slot_Count; + /** The number of octets in the Subevent_Data parameter. + * Values: + * - 0x00 ... 0xFB + */ + uint8_t Subevent_Data_Length; + /** Advertising data formatted as defined in [Vol 3] Part C, Section 11. + */ + uint8_t *Subevent_Data; +} Subevent_Data_Parameters_t; + +void aci_adv_nwk_init(void); + +tBleStatus aci_gap_set_advertising_data_nwk(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Advertising_Data_Length, + uint8_t *Advertising_Data); + +tBleStatus aci_gap_set_scan_response_data_nwk(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Scan_Response_Data_Length, + uint8_t *Scan_Response_Data); + +tBleStatus hci_le_set_advertising_data(uint8_t Advertising_Data_Length, + uint8_t Advertising_Data[31]); + +tBleStatus hci_le_set_scan_response_data(uint8_t Scan_Response_Data_Length, + uint8_t Scan_Response_Data[31]); + +tBleStatus hci_le_set_extended_advertising_data(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Fragment_Preference, + uint8_t Advertising_Data_Length, + uint8_t *Advertising_Data); + +tBleStatus hci_le_set_extended_scan_response_data(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Fragment_Preference, + uint8_t Scan_Response_Data_Length, + uint8_t *Scan_Response_Data); + +tBleStatus hci_le_set_periodic_advertising_data(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Advertising_Data_Length, + uint8_t Advertising_Data[]); + +tBleStatus hci_le_set_periodic_advertising_subevent_data(uint8_t Advertising_Handle, + uint8_t Num_Subevents, + Subevent_Data_Parameters_t Subevent_Data_Parameters[]); + +tBleStatus hci_le_set_periodic_advertising_response_data(uint16_t Sync_Handle, + uint16_t Request_Event, + uint8_t Request_Subevent, + uint8_t Response_Subevent, + uint8_t Response_Slot, + uint8_t Response_Data_Length, + uint8_t Response_Data[]); + +tBleStatus aci_gap_encrypt_adv_data_nwk(uint8_t session_key[16], + uint8_t iv[8], + uint8_t adv_payload_data_len, + uint8_t adv_payload_data_clear[], + uint8_t *adv_payload_data_encrypted_len, + uint8_t adv_payload_data_encrypted[]); + +tBleStatus aci_gap_decrypt_adv_data_nwk(uint8_t session_key[16], + uint8_t iv[8], + uint8_t adv_payload_encrypted_data_len, + uint8_t adv_payload_encrypted_data[], + uint8_t *adv_payload_clear_data_len, + uint8_t adv_payload_clear_data[]); + +#endif /* ACI_ADV_NWK_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.c new file mode 100644 index 000000000..1226a09c3 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.c @@ -0,0 +1,2122 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file aci_gatt_nwk.c + * @author MCD Application Team + * @brief Adaptation layer from GATT native interface to GATT network + * processor interface + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/****************************************************************************** + * INCLUDE HEADER FILES + *****************************************************************************/ +#include "app_common.h" +#include "ble.h" +#include "aci_gatt_nwk.h" +#include "gap_profile.h" +#include "gatt_profile.h" +#include "osal.h" +#include "eatt_pwrq.h" +#include "dm_alloc.h" +#include "dtm_cmd_db.h" + +/****************************************************************************** + * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS) + *****************************************************************************/ +typedef enum { + DEF_TYPE_SERVICE = 0, /**< Service definition node. */ + DEF_TYPE_CHAR, /**< Characteristic definition node. */ + DEF_TYPE_DESCR, /** 0U) + { + q_wr_p = (uint8_t *)dm_alloc(pwrq_size); + if (q_wr_p == NULL) + { + pwrq_size = 0U; + } + } + else + { + q_wr_p = NULL; + } + (void)EATT_pwrq_init(pwrq_size, q_wr_p); +} + +void ACI_gatt_nwk_proc_complete(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Error_Code) +{ + ACI_gatt_nwk_rm_write_ops(Connection_Handle, CID); +} + +void ACI_gatt_nwk_disconnection(uint16_t Connection_Handle, uint16_t CID) +{ + ACI_gatt_nwk_rm_write_ops(Connection_Handle, CID); + + /** + * Propagate disconnection event to the Prepare Write Queue module to flush + * all pending prepared write. + */ + EATT_pwrq_flush(Connection_Handle, EATT_PWRQ_CID_ALL); +} + +tBleStatus aci_gatt_srv_add_service_nwk(uint8_t Service_UUID_Type, + Service_UUID_t *Service_UUID, + uint8_t Service_Type, + uint8_t Max_Attribute_Records, + uint16_t *Service_Handle) +{ + ble_gatt_srv_def_t *srv_def_p; + ACI_gatt_nwk_def_entry_t *def_p; + tBleStatus ret; + + /** + * Allocate service node. + */ + def_p = (ACI_gatt_nwk_def_entry_t *)dm_alloc(sizeof(ACI_gatt_nwk_def_entry_t)); + if (def_p == NULL) + { + return BLE_STATUS_OUT_OF_MEMORY; + } + memset(def_p, 0, sizeof(ACI_gatt_nwk_def_entry_t)); + + /** + * Allocate service definition. + */ + srv_def_p = (ble_gatt_srv_def_t *)dm_alloc(sizeof(ble_gatt_srv_def_t)); + if (srv_def_p == NULL) + { + return BLE_STATUS_OUT_OF_MEMORY; + } + memset(srv_def_p, 0, sizeof(ble_gatt_srv_def_t)); + + /** + * Populate service definition. + */ + srv_def_p->chrs.chr_count = 0U; + srv_def_p->group_size = Max_Attribute_Records; + srv_def_p->type = Service_Type; + srv_def_p->included_srv.incl_srv_count = 0U; + ACI_gatt_nwk_set_uuid(Service_UUID_Type, (uint8_t const *)Service_UUID, + &srv_def_p->uuid); + + /** + * Add new service. + */ + ret = aci_gatt_srv_add_service(srv_def_p); + if (ret == BLE_STATUS_SUCCESS) + { + def_p->attr_handle = aci_gatt_srv_get_service_handle(srv_def_p); + def_p->val_p = NULL; + def_p->def_p = (uint8_t *)srv_def_p; + def_p->def_type = DEF_TYPE_SERVICE; + + /** + * Add new node to attribute definition list. + */ + ACI_gatt_nwk_add_def_entry(def_p); + + *Service_Handle = def_p->attr_handle; + } + else + { + /** + * The service is not registered. Release allocated resources. + */ + dm_free((uint32_t *)def_p->def_p); + dm_free((uint32_t *)def_p); + } + + return ret; +} + +tBleStatus aci_gatt_srv_include_service_nwk(uint16_t Service_Handle, + uint16_t Included_Service_Handle, + uint16_t *Include_Handle) +{ + tBleStatus ret; + uint16_t handle; + ble_gatt_srv_def_t *srv_def_p; + + ret = aci_gatt_srv_include_service(Service_Handle, Included_Service_Handle); + if (ret == BLE_STATUS_SUCCESS) + { + srv_def_p = NULL; + handle = Gatt_profile_get_service_handle(); + if (handle == Included_Service_Handle) + { + srv_def_p = Gatt_profile_get_service_definition_p(); + } + else + { + handle = Gap_profile_get_service_handle(); + if (handle == Included_Service_Handle) + { + srv_def_p = Gap_profile_get_service_definition_p(); + } + else + { + ACI_gatt_nwk_def_entry_t *def_p; + + def_p = ACI_gatt_nwk_find_def_entry(Included_Service_Handle); + srv_def_p = (ble_gatt_srv_def_t *)def_p->def_p; + } + } + + *Include_Handle = aci_gatt_srv_get_include_service_handle(Service_Handle, + srv_def_p); + } + + return ret; +} + +tBleStatus aci_gatt_srv_add_char_nwk(uint16_t Service_Handle, + uint8_t Char_UUID_Type, + Char_UUID_t *Char_UUID, + uint16_t Char_Value_Length, + uint8_t Char_Properties, + uint8_t Security_Permissions, + uint8_t GATT_Evt_Mask, + uint8_t Enc_Key_Size, + uint8_t Is_Variable, + uint16_t *Char_Handle) +{ + ble_gatt_chr_def_t *chr_def_p; + ACI_gatt_nwk_def_entry_t *def_p; + Char_Desc_Uuid_t uuid; + tBleStatus ret; + + if (Char_Value_Length > BLE_GATT_MAX_ATTR_VALUE_SIZE) + { + return BLE_STATUS_INVALID_PARAMS; + } + + /** + * Allocate characteristic node. + */ + def_p = (ACI_gatt_nwk_def_entry_t *)dm_alloc(sizeof(ACI_gatt_nwk_def_entry_t)); + if (def_p == NULL) + { + return BLE_STATUS_OUT_OF_MEMORY; + } + memset(def_p, 0, sizeof(ACI_gatt_nwk_def_entry_t)); + + /** + * Allocate characteristic definition. + */ + chr_def_p = (ble_gatt_chr_def_t *)dm_alloc(sizeof(ble_gatt_chr_def_t)); + if (chr_def_p == NULL) + { + dm_free((uint32_t *)def_p); + + return BLE_STATUS_OUT_OF_MEMORY; + } + memset(chr_def_p, 0, sizeof(ble_gatt_chr_def_t)); + + /** + * Populate characteristic definition. + */ + ACI_gatt_nwk_set_uuid(Char_UUID_Type, (uint8_t const *)Char_UUID, + &chr_def_p->uuid); + chr_def_p->min_key_size = Enc_Key_Size; + chr_def_p->properties = Char_Properties; + chr_def_p->permissions = Security_Permissions; + chr_def_p->descrs.descr_count = 0U; + + /** + * Set characteristic node definition pointer. + */ + def_p->def_p = (uint8_t *)chr_def_p; + + /** + * Allocate structure to store characteristic value. + */ + def_p->val_p = (ACI_gatt_nwk_value_t *)dm_alloc(sizeof(ACI_gatt_nwk_value_t) + + Char_Value_Length); + if (def_p->val_p == NULL) + { + dm_free((uint32_t *)def_p->def_p); + dm_free((uint32_t *)def_p); + + return BLE_STATUS_OUT_OF_MEMORY; + } + + /** + * Populate characteristic value structure. + */ + def_p->val_p->val_len = Char_Value_Length; + def_p->val_p->is_variable = Is_Variable; + def_p->val_p->buffer_len = Char_Value_Length; + def_p->val_p->event_mask = GATT_Evt_Mask; + memset(def_p->val_p->buffer_va, 0, Char_Value_Length); + + /** + * Register the characteristic. + */ + ret = aci_gatt_srv_add_char(chr_def_p, Service_Handle); + if (ret == BLE_STATUS_SUCCESS) + { + *Char_Handle = aci_gatt_srv_get_char_decl_handle(chr_def_p); + def_p->attr_handle = *Char_Handle + 1; + def_p->def_type = DEF_TYPE_CHAR; + + /** + * Add new node to attribute definition list. + */ + ACI_gatt_nwk_add_def_entry(def_p); + } + else + { + /** + * The characteristic is not register. Release any allocated resources. + */ + dm_free((uint32_t *)def_p->val_p); + dm_free((uint32_t *)def_p->def_p); + dm_free((uint32_t *)def_p); + } + + /** + * Register mandatory descriptor on the basis of characteristic properties. + */ + if ((ret == BLE_STATUS_SUCCESS) && + ((chr_def_p->properties & (BLE_GATT_SRV_CHAR_PROP_NOTIFY | BLE_GATT_SRV_CHAR_PROP_INDICATE)) != 0U)) + { + /** + * Add CCCD. + */ + uint16_t attr_handle; + uint8_t cccd_val[BLE_GATT_SRV_CCCD_BUFF_SIZE(ACI_GATT_WR_MAX_NUM_OF_LINK)] = { 0 }; + + uuid.Char_UUID_16 = BLE_GATT_SRV_CLIENT_CHAR_CONF_DESCR_TYPE_UUID; + ret = aci_gatt_srv_add_char_desc_nwk(*Char_Handle, + 0x01, + &uuid, + BLE_GATT_SRV_CCCD_BUFF_SIZE(ACI_GATT_WR_MAX_NUM_OF_LINK), + BLE_GATT_SRV_CCCD_BUFF_SIZE(ACI_GATT_WR_MAX_NUM_OF_LINK), + cccd_val, + Security_Permissions & + (BLE_GATT_SRV_PERM_AUTHEN_WRITE | + BLE_GATT_SRV_PERM_ENCRY_WRITE), + GATT_DESCR_ACCESS_PERM_READ | + GATT_DESCR_ACCESS_PERM_WRITE, + GATT_SERVER_ATTR_WRITE, + 0x07U, + FALSE, + &attr_handle); + } + if ((ret == BLE_STATUS_SUCCESS) && + ((chr_def_p->properties & BLE_GATT_SRV_CHAR_PROP_BROADCAST) != 0U)) + { + /** + * Add Server Characteristic Configuration Descriptor. + */ + uint16_t attr_handle; + uint8_t val[2] = { 0 }; + + uuid.Char_UUID_16 = BLE_GATT_SRV_SERVER_CHAR_CONF_DESCR_TYPE_UUID; + ret = aci_gatt_srv_add_char_desc_nwk(*Char_Handle, + 0x01, + &uuid, + 2, + 2, + val, + Security_Permissions & + (BLE_GATT_SRV_PERM_AUTHEN_WRITE | + BLE_GATT_SRV_PERM_ENCRY_WRITE), + GATT_DESCR_ACCESS_PERM_READ | + GATT_DESCR_ACCESS_PERM_WRITE, + GATT_SERVER_ATTR_WRITE, + 0x07U, + FALSE, + &attr_handle); + } + if ((ret == BLE_STATUS_SUCCESS) && + ((chr_def_p->properties & BLE_GATT_SRV_CHAR_PROP_EXTENDED_PROP) != 0U)) + { + /** + * Add Server Characteristic Extended Properties Descriptor. + */ + uint16_t attr_handle; + uint8_t val[2] = { 0 }; + + uuid.Char_UUID_16 = BLE_GATT_SRV_CHAR_EXT_PROP_DESCR_TYPE_UUID; + ret = aci_gatt_srv_add_char_desc_nwk(*Char_Handle, + 0x01, + &uuid, + 2, + 2, + val, + BLE_GATT_SRV_PERM_NONE, + GATT_DESCR_ACCESS_PERM_READ, + 0x00U, + 0x07U, + FALSE, + &attr_handle); + } + + return ret; +} + +tBleStatus aci_gatt_srv_add_char_desc_nwk(uint16_t Char_Handle, + uint8_t Char_Desc_Uuid_Type, + Char_Desc_Uuid_t *Char_Desc_Uuid, + uint16_t Char_Desc_Value_Max_Len, + uint16_t Char_Desc_Value_Length, + uint8_t Char_Desc_Value[], + uint8_t Security_Permissions, + uint8_t Access_Permissions, + uint8_t GATT_Evt_Mask, + uint8_t Enc_Key_Size, + uint8_t Is_Variable, + uint16_t *Char_Desc_Handle) +{ + ble_gatt_descr_def_t *descr_def_p; + ACI_gatt_nwk_def_entry_t *def_p; + tBleStatus ret = BLE_STATUS_OUT_OF_MEMORY; + + descr_def_p = NULL; + if (Char_Desc_Value_Max_Len > BLE_GATT_MAX_ATTR_VALUE_SIZE) + { + return BLE_STATUS_INVALID_PARAMS; + } + + /** + * Allocate characteristic descriptor node. + */ + def_p = (ACI_gatt_nwk_def_entry_t *)dm_alloc(sizeof(ACI_gatt_nwk_def_entry_t)); + if (def_p == NULL) + { + goto __error; + } + memset(def_p, 0, sizeof(ACI_gatt_nwk_def_entry_t)); + + /** + * Allocate characteristic descriptor definition. + */ + descr_def_p = (ble_gatt_descr_def_t *)dm_alloc(sizeof(ble_gatt_descr_def_t)); + if (descr_def_p == NULL) + { + goto __error; + } + memset(descr_def_p, 0, sizeof(ble_gatt_descr_def_t)); + + /** + * Set characteristic descriptor node definition pointer. + */ + def_p->def_p = (uint8_t *)descr_def_p; + + if ((Char_Desc_Uuid_Type == 0x01) && + ((Char_Desc_Uuid->Char_UUID_16 == BLE_GATT_SRV_CLIENT_CHAR_CONF_DESCR_TYPE_UUID) || + (Char_Desc_Uuid->Char_UUID_16 == BLE_GATT_SRV_CHAR_EXT_PROP_DESCR_TYPE_UUID))) + { + /** + * For CCCD and Characteristic Extended Properties Descriptor the value + * buffer shall be directly accessible by the stack hence the value + * buffer shall be allocated. + */ + descr_def_p->val_buffer_p = (ble_gatt_val_buffer_def_t *) + dm_alloc(sizeof(ble_gatt_val_buffer_def_t)); + if (descr_def_p->val_buffer_p == NULL) + { + goto __error; + } + memset(descr_def_p->val_buffer_p, 0, sizeof(ble_gatt_val_buffer_def_t)); + + /** + * Allocate the buffer that store descriptor value. + */ + descr_def_p->val_buffer_p->buffer_p = (uint8_t *)dm_alloc( + sizeof(uint8_t) * Char_Desc_Value_Max_Len); + if (descr_def_p->val_buffer_p->buffer_p == NULL) + { + goto __error; + } + + /** + * Copy provided initial descriptor value. + */ + (void)Osal_MemCpy(descr_def_p->val_buffer_p->buffer_p, Char_Desc_Value, + Char_Desc_Value_Length); + descr_def_p->val_buffer_p->buffer_len = Char_Desc_Value_Max_Len; + if ((GATT_Evt_Mask & GATT_NOTIFY_ATTRIBUTE_WRITE) != 0U) + { + /** + * Once the descriptor value is changed by a client an attribute + * modified event shall be generated to indicate such value to user + * application. + */ + descr_def_p->val_buffer_p->op_flags = + BLE_GATT_SRV_OP_MODIFIED_EVT_ENABLE_FLAG; + } + } + else + { + /** + * Characteristic descriptor value is access by the stack through the + * events mechanism (aci_gatt_srv_write_event and aci_gatt_srv_read_event). + * Allocate value buffer to store descriptor value. + */ + def_p->val_p = (ACI_gatt_nwk_value_t *)dm_alloc(sizeof(ACI_gatt_nwk_value_t) + + Char_Desc_Value_Max_Len); + if (def_p->val_p == NULL) + { + goto __error; + } + + /** + * Copy provided initial descriptor value. + */ + (void)Osal_MemCpy(def_p->val_p->buffer_va, Char_Desc_Value, + Char_Desc_Value_Length); + + def_p->val_p->val_len = Char_Desc_Value_Length; + def_p->val_p->is_variable = Is_Variable; + def_p->val_p->buffer_len = Char_Desc_Value_Max_Len; + def_p->val_p->event_mask = GATT_Evt_Mask; + descr_def_p->val_buffer_p = NULL; + } + /** + * Copy descriptor's UUID value. + */ + ACI_gatt_nwk_set_uuid(Char_Desc_Uuid_Type, (uint8_t const *)Char_Desc_Uuid, + &descr_def_p->uuid); + + /** + * Set minimum encryption key size to access descriptor value. + */ + descr_def_p->min_key_size = Enc_Key_Size; + + /** + * Set descriptor's access properties. + */ + descr_def_p->properties = Access_Permissions & (BLE_GATT_SRV_DESCR_PROP_READ | + BLE_GATT_SRV_DESCR_PROP_WRITE); + + /** + * Set descriptor's security permissions. + */ + descr_def_p->permissions = Security_Permissions; + + /** + * Add descriptor to ATT DB. + */ + ret = aci_gatt_srv_add_char_desc(descr_def_p, Char_Handle); + if (ret == BLE_STATUS_SUCCESS) + { + def_p->attr_handle = aci_gatt_srv_get_descriptor_handle(descr_def_p); + *Char_Desc_Handle = def_p->attr_handle; + def_p->def_type = DEF_TYPE_DESCR; + + /** + * Add new node to attribute definition list. + */ + ACI_gatt_nwk_add_def_entry(def_p); + } + else + { + goto __error; + } + + return ret; + +__error: + /** + * An error arise. Release all allocated memory. + */ + if (descr_def_p != NULL) + { + if (descr_def_p->val_buffer_p != NULL) + { + if (descr_def_p->val_buffer_p->buffer_p != NULL) + { + dm_free((uint32_t *)descr_def_p->val_buffer_p->buffer_p); + } + dm_free((uint32_t *)descr_def_p->val_buffer_p); + } + dm_free((uint32_t *)descr_def_p); + } + if (def_p != NULL) + { + if (def_p->val_p != NULL) + { + dm_free((uint32_t *)def_p->val_p); + } + dm_free((uint32_t *)def_p); + } + + return ret; +} + +tBleStatus aci_gatt_srv_rm_char_nwk(uint16_t Char_Handle) +{ + tBleStatus ret; + ACI_gatt_nwk_def_entry_t *def_p; + + /** + * Remove characteristic from Attribute DB. + */ + ret = aci_gatt_srv_rm_char(Char_Handle); + if (ret == BLE_STATUS_SUCCESS) + { + def_p = ACI_gatt_nwk_find_def_entry(Char_Handle + 1U); + if (def_p != NULL) + { + /** + * Characteristic attribute and all attributes of the group was removed. + * Release attribute nodes and all the allocated resources. All nested + * nodes (descriptors) will be released. + */ + ACI_gatt_nwk_release_def(def_p, DEF_TYPE_CHAR); + } + } + + return ret; +} + +tBleStatus aci_gatt_srv_rm_service_nwk(uint16_t Serv_Handle) +{ + ACI_gatt_nwk_def_entry_t *def_p; + tBleStatus ret; + + /** + * Remove service from Attribute DB. + */ + ret = aci_gatt_srv_rm_service(Serv_Handle); + if (ret == BLE_STATUS_SUCCESS) + { + def_p = ACI_gatt_nwk_find_def_entry(Serv_Handle); + if (def_p != NULL) + { + /** + * Service and all attributes of the group was removed. Release + * attribute nodes and all the allocated resources. All nested nodes + * (characteristics and descriptors) will be released. + */ + ACI_gatt_nwk_release_def(def_p, DEF_TYPE_SERVICE); + } + } + + return ret; +} + +tBleStatus aci_gatt_srv_rm_include_service_nwk(uint16_t Include_Handle) +{ + return aci_gatt_srv_rm_include_service(Include_Handle); +} + +tBleStatus aci_gatt_srv_read_handle_value_nwk(uint16_t Attr_Handle, + uint16_t Offset, + uint16_t Value_Length_Requested, + uint16_t *Length, + uint16_t *Value_Length, + uint8_t Value[]) +{ + ACI_gatt_nwk_def_entry_t *def_p; + tBleStatus ret; + uint8_t *val; + + /** + * If the attribute value is directly handled by the stack (eg. CCCD)its + * value shall be returned by the stack itself. + */ + ret = aci_gatt_srv_read_handle_value(Attr_Handle, Length, &val); + if (ret == BLE_STATUS_SUCCESS) + { + /** + * The value is returned by the stack. + */ + *Value_Length = MIN((*Length - Offset), Value_Length_Requested); + (void)Osal_MemCpy(Value, val, *Value_Length); + } + else + { + /** + * The value is handled by this wrapper. + * Search for attribute definition node. + */ + def_p = ACI_gatt_nwk_find_def_entry(Attr_Handle); + if (def_p == NULL) + { + /** + * Invalid attribute handle. + */ + ret = BLE_STATUS_INVALID_PARAMS; + } + else + { + /** + * We should not send the complete data length of attribute in the + * event but only the length we are sending in the event if Length + * is of Value_Length_Requested bytes and the offset provided is + * also Value_Length_Requested, then we end up not copying anything, + * as _dataLen-Offset turns out to be 0 and in this case we will + * never increase the pBuffer index of the event packet. + */ + if (Offset >= def_p->val_p->val_len) + { + return BLE_STATUS_INVALID_PARAMS; + } + *Length = def_p->val_p->val_len - Offset; + *Value_Length = MIN((def_p->val_p->val_len - Offset), + Value_Length_Requested); + + /** + * Copy attribute value. + */ + (void)Osal_MemCpy(Value, &def_p->val_p->buffer_va[Offset], + *Value_Length); + + ret = BLE_STATUS_SUCCESS; + } + } + + return ret; +} + +tBleStatus aci_gatt_srv_write_handle_value_nwk(uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Char_Value_Length, + uint8_t Char_Value[]) +{ + tBleStatus ret; + ACI_gatt_nwk_def_entry_t *def_p; + + /** + * Check if the attribute value to change is a GAP Profile's attribute and + * if true write it. + */ + ret = Gap_profile_set_char_value(Attr_Handle, Val_Offset, Char_Value_Length, + Char_Value); + if (ret == BLE_STATUS_SUCCESS) + { + return ret; + } + + /** + * Find attribute definition node. + */ + def_p = ACI_gatt_nwk_find_def_entry(Attr_Handle); + if ((def_p == NULL) || + ((Val_Offset + Char_Value_Length) > def_p->val_p->buffer_len)) + { + /** + * Value length or offset is wrong. + */ + return BLE_STATUS_INVALID_PARAMS; + } + + if (def_p->def_type == DEF_TYPE_DESCR) + { + ble_gatt_descr_def_t *descr_def_p; + + descr_def_p = (ble_gatt_descr_def_t *)def_p->def_p; + if ((descr_def_p->uuid.uuid_type == BLE_UUID_TYPE_16BITS) && + (descr_def_p->uuid.v_16.v == BLE_GATT_SRV_CLIENT_CHAR_CONF_DESCR_TYPE_UUID)) + { + return BLE_STATUS_NOT_ALLOWED; + } + } + + if (def_p->val_p->is_variable == TRUE) + { + /** + * It is a variable length attribute. Update the length parameter to the + * new value. + */ + def_p->val_p->val_len = Char_Value_Length; + } + + /** + * Write attribute value. + */ + (void)Osal_MemCpy(&def_p->val_p->buffer_va[Val_Offset], Char_Value, + Char_Value_Length); + + return BLE_STATUS_SUCCESS; +} + +tBleStatus aci_gatt_srv_set_security_permission_nwk(uint16_t Attr_Handle, + uint8_t Security_Permissions) +{ + tBleStatus ret; + ACI_gatt_nwk_def_entry_t *def_p; + ble_gatt_descr_def_t *descr_def_p; + ble_gatt_chr_def_t *chr_def_p; + + if ((Security_Permissions & (~BLE_GATT_SRV_PERM_ALL)) != 0U) + { + return BLE_STATUS_INVALID_PARAMS; + } + + ret = Gatt_profile_set_security_permission(Attr_Handle, Security_Permissions); + if (ret != BLE_STATUS_FAILED) + { + return ret; + } + + ret = Gap_profile_set_security_permission(Attr_Handle, Security_Permissions); + if (ret != BLE_STATUS_FAILED) + { + return ret; + } + + /** + * Search for attribute definition node. + */ + def_p = ACI_gatt_nwk_find_def_entry(Attr_Handle); + if (def_p == NULL) + { + return BLE_STATUS_INVALID_PARAMS; + } + + /** + * Extract definition structure casting it on the basis of the type and + * update its security permissions. + */ + if (def_p->def_type == DEF_TYPE_CHAR) + { + chr_def_p = (ble_gatt_chr_def_t *)def_p->def_p; + chr_def_p->permissions = Security_Permissions; + } + else if (def_p->def_type == DEF_TYPE_DESCR) + { + descr_def_p = (ble_gatt_descr_def_t *)def_p->def_p; + if (descr_def_p->uuid.uuid_type == BLE_UUID_TYPE_16BITS) + { + if ((descr_def_p->uuid.v_16.v == BLE_GATT_SRV_CLIENT_CHAR_CONF_DESCR_TYPE_UUID) || + (descr_def_p->uuid.v_16.v == BLE_GATT_SRV_SERVER_CHAR_CONF_DESCR_TYPE_UUID)) + { + if ((Security_Permissions & (BLE_GATT_SRV_PERM_ENCRY_READ | + BLE_GATT_SRV_PERM_AUTHEN_READ)) != 0U) + { + /** + * <> + * + * Table 3.10: Client Characteristic Configuration declaration + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part G page 1556 + * + * Table 3.12: Server Characteristic Configuration declaration + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part G page 1557 + */ + return BLE_STATUS_NOT_ALLOWED; + } + } + else if ((descr_def_p->uuid.v_16.v == BLE_GATT_SRV_CHAR_EXT_PROP_DESCR_TYPE_UUID) || + (descr_def_p->uuid.v_16.v == BLE_GATT_SRV_CHAR_PRES_FORMAT_DESCR_TYPE_UUID) || + (descr_def_p->uuid.v_16.v == BLE_GATT_SRV_CHAR_AGGR_FORMAT_DESCR_TYPE_UUID)) + { + /** + * The security permission can't be changed for this descriptor. + */ + return BLE_STATUS_NOT_ALLOWED; + } + } + descr_def_p->permissions = Security_Permissions; + } + else + { + return BLE_STATUS_INVALID_PARAMS; + } + + return BLE_STATUS_SUCCESS; +} + +/* The length of the Value buffer must be at least equal to 16 octets. */ +tBleStatus aci_gatt_srv_read_multiple_instance_handle_value_nwk(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t *Value_Length, + uint8_t Value[]) +{ + uint8_t *value_p; + tBleStatus ret; + + ret = aci_gatt_srv_read_multiple_instance_handle_value(Connection_Handle, + Attr_Handle, + Value_Length, + &value_p); + + if(ret == BLE_STATUS_SUCCESS) + { + if(*Value_Length > 16) + return BLE_ERROR_MEMORY_CAPACITY_EXCEEDED; + + Osal_MemCpy(Value,value_p, *Value_Length); + } + + return ret; + +} + +tBleStatus aci_gatt_srv_set_access_permission_nwk(uint16_t Attr_Handle, + uint8_t Access_Permissions) +{ + uint8_t *prop, perm; + tBleStatus ret; + ACI_gatt_nwk_def_entry_t *def_p; + ble_gatt_descr_def_t *descr_def_p; + ble_gatt_chr_def_t *chr_def_p; + + perm = 0U; + if ((Access_Permissions & 0x01U) != 0U) + { + perm |= BLE_GATT_SRV_CHAR_PROP_READ; + } + if ((Access_Permissions & 0x02) != 0U) + { + perm |= BLE_GATT_SRV_CHAR_PROP_WRITE; + } + if ((Access_Permissions & 0x04) != 0U) + { + perm |= BLE_GATT_SRV_CHAR_PROP_WRITE_NO_RESP; + } + if ((Access_Permissions & 0x08) != 0U) + { + perm |= BLE_GATT_SRV_CHAR_PROP_AUTH_SIGN_WRITE; + } + + ret = Gatt_profile_set_access_permission(Attr_Handle, perm); + if (ret == BLE_STATUS_SUCCESS) + { + return ret; + } + + ret = Gap_profile_set_access_permission(Attr_Handle, perm); + if (ret == BLE_STATUS_SUCCESS) + { + return ret; + } + + /** + * Search for attribute definition node. + */ + def_p = ACI_gatt_nwk_find_def_entry(Attr_Handle); + if (def_p == NULL) + { + return BLE_STATUS_INVALID_PARAMS; + } + + /** + * Extract definition structure casting it on the basis of the type and + * get pointer to the properties field. + */ + if (def_p->def_type == DEF_TYPE_CHAR) + { + chr_def_p = (ble_gatt_chr_def_t *)def_p->def_p; + prop = &chr_def_p->properties; + } + else if (def_p->def_type == DEF_TYPE_DESCR) + { + descr_def_p = (ble_gatt_descr_def_t *)def_p->def_p; + if ((descr_def_p->uuid.uuid_type == BLE_UUID_TYPE_16BITS) && + ((descr_def_p->uuid.v_16.v == BLE_GATT_SRV_CHAR_PRES_FORMAT_DESCR_TYPE_UUID) || + (descr_def_p->uuid.v_16.v == BLE_GATT_SRV_CHAR_AGGR_FORMAT_DESCR_TYPE_UUID) || + (descr_def_p->uuid.v_16.v == BLE_GATT_SRV_CHAR_EXT_PROP_DESCR_TYPE_UUID))) + { + /** + * The attribute permission of the following descriptors are standard + * defined and can't be altered: + * - 3.3.3.1 Characteristic Extended Properties + * - 3.3.3.5 Characteristic Presentation Format + * - 3.3.3.6 Characteristic Aggregate Format + */ + return BLE_STATUS_NOT_ALLOWED; + } + prop = &descr_def_p->properties; + } + else + { + return BLE_STATUS_INVALID_PARAMS; + } + + /** + * Update properties. + */ + *prop &= ~BLE_GATT_SRV_CHAR_PROP_ACCESS_PERM_MASK; + *prop |= perm; + + return BLE_STATUS_SUCCESS; +} + +tBleStatus aci_gatt_srv_authorize_resp_nwk(uint16_t Conn_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Operation_Type, + uint8_t Error_Code, + uint16_t Data_Offset, + uint16_t Data_Length, + uint8_t Data[]) +{ + tBleStatus ret; + uint8_t att_err, *data_p; + uint16_t data_len; + ACI_gatt_nwk_def_entry_t *def_p; + + if ((Error_Code != BLE_ATT_ERR_NONE) && + (Error_Code != BLE_ATT_ERR_INSUFF_AUTHORIZATION) && + !((Error_Code >= BLE_ATT_ERR_APPL_MIN) && + (Error_Code <= BLE_ATT_ERR_APPL_MAX))) + { + /** + * Invalid error code. + */ + return BLE_STATUS_INVALID_PARAMS; + } + + data_len = 0; + data_p = NULL; + if (Error_Code == BLE_ATT_ERR_NONE) + { + att_err = BLE_ATT_ERR_NONE; + if (Operation_Type == GATT_AUTHOR_OP_TYPE_READ) + { + def_p = ACI_gatt_nwk_find_def_entry(Attr_Handle); + if (def_p == NULL) + { + /** + * Invalid attribute handle. + */ + return BLE_STATUS_INVALID_PARAMS; + } + /** + * Check read offset parameter. + */ + if (Data_Offset > def_p->val_p->val_len) + { + /** + * Invalid offset. + */ + att_err = BLE_ATT_ERR_INVALID_OFFSET; + } + else + { + /** + * Populate variables to return to the stack. + */ + data_len = def_p->val_p->val_len; + data_p = &def_p->val_p->buffer_va[Data_Offset]; + } + } + else if (Operation_Type == GATT_AUTHOR_OP_TYPE_PREP_WRITE) + { + /** + * Push the prepare write in the queue. + */ + ret = EATT_pwrq_push(Conn_Handle, CID, Attr_Handle, + Data_Offset, Data_Length, Data); + if (ret != BLE_STATUS_SUCCESS) + { + att_err = BLE_ATT_ERR_PREP_QUEUE_FULL; + } + data_len = Data_Length; + data_p = Data; + } + else if ((Operation_Type == GATT_AUTHOR_OP_TYPE_WRITE) || + (Operation_Type == GATT_AUTHOR_OP_TYPE_WRITE_CMD)) + { + def_p = ACI_gatt_nwk_find_def_entry(Attr_Handle); + if (Data_Length > def_p->val_p->buffer_len) + { + att_err = BLE_ATT_ERR_INVAL_ATTR_VALUE_LEN; + } + else + { + /** + * Write received data into attribute value buffer. + */ + Osal_MemCpy(def_p->val_p->buffer_va, Data, Data_Length); + att_err = BLE_ATT_ERR_NONE; + } + if (def_p->val_p->is_variable == TRUE) + { + /** + * Update value length. + */ + def_p->val_p->val_len = Data_Length; + } + if ((def_p->val_p->event_mask & GATT_SERVER_ATTR_WRITE) != 0x00U) + { + /** + * The application expects to receive the attribute modified event. + */ + aci_gatt_srv_attribute_modified_event(Conn_Handle, + CID, + Attr_Handle, + Data_Length, + def_p->val_p->buffer_va); + + } + } + } + else + { + att_err = Error_Code; + } + + if (Operation_Type != GATT_AUTHOR_OP_TYPE_WRITE_CMD) + { + aci_gatt_srv_resp(Conn_Handle, CID, Attr_Handle, att_err, data_len, data_p); + } + + return BLE_STATUS_SUCCESS; +} + +tBleStatus aci_gatt_srv_exec_write_resp_nwk(uint16_t Conn_Handle, + uint16_t CID, + uint8_t Exec) +{ + uint8_t att_error; + + att_error = BLE_ATT_ERR_NONE; + if (Exec == 1U) + { + att_error = ACI_gatt_nwk_write_queue(Conn_Handle); + } + + /** + * Flush the queue from all prepared write received by this connection handle. + */ + EATT_pwrq_flush(Conn_Handle, EATT_PWRQ_CID_ALL); + + /** + * Return to the stack to send the Execute Write Response or in case the + * error response if the att_error is not zero. + */ + aci_gatt_srv_resp(Conn_Handle, CID, 0U, att_error, 0U, NULL); + + return BLE_STATUS_SUCCESS; +} + +tBleStatus aci_gatt_srv_read_prepare_queue_nwk(uint16_t Conn_Handle, + uint8_t Item_Index, + uint16_t *Attr_Handle, + uint16_t *Value_Offset, + uint16_t *Value_Length, + uint8_t Value[]) +{ + tBleStatus ret; + ble_gatt_clt_write_ops_t wr_ops; + + /** + * Read the queued write at the given queue index. + */ + ret = EATT_pwrq_read(Conn_Handle, EATT_PWRQ_CID_ALL, Item_Index, &wr_ops); + if (ret == BLE_STATUS_SUCCESS) + { + *Attr_Handle = wr_ops.attr_h; + *Value_Offset = wr_ops.attr_offset; + *Value_Length = wr_ops.data_len; + (void)Osal_MemCpy(Value, wr_ops.data_p, wr_ops.data_len); + } + + return ret; +} + +tBleStatus aci_gatt_clt_write_long_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]) +{ + ACI_gatt_nwk_write_ops_t *ops_p; + tBleStatus ret; + + ret = BLE_STATUS_FAILED; + ops_p = ACI_gatt_nwk_add_write_ops(Connection_Handle, CID, 1U, Attribute_Val_Length); + if (ops_p != NULL) + { + ops_p->write_ops_p->attr_h = Attr_Handle; + ops_p->write_ops_p->attr_offset = Val_Offset; + ops_p->write_ops_p->data_len = Attribute_Val_Length; + ops_p->write_ops_p->data_p = ops_p->buffer; + (void)Osal_MemCpy(ops_p->buffer, Attribute_Val, Attribute_Val_Length); + + ret = aci_gatt_clt_write_long(Connection_Handle, CID, ops_p->write_ops_p); + if (ret != BLE_STATUS_SUCCESS) + { + ACI_gatt_nwk_rm_write_ops(Connection_Handle, CID); + } + } + + return ret; +} + +tBleStatus aci_gatt_clt_write_char_reliable_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]) +{ + ACI_gatt_nwk_write_ops_t *ops_p; + tBleStatus ret; + + ret = BLE_STATUS_FAILED; + ops_p = ACI_gatt_nwk_add_write_ops(Connection_Handle, CID, 1U, Attribute_Val_Length); + if (ops_p != NULL) + { + ops_p->write_ops_p[0].attr_h = Attr_Handle; + ops_p->write_ops_p[0].attr_offset = Val_Offset; + ops_p->write_ops_p[0].data_len = Attribute_Val_Length; + ops_p->write_ops_p[0].data_p = &ops_p->buffer[0]; + (void)Osal_MemCpy(ops_p->write_ops_p[0].data_p, Attribute_Val, + Attribute_Val_Length); + + ret = aci_gatt_clt_write_char_reliable(Connection_Handle, + CID, + 1U, + ops_p->write_ops_p); + if (ret != BLE_STATUS_SUCCESS) + { + ACI_gatt_nwk_rm_write_ops(Connection_Handle, CID); + } + } + + return ret; +} + +tBleStatus aci_gatt_clt_write_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]) +{ + ACI_gatt_nwk_write_ops_t *ops_p; + tBleStatus ret; + + ret = BLE_STATUS_FAILED; + ops_p = ACI_gatt_nwk_add_write_ops(Connection_Handle, CID, 1U, Attribute_Val_Length); + if (ops_p != NULL) + { + (void)Osal_MemCpy(ops_p->buffer, Attribute_Val, Attribute_Val_Length); + + ret = aci_gatt_clt_write(Connection_Handle, CID, Attr_Handle, + Attribute_Val_Length, ops_p->buffer); + if (ret != BLE_STATUS_SUCCESS) + { + ACI_gatt_nwk_rm_write_ops(Connection_Handle, CID); + } + } + + return ret; +} + +/****************************************************************************** + * EVENT HANDLERS + *****************************************************************************/ +int aci_gatt_srv_write_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Resp_Needed, + uint16_t Attribute_Handle, + uint16_t Data_Length, + uint8_t Data[]) +{ + uint8_t att_err; + ACI_gatt_nwk_def_entry_t *def_p; + + /** + * Search for attribute definition node. + */ + def_p = ACI_gatt_nwk_find_def_entry(Attribute_Handle); + if (def_p != NULL) + { + if ((def_p->val_p->event_mask & GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP) != 0U) + { + /** + * The user application has to authorize this write operation. + */ + uint8_t op_type; + + if (Resp_Needed) + { + op_type = GATT_AUTHOR_OP_TYPE_WRITE; + } + else + { + op_type = GATT_AUTHOR_OP_TYPE_WRITE_CMD; + } + aci_gatt_srv_authorize_nwk_event(Connection_Handle, + CID, + Attribute_Handle, + op_type, + 0x0000U, + Data_Length, Data); + + return 1; + } + else + { + if (Data_Length > def_p->val_p->buffer_len) + { + att_err = BLE_ATT_ERR_INVAL_ATTR_VALUE_LEN; + } + else + { + /** + * Write received data into attribute value buffer. + */ + Osal_MemCpy(def_p->val_p->buffer_va, Data, Data_Length); + att_err = BLE_ATT_ERR_NONE; + } + if (def_p->val_p->is_variable == TRUE) + { + /** + * Update value length. + */ + def_p->val_p->val_len = Data_Length; + } + } + if (Resp_Needed == 1U) + { + /** + * It is a write request then call response function to generate + * write response message. + */ + aci_gatt_srv_resp(Connection_Handle, + CID, + Attribute_Handle, + att_err, + 0, + NULL); + } + if ((att_err == BLE_ATT_ERR_NONE) && + ((def_p->val_p->event_mask & GATT_SERVER_ATTR_WRITE) != 0x00U)) + { + /** + * The application expect to receive the attribute modified event. + */ + uint16_t event_data_len; + + if (def_p->val_p->is_variable == TRUE) + { + event_data_len = def_p->val_p->val_len; + } + else + { + event_data_len = def_p->val_p->buffer_len; + } + aci_gatt_srv_attribute_modified_event(Connection_Handle, + CID, + Attribute_Handle, + event_data_len, + def_p->val_p->buffer_va); + } + } + + return 1; +} + +int aci_gatt_srv_read_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attribute_Handle, + uint16_t Data_Offset) +{ + uint8_t att_err, *data_p; + uint16_t data_len; + ACI_gatt_nwk_def_entry_t *def_p; + + data_len = 0U; + data_p = NULL; + /** + * Search for attribute definition node. + */ + def_p = ACI_gatt_nwk_find_def_entry(Attribute_Handle); + if (def_p == NULL) + { + /** + * Invalid attribute handle. + */ + att_err = BLE_ATT_ERR_INVALID_HANDLE; + } + else + { + if (def_p->val_p == NULL) + { + att_err = BLE_ATT_ERR_UNLIKELY; + } + else if ((def_p->val_p->event_mask & GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP) != 0x00U) + { + /** + * The application has to authorize read operation for the requested + * attribute value. + */ + aci_gatt_srv_authorize_nwk_event(Connection_Handle, + CID, + Attribute_Handle, + GATT_AUTHOR_OP_TYPE_READ, + Data_Offset, + 0U, NULL); + return 1; + } + else + { + /** + * Check read offset parameter. + */ + if (Data_Offset > def_p->val_p->val_len) + { + /** + * Invalid offset. + */ + att_err = BLE_ATT_ERR_INVALID_OFFSET; + } + else + { + /** + * Populate variables to return to the stack. + */ + data_len = def_p->val_p->val_len; + data_p = &def_p->val_p->buffer_va[Data_Offset]; + att_err = BLE_ATT_ERR_NONE; + } + } + } + + /** + * Return to the stack the value to read information and in case the error + * code. + */ + aci_gatt_srv_resp(Connection_Handle, CID, Attribute_Handle, att_err, + data_len, data_p); + + return 1; /* Discard event */ +} + +int aci_att_srv_prepare_write_req_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attribute_Handle, + uint16_t Data_Offset, + uint16_t Data_Length, + uint8_t Data[]) +{ + ACI_gatt_nwk_def_entry_t *def_p; + uint8_t att_err; + tBleStatus ret; + + def_p = ACI_gatt_nwk_find_def_entry(Attribute_Handle); + if (def_p != NULL) + { + if ((def_p->val_p->event_mask & GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP) != 0U) + { + /** + * Generate authorization event. + */ + aci_gatt_srv_authorize_nwk_event(Connection_Handle, + CID, + Attribute_Handle, + GATT_AUTHOR_OP_TYPE_PREP_WRITE, + Data_Offset, + Data_Length, + Data); + + /** + * No response has to be sent before application response. + */ + return 1; + } + else + { + /** + * This attribute has not be set for authorization. Push the received + * prepare write in the queue. + */ + ret = EATT_pwrq_push(Connection_Handle, CID, Attribute_Handle, + Data_Offset, Data_Length, Data); + if (ret != BLE_STATUS_SUCCESS) + { + att_err = BLE_ATT_ERR_PREP_QUEUE_FULL; + } + else + { + att_err = BLE_ATT_ERR_NONE; + } + } + } + else + { + att_err = BLE_ATT_ERR_INVALID_HANDLE; + } + + /** + * Send response. + */ + aci_gatt_srv_resp(Connection_Handle, CID, Attribute_Handle, att_err, + Data_Length, Data); + return 1; +} + +/****************************************************************************** + * PRIVATE FUNCTIONS + *****************************************************************************/ +static void ACI_gatt_nwk_add_def_entry(ACI_gatt_nwk_def_entry_t *def_p) +{ + ACI_gatt_nwk_def_entry_t *p; + + if (aci_gatt_nwk_ctx_s.head == NULL) + { + /** + * Definition list is empty. + */ + aci_gatt_nwk_ctx_s.head = def_p; + def_p->next_p = NULL; + } + else + { + p = aci_gatt_nwk_ctx_s.head; + if (p->attr_handle > def_p->attr_handle) + { + def_p->next_p = p; + aci_gatt_nwk_ctx_s.head = def_p; + } + else + { + while (p->next_p != NULL) + { + /** + * Search for the node with an attribute handle greater than the + * new one. + */ + if (p->next_p->attr_handle > def_p->attr_handle) + { + break; + } + p = p->next_p; + } + /** + * Insert new node. + */ + def_p->next_p = p->next_p; + p->next_p = def_p; + } + } +} + +static void ACI_gatt_nwk_rm_def_entry(ACI_gatt_nwk_def_entry_t *def_p) +{ + ACI_gatt_nwk_def_entry_t *p; + + if (aci_gatt_nwk_ctx_s.head != NULL) + { + p = aci_gatt_nwk_ctx_s.head; + if (p->attr_handle == def_p->attr_handle) + { + /** + * It is the head of the list. + */ + aci_gatt_nwk_ctx_s.head = p->next_p; + } + else + { + while (p->next_p != NULL) + { + if (p->next_p->attr_handle == def_p->attr_handle) + { + /** + * Next node has the required attribute handle. Un-link it. + */ + p->next_p = p->next_p->next_p; + + break; + } + p = p->next_p; + } + } + } +} + +static void ACI_gatt_nwk_free_def_entry(ACI_gatt_nwk_def_entry_t *def_p) +{ + ble_gatt_val_buffer_def_t *val_buffer_p; + + switch (def_p->def_type) + { + case DEF_TYPE_DESCR: + { + ble_gatt_descr_def_t *descr_p = (ble_gatt_descr_def_t *)def_p->def_p; + val_buffer_p = descr_p->val_buffer_p; + } + break; + + case DEF_TYPE_CHAR: + { + ble_gatt_chr_def_t *chr_p = (ble_gatt_chr_def_t *)def_p->def_p; + val_buffer_p = chr_p->val_buffer_p; + } + + break; + + default: + val_buffer_p = NULL; + break; + } + + if (val_buffer_p != NULL) + { + /** + * Release value buffer memory. + */ + if (val_buffer_p->buffer_p != NULL) + { + dm_free((uint32_t *)val_buffer_p->buffer_p); + } + dm_free((uint32_t *)val_buffer_p); + } + + if (def_p->val_p != NULL) + { + /** + * Release value buffer definition memory. + */ + dm_free((uint32_t *)def_p->val_p); + } + + /** + * Release Attribute definition memory. + */ + dm_free((uint32_t *)def_p->def_p); + + /** + * Release node memory. + */ + dm_free((uint32_t *)def_p); +} + +static void ACI_gatt_nwk_release_def(ACI_gatt_nwk_def_entry_t *def_p, def_type_et type) +{ + ACI_gatt_nwk_def_entry_t *next_def_p; + + while (def_p != NULL) + { + next_def_p = def_p->next_p; + + /** + * Unlink node. + */ + ACI_gatt_nwk_rm_def_entry(def_p); + + /** + * Release node memory. + */ + ACI_gatt_nwk_free_def_entry(def_p); + + if (next_def_p->def_type == type) + { + /** + * Next node has the same group type of the removing entry. Stop! + */ + break; + } + def_p = next_def_p; + } +} + +static ACI_gatt_nwk_def_entry_t *ACI_gatt_nwk_find_def_entry(uint16_t attr_handle) +{ + ACI_gatt_nwk_def_entry_t *p; + + p = aci_gatt_nwk_ctx_s.head; + while (p != NULL) + { + if (p->attr_handle == attr_handle) + { + return p; + } + p = p->next_p; + } + + return NULL; +} + +static tBleStatus ACI_gatt_nwk_set_uuid(const uint8_t src_uuid_type, + const uint8_t *src_uuid_p, + ble_uuid_t *uuid_p) +{ + if (src_uuid_type == 0x01) + { + /** + * Copy 16 bits UUID. + */ + (void)Osal_MemCpy((uint8_t *)&uuid_p->v_16.v, src_uuid_p, BLE_UUID_16_LENGTH); + uuid_p->uuid_type = BLE_UUID_TYPE_16BITS; + } + else if (src_uuid_type == 0x02) + { + /** + * Copy 128 bits UUID. + */ + + (void)Osal_MemCpy(uuid_p->v_128.v, src_uuid_p, BLE_UUID_128_LENGTH); + uuid_p->uuid_type = BLE_UUID_TYPE_128BITS; + } + else + { + return BLE_STATUS_INVALID_PARAMS; + } + + return BLE_STATUS_SUCCESS; +} + +static ACI_gatt_nwk_write_ops_t *ACI_gatt_nwk_add_write_ops(uint16_t conn_handle, + uint16_t cid, + uint8_t num_write_ops, + uint16_t buffer_size) +{ + ACI_gatt_nwk_write_ops_t *ops_p, *prev_p; + + ops_p = (ACI_gatt_nwk_write_ops_t *)dm_alloc(sizeof(ACI_gatt_nwk_write_ops_t) + buffer_size); + if (ops_p != NULL) + { + ops_p->write_ops_p = (ble_gatt_clt_write_ops_t *) + dm_alloc(sizeof(ble_gatt_clt_write_ops_t) * num_write_ops); + if (ops_p->write_ops_p == NULL) + { + dm_free((uint32_t *)ops_p); + ops_p = NULL; + } + else + { + ops_p->next_p = NULL; + ops_p->conn_handle = conn_handle; + ops_p->cid = cid; + if (aci_gatt_nwk_ctx_s.write_ops_head_p == NULL) + { + aci_gatt_nwk_ctx_s.write_ops_head_p = ops_p; + } + else + { + prev_p = aci_gatt_nwk_ctx_s.write_ops_head_p; + while (prev_p->next_p != NULL) + { + prev_p = prev_p->next_p; + } + prev_p->next_p = ops_p; + } + } + } + + return ops_p; +} + +static void ACI_gatt_nwk_rm_write_ops(uint16_t conn_handle, uint16_t cid) +{ + ACI_gatt_nwk_write_ops_t *ops_p = NULL, *prev_p = NULL; + + ops_p = aci_gatt_nwk_ctx_s.write_ops_head_p; + + while (ops_p != NULL) + { + if ((ops_p->conn_handle == conn_handle) && (ops_p->cid == cid)) + { + if(ops_p == aci_gatt_nwk_ctx_s.write_ops_head_p) + { + /* First element in the list */ + aci_gatt_nwk_ctx_s.write_ops_head_p = ops_p->next_p; + } + else + { + prev_p->next_p = ops_p->next_p; + } + break; + } + prev_p = ops_p; + ops_p = ops_p->next_p; + } + + if (ops_p != NULL) + { + dm_free((uint32_t *)ops_p->write_ops_p); + dm_free((uint32_t *)ops_p); + } +} + +static uint8_t ACI_gatt_nwk_write_queue(uint16_t conn_handle) +{ + tBleStatus ret; + uint16_t attr_h, data_len; + ble_gatt_clt_write_ops_t wr_ops; + ACI_gatt_nwk_def_entry_t *def_p; + + /** + * Set attribute handle to 0x0000 to extract the first found entry. + */ + attr_h = EATT_PWRQ_ATTR_HANDLE_INVALID; + def_p = NULL; + while (TRUE) + { + /** + * Extract queued write. + */ + ret = EATT_pwrq_pop(conn_handle, EATT_PWRQ_CID_ALL, attr_h, &wr_ops); + if (ret == BLE_STATUS_SUCCESS) + { + if (attr_h == EATT_PWRQ_ATTR_HANDLE_INVALID) + { + /** + * Select the first extracted attribute handle for the next + * search. + */ + attr_h = wr_ops.attr_h; + + /** + * Search for attribute definition node. + */ + def_p = ACI_gatt_nwk_find_def_entry(wr_ops.attr_h); + if (def_p == NULL) + { + /** + * Invalid attribute handle. + */ + return BLE_ATT_ERR_UNLIKELY; + } + } + + if (def_p == NULL) + { + return BLE_ATT_ERR_ATTR_NOT_FOUND; + } + + /** + * Check write offset. + */ + if (wr_ops.attr_offset > def_p->val_p->buffer_len) + { + return BLE_ATT_ERR_INVALID_OFFSET; + } + + /** + * Check write length. + */ + if ((wr_ops.attr_offset + wr_ops.data_len) > def_p->val_p->buffer_len) + { + return BLE_ATT_ERR_INVAL_ATTR_VALUE_LEN; + } + + /** + * Write dato into attribute value buffer. + */ + (void)Osal_MemCpy(&def_p->val_p->buffer_va[wr_ops.attr_offset], + wr_ops.data_p, + wr_ops.data_len); + + if (def_p->val_p->is_variable == TRUE) + { + /** + * Update attribute value length. + */ + def_p->val_p->val_len = wr_ops.attr_offset + wr_ops.data_len; + } + } + else + { + if (attr_h != 0x0000U) + { + /** + * No more entries are present for the selected attribute handle. + */ + if (def_p != NULL) + { + if ((def_p->val_p->event_mask & GATT_SERVER_ATTR_WRITE) != 0x00U) + { + if (def_p->val_p->is_variable == TRUE) + { + data_len = def_p->val_p->val_len; + } + else + { + data_len = def_p->val_p->buffer_len; + } + + /** + * The application expect to receive the attribute modified event. + */ + aci_gatt_srv_attribute_modified_event(conn_handle, + EATT_PWRQ_CID_ALL, + attr_h, + data_len, + def_p->val_p->buffer_va); + } + } + + /** + * Reset attribute handle to extract the next first found entry. + */ + attr_h = 0x0000U; + } + else + { + /** + * No more entries are present for the selected connection handle. + */ + break; + } + } + } + + return BLE_ATT_ERR_NONE; +} + +/* Hooks for DTM commands */ + +int hci_disconnection_complete_event_preprocess(uint8_t Status, + uint16_t Connection_Handle, + uint8_t Reason) +{ + /* This is needed to remove all write ops for unenhanced ATT and fush prepare + write queue. */ + ACI_gatt_nwk_disconnection(Connection_Handle, L2C_CID_ATTRIBUTE_PROTOCOL); + + return 0; +} + +int aci_gatt_clt_proc_complete_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Error_Code) +{ + ACI_gatt_nwk_proc_complete(Connection_Handle, CID, Error_Code); + + return 0; +} + +#else /* (CFG_BLE_CONNECTION_ENABLED == 1) && (BLESTACK_CONTROLLER_ONLY == 0) */ + +void ACI_gatt_nwk_init(uint16_t buffer_size) +{ +} + +void ACI_gatt_nwk_reset(void) +{ +} + +void ACI_gatt_nwk_proc_complete(uint16_t Connection_Handle, uint16_t CID, uint8_t Error_Code) +{ +} + +void ACI_gatt_nwk_disconnection(uint16_t Connection_Handle, uint16_t CID) +{ +} + +int hci_disconnection_complete_event_preprocess(uint8_t Status, + uint16_t Connection_Handle, + uint8_t Reason) +{ + return 0; +} + +int aci_gatt_clt_proc_complete_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Error_Code) +{ + return 0; +} + +int aci_gatt_srv_write_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Resp_Needed, + uint16_t Attribute_Handle, + uint16_t Data_Length, + uint8_t Data[]) +{ + return 0; +} + +int aci_gatt_srv_read_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attribute_Handle, + uint16_t Data_Offset) +{ + return 0; +} + +int aci_att_srv_prepare_write_req_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attribute_Handle, + uint16_t Data_Offset, + uint16_t Data_Length, + uint8_t Data[]) +{ + return 0; +} + +#endif /* (CFG_BLE_CONNECTION_ENABLED == 1) && (BLESTACK_CONTROLLER_ONLY == 0) */ + diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.h new file mode 100644 index 000000000..2a6e5a409 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.h @@ -0,0 +1,586 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file aci_gatt_nwk.h + * @author MCD Application Team + * @brief Adaptation layer from GATT native interface to GATT network + * processor interface + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef ACI_GATT_NWK_H +#define ACI_GATT_NWK_H + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "app_conf.h" + +/****************************************************************************** + * CONSTANT SYMBOLS + *****************************************************************************/ +#define ACI_GATT_WR_MAX_NUM_OF_LINK (CFG_BLE_NUM_RADIO_TASKS) + +/** + * If this bit is set, then Attribute Modified Event is generated + */ +#define GATT_SERVER_ATTR_WRITE (0x01U) + +#define GATT_DESCR_ACCESS_PERM_NONE (0x00U) +#define GATT_DESCR_ACCESS_PERM_READ (0x01U) +#define GATT_DESCR_ACCESS_PERM_WRITE (0x02U) +#define GATT_DESCR_ACCESS_PERM_WRITE_NO_RESP (0x04U) +#define GATT_DESCR_ACCESS_PERM_SIGNED_WRITE (0x08U) + +#define GATT_AUTHOR_OP_TYPE_READ (0x00U) +#define GATT_AUTHOR_OP_TYPE_WRITE (0x10U) +#define GATT_AUTHOR_OP_TYPE_WRITE_CMD (0x11U) +#define GATT_AUTHOR_OP_TYPE_PREP_WRITE (0x12U) + +#define L2C_CID_ATTRIBUTE_PROTOCOL (4U) + +/****************************************************************************** + * TYPES + *****************************************************************************/ +/** Documentation for C union Service_UUID_t */ +typedef union Service_UUID_t_s +{ + /** 16-bit UUID + */ + uint16_t Service_UUID_16; + /** 128-bit UUID + */ + uint8_t Service_UUID_128[16]; +} Service_UUID_t; +/** Documentation for C union Char_UUID_t */ +typedef union Char_UUID_t_s +{ + /** 16-bit UUID + */ + uint16_t Char_UUID_16; + /** 128-bit UUID + */ + uint8_t Char_UUID_128[16]; +} Char_UUID_t; +/** Documentation for C union Char_Desc_Uuid_t */ +typedef union Char_Desc_Uuid_t_s +{ + /** 16-bit UUID + */ + uint16_t Char_UUID_16; + /** 128-bit UUID + */ + uint8_t Char_UUID_128[16]; +} Char_Desc_Uuid_t; +/****************************************************************************** + * FUNCTION PROTOTYPES + *****************************************************************************/ + +/** + * @brief Initialize ACI GATT nwk component + * + * @param pwrq_size[in] The size of the buffer assigned to PWRQ module. + * + * @return void + * + */ +void ACI_gatt_nwk_init(uint16_t pwrq_size); + +/** + * @brief Reset ACI GATT nwk component, erasing any allocated attributes and values. + * + * @return void + * + */ +void ACI_gatt_nwk_reset(void); + +/** + * @brief Procedure Complete Event handler. This function is used to release the + * locket value buffer. + * + * @param Connection_Handle[in] The connection handle for which the Procedure + * Complete event is issued. + * @param CID[in] The channel ID. + * @param Error_Code[in] The returned error coded. + * + * @return void + * + */ +void ACI_gatt_nwk_proc_complete(uint16_t Connection_Handle, uint16_t CID, uint8_t Error_Code); + +/** + * @brief Disconnection Event handler. This function is used to release the + * allocated resources for the given connection handle. + * + * @param Connection_Handle[in] The connection handle + * @param CID[in] The channel ID. + * + * @return void + * + */ +void ACI_gatt_nwk_disconnection(uint16_t Connection_Handle, uint16_t CID); + +/** + * @brief Add a service to GATT Server. When a service is created in the server, the host needs to + * reserve the handle ranges for this service using Max_Attribute_Records parameter. This + * parameter specifies the maximum number of attribute records that can be added to this + * service (including the service attribute, include attribute, characteristic attribute, + * characteristic value attribute and characteristic descriptor attribute). Handle of the created + * service is returned in command complete event. Service declaration is taken from the service pool. + * The attributes for characteristics and descriptors are allocated from the attribute pool. + * @param Service_UUID_Type UUID type. + * Values: + * - 0x01: 16-bit UUID + * - 0x02: 128-bit UUID + * @param Service_UUID See @ref Service_UUID_t + * @param Service_Type Service type. + * Values: + * - 0x01: Primary Service + * - 0x02: Secondary Service + * @param Max_Attribute_Records Maximum number of attribute records that can be added to this service + * @param[out] Service_Handle Handle of the Service. + * When this service is added, a handle is allocated by the server for this service. + * Server also allocates a range of handles for this service from serviceHandle to + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_add_service_nwk(uint8_t Service_UUID_Type, + Service_UUID_t *Service_UUID, + uint8_t Service_Type, + uint8_t Max_Attribute_Records, + uint16_t *Service_Handle); +/** + * @brief Include a service given by Included_Handle to another + * service given by Service_Handle. Attribute server creates an INCLUDE definition + * attribute and return the handle of this attribute in Included_handle. + * @param Service_Handle Handle of the Service to which another service has to be included. + * Values: + * - 0x0001 ... 0xFFFF + * @param Included_Service_Handle Attribute Handle of the Service which has to be included in service + * Values: + * - 0x0001 ... 0xFFFF + * @param[out] Include_Handle Handle of the include declaration + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_include_service_nwk(uint16_t Service_Handle, + uint16_t Included_Service_Handle, + uint16_t *Include_Handle); +/** + * @brief Add a characteristic to a service. + * @param Service_Handle Handle of the Service to which the characteristic will be added + * Values: + * - 0x0001 ... 0xFFFF + * @param Char_UUID_Type UUID type. + * Values: + * - 0x01: 16-bit UUID + * - 0x02: 128-bit UUID + * @param Char_UUID See @ref Char_UUID_t + * @param Char_Value_Length Maximum length of the characteristic value. + * Values: + * - 0 ... 512 + * @param Char_Properties Characteristic Properties (Volume 3, Part G, section 3.3.1.1 of Bluetooth Specification 4.1) + * Flags: + * - 0x00: CHAR_PROP_NONE + * - 0x01: CHAR_PROP_BROADCAST (Broadcast) + * - 0x02: CHAR_PROP_READ (Read) + * - 0x04: CHAR_PROP_WRITE_WITHOUT_RESP (Write w/o resp) + * - 0x08: CHAR_PROP_WRITE (Write) + * - 0x10: CHAR_PROP_NOTIFY (Notify) + * - 0x20: CHAR_PROP_INDICATE (Indicate) + * - 0x40: CHAR_PROP_SIGNED_WRITE (Authenticated Signed Writes) + * - 0x80: CHAR_PROP_EXT (Extended Properties) + * @param Security_Permissions Security permission flags. + * Flags: + * - 0x00: None + * - 0x01: AUTHEN_READ (Need authentication to read) + * - 0x04: ENCRY_READ (Need encryption to read) + * - 0x08: AUTHEN_WRITE (need authentication to write) + * - 0x20: ENCRY_WRITE (need encryption to write) + * @param GATT_Evt_Mask GATT event mask. + * Flags: + * - 0x00: GATT_DONT_NOTIFY_EVENTS + * - 0x01: GATT_NOTIFY_ATTRIBUTE_WRITE + * - 0x02: GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP + * - 0x04: GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP + * @param Enc_Key_Size Minimum encryption key size required to read the characteristic. + * Values: + * - 0x07 ... 0x10 + * @param Is_Variable Specify if the characteristic value has a fixed length or + * a variable length. + * Values: + * - 0x00: Fixed length + * - 0x01: Variable length + * @param[out] Char_Handle Handle of the Characteristic that has been added. + * It is the handle of the characteristic declaration. + * The attribute that holds the characteristic value is allocated at the next handle, + * followed by the Client Characteristic Configuration descriptor if the characteristic + * has CHAR_PROP_NOTIFY or CHAR_PROP_INDICATE properties. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_add_char_nwk(uint16_t Service_Handle, + uint8_t Char_UUID_Type, + Char_UUID_t *Char_UUID, + uint16_t Char_Value_Length, + uint8_t Char_Properties, + uint8_t Security_Permissions, + uint8_t GATT_Evt_Mask, + uint8_t Enc_Key_Size, + uint8_t Is_Variable, + uint16_t *Char_Handle); + +/** + * @brief Add a characteristic descriptor to a characteristic. + * @param Char_Handle Handle of the characteristic to which description has to be added + * Values: + * - 0x0001 ... 0xFFFF + * @param Char_Desc_Uuid_Type UUID type. + * Values: + * - 0x01: 16-bit UUID + * - 0x02: 128-bit UUID + * @param Char_Desc_Uuid See @ref Char_Desc_Uuid_t + * @param Char_Desc_Value_Max_Len The maximum length of the descriptor value + * Values: + * - 0 ... 512 + * @param Char_Desc_Value_Length Current Length of the characteristic descriptor value + * Values: + * - 0 ... 512 + * @param Char_Desc_Value Value of the characteristic description + * @param Security_Permissions Security permission flags. + * Flags: + * - 0x00: None + * - 0x01: AUTHEN_READ (Need authentication to read) + * - 0x04: ENCRY_READ (Need encryption to read) + * - 0x08: AUTHEN_WRITE (need authentication to write) + * - 0x20: ENCRY_WRITE (need encryption to write) + * @param Access_Permissions Access permission + * Flags: + * - 0x00: None + * - 0x01: READ + * - 0x02: WRITE + * - 0x04: WRITE_WO_RESP + * - 0x08: SIGNED_WRITE + * @param GATT_Evt_Mask GATT event mask. + * Flags: + * - 0x00: GATT_DONT_NOTIFY_EVENTS + * - 0x01: GATT_NOTIFY_ATTRIBUTE_WRITE + * - 0x02: GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP + * - 0x04: GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP + * @param Enc_Key_Size Minimum encryption key size required to read the characteristic. + * Values: + * - 0x07 ... 0x10 + * @param Is_Variable Specify if the characteristic value has a fixed length or + * a variable length. + * Values: + * - 0x00: Fixed length + * - 0x01: Variable length + * @param[out] Char_Desc_Handle Handle of the characteristic descriptor + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_add_char_desc_nwk(uint16_t Char_Handle, + uint8_t Char_Desc_Uuid_Type, + Char_Desc_Uuid_t *Char_Desc_Uuid, + uint16_t Char_Desc_Value_Max_Len, + uint16_t Char_Desc_Value_Length, + uint8_t Char_Desc_Value[], + uint8_t Security_Permissions, + uint8_t Access_Permissions, + uint8_t GATT_Evt_Mask, + uint8_t Enc_Key_Size, + uint8_t Is_Variable, + uint16_t *Char_Desc_Handle); + +/** + * @brief Update an attribute value. + * + * @param Attr_Handle Handle of the attribute + * Values: + * - 0x0001 ... 0xFFFF + * @param Val_Offset The offset from which the attribute value has to be updated. + * If this is set to 0 and the attribute value is of variable length, then the length of the attribute will be set to the Char_Value_Length. + * If the Val_Offset is set to a value greater than 0, then the length of the attribute will be set to the maximum length as + * specified for the attribute while adding the characteristic. + * Values: + * - 0 ... 511 + * @param Value_Length Length of the attribute value in octets + * @param Value Attribute value + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_write_handle_value_nwk(uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Value_Length, + uint8_t Value[]); +/** + * @brief Delete the specified characteristic from the service. + * @param Char_Handle Handle of the characteristic which has to be deleted + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_rm_char_nwk(uint16_t Char_Handle); +/** + * @brief Delete the specified service from the GATT server database. + * @param Serv_Handle Handle of the service to be deleted + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_rm_service_nwk(uint16_t Serv_Handle); +/** + * @brief Delete the Include definition from the service. + * @param Include_Handle Handle of the included service which has to be deleted + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_rm_include_service_nwk(uint16_t Include_Handle); + +/** + * @brief This command sets the security permission for the attribute handle specified. Currently the + * setting of security permission is allowed only for client configuration descriptor. + * @param Attr_Handle Handle of the attribute whose security permission has to be modified + * Values: + * - 0x0001 ... 0xFFFF + * @param Security_Permissions Security permission flags. + * Flags: + * - 0x00: None + * - 0x01: AUTHEN_READ (Need authentication to read) + * - 0x04: ENCRY_READ (Need encryption to read) + * - 0x08: AUTHEN_WRITE (need authentication to write) + * - 0x20: ENCRY_WRITE (need encryption to write) + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_set_security_permission_nwk(uint16_t Attr_Handle, + uint8_t Security_Permissions); +/** + * @brief Reads the value of the attribute handle specified from the local GATT database. + * @param Attr_Handle Handle of the attribute to read + * Values: + * - 0x0001 ... 0xFFFF + * @param Offset Offset from which the value needs to be read + * Values: + * - 0 ... 511 + * @param Value_Length_Requested Maximum number of octets to be returned as attribute value + * Values: + * - 0 ... 512 + * @param[out] Length Length of the attribute value + * @param[out] Value_Length Length in octets of the Value parameter + * @param[out] Value Attribute value + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_read_handle_value_nwk(uint16_t Attr_Handle, + uint16_t Offset, + uint16_t Value_Length_Requested, + uint16_t *Length, + uint16_t *Value_Length, + uint8_t Value[]); + +/** + * @brief Reads the value for that kind of attributes that have different values + * for each connection, e.g. the Client Characteristic Configuration Descriptors. + * @param Connection_Handle Connection handle for which the attribute value will be read. + * @param Attr_Handle Handle of the attribute to read + * Values: + * - 0x0001 ... 0xFFFF + * @param[out] Value_Length Length in octets of the Value parameter. + * @param[out] Value Where value is stored. The length of the Value buffer should + * be at least equal to 16 octets. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_read_multiple_instance_handle_value_nwk(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t *Value_Length, + uint8_t Value[]); +/** + * @brief This command sets the access permission for the attribute handle specified. + * @param Attr_Handle Handle of the attribute whose security permission has to be modified + * Values: + * - 0x0001 ... 0xFFFF + * @param Access_Permissions Access permission + * Values: + * - 0x00: None + * - 0x01: READ + * - 0x02: WRITE + * - 0x04: WRITE_NO_RESP + * - 0x08: SIGNED_WRITE + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_set_access_permission_nwk(uint16_t Attr_Handle, + uint8_t Access_Permissions); + +/** + * @brief + * @param Conn_Handle Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + * @param Item_Index + * @param[out] Attr_Handle + * @param[out] Value_Offset + * @param[out] Value_Length Length in octets of the Value parameter + * @param[out] Value Attribute value + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_read_prepare_queue_nwk(uint16_t Conn_Handle, + uint8_t Item_Index, + uint16_t *Attr_Handle, + uint16_t *Value_Offset, + uint16_t *Value_Length, + uint8_t Value[]); +/** + * @brief Start the procedure to write an attribute value. + * When the procedure is completed, a @ref aci_gatt_clt_proc_complete_event event is generated. + * During the procedure, @ref aci_att_clt_prepare_write_resp_event and @ref aci_att_clt_exec_write_resp_event + * events are raised. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Attr_Handle Handle of the attribute to be written + * Values: + * - 0x0001 ... 0xFFFF + * @param Attribute_Val_Length Length of the value to be written + * @param Attribute_Val Value to be written + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_write_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); +/** + * @brief Start the procedure to write a long attribute value. + * When the procedure is completed, a @ref aci_gatt_clt_proc_complete_event event is generated. + * During the procedure, @ref aci_att_clt_prepare_write_resp_event and @ref aci_att_clt_exec_write_resp_event + * events are raised. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Attr_Handle Handle of the attribute to be written + * Values: + * - 0x0001 ... 0xFFFF + * @param Val_Offset Offset at which the attribute has to be written + * Values: + * - 0 ... 511 + * @param Attribute_Val_Length Length of the value to be written + * @param Attribute_Val Value to be written + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_write_long_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); +/** + * @brief Start the procedure to write a characteristic reliably. + * When the procedure is completed, a @ref aci_gatt_clt_proc_complete_event event is generated. + * During the procedure, @ref aci_att_clt_prepare_write_resp_event and @ref aci_att_clt_exec_write_resp_event + * events are raised. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Attr_Handle Handle of the attribute to be written + * Values: + * - 0x0001 ... 0xFFFF + * @param Val_Offset Offset at which the attribute has to be written + * Values: + * - 0 ... 511 + * @param Attribute_Val_Length Length of the value to be written + * @param Attribute_Val Value to be written + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_write_char_reliable_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); + +/** + * @brief + * @param Conn_Handle Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + * @param Attr_Handle Offset from which the value needs to be read or write + * Values: + * - 0 ... 511 + * @param Operation_Type + * Values: + * - 0x00: Read + * - 0x10: Write Request + * - 0x11: Write Command or Signed Write Command + * - 0x12: Prepare Write Request + * @param Error_Code Offset from which the value needs to be read or write + * Values: + * - 0 ... 511 + * @param Data_Offset Offset from which the value needs to be read or write + * Values: + * - 0 ... 511 + * @param Data_Length Length of Data field + * @param Data The data that the client has requested to write + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_authorize_resp_nwk(uint16_t Conn_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Operation_Type, + uint8_t Error_Code, + uint16_t Data_Offset, + uint16_t Data_Length, + uint8_t Data[]); + +/** + * @brief This event is generated if authorization is needed to access the attribute value. + * @ref aci_gatt_srv_authorize_resp_nwk command must be sent in response to this event. + * @param Conn_Handle Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + * @param Attr_Handle + * @param Operation_Type + * Values: + * - 0x00: Read + * - 0x10: Write Request + * - 0x11: Write Command or Signed Write Command + * - 0x12: Prepare Write Request + * @param Attr_Val_Offset Offset from which the value needs to be read or write + * Values: + * - 0 ... 511 + * @param Data_Length Length of Data field + * @param Data The data that the client has requested to write + * @retval None + */ +void aci_gatt_srv_authorize_nwk_event(uint16_t Conn_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Operation_Type, + uint16_t Attr_Val_Offset, + uint8_t Data_Length, + uint8_t Data[]); + +/** + * @brief Response to aci_att_srv_exec_write_req_event. + * @param Conn_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Exec If 1, allow execution of queued writes. If 0 flush all queued + * writes for the given connection handle. + * Values: + * - 0x00: FLUSH + * - 0x01: EXECUTE + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_exec_write_resp_nwk(uint16_t Conn_Handle, + uint16_t CID, + uint8_t Exec); + +#endif diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_l2cap_nwk.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_l2cap_nwk.c new file mode 100644 index 000000000..93a335e01 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_l2cap_nwk.c @@ -0,0 +1,52 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file aci_l2cap_nwk.c + * @author GPM WBL Application Team + * @brief Adaptation layer from L2CAP native interface to network + * processor interface + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include "app_common.h" +#include "ble.h" +#include "aci_l2cap_nwk.h" +#include "dtm_preprocess_events.h" + +#if (CFG_BLE_L2CAP_COS_ENABLED == 1) && (BLESTACK_CONTROLLER_ONLY == 0) + +#define RX_SDU_BUFFER_SIZE 600 + +int aci_l2cap_cos_sdu_data_rx_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credit_Balance, + uint16_t SDU_Length) +{ + tBleStatus ret; + + uint8_t SDU_Data_Buffer[RX_SDU_BUFFER_SIZE]; /* Probably need to move outside of CSTACK. */ + uint16_t SDU_Length_extracted = 0x0000; + + ret = aci_l2cap_cos_sdu_data_extract(Connection_Handle, CID, sizeof(SDU_Data_Buffer), SDU_Data_Buffer, &SDU_Length_extracted); + + if(ret == BLE_STATUS_SUCCESS) + { + aci_l2cap_cos_sdu_data_rx_nwk_event(Connection_Handle, CID, RX_Credit_Balance, SDU_Length_extracted, SDU_Data_Buffer); + } + + /* Discard event */ + return 1; +} + +#endif diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_l2cap_nwk.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_l2cap_nwk.h new file mode 100644 index 000000000..b96b9be3d --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_l2cap_nwk.h @@ -0,0 +1,16 @@ + +#ifndef ACI_L2CAP_NWK_H +#define ACI_L2CAP_NWK_H + +void aci_l2cap_cos_sdu_data_rx_nwk_event(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credit_Balance, + uint16_t SDU_Length, + uint8_t SDU_Data[]); + +void aci_l2cap_cos_sdu_data_tx_nwk_event(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Length, + uint16_t TX_Credit_Balance); + +#endif diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.c new file mode 100644 index 000000000..8c6c8fc81 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.c @@ -0,0 +1,275 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file adv_buff_alloc.c + * @author AMS - RF Application team + * @brief Module providing buffer allocation for advertising data. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +#include "app_common.h" +#include "adv_buff_alloc.h" +#include "dm_alloc.h" + +#define NUM_ADV_BUFF_TYPES 3 + +/* Bidimensional array. First dimension for the differetn types of data: + * advertising data, scan response data, periodic advertsing data. */ +struct adv_set_info_s{ + uint8_t handle; + uint8_t *old_buff_data; + uint8_t *curr_buff_data; + uint8_t *next_buff_data; + uint16_t next_buff_len; +}adv_buf_info[NUM_ADV_BUFF_TYPES][CFG_BLE_NUM_ADV_SETS]; + +/** +* @brief Initialize the module for buffer allocation. Mandatory before any use of the module. +* @retval None +*/ +void adv_buff_init(void) +{ + uint8_t i, j; + + for(i = 0; i < NUM_ADV_BUFF_TYPES; i++) + for(j = 0; j < CFG_BLE_NUM_ADV_SETS; j++) + adv_buf_info[i][j].handle = 0xFF; +} + +/** +* @brief Retrieve buffer info +* @param handle Advertising handle +* @param data_type Type of advertising data (see @ref ADV_DATA_TYPES) +* @retval It returns the pointer to the buffer info structure +*/ +static struct adv_set_info_s *search_handle(uint8_t handle, uint8_t data_type) +{ + int i; + + /* Just a check, but this should not happen. */ + if(data_type >= NUM_ADV_BUFF_TYPES) + return NULL; + + for(i = 0; i < CFG_BLE_NUM_ADV_SETS; i++){ + if(adv_buf_info[data_type][i].handle == handle) + return &adv_buf_info[data_type][i]; + } + return NULL; +} + +/** +* @brief Check if a new buffer is allocated with data not yet passed to the stack (i.e. buffer not yet activated). +* @param handle Advertising handle +* @param data_type Type of advertising data (see @ref ADV_DATA_TYPES) +* @retval It returns TRUE if there is a new buffer to be activated. +*/ +uint8_t new_buff_pending(uint8_t handle, uint8_t data_type) +{ + struct adv_set_info_s *info; + + info = search_handle(handle, data_type); + + if(info == NULL || info->next_buff_data == NULL){ + return FALSE; + } + else { + return TRUE; + } + +} + +/** +* @brief It allocates a buffer for advertising or scan response data. +* @param handle Advertising handle +* @param buffer_len New length to be allocated +* @param extend If 0, it allocates a new buffer for the given advertising set, after having been +* freed any previously allocated buffer. +* If 1, increase the size of the current block allocated for the advertising set, possibly +* allocating a new block different from the previous one (in this case with a different address). +* @param[out] old_buff_len Size of the old buffer in case of an extension, otherwise 0. +* @param data_type Type of advertising data (see @ref ADV_DATA_TYPES) +* @retval It returns the pointer to the entire buffer. +*/ +uint8_t *adv_buff_alloc(uint8_t handle, uint16_t buffer_len, uint8_t extend, uint16_t *old_buff_len, uint8_t data_type) +{ + struct adv_set_info_s *info; + + *old_buff_len = 0; + + info = search_handle(handle, data_type); + if(info == NULL){ + // No existing handle found. Search free locations. + info = search_handle(0xFF, data_type); + if(info){ + info->handle = handle; + info->old_buff_data = NULL; + info->curr_buff_data = NULL; + info->next_buff_data = NULL; + info->next_buff_len = 0; + } + else { + // No free locations + return NULL; + } + } + + if(!extend){ // New allocation + + if(info->old_buff_data) // A buffer which still need to be freed. Do not allow new allocations. + return NULL; + + if(info->next_buff_data) // A buffer has been previously allocated + dm_free(info->next_buff_data); + + if(buffer_len) + info->next_buff_data = dm_alloc(buffer_len); + else + info->next_buff_data = NULL; + if(info->next_buff_data) + info->next_buff_len = buffer_len; + else + info->next_buff_len = 0; + } + else { // Reallocation + uint8_t *buffer; + if(!info->next_buff_data) // No buffer previously allocated + return NULL; + buffer = dm_realloc(info->next_buff_data, info->next_buff_len + buffer_len); + if(buffer){ + info->next_buff_data = buffer; + *old_buff_len = info->next_buff_len; + info->next_buff_len += buffer_len; + } + else { + dm_free(info->next_buff_data); + info->next_buff_data = 0; + info->next_buff_len = 0; + } + } + return info->next_buff_data; +} + +/** +* @brief Free the buffer that is currently active. +* @param handle Advertising handle +* @param data_type Type of advertising data (see @ref ADV_DATA_TYPES) +* @retval None +*/ +void adv_buff_free_current(uint8_t handle, uint8_t data_type) +{ + struct adv_set_info_s *info; + + info = search_handle(handle, data_type); + if(info == NULL) + return; + + dm_free(info->curr_buff_data); + info->curr_buff_data = NULL; +} + +/** +* @brief Free the buffer that is allocated to hold next data +* @param handle Advertising handle +* @param data_type Type of advertising data (see @ref ADV_DATA_TYPES) +* @retval None +*/ +void adv_buff_free_next(uint8_t handle, uint8_t data_type) +{ + struct adv_set_info_s *info; + + info = search_handle(handle, data_type); + if(info == NULL) + return; + + dm_free(info->next_buff_data); + info->next_buff_data = NULL; + info->next_buff_len = 0; +} + +/** +* @brief Free the old buffer, which was waiting to be abandoned by the stack +* @param buff Pointer to the buffer +* @retval None +*/ +void adv_buff_free_old(uint8_t *buff) +{ + uint8_t i, j; + + if(buff == NULL) + return; + + for(j = 0; j < NUM_ADV_BUFF_TYPES; j++){ + + for(i = 0; i < CFG_BLE_NUM_ADV_SETS; i++){ + if(adv_buf_info[j][i].old_buff_data == buff){ + dm_free(buff); + adv_buf_info[j][i].old_buff_data = NULL; + return; + } + /* Check also if it has been requested to free the current buffer. + This may happen if the advertising set is removed. */ + if(adv_buf_info[j][i].curr_buff_data == buff){ + /* Free buffers and remove info about this handle, since advertising set + has been removed */ + dm_free(adv_buf_info[j][i].curr_buff_data); + adv_buf_info[j][i].curr_buff_data = NULL; + //dm_free(adv_buf_info[i].old_buff_data); This line should not be needed. + adv_buf_info[j][i].handle = 0xFF; + return; + } + } + + } +} + +/** +* @brief Function to be called when the new allocated buffer is successfully passed +* to the stack to be the new buffer. The new allocated buffer is now +* considered as the current buffer in use by the stack. If needed, call +* adv_buff_deactivate_current() before calling this function. +* @param handle Advertising handle +* @param data_type Type of advertising data (see @ref ADV_DATA_TYPES) +* @retval None +*/ +void adv_buff_activate_next(uint8_t handle, uint8_t data_type) +{ + struct adv_set_info_s *info; + + info = search_handle(handle, data_type); + if(info == NULL) + return; + + info->curr_buff_data = info->next_buff_data; + info->next_buff_data = NULL; + info->next_buff_len = 0; +} + +/** +* @brief Function to be called after having been informed the stack that the current + buffer does not have to be used anymore. +* @param handle Advertising handle +* @param data_type Type of advertising data (see @ref ADV_DATA_TYPES) +* @retval None +*/ +void adv_buff_deactivate_current(uint8_t handle, uint8_t data_type) +{ + struct adv_set_info_s *info; + + info = search_handle(handle, data_type); + if(info == NULL) + return; + + info->old_buff_data = info->curr_buff_data; // What is in old_buff_data has to be freed. + info->curr_buff_data = NULL; +} + diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.h new file mode 100644 index 000000000..5c2726650 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.h @@ -0,0 +1,23 @@ +#ifndef _ADV_BUFF_ALLOC_H_ +#define _ADV_BUFF_ALLOC_H_ + +/** @defgroup ADV_DATA_TYPES + * @{ + */ +#define ADV_DATA 0 +#define SCAN_RESP_DATA 1 +#define PERIODIC_ADV_DATA 2 +/** + * @} + */ + +void adv_buff_init(void); +uint8_t *adv_buff_alloc(uint8_t handle, uint16_t buffer_len, uint8_t extend, uint16_t *old_buff_len, uint8_t data_type); +void adv_buff_free_current(uint8_t handle, uint8_t data_type); +void adv_buff_free_next(uint8_t handle, uint8_t data_type); +void adv_buff_free_old(uint8_t *buff); +void adv_buff_activate_next(uint8_t handle, uint8_t data_type); +void adv_buff_deactivate_current(uint8_t handle, uint8_t data_type); +uint8_t new_buff_pending(uint8_t handle, uint8_t data_type); + +#endif /* _ADV_BUFF_ALLOC_H_ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc_tiny.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc_tiny.c new file mode 100644 index 000000000..9a2c7e4a0 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc_tiny.c @@ -0,0 +1,79 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file adv_buff_alloc_tiny.c + * @author AMS - RF Application team + * @brief Module providing a simplified scheme for buffer allocation for + * legacy advertising. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +#include +#include +#include "adv_buff_alloc_tiny.h" + +uint8_t buffer[NUM_BUFFERS][31]; + +/* Variable used to keep which buffer is used and which one is not in use by the link layer. */ +uint8_t used_buffers_msk; + +#define BUFFER_IN_USE(i) (used_buffers_msk & (1< +#include +#include "main.h" +#include "stm32wb0x.h" +#include "ble.h" +#include "gap_profile.h" +#include "app_ble.h" +#include "stm32wb0x_hal_radio_timer.h" +#include "bleplat.h" +#include "nvm_db.h" +#include "blenvm.h" +#include "pka_manager.h" +#include "stm32_seq.h" +#include "transport_layer.h" +#include "miscutil.h" +#include "aci_l2cap_nwk.h" +#include "aci_gatt_nwk.h" +#include "dm_alloc.h" +#include "aci_adv_nwk.h" +#include "dtm_burst.h" +/* Add aci_blue_initialized_event() prototype */ +void aci_blue_initialized_event(uint8_t Reason_Code); + +/* Add aci_blue_crash_info_event() prototype */ +void aci_blue_crash_info_event(uint8_t Crash_Type, + uint32_t SP, + uint32_t R0, + uint32_t R1, + uint32_t R2, + uint32_t R3, + uint32_t R12, + uint32_t LR, + uint32_t PC, + uint32_t xPSR, + uint8_t Debug_Data_Length, + uint8_t Debug_Data[]); + +uint16_t num_packets = 0; +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ +/* Private define ------------------------------------------------------------*/ +#define RESET_REASON_WDG ((uint8_t)0x05) +#define RESET_REASON_LOCKUP ((uint8_t)0x06) +#define RESET_REASON_POR_BOR ((uint8_t)0x07) +#define RESET_REASON_CRASH ((uint8_t)0x08) +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ +/* Private variables ---------------------------------------------------------*/ + +NO_INIT(uint32_t dyn_alloc_a[BLE_DYN_ALLOC_SIZE>>2]); + +NO_INIT(uint32_t aci_gatt_adv_nwk_buffer[CFG_BLE_GATT_ADV_NWK_BUFFER_SIZE>>2]); + +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External variables --------------------------------------------------------*/ + +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN PF */ + +/* USER CODE END PF */ + +/* Functions Definition ------------------------------------------------------*/ +void ModulesInit(void) +{ + BLENVM_Init(); + if (PKAMGR_Init() == PKAMGR_ERROR) + { + Error_Handler(); + } +} + +void BLE_Init(void) +{ + tBleStatus ret; + + BLE_STACK_InitTypeDef BLE_STACK_InitParams = { + .BLEStartRamAddress = (uint8_t*)dyn_alloc_a, + .TotalBufferSize = BLE_DYN_ALLOC_SIZE, + .NumAttrRecords = CFG_BLE_NUM_GATT_ATTRIBUTES, + .MaxNumOfClientProcs = CFG_BLE_NUM_OF_CONCURRENT_GATT_CLIENT_PROC, + .NumOfRadioTasks = CFG_BLE_NUM_RADIO_TASKS, + .NumOfEATTChannels = CFG_BLE_NUM_EATT_CHANNELS, + .NumBlockCount = CFG_BLE_MBLOCKS_COUNT, + .ATT_MTU = CFG_BLE_ATT_MTU_MAX, + .MaxConnEventLength = CFG_BLE_CONN_EVENT_LENGTH_MAX, + .SleepClockAccuracy = CFG_BLE_SLEEP_CLOCK_ACCURACY, + .NumOfAdvDataSet = CFG_BLE_NUM_ADV_SETS, + .NumOfSubeventsPAwR = CFG_BLE_NUM_PAWR_SUBEVENTS, + .MaxPAwRSubeventDataCount = CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX, + .NumOfAuxScanSlots = CFG_BLE_NUM_AUX_SCAN_SLOTS, + .FilterAcceptListSizeLog2 = CFG_BLE_FILTER_ACCEPT_LIST_SIZE_LOG2, + .L2CAP_MPS = CFG_BLE_COC_MPS_MAX, + .L2CAP_NumChannels = CFG_BLE_COC_NBR_MAX, + .NumOfSyncSlots = CFG_BLE_NUM_SYNC_SLOTS, + .CTE_MaxNumAntennaIDs = CFG_BLE_NUM_CTE_ANTENNA_IDS_MAX, + .CTE_MaxNumIQSamples = CFG_BLE_NUM_CTE_IQ_SAMPLES_MAX, + .NumOfSyncBIG = CFG_BLE_NUM_SYNC_BIG_MAX, + .NumOfBrcBIG = CFG_BLE_NUM_BRC_BIG_MAX, + .NumOfSyncBIS = CFG_BLE_NUM_SYNC_BIS_MAX, + .NumOfBrcBIS = CFG_BLE_NUM_BRC_BIS_MAX, + .NumOfCIG = CFG_BLE_NUM_CIG_MAX, + .NumOfCIS = CFG_BLE_NUM_CIS_MAX, + .isr0_fifo_size = CFG_BLE_ISR0_FIFO_SIZE, + .isr1_fifo_size = CFG_BLE_ISR1_FIFO_SIZE, + .user_fifo_size = CFG_BLE_USER_FIFO_SIZE + }; + + /* Bluetooth LE stack init */ + ret = BLE_STACK_Init(&BLE_STACK_InitParams); + if (ret != BLE_STATUS_SUCCESS) { + Error_Handler(); + } +} + +void BLEStack_Process_Schedule(void) +{ + /* Keep BLE Stack Process priority low, since there are limited cases + where stack wants to be rescheduled for busy waiting. */ + UTIL_SEQ_SetTask( 1U << CFG_TASK_BLE_STACK, CFG_SEQ_PRIO_1); +} + +static void BLEStack_Process(void) +{ + APP_DEBUG_SIGNAL_SET(APP_STACK_PROCESS); + BLE_STACK_Tick(); + + if(BLE_STACK_SleepCheck() == 0) + { + BLEStack_Process_Schedule(); + } + APP_DEBUG_SIGNAL_RESET(APP_STACK_PROCESS); +} + +void VTimer_Process(void) +{ + HAL_RADIO_TIMER_Tick(); +} + +void VTimer_Process_Schedule(void) +{ + UTIL_SEQ_SetTask( 1U << CFG_TASK_VTIMER, CFG_SEQ_PRIO_0); +} + +void NVM_Process(void) +{ + NVMDB_Tick(); +} + +void NVM_Process_Schedule(void) +{ + UTIL_SEQ_SetTask( 1U << CFG_TASK_NVM, CFG_SEQ_PRIO_1); +} + +void TM_Process_Schedule(void) +{ + UTIL_SEQ_SetTask( 1U << CFG_TASK_TM, CFG_SEQ_PRIO_1); +} + +void TM_Process(void) +{ + transport_layer_tick(); +} + +void BURST_Process_Schedule(void) +{ + UTIL_SEQ_SetTask( 1U << CFG_TASK_BURST, CFG_SEQ_PRIO_1); +} + +void BURST_Process(void) +{ + BURST_Tick(); +} + +/* Function called from PKA_IRQHandler() context. */ +void PKAMGR_IRQCallback(void) +{ + BLEStack_Process_Schedule(); +} + +/* Function called from RADIO_TIMER_TXRX_WKUP_IRQHandler() context. */ +void HAL_RADIO_TIMER_TxRxWakeUpCallback(void) +{ + VTimer_Process_Schedule(); + BLEStack_Process_Schedule(); +} + +/* Function called from RADIO_TIMER_CPU_WKUP_IRQHandler() context. */ +void HAL_RADIO_TIMER_CpuWakeUpCallback(void) +{ + VTimer_Process_Schedule(); + BLEStack_Process_Schedule(); +} + +/* Function called from RADIO_TXRX_IRQHandler() context. */ +void HAL_RADIO_TxRxCallback(uint32_t flags) +{ + BLE_STACK_RadioHandler(flags); + + BLEStack_Process_Schedule(); + VTimer_Process_Schedule(); + NVM_Process_Schedule(); +} + +/* Functions Definition ------------------------------------------------------*/ +void APP_BLE_Init(void) +{ + crash_info_t crash_info; + /* USER CODE BEGIN APP_BLE_Init_1 */ + + /* USER CODE END APP_BLE_Init_1 */ + + UTIL_SEQ_RegTask(1U << CFG_TASK_BLE_STACK, UTIL_SEQ_RFU, BLEStack_Process); + UTIL_SEQ_RegTask(1U << CFG_TASK_VTIMER, UTIL_SEQ_RFU, VTimer_Process); + UTIL_SEQ_RegTask(1U << CFG_TASK_NVM, UTIL_SEQ_RFU, NVM_Process); + UTIL_SEQ_RegTask(1U << CFG_TASK_TM, UTIL_SEQ_RFU, TM_Process); + UTIL_SEQ_RegTask(1U << CFG_TASK_BURST, UTIL_SEQ_RFU, BURST_Process); + + ModulesInit(); + + /* Initialization of HCI & GATT & GAP layer */ + BLE_Init(); + + /* Need to call stack process at least once. */ + BLEStack_Process_Schedule(); + + /* Used by aci_gatt_nwk and adv_buff_alloc libraries. */ + dm_init(CFG_BLE_GATT_ADV_NWK_BUFFER_SIZE, aci_gatt_adv_nwk_buffer); + + aci_adv_nwk_init(); + +#if (BLESTACK_CONTROLLER_ONLY == 0) + ACI_gatt_nwk_init(CFG_BLE_ATT_QUEUED_WRITE_SIZE); +#endif + + transport_layer_init(); + + /* Get crash info */ + GetCrashInfo(&crash_info); + + if(RAM_VR.Reserved[0] == 0x01){ + // Send a command complete event for HCI_Reset + uint8_t buffer_out[] = {0x04,0x0E,0x04,0x01,0x03,0x0C,0x00}; + RAM_VR.Reserved[0] = 0x00; + send_event(buffer_out,7,-1); + } + +#if (BLESTACK_CONTROLLER_ONLY == 0) + + uint8_t reset_reason = 0x01; + + /* EVT_BLUE_INITIALIZED */ + /* Check the reset reason */ + if(RAM_VR.ResetReason & RCC_CSR_WDGRSTF){ + reset_reason = RESET_REASON_WDG; + } + else if(RAM_VR.ResetReason & RCC_CSR_LOCKUPRSTF) { + reset_reason = RESET_REASON_LOCKUP; + } + else if(RAM_VR.ResetReason & RCC_CSR_PORRSTF) { + reset_reason = RESET_REASON_POR_BOR; + } + + if((crash_info.signature&0xFFFF0000) == CRASH_SIGNATURE_BASE) { + reset_reason = RESET_REASON_CRASH; + } + + aci_blue_initialized_event(reset_reason); + +#endif + + if((crash_info.signature&0xFFFF0000) == CRASH_SIGNATURE_BASE) { + aci_blue_crash_info_event(crash_info.signature&0xFF, + crash_info.SP, + crash_info.R0, + crash_info.R1, + crash_info.R2, + crash_info.R3, + crash_info.R12, + crash_info.LR, + crash_info.PC, + crash_info.xPSR, + 0, + NULL); + } + + /* USER CODE BEGIN APP_BLE_Init_2 */ + + /* USER CODE END APP_BLE_Init_2 */ + + return; +} + +/* Implementation of event hooks. */ + +int aci_l2cap_cos_disconnection_complete_event_preprocess(uint16_t Connection_Handle, + uint16_t CID) +{ + ACI_gatt_nwk_disconnection(Connection_Handle, CID); + + return 0; +} + +int aci_gatt_srv_attribute_modified_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attr_Data_Length, + uint8_t Attr_Data[]) +{ + return BURST_WriteReceived(Connection_Handle, Attr_Handle, Attr_Data_Length, Attr_Data); +} + +int aci_gatt_clt_notification_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attribute_Handle, + uint16_t Attribute_Value_Length, + uint8_t Attribute_Value[]) +{ + return BURST_NotificationReceived(Connection_Handle, Attribute_Handle, Attribute_Value_Length, Attribute_Value); +} + +int aci_gatt_tx_pool_available_event_preprocess(uint16_t Connection_Handle, + uint16_t Available_Buffers) +{ + if(BURST_BufferAvailableNotify()) + { + /* BURST is currently enabled. */ + BURST_Process_Schedule(); + + return 1; + } + + return 0; +} + +void BURST_StartCallback(void) +{ + BURST_Process_Schedule(); +} + +void TL_ProcessReqCallback(void) +{ + TM_Process_Schedule(); +} + +void TL_ResetReqCallback(void) +{ + RAM_VR.Reserved[0] = 0x01; // Remember to send a command complete after reset is completed. + NVIC_SystemReset(); +} + +/** \endcond + */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h new file mode 100644 index 000000000..11bc02f0c --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h @@ -0,0 +1,136 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file app_ble.h + * @author MCD Application Team + * @brief Header for ble application + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_BLE_H +#define APP_BLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "ble_events.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ + +typedef enum +{ + APP_BLE_IDLE, + APP_BLE_LP_CONNECTING, + APP_BLE_CONNECTED_SERVER, + APP_BLE_CONNECTED_CLIENT, + APP_BLE_ADV_FAST, + APP_BLE_ADV_LP, +/* USER CODE BEGIN ConnStatus_t */ + +/* USER CODE END ConnStatus_t */ +} APP_BLE_ConnStatus_t; + +typedef enum +{ + PROC_GAP_GEN_PHY_TOGGLE, + PROC_GAP_GEN_CONN_TERMINATE, + PROC_GATT_EXCHANGE_CONFIG, + /* USER CODE BEGIN ProcGapGeneralId_t*/ + + /* USER CODE END ProcGapGeneralId_t */ +}ProcGapGeneralId_t; + +typedef enum +{ + PROC_GAP_PERIPH_ADVERTISE_START_LP, + PROC_GAP_PERIPH_ADVERTISE_START_FAST, + PROC_GAP_PERIPH_ADVERTISE_STOP, + PROC_GAP_PERIPH_ADVERTISE_DATA_UPDATE, + PROC_GAP_PERIPH_CONN_PARAM_UPDATE, + PROC_GAP_PERIPH_CONN_TERMINATE, + + PROC_GAP_PERIPH_SET_BROADCAST_MODE, + /* USER CODE BEGIN ProcGapPeripheralId_t */ + + /* USER CODE END ProcGapPeripheralId_t */ +}ProcGapPeripheralId_t; + +typedef enum +{ + PROC_GAP_CENTRAL_SCAN_START, + PROC_GAP_CENTRAL_SCAN_TERMINATE, + /* USER CODE BEGIN ProcGapCentralId_t */ + + /* USER CODE END ProcGapCentralId_t */ +}ProcGapCentralId_t; + +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* External variables --------------------------------------------------------*/ + +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Exported macro ------------------------------------------------------------*/ +#define SCAN_WIN_MS(x) ((uint16_t)((x)/0.625f)) +#define SCAN_INT_MS(x) ((uint16_t)((x)/0.625f)) +#define CONN_INT_MS(x) ((uint16_t)((x)/1.25f)) +#define CONN_SUP_TIMEOUT_MS(x) ((uint16_t)((x)/10.0f)) +#define CONN_CE_LENGTH_MS(x) ((uint16_t)((x)/0.625f)) + +/* STM32WB09 Transparent Mode/DTM version (Bluetooth LE stack v4.0) */ +#define DTM_FW_VERSION_MAJOR 1 +#define DTM_FW_VERSION_MINOR 0 +#define DTM_FW_VERSION_PATCH 0 + +#define UART_INTERFACE + +#ifdef UART_INTERFACE +#define DTM_VARIANT 1 +#endif +#ifdef SPI_INTERFACE +#define DTM_VARIANT 2 +#endif +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions ---------------------------------------------*/ +void ModulesInit(void); +void BLE_Init(void); +void APP_BLE_Init(void); +/* USER CODE BEGIN EF */ + +/* USER CODE END EF */ + +#ifdef __cplusplus +} +#endif + +#endif /*APP_BLE_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/ble_conf.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/ble_conf.h new file mode 100644 index 000000000..a05e4d7ff --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/ble_conf.h @@ -0,0 +1,42 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file ble_conf.h + * @author MCD Application Team + * @brief Configuration file for BLE Middleware. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef BLE_CONF_H +#define BLE_CONF_H + +#include "app_conf.h" + +/****************************************************************************** + * + * BLE Event Handler configuration + * + ******************************************************************************/ + +/** + * There is one handler per BLE service + */ +#define BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS (10) + +/* USER CODE BEGIN ble_conf_1 */ + +/* USER CODE END ble_conf_1 */ + +#endif /*BLE_CONF_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/ble_dbg_conf.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/ble_dbg_conf.h new file mode 100644 index 000000000..360082375 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/ble_dbg_conf.h @@ -0,0 +1,40 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file ble_dbg_conf.h + * @author MCD Application Team + * @brief Debug configuration file for BLE Middleware. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef BLE_DBG_CONF_H +#define BLE_DBG_CONF_H + +/** + * Enable or Disable traces from BLE + */ + +#define BLE_DBG_APP_EN 0 + +/** + * Macro definition + */ +#if (BLE_DBG_APP_EN != 0) +#define BLE_DBG_APP_MSG PRINT_MESG_DBG +#else +#define BLE_DBG_APP_MSG PRINT_NO_MESG +#endif + +#endif /*BLE_DBG_CONF_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/board_cmd.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/board_cmd.c new file mode 100644 index 000000000..1dd3d2298 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/board_cmd.c @@ -0,0 +1,81 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file board_cmd.c + * @author GPM WBL Application Team + * @brief Module that implements board commands + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include "stm32wb0x.h" +#include "board_cmd.h" +#include "hci_parser.h" +#include "transport_layer.h" + +#define RESP_VENDOR_CODE_OFFSET 1 +#define RESP_LEN_OFFSET_LSB 2 +#define RESP_LEN_OFFSET_MSB 3 +#define RESP_CMDCODE_OFFSET 4 +#define RESP_STATUS_OFFSET 5 +#define RESP_PARAM_OFFSET 6 + +/* Types of vendor codes */ +#define ERROR 0 +/* Error codes */ +#define UNKNOWN_COMMAND 0x01 +#define INVALID_PARAMETERS 0x12 + +#define RESPONSE 1 +/* end of vendor codes */ + +/* Command parser + * bytes + * 1 Type of packet (FF for special command) + * 1 cmdcode + * 2 cmd length (length of arguments) + * variable payload + */ + /* Actually only for UART INTERFACE */ + +uint16_t parse_cmd(uint8_t *hci_buffer, uint16_t hci_pckt_len, uint8_t *buffer_out) +{ + uint16_t len = 0; + buffer_out[0] = HCI_VENDOR_PKT; + buffer_out[RESP_VENDOR_CODE_OFFSET] = RESPONSE; + buffer_out[RESP_CMDCODE_OFFSET] = hci_buffer[HCI_VENDOR_CMDCODE_OFFSET]; + buffer_out[RESP_STATUS_OFFSET] = 0; + + switch(hci_buffer[HCI_VENDOR_CMDCODE_OFFSET]) + { + case SYSTEM_RESET: + NVIC_SystemReset(); + break; +#if defined(STM32WB05N) + case HW_BOOTLOADER: + RAM_VR.BlueFlag = BLUE_FLAG_RAM_RESET; + NVIC_SystemReset(); + break; +#endif + default: + buffer_out[RESP_VENDOR_CODE_OFFSET] = ERROR; + buffer_out[RESP_STATUS_OFFSET] = UNKNOWN_COMMAND; + } + + len += 2; // Status and Command code + PACK_2_BYTE_PARAMETER(buffer_out+RESP_LEN_OFFSET_LSB,len); + len += RESP_CMDCODE_OFFSET; + + return len; +} + diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/board_cmd.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/board_cmd.h new file mode 100644 index 000000000..414eea6ff --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/board_cmd.h @@ -0,0 +1,47 @@ +#ifndef _CMD_H_ +#define _CMD_H_ + +#include + +#define UNPACK_2_BYTE_PARAMETER(ptr) \ + (uint16_t)((uint16_t)(*((uint8_t *)ptr))) | \ + (uint16_t)((((uint16_t)(*((uint8_t *)ptr + 1))) << 8)) + +#define UNPACK_3_BYTE_PARAMETER(ptr) \ + (uint32_t)(((uint32)(*((uint8_t *)ptr))) << 16) | \ + (uint32_t)(((uint32)(*((uint8_t *)ptr + 1))) << 8) | \ + (uint32_t)(((uint32)(*((uint8_t *)ptr + 2)))) + +#define UNPACK_4_BYTE_PARAMETER(ptr) \ + (uint32_t)(((uint32)(*((uint8_t *)ptr))) << 24) | \ + (uint32_t)(((uint32)(*((uint8_t *)ptr + 1))) << 16) | \ + (uint32_t)(((uint32)(*((uint8_t *)ptr + 2))) << 8) | \ + (uint32_t)(((uint32)(*((uint8_t *)ptr + 3)))) + +#define PACK_2_BYTE_PARAMETER(ptr, param) do{\ + *((uint8_t *)ptr) = (uint8_t)(param); \ + *((uint8_t *)ptr+1) = (uint8_t)(param)>>8; \ + }while(0) + +#define PACK_3_BYTE_PARAMETER(ptr, param) do{\ + *((uint8_t *)ptr) = (uint8_t)(param); \ + *((uint8_t *)ptr+1) = (uint8_t)(param)>>8; \ + *((uint8_t *)ptr+2) = (uint8_t)(param)>>16; \ + }while(0) + +#define PACK_4_BYTE_PARAMETER(ptr, param) do{\ + *((uint8_t *)ptr) = (uint8_t)(param); \ + *((uint8_t *)ptr+1) = (uint8_t)(param)>>8; \ + *((uint8_t *)ptr+2) = (uint8_t)(param)>>16; \ + *((uint8_t *)ptr+3) = (uint8_t)(param)>>24; \ + }while(0) + +/* Commands */ +#define SYSTEM_RESET (0x04) +#if defined(STM32WB05N) +#define HW_BOOTLOADER (0x05) +#endif + +uint16_t parse_cmd(uint8_t *hci_buffer, uint16_t hci_pckt_len, uint8_t *buffer_out); + +#endif /* _CMD_H_ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dm_alloc.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dm_alloc.c new file mode 100644 index 000000000..c1a67a2c3 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dm_alloc.c @@ -0,0 +1,374 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file dm_alloc.c + * @author GPM WBL Application Team + * @brief Dynamic Memory Allocator + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/****************************************************************************** + * INCLUDE HEADER FILES + *****************************************************************************/ +#include "dm_alloc.h" +#include "osal.h" +#include + +/****************************************************************************** + * LOCAL MACROS + *****************************************************************************/ +#define ALIGN_UPTO_32BITS(VAL) (((((unsigned int)(VAL)) - 1U) | (sizeof(uint32_t) - 1U)) + 1U) +#define DM_SLICE_THRESHOLD (3 * sizeof(db_alloc_header_t)) +#define DM_FREE 0x00 +#define DM_ALLOC 0x01 +/*#define DM_DEBUG (1) */ +#if defined(DM_DEBUG) +#define DM_DEBUG_STAMP (0xBEAF) +#endif + +#define MIN(a,b) (((a) < (b))? (a) : (b)) + +/****************************************************************************** + * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS) + *****************************************************************************/ +typedef struct db_alloc_header_s { + uint16_t buffer_size; + uint16_t flags; + uint32_t buffer_a[]; +} db_alloc_header_t; + +typedef struct db_free_header_s { + uint16_t buffer_size; + uint16_t flags; + struct db_free_header_s *next; + uint32_t buffer_a[]; +} dm_free_header_t; + +typedef struct dm_ctx_s { +#if defined(DM_DEBUG) + uint16_t alloc_size; + uint16_t alloc_max_size; +#endif + dm_free_header_t *head; + uint32_t *alloc_space_p; + uint16_t buffer_size; +} dm_ctx_t; + +/****************************************************************************** + * LOCAL FUNCTION PROTOTYPES + *****************************************************************************/ +/****************************************************************************** + * Local Variables + *****************************************************************************/ +static dm_ctx_t dm_ctx; + +void dm_init(uint16_t buffer_size, uint32_t *buffer_p) +{ + dm_ctx.alloc_space_p = (void *)buffer_p; + dm_ctx.head = (dm_free_header_t *)buffer_p; + dm_ctx.head->buffer_size = buffer_size; + dm_ctx.buffer_size = buffer_size; + dm_ctx.head->flags = DM_FREE; +#if defined(DM_DEBUG) + dm_ctx.alloc_size = 0U; + dm_ctx.alloc_max_size = 0U; +#endif + dm_ctx.head->next = NULL; +} + +static void db_extract_from_free_list(dm_free_header_t *entry_p) +{ + dm_free_header_t *e_p; + +#if defined(DM_DEBUG) + if (entry_p->flags != DM_FREE) + { + while (1) + ; + } +#endif + if (entry_p == dm_ctx.head) + { + dm_ctx.head = entry_p->next; + } + else + { + e_p = dm_ctx.head; + while (e_p != NULL) + { + if (e_p->next == entry_p) + { + e_p->next = entry_p->next; + break; + } + e_p = e_p->next; + } + } +} + +static void db_add_to_free_list(dm_free_header_t *free_entry_p) +{ + dm_free_header_t *prev_p; + + if (free_entry_p != NULL) + { +#if defined(DM_DEBUG) + if (free_entry_p->flags != DM_FREE) + { + while (1) + ; + } +#endif + prev_p = NULL; + if (dm_ctx.head == NULL) + { + /** + * The free list is empty. Assign the new entry to the list. + */ + dm_ctx.head = free_entry_p; + } + else + { + if ((uintptr_t)free_entry_p < (uintptr_t)dm_ctx.head) + { + /** + * Insert the new element at the head of the list. + */ + free_entry_p->next = dm_ctx.head; + dm_ctx.head = free_entry_p; + } + else + { + prev_p = dm_ctx.head; + while (prev_p->next != NULL) + { + /** + * The free list is ordered by index (address) then search + * into the list to find the previous node. + */ + if ((uintptr_t)prev_p->next > (uintptr_t)free_entry_p) + { + break; + } + prev_p = prev_p->next; + } + + /** + * Insert the new element. + */ + free_entry_p->next = prev_p->next; + prev_p->next = free_entry_p; + + /** + * Try to make the new free entry coalesce with the previous. + */ + if (((uintptr_t)prev_p + prev_p->buffer_size) == + (uintptr_t)free_entry_p) + { + prev_p->next = free_entry_p->next; + prev_p->buffer_size += free_entry_p->buffer_size; + } + } + + /** + * Try to make the new free entry coalesce with the next. + */ + if (((uintptr_t)free_entry_p + free_entry_p->buffer_size) == + (uintptr_t)free_entry_p->next) + { + dm_free_header_t *ne_p; + + ne_p = free_entry_p->next; + free_entry_p->next = ne_p->next; + free_entry_p->buffer_size += ne_p->buffer_size; + } + } + } +} + +/* Release part of a free block and add it to the list of free blocks. + Returns the size of the slot not freed. */ +static uint16_t dm_slice(dm_free_header_t *free_entry_p, uint16_t min_size) +{ + uint16_t slice_size; + + slice_size = free_entry_p->buffer_size - min_size; + if (slice_size > DM_SLICE_THRESHOLD) + { + dm_free_header_t *slice_p; + + slice_p = (dm_free_header_t *)&free_entry_p->buffer_a[(min_size - + sizeof(dm_free_header_t)) >> 2]; + slice_p->buffer_size = slice_size; + slice_p->flags = DM_FREE; + slice_p->next = NULL; + db_add_to_free_list(slice_p); + return min_size; + } + + return free_entry_p->buffer_size; +} + +void *dm_alloc(uint16_t size) +{ + uint16_t alloc_size; + dm_free_header_t *entry_p, *best_entry_p; + + best_entry_p = NULL; + entry_p = dm_ctx.head; + alloc_size = (uint16_t)(ALIGN_UPTO_32BITS(size) + sizeof(db_alloc_header_t)); +#if defined(DM_DEBUG) + if (entry_p != NULL) + { + if (entry_p->flags != DM_FREE) + { + while (1) + ; + } + } +#endif + while (entry_p != NULL) + { + /** + * Best fit strategy: search for the entry that has the size closer to + * the requested value. + */ + if (entry_p->buffer_size >= alloc_size) + { + if ((best_entry_p == NULL) || + ((best_entry_p != NULL) && + (best_entry_p->buffer_size > entry_p->buffer_size))) + { + best_entry_p = entry_p; + } + } + entry_p = entry_p->next; + } + + if (best_entry_p != NULL) + { + db_alloc_header_t *alloc_entry_p; + + /** + * Detach entry by free list. + */ + db_extract_from_free_list(best_entry_p); + + /** + * If the extracted entry has a size "much" greater then the + * requested one then slice it releasing the not requested space. + */ + best_entry_p->buffer_size = dm_slice(best_entry_p, alloc_size); + + alloc_entry_p = (db_alloc_header_t *)best_entry_p; +#if defined(DM_DEBUG) + if (alloc_entry_p->flags != DM_FREE) + { + while (1) + ; + } + dm_ctx.alloc_size += alloc_size + sizeof(uint32_t); + if (dm_ctx.alloc_size > dm_ctx.alloc_max_size) + { + dm_ctx.alloc_max_size = dm_ctx.alloc_size; + } +#endif + best_entry_p->flags = DM_ALLOC; + + return alloc_entry_p->buffer_a; + } + + return NULL; +} + +void dm_free(void *buffer_p) +{ + if (buffer_p == NULL) + return; + dm_free_header_t *free_entry_p; + uint32_t *buffer32_p = buffer_p; + + free_entry_p = (dm_free_header_t *)(--buffer32_p); + free_entry_p->flags = DM_FREE; + free_entry_p->next = NULL; +#if defined(DM_DEBUG) + dm_ctx.alloc_size -= free_entry_p->buffer_size; +#endif + db_add_to_free_list(free_entry_p); +} + +void *dm_realloc(void *buffer_p, uint16_t size) +{ + uint16_t total_alloc_size; /* Total size that needs to be allocated for new buffer (including existing one). */ + uint16_t add_alloc_size; /* Additional space needed in case allocated memory needs to be increased. */ + dm_free_header_t *entry_p; + uint32_t *next_addr, *new_buffer_p; + uint32_t *buffer32_p = buffer_p; + + db_alloc_header_t *allocated_entry_p = (db_alloc_header_t *)(buffer32_p - 1); + + total_alloc_size = ALIGN_UPTO_32BITS(size) + sizeof(db_alloc_header_t); + + /* Check if current buffer has already the requested size. + If this is the case, try to reduce it. */ + if(allocated_entry_p->buffer_size >= total_alloc_size) + { + allocated_entry_p->buffer_size = dm_slice((dm_free_header_t*)allocated_entry_p, total_alloc_size); + + return buffer_p; + } + + add_alloc_size = total_alloc_size - allocated_entry_p->buffer_size; + + next_addr = &allocated_entry_p->buffer_a[(allocated_entry_p->buffer_size - sizeof(db_alloc_header_t)) >> 2]; + + entry_p = (dm_free_header_t*)next_addr; + + /* Look into next block and check if it is free and has enough space to contain additional data. */ + if(next_addr < dm_ctx.alloc_space_p + dm_ctx.buffer_size && entry_p->flags == DM_FREE) + { + if(entry_p->buffer_size >= add_alloc_size) + { + /* Next contiguous slot is big enough. */ + + db_extract_from_free_list(entry_p); + + allocated_entry_p->buffer_size += dm_slice(entry_p, add_alloc_size); + +#if defined(DM_DEBUG) + dm_ctx.alloc_size += alloc_size + sizeof(uint32_t); + if (dm_ctx.alloc_size > dm_ctx.alloc_max_size) + { + dm_ctx.alloc_max_size = dm_ctx.alloc_size; + } +#endif + return allocated_entry_p->buffer_a; + } + } + + /* No contiguous free memory slot found with enough space. + Need to allocate new slot. */ + + new_buffer_p = dm_alloc(size); + if (new_buffer_p != NULL) + { + /* Copy old data */ + uint16_t old_data_size = allocated_entry_p->buffer_size - sizeof(db_alloc_header_t); + Osal_MemCpy(new_buffer_p, buffer_p, MIN(size, old_data_size)); + dm_free(buffer_p); + } + + return new_buffer_p; +} + diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dm_alloc.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dm_alloc.h new file mode 100644 index 000000000..5c01a4704 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dm_alloc.h @@ -0,0 +1,44 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file dm_alloc.h + * @author GPM WBL Application Team + * @brief Dynamic Memory Allocator + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef __DM_ALLOC_H__ +#define __DM_ALLOC_H__ +/****************************************************************************** + * Includes + *****************************************************************************/ +#include +/****************************************************************************** + * CONSTANT SYMBOLS + *****************************************************************************/ +/****************************************************************************** + * LOCAL MACROS + *****************************************************************************/ +/****************************************************************************** + * TYPES + *****************************************************************************/ +/****************************************************************************** + * FUNCTION PROTOTYPES + *****************************************************************************/ +void dm_init(uint16_t buffer_size, uint32_t *buffer_p); +void *dm_alloc(uint16_t size); +void *dm_realloc(void *buffer_p, uint16_t size); +void dm_free(void *buffer_p); + +#endif diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_burst.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_burst.c new file mode 100644 index 000000000..72feb1de1 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_burst.c @@ -0,0 +1,300 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file dtm_burst.c + * @author GPM WBL Application Team + * @brief Module that implements test burst commands + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include "stm32wb0x.h" +#include "ble.h" +#include "dtm_burst.h" +#include "app_common.h" + +#define OFF 0 +#define NOTIFICATIONS 1 +#define WRITE_COMMANDS 2 + +#if (CFG_BLE_CONNECTION_ENABLED == 1) && (BLESTACK_CONTROLLER_ONLY == 0) + +struct { + uint8_t Enable; // OFF, NOTIFICATIONS or WRITE_COMMANDS + uint8_t tx_buffer_full; + uint16_t Connection_Handle; + uint16_t Service_Handle; // Not used for write commands + uint16_t Handle; // Characteristic handle in case of notifications, attribute handle in case of write commands + uint16_t Value_Length; + uint32_t Seq_Num; +}TXBurstData; + +struct { + uint8_t Enable; // OFF, NOTIFICATIONS or WRITE_COMMANDS + uint16_t Connection_Handle; + uint16_t Attribute_Handle; + uint32_t Received_Packets; + uint32_t Next_Seq_Num; + uint32_t Seq_Errors; + uint16_t Value_Length; // Holds length of last packet only +}RxBurstData; + +tBleStatus BURST_TXNotificationStart(uint16_t Connection_Handle, uint16_t Service_Handle, + uint16_t Char_Handle, uint16_t Value_Length) +{ + tBleStatus ret; + uint32_t Value[(CFG_BLE_ATT_MTU_MAX+3)/4]; + uint32_t *pSeqNum = Value; + + if(TXBurstData.Enable != OFF) + return BLE_ERROR_COMMAND_DISALLOWED; + + memset(Value,0, sizeof(Value)); + + TXBurstData.Seq_Num = 0; + + *pSeqNum = TXBurstData.Seq_Num; + + ret = aci_gatt_srv_notify(Connection_Handle, BLE_GATT_UNENHANCED_ATT_L2CAP_CID, Char_Handle + 1, GATT_NOTIFICATION, Value_Length, (uint8_t *)Value); + + if(ret == BLE_STATUS_SUCCESS){ + // Everything went well. Store all the information + TXBurstData.Connection_Handle = Connection_Handle; + TXBurstData.Service_Handle = Service_Handle; + TXBurstData.Handle = Char_Handle; + TXBurstData.Value_Length = Value_Length; + TXBurstData.Seq_Num = 1; + TXBurstData.Enable = NOTIFICATIONS; + TXBurstData.tx_buffer_full = FALSE; + + BURST_StartCallback(); + + return BLE_STATUS_SUCCESS; + } + + return ret; +} + +tBleStatus BURST_TXWriteCommandStart(uint16_t Connection_Handle, uint16_t Attr_Handle, + uint16_t Value_Length) +{ + tBleStatus ret; + uint32_t Value[(CFG_BLE_ATT_MTU_MAX+3)/4]; + uint32_t *pSeqNum = Value; + + if(TXBurstData.Enable != OFF) + return BLE_ERROR_COMMAND_DISALLOWED; + + memset(Value,0, sizeof(Value)); + + TXBurstData.Seq_Num = 0; + + *pSeqNum = TXBurstData.Seq_Num; + + //TBR Replace with new API + ret = aci_gatt_clt_write_without_resp(Connection_Handle, BLE_GATT_UNENHANCED_ATT_L2CAP_CID, Attr_Handle, + Value_Length, (uint8_t *)Value); + if(ret == BLE_STATUS_SUCCESS){ + // Everything went well. Store all the information + TXBurstData.Connection_Handle = Connection_Handle; + TXBurstData.Handle = Attr_Handle; + TXBurstData.Value_Length = Value_Length; + TXBurstData.Seq_Num = 1; + TXBurstData.Enable = WRITE_COMMANDS; + TXBurstData.tx_buffer_full = FALSE; + + BURST_StartCallback(); + + return BLE_STATUS_SUCCESS; + } + + return ret; +} + +tBleStatus BURST_RXStart(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint8_t Notifications_WriteCmds) +{ + if(RxBurstData.Enable != OFF) + return BLE_ERROR_COMMAND_DISALLOWED; + + if(Notifications_WriteCmds == 0) + RxBurstData.Enable = NOTIFICATIONS; + else + RxBurstData.Enable = WRITE_COMMANDS; + + RxBurstData.Connection_Handle = Connection_Handle; + RxBurstData.Attribute_Handle = Attribute_Handle; + RxBurstData.Received_Packets = 0; + RxBurstData.Next_Seq_Num = 0; + RxBurstData.Seq_Errors = 0; + + return BLE_STATUS_SUCCESS; +} + +tBleStatus BURST_TXStop(void) +{ + if(TXBurstData.Enable == OFF) + return BLE_ERROR_COMMAND_DISALLOWED; + + TXBurstData.Enable = OFF; + + return BLE_STATUS_SUCCESS; +} + +tBleStatus BURST_RXStop(void) +{ + if(RxBurstData.Enable == OFF) + return BLE_ERROR_COMMAND_DISALLOWED; + + RxBurstData.Enable = OFF; + + return BLE_STATUS_SUCCESS; +} + +static uint8_t PacketReceived(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint16_t Value_Length, uint8_t Value[]) +{ + uint32_t seq_num; + + if(RxBurstData.Connection_Handle == Connection_Handle && RxBurstData.Attribute_Handle == Attribute_Handle){ + + seq_num = LE_TO_HOST_32(Value); + + if(seq_num != RxBurstData.Next_Seq_Num){ + // Sequence error + RxBurstData.Seq_Errors++; + } + + RxBurstData.Next_Seq_Num = seq_num + 1; + RxBurstData.Received_Packets++; + RxBurstData.Value_Length = Value_Length; + + return 1; + } + + return 0; +} + +/* To be called from the aci_gatt_clt_notification_event(). Returns 1 if burst mode is ON + and notification event should not be sent to application. */ +uint8_t BURST_NotificationReceived(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint16_t Value_Length, uint8_t Value[]) +{ + if(RxBurstData.Enable == NOTIFICATIONS) + return PacketReceived(Connection_Handle, Attribute_Handle, Value_Length, Value); + + return 0; +} + +/* To be called from the aci_gatt_srv_attribute_modified_event(). Returns 1 if burst mode is ON + and attribute_modified event should not be sent to application. */ +uint8_t BURST_WriteReceived(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint16_t Value_Length, uint8_t Value[]) +{ + if(RxBurstData.Enable == WRITE_COMMANDS) + return PacketReceived(Connection_Handle, Attribute_Handle, Value_Length, Value); + + return 0; +} + +/* To be called from the aci_gatt_tx_pool_available_event() */ +uint8_t BURST_BufferAvailableNotify(void) +{ + if(TXBurstData.Enable != OFF){ + TXBurstData.tx_buffer_full = FALSE; + return 1; + } + return 0; +} + +uint32_t BURST_TXReport(void) +{ + return TXBurstData.Seq_Num; +} + +uint32_t BURST_RXReport(uint16_t *Data_Length, uint32_t *Sequence_Errors) +{ + if(Data_Length != NULL) + *Data_Length = RxBurstData.Value_Length; + if(Sequence_Errors != NULL) + *Sequence_Errors = RxBurstData.Seq_Errors; + + return RxBurstData.Received_Packets; +} + +static void SendNotificationBurst(void) +{ + uint32_t Value[(CFG_BLE_ATT_MTU_MAX+3)/4]; + uint32_t *pSeqNum = Value; + tBleStatus ret = BLE_STATUS_SUCCESS; + + memset(Value,0, sizeof(Value)); + + *pSeqNum = TXBurstData.Seq_Num; + + while(ret == BLE_STATUS_SUCCESS){ + + ret = aci_gatt_srv_notify(TXBurstData.Connection_Handle, BLE_GATT_UNENHANCED_ATT_L2CAP_CID, TXBurstData.Handle + 1, 0, TXBurstData.Value_Length, (uint8_t *)Value); + if(ret == BLE_STATUS_SUCCESS){ + (*pSeqNum)++; + } + } + + if(ret == BLE_STATUS_INSUFFICIENT_RESOURCES){ + TXBurstData.tx_buffer_full = TRUE; + } + + TXBurstData.Seq_Num = *pSeqNum; +} + +static void SendWriteCommandBurst(void) +{ + uint32_t Value[(CFG_BLE_ATT_MTU_MAX+3)/4]; + uint32_t *pSeqNum = Value; + tBleStatus ret = BLE_STATUS_SUCCESS; + + memset(Value,0, sizeof(Value)); + + *pSeqNum = TXBurstData.Seq_Num; + + while(ret == BLE_STATUS_SUCCESS){ + + ret = aci_gatt_clt_write_without_resp(TXBurstData.Connection_Handle, BLE_GATT_UNENHANCED_ATT_L2CAP_CID, TXBurstData.Handle, + TXBurstData.Value_Length, (uint8_t *)Value); + if(ret == BLE_STATUS_SUCCESS){ + (*pSeqNum)++; + } + } + + if(ret == BLE_STATUS_INSUFFICIENT_RESOURCES){ + TXBurstData.tx_buffer_full = TRUE; + } + + TXBurstData.Seq_Num = *pSeqNum; +} + +void BURST_Tick(void) +{ + if(TXBurstData.tx_buffer_full == FALSE){ + if(TXBurstData.Enable == NOTIFICATIONS){ + SendNotificationBurst(); + } + else if(TXBurstData.Enable == WRITE_COMMANDS){ + SendWriteCommandBurst(); + } + } +} + +__weak void BURST_StartCallback(void){} + +#else + +void BURST_Tick(void){} + +#endif diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_burst.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_burst.h new file mode 100644 index 000000000..31fa1051c --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_burst.h @@ -0,0 +1,53 @@ +/* USER CODE BEGIN Header */ + +/** + ****************************************************************************** + * @file dtm_burst.h + * @author GPM WBL Application Team + * @brief Header file for module implementing test burst commands + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef _DTM_BURST_H_ +#define _DTM_BURST_H_ + +#include "ble_status.h" + +tBleStatus BURST_TXNotificationStart(uint16_t Connection_Handle, uint16_t Service_Handle, + uint16_t Char_Handle, uint16_t Value_Length); + +tBleStatus BURST_TXWriteCommandStart(uint16_t Connection_Handle, uint16_t Attr_Handle, + uint16_t Value_Length); + +tBleStatus BURST_RXStart(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint8_t Notifications_WriteCmds); + +tBleStatus BURST_TXStop(void); + +tBleStatus BURST_RXStop(void); + +uint8_t BURST_NotificationReceived(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint16_t Value_Length, uint8_t Value[]); + +uint8_t BURST_WriteReceived(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint16_t Value_Length, uint8_t Value[]); + +uint8_t BURST_BufferAvailableNotify(void); + +uint32_t BURST_TXReport(void); + +uint32_t BURST_RXReport(uint16_t *Data_Length, uint32_t *Sequence_Errors); + +void BURST_Tick(void); + +void BURST_StartCallback(void); + +#endif /* _DTM_BURST_H_ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c new file mode 100644 index 000000000..33dffa50f --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c @@ -0,0 +1,14875 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file DTM_cmd_db.c + * @author AMS - RF Application team + * @date 24 October 2023 + * @brief Autogenerated files, do not edit!! + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include +#include "stm32wb0x.h" +#include "compiler.h" +#include "app_common.h" +#include "ble_stack.h" +#include "osal.h" +#include "aci_gatt_nwk.h" +#include "aci_adv_nwk.h" +#include "aci_l2cap_nwk.h" +#ifndef __ZEPHYR__ +#include "gatt_profile.h" +#include "gap_profile.h" +#endif /* __ZEPHYR__ */ +#include "dtm_cmd_db.h" +#include "dtm_cmd_en.h" +#include "RADIO_utils.h" +#include "transport_layer.h" + +#include + +/** Documentation for C struct Advertising_Set_Parameters_t */ +typedef PACKED(struct) packed_Advertising_Set_Parameters_t_s { + /** It is used to identify an advertising set. + * Values: + * - 0x00 ... 0xEF + */ + uint8_t Advertising_Handle; + /** The Duration[i] parameter indicates the duration for which that advertising set + * is enabled. The duration begins at the start of the first advertising + * event of this advertising set. The Controller should not start an extended + * advertising event that it cannot complete within the duration. Time = N * + * 10 ms 0x00 means no advertising duration: advertising will continue until + * the Host disables it. + * Values: + * - 0x0000 (0 ms) : No advertising duration + * - 0x0001 (10 ms) ... 0xFFFF (655350 ms) + */ + uint16_t Duration; + /** The Max_Extended_Advertising_Events[i] parameter, if non-zero, indicates the + * maximum number of extended advertising events that shall be sent prior to + * disabling the extended advertising set even if the Duration[i] parameter + * has not expired. + * Values: + * - 0x00: No maximum number of advertising events. + * - 0x01 ... 0xFF: Maximum number of extended advertising events. + */ + uint8_t Max_Extended_Advertising_Events; +} packed_Advertising_Set_Parameters_t; + +/** Documentation for C struct Extended_Scan_Parameters_t */ +typedef PACKED(struct) packed_Extended_Scan_Parameters_t_s { + /** The Scan_Type parameter specifies the type of scan to perform. 0: Passive + * Scanning. No scan request PDUs shall be sent. 1: Active Scanning. Scan + * request PDUs may be sent. + * Values: + * - 0x00: Passive Scanning + * - 0x01: Active Scanning + */ + uint8_t Scan_Type; + /** Time interval from when the Controller started its last scan until it begins the + * subsequent scan on the primary advertising channel. Time = N * 0.625 ms + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Scan_Interval; + /** Duration of the scan on the primary advertising channel. Time = N * 0.625 ms + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Scan_Window; +} packed_Extended_Scan_Parameters_t; + +/** Documentation for C struct Extended_Create_Connection_Parameters_t */ +typedef PACKED(struct) packed_Extended_Create_Connection_Parameters_t_s { + /** Time interval from when the Controller started its last scan until it begins the + * subsequent scan on the primary advertising channel. Time = N * 0.625 ms; + * Time Range: 2.5 ms to 40.959375 s. + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Scan_Interval; + /** Duration of the scan on the primary advertising channel. Time = N * 0.625 ms; + * Time Range: 2.5 ms to 40.959375 s. + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Scan_Window; + /** Minimum value for the connection interval. This shall be less than or equal to + * Connection_Interval_Max[i]. Time = N * 1.25 ms; Time Range: 7.5 ms to 4 s. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ + uint16_t Connection_Interval_Min; + /** Maximum value for the connection interval. This shall be less than or equal to + * Connection_Interval_Max[i]. Time = N * 1.25 ms; Time Range: 7.5 ms to 4 s. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ + uint16_t Connection_Interval_Max; + /** Peripheral latency for the connection in number of connection events + * Values: + * - 0x0000 ... 0x01F3 + */ + uint16_t Max_Latency; + /** Supervision timeout for the LE Link. (See [Vol 6] Part B, Section 4.5.2) Time = + * N * 10 ms; Time Range: 100 ms to 32 s. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + */ + uint16_t Supervision_Timeout; + /** Informative parameter recommending the minimum length of connection event needed + * for this LE connection. Time = N * 0.625 ms. + * Values: + * - 0x0000 (0.000 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Min_CE_Length; + /** Informative parameter recommending the maximum length of connection event needed + * for this LE connection. Time = N * 0.625 ms. + * Values: + * - 0x0000 (0.000 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Max_CE_Length; +} packed_Extended_Create_Connection_Parameters_t; + +/** Documentation for C struct CIS_Param_t */ +typedef PACKED(struct) packed_CIS_Param_t_s { + /** Used to identify a CIS. + * Values: + * - 0x00 ... 0xEF + */ + uint8_t CIS_ID; + /** Maximum size, in octets, of the payload from the Central's Host. + * Values: + * - 0x0000 ... 0x0FFF + */ + uint16_t Max_SDU_C_To_P; + /** Maximum size, in octets, of the payload from the Peripheral's Host. + * Values: + * - 0x0000 ... 0x0FFF + */ + uint16_t Max_SDU_P_To_C; + /** PHY to use for transmission from the Central to the Peripheral. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + */ + uint8_t PHY_C_To_P; + /** PHY to use for transmission from the Peripheral to the Central. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + */ + uint8_t PHY_P_To_C; + /** Number of times every CIS Data PDU should be retransmitted from the Central to + * the Peripheral. + */ + uint8_t RTN_C_To_P; + /** Number of times every CIS Data PDU should be retransmitted from the Peripheral + * to the Central. + */ + uint8_t RTN_P_To_C; +} packed_CIS_Param_t; + +/** Documentation for C struct CIS_Param_Test_t */ +typedef PACKED(struct) packed_CIS_Param_Test_t_s { + /** Used to identify a CIS. + * Values: + * - 0x00 ... 0xEF + */ + uint8_t CIS_ID; + /** Maximum number of subevents in each CIS event. + * Values: + * - 0x01 ... 0x1F + */ + uint8_t NSE; + /** Maximum size, in octets, of the payload from the Central's Host. + * Values: + * - 0x0000 ... 0x0FFF + */ + uint16_t Max_SDU_C_To_P; + /** Maximum size, in octets, of the payload from the Peripheral's Host. + * Values: + * - 0x0000 ... 0x0FFF + */ + uint16_t Max_SDU_P_To_C; + /** Maximum size, in octets, of the payload from the Central's Link Layer to the + * Peripheral's Link Layer. + * Values: + * - 0x0000 ... 0x00FB + */ + uint16_t Max_PDU_C_To_P; + /** Maximum size, in octets, of the payload from the Peripheral's Link Layer to the + * Central's Link Layer. + * Values: + * - 0x0000 ... 0x00FB + */ + uint16_t Max_PDU_P_To_C; + /** PHY to use for transmission from the Central to the Peripheral. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + */ + uint8_t PHY_C_To_P; + /** PHY to use for transmission from the Peripheral to the Central. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + */ + uint8_t PHY_P_To_C; + /** The burst number for Central to Peripheral. + * Values: + * - 0x00: No data + * - 0x01 ... 0x0F + */ + uint8_t BN_C_To_P; + /** The burst number for Peripheral to Central. + * Values: + * - 0x00: No data + * - 0x01 ... 0x0F + */ + uint8_t BN_P_To_C; +} packed_CIS_Param_Test_t; + +/** Documentation for C struct CIS_Handles_t */ +typedef PACKED(struct) packed_CIS_Handles_t_s { + /** Connection handle of a CIS. + * Values: + * - 0x0000 ... 0x0EFF + */ + uint16_t CIS_Connection_Handle; + /** Connection handle of an ACL connection. + * Values: + * - 0x0000 ... 0x0EFF + */ + uint16_t ACL_Connection_Handle; +} packed_CIS_Handles_t; + +/** Documentation for C struct Subevent_Data_Parameters_t */ +typedef PACKED(struct) packed_Subevent_Data_Parameters_t_s { + /** The subevent index of the data. + * Values: + * - 0x00 ... 0x7F + */ + uint8_t Subevent; + /** The first response slots to be used in this subevent. + */ + uint8_t Response_Slot_Start; + /** The number of response slots to be used. + */ + uint8_t Response_Slot_Count; + /** The number of octets in the Subevent_Data parameter. + * Values: + * - 0x00 ... 0xFB + */ + uint8_t Subevent_Data_Length; + /** Advertising data formatted as defined in [Vol 3] Part C, Section 11. + */ + uint8_t Subevent_Data[1]; +} packed_Subevent_Data_Parameters_t; + +/** Documentation for C struct Bonded_Device_Entry_t */ +typedef PACKED(struct) packed_Bonded_Device_Entry_t_s { + /** Address type. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + */ + uint8_t Address_Type; + /** Identity Address (Public or Random) of the device. + */ + uint8_t Address[6]; +} packed_Bonded_Device_Entry_t; + +/** Documentation for C struct List_Entry_t */ +typedef PACKED(struct) packed_List_Entry_t_s { + /** Address type. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + */ + uint8_t Peer_Address_Type; + /** Public Device Address or Random Device Address of the device to be added to the + * list. + */ + uint8_t Peer_Address[6]; +} packed_List_Entry_t; + +/** Documentation for C union Service_UUID_t */ +typedef PACKED(union) packed_Service_UUID_t_s { + /** 16-bit UUID + */ + uint16_t Service_UUID_16; + /** 128-bit UUID + */ + uint8_t Service_UUID_128[16]; +} packed_Service_UUID_t; + +/** Documentation for C union Char_UUID_t */ +typedef PACKED(union) packed_Char_UUID_t_s { + /** 16-bit UUID + */ + uint16_t Char_UUID_16; + /** 128-bit UUID + */ + uint8_t Char_UUID_128[16]; +} packed_Char_UUID_t; + +/** Documentation for C union Char_Desc_Uuid_t */ +typedef PACKED(union) packed_Char_Desc_Uuid_t_s { + /** 16-bit UUID + */ + uint16_t Char_UUID_16; + /** 128-bit UUID + */ + uint8_t Char_UUID_128[16]; +} packed_Char_Desc_Uuid_t; + +/** Documentation for C union UUID_t */ +typedef PACKED(union) packed_UUID_t_s { + /** 16-bit UUID + */ + uint16_t UUID_16; + /** 128-bit UUID + */ + uint8_t UUID_128[16]; +} packed_UUID_t; + +/** Documentation for C struct Gatt_Srv_Notify_Attr_t */ +typedef PACKED(struct) packed_Gatt_Srv_Notify_Attr_t_s { + /** + */ + uint16_t Handle; + /** + */ + uint16_t Val_Length; + /** + */ + uint8_t Val[1]; +} packed_Gatt_Srv_Notify_Attr_t; + +typedef PACKED(struct) hci_disconnect_cp0_s { + uint16_t Connection_Handle; + uint8_t Reason; +} hci_disconnect_cp0; + +typedef PACKED(struct) hci_disconnect_rp0_s { + uint8_t Status; +} hci_disconnect_rp0; + +typedef PACKED(struct) hci_read_remote_version_information_cp0_s { + uint16_t Connection_Handle; +} hci_read_remote_version_information_cp0; + +typedef PACKED(struct) hci_read_remote_version_information_rp0_s { + uint8_t Status; +} hci_read_remote_version_information_rp0; + +typedef PACKED(struct) hci_set_event_mask_cp0_s { + uint8_t Event_Mask[8]; +} hci_set_event_mask_cp0; + +typedef PACKED(struct) hci_set_event_mask_rp0_s { + uint8_t Status; +} hci_set_event_mask_rp0; + +typedef PACKED(struct) hci_read_connection_accept_timeout_rp0_s { + uint8_t Status; + uint16_t Connection_Accept_Timeout; +} hci_read_connection_accept_timeout_rp0; + +typedef PACKED(struct) hci_write_connection_accept_timeout_cp0_s { + uint16_t Connection_Accept_Timeout; +} hci_write_connection_accept_timeout_cp0; + +typedef PACKED(struct) hci_write_connection_accept_timeout_rp0_s { + uint8_t Status; +} hci_write_connection_accept_timeout_rp0; + +typedef PACKED(struct) hci_read_transmit_power_level_cp0_s { + uint16_t Connection_Handle; + uint8_t Type; +} hci_read_transmit_power_level_cp0; + +typedef PACKED(struct) hci_read_transmit_power_level_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + int8_t Transmit_Power_Level; +} hci_read_transmit_power_level_rp0; + +typedef PACKED(struct) hci_read_afh_channel_assessment_mode_rp0_s { + uint8_t Status; + uint8_t AFH_Channel_Assessment_Mode; +} hci_read_afh_channel_assessment_mode_rp0; + +typedef PACKED(struct) hci_write_afh_channel_assessment_mode_cp0_s { + uint8_t AFH_Channel_Assessment_Mode; +} hci_write_afh_channel_assessment_mode_cp0; + +typedef PACKED(struct) hci_write_afh_channel_assessment_mode_rp0_s { + uint8_t Status; +} hci_write_afh_channel_assessment_mode_rp0; + +typedef PACKED(struct) hci_set_event_mask_page_2_cp0_s { + uint8_t Event_Mask_Page_2[8]; +} hci_set_event_mask_page_2_cp0; + +typedef PACKED(struct) hci_set_event_mask_page_2_rp0_s { + uint8_t Status; +} hci_set_event_mask_page_2_rp0; + +typedef PACKED(struct) hci_read_authenticated_payload_timeout_cp0_s { + uint16_t Connection_Handle; +} hci_read_authenticated_payload_timeout_cp0; + +typedef PACKED(struct) hci_read_authenticated_payload_timeout_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint16_t Authenticated_Payload_Timeout; +} hci_read_authenticated_payload_timeout_rp0; + +typedef PACKED(struct) hci_write_authenticated_payload_timeout_cp0_s { + uint16_t Connection_Handle; + uint16_t Authenticated_Payload_Timeout; +} hci_write_authenticated_payload_timeout_cp0; + +typedef PACKED(struct) hci_write_authenticated_payload_timeout_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_write_authenticated_payload_timeout_rp0; + +typedef PACKED(struct) hci_read_local_version_information_rp0_s { + uint8_t Status; + uint8_t HCI_Version; + uint16_t HCI_Revision; + uint8_t LMP_PAL_Version; + uint16_t Manufacturer_Name; + uint16_t LMP_PAL_Subversion; +} hci_read_local_version_information_rp0; + +typedef PACKED(struct) hci_read_local_supported_commands_rp0_s { + uint8_t Status; + uint8_t Supported_Commands[64]; +} hci_read_local_supported_commands_rp0; + +typedef PACKED(struct) hci_read_local_supported_features_rp0_s { + uint8_t Status; + uint8_t LMP_Features[8]; +} hci_read_local_supported_features_rp0; + +typedef PACKED(struct) hci_read_bd_addr_rp0_s { + uint8_t Status; + uint8_t BD_ADDR[6]; +} hci_read_bd_addr_rp0; + +typedef PACKED(struct) hci_read_rssi_cp0_s { + uint16_t Connection_Handle; +} hci_read_rssi_cp0; + +typedef PACKED(struct) hci_read_rssi_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + int8_t RSSI; +} hci_read_rssi_rp0; + +typedef PACKED(struct) hci_le_set_event_mask_cp0_s { + uint8_t LE_Event_Mask[8]; +} hci_le_set_event_mask_cp0; + +typedef PACKED(struct) hci_le_set_event_mask_rp0_s { + uint8_t Status; +} hci_le_set_event_mask_rp0; + +typedef PACKED(struct) hci_le_read_buffer_size_rp0_s { + uint8_t Status; + uint16_t HC_LE_ACL_Data_Packet_Length; + uint8_t HC_Total_Num_LE_ACL_Data_Packets; +} hci_le_read_buffer_size_rp0; + +typedef PACKED(struct) hci_le_read_local_supported_features_rp0_s { + uint8_t Status; + uint8_t LE_Features[8]; +} hci_le_read_local_supported_features_rp0; + +typedef PACKED(struct) hci_le_set_random_address_cp0_s { + uint8_t Random_Address[6]; +} hci_le_set_random_address_cp0; + +typedef PACKED(struct) hci_le_set_random_address_rp0_s { + uint8_t Status; +} hci_le_set_random_address_rp0; + +typedef PACKED(struct) hci_le_set_advertising_parameters_cp0_s { + uint16_t Advertising_Interval_Min; + uint16_t Advertising_Interval_Max; + uint8_t Advertising_Type; + uint8_t Own_Address_Type; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Advertising_Channel_Map; + uint8_t Advertising_Filter_Policy; +} hci_le_set_advertising_parameters_cp0; + +typedef PACKED(struct) hci_le_set_advertising_parameters_rp0_s { + uint8_t Status; +} hci_le_set_advertising_parameters_rp0; + +typedef PACKED(struct) hci_le_read_advertising_physical_channel_tx_power_rp0_s { + uint8_t Status; + int8_t Transmit_Power_Level; +} hci_le_read_advertising_physical_channel_tx_power_rp0; + +typedef PACKED(struct) hci_le_set_advertising_data_cp0_s { + uint8_t Advertising_Data_Length; + uint8_t Advertising_Data[31]; +} hci_le_set_advertising_data_cp0; + +typedef PACKED(struct) hci_le_set_advertising_data_rp0_s { + uint8_t Status; +} hci_le_set_advertising_data_rp0; + +typedef PACKED(struct) hci_le_set_scan_response_data_cp0_s { + uint8_t Scan_Response_Data_Length; + uint8_t Scan_Response_Data[31]; +} hci_le_set_scan_response_data_cp0; + +typedef PACKED(struct) hci_le_set_scan_response_data_rp0_s { + uint8_t Status; +} hci_le_set_scan_response_data_rp0; + +typedef PACKED(struct) hci_le_set_advertising_enable_cp0_s { + uint8_t Advertising_Enable; +} hci_le_set_advertising_enable_cp0; + +typedef PACKED(struct) hci_le_set_advertising_enable_rp0_s { + uint8_t Status; +} hci_le_set_advertising_enable_rp0; + +typedef PACKED(struct) hci_le_set_scan_parameters_cp0_s { + uint8_t LE_Scan_Type; + uint16_t LE_Scan_Interval; + uint16_t LE_Scan_Window; + uint8_t Own_Address_Type; + uint8_t Scanning_Filter_Policy; +} hci_le_set_scan_parameters_cp0; + +typedef PACKED(struct) hci_le_set_scan_parameters_rp0_s { + uint8_t Status; +} hci_le_set_scan_parameters_rp0; + +typedef PACKED(struct) hci_le_set_scan_enable_cp0_s { + uint8_t LE_Scan_Enable; + uint8_t Filter_Duplicates; +} hci_le_set_scan_enable_cp0; + +typedef PACKED(struct) hci_le_set_scan_enable_rp0_s { + uint8_t Status; +} hci_le_set_scan_enable_rp0; + +typedef PACKED(struct) hci_le_create_connection_cp0_s { + uint16_t LE_Scan_Interval; + uint16_t LE_Scan_Window; + uint8_t Initiator_Filter_Policy; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Own_Address_Type; + uint16_t Connection_Interval_Min; + uint16_t Connection_Interval_Max; + uint16_t Max_Latency; + uint16_t Supervision_Timeout; + uint16_t Min_CE_Length; + uint16_t Max_CE_Length; +} hci_le_create_connection_cp0; + +typedef PACKED(struct) hci_le_create_connection_rp0_s { + uint8_t Status; +} hci_le_create_connection_rp0; + +typedef PACKED(struct) hci_le_create_connection_cancel_rp0_s { + uint8_t Status; +} hci_le_create_connection_cancel_rp0; + +typedef PACKED(struct) hci_le_read_filter_accept_list_size_rp0_s { + uint8_t Status; + uint8_t Filter_Accept_List_Size; +} hci_le_read_filter_accept_list_size_rp0; + +typedef PACKED(struct) hci_le_clear_filter_accept_list_rp0_s { + uint8_t Status; +} hci_le_clear_filter_accept_list_rp0; + +typedef PACKED(struct) hci_le_add_device_to_filter_accept_list_cp0_s { + uint8_t Address_Type; + uint8_t Address[6]; +} hci_le_add_device_to_filter_accept_list_cp0; + +typedef PACKED(struct) hci_le_add_device_to_filter_accept_list_rp0_s { + uint8_t Status; +} hci_le_add_device_to_filter_accept_list_rp0; + +typedef PACKED(struct) hci_le_remove_device_from_filter_accept_list_cp0_s { + uint8_t Address_Type; + uint8_t Address[6]; +} hci_le_remove_device_from_filter_accept_list_cp0; + +typedef PACKED(struct) hci_le_remove_device_from_filter_accept_list_rp0_s { + uint8_t Status; +} hci_le_remove_device_from_filter_accept_list_rp0; + +typedef PACKED(struct) hci_le_connection_update_cp0_s { + uint16_t Connection_Handle; + uint16_t Connection_Interval_Min; + uint16_t Connection_Interval_Max; + uint16_t Max_Latency; + uint16_t Supervision_Timeout; + uint16_t Min_CE_Length; + uint16_t Max_CE_Length; +} hci_le_connection_update_cp0; + +typedef PACKED(struct) hci_le_connection_update_rp0_s { + uint8_t Status; +} hci_le_connection_update_rp0; + +typedef PACKED(struct) hci_le_set_host_channel_classification_cp0_s { + uint8_t LE_Channel_Map[5]; +} hci_le_set_host_channel_classification_cp0; + +typedef PACKED(struct) hci_le_set_host_channel_classification_rp0_s { + uint8_t Status; +} hci_le_set_host_channel_classification_rp0; + +typedef PACKED(struct) hci_le_read_channel_map_cp0_s { + uint16_t Connection_Handle; +} hci_le_read_channel_map_cp0; + +typedef PACKED(struct) hci_le_read_channel_map_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t LE_Channel_Map[5]; +} hci_le_read_channel_map_rp0; + +typedef PACKED(struct) hci_le_read_remote_features_cp0_s { + uint16_t Connection_Handle; +} hci_le_read_remote_features_cp0; + +typedef PACKED(struct) hci_le_read_remote_features_rp0_s { + uint8_t Status; +} hci_le_read_remote_features_rp0; + +typedef PACKED(struct) hci_le_encrypt_cp0_s { + uint8_t Key[16]; + uint8_t Plaintext_Data[16]; +} hci_le_encrypt_cp0; + +typedef PACKED(struct) hci_le_encrypt_rp0_s { + uint8_t Status; + uint8_t Encrypted_Data[16]; +} hci_le_encrypt_rp0; + +typedef PACKED(struct) hci_le_rand_rp0_s { + uint8_t Status; + uint8_t Random_Number[8]; +} hci_le_rand_rp0; + +typedef PACKED(struct) hci_le_enable_encryption_cp0_s { + uint16_t Connection_Handle; + uint8_t Random_Number[8]; + uint16_t Encrypted_Diversifier; + uint8_t Long_Term_Key[16]; +} hci_le_enable_encryption_cp0; + +typedef PACKED(struct) hci_le_enable_encryption_rp0_s { + uint8_t Status; +} hci_le_enable_encryption_rp0; + +typedef PACKED(struct) hci_le_long_term_key_request_reply_cp0_s { + uint16_t Connection_Handle; + uint8_t Long_Term_Key[16]; +} hci_le_long_term_key_request_reply_cp0; + +typedef PACKED(struct) hci_le_long_term_key_request_reply_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_long_term_key_request_reply_rp0; + +typedef PACKED(struct) hci_le_long_term_key_request_negative_reply_cp0_s { + uint16_t Connection_Handle; +} hci_le_long_term_key_request_negative_reply_cp0; + +typedef PACKED(struct) hci_le_long_term_key_request_negative_reply_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_long_term_key_request_negative_reply_rp0; + +typedef PACKED(struct) hci_le_read_supported_states_rp0_s { + uint8_t Status; + uint8_t LE_States[8]; +} hci_le_read_supported_states_rp0; + +typedef PACKED(struct) hci_le_receiver_test_cp0_s { + uint8_t RX_Frequency; +} hci_le_receiver_test_cp0; + +typedef PACKED(struct) hci_le_receiver_test_rp0_s { + uint8_t Status; +} hci_le_receiver_test_rp0; + +typedef PACKED(struct) hci_le_transmitter_test_cp0_s { + uint8_t TX_Frequency; + uint8_t Length_Of_Test_Data; + uint8_t Packet_Payload; +} hci_le_transmitter_test_cp0; + +typedef PACKED(struct) hci_le_transmitter_test_rp0_s { + uint8_t Status; +} hci_le_transmitter_test_rp0; + +typedef PACKED(struct) hci_le_test_end_rp0_s { + uint8_t Status; + uint16_t Number_Of_Packets; +} hci_le_test_end_rp0; + +typedef PACKED(struct) hci_le_set_data_length_cp0_s { + uint16_t Connection_Handle; + uint16_t TxOctets; + uint16_t TxTime; +} hci_le_set_data_length_cp0; + +typedef PACKED(struct) hci_le_set_data_length_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_set_data_length_rp0; + +typedef PACKED(struct) hci_le_read_suggested_default_data_length_rp0_s { + uint8_t Status; + uint16_t SuggestedMaxTxOctets; + uint16_t SuggestedMaxTxTime; +} hci_le_read_suggested_default_data_length_rp0; + +typedef PACKED(struct) hci_le_write_suggested_default_data_length_cp0_s { + uint16_t SuggestedMaxTxOctets; + uint16_t SuggestedMaxTxTime; +} hci_le_write_suggested_default_data_length_cp0; + +typedef PACKED(struct) hci_le_write_suggested_default_data_length_rp0_s { + uint8_t Status; +} hci_le_write_suggested_default_data_length_rp0; + +typedef PACKED(struct) hci_le_read_local_p256_public_key_rp0_s { + uint8_t Status; +} hci_le_read_local_p256_public_key_rp0; + +typedef PACKED(struct) hci_le_generate_dhkey_cp0_s { + uint8_t Remote_P256_Public_Key[64]; +} hci_le_generate_dhkey_cp0; + +typedef PACKED(struct) hci_le_generate_dhkey_rp0_s { + uint8_t Status; +} hci_le_generate_dhkey_rp0; + +typedef PACKED(struct) hci_le_add_device_to_resolving_list_cp0_s { + uint8_t Peer_Identity_Address_Type; + uint8_t Peer_Identity_Address[6]; + uint8_t Peer_IRK[16]; + uint8_t Local_IRK[16]; +} hci_le_add_device_to_resolving_list_cp0; + +typedef PACKED(struct) hci_le_add_device_to_resolving_list_rp0_s { + uint8_t Status; +} hci_le_add_device_to_resolving_list_rp0; + +typedef PACKED(struct) hci_le_remove_device_from_resolving_list_cp0_s { + uint8_t Peer_Identity_Address_Type; + uint8_t Peer_Identity_Address[6]; +} hci_le_remove_device_from_resolving_list_cp0; + +typedef PACKED(struct) hci_le_remove_device_from_resolving_list_rp0_s { + uint8_t Status; +} hci_le_remove_device_from_resolving_list_rp0; + +typedef PACKED(struct) hci_le_clear_resolving_list_rp0_s { + uint8_t Status; +} hci_le_clear_resolving_list_rp0; + +typedef PACKED(struct) hci_le_read_resolving_list_size_rp0_s { + uint8_t Status; + uint8_t Resolving_List_Size; +} hci_le_read_resolving_list_size_rp0; + +typedef PACKED(struct) hci_le_read_peer_resolvable_address_cp0_s { + uint8_t Peer_Identity_Address_Type; + uint8_t Peer_Identity_Address[6]; +} hci_le_read_peer_resolvable_address_cp0; + +typedef PACKED(struct) hci_le_read_peer_resolvable_address_rp0_s { + uint8_t Status; + uint8_t Peer_Resolvable_Address[6]; +} hci_le_read_peer_resolvable_address_rp0; + +typedef PACKED(struct) hci_le_read_local_resolvable_address_cp0_s { + uint8_t Peer_Identity_Address_Type; + uint8_t Peer_Identity_Address[6]; +} hci_le_read_local_resolvable_address_cp0; + +typedef PACKED(struct) hci_le_read_local_resolvable_address_rp0_s { + uint8_t Status; + uint8_t Local_Resolvable_Address[6]; +} hci_le_read_local_resolvable_address_rp0; + +typedef PACKED(struct) hci_le_set_address_resolution_enable_cp0_s { + uint8_t Address_Resolution_Enable; +} hci_le_set_address_resolution_enable_cp0; + +typedef PACKED(struct) hci_le_set_address_resolution_enable_rp0_s { + uint8_t Status; +} hci_le_set_address_resolution_enable_rp0; + +typedef PACKED(struct) hci_le_set_resolvable_private_address_timeout_cp0_s { + uint16_t RPA_Timeout; +} hci_le_set_resolvable_private_address_timeout_cp0; + +typedef PACKED(struct) hci_le_set_resolvable_private_address_timeout_rp0_s { + uint8_t Status; +} hci_le_set_resolvable_private_address_timeout_rp0; + +typedef PACKED(struct) hci_le_read_maximum_data_length_rp0_s { + uint8_t Status; + uint16_t supportedMaxTxOctets; + uint16_t supportedMaxTxTime; + uint16_t supportedMaxRxOctets; + uint16_t supportedMaxRxTime; +} hci_le_read_maximum_data_length_rp0; + +typedef PACKED(struct) hci_le_read_phy_cp0_s { + uint16_t Connection_Handle; +} hci_le_read_phy_cp0; + +typedef PACKED(struct) hci_le_read_phy_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t TX_PHY; + uint8_t RX_PHY; +} hci_le_read_phy_rp0; + +typedef PACKED(struct) hci_le_set_default_phy_cp0_s { + uint8_t ALL_PHYS; + uint8_t TX_PHYS; + uint8_t RX_PHYS; +} hci_le_set_default_phy_cp0; + +typedef PACKED(struct) hci_le_set_default_phy_rp0_s { + uint8_t Status; +} hci_le_set_default_phy_rp0; + +typedef PACKED(struct) hci_le_set_phy_cp0_s { + uint16_t Connection_Handle; + uint8_t ALL_PHYS; + uint8_t TX_PHYS; + uint8_t RX_PHYS; + uint16_t PHY_options; +} hci_le_set_phy_cp0; + +typedef PACKED(struct) hci_le_set_phy_rp0_s { + uint8_t Status; +} hci_le_set_phy_rp0; + +typedef PACKED(struct) hci_le_receiver_test_v2_cp0_s { + uint8_t RX_Channel; + uint8_t PHY; + uint8_t Modulation_index; +} hci_le_receiver_test_v2_cp0; + +typedef PACKED(struct) hci_le_receiver_test_v2_rp0_s { + uint8_t Status; +} hci_le_receiver_test_v2_rp0; + +typedef PACKED(struct) hci_le_transmitter_test_v2_cp0_s { + uint8_t TX_Channel; + uint8_t Length_Of_Test_Data; + uint8_t Packet_Payload; + uint8_t PHY; +} hci_le_transmitter_test_v2_cp0; + +typedef PACKED(struct) hci_le_transmitter_test_v2_rp0_s { + uint8_t Status; +} hci_le_transmitter_test_v2_rp0; + +typedef PACKED(struct) hci_le_set_advertising_set_random_address_cp0_s { + uint8_t Advertising_Handle; + uint8_t Advertising_Random_Address[6]; +} hci_le_set_advertising_set_random_address_cp0; + +typedef PACKED(struct) hci_le_set_advertising_set_random_address_rp0_s { + uint8_t Status; +} hci_le_set_advertising_set_random_address_rp0; + +typedef PACKED(struct) hci_le_set_extended_advertising_parameters_cp0_s { + uint8_t Advertising_Handle; + uint16_t Advertising_Event_Properties; + uint8_t Primary_Advertising_Interval_Min[3]; + uint8_t Primary_Advertising_Interval_Max[3]; + uint8_t Primary_Advertising_Channel_Map; + uint8_t Own_Address_Type; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Advertising_Filter_Policy; + int8_t Advertising_Tx_Power; + uint8_t Primary_Advertising_PHY; + uint8_t Secondary_Advertising_Max_Skip; + uint8_t Secondary_Advertising_PHY; + uint8_t Advertising_SID; + uint8_t Scan_Request_Notification_Enable; +} hci_le_set_extended_advertising_parameters_cp0; + +typedef PACKED(struct) hci_le_set_extended_advertising_parameters_rp0_s { + uint8_t Status; + int8_t Selected_Tx_Power; +} hci_le_set_extended_advertising_parameters_rp0; + +typedef PACKED(struct) hci_le_set_extended_advertising_data_cp0_s { + uint8_t Advertising_Handle; + uint8_t Operation; + uint8_t Fragment_Preference; + uint8_t Advertising_Data_Length; + uint8_t Advertising_Data[(HCI_MAX_PAYLOAD_SIZE - 4)/sizeof(uint8_t)]; +} hci_le_set_extended_advertising_data_cp0; + +typedef PACKED(struct) hci_le_set_extended_advertising_data_rp0_s { + uint8_t Status; +} hci_le_set_extended_advertising_data_rp0; + +typedef PACKED(struct) hci_le_set_extended_scan_response_data_cp0_s { + uint8_t Advertising_Handle; + uint8_t Operation; + uint8_t Fragment_Preference; + uint8_t Scan_Response_Data_Length; + uint8_t Scan_Response_Data[(HCI_MAX_PAYLOAD_SIZE - 4)/sizeof(uint8_t)]; +} hci_le_set_extended_scan_response_data_cp0; + +typedef PACKED(struct) hci_le_set_extended_scan_response_data_rp0_s { + uint8_t Status; +} hci_le_set_extended_scan_response_data_rp0; + +typedef PACKED(struct) hci_le_set_extended_advertising_enable_cp0_s { + uint8_t Enable; + uint8_t Number_of_Sets; + packed_Advertising_Set_Parameters_t Advertising_Set_Parameters[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(packed_Advertising_Set_Parameters_t)]; +} hci_le_set_extended_advertising_enable_cp0; + +typedef PACKED(struct) hci_le_set_extended_advertising_enable_rp0_s { + uint8_t Status; +} hci_le_set_extended_advertising_enable_rp0; + +typedef PACKED(struct) hci_le_read_maximum_advertising_data_length_rp0_s { + uint8_t Status; + uint16_t Maximum_Advertising_Data_Length; +} hci_le_read_maximum_advertising_data_length_rp0; + +typedef PACKED(struct) hci_le_read_number_of_supported_advertising_sets_rp0_s { + uint8_t Status; + uint8_t Num_Supported_Advertising_Sets; +} hci_le_read_number_of_supported_advertising_sets_rp0; + +typedef PACKED(struct) hci_le_remove_advertising_set_cp0_s { + uint8_t Advertising_Handle; +} hci_le_remove_advertising_set_cp0; + +typedef PACKED(struct) hci_le_remove_advertising_set_rp0_s { + uint8_t Status; +} hci_le_remove_advertising_set_rp0; + +typedef PACKED(struct) hci_le_clear_advertising_sets_rp0_s { + uint8_t Status; +} hci_le_clear_advertising_sets_rp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_parameters_cp0_s { + uint8_t Advertising_Handle; + uint16_t Periodic_Advertising_Interval_Min; + uint16_t Periodic_Advertising_Interval_Max; + uint16_t Periodic_Advertising_Properties; +} hci_le_set_periodic_advertising_parameters_cp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_parameters_rp0_s { + uint8_t Status; +} hci_le_set_periodic_advertising_parameters_rp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_data_cp0_s { + uint8_t Advertising_Handle; + uint8_t Operation; + uint8_t Advertising_Data_Length; + uint8_t Advertising_Data[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint8_t)]; +} hci_le_set_periodic_advertising_data_cp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_data_rp0_s { + uint8_t Status; +} hci_le_set_periodic_advertising_data_rp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_enable_cp0_s { + uint8_t Enable; + uint8_t Advertising_Handle; +} hci_le_set_periodic_advertising_enable_cp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_enable_rp0_s { + uint8_t Status; +} hci_le_set_periodic_advertising_enable_rp0; + +typedef PACKED(struct) hci_le_set_extended_scan_parameters_cp0_s { + uint8_t Own_Address_Type; + uint8_t Scanning_Filter_Policy; + uint8_t Scanning_PHYs; + packed_Extended_Scan_Parameters_t Extended_Scan_Parameters[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(packed_Extended_Scan_Parameters_t)]; +} hci_le_set_extended_scan_parameters_cp0; + +typedef PACKED(struct) hci_le_set_extended_scan_parameters_rp0_s { + uint8_t Status; +} hci_le_set_extended_scan_parameters_rp0; + +typedef PACKED(struct) hci_le_set_extended_scan_enable_cp0_s { + uint8_t Enable; + uint8_t Filter_Duplicates; + uint16_t Duration; + uint16_t Period; +} hci_le_set_extended_scan_enable_cp0; + +typedef PACKED(struct) hci_le_set_extended_scan_enable_rp0_s { + uint8_t Status; +} hci_le_set_extended_scan_enable_rp0; + +typedef PACKED(struct) hci_le_extended_create_connection_cp0_s { + uint8_t Initiator_Filter_Policy; + uint8_t Own_Address_Type; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Initiating_PHYs; + packed_Extended_Create_Connection_Parameters_t Extended_Create_Connection_Parameters[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(packed_Extended_Create_Connection_Parameters_t)]; +} hci_le_extended_create_connection_cp0; + +typedef PACKED(struct) hci_le_extended_create_connection_rp0_s { + uint8_t Status; +} hci_le_extended_create_connection_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_create_sync_cp0_s { + uint8_t Options; + uint8_t Advertising_SID; + uint8_t Advertiser_Address_Type; + uint8_t Advertiser_Address[6]; + uint16_t Skip; + uint16_t Sync_Timeout; + uint8_t Sync_CTE_Type; +} hci_le_periodic_advertising_create_sync_cp0; + +typedef PACKED(struct) hci_le_periodic_advertising_create_sync_rp0_s { + uint8_t Status; +} hci_le_periodic_advertising_create_sync_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_create_sync_cancel_rp0_s { + uint8_t Status; +} hci_le_periodic_advertising_create_sync_cancel_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_terminate_sync_cp0_s { + uint16_t Sync_Handle; +} hci_le_periodic_advertising_terminate_sync_cp0; + +typedef PACKED(struct) hci_le_periodic_advertising_terminate_sync_rp0_s { + uint8_t Status; +} hci_le_periodic_advertising_terminate_sync_rp0; + +typedef PACKED(struct) hci_le_add_device_to_periodic_advertiser_list_cp0_s { + uint8_t Advertiser_Address_Type; + uint8_t Advertiser_Address[6]; + uint8_t Advertising_SID; +} hci_le_add_device_to_periodic_advertiser_list_cp0; + +typedef PACKED(struct) hci_le_add_device_to_periodic_advertiser_list_rp0_s { + uint8_t Status; +} hci_le_add_device_to_periodic_advertiser_list_rp0; + +typedef PACKED(struct) hci_le_remove_device_from_periodic_advertiser_list_cp0_s { + uint8_t Advertiser_Address_Type; + uint8_t Advertiser_Address[6]; + uint8_t Advertising_SID; +} hci_le_remove_device_from_periodic_advertiser_list_cp0; + +typedef PACKED(struct) hci_le_remove_device_from_periodic_advertiser_list_rp0_s { + uint8_t Status; +} hci_le_remove_device_from_periodic_advertiser_list_rp0; + +typedef PACKED(struct) hci_le_clear_periodic_advertiser_list_rp0_s { + uint8_t Status; +} hci_le_clear_periodic_advertiser_list_rp0; + +typedef PACKED(struct) hci_le_read_periodic_advertiser_list_size_rp0_s { + uint8_t Status; + uint8_t Periodic_Advertiser_List_Size; +} hci_le_read_periodic_advertiser_list_size_rp0; + +typedef PACKED(struct) hci_le_read_transmit_power_rp0_s { + uint8_t Status; + int8_t Min_Tx_Power; + int8_t Max_Tx_Power; +} hci_le_read_transmit_power_rp0; + +typedef PACKED(struct) hci_le_read_rf_path_compensation_rp0_s { + uint8_t Status; + int16_t RF_TX_Path_Compensation_Value; + int16_t RF_RX_Path_Compensation_Value; +} hci_le_read_rf_path_compensation_rp0; + +typedef PACKED(struct) hci_le_write_rf_path_compensation_cp0_s { + int16_t RF_TX_Path_Compensation_Value; + int16_t RF_RX_Path_Compensation_Value; +} hci_le_write_rf_path_compensation_cp0; + +typedef PACKED(struct) hci_le_write_rf_path_compensation_rp0_s { + uint8_t Status; +} hci_le_write_rf_path_compensation_rp0; + +typedef PACKED(struct) hci_le_set_privacy_mode_cp0_s { + uint8_t Peer_Identity_Address_Type; + uint8_t Peer_Identity_Address[6]; + uint8_t Privacy_Mode; +} hci_le_set_privacy_mode_cp0; + +typedef PACKED(struct) hci_le_set_privacy_mode_rp0_s { + uint8_t Status; +} hci_le_set_privacy_mode_rp0; + +typedef PACKED(struct) hci_le_receiver_test_v3_cp0_s { + uint8_t RX_Channel; + uint8_t PHY; + uint8_t Modulation_Index; + uint8_t Expected_CTE_Length; + uint8_t Expected_CTE_Type; + uint8_t Slot_Durations; + uint8_t Switching_Pattern_Length; + uint8_t Antenna_IDs[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} hci_le_receiver_test_v3_cp0; + +typedef PACKED(struct) hci_le_receiver_test_v3_rp0_s { + uint8_t Status; +} hci_le_receiver_test_v3_rp0; + +typedef PACKED(struct) hci_le_transmitter_test_v3_cp0_s { + uint8_t TX_Channel; + uint8_t Test_Data_Length; + uint8_t Packet_Payload; + uint8_t PHY; + uint8_t CTE_Length; + uint8_t CTE_Type; + uint8_t Switching_Pattern_Length; + uint8_t Antenna_IDs[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} hci_le_transmitter_test_v3_cp0; + +typedef PACKED(struct) hci_le_transmitter_test_v3_rp0_s { + uint8_t Status; +} hci_le_transmitter_test_v3_rp0; + +typedef PACKED(struct) hci_le_set_connectionless_cte_transmit_parameters_cp0_s { + uint8_t Advertising_Handle; + uint8_t CTE_Length; + uint8_t CTE_Type; + uint8_t CTE_Count; + uint8_t Switching_Pattern_Length; + uint8_t Antenna_IDs[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(uint8_t)]; +} hci_le_set_connectionless_cte_transmit_parameters_cp0; + +typedef PACKED(struct) hci_le_set_connectionless_cte_transmit_parameters_rp0_s { + uint8_t Status; +} hci_le_set_connectionless_cte_transmit_parameters_rp0; + +typedef PACKED(struct) hci_le_set_connectionless_cte_transmit_enable_cp0_s { + uint8_t Advertising_Handle; + uint8_t CTE_Enable; +} hci_le_set_connectionless_cte_transmit_enable_cp0; + +typedef PACKED(struct) hci_le_set_connectionless_cte_transmit_enable_rp0_s { + uint8_t Status; +} hci_le_set_connectionless_cte_transmit_enable_rp0; + +typedef PACKED(struct) hci_le_set_connectionless_iq_sampling_enable_cp0_s { + uint16_t Sync_Handle; + uint8_t Sampling_Enable; + uint8_t Slot_Durations; + uint8_t Max_Sampled_CTEs; + uint8_t Switching_Pattern_Length; + uint8_t Antenna_IDs[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} hci_le_set_connectionless_iq_sampling_enable_cp0; + +typedef PACKED(struct) hci_le_set_connectionless_iq_sampling_enable_rp0_s { + uint8_t Status; + uint16_t Sync_Handle; +} hci_le_set_connectionless_iq_sampling_enable_rp0; + +typedef PACKED(struct) hci_le_set_connection_cte_receive_parameters_cp0_s { + uint16_t Connection_Handle; + uint8_t Sampling_Enable; + uint8_t Slot_Durations; + uint8_t Switching_Pattern_Length; + uint8_t Antenna_IDs[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(uint8_t)]; +} hci_le_set_connection_cte_receive_parameters_cp0; + +typedef PACKED(struct) hci_le_set_connection_cte_receive_parameters_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_set_connection_cte_receive_parameters_rp0; + +typedef PACKED(struct) hci_le_set_connection_cte_transmit_parameters_cp0_s { + uint16_t Connection_Handle; + uint8_t CTE_Type; + uint8_t Switching_Pattern_Length; + uint8_t Antenna_IDs[(HCI_MAX_PAYLOAD_SIZE - 4)/sizeof(uint8_t)]; +} hci_le_set_connection_cte_transmit_parameters_cp0; + +typedef PACKED(struct) hci_le_set_connection_cte_transmit_parameters_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_set_connection_cte_transmit_parameters_rp0; + +typedef PACKED(struct) hci_le_connection_cte_request_enable_cp0_s { + uint16_t Connection_Handle; + uint8_t Enable; + uint16_t CTE_Request_Interval; + uint8_t Requested_CTE_Length; + uint8_t Requested_CTE_Type; +} hci_le_connection_cte_request_enable_cp0; + +typedef PACKED(struct) hci_le_connection_cte_request_enable_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_connection_cte_request_enable_rp0; + +typedef PACKED(struct) hci_le_connection_cte_response_enable_cp0_s { + uint16_t Connection_Handle; + uint8_t Enable; +} hci_le_connection_cte_response_enable_cp0; + +typedef PACKED(struct) hci_le_connection_cte_response_enable_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_connection_cte_response_enable_rp0; + +typedef PACKED(struct) hci_le_read_antenna_information_rp0_s { + uint8_t Status; + uint8_t Supported_Switching_Sampling_Rates; + uint8_t Num_Antennae; + uint8_t Max_Switching_Pattern_Length; + uint8_t Max_CTE_Length; +} hci_le_read_antenna_information_rp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_receive_enable_cp0_s { + uint16_t Sync_Handle; + uint8_t Enable; +} hci_le_set_periodic_advertising_receive_enable_cp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_receive_enable_rp0_s { + uint8_t Status; +} hci_le_set_periodic_advertising_receive_enable_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_sync_transfer_cp0_s { + uint16_t Connection_Handle; + uint16_t Service_Data; + uint16_t Sync_Handle; +} hci_le_periodic_advertising_sync_transfer_cp0; + +typedef PACKED(struct) hci_le_periodic_advertising_sync_transfer_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_periodic_advertising_sync_transfer_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_set_info_transfer_cp0_s { + uint16_t Connection_Handle; + uint16_t Service_Data; + uint8_t Advertising_Handle; +} hci_le_periodic_advertising_set_info_transfer_cp0; + +typedef PACKED(struct) hci_le_periodic_advertising_set_info_transfer_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_periodic_advertising_set_info_transfer_rp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_sync_transfer_parameters_cp0_s { + uint16_t Connection_Handle; + uint8_t Mode; + uint16_t Skip; + uint16_t Sync_Timeout; + uint8_t CTE_Type; +} hci_le_set_periodic_advertising_sync_transfer_parameters_cp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_sync_transfer_parameters_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_set_periodic_advertising_sync_transfer_parameters_rp0; + +typedef PACKED(struct) hci_le_set_default_periodic_advertising_sync_transfer_parameters_cp0_s { + uint8_t Mode; + uint16_t Skip; + uint16_t Sync_Timeout; + uint8_t CTE_Type; +} hci_le_set_default_periodic_advertising_sync_transfer_parameters_cp0; + +typedef PACKED(struct) hci_le_set_default_periodic_advertising_sync_transfer_parameters_rp0_s { + uint8_t Status; +} hci_le_set_default_periodic_advertising_sync_transfer_parameters_rp0; + +typedef PACKED(struct) hci_le_read_buffer_size_v2_rp0_s { + uint8_t Status; + uint16_t HC_LE_ACL_Data_Packet_Length; + uint8_t HC_Total_Num_LE_ACL_Data_Packets; + uint16_t ISO_Data_Packet_Length; + uint8_t Total_Num_ISO_Data_Packets; +} hci_le_read_buffer_size_v2_rp0; + +typedef PACKED(struct) hci_le_read_iso_tx_sync_cp0_s { + uint16_t Connection_Handle; +} hci_le_read_iso_tx_sync_cp0; + +typedef PACKED(struct) hci_le_read_iso_tx_sync_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint16_t Packet_Sequence_Number; + uint32_t TX_Time_Stamp; + uint8_t Time_Offset[3]; +} hci_le_read_iso_tx_sync_rp0; + +typedef PACKED(struct) hci_le_set_cig_parameters_cp0_s { + uint8_t CIG_ID; + uint8_t SDU_Interval_C_To_P[3]; + uint8_t SDU_Interval_P_To_C[3]; + uint8_t Worst_Case_SCA; + uint8_t Packing; + uint8_t Framing; + uint16_t Max_Transport_Latency_C_To_P; + uint16_t Max_Transport_Latency_P_To_C; + uint8_t CIS_Count; + packed_CIS_Param_t CIS_Param[(HCI_MAX_PAYLOAD_SIZE - 15)/sizeof(packed_CIS_Param_t)]; +} hci_le_set_cig_parameters_cp0; + +typedef PACKED(struct) hci_le_set_cig_parameters_rp0_s { + uint8_t Status; + uint8_t CIG_ID; + uint8_t CIS_Count; + uint16_t Connection_Handle[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint16_t)]; +} hci_le_set_cig_parameters_rp0; + +typedef PACKED(struct) hci_le_set_cig_parameters_test_cp0_s { + uint8_t CIG_ID; + uint8_t SDU_Interval_C_To_P[3]; + uint8_t SDU_Interval_P_To_C[3]; + uint8_t FT_C_To_P; + uint8_t FT_P_To_C; + uint16_t ISO_Interval; + uint8_t Worst_Case_SCA; + uint8_t Packing; + uint8_t Framing; + uint8_t CIS_Count; + packed_CIS_Param_Test_t CIS_Param_Test[(HCI_MAX_PAYLOAD_SIZE - 15)/sizeof(packed_CIS_Param_Test_t)]; +} hci_le_set_cig_parameters_test_cp0; + +typedef PACKED(struct) hci_le_set_cig_parameters_test_rp0_s { + uint8_t Status; + uint8_t CIG_ID; + uint8_t CIS_Count; + uint16_t Connection_Handle[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint16_t)]; +} hci_le_set_cig_parameters_test_rp0; + +typedef PACKED(struct) hci_le_create_cis_cp0_s { + uint8_t CIS_Count; + packed_CIS_Handles_t CIS_Handles[(HCI_MAX_PAYLOAD_SIZE - 1)/sizeof(packed_CIS_Handles_t)]; +} hci_le_create_cis_cp0; + +typedef PACKED(struct) hci_le_create_cis_rp0_s { + uint8_t Status; +} hci_le_create_cis_rp0; + +typedef PACKED(struct) hci_le_remove_cig_cp0_s { + uint8_t CIG_ID; +} hci_le_remove_cig_cp0; + +typedef PACKED(struct) hci_le_remove_cig_rp0_s { + uint8_t Status; + uint8_t CIG_ID; +} hci_le_remove_cig_rp0; + +typedef PACKED(struct) hci_le_accept_cis_request_cp0_s { + uint16_t Connection_Handle; +} hci_le_accept_cis_request_cp0; + +typedef PACKED(struct) hci_le_accept_cis_request_rp0_s { + uint8_t Status; +} hci_le_accept_cis_request_rp0; + +typedef PACKED(struct) hci_le_reject_cis_request_cp0_s { + uint16_t Connection_Handle; + uint8_t Reason; +} hci_le_reject_cis_request_cp0; + +typedef PACKED(struct) hci_le_reject_cis_request_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_reject_cis_request_rp0; + +typedef PACKED(struct) hci_le_create_big_cp0_s { + uint8_t BIG_Handle; + uint8_t Advertising_Handle; + uint8_t Num_BIS; + uint8_t SDU_Interval[3]; + uint16_t Max_SDU; + uint16_t Max_Transport_Latency; + uint8_t RTN; + uint8_t PHY; + uint8_t Packing; + uint8_t Framing; + uint8_t Encryption; + uint8_t Broadcast_Code[16]; +} hci_le_create_big_cp0; + +typedef PACKED(struct) hci_le_create_big_rp0_s { + uint8_t Status; +} hci_le_create_big_rp0; + +typedef PACKED(struct) hci_le_create_big_test_cp0_s { + uint8_t BIG_Handle; + uint8_t Advertising_Handle; + uint8_t Num_BIS; + uint8_t SDU_Interval[3]; + uint16_t ISO_Interval; + uint8_t NSE; + uint16_t Max_SDU; + uint16_t Max_PDU; + uint8_t PHY; + uint8_t Packing; + uint8_t Framing; + uint8_t BN; + uint8_t IRC; + uint8_t PTO; + uint8_t Encryption; + uint8_t Broadcast_Code[16]; +} hci_le_create_big_test_cp0; + +typedef PACKED(struct) hci_le_create_big_test_rp0_s { + uint8_t Status; +} hci_le_create_big_test_rp0; + +typedef PACKED(struct) hci_le_terminate_big_cp0_s { + uint8_t BIG_Handle; + uint8_t Reason; +} hci_le_terminate_big_cp0; + +typedef PACKED(struct) hci_le_terminate_big_rp0_s { + uint8_t Status; +} hci_le_terminate_big_rp0; + +typedef PACKED(struct) hci_le_big_create_sync_cp0_s { + uint8_t BIG_Handle; + uint16_t Sync_Handle; + uint8_t Encryption; + uint8_t Broadcast_Code[16]; + uint8_t MSE; + uint16_t BIG_Sync_Timeout; + uint8_t Num_BIS; + uint8_t BIS[(HCI_MAX_PAYLOAD_SIZE - 24)/sizeof(uint8_t)]; +} hci_le_big_create_sync_cp0; + +typedef PACKED(struct) hci_le_big_create_sync_rp0_s { + uint8_t Status; +} hci_le_big_create_sync_rp0; + +typedef PACKED(struct) hci_le_big_terminate_sync_cp0_s { + uint8_t BIG_Handle; +} hci_le_big_terminate_sync_cp0; + +typedef PACKED(struct) hci_le_big_terminate_sync_rp0_s { + uint8_t Status; + uint8_t BIG_Handle; +} hci_le_big_terminate_sync_rp0; + +typedef PACKED(struct) hci_le_request_peer_sca_cp0_s { + uint16_t Connection_Handle; +} hci_le_request_peer_sca_cp0; + +typedef PACKED(struct) hci_le_request_peer_sca_rp0_s { + uint8_t Status; +} hci_le_request_peer_sca_rp0; + +typedef PACKED(struct) hci_le_setup_iso_data_path_cp0_s { + uint16_t Connection_Handle; + uint8_t Data_Path_Direction; + uint8_t Data_Path_ID; + uint8_t Codec_ID[5]; + uint8_t Controller_Delay[3]; + uint8_t Codec_Configuration_Length; + uint8_t Codec_Configuration[(HCI_MAX_PAYLOAD_SIZE - 13)/sizeof(uint8_t)]; +} hci_le_setup_iso_data_path_cp0; + +typedef PACKED(struct) hci_le_setup_iso_data_path_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_setup_iso_data_path_rp0; + +typedef PACKED(struct) hci_le_remove_iso_data_path_cp0_s { + uint16_t Connection_Handle; + uint8_t Data_Path_Direction; +} hci_le_remove_iso_data_path_cp0; + +typedef PACKED(struct) hci_le_remove_iso_data_path_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_remove_iso_data_path_rp0; + +typedef PACKED(struct) hci_le_iso_transmit_test_cp0_s { + uint16_t Connection_Handle; + uint8_t Payload_Type; +} hci_le_iso_transmit_test_cp0; + +typedef PACKED(struct) hci_le_iso_transmit_test_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_iso_transmit_test_rp0; + +typedef PACKED(struct) hci_le_iso_receive_test_cp0_s { + uint16_t Connection_Handle; + uint8_t Payload_Type; +} hci_le_iso_receive_test_cp0; + +typedef PACKED(struct) hci_le_iso_receive_test_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_iso_receive_test_rp0; + +typedef PACKED(struct) hci_le_iso_read_test_counters_cp0_s { + uint16_t Connection_Handle; +} hci_le_iso_read_test_counters_cp0; + +typedef PACKED(struct) hci_le_iso_read_test_counters_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint32_t Received_Packet_Count; + uint32_t Missed_Packet_Count; + uint32_t Failed_Packet_Count; +} hci_le_iso_read_test_counters_rp0; + +typedef PACKED(struct) hci_le_iso_test_end_cp0_s { + uint16_t Connection_Handle; +} hci_le_iso_test_end_cp0; + +typedef PACKED(struct) hci_le_iso_test_end_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint32_t Received_Packet_Count; + uint32_t Missed_Packet_Count; + uint32_t Failed_Packet_Count; +} hci_le_iso_test_end_rp0; + +typedef PACKED(struct) hci_le_set_host_feature_cp0_s { + uint8_t Bit_Number; + uint8_t Bit_Value; +} hci_le_set_host_feature_cp0; + +typedef PACKED(struct) hci_le_set_host_feature_rp0_s { + uint8_t Status; +} hci_le_set_host_feature_rp0; + +typedef PACKED(struct) hci_le_read_iso_link_quality_cp0_s { + uint16_t Connection_Handle; +} hci_le_read_iso_link_quality_cp0; + +typedef PACKED(struct) hci_le_read_iso_link_quality_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint32_t Tx_UnACKed_Packets; + uint32_t Tx_Flushed_Packets; + uint32_t Tx_Last_Subevent_Packets; + uint32_t Retransmitted_Packets; + uint32_t CRC_Error_Packets; + uint32_t Rx_Unreceived_Packets; + uint32_t Duplicate_Packets; +} hci_le_read_iso_link_quality_rp0; + +typedef PACKED(struct) hci_le_enhanced_read_transmit_power_level_cp0_s { + uint16_t Connection_Handle; + uint8_t PHY; +} hci_le_enhanced_read_transmit_power_level_cp0; + +typedef PACKED(struct) hci_le_enhanced_read_transmit_power_level_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t PHY; + int8_t Current_Transmit_Power_Level; + int8_t Max_Transmit_Power_Level; +} hci_le_enhanced_read_transmit_power_level_rp0; + +typedef PACKED(struct) hci_le_read_remote_transmit_power_level_cp0_s { + uint16_t Connection_Handle; + uint8_t PHY; +} hci_le_read_remote_transmit_power_level_cp0; + +typedef PACKED(struct) hci_le_read_remote_transmit_power_level_rp0_s { + uint8_t Status; +} hci_le_read_remote_transmit_power_level_rp0; + +typedef PACKED(struct) hci_le_set_path_loss_reporting_parameters_cp0_s { + uint16_t Connection_Handle; + uint8_t High_Threshold; + uint8_t High_Hysteresis; + uint8_t Low_Threshold; + uint8_t Low_Hysteresis; + uint16_t Min_Time_Spent; +} hci_le_set_path_loss_reporting_parameters_cp0; + +typedef PACKED(struct) hci_le_set_path_loss_reporting_parameters_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_set_path_loss_reporting_parameters_rp0; + +typedef PACKED(struct) hci_le_set_path_loss_reporting_enable_cp0_s { + uint16_t Connection_Handle; + uint8_t Enable; +} hci_le_set_path_loss_reporting_enable_cp0; + +typedef PACKED(struct) hci_le_set_path_loss_reporting_enable_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_set_path_loss_reporting_enable_rp0; + +typedef PACKED(struct) hci_le_set_transmit_power_reporting_enable_cp0_s { + uint16_t Connection_Handle; + uint8_t Local_Enable; + uint8_t Remote_Enable; +} hci_le_set_transmit_power_reporting_enable_cp0; + +typedef PACKED(struct) hci_le_set_transmit_power_reporting_enable_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_set_transmit_power_reporting_enable_rp0; + +typedef PACKED(struct) hci_le_transmitter_test_v4_cp0_s { + uint8_t TX_Channel; + uint8_t Test_Data_Length; + uint8_t Packet_Payload; + uint8_t PHY; + uint8_t CTE_Length; + uint8_t CTE_Type; + uint8_t Switching_Pattern_Length; + uint8_t Antenna_IDs[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} hci_le_transmitter_test_v4_cp0; + +typedef PACKED(struct) hci_le_transmitter_test_v4_cp1_s { + int8_t Transmit_Power_Level; +} hci_le_transmitter_test_v4_cp1; + +typedef PACKED(struct) hci_le_transmitter_test_v4_rp0_s { + uint8_t Status; +} hci_le_transmitter_test_v4_rp0; + +typedef PACKED(struct) hci_le_set_data_related_address_changes_cp0_s { + uint8_t Advertising_Handle; + uint8_t Change_Reasons; +} hci_le_set_data_related_address_changes_cp0; + +typedef PACKED(struct) hci_le_set_data_related_address_changes_rp0_s { + uint8_t Status; +} hci_le_set_data_related_address_changes_rp0; + +typedef PACKED(struct) hci_le_set_default_subrate_cp0_s { + uint16_t Subrate_Min; + uint16_t Subrate_Max; + uint16_t Max_Latency; + uint16_t Continuation_Number; + uint16_t Supervision_Timeout; +} hci_le_set_default_subrate_cp0; + +typedef PACKED(struct) hci_le_set_default_subrate_rp0_s { + uint8_t Status; +} hci_le_set_default_subrate_rp0; + +typedef PACKED(struct) hci_le_subrate_request_cp0_s { + uint16_t Connection_Handle; + uint16_t Subrate_Min; + uint16_t Subrate_Max; + uint16_t Max_Latency; + uint16_t Continuation_Number; + uint16_t Supervision_Timeout; +} hci_le_subrate_request_cp0; + +typedef PACKED(struct) hci_le_subrate_request_rp0_s { + uint8_t Status; +} hci_le_subrate_request_rp0; + +typedef PACKED(struct) hci_le_set_extended_advertising_parameters_v2_cp0_s { + uint8_t Advertising_Handle; + uint16_t Advertising_Event_Properties; + uint8_t Primary_Advertising_Interval_Min[3]; + uint8_t Primary_Advertising_Interval_Max[3]; + uint8_t Primary_Advertising_Channel_Map; + uint8_t Own_Address_Type; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Advertising_Filter_Policy; + int8_t Advertising_Tx_Power; + uint8_t Primary_Advertising_PHY; + uint8_t Secondary_Advertising_Max_Skip; + uint8_t Secondary_Advertising_PHY; + uint8_t Advertising_SID; + uint8_t Scan_Request_Notification_Enable; + uint8_t Primary_Advertising_PHY_Options; + uint8_t Secondary_Advertising_PHY_Options; +} hci_le_set_extended_advertising_parameters_v2_cp0; + +typedef PACKED(struct) hci_le_set_extended_advertising_parameters_v2_rp0_s { + uint8_t Status; + int8_t Selected_Tx_Power; +} hci_le_set_extended_advertising_parameters_v2_rp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_subevent_data_cp0_s { + uint8_t Advertising_Handle; + uint8_t Num_Subevents; + packed_Subevent_Data_Parameters_t Subevent_Data_Parameters[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(packed_Subevent_Data_Parameters_t)]; +} hci_le_set_periodic_advertising_subevent_data_cp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_subevent_data_rp0_s { + uint8_t Status; + uint8_t Advertising_Handle; +} hci_le_set_periodic_advertising_subevent_data_rp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_response_data_cp0_s { + uint16_t Sync_Handle; + uint16_t Request_Event; + uint8_t Request_Subevent; + uint8_t Response_Subevent; + uint8_t Response_Slot; + uint8_t Response_Data_Length; + uint8_t Response_Data[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; +} hci_le_set_periodic_advertising_response_data_cp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_response_data_rp0_s { + uint8_t Status; + uint16_t Sync_Handle; +} hci_le_set_periodic_advertising_response_data_rp0; + +typedef PACKED(struct) hci_le_set_periodic_sync_subevent_cp0_s { + uint16_t Sync_Handle; + uint16_t Periodic_Advertising_Properties; + uint8_t Num_Subevents; + uint8_t Subevent[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(uint8_t)]; +} hci_le_set_periodic_sync_subevent_cp0; + +typedef PACKED(struct) hci_le_set_periodic_sync_subevent_rp0_s { + uint8_t Status; + uint16_t Sync_Handle; +} hci_le_set_periodic_sync_subevent_rp0; + +typedef PACKED(struct) hci_le_extended_create_connection_v2_cp0_s { + uint8_t Advertising_Handle; + uint8_t Subevent; + uint8_t Initiator_Filter_Policy; + uint8_t Own_Address_Type; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Initiating_PHYs; + packed_Extended_Create_Connection_Parameters_t Extended_Create_Connection_Parameters[(HCI_MAX_PAYLOAD_SIZE - 12)/sizeof(packed_Extended_Create_Connection_Parameters_t)]; +} hci_le_extended_create_connection_v2_cp0; + +typedef PACKED(struct) hci_le_extended_create_connection_v2_rp0_s { + uint8_t Status; +} hci_le_extended_create_connection_v2_rp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_parameters_v2_cp0_s { + uint8_t Advertising_Handle; + uint16_t Periodic_Advertising_Interval_Min; + uint16_t Periodic_Advertising_Interval_Max; + uint16_t Periodic_Advertising_Properties; + uint8_t Num_Subevents; + uint8_t Subevent_Interval; + uint8_t Response_Slot_Delay; + uint8_t Response_Slot_Spacing; + uint8_t Num_Response_Slots; +} hci_le_set_periodic_advertising_parameters_v2_cp0; + +typedef PACKED(struct) hci_le_set_periodic_advertising_parameters_v2_rp0_s { + uint8_t Status; + uint8_t Advertising_Handle; +} hci_le_set_periodic_advertising_parameters_v2_rp0; + +typedef PACKED(struct) aci_hal_get_fw_build_number_rp0_s { + uint8_t Status; + uint16_t Build_Number; +} aci_hal_get_fw_build_number_rp0; + +typedef PACKED(struct) aci_hal_get_firmware_details_rp0_s { + uint8_t Status; + uint8_t DTM_version_major; + uint8_t DTM_version_minor; + uint8_t DTM_version_patch; + uint8_t DTM_variant; + uint16_t DTM_Build_Number; + uint8_t BTLE_Stack_version_major; + uint8_t BTLE_Stack_version_minor; + uint8_t BTLE_Stack_version_patch; + uint8_t BTLE_Stack_development; + uint16_t BTLE_Stack_variant; + uint16_t BTLE_Stack_Build_Number; +} aci_hal_get_firmware_details_rp0; + +typedef PACKED(struct) aci_hal_get_firmware_details_v2_rp0_s { + uint8_t Status; + uint8_t DTM_version_major; + uint8_t DTM_version_minor; + uint8_t DTM_version_patch; + uint8_t DTM_variant; + uint16_t DTM_Build_Number; + uint8_t BTLE_Stack_version_major; + uint8_t BTLE_Stack_version_minor; + uint8_t BTLE_Stack_version_patch; + uint8_t BTLE_Stack_development; + uint32_t BTLE_Stack_variant; + uint16_t BTLE_Stack_Build_Number; +} aci_hal_get_firmware_details_v2_rp0; + +typedef PACKED(struct) aci_hal_write_config_data_cp0_s { + uint8_t Offset; + uint8_t Length; + uint8_t Value[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint8_t)]; +} aci_hal_write_config_data_cp0; + +typedef PACKED(struct) aci_hal_write_config_data_rp0_s { + uint8_t Status; +} aci_hal_write_config_data_rp0; + +typedef PACKED(struct) aci_hal_read_config_data_cp0_s { + uint8_t Offset; +} aci_hal_read_config_data_cp0; + +typedef PACKED(struct) aci_hal_read_config_data_rp0_s { + uint8_t Status; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint8_t)]; +} aci_hal_read_config_data_rp0; + +typedef PACKED(struct) aci_hal_set_tx_power_level_cp0_s { + uint8_t En_High_Power; + uint8_t PA_Level; +} aci_hal_set_tx_power_level_cp0; + +typedef PACKED(struct) aci_hal_set_tx_power_level_rp0_s { + uint8_t Status; +} aci_hal_set_tx_power_level_rp0; + +typedef PACKED(struct) aci_hal_le_tx_test_packet_number_rp0_s { + uint8_t Status; + uint32_t Number_Of_Packets; +} aci_hal_le_tx_test_packet_number_rp0; + +typedef PACKED(struct) aci_hal_tone_start_cp0_s { + uint8_t RF_Channel; + uint8_t Offset; +} aci_hal_tone_start_cp0; + +typedef PACKED(struct) aci_hal_tone_start_rp0_s { + uint8_t Status; +} aci_hal_tone_start_rp0; + +typedef PACKED(struct) aci_hal_tone_stop_rp0_s { + uint8_t Status; +} aci_hal_tone_stop_rp0; + +typedef PACKED(struct) aci_hal_get_link_status_cp0_s { + uint8_t Bank_index; +} aci_hal_get_link_status_cp0; + +typedef PACKED(struct) aci_hal_get_link_status_rp0_s { + uint8_t Status; + uint8_t Link_Status[8]; + uint16_t Link_Connection_Handle[16 / 2]; +} aci_hal_get_link_status_rp0; + +typedef PACKED(struct) aci_hal_set_radio_activity_mask_cp0_s { + uint16_t Radio_Activity_Mask; +} aci_hal_set_radio_activity_mask_cp0; + +typedef PACKED(struct) aci_hal_set_radio_activity_mask_rp0_s { + uint8_t Status; +} aci_hal_set_radio_activity_mask_rp0; + +typedef PACKED(struct) aci_hal_set_le_power_control_cp0_s { + uint8_t Enable; + uint8_t PHY; + int8_t RSSI_Target; + uint8_t RSSI_Hysteresis; + int8_t Initial_TX_Power; + uint8_t RSSI_Filtering_Coefficient; +} aci_hal_set_le_power_control_cp0; + +typedef PACKED(struct) aci_hal_set_le_power_control_rp0_s { + uint8_t Status; +} aci_hal_set_le_power_control_rp0; + +typedef PACKED(struct) aci_hal_transmitter_test_packets_cp0_s { + uint8_t TX_Frequency; + uint8_t Length_Of_Test_Data; + uint8_t Packet_Payload; + uint16_t Number_Of_Packets; + uint8_t PHY; +} aci_hal_transmitter_test_packets_cp0; + +typedef PACKED(struct) aci_hal_transmitter_test_packets_rp0_s { + uint8_t Status; +} aci_hal_transmitter_test_packets_rp0; + +typedef PACKED(struct) aci_hal_transmitter_test_packets_v2_cp0_s { + uint8_t TX_Channel; + uint8_t Test_Data_Length; + uint8_t Packet_Payload; + uint16_t Number_Of_Packets; + uint8_t PHY; + uint8_t CTE_Length; + uint8_t CTE_Type; + uint8_t Switching_Pattern_Length; + uint8_t Antenna_IDs[(HCI_MAX_PAYLOAD_SIZE - 9)/sizeof(uint8_t)]; +} aci_hal_transmitter_test_packets_v2_cp0; + +typedef PACKED(struct) aci_hal_transmitter_test_packets_v2_rp0_s { + uint8_t Status; +} aci_hal_transmitter_test_packets_v2_rp0; + +typedef PACKED(struct) aci_hal_write_radio_reg_cp0_s { + uint32_t Start_Address; + uint8_t Num_Bytes; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(uint8_t)]; +} aci_hal_write_radio_reg_cp0; + +typedef PACKED(struct) aci_hal_write_radio_reg_rp0_s { + uint8_t Status; +} aci_hal_write_radio_reg_rp0; + +typedef PACKED(struct) aci_hal_read_radio_reg_cp0_s { + uint32_t Start_Address; + uint8_t Num_Bytes; +} aci_hal_read_radio_reg_cp0; + +typedef PACKED(struct) aci_hal_read_radio_reg_rp0_s { + uint8_t Status; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint8_t)]; +} aci_hal_read_radio_reg_rp0; + +typedef PACKED(struct) aci_hal_set_antenna_switch_parameters_cp0_s { + uint8_t Antenna_IDs; + uint8_t Antenna_ID_Shift; + uint8_t Default_Antenna_ID; + uint8_t RF_Activity_Enable; +} aci_hal_set_antenna_switch_parameters_cp0; + +typedef PACKED(struct) aci_hal_set_antenna_switch_parameters_rp0_s { + uint8_t Status; +} aci_hal_set_antenna_switch_parameters_rp0; + +typedef PACKED(struct) aci_hal_peripheral_latency_enable_cp0_s { + uint16_t Connection_Handle; + uint8_t Enable; +} aci_hal_peripheral_latency_enable_cp0; + +typedef PACKED(struct) aci_hal_peripheral_latency_enable_rp0_s { + uint8_t Status; +} aci_hal_peripheral_latency_enable_rp0; + +typedef PACKED(struct) aci_hal_get_evt_fifo_max_level_rp0_s { + uint8_t Status; + uint16_t ISR0_FIFO_Max_Level; + uint16_t ISR1_FIFO_Max_Level; + uint16_t User_FIFO_Max_Level; +} aci_hal_get_evt_fifo_max_level_rp0; + +typedef PACKED(struct) aci_gap_init_cp0_s { + uint8_t Privacy_Type; + uint8_t Identity_Address_Type; +} aci_gap_init_cp0; + +typedef PACKED(struct) aci_gap_init_rp0_s { + uint8_t Status; +} aci_gap_init_rp0; + +typedef PACKED(struct) aci_gap_set_io_capability_cp0_s { + uint8_t IO_Capability; +} aci_gap_set_io_capability_cp0; + +typedef PACKED(struct) aci_gap_set_io_capability_rp0_s { + uint8_t Status; +} aci_gap_set_io_capability_rp0; + +typedef PACKED(struct) aci_gap_set_security_requirements_cp0_s { + uint8_t Bonding_Mode; + uint8_t MITM_Mode; + uint8_t SC_Support; + uint8_t KeyPress_Notification_Support; + uint8_t Min_Encryption_Key_Size; + uint8_t Max_Encryption_Key_Size; + uint8_t Pairing_Response; +} aci_gap_set_security_requirements_cp0; + +typedef PACKED(struct) aci_gap_set_security_requirements_rp0_s { + uint8_t Status; +} aci_gap_set_security_requirements_rp0; + +typedef PACKED(struct) aci_gap_passkey_resp_cp0_s { + uint16_t Connection_Handle; + uint32_t Passkey; +} aci_gap_passkey_resp_cp0; + +typedef PACKED(struct) aci_gap_passkey_resp_rp0_s { + uint8_t Status; +} aci_gap_passkey_resp_rp0; + +typedef PACKED(struct) aci_gap_profile_init_cp0_s { + uint8_t Role; + uint8_t Privacy_Type; +} aci_gap_profile_init_cp0; + +typedef PACKED(struct) aci_gap_profile_init_rp0_s { + uint8_t Status; + uint16_t Dev_Name_Char_Handle; + uint16_t Appearance_Char_Handle; + uint16_t Periph_Pref_Conn_Param_Char_Handle; +} aci_gap_profile_init_rp0; + +typedef PACKED(struct) aci_gap_set_security_cp0_s { + uint16_t Connection_Handle; + uint8_t Security_Level; + uint8_t Force_Pairing; +} aci_gap_set_security_cp0; + +typedef PACKED(struct) aci_gap_set_security_rp0_s { + uint8_t Status; +} aci_gap_set_security_rp0; + +typedef PACKED(struct) aci_gap_get_security_level_cp0_s { + uint16_t Connection_Handle; +} aci_gap_get_security_level_cp0; + +typedef PACKED(struct) aci_gap_get_security_level_rp0_s { + uint8_t Status; + uint8_t Security_Mode; + uint8_t Security_Level; +} aci_gap_get_security_level_rp0; + +typedef PACKED(struct) aci_gap_set_le_event_mask_cp0_s { + uint8_t LE_Event_Mask[8]; +} aci_gap_set_le_event_mask_cp0; + +typedef PACKED(struct) aci_gap_set_le_event_mask_rp0_s { + uint8_t Status; +} aci_gap_set_le_event_mask_rp0; + +typedef PACKED(struct) aci_gap_terminate_cp0_s { + uint16_t Connection_Handle; + uint8_t Reason; +} aci_gap_terminate_cp0; + +typedef PACKED(struct) aci_gap_terminate_rp0_s { + uint8_t Status; +} aci_gap_terminate_rp0; + +typedef PACKED(struct) aci_gap_clear_security_db_rp0_s { + uint8_t Status; +} aci_gap_clear_security_db_rp0; + +typedef PACKED(struct) aci_gap_pairing_resp_cp0_s { + uint16_t Connection_Handle; + uint8_t Accept; +} aci_gap_pairing_resp_cp0; + +typedef PACKED(struct) aci_gap_pairing_resp_rp0_s { + uint8_t Status; +} aci_gap_pairing_resp_rp0; + +typedef PACKED(struct) aci_gap_create_connection_cp0_s { + uint8_t Initiating_PHY; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; +} aci_gap_create_connection_cp0; + +typedef PACKED(struct) aci_gap_create_connection_rp0_s { + uint8_t Status; +} aci_gap_create_connection_rp0; + +typedef PACKED(struct) aci_gap_terminate_proc_cp0_s { + uint8_t Procedure_Code; +} aci_gap_terminate_proc_cp0; + +typedef PACKED(struct) aci_gap_terminate_proc_rp0_s { + uint8_t Status; +} aci_gap_terminate_proc_rp0; + +typedef PACKED(struct) aci_gap_start_connection_update_cp0_s { + uint16_t Connection_Handle; + uint16_t Connection_Interval_Min; + uint16_t Connection_Interval_Max; + uint16_t Max_Latency; + uint16_t Supervision_Timeout; + uint16_t Min_CE_Length; + uint16_t Max_CE_Length; +} aci_gap_start_connection_update_cp0; + +typedef PACKED(struct) aci_gap_start_connection_update_rp0_s { + uint8_t Status; +} aci_gap_start_connection_update_rp0; + +typedef PACKED(struct) aci_gap_resolve_private_addr_cp0_s { + uint8_t Address[6]; +} aci_gap_resolve_private_addr_cp0; + +typedef PACKED(struct) aci_gap_resolve_private_addr_rp0_s { + uint8_t Status; + uint8_t Actual_Address[6]; +} aci_gap_resolve_private_addr_rp0; + +typedef PACKED(struct) aci_gap_get_bonded_devices_cp0_s { + uint8_t Offset; + uint8_t Max_Num_Of_Addresses; +} aci_gap_get_bonded_devices_cp0; + +typedef PACKED(struct) aci_gap_get_bonded_devices_rp0_s { + uint8_t Status; + uint8_t Num_of_Addresses; + packed_Bonded_Device_Entry_t Bonded_Device_Entry[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(packed_Bonded_Device_Entry_t)]; +} aci_gap_get_bonded_devices_rp0; + +typedef PACKED(struct) aci_gap_is_device_bonded_cp0_s { + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; +} aci_gap_is_device_bonded_cp0; + +typedef PACKED(struct) aci_gap_is_device_bonded_rp0_s { + uint8_t Status; +} aci_gap_is_device_bonded_rp0; + +typedef PACKED(struct) aci_gap_numeric_comparison_value_confirm_yesno_cp0_s { + uint16_t Connection_Handle; + uint8_t Confirm_Yes_No; +} aci_gap_numeric_comparison_value_confirm_yesno_cp0; + +typedef PACKED(struct) aci_gap_numeric_comparison_value_confirm_yesno_rp0_s { + uint8_t Status; +} aci_gap_numeric_comparison_value_confirm_yesno_rp0; + +typedef PACKED(struct) aci_gap_passkey_input_cp0_s { + uint16_t Connection_Handle; + uint8_t Input_Type; +} aci_gap_passkey_input_cp0; + +typedef PACKED(struct) aci_gap_passkey_input_rp0_s { + uint8_t Status; +} aci_gap_passkey_input_rp0; + +typedef PACKED(struct) aci_gap_get_oob_data_cp0_s { + uint8_t OOB_Data_Type; +} aci_gap_get_oob_data_cp0; + +typedef PACKED(struct) aci_gap_get_oob_data_rp0_s { + uint8_t Status; + uint8_t Address_Type; + uint8_t Address[6]; + uint8_t OOB_Data_Type; + uint8_t OOB_Data_Len; + uint8_t OOB_Data[16]; +} aci_gap_get_oob_data_rp0; + +typedef PACKED(struct) aci_gap_set_oob_data_cp0_s { + uint8_t Device_Type; + uint8_t Address_Type; + uint8_t Address[6]; + uint8_t OOB_Data_Type; + uint8_t OOB_Data_Len; + uint8_t OOB_Data[16]; +} aci_gap_set_oob_data_cp0; + +typedef PACKED(struct) aci_gap_set_oob_data_rp0_s { + uint8_t Status; +} aci_gap_set_oob_data_rp0; + +typedef PACKED(struct) aci_gap_remove_bonded_device_cp0_s { + uint8_t Peer_Identity_Address_Type; + uint8_t Peer_Identity_Address[6]; +} aci_gap_remove_bonded_device_cp0; + +typedef PACKED(struct) aci_gap_remove_bonded_device_rp0_s { + uint8_t Status; +} aci_gap_remove_bonded_device_rp0; + +typedef PACKED(struct) aci_gap_set_advertising_configuration_cp0_s { + uint8_t Advertising_Handle; + uint8_t Discoverable_Mode; + uint16_t Advertising_Event_Properties; + uint32_t Primary_Advertising_Interval_Min; + uint32_t Primary_Advertising_Interval_Max; + uint8_t Primary_Advertising_Channel_Map; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Advertising_Filter_Policy; + int8_t Advertising_Tx_Power; + uint8_t Primary_Advertising_PHY; + uint8_t Secondary_Advertising_Max_Skip; + uint8_t Secondary_Advertising_PHY; + uint8_t Advertising_SID; + uint8_t Scan_Request_Notification_Enable; +} aci_gap_set_advertising_configuration_cp0; + +typedef PACKED(struct) aci_gap_set_advertising_configuration_rp0_s { + uint8_t Status; +} aci_gap_set_advertising_configuration_rp0; + +typedef PACKED(struct) aci_gap_set_advertising_enable_cp0_s { + uint8_t Enable; + uint8_t Number_of_Sets; + packed_Advertising_Set_Parameters_t Advertising_Set_Parameters[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(packed_Advertising_Set_Parameters_t)]; +} aci_gap_set_advertising_enable_cp0; + +typedef PACKED(struct) aci_gap_set_advertising_enable_rp0_s { + uint8_t Status; +} aci_gap_set_advertising_enable_rp0; + +typedef PACKED(struct) aci_gap_set_advertising_data_nwk_cp0_s { + uint8_t Advertising_Handle; + uint8_t Operation; + uint8_t Advertising_Data_Length; + uint8_t Advertising_Data[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint8_t)]; +} aci_gap_set_advertising_data_nwk_cp0; + +typedef PACKED(struct) aci_gap_set_advertising_data_nwk_rp0_s { + uint8_t Status; +} aci_gap_set_advertising_data_nwk_rp0; + +typedef PACKED(struct) aci_gap_set_scan_response_data_nwk_cp0_s { + uint8_t Advertising_Handle; + uint8_t Operation; + uint8_t Scan_Response_Data_Length; + uint8_t Scan_Response_Data[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint8_t)]; +} aci_gap_set_scan_response_data_nwk_cp0; + +typedef PACKED(struct) aci_gap_set_scan_response_data_nwk_rp0_s { + uint8_t Status; +} aci_gap_set_scan_response_data_nwk_rp0; + +typedef PACKED(struct) aci_gap_set_scan_configuration_cp0_s { + uint8_t Filter_Duplicates; + uint8_t Scanning_Filter_Policy; + uint8_t Scanning_PHY; + uint8_t Scan_Type; + uint16_t Scan_Interval; + uint16_t Scan_Window; +} aci_gap_set_scan_configuration_cp0; + +typedef PACKED(struct) aci_gap_set_scan_configuration_rp0_s { + uint8_t Status; +} aci_gap_set_scan_configuration_rp0; + +typedef PACKED(struct) aci_gap_set_connection_configuration_cp0_s { + uint8_t Initiating_PHY; + uint16_t Connection_Interval_Min; + uint16_t Connection_Interval_Max; + uint16_t Max_Latency; + uint16_t Supervision_Timeout; + uint16_t Min_CE_Length; + uint16_t Max_CE_Length; +} aci_gap_set_connection_configuration_cp0; + +typedef PACKED(struct) aci_gap_set_connection_configuration_rp0_s { + uint8_t Status; +} aci_gap_set_connection_configuration_rp0; + +typedef PACKED(struct) aci_gap_start_procedure_cp0_s { + uint8_t Procedure_Code; + uint8_t PHYs; + uint16_t Duration; + uint16_t Period; +} aci_gap_start_procedure_cp0; + +typedef PACKED(struct) aci_gap_start_procedure_rp0_s { + uint8_t Status; +} aci_gap_start_procedure_rp0; + +typedef PACKED(struct) aci_gap_discover_name_cp0_s { + uint8_t PHYs; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; +} aci_gap_discover_name_cp0; + +typedef PACKED(struct) aci_gap_discover_name_rp0_s { + uint8_t Status; +} aci_gap_discover_name_rp0; + +typedef PACKED(struct) aci_gap_add_devices_to_filter_accept_and_resolving_list_cp0_s { + uint8_t Lists; + uint8_t Clear_Lists; + uint8_t Num_of_List_Entries; + packed_List_Entry_t List_Entry[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(packed_List_Entry_t)]; +} aci_gap_add_devices_to_filter_accept_and_resolving_list_cp0; + +typedef PACKED(struct) aci_gap_add_devices_to_filter_accept_and_resolving_list_rp0_s { + uint8_t Status; +} aci_gap_add_devices_to_filter_accept_and_resolving_list_rp0; + +typedef PACKED(struct) aci_gap_configure_filter_accept_and_resolving_list_cp0_s { + uint8_t Lists; +} aci_gap_configure_filter_accept_and_resolving_list_cp0; + +typedef PACKED(struct) aci_gap_configure_filter_accept_and_resolving_list_rp0_s { + uint8_t Status; +} aci_gap_configure_filter_accept_and_resolving_list_rp0; + +typedef PACKED(struct) aci_gap_remove_advertising_set_cp0_s { + uint8_t Advertising_Handle; +} aci_gap_remove_advertising_set_cp0; + +typedef PACKED(struct) aci_gap_remove_advertising_set_rp0_s { + uint8_t Status; +} aci_gap_remove_advertising_set_rp0; + +typedef PACKED(struct) aci_gap_clear_advertising_sets_rp0_s { + uint8_t Status; +} aci_gap_clear_advertising_sets_rp0; + +typedef PACKED(struct) aci_gap_create_periodic_advertising_connection_cp0_s { + uint8_t Advertising_Handle; + uint8_t Subevent; + uint8_t Initiator_Filter_Policy; + uint8_t Own_Address_Type; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint16_t Connection_Interval_Min; + uint16_t Connection_Interval_Max; + uint16_t Max_Latency; + uint16_t Supervision_Timeout; + uint16_t Min_CE_Length; + uint16_t Max_CE_Length; +} aci_gap_create_periodic_advertising_connection_cp0; + +typedef PACKED(struct) aci_gap_create_periodic_advertising_connection_rp0_s { + uint8_t Status; +} aci_gap_create_periodic_advertising_connection_rp0; + +typedef PACKED(struct) aci_gap_encrypt_adv_data_nwk_cp0_s { + uint8_t Session_Key[16]; + uint8_t IV[8]; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 25)/sizeof(uint8_t)]; +} aci_gap_encrypt_adv_data_nwk_cp0; + +typedef PACKED(struct) aci_gap_encrypt_adv_data_nwk_rp0_s { + uint8_t Status; + uint8_t Encrypted_Data_Length; + uint8_t Encrypted_Data[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint8_t)]; +} aci_gap_encrypt_adv_data_nwk_rp0; + +typedef PACKED(struct) aci_gap_decrypt_adv_data_nwk_cp0_s { + uint8_t Session_Key[16]; + uint8_t IV[8]; + uint8_t Encrypted_Data_Length; + uint8_t Encrypted_Data[(HCI_MAX_PAYLOAD_SIZE - 25)/sizeof(uint8_t)]; +} aci_gap_decrypt_adv_data_nwk_cp0; + +typedef PACKED(struct) aci_gap_decrypt_adv_data_nwk_rp0_s { + uint8_t Status; + uint8_t Decrypted_Data_Length; + uint8_t Decrypted_Data[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint8_t)]; +} aci_gap_decrypt_adv_data_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_profile_init_cp0_s { + uint8_t Characteristics; +} aci_gatt_srv_profile_init_cp0; + +typedef PACKED(struct) aci_gatt_srv_profile_init_rp0_s { + uint8_t Status; + uint16_t Service_Changed_Handle; +} aci_gatt_srv_profile_init_rp0; + +typedef PACKED(struct) aci_gatt_srv_add_service_nwk_cp0_s { + uint8_t Service_UUID_Type; + packed_Service_UUID_t Service_UUID; +} aci_gatt_srv_add_service_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_add_service_nwk_cp1_s { + uint8_t Service_Type; + uint8_t Max_Attribute_Records; +} aci_gatt_srv_add_service_nwk_cp1; + +typedef PACKED(struct) aci_gatt_srv_add_service_nwk_rp0_s { + uint8_t Status; + uint16_t Service_Handle; +} aci_gatt_srv_add_service_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_include_service_nwk_cp0_s { + uint16_t Service_Handle; + uint16_t Included_Service_Handle; +} aci_gatt_srv_include_service_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_include_service_nwk_rp0_s { + uint8_t Status; + uint16_t Include_Handle; +} aci_gatt_srv_include_service_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_add_char_nwk_cp0_s { + uint16_t Service_Handle; + uint8_t Char_UUID_Type; + packed_Char_UUID_t Char_UUID; +} aci_gatt_srv_add_char_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_add_char_nwk_cp1_s { + uint16_t Char_Value_Length; + uint8_t Char_Properties; + uint8_t Security_Permissions; + uint8_t GATT_Evt_Mask; + uint8_t Enc_Key_Size; + uint8_t Is_Variable; +} aci_gatt_srv_add_char_nwk_cp1; + +typedef PACKED(struct) aci_gatt_srv_add_char_nwk_rp0_s { + uint8_t Status; + uint16_t Char_Handle; +} aci_gatt_srv_add_char_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_add_char_desc_nwk_cp0_s { + uint16_t Char_Handle; + uint8_t Char_Desc_Uuid_Type; + packed_Char_Desc_Uuid_t Char_Desc_Uuid; +} aci_gatt_srv_add_char_desc_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_add_char_desc_nwk_cp1_s { + uint16_t Char_Desc_Value_Max_Len; + uint16_t Char_Desc_Value_Length; + uint8_t Char_Desc_Value[(HCI_MAX_PAYLOAD_SIZE - 4)/sizeof(uint8_t)]; +} aci_gatt_srv_add_char_desc_nwk_cp1; + +typedef PACKED(struct) aci_gatt_srv_add_char_desc_nwk_cp2_s { + uint8_t Security_Permissions; + uint8_t Access_Permissions; + uint8_t GATT_Evt_Mask; + uint8_t Enc_Key_Size; + uint8_t Is_Variable; +} aci_gatt_srv_add_char_desc_nwk_cp2; + +typedef PACKED(struct) aci_gatt_srv_add_char_desc_nwk_rp0_s { + uint8_t Status; + uint16_t Char_Desc_Handle; +} aci_gatt_srv_add_char_desc_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_write_handle_value_nwk_cp0_s { + uint16_t Attr_Handle; + uint16_t Val_Offset; + uint16_t Value_Length; + uint8_t Value[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_gatt_srv_write_handle_value_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_write_handle_value_nwk_rp0_s { + uint8_t Status; +} aci_gatt_srv_write_handle_value_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_rm_char_nwk_cp0_s { + uint16_t Char_Handle; +} aci_gatt_srv_rm_char_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_rm_char_nwk_rp0_s { + uint8_t Status; +} aci_gatt_srv_rm_char_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_rm_service_nwk_cp0_s { + uint16_t Serv_Handle; +} aci_gatt_srv_rm_service_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_rm_service_nwk_rp0_s { + uint8_t Status; +} aci_gatt_srv_rm_service_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_rm_include_service_nwk_cp0_s { + uint16_t Include_Handle; +} aci_gatt_srv_rm_include_service_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_rm_include_service_nwk_rp0_s { + uint8_t Status; +} aci_gatt_srv_rm_include_service_nwk_rp0; + +typedef PACKED(struct) aci_gatt_set_event_mask_cp0_s { + uint32_t GATT_Evt_Mask; +} aci_gatt_set_event_mask_cp0; + +typedef PACKED(struct) aci_gatt_set_event_mask_rp0_s { + uint8_t Status; +} aci_gatt_set_event_mask_rp0; + +typedef PACKED(struct) aci_gatt_clt_exchange_config_cp0_s { + uint16_t Connection_Handle; +} aci_gatt_clt_exchange_config_cp0; + +typedef PACKED(struct) aci_gatt_clt_exchange_config_rp0_s { + uint8_t Status; +} aci_gatt_clt_exchange_config_rp0; + +typedef PACKED(struct) aci_gatt_clt_prepare_write_req_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint16_t Val_Offset; + uint16_t Attribute_Val_Length; + uint8_t Attribute_Val[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; +} aci_gatt_clt_prepare_write_req_cp0; + +typedef PACKED(struct) aci_gatt_clt_prepare_write_req_rp0_s { + uint8_t Status; +} aci_gatt_clt_prepare_write_req_rp0; + +typedef PACKED(struct) aci_gatt_clt_execute_write_req_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Execute; +} aci_gatt_clt_execute_write_req_cp0; + +typedef PACKED(struct) aci_gatt_clt_execute_write_req_rp0_s { + uint8_t Status; +} aci_gatt_clt_execute_write_req_rp0; + +typedef PACKED(struct) aci_gatt_clt_disc_all_primary_services_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; +} aci_gatt_clt_disc_all_primary_services_cp0; + +typedef PACKED(struct) aci_gatt_clt_disc_all_primary_services_rp0_s { + uint8_t Status; +} aci_gatt_clt_disc_all_primary_services_rp0; + +typedef PACKED(struct) aci_gatt_clt_disc_primary_service_by_uuid_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t UUID_Type; + packed_UUID_t UUID; +} aci_gatt_clt_disc_primary_service_by_uuid_cp0; + +typedef PACKED(struct) aci_gatt_clt_disc_primary_service_by_uuid_rp0_s { + uint8_t Status; +} aci_gatt_clt_disc_primary_service_by_uuid_rp0; + +typedef PACKED(struct) aci_gatt_clt_find_included_services_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Start_Handle; + uint16_t End_Handle; +} aci_gatt_clt_find_included_services_cp0; + +typedef PACKED(struct) aci_gatt_clt_find_included_services_rp0_s { + uint8_t Status; +} aci_gatt_clt_find_included_services_rp0; + +typedef PACKED(struct) aci_gatt_clt_disc_all_char_of_service_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Start_Handle; + uint16_t End_Handle; +} aci_gatt_clt_disc_all_char_of_service_cp0; + +typedef PACKED(struct) aci_gatt_clt_disc_all_char_of_service_rp0_s { + uint8_t Status; +} aci_gatt_clt_disc_all_char_of_service_rp0; + +typedef PACKED(struct) aci_gatt_clt_disc_char_by_uuid_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Start_Handle; + uint16_t End_Handle; + uint8_t UUID_Type; + packed_UUID_t UUID; +} aci_gatt_clt_disc_char_by_uuid_cp0; + +typedef PACKED(struct) aci_gatt_clt_disc_char_by_uuid_rp0_s { + uint8_t Status; +} aci_gatt_clt_disc_char_by_uuid_rp0; + +typedef PACKED(struct) aci_gatt_clt_disc_all_char_desc_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Char_Handle; + uint16_t End_Handle; +} aci_gatt_clt_disc_all_char_desc_cp0; + +typedef PACKED(struct) aci_gatt_clt_disc_all_char_desc_rp0_s { + uint8_t Status; +} aci_gatt_clt_disc_all_char_desc_rp0; + +typedef PACKED(struct) aci_gatt_clt_read_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; +} aci_gatt_clt_read_cp0; + +typedef PACKED(struct) aci_gatt_clt_read_rp0_s { + uint8_t Status; +} aci_gatt_clt_read_rp0; + +typedef PACKED(struct) aci_gatt_clt_read_using_char_uuid_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Start_Handle; + uint16_t End_Handle; + uint8_t UUID_Type; + packed_UUID_t UUID; +} aci_gatt_clt_read_using_char_uuid_cp0; + +typedef PACKED(struct) aci_gatt_clt_read_using_char_uuid_rp0_s { + uint8_t Status; +} aci_gatt_clt_read_using_char_uuid_rp0; + +typedef PACKED(struct) aci_gatt_clt_read_long_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint16_t Val_Offset; +} aci_gatt_clt_read_long_cp0; + +typedef PACKED(struct) aci_gatt_clt_read_long_rp0_s { + uint8_t Status; +} aci_gatt_clt_read_long_rp0; + +typedef PACKED(struct) aci_gatt_clt_read_multiple_char_value_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Number_of_Handles; + uint16_t Handle[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(uint16_t)]; +} aci_gatt_clt_read_multiple_char_value_cp0; + +typedef PACKED(struct) aci_gatt_clt_read_multiple_char_value_rp0_s { + uint8_t Status; +} aci_gatt_clt_read_multiple_char_value_rp0; + +typedef PACKED(struct) aci_gatt_clt_write_nwk_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint16_t Attribute_Val_Length; + uint8_t Attribute_Val[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; +} aci_gatt_clt_write_nwk_cp0; + +typedef PACKED(struct) aci_gatt_clt_write_nwk_rp0_s { + uint8_t Status; +} aci_gatt_clt_write_nwk_rp0; + +typedef PACKED(struct) aci_gatt_clt_write_long_nwk_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint16_t Val_Offset; + uint16_t Attribute_Val_Length; + uint8_t Attribute_Val[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; +} aci_gatt_clt_write_long_nwk_cp0; + +typedef PACKED(struct) aci_gatt_clt_write_long_nwk_rp0_s { + uint8_t Status; +} aci_gatt_clt_write_long_nwk_rp0; + +typedef PACKED(struct) aci_gatt_clt_write_char_reliable_nwk_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint16_t Val_Offset; + uint16_t Attribute_Val_Length; + uint8_t Attribute_Val[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; +} aci_gatt_clt_write_char_reliable_nwk_cp0; + +typedef PACKED(struct) aci_gatt_clt_write_char_reliable_nwk_rp0_s { + uint8_t Status; +} aci_gatt_clt_write_char_reliable_nwk_rp0; + +typedef PACKED(struct) aci_gatt_clt_write_without_resp_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint16_t Attribute_Val_Length; + uint8_t Attribute_Val[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; +} aci_gatt_clt_write_without_resp_cp0; + +typedef PACKED(struct) aci_gatt_clt_write_without_resp_rp0_s { + uint8_t Status; +} aci_gatt_clt_write_without_resp_rp0; + +typedef PACKED(struct) aci_gatt_clt_signed_write_without_resp_cp0_s { + uint16_t Connection_Handle; + uint16_t Attr_Handle; + uint16_t Attribute_Val_Length; + uint8_t Attribute_Val[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_gatt_clt_signed_write_without_resp_cp0; + +typedef PACKED(struct) aci_gatt_clt_signed_write_without_resp_rp0_s { + uint8_t Status; +} aci_gatt_clt_signed_write_without_resp_rp0; + +typedef PACKED(struct) aci_gatt_clt_confirm_indication_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; +} aci_gatt_clt_confirm_indication_cp0; + +typedef PACKED(struct) aci_gatt_clt_confirm_indication_rp0_s { + uint8_t Status; +} aci_gatt_clt_confirm_indication_rp0; + +typedef PACKED(struct) aci_gatt_srv_set_security_permission_nwk_cp0_s { + uint16_t Attr_Handle; + uint8_t Security_Permissions; +} aci_gatt_srv_set_security_permission_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_set_security_permission_nwk_rp0_s { + uint8_t Status; +} aci_gatt_srv_set_security_permission_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_read_handle_value_nwk_cp0_s { + uint16_t Attr_Handle; + uint16_t Offset; + uint16_t Value_Length_Requested; +} aci_gatt_srv_read_handle_value_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_read_handle_value_nwk_rp0_s { + uint8_t Status; + uint16_t Length; + uint16_t Value_Length; + uint8_t Value[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(uint8_t)]; +} aci_gatt_srv_read_handle_value_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_set_access_permission_nwk_cp0_s { + uint16_t Attr_Handle; + uint8_t Access_Permissions; +} aci_gatt_srv_set_access_permission_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_set_access_permission_nwk_rp0_s { + uint8_t Status; +} aci_gatt_srv_set_access_permission_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_notify_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint8_t Flags; + uint16_t Val_Length; + uint8_t Val[(HCI_MAX_PAYLOAD_SIZE - 9)/sizeof(uint8_t)]; +} aci_gatt_srv_notify_cp0; + +typedef PACKED(struct) aci_gatt_srv_notify_rp0_s { + uint8_t Status; +} aci_gatt_srv_notify_rp0; + +typedef PACKED(struct) aci_gatt_srv_exec_write_resp_nwk_cp0_s { + uint16_t Conn_Handle; + uint16_t CID; + uint8_t Exec; +} aci_gatt_srv_exec_write_resp_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_exec_write_resp_nwk_rp0_s { + uint8_t Status; +} aci_gatt_srv_exec_write_resp_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_authorize_resp_nwk_cp0_s { + uint16_t Conn_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint8_t Operation_Type; + uint8_t Error_Code; + uint16_t Attr_Val_Offset; + uint16_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 12)/sizeof(uint8_t)]; +} aci_gatt_srv_authorize_resp_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_authorize_resp_nwk_rp0_s { + uint8_t Status; +} aci_gatt_srv_authorize_resp_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_read_prepare_queue_nwk_cp0_s { + uint16_t Conn_Handle; + uint8_t Item_Index; +} aci_gatt_srv_read_prepare_queue_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_read_prepare_queue_nwk_rp0_s { + uint8_t Status; + uint16_t Attr_Handle; + uint16_t Value_Offset; + uint16_t Value_Length; + uint8_t Value[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} aci_gatt_srv_read_prepare_queue_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_write_multiple_instance_handle_value_cp0_s { + uint16_t Connection_Handle; + uint16_t Attr_Handle; + uint16_t Value_Length; + uint8_t Value[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_gatt_srv_write_multiple_instance_handle_value_cp0; + +typedef PACKED(struct) aci_gatt_srv_write_multiple_instance_handle_value_rp0_s { + uint8_t Status; +} aci_gatt_srv_write_multiple_instance_handle_value_rp0; + +typedef PACKED(struct) aci_gatt_srv_read_multiple_instance_handle_value_nwk_cp0_s { + uint16_t Connection_Handle; + uint16_t Attr_Handle; +} aci_gatt_srv_read_multiple_instance_handle_value_nwk_cp0; + +typedef PACKED(struct) aci_gatt_srv_read_multiple_instance_handle_value_nwk_rp0_s { + uint8_t Status; + uint16_t Value_Length; + uint8_t Value[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint8_t)]; +} aci_gatt_srv_read_multiple_instance_handle_value_nwk_rp0; + +typedef PACKED(struct) aci_gatt_srv_multi_notify_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Flags; + uint8_t Num_Of_Attr; + packed_Gatt_Srv_Notify_Attr_t Gatt_Srv_Notify_Attr[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(packed_Gatt_Srv_Notify_Attr_t)]; +} aci_gatt_srv_multi_notify_cp0; + +typedef PACKED(struct) aci_gatt_srv_multi_notify_rp0_s { + uint8_t Status; +} aci_gatt_srv_multi_notify_rp0; + +typedef PACKED(struct) aci_gatt_clt_read_multiple_var_len_char_value_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Number_of_Handles; + uint16_t Handle[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(uint16_t)]; +} aci_gatt_clt_read_multiple_var_len_char_value_cp0; + +typedef PACKED(struct) aci_gatt_clt_read_multiple_var_len_char_value_rp0_s { + uint8_t Status; +} aci_gatt_clt_read_multiple_var_len_char_value_rp0; + +typedef PACKED(struct) aci_l2cap_connection_parameter_update_req_cp0_s { + uint16_t Connection_Handle; + uint16_t Connection_Interval_Min; + uint16_t Connection_Interval_Max; + uint16_t Peripheral_Latency; + uint16_t Timeout_Multiplier; +} aci_l2cap_connection_parameter_update_req_cp0; + +typedef PACKED(struct) aci_l2cap_connection_parameter_update_req_rp0_s { + uint8_t Status; +} aci_l2cap_connection_parameter_update_req_rp0; + +typedef PACKED(struct) aci_l2cap_connection_parameter_update_resp_cp0_s { + uint16_t Connection_Handle; + uint16_t Connection_Interval_Min; + uint16_t Connection_Interval_Max; + uint16_t Peripheral_Latency; + uint16_t Timeout_Multiplier; + uint16_t Min_CE_Length; + uint16_t Max_CE_Length; + uint8_t Identifier; + uint8_t Accept; +} aci_l2cap_connection_parameter_update_resp_cp0; + +typedef PACKED(struct) aci_l2cap_connection_parameter_update_resp_rp0_s { + uint8_t Status; +} aci_l2cap_connection_parameter_update_resp_rp0; + +typedef PACKED(struct) aci_l2cap_cos_connection_req_cp0_s { + uint16_t Connection_Handle; + uint16_t SPSM; + uint16_t MTU; + uint16_t MPS; + uint8_t Channel_Type; + uint8_t CID_Count; +} aci_l2cap_cos_connection_req_cp0; + +typedef PACKED(struct) aci_l2cap_cos_connection_req_rp0_s { + uint8_t Status; +} aci_l2cap_cos_connection_req_rp0; + +typedef PACKED(struct) aci_l2cap_cos_connection_resp_cp0_s { + uint16_t Connection_Handle; + uint8_t Identifier; + uint16_t MTU; + uint16_t MPS; + uint16_t Result; + uint8_t CID_Count; +} aci_l2cap_cos_connection_resp_cp0; + +typedef PACKED(struct) aci_l2cap_cos_connection_resp_rp0_s { + uint8_t Status; + uint8_t CID_Count; + uint16_t CID[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint16_t)]; +} aci_l2cap_cos_connection_resp_rp0; + +typedef PACKED(struct) aci_l2cap_cos_disconnect_req_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; +} aci_l2cap_cos_disconnect_req_cp0; + +typedef PACKED(struct) aci_l2cap_cos_disconnect_req_rp0_s { + uint8_t Status; +} aci_l2cap_cos_disconnect_req_rp0; + +typedef PACKED(struct) aci_l2cap_cos_sdu_data_transmit_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t SDU_Length; + uint8_t SDU_Data[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_l2cap_cos_sdu_data_transmit_cp0; + +typedef PACKED(struct) aci_l2cap_cos_sdu_data_transmit_rp0_s { + uint8_t Status; +} aci_l2cap_cos_sdu_data_transmit_rp0; + +typedef PACKED(struct) aci_l2cap_cos_reconfigure_req_cp0_s { + uint16_t Connection_Handle; + uint16_t MTU; + uint16_t MPS; + uint8_t CID_Count; + uint16_t CID[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint16_t)]; +} aci_l2cap_cos_reconfigure_req_cp0; + +typedef PACKED(struct) aci_l2cap_cos_reconfigure_req_rp0_s { + uint8_t Status; +} aci_l2cap_cos_reconfigure_req_rp0; + +typedef PACKED(struct) aci_l2cap_cos_reconfigure_resp_cp0_s { + uint16_t Connection_Handle; + uint8_t Identifier; + uint16_t Result; +} aci_l2cap_cos_reconfigure_resp_cp0; + +typedef PACKED(struct) aci_l2cap_cos_reconfigure_resp_rp0_s { + uint8_t Status; +} aci_l2cap_cos_reconfigure_resp_rp0; + +typedef PACKED(struct) aci_test_tx_notification_start_cp0_s { + uint16_t Connection_Handle; + uint16_t Service_Handle; + uint16_t Char_Handle; + uint16_t Value_Length; +} aci_test_tx_notification_start_cp0; + +typedef PACKED(struct) aci_test_tx_notification_start_rp0_s { + uint8_t Status; +} aci_test_tx_notification_start_rp0; + +typedef PACKED(struct) aci_test_tx_write_command_start_cp0_s { + uint16_t Connection_Handle; + uint16_t Attr_Handle; + uint16_t Value_Length; +} aci_test_tx_write_command_start_cp0; + +typedef PACKED(struct) aci_test_tx_write_command_start_rp0_s { + uint8_t Status; +} aci_test_tx_write_command_start_rp0; + +typedef PACKED(struct) aci_test_rx_start_cp0_s { + uint16_t Connection_Handle; + uint16_t Attr_Handle; + uint8_t Notifications_WriteCmds; +} aci_test_rx_start_cp0; + +typedef PACKED(struct) aci_test_rx_start_rp0_s { + uint8_t Status; +} aci_test_rx_start_rp0; + +typedef PACKED(struct) aci_test_stop_cp0_s { + uint8_t TX_RX; +} aci_test_stop_cp0; + +typedef PACKED(struct) aci_test_stop_rp0_s { + uint8_t Status; +} aci_test_stop_rp0; + +typedef PACKED(struct) aci_test_report_rp0_s { + uint8_t Status; + uint32_t TX_Packets; + uint32_t RX_Packets; + uint16_t RX_Data_Length; + uint32_t RX_Sequence_Errors; +} aci_test_report_rp0; + +typedef PACKED(struct) aci_blue_initialized_event_rp0_s { + uint8_t Reason_Code; +} aci_blue_initialized_event_rp0; + +typedef PACKED(struct) aci_blue_crash_info_event_rp0_s { + uint8_t Crash_Type; + uint32_t SP; + uint32_t R0; + uint32_t R1; + uint32_t R2; + uint32_t R3; + uint32_t R12; + uint32_t LR; + uint32_t PC; + uint32_t xPSR; + uint8_t Debug_Data_Length; + uint8_t Debug_Data[(HCI_MAX_PAYLOAD_SIZE - 38)/sizeof(uint8_t)]; +} aci_blue_crash_info_event_rp0; + +typedef PACKED(struct) aci_hal_le_test_end_event_rp0_s { + uint16_t Number_Of_Packets; +} aci_hal_le_test_end_event_rp0; + +typedef PACKED(struct) aci_l2cap_cos_sdu_data_rx_nwk_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t RX_Credit_Balance; + uint16_t SDU_Length; + uint8_t SDU_Data[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; +} aci_l2cap_cos_sdu_data_rx_nwk_event_rp0; + +typedef PACKED(struct) aci_gatt_srv_authorize_nwk_event_rp0_s { + uint16_t Conn_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint8_t Operation_Type; + uint16_t Attr_Val_Offset; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; +} aci_gatt_srv_authorize_nwk_event_rp0; + +uint16_t hci_disconnect_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_remote_version_information_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_set_event_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_connection_accept_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_write_connection_accept_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_transmit_power_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_afh_channel_assessment_mode_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_write_afh_channel_assessment_mode_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_set_event_mask_page_2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_authenticated_payload_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_write_authenticated_payload_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_local_version_information_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_local_supported_commands_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_local_supported_features_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_bd_addr_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_read_rssi_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_event_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_buffer_size_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_local_supported_features_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_random_address_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_advertising_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_advertising_physical_channel_tx_power_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_advertising_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_scan_response_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_advertising_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_scan_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_scan_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_create_connection_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_create_connection_cancel_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_filter_accept_list_size_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_clear_filter_accept_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_add_device_to_filter_accept_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_remove_device_from_filter_accept_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_connection_update_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_host_channel_classification_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_channel_map_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_remote_features_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_encrypt_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_rand_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_enable_encryption_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_long_term_key_request_reply_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_long_term_key_request_negative_reply_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_supported_states_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_receiver_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_transmitter_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_test_end_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_suggested_default_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_write_suggested_default_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_local_p256_public_key_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_generate_dhkey_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_add_device_to_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_remove_device_from_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_clear_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_resolving_list_size_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_peer_resolvable_address_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_local_resolvable_address_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_address_resolution_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_resolvable_private_address_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_maximum_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_phy_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_default_phy_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_phy_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_receiver_test_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_transmitter_test_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_advertising_set_random_address_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_extended_advertising_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_extended_advertising_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_extended_scan_response_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_extended_advertising_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_maximum_advertising_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_number_of_supported_advertising_sets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_remove_advertising_set_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_clear_advertising_sets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_advertising_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_advertising_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_advertising_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_extended_scan_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_extended_scan_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_extended_create_connection_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_periodic_advertising_create_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_periodic_advertising_create_sync_cancel_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_periodic_advertising_terminate_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_add_device_to_periodic_advertiser_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_remove_device_from_periodic_advertiser_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_clear_periodic_advertiser_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_periodic_advertiser_list_size_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_transmit_power_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_rf_path_compensation_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_write_rf_path_compensation_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_privacy_mode_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_receiver_test_v3_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_transmitter_test_v3_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_connectionless_cte_transmit_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_connectionless_cte_transmit_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_connectionless_iq_sampling_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_connection_cte_receive_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_connection_cte_transmit_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_connection_cte_request_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_connection_cte_response_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_antenna_information_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_advertising_receive_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_periodic_advertising_sync_transfer_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_periodic_advertising_set_info_transfer_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_advertising_sync_transfer_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_default_periodic_advertising_sync_transfer_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_buffer_size_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_iso_tx_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_cig_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_cig_parameters_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_create_cis_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_remove_cig_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_accept_cis_request_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_reject_cis_request_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_create_big_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_create_big_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_terminate_big_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_big_create_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_big_terminate_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_request_peer_sca_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_setup_iso_data_path_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_remove_iso_data_path_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_iso_transmit_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_iso_receive_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_iso_read_test_counters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_iso_test_end_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_host_feature_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_iso_link_quality_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_enhanced_read_transmit_power_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_read_remote_transmit_power_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_path_loss_reporting_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_path_loss_reporting_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_transmit_power_reporting_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_transmitter_test_v4_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_data_related_address_changes_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_default_subrate_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_subrate_request_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_extended_advertising_parameters_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_advertising_subevent_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_advertising_response_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_sync_subevent_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_extended_create_connection_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t hci_le_set_periodic_advertising_parameters_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_get_fw_build_number_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_get_firmware_details_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_get_firmware_details_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_write_config_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_read_config_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_set_tx_power_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_le_tx_test_packet_number_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_tone_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_tone_stop_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_get_link_status_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_set_radio_activity_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_set_le_power_control_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_transmitter_test_packets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_transmitter_test_packets_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_write_radio_reg_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_read_radio_reg_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_set_antenna_switch_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_peripheral_latency_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_get_evt_fifo_max_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_init_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_io_capability_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_security_requirements_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_passkey_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_profile_init_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_security_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_get_security_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_le_event_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_terminate_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_clear_security_db_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_pairing_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_create_connection_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_terminate_proc_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_start_connection_update_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_resolve_private_addr_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_get_bonded_devices_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_is_device_bonded_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_numeric_comparison_value_confirm_yesno_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_passkey_input_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_get_oob_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_oob_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_remove_bonded_device_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_advertising_configuration_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_advertising_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_advertising_data_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_scan_response_data_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_scan_configuration_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_set_connection_configuration_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_start_procedure_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_discover_name_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_add_devices_to_filter_accept_and_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_configure_filter_accept_and_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_remove_advertising_set_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_clear_advertising_sets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_create_periodic_advertising_connection_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_encrypt_adv_data_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gap_decrypt_adv_data_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_profile_init_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_add_service_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_include_service_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_add_char_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_add_char_desc_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_write_handle_value_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_rm_char_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_rm_service_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_rm_include_service_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_set_event_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_exchange_config_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_prepare_write_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_execute_write_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_disc_all_primary_services_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_disc_primary_service_by_uuid_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_find_included_services_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_disc_all_char_of_service_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_disc_char_by_uuid_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_disc_all_char_desc_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_read_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_read_using_char_uuid_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_read_long_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_read_multiple_char_value_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_write_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_write_long_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_write_char_reliable_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_write_without_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_signed_write_without_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_confirm_indication_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_set_security_permission_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_read_handle_value_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_set_access_permission_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_notify_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_exec_write_resp_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_authorize_resp_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_read_prepare_queue_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_write_multiple_instance_handle_value_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_read_multiple_instance_handle_value_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_srv_multi_notify_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_read_multiple_var_len_char_value_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_connection_parameter_update_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_connection_parameter_update_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_cos_connection_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_cos_connection_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_cos_disconnect_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_cos_sdu_data_transmit_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_cos_reconfigure_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_cos_reconfigure_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_test_tx_notification_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_test_tx_write_command_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_test_rx_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_test_stop_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_test_report_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +const hci_command_table_type hci_command_table[] = { +#if (!defined(HCI_DISCONNECT_ENABLED) || HCI_DISCONNECT_ENABLED) && !HCI_DISCONNECT_FORCE_DISABLED + /* hci_disconnect */ + {0x0406, hci_disconnect_process}, +#endif +#if (!defined(HCI_READ_REMOTE_VERSION_INFORMATION_ENABLED) || HCI_READ_REMOTE_VERSION_INFORMATION_ENABLED) && !HCI_READ_REMOTE_VERSION_INFORMATION_FORCE_DISABLED + /* hci_read_remote_version_information */ + {0x041d, hci_read_remote_version_information_process}, +#endif +#if (!defined(HCI_SET_EVENT_MASK_ENABLED) || HCI_SET_EVENT_MASK_ENABLED) && !HCI_SET_EVENT_MASK_FORCE_DISABLED + /* hci_set_event_mask */ + {0x0c01, hci_set_event_mask_process}, +#endif +#if (!defined(HCI_READ_CONNECTION_ACCEPT_TIMEOUT_ENABLED) || HCI_READ_CONNECTION_ACCEPT_TIMEOUT_ENABLED) && !HCI_READ_CONNECTION_ACCEPT_TIMEOUT_FORCE_DISABLED + /* hci_read_connection_accept_timeout */ + {0x0c15, hci_read_connection_accept_timeout_process}, +#endif +#if (!defined(HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_ENABLED) || HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_ENABLED) && !HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_FORCE_DISABLED + /* hci_write_connection_accept_timeout */ + {0x0c16, hci_write_connection_accept_timeout_process}, +#endif +#if (!defined(HCI_READ_TRANSMIT_POWER_LEVEL_ENABLED) || HCI_READ_TRANSMIT_POWER_LEVEL_ENABLED) && !HCI_READ_TRANSMIT_POWER_LEVEL_FORCE_DISABLED + /* hci_read_transmit_power_level */ + {0x0c2d, hci_read_transmit_power_level_process}, +#endif +#if (!defined(HCI_READ_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED) || HCI_READ_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED) && !HCI_READ_AFH_CHANNEL_ASSESSMENT_MODE_FORCE_DISABLED + /* hci_read_afh_channel_assessment_mode */ + {0x0c48, hci_read_afh_channel_assessment_mode_process}, +#endif +#if (!defined(HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED) || HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED) && !HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE_FORCE_DISABLED + /* hci_write_afh_channel_assessment_mode */ + {0x0c49, hci_write_afh_channel_assessment_mode_process}, +#endif +#if (!defined(HCI_SET_EVENT_MASK_PAGE_2_ENABLED) || HCI_SET_EVENT_MASK_PAGE_2_ENABLED) && !HCI_SET_EVENT_MASK_PAGE_2_FORCE_DISABLED + /* hci_set_event_mask_page_2 */ + {0x0c63, hci_set_event_mask_page_2_process}, +#endif +#if (!defined(HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED) || HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED) && !HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_FORCE_DISABLED + /* hci_read_authenticated_payload_timeout */ + {0x0c7b, hci_read_authenticated_payload_timeout_process}, +#endif +#if (!defined(HCI_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED) || HCI_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED) && !HCI_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_FORCE_DISABLED + /* hci_write_authenticated_payload_timeout */ + {0x0c7c, hci_write_authenticated_payload_timeout_process}, +#endif +#if (!defined(HCI_READ_LOCAL_VERSION_INFORMATION_ENABLED) || HCI_READ_LOCAL_VERSION_INFORMATION_ENABLED) && !HCI_READ_LOCAL_VERSION_INFORMATION_FORCE_DISABLED + /* hci_read_local_version_information */ + {0x1001, hci_read_local_version_information_process}, +#endif +#if (!defined(HCI_READ_LOCAL_SUPPORTED_COMMANDS_ENABLED) || HCI_READ_LOCAL_SUPPORTED_COMMANDS_ENABLED) && !HCI_READ_LOCAL_SUPPORTED_COMMANDS_FORCE_DISABLED + /* hci_read_local_supported_commands */ + {0x1002, hci_read_local_supported_commands_process}, +#endif +#if (!defined(HCI_READ_LOCAL_SUPPORTED_FEATURES_ENABLED) || HCI_READ_LOCAL_SUPPORTED_FEATURES_ENABLED) && !HCI_READ_LOCAL_SUPPORTED_FEATURES_FORCE_DISABLED + /* hci_read_local_supported_features */ + {0x1003, hci_read_local_supported_features_process}, +#endif +#if (!defined(HCI_READ_BD_ADDR_ENABLED) || HCI_READ_BD_ADDR_ENABLED) && !HCI_READ_BD_ADDR_FORCE_DISABLED + /* hci_read_bd_addr */ + {0x1009, hci_read_bd_addr_process}, +#endif +#if (!defined(HCI_READ_RSSI_ENABLED) || HCI_READ_RSSI_ENABLED) && !HCI_READ_RSSI_FORCE_DISABLED + /* hci_read_rssi */ + {0x1405, hci_read_rssi_process}, +#endif +#if (!defined(HCI_LE_SET_EVENT_MASK_ENABLED) || HCI_LE_SET_EVENT_MASK_ENABLED) && !HCI_LE_SET_EVENT_MASK_FORCE_DISABLED + /* hci_le_set_event_mask */ + {0x2001, hci_le_set_event_mask_process}, +#endif +#if (!defined(HCI_LE_READ_BUFFER_SIZE_ENABLED) || HCI_LE_READ_BUFFER_SIZE_ENABLED) && !HCI_LE_READ_BUFFER_SIZE_FORCE_DISABLED + /* hci_le_read_buffer_size */ + {0x2002, hci_le_read_buffer_size_process}, +#endif +#if (!defined(HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_ENABLED) || HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_ENABLED) && !HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_FORCE_DISABLED + /* hci_le_read_local_supported_features */ + {0x2003, hci_le_read_local_supported_features_process}, +#endif +#if (!defined(HCI_LE_SET_RANDOM_ADDRESS_ENABLED) || HCI_LE_SET_RANDOM_ADDRESS_ENABLED) && !HCI_LE_SET_RANDOM_ADDRESS_FORCE_DISABLED + /* hci_le_set_random_address */ + {0x2005, hci_le_set_random_address_process}, +#endif +#if (!defined(HCI_LE_SET_ADVERTISING_PARAMETERS_ENABLED) || HCI_LE_SET_ADVERTISING_PARAMETERS_ENABLED) && !HCI_LE_SET_ADVERTISING_PARAMETERS_FORCE_DISABLED + /* hci_le_set_advertising_parameters */ + {0x2006, hci_le_set_advertising_parameters_process}, +#endif +#if (!defined(HCI_LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER_ENABLED) || HCI_LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER_ENABLED) && !HCI_LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER_FORCE_DISABLED + /* hci_le_read_advertising_physical_channel_tx_power */ + {0x2007, hci_le_read_advertising_physical_channel_tx_power_process}, +#endif +#if (!defined(HCI_LE_SET_ADVERTISING_DATA_ENABLED) || HCI_LE_SET_ADVERTISING_DATA_ENABLED) && !HCI_LE_SET_ADVERTISING_DATA_FORCE_DISABLED + /* hci_le_set_advertising_data */ + {0x2008, hci_le_set_advertising_data_process}, +#endif +#if (!defined(HCI_LE_SET_SCAN_RESPONSE_DATA_ENABLED) || HCI_LE_SET_SCAN_RESPONSE_DATA_ENABLED) && !HCI_LE_SET_SCAN_RESPONSE_DATA_FORCE_DISABLED + /* hci_le_set_scan_response_data */ + {0x2009, hci_le_set_scan_response_data_process}, +#endif +#if (!defined(HCI_LE_SET_ADVERTISING_ENABLE_ENABLED) || HCI_LE_SET_ADVERTISING_ENABLE_ENABLED) && !HCI_LE_SET_ADVERTISING_ENABLE_FORCE_DISABLED + /* hci_le_set_advertising_enable */ + {0x200a, hci_le_set_advertising_enable_process}, +#endif +#if (!defined(HCI_LE_SET_SCAN_PARAMETERS_ENABLED) || HCI_LE_SET_SCAN_PARAMETERS_ENABLED) && !HCI_LE_SET_SCAN_PARAMETERS_FORCE_DISABLED + /* hci_le_set_scan_parameters */ + {0x200b, hci_le_set_scan_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_SCAN_ENABLE_ENABLED) || HCI_LE_SET_SCAN_ENABLE_ENABLED) && !HCI_LE_SET_SCAN_ENABLE_FORCE_DISABLED + /* hci_le_set_scan_enable */ + {0x200c, hci_le_set_scan_enable_process}, +#endif +#if (!defined(HCI_LE_CREATE_CONNECTION_ENABLED) || HCI_LE_CREATE_CONNECTION_ENABLED) && !HCI_LE_CREATE_CONNECTION_FORCE_DISABLED + /* hci_le_create_connection */ + {0x200d, hci_le_create_connection_process}, +#endif +#if (!defined(HCI_LE_CREATE_CONNECTION_CANCEL_ENABLED) || HCI_LE_CREATE_CONNECTION_CANCEL_ENABLED) && !HCI_LE_CREATE_CONNECTION_CANCEL_FORCE_DISABLED + /* hci_le_create_connection_cancel */ + {0x200e, hci_le_create_connection_cancel_process}, +#endif +#if (!defined(HCI_LE_READ_FILTER_ACCEPT_LIST_SIZE_ENABLED) || HCI_LE_READ_FILTER_ACCEPT_LIST_SIZE_ENABLED) && !HCI_LE_READ_FILTER_ACCEPT_LIST_SIZE_FORCE_DISABLED + /* hci_le_read_filter_accept_list_size */ + {0x200f, hci_le_read_filter_accept_list_size_process}, +#endif +#if (!defined(HCI_LE_CLEAR_FILTER_ACCEPT_LIST_ENABLED) || HCI_LE_CLEAR_FILTER_ACCEPT_LIST_ENABLED) && !HCI_LE_CLEAR_FILTER_ACCEPT_LIST_FORCE_DISABLED + /* hci_le_clear_filter_accept_list */ + {0x2010, hci_le_clear_filter_accept_list_process}, +#endif +#if (!defined(HCI_LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST_ENABLED) || HCI_LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST_ENABLED) && !HCI_LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST_FORCE_DISABLED + /* hci_le_add_device_to_filter_accept_list */ + {0x2011, hci_le_add_device_to_filter_accept_list_process}, +#endif +#if (!defined(HCI_LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST_ENABLED) || HCI_LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST_ENABLED) && !HCI_LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST_FORCE_DISABLED + /* hci_le_remove_device_from_filter_accept_list */ + {0x2012, hci_le_remove_device_from_filter_accept_list_process}, +#endif +#if (!defined(HCI_LE_CONNECTION_UPDATE_ENABLED) || HCI_LE_CONNECTION_UPDATE_ENABLED) && !HCI_LE_CONNECTION_UPDATE_FORCE_DISABLED + /* hci_le_connection_update */ + {0x2013, hci_le_connection_update_process}, +#endif +#if (!defined(HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION_ENABLED) || HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION_ENABLED) && !HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION_FORCE_DISABLED + /* hci_le_set_host_channel_classification */ + {0x2014, hci_le_set_host_channel_classification_process}, +#endif +#if (!defined(HCI_LE_READ_CHANNEL_MAP_ENABLED) || HCI_LE_READ_CHANNEL_MAP_ENABLED) && !HCI_LE_READ_CHANNEL_MAP_FORCE_DISABLED + /* hci_le_read_channel_map */ + {0x2015, hci_le_read_channel_map_process}, +#endif +#if (!defined(HCI_LE_READ_REMOTE_FEATURES_ENABLED) || HCI_LE_READ_REMOTE_FEATURES_ENABLED) && !HCI_LE_READ_REMOTE_FEATURES_FORCE_DISABLED + /* hci_le_read_remote_features */ + {0x2016, hci_le_read_remote_features_process}, +#endif +#if (!defined(HCI_LE_ENCRYPT_ENABLED) || HCI_LE_ENCRYPT_ENABLED) && !HCI_LE_ENCRYPT_FORCE_DISABLED + /* hci_le_encrypt */ + {0x2017, hci_le_encrypt_process}, +#endif +#if (!defined(HCI_LE_RAND_ENABLED) || HCI_LE_RAND_ENABLED) && !HCI_LE_RAND_FORCE_DISABLED + /* hci_le_rand */ + {0x2018, hci_le_rand_process}, +#endif +#if (!defined(HCI_LE_ENABLE_ENCRYPTION_ENABLED) || HCI_LE_ENABLE_ENCRYPTION_ENABLED) && !HCI_LE_ENABLE_ENCRYPTION_FORCE_DISABLED + /* hci_le_enable_encryption */ + {0x2019, hci_le_enable_encryption_process}, +#endif +#if (!defined(HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_ENABLED) || HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_ENABLED) && !HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_FORCE_DISABLED + /* hci_le_long_term_key_request_reply */ + {0x201a, hci_le_long_term_key_request_reply_process}, +#endif +#if (!defined(HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_ENABLED) || HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_ENABLED) && !HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_FORCE_DISABLED + /* hci_le_long_term_key_request_negative_reply */ + {0x201b, hci_le_long_term_key_request_negative_reply_process}, +#endif +#if (!defined(HCI_LE_READ_SUPPORTED_STATES_ENABLED) || HCI_LE_READ_SUPPORTED_STATES_ENABLED) && !HCI_LE_READ_SUPPORTED_STATES_FORCE_DISABLED + /* hci_le_read_supported_states */ + {0x201c, hci_le_read_supported_states_process}, +#endif +#if (!defined(HCI_LE_RECEIVER_TEST_ENABLED) || HCI_LE_RECEIVER_TEST_ENABLED) && !HCI_LE_RECEIVER_TEST_FORCE_DISABLED + /* hci_le_receiver_test */ + {0x201d, hci_le_receiver_test_process}, +#endif +#if (!defined(HCI_LE_TRANSMITTER_TEST_ENABLED) || HCI_LE_TRANSMITTER_TEST_ENABLED) && !HCI_LE_TRANSMITTER_TEST_FORCE_DISABLED + /* hci_le_transmitter_test */ + {0x201e, hci_le_transmitter_test_process}, +#endif +#if (!defined(HCI_LE_TEST_END_ENABLED) || HCI_LE_TEST_END_ENABLED) && !HCI_LE_TEST_END_FORCE_DISABLED + /* hci_le_test_end */ + {0x201f, hci_le_test_end_process}, +#endif +#if (!defined(HCI_LE_SET_DATA_LENGTH_ENABLED) || HCI_LE_SET_DATA_LENGTH_ENABLED) && !HCI_LE_SET_DATA_LENGTH_FORCE_DISABLED + /* hci_le_set_data_length */ + {0x2022, hci_le_set_data_length_process}, +#endif +#if (!defined(HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED) || HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED) && !HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_FORCE_DISABLED + /* hci_le_read_suggested_default_data_length */ + {0x2023, hci_le_read_suggested_default_data_length_process}, +#endif +#if (!defined(HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED) || HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED) && !HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_FORCE_DISABLED + /* hci_le_write_suggested_default_data_length */ + {0x2024, hci_le_write_suggested_default_data_length_process}, +#endif +#if (!defined(HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_ENABLED) || HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_ENABLED) && !HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_FORCE_DISABLED + /* hci_le_read_local_p256_public_key */ + {0x2025, hci_le_read_local_p256_public_key_process}, +#endif +#if (!defined(HCI_LE_GENERATE_DHKEY_ENABLED) || HCI_LE_GENERATE_DHKEY_ENABLED) && !HCI_LE_GENERATE_DHKEY_FORCE_DISABLED + /* hci_le_generate_dhkey */ + {0x2026, hci_le_generate_dhkey_process}, +#endif +#if (!defined(HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST_ENABLED) || HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST_ENABLED) && !HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST_FORCE_DISABLED + /* hci_le_add_device_to_resolving_list */ + {0x2027, hci_le_add_device_to_resolving_list_process}, +#endif +#if (!defined(HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_ENABLED) || HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_ENABLED) && !HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_FORCE_DISABLED + /* hci_le_remove_device_from_resolving_list */ + {0x2028, hci_le_remove_device_from_resolving_list_process}, +#endif +#if (!defined(HCI_LE_CLEAR_RESOLVING_LIST_ENABLED) || HCI_LE_CLEAR_RESOLVING_LIST_ENABLED) && !HCI_LE_CLEAR_RESOLVING_LIST_FORCE_DISABLED + /* hci_le_clear_resolving_list */ + {0x2029, hci_le_clear_resolving_list_process}, +#endif +#if (!defined(HCI_LE_READ_RESOLVING_LIST_SIZE_ENABLED) || HCI_LE_READ_RESOLVING_LIST_SIZE_ENABLED) && !HCI_LE_READ_RESOLVING_LIST_SIZE_FORCE_DISABLED + /* hci_le_read_resolving_list_size */ + {0x202a, hci_le_read_resolving_list_size_process}, +#endif +#if (!defined(HCI_LE_READ_PEER_RESOLVABLE_ADDRESS_ENABLED) || HCI_LE_READ_PEER_RESOLVABLE_ADDRESS_ENABLED) && !HCI_LE_READ_PEER_RESOLVABLE_ADDRESS_FORCE_DISABLED + /* hci_le_read_peer_resolvable_address */ + {0x202b, hci_le_read_peer_resolvable_address_process}, +#endif +#if (!defined(HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS_ENABLED) || HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS_ENABLED) && !HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS_FORCE_DISABLED + /* hci_le_read_local_resolvable_address */ + {0x202c, hci_le_read_local_resolvable_address_process}, +#endif +#if (!defined(HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_ENABLED) || HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_ENABLED) && !HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_FORCE_DISABLED + /* hci_le_set_address_resolution_enable */ + {0x202d, hci_le_set_address_resolution_enable_process}, +#endif +#if (!defined(HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_ENABLED) || HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_ENABLED) && !HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_FORCE_DISABLED + /* hci_le_set_resolvable_private_address_timeout */ + {0x202e, hci_le_set_resolvable_private_address_timeout_process}, +#endif +#if (!defined(HCI_LE_READ_MAXIMUM_DATA_LENGTH_ENABLED) || HCI_LE_READ_MAXIMUM_DATA_LENGTH_ENABLED) && !HCI_LE_READ_MAXIMUM_DATA_LENGTH_FORCE_DISABLED + /* hci_le_read_maximum_data_length */ + {0x202f, hci_le_read_maximum_data_length_process}, +#endif +#if (!defined(HCI_LE_READ_PHY_ENABLED) || HCI_LE_READ_PHY_ENABLED) && !HCI_LE_READ_PHY_FORCE_DISABLED + /* hci_le_read_phy */ + {0x2030, hci_le_read_phy_process}, +#endif +#if (!defined(HCI_LE_SET_DEFAULT_PHY_ENABLED) || HCI_LE_SET_DEFAULT_PHY_ENABLED) && !HCI_LE_SET_DEFAULT_PHY_FORCE_DISABLED + /* hci_le_set_default_phy */ + {0x2031, hci_le_set_default_phy_process}, +#endif +#if (!defined(HCI_LE_SET_PHY_ENABLED) || HCI_LE_SET_PHY_ENABLED) && !HCI_LE_SET_PHY_FORCE_DISABLED + /* hci_le_set_phy */ + {0x2032, hci_le_set_phy_process}, +#endif +#if (!defined(HCI_LE_RECEIVER_TEST_V2_ENABLED) || HCI_LE_RECEIVER_TEST_V2_ENABLED) && !HCI_LE_RECEIVER_TEST_V2_FORCE_DISABLED + /* hci_le_receiver_test_v2 */ + {0x2033, hci_le_receiver_test_v2_process}, +#endif +#if (!defined(HCI_LE_TRANSMITTER_TEST_V2_ENABLED) || HCI_LE_TRANSMITTER_TEST_V2_ENABLED) && !HCI_LE_TRANSMITTER_TEST_V2_FORCE_DISABLED + /* hci_le_transmitter_test_v2 */ + {0x2034, hci_le_transmitter_test_v2_process}, +#endif +#if (!defined(HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_ENABLED) || HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_ENABLED) && !HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_FORCE_DISABLED + /* hci_le_set_advertising_set_random_address */ + {0x2035, hci_le_set_advertising_set_random_address_process}, +#endif +#if (!defined(HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_ENABLED) || HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_ENABLED) && !HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_FORCE_DISABLED + /* hci_le_set_extended_advertising_parameters */ + {0x2036, hci_le_set_extended_advertising_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_EXTENDED_ADVERTISING_DATA_ENABLED) || HCI_LE_SET_EXTENDED_ADVERTISING_DATA_ENABLED) && !HCI_LE_SET_EXTENDED_ADVERTISING_DATA_FORCE_DISABLED + /* hci_le_set_extended_advertising_data */ + {0x2037, hci_le_set_extended_advertising_data_process}, +#endif +#if (!defined(HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_ENABLED) || HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_ENABLED) && !HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_FORCE_DISABLED + /* hci_le_set_extended_scan_response_data */ + {0x2038, hci_le_set_extended_scan_response_data_process}, +#endif +#if (!defined(HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE_ENABLED) || HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE_ENABLED) && !HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE_FORCE_DISABLED + /* hci_le_set_extended_advertising_enable */ + {0x2039, hci_le_set_extended_advertising_enable_process}, +#endif +#if (!defined(HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_ENABLED) || HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_ENABLED) && !HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_FORCE_DISABLED + /* hci_le_read_maximum_advertising_data_length */ + {0x203a, hci_le_read_maximum_advertising_data_length_process}, +#endif +#if (!defined(HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_ENABLED) || HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_ENABLED) && !HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_FORCE_DISABLED + /* hci_le_read_number_of_supported_advertising_sets */ + {0x203b, hci_le_read_number_of_supported_advertising_sets_process}, +#endif +#if (!defined(HCI_LE_REMOVE_ADVERTISING_SET_ENABLED) || HCI_LE_REMOVE_ADVERTISING_SET_ENABLED) && !HCI_LE_REMOVE_ADVERTISING_SET_FORCE_DISABLED + /* hci_le_remove_advertising_set */ + {0x203c, hci_le_remove_advertising_set_process}, +#endif +#if (!defined(HCI_LE_CLEAR_ADVERTISING_SETS_ENABLED) || HCI_LE_CLEAR_ADVERTISING_SETS_ENABLED) && !HCI_LE_CLEAR_ADVERTISING_SETS_FORCE_DISABLED + /* hci_le_clear_advertising_sets */ + {0x203d, hci_le_clear_advertising_sets_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_FORCE_DISABLED + /* hci_le_set_periodic_advertising_parameters */ + {0x203e, hci_le_set_periodic_advertising_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_DATA_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_DATA_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_DATA_FORCE_DISABLED + /* hci_le_set_periodic_advertising_data */ + {0x203f, hci_le_set_periodic_advertising_data_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE_FORCE_DISABLED + /* hci_le_set_periodic_advertising_enable */ + {0x2040, hci_le_set_periodic_advertising_enable_process}, +#endif +#if (!defined(HCI_LE_SET_EXTENDED_SCAN_PARAMETERS_ENABLED) || HCI_LE_SET_EXTENDED_SCAN_PARAMETERS_ENABLED) && !HCI_LE_SET_EXTENDED_SCAN_PARAMETERS_FORCE_DISABLED + /* hci_le_set_extended_scan_parameters */ + {0x2041, hci_le_set_extended_scan_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_EXTENDED_SCAN_ENABLE_ENABLED) || HCI_LE_SET_EXTENDED_SCAN_ENABLE_ENABLED) && !HCI_LE_SET_EXTENDED_SCAN_ENABLE_FORCE_DISABLED + /* hci_le_set_extended_scan_enable */ + {0x2042, hci_le_set_extended_scan_enable_process}, +#endif +#if (!defined(HCI_LE_EXTENDED_CREATE_CONNECTION_ENABLED) || HCI_LE_EXTENDED_CREATE_CONNECTION_ENABLED) && !HCI_LE_EXTENDED_CREATE_CONNECTION_FORCE_DISABLED + /* hci_le_extended_create_connection */ + {0x2043, hci_le_extended_create_connection_process}, +#endif +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_FORCE_DISABLED + /* hci_le_periodic_advertising_create_sync */ + {0x2044, hci_le_periodic_advertising_create_sync_process}, +#endif +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_FORCE_DISABLED + /* hci_le_periodic_advertising_create_sync_cancel */ + {0x2045, hci_le_periodic_advertising_create_sync_cancel_process}, +#endif +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_FORCE_DISABLED + /* hci_le_periodic_advertising_terminate_sync */ + {0x2046, hci_le_periodic_advertising_terminate_sync_process}, +#endif +#if (!defined(HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_ENABLED) || HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_ENABLED) && !HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_FORCE_DISABLED + /* hci_le_add_device_to_periodic_advertiser_list */ + {0x2047, hci_le_add_device_to_periodic_advertiser_list_process}, +#endif +#if (!defined(HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_ENABLED) || HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_ENABLED) && !HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_FORCE_DISABLED + /* hci_le_remove_device_from_periodic_advertiser_list */ + {0x2048, hci_le_remove_device_from_periodic_advertiser_list_process}, +#endif +#if (!defined(HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST_ENABLED) || HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST_ENABLED) && !HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST_FORCE_DISABLED + /* hci_le_clear_periodic_advertiser_list */ + {0x2049, hci_le_clear_periodic_advertiser_list_process}, +#endif +#if (!defined(HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_ENABLED) || HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_ENABLED) && !HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_FORCE_DISABLED + /* hci_le_read_periodic_advertiser_list_size */ + {0x204a, hci_le_read_periodic_advertiser_list_size_process}, +#endif +#if (!defined(HCI_LE_READ_TRANSMIT_POWER_ENABLED) || HCI_LE_READ_TRANSMIT_POWER_ENABLED) && !HCI_LE_READ_TRANSMIT_POWER_FORCE_DISABLED + /* hci_le_read_transmit_power */ + {0x204b, hci_le_read_transmit_power_process}, +#endif +#if (!defined(HCI_LE_READ_RF_PATH_COMPENSATION_ENABLED) || HCI_LE_READ_RF_PATH_COMPENSATION_ENABLED) && !HCI_LE_READ_RF_PATH_COMPENSATION_FORCE_DISABLED + /* hci_le_read_rf_path_compensation */ + {0x204c, hci_le_read_rf_path_compensation_process}, +#endif +#if (!defined(HCI_LE_WRITE_RF_PATH_COMPENSATION_ENABLED) || HCI_LE_WRITE_RF_PATH_COMPENSATION_ENABLED) && !HCI_LE_WRITE_RF_PATH_COMPENSATION_FORCE_DISABLED + /* hci_le_write_rf_path_compensation */ + {0x204d, hci_le_write_rf_path_compensation_process}, +#endif +#if (!defined(HCI_LE_SET_PRIVACY_MODE_ENABLED) || HCI_LE_SET_PRIVACY_MODE_ENABLED) && !HCI_LE_SET_PRIVACY_MODE_FORCE_DISABLED + /* hci_le_set_privacy_mode */ + {0x204e, hci_le_set_privacy_mode_process}, +#endif +#if (!defined(HCI_LE_RECEIVER_TEST_V3_ENABLED) || HCI_LE_RECEIVER_TEST_V3_ENABLED) && !HCI_LE_RECEIVER_TEST_V3_FORCE_DISABLED + /* hci_le_receiver_test_v3 */ + {0x204f, hci_le_receiver_test_v3_process}, +#endif +#if (!defined(HCI_LE_TRANSMITTER_TEST_V3_ENABLED) || HCI_LE_TRANSMITTER_TEST_V3_ENABLED) && !HCI_LE_TRANSMITTER_TEST_V3_FORCE_DISABLED + /* hci_le_transmitter_test_v3 */ + {0x2050, hci_le_transmitter_test_v3_process}, +#endif +#if (!defined(HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS_ENABLED) || HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS_ENABLED) && !HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS_FORCE_DISABLED + /* hci_le_set_connectionless_cte_transmit_parameters */ + {0x2051, hci_le_set_connectionless_cte_transmit_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE_ENABLED) || HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE_ENABLED) && !HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE_FORCE_DISABLED + /* hci_le_set_connectionless_cte_transmit_enable */ + {0x2052, hci_le_set_connectionless_cte_transmit_enable_process}, +#endif +#if (!defined(HCI_LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE_ENABLED) || HCI_LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE_ENABLED) && !HCI_LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE_FORCE_DISABLED + /* hci_le_set_connectionless_iq_sampling_enable */ + {0x2053, hci_le_set_connectionless_iq_sampling_enable_process}, +#endif +#if (!defined(HCI_LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS_ENABLED) || HCI_LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS_ENABLED) && !HCI_LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS_FORCE_DISABLED + /* hci_le_set_connection_cte_receive_parameters */ + {0x2054, hci_le_set_connection_cte_receive_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS_ENABLED) || HCI_LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS_ENABLED) && !HCI_LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS_FORCE_DISABLED + /* hci_le_set_connection_cte_transmit_parameters */ + {0x2055, hci_le_set_connection_cte_transmit_parameters_process}, +#endif +#if (!defined(HCI_LE_CONNECTION_CTE_REQUEST_ENABLE_ENABLED) || HCI_LE_CONNECTION_CTE_REQUEST_ENABLE_ENABLED) && !HCI_LE_CONNECTION_CTE_REQUEST_ENABLE_FORCE_DISABLED + /* hci_le_connection_cte_request_enable */ + {0x2056, hci_le_connection_cte_request_enable_process}, +#endif +#if (!defined(HCI_LE_CONNECTION_CTE_RESPONSE_ENABLE_ENABLED) || HCI_LE_CONNECTION_CTE_RESPONSE_ENABLE_ENABLED) && !HCI_LE_CONNECTION_CTE_RESPONSE_ENABLE_FORCE_DISABLED + /* hci_le_connection_cte_response_enable */ + {0x2057, hci_le_connection_cte_response_enable_process}, +#endif +#if (!defined(HCI_LE_READ_ANTENNA_INFORMATION_ENABLED) || HCI_LE_READ_ANTENNA_INFORMATION_ENABLED) && !HCI_LE_READ_ANTENNA_INFORMATION_FORCE_DISABLED + /* hci_le_read_antenna_information */ + {0x2058, hci_le_read_antenna_information_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE_FORCE_DISABLED + /* hci_le_set_periodic_advertising_receive_enable */ + {0x2059, hci_le_set_periodic_advertising_receive_enable_process}, +#endif +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_FORCE_DISABLED + /* hci_le_periodic_advertising_sync_transfer */ + {0x205a, hci_le_periodic_advertising_sync_transfer_process}, +#endif +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER_FORCE_DISABLED + /* hci_le_periodic_advertising_set_info_transfer */ + {0x205b, hci_le_periodic_advertising_set_info_transfer_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_FORCE_DISABLED + /* hci_le_set_periodic_advertising_sync_transfer_parameters */ + {0x205c, hci_le_set_periodic_advertising_sync_transfer_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED) || HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED) && !HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_FORCE_DISABLED + /* hci_le_set_default_periodic_advertising_sync_transfer_parameters */ + {0x205d, hci_le_set_default_periodic_advertising_sync_transfer_parameters_process}, +#endif +#if (!defined(HCI_LE_READ_BUFFER_SIZE_V2_ENABLED) || HCI_LE_READ_BUFFER_SIZE_V2_ENABLED) && !HCI_LE_READ_BUFFER_SIZE_V2_FORCE_DISABLED + /* hci_le_read_buffer_size_v2 */ + {0x2060, hci_le_read_buffer_size_v2_process}, +#endif +#if (!defined(HCI_LE_READ_ISO_TX_SYNC_ENABLED) || HCI_LE_READ_ISO_TX_SYNC_ENABLED) && !HCI_LE_READ_ISO_TX_SYNC_FORCE_DISABLED + /* hci_le_read_iso_tx_sync */ + {0x2061, hci_le_read_iso_tx_sync_process}, +#endif +#if (!defined(HCI_LE_SET_CIG_PARAMETERS_ENABLED) || HCI_LE_SET_CIG_PARAMETERS_ENABLED) && !HCI_LE_SET_CIG_PARAMETERS_FORCE_DISABLED + /* hci_le_set_cig_parameters */ + {0x2062, hci_le_set_cig_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_CIG_PARAMETERS_TEST_ENABLED) || HCI_LE_SET_CIG_PARAMETERS_TEST_ENABLED) && !HCI_LE_SET_CIG_PARAMETERS_TEST_FORCE_DISABLED + /* hci_le_set_cig_parameters_test */ + {0x2063, hci_le_set_cig_parameters_test_process}, +#endif +#if (!defined(HCI_LE_CREATE_CIS_ENABLED) || HCI_LE_CREATE_CIS_ENABLED) && !HCI_LE_CREATE_CIS_FORCE_DISABLED + /* hci_le_create_cis */ + {0x2064, hci_le_create_cis_process}, +#endif +#if (!defined(HCI_LE_REMOVE_CIG_ENABLED) || HCI_LE_REMOVE_CIG_ENABLED) && !HCI_LE_REMOVE_CIG_FORCE_DISABLED + /* hci_le_remove_cig */ + {0x2065, hci_le_remove_cig_process}, +#endif +#if (!defined(HCI_LE_ACCEPT_CIS_REQUEST_ENABLED) || HCI_LE_ACCEPT_CIS_REQUEST_ENABLED) && !HCI_LE_ACCEPT_CIS_REQUEST_FORCE_DISABLED + /* hci_le_accept_cis_request */ + {0x2066, hci_le_accept_cis_request_process}, +#endif +#if (!defined(HCI_LE_REJECT_CIS_REQUEST_ENABLED) || HCI_LE_REJECT_CIS_REQUEST_ENABLED) && !HCI_LE_REJECT_CIS_REQUEST_FORCE_DISABLED + /* hci_le_reject_cis_request */ + {0x2067, hci_le_reject_cis_request_process}, +#endif +#if (!defined(HCI_LE_CREATE_BIG_ENABLED) || HCI_LE_CREATE_BIG_ENABLED) && !HCI_LE_CREATE_BIG_FORCE_DISABLED + /* hci_le_create_big */ + {0x2068, hci_le_create_big_process}, +#endif +#if (!defined(HCI_LE_CREATE_BIG_TEST_ENABLED) || HCI_LE_CREATE_BIG_TEST_ENABLED) && !HCI_LE_CREATE_BIG_TEST_FORCE_DISABLED + /* hci_le_create_big_test */ + {0x2069, hci_le_create_big_test_process}, +#endif +#if (!defined(HCI_LE_TERMINATE_BIG_ENABLED) || HCI_LE_TERMINATE_BIG_ENABLED) && !HCI_LE_TERMINATE_BIG_FORCE_DISABLED + /* hci_le_terminate_big */ + {0x206a, hci_le_terminate_big_process}, +#endif +#if (!defined(HCI_LE_BIG_CREATE_SYNC_ENABLED) || HCI_LE_BIG_CREATE_SYNC_ENABLED) && !HCI_LE_BIG_CREATE_SYNC_FORCE_DISABLED + /* hci_le_big_create_sync */ + {0x206b, hci_le_big_create_sync_process}, +#endif +#if (!defined(HCI_LE_BIG_TERMINATE_SYNC_ENABLED) || HCI_LE_BIG_TERMINATE_SYNC_ENABLED) && !HCI_LE_BIG_TERMINATE_SYNC_FORCE_DISABLED + /* hci_le_big_terminate_sync */ + {0x206c, hci_le_big_terminate_sync_process}, +#endif +#if (!defined(HCI_LE_REQUEST_PEER_SCA_ENABLED) || HCI_LE_REQUEST_PEER_SCA_ENABLED) && !HCI_LE_REQUEST_PEER_SCA_FORCE_DISABLED + /* hci_le_request_peer_sca */ + {0x206d, hci_le_request_peer_sca_process}, +#endif +#if (!defined(HCI_LE_SETUP_ISO_DATA_PATH_ENABLED) || HCI_LE_SETUP_ISO_DATA_PATH_ENABLED) && !HCI_LE_SETUP_ISO_DATA_PATH_FORCE_DISABLED + /* hci_le_setup_iso_data_path */ + {0x206e, hci_le_setup_iso_data_path_process}, +#endif +#if (!defined(HCI_LE_REMOVE_ISO_DATA_PATH_ENABLED) || HCI_LE_REMOVE_ISO_DATA_PATH_ENABLED) && !HCI_LE_REMOVE_ISO_DATA_PATH_FORCE_DISABLED + /* hci_le_remove_iso_data_path */ + {0x206f, hci_le_remove_iso_data_path_process}, +#endif +#if (!defined(HCI_LE_ISO_TRANSMIT_TEST_ENABLED) || HCI_LE_ISO_TRANSMIT_TEST_ENABLED) && !HCI_LE_ISO_TRANSMIT_TEST_FORCE_DISABLED + /* hci_le_iso_transmit_test */ + {0x2070, hci_le_iso_transmit_test_process}, +#endif +#if (!defined(HCI_LE_ISO_RECEIVE_TEST_ENABLED) || HCI_LE_ISO_RECEIVE_TEST_ENABLED) && !HCI_LE_ISO_RECEIVE_TEST_FORCE_DISABLED + /* hci_le_iso_receive_test */ + {0x2071, hci_le_iso_receive_test_process}, +#endif +#if (!defined(HCI_LE_ISO_READ_TEST_COUNTERS_ENABLED) || HCI_LE_ISO_READ_TEST_COUNTERS_ENABLED) && !HCI_LE_ISO_READ_TEST_COUNTERS_FORCE_DISABLED + /* hci_le_iso_read_test_counters */ + {0x2072, hci_le_iso_read_test_counters_process}, +#endif +#if (!defined(HCI_LE_ISO_TEST_END_ENABLED) || HCI_LE_ISO_TEST_END_ENABLED) && !HCI_LE_ISO_TEST_END_FORCE_DISABLED + /* hci_le_iso_test_end */ + {0x2073, hci_le_iso_test_end_process}, +#endif +#if (!defined(HCI_LE_SET_HOST_FEATURE_ENABLED) || HCI_LE_SET_HOST_FEATURE_ENABLED) && !HCI_LE_SET_HOST_FEATURE_FORCE_DISABLED + /* hci_le_set_host_feature */ + {0x2074, hci_le_set_host_feature_process}, +#endif +#if (!defined(HCI_LE_READ_ISO_LINK_QUALITY_ENABLED) || HCI_LE_READ_ISO_LINK_QUALITY_ENABLED) && !HCI_LE_READ_ISO_LINK_QUALITY_FORCE_DISABLED + /* hci_le_read_iso_link_quality */ + {0x2075, hci_le_read_iso_link_quality_process}, +#endif +#if (!defined(HCI_LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL_ENABLED) || HCI_LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL_ENABLED) && !HCI_LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL_FORCE_DISABLED + /* hci_le_enhanced_read_transmit_power_level */ + {0x2076, hci_le_enhanced_read_transmit_power_level_process}, +#endif +#if (!defined(HCI_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL_ENABLED) || HCI_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL_ENABLED) && !HCI_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL_FORCE_DISABLED + /* hci_le_read_remote_transmit_power_level */ + {0x2077, hci_le_read_remote_transmit_power_level_process}, +#endif +#if (!defined(HCI_LE_SET_PATH_LOSS_REPORTING_PARAMETERS_ENABLED) || HCI_LE_SET_PATH_LOSS_REPORTING_PARAMETERS_ENABLED) && !HCI_LE_SET_PATH_LOSS_REPORTING_PARAMETERS_FORCE_DISABLED + /* hci_le_set_path_loss_reporting_parameters */ + {0x2078, hci_le_set_path_loss_reporting_parameters_process}, +#endif +#if (!defined(HCI_LE_SET_PATH_LOSS_REPORTING_ENABLE_ENABLED) || HCI_LE_SET_PATH_LOSS_REPORTING_ENABLE_ENABLED) && !HCI_LE_SET_PATH_LOSS_REPORTING_ENABLE_FORCE_DISABLED + /* hci_le_set_path_loss_reporting_enable */ + {0x2079, hci_le_set_path_loss_reporting_enable_process}, +#endif +#if (!defined(HCI_LE_SET_TRANSMIT_POWER_REPORTING_ENABLE_ENABLED) || HCI_LE_SET_TRANSMIT_POWER_REPORTING_ENABLE_ENABLED) && !HCI_LE_SET_TRANSMIT_POWER_REPORTING_ENABLE_FORCE_DISABLED + /* hci_le_set_transmit_power_reporting_enable */ + {0x207a, hci_le_set_transmit_power_reporting_enable_process}, +#endif +#if (!defined(HCI_LE_TRANSMITTER_TEST_V4_ENABLED) || HCI_LE_TRANSMITTER_TEST_V4_ENABLED) && !HCI_LE_TRANSMITTER_TEST_V4_FORCE_DISABLED + /* hci_le_transmitter_test_v4 */ + {0x207b, hci_le_transmitter_test_v4_process}, +#endif +#if (!defined(HCI_LE_SET_DATA_RELATED_ADDRESS_CHANGES_ENABLED) || HCI_LE_SET_DATA_RELATED_ADDRESS_CHANGES_ENABLED) && !HCI_LE_SET_DATA_RELATED_ADDRESS_CHANGES_FORCE_DISABLED + /* hci_le_set_data_related_address_changes */ + {0x207c, hci_le_set_data_related_address_changes_process}, +#endif +#if (!defined(HCI_LE_SET_DEFAULT_SUBRATE_ENABLED) || HCI_LE_SET_DEFAULT_SUBRATE_ENABLED) && !HCI_LE_SET_DEFAULT_SUBRATE_FORCE_DISABLED + /* hci_le_set_default_subrate */ + {0x207d, hci_le_set_default_subrate_process}, +#endif +#if (!defined(HCI_LE_SUBRATE_REQUEST_ENABLED) || HCI_LE_SUBRATE_REQUEST_ENABLED) && !HCI_LE_SUBRATE_REQUEST_FORCE_DISABLED + /* hci_le_subrate_request */ + {0x207e, hci_le_subrate_request_process}, +#endif +#if (!defined(HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V2_ENABLED) || HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V2_ENABLED) && !HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V2_FORCE_DISABLED + /* hci_le_set_extended_advertising_parameters_v2 */ + {0x207f, hci_le_set_extended_advertising_parameters_v2_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_SUBEVENT_DATA_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_SUBEVENT_DATA_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_SUBEVENT_DATA_FORCE_DISABLED + /* hci_le_set_periodic_advertising_subevent_data */ + {0x2082, hci_le_set_periodic_advertising_subevent_data_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_RESPONSE_DATA_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_RESPONSE_DATA_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_RESPONSE_DATA_FORCE_DISABLED + /* hci_le_set_periodic_advertising_response_data */ + {0x2083, hci_le_set_periodic_advertising_response_data_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_SYNC_SUBEVENT_ENABLED) || HCI_LE_SET_PERIODIC_SYNC_SUBEVENT_ENABLED) && !HCI_LE_SET_PERIODIC_SYNC_SUBEVENT_FORCE_DISABLED + /* hci_le_set_periodic_sync_subevent */ + {0x2084, hci_le_set_periodic_sync_subevent_process}, +#endif +#if (!defined(HCI_LE_EXTENDED_CREATE_CONNECTION_V2_ENABLED) || HCI_LE_EXTENDED_CREATE_CONNECTION_V2_ENABLED) && !HCI_LE_EXTENDED_CREATE_CONNECTION_V2_FORCE_DISABLED + /* hci_le_extended_create_connection_v2 */ + {0x2085, hci_le_extended_create_connection_v2_process}, +#endif +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_V2_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_V2_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_V2_FORCE_DISABLED + /* hci_le_set_periodic_advertising_parameters_v2 */ + {0x2086, hci_le_set_periodic_advertising_parameters_v2_process}, +#endif +#if (!defined(ACI_HAL_GET_FW_BUILD_NUMBER_ENABLED) || ACI_HAL_GET_FW_BUILD_NUMBER_ENABLED) && !ACI_HAL_GET_FW_BUILD_NUMBER_FORCE_DISABLED + /* aci_hal_get_fw_build_number */ + {0xfc00, aci_hal_get_fw_build_number_process}, +#endif +#if (!defined(ACI_HAL_GET_FIRMWARE_DETAILS_ENABLED) || ACI_HAL_GET_FIRMWARE_DETAILS_ENABLED) && !ACI_HAL_GET_FIRMWARE_DETAILS_FORCE_DISABLED + /* aci_hal_get_firmware_details */ + {0xfc01, aci_hal_get_firmware_details_process}, +#endif +#if (!defined(ACI_HAL_GET_FIRMWARE_DETAILS_V2_ENABLED) || ACI_HAL_GET_FIRMWARE_DETAILS_V2_ENABLED) && !ACI_HAL_GET_FIRMWARE_DETAILS_V2_FORCE_DISABLED + /* aci_hal_get_firmware_details_v2 */ + {0xfc02, aci_hal_get_firmware_details_v2_process}, +#endif +#if (!defined(ACI_HAL_WRITE_CONFIG_DATA_ENABLED) || ACI_HAL_WRITE_CONFIG_DATA_ENABLED) && !ACI_HAL_WRITE_CONFIG_DATA_FORCE_DISABLED + /* aci_hal_write_config_data */ + {0xfc0c, aci_hal_write_config_data_process}, +#endif +#if (!defined(ACI_HAL_READ_CONFIG_DATA_ENABLED) || ACI_HAL_READ_CONFIG_DATA_ENABLED) && !ACI_HAL_READ_CONFIG_DATA_FORCE_DISABLED + /* aci_hal_read_config_data */ + {0xfc0d, aci_hal_read_config_data_process}, +#endif +#if (!defined(ACI_HAL_SET_TX_POWER_LEVEL_ENABLED) || ACI_HAL_SET_TX_POWER_LEVEL_ENABLED) && !ACI_HAL_SET_TX_POWER_LEVEL_FORCE_DISABLED + /* aci_hal_set_tx_power_level */ + {0xfc0f, aci_hal_set_tx_power_level_process}, +#endif +#if (!defined(ACI_HAL_LE_TX_TEST_PACKET_NUMBER_ENABLED) || ACI_HAL_LE_TX_TEST_PACKET_NUMBER_ENABLED) && !ACI_HAL_LE_TX_TEST_PACKET_NUMBER_FORCE_DISABLED + /* aci_hal_le_tx_test_packet_number */ + {0xfc14, aci_hal_le_tx_test_packet_number_process}, +#endif +#if (!defined(ACI_HAL_TONE_START_ENABLED) || ACI_HAL_TONE_START_ENABLED) && !ACI_HAL_TONE_START_FORCE_DISABLED + /* aci_hal_tone_start */ + {0xfc15, aci_hal_tone_start_process}, +#endif +#if (!defined(ACI_HAL_TONE_STOP_ENABLED) || ACI_HAL_TONE_STOP_ENABLED) && !ACI_HAL_TONE_STOP_FORCE_DISABLED + /* aci_hal_tone_stop */ + {0xfc16, aci_hal_tone_stop_process}, +#endif +#if (!defined(ACI_HAL_GET_LINK_STATUS_ENABLED) || ACI_HAL_GET_LINK_STATUS_ENABLED) && !ACI_HAL_GET_LINK_STATUS_FORCE_DISABLED + /* aci_hal_get_link_status */ + {0xfc17, aci_hal_get_link_status_process}, +#endif +#if (!defined(ACI_HAL_SET_RADIO_ACTIVITY_MASK_ENABLED) || ACI_HAL_SET_RADIO_ACTIVITY_MASK_ENABLED) && !ACI_HAL_SET_RADIO_ACTIVITY_MASK_FORCE_DISABLED + /* aci_hal_set_radio_activity_mask */ + {0xfc18, aci_hal_set_radio_activity_mask_process}, +#endif +#if (!defined(ACI_HAL_SET_LE_POWER_CONTROL_ENABLED) || ACI_HAL_SET_LE_POWER_CONTROL_ENABLED) && !ACI_HAL_SET_LE_POWER_CONTROL_FORCE_DISABLED + /* aci_hal_set_le_power_control */ + {0xfc1c, aci_hal_set_le_power_control_process}, +#endif +#if (!defined(ACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED) || ACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED) && !ACI_HAL_TRANSMITTER_TEST_PACKETS_FORCE_DISABLED + /* aci_hal_transmitter_test_packets */ + {0xfc2b, aci_hal_transmitter_test_packets_process}, +#endif +#if (!defined(ACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED) || ACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED) && !ACI_HAL_TRANSMITTER_TEST_PACKETS_V2_FORCE_DISABLED + /* aci_hal_transmitter_test_packets_v2 */ + {0xfc2c, aci_hal_transmitter_test_packets_v2_process}, +#endif +#if (!defined(ACI_HAL_WRITE_RADIO_REG_ENABLED) || ACI_HAL_WRITE_RADIO_REG_ENABLED) && !ACI_HAL_WRITE_RADIO_REG_FORCE_DISABLED + /* aci_hal_write_radio_reg */ + {0xfc35, aci_hal_write_radio_reg_process}, +#endif +#if (!defined(ACI_HAL_READ_RADIO_REG_ENABLED) || ACI_HAL_READ_RADIO_REG_ENABLED) && !ACI_HAL_READ_RADIO_REG_FORCE_DISABLED + /* aci_hal_read_radio_reg */ + {0xfc36, aci_hal_read_radio_reg_process}, +#endif +#if (!defined(ACI_HAL_SET_ANTENNA_SWITCH_PARAMETERS_ENABLED) || ACI_HAL_SET_ANTENNA_SWITCH_PARAMETERS_ENABLED) && !ACI_HAL_SET_ANTENNA_SWITCH_PARAMETERS_FORCE_DISABLED + /* aci_hal_set_antenna_switch_parameters */ + {0xfc37, aci_hal_set_antenna_switch_parameters_process}, +#endif +#if (!defined(ACI_HAL_PERIPHERAL_LATENCY_ENABLE_ENABLED) || ACI_HAL_PERIPHERAL_LATENCY_ENABLE_ENABLED) && !ACI_HAL_PERIPHERAL_LATENCY_ENABLE_FORCE_DISABLED + /* aci_hal_peripheral_latency_enable */ + {0xfc38, aci_hal_peripheral_latency_enable_process}, +#endif +#if (!defined(ACI_HAL_GET_EVT_FIFO_MAX_LEVEL_ENABLED) || ACI_HAL_GET_EVT_FIFO_MAX_LEVEL_ENABLED) && !ACI_HAL_GET_EVT_FIFO_MAX_LEVEL_FORCE_DISABLED + /* aci_hal_get_evt_fifo_max_level */ + {0xfc60, aci_hal_get_evt_fifo_max_level_process}, +#endif + +#if BLESTACK_CONTROLLER_ONLY==0 + +#if (!defined(ACI_GAP_INIT_ENABLED) || ACI_GAP_INIT_ENABLED) && !ACI_GAP_INIT_FORCE_DISABLED + /* aci_gap_init */ + {0xfc81, aci_gap_init_process}, +#endif +#if (!defined(ACI_GAP_SET_IO_CAPABILITY_ENABLED) || ACI_GAP_SET_IO_CAPABILITY_ENABLED) && !ACI_GAP_SET_IO_CAPABILITY_FORCE_DISABLED + /* aci_gap_set_io_capability */ + {0xfc85, aci_gap_set_io_capability_process}, +#endif +#if (!defined(ACI_GAP_SET_SECURITY_REQUIREMENTS_ENABLED) || ACI_GAP_SET_SECURITY_REQUIREMENTS_ENABLED) && !ACI_GAP_SET_SECURITY_REQUIREMENTS_FORCE_DISABLED + /* aci_gap_set_security_requirements */ + {0xfc86, aci_gap_set_security_requirements_process}, +#endif +#if (!defined(ACI_GAP_PASSKEY_RESP_ENABLED) || ACI_GAP_PASSKEY_RESP_ENABLED) && !ACI_GAP_PASSKEY_RESP_FORCE_DISABLED + /* aci_gap_passkey_resp */ + {0xfc88, aci_gap_passkey_resp_process}, +#endif +#if (!defined(ACI_GAP_PROFILE_INIT_ENABLED) || ACI_GAP_PROFILE_INIT_ENABLED) && !ACI_GAP_PROFILE_INIT_FORCE_DISABLED + /* aci_gap_profile_init */ + {0xfc8a, aci_gap_profile_init_process}, +#endif +#if (!defined(ACI_GAP_SET_SECURITY_ENABLED) || ACI_GAP_SET_SECURITY_ENABLED) && !ACI_GAP_SET_SECURITY_FORCE_DISABLED + /* aci_gap_set_security */ + {0xfc8d, aci_gap_set_security_process}, +#endif +#if (!defined(ACI_GAP_GET_SECURITY_LEVEL_ENABLED) || ACI_GAP_GET_SECURITY_LEVEL_ENABLED) && !ACI_GAP_GET_SECURITY_LEVEL_FORCE_DISABLED + /* aci_gap_get_security_level */ + {0xfc90, aci_gap_get_security_level_process}, +#endif +#if (!defined(ACI_GAP_SET_LE_EVENT_MASK_ENABLED) || ACI_GAP_SET_LE_EVENT_MASK_ENABLED) && !ACI_GAP_SET_LE_EVENT_MASK_FORCE_DISABLED + /* aci_gap_set_le_event_mask */ + {0xfc92, aci_gap_set_le_event_mask_process}, +#endif +#if (!defined(ACI_GAP_TERMINATE_ENABLED) || ACI_GAP_TERMINATE_ENABLED) && !ACI_GAP_TERMINATE_FORCE_DISABLED + /* aci_gap_terminate */ + {0xfc93, aci_gap_terminate_process}, +#endif +#if (!defined(ACI_GAP_CLEAR_SECURITY_DB_ENABLED) || ACI_GAP_CLEAR_SECURITY_DB_ENABLED) && !ACI_GAP_CLEAR_SECURITY_DB_FORCE_DISABLED + /* aci_gap_clear_security_db */ + {0xfc94, aci_gap_clear_security_db_process}, +#endif +#if (!defined(ACI_GAP_PAIRING_RESP_ENABLED) || ACI_GAP_PAIRING_RESP_ENABLED) && !ACI_GAP_PAIRING_RESP_FORCE_DISABLED + /* aci_gap_pairing_resp */ + {0xfc96, aci_gap_pairing_resp_process}, +#endif +#if (!defined(ACI_GAP_CREATE_CONNECTION_ENABLED) || ACI_GAP_CREATE_CONNECTION_ENABLED) && !ACI_GAP_CREATE_CONNECTION_FORCE_DISABLED + /* aci_gap_create_connection */ + {0xfc9c, aci_gap_create_connection_process}, +#endif +#if (!defined(ACI_GAP_TERMINATE_PROC_ENABLED) || ACI_GAP_TERMINATE_PROC_ENABLED) && !ACI_GAP_TERMINATE_PROC_FORCE_DISABLED + /* aci_gap_terminate_proc */ + {0xfc9d, aci_gap_terminate_proc_process}, +#endif +#if (!defined(ACI_GAP_START_CONNECTION_UPDATE_ENABLED) || ACI_GAP_START_CONNECTION_UPDATE_ENABLED) && !ACI_GAP_START_CONNECTION_UPDATE_FORCE_DISABLED + /* aci_gap_start_connection_update */ + {0xfc9e, aci_gap_start_connection_update_process}, +#endif +#if (!defined(ACI_GAP_RESOLVE_PRIVATE_ADDR_ENABLED) || ACI_GAP_RESOLVE_PRIVATE_ADDR_ENABLED) && !ACI_GAP_RESOLVE_PRIVATE_ADDR_FORCE_DISABLED + /* aci_gap_resolve_private_addr */ + {0xfca0, aci_gap_resolve_private_addr_process}, +#endif +#if (!defined(ACI_GAP_GET_BONDED_DEVICES_ENABLED) || ACI_GAP_GET_BONDED_DEVICES_ENABLED) && !ACI_GAP_GET_BONDED_DEVICES_FORCE_DISABLED + /* aci_gap_get_bonded_devices */ + {0xfca3, aci_gap_get_bonded_devices_process}, +#endif +#if (!defined(ACI_GAP_IS_DEVICE_BONDED_ENABLED) || ACI_GAP_IS_DEVICE_BONDED_ENABLED) && !ACI_GAP_IS_DEVICE_BONDED_FORCE_DISABLED + /* aci_gap_is_device_bonded */ + {0xfca4, aci_gap_is_device_bonded_process}, +#endif +#if (!defined(ACI_GAP_NUMERIC_COMPARISON_VALUE_CONFIRM_YESNO_ENABLED) || ACI_GAP_NUMERIC_COMPARISON_VALUE_CONFIRM_YESNO_ENABLED) && !ACI_GAP_NUMERIC_COMPARISON_VALUE_CONFIRM_YESNO_FORCE_DISABLED + /* aci_gap_numeric_comparison_value_confirm_yesno */ + {0xfca5, aci_gap_numeric_comparison_value_confirm_yesno_process}, +#endif +#if (!defined(ACI_GAP_PASSKEY_INPUT_ENABLED) || ACI_GAP_PASSKEY_INPUT_ENABLED) && !ACI_GAP_PASSKEY_INPUT_FORCE_DISABLED + /* aci_gap_passkey_input */ + {0xfca6, aci_gap_passkey_input_process}, +#endif +#if (!defined(ACI_GAP_GET_OOB_DATA_ENABLED) || ACI_GAP_GET_OOB_DATA_ENABLED) && !ACI_GAP_GET_OOB_DATA_FORCE_DISABLED + /* aci_gap_get_oob_data */ + {0xfca7, aci_gap_get_oob_data_process}, +#endif +#if (!defined(ACI_GAP_SET_OOB_DATA_ENABLED) || ACI_GAP_SET_OOB_DATA_ENABLED) && !ACI_GAP_SET_OOB_DATA_FORCE_DISABLED + /* aci_gap_set_oob_data */ + {0xfca8, aci_gap_set_oob_data_process}, +#endif +#if (!defined(ACI_GAP_REMOVE_BONDED_DEVICE_ENABLED) || ACI_GAP_REMOVE_BONDED_DEVICE_ENABLED) && !ACI_GAP_REMOVE_BONDED_DEVICE_FORCE_DISABLED + /* aci_gap_remove_bonded_device */ + {0xfcaa, aci_gap_remove_bonded_device_process}, +#endif +#if (!defined(ACI_GAP_SET_ADVERTISING_CONFIGURATION_ENABLED) || ACI_GAP_SET_ADVERTISING_CONFIGURATION_ENABLED) && !ACI_GAP_SET_ADVERTISING_CONFIGURATION_FORCE_DISABLED + /* aci_gap_set_advertising_configuration */ + {0xfcab, aci_gap_set_advertising_configuration_process}, +#endif +#if (!defined(ACI_GAP_SET_ADVERTISING_ENABLE_ENABLED) || ACI_GAP_SET_ADVERTISING_ENABLE_ENABLED) && !ACI_GAP_SET_ADVERTISING_ENABLE_FORCE_DISABLED + /* aci_gap_set_advertising_enable */ + {0xfcac, aci_gap_set_advertising_enable_process}, +#endif +#if (!defined(ACI_GAP_SET_ADVERTISING_DATA_NWK_ENABLED) || ACI_GAP_SET_ADVERTISING_DATA_NWK_ENABLED) && !ACI_GAP_SET_ADVERTISING_DATA_NWK_FORCE_DISABLED + /* aci_gap_set_advertising_data_nwk */ + {0xfcad, aci_gap_set_advertising_data_nwk_process}, +#endif +#if (!defined(ACI_GAP_SET_SCAN_RESPONSE_DATA_NWK_ENABLED) || ACI_GAP_SET_SCAN_RESPONSE_DATA_NWK_ENABLED) && !ACI_GAP_SET_SCAN_RESPONSE_DATA_NWK_FORCE_DISABLED + /* aci_gap_set_scan_response_data_nwk */ + {0xfcae, aci_gap_set_scan_response_data_nwk_process}, +#endif +#if (!defined(ACI_GAP_SET_SCAN_CONFIGURATION_ENABLED) || ACI_GAP_SET_SCAN_CONFIGURATION_ENABLED) && !ACI_GAP_SET_SCAN_CONFIGURATION_FORCE_DISABLED + /* aci_gap_set_scan_configuration */ + {0xfcaf, aci_gap_set_scan_configuration_process}, +#endif +#if (!defined(ACI_GAP_SET_CONNECTION_CONFIGURATION_ENABLED) || ACI_GAP_SET_CONNECTION_CONFIGURATION_ENABLED) && !ACI_GAP_SET_CONNECTION_CONFIGURATION_FORCE_DISABLED + /* aci_gap_set_connection_configuration */ + {0xfcb0, aci_gap_set_connection_configuration_process}, +#endif +#if (!defined(ACI_GAP_START_PROCEDURE_ENABLED) || ACI_GAP_START_PROCEDURE_ENABLED) && !ACI_GAP_START_PROCEDURE_FORCE_DISABLED + /* aci_gap_start_procedure */ + {0xfcb1, aci_gap_start_procedure_process}, +#endif +#if (!defined(ACI_GAP_DISCOVER_NAME_ENABLED) || ACI_GAP_DISCOVER_NAME_ENABLED) && !ACI_GAP_DISCOVER_NAME_FORCE_DISABLED + /* aci_gap_discover_name */ + {0xfcb2, aci_gap_discover_name_process}, +#endif +#if (!defined(ACI_GAP_ADD_DEVICES_TO_FILTER_ACCEPT_AND_RESOLVING_LIST_ENABLED) || ACI_GAP_ADD_DEVICES_TO_FILTER_ACCEPT_AND_RESOLVING_LIST_ENABLED) && !ACI_GAP_ADD_DEVICES_TO_FILTER_ACCEPT_AND_RESOLVING_LIST_FORCE_DISABLED + /* aci_gap_add_devices_to_filter_accept_and_resolving_list */ + {0xfcb3, aci_gap_add_devices_to_filter_accept_and_resolving_list_process}, +#endif +#if (!defined(ACI_GAP_CONFIGURE_FILTER_ACCEPT_AND_RESOLVING_LIST_ENABLED) || ACI_GAP_CONFIGURE_FILTER_ACCEPT_AND_RESOLVING_LIST_ENABLED) && !ACI_GAP_CONFIGURE_FILTER_ACCEPT_AND_RESOLVING_LIST_FORCE_DISABLED + /* aci_gap_configure_filter_accept_and_resolving_list */ + {0xfcb4, aci_gap_configure_filter_accept_and_resolving_list_process}, +#endif +#if (!defined(ACI_GAP_REMOVE_ADVERTISING_SET_ENABLED) || ACI_GAP_REMOVE_ADVERTISING_SET_ENABLED) && !ACI_GAP_REMOVE_ADVERTISING_SET_FORCE_DISABLED + /* aci_gap_remove_advertising_set */ + {0xfcba, aci_gap_remove_advertising_set_process}, +#endif +#if (!defined(ACI_GAP_CLEAR_ADVERTISING_SETS_ENABLED) || ACI_GAP_CLEAR_ADVERTISING_SETS_ENABLED) && !ACI_GAP_CLEAR_ADVERTISING_SETS_FORCE_DISABLED + /* aci_gap_clear_advertising_sets */ + {0xfcbb, aci_gap_clear_advertising_sets_process}, +#endif +#if (!defined(ACI_GAP_CREATE_PERIODIC_ADVERTISING_CONNECTION_ENABLED) || ACI_GAP_CREATE_PERIODIC_ADVERTISING_CONNECTION_ENABLED) && !ACI_GAP_CREATE_PERIODIC_ADVERTISING_CONNECTION_FORCE_DISABLED + /* aci_gap_create_periodic_advertising_connection */ + {0xfcca, aci_gap_create_periodic_advertising_connection_process}, +#endif +#if (!defined(ACI_GAP_ENCRYPT_ADV_DATA_NWK_ENABLED) || ACI_GAP_ENCRYPT_ADV_DATA_NWK_ENABLED) && !ACI_GAP_ENCRYPT_ADV_DATA_NWK_FORCE_DISABLED + /* aci_gap_encrypt_adv_data_nwk */ + {0xfccb, aci_gap_encrypt_adv_data_nwk_process}, +#endif +#if (!defined(ACI_GAP_DECRYPT_ADV_DATA_NWK_ENABLED) || ACI_GAP_DECRYPT_ADV_DATA_NWK_ENABLED) && !ACI_GAP_DECRYPT_ADV_DATA_NWK_FORCE_DISABLED + /* aci_gap_decrypt_adv_data_nwk */ + {0xfccc, aci_gap_decrypt_adv_data_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_PROFILE_INIT_ENABLED) || ACI_GATT_SRV_PROFILE_INIT_ENABLED) && !ACI_GATT_SRV_PROFILE_INIT_FORCE_DISABLED + /* aci_gatt_srv_profile_init */ + {0xfd01, aci_gatt_srv_profile_init_process}, +#endif +#if (!defined(ACI_GATT_SRV_ADD_SERVICE_NWK_ENABLED) || ACI_GATT_SRV_ADD_SERVICE_NWK_ENABLED) && !ACI_GATT_SRV_ADD_SERVICE_NWK_FORCE_DISABLED + /* aci_gatt_srv_add_service_nwk */ + {0xfd02, aci_gatt_srv_add_service_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_INCLUDE_SERVICE_NWK_ENABLED) || ACI_GATT_SRV_INCLUDE_SERVICE_NWK_ENABLED) && !ACI_GATT_SRV_INCLUDE_SERVICE_NWK_FORCE_DISABLED + /* aci_gatt_srv_include_service_nwk */ + {0xfd03, aci_gatt_srv_include_service_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_ADD_CHAR_NWK_ENABLED) || ACI_GATT_SRV_ADD_CHAR_NWK_ENABLED) && !ACI_GATT_SRV_ADD_CHAR_NWK_FORCE_DISABLED + /* aci_gatt_srv_add_char_nwk */ + {0xfd04, aci_gatt_srv_add_char_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_ADD_CHAR_DESC_NWK_ENABLED) || ACI_GATT_SRV_ADD_CHAR_DESC_NWK_ENABLED) && !ACI_GATT_SRV_ADD_CHAR_DESC_NWK_FORCE_DISABLED + /* aci_gatt_srv_add_char_desc_nwk */ + {0xfd05, aci_gatt_srv_add_char_desc_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_WRITE_HANDLE_VALUE_NWK_ENABLED) || ACI_GATT_SRV_WRITE_HANDLE_VALUE_NWK_ENABLED) && !ACI_GATT_SRV_WRITE_HANDLE_VALUE_NWK_FORCE_DISABLED + /* aci_gatt_srv_write_handle_value_nwk */ + {0xfd06, aci_gatt_srv_write_handle_value_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_RM_CHAR_NWK_ENABLED) || ACI_GATT_SRV_RM_CHAR_NWK_ENABLED) && !ACI_GATT_SRV_RM_CHAR_NWK_FORCE_DISABLED + /* aci_gatt_srv_rm_char_nwk */ + {0xfd07, aci_gatt_srv_rm_char_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_RM_SERVICE_NWK_ENABLED) || ACI_GATT_SRV_RM_SERVICE_NWK_ENABLED) && !ACI_GATT_SRV_RM_SERVICE_NWK_FORCE_DISABLED + /* aci_gatt_srv_rm_service_nwk */ + {0xfd08, aci_gatt_srv_rm_service_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_RM_INCLUDE_SERVICE_NWK_ENABLED) || ACI_GATT_SRV_RM_INCLUDE_SERVICE_NWK_ENABLED) && !ACI_GATT_SRV_RM_INCLUDE_SERVICE_NWK_FORCE_DISABLED + /* aci_gatt_srv_rm_include_service_nwk */ + {0xfd09, aci_gatt_srv_rm_include_service_nwk_process}, +#endif +#if (!defined(ACI_GATT_SET_EVENT_MASK_ENABLED) || ACI_GATT_SET_EVENT_MASK_ENABLED) && !ACI_GATT_SET_EVENT_MASK_FORCE_DISABLED + /* aci_gatt_set_event_mask */ + {0xfd0a, aci_gatt_set_event_mask_process}, +#endif +#if (!defined(ACI_GATT_CLT_EXCHANGE_CONFIG_ENABLED) || ACI_GATT_CLT_EXCHANGE_CONFIG_ENABLED) && !ACI_GATT_CLT_EXCHANGE_CONFIG_FORCE_DISABLED + /* aci_gatt_clt_exchange_config */ + {0xfd0b, aci_gatt_clt_exchange_config_process}, +#endif +#if (!defined(ACI_GATT_CLT_PREPARE_WRITE_REQ_ENABLED) || ACI_GATT_CLT_PREPARE_WRITE_REQ_ENABLED) && !ACI_GATT_CLT_PREPARE_WRITE_REQ_FORCE_DISABLED + /* aci_gatt_clt_prepare_write_req */ + {0xfd10, aci_gatt_clt_prepare_write_req_process}, +#endif +#if (!defined(ACI_GATT_CLT_EXECUTE_WRITE_REQ_ENABLED) || ACI_GATT_CLT_EXECUTE_WRITE_REQ_ENABLED) && !ACI_GATT_CLT_EXECUTE_WRITE_REQ_FORCE_DISABLED + /* aci_gatt_clt_execute_write_req */ + {0xfd11, aci_gatt_clt_execute_write_req_process}, +#endif +#if (!defined(ACI_GATT_CLT_DISC_ALL_PRIMARY_SERVICES_ENABLED) || ACI_GATT_CLT_DISC_ALL_PRIMARY_SERVICES_ENABLED) && !ACI_GATT_CLT_DISC_ALL_PRIMARY_SERVICES_FORCE_DISABLED + /* aci_gatt_clt_disc_all_primary_services */ + {0xfd12, aci_gatt_clt_disc_all_primary_services_process}, +#endif +#if (!defined(ACI_GATT_CLT_DISC_PRIMARY_SERVICE_BY_UUID_ENABLED) || ACI_GATT_CLT_DISC_PRIMARY_SERVICE_BY_UUID_ENABLED) && !ACI_GATT_CLT_DISC_PRIMARY_SERVICE_BY_UUID_FORCE_DISABLED + /* aci_gatt_clt_disc_primary_service_by_uuid */ + {0xfd13, aci_gatt_clt_disc_primary_service_by_uuid_process}, +#endif +#if (!defined(ACI_GATT_CLT_FIND_INCLUDED_SERVICES_ENABLED) || ACI_GATT_CLT_FIND_INCLUDED_SERVICES_ENABLED) && !ACI_GATT_CLT_FIND_INCLUDED_SERVICES_FORCE_DISABLED + /* aci_gatt_clt_find_included_services */ + {0xfd14, aci_gatt_clt_find_included_services_process}, +#endif +#if (!defined(ACI_GATT_CLT_DISC_ALL_CHAR_OF_SERVICE_ENABLED) || ACI_GATT_CLT_DISC_ALL_CHAR_OF_SERVICE_ENABLED) && !ACI_GATT_CLT_DISC_ALL_CHAR_OF_SERVICE_FORCE_DISABLED + /* aci_gatt_clt_disc_all_char_of_service */ + {0xfd15, aci_gatt_clt_disc_all_char_of_service_process}, +#endif +#if (!defined(ACI_GATT_CLT_DISC_CHAR_BY_UUID_ENABLED) || ACI_GATT_CLT_DISC_CHAR_BY_UUID_ENABLED) && !ACI_GATT_CLT_DISC_CHAR_BY_UUID_FORCE_DISABLED + /* aci_gatt_clt_disc_char_by_uuid */ + {0xfd16, aci_gatt_clt_disc_char_by_uuid_process}, +#endif +#if (!defined(ACI_GATT_CLT_DISC_ALL_CHAR_DESC_ENABLED) || ACI_GATT_CLT_DISC_ALL_CHAR_DESC_ENABLED) && !ACI_GATT_CLT_DISC_ALL_CHAR_DESC_FORCE_DISABLED + /* aci_gatt_clt_disc_all_char_desc */ + {0xfd17, aci_gatt_clt_disc_all_char_desc_process}, +#endif +#if (!defined(ACI_GATT_CLT_READ_ENABLED) || ACI_GATT_CLT_READ_ENABLED) && !ACI_GATT_CLT_READ_FORCE_DISABLED + /* aci_gatt_clt_read */ + {0xfd18, aci_gatt_clt_read_process}, +#endif +#if (!defined(ACI_GATT_CLT_READ_USING_CHAR_UUID_ENABLED) || ACI_GATT_CLT_READ_USING_CHAR_UUID_ENABLED) && !ACI_GATT_CLT_READ_USING_CHAR_UUID_FORCE_DISABLED + /* aci_gatt_clt_read_using_char_uuid */ + {0xfd19, aci_gatt_clt_read_using_char_uuid_process}, +#endif +#if (!defined(ACI_GATT_CLT_READ_LONG_ENABLED) || ACI_GATT_CLT_READ_LONG_ENABLED) && !ACI_GATT_CLT_READ_LONG_FORCE_DISABLED + /* aci_gatt_clt_read_long */ + {0xfd1a, aci_gatt_clt_read_long_process}, +#endif +#if (!defined(ACI_GATT_CLT_READ_MULTIPLE_CHAR_VALUE_ENABLED) || ACI_GATT_CLT_READ_MULTIPLE_CHAR_VALUE_ENABLED) && !ACI_GATT_CLT_READ_MULTIPLE_CHAR_VALUE_FORCE_DISABLED + /* aci_gatt_clt_read_multiple_char_value */ + {0xfd1b, aci_gatt_clt_read_multiple_char_value_process}, +#endif +#if (!defined(ACI_GATT_CLT_WRITE_NWK_ENABLED) || ACI_GATT_CLT_WRITE_NWK_ENABLED) && !ACI_GATT_CLT_WRITE_NWK_FORCE_DISABLED + /* aci_gatt_clt_write_nwk */ + {0xfd1c, aci_gatt_clt_write_nwk_process}, +#endif +#if (!defined(ACI_GATT_CLT_WRITE_LONG_NWK_ENABLED) || ACI_GATT_CLT_WRITE_LONG_NWK_ENABLED) && !ACI_GATT_CLT_WRITE_LONG_NWK_FORCE_DISABLED + /* aci_gatt_clt_write_long_nwk */ + {0xfd1d, aci_gatt_clt_write_long_nwk_process}, +#endif +#if (!defined(ACI_GATT_CLT_WRITE_CHAR_RELIABLE_NWK_ENABLED) || ACI_GATT_CLT_WRITE_CHAR_RELIABLE_NWK_ENABLED) && !ACI_GATT_CLT_WRITE_CHAR_RELIABLE_NWK_FORCE_DISABLED + /* aci_gatt_clt_write_char_reliable_nwk */ + {0xfd1e, aci_gatt_clt_write_char_reliable_nwk_process}, +#endif +#if (!defined(ACI_GATT_CLT_WRITE_WITHOUT_RESP_ENABLED) || ACI_GATT_CLT_WRITE_WITHOUT_RESP_ENABLED) && !ACI_GATT_CLT_WRITE_WITHOUT_RESP_FORCE_DISABLED + /* aci_gatt_clt_write_without_resp */ + {0xfd23, aci_gatt_clt_write_without_resp_process}, +#endif +#if (!defined(ACI_GATT_CLT_SIGNED_WRITE_WITHOUT_RESP_ENABLED) || ACI_GATT_CLT_SIGNED_WRITE_WITHOUT_RESP_ENABLED) && !ACI_GATT_CLT_SIGNED_WRITE_WITHOUT_RESP_FORCE_DISABLED + /* aci_gatt_clt_signed_write_without_resp */ + {0xfd24, aci_gatt_clt_signed_write_without_resp_process}, +#endif +#if (!defined(ACI_GATT_CLT_CONFIRM_INDICATION_ENABLED) || ACI_GATT_CLT_CONFIRM_INDICATION_ENABLED) && !ACI_GATT_CLT_CONFIRM_INDICATION_FORCE_DISABLED + /* aci_gatt_clt_confirm_indication */ + {0xfd25, aci_gatt_clt_confirm_indication_process}, +#endif +#if (!defined(ACI_GATT_SRV_SET_SECURITY_PERMISSION_NWK_ENABLED) || ACI_GATT_SRV_SET_SECURITY_PERMISSION_NWK_ENABLED) && !ACI_GATT_SRV_SET_SECURITY_PERMISSION_NWK_FORCE_DISABLED + /* aci_gatt_srv_set_security_permission_nwk */ + {0xfd28, aci_gatt_srv_set_security_permission_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_READ_HANDLE_VALUE_NWK_ENABLED) || ACI_GATT_SRV_READ_HANDLE_VALUE_NWK_ENABLED) && !ACI_GATT_SRV_READ_HANDLE_VALUE_NWK_FORCE_DISABLED + /* aci_gatt_srv_read_handle_value_nwk */ + {0xfd2a, aci_gatt_srv_read_handle_value_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_SET_ACCESS_PERMISSION_NWK_ENABLED) || ACI_GATT_SRV_SET_ACCESS_PERMISSION_NWK_ENABLED) && !ACI_GATT_SRV_SET_ACCESS_PERMISSION_NWK_FORCE_DISABLED + /* aci_gatt_srv_set_access_permission_nwk */ + {0xfd2e, aci_gatt_srv_set_access_permission_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_NOTIFY_ENABLED) || ACI_GATT_SRV_NOTIFY_ENABLED) && !ACI_GATT_SRV_NOTIFY_FORCE_DISABLED + /* aci_gatt_srv_notify */ + {0xfd2f, aci_gatt_srv_notify_process}, +#endif +#if (!defined(ACI_GATT_SRV_EXEC_WRITE_RESP_NWK_ENABLED) || ACI_GATT_SRV_EXEC_WRITE_RESP_NWK_ENABLED) && !ACI_GATT_SRV_EXEC_WRITE_RESP_NWK_FORCE_DISABLED + /* aci_gatt_srv_exec_write_resp_nwk */ + {0xfd31, aci_gatt_srv_exec_write_resp_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_AUTHORIZE_RESP_NWK_ENABLED) || ACI_GATT_SRV_AUTHORIZE_RESP_NWK_ENABLED) && !ACI_GATT_SRV_AUTHORIZE_RESP_NWK_FORCE_DISABLED + /* aci_gatt_srv_authorize_resp_nwk */ + {0xfd33, aci_gatt_srv_authorize_resp_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_READ_PREPARE_QUEUE_NWK_ENABLED) || ACI_GATT_SRV_READ_PREPARE_QUEUE_NWK_ENABLED) && !ACI_GATT_SRV_READ_PREPARE_QUEUE_NWK_FORCE_DISABLED + /* aci_gatt_srv_read_prepare_queue_nwk */ + {0xfd35, aci_gatt_srv_read_prepare_queue_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_WRITE_MULTIPLE_INSTANCE_HANDLE_VALUE_ENABLED) || ACI_GATT_SRV_WRITE_MULTIPLE_INSTANCE_HANDLE_VALUE_ENABLED) && !ACI_GATT_SRV_WRITE_MULTIPLE_INSTANCE_HANDLE_VALUE_FORCE_DISABLED + /* aci_gatt_srv_write_multiple_instance_handle_value */ + {0xfd36, aci_gatt_srv_write_multiple_instance_handle_value_process}, +#endif +#if (!defined(ACI_GATT_SRV_READ_MULTIPLE_INSTANCE_HANDLE_VALUE_NWK_ENABLED) || ACI_GATT_SRV_READ_MULTIPLE_INSTANCE_HANDLE_VALUE_NWK_ENABLED) && !ACI_GATT_SRV_READ_MULTIPLE_INSTANCE_HANDLE_VALUE_NWK_FORCE_DISABLED + /* aci_gatt_srv_read_multiple_instance_handle_value_nwk */ + {0xfd37, aci_gatt_srv_read_multiple_instance_handle_value_nwk_process}, +#endif +#if (!defined(ACI_GATT_SRV_MULTI_NOTIFY_ENABLED) || ACI_GATT_SRV_MULTI_NOTIFY_ENABLED) && !ACI_GATT_SRV_MULTI_NOTIFY_FORCE_DISABLED + /* aci_gatt_srv_multi_notify */ + {0xfd38, aci_gatt_srv_multi_notify_process}, +#endif +#if (!defined(ACI_GATT_CLT_READ_MULTIPLE_VAR_LEN_CHAR_VALUE_ENABLED) || ACI_GATT_CLT_READ_MULTIPLE_VAR_LEN_CHAR_VALUE_ENABLED) && !ACI_GATT_CLT_READ_MULTIPLE_VAR_LEN_CHAR_VALUE_FORCE_DISABLED + /* aci_gatt_clt_read_multiple_var_len_char_value */ + {0xfd39, aci_gatt_clt_read_multiple_var_len_char_value_process}, +#endif +#if (!defined(ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED) || ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED) && !ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_FORCE_DISABLED + /* aci_l2cap_connection_parameter_update_req */ + {0xfd81, aci_l2cap_connection_parameter_update_req_process}, +#endif +#if (!defined(ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_RESP_ENABLED) || ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_RESP_ENABLED) && !ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_RESP_FORCE_DISABLED + /* aci_l2cap_connection_parameter_update_resp */ + {0xfd82, aci_l2cap_connection_parameter_update_resp_process}, +#endif +#if (!defined(ACI_L2CAP_COS_CONNECTION_REQ_ENABLED) || ACI_L2CAP_COS_CONNECTION_REQ_ENABLED) && !ACI_L2CAP_COS_CONNECTION_REQ_FORCE_DISABLED + /* aci_l2cap_cos_connection_req */ + {0xfd83, aci_l2cap_cos_connection_req_process}, +#endif +#if (!defined(ACI_L2CAP_COS_CONNECTION_RESP_ENABLED) || ACI_L2CAP_COS_CONNECTION_RESP_ENABLED) && !ACI_L2CAP_COS_CONNECTION_RESP_FORCE_DISABLED + /* aci_l2cap_cos_connection_resp */ + {0xfd84, aci_l2cap_cos_connection_resp_process}, +#endif +#if (!defined(ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED) || ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED) && !ACI_L2CAP_COS_DISCONNECT_REQ_FORCE_DISABLED + /* aci_l2cap_cos_disconnect_req */ + {0xfd86, aci_l2cap_cos_disconnect_req_process}, +#endif +#if (!defined(ACI_L2CAP_COS_SDU_DATA_TRANSMIT_ENABLED) || ACI_L2CAP_COS_SDU_DATA_TRANSMIT_ENABLED) && !ACI_L2CAP_COS_SDU_DATA_TRANSMIT_FORCE_DISABLED + /* aci_l2cap_cos_sdu_data_transmit */ + {0xfd87, aci_l2cap_cos_sdu_data_transmit_process}, +#endif +#if (!defined(ACI_L2CAP_COS_RECONFIGURE_REQ_ENABLED) || ACI_L2CAP_COS_RECONFIGURE_REQ_ENABLED) && !ACI_L2CAP_COS_RECONFIGURE_REQ_FORCE_DISABLED + /* aci_l2cap_cos_reconfigure_req */ + {0xfd8a, aci_l2cap_cos_reconfigure_req_process}, +#endif +#if (!defined(ACI_L2CAP_COS_RECONFIGURE_RESP_ENABLED) || ACI_L2CAP_COS_RECONFIGURE_RESP_ENABLED) && !ACI_L2CAP_COS_RECONFIGURE_RESP_FORCE_DISABLED + /* aci_l2cap_cos_reconfigure_resp */ + {0xfd8b, aci_l2cap_cos_reconfigure_resp_process}, +#endif +#if (!defined(ACI_TEST_TX_NOTIFICATION_START_ENABLED) || ACI_TEST_TX_NOTIFICATION_START_ENABLED) && !ACI_TEST_TX_NOTIFICATION_START_FORCE_DISABLED + /* aci_test_tx_notification_start */ + {0xfe00, aci_test_tx_notification_start_process}, +#endif +#if (!defined(ACI_TEST_TX_WRITE_COMMAND_START_ENABLED) || ACI_TEST_TX_WRITE_COMMAND_START_ENABLED) && !ACI_TEST_TX_WRITE_COMMAND_START_FORCE_DISABLED + /* aci_test_tx_write_command_start */ + {0xfe01, aci_test_tx_write_command_start_process}, +#endif +#if (!defined(ACI_TEST_RX_START_ENABLED) || ACI_TEST_RX_START_ENABLED) && !ACI_TEST_RX_START_FORCE_DISABLED + /* aci_test_rx_start */ + {0xfe02, aci_test_rx_start_process}, +#endif +#if (!defined(ACI_TEST_STOP_ENABLED) || ACI_TEST_STOP_ENABLED) && !ACI_TEST_STOP_FORCE_DISABLED + /* aci_test_stop */ + {0xfe03, aci_test_stop_process}, +#endif +#if (!defined(ACI_TEST_REPORT_ENABLED) || ACI_TEST_REPORT_ENABLED) && !ACI_TEST_REPORT_FORCE_DISABLED + /* aci_test_report */ + {0xfe04, aci_test_report_process}, +#endif + +#endif /* BLESTACK_CONTROLLER_ONLY==0 */ + {0, NULL} +}; + +#if (!defined(HCI_DISCONNECT_ENABLED) || HCI_DISCONNECT_ENABLED) && !HCI_DISCONNECT_FORCE_DISABLED +/* tBleStatus hci_disconnect(uint16_t Connection_Handle, + uint8_t Reason); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t hci_disconnect_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_disconnect_cp0 *cp0 = (hci_disconnect_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = hci_disconnect(cp0->Connection_Handle /* 2 */, + cp0->Reason /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x06; + buffer_out[6] = 0x04; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_REMOTE_VERSION_INFORMATION_ENABLED) || HCI_READ_REMOTE_VERSION_INFORMATION_ENABLED) && !HCI_READ_REMOTE_VERSION_INFORMATION_FORCE_DISABLED +/* tBleStatus hci_read_remote_version_information(uint16_t Connection_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t hci_read_remote_version_information_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_read_remote_version_information_cp0 *cp0 = (hci_read_remote_version_information_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = hci_read_remote_version_information(cp0->Connection_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x1d; + buffer_out[6] = 0x04; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_SET_EVENT_MASK_ENABLED) || HCI_SET_EVENT_MASK_ENABLED) && !HCI_SET_EVENT_MASK_FORCE_DISABLED +/* tBleStatus hci_set_event_mask(uint8_t Event_Mask[8]); + */ +/* Command len: 8 */ +/* Response len: 1 */ +uint16_t hci_set_event_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_set_event_mask_cp0 *cp0 = (hci_set_event_mask_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 8) + { + goto fail; + } + + *status = hci_set_event_mask(cp0->Event_Mask /* 8 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x01; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_CONNECTION_ACCEPT_TIMEOUT_ENABLED) || HCI_READ_CONNECTION_ACCEPT_TIMEOUT_ENABLED) && !HCI_READ_CONNECTION_ACCEPT_TIMEOUT_FORCE_DISABLED +/* tBleStatus hci_read_connection_accept_timeout(uint16_t *Connection_Accept_Timeout); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 */ +uint16_t hci_read_connection_accept_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2; + /* Output params */ + hci_read_connection_accept_timeout_rp0 *rp0 = (hci_read_connection_accept_timeout_rp0 *) (buffer_out + 6); + uint16_t Connection_Accept_Timeout = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_read_connection_accept_timeout(&Connection_Accept_Timeout); +fail: + rp0->Connection_Accept_Timeout = Connection_Accept_Timeout; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x15; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_ENABLED) || HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_ENABLED) && !HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_FORCE_DISABLED +/* tBleStatus hci_write_connection_accept_timeout(uint16_t Connection_Accept_Timeout); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t hci_write_connection_accept_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_write_connection_accept_timeout_cp0 *cp0 = (hci_write_connection_accept_timeout_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = hci_write_connection_accept_timeout(cp0->Connection_Accept_Timeout /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x16; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_TRANSMIT_POWER_LEVEL_ENABLED) || HCI_READ_TRANSMIT_POWER_LEVEL_ENABLED) && !HCI_READ_TRANSMIT_POWER_LEVEL_FORCE_DISABLED +/* tBleStatus hci_read_transmit_power_level(uint16_t Connection_Handle, + uint8_t Type, + int8_t *Transmit_Power_Level); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 + 1 */ +uint16_t hci_read_transmit_power_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_read_transmit_power_level_cp0 *cp0 = (hci_read_transmit_power_level_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 1; + /* Output params */ + hci_read_transmit_power_level_rp0 *rp0 = (hci_read_transmit_power_level_rp0 *) (buffer_out + 6); + int8_t Transmit_Power_Level = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = hci_read_transmit_power_level(cp0->Connection_Handle /* 2 */, + cp0->Type /* 1 */, + &Transmit_Power_Level); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->Transmit_Power_Level = Transmit_Power_Level; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2d; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED) || HCI_READ_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED) && !HCI_READ_AFH_CHANNEL_ASSESSMENT_MODE_FORCE_DISABLED +/* tBleStatus hci_read_afh_channel_assessment_mode(uint8_t *AFH_Channel_Assessment_Mode); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 */ +uint16_t hci_read_afh_channel_assessment_mode_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1; + /* Output params */ + hci_read_afh_channel_assessment_mode_rp0 *rp0 = (hci_read_afh_channel_assessment_mode_rp0 *) (buffer_out + 6); + uint8_t AFH_Channel_Assessment_Mode = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_read_afh_channel_assessment_mode(&AFH_Channel_Assessment_Mode); +fail: + rp0->AFH_Channel_Assessment_Mode = AFH_Channel_Assessment_Mode; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x48; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED) || HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED) && !HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE_FORCE_DISABLED +/* tBleStatus hci_write_afh_channel_assessment_mode(uint8_t AFH_Channel_Assessment_Mode); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t hci_write_afh_channel_assessment_mode_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_write_afh_channel_assessment_mode_cp0 *cp0 = (hci_write_afh_channel_assessment_mode_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = hci_write_afh_channel_assessment_mode(cp0->AFH_Channel_Assessment_Mode /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x49; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_SET_EVENT_MASK_PAGE_2_ENABLED) || HCI_SET_EVENT_MASK_PAGE_2_ENABLED) && !HCI_SET_EVENT_MASK_PAGE_2_FORCE_DISABLED +/* tBleStatus hci_set_event_mask_page_2(uint8_t Event_Mask_Page_2[8]); + */ +/* Command len: 8 */ +/* Response len: 1 */ +uint16_t hci_set_event_mask_page_2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_set_event_mask_page_2_cp0 *cp0 = (hci_set_event_mask_page_2_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 8) + { + goto fail; + } + + *status = hci_set_event_mask_page_2(cp0->Event_Mask_Page_2 /* 8 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x63; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED) || HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED) && !HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_FORCE_DISABLED +/* tBleStatus hci_read_authenticated_payload_timeout(uint16_t Connection_Handle, + uint16_t *Authenticated_Payload_Timeout); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 + 2 */ +uint16_t hci_read_authenticated_payload_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_read_authenticated_payload_timeout_cp0 *cp0 = (hci_read_authenticated_payload_timeout_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 2; + /* Output params */ + hci_read_authenticated_payload_timeout_rp0 *rp0 = (hci_read_authenticated_payload_timeout_rp0 *) (buffer_out + 6); + uint16_t Authenticated_Payload_Timeout = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 2 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_read_authenticated_payload_timeout(cp0->Connection_Handle /* 2 */, + &Authenticated_Payload_Timeout); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->Authenticated_Payload_Timeout = Authenticated_Payload_Timeout; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x7b; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED) || HCI_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED) && !HCI_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_FORCE_DISABLED +/* tBleStatus hci_write_authenticated_payload_timeout(uint16_t Connection_Handle, + uint16_t Authenticated_Payload_Timeout); + */ +/* Command len: 2 + 2 */ +/* Response len: 1 + 2 */ +uint16_t hci_write_authenticated_payload_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_write_authenticated_payload_timeout_cp0 *cp0 = (hci_write_authenticated_payload_timeout_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_write_authenticated_payload_timeout_rp0 *rp0 = (hci_write_authenticated_payload_timeout_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 2) + { + goto fail; + } + + rp0->Status = hci_write_authenticated_payload_timeout(cp0->Connection_Handle /* 2 */, + cp0->Authenticated_Payload_Timeout /* 2 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x7c; + buffer_out[5] = 0x0c; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_LOCAL_VERSION_INFORMATION_ENABLED) || HCI_READ_LOCAL_VERSION_INFORMATION_ENABLED) && !HCI_READ_LOCAL_VERSION_INFORMATION_FORCE_DISABLED +/* tBleStatus hci_read_local_version_information(uint8_t *HCI_Version, + uint16_t *HCI_Revision, + uint8_t *LMP_PAL_Version, + uint16_t *Manufacturer_Name, + uint16_t *LMP_PAL_Subversion); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 + 2 + 1 + 2 + 2 */ +uint16_t hci_read_local_version_information_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1 + 2 + 1 + 2 + 2; + /* Output params */ + hci_read_local_version_information_rp0 *rp0 = (hci_read_local_version_information_rp0 *) (buffer_out + 6); + uint8_t HCI_Version = 0; + uint16_t HCI_Revision = 0; + uint8_t LMP_PAL_Version = 0; + uint16_t Manufacturer_Name = 0; + uint16_t LMP_PAL_Subversion = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 2 + 1 + 2 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_read_local_version_information(&HCI_Version, + &HCI_Revision, + &LMP_PAL_Version, + &Manufacturer_Name, + &LMP_PAL_Subversion); +fail: + rp0->HCI_Version = HCI_Version; + rp0->HCI_Revision = HCI_Revision; + rp0->LMP_PAL_Version = LMP_PAL_Version; + rp0->Manufacturer_Name = Manufacturer_Name; + rp0->LMP_PAL_Subversion = LMP_PAL_Subversion; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x01; + buffer_out[5] = 0x10; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_LOCAL_SUPPORTED_COMMANDS_ENABLED) || HCI_READ_LOCAL_SUPPORTED_COMMANDS_ENABLED) && !HCI_READ_LOCAL_SUPPORTED_COMMANDS_FORCE_DISABLED +/* tBleStatus hci_read_local_supported_commands(uint8_t Supported_Commands[64]); + */ +/* Command len: 0 */ +/* Response len: 1 + 64 */ +uint16_t hci_read_local_supported_commands_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 64; + /* Output params */ + hci_read_local_supported_commands_rp0 *rp0 = (hci_read_local_supported_commands_rp0 *) (buffer_out + 6); + uint8_t Supported_Commands[64] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 64 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_read_local_supported_commands(Supported_Commands); +fail: + Osal_MemCpy((void *) rp0->Supported_Commands,(const void *) Supported_Commands, 64); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x02; + buffer_out[5] = 0x10; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_LOCAL_SUPPORTED_FEATURES_ENABLED) || HCI_READ_LOCAL_SUPPORTED_FEATURES_ENABLED) && !HCI_READ_LOCAL_SUPPORTED_FEATURES_FORCE_DISABLED +/* tBleStatus hci_read_local_supported_features(uint8_t LMP_Features[8]); + */ +/* Command len: 0 */ +/* Response len: 1 + 8 */ +uint16_t hci_read_local_supported_features_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 8; + /* Output params */ + hci_read_local_supported_features_rp0 *rp0 = (hci_read_local_supported_features_rp0 *) (buffer_out + 6); + uint8_t LMP_Features[8] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 8 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_read_local_supported_features(LMP_Features); +fail: + Osal_MemCpy((void *) rp0->LMP_Features,(const void *) LMP_Features, 8); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x03; + buffer_out[5] = 0x10; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_BD_ADDR_ENABLED) || HCI_READ_BD_ADDR_ENABLED) && !HCI_READ_BD_ADDR_FORCE_DISABLED +/* tBleStatus hci_read_bd_addr(uint8_t BD_ADDR[6]); + */ +/* Command len: 0 */ +/* Response len: 1 + 6 */ +uint16_t hci_read_bd_addr_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 6; + /* Output params */ + hci_read_bd_addr_rp0 *rp0 = (hci_read_bd_addr_rp0 *) (buffer_out + 6); + uint8_t BD_ADDR[6] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_read_bd_addr(BD_ADDR); +fail: + Osal_MemCpy((void *) rp0->BD_ADDR,(const void *) BD_ADDR, 6); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x09; + buffer_out[5] = 0x10; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_READ_RSSI_ENABLED) || HCI_READ_RSSI_ENABLED) && !HCI_READ_RSSI_FORCE_DISABLED +/* tBleStatus hci_read_rssi(uint16_t Connection_Handle, + int8_t *RSSI); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 + 1 */ +uint16_t hci_read_rssi_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_read_rssi_cp0 *cp0 = (hci_read_rssi_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 1; + /* Output params */ + hci_read_rssi_rp0 *rp0 = (hci_read_rssi_rp0 *) (buffer_out + 6); + int8_t RSSI = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_read_rssi(cp0->Connection_Handle /* 2 */, + &RSSI); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->RSSI = RSSI; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x05; + buffer_out[5] = 0x14; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_EVENT_MASK_ENABLED) || HCI_LE_SET_EVENT_MASK_ENABLED) && !HCI_LE_SET_EVENT_MASK_FORCE_DISABLED +/* tBleStatus hci_le_set_event_mask(uint8_t LE_Event_Mask[8]); + */ +/* Command len: 8 */ +/* Response len: 1 */ +uint16_t hci_le_set_event_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_event_mask_cp0 *cp0 = (hci_le_set_event_mask_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 8) + { + goto fail; + } + + *status = hci_le_set_event_mask(cp0->LE_Event_Mask /* 8 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x01; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_BUFFER_SIZE_ENABLED) || HCI_LE_READ_BUFFER_SIZE_ENABLED) && !HCI_LE_READ_BUFFER_SIZE_FORCE_DISABLED +/* tBleStatus hci_le_read_buffer_size(uint16_t *HC_LE_ACL_Data_Packet_Length, + uint8_t *HC_Total_Num_LE_ACL_Data_Packets); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 + 1 */ +uint16_t hci_le_read_buffer_size_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2 + 1; + /* Output params */ + hci_le_read_buffer_size_rp0 *rp0 = (hci_le_read_buffer_size_rp0 *) (buffer_out + 6); + uint16_t HC_LE_ACL_Data_Packet_Length = 0; + uint8_t HC_Total_Num_LE_ACL_Data_Packets = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_buffer_size(&HC_LE_ACL_Data_Packet_Length, + &HC_Total_Num_LE_ACL_Data_Packets); +fail: + rp0->HC_LE_ACL_Data_Packet_Length = HC_LE_ACL_Data_Packet_Length; + rp0->HC_Total_Num_LE_ACL_Data_Packets = HC_Total_Num_LE_ACL_Data_Packets; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x02; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_ENABLED) || HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_ENABLED) && !HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_FORCE_DISABLED +/* tBleStatus hci_le_read_local_supported_features(uint8_t LE_Features[8]); + */ +/* Command len: 0 */ +/* Response len: 1 + 8 */ +uint16_t hci_le_read_local_supported_features_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 8; + /* Output params */ + hci_le_read_local_supported_features_rp0 *rp0 = (hci_le_read_local_supported_features_rp0 *) (buffer_out + 6); + uint8_t LE_Features[8] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 8 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_local_supported_features(LE_Features); +fail: + Osal_MemCpy((void *) rp0->LE_Features,(const void *) LE_Features, 8); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x03; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_RANDOM_ADDRESS_ENABLED) || HCI_LE_SET_RANDOM_ADDRESS_ENABLED) && !HCI_LE_SET_RANDOM_ADDRESS_FORCE_DISABLED +/* tBleStatus hci_le_set_random_address(uint8_t Random_Address[6]); + */ +/* Command len: 6 */ +/* Response len: 1 */ +uint16_t hci_le_set_random_address_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_random_address_cp0 *cp0 = (hci_le_set_random_address_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 6) + { + goto fail; + } + + *status = hci_le_set_random_address(cp0->Random_Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x05; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_ADVERTISING_PARAMETERS_ENABLED) || HCI_LE_SET_ADVERTISING_PARAMETERS_ENABLED) && !HCI_LE_SET_ADVERTISING_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_advertising_parameters(uint16_t Advertising_Interval_Min, + uint16_t Advertising_Interval_Max, + uint8_t Advertising_Type, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Channel_Map, + uint8_t Advertising_Filter_Policy); + */ +/* Command len: 2 + 2 + 1 + 1 + 1 + 6 + 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_advertising_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_advertising_parameters_cp0 *cp0 = (hci_le_set_advertising_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1 + 1 + 1 + 6 + 1 + 1) + { + goto fail; + } + + *status = hci_le_set_advertising_parameters(cp0->Advertising_Interval_Min /* 2 */, + cp0->Advertising_Interval_Max /* 2 */, + cp0->Advertising_Type /* 1 */, + cp0->Own_Address_Type /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */, + cp0->Advertising_Channel_Map /* 1 */, + cp0->Advertising_Filter_Policy /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x06; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER_ENABLED) || HCI_LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER_ENABLED) && !HCI_LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER_FORCE_DISABLED +/* tBleStatus hci_le_read_advertising_physical_channel_tx_power(int8_t *Transmit_Power_Level); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_read_advertising_physical_channel_tx_power_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1; + /* Output params */ + hci_le_read_advertising_physical_channel_tx_power_rp0 *rp0 = (hci_le_read_advertising_physical_channel_tx_power_rp0 *) (buffer_out + 6); + int8_t Transmit_Power_Level = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_advertising_physical_channel_tx_power(&Transmit_Power_Level); +fail: + rp0->Transmit_Power_Level = Transmit_Power_Level; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x07; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_ADVERTISING_DATA_ENABLED) || HCI_LE_SET_ADVERTISING_DATA_ENABLED) && !HCI_LE_SET_ADVERTISING_DATA_FORCE_DISABLED +/* tBleStatus hci_le_set_advertising_data(uint8_t Advertising_Data_Length, + uint8_t Advertising_Data[31]); + */ +/* Command len: 1 + 31 */ +/* Response len: 1 */ +uint16_t hci_le_set_advertising_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_advertising_data_cp0 *cp0 = (hci_le_set_advertising_data_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 31) + { + goto fail; + } + + *status = hci_le_set_advertising_data(cp0->Advertising_Data_Length /* 1 */, + cp0->Advertising_Data /* 31 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x08; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_SCAN_RESPONSE_DATA_ENABLED) || HCI_LE_SET_SCAN_RESPONSE_DATA_ENABLED) && !HCI_LE_SET_SCAN_RESPONSE_DATA_FORCE_DISABLED +/* tBleStatus hci_le_set_scan_response_data(uint8_t Scan_Response_Data_Length, + uint8_t Scan_Response_Data[31]); + */ +/* Command len: 1 + 31 */ +/* Response len: 1 */ +uint16_t hci_le_set_scan_response_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_scan_response_data_cp0 *cp0 = (hci_le_set_scan_response_data_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 31) + { + goto fail; + } + + *status = hci_le_set_scan_response_data(cp0->Scan_Response_Data_Length /* 1 */, + cp0->Scan_Response_Data /* 31 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x09; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_ADVERTISING_ENABLE_ENABLED) || HCI_LE_SET_ADVERTISING_ENABLE_ENABLED) && !HCI_LE_SET_ADVERTISING_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_advertising_enable(uint8_t Advertising_Enable); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_advertising_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_advertising_enable_cp0 *cp0 = (hci_le_set_advertising_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = hci_le_set_advertising_enable(cp0->Advertising_Enable /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0a; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_SCAN_PARAMETERS_ENABLED) || HCI_LE_SET_SCAN_PARAMETERS_ENABLED) && !HCI_LE_SET_SCAN_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_scan_parameters(uint8_t LE_Scan_Type, + uint16_t LE_Scan_Interval, + uint16_t LE_Scan_Window, + uint8_t Own_Address_Type, + uint8_t Scanning_Filter_Policy); + */ +/* Command len: 1 + 2 + 2 + 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_scan_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_scan_parameters_cp0 *cp0 = (hci_le_set_scan_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 2 + 2 + 1 + 1) + { + goto fail; + } + + *status = hci_le_set_scan_parameters(cp0->LE_Scan_Type /* 1 */, + cp0->LE_Scan_Interval /* 2 */, + cp0->LE_Scan_Window /* 2 */, + cp0->Own_Address_Type /* 1 */, + cp0->Scanning_Filter_Policy /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0b; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_SCAN_ENABLE_ENABLED) || HCI_LE_SET_SCAN_ENABLE_ENABLED) && !HCI_LE_SET_SCAN_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_scan_enable(uint8_t LE_Scan_Enable, + uint8_t Filter_Duplicates); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_scan_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_scan_enable_cp0 *cp0 = (hci_le_set_scan_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = hci_le_set_scan_enable(cp0->LE_Scan_Enable /* 1 */, + cp0->Filter_Duplicates /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0c; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CREATE_CONNECTION_ENABLED) || HCI_LE_CREATE_CONNECTION_ENABLED) && !HCI_LE_CREATE_CONNECTION_FORCE_DISABLED +/* tBleStatus hci_le_create_connection(uint16_t LE_Scan_Interval, + uint16_t LE_Scan_Window, + uint8_t Initiator_Filter_Policy, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Own_Address_Type, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + */ +/* Command len: 2 + 2 + 1 + 1 + 6 + 1 + 2 + 2 + 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_create_connection_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_create_connection_cp0 *cp0 = (hci_le_create_connection_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1 + 1 + 6 + 1 + 2 + 2 + 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = hci_le_create_connection(cp0->LE_Scan_Interval /* 2 */, + cp0->LE_Scan_Window /* 2 */, + cp0->Initiator_Filter_Policy /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */, + cp0->Own_Address_Type /* 1 */, + cp0->Connection_Interval_Min /* 2 */, + cp0->Connection_Interval_Max /* 2 */, + cp0->Max_Latency /* 2 */, + cp0->Supervision_Timeout /* 2 */, + cp0->Min_CE_Length /* 2 */, + cp0->Max_CE_Length /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x0d; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CREATE_CONNECTION_CANCEL_ENABLED) || HCI_LE_CREATE_CONNECTION_CANCEL_ENABLED) && !HCI_LE_CREATE_CONNECTION_CANCEL_FORCE_DISABLED +/* tBleStatus hci_le_create_connection_cancel(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t hci_le_create_connection_cancel_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = hci_le_create_connection_cancel(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0e; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_FILTER_ACCEPT_LIST_SIZE_ENABLED) || HCI_LE_READ_FILTER_ACCEPT_LIST_SIZE_ENABLED) && !HCI_LE_READ_FILTER_ACCEPT_LIST_SIZE_FORCE_DISABLED +/* tBleStatus hci_le_read_filter_accept_list_size(uint8_t *Filter_Accept_List_Size); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_read_filter_accept_list_size_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1; + /* Output params */ + hci_le_read_filter_accept_list_size_rp0 *rp0 = (hci_le_read_filter_accept_list_size_rp0 *) (buffer_out + 6); + uint8_t Filter_Accept_List_Size = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_filter_accept_list_size(&Filter_Accept_List_Size); +fail: + rp0->Filter_Accept_List_Size = Filter_Accept_List_Size; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0f; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CLEAR_FILTER_ACCEPT_LIST_ENABLED) || HCI_LE_CLEAR_FILTER_ACCEPT_LIST_ENABLED) && !HCI_LE_CLEAR_FILTER_ACCEPT_LIST_FORCE_DISABLED +/* tBleStatus hci_le_clear_filter_accept_list(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t hci_le_clear_filter_accept_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = hci_le_clear_filter_accept_list(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x10; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST_ENABLED) || HCI_LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST_ENABLED) && !HCI_LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST_FORCE_DISABLED +/* tBleStatus hci_le_add_device_to_filter_accept_list(uint8_t Address_Type, + uint8_t Address[6]); + */ +/* Command len: 1 + 6 */ +/* Response len: 1 */ +uint16_t hci_le_add_device_to_filter_accept_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_add_device_to_filter_accept_list_cp0 *cp0 = (hci_le_add_device_to_filter_accept_list_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6) + { + goto fail; + } + + *status = hci_le_add_device_to_filter_accept_list(cp0->Address_Type /* 1 */, + cp0->Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x11; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST_ENABLED) || HCI_LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST_ENABLED) && !HCI_LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST_FORCE_DISABLED +/* tBleStatus hci_le_remove_device_from_filter_accept_list(uint8_t Address_Type, + uint8_t Address[6]); + */ +/* Command len: 1 + 6 */ +/* Response len: 1 */ +uint16_t hci_le_remove_device_from_filter_accept_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_remove_device_from_filter_accept_list_cp0 *cp0 = (hci_le_remove_device_from_filter_accept_list_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6) + { + goto fail; + } + + *status = hci_le_remove_device_from_filter_accept_list(cp0->Address_Type /* 1 */, + cp0->Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x12; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CONNECTION_UPDATE_ENABLED) || HCI_LE_CONNECTION_UPDATE_ENABLED) && !HCI_LE_CONNECTION_UPDATE_FORCE_DISABLED +/* tBleStatus hci_le_connection_update(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_connection_update_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_connection_update_cp0 *cp0 = (hci_le_connection_update_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = hci_le_connection_update(cp0->Connection_Handle /* 2 */, + cp0->Connection_Interval_Min /* 2 */, + cp0->Connection_Interval_Max /* 2 */, + cp0->Max_Latency /* 2 */, + cp0->Supervision_Timeout /* 2 */, + cp0->Min_CE_Length /* 2 */, + cp0->Max_CE_Length /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x13; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION_ENABLED) || HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION_ENABLED) && !HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION_FORCE_DISABLED +/* tBleStatus hci_le_set_host_channel_classification(uint8_t LE_Channel_Map[5]); + */ +/* Command len: 5 */ +/* Response len: 1 */ +uint16_t hci_le_set_host_channel_classification_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_host_channel_classification_cp0 *cp0 = (hci_le_set_host_channel_classification_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 5) + { + goto fail; + } + + *status = hci_le_set_host_channel_classification(cp0->LE_Channel_Map /* 5 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x14; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_CHANNEL_MAP_ENABLED) || HCI_LE_READ_CHANNEL_MAP_ENABLED) && !HCI_LE_READ_CHANNEL_MAP_FORCE_DISABLED +/* tBleStatus hci_le_read_channel_map(uint16_t Connection_Handle, + uint8_t LE_Channel_Map[5]); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 + 5 */ +uint16_t hci_le_read_channel_map_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_read_channel_map_cp0 *cp0 = (hci_le_read_channel_map_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 5; + /* Output params */ + hci_le_read_channel_map_rp0 *rp0 = (hci_le_read_channel_map_rp0 *) (buffer_out + 6); + uint8_t LE_Channel_Map[5] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 5 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_le_read_channel_map(cp0->Connection_Handle /* 2 */, + LE_Channel_Map); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + Osal_MemCpy((void *) rp0->LE_Channel_Map,(const void *) LE_Channel_Map, 5); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x15; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_REMOTE_FEATURES_ENABLED) || HCI_LE_READ_REMOTE_FEATURES_ENABLED) && !HCI_LE_READ_REMOTE_FEATURES_FORCE_DISABLED +/* tBleStatus hci_le_read_remote_features(uint16_t Connection_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t hci_le_read_remote_features_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_read_remote_features_cp0 *cp0 = (hci_le_read_remote_features_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = hci_le_read_remote_features(cp0->Connection_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x16; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ENCRYPT_ENABLED) || HCI_LE_ENCRYPT_ENABLED) && !HCI_LE_ENCRYPT_FORCE_DISABLED +/* tBleStatus hci_le_encrypt(uint8_t Key[16], + uint8_t Plaintext_Data[16], + uint8_t Encrypted_Data[16]); + */ +/* Command len: 16 + 16 */ +/* Response len: 1 + 16 */ +uint16_t hci_le_encrypt_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_encrypt_cp0 *cp0 = (hci_le_encrypt_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 16; + /* Output params */ + hci_le_encrypt_rp0 *rp0 = (hci_le_encrypt_rp0 *) (buffer_out + 6); + uint8_t Encrypted_Data[16] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 16 + 6)) { return 0; } + if(buffer_in_length != 16 + 16) + { + goto fail; + } + + rp0->Status = hci_le_encrypt(cp0->Key /* 16 */, + cp0->Plaintext_Data /* 16 */, + Encrypted_Data); +fail: + Osal_MemCpy((void *) rp0->Encrypted_Data,(const void *) Encrypted_Data, 16); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x17; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_RAND_ENABLED) || HCI_LE_RAND_ENABLED) && !HCI_LE_RAND_FORCE_DISABLED +/* tBleStatus hci_le_rand(uint8_t Random_Number[8]); + */ +/* Command len: 0 */ +/* Response len: 1 + 8 */ +uint16_t hci_le_rand_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 8; + /* Output params */ + hci_le_rand_rp0 *rp0 = (hci_le_rand_rp0 *) (buffer_out + 6); + uint8_t Random_Number[8] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 8 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_rand(Random_Number); +fail: + Osal_MemCpy((void *) rp0->Random_Number,(const void *) Random_Number, 8); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x18; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ENABLE_ENCRYPTION_ENABLED) || HCI_LE_ENABLE_ENCRYPTION_ENABLED) && !HCI_LE_ENABLE_ENCRYPTION_FORCE_DISABLED +/* tBleStatus hci_le_enable_encryption(uint16_t Connection_Handle, + uint8_t Random_Number[8], + uint16_t Encrypted_Diversifier, + uint8_t Long_Term_Key[16]); + */ +/* Command len: 2 + 8 + 2 + 16 */ +/* Response len: 1 */ +uint16_t hci_le_enable_encryption_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_enable_encryption_cp0 *cp0 = (hci_le_enable_encryption_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 8 + 2 + 16) + { + goto fail; + } + + *status = hci_le_enable_encryption(cp0->Connection_Handle /* 2 */, + cp0->Random_Number /* 8 */, + cp0->Encrypted_Diversifier /* 2 */, + cp0->Long_Term_Key /* 16 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x19; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_ENABLED) || HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_ENABLED) && !HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_FORCE_DISABLED +/* tBleStatus hci_le_long_term_key_request_reply(uint16_t Connection_Handle, + uint8_t Long_Term_Key[16]); + */ +/* Command len: 2 + 16 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_long_term_key_request_reply_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_long_term_key_request_reply_cp0 *cp0 = (hci_le_long_term_key_request_reply_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_long_term_key_request_reply_rp0 *rp0 = (hci_le_long_term_key_request_reply_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 16) + { + goto fail; + } + + rp0->Status = hci_le_long_term_key_request_reply(cp0->Connection_Handle /* 2 */, + cp0->Long_Term_Key /* 16 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x1a; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_ENABLED) || HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_ENABLED) && !HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_FORCE_DISABLED +/* tBleStatus hci_le_long_term_key_request_negative_reply(uint16_t Connection_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_long_term_key_request_negative_reply_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_long_term_key_request_negative_reply_cp0 *cp0 = (hci_le_long_term_key_request_negative_reply_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_long_term_key_request_negative_reply_rp0 *rp0 = (hci_le_long_term_key_request_negative_reply_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_le_long_term_key_request_negative_reply(cp0->Connection_Handle /* 2 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x1b; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_SUPPORTED_STATES_ENABLED) || HCI_LE_READ_SUPPORTED_STATES_ENABLED) && !HCI_LE_READ_SUPPORTED_STATES_FORCE_DISABLED +/* tBleStatus hci_le_read_supported_states(uint8_t LE_States[8]); + */ +/* Command len: 0 */ +/* Response len: 1 + 8 */ +uint16_t hci_le_read_supported_states_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 8; + /* Output params */ + hci_le_read_supported_states_rp0 *rp0 = (hci_le_read_supported_states_rp0 *) (buffer_out + 6); + uint8_t LE_States[8] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 8 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_supported_states(LE_States); +fail: + Osal_MemCpy((void *) rp0->LE_States,(const void *) LE_States, 8); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x1c; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_RECEIVER_TEST_ENABLED) || HCI_LE_RECEIVER_TEST_ENABLED) && !HCI_LE_RECEIVER_TEST_FORCE_DISABLED +/* tBleStatus hci_le_receiver_test(uint8_t RX_Frequency); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t hci_le_receiver_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_receiver_test_cp0 *cp0 = (hci_le_receiver_test_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = hci_le_receiver_test(cp0->RX_Frequency /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x1d; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_TRANSMITTER_TEST_ENABLED) || HCI_LE_TRANSMITTER_TEST_ENABLED) && !HCI_LE_TRANSMITTER_TEST_FORCE_DISABLED +/* tBleStatus hci_le_transmitter_test(uint8_t TX_Frequency, + uint8_t Length_Of_Test_Data, + uint8_t Packet_Payload); + */ +/* Command len: 1 + 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_transmitter_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_transmitter_test_cp0 *cp0 = (hci_le_transmitter_test_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1) + { + goto fail; + } + + *status = hci_le_transmitter_test(cp0->TX_Frequency /* 1 */, + cp0->Length_Of_Test_Data /* 1 */, + cp0->Packet_Payload /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x1e; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_TEST_END_ENABLED) || HCI_LE_TEST_END_ENABLED) && !HCI_LE_TEST_END_FORCE_DISABLED +/* tBleStatus hci_le_test_end(uint16_t *Number_Of_Packets); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_test_end_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2; + /* Output params */ + hci_le_test_end_rp0 *rp0 = (hci_le_test_end_rp0 *) (buffer_out + 6); + uint16_t Number_Of_Packets = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_test_end(&Number_Of_Packets); +fail: + rp0->Number_Of_Packets = Number_Of_Packets; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x1f; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_DATA_LENGTH_ENABLED) || HCI_LE_SET_DATA_LENGTH_ENABLED) && !HCI_LE_SET_DATA_LENGTH_FORCE_DISABLED +/* tBleStatus hci_le_set_data_length(uint16_t Connection_Handle, + uint16_t TxOctets, + uint16_t TxTime); + */ +/* Command len: 2 + 2 + 2 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_data_length_cp0 *cp0 = (hci_le_set_data_length_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_data_length_rp0 *rp0 = (hci_le_set_data_length_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2) + { + goto fail; + } + + rp0->Status = hci_le_set_data_length(cp0->Connection_Handle /* 2 */, + cp0->TxOctets /* 2 */, + cp0->TxTime /* 2 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x22; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED) || HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED) && !HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_FORCE_DISABLED +/* tBleStatus hci_le_read_suggested_default_data_length(uint16_t *SuggestedMaxTxOctets, + uint16_t *SuggestedMaxTxTime); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 + 2 */ +uint16_t hci_le_read_suggested_default_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2 + 2; + /* Output params */ + hci_le_read_suggested_default_data_length_rp0 *rp0 = (hci_le_read_suggested_default_data_length_rp0 *) (buffer_out + 6); + uint16_t SuggestedMaxTxOctets = 0; + uint16_t SuggestedMaxTxTime = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_suggested_default_data_length(&SuggestedMaxTxOctets, + &SuggestedMaxTxTime); +fail: + rp0->SuggestedMaxTxOctets = SuggestedMaxTxOctets; + rp0->SuggestedMaxTxTime = SuggestedMaxTxTime; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x23; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED) || HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED) && !HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_FORCE_DISABLED +/* tBleStatus hci_le_write_suggested_default_data_length(uint16_t SuggestedMaxTxOctets, + uint16_t SuggestedMaxTxTime); + */ +/* Command len: 2 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_write_suggested_default_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_write_suggested_default_data_length_cp0 *cp0 = (hci_le_write_suggested_default_data_length_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2) + { + goto fail; + } + + *status = hci_le_write_suggested_default_data_length(cp0->SuggestedMaxTxOctets /* 2 */, + cp0->SuggestedMaxTxTime /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x24; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_ENABLED) || HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_ENABLED) && !HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_FORCE_DISABLED +/* tBleStatus hci_le_read_local_p256_public_key(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t hci_le_read_local_p256_public_key_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = hci_le_read_local_p256_public_key(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x25; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_GENERATE_DHKEY_ENABLED) || HCI_LE_GENERATE_DHKEY_ENABLED) && !HCI_LE_GENERATE_DHKEY_FORCE_DISABLED +/* tBleStatus hci_le_generate_dhkey(uint8_t Remote_P256_Public_Key[64]); + */ +/* Command len: 64 */ +/* Response len: 1 */ +uint16_t hci_le_generate_dhkey_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_generate_dhkey_cp0 *cp0 = (hci_le_generate_dhkey_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 64) + { + goto fail; + } + + *status = hci_le_generate_dhkey(cp0->Remote_P256_Public_Key /* 64 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x26; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST_ENABLED) || HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST_ENABLED) && !HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST_FORCE_DISABLED +/* tBleStatus hci_le_add_device_to_resolving_list(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Peer_IRK[16], + uint8_t Local_IRK[16]); + */ +/* Command len: 1 + 6 + 16 + 16 */ +/* Response len: 1 */ +uint16_t hci_le_add_device_to_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_add_device_to_resolving_list_cp0 *cp0 = (hci_le_add_device_to_resolving_list_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6 + 16 + 16) + { + goto fail; + } + + *status = hci_le_add_device_to_resolving_list(cp0->Peer_Identity_Address_Type /* 1 */, + cp0->Peer_Identity_Address /* 6 */, + cp0->Peer_IRK /* 16 */, + cp0->Local_IRK /* 16 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x27; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_ENABLED) || HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_ENABLED) && !HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_FORCE_DISABLED +/* tBleStatus hci_le_remove_device_from_resolving_list(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6]); + */ +/* Command len: 1 + 6 */ +/* Response len: 1 */ +uint16_t hci_le_remove_device_from_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_remove_device_from_resolving_list_cp0 *cp0 = (hci_le_remove_device_from_resolving_list_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6) + { + goto fail; + } + + *status = hci_le_remove_device_from_resolving_list(cp0->Peer_Identity_Address_Type /* 1 */, + cp0->Peer_Identity_Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x28; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CLEAR_RESOLVING_LIST_ENABLED) || HCI_LE_CLEAR_RESOLVING_LIST_ENABLED) && !HCI_LE_CLEAR_RESOLVING_LIST_FORCE_DISABLED +/* tBleStatus hci_le_clear_resolving_list(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t hci_le_clear_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = hci_le_clear_resolving_list(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x29; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_RESOLVING_LIST_SIZE_ENABLED) || HCI_LE_READ_RESOLVING_LIST_SIZE_ENABLED) && !HCI_LE_READ_RESOLVING_LIST_SIZE_FORCE_DISABLED +/* tBleStatus hci_le_read_resolving_list_size(uint8_t *Resolving_List_Size); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_read_resolving_list_size_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1; + /* Output params */ + hci_le_read_resolving_list_size_rp0 *rp0 = (hci_le_read_resolving_list_size_rp0 *) (buffer_out + 6); + uint8_t Resolving_List_Size = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_resolving_list_size(&Resolving_List_Size); +fail: + rp0->Resolving_List_Size = Resolving_List_Size; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2a; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_PEER_RESOLVABLE_ADDRESS_ENABLED) || HCI_LE_READ_PEER_RESOLVABLE_ADDRESS_ENABLED) && !HCI_LE_READ_PEER_RESOLVABLE_ADDRESS_FORCE_DISABLED +/* tBleStatus hci_le_read_peer_resolvable_address(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Peer_Resolvable_Address[6]); + */ +/* Command len: 1 + 6 */ +/* Response len: 1 + 6 */ +uint16_t hci_le_read_peer_resolvable_address_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_read_peer_resolvable_address_cp0 *cp0 = (hci_le_read_peer_resolvable_address_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 6; + /* Output params */ + hci_le_read_peer_resolvable_address_rp0 *rp0 = (hci_le_read_peer_resolvable_address_rp0 *) (buffer_out + 6); + uint8_t Peer_Resolvable_Address[6] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6 + 6)) { return 0; } + if(buffer_in_length != 1 + 6) + { + goto fail; + } + + rp0->Status = hci_le_read_peer_resolvable_address(cp0->Peer_Identity_Address_Type /* 1 */, + cp0->Peer_Identity_Address /* 6 */, + Peer_Resolvable_Address); +fail: + Osal_MemCpy((void *) rp0->Peer_Resolvable_Address,(const void *) Peer_Resolvable_Address, 6); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2b; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS_ENABLED) || HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS_ENABLED) && !HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS_FORCE_DISABLED +/* tBleStatus hci_le_read_local_resolvable_address(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Local_Resolvable_Address[6]); + */ +/* Command len: 1 + 6 */ +/* Response len: 1 + 6 */ +uint16_t hci_le_read_local_resolvable_address_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_read_local_resolvable_address_cp0 *cp0 = (hci_le_read_local_resolvable_address_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 6; + /* Output params */ + hci_le_read_local_resolvable_address_rp0 *rp0 = (hci_le_read_local_resolvable_address_rp0 *) (buffer_out + 6); + uint8_t Local_Resolvable_Address[6] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6 + 6)) { return 0; } + if(buffer_in_length != 1 + 6) + { + goto fail; + } + + rp0->Status = hci_le_read_local_resolvable_address(cp0->Peer_Identity_Address_Type /* 1 */, + cp0->Peer_Identity_Address /* 6 */, + Local_Resolvable_Address); +fail: + Osal_MemCpy((void *) rp0->Local_Resolvable_Address,(const void *) Local_Resolvable_Address, 6); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2c; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_ENABLED) || HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_ENABLED) && !HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_address_resolution_enable(uint8_t Address_Resolution_Enable); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_address_resolution_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_address_resolution_enable_cp0 *cp0 = (hci_le_set_address_resolution_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = hci_le_set_address_resolution_enable(cp0->Address_Resolution_Enable /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2d; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_ENABLED) || HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_ENABLED) && !HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_FORCE_DISABLED +/* tBleStatus hci_le_set_resolvable_private_address_timeout(uint16_t RPA_Timeout); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t hci_le_set_resolvable_private_address_timeout_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_resolvable_private_address_timeout_cp0 *cp0 = (hci_le_set_resolvable_private_address_timeout_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = hci_le_set_resolvable_private_address_timeout(cp0->RPA_Timeout /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2e; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_MAXIMUM_DATA_LENGTH_ENABLED) || HCI_LE_READ_MAXIMUM_DATA_LENGTH_ENABLED) && !HCI_LE_READ_MAXIMUM_DATA_LENGTH_FORCE_DISABLED +/* tBleStatus hci_le_read_maximum_data_length(uint16_t *supportedMaxTxOctets, + uint16_t *supportedMaxTxTime, + uint16_t *supportedMaxRxOctets, + uint16_t *supportedMaxRxTime); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 + 2 + 2 + 2 */ +uint16_t hci_le_read_maximum_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2 + 2 + 2 + 2; + /* Output params */ + hci_le_read_maximum_data_length_rp0 *rp0 = (hci_le_read_maximum_data_length_rp0 *) (buffer_out + 6); + uint16_t supportedMaxTxOctets = 0; + uint16_t supportedMaxTxTime = 0; + uint16_t supportedMaxRxOctets = 0; + uint16_t supportedMaxRxTime = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 2 + 2 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_maximum_data_length(&supportedMaxTxOctets, + &supportedMaxTxTime, + &supportedMaxRxOctets, + &supportedMaxRxTime); +fail: + rp0->supportedMaxTxOctets = supportedMaxTxOctets; + rp0->supportedMaxTxTime = supportedMaxTxTime; + rp0->supportedMaxRxOctets = supportedMaxRxOctets; + rp0->supportedMaxRxTime = supportedMaxRxTime; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2f; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_PHY_ENABLED) || HCI_LE_READ_PHY_ENABLED) && !HCI_LE_READ_PHY_FORCE_DISABLED +/* tBleStatus hci_le_read_phy(uint16_t Connection_Handle, + uint8_t *TX_PHY, + uint8_t *RX_PHY); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 + 1 + 1 */ +uint16_t hci_le_read_phy_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_read_phy_cp0 *cp0 = (hci_le_read_phy_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 1 + 1; + /* Output params */ + hci_le_read_phy_rp0 *rp0 = (hci_le_read_phy_rp0 *) (buffer_out + 6); + uint8_t TX_PHY = 0; + uint8_t RX_PHY = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 1 + 1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_le_read_phy(cp0->Connection_Handle /* 2 */, + &TX_PHY, + &RX_PHY); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->TX_PHY = TX_PHY; + rp0->RX_PHY = RX_PHY; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x30; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_DEFAULT_PHY_ENABLED) || HCI_LE_SET_DEFAULT_PHY_ENABLED) && !HCI_LE_SET_DEFAULT_PHY_FORCE_DISABLED +/* tBleStatus hci_le_set_default_phy(uint8_t ALL_PHYS, + uint8_t TX_PHYS, + uint8_t RX_PHYS); + */ +/* Command len: 1 + 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_default_phy_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_default_phy_cp0 *cp0 = (hci_le_set_default_phy_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1) + { + goto fail; + } + + *status = hci_le_set_default_phy(cp0->ALL_PHYS /* 1 */, + cp0->TX_PHYS /* 1 */, + cp0->RX_PHYS /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x31; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PHY_ENABLED) || HCI_LE_SET_PHY_ENABLED) && !HCI_LE_SET_PHY_FORCE_DISABLED +/* tBleStatus hci_le_set_phy(uint16_t Connection_Handle, + uint8_t ALL_PHYS, + uint8_t TX_PHYS, + uint8_t RX_PHYS, + uint16_t PHY_options); + */ +/* Command len: 2 + 1 + 1 + 1 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_set_phy_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_phy_cp0 *cp0 = (hci_le_set_phy_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 1 + 1 + 2) + { + goto fail; + } + + *status = hci_le_set_phy(cp0->Connection_Handle /* 2 */, + cp0->ALL_PHYS /* 1 */, + cp0->TX_PHYS /* 1 */, + cp0->RX_PHYS /* 1 */, + cp0->PHY_options /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x32; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_RECEIVER_TEST_V2_ENABLED) || HCI_LE_RECEIVER_TEST_V2_ENABLED) && !HCI_LE_RECEIVER_TEST_V2_FORCE_DISABLED +/* tBleStatus hci_le_receiver_test_v2(uint8_t RX_Channel, + uint8_t PHY, + uint8_t Modulation_index); + */ +/* Command len: 1 + 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_receiver_test_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_receiver_test_v2_cp0 *cp0 = (hci_le_receiver_test_v2_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1) + { + goto fail; + } + + *status = hci_le_receiver_test_v2(cp0->RX_Channel /* 1 */, + cp0->PHY /* 1 */, + cp0->Modulation_index /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x33; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_TRANSMITTER_TEST_V2_ENABLED) || HCI_LE_TRANSMITTER_TEST_V2_ENABLED) && !HCI_LE_TRANSMITTER_TEST_V2_FORCE_DISABLED +/* tBleStatus hci_le_transmitter_test_v2(uint8_t TX_Channel, + uint8_t Length_Of_Test_Data, + uint8_t Packet_Payload, + uint8_t PHY); + */ +/* Command len: 1 + 1 + 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_transmitter_test_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_transmitter_test_v2_cp0 *cp0 = (hci_le_transmitter_test_v2_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1) + { + goto fail; + } + + *status = hci_le_transmitter_test_v2(cp0->TX_Channel /* 1 */, + cp0->Length_Of_Test_Data /* 1 */, + cp0->Packet_Payload /* 1 */, + cp0->PHY /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x34; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_ENABLED) || HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_ENABLED) && !HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_FORCE_DISABLED +/* tBleStatus hci_le_set_advertising_set_random_address(uint8_t Advertising_Handle, + uint8_t Advertising_Random_Address[6]); + */ +/* Command len: 1 + 6 */ +/* Response len: 1 */ +uint16_t hci_le_set_advertising_set_random_address_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_advertising_set_random_address_cp0 *cp0 = (hci_le_set_advertising_set_random_address_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6) + { + goto fail; + } + + *status = hci_le_set_advertising_set_random_address(cp0->Advertising_Handle /* 1 */, + cp0->Advertising_Random_Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x35; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_ENABLED) || HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_ENABLED) && !HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_extended_advertising_parameters(uint8_t Advertising_Handle, + uint16_t Advertising_Event_Properties, + uint8_t Primary_Advertising_Interval_Min[3], + uint8_t Primary_Advertising_Interval_Max[3], + uint8_t Primary_Advertising_Channel_Map, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable, + int8_t *Selected_Tx_Power); + */ +/* Command len: 1 + 2 + 3 + 3 + 1 + 1 + 1 + 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_set_extended_advertising_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_extended_advertising_parameters_cp0 *cp0 = (hci_le_set_extended_advertising_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 1; + /* Output params */ + hci_le_set_extended_advertising_parameters_rp0 *rp0 = (hci_le_set_extended_advertising_parameters_rp0 *) (buffer_out + 6); + int8_t Selected_Tx_Power = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 1 + 2 + 3 + 3 + 1 + 1 + 1 + 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1) + { + goto fail; + } + + rp0->Status = hci_le_set_extended_advertising_parameters(cp0->Advertising_Handle /* 1 */, + cp0->Advertising_Event_Properties /* 2 */, + cp0->Primary_Advertising_Interval_Min /* 3 */, + cp0->Primary_Advertising_Interval_Max /* 3 */, + cp0->Primary_Advertising_Channel_Map /* 1 */, + cp0->Own_Address_Type /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */, + cp0->Advertising_Filter_Policy /* 1 */, + cp0->Advertising_Tx_Power /* 1 */, + cp0->Primary_Advertising_PHY /* 1 */, + cp0->Secondary_Advertising_Max_Skip /* 1 */, + cp0->Secondary_Advertising_PHY /* 1 */, + cp0->Advertising_SID /* 1 */, + cp0->Scan_Request_Notification_Enable /* 1 */, + &Selected_Tx_Power); +fail: + rp0->Selected_Tx_Power = Selected_Tx_Power; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x36; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_EXTENDED_ADVERTISING_DATA_ENABLED) || HCI_LE_SET_EXTENDED_ADVERTISING_DATA_ENABLED) && !HCI_LE_SET_EXTENDED_ADVERTISING_DATA_FORCE_DISABLED +/* tBleStatus hci_le_set_extended_advertising_data(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Fragment_Preference, + uint8_t Advertising_Data_Length, + uint8_t Advertising_Data[]); + */ +/* Command len: 1 + 1 + 1 + 1 + cp0->Advertising_Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t hci_le_set_extended_advertising_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_extended_advertising_data_cp0 *cp0 = (hci_le_set_extended_advertising_data_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + cp0->Advertising_Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = hci_le_set_extended_advertising_data(cp0->Advertising_Handle /* 1 */, + cp0->Operation /* 1 */, + cp0->Fragment_Preference /* 1 */, + cp0->Advertising_Data_Length /* 1 */, + cp0->Advertising_Data /* cp0->Advertising_Data_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x37; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_ENABLED) || HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_ENABLED) && !HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_FORCE_DISABLED +/* tBleStatus hci_le_set_extended_scan_response_data(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Fragment_Preference, + uint8_t Scan_Response_Data_Length, + uint8_t Scan_Response_Data[]); + */ +/* Command len: 1 + 1 + 1 + 1 + cp0->Scan_Response_Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t hci_le_set_extended_scan_response_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_extended_scan_response_data_cp0 *cp0 = (hci_le_set_extended_scan_response_data_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + cp0->Scan_Response_Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = hci_le_set_extended_scan_response_data(cp0->Advertising_Handle /* 1 */, + cp0->Operation /* 1 */, + cp0->Fragment_Preference /* 1 */, + cp0->Scan_Response_Data_Length /* 1 */, + cp0->Scan_Response_Data /* cp0->Scan_Response_Data_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x38; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE_ENABLED) || HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE_ENABLED) && !HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE_FORCE_DISABLED +tBleStatus hci_le_set_extended_advertising_enable_preprocess(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]); +/* tBleStatus hci_le_set_extended_advertising_enable(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]); + */ +/* Command len: 1 + 1 + struct_length */ +/* Response len: 1 */ +uint16_t hci_le_set_extended_advertising_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_extended_advertising_enable_cp0 *cp0 = (hci_le_set_extended_advertising_enable_cp0 *)(buffer_in + (0)); + Advertising_Set_Parameters_t Advertising_Set_Parameters[HCI_MAX_PAYLOAD_SIZE/sizeof(Advertising_Set_Parameters_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + int i; + int struct_length = 0; + if(cp0->Number_of_Sets > HCI_MAX_PAYLOAD_SIZE/sizeof(Advertising_Set_Parameters_t)) + { + cp0->Number_of_Sets = 0; + goto fail; + } + for (i = 0; i < cp0->Number_of_Sets; i++) { + packed_Advertising_Set_Parameters_t *Advertising_Set_Parameters_tmp = (packed_Advertising_Set_Parameters_t *)(((uint8_t *)cp0->Advertising_Set_Parameters) + struct_length); + Advertising_Set_Parameters[i].Advertising_Handle = Advertising_Set_Parameters_tmp->Advertising_Handle; + struct_length += 1; + Advertising_Set_Parameters[i].Duration = Advertising_Set_Parameters_tmp->Duration; + struct_length += 2; + Advertising_Set_Parameters[i].Max_Extended_Advertising_Events = Advertising_Set_Parameters_tmp->Max_Extended_Advertising_Events; + struct_length += 1; + } + if(buffer_in_length != 1 + 1 + struct_length) + { + goto fail; + } + + *status = hci_le_set_extended_advertising_enable_preprocess(cp0->Enable /* 1 */, + cp0->Number_of_Sets /* 1 */, + Advertising_Set_Parameters /* struct_length */); + if(*status) + goto fail; + + *status = hci_le_set_extended_advertising_enable(cp0->Enable /* 1 */, + cp0->Number_of_Sets /* 1 */, + Advertising_Set_Parameters /* struct_length */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x39; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_ENABLED) || HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_ENABLED) && !HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_FORCE_DISABLED +/* tBleStatus hci_le_read_maximum_advertising_data_length(uint16_t *Maximum_Advertising_Data_Length); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_read_maximum_advertising_data_length_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2; + /* Output params */ + hci_le_read_maximum_advertising_data_length_rp0 *rp0 = (hci_le_read_maximum_advertising_data_length_rp0 *) (buffer_out + 6); + uint16_t Maximum_Advertising_Data_Length = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_maximum_advertising_data_length(&Maximum_Advertising_Data_Length); +fail: + rp0->Maximum_Advertising_Data_Length = Maximum_Advertising_Data_Length; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x3a; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_ENABLED) || HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_ENABLED) && !HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_FORCE_DISABLED +/* tBleStatus hci_le_read_number_of_supported_advertising_sets(uint8_t *Num_Supported_Advertising_Sets); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_read_number_of_supported_advertising_sets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1; + /* Output params */ + hci_le_read_number_of_supported_advertising_sets_rp0 *rp0 = (hci_le_read_number_of_supported_advertising_sets_rp0 *) (buffer_out + 6); + uint8_t Num_Supported_Advertising_Sets = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_number_of_supported_advertising_sets(&Num_Supported_Advertising_Sets); +fail: + rp0->Num_Supported_Advertising_Sets = Num_Supported_Advertising_Sets; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x3b; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_REMOVE_ADVERTISING_SET_ENABLED) || HCI_LE_REMOVE_ADVERTISING_SET_ENABLED) && !HCI_LE_REMOVE_ADVERTISING_SET_FORCE_DISABLED +/* tBleStatus hci_le_remove_advertising_set(uint8_t Advertising_Handle); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t hci_le_remove_advertising_set_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_remove_advertising_set_cp0 *cp0 = (hci_le_remove_advertising_set_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = hci_le_remove_advertising_set(cp0->Advertising_Handle /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x3c; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CLEAR_ADVERTISING_SETS_ENABLED) || HCI_LE_CLEAR_ADVERTISING_SETS_ENABLED) && !HCI_LE_CLEAR_ADVERTISING_SETS_FORCE_DISABLED +/* tBleStatus hci_le_clear_advertising_sets(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t hci_le_clear_advertising_sets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = hci_le_clear_advertising_sets(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x3d; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_periodic_advertising_parameters(uint8_t Advertising_Handle, + uint16_t Periodic_Advertising_Interval_Min, + uint16_t Periodic_Advertising_Interval_Max, + uint16_t Periodic_Advertising_Properties); + */ +/* Command len: 1 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_set_periodic_advertising_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_advertising_parameters_cp0 *cp0 = (hci_le_set_periodic_advertising_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 2 + 2 + 2) + { + goto fail; + } + + *status = hci_le_set_periodic_advertising_parameters(cp0->Advertising_Handle /* 1 */, + cp0->Periodic_Advertising_Interval_Min /* 2 */, + cp0->Periodic_Advertising_Interval_Max /* 2 */, + cp0->Periodic_Advertising_Properties /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x3e; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_DATA_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_DATA_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_DATA_FORCE_DISABLED +/* tBleStatus hci_le_set_periodic_advertising_data(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Advertising_Data_Length, + uint8_t Advertising_Data[]); + */ +/* Command len: 1 + 1 + 1 + cp0->Advertising_Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t hci_le_set_periodic_advertising_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_advertising_data_cp0 *cp0 = (hci_le_set_periodic_advertising_data_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + cp0->Advertising_Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = hci_le_set_periodic_advertising_data(cp0->Advertising_Handle /* 1 */, + cp0->Operation /* 1 */, + cp0->Advertising_Data_Length /* 1 */, + cp0->Advertising_Data /* cp0->Advertising_Data_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x3f; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE_FORCE_DISABLED +tBleStatus hci_le_set_periodic_advertising_enable_preprocess(uint8_t Enable, + uint8_t Advertising_Handle); +/* tBleStatus hci_le_set_periodic_advertising_enable(uint8_t Enable, + uint8_t Advertising_Handle); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_periodic_advertising_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_advertising_enable_cp0 *cp0 = (hci_le_set_periodic_advertising_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = hci_le_set_periodic_advertising_enable_preprocess(cp0->Enable /* 1 */, + cp0->Advertising_Handle /* 1 */); + if(*status) + goto fail; + + *status = hci_le_set_periodic_advertising_enable(cp0->Enable /* 1 */, + cp0->Advertising_Handle /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x40; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_EXTENDED_SCAN_PARAMETERS_ENABLED) || HCI_LE_SET_EXTENDED_SCAN_PARAMETERS_ENABLED) && !HCI_LE_SET_EXTENDED_SCAN_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_extended_scan_parameters(uint8_t Own_Address_Type, + uint8_t Scanning_Filter_Policy, + uint8_t Scanning_PHYs, + Extended_Scan_Parameters_t Extended_Scan_Parameters[]); + */ +/* Command len: 1 + 1 + 1 + struct_length */ +/* Response len: 1 */ +uint16_t hci_le_set_extended_scan_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_extended_scan_parameters_cp0 *cp0 = (hci_le_set_extended_scan_parameters_cp0 *)(buffer_in + (0)); + Extended_Scan_Parameters_t Extended_Scan_Parameters[HCI_MAX_PAYLOAD_SIZE/sizeof(Extended_Scan_Parameters_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + int i; + int struct_length = 0; + int len = 0; + + for (i = 0; i < sizeof( cp0->Scanning_PHYs)*8; i++) { + if((cp0->Scanning_PHYs >> i) & 0x01){ + len++; + } + } + if(len > HCI_MAX_PAYLOAD_SIZE/sizeof(Extended_Scan_Parameters_t)) + { + len = 0; + goto fail; + } + for (i = 0; i < len; i++) { + packed_Extended_Scan_Parameters_t *Extended_Scan_Parameters_tmp = (packed_Extended_Scan_Parameters_t *)(((uint8_t *)cp0->Extended_Scan_Parameters) + struct_length); + Extended_Scan_Parameters[i].Scan_Type = Extended_Scan_Parameters_tmp->Scan_Type; + struct_length += 1; + Extended_Scan_Parameters[i].Scan_Interval = Extended_Scan_Parameters_tmp->Scan_Interval; + struct_length += 2; + Extended_Scan_Parameters[i].Scan_Window = Extended_Scan_Parameters_tmp->Scan_Window; + struct_length += 2; + } + if(buffer_in_length != 1 + 1 + 1 + struct_length) + { + goto fail; + } + + *status = hci_le_set_extended_scan_parameters(cp0->Own_Address_Type /* 1 */, + cp0->Scanning_Filter_Policy /* 1 */, + cp0->Scanning_PHYs /* 1 */, + Extended_Scan_Parameters /* struct_length */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x41; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_EXTENDED_SCAN_ENABLE_ENABLED) || HCI_LE_SET_EXTENDED_SCAN_ENABLE_ENABLED) && !HCI_LE_SET_EXTENDED_SCAN_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_extended_scan_enable(uint8_t Enable, + uint8_t Filter_Duplicates, + uint16_t Duration, + uint16_t Period); + */ +/* Command len: 1 + 1 + 2 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_set_extended_scan_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_extended_scan_enable_cp0 *cp0 = (hci_le_set_extended_scan_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 2 + 2) + { + goto fail; + } + + *status = hci_le_set_extended_scan_enable(cp0->Enable /* 1 */, + cp0->Filter_Duplicates /* 1 */, + cp0->Duration /* 2 */, + cp0->Period /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x42; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_EXTENDED_CREATE_CONNECTION_ENABLED) || HCI_LE_EXTENDED_CREATE_CONNECTION_ENABLED) && !HCI_LE_EXTENDED_CREATE_CONNECTION_FORCE_DISABLED +/* tBleStatus hci_le_extended_create_connection(uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Initiating_PHYs, + Extended_Create_Connection_Parameters_t Extended_Create_Connection_Parameters[]); + */ +/* Command len: 1 + 1 + 1 + 6 + 1 + struct_length */ +/* Response len: 1 */ +uint16_t hci_le_extended_create_connection_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_extended_create_connection_cp0 *cp0 = (hci_le_extended_create_connection_cp0 *)(buffer_in + (0)); + Extended_Create_Connection_Parameters_t Extended_Create_Connection_Parameters[HCI_MAX_PAYLOAD_SIZE/sizeof(Extended_Create_Connection_Parameters_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + int i; + int struct_length = 0; + int len = 0; + + for (i = 0; i < sizeof( cp0->Initiating_PHYs)*8; i++) { + if((cp0->Initiating_PHYs >> i) & 0x01){ + len++; + } + } + if(len > HCI_MAX_PAYLOAD_SIZE/sizeof(Extended_Create_Connection_Parameters_t)) + { + len = 0; + goto fail; + } + for (i = 0; i < len; i++) { + packed_Extended_Create_Connection_Parameters_t *Extended_Create_Connection_Parameters_tmp = (packed_Extended_Create_Connection_Parameters_t *)(((uint8_t *)cp0->Extended_Create_Connection_Parameters) + struct_length); + Extended_Create_Connection_Parameters[i].Scan_Interval = Extended_Create_Connection_Parameters_tmp->Scan_Interval; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Scan_Window = Extended_Create_Connection_Parameters_tmp->Scan_Window; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Connection_Interval_Min = Extended_Create_Connection_Parameters_tmp->Connection_Interval_Min; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Connection_Interval_Max = Extended_Create_Connection_Parameters_tmp->Connection_Interval_Max; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Max_Latency = Extended_Create_Connection_Parameters_tmp->Max_Latency; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Supervision_Timeout = Extended_Create_Connection_Parameters_tmp->Supervision_Timeout; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Min_CE_Length = Extended_Create_Connection_Parameters_tmp->Min_CE_Length; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Max_CE_Length = Extended_Create_Connection_Parameters_tmp->Max_CE_Length; + struct_length += 2; + } + if(buffer_in_length != 1 + 1 + 1 + 6 + 1 + struct_length) + { + goto fail; + } + + *status = hci_le_extended_create_connection(cp0->Initiator_Filter_Policy /* 1 */, + cp0->Own_Address_Type /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */, + cp0->Initiating_PHYs /* 1 */, + Extended_Create_Connection_Parameters /* struct_length */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x43; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_FORCE_DISABLED +/* tBleStatus hci_le_periodic_advertising_create_sync(uint8_t Options, + uint8_t Advertising_SID, + uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t Sync_CTE_Type); + */ +/* Command len: 1 + 1 + 1 + 6 + 2 + 2 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_periodic_advertising_create_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_periodic_advertising_create_sync_cp0 *cp0 = (hci_le_periodic_advertising_create_sync_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 6 + 2 + 2 + 1) + { + goto fail; + } + + *status = hci_le_periodic_advertising_create_sync(cp0->Options /* 1 */, + cp0->Advertising_SID /* 1 */, + cp0->Advertiser_Address_Type /* 1 */, + cp0->Advertiser_Address /* 6 */, + cp0->Skip /* 2 */, + cp0->Sync_Timeout /* 2 */, + cp0->Sync_CTE_Type /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x44; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_FORCE_DISABLED +/* tBleStatus hci_le_periodic_advertising_create_sync_cancel(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t hci_le_periodic_advertising_create_sync_cancel_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = hci_le_periodic_advertising_create_sync_cancel(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x45; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_FORCE_DISABLED +/* tBleStatus hci_le_periodic_advertising_terminate_sync(uint16_t Sync_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t hci_le_periodic_advertising_terminate_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_periodic_advertising_terminate_sync_cp0 *cp0 = (hci_le_periodic_advertising_terminate_sync_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = hci_le_periodic_advertising_terminate_sync(cp0->Sync_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x46; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_ENABLED) || HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_ENABLED) && !HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_FORCE_DISABLED +/* tBleStatus hci_le_add_device_to_periodic_advertiser_list(uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint8_t Advertising_SID); + */ +/* Command len: 1 + 6 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_add_device_to_periodic_advertiser_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_add_device_to_periodic_advertiser_list_cp0 *cp0 = (hci_le_add_device_to_periodic_advertiser_list_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6 + 1) + { + goto fail; + } + + *status = hci_le_add_device_to_periodic_advertiser_list(cp0->Advertiser_Address_Type /* 1 */, + cp0->Advertiser_Address /* 6 */, + cp0->Advertising_SID /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x47; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_ENABLED) || HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_ENABLED) && !HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_FORCE_DISABLED +/* tBleStatus hci_le_remove_device_from_periodic_advertiser_list(uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint8_t Advertising_SID); + */ +/* Command len: 1 + 6 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_remove_device_from_periodic_advertiser_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_remove_device_from_periodic_advertiser_list_cp0 *cp0 = (hci_le_remove_device_from_periodic_advertiser_list_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6 + 1) + { + goto fail; + } + + *status = hci_le_remove_device_from_periodic_advertiser_list(cp0->Advertiser_Address_Type /* 1 */, + cp0->Advertiser_Address /* 6 */, + cp0->Advertising_SID /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x48; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST_ENABLED) || HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST_ENABLED) && !HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST_FORCE_DISABLED +/* tBleStatus hci_le_clear_periodic_advertiser_list(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t hci_le_clear_periodic_advertiser_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = hci_le_clear_periodic_advertiser_list(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x49; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_ENABLED) || HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_ENABLED) && !HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_FORCE_DISABLED +/* tBleStatus hci_le_read_periodic_advertiser_list_size(uint8_t *Periodic_Advertiser_List_Size); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_read_periodic_advertiser_list_size_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1; + /* Output params */ + hci_le_read_periodic_advertiser_list_size_rp0 *rp0 = (hci_le_read_periodic_advertiser_list_size_rp0 *) (buffer_out + 6); + uint8_t Periodic_Advertiser_List_Size = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_periodic_advertiser_list_size(&Periodic_Advertiser_List_Size); +fail: + rp0->Periodic_Advertiser_List_Size = Periodic_Advertiser_List_Size; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x4a; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_TRANSMIT_POWER_ENABLED) || HCI_LE_READ_TRANSMIT_POWER_ENABLED) && !HCI_LE_READ_TRANSMIT_POWER_FORCE_DISABLED +/* tBleStatus hci_le_read_transmit_power(int8_t *Min_Tx_Power, + int8_t *Max_Tx_Power); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 + 1 */ +uint16_t hci_le_read_transmit_power_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1 + 1; + /* Output params */ + hci_le_read_transmit_power_rp0 *rp0 = (hci_le_read_transmit_power_rp0 *) (buffer_out + 6); + int8_t Min_Tx_Power = 0; + int8_t Max_Tx_Power = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_transmit_power(&Min_Tx_Power, + &Max_Tx_Power); +fail: + rp0->Min_Tx_Power = Min_Tx_Power; + rp0->Max_Tx_Power = Max_Tx_Power; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x4b; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_RF_PATH_COMPENSATION_ENABLED) || HCI_LE_READ_RF_PATH_COMPENSATION_ENABLED) && !HCI_LE_READ_RF_PATH_COMPENSATION_FORCE_DISABLED +/* tBleStatus hci_le_read_rf_path_compensation(int16_t *RF_TX_Path_Compensation_Value, + int16_t *RF_RX_Path_Compensation_Value); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 + 2 */ +uint16_t hci_le_read_rf_path_compensation_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2 + 2; + /* Output params */ + hci_le_read_rf_path_compensation_rp0 *rp0 = (hci_le_read_rf_path_compensation_rp0 *) (buffer_out + 6); + int16_t RF_TX_Path_Compensation_Value = 0; + int16_t RF_RX_Path_Compensation_Value = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_rf_path_compensation(&RF_TX_Path_Compensation_Value, + &RF_RX_Path_Compensation_Value); +fail: + rp0->RF_TX_Path_Compensation_Value = RF_TX_Path_Compensation_Value; + rp0->RF_RX_Path_Compensation_Value = RF_RX_Path_Compensation_Value; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x4c; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_WRITE_RF_PATH_COMPENSATION_ENABLED) || HCI_LE_WRITE_RF_PATH_COMPENSATION_ENABLED) && !HCI_LE_WRITE_RF_PATH_COMPENSATION_FORCE_DISABLED +/* tBleStatus hci_le_write_rf_path_compensation(int16_t RF_TX_Path_Compensation_Value, + int16_t RF_RX_Path_Compensation_Value); + */ +/* Command len: 2 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_write_rf_path_compensation_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_write_rf_path_compensation_cp0 *cp0 = (hci_le_write_rf_path_compensation_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2) + { + goto fail; + } + + *status = hci_le_write_rf_path_compensation(cp0->RF_TX_Path_Compensation_Value /* 2 */, + cp0->RF_RX_Path_Compensation_Value /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x4d; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PRIVACY_MODE_ENABLED) || HCI_LE_SET_PRIVACY_MODE_ENABLED) && !HCI_LE_SET_PRIVACY_MODE_FORCE_DISABLED +/* tBleStatus hci_le_set_privacy_mode(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Privacy_Mode); + */ +/* Command len: 1 + 6 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_privacy_mode_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_privacy_mode_cp0 *cp0 = (hci_le_set_privacy_mode_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6 + 1) + { + goto fail; + } + + *status = hci_le_set_privacy_mode(cp0->Peer_Identity_Address_Type /* 1 */, + cp0->Peer_Identity_Address /* 6 */, + cp0->Privacy_Mode /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x4e; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_RECEIVER_TEST_V3_ENABLED) || HCI_LE_RECEIVER_TEST_V3_ENABLED) && !HCI_LE_RECEIVER_TEST_V3_FORCE_DISABLED +/* tBleStatus hci_le_receiver_test_v3(uint8_t RX_Channel, + uint8_t PHY, + uint8_t Modulation_Index, + uint8_t Expected_CTE_Length, + uint8_t Expected_CTE_Type, + uint8_t Slot_Durations, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); + */ +/* Command len: 1 + 1 + 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t hci_le_receiver_test_v3_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_receiver_test_v3_cp0 *cp0 = (hci_le_receiver_test_v3_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = hci_le_receiver_test_v3(cp0->RX_Channel /* 1 */, + cp0->PHY /* 1 */, + cp0->Modulation_Index /* 1 */, + cp0->Expected_CTE_Length /* 1 */, + cp0->Expected_CTE_Type /* 1 */, + cp0->Slot_Durations /* 1 */, + cp0->Switching_Pattern_Length /* 1 */, + cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x4f; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_TRANSMITTER_TEST_V3_ENABLED) || HCI_LE_TRANSMITTER_TEST_V3_ENABLED) && !HCI_LE_TRANSMITTER_TEST_V3_FORCE_DISABLED +/* tBleStatus hci_le_transmitter_test_v3(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); + */ +/* Command len: 1 + 1 + 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t hci_le_transmitter_test_v3_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_transmitter_test_v3_cp0 *cp0 = (hci_le_transmitter_test_v3_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = hci_le_transmitter_test_v3(cp0->TX_Channel /* 1 */, + cp0->Test_Data_Length /* 1 */, + cp0->Packet_Payload /* 1 */, + cp0->PHY /* 1 */, + cp0->CTE_Length /* 1 */, + cp0->CTE_Type /* 1 */, + cp0->Switching_Pattern_Length /* 1 */, + cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x50; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS_ENABLED) || HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS_ENABLED) && !HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_connectionless_cte_transmit_parameters(uint8_t Advertising_Handle, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t CTE_Count, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); + */ +/* Command len: 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t hci_le_set_connectionless_cte_transmit_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_connectionless_cte_transmit_parameters_cp0 *cp0 = (hci_le_set_connectionless_cte_transmit_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = hci_le_set_connectionless_cte_transmit_parameters(cp0->Advertising_Handle /* 1 */, + cp0->CTE_Length /* 1 */, + cp0->CTE_Type /* 1 */, + cp0->CTE_Count /* 1 */, + cp0->Switching_Pattern_Length /* 1 */, + cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x51; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE_ENABLED) || HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE_ENABLED) && !HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_connectionless_cte_transmit_enable(uint8_t Advertising_Handle, + uint8_t CTE_Enable); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_connectionless_cte_transmit_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_connectionless_cte_transmit_enable_cp0 *cp0 = (hci_le_set_connectionless_cte_transmit_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = hci_le_set_connectionless_cte_transmit_enable(cp0->Advertising_Handle /* 1 */, + cp0->CTE_Enable /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x52; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE_ENABLED) || HCI_LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE_ENABLED) && !HCI_LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_connectionless_iq_sampling_enable(uint16_t Sync_Handle, + uint8_t Sampling_Enable, + uint8_t Slot_Durations, + uint8_t Max_Sampled_CTEs, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); + */ +/* Command len: 2 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_connectionless_iq_sampling_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_connectionless_iq_sampling_enable_cp0 *cp0 = (hci_le_set_connectionless_iq_sampling_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_connectionless_iq_sampling_enable_rp0 *rp0 = (hci_le_set_connectionless_iq_sampling_enable_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t))) + { + goto fail; + } + + rp0->Status = hci_le_set_connectionless_iq_sampling_enable(cp0->Sync_Handle /* 2 */, + cp0->Sampling_Enable /* 1 */, + cp0->Slot_Durations /* 1 */, + cp0->Max_Sampled_CTEs /* 1 */, + cp0->Switching_Pattern_Length /* 1 */, + cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */); +fail: + rp0->Sync_Handle = cp0->Sync_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x53; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS_ENABLED) || HCI_LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS_ENABLED) && !HCI_LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_connection_cte_receive_parameters(uint16_t Connection_Handle, + uint8_t Sampling_Enable, + uint8_t Slot_Durations, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); + */ +/* Command len: 2 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_connection_cte_receive_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_connection_cte_receive_parameters_cp0 *cp0 = (hci_le_set_connection_cte_receive_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_connection_cte_receive_parameters_rp0 *rp0 = (hci_le_set_connection_cte_receive_parameters_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t))) + { + goto fail; + } + + rp0->Status = hci_le_set_connection_cte_receive_parameters(cp0->Connection_Handle /* 2 */, + cp0->Sampling_Enable /* 1 */, + cp0->Slot_Durations /* 1 */, + cp0->Switching_Pattern_Length /* 1 */, + cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x54; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS_ENABLED) || HCI_LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS_ENABLED) && !HCI_LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_connection_cte_transmit_parameters(uint16_t Connection_Handle, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); + */ +/* Command len: 2 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_connection_cte_transmit_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_connection_cte_transmit_parameters_cp0 *cp0 = (hci_le_set_connection_cte_transmit_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_connection_cte_transmit_parameters_rp0 *rp0 = (hci_le_set_connection_cte_transmit_parameters_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t))) + { + goto fail; + } + + rp0->Status = hci_le_set_connection_cte_transmit_parameters(cp0->Connection_Handle /* 2 */, + cp0->CTE_Type /* 1 */, + cp0->Switching_Pattern_Length /* 1 */, + cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x55; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CONNECTION_CTE_REQUEST_ENABLE_ENABLED) || HCI_LE_CONNECTION_CTE_REQUEST_ENABLE_ENABLED) && !HCI_LE_CONNECTION_CTE_REQUEST_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_connection_cte_request_enable(uint16_t Connection_Handle, + uint8_t Enable, + uint16_t CTE_Request_Interval, + uint8_t Requested_CTE_Length, + uint8_t Requested_CTE_Type); + */ +/* Command len: 2 + 1 + 2 + 1 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_connection_cte_request_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_connection_cte_request_enable_cp0 *cp0 = (hci_le_connection_cte_request_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_connection_cte_request_enable_rp0 *rp0 = (hci_le_connection_cte_request_enable_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 2 + 1 + 1) + { + goto fail; + } + + rp0->Status = hci_le_connection_cte_request_enable(cp0->Connection_Handle /* 2 */, + cp0->Enable /* 1 */, + cp0->CTE_Request_Interval /* 2 */, + cp0->Requested_CTE_Length /* 1 */, + cp0->Requested_CTE_Type /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x56; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CONNECTION_CTE_RESPONSE_ENABLE_ENABLED) || HCI_LE_CONNECTION_CTE_RESPONSE_ENABLE_ENABLED) && !HCI_LE_CONNECTION_CTE_RESPONSE_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_connection_cte_response_enable(uint16_t Connection_Handle, + uint8_t Enable); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_connection_cte_response_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_connection_cte_response_enable_cp0 *cp0 = (hci_le_connection_cte_response_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_connection_cte_response_enable_rp0 *rp0 = (hci_le_connection_cte_response_enable_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_connection_cte_response_enable(cp0->Connection_Handle /* 2 */, + cp0->Enable /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x57; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_ANTENNA_INFORMATION_ENABLED) || HCI_LE_READ_ANTENNA_INFORMATION_ENABLED) && !HCI_LE_READ_ANTENNA_INFORMATION_FORCE_DISABLED +/* tBleStatus hci_le_read_antenna_information(uint8_t *Supported_Switching_Sampling_Rates, + uint8_t *Num_Antennae, + uint8_t *Max_Switching_Pattern_Length, + uint8_t *Max_CTE_Length); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 + 1 + 1 + 1 */ +uint16_t hci_le_read_antenna_information_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1 + 1 + 1 + 1; + /* Output params */ + hci_le_read_antenna_information_rp0 *rp0 = (hci_le_read_antenna_information_rp0 *) (buffer_out + 6); + uint8_t Supported_Switching_Sampling_Rates = 0; + uint8_t Num_Antennae = 0; + uint8_t Max_Switching_Pattern_Length = 0; + uint8_t Max_CTE_Length = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 1 + 1 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_antenna_information(&Supported_Switching_Sampling_Rates, + &Num_Antennae, + &Max_Switching_Pattern_Length, + &Max_CTE_Length); +fail: + rp0->Supported_Switching_Sampling_Rates = Supported_Switching_Sampling_Rates; + rp0->Num_Antennae = Num_Antennae; + rp0->Max_Switching_Pattern_Length = Max_Switching_Pattern_Length; + rp0->Max_CTE_Length = Max_CTE_Length; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x58; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_periodic_advertising_receive_enable(uint16_t Sync_Handle, + uint8_t Enable); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_periodic_advertising_receive_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_advertising_receive_enable_cp0 *cp0 = (hci_le_set_periodic_advertising_receive_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = hci_le_set_periodic_advertising_receive_enable(cp0->Sync_Handle /* 2 */, + cp0->Enable /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x59; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_FORCE_DISABLED +/* tBleStatus hci_le_periodic_advertising_sync_transfer(uint16_t Connection_Handle, + uint16_t Service_Data, + uint16_t Sync_Handle); + */ +/* Command len: 2 + 2 + 2 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_periodic_advertising_sync_transfer_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_periodic_advertising_sync_transfer_cp0 *cp0 = (hci_le_periodic_advertising_sync_transfer_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_periodic_advertising_sync_transfer_rp0 *rp0 = (hci_le_periodic_advertising_sync_transfer_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2) + { + goto fail; + } + + rp0->Status = hci_le_periodic_advertising_sync_transfer(cp0->Connection_Handle /* 2 */, + cp0->Service_Data /* 2 */, + cp0->Sync_Handle /* 2 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x5a; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER_ENABLED) || HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER_ENABLED) && !HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER_FORCE_DISABLED +/* tBleStatus hci_le_periodic_advertising_set_info_transfer(uint16_t Connection_Handle, + uint16_t Service_Data, + uint8_t Advertising_Handle); + */ +/* Command len: 2 + 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_periodic_advertising_set_info_transfer_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_periodic_advertising_set_info_transfer_cp0 *cp0 = (hci_le_periodic_advertising_set_info_transfer_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_periodic_advertising_set_info_transfer_rp0 *rp0 = (hci_le_periodic_advertising_set_info_transfer_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_periodic_advertising_set_info_transfer(cp0->Connection_Handle /* 2 */, + cp0->Service_Data /* 2 */, + cp0->Advertising_Handle /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x5b; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_periodic_advertising_sync_transfer_parameters(uint16_t Connection_Handle, + uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type); + */ +/* Command len: 2 + 1 + 2 + 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_periodic_advertising_sync_transfer_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_advertising_sync_transfer_parameters_cp0 *cp0 = (hci_le_set_periodic_advertising_sync_transfer_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_periodic_advertising_sync_transfer_parameters_rp0 *rp0 = (hci_le_set_periodic_advertising_sync_transfer_parameters_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 2 + 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_set_periodic_advertising_sync_transfer_parameters(cp0->Connection_Handle /* 2 */, + cp0->Mode /* 1 */, + cp0->Skip /* 2 */, + cp0->Sync_Timeout /* 2 */, + cp0->CTE_Type /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x5c; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED) || HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED) && !HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_default_periodic_advertising_sync_transfer_parameters(uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type); + */ +/* Command len: 1 + 2 + 2 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_default_periodic_advertising_sync_transfer_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_default_periodic_advertising_sync_transfer_parameters_cp0 *cp0 = (hci_le_set_default_periodic_advertising_sync_transfer_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 2 + 2 + 1) + { + goto fail; + } + + *status = hci_le_set_default_periodic_advertising_sync_transfer_parameters(cp0->Mode /* 1 */, + cp0->Skip /* 2 */, + cp0->Sync_Timeout /* 2 */, + cp0->CTE_Type /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x5d; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_BUFFER_SIZE_V2_ENABLED) || HCI_LE_READ_BUFFER_SIZE_V2_ENABLED) && !HCI_LE_READ_BUFFER_SIZE_V2_FORCE_DISABLED +/* tBleStatus hci_le_read_buffer_size_v2(uint16_t *HC_LE_ACL_Data_Packet_Length, + uint8_t *HC_Total_Num_LE_ACL_Data_Packets, + uint16_t *ISO_Data_Packet_Length, + uint8_t *Total_Num_ISO_Data_Packets); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 + 1 + 2 + 1 */ +uint16_t hci_le_read_buffer_size_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2 + 1 + 2 + 1; + /* Output params */ + hci_le_read_buffer_size_v2_rp0 *rp0 = (hci_le_read_buffer_size_v2_rp0 *) (buffer_out + 6); + uint16_t HC_LE_ACL_Data_Packet_Length = 0; + uint8_t HC_Total_Num_LE_ACL_Data_Packets = 0; + uint16_t ISO_Data_Packet_Length = 0; + uint8_t Total_Num_ISO_Data_Packets = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 1 + 2 + 1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = hci_le_read_buffer_size_v2(&HC_LE_ACL_Data_Packet_Length, + &HC_Total_Num_LE_ACL_Data_Packets, + &ISO_Data_Packet_Length, + &Total_Num_ISO_Data_Packets); +fail: + rp0->HC_LE_ACL_Data_Packet_Length = HC_LE_ACL_Data_Packet_Length; + rp0->HC_Total_Num_LE_ACL_Data_Packets = HC_Total_Num_LE_ACL_Data_Packets; + rp0->ISO_Data_Packet_Length = ISO_Data_Packet_Length; + rp0->Total_Num_ISO_Data_Packets = Total_Num_ISO_Data_Packets; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x60; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_ISO_TX_SYNC_ENABLED) || HCI_LE_READ_ISO_TX_SYNC_ENABLED) && !HCI_LE_READ_ISO_TX_SYNC_FORCE_DISABLED +/* tBleStatus hci_le_read_iso_tx_sync(uint16_t Connection_Handle, + uint16_t *Packet_Sequence_Number, + uint32_t *TX_Time_Stamp, + uint8_t Time_Offset[3]); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 + 2 + 4 + 3 */ +uint16_t hci_le_read_iso_tx_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_read_iso_tx_sync_cp0 *cp0 = (hci_le_read_iso_tx_sync_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 2 + 4 + 3; + /* Output params */ + hci_le_read_iso_tx_sync_rp0 *rp0 = (hci_le_read_iso_tx_sync_rp0 *) (buffer_out + 6); + uint16_t Packet_Sequence_Number = 0; + uint32_t TX_Time_Stamp = 0; + uint8_t Time_Offset[3] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 2 + 4 + 3 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_le_read_iso_tx_sync(cp0->Connection_Handle /* 2 */, + &Packet_Sequence_Number, + &TX_Time_Stamp, + Time_Offset); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->Packet_Sequence_Number = Packet_Sequence_Number; + rp0->TX_Time_Stamp = TX_Time_Stamp; + Osal_MemCpy((void *) rp0->Time_Offset,(const void *) Time_Offset, 3); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x61; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_CIG_PARAMETERS_ENABLED) || HCI_LE_SET_CIG_PARAMETERS_ENABLED) && !HCI_LE_SET_CIG_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_cig_parameters(uint8_t CIG_ID, + uint8_t SDU_Interval_C_To_P[3], + uint8_t SDU_Interval_P_To_C[3], + uint8_t Worst_Case_SCA, + uint8_t Packing, + uint8_t Framing, + uint16_t Max_Transport_Latency_C_To_P, + uint16_t Max_Transport_Latency_P_To_C, + uint8_t CIS_Count, + CIS_Param_t CIS_Param[], + uint16_t Connection_Handle[]); + */ +/* Command len: 1 + 3 + 3 + 1 + 1 + 1 + 2 + 2 + 1 + struct_length */ +/* Response len: 1 + 1 + 1 + rp0->CIS_Count * (sizeof(uint16_t)) */ +uint16_t hci_le_set_cig_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_cig_parameters_cp0 *cp0 = (hci_le_set_cig_parameters_cp0 *)(buffer_in + (0)); + CIS_Param_t CIS_Param[HCI_MAX_PAYLOAD_SIZE/sizeof(CIS_Param_t)]; + + int output_size = 0; + /* Output params */ + hci_le_set_cig_parameters_rp0 *rp0 = (hci_le_set_cig_parameters_rp0 *) (buffer_out + 6); + uint16_t Connection_Handle[HCI_MAX_PAYLOAD_SIZE/sizeof(uint16_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + int i; + int struct_length = 0; + if(cp0->CIS_Count > HCI_MAX_PAYLOAD_SIZE/sizeof(CIS_Param_t)) + { + cp0->CIS_Count = 0; + goto fail; + } + for (i = 0; i < cp0->CIS_Count; i++) { + packed_CIS_Param_t *CIS_Param_tmp = (packed_CIS_Param_t *)(((uint8_t *)cp0->CIS_Param) + struct_length); + CIS_Param[i].CIS_ID = CIS_Param_tmp->CIS_ID; + struct_length += 1; + CIS_Param[i].Max_SDU_C_To_P = CIS_Param_tmp->Max_SDU_C_To_P; + struct_length += 2; + CIS_Param[i].Max_SDU_P_To_C = CIS_Param_tmp->Max_SDU_P_To_C; + struct_length += 2; + CIS_Param[i].PHY_C_To_P = CIS_Param_tmp->PHY_C_To_P; + struct_length += 1; + CIS_Param[i].PHY_P_To_C = CIS_Param_tmp->PHY_P_To_C; + struct_length += 1; + CIS_Param[i].RTN_C_To_P = CIS_Param_tmp->RTN_C_To_P; + struct_length += 1; + CIS_Param[i].RTN_P_To_C = CIS_Param_tmp->RTN_P_To_C; + struct_length += 1; + } + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 3 + 3 + 1 + 1 + 1 + 2 + 2 + 1 + struct_length) + { + goto fail; + } + + rp0->Status = hci_le_set_cig_parameters(cp0->CIG_ID /* 1 */, + cp0->SDU_Interval_C_To_P /* 3 */, + cp0->SDU_Interval_P_To_C /* 3 */, + cp0->Worst_Case_SCA /* 1 */, + cp0->Packing /* 1 */, + cp0->Framing /* 1 */, + cp0->Max_Transport_Latency_C_To_P /* 2 */, + cp0->Max_Transport_Latency_P_To_C /* 2 */, + cp0->CIS_Count /* 1 */, + CIS_Param /* struct_length */, + Connection_Handle); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->CIG_ID = cp0->CIG_ID; + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->CIS_Count = cp0->CIS_Count; + output_size += 1; + if (buffer_out_max_length < (output_size + (rp0->CIS_Count * (sizeof(uint16_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Connection_Handle,(const void *) Connection_Handle, rp0->CIS_Count * (sizeof(uint16_t))); + output_size += rp0->CIS_Count * (sizeof(uint16_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x62; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_CIG_PARAMETERS_TEST_ENABLED) || HCI_LE_SET_CIG_PARAMETERS_TEST_ENABLED) && !HCI_LE_SET_CIG_PARAMETERS_TEST_FORCE_DISABLED +/* tBleStatus hci_le_set_cig_parameters_test(uint8_t CIG_ID, + uint8_t SDU_Interval_C_To_P[3], + uint8_t SDU_Interval_P_To_C[3], + uint8_t FT_C_To_P, + uint8_t FT_P_To_C, + uint16_t ISO_Interval, + uint8_t Worst_Case_SCA, + uint8_t Packing, + uint8_t Framing, + uint8_t CIS_Count, + CIS_Param_Test_t CIS_Param_Test[], + uint16_t Connection_Handle[]); + */ +/* Command len: 1 + 3 + 3 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + struct_length */ +/* Response len: 1 + 1 + 1 + rp0->CIS_Count * (sizeof(uint16_t)) */ +uint16_t hci_le_set_cig_parameters_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_cig_parameters_test_cp0 *cp0 = (hci_le_set_cig_parameters_test_cp0 *)(buffer_in + (0)); + CIS_Param_Test_t CIS_Param_Test[HCI_MAX_PAYLOAD_SIZE/sizeof(CIS_Param_Test_t)]; + + int output_size = 0; + /* Output params */ + hci_le_set_cig_parameters_test_rp0 *rp0 = (hci_le_set_cig_parameters_test_rp0 *) (buffer_out + 6); + uint16_t Connection_Handle[HCI_MAX_PAYLOAD_SIZE/sizeof(uint16_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + int i; + int struct_length = 0; + if(cp0->CIS_Count > HCI_MAX_PAYLOAD_SIZE/sizeof(CIS_Param_Test_t)) + { + cp0->CIS_Count = 0; + goto fail; + } + for (i = 0; i < cp0->CIS_Count; i++) { + packed_CIS_Param_Test_t *CIS_Param_Test_tmp = (packed_CIS_Param_Test_t *)(((uint8_t *)cp0->CIS_Param_Test) + struct_length); + CIS_Param_Test[i].CIS_ID = CIS_Param_Test_tmp->CIS_ID; + struct_length += 1; + CIS_Param_Test[i].NSE = CIS_Param_Test_tmp->NSE; + struct_length += 1; + CIS_Param_Test[i].Max_SDU_C_To_P = CIS_Param_Test_tmp->Max_SDU_C_To_P; + struct_length += 2; + CIS_Param_Test[i].Max_SDU_P_To_C = CIS_Param_Test_tmp->Max_SDU_P_To_C; + struct_length += 2; + CIS_Param_Test[i].Max_PDU_C_To_P = CIS_Param_Test_tmp->Max_PDU_C_To_P; + struct_length += 2; + CIS_Param_Test[i].Max_PDU_P_To_C = CIS_Param_Test_tmp->Max_PDU_P_To_C; + struct_length += 2; + CIS_Param_Test[i].PHY_C_To_P = CIS_Param_Test_tmp->PHY_C_To_P; + struct_length += 1; + CIS_Param_Test[i].PHY_P_To_C = CIS_Param_Test_tmp->PHY_P_To_C; + struct_length += 1; + CIS_Param_Test[i].BN_C_To_P = CIS_Param_Test_tmp->BN_C_To_P; + struct_length += 1; + CIS_Param_Test[i].BN_P_To_C = CIS_Param_Test_tmp->BN_P_To_C; + struct_length += 1; + } + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 3 + 3 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + struct_length) + { + goto fail; + } + + rp0->Status = hci_le_set_cig_parameters_test(cp0->CIG_ID /* 1 */, + cp0->SDU_Interval_C_To_P /* 3 */, + cp0->SDU_Interval_P_To_C /* 3 */, + cp0->FT_C_To_P /* 1 */, + cp0->FT_P_To_C /* 1 */, + cp0->ISO_Interval /* 2 */, + cp0->Worst_Case_SCA /* 1 */, + cp0->Packing /* 1 */, + cp0->Framing /* 1 */, + cp0->CIS_Count /* 1 */, + CIS_Param_Test /* struct_length */, + Connection_Handle); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->CIG_ID = cp0->CIG_ID; + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->CIS_Count = cp0->CIS_Count; + output_size += 1; + if (buffer_out_max_length < (output_size + (rp0->CIS_Count * (sizeof(uint16_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Connection_Handle,(const void *) Connection_Handle, rp0->CIS_Count * (sizeof(uint16_t))); + output_size += rp0->CIS_Count * (sizeof(uint16_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x63; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CREATE_CIS_ENABLED) || HCI_LE_CREATE_CIS_ENABLED) && !HCI_LE_CREATE_CIS_FORCE_DISABLED +/* tBleStatus hci_le_create_cis(uint8_t CIS_Count, + CIS_Handles_t CIS_Handles[]); + */ +/* Command len: 1 + struct_length */ +/* Response len: 1 */ +uint16_t hci_le_create_cis_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_create_cis_cp0 *cp0 = (hci_le_create_cis_cp0 *)(buffer_in + (0)); + CIS_Handles_t CIS_Handles[HCI_MAX_PAYLOAD_SIZE/sizeof(CIS_Handles_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + int i; + int struct_length = 0; + if(cp0->CIS_Count > HCI_MAX_PAYLOAD_SIZE/sizeof(CIS_Handles_t)) + { + cp0->CIS_Count = 0; + goto fail; + } + for (i = 0; i < cp0->CIS_Count; i++) { + packed_CIS_Handles_t *CIS_Handles_tmp = (packed_CIS_Handles_t *)(((uint8_t *)cp0->CIS_Handles) + struct_length); + CIS_Handles[i].CIS_Connection_Handle = CIS_Handles_tmp->CIS_Connection_Handle; + struct_length += 2; + CIS_Handles[i].ACL_Connection_Handle = CIS_Handles_tmp->ACL_Connection_Handle; + struct_length += 2; + } + if(buffer_in_length != 1 + struct_length) + { + goto fail; + } + + *status = hci_le_create_cis(cp0->CIS_Count /* 1 */, + CIS_Handles /* struct_length */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x64; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_REMOVE_CIG_ENABLED) || HCI_LE_REMOVE_CIG_ENABLED) && !HCI_LE_REMOVE_CIG_FORCE_DISABLED +/* tBleStatus hci_le_remove_cig(uint8_t CIG_ID); + */ +/* Command len: 1 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_remove_cig_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_remove_cig_cp0 *cp0 = (hci_le_remove_cig_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 1; + /* Output params */ + hci_le_remove_cig_rp0 *rp0 = (hci_le_remove_cig_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + rp0->Status = hci_le_remove_cig(cp0->CIG_ID /* 1 */); +fail: + rp0->CIG_ID = cp0->CIG_ID; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x65; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ACCEPT_CIS_REQUEST_ENABLED) || HCI_LE_ACCEPT_CIS_REQUEST_ENABLED) && !HCI_LE_ACCEPT_CIS_REQUEST_FORCE_DISABLED +/* tBleStatus hci_le_accept_cis_request(uint16_t Connection_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t hci_le_accept_cis_request_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_accept_cis_request_cp0 *cp0 = (hci_le_accept_cis_request_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = hci_le_accept_cis_request(cp0->Connection_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x66; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_REJECT_CIS_REQUEST_ENABLED) || HCI_LE_REJECT_CIS_REQUEST_ENABLED) && !HCI_LE_REJECT_CIS_REQUEST_FORCE_DISABLED +/* tBleStatus hci_le_reject_cis_request(uint16_t Connection_Handle, + uint8_t Reason); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_reject_cis_request_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_reject_cis_request_cp0 *cp0 = (hci_le_reject_cis_request_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_reject_cis_request_rp0 *rp0 = (hci_le_reject_cis_request_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_reject_cis_request(cp0->Connection_Handle /* 2 */, + cp0->Reason /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x67; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CREATE_BIG_ENABLED) || HCI_LE_CREATE_BIG_ENABLED) && !HCI_LE_CREATE_BIG_FORCE_DISABLED +/* tBleStatus hci_le_create_big(uint8_t BIG_Handle, + uint8_t Advertising_Handle, + uint8_t Num_BIS, + uint8_t SDU_Interval[3], + uint16_t Max_SDU, + uint16_t Max_Transport_Latency, + uint8_t RTN, + uint8_t PHY, + uint8_t Packing, + uint8_t Framing, + uint8_t Encryption, + uint8_t Broadcast_Code[16]); + */ +/* Command len: 1 + 1 + 1 + 3 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 16 */ +/* Response len: 1 */ +uint16_t hci_le_create_big_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_create_big_cp0 *cp0 = (hci_le_create_big_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 3 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 16) + { + goto fail; + } + + *status = hci_le_create_big(cp0->BIG_Handle /* 1 */, + cp0->Advertising_Handle /* 1 */, + cp0->Num_BIS /* 1 */, + cp0->SDU_Interval /* 3 */, + cp0->Max_SDU /* 2 */, + cp0->Max_Transport_Latency /* 2 */, + cp0->RTN /* 1 */, + cp0->PHY /* 1 */, + cp0->Packing /* 1 */, + cp0->Framing /* 1 */, + cp0->Encryption /* 1 */, + cp0->Broadcast_Code /* 16 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x68; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_CREATE_BIG_TEST_ENABLED) || HCI_LE_CREATE_BIG_TEST_ENABLED) && !HCI_LE_CREATE_BIG_TEST_FORCE_DISABLED +/* tBleStatus hci_le_create_big_test(uint8_t BIG_Handle, + uint8_t Advertising_Handle, + uint8_t Num_BIS, + uint8_t SDU_Interval[3], + uint16_t ISO_Interval, + uint8_t NSE, + uint16_t Max_SDU, + uint16_t Max_PDU, + uint8_t PHY, + uint8_t Packing, + uint8_t Framing, + uint8_t BN, + uint8_t IRC, + uint8_t PTO, + uint8_t Encryption, + uint8_t Broadcast_Code[16]); + */ +/* Command len: 1 + 1 + 1 + 3 + 2 + 1 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 16 */ +/* Response len: 1 */ +uint16_t hci_le_create_big_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_create_big_test_cp0 *cp0 = (hci_le_create_big_test_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 3 + 2 + 1 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 16) + { + goto fail; + } + + *status = hci_le_create_big_test(cp0->BIG_Handle /* 1 */, + cp0->Advertising_Handle /* 1 */, + cp0->Num_BIS /* 1 */, + cp0->SDU_Interval /* 3 */, + cp0->ISO_Interval /* 2 */, + cp0->NSE /* 1 */, + cp0->Max_SDU /* 2 */, + cp0->Max_PDU /* 2 */, + cp0->PHY /* 1 */, + cp0->Packing /* 1 */, + cp0->Framing /* 1 */, + cp0->BN /* 1 */, + cp0->IRC /* 1 */, + cp0->PTO /* 1 */, + cp0->Encryption /* 1 */, + cp0->Broadcast_Code /* 16 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x69; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_TERMINATE_BIG_ENABLED) || HCI_LE_TERMINATE_BIG_ENABLED) && !HCI_LE_TERMINATE_BIG_FORCE_DISABLED +/* tBleStatus hci_le_terminate_big(uint8_t BIG_Handle, + uint8_t Reason); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_terminate_big_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_terminate_big_cp0 *cp0 = (hci_le_terminate_big_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = hci_le_terminate_big(cp0->BIG_Handle /* 1 */, + cp0->Reason /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x6a; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_BIG_CREATE_SYNC_ENABLED) || HCI_LE_BIG_CREATE_SYNC_ENABLED) && !HCI_LE_BIG_CREATE_SYNC_FORCE_DISABLED +/* tBleStatus hci_le_big_create_sync(uint8_t BIG_Handle, + uint16_t Sync_Handle, + uint8_t Encryption, + uint8_t Broadcast_Code[16], + uint8_t MSE, + uint16_t BIG_Sync_Timeout, + uint8_t Num_BIS, + uint8_t BIS[]); + */ +/* Command len: 1 + 2 + 1 + 16 + 1 + 2 + 1 + cp0->Num_BIS * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t hci_le_big_create_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_big_create_sync_cp0 *cp0 = (hci_le_big_create_sync_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 2 + 1 + 16 + 1 + 2 + 1 + cp0->Num_BIS * (sizeof(uint8_t))) + { + goto fail; + } + + *status = hci_le_big_create_sync(cp0->BIG_Handle /* 1 */, + cp0->Sync_Handle /* 2 */, + cp0->Encryption /* 1 */, + cp0->Broadcast_Code /* 16 */, + cp0->MSE /* 1 */, + cp0->BIG_Sync_Timeout /* 2 */, + cp0->Num_BIS /* 1 */, + cp0->BIS /* cp0->Num_BIS * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x6b; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_BIG_TERMINATE_SYNC_ENABLED) || HCI_LE_BIG_TERMINATE_SYNC_ENABLED) && !HCI_LE_BIG_TERMINATE_SYNC_FORCE_DISABLED +/* tBleStatus hci_le_big_terminate_sync(uint8_t BIG_Handle); + */ +/* Command len: 1 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_big_terminate_sync_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_big_terminate_sync_cp0 *cp0 = (hci_le_big_terminate_sync_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 1; + /* Output params */ + hci_le_big_terminate_sync_rp0 *rp0 = (hci_le_big_terminate_sync_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + rp0->Status = hci_le_big_terminate_sync(cp0->BIG_Handle /* 1 */); +fail: + rp0->BIG_Handle = cp0->BIG_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x6c; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_REQUEST_PEER_SCA_ENABLED) || HCI_LE_REQUEST_PEER_SCA_ENABLED) && !HCI_LE_REQUEST_PEER_SCA_FORCE_DISABLED +/* tBleStatus hci_le_request_peer_sca(uint16_t Connection_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t hci_le_request_peer_sca_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_request_peer_sca_cp0 *cp0 = (hci_le_request_peer_sca_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = hci_le_request_peer_sca(cp0->Connection_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x6d; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SETUP_ISO_DATA_PATH_ENABLED) || HCI_LE_SETUP_ISO_DATA_PATH_ENABLED) && !HCI_LE_SETUP_ISO_DATA_PATH_FORCE_DISABLED +/* tBleStatus hci_le_setup_iso_data_path(uint16_t Connection_Handle, + uint8_t Data_Path_Direction, + uint8_t Data_Path_ID, + uint8_t Codec_ID[5], + uint8_t Controller_Delay[3], + uint8_t Codec_Configuration_Length, + uint8_t Codec_Configuration[]); + */ +/* Command len: 2 + 1 + 1 + 5 + 3 + 1 + cp0->Codec_Configuration_Length * (sizeof(uint8_t)) */ +/* Response len: 1 + 2 */ +uint16_t hci_le_setup_iso_data_path_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_setup_iso_data_path_cp0 *cp0 = (hci_le_setup_iso_data_path_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_setup_iso_data_path_rp0 *rp0 = (hci_le_setup_iso_data_path_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 1 + 5 + 3 + 1 + cp0->Codec_Configuration_Length * (sizeof(uint8_t))) + { + goto fail; + } + + rp0->Status = hci_le_setup_iso_data_path(cp0->Connection_Handle /* 2 */, + cp0->Data_Path_Direction /* 1 */, + cp0->Data_Path_ID /* 1 */, + cp0->Codec_ID /* 5 */, + cp0->Controller_Delay /* 3 */, + cp0->Codec_Configuration_Length /* 1 */, + cp0->Codec_Configuration /* cp0->Codec_Configuration_Length * (sizeof(uint8_t)) */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x6e; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_REMOVE_ISO_DATA_PATH_ENABLED) || HCI_LE_REMOVE_ISO_DATA_PATH_ENABLED) && !HCI_LE_REMOVE_ISO_DATA_PATH_FORCE_DISABLED +/* tBleStatus hci_le_remove_iso_data_path(uint16_t Connection_Handle, + uint8_t Data_Path_Direction); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_remove_iso_data_path_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_remove_iso_data_path_cp0 *cp0 = (hci_le_remove_iso_data_path_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_remove_iso_data_path_rp0 *rp0 = (hci_le_remove_iso_data_path_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_remove_iso_data_path(cp0->Connection_Handle /* 2 */, + cp0->Data_Path_Direction /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x6f; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ISO_TRANSMIT_TEST_ENABLED) || HCI_LE_ISO_TRANSMIT_TEST_ENABLED) && !HCI_LE_ISO_TRANSMIT_TEST_FORCE_DISABLED +/* tBleStatus hci_le_iso_transmit_test(uint16_t Connection_Handle, + uint8_t Payload_Type); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_iso_transmit_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_iso_transmit_test_cp0 *cp0 = (hci_le_iso_transmit_test_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_iso_transmit_test_rp0 *rp0 = (hci_le_iso_transmit_test_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_iso_transmit_test(cp0->Connection_Handle /* 2 */, + cp0->Payload_Type /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x70; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ISO_RECEIVE_TEST_ENABLED) || HCI_LE_ISO_RECEIVE_TEST_ENABLED) && !HCI_LE_ISO_RECEIVE_TEST_FORCE_DISABLED +/* tBleStatus hci_le_iso_receive_test(uint16_t Connection_Handle, + uint8_t Payload_Type); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_iso_receive_test_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_iso_receive_test_cp0 *cp0 = (hci_le_iso_receive_test_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_iso_receive_test_rp0 *rp0 = (hci_le_iso_receive_test_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_iso_receive_test(cp0->Connection_Handle /* 2 */, + cp0->Payload_Type /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x71; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ISO_READ_TEST_COUNTERS_ENABLED) || HCI_LE_ISO_READ_TEST_COUNTERS_ENABLED) && !HCI_LE_ISO_READ_TEST_COUNTERS_FORCE_DISABLED +/* tBleStatus hci_le_iso_read_test_counters(uint16_t Connection_Handle, + uint32_t *Received_Packet_Count, + uint32_t *Missed_Packet_Count, + uint32_t *Failed_Packet_Count); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 + 4 + 4 + 4 */ +uint16_t hci_le_iso_read_test_counters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_iso_read_test_counters_cp0 *cp0 = (hci_le_iso_read_test_counters_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 4 + 4 + 4; + /* Output params */ + hci_le_iso_read_test_counters_rp0 *rp0 = (hci_le_iso_read_test_counters_rp0 *) (buffer_out + 6); + uint32_t Received_Packet_Count = 0; + uint32_t Missed_Packet_Count = 0; + uint32_t Failed_Packet_Count = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 4 + 4 + 4 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_le_iso_read_test_counters(cp0->Connection_Handle /* 2 */, + &Received_Packet_Count, + &Missed_Packet_Count, + &Failed_Packet_Count); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->Received_Packet_Count = Received_Packet_Count; + rp0->Missed_Packet_Count = Missed_Packet_Count; + rp0->Failed_Packet_Count = Failed_Packet_Count; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x72; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ISO_TEST_END_ENABLED) || HCI_LE_ISO_TEST_END_ENABLED) && !HCI_LE_ISO_TEST_END_FORCE_DISABLED +/* tBleStatus hci_le_iso_test_end(uint16_t Connection_Handle, + uint32_t *Received_Packet_Count, + uint32_t *Missed_Packet_Count, + uint32_t *Failed_Packet_Count); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 + 4 + 4 + 4 */ +uint16_t hci_le_iso_test_end_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_iso_test_end_cp0 *cp0 = (hci_le_iso_test_end_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 4 + 4 + 4; + /* Output params */ + hci_le_iso_test_end_rp0 *rp0 = (hci_le_iso_test_end_rp0 *) (buffer_out + 6); + uint32_t Received_Packet_Count = 0; + uint32_t Missed_Packet_Count = 0; + uint32_t Failed_Packet_Count = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 4 + 4 + 4 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_le_iso_test_end(cp0->Connection_Handle /* 2 */, + &Received_Packet_Count, + &Missed_Packet_Count, + &Failed_Packet_Count); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->Received_Packet_Count = Received_Packet_Count; + rp0->Missed_Packet_Count = Missed_Packet_Count; + rp0->Failed_Packet_Count = Failed_Packet_Count; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x73; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_HOST_FEATURE_ENABLED) || HCI_LE_SET_HOST_FEATURE_ENABLED) && !HCI_LE_SET_HOST_FEATURE_FORCE_DISABLED +/* tBleStatus hci_le_set_host_feature(uint8_t Bit_Number, + uint8_t Bit_Value); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_host_feature_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_host_feature_cp0 *cp0 = (hci_le_set_host_feature_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = hci_le_set_host_feature(cp0->Bit_Number /* 1 */, + cp0->Bit_Value /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x74; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_ISO_LINK_QUALITY_ENABLED) || HCI_LE_READ_ISO_LINK_QUALITY_ENABLED) && !HCI_LE_READ_ISO_LINK_QUALITY_FORCE_DISABLED +/* tBleStatus hci_le_read_iso_link_quality(uint16_t Connection_Handle, + uint32_t *Tx_UnACKed_Packets, + uint32_t *Tx_Flushed_Packets, + uint32_t *Tx_Last_Subevent_Packets, + uint32_t *Retransmitted_Packets, + uint32_t *CRC_Error_Packets, + uint32_t *Rx_Unreceived_Packets, + uint32_t *Duplicate_Packets); + */ +/* Command len: 2 */ +/* Response len: 1 + 2 + 4 + 4 + 4 + 4 + 4 + 4 + 4 */ +uint16_t hci_le_read_iso_link_quality_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_read_iso_link_quality_cp0 *cp0 = (hci_le_read_iso_link_quality_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 4 + 4 + 4 + 4 + 4 + 4 + 4; + /* Output params */ + hci_le_read_iso_link_quality_rp0 *rp0 = (hci_le_read_iso_link_quality_rp0 *) (buffer_out + 6); + uint32_t Tx_UnACKed_Packets = 0; + uint32_t Tx_Flushed_Packets = 0; + uint32_t Tx_Last_Subevent_Packets = 0; + uint32_t Retransmitted_Packets = 0; + uint32_t CRC_Error_Packets = 0; + uint32_t Rx_Unreceived_Packets = 0; + uint32_t Duplicate_Packets = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = hci_le_read_iso_link_quality(cp0->Connection_Handle /* 2 */, + &Tx_UnACKed_Packets, + &Tx_Flushed_Packets, + &Tx_Last_Subevent_Packets, + &Retransmitted_Packets, + &CRC_Error_Packets, + &Rx_Unreceived_Packets, + &Duplicate_Packets); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->Tx_UnACKed_Packets = Tx_UnACKed_Packets; + rp0->Tx_Flushed_Packets = Tx_Flushed_Packets; + rp0->Tx_Last_Subevent_Packets = Tx_Last_Subevent_Packets; + rp0->Retransmitted_Packets = Retransmitted_Packets; + rp0->CRC_Error_Packets = CRC_Error_Packets; + rp0->Rx_Unreceived_Packets = Rx_Unreceived_Packets; + rp0->Duplicate_Packets = Duplicate_Packets; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x75; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL_ENABLED) || HCI_LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL_ENABLED) && !HCI_LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL_FORCE_DISABLED +/* tBleStatus hci_le_enhanced_read_transmit_power_level(uint16_t Connection_Handle, + uint8_t PHY, + int8_t *Current_Transmit_Power_Level, + int8_t *Max_Transmit_Power_Level); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 + 1 + 1 + 1 */ +uint16_t hci_le_enhanced_read_transmit_power_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_enhanced_read_transmit_power_level_cp0 *cp0 = (hci_le_enhanced_read_transmit_power_level_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 1 + 1 + 1; + /* Output params */ + hci_le_enhanced_read_transmit_power_level_rp0 *rp0 = (hci_le_enhanced_read_transmit_power_level_rp0 *) (buffer_out + 6); + int8_t Current_Transmit_Power_Level = 0; + int8_t Max_Transmit_Power_Level = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 1 + 1 + 1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_enhanced_read_transmit_power_level(cp0->Connection_Handle /* 2 */, + cp0->PHY /* 1 */, + &Current_Transmit_Power_Level, + &Max_Transmit_Power_Level); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + rp0->PHY = cp0->PHY; + rp0->Current_Transmit_Power_Level = Current_Transmit_Power_Level; + rp0->Max_Transmit_Power_Level = Max_Transmit_Power_Level; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x76; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL_ENABLED) || HCI_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL_ENABLED) && !HCI_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL_FORCE_DISABLED +/* tBleStatus hci_le_read_remote_transmit_power_level(uint16_t Connection_Handle, + uint8_t PHY); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_read_remote_transmit_power_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_read_remote_transmit_power_level_cp0 *cp0 = (hci_le_read_remote_transmit_power_level_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = hci_le_read_remote_transmit_power_level(cp0->Connection_Handle /* 2 */, + cp0->PHY /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x77; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PATH_LOSS_REPORTING_PARAMETERS_ENABLED) || HCI_LE_SET_PATH_LOSS_REPORTING_PARAMETERS_ENABLED) && !HCI_LE_SET_PATH_LOSS_REPORTING_PARAMETERS_FORCE_DISABLED +/* tBleStatus hci_le_set_path_loss_reporting_parameters(uint16_t Connection_Handle, + uint8_t High_Threshold, + uint8_t High_Hysteresis, + uint8_t Low_Threshold, + uint8_t Low_Hysteresis, + uint16_t Min_Time_Spent); + */ +/* Command len: 2 + 1 + 1 + 1 + 1 + 2 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_path_loss_reporting_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_path_loss_reporting_parameters_cp0 *cp0 = (hci_le_set_path_loss_reporting_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_path_loss_reporting_parameters_rp0 *rp0 = (hci_le_set_path_loss_reporting_parameters_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 1 + 1 + 1 + 2) + { + goto fail; + } + + rp0->Status = hci_le_set_path_loss_reporting_parameters(cp0->Connection_Handle /* 2 */, + cp0->High_Threshold /* 1 */, + cp0->High_Hysteresis /* 1 */, + cp0->Low_Threshold /* 1 */, + cp0->Low_Hysteresis /* 1 */, + cp0->Min_Time_Spent /* 2 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x78; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PATH_LOSS_REPORTING_ENABLE_ENABLED) || HCI_LE_SET_PATH_LOSS_REPORTING_ENABLE_ENABLED) && !HCI_LE_SET_PATH_LOSS_REPORTING_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_path_loss_reporting_enable(uint16_t Connection_Handle, + uint8_t Enable); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_path_loss_reporting_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_path_loss_reporting_enable_cp0 *cp0 = (hci_le_set_path_loss_reporting_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_path_loss_reporting_enable_rp0 *rp0 = (hci_le_set_path_loss_reporting_enable_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = hci_le_set_path_loss_reporting_enable(cp0->Connection_Handle /* 2 */, + cp0->Enable /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x79; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_TRANSMIT_POWER_REPORTING_ENABLE_ENABLED) || HCI_LE_SET_TRANSMIT_POWER_REPORTING_ENABLE_ENABLED) && !HCI_LE_SET_TRANSMIT_POWER_REPORTING_ENABLE_FORCE_DISABLED +/* tBleStatus hci_le_set_transmit_power_reporting_enable(uint16_t Connection_Handle, + uint8_t Local_Enable, + uint8_t Remote_Enable); + */ +/* Command len: 2 + 1 + 1 */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_transmit_power_reporting_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_transmit_power_reporting_enable_cp0 *cp0 = (hci_le_set_transmit_power_reporting_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_transmit_power_reporting_enable_rp0 *rp0 = (hci_le_set_transmit_power_reporting_enable_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 1) + { + goto fail; + } + + rp0->Status = hci_le_set_transmit_power_reporting_enable(cp0->Connection_Handle /* 2 */, + cp0->Local_Enable /* 1 */, + cp0->Remote_Enable /* 1 */); +fail: + rp0->Connection_Handle = cp0->Connection_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x7a; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_TRANSMITTER_TEST_V4_ENABLED) || HCI_LE_TRANSMITTER_TEST_V4_ENABLED) && !HCI_LE_TRANSMITTER_TEST_V4_FORCE_DISABLED +/* tBleStatus hci_le_transmitter_test_v4(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[], + int8_t Transmit_Power_Level); + */ +/* Command len: 1 + 1 + 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) + 1 */ +/* Response len: 1 */ +uint16_t hci_le_transmitter_test_v4_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_transmitter_test_v4_cp0 *cp0 = (hci_le_transmitter_test_v4_cp0 *)(buffer_in + (0)); + hci_le_transmitter_test_v4_cp1 *cp1 = (hci_le_transmitter_test_v4_cp1 *)(buffer_in + (0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)))); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) + 1) + { + goto fail; + } + + *status = hci_le_transmitter_test_v4(cp0->TX_Channel /* 1 */, + cp0->Test_Data_Length /* 1 */, + cp0->Packet_Payload /* 1 */, + cp0->PHY /* 1 */, + cp0->CTE_Length /* 1 */, + cp0->CTE_Type /* 1 */, + cp0->Switching_Pattern_Length /* 1 */, + cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */, + cp1->Transmit_Power_Level /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x7b; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_DATA_RELATED_ADDRESS_CHANGES_ENABLED) || HCI_LE_SET_DATA_RELATED_ADDRESS_CHANGES_ENABLED) && !HCI_LE_SET_DATA_RELATED_ADDRESS_CHANGES_FORCE_DISABLED +/* tBleStatus hci_le_set_data_related_address_changes(uint8_t Advertising_Handle, + uint8_t Change_Reasons); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t hci_le_set_data_related_address_changes_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_data_related_address_changes_cp0 *cp0 = (hci_le_set_data_related_address_changes_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = hci_le_set_data_related_address_changes(cp0->Advertising_Handle /* 1 */, + cp0->Change_Reasons /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x7c; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_DEFAULT_SUBRATE_ENABLED) || HCI_LE_SET_DEFAULT_SUBRATE_ENABLED) && !HCI_LE_SET_DEFAULT_SUBRATE_FORCE_DISABLED +/* tBleStatus hci_le_set_default_subrate(uint16_t Subrate_Min, + uint16_t Subrate_Max, + uint16_t Max_Latency, + uint16_t Continuation_Number, + uint16_t Supervision_Timeout); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_set_default_subrate_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_default_subrate_cp0 *cp0 = (hci_le_set_default_subrate_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = hci_le_set_default_subrate(cp0->Subrate_Min /* 2 */, + cp0->Subrate_Max /* 2 */, + cp0->Max_Latency /* 2 */, + cp0->Continuation_Number /* 2 */, + cp0->Supervision_Timeout /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x7d; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SUBRATE_REQUEST_ENABLED) || HCI_LE_SUBRATE_REQUEST_ENABLED) && !HCI_LE_SUBRATE_REQUEST_FORCE_DISABLED +/* tBleStatus hci_le_subrate_request(uint16_t Connection_Handle, + uint16_t Subrate_Min, + uint16_t Subrate_Max, + uint16_t Max_Latency, + uint16_t Continuation_Number, + uint16_t Supervision_Timeout); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t hci_le_subrate_request_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_subrate_request_cp0 *cp0 = (hci_le_subrate_request_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = hci_le_subrate_request(cp0->Connection_Handle /* 2 */, + cp0->Subrate_Min /* 2 */, + cp0->Subrate_Max /* 2 */, + cp0->Max_Latency /* 2 */, + cp0->Continuation_Number /* 2 */, + cp0->Supervision_Timeout /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x7e; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V2_ENABLED) || HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V2_ENABLED) && !HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V2_FORCE_DISABLED +/* tBleStatus hci_le_set_extended_advertising_parameters_v2(uint8_t Advertising_Handle, + uint16_t Advertising_Event_Properties, + uint8_t Primary_Advertising_Interval_Min[3], + uint8_t Primary_Advertising_Interval_Max[3], + uint8_t Primary_Advertising_Channel_Map, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable, + uint8_t Primary_Advertising_PHY_Options, + uint8_t Secondary_Advertising_PHY_Options, + int8_t *Selected_Tx_Power); + */ +/* Command len: 1 + 2 + 3 + 3 + 1 + 1 + 1 + 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_set_extended_advertising_parameters_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_extended_advertising_parameters_v2_cp0 *cp0 = (hci_le_set_extended_advertising_parameters_v2_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 1; + /* Output params */ + hci_le_set_extended_advertising_parameters_v2_rp0 *rp0 = (hci_le_set_extended_advertising_parameters_v2_rp0 *) (buffer_out + 6); + int8_t Selected_Tx_Power = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 1 + 2 + 3 + 3 + 1 + 1 + 1 + 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1) + { + goto fail; + } + + rp0->Status = hci_le_set_extended_advertising_parameters_v2(cp0->Advertising_Handle /* 1 */, + cp0->Advertising_Event_Properties /* 2 */, + cp0->Primary_Advertising_Interval_Min /* 3 */, + cp0->Primary_Advertising_Interval_Max /* 3 */, + cp0->Primary_Advertising_Channel_Map /* 1 */, + cp0->Own_Address_Type /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */, + cp0->Advertising_Filter_Policy /* 1 */, + cp0->Advertising_Tx_Power /* 1 */, + cp0->Primary_Advertising_PHY /* 1 */, + cp0->Secondary_Advertising_Max_Skip /* 1 */, + cp0->Secondary_Advertising_PHY /* 1 */, + cp0->Advertising_SID /* 1 */, + cp0->Scan_Request_Notification_Enable /* 1 */, + cp0->Primary_Advertising_PHY_Options /* 1 */, + cp0->Secondary_Advertising_PHY_Options /* 1 */, + &Selected_Tx_Power); +fail: + rp0->Selected_Tx_Power = Selected_Tx_Power; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x7f; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_SUBEVENT_DATA_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_SUBEVENT_DATA_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_SUBEVENT_DATA_FORCE_DISABLED +/* tBleStatus hci_le_set_periodic_advertising_subevent_data(uint8_t Advertising_Handle, + uint8_t Num_Subevents, + Subevent_Data_Parameters_t Subevent_Data_Parameters[]); + */ +/* Command len: 1 + 1 + struct_length */ +/* Response len: 1 + 1 */ +uint16_t hci_le_set_periodic_advertising_subevent_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_advertising_subevent_data_cp0 *cp0 = (hci_le_set_periodic_advertising_subevent_data_cp0 *)(buffer_in + (0)); + Subevent_Data_Parameters_t Subevent_Data_Parameters[HCI_MAX_PAYLOAD_SIZE/sizeof(Subevent_Data_Parameters_t)]; + + int output_size = 1 + 1; + /* Output params */ + hci_le_set_periodic_advertising_subevent_data_rp0 *rp0 = (hci_le_set_periodic_advertising_subevent_data_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + int i; + int struct_length = 0; + if(cp0->Num_Subevents > HCI_MAX_PAYLOAD_SIZE/sizeof(Subevent_Data_Parameters_t)) + { + cp0->Num_Subevents = 0; + goto fail; + } + for (i = 0; i < cp0->Num_Subevents; i++) { + packed_Subevent_Data_Parameters_t *Subevent_Data_Parameters_tmp = (packed_Subevent_Data_Parameters_t *)(((uint8_t *)cp0->Subevent_Data_Parameters) + struct_length); + Subevent_Data_Parameters[i].Subevent = Subevent_Data_Parameters_tmp->Subevent; + struct_length += 1; + Subevent_Data_Parameters[i].Response_Slot_Start = Subevent_Data_Parameters_tmp->Response_Slot_Start; + struct_length += 1; + Subevent_Data_Parameters[i].Response_Slot_Count = Subevent_Data_Parameters_tmp->Response_Slot_Count; + struct_length += 1; + Subevent_Data_Parameters[i].Subevent_Data_Length = Subevent_Data_Parameters_tmp->Subevent_Data_Length; + struct_length += 1; + Subevent_Data_Parameters[i].Subevent_Data = Subevent_Data_Parameters_tmp->Subevent_Data; + struct_length += Subevent_Data_Parameters_tmp->Subevent_Data_Length; + } + if(buffer_in_length != 1 + 1 + struct_length) + { + goto fail; + } + + rp0->Status = hci_le_set_periodic_advertising_subevent_data(cp0->Advertising_Handle /* 1 */, + cp0->Num_Subevents /* 1 */, + Subevent_Data_Parameters /* struct_length */); +fail: + rp0->Advertising_Handle = cp0->Advertising_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x82; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_RESPONSE_DATA_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_RESPONSE_DATA_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_RESPONSE_DATA_FORCE_DISABLED +/* tBleStatus hci_le_set_periodic_advertising_response_data(uint16_t Sync_Handle, + uint16_t Request_Event, + uint8_t Request_Subevent, + uint8_t Response_Subevent, + uint8_t Response_Slot, + uint8_t Response_Data_Length, + uint8_t Response_Data[]); + */ +/* Command len: 2 + 2 + 1 + 1 + 1 + 1 + cp0->Response_Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_periodic_advertising_response_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_advertising_response_data_cp0 *cp0 = (hci_le_set_periodic_advertising_response_data_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_periodic_advertising_response_data_rp0 *rp0 = (hci_le_set_periodic_advertising_response_data_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1 + 1 + 1 + 1 + cp0->Response_Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + rp0->Status = hci_le_set_periodic_advertising_response_data(cp0->Sync_Handle /* 2 */, + cp0->Request_Event /* 2 */, + cp0->Request_Subevent /* 1 */, + cp0->Response_Subevent /* 1 */, + cp0->Response_Slot /* 1 */, + cp0->Response_Data_Length /* 1 */, + cp0->Response_Data /* cp0->Response_Data_Length * (sizeof(uint8_t)) */); +fail: + rp0->Sync_Handle = cp0->Sync_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x83; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_SYNC_SUBEVENT_ENABLED) || HCI_LE_SET_PERIODIC_SYNC_SUBEVENT_ENABLED) && !HCI_LE_SET_PERIODIC_SYNC_SUBEVENT_FORCE_DISABLED +/* tBleStatus hci_le_set_periodic_sync_subevent(uint16_t Sync_Handle, + uint16_t Periodic_Advertising_Properties, + uint8_t Num_Subevents, + uint8_t Subevent[]); + */ +/* Command len: 2 + 2 + 1 + cp0->Num_Subevents * (sizeof(uint8_t)) */ +/* Response len: 1 + 2 */ +uint16_t hci_le_set_periodic_sync_subevent_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_sync_subevent_cp0 *cp0 = (hci_le_set_periodic_sync_subevent_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + hci_le_set_periodic_sync_subevent_rp0 *rp0 = (hci_le_set_periodic_sync_subevent_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1 + cp0->Num_Subevents * (sizeof(uint8_t))) + { + goto fail; + } + + rp0->Status = hci_le_set_periodic_sync_subevent(cp0->Sync_Handle /* 2 */, + cp0->Periodic_Advertising_Properties /* 2 */, + cp0->Num_Subevents /* 1 */, + cp0->Subevent /* cp0->Num_Subevents * (sizeof(uint8_t)) */); +fail: + rp0->Sync_Handle = cp0->Sync_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x84; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_EXTENDED_CREATE_CONNECTION_V2_ENABLED) || HCI_LE_EXTENDED_CREATE_CONNECTION_V2_ENABLED) && !HCI_LE_EXTENDED_CREATE_CONNECTION_V2_FORCE_DISABLED +/* tBleStatus hci_le_extended_create_connection_v2(uint8_t Advertising_Handle, + uint8_t Subevent, + uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Initiating_PHYs, + Extended_Create_Connection_Parameters_t Extended_Create_Connection_Parameters[]); + */ +/* Command len: 1 + 1 + 1 + 1 + 1 + 6 + 1 + struct_length */ +/* Response len: 1 */ +uint16_t hci_le_extended_create_connection_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_extended_create_connection_v2_cp0 *cp0 = (hci_le_extended_create_connection_v2_cp0 *)(buffer_in + (0)); + Extended_Create_Connection_Parameters_t Extended_Create_Connection_Parameters[HCI_MAX_PAYLOAD_SIZE/sizeof(Extended_Create_Connection_Parameters_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + int i; + int struct_length = 0; + int len = 0; + + for (i = 0; i < sizeof( cp0->Initiating_PHYs)*8; i++) { + if((cp0->Initiating_PHYs >> i) & 0x01){ + len++; + } + } + if(len > HCI_MAX_PAYLOAD_SIZE/sizeof(Extended_Create_Connection_Parameters_t)) + { + len = 0; + goto fail; + } + for (i = 0; i < len; i++) { + packed_Extended_Create_Connection_Parameters_t *Extended_Create_Connection_Parameters_tmp = (packed_Extended_Create_Connection_Parameters_t *)(((uint8_t *)cp0->Extended_Create_Connection_Parameters) + struct_length); + Extended_Create_Connection_Parameters[i].Scan_Interval = Extended_Create_Connection_Parameters_tmp->Scan_Interval; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Scan_Window = Extended_Create_Connection_Parameters_tmp->Scan_Window; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Connection_Interval_Min = Extended_Create_Connection_Parameters_tmp->Connection_Interval_Min; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Connection_Interval_Max = Extended_Create_Connection_Parameters_tmp->Connection_Interval_Max; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Max_Latency = Extended_Create_Connection_Parameters_tmp->Max_Latency; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Supervision_Timeout = Extended_Create_Connection_Parameters_tmp->Supervision_Timeout; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Min_CE_Length = Extended_Create_Connection_Parameters_tmp->Min_CE_Length; + struct_length += 2; + Extended_Create_Connection_Parameters[i].Max_CE_Length = Extended_Create_Connection_Parameters_tmp->Max_CE_Length; + struct_length += 2; + } + if(buffer_in_length != 1 + 1 + 1 + 1 + 1 + 6 + 1 + struct_length) + { + goto fail; + } + + *status = hci_le_extended_create_connection_v2(cp0->Advertising_Handle /* 1 */, + cp0->Subevent /* 1 */, + cp0->Initiator_Filter_Policy /* 1 */, + cp0->Own_Address_Type /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */, + cp0->Initiating_PHYs /* 1 */, + Extended_Create_Connection_Parameters /* struct_length */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x85; + buffer_out[6] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_V2_ENABLED) || HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_V2_ENABLED) && !HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_V2_FORCE_DISABLED +/* tBleStatus hci_le_set_periodic_advertising_parameters_v2(uint8_t Advertising_Handle, + uint16_t Periodic_Advertising_Interval_Min, + uint16_t Periodic_Advertising_Interval_Max, + uint16_t Periodic_Advertising_Properties, + uint8_t Num_Subevents, + uint8_t Subevent_Interval, + uint8_t Response_Slot_Delay, + uint8_t Response_Slot_Spacing, + uint8_t Num_Response_Slots); + */ +/* Command len: 1 + 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1 */ +/* Response len: 1 + 1 */ +uint16_t hci_le_set_periodic_advertising_parameters_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + hci_le_set_periodic_advertising_parameters_v2_cp0 *cp0 = (hci_le_set_periodic_advertising_parameters_v2_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 1; + /* Output params */ + hci_le_set_periodic_advertising_parameters_v2_rp0 *rp0 = (hci_le_set_periodic_advertising_parameters_v2_rp0 *) (buffer_out + 6); + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6)) { return 0; } + if(buffer_in_length != 1 + 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1) + { + goto fail; + } + + rp0->Status = hci_le_set_periodic_advertising_parameters_v2(cp0->Advertising_Handle /* 1 */, + cp0->Periodic_Advertising_Interval_Min /* 2 */, + cp0->Periodic_Advertising_Interval_Max /* 2 */, + cp0->Periodic_Advertising_Properties /* 2 */, + cp0->Num_Subevents /* 1 */, + cp0->Subevent_Interval /* 1 */, + cp0->Response_Slot_Delay /* 1 */, + cp0->Response_Slot_Spacing /* 1 */, + cp0->Num_Response_Slots /* 1 */); +fail: + rp0->Advertising_Handle = cp0->Advertising_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x86; + buffer_out[5] = 0x20; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_GET_FW_BUILD_NUMBER_ENABLED) || ACI_HAL_GET_FW_BUILD_NUMBER_ENABLED) && !ACI_HAL_GET_FW_BUILD_NUMBER_FORCE_DISABLED +/* tBleStatus aci_hal_get_fw_build_number(uint16_t *Build_Number); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 */ +uint16_t aci_hal_get_fw_build_number_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2; + /* Output params */ + aci_hal_get_fw_build_number_rp0 *rp0 = (aci_hal_get_fw_build_number_rp0 *) (buffer_out + 6); + uint16_t Build_Number = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = aci_hal_get_fw_build_number(&Build_Number); +fail: + rp0->Build_Number = Build_Number; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x00; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_GET_FIRMWARE_DETAILS_ENABLED) || ACI_HAL_GET_FIRMWARE_DETAILS_ENABLED) && !ACI_HAL_GET_FIRMWARE_DETAILS_FORCE_DISABLED +/* tBleStatus aci_hal_get_firmware_details(uint8_t *DTM_version_major, + uint8_t *DTM_version_minor, + uint8_t *DTM_version_patch, + uint8_t *DTM_variant, + uint16_t *DTM_Build_Number, + uint8_t *BTLE_Stack_version_major, + uint8_t *BTLE_Stack_version_minor, + uint8_t *BTLE_Stack_version_patch, + uint8_t *BTLE_Stack_development, + uint16_t *BTLE_Stack_variant, + uint16_t *BTLE_Stack_Build_Number); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 2 + 2 */ +uint16_t aci_hal_get_firmware_details_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 2 + 2; + /* Output params */ + aci_hal_get_firmware_details_rp0 *rp0 = (aci_hal_get_firmware_details_rp0 *) (buffer_out + 6); + uint8_t DTM_version_major = 0; + uint8_t DTM_version_minor = 0; + uint8_t DTM_version_patch = 0; + uint8_t DTM_variant = 0; + uint16_t DTM_Build_Number = 0; + uint8_t BTLE_Stack_version_major = 0; + uint8_t BTLE_Stack_version_minor = 0; + uint8_t BTLE_Stack_version_patch = 0; + uint8_t BTLE_Stack_development = 0; + uint16_t BTLE_Stack_variant = 0; + uint16_t BTLE_Stack_Build_Number = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 2 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = aci_hal_get_firmware_details(&DTM_version_major, + &DTM_version_minor, + &DTM_version_patch, + &DTM_variant, + &DTM_Build_Number, + &BTLE_Stack_version_major, + &BTLE_Stack_version_minor, + &BTLE_Stack_version_patch, + &BTLE_Stack_development, + &BTLE_Stack_variant, + &BTLE_Stack_Build_Number); +fail: + rp0->DTM_version_major = DTM_version_major; + rp0->DTM_version_minor = DTM_version_minor; + rp0->DTM_version_patch = DTM_version_patch; + rp0->DTM_variant = DTM_variant; + rp0->DTM_Build_Number = DTM_Build_Number; + rp0->BTLE_Stack_version_major = BTLE_Stack_version_major; + rp0->BTLE_Stack_version_minor = BTLE_Stack_version_minor; + rp0->BTLE_Stack_version_patch = BTLE_Stack_version_patch; + rp0->BTLE_Stack_development = BTLE_Stack_development; + rp0->BTLE_Stack_variant = BTLE_Stack_variant; + rp0->BTLE_Stack_Build_Number = BTLE_Stack_Build_Number; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x01; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_GET_FIRMWARE_DETAILS_V2_ENABLED) || ACI_HAL_GET_FIRMWARE_DETAILS_V2_ENABLED) && !ACI_HAL_GET_FIRMWARE_DETAILS_V2_FORCE_DISABLED +/* tBleStatus aci_hal_get_firmware_details_v2(uint8_t *DTM_version_major, + uint8_t *DTM_version_minor, + uint8_t *DTM_version_patch, + uint8_t *DTM_variant, + uint16_t *DTM_Build_Number, + uint8_t *BTLE_Stack_version_major, + uint8_t *BTLE_Stack_version_minor, + uint8_t *BTLE_Stack_version_patch, + uint8_t *BTLE_Stack_development, + uint32_t *BTLE_Stack_variant, + uint16_t *BTLE_Stack_Build_Number); + */ +/* Command len: 0 */ +/* Response len: 1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 4 + 2 */ +uint16_t aci_hal_get_firmware_details_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 4 + 2; + /* Output params */ + aci_hal_get_firmware_details_v2_rp0 *rp0 = (aci_hal_get_firmware_details_v2_rp0 *) (buffer_out + 6); + uint8_t DTM_version_major = 0; + uint8_t DTM_version_minor = 0; + uint8_t DTM_version_patch = 0; + uint8_t DTM_variant = 0; + uint16_t DTM_Build_Number = 0; + uint8_t BTLE_Stack_version_major = 0; + uint8_t BTLE_Stack_version_minor = 0; + uint8_t BTLE_Stack_version_patch = 0; + uint8_t BTLE_Stack_development = 0; + uint32_t BTLE_Stack_variant = 0; + uint16_t BTLE_Stack_Build_Number = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 4 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = aci_hal_get_firmware_details_v2(&DTM_version_major, + &DTM_version_minor, + &DTM_version_patch, + &DTM_variant, + &DTM_Build_Number, + &BTLE_Stack_version_major, + &BTLE_Stack_version_minor, + &BTLE_Stack_version_patch, + &BTLE_Stack_development, + &BTLE_Stack_variant, + &BTLE_Stack_Build_Number); +fail: + rp0->DTM_version_major = DTM_version_major; + rp0->DTM_version_minor = DTM_version_minor; + rp0->DTM_version_patch = DTM_version_patch; + rp0->DTM_variant = DTM_variant; + rp0->DTM_Build_Number = DTM_Build_Number; + rp0->BTLE_Stack_version_major = BTLE_Stack_version_major; + rp0->BTLE_Stack_version_minor = BTLE_Stack_version_minor; + rp0->BTLE_Stack_version_patch = BTLE_Stack_version_patch; + rp0->BTLE_Stack_development = BTLE_Stack_development; + rp0->BTLE_Stack_variant = BTLE_Stack_variant; + rp0->BTLE_Stack_Build_Number = BTLE_Stack_Build_Number; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x02; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_WRITE_CONFIG_DATA_ENABLED) || ACI_HAL_WRITE_CONFIG_DATA_ENABLED) && !ACI_HAL_WRITE_CONFIG_DATA_FORCE_DISABLED +/* tBleStatus aci_hal_write_config_data(uint8_t Offset, + uint8_t Length, + uint8_t Value[]); + */ +/* Command len: 1 + 1 + cp0->Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_hal_write_config_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_write_config_data_cp0 *cp0 = (aci_hal_write_config_data_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + cp0->Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_hal_write_config_data(cp0->Offset /* 1 */, + cp0->Length /* 1 */, + cp0->Value /* cp0->Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0c; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_READ_CONFIG_DATA_ENABLED) || ACI_HAL_READ_CONFIG_DATA_ENABLED) && !ACI_HAL_READ_CONFIG_DATA_FORCE_DISABLED +/* tBleStatus aci_hal_read_config_data(uint8_t Offset, + uint8_t *Data_Length, + uint8_t Data[]); + */ +/* Command len: 1 */ +/* Response len: 1 + 1 + rp0->Data_Length * (sizeof(uint8_t)) */ +uint16_t aci_hal_read_config_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_read_config_data_cp0 *cp0 = (aci_hal_read_config_data_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_hal_read_config_data_rp0 *rp0 = (aci_hal_read_config_data_rp0 *) (buffer_out + 6); + uint8_t Data_Length = 0; + uint8_t Data[HCI_MAX_PAYLOAD_SIZE/sizeof(uint8_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + rp0->Status = aci_hal_read_config_data(cp0->Offset /* 1 */, + &Data_Length, + Data); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->Data_Length = Data_Length; + output_size += 1; + if (buffer_out_max_length < (output_size + (rp0->Data_Length * (sizeof(uint8_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Data,(const void *) Data, rp0->Data_Length * (sizeof(uint8_t))); + output_size += rp0->Data_Length * (sizeof(uint8_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0d; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_SET_TX_POWER_LEVEL_ENABLED) || ACI_HAL_SET_TX_POWER_LEVEL_ENABLED) && !ACI_HAL_SET_TX_POWER_LEVEL_FORCE_DISABLED +tBleStatus aci_hal_set_tx_power_level_preprocess(uint8_t En_High_Power, + uint8_t PA_Level); +/* tBleStatus aci_hal_set_tx_power_level(uint8_t En_High_Power, + uint8_t PA_Level); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_hal_set_tx_power_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_set_tx_power_level_cp0 *cp0 = (aci_hal_set_tx_power_level_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = aci_hal_set_tx_power_level_preprocess(cp0->En_High_Power /* 1 */, + cp0->PA_Level /* 1 */); + if(*status) + goto fail; + + *status = aci_hal_set_tx_power_level(cp0->En_High_Power /* 1 */, + cp0->PA_Level /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0f; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_LE_TX_TEST_PACKET_NUMBER_ENABLED) || ACI_HAL_LE_TX_TEST_PACKET_NUMBER_ENABLED) && !ACI_HAL_LE_TX_TEST_PACKET_NUMBER_FORCE_DISABLED +/* tBleStatus aci_hal_le_tx_test_packet_number(uint32_t *Number_Of_Packets); + */ +/* Command len: 0 */ +/* Response len: 1 + 4 */ +uint16_t aci_hal_le_tx_test_packet_number_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 4; + /* Output params */ + aci_hal_le_tx_test_packet_number_rp0 *rp0 = (aci_hal_le_tx_test_packet_number_rp0 *) (buffer_out + 6); + uint32_t Number_Of_Packets = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 4 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = aci_hal_le_tx_test_packet_number(&Number_Of_Packets); +fail: + rp0->Number_Of_Packets = Number_Of_Packets; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x14; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_TONE_START_ENABLED) || ACI_HAL_TONE_START_ENABLED) && !ACI_HAL_TONE_START_FORCE_DISABLED +/* tBleStatus aci_hal_tone_start(uint8_t RF_Channel, + uint8_t Offset); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_hal_tone_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_tone_start_cp0 *cp0 = (aci_hal_tone_start_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = aci_hal_tone_start(cp0->RF_Channel /* 1 */, + cp0->Offset /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x15; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_TONE_STOP_ENABLED) || ACI_HAL_TONE_STOP_ENABLED) && !ACI_HAL_TONE_STOP_FORCE_DISABLED +/* tBleStatus aci_hal_tone_stop(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t aci_hal_tone_stop_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = aci_hal_tone_stop(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x16; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_GET_LINK_STATUS_ENABLED) || ACI_HAL_GET_LINK_STATUS_ENABLED) && !ACI_HAL_GET_LINK_STATUS_FORCE_DISABLED +/* tBleStatus aci_hal_get_link_status(uint8_t Bank_index, + uint8_t Link_Status[8], + uint16_t Link_Connection_Handle[16 / 2]); + */ +/* Command len: 1 */ +/* Response len: 1 + 8 + 16 */ +uint16_t aci_hal_get_link_status_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_get_link_status_cp0 *cp0 = (aci_hal_get_link_status_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 8 + 16; + /* Output params */ + aci_hal_get_link_status_rp0 *rp0 = (aci_hal_get_link_status_rp0 *) (buffer_out + 6); + uint8_t Link_Status[8] = {0}; + uint16_t Link_Connection_Handle[16 / 2] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 8 + 16 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + rp0->Status = aci_hal_get_link_status(cp0->Bank_index /* 1 */, + Link_Status, + Link_Connection_Handle); +fail: + Osal_MemCpy((void *) rp0->Link_Status,(const void *) Link_Status, 8); + Osal_MemCpy((void *) rp0->Link_Connection_Handle,(const void *) Link_Connection_Handle, 16); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x17; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_SET_RADIO_ACTIVITY_MASK_ENABLED) || ACI_HAL_SET_RADIO_ACTIVITY_MASK_ENABLED) && !ACI_HAL_SET_RADIO_ACTIVITY_MASK_FORCE_DISABLED +/* tBleStatus aci_hal_set_radio_activity_mask(uint16_t Radio_Activity_Mask); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t aci_hal_set_radio_activity_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_set_radio_activity_mask_cp0 *cp0 = (aci_hal_set_radio_activity_mask_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = aci_hal_set_radio_activity_mask(cp0->Radio_Activity_Mask /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x18; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_SET_LE_POWER_CONTROL_ENABLED) || ACI_HAL_SET_LE_POWER_CONTROL_ENABLED) && !ACI_HAL_SET_LE_POWER_CONTROL_FORCE_DISABLED +/* tBleStatus aci_hal_set_le_power_control(uint8_t Enable, + uint8_t PHY, + int8_t RSSI_Target, + uint8_t RSSI_Hysteresis, + int8_t Initial_TX_Power, + uint8_t RSSI_Filtering_Coefficient); + */ +/* Command len: 1 + 1 + 1 + 1 + 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_hal_set_le_power_control_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_set_le_power_control_cp0 *cp0 = (aci_hal_set_le_power_control_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + 1 + 1) + { + goto fail; + } + + *status = aci_hal_set_le_power_control(cp0->Enable /* 1 */, + cp0->PHY /* 1 */, + cp0->RSSI_Target /* 1 */, + cp0->RSSI_Hysteresis /* 1 */, + cp0->Initial_TX_Power /* 1 */, + cp0->RSSI_Filtering_Coefficient /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x1c; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED) || ACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED) && !ACI_HAL_TRANSMITTER_TEST_PACKETS_FORCE_DISABLED +/* tBleStatus aci_hal_transmitter_test_packets(uint8_t TX_Frequency, + uint8_t Length_Of_Test_Data, + uint8_t Packet_Payload, + uint16_t Number_Of_Packets, + uint8_t PHY); + */ +/* Command len: 1 + 1 + 1 + 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_hal_transmitter_test_packets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_transmitter_test_packets_cp0 *cp0 = (aci_hal_transmitter_test_packets_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 2 + 1) + { + goto fail; + } + + *status = aci_hal_transmitter_test_packets(cp0->TX_Frequency /* 1 */, + cp0->Length_Of_Test_Data /* 1 */, + cp0->Packet_Payload /* 1 */, + cp0->Number_Of_Packets /* 2 */, + cp0->PHY /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x2b; + buffer_out[6] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED) || ACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED) && !ACI_HAL_TRANSMITTER_TEST_PACKETS_V2_FORCE_DISABLED +/* tBleStatus aci_hal_transmitter_test_packets_v2(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint16_t Number_Of_Packets, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); + */ +/* Command len: 1 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_hal_transmitter_test_packets_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_transmitter_test_packets_v2_cp0 *cp0 = (aci_hal_transmitter_test_packets_v2_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + cp0->Switching_Pattern_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_hal_transmitter_test_packets_v2(cp0->TX_Channel /* 1 */, + cp0->Test_Data_Length /* 1 */, + cp0->Packet_Payload /* 1 */, + cp0->Number_Of_Packets /* 2 */, + cp0->PHY /* 1 */, + cp0->CTE_Length /* 1 */, + cp0->CTE_Type /* 1 */, + cp0->Switching_Pattern_Length /* 1 */, + cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2c; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_WRITE_RADIO_REG_ENABLED) || ACI_HAL_WRITE_RADIO_REG_ENABLED) && !ACI_HAL_WRITE_RADIO_REG_FORCE_DISABLED +/* tBleStatus aci_hal_write_radio_reg(uint32_t Start_Address, + uint8_t Num_Bytes, + uint8_t Data[]); + */ +/* Command len: 4 + 1 + cp0->Num_Bytes * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_hal_write_radio_reg_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_write_radio_reg_cp0 *cp0 = (aci_hal_write_radio_reg_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 4 + 1 + cp0->Num_Bytes * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_hal_write_radio_reg(cp0->Start_Address /* 4 */, + cp0->Num_Bytes /* 1 */, + cp0->Data /* cp0->Num_Bytes * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x35; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_READ_RADIO_REG_ENABLED) || ACI_HAL_READ_RADIO_REG_ENABLED) && !ACI_HAL_READ_RADIO_REG_FORCE_DISABLED +/* tBleStatus aci_hal_read_radio_reg(uint32_t Start_Address, + uint8_t Num_Bytes, + uint8_t *Data_Length, + uint8_t Data[]); + */ +/* Command len: 4 + 1 */ +/* Response len: 1 + 1 + rp0->Data_Length * (sizeof(uint8_t)) */ +uint16_t aci_hal_read_radio_reg_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_read_radio_reg_cp0 *cp0 = (aci_hal_read_radio_reg_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_hal_read_radio_reg_rp0 *rp0 = (aci_hal_read_radio_reg_rp0 *) (buffer_out + 6); + uint8_t Data_Length = 0; + uint8_t Data[HCI_MAX_PAYLOAD_SIZE/sizeof(uint8_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 4 + 1) + { + goto fail; + } + + rp0->Status = aci_hal_read_radio_reg(cp0->Start_Address /* 4 */, + cp0->Num_Bytes /* 1 */, + &Data_Length, + Data); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->Data_Length = Data_Length; + output_size += 1; + if (buffer_out_max_length < (output_size + (rp0->Data_Length * (sizeof(uint8_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Data,(const void *) Data, rp0->Data_Length * (sizeof(uint8_t))); + output_size += rp0->Data_Length * (sizeof(uint8_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x36; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_SET_ANTENNA_SWITCH_PARAMETERS_ENABLED) || ACI_HAL_SET_ANTENNA_SWITCH_PARAMETERS_ENABLED) && !ACI_HAL_SET_ANTENNA_SWITCH_PARAMETERS_FORCE_DISABLED +/* tBleStatus aci_hal_set_antenna_switch_parameters(uint8_t Antenna_IDs, + uint8_t Antenna_ID_Shift, + uint8_t Default_Antenna_ID, + uint8_t RF_Activity_Enable); + */ +/* Command len: 1 + 1 + 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_hal_set_antenna_switch_parameters_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_set_antenna_switch_parameters_cp0 *cp0 = (aci_hal_set_antenna_switch_parameters_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1) + { + goto fail; + } + + *status = aci_hal_set_antenna_switch_parameters(cp0->Antenna_IDs /* 1 */, + cp0->Antenna_ID_Shift /* 1 */, + cp0->Default_Antenna_ID /* 1 */, + cp0->RF_Activity_Enable /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x37; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_PERIPHERAL_LATENCY_ENABLE_ENABLED) || ACI_HAL_PERIPHERAL_LATENCY_ENABLE_ENABLED) && !ACI_HAL_PERIPHERAL_LATENCY_ENABLE_FORCE_DISABLED +/* tBleStatus aci_hal_peripheral_latency_enable(uint16_t Connection_Handle, + uint8_t Enable); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_hal_peripheral_latency_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_hal_peripheral_latency_enable_cp0 *cp0 = (aci_hal_peripheral_latency_enable_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = aci_hal_peripheral_latency_enable(cp0->Connection_Handle /* 2 */, + cp0->Enable /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x38; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_HAL_GET_EVT_FIFO_MAX_LEVEL_ENABLED) || ACI_HAL_GET_EVT_FIFO_MAX_LEVEL_ENABLED) && !ACI_HAL_GET_EVT_FIFO_MAX_LEVEL_FORCE_DISABLED +/* tBleStatus aci_hal_get_evt_fifo_max_level(uint16_t *ISR0_FIFO_Max_Level, + uint16_t *ISR1_FIFO_Max_Level, + uint16_t *User_FIFO_Max_Level); + */ +/* Command len: 0 */ +/* Response len: 1 + 2 + 2 + 2 */ +uint16_t aci_hal_get_evt_fifo_max_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 2 + 2 + 2; + /* Output params */ + aci_hal_get_evt_fifo_max_level_rp0 *rp0 = (aci_hal_get_evt_fifo_max_level_rp0 *) (buffer_out + 6); + uint16_t ISR0_FIFO_Max_Level = 0; + uint16_t ISR1_FIFO_Max_Level = 0; + uint16_t User_FIFO_Max_Level = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 2 + 2 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = aci_hal_get_evt_fifo_max_level(&ISR0_FIFO_Max_Level, + &ISR1_FIFO_Max_Level, + &User_FIFO_Max_Level); +fail: + rp0->ISR0_FIFO_Max_Level = ISR0_FIFO_Max_Level; + rp0->ISR1_FIFO_Max_Level = ISR1_FIFO_Max_Level; + rp0->User_FIFO_Max_Level = User_FIFO_Max_Level; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x60; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if BLESTACK_CONTROLLER_ONLY==0 + +#if (!defined(ACI_GAP_INIT_ENABLED) || ACI_GAP_INIT_ENABLED) && !ACI_GAP_INIT_FORCE_DISABLED +/* tBleStatus aci_gap_init(uint8_t Privacy_Type, + uint8_t Identity_Address_Type); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_gap_init_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_init_cp0 *cp0 = (aci_gap_init_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + *status = aci_gap_init(cp0->Privacy_Type /* 1 */, + cp0->Identity_Address_Type /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x81; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_IO_CAPABILITY_ENABLED) || ACI_GAP_SET_IO_CAPABILITY_ENABLED) && !ACI_GAP_SET_IO_CAPABILITY_FORCE_DISABLED +/* tBleStatus aci_gap_set_io_capability(uint8_t IO_Capability); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t aci_gap_set_io_capability_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_io_capability_cp0 *cp0 = (aci_gap_set_io_capability_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = aci_gap_set_io_capability(cp0->IO_Capability /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x85; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_SECURITY_REQUIREMENTS_ENABLED) || ACI_GAP_SET_SECURITY_REQUIREMENTS_ENABLED) && !ACI_GAP_SET_SECURITY_REQUIREMENTS_FORCE_DISABLED +/* tBleStatus aci_gap_set_security_requirements(uint8_t Bonding_Mode, + uint8_t MITM_Mode, + uint8_t SC_Support, + uint8_t KeyPress_Notification_Support, + uint8_t Min_Encryption_Key_Size, + uint8_t Max_Encryption_Key_Size, + uint8_t Pairing_Response); + */ +/* Command len: 1 + 1 + 1 + 1 + 1 + 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_gap_set_security_requirements_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_security_requirements_cp0 *cp0 = (aci_gap_set_security_requirements_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + 1 + 1 + 1) + { + goto fail; + } + + *status = aci_gap_set_security_requirements(cp0->Bonding_Mode /* 1 */, + cp0->MITM_Mode /* 1 */, + cp0->SC_Support /* 1 */, + cp0->KeyPress_Notification_Support /* 1 */, + cp0->Min_Encryption_Key_Size /* 1 */, + cp0->Max_Encryption_Key_Size /* 1 */, + cp0->Pairing_Response /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x86; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_PASSKEY_RESP_ENABLED) || ACI_GAP_PASSKEY_RESP_ENABLED) && !ACI_GAP_PASSKEY_RESP_FORCE_DISABLED +/* tBleStatus aci_gap_passkey_resp(uint16_t Connection_Handle, + uint32_t Passkey); + */ +/* Command len: 2 + 4 */ +/* Response len: 1 */ +uint16_t aci_gap_passkey_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_passkey_resp_cp0 *cp0 = (aci_gap_passkey_resp_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 4) + { + goto fail; + } + + *status = aci_gap_passkey_resp(cp0->Connection_Handle /* 2 */, + cp0->Passkey /* 4 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x88; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_PROFILE_INIT_ENABLED) || ACI_GAP_PROFILE_INIT_ENABLED) && !ACI_GAP_PROFILE_INIT_FORCE_DISABLED +/* tBleStatus aci_gap_profile_init(uint8_t Role, + uint8_t Privacy_Type, + uint16_t *Dev_Name_Char_Handle, + uint16_t *Appearance_Char_Handle, + uint16_t *Periph_Pref_Conn_Param_Char_Handle); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 + 2 + 2 + 2 */ +uint16_t aci_gap_profile_init_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_profile_init_cp0 *cp0 = (aci_gap_profile_init_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2 + 2 + 2; + /* Output params */ + aci_gap_profile_init_rp0 *rp0 = (aci_gap_profile_init_rp0 *) (buffer_out + 6); + uint16_t Dev_Name_Char_Handle = 0; + uint16_t Appearance_Char_Handle = 0; + uint16_t Periph_Pref_Conn_Param_Char_Handle = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 2 + 2 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + rp0->Status = aci_gap_profile_init(cp0->Role /* 1 */, + cp0->Privacy_Type /* 1 */, + &Dev_Name_Char_Handle, + &Appearance_Char_Handle, + &Periph_Pref_Conn_Param_Char_Handle); +fail: + rp0->Dev_Name_Char_Handle = Dev_Name_Char_Handle; + rp0->Appearance_Char_Handle = Appearance_Char_Handle; + rp0->Periph_Pref_Conn_Param_Char_Handle = Periph_Pref_Conn_Param_Char_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x8a; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_SECURITY_ENABLED) || ACI_GAP_SET_SECURITY_ENABLED) && !ACI_GAP_SET_SECURITY_FORCE_DISABLED +/* tBleStatus aci_gap_set_security(uint16_t Connection_Handle, + uint8_t Security_Level, + uint8_t Force_Pairing); + */ +/* Command len: 2 + 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_gap_set_security_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_security_cp0 *cp0 = (aci_gap_set_security_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 1) + { + goto fail; + } + + *status = aci_gap_set_security(cp0->Connection_Handle /* 2 */, + cp0->Security_Level /* 1 */, + cp0->Force_Pairing /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x8d; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_GET_SECURITY_LEVEL_ENABLED) || ACI_GAP_GET_SECURITY_LEVEL_ENABLED) && !ACI_GAP_GET_SECURITY_LEVEL_FORCE_DISABLED +/* tBleStatus aci_gap_get_security_level(uint16_t Connection_Handle, + uint8_t *Security_Mode, + uint8_t *Security_Level); + */ +/* Command len: 2 */ +/* Response len: 1 + 1 + 1 */ +uint16_t aci_gap_get_security_level_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_get_security_level_cp0 *cp0 = (aci_gap_get_security_level_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 1 + 1; + /* Output params */ + aci_gap_get_security_level_rp0 *rp0 = (aci_gap_get_security_level_rp0 *) (buffer_out + 6); + uint8_t Security_Mode = 0; + uint8_t Security_Level = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + rp0->Status = aci_gap_get_security_level(cp0->Connection_Handle /* 2 */, + &Security_Mode, + &Security_Level); +fail: + rp0->Security_Mode = Security_Mode; + rp0->Security_Level = Security_Level; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x90; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_LE_EVENT_MASK_ENABLED) || ACI_GAP_SET_LE_EVENT_MASK_ENABLED) && !ACI_GAP_SET_LE_EVENT_MASK_FORCE_DISABLED +/* tBleStatus aci_gap_set_le_event_mask(uint8_t LE_Event_Mask[8]); + */ +/* Command len: 8 */ +/* Response len: 1 */ +uint16_t aci_gap_set_le_event_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_le_event_mask_cp0 *cp0 = (aci_gap_set_le_event_mask_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 8) + { + goto fail; + } + + *status = aci_gap_set_le_event_mask(cp0->LE_Event_Mask /* 8 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x92; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_TERMINATE_ENABLED) || ACI_GAP_TERMINATE_ENABLED) && !ACI_GAP_TERMINATE_FORCE_DISABLED +/* tBleStatus aci_gap_terminate(uint16_t Connection_Handle, + uint8_t Reason); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gap_terminate_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_terminate_cp0 *cp0 = (aci_gap_terminate_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = aci_gap_terminate(cp0->Connection_Handle /* 2 */, + cp0->Reason /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x93; + buffer_out[6] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_CLEAR_SECURITY_DB_ENABLED) || ACI_GAP_CLEAR_SECURITY_DB_ENABLED) && !ACI_GAP_CLEAR_SECURITY_DB_FORCE_DISABLED +/* tBleStatus aci_gap_clear_security_db(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t aci_gap_clear_security_db_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = aci_gap_clear_security_db(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x94; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_PAIRING_RESP_ENABLED) || ACI_GAP_PAIRING_RESP_ENABLED) && !ACI_GAP_PAIRING_RESP_FORCE_DISABLED +/* tBleStatus aci_gap_pairing_resp(uint16_t Connection_Handle, + uint8_t Accept); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gap_pairing_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_pairing_resp_cp0 *cp0 = (aci_gap_pairing_resp_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = aci_gap_pairing_resp(cp0->Connection_Handle /* 2 */, + cp0->Accept /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x96; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_CREATE_CONNECTION_ENABLED) || ACI_GAP_CREATE_CONNECTION_ENABLED) && !ACI_GAP_CREATE_CONNECTION_FORCE_DISABLED +/* tBleStatus aci_gap_create_connection(uint8_t Initiating_PHY, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); + */ +/* Command len: 1 + 1 + 6 */ +/* Response len: 1 */ +uint16_t aci_gap_create_connection_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_create_connection_cp0 *cp0 = (aci_gap_create_connection_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 6) + { + goto fail; + } + + *status = aci_gap_create_connection(cp0->Initiating_PHY /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x9c; + buffer_out[6] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_TERMINATE_PROC_ENABLED) || ACI_GAP_TERMINATE_PROC_ENABLED) && !ACI_GAP_TERMINATE_PROC_FORCE_DISABLED +/* tBleStatus aci_gap_terminate_proc(uint8_t Procedure_Code); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t aci_gap_terminate_proc_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_terminate_proc_cp0 *cp0 = (aci_gap_terminate_proc_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = aci_gap_terminate_proc(cp0->Procedure_Code /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x9d; + buffer_out[6] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_START_CONNECTION_UPDATE_ENABLED) || ACI_GAP_START_CONNECTION_UPDATE_ENABLED) && !ACI_GAP_START_CONNECTION_UPDATE_FORCE_DISABLED +/* tBleStatus aci_gap_start_connection_update(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gap_start_connection_update_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_start_connection_update_cp0 *cp0 = (aci_gap_start_connection_update_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_gap_start_connection_update(cp0->Connection_Handle /* 2 */, + cp0->Connection_Interval_Min /* 2 */, + cp0->Connection_Interval_Max /* 2 */, + cp0->Max_Latency /* 2 */, + cp0->Supervision_Timeout /* 2 */, + cp0->Min_CE_Length /* 2 */, + cp0->Max_CE_Length /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x9e; + buffer_out[6] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_RESOLVE_PRIVATE_ADDR_ENABLED) || ACI_GAP_RESOLVE_PRIVATE_ADDR_ENABLED) && !ACI_GAP_RESOLVE_PRIVATE_ADDR_FORCE_DISABLED +/* tBleStatus aci_gap_resolve_private_addr(uint8_t Address[6], + uint8_t Actual_Address[6]); + */ +/* Command len: 6 */ +/* Response len: 1 + 6 */ +uint16_t aci_gap_resolve_private_addr_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_resolve_private_addr_cp0 *cp0 = (aci_gap_resolve_private_addr_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 6; + /* Output params */ + aci_gap_resolve_private_addr_rp0 *rp0 = (aci_gap_resolve_private_addr_rp0 *) (buffer_out + 6); + uint8_t Actual_Address[6] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6 + 6)) { return 0; } + if(buffer_in_length != 6) + { + goto fail; + } + + rp0->Status = aci_gap_resolve_private_addr(cp0->Address /* 6 */, + Actual_Address); +fail: + Osal_MemCpy((void *) rp0->Actual_Address,(const void *) Actual_Address, 6); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xa0; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_GET_BONDED_DEVICES_ENABLED) || ACI_GAP_GET_BONDED_DEVICES_ENABLED) && !ACI_GAP_GET_BONDED_DEVICES_FORCE_DISABLED +/* tBleStatus aci_gap_get_bonded_devices(uint8_t Offset, + uint8_t Max_Num_Of_Addresses, + uint8_t *Num_of_Addresses, + Bonded_Device_Entry_t Bonded_Device_Entry[]); + */ +/* Command len: 1 + 1 */ +/* Response len: 1 + 1 + struct_length */ +uint16_t aci_gap_get_bonded_devices_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_get_bonded_devices_cp0 *cp0 = (aci_gap_get_bonded_devices_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_gap_get_bonded_devices_rp0 *rp0 = (aci_gap_get_bonded_devices_rp0 *) (buffer_out + 6); + uint8_t Num_of_Addresses = 0; + Bonded_Device_Entry_t Bonded_Device_Entry[HCI_MAX_PAYLOAD_SIZE/sizeof(Bonded_Device_Entry_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1) + { + goto fail; + } + + rp0->Status = aci_gap_get_bonded_devices(cp0->Offset /* 1 */, + cp0->Max_Num_Of_Addresses /* 1 */, + &Num_of_Addresses, + Bonded_Device_Entry); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->Num_of_Addresses = Num_of_Addresses; + output_size += 1; + { + int i; + for (i = 0; i < rp0->Num_of_Addresses; i++) { + if (buffer_out_max_length < (output_size + (sizeof(uint8_t)) + 6)) { return 0; } + rp0->Bonded_Device_Entry[i].Address_Type = Bonded_Device_Entry[i].Address_Type; + output_size += sizeof(uint8_t); + if (buffer_out_max_length < (output_size + (6) + 6)) { return 0; } + Osal_MemCpy((void *) &rp0->Bonded_Device_Entry[i].Address, (const void *) Bonded_Device_Entry[i].Address, 6); + output_size += 6; + } + } + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xa3; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_IS_DEVICE_BONDED_ENABLED) || ACI_GAP_IS_DEVICE_BONDED_ENABLED) && !ACI_GAP_IS_DEVICE_BONDED_FORCE_DISABLED +/* tBleStatus aci_gap_is_device_bonded(uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); + */ +/* Command len: 1 + 6 */ +/* Response len: 1 */ +uint16_t aci_gap_is_device_bonded_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_is_device_bonded_cp0 *cp0 = (aci_gap_is_device_bonded_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6) + { + goto fail; + } + + *status = aci_gap_is_device_bonded(cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xa4; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_NUMERIC_COMPARISON_VALUE_CONFIRM_YESNO_ENABLED) || ACI_GAP_NUMERIC_COMPARISON_VALUE_CONFIRM_YESNO_ENABLED) && !ACI_GAP_NUMERIC_COMPARISON_VALUE_CONFIRM_YESNO_FORCE_DISABLED +/* tBleStatus aci_gap_numeric_comparison_value_confirm_yesno(uint16_t Connection_Handle, + uint8_t Confirm_Yes_No); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gap_numeric_comparison_value_confirm_yesno_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_numeric_comparison_value_confirm_yesno_cp0 *cp0 = (aci_gap_numeric_comparison_value_confirm_yesno_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = aci_gap_numeric_comparison_value_confirm_yesno(cp0->Connection_Handle /* 2 */, + cp0->Confirm_Yes_No /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xa5; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_PASSKEY_INPUT_ENABLED) || ACI_GAP_PASSKEY_INPUT_ENABLED) && !ACI_GAP_PASSKEY_INPUT_FORCE_DISABLED +/* tBleStatus aci_gap_passkey_input(uint16_t Connection_Handle, + uint8_t Input_Type); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gap_passkey_input_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_passkey_input_cp0 *cp0 = (aci_gap_passkey_input_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = aci_gap_passkey_input(cp0->Connection_Handle /* 2 */, + cp0->Input_Type /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xa6; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_GET_OOB_DATA_ENABLED) || ACI_GAP_GET_OOB_DATA_ENABLED) && !ACI_GAP_GET_OOB_DATA_FORCE_DISABLED +/* tBleStatus aci_gap_get_oob_data(uint8_t OOB_Data_Type, + uint8_t *Address_Type, + uint8_t Address[6], + uint8_t *OOB_Data_Len, + uint8_t OOB_Data[16]); + */ +/* Command len: 1 */ +/* Response len: 1 + 1 + 6 + 1 + 1 + 16 */ +uint16_t aci_gap_get_oob_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_get_oob_data_cp0 *cp0 = (aci_gap_get_oob_data_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 1 + 6 + 1 + 1 + 16; + /* Output params */ + aci_gap_get_oob_data_rp0 *rp0 = (aci_gap_get_oob_data_rp0 *) (buffer_out + 6); + uint8_t Address_Type = 0; + uint8_t Address[6] = {0}; + uint8_t OOB_Data_Len = 0; + uint8_t OOB_Data[16] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 1 + 6 + 1 + 1 + 16 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + rp0->Status = aci_gap_get_oob_data(cp0->OOB_Data_Type /* 1 */, + &Address_Type, + Address, + &OOB_Data_Len, + OOB_Data); +fail: + rp0->Address_Type = Address_Type; + Osal_MemCpy((void *) rp0->Address,(const void *) Address, 6); + rp0->OOB_Data_Type = cp0->OOB_Data_Type; + rp0->OOB_Data_Len = OOB_Data_Len; + Osal_MemCpy((void *) rp0->OOB_Data,(const void *) OOB_Data, 16); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xa7; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_OOB_DATA_ENABLED) || ACI_GAP_SET_OOB_DATA_ENABLED) && !ACI_GAP_SET_OOB_DATA_FORCE_DISABLED +/* tBleStatus aci_gap_set_oob_data(uint8_t Device_Type, + uint8_t Address_Type, + uint8_t Address[6], + uint8_t OOB_Data_Type, + uint8_t OOB_Data_Len, + uint8_t OOB_Data[16]); + */ +/* Command len: 1 + 1 + 6 + 1 + 1 + 16 */ +/* Response len: 1 */ +uint16_t aci_gap_set_oob_data_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_oob_data_cp0 *cp0 = (aci_gap_set_oob_data_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 6 + 1 + 1 + 16) + { + goto fail; + } + + *status = aci_gap_set_oob_data(cp0->Device_Type /* 1 */, + cp0->Address_Type /* 1 */, + cp0->Address /* 6 */, + cp0->OOB_Data_Type /* 1 */, + cp0->OOB_Data_Len /* 1 */, + cp0->OOB_Data /* 16 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xa8; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_REMOVE_BONDED_DEVICE_ENABLED) || ACI_GAP_REMOVE_BONDED_DEVICE_ENABLED) && !ACI_GAP_REMOVE_BONDED_DEVICE_FORCE_DISABLED +/* tBleStatus aci_gap_remove_bonded_device(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6]); + */ +/* Command len: 1 + 6 */ +/* Response len: 1 */ +uint16_t aci_gap_remove_bonded_device_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_remove_bonded_device_cp0 *cp0 = (aci_gap_remove_bonded_device_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 6) + { + goto fail; + } + + *status = aci_gap_remove_bonded_device(cp0->Peer_Identity_Address_Type /* 1 */, + cp0->Peer_Identity_Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xaa; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_ADVERTISING_CONFIGURATION_ENABLED) || ACI_GAP_SET_ADVERTISING_CONFIGURATION_ENABLED) && !ACI_GAP_SET_ADVERTISING_CONFIGURATION_FORCE_DISABLED +/* tBleStatus aci_gap_set_advertising_configuration(uint8_t Advertising_Handle, + uint8_t Discoverable_Mode, + uint16_t Advertising_Event_Properties, + uint32_t Primary_Advertising_Interval_Min, + uint32_t Primary_Advertising_Interval_Max, + uint8_t Primary_Advertising_Channel_Map, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable); + */ +/* Command len: 1 + 1 + 2 + 4 + 4 + 1 + 1 + 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_gap_set_advertising_configuration_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_advertising_configuration_cp0 *cp0 = (aci_gap_set_advertising_configuration_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 2 + 4 + 4 + 1 + 1 + 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1) + { + goto fail; + } + + *status = aci_gap_set_advertising_configuration(cp0->Advertising_Handle /* 1 */, + cp0->Discoverable_Mode /* 1 */, + cp0->Advertising_Event_Properties /* 2 */, + cp0->Primary_Advertising_Interval_Min /* 4 */, + cp0->Primary_Advertising_Interval_Max /* 4 */, + cp0->Primary_Advertising_Channel_Map /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */, + cp0->Advertising_Filter_Policy /* 1 */, + cp0->Advertising_Tx_Power /* 1 */, + cp0->Primary_Advertising_PHY /* 1 */, + cp0->Secondary_Advertising_Max_Skip /* 1 */, + cp0->Secondary_Advertising_PHY /* 1 */, + cp0->Advertising_SID /* 1 */, + cp0->Scan_Request_Notification_Enable /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xab; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_ADVERTISING_ENABLE_ENABLED) || ACI_GAP_SET_ADVERTISING_ENABLE_ENABLED) && !ACI_GAP_SET_ADVERTISING_ENABLE_FORCE_DISABLED +tBleStatus aci_gap_set_advertising_enable_preprocess(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]); +/* tBleStatus aci_gap_set_advertising_enable(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]); + */ +/* Command len: 1 + 1 + struct_length */ +/* Response len: 1 */ +uint16_t aci_gap_set_advertising_enable_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_advertising_enable_cp0 *cp0 = (aci_gap_set_advertising_enable_cp0 *)(buffer_in + (0)); + Advertising_Set_Parameters_t Advertising_Set_Parameters[HCI_MAX_PAYLOAD_SIZE/sizeof(Advertising_Set_Parameters_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + int i; + int struct_length = 0; + if(cp0->Number_of_Sets > HCI_MAX_PAYLOAD_SIZE/sizeof(Advertising_Set_Parameters_t)) + { + cp0->Number_of_Sets = 0; + goto fail; + } + for (i = 0; i < cp0->Number_of_Sets; i++) { + packed_Advertising_Set_Parameters_t *Advertising_Set_Parameters_tmp = (packed_Advertising_Set_Parameters_t *)(((uint8_t *)cp0->Advertising_Set_Parameters) + struct_length); + Advertising_Set_Parameters[i].Advertising_Handle = Advertising_Set_Parameters_tmp->Advertising_Handle; + struct_length += 1; + Advertising_Set_Parameters[i].Duration = Advertising_Set_Parameters_tmp->Duration; + struct_length += 2; + Advertising_Set_Parameters[i].Max_Extended_Advertising_Events = Advertising_Set_Parameters_tmp->Max_Extended_Advertising_Events; + struct_length += 1; + } + if(buffer_in_length != 1 + 1 + struct_length) + { + goto fail; + } + + *status = aci_gap_set_advertising_enable_preprocess(cp0->Enable /* 1 */, + cp0->Number_of_Sets /* 1 */, + Advertising_Set_Parameters /* struct_length */); + if(*status) + goto fail; + + *status = aci_gap_set_advertising_enable(cp0->Enable /* 1 */, + cp0->Number_of_Sets /* 1 */, + Advertising_Set_Parameters /* struct_length */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xac; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_ADVERTISING_DATA_NWK_ENABLED) || ACI_GAP_SET_ADVERTISING_DATA_NWK_ENABLED) && !ACI_GAP_SET_ADVERTISING_DATA_NWK_FORCE_DISABLED +/* tBleStatus aci_gap_set_advertising_data_nwk(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Advertising_Data_Length, + uint8_t Advertising_Data[]); + */ +/* Command len: 1 + 1 + 1 + cp0->Advertising_Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gap_set_advertising_data_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_advertising_data_nwk_cp0 *cp0 = (aci_gap_set_advertising_data_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + cp0->Advertising_Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gap_set_advertising_data_nwk(cp0->Advertising_Handle /* 1 */, + cp0->Operation /* 1 */, + cp0->Advertising_Data_Length /* 1 */, + cp0->Advertising_Data /* cp0->Advertising_Data_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xad; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_SCAN_RESPONSE_DATA_NWK_ENABLED) || ACI_GAP_SET_SCAN_RESPONSE_DATA_NWK_ENABLED) && !ACI_GAP_SET_SCAN_RESPONSE_DATA_NWK_FORCE_DISABLED +/* tBleStatus aci_gap_set_scan_response_data_nwk(uint8_t Advertising_Handle, + uint8_t Operation, + uint8_t Scan_Response_Data_Length, + uint8_t Scan_Response_Data[]); + */ +/* Command len: 1 + 1 + 1 + cp0->Scan_Response_Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gap_set_scan_response_data_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_scan_response_data_nwk_cp0 *cp0 = (aci_gap_set_scan_response_data_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + cp0->Scan_Response_Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gap_set_scan_response_data_nwk(cp0->Advertising_Handle /* 1 */, + cp0->Operation /* 1 */, + cp0->Scan_Response_Data_Length /* 1 */, + cp0->Scan_Response_Data /* cp0->Scan_Response_Data_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xae; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_SCAN_CONFIGURATION_ENABLED) || ACI_GAP_SET_SCAN_CONFIGURATION_ENABLED) && !ACI_GAP_SET_SCAN_CONFIGURATION_FORCE_DISABLED +/* tBleStatus aci_gap_set_scan_configuration(uint8_t Filter_Duplicates, + uint8_t Scanning_Filter_Policy, + uint8_t Scanning_PHY, + uint8_t Scan_Type, + uint16_t Scan_Interval, + uint16_t Scan_Window); + */ +/* Command len: 1 + 1 + 1 + 1 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gap_set_scan_configuration_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_scan_configuration_cp0 *cp0 = (aci_gap_set_scan_configuration_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + 2 + 2) + { + goto fail; + } + + *status = aci_gap_set_scan_configuration(cp0->Filter_Duplicates /* 1 */, + cp0->Scanning_Filter_Policy /* 1 */, + cp0->Scanning_PHY /* 1 */, + cp0->Scan_Type /* 1 */, + cp0->Scan_Interval /* 2 */, + cp0->Scan_Window /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xaf; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_SET_CONNECTION_CONFIGURATION_ENABLED) || ACI_GAP_SET_CONNECTION_CONFIGURATION_ENABLED) && !ACI_GAP_SET_CONNECTION_CONFIGURATION_FORCE_DISABLED +/* tBleStatus aci_gap_set_connection_configuration(uint8_t Initiating_PHY, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + */ +/* Command len: 1 + 2 + 2 + 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gap_set_connection_configuration_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_set_connection_configuration_cp0 *cp0 = (aci_gap_set_connection_configuration_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 2 + 2 + 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_gap_set_connection_configuration(cp0->Initiating_PHY /* 1 */, + cp0->Connection_Interval_Min /* 2 */, + cp0->Connection_Interval_Max /* 2 */, + cp0->Max_Latency /* 2 */, + cp0->Supervision_Timeout /* 2 */, + cp0->Min_CE_Length /* 2 */, + cp0->Max_CE_Length /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xb0; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_START_PROCEDURE_ENABLED) || ACI_GAP_START_PROCEDURE_ENABLED) && !ACI_GAP_START_PROCEDURE_FORCE_DISABLED +/* tBleStatus aci_gap_start_procedure(uint8_t Procedure_Code, + uint8_t PHYs, + uint16_t Duration, + uint16_t Period); + */ +/* Command len: 1 + 1 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gap_start_procedure_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_start_procedure_cp0 *cp0 = (aci_gap_start_procedure_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 2 + 2) + { + goto fail; + } + + *status = aci_gap_start_procedure(cp0->Procedure_Code /* 1 */, + cp0->PHYs /* 1 */, + cp0->Duration /* 2 */, + cp0->Period /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xb1; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_DISCOVER_NAME_ENABLED) || ACI_GAP_DISCOVER_NAME_ENABLED) && !ACI_GAP_DISCOVER_NAME_FORCE_DISABLED +/* tBleStatus aci_gap_discover_name(uint8_t PHYs, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); + */ +/* Command len: 1 + 1 + 6 */ +/* Response len: 1 */ +uint16_t aci_gap_discover_name_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_discover_name_cp0 *cp0 = (aci_gap_discover_name_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 6) + { + goto fail; + } + + *status = aci_gap_discover_name(cp0->PHYs /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xb2; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_ADD_DEVICES_TO_FILTER_ACCEPT_AND_RESOLVING_LIST_ENABLED) || ACI_GAP_ADD_DEVICES_TO_FILTER_ACCEPT_AND_RESOLVING_LIST_ENABLED) && !ACI_GAP_ADD_DEVICES_TO_FILTER_ACCEPT_AND_RESOLVING_LIST_FORCE_DISABLED +/* tBleStatus aci_gap_add_devices_to_filter_accept_and_resolving_list(uint8_t Lists, + uint8_t Clear_Lists, + uint8_t Num_of_List_Entries, + List_Entry_t List_Entry[]); + */ +/* Command len: 1 + 1 + 1 + struct_length */ +/* Response len: 1 */ +uint16_t aci_gap_add_devices_to_filter_accept_and_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_add_devices_to_filter_accept_and_resolving_list_cp0 *cp0 = (aci_gap_add_devices_to_filter_accept_and_resolving_list_cp0 *)(buffer_in + (0)); + List_Entry_t List_Entry[HCI_MAX_PAYLOAD_SIZE/sizeof(List_Entry_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + int i; + int struct_length = 0; + if(cp0->Num_of_List_Entries > HCI_MAX_PAYLOAD_SIZE/sizeof(List_Entry_t)) + { + cp0->Num_of_List_Entries = 0; + goto fail; + } + for (i = 0; i < cp0->Num_of_List_Entries; i++) { + packed_List_Entry_t *List_Entry_tmp = (packed_List_Entry_t *)(((uint8_t *)cp0->List_Entry) + struct_length); + List_Entry[i].Peer_Address_Type = List_Entry_tmp->Peer_Address_Type; + struct_length += 1; + Osal_MemCpy((void *) &List_Entry[i].Peer_Address, (const void *) &cp0->List_Entry[i].Peer_Address, 6); + struct_length += 6; + } + if(buffer_in_length != 1 + 1 + 1 + struct_length) + { + goto fail; + } + + *status = aci_gap_add_devices_to_filter_accept_and_resolving_list(cp0->Lists /* 1 */, + cp0->Clear_Lists /* 1 */, + cp0->Num_of_List_Entries /* 1 */, + List_Entry /* struct_length */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xb3; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_CONFIGURE_FILTER_ACCEPT_AND_RESOLVING_LIST_ENABLED) || ACI_GAP_CONFIGURE_FILTER_ACCEPT_AND_RESOLVING_LIST_ENABLED) && !ACI_GAP_CONFIGURE_FILTER_ACCEPT_AND_RESOLVING_LIST_FORCE_DISABLED +/* tBleStatus aci_gap_configure_filter_accept_and_resolving_list(uint8_t Lists); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t aci_gap_configure_filter_accept_and_resolving_list_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_configure_filter_accept_and_resolving_list_cp0 *cp0 = (aci_gap_configure_filter_accept_and_resolving_list_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = aci_gap_configure_filter_accept_and_resolving_list(cp0->Lists /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xb4; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_REMOVE_ADVERTISING_SET_ENABLED) || ACI_GAP_REMOVE_ADVERTISING_SET_ENABLED) && !ACI_GAP_REMOVE_ADVERTISING_SET_FORCE_DISABLED +/* tBleStatus aci_gap_remove_advertising_set(uint8_t Advertising_Handle); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t aci_gap_remove_advertising_set_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_remove_advertising_set_cp0 *cp0 = (aci_gap_remove_advertising_set_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = aci_gap_remove_advertising_set(cp0->Advertising_Handle /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xba; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_CLEAR_ADVERTISING_SETS_ENABLED) || ACI_GAP_CLEAR_ADVERTISING_SETS_ENABLED) && !ACI_GAP_CLEAR_ADVERTISING_SETS_FORCE_DISABLED +/* tBleStatus aci_gap_clear_advertising_sets(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t aci_gap_clear_advertising_sets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = aci_gap_clear_advertising_sets(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xbb; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_CREATE_PERIODIC_ADVERTISING_CONNECTION_ENABLED) || ACI_GAP_CREATE_PERIODIC_ADVERTISING_CONNECTION_ENABLED) && !ACI_GAP_CREATE_PERIODIC_ADVERTISING_CONNECTION_FORCE_DISABLED +/* tBleStatus aci_gap_create_periodic_advertising_connection(uint8_t Advertising_Handle, + uint8_t Subevent, + uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + */ +/* Command len: 1 + 1 + 1 + 1 + 1 + 6 + 2 + 2 + 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gap_create_periodic_advertising_connection_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_create_periodic_advertising_connection_cp0 *cp0 = (aci_gap_create_periodic_advertising_connection_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1 + 1 + 1 + 1 + 1 + 6 + 2 + 2 + 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_gap_create_periodic_advertising_connection(cp0->Advertising_Handle /* 1 */, + cp0->Subevent /* 1 */, + cp0->Initiator_Filter_Policy /* 1 */, + cp0->Own_Address_Type /* 1 */, + cp0->Peer_Address_Type /* 1 */, + cp0->Peer_Address /* 6 */, + cp0->Connection_Interval_Min /* 2 */, + cp0->Connection_Interval_Max /* 2 */, + cp0->Max_Latency /* 2 */, + cp0->Supervision_Timeout /* 2 */, + cp0->Min_CE_Length /* 2 */, + cp0->Max_CE_Length /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0xca; + buffer_out[6] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_ENCRYPT_ADV_DATA_NWK_ENABLED) || ACI_GAP_ENCRYPT_ADV_DATA_NWK_ENABLED) && !ACI_GAP_ENCRYPT_ADV_DATA_NWK_FORCE_DISABLED +/* tBleStatus aci_gap_encrypt_adv_data_nwk(uint8_t Session_Key[16], + uint8_t IV[8], + uint8_t Data_Length, + uint8_t Data[], + uint8_t *Encrypted_Data_Length, + uint8_t Encrypted_Data[]); + */ +/* Command len: 16 + 8 + 1 + cp0->Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 + 1 + rp0->Encrypted_Data_Length * (sizeof(uint8_t)) */ +uint16_t aci_gap_encrypt_adv_data_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_encrypt_adv_data_nwk_cp0 *cp0 = (aci_gap_encrypt_adv_data_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_gap_encrypt_adv_data_nwk_rp0 *rp0 = (aci_gap_encrypt_adv_data_nwk_rp0 *) (buffer_out + 6); + uint8_t Encrypted_Data_Length = 0; + uint8_t Encrypted_Data[HCI_MAX_PAYLOAD_SIZE/sizeof(uint8_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 16 + 8 + 1 + cp0->Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + rp0->Status = aci_gap_encrypt_adv_data_nwk(cp0->Session_Key /* 16 */, + cp0->IV /* 8 */, + cp0->Data_Length /* 1 */, + cp0->Data /* cp0->Data_Length * (sizeof(uint8_t)) */, + &Encrypted_Data_Length, + Encrypted_Data); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->Encrypted_Data_Length = Encrypted_Data_Length; + output_size += 1; + if (buffer_out_max_length < (output_size + (rp0->Encrypted_Data_Length * (sizeof(uint8_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Encrypted_Data,(const void *) Encrypted_Data, rp0->Encrypted_Data_Length * (sizeof(uint8_t))); + output_size += rp0->Encrypted_Data_Length * (sizeof(uint8_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xcb; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GAP_DECRYPT_ADV_DATA_NWK_ENABLED) || ACI_GAP_DECRYPT_ADV_DATA_NWK_ENABLED) && !ACI_GAP_DECRYPT_ADV_DATA_NWK_FORCE_DISABLED +/* tBleStatus aci_gap_decrypt_adv_data_nwk(uint8_t Session_Key[16], + uint8_t IV[8], + uint8_t Encrypted_Data_Length, + uint8_t Encrypted_Data[], + uint8_t *Decrypted_Data_Length, + uint8_t Decrypted_Data[]); + */ +/* Command len: 16 + 8 + 1 + cp0->Encrypted_Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 + 1 + rp0->Decrypted_Data_Length * (sizeof(uint8_t)) */ +uint16_t aci_gap_decrypt_adv_data_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gap_decrypt_adv_data_nwk_cp0 *cp0 = (aci_gap_decrypt_adv_data_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_gap_decrypt_adv_data_nwk_rp0 *rp0 = (aci_gap_decrypt_adv_data_nwk_rp0 *) (buffer_out + 6); + uint8_t Decrypted_Data_Length = 0; + uint8_t Decrypted_Data[HCI_MAX_PAYLOAD_SIZE/sizeof(uint8_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 16 + 8 + 1 + cp0->Encrypted_Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + rp0->Status = aci_gap_decrypt_adv_data_nwk(cp0->Session_Key /* 16 */, + cp0->IV /* 8 */, + cp0->Encrypted_Data_Length /* 1 */, + cp0->Encrypted_Data /* cp0->Encrypted_Data_Length * (sizeof(uint8_t)) */, + &Decrypted_Data_Length, + Decrypted_Data); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->Decrypted_Data_Length = Decrypted_Data_Length; + output_size += 1; + if (buffer_out_max_length < (output_size + (rp0->Decrypted_Data_Length * (sizeof(uint8_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Decrypted_Data,(const void *) Decrypted_Data, rp0->Decrypted_Data_Length * (sizeof(uint8_t))); + output_size += rp0->Decrypted_Data_Length * (sizeof(uint8_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0xcc; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_PROFILE_INIT_ENABLED) || ACI_GATT_SRV_PROFILE_INIT_ENABLED) && !ACI_GATT_SRV_PROFILE_INIT_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_profile_init(uint8_t Characteristics, + uint16_t *Service_Changed_Handle); + */ +/* Command len: 1 */ +/* Response len: 1 + 2 */ +uint16_t aci_gatt_srv_profile_init_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_profile_init_cp0 *cp0 = (aci_gatt_srv_profile_init_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + aci_gatt_srv_profile_init_rp0 *rp0 = (aci_gatt_srv_profile_init_rp0 *) (buffer_out + 6); + uint16_t Service_Changed_Handle = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + rp0->Status = aci_gatt_srv_profile_init(cp0->Characteristics /* 1 */, + &Service_Changed_Handle); +fail: + rp0->Service_Changed_Handle = Service_Changed_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x01; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_ADD_SERVICE_NWK_ENABLED) || ACI_GATT_SRV_ADD_SERVICE_NWK_ENABLED) && !ACI_GATT_SRV_ADD_SERVICE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_add_service_nwk(uint8_t Service_UUID_Type, + Service_UUID_t *Service_UUID, + uint8_t Service_Type, + uint8_t Max_Attribute_Records, + uint16_t *Service_Handle); + */ +/* Command len: 1 + (cp0->Service_UUID_Type == 1 ? 2 : (cp0->Service_UUID_Type == 2 ? 16 : 0)) + 1 + 1 */ +/* Response len: 1 + 2 */ +uint16_t aci_gatt_srv_add_service_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_add_service_nwk_cp0 *cp0 = (aci_gatt_srv_add_service_nwk_cp0 *)(buffer_in + (0)); + aci_gatt_srv_add_service_nwk_cp1 *cp1 = (aci_gatt_srv_add_service_nwk_cp1 *)(buffer_in + (0 + 1 + (cp0->Service_UUID_Type == 1 ? 2 : (cp0->Service_UUID_Type == 2 ? 16 : 0)))); + Service_UUID_t Service_UUID; + + int output_size = 1 + 2; + /* Output params */ + aci_gatt_srv_add_service_nwk_rp0 *rp0 = (aci_gatt_srv_add_service_nwk_rp0 *) (buffer_out + 6); + uint16_t Service_Handle = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + Osal_MemCpy((void *) &Service_UUID.Service_UUID_16, (const void *) &cp0->Service_UUID.Service_UUID_16, (cp0->Service_UUID_Type == 1 ? 2 : (cp0->Service_UUID_Type == 2 ? 16 : 0))); + if(buffer_in_length != 1 + (cp0->Service_UUID_Type == 1 ? 2 : (cp0->Service_UUID_Type == 2 ? 16 : 0)) + 1 + 1) + { + goto fail; + } + + rp0->Status = aci_gatt_srv_add_service_nwk(cp0->Service_UUID_Type /* 1 */, + &Service_UUID /* (cp0->Service_UUID_Type == 1 ? 2 : (cp0->Service_UUID_Type == 2 ? 16 : 0)) */, + cp1->Service_Type /* 1 */, + cp1->Max_Attribute_Records /* 1 */, + &Service_Handle); +fail: + rp0->Service_Handle = Service_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x02; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_INCLUDE_SERVICE_NWK_ENABLED) || ACI_GATT_SRV_INCLUDE_SERVICE_NWK_ENABLED) && !ACI_GATT_SRV_INCLUDE_SERVICE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_include_service_nwk(uint16_t Service_Handle, + uint16_t Included_Service_Handle, + uint16_t *Include_Handle); + */ +/* Command len: 2 + 2 */ +/* Response len: 1 + 2 */ +uint16_t aci_gatt_srv_include_service_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_include_service_nwk_cp0 *cp0 = (aci_gatt_srv_include_service_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + aci_gatt_srv_include_service_nwk_rp0 *rp0 = (aci_gatt_srv_include_service_nwk_rp0 *) (buffer_out + 6); + uint16_t Include_Handle = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 2) + { + goto fail; + } + + rp0->Status = aci_gatt_srv_include_service_nwk(cp0->Service_Handle /* 2 */, + cp0->Included_Service_Handle /* 2 */, + &Include_Handle); +fail: + rp0->Include_Handle = Include_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x03; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_ADD_CHAR_NWK_ENABLED) || ACI_GATT_SRV_ADD_CHAR_NWK_ENABLED) && !ACI_GATT_SRV_ADD_CHAR_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_add_char_nwk(uint16_t Service_Handle, + uint8_t Char_UUID_Type, + Char_UUID_t *Char_UUID, + uint16_t Char_Value_Length, + uint8_t Char_Properties, + uint8_t Security_Permissions, + uint8_t GATT_Evt_Mask, + uint8_t Enc_Key_Size, + uint8_t Is_Variable, + uint16_t *Char_Handle); + */ +/* Command len: 2 + 1 + (cp0->Char_UUID_Type == 1 ? 2 : (cp0->Char_UUID_Type == 2 ? 16 : 0)) + 2 + 1 + 1 + 1 + 1 + 1 */ +/* Response len: 1 + 2 */ +uint16_t aci_gatt_srv_add_char_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_add_char_nwk_cp0 *cp0 = (aci_gatt_srv_add_char_nwk_cp0 *)(buffer_in + (0)); + aci_gatt_srv_add_char_nwk_cp1 *cp1 = (aci_gatt_srv_add_char_nwk_cp1 *)(buffer_in + (0 + 2 + 1 + (cp0->Char_UUID_Type == 1 ? 2 : (cp0->Char_UUID_Type == 2 ? 16 : 0)))); + Char_UUID_t Char_UUID; + + int output_size = 1 + 2; + /* Output params */ + aci_gatt_srv_add_char_nwk_rp0 *rp0 = (aci_gatt_srv_add_char_nwk_rp0 *) (buffer_out + 6); + uint16_t Char_Handle = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + Osal_MemCpy((void *) &Char_UUID.Char_UUID_16, (const void *) &cp0->Char_UUID.Char_UUID_16, (cp0->Char_UUID_Type == 1 ? 2 : (cp0->Char_UUID_Type == 2 ? 16 : 0))); + if(buffer_in_length != 2 + 1 + (cp0->Char_UUID_Type == 1 ? 2 : (cp0->Char_UUID_Type == 2 ? 16 : 0)) + 2 + 1 + 1 + 1 + 1 + 1) + { + goto fail; + } + + rp0->Status = aci_gatt_srv_add_char_nwk(cp0->Service_Handle /* 2 */, + cp0->Char_UUID_Type /* 1 */, + &Char_UUID /* (cp0->Char_UUID_Type == 1 ? 2 : (cp0->Char_UUID_Type == 2 ? 16 : 0)) */, + cp1->Char_Value_Length /* 2 */, + cp1->Char_Properties /* 1 */, + cp1->Security_Permissions /* 1 */, + cp1->GATT_Evt_Mask /* 1 */, + cp1->Enc_Key_Size /* 1 */, + cp1->Is_Variable /* 1 */, + &Char_Handle); +fail: + rp0->Char_Handle = Char_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x04; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_ADD_CHAR_DESC_NWK_ENABLED) || ACI_GATT_SRV_ADD_CHAR_DESC_NWK_ENABLED) && !ACI_GATT_SRV_ADD_CHAR_DESC_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_add_char_desc_nwk(uint16_t Char_Handle, + uint8_t Char_Desc_Uuid_Type, + Char_Desc_Uuid_t *Char_Desc_Uuid, + uint16_t Char_Desc_Value_Max_Len, + uint16_t Char_Desc_Value_Length, + uint8_t Char_Desc_Value[], + uint8_t Security_Permissions, + uint8_t Access_Permissions, + uint8_t GATT_Evt_Mask, + uint8_t Enc_Key_Size, + uint8_t Is_Variable, + uint16_t *Char_Desc_Handle); + */ +/* Command len: 2 + 1 + (cp0->Char_Desc_Uuid_Type == 1 ? 2 : (cp0->Char_Desc_Uuid_Type == 2 ? 16 : 0)) + 2 + 2 + cp1->Char_Desc_Value_Length * (sizeof(uint8_t)) + 1 + 1 + 1 + 1 + 1 */ +/* Response len: 1 + 2 */ +uint16_t aci_gatt_srv_add_char_desc_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_add_char_desc_nwk_cp0 *cp0 = (aci_gatt_srv_add_char_desc_nwk_cp0 *)(buffer_in + (0)); + aci_gatt_srv_add_char_desc_nwk_cp1 *cp1 = (aci_gatt_srv_add_char_desc_nwk_cp1 *)(buffer_in + (0 + 2 + 1 + (cp0->Char_Desc_Uuid_Type == 1 ? 2 : (cp0->Char_Desc_Uuid_Type == 2 ? 16 : 0)))); + aci_gatt_srv_add_char_desc_nwk_cp2 *cp2 = (aci_gatt_srv_add_char_desc_nwk_cp2 *)(buffer_in + (0 + 2 + 1 + (cp0->Char_Desc_Uuid_Type == 1 ? 2 : (cp0->Char_Desc_Uuid_Type == 2 ? 16 : 0)) + 2 + 2 + cp1->Char_Desc_Value_Length * (sizeof(uint8_t)))); + Char_Desc_Uuid_t Char_Desc_Uuid; + + int output_size = 1 + 2; + /* Output params */ + aci_gatt_srv_add_char_desc_nwk_rp0 *rp0 = (aci_gatt_srv_add_char_desc_nwk_rp0 *) (buffer_out + 6); + uint16_t Char_Desc_Handle = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + Osal_MemCpy((void *) &Char_Desc_Uuid.Char_UUID_16, (const void *) &cp0->Char_Desc_Uuid.Char_UUID_16, (cp0->Char_Desc_Uuid_Type == 1 ? 2 : (cp0->Char_Desc_Uuid_Type == 2 ? 16 : 0))); + if(buffer_in_length != 2 + 1 + (cp0->Char_Desc_Uuid_Type == 1 ? 2 : (cp0->Char_Desc_Uuid_Type == 2 ? 16 : 0)) + 2 + 2 + cp1->Char_Desc_Value_Length * (sizeof(uint8_t)) + 1 + 1 + 1 + 1 + 1) + { + goto fail; + } + + rp0->Status = aci_gatt_srv_add_char_desc_nwk(cp0->Char_Handle /* 2 */, + cp0->Char_Desc_Uuid_Type /* 1 */, + &Char_Desc_Uuid /* (cp0->Char_Desc_Uuid_Type == 1 ? 2 : (cp0->Char_Desc_Uuid_Type == 2 ? 16 : 0)) */, + cp1->Char_Desc_Value_Max_Len /* 2 */, + cp1->Char_Desc_Value_Length /* 2 */, + cp1->Char_Desc_Value /* cp1->Char_Desc_Value_Length * (sizeof(uint8_t)) */, + cp2->Security_Permissions /* 1 */, + cp2->Access_Permissions /* 1 */, + cp2->GATT_Evt_Mask /* 1 */, + cp2->Enc_Key_Size /* 1 */, + cp2->Is_Variable /* 1 */, + &Char_Desc_Handle); +fail: + rp0->Char_Desc_Handle = Char_Desc_Handle; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x05; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_WRITE_HANDLE_VALUE_NWK_ENABLED) || ACI_GATT_SRV_WRITE_HANDLE_VALUE_NWK_ENABLED) && !ACI_GATT_SRV_WRITE_HANDLE_VALUE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_write_handle_value_nwk(uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Value_Length, + uint8_t Value[]); + */ +/* Command len: 2 + 2 + 2 + cp0->Value_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_write_handle_value_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_write_handle_value_nwk_cp0 *cp0 = (aci_gatt_srv_write_handle_value_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + cp0->Value_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_srv_write_handle_value_nwk(cp0->Attr_Handle /* 2 */, + cp0->Val_Offset /* 2 */, + cp0->Value_Length /* 2 */, + cp0->Value /* cp0->Value_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x06; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_RM_CHAR_NWK_ENABLED) || ACI_GATT_SRV_RM_CHAR_NWK_ENABLED) && !ACI_GATT_SRV_RM_CHAR_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_rm_char_nwk(uint16_t Char_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_rm_char_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_rm_char_nwk_cp0 *cp0 = (aci_gatt_srv_rm_char_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = aci_gatt_srv_rm_char_nwk(cp0->Char_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x07; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_RM_SERVICE_NWK_ENABLED) || ACI_GATT_SRV_RM_SERVICE_NWK_ENABLED) && !ACI_GATT_SRV_RM_SERVICE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_rm_service_nwk(uint16_t Serv_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_rm_service_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_rm_service_nwk_cp0 *cp0 = (aci_gatt_srv_rm_service_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = aci_gatt_srv_rm_service_nwk(cp0->Serv_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x08; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_RM_INCLUDE_SERVICE_NWK_ENABLED) || ACI_GATT_SRV_RM_INCLUDE_SERVICE_NWK_ENABLED) && !ACI_GATT_SRV_RM_INCLUDE_SERVICE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_rm_include_service_nwk(uint16_t Include_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_rm_include_service_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_rm_include_service_nwk_cp0 *cp0 = (aci_gatt_srv_rm_include_service_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = aci_gatt_srv_rm_include_service_nwk(cp0->Include_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x09; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SET_EVENT_MASK_ENABLED) || ACI_GATT_SET_EVENT_MASK_ENABLED) && !ACI_GATT_SET_EVENT_MASK_FORCE_DISABLED +/* tBleStatus aci_gatt_set_event_mask(uint32_t GATT_Evt_Mask); + */ +/* Command len: 4 */ +/* Response len: 1 */ +uint16_t aci_gatt_set_event_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_set_event_mask_cp0 *cp0 = (aci_gatt_set_event_mask_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 4) + { + goto fail; + } + + *status = aci_gatt_set_event_mask(cp0->GATT_Evt_Mask /* 4 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x0a; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_EXCHANGE_CONFIG_ENABLED) || ACI_GATT_CLT_EXCHANGE_CONFIG_ENABLED) && !ACI_GATT_CLT_EXCHANGE_CONFIG_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_exchange_config(uint16_t Connection_Handle); + */ +/* Command len: 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_exchange_config_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_exchange_config_cp0 *cp0 = (aci_gatt_clt_exchange_config_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2) + { + goto fail; + } + + *status = aci_gatt_clt_exchange_config(cp0->Connection_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x0b; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_PREPARE_WRITE_REQ_ENABLED) || ACI_GATT_CLT_PREPARE_WRITE_REQ_ENABLED) && !ACI_GATT_CLT_PREPARE_WRITE_REQ_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_prepare_write_req(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_prepare_write_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_prepare_write_req_cp0 *cp0 = (aci_gatt_clt_prepare_write_req_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_clt_prepare_write_req(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Val_Offset /* 2 */, + cp0->Attribute_Val_Length /* 2 */, + cp0->Attribute_Val /* cp0->Attribute_Val_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x10; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_EXECUTE_WRITE_REQ_ENABLED) || ACI_GATT_CLT_EXECUTE_WRITE_REQ_ENABLED) && !ACI_GATT_CLT_EXECUTE_WRITE_REQ_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_execute_write_req(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Execute); + */ +/* Command len: 2 + 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_execute_write_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_execute_write_req_cp0 *cp0 = (aci_gatt_clt_execute_write_req_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1) + { + goto fail; + } + + *status = aci_gatt_clt_execute_write_req(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Execute /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x11; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_DISC_ALL_PRIMARY_SERVICES_ENABLED) || ACI_GATT_CLT_DISC_ALL_PRIMARY_SERVICES_ENABLED) && !ACI_GATT_CLT_DISC_ALL_PRIMARY_SERVICES_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_disc_all_primary_services(uint16_t Connection_Handle, + uint16_t CID); + */ +/* Command len: 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_disc_all_primary_services_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_disc_all_primary_services_cp0 *cp0 = (aci_gatt_clt_disc_all_primary_services_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2) + { + goto fail; + } + + *status = aci_gatt_clt_disc_all_primary_services(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x12; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_DISC_PRIMARY_SERVICE_BY_UUID_ENABLED) || ACI_GATT_CLT_DISC_PRIMARY_SERVICE_BY_UUID_ENABLED) && !ACI_GATT_CLT_DISC_PRIMARY_SERVICE_BY_UUID_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_disc_primary_service_by_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint8_t UUID_Type, + UUID_t *UUID); + */ +/* Command len: 2 + 2 + 1 + (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_disc_primary_service_by_uuid_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_disc_primary_service_by_uuid_cp0 *cp0 = (aci_gatt_clt_disc_primary_service_by_uuid_cp0 *)(buffer_in + (0)); + UUID_t UUID; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + Osal_MemCpy((void *) &UUID.UUID_16, (const void *) &cp0->UUID.UUID_16, (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0))); + if(buffer_in_length != 2 + 2 + 1 + (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0))) + { + goto fail; + } + + *status = aci_gatt_clt_disc_primary_service_by_uuid(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->UUID_Type /* 1 */, + &UUID /* (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x13; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_FIND_INCLUDED_SERVICES_ENABLED) || ACI_GATT_CLT_FIND_INCLUDED_SERVICES_ENABLED) && !ACI_GATT_CLT_FIND_INCLUDED_SERVICES_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_find_included_services(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle); + */ +/* Command len: 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_find_included_services_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_find_included_services_cp0 *cp0 = (aci_gatt_clt_find_included_services_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_gatt_clt_find_included_services(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Start_Handle /* 2 */, + cp0->End_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x14; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_DISC_ALL_CHAR_OF_SERVICE_ENABLED) || ACI_GATT_CLT_DISC_ALL_CHAR_OF_SERVICE_ENABLED) && !ACI_GATT_CLT_DISC_ALL_CHAR_OF_SERVICE_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_disc_all_char_of_service(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle); + */ +/* Command len: 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_disc_all_char_of_service_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_disc_all_char_of_service_cp0 *cp0 = (aci_gatt_clt_disc_all_char_of_service_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_gatt_clt_disc_all_char_of_service(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Start_Handle /* 2 */, + cp0->End_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x15; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_DISC_CHAR_BY_UUID_ENABLED) || ACI_GATT_CLT_DISC_CHAR_BY_UUID_ENABLED) && !ACI_GATT_CLT_DISC_CHAR_BY_UUID_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_disc_char_by_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle, + uint8_t UUID_Type, + UUID_t *UUID); + */ +/* Command len: 2 + 2 + 2 + 2 + 1 + (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_disc_char_by_uuid_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_disc_char_by_uuid_cp0 *cp0 = (aci_gatt_clt_disc_char_by_uuid_cp0 *)(buffer_in + (0)); + UUID_t UUID; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + Osal_MemCpy((void *) &UUID.UUID_16, (const void *) &cp0->UUID.UUID_16, (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0))); + if(buffer_in_length != 2 + 2 + 2 + 2 + 1 + (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0))) + { + goto fail; + } + + *status = aci_gatt_clt_disc_char_by_uuid(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Start_Handle /* 2 */, + cp0->End_Handle /* 2 */, + cp0->UUID_Type /* 1 */, + &UUID /* (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x16; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_DISC_ALL_CHAR_DESC_ENABLED) || ACI_GATT_CLT_DISC_ALL_CHAR_DESC_ENABLED) && !ACI_GATT_CLT_DISC_ALL_CHAR_DESC_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_disc_all_char_desc(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Char_Handle, + uint16_t End_Handle); + */ +/* Command len: 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_disc_all_char_desc_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_disc_all_char_desc_cp0 *cp0 = (aci_gatt_clt_disc_all_char_desc_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_gatt_clt_disc_all_char_desc(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Char_Handle /* 2 */, + cp0->End_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x17; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_READ_ENABLED) || ACI_GATT_CLT_READ_ENABLED) && !ACI_GATT_CLT_READ_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_read(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle); + */ +/* Command len: 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_read_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_read_cp0 *cp0 = (aci_gatt_clt_read_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2) + { + goto fail; + } + + *status = aci_gatt_clt_read(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x18; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_READ_USING_CHAR_UUID_ENABLED) || ACI_GATT_CLT_READ_USING_CHAR_UUID_ENABLED) && !ACI_GATT_CLT_READ_USING_CHAR_UUID_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_read_using_char_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle, + uint8_t UUID_Type, + UUID_t *UUID); + */ +/* Command len: 2 + 2 + 2 + 2 + 1 + (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_read_using_char_uuid_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_read_using_char_uuid_cp0 *cp0 = (aci_gatt_clt_read_using_char_uuid_cp0 *)(buffer_in + (0)); + UUID_t UUID; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + Osal_MemCpy((void *) &UUID.UUID_16, (const void *) &cp0->UUID.UUID_16, (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0))); + if(buffer_in_length != 2 + 2 + 2 + 2 + 1 + (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0))) + { + goto fail; + } + + *status = aci_gatt_clt_read_using_char_uuid(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Start_Handle /* 2 */, + cp0->End_Handle /* 2 */, + cp0->UUID_Type /* 1 */, + &UUID /* (cp0->UUID_Type == 1 ? 2 : (cp0->UUID_Type == 2 ? 16 : 0)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x19; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_READ_LONG_ENABLED) || ACI_GATT_CLT_READ_LONG_ENABLED) && !ACI_GATT_CLT_READ_LONG_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_read_long(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset); + */ +/* Command len: 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_read_long_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_read_long_cp0 *cp0 = (aci_gatt_clt_read_long_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_gatt_clt_read_long(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Val_Offset /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x1a; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_READ_MULTIPLE_CHAR_VALUE_ENABLED) || ACI_GATT_CLT_READ_MULTIPLE_CHAR_VALUE_ENABLED) && !ACI_GATT_CLT_READ_MULTIPLE_CHAR_VALUE_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_read_multiple_char_value(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Number_of_Handles, + uint16_t Handle[]); + */ +/* Command len: 2 + 2 + 1 + cp0->Number_of_Handles * (sizeof(uint16_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_read_multiple_char_value_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_read_multiple_char_value_cp0 *cp0 = (aci_gatt_clt_read_multiple_char_value_cp0 *)(buffer_in + (0)); + uint16_t Handle[HCI_MAX_PAYLOAD_SIZE/sizeof(uint16_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + Osal_MemCpy(Handle, cp0->Handle, cp0->Number_of_Handles * (sizeof(uint16_t))); + if(buffer_in_length != 2 + 2 + 1 + cp0->Number_of_Handles * (sizeof(uint16_t))) + { + goto fail; + } + + *status = aci_gatt_clt_read_multiple_char_value(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Number_of_Handles /* 1 */, + Handle /* cp0->Number_of_Handles * (sizeof(uint16_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x1b; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_WRITE_NWK_ENABLED) || ACI_GATT_CLT_WRITE_NWK_ENABLED) && !ACI_GATT_CLT_WRITE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_write_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); + */ +/* Command len: 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_write_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_write_nwk_cp0 *cp0 = (aci_gatt_clt_write_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_clt_write_nwk(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Attribute_Val_Length /* 2 */, + cp0->Attribute_Val /* cp0->Attribute_Val_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x1c; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_WRITE_LONG_NWK_ENABLED) || ACI_GATT_CLT_WRITE_LONG_NWK_ENABLED) && !ACI_GATT_CLT_WRITE_LONG_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_write_long_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_write_long_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_write_long_nwk_cp0 *cp0 = (aci_gatt_clt_write_long_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_clt_write_long_nwk(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Val_Offset /* 2 */, + cp0->Attribute_Val_Length /* 2 */, + cp0->Attribute_Val /* cp0->Attribute_Val_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x1d; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_WRITE_CHAR_RELIABLE_NWK_ENABLED) || ACI_GATT_CLT_WRITE_CHAR_RELIABLE_NWK_ENABLED) && !ACI_GATT_CLT_WRITE_CHAR_RELIABLE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_write_char_reliable_nwk(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_write_char_reliable_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_write_char_reliable_nwk_cp0 *cp0 = (aci_gatt_clt_write_char_reliable_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_clt_write_char_reliable_nwk(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Val_Offset /* 2 */, + cp0->Attribute_Val_Length /* 2 */, + cp0->Attribute_Val /* cp0->Attribute_Val_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x1e; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_WRITE_WITHOUT_RESP_ENABLED) || ACI_GATT_CLT_WRITE_WITHOUT_RESP_ENABLED) && !ACI_GATT_CLT_WRITE_WITHOUT_RESP_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_write_without_resp(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); + */ +/* Command len: 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_write_without_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_write_without_resp_cp0 *cp0 = (aci_gatt_clt_write_without_resp_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_clt_write_without_resp(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Attribute_Val_Length /* 2 */, + cp0->Attribute_Val /* cp0->Attribute_Val_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x23; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_SIGNED_WRITE_WITHOUT_RESP_ENABLED) || ACI_GATT_CLT_SIGNED_WRITE_WITHOUT_RESP_ENABLED) && !ACI_GATT_CLT_SIGNED_WRITE_WITHOUT_RESP_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_signed_write_without_resp(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); + */ +/* Command len: 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_signed_write_without_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_signed_write_without_resp_cp0 *cp0 = (aci_gatt_clt_signed_write_without_resp_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + cp0->Attribute_Val_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_clt_signed_write_without_resp(cp0->Connection_Handle /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Attribute_Val_Length /* 2 */, + cp0->Attribute_Val /* cp0->Attribute_Val_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x24; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_CONFIRM_INDICATION_ENABLED) || ACI_GATT_CLT_CONFIRM_INDICATION_ENABLED) && !ACI_GATT_CLT_CONFIRM_INDICATION_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_confirm_indication(uint16_t Connection_Handle, + uint16_t CID); + */ +/* Command len: 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_confirm_indication_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_confirm_indication_cp0 *cp0 = (aci_gatt_clt_confirm_indication_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2) + { + goto fail; + } + + *status = aci_gatt_clt_confirm_indication(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x25; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_SET_SECURITY_PERMISSION_NWK_ENABLED) || ACI_GATT_SRV_SET_SECURITY_PERMISSION_NWK_ENABLED) && !ACI_GATT_SRV_SET_SECURITY_PERMISSION_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_set_security_permission_nwk(uint16_t Attr_Handle, + uint8_t Security_Permissions); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_set_security_permission_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_set_security_permission_nwk_cp0 *cp0 = (aci_gatt_srv_set_security_permission_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = aci_gatt_srv_set_security_permission_nwk(cp0->Attr_Handle /* 2 */, + cp0->Security_Permissions /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x28; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_READ_HANDLE_VALUE_NWK_ENABLED) || ACI_GATT_SRV_READ_HANDLE_VALUE_NWK_ENABLED) && !ACI_GATT_SRV_READ_HANDLE_VALUE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_read_handle_value_nwk(uint16_t Attr_Handle, + uint16_t Offset, + uint16_t Value_Length_Requested, + uint16_t *Length, + uint16_t *Value_Length, + uint8_t Value[]); + */ +/* Command len: 2 + 2 + 2 */ +/* Response len: 1 + 2 + 2 + rp0->Value_Length * (sizeof(uint8_t)) */ +uint16_t aci_gatt_srv_read_handle_value_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_read_handle_value_nwk_cp0 *cp0 = (aci_gatt_srv_read_handle_value_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_gatt_srv_read_handle_value_nwk_rp0 *rp0 = (aci_gatt_srv_read_handle_value_nwk_rp0 *) (buffer_out + 6); + uint16_t Length = 0; + uint16_t Value_Length = 0; + uint8_t Value[HCI_MAX_PAYLOAD_SIZE/sizeof(uint8_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2) + { + goto fail; + } + + rp0->Status = aci_gatt_srv_read_handle_value_nwk(cp0->Attr_Handle /* 2 */, + cp0->Offset /* 2 */, + cp0->Value_Length_Requested /* 2 */, + &Length, + &Value_Length, + Value); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (2) + 6)) { return 0; } + rp0->Length = Length; + output_size += 2; + if (buffer_out_max_length < (output_size + (2) + 6)) { return 0; } + rp0->Value_Length = Value_Length; + output_size += 2; + if (buffer_out_max_length < (output_size + (rp0->Value_Length * (sizeof(uint8_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Value,(const void *) Value, rp0->Value_Length * (sizeof(uint8_t))); + output_size += rp0->Value_Length * (sizeof(uint8_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2a; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_SET_ACCESS_PERMISSION_NWK_ENABLED) || ACI_GATT_SRV_SET_ACCESS_PERMISSION_NWK_ENABLED) && !ACI_GATT_SRV_SET_ACCESS_PERMISSION_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_set_access_permission_nwk(uint16_t Attr_Handle, + uint8_t Access_Permissions); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_set_access_permission_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_set_access_permission_nwk_cp0 *cp0 = (aci_gatt_srv_set_access_permission_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + *status = aci_gatt_srv_set_access_permission_nwk(cp0->Attr_Handle /* 2 */, + cp0->Access_Permissions /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2e; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_NOTIFY_ENABLED) || ACI_GATT_SRV_NOTIFY_ENABLED) && !ACI_GATT_SRV_NOTIFY_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_notify(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Flags, + uint16_t Val_Length, + uint8_t Val[]); + */ +/* Command len: 2 + 2 + 2 + 1 + 2 + cp0->Val_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_notify_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_notify_cp0 *cp0 = (aci_gatt_srv_notify_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 1 + 2 + cp0->Val_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_srv_notify(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Flags /* 1 */, + cp0->Val_Length /* 2 */, + cp0->Val /* cp0->Val_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x2f; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_EXEC_WRITE_RESP_NWK_ENABLED) || ACI_GATT_SRV_EXEC_WRITE_RESP_NWK_ENABLED) && !ACI_GATT_SRV_EXEC_WRITE_RESP_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_exec_write_resp_nwk(uint16_t Conn_Handle, + uint16_t CID, + uint8_t Exec); + */ +/* Command len: 2 + 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_exec_write_resp_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_exec_write_resp_nwk_cp0 *cp0 = (aci_gatt_srv_exec_write_resp_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1) + { + goto fail; + } + + *status = aci_gatt_srv_exec_write_resp_nwk(cp0->Conn_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Exec /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x31; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_AUTHORIZE_RESP_NWK_ENABLED) || ACI_GATT_SRV_AUTHORIZE_RESP_NWK_ENABLED) && !ACI_GATT_SRV_AUTHORIZE_RESP_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_authorize_resp_nwk(uint16_t Conn_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Operation_Type, + uint8_t Error_Code, + uint16_t Attr_Val_Offset, + uint16_t Data_Length, + uint8_t Data[]); + */ +/* Command len: 2 + 2 + 2 + 1 + 1 + 2 + 2 + cp0->Data_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_authorize_resp_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_authorize_resp_nwk_cp0 *cp0 = (aci_gatt_srv_authorize_resp_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 1 + 1 + 2 + 2 + cp0->Data_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_srv_authorize_resp_nwk(cp0->Conn_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Operation_Type /* 1 */, + cp0->Error_Code /* 1 */, + cp0->Attr_Val_Offset /* 2 */, + cp0->Data_Length /* 2 */, + cp0->Data /* cp0->Data_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x33; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_READ_PREPARE_QUEUE_NWK_ENABLED) || ACI_GATT_SRV_READ_PREPARE_QUEUE_NWK_ENABLED) && !ACI_GATT_SRV_READ_PREPARE_QUEUE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_read_prepare_queue_nwk(uint16_t Conn_Handle, + uint8_t Item_Index, + uint16_t *Attr_Handle, + uint16_t *Value_Offset, + uint16_t *Value_Length, + uint8_t Value[]); + */ +/* Command len: 2 + 1 */ +/* Response len: 1 + 2 + 2 + 2 + rp0->Value_Length * (sizeof(uint8_t)) */ +uint16_t aci_gatt_srv_read_prepare_queue_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_read_prepare_queue_nwk_cp0 *cp0 = (aci_gatt_srv_read_prepare_queue_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_gatt_srv_read_prepare_queue_nwk_rp0 *rp0 = (aci_gatt_srv_read_prepare_queue_nwk_rp0 *) (buffer_out + 6); + uint16_t Attr_Handle = 0; + uint16_t Value_Offset = 0; + uint16_t Value_Length = 0; + uint8_t Value[HCI_MAX_PAYLOAD_SIZE/sizeof(uint8_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1) + { + goto fail; + } + + rp0->Status = aci_gatt_srv_read_prepare_queue_nwk(cp0->Conn_Handle /* 2 */, + cp0->Item_Index /* 1 */, + &Attr_Handle, + &Value_Offset, + &Value_Length, + Value); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (2) + 6)) { return 0; } + rp0->Attr_Handle = Attr_Handle; + output_size += 2; + if (buffer_out_max_length < (output_size + (2) + 6)) { return 0; } + rp0->Value_Offset = Value_Offset; + output_size += 2; + if (buffer_out_max_length < (output_size + (2) + 6)) { return 0; } + rp0->Value_Length = Value_Length; + output_size += 2; + if (buffer_out_max_length < (output_size + (rp0->Value_Length * (sizeof(uint8_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Value,(const void *) Value, rp0->Value_Length * (sizeof(uint8_t))); + output_size += rp0->Value_Length * (sizeof(uint8_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x35; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_WRITE_MULTIPLE_INSTANCE_HANDLE_VALUE_ENABLED) || ACI_GATT_SRV_WRITE_MULTIPLE_INSTANCE_HANDLE_VALUE_ENABLED) && !ACI_GATT_SRV_WRITE_MULTIPLE_INSTANCE_HANDLE_VALUE_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_write_multiple_instance_handle_value(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Value_Length, + uint8_t Value[]); + */ +/* Command len: 2 + 2 + 2 + cp0->Value_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_write_multiple_instance_handle_value_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_write_multiple_instance_handle_value_cp0 *cp0 = (aci_gatt_srv_write_multiple_instance_handle_value_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + cp0->Value_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_gatt_srv_write_multiple_instance_handle_value(cp0->Connection_Handle /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Value_Length /* 2 */, + cp0->Value /* cp0->Value_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x36; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_READ_MULTIPLE_INSTANCE_HANDLE_VALUE_NWK_ENABLED) || ACI_GATT_SRV_READ_MULTIPLE_INSTANCE_HANDLE_VALUE_NWK_ENABLED) && !ACI_GATT_SRV_READ_MULTIPLE_INSTANCE_HANDLE_VALUE_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_read_multiple_instance_handle_value_nwk(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t *Value_Length, + uint8_t Value[]); + */ +/* Command len: 2 + 2 */ +/* Response len: 1 + 2 + rp0->Value_Length * (sizeof(uint8_t)) */ +uint16_t aci_gatt_srv_read_multiple_instance_handle_value_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_read_multiple_instance_handle_value_nwk_cp0 *cp0 = (aci_gatt_srv_read_multiple_instance_handle_value_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_gatt_srv_read_multiple_instance_handle_value_nwk_rp0 *rp0 = (aci_gatt_srv_read_multiple_instance_handle_value_nwk_rp0 *) (buffer_out + 6); + uint16_t Value_Length = 0; + uint8_t Value[HCI_MAX_PAYLOAD_SIZE/sizeof(uint8_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2) + { + goto fail; + } + + rp0->Status = aci_gatt_srv_read_multiple_instance_handle_value_nwk(cp0->Connection_Handle /* 2 */, + cp0->Attr_Handle /* 2 */, + &Value_Length, + Value); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (2) + 6)) { return 0; } + rp0->Value_Length = Value_Length; + output_size += 2; + if (buffer_out_max_length < (output_size + (rp0->Value_Length * (sizeof(uint8_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->Value,(const void *) Value, rp0->Value_Length * (sizeof(uint8_t))); + output_size += rp0->Value_Length * (sizeof(uint8_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x37; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_SRV_MULTI_NOTIFY_ENABLED) || ACI_GATT_SRV_MULTI_NOTIFY_ENABLED) && !ACI_GATT_SRV_MULTI_NOTIFY_FORCE_DISABLED +/* tBleStatus aci_gatt_srv_multi_notify(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Flags, + uint8_t Num_Of_Attr, + Gatt_Srv_Notify_Attr_t Gatt_Srv_Notify_Attr[]); + */ +/* Command len: 2 + 2 + 1 + 1 + struct_length */ +/* Response len: 1 */ +uint16_t aci_gatt_srv_multi_notify_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_srv_multi_notify_cp0 *cp0 = (aci_gatt_srv_multi_notify_cp0 *)(buffer_in + (0)); + Gatt_Srv_Notify_Attr_t Gatt_Srv_Notify_Attr[HCI_MAX_PAYLOAD_SIZE/sizeof(Gatt_Srv_Notify_Attr_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + int i; + int struct_length = 0; + if(cp0->Num_Of_Attr > HCI_MAX_PAYLOAD_SIZE/sizeof(Gatt_Srv_Notify_Attr_t)) + { + cp0->Num_Of_Attr = 0; + goto fail; + } + for (i = 0; i < cp0->Num_Of_Attr; i++) { + packed_Gatt_Srv_Notify_Attr_t *Gatt_Srv_Notify_Attr_tmp = (packed_Gatt_Srv_Notify_Attr_t *)(((uint8_t *)cp0->Gatt_Srv_Notify_Attr) + struct_length); + Gatt_Srv_Notify_Attr[i].Handle = Gatt_Srv_Notify_Attr_tmp->Handle; + struct_length += 2; + Gatt_Srv_Notify_Attr[i].Val_Length = Gatt_Srv_Notify_Attr_tmp->Val_Length; + struct_length += 2; + Gatt_Srv_Notify_Attr[i].Val = Gatt_Srv_Notify_Attr_tmp->Val; + struct_length += Gatt_Srv_Notify_Attr_tmp->Val_Length; + } + if(buffer_in_length != 2 + 2 + 1 + 1 + struct_length) + { + goto fail; + } + + *status = aci_gatt_srv_multi_notify(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Flags /* 1 */, + cp0->Num_Of_Attr /* 1 */, + Gatt_Srv_Notify_Attr /* struct_length */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x38; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_GATT_CLT_READ_MULTIPLE_VAR_LEN_CHAR_VALUE_ENABLED) || ACI_GATT_CLT_READ_MULTIPLE_VAR_LEN_CHAR_VALUE_ENABLED) && !ACI_GATT_CLT_READ_MULTIPLE_VAR_LEN_CHAR_VALUE_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_read_multiple_var_len_char_value(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Number_of_Handles, + uint16_t Handle[]); + */ +/* Command len: 2 + 2 + 1 + cp0->Number_of_Handles * (sizeof(uint16_t)) */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_read_multiple_var_len_char_value_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_read_multiple_var_len_char_value_cp0 *cp0 = (aci_gatt_clt_read_multiple_var_len_char_value_cp0 *)(buffer_in + (0)); + uint16_t Handle[HCI_MAX_PAYLOAD_SIZE/sizeof(uint16_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + Osal_MemCpy(Handle, cp0->Handle, cp0->Number_of_Handles * (sizeof(uint16_t))); + if(buffer_in_length != 2 + 2 + 1 + cp0->Number_of_Handles * (sizeof(uint16_t))) + { + goto fail; + } + + *status = aci_gatt_clt_read_multiple_var_len_char_value(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->Number_of_Handles /* 1 */, + Handle /* cp0->Number_of_Handles * (sizeof(uint16_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x39; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED) || ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED) && !ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_FORCE_DISABLED +/* tBleStatus aci_l2cap_connection_parameter_update_req(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Peripheral_Latency, + uint16_t Timeout_Multiplier); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_l2cap_connection_parameter_update_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_connection_parameter_update_req_cp0 *cp0 = (aci_l2cap_connection_parameter_update_req_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_l2cap_connection_parameter_update_req(cp0->Connection_Handle /* 2 */, + cp0->Connection_Interval_Min /* 2 */, + cp0->Connection_Interval_Max /* 2 */, + cp0->Peripheral_Latency /* 2 */, + cp0->Timeout_Multiplier /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x81; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_RESP_ENABLED) || ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_RESP_ENABLED) && !ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_RESP_FORCE_DISABLED +/* tBleStatus aci_l2cap_connection_parameter_update_resp(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Peripheral_Latency, + uint16_t Timeout_Multiplier, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length, + uint8_t Identifier, + uint8_t Accept); + */ +/* Command len: 2 + 2 + 2 + 2 + 2 + 2 + 2 + 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_l2cap_connection_parameter_update_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_connection_parameter_update_resp_cp0 *cp0 = (aci_l2cap_connection_parameter_update_resp_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 2 + 2 + 2 + 1 + 1) + { + goto fail; + } + + *status = aci_l2cap_connection_parameter_update_resp(cp0->Connection_Handle /* 2 */, + cp0->Connection_Interval_Min /* 2 */, + cp0->Connection_Interval_Max /* 2 */, + cp0->Peripheral_Latency /* 2 */, + cp0->Timeout_Multiplier /* 2 */, + cp0->Min_CE_Length /* 2 */, + cp0->Max_CE_Length /* 2 */, + cp0->Identifier /* 1 */, + cp0->Accept /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x82; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_L2CAP_COS_CONNECTION_REQ_ENABLED) || ACI_L2CAP_COS_CONNECTION_REQ_ENABLED) && !ACI_L2CAP_COS_CONNECTION_REQ_FORCE_DISABLED +/* tBleStatus aci_l2cap_cos_connection_req(uint16_t Connection_Handle, + uint16_t SPSM, + uint16_t MTU, + uint16_t MPS, + uint8_t Channel_Type, + uint8_t CID_Count); + */ +/* Command len: 2 + 2 + 2 + 2 + 1 + 1 */ +/* Response len: 1 */ +uint16_t aci_l2cap_cos_connection_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_cos_connection_req_cp0 *cp0 = (aci_l2cap_cos_connection_req_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2 + 1 + 1) + { + goto fail; + } + + *status = aci_l2cap_cos_connection_req(cp0->Connection_Handle /* 2 */, + cp0->SPSM /* 2 */, + cp0->MTU /* 2 */, + cp0->MPS /* 2 */, + cp0->Channel_Type /* 1 */, + cp0->CID_Count /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x83; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_L2CAP_COS_CONNECTION_RESP_ENABLED) || ACI_L2CAP_COS_CONNECTION_RESP_ENABLED) && !ACI_L2CAP_COS_CONNECTION_RESP_FORCE_DISABLED +/* tBleStatus aci_l2cap_cos_connection_resp(uint16_t Connection_Handle, + uint8_t Identifier, + uint16_t MTU, + uint16_t MPS, + uint16_t Result, + uint8_t CID_Count, + uint16_t CID[]); + */ +/* Command len: 2 + 1 + 2 + 2 + 2 + 1 */ +/* Response len: 1 + 1 + rp0->CID_Count * (sizeof(uint16_t)) */ +uint16_t aci_l2cap_cos_connection_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_cos_connection_resp_cp0 *cp0 = (aci_l2cap_cos_connection_resp_cp0 *)(buffer_in + (0)); + + int output_size = 0; + /* Output params */ + aci_l2cap_cos_connection_resp_rp0 *rp0 = (aci_l2cap_cos_connection_resp_rp0 *) (buffer_out + 6); + uint16_t CID[HCI_MAX_PAYLOAD_SIZE/sizeof(uint16_t)] = {0}; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 2 + 2 + 2 + 1) + { + goto fail; + } + + rp0->Status = aci_l2cap_cos_connection_resp(cp0->Connection_Handle /* 2 */, + cp0->Identifier /* 1 */, + cp0->MTU /* 2 */, + cp0->MPS /* 2 */, + cp0->Result /* 2 */, + cp0->CID_Count /* 1 */, + CID); +fail: + output_size += 1; + if (buffer_out_max_length < (output_size + (1) + 6)) { return 0; } + rp0->CID_Count = cp0->CID_Count; + output_size += 1; + if (buffer_out_max_length < (output_size + (rp0->CID_Count * (sizeof(uint16_t))) + 6)) { return 0; } + Osal_MemCpy((void *) rp0->CID,(const void *) CID, rp0->CID_Count * (sizeof(uint16_t))); + output_size += rp0->CID_Count * (sizeof(uint16_t)); + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x84; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED) || ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED) && !ACI_L2CAP_COS_DISCONNECT_REQ_FORCE_DISABLED +/* tBleStatus aci_l2cap_cos_disconnect_req(uint16_t Connection_Handle, + uint16_t CID); + */ +/* Command len: 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_l2cap_cos_disconnect_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_cos_disconnect_req_cp0 *cp0 = (aci_l2cap_cos_disconnect_req_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 3); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2) + { + goto fail; + } + + *status = aci_l2cap_cos_disconnect_req(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = output_size + 3; + buffer_out[4] = 0x01; + buffer_out[5] = 0x86; + buffer_out[6] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_L2CAP_COS_SDU_DATA_TRANSMIT_ENABLED) || ACI_L2CAP_COS_SDU_DATA_TRANSMIT_ENABLED) && !ACI_L2CAP_COS_SDU_DATA_TRANSMIT_FORCE_DISABLED +/* tBleStatus aci_l2cap_cos_sdu_data_transmit(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Length, + uint8_t SDU_Data[]); + */ +/* Command len: 2 + 2 + 2 + cp0->SDU_Length * (sizeof(uint8_t)) */ +/* Response len: 1 */ +uint16_t aci_l2cap_cos_sdu_data_transmit_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_cos_sdu_data_transmit_cp0 *cp0 = (aci_l2cap_cos_sdu_data_transmit_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + cp0->SDU_Length * (sizeof(uint8_t))) + { + goto fail; + } + + *status = aci_l2cap_cos_sdu_data_transmit(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->SDU_Length /* 2 */, + cp0->SDU_Data /* cp0->SDU_Length * (sizeof(uint8_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x87; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_L2CAP_COS_RECONFIGURE_REQ_ENABLED) || ACI_L2CAP_COS_RECONFIGURE_REQ_ENABLED) && !ACI_L2CAP_COS_RECONFIGURE_REQ_FORCE_DISABLED +/* tBleStatus aci_l2cap_cos_reconfigure_req(uint16_t Connection_Handle, + uint16_t MTU, + uint16_t MPS, + uint8_t CID_Count, + uint16_t CID[]); + */ +/* Command len: 2 + 2 + 2 + 1 + cp0->CID_Count * (sizeof(uint16_t)) */ +/* Response len: 1 */ +uint16_t aci_l2cap_cos_reconfigure_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_cos_reconfigure_req_cp0 *cp0 = (aci_l2cap_cos_reconfigure_req_cp0 *)(buffer_in + (0)); + uint16_t CID[HCI_MAX_PAYLOAD_SIZE/sizeof(uint16_t)]; + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + Osal_MemCpy(CID, cp0->CID, cp0->CID_Count * (sizeof(uint16_t))); + if(buffer_in_length != 2 + 2 + 2 + 1 + cp0->CID_Count * (sizeof(uint16_t))) + { + goto fail; + } + + *status = aci_l2cap_cos_reconfigure_req(cp0->Connection_Handle /* 2 */, + cp0->MTU /* 2 */, + cp0->MPS /* 2 */, + cp0->CID_Count /* 1 */, + CID /* cp0->CID_Count * (sizeof(uint16_t)) */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x8a; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_L2CAP_COS_RECONFIGURE_RESP_ENABLED) || ACI_L2CAP_COS_RECONFIGURE_RESP_ENABLED) && !ACI_L2CAP_COS_RECONFIGURE_RESP_FORCE_DISABLED +/* tBleStatus aci_l2cap_cos_reconfigure_resp(uint16_t Connection_Handle, + uint8_t Identifier, + uint16_t Result); + */ +/* Command len: 2 + 1 + 2 */ +/* Response len: 1 */ +uint16_t aci_l2cap_cos_reconfigure_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_cos_reconfigure_resp_cp0 *cp0 = (aci_l2cap_cos_reconfigure_resp_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 1 + 2) + { + goto fail; + } + + *status = aci_l2cap_cos_reconfigure_resp(cp0->Connection_Handle /* 2 */, + cp0->Identifier /* 1 */, + cp0->Result /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x8b; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_TEST_TX_NOTIFICATION_START_ENABLED) || ACI_TEST_TX_NOTIFICATION_START_ENABLED) && !ACI_TEST_TX_NOTIFICATION_START_FORCE_DISABLED +/* tBleStatus aci_test_tx_notification_start(uint16_t Connection_Handle, + uint16_t Service_Handle, + uint16_t Char_Handle, + uint16_t Value_Length); + */ +/* Command len: 2 + 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_test_tx_notification_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_test_tx_notification_start_cp0 *cp0 = (aci_test_tx_notification_start_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 2) + { + goto fail; + } + + *status = aci_test_tx_notification_start(cp0->Connection_Handle /* 2 */, + cp0->Service_Handle /* 2 */, + cp0->Char_Handle /* 2 */, + cp0->Value_Length /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x00; + buffer_out[5] = 0xfe; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_TEST_TX_WRITE_COMMAND_START_ENABLED) || ACI_TEST_TX_WRITE_COMMAND_START_ENABLED) && !ACI_TEST_TX_WRITE_COMMAND_START_FORCE_DISABLED +/* tBleStatus aci_test_tx_write_command_start(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Value_Length); + */ +/* Command len: 2 + 2 + 2 */ +/* Response len: 1 */ +uint16_t aci_test_tx_write_command_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_test_tx_write_command_start_cp0 *cp0 = (aci_test_tx_write_command_start_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2) + { + goto fail; + } + + *status = aci_test_tx_write_command_start(cp0->Connection_Handle /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Value_Length /* 2 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x01; + buffer_out[5] = 0xfe; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_TEST_RX_START_ENABLED) || ACI_TEST_RX_START_ENABLED) && !ACI_TEST_RX_START_FORCE_DISABLED +/* tBleStatus aci_test_rx_start(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint8_t Notifications_WriteCmds); + */ +/* Command len: 2 + 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_test_rx_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_test_rx_start_cp0 *cp0 = (aci_test_rx_start_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1) + { + goto fail; + } + + *status = aci_test_rx_start(cp0->Connection_Handle /* 2 */, + cp0->Attr_Handle /* 2 */, + cp0->Notifications_WriteCmds /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x02; + buffer_out[5] = 0xfe; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_TEST_STOP_ENABLED) || ACI_TEST_STOP_ENABLED) && !ACI_TEST_STOP_FORCE_DISABLED +/* tBleStatus aci_test_stop(uint8_t TX_RX); + */ +/* Command len: 1 */ +/* Response len: 1 */ +uint16_t aci_test_stop_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_test_stop_cp0 *cp0 = (aci_test_stop_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 1) + { + goto fail; + } + + *status = aci_test_stop(cp0->TX_RX /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x03; + buffer_out[5] = 0xfe; + return (output_size + 6); +} +#endif + +#if (!defined(ACI_TEST_REPORT_ENABLED) || ACI_TEST_REPORT_ENABLED) && !ACI_TEST_REPORT_FORCE_DISABLED +/* tBleStatus aci_test_report(uint32_t *TX_Packets, + uint32_t *RX_Packets, + uint16_t *RX_Data_Length, + uint32_t *RX_Sequence_Errors); + */ +/* Command len: 0 */ +/* Response len: 1 + 4 + 4 + 2 + 4 */ +uint16_t aci_test_report_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1 + 4 + 4 + 2 + 4; + /* Output params */ + aci_test_report_rp0 *rp0 = (aci_test_report_rp0 *) (buffer_out + 6); + uint32_t TX_Packets = 0; + uint32_t RX_Packets = 0; + uint16_t RX_Data_Length = 0; + uint32_t RX_Sequence_Errors = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 4 + 4 + 2 + 4 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + rp0->Status = aci_test_report(&TX_Packets, + &RX_Packets, + &RX_Data_Length, + &RX_Sequence_Errors); +fail: + rp0->TX_Packets = TX_Packets; + rp0->RX_Packets = RX_Packets; + rp0->RX_Data_Length = RX_Data_Length; + rp0->RX_Sequence_Errors = RX_Sequence_Errors; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x04; + buffer_out[5] = 0xfe; + return (output_size + 6); +} +#endif + +#endif /* if BLESTACK_CONTROLLER_ONLY==0 */ +/* aci_blue_initialized_event */ +/* Event len: 1 */ +/** + * @brief This event inform the application that the network coprocessor has + * been reset. If the reason code is a system crash, a following event + * @ref aci_blue_crash_info_event will provide more information regarding + * the system crash details. + * @param Reason_Code Reason code describing why device was reset and in which + * mode is operating (Updater or Normal mode) + * Values: + * - 0x01: Firmware started properly + * - 0x02: Updater mode entered with ACI command + * - 0x03: Updater mode entered due to bad Blue Flag + * - 0x04: Updater mode entered due to boot pin + * - 0x05: System reset due to watchdog + * - 0x06: System reset due to lockup + * - 0x07: System reset due to brownout reset + * - 0x08: System reset due to crash + * - 0x09: System reset due to ECC error + * @retval None + */ +void aci_blue_initialized_event(uint8_t Reason_Code) +{ + uint8_t buffer_out[532]; + /* Output params */ + aci_blue_initialized_event_rp0 *rp0 = (aci_blue_initialized_event_rp0 *) (buffer_out + 6); + rp0->Reason_Code = Reason_Code; + buffer_out[0] = 0x82; + buffer_out[1] = 0xFF; + HOST_TO_LE_16(buffer_out+2,1 + 2); + buffer_out[4] = 0x01; + buffer_out[5] = 0x00; + send_event(buffer_out, 1 + 6, 8); +} + +void aci_blue_initialized_legacy_event(uint8_t Reason_Code) +{ + uint8_t buffer_out[258]; + /* Output params */ + aci_blue_initialized_event_rp0 *rp0 = (aci_blue_initialized_event_rp0 *) (buffer_out + 5); + rp0->Reason_Code = Reason_Code; + buffer_out[0] = 0x04; + buffer_out[1] = 0xFF; + buffer_out[2] = 1 + 2; + buffer_out[3] = 0x01; + buffer_out[4] = 0x00; + send_event(buffer_out, 1 + 5, 8); +} + +/* aci_blue_crash_info_event */ +/* Event len: 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1 + rp0->Debug_Data_Length * (sizeof(uint8_t)) */ +/** + * @brief This event is given to the application after the @ref + * aci_blue_initialized_event when a system crash is detected. This + * events returns system crash information for debugging purposes. + * Information reported are useful to understand the root cause of the + * crash. + * @param Crash_Type Crash type + * Values: + * - 0x00: Assert failed + * - 0x01: NMI fault + * - 0x02: Hard fault + * @param SP Stack pointer + * @param R0 Register R0 + * @param R1 Register R1 + * @param R2 Register R2 + * @param R3 Register R3 + * @param R12 Register R12 + * @param LR Link register + * @param PC Program counter where crash occurred + * @param xPSR xPSR register + * @param Debug_Data_Length Length of Debug_Data field + * @param Debug_Data Debug data + * @retval None + */ +void aci_blue_crash_info_event(uint8_t Crash_Type, + uint32_t SP, + uint32_t R0, + uint32_t R1, + uint32_t R2, + uint32_t R3, + uint32_t R12, + uint32_t LR, + uint32_t PC, + uint32_t xPSR, + uint8_t Debug_Data_Length, + uint8_t Debug_Data[]) +{ + uint8_t buffer_out[258]; + /* Output params */ + aci_blue_crash_info_event_rp0 *rp0 = (aci_blue_crash_info_event_rp0 *) (buffer_out + 5); + rp0->Crash_Type = Crash_Type; + rp0->SP = SP; + rp0->R0 = R0; + rp0->R1 = R1; + rp0->R2 = R2; + rp0->R3 = R3; + rp0->R12 = R12; + rp0->LR = LR; + rp0->PC = PC; + rp0->xPSR = xPSR; + rp0->Debug_Data_Length = Debug_Data_Length; + Osal_MemCpy((void *) rp0->Debug_Data,(const void *) Debug_Data, Debug_Data_Length); + buffer_out[0] = 0x04; + buffer_out[1] = 0xFF; + buffer_out[2] = 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1 + Debug_Data_Length + 2; + buffer_out[3] = 0x03; + buffer_out[4] = 0x00; + send_event(buffer_out, 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1 + Debug_Data_Length + 5, -1); +} + +/* aci_hal_le_test_end_event */ +/* Event len: 2 */ +/** + * @brief This event is generated when the amount of transmitted test packets + * specified with aci_hal_transmitter_test_packets() has been reached. + * @param Number_Of_Packets The number of test packets actually transmitted. + * @retval None + */ +void aci_hal_le_test_end_event(uint16_t Number_Of_Packets) +{ + uint8_t buffer_out[532]; + /* Output params */ + aci_hal_le_test_end_event_rp0 *rp0 = (aci_hal_le_test_end_event_rp0 *) (buffer_out + 6); + rp0->Number_Of_Packets = Number_Of_Packets; + buffer_out[0] = 0x82; + buffer_out[1] = 0xFF; + HOST_TO_LE_16(buffer_out+2,2 + 2); + buffer_out[4] = 0x07; + buffer_out[5] = 0x00; + send_event(buffer_out, 2 + 6, -1); +} + +/* aci_l2cap_cos_sdu_data_rx_nwk_event */ +/* Event len: 2 + 2 + 2 + 2 + rp0->SDU_Length * (sizeof(uint8_t)) */ +/** + * @brief Event raised when an SDU has been received. + * @param Connection_Handle Handle identifying the connection. + * @param CID The local channel endpoint that identifies the L2CAP channel. + * @param RX_Credit_Balance Remaining number of K-frames that local L2CAP layer + * entity can currently receive from the peer. If automatic management of + * credits is enabled, this number is automatically changed after the SDU + * is extracted. + * @param SDU_Length + * @param SDU_Data + * @retval None + */ +void aci_l2cap_cos_sdu_data_rx_nwk_event(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credit_Balance, + uint16_t SDU_Length, + uint8_t SDU_Data[]) +{ + uint8_t buffer_out[6+ sizeof(aci_l2cap_cos_sdu_data_rx_nwk_event_rp0)-sizeof(((aci_l2cap_cos_sdu_data_rx_nwk_event_rp0*)0)->SDU_Data)]; + /* Output params */ + aci_l2cap_cos_sdu_data_rx_nwk_event_rp0 *rp0 = (aci_l2cap_cos_sdu_data_rx_nwk_event_rp0 *) (buffer_out + 6); + rp0->Connection_Handle = Connection_Handle; + rp0->CID = CID; + rp0->RX_Credit_Balance = RX_Credit_Balance; + rp0->SDU_Length = SDU_Length; + buffer_out[0] = 0x82; + buffer_out[1] = 0xFF; + HOST_TO_LE_16(buffer_out+2,2 + 2 + 2 + 2 + SDU_Length + 2); + buffer_out[4] = 0x07; + buffer_out[5] = 0x08; + send_event_2buffers(buffer_out, 6 + sizeof(aci_l2cap_cos_sdu_data_rx_nwk_event_rp0)-sizeof(((aci_l2cap_cos_sdu_data_rx_nwk_event_rp0*)0)->SDU_Data), SDU_Data, SDU_Length, -1); +} + +/* aci_gatt_srv_authorize_nwk_event */ +/* Event len: 2 + 2 + 2 + 1 + 2 + 1 + rp0->Data_Length * (sizeof(uint8_t)) */ +/** + * @brief This event is generated if authorization is needed to access the + * attribute value. aci_gatt_srv_authorize_resp_nwk command must be sent + * in response to this event. + * @param Conn_Handle Connection handle to be used to identify the connection + * with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID If equal to 0x0004, the event is related to an unenhanced ATT + * bearer. Otherwise, the value is the local endpoint identifying the + * enhanced ATT bearer. + * @param Attr_Handle + * @param Operation_Type + * Values: + * - 0x00: Read + * - 0x10: Write Request + * - 0x11: Write Command or Signed Write Command + * - 0x12: Prepare Write Request + * @param Attr_Val_Offset Offset from which the value needs to be read or write + * Values: + * - 0 ... 511 + * @param Data_Length Length of Data field + * @param Data The data that the client has requested to write + * @retval None + */ +void aci_gatt_srv_authorize_nwk_event(uint16_t Conn_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Operation_Type, + uint16_t Attr_Val_Offset, + uint8_t Data_Length, + uint8_t Data[]) +{ + uint8_t buffer_out[532]; + /* Output params */ + aci_gatt_srv_authorize_nwk_event_rp0 *rp0 = (aci_gatt_srv_authorize_nwk_event_rp0 *) (buffer_out + 6); + rp0->Conn_Handle = Conn_Handle; + rp0->CID = CID; + rp0->Attr_Handle = Attr_Handle; + rp0->Operation_Type = Operation_Type; + rp0->Attr_Val_Offset = Attr_Val_Offset; + rp0->Data_Length = Data_Length; + Osal_MemCpy((void *) rp0->Data,(const void *) Data, Data_Length); + buffer_out[0] = 0x82; + buffer_out[1] = 0xFF; + HOST_TO_LE_16(buffer_out+2,2 + 2 + 2 + 1 + 2 + 1 + Data_Length + 2); + buffer_out[4] = 0x1d; + buffer_out[5] = 0x0c; + send_event(buffer_out, 2 + 2 + 2 + 1 + 2 + 1 + Data_Length + 6, -1); +} + +/* aci_gatt_srv_attribute_modified_event */ +/* Event len: 2 + 2 + 2 + 2 + rp0->Attr_Data_Length * (sizeof(uint8_t)) */ +/** + * @brief This event is generated to the application by the GATT server when a + * client modifies any attribute on the server, as consequence of one of + * the following GATT procedures: - write without response - signed write + * without response - write characteristic value - write long + * characteristic value - reliable write. + * @param Connection_Handle The connection handle which modified the attribute. + * @param CID If equal to 0x0004, the event is related to an unenhanced ATT + * bearer. Otherwise, the value is the local endpoint identifying the + * enhanced ATT bearer. + * @param Attr_Handle Handle of the attribute that was modified. + * @param Attr_Data_Length Length of Attr_Data in octets + * @param Attr_Data A concatenation of Handle, Length and Values for each of the + * attributes being notified. + * @retval None + */ +void aci_gatt_srv_attribute_modified_event(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attr_Data_Length, + uint8_t Attr_Data[]) +{ + uint8_t buffer_out[532]; + + /* Output params */ + aci_gatt_srv_attribute_modified_event_rp0 *rp0 = (aci_gatt_srv_attribute_modified_event_rp0 *) (buffer_out + 6); + rp0->Connection_Handle = Connection_Handle; + rp0->CID = CID; + rp0->Attr_Handle = Attr_Handle; + rp0->Attr_Data_Length = Attr_Data_Length; + Osal_MemCpy((void *) rp0->Attr_Data,(const void *) Attr_Data, Attr_Data_Length); + buffer_out[0] = 0x82; + buffer_out[1] = 0xFF; + HOST_TO_LE_16(buffer_out+2,2 + 2 + 2 + 2 + Attr_Data_Length + 2); + buffer_out[4] = 0x01; + buffer_out[5] = 0x0c; + send_event(buffer_out, 2 + 2 + 2 + 2 + Attr_Data_Length + 6, 20); +} diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.h new file mode 100644 index 000000000..4bd5b302f --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.h @@ -0,0 +1,84 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file DTM_cmd_db.h + * @author AMS - RF Application team + * @date 12 May 2022 + * @brief Autogenerated files, do not edit!! + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef _DTM_CMD_DB_H_ +#define _DTM_CMD_DB_H_ +#include +#include "ble_stack.h" +#include "miscutil.h" + +typedef uint16_t (*hci_command_process_and_response_type)(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) ; +typedef struct hci_command_table_type_s { + uint16_t opcode; + hci_command_process_and_response_type execute; +} hci_command_table_type; + +extern const hci_command_table_type hci_command_table[]; + +tBleStatus aci_hal_get_firmware_details(uint8_t *DTM_version_major,uint8_t *DTM_version_minor,uint8_t *DTM_version_patch,uint8_t *DTM_variant,uint16_t *DTM_Build_Number,uint8_t *BTLE_Stack_version_major,uint8_t *BTLE_Stack_version_minor,uint8_t *BTLE_Stack_version_patch,uint8_t *BTLE_Stack_development,uint16_t *BTLE_Stack_variant,uint16_t *BTLE_Stack_Build_Number); +tBleStatus aci_hal_get_firmware_details_v2(uint8_t *DTM_version_major,uint8_t *DTM_version_minor,uint8_t *DTM_version_patch,uint8_t *DTM_variant,uint16_t *DTM_Build_Number,uint8_t *BTLE_Stack_version_major,uint8_t *BTLE_Stack_version_minor,uint8_t *BTLE_Stack_version_patch,uint8_t *BTLE_Stack_development,uint32_t *BTLE_Stack_variant,uint16_t *BTLE_Stack_Build_Number); +tBleStatus aci_hal_transmitter_test_packets(uint8_t TX_Frequency,uint8_t Length_Of_Test_Data, uint8_t Packet_Payload, uint16_t Number_Of_Packets, uint8_t PHY); +tBleStatus aci_hal_transmitter_test_packets_v2(uint8_t TX_Channel,uint8_t Test_Data_Length,uint8_t Packet_Payload,uint16_t Number_Of_Packets,uint8_t PHY,uint8_t CTE_Length,uint8_t CTE_Type,uint8_t Switching_Pattern_Length, uint8_t Antenna_IDs[]); +tBleStatus aci_hal_write_radio_reg(uint32_t Start_Address, uint8_t Num_Bytes, uint8_t Data[]); +tBleStatus aci_hal_read_radio_reg(uint32_t Start_Address, uint8_t Num_Bytes, uint8_t *Data_Length, uint8_t Data[]); +tBleStatus hci_le_read_maximum_advertising_data_length(uint16_t *Maximum_Advertising_Data_Length); +tBleStatus aci_test_tx_notification_start(uint16_t Connection_Handle, uint16_t Service_Handle, uint16_t Char_Handle, uint16_t Value_Length); +tBleStatus aci_test_tx_write_command_start(uint16_t Connection_Handle, uint16_t Attr_Handle, uint16_t Value_Length); +tBleStatus aci_test_rx_start(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint8_t Notifications_WriteCmds); +tBleStatus aci_test_stop(uint8_t TX_RX); +tBleStatus aci_test_report(uint32_t *TX_Notifications, uint32_t *RX_Notifications, uint16_t *RX_Data_Length, uint32_t *RX_Sequence_Errors); + +void aci_blue_initialized_event(uint8_t Reason_Code); +void aci_blue_crash_info_event(uint8_t Crash_Type, + uint32_t SP, + uint32_t R0, + uint32_t R1, + uint32_t R2, + uint32_t R3, + uint32_t R12, + uint32_t LR, + uint32_t PC, + uint32_t xPSR, + uint8_t Debug_Data_Length, + uint8_t Debug_Data[]); +void aci_hal_le_test_end_event(uint16_t Number_Of_Packets); +void aci_l2cap_sdu_data_tx_nwk_event(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Length, + uint16_t TX_Credit_Balance); +void aci_l2cap_sdu_data_rx_nwk_event(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credit_Balance, + uint16_t SDU_Length, + uint8_t SDU_Data[]); +void aci_gatt_srv_authorize_nwk_event(uint16_t Conn_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Operation_Type, + uint16_t Attr_Val_Offset, + uint8_t Data_Length, + uint8_t Data[]); +void aci_gatt_srv_attribute_modified_event(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attr_Data_Length, + uint8_t Attr_Data[]); +#endif /* _DTM_CMD_DB_H_ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h new file mode 100644 index 000000000..96df1bdb7 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h @@ -0,0 +1,153 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file dtm_cmd_en.h + * @author AMS - RF Application team + * @version V1.0.0 + * @date 21 July 2022 + * @brief List of macros used to configure the DTM ACI/HCI command table + * with modularity + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef _DTM_CMD_EN_H_ +#define _DTM_CMD_EN_H_ + +/* Include header file containing macros for command exported by stack library */ +#include "ble_stack_user_cfg.h" +#include "dtm_cmd_stack_en.h" + +/* Enabling macros for functions outside of the stack */ +#define HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_EXTENDED_ADVERTISING_DATA_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_PERIODIC_ADVERTISING_DATA_ENABLED\ + (CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_SET_PERIODIC_ADVERTISING_SUBEVENT_DATA_ENABLED\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED) +#define HCI_LE_SET_PERIODIC_ADVERTISING_RESPONSE_DATA_ENABLED\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED) +#define ACI_GATT_SRV_ADD_SERVICE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_INCLUDE_SERVICE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_ADD_CHAR_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_ADD_CHAR_DESC_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_WRITE_HANDLE_VALUE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_RM_CHAR_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_RM_SERVICE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_RM_INCLUDE_SERVICE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_WRITE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_WRITE_LONG_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_WRITE_CHAR_RELIABLE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_SET_SECURITY_PERMISSION_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_READ_HANDLE_VALUE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_SET_ACCESS_PERMISSION_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_EXEC_WRITE_RESP_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_AUTHORIZE_RESP_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_READ_PREPARE_QUEUE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_READ_MULTIPLE_INSTANCE_HANDLE_VALUE_NWK_ENABLED\ + (CONNECTION_ENABLED) +#ifndef __ZEPHYR__ +#define ACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED\ + (CONTROLLER_CTE_ENABLED) +#endif /* __ZEPHYR__ */ +#define ACI_TEST_TX_NOTIFICATION_START_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_TEST_TX_WRITE_COMMAND_START_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_TEST_RX_START_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_TEST_STOP_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_TEST_REPORT_ENABLED\ + (CONNECTION_ENABLED) + +#if CONFIG_NO_HCI_COMMANDS +/* Macros to force exclusion of some unnecessary HCI/ACI commands from DTM */ +#define HCI_DISCONNECT_FORCE_DISABLED 1 +#define HCI_READ_TRANSMIT_POWER_LEVEL_FORCE_DISABLED 1 +#define HCI_READ_LOCAL_SUPPORTED_COMMANDS_FORCE_DISABLED 1 +#define HCI_READ_LOCAL_SUPPORTED_FEATURES_FORCE_DISABLED 1 +#define HCI_READ_BD_ADDR_FORCE_DISABLED 1 +#define HCI_LE_READ_BUFFER_SIZE_FORCE_DISABLED 1 +#define HCI_LE_READ_BUFFER_SIZE_V2_FORCE_DISABLED 1 +#define HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_FORCE_DISABLED 1 +#define HCI_LE_SET_RANDOM_ADDRESS_FORCE_DISABLED 1 +#define HCI_LE_SET_ADVERTISING_PARAMETERS_FORCE_DISABLED 1 +#define HCI_LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER_FORCE_DISABLED 1 +#define HCI_LE_SET_ADVERTISING_DATA_FORCE_DISABLED 1 +#define HCI_LE_SET_SCAN_RESPONSE_DATA_FORCE_DISABLED 1 +#define HCI_LE_SET_ADVERTISING_ENABLE_FORCE_DISABLED 1 +#define HCI_LE_SET_SCAN_PARAMETERS_FORCE_DISABLED 1 +#define HCI_LE_SET_SCAN_ENABLE_FORCE_DISABLED 1 +#define HCI_LE_CREATE_CONNECTION_FORCE_DISABLED 1 +#define HCI_LE_CREATE_CONNECTION_CANCEL_FORCE_DISABLED 1 +#define HCI_LE_CLEAR_FILTER_ACCEPT_LIST_FORCE_DISABLED 1 +#define HCI_LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST_FORCE_DISABLED 1 +#define HCI_LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST_FORCE_DISABLED 1 +#define HCI_LE_CONNECTION_UPDATE_FORCE_DISABLED 1 +#define HCI_LE_READ_CHANNEL_MAP_FORCE_DISABLED 1 +#define HCI_LE_ENCRYPT_FORCE_DISABLED 1 +#define HCI_LE_RAND_FORCE_DISABLED 1 +#define HCI_LE_ENABLE_ENCRYPTION_FORCE_DISABLED 1 +#define HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_FORCE_DISABLED 1 +#define HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_FORCE_DISABLED 1 +#define HCI_LE_READ_SUPPORTED_STATES_FORCE_DISABLED 1 +#define HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_FORCE_DISABLED 1 +#define HCI_LE_GENERATE_DHKEY_FORCE_DISABLED 1 +#define HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST_FORCE_DISABLED 1 +#define HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_FORCE_DISABLED 1 +#define HCI_LE_CLEAR_RESOLVING_LIST_FORCE_DISABLED 1 +#define HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_FORCE_DISABLED 1 +#define HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_FORCE_DISABLED 1 +#define HCI_LE_READ_MAXIMUM_DATA_LENGTH_FORCE_DISABLED 0 +#define HCI_LE_READ_PHY_FORCE_DISABLED 1 +#define HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_FORCE_DISABLED 1 +#define HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_FORCE_DISABLED 1 +#define HCI_LE_SET_EXTENDED_ADVERTISING_DATA_FORCE_DISABLED 1 +#define HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA_FORCE_DISABLED 1 +#define HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE_FORCE_DISABLED 1 +#define HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_FORCE_DISABLED 1 +#define HCI_LE_REMOVE_ADVERTISING_SET_FORCE_DISABLED 1 +#define HCI_LE_CLEAR_ADVERTISING_SETS_FORCE_DISABLED 1 +#define HCI_LE_SET_EXTENDED_SCAN_PARAMETERS_FORCE_DISABLED 1 +#define HCI_LE_SET_EXTENDED_SCAN_ENABLE_FORCE_DISABLED 1 +#define HCI_LE_EXTENDED_CREATE_CONNECTION_FORCE_DISABLED 1 +#define HCI_LE_READ_TRANSMIT_POWER_FORCE_DISABLED 1 +#define HCI_LE_READ_RF_PATH_COMPENSATION_FORCE_DISABLED 1 +#define HCI_LE_READ_ANTENNA_INFORMATION_FORCE_DISABLED 1 +#define ACI_HAL_GET_FW_BUILD_NUMBER_FORCE_DISABLED 1 +#endif + +#endif /* _DTM_CMD_EN_H_ */ + diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h new file mode 100644 index 000000000..d4700307c --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h @@ -0,0 +1,645 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file dtm_cmd_stack_en.h + * @author AMS - RF Application team + * @version V1.0.0 + * @date 19 July 2022 + * @brief List of macros used to configure the DTM ACI/HCI command table + * with modularity + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef _DTM_CMD_STACK_EN_H_ +#define _DTM_CMD_STACK_EN_H_ + +#include "ble_stack_user_cfg.h" + +/* Command support enabling macros */ +#define ACI_GAP_CLEAR_ADVERTISING_SETS_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define ACI_GAP_CLEAR_SECURITY_DB_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_CREATE_CONNECTION_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_GAP_CREATE_PERIODIC_ADVERTISING_CONNECTION_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONNECTION_ENABLED &\ + CONTROLLER_PERIODIC_ADV_WR_ENABLED) +#define ACI_GAP_DISCOVER_NAME_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_GAP_GET_BONDED_DEVICES_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_GET_OOB_DATA_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_GET_SECURITY_LEVEL_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_IS_DEVICE_BONDED_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_NUMERIC_COMPARISON_VALUE_CONFIRM_YESNO_ENABLED\ + (SECURE_CONNECTIONS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_GAP_PAIRING_RESP_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_PASSKEY_INPUT_ENABLED\ + (SECURE_CONNECTIONS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_GAP_PASSKEY_RESP_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_REMOVE_ADVERTISING_SET_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define ACI_GAP_REMOVE_BONDED_DEVICE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_SET_CONNECTION_CONFIGURATION_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_GAP_SET_IO_CAPABILITY_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_SET_OOB_DATA_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_SET_SCAN_CONFIGURATION_ENABLED\ + (CONTROLLER_SCAN_ENABLED) +#define ACI_GAP_SET_SECURITY_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_SET_SECURITY_REQUIREMENTS_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_START_CONNECTION_UPDATE_ENABLED\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +#define ACI_GAP_START_PROCEDURE_ENABLED\ + (CONTROLLER_SCAN_ENABLED) +#define ACI_GAP_TERMINATE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GAP_TERMINATE_PROC_ENABLED\ + (CONTROLLER_SCAN_ENABLED) +#define ACI_GATT_CLT_CONFIRM_INDICATION_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_DISC_ALL_CHAR_DESC_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_DISC_ALL_CHAR_OF_SERVICE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_DISC_ALL_PRIMARY_SERVICES_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_DISC_CHAR_BY_UUID_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_DISC_PRIMARY_SERVICE_BY_UUID_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_EXCHANGE_CONFIG_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_EXECUTE_WRITE_REQ_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_FIND_INCLUDED_SERVICES_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_PREPARE_WRITE_REQ_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_READ_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_READ_LONG_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_READ_MULTIPLE_CHAR_VALUE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_READ_MULTIPLE_VAR_LEN_CHAR_VALUE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_READ_USING_CHAR_UUID_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_SIGNED_WRITE_WITHOUT_RESP_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_WRITE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_WRITE_CHAR_RELIABLE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_WRITE_LONG_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_CLT_WRITE_WITHOUT_RESP_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SET_EVENT_MASK_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_ADD_CHAR_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_ADD_CHAR_DESC_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_ADD_SERVICE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_GET_CHAR_DECL_HANDLE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_GET_DESCRIPTOR_HANDLE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_GET_INCLUDE_SERVICE_HANDLE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_GET_SERVICE_HANDLE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_INCLUDE_SERVICE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_MULTI_NOTIFY_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_NOTIFY_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_READ_HANDLE_VALUE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_READ_MULTIPLE_INSTANCE_HANDLE_VALUE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_RESP_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_RM_CHAR_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_RM_INCLUDE_SERVICE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_RM_SERVICE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_GATT_SRV_WRITE_MULTIPLE_INSTANCE_HANDLE_VALUE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_HAL_GET_ANCHOR_POINT_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_HAL_PERIPHERAL_LATENCY_ENABLE_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_HAL_SET_LE_POWER_CONTROL_ENABLED\ + (CONTROLLER_POWER_CONTROL_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED\ + (CONNECTION_ENABLED) +#define ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_RESP_ENABLED\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +#define ACI_L2CAP_COS_CONNECTION_REQ_ENABLED\ + (L2CAP_COS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_L2CAP_COS_CONNECTION_RESP_ENABLED\ + (L2CAP_COS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED\ + (L2CAP_COS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_L2CAP_COS_FLOW_CONTROL_CREDITS_IND_ENABLED\ + (L2CAP_COS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_L2CAP_COS_RECONFIGURE_REQ_ENABLED\ + (L2CAP_COS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_L2CAP_COS_RECONFIGURE_RESP_ENABLED\ + (L2CAP_COS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_L2CAP_COS_SDU_DATA_EXTRACT_ENABLED\ + (L2CAP_COS_ENABLED &\ + CONNECTION_ENABLED) +#define ACI_L2CAP_COS_SDU_DATA_TRANSMIT_ENABLED\ + (L2CAP_COS_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_DISCONNECT_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_ACCEPT_CIS_REQUEST_ENABLED\ + (CONNECTION_ENABLED &\ + CONTROLLER_CIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_BIG_CREATE_SYNC_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONTROLLER_BIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_LE_BIG_TERMINATE_SYNC_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONTROLLER_BIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_LE_CLEAR_ADVERTISING_SETS_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_CLEAR_RESOLVING_LIST_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_CONNECTION_CTE_REQUEST_ENABLE_ENABLED\ + (CONTROLLER_CTE_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_CONNECTION_CTE_RESPONSE_ENABLE_ENABLED\ + (CONTROLLER_CTE_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_CONNECTION_UPDATE_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_CREATE_BIG_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONTROLLER_BIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_LE_CREATE_BIG_TEST_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONTROLLER_BIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_LE_CREATE_CIS_ENABLED\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +#define HCI_LE_CREATE_CONNECTION_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_CREATE_CONNECTION_CANCEL_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_ENABLE_ENCRYPTION_ENABLED\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +#define HCI_LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL_ENABLED\ + (CONTROLLER_POWER_CONTROL_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_EXTENDED_CREATE_CONNECTION_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_EXTENDED_CREATE_CONNECTION_V2_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONNECTION_ENABLED &\ + CONTROLLER_PERIODIC_ADV_WR_ENABLED) +#define HCI_LE_GENERATE_DHKEY_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_ISO_READ_TEST_COUNTERS_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_ISO_RECEIVE_TEST_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_ISO_TEST_END_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_ISO_TRANSMIT_TEST_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_READ_ANTENNA_INFORMATION_ENABLED\ + (CONTROLLER_CTE_ENABLED) +#define HCI_LE_READ_BUFFER_SIZE_V2_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_READ_CHANNEL_MAP_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_READ_ISO_LINK_QUALITY_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_READ_ISO_TX_SYNC_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_READ_MAXIMUM_DATA_LENGTH_ENABLED\ + (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_READ_PEER_RESOLVABLE_ADDRESS_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_READ_PHY_ENABLED\ + (CONTROLLER_2M_CODED_PHY_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_READ_REMOTE_FEATURES_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL_ENABLED\ + (CONTROLLER_POWER_CONTROL_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_READ_RESOLVING_LIST_SIZE_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED\ + (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_RECEIVER_TEST_V2_ENABLED\ + (CONTROLLER_2M_CODED_PHY_ENABLED) +#define HCI_LE_RECEIVER_TEST_V3_ENABLED\ + (CONTROLLER_CTE_ENABLED) +#define HCI_LE_REJECT_CIS_REQUEST_ENABLED\ + (CONNECTION_ENABLED &\ + CONTROLLER_CIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_LE_REMOVE_ADVERTISING_SET_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_REMOVE_CIG_ENABLED\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +#define HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_REMOVE_ISO_DATA_PATH_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_REQUEST_PEER_SCA_ENABLED\ + (CONNECTION_ENABLED &\ + CONTROLLER_CIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_CIG_PARAMETERS_ENABLED\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +#define HCI_LE_SET_CIG_PARAMETERS_TEST_ENABLED\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +#define HCI_LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS_ENABLED\ + (CONTROLLER_CTE_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS_ENABLED\ + (CONTROLLER_CTE_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONTROLLER_CTE_ENABLED) +#define HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONTROLLER_CTE_ENABLED) +#define HCI_LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONTROLLER_CTE_ENABLED) +#define HCI_LE_SET_DATA_LENGTH_ENABLED\ + (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SET_DATA_RELATED_ADDRESS_CHANGES_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SET_DEFAULT_PHY_ENABLED\ + (CONTROLLER_2M_CODED_PHY_ENABLED) +#define HCI_LE_SET_DEFAULT_SUBRATE_ENABLED\ + (CONNECTION_ENABLED &\ + CONNECTION_SUBRATING_ENABLED) +#define HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V2_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_EXTENDED_SCAN_ENABLE_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_EXTENDED_SCAN_PARAMETERS_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED) +#define HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION_ENABLED\ + (\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (CONTROLLER_CHAN_CLASS_ENABLED == 1)\ + )\ + )\ + ||\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)\ + ) +#define HCI_LE_SET_HOST_FEATURE_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED |\ + CONNECTION_ENABLED) +#define HCI_LE_SET_PATH_LOSS_REPORTING_ENABLE_ENABLED\ + (CONTROLLER_POWER_CONTROL_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SET_PATH_LOSS_REPORTING_PARAMETERS_ENABLED\ + (CONTROLLER_POWER_CONTROL_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS_V2_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONNECTION_ENABLED &\ + CONTROLLER_PERIODIC_ADV_WR_ENABLED) +#define HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED) +#define HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SET_PERIODIC_SYNC_SUBEVENT_ENABLED\ + (CONTROLLER_SCAN_ENABLED &\ + CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONNECTION_ENABLED &\ + CONTROLLER_PERIODIC_ADV_WR_ENABLED) +#define HCI_LE_SET_PHY_ENABLED\ + (CONTROLLER_2M_CODED_PHY_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SET_PRIVACY_MODE_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_ENABLED\ + (CONTROLLER_PRIVACY_ENABLED) +#define HCI_LE_SET_SCAN_ENABLE_ENABLED\ + (CONTROLLER_SCAN_ENABLED) +#define HCI_LE_SET_SCAN_PARAMETERS_ENABLED\ + (CONTROLLER_SCAN_ENABLED) +#define HCI_LE_SET_TRANSMIT_POWER_REPORTING_ENABLE_ENABLED\ + (CONTROLLER_POWER_CONTROL_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_LE_SETUP_ISO_DATA_PATH_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_LE_SUBRATE_REQUEST_ENABLED\ + (CONNECTION_ENABLED &\ + CONNECTION_SUBRATING_ENABLED) +#define HCI_LE_TERMINATE_BIG_ENABLED\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ + CONTROLLER_PERIODIC_ADV_ENABLED &\ + CONTROLLER_BIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_LE_TRANSMITTER_TEST_V2_ENABLED\ + (CONTROLLER_2M_CODED_PHY_ENABLED) +#define HCI_LE_TRANSMITTER_TEST_V3_ENABLED\ + (CONTROLLER_CTE_ENABLED) +#define HCI_LE_TRANSMITTER_TEST_V4_ENABLED\ + (CONTROLLER_CTE_ENABLED |\ + CONTROLLER_POWER_CONTROL_ENABLED) +#define HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_ENABLED\ + (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED &\ + CONNECTION_ENABLED) +#define HCI_READ_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED\ + (CONNECTION_ENABLED &\ + CONTROLLER_CHAN_CLASS_ENABLED) +#define HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_READ_CONNECTION_ACCEPT_TIMEOUT_ENABLED\ + (CONNECTION_ENABLED &\ + CONTROLLER_CIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) +#define HCI_READ_REMOTE_VERSION_INFORMATION_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_READ_RSSI_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_READ_TRANSMIT_POWER_LEVEL_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_TX_ISO_DATA_ENABLED\ + (CONTROLLER_ISO_ENABLED) +#define HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED\ + (CONNECTION_ENABLED &\ + CONTROLLER_CHAN_CLASS_ENABLED) +#define HCI_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_ENABLED\ + (CONNECTION_ENABLED) +#define HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_ENABLED\ + (CONNECTION_ENABLED &\ + CONTROLLER_CIS_ENABLED &\ + CONTROLLER_ISO_ENABLED) + +#endif /* _DTM_CMD_STACK_EN_H_ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c new file mode 100644 index 000000000..4d5224d7b --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c @@ -0,0 +1,370 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file dtm_cmds.c + * @author GPM WBL Application Team + * @brief DTM specific commands to be implemented on DTM context (not present on BLE stack) + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include "stm32wb0x.h" +#include "ble_stack.h" +#include "dtm_cmd_db.h" +#include "transport_layer.h" +#include "adv_buff_alloc.h" +#include "adv_buff_alloc_tiny.h" +#include "ble_const.h" +#include "dtm_burst.h" +#include "app_ble.h" +#include "app_common.h" + +#ifndef MIN +# define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifdef WATCHDOG +#include "rf_driver_ll_iwdg.h" +#endif + +/* Private macro -------------------------------------------------------------*/ +/** @name BLE stack v3.1 stack modular configurations bitmap + * @{ + */ +#define CONTROLLER_PRIVACY_BIT ((uint32_t)0x00000001) /*!< Bit 0 selected */ +#define SECURE_CONNECTIONS_BIT ((uint32_t)0x00000002) /*!< Bit 1 selected */ +/* Observer (scanner) or Central role support: + - Observer disabled (CONTROLLER_SCAN_BIT = 0) or enabled (CONTROLLER_SCAN_BIT = 1) if CONNECTION_BIT = 0; + - Observer and Central disabled (CONTROLLER_SCAN_BIT = 0) or enabled (CONTROLLER_SCAN_BIT = 1) if CONNECTION_BIT = 1. +*/ +#define CONTROLLER_SCAN_BIT ((uint32_t)0x00000004) /*!< Bit 2 selected */ +#define CONTROLLER_DATA_LENGTH_EXTENSION_BIT ((uint32_t)0x00000008) /*!< Bit 3 selected */ +#define LINK_LAYER_ONLY_BIT ((uint32_t)0x00000010) /*!< Bit 4 selected */ +#define CONTROLLER_2M_CODED_PHY_BIT ((uint32_t)0x00000020) /*!< Bit 5 selected */ +#define CONTROLLER_EXT_ADV_SCAN_BIT ((uint32_t)0x00000040) /*!< Bit 6 selected */ +#define L2CAP_COS_BIT ((uint32_t)0x00000080) /*!< Bit 7 selected */ +#define CONTROLLER_PERIODIC_ADV_BIT ((uint32_t)0x00000100) /*!< Bit 8 selected */ +#define CONTROLLER_CTE_BIT ((uint32_t)0x00000200) /*!< Bit 9 selected */ +#define CONTROLLER_POWER_CONTROL_BIT ((uint32_t)0x00000400) /*!< Bit 10 selected */ +/* Support to connections: + - If CONNECTION_BIT = 0, connections are not supported; + device is a broadcaster-only if CONTROLLER_SCAN_BIT = 0, + or a broadcaster and observer if CONTROLLER_SCAN_BIT = 1. + - If CONNECTION_BIT = 1, connections are supported; + device can only act as broadcaster or peripheral if CONTROLLER_SCAN_BIT = 0, + or any role (broadcaster, observer, peripheral, and central) if CONTROLLER_SCAN_BIT = 1. +*/ +#define CONNECTION_BIT ((uint32_t)0x00000800) /*!< Bit 11 selected */ +#define CONTROLLER_ONLY_BIT ((uint32_t)0x00001000) /*!< Bit 12 selected */ +#define CONTROLLER_CHAN_CLASS_BIT ((uint32_t)0x00010000) /*!< Bit 16 selected */ +#define CONTROLLER_BIS_BIT ((uint32_t)0x00020000) /*!< Bit 17 selected */ +#define CONNECTION_SUBRATING_BIT ((uint32_t)0x00080000) /*!< Bit 19 selected */ +#define CONTROLLER_CIS_BIT ((uint32_t)0x00100000) /*!< Bit 20 selected */ +#define CONTROLLER_PERIODIC_ADV_WR_BIT ((uint32_t)0x00400000) /*!< Bit 22 selected */ +/** + * @} + */ + +/** @brief Link Layer Enabled or not based on LL_ONLY and BLESTACK_CONTROLLER_ONLY preprocessor options */ +#ifndef BLESTACK_CONTROLLER_ONLY +#define BLESTACK_CONTROLLER_ONLY (0U) +#endif +#if (BLESTACK_CONTROLLER_ONLY == 1U) +#define LINK_LAYER_ONLY_ENABLED (1U) +#else +#define LINK_LAYER_ONLY_ENABLED (0U) +#endif + +/** @brief Define BLE stack configurations variant bitmap value based on enabled BLE stack options and associated bits (LSB 5 bits) */ +#define BLE_STACK_CONFIGURATIONS_VARIANT ( \ + ((uint32_t)(CONTROLLER_PRIVACY_ENABLED * CONTROLLER_PRIVACY_BIT)) | \ + ((uint32_t)(SECURE_CONNECTIONS_ENABLED * SECURE_CONNECTIONS_BIT)) | \ + ((uint32_t)(CONTROLLER_SCAN_ENABLED * CONTROLLER_SCAN_BIT)) | \ + ((uint32_t)(CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED * CONTROLLER_DATA_LENGTH_EXTENSION_BIT)) | \ + ((uint32_t)(LINK_LAYER_ONLY_ENABLED * LINK_LAYER_ONLY_BIT)) | \ + ((uint32_t)(CONTROLLER_2M_CODED_PHY_ENABLED * CONTROLLER_2M_CODED_PHY_BIT)) | \ + ((uint32_t)(CONTROLLER_EXT_ADV_SCAN_ENABLED * CONTROLLER_EXT_ADV_SCAN_BIT)) | \ + ((uint32_t)(L2CAP_COS_ENABLED * L2CAP_COS_BIT)) | \ + ((uint32_t)(CONTROLLER_PERIODIC_ADV_ENABLED * CONTROLLER_PERIODIC_ADV_BIT)) | \ + ((uint32_t)(CONTROLLER_CTE_ENABLED * CONTROLLER_CTE_BIT)) | \ + ((uint32_t)(CONTROLLER_POWER_CONTROL_ENABLED * CONTROLLER_POWER_CONTROL_BIT)) | \ + ((uint32_t)(CONNECTION_ENABLED * CONNECTION_BIT)) | \ + ((uint32_t)(BLESTACK_CONTROLLER_ONLY * CONTROLLER_ONLY_BIT)) | \ + ((uint32_t)(CONTROLLER_CHAN_CLASS_ENABLED * CONTROLLER_CHAN_CLASS_BIT)) | \ + ((uint32_t)(CONTROLLER_BIS_ENABLED * CONTROLLER_BIS_BIT)) | \ + ((uint32_t)(CONNECTION_SUBRATING_ENABLED * CONNECTION_SUBRATING_BIT)) | \ + ((uint32_t)(CONTROLLER_CIS_ENABLED * CONTROLLER_CIS_BIT)) | \ + ((uint32_t)(CONTROLLER_PERIODIC_ADV_WR_ENABLED * CONTROLLER_PERIODIC_ADV_WR_BIT)) \ +) + +tBleStatus aci_hal_get_firmware_details(uint8_t *DTM_version_major, + uint8_t *DTM_version_minor, + uint8_t *DTM_version_patch, + uint8_t *DTM_variant, + uint16_t *DTM_Build_Number, + uint8_t *BTLE_Stack_version_major, + uint8_t *BTLE_Stack_version_minor, + uint8_t *BTLE_Stack_version_patch, + uint8_t *BTLE_Stack_development, + uint16_t *BTLE_Stack_variant, + uint16_t *BTLE_Stack_Build_Number) +{ + tBleStatus ret; + uint32_t BTLE_Stack_variant_ext; + + ret = aci_hal_get_firmware_details_v2(DTM_version_major,DTM_version_minor,DTM_version_patch, + DTM_variant,DTM_Build_Number,BTLE_Stack_version_major, + BTLE_Stack_version_minor,BTLE_Stack_version_patch, + BTLE_Stack_development,&BTLE_Stack_variant_ext, + BTLE_Stack_Build_Number); + *BTLE_Stack_variant = BTLE_Stack_variant_ext; + + return ret; +} + +tBleStatus aci_hal_get_firmware_details_v2(uint8_t *DTM_version_major, + uint8_t *DTM_version_minor, + uint8_t *DTM_version_patch, + uint8_t *DTM_variant, + uint16_t *DTM_Build_Number, + uint8_t *BTLE_Stack_version_major, + uint8_t *BTLE_Stack_version_minor, + uint8_t *BTLE_Stack_version_patch, + uint8_t *BTLE_Stack_development, + uint32_t *BTLE_Stack_variant, + uint16_t *BTLE_Stack_Build_Number) +{ + + aci_hal_get_fw_build_number(BTLE_Stack_Build_Number); + uint8_t HCI_Version = 0; + uint16_t HCI_Revision = 0; + uint8_t LMP_PAL_Version = 0; + uint16_t Manufacturer_Name = 0; + uint16_t LMP_PAL_Subversion = 0; + + hci_read_local_version_information(&HCI_Version, &HCI_Revision, &LMP_PAL_Version, + &Manufacturer_Name, &LMP_PAL_Subversion); + + *DTM_version_major = DTM_FW_VERSION_MAJOR; + *DTM_version_minor = DTM_FW_VERSION_MINOR; + *DTM_version_patch = DTM_FW_VERSION_PATCH; + *DTM_variant = DTM_VARIANT; + *DTM_Build_Number = 0; + *BTLE_Stack_version_major = HCI_Revision&0x0F; + *BTLE_Stack_version_minor = (LMP_PAL_Subversion>>4)&0x0F; + *BTLE_Stack_version_patch = LMP_PAL_Subversion&0x0F; + *BTLE_Stack_development = (LMP_PAL_Subversion>>15)&0x01; + + /* Set the stack configurations variant bitmap value: + first LSB 7 bits are reserved for BLE stack modular options + Link Layer only*/ + *BTLE_Stack_variant = BLE_STACK_CONFIGURATIONS_VARIANT; + + return (BLE_STATUS_SUCCESS); + +} + +/** + * @brief This API implements the hci le transmitter test with + * the capability to set the number of packets to be sent. + * @param TX_Frequency: TX frequency + * @param Length_Of_Test_Data: length of test data + * @param Packet_Payload: packet payload + * @param Number_Of_Packets: number pf packets to be sent on test + * @param PHY: PHY to be used by the transmitter + * @retval status +*/ +tBleStatus aci_hal_transmitter_test_packets(uint8_t TX_Frequency, + uint8_t Length_Of_Test_Data, + uint8_t Packet_Payload, + uint16_t Number_Of_Packets, + uint8_t PHY) +{ + extern uint16_t num_packets; + tBleStatus status; + + if(Number_Of_Packets == 0) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + +#if CONTROLLER_2M_CODED_PHY_ENABLED + + status = hci_le_transmitter_test_v2(TX_Frequency, + Length_Of_Test_Data, + Packet_Payload, + PHY); + +#else + + status = hci_le_transmitter_test(TX_Frequency /* 1 */, + Length_Of_Test_Data /* 1 */, + Packet_Payload /* 1 */); +#endif + + if(status == 0x00) + { + num_packets = Number_Of_Packets; + } + + return status; +} + +#if CONTROLLER_CTE_ENABLED +/** + * @brief This API implements the hci le transmitter test v2 with + * the capability to set the number of packets to be sent. + * @param TX_Channel: TX channel + * @param Test_Data_Length: length of test data + * @param Packet_Payload: packet payload + * @param Number_Of_Packets: number of packets to be sent on test + * @param PHY: PHY to be used by the transmitter + * @param CTE_Length: CTE length + * @param CTE_Type: CTE type + * @param Switching_Pattern_Length: switching pattern length + * @param Antenna_IDs: antenna ids + * @param Transmit_Power_Level: tx power level + * @retval status +*/ +tBleStatus aci_hal_transmitter_test_packets_v2(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint16_t Number_Of_Packets, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]) +{ + extern uint16_t num_packets; + tBleStatus status; + + if(Number_Of_Packets == 0) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + status = hci_le_transmitter_test_v3(TX_Channel, + Test_Data_Length, + Packet_Payload, + PHY, + CTE_Length, + CTE_Type, + Switching_Pattern_Length, + Antenna_IDs); + + if(status == 0x00) + { + num_packets = Number_Of_Packets; + } + + return status; +} +#endif + +#if (CONNECTION_ENABLED == 1) && (BLESTACK_CONTROLLER_ONLY==0) + +tBleStatus aci_test_tx_notification_start(uint16_t Connection_Handle, uint16_t Service_Handle, uint16_t Char_Handle, uint16_t Value_Length) +{ + return BURST_TXNotificationStart(Connection_Handle, Service_Handle, Char_Handle, Value_Length); +} + +tBleStatus aci_test_tx_write_command_start(uint16_t Connection_Handle, uint16_t Attr_Handle, uint16_t Value_Length) +{ + return BURST_TXWriteCommandStart(Connection_Handle, Attr_Handle, Value_Length); +} + +tBleStatus aci_test_rx_start(uint16_t Connection_Handle, uint16_t Attribute_Handle, uint8_t Notifications_WriteCmds) +{ + return BURST_RXStart(Connection_Handle, Attribute_Handle, Notifications_WriteCmds); +} + +tBleStatus aci_test_stop(uint8_t TX_RX) +{ + switch(TX_RX){ + case 0: + BURST_TXStop(); + break; + case 1: + BURST_RXStop(); + break; + default: + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + return BLE_STATUS_SUCCESS; +} + +tBleStatus aci_test_report(uint32_t *TX_Packets, uint32_t *RX_Packets, uint16_t *RX_Data_Length, uint32_t *RX_Sequence_Errors) +{ + *TX_Packets = BURST_TXReport(); + *RX_Packets = BURST_RXReport(RX_Data_Length, RX_Sequence_Errors); + + return BLE_STATUS_SUCCESS; +} + +#endif + +tBleStatus aci_hal_write_radio_reg(uint32_t Start_Address, + uint8_t Num_Bytes, + uint8_t Data[]) +{ + uint32_t *address = (uint32_t *)Start_Address; + + if (((Num_Bytes & 0x03U) != 0x00U) || + ((Start_Address & 0x03U) != 0x00U)) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + for (uint32_t word = 0; word < ((uint32_t)Num_Bytes >> 2); word++) + { + uint32_t tmp_word = 0x00000000; + for (int byte = 3; byte >= 0; byte--) + { + tmp_word <<= 8; + tmp_word |= Data[word * 4U + (uint32_t)byte]; + } + address[word] = tmp_word; + } + + return BLE_STATUS_SUCCESS; +} + +tBleStatus aci_hal_read_radio_reg(uint32_t Start_Address, + uint8_t Num_Bytes, + uint8_t *Data_Length, + uint8_t Data[]) +{ + uint32_t *address = (uint32_t *)Start_Address; + + if (((Num_Bytes & 0x03U) != 0x00U) || + ((Start_Address & 0x03U) != 0x00U)) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + ATOMIC_SECTION_BEGIN(); + for (uint32_t word = 0; word < ((uint32_t)Num_Bytes >> 2); word++) + { + uint32_t tmp_word = address[word]; + for (int byte = 0; byte < 4; byte++) + { + Data[word * 4U + (uint32_t)byte] = (uint8_t)(tmp_word & 0x000000FFU); + tmp_word >>= 8; + } + } + ATOMIC_SECTION_END(); + * Data_Length = Num_Bytes; + + return BLE_STATUS_SUCCESS; +} diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.c new file mode 100644 index 000000000..58c35e227 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.c @@ -0,0 +1,227 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file dtm_preprocess_events.c + * @author GPM WBL Application Team + * @brief File containing hooks for network processor mode. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +#include +#include +#include "dtm_preprocess_events.h" +#include "ble.h" + +int hci_disconnection_complete_event_process(uint8_t *buffer_in); +int aci_hal_adv_scan_resp_data_update_event_process(uint8_t *buffer_in); +int aci_hal_pawr_data_free_event_process(uint8_t *buffer_in); +int aci_l2cap_cos_disconnection_complete_event_process(uint8_t *buffer_in); +int aci_l2cap_cos_connection_event_process(uint8_t *buffer_in); +int aci_l2cap_cos_sdu_data_rx_event_process(uint8_t *buffer_in); +int aci_gatt_srv_attribute_modified_event_process(uint8_t *buffer_in); +int aci_gatt_clt_notification_event_process(uint8_t *buffer_in); +int aci_gatt_clt_proc_complete_event_process(uint8_t *buffer_in); +int aci_gatt_tx_pool_available_event_process(uint8_t *buffer_in); +int aci_gatt_srv_read_event_process(uint8_t *buffer_in); +int aci_gatt_srv_write_event_process(uint8_t *buffer_in); +int aci_att_srv_prepare_write_req_event_process(uint8_t *buffer_in); + +const hci_events_table_type hci_events_table[] = { +#if (BLESTACK_CONTROLLER_ONLY == 0) + {HCI_DISCONNECTION_COMPLETE_EVT_CODE, hci_disconnection_complete_event_process}, +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + {0,NULL}, +}; +const hci_le_meta_events_table_type hci_le_meta_events_table[] = { + {0,NULL}, +}; +const hci_vendor_specific_events_table_type hci_vendor_specific_events_table[] = { + {ACI_HAL_ADV_SCAN_RESP_DATA_UPDATE_VSEVT_CODE, aci_hal_adv_scan_resp_data_update_event_process}, +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) + {ACI_HAL_PAWR_DATA_FREE_VSEVT_CODE, aci_hal_pawr_data_free_event_process}, +#endif /* (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) */ +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CFG_BLE_L2CAP_COS_ENABLED == 1) + {ACI_L2CAP_COS_DISCONNECTION_COMPLETE_VSEVT_CODE, aci_l2cap_cos_disconnection_complete_event_process}, + {ACI_L2CAP_COS_SDU_DATA_RX_VSEVT_CODE, aci_l2cap_cos_sdu_data_rx_event_process}, +#endif /* (CFG_BLE_L2CAP_COS_ENABLED == 1) */ +#if (CFG_BLE_CONNECTION_ENABLED == 1) + {ACI_GATT_SRV_ATTRIBUTE_MODIFIED_VSEVT_CODE, aci_gatt_srv_attribute_modified_event_process}, + {ACI_GATT_CLT_NOTIFICATION_VSEVT_CODE, aci_gatt_clt_notification_event_process}, + {ACI_GATT_CLT_PROC_COMPLETE_VSEVT_CODE, aci_gatt_clt_proc_complete_event_process}, + {ACI_GATT_TX_POOL_AVAILABLE_VSEVT_CODE, aci_gatt_tx_pool_available_event_process}, + {ACI_GATT_SRV_READ_VSEVT_CODE, aci_gatt_srv_read_event_process}, + {ACI_GATT_SRV_WRITE_VSEVT_CODE, aci_gatt_srv_write_event_process}, + {ACI_ATT_SRV_PREPARE_WRITE_REQ_VSEVT_CODE, aci_att_srv_prepare_write_req_event_process}, +#endif /* (CFG_BLE_CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + {0,NULL}, +}; + +int hci_disconnection_complete_event_process(uint8_t *buffer_in) +{ + tBleStatus ret; + /* Input params */ + hci_disconnection_complete_event_rp0 *evt = (hci_disconnection_complete_event_rp0 *)buffer_in; + + ret = hci_disconnection_complete_event_preprocess(evt->Status, + evt->Connection_Handle, + evt->Reason); + + return ret; +} + +int aci_hal_adv_scan_resp_data_update_event_process(uint8_t *buffer_in) +{ + int ret; + /* Input params */ + aci_hal_adv_scan_resp_data_update_event_rp0 *evt = (aci_hal_adv_scan_resp_data_update_event_rp0 *)buffer_in; + + ret = aci_hal_adv_scan_resp_data_update_event_preprocess(evt->Old_Pointer, evt->New_Pointer); + + return ret; +} + +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) + +int aci_hal_pawr_data_free_event_process(uint8_t *buffer_in) +{ + int ret = 0; + + /* Input params */ + aci_hal_pawr_data_free_event_rp0 *evt = (aci_hal_pawr_data_free_event_rp0 *)buffer_in; + ret = aci_hal_pawr_data_free_event_preprocess(evt->Buffer, evt->Type); + + return ret; +} + +#endif /* (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CFG_BLE_L2CAP_COS_ENABLED == 1) + +int aci_l2cap_cos_disconnection_complete_event_process(uint8_t *buffer_in) +{ + int ret; + /* Input params */ + aci_l2cap_cos_disconnection_complete_event_rp0 *evt = (aci_l2cap_cos_disconnection_complete_event_rp0 *)buffer_in; + ret = aci_l2cap_cos_disconnection_complete_event_preprocess(evt->Connection_Handle, + evt->CID); + + return ret; +} + +int aci_l2cap_cos_sdu_data_rx_event_process(uint8_t *buffer_in) +{ + int ret; + + aci_l2cap_cos_sdu_data_rx_event_rp0 *evt = (aci_l2cap_cos_sdu_data_rx_event_rp0 *)buffer_in; + + ret = aci_l2cap_cos_sdu_data_rx_event_preprocess(evt->Connection_Handle, + evt->CID, + evt->RX_Credit_Balance, + evt->SDU_Length); + + return ret; +} + +#endif /* (CFG_BLE_L2CAP_COS_ENABLED == 1) */ + +#if (CFG_BLE_CONNECTION_ENABLED == 1) + +int aci_gatt_tx_pool_available_event_process(uint8_t *buffer_in) +{ + int ret; + + aci_gatt_tx_pool_available_event_rp0 *evt = (aci_gatt_tx_pool_available_event_rp0 *)buffer_in; + ret = aci_gatt_tx_pool_available_event_preprocess(evt->Connection_Handle, + evt->Available_Buffers); + + return ret; +} + +int aci_gatt_srv_attribute_modified_event_process(uint8_t *buffer_in) +{ + int ret; + + aci_gatt_srv_attribute_modified_event_rp0 *evt = (aci_gatt_srv_attribute_modified_event_rp0 *)buffer_in; + ret = aci_gatt_srv_attribute_modified_event_preprocess(evt->Connection_Handle, + evt->CID, + evt->Attr_Handle, + evt->Attr_Data_Length, + evt->Attr_Data); + + return ret; +} + +int aci_gatt_clt_notification_event_process(uint8_t *buffer_in) +{ + int ret; + /* Input params */ + aci_gatt_clt_notification_event_rp0 *evt = (aci_gatt_clt_notification_event_rp0 *)buffer_in; + ret = aci_gatt_clt_notification_event_preprocess(evt->Connection_Handle, + evt->CID, + evt->Attribute_Handle, + evt->Attribute_Value_Length, + evt->Attribute_Value); + + return ret; +} + +int aci_gatt_clt_proc_complete_event_process(uint8_t *buffer_in) +{ + tBleStatus ret; + /* Input params */ + aci_gatt_clt_proc_complete_event_rp0 *evt = (aci_gatt_clt_proc_complete_event_rp0 *)buffer_in; + ret = aci_gatt_clt_proc_complete_event_preprocess(evt->Connection_Handle, + evt->CID, + evt->Error_Code); + + return ret; +} + +int aci_gatt_srv_read_event_process(uint8_t *buffer_in) +{ + int ret; + + aci_gatt_srv_read_event_rp0 *evt = (aci_gatt_srv_read_event_rp0 *)buffer_in; + ret = aci_gatt_srv_read_event_preprocess(evt->Connection_Handle, evt->CID, evt->Attribute_Handle, evt->Data_Offset); + + return ret; +} + +int aci_gatt_srv_write_event_process(uint8_t *buffer_in) +{ + int ret; + + aci_gatt_srv_write_event_rp0 *evt = (aci_gatt_srv_write_event_rp0 *)buffer_in; + ret = aci_gatt_srv_write_event_preprocess(evt->Connection_Handle, evt->CID, evt->Resp_Needed, + evt->Attribute_Handle, evt->Data_Length, evt->Data); + + return ret; +} + +int aci_att_srv_prepare_write_req_event_process(uint8_t *buffer_in) +{ + int ret = 0; + + /* Input params */ + aci_att_srv_prepare_write_req_event_rp0 *evt = (aci_att_srv_prepare_write_req_event_rp0 *)buffer_in; + ret = aci_att_srv_prepare_write_req_event_preprocess(evt->Connection_Handle, evt->CID, evt->Attribute_Handle, + evt->Data_Offset, evt->Data_Length, evt->Data); + return ret; +} + +#endif /* (CFG_BLE_CONNECTION_ENABLED == 1) */ + +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.h new file mode 100644 index 000000000..4d7ee500b --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.h @@ -0,0 +1,98 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file dtm_preprocess_events.h + * @author GPM WBL Application Team + * @brief Header file preprocess hooks for events. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +#ifndef DTM_PREPROCESS_EVENTS_H +#define DTM_PREPROCESS_EVENTS_H + +#include +#include "ble_status.h" + +typedef int (*hci_event_process)(uint8_t *buffer_in); +typedef struct hci_event_table_type_s { + uint16_t evt_code; + hci_event_process process; +} hci_events_table_type, hci_le_meta_events_table_type, hci_vendor_specific_events_table_type; + +extern const hci_events_table_type hci_events_table[]; +extern const hci_le_meta_events_table_type hci_le_meta_events_table[]; +extern const hci_vendor_specific_events_table_type hci_vendor_specific_events_table[]; + +int hci_disconnection_complete_event_preprocess(uint8_t Status, + uint16_t Connection_Handle, + uint8_t Reason); + +int aci_gatt_srv_attribute_modified_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attr_Data_Length, + uint8_t Attr_Data[]); + +int aci_gatt_clt_notification_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attribute_Handle, + uint16_t Attribute_Value_Length, + uint8_t Attribute_Value[]); + +int aci_gatt_clt_proc_complete_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Error_Code); + +int aci_gatt_tx_pool_available_event_preprocess(uint16_t Connection_Handle, + uint16_t Available_Buffers); + +int aci_gatt_srv_read_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attribute_Handle, + uint16_t Data_Offset); + +int aci_gatt_srv_write_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Resp_Needed, + uint16_t Attribute_Handle, + uint16_t Data_Length, + uint8_t Data[]); + +int aci_att_srv_prepare_write_req_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attribute_Handle, + uint16_t Data_Offset, + uint16_t Data_Length, + uint8_t Data[]); + +int aci_l2cap_cos_disconnection_complete_event_preprocess(uint16_t Connection_Handle, + uint16_t CID); + +int aci_l2cap_cos_sdu_data_tx_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Length, + void * SDU_Data_Buffer, + uint16_t TX_Credit_Balance); + +int aci_l2cap_cos_sdu_data_rx_event_preprocess(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credit_Balance, + uint16_t SDU_Length); + +int aci_hal_adv_scan_resp_data_update_event_preprocess(void * Old_Pointer, + void * New_Pointer); + +int aci_hal_pawr_data_free_event_preprocess(void * Buffer, + uint8_t Type); + +#endif /* DTM_PREPROCESS_EVENTS_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/fifo.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/fifo.c new file mode 100644 index 000000000..cbad6bdd5 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/fifo.c @@ -0,0 +1,184 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file fifo.c + * @author VMA RF Application Team + * @version V1.0.0 + * @date July-2015 + * @brief FIFO management sources + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +#include "fifo.h" +#include "osal.h" + +#define MIN(a, b) ((a <= b) ? (a) : (b)) +#define MAX(a, b) ((a < b) ? (b) : (a)) +#define FIFO_ALIGN(value, alignment) ((value + alignment - 1) & ~(alignment - 1)) +#define ADVANCE_QUEUE(index, size, max_size) ((index + size) % max_size) /* (((index + size) >= max_size) ? 0 : (index + size))*/ +#define ROLLBACK_QUEUE(index, size, max_size) ((index)>=(size)?((index) - (size)):((max_size)+(index)-(size))) +#define FIFO_ALIGNMENT fifo->alignment +#define FIFO_GET_SIZE(fifo) ((fifo->tail>=fifo->head) ? (fifo->tail - fifo->head) : (fifo->max_size - (fifo->head - fifo->tail))) +#define VAR_LEN_ITEM_SIZE_LENGTH 2 + +/** +* @brief Initialize a circular fifo specfiyng also elements alignment +* The buffer allocated memory should max_size+maximum length of element, +* so that no wrapping occurs and each element is made of only linear buffer segments. +* @retval None +*/ + +void fifo_init(circular_fifo_t *fifo, uint16_t max_size, uint8_t *buffer, uint8_t alignment) +{ + fifo->tail = fifo->head = 0; + fifo->max_size = max_size; + fifo->buffer = buffer; + fifo->alignment = alignment; +} +/** +* @brief Return number of bytes held in the FIFO +* @retval None +*/ + +uint16_t fifo_size(circular_fifo_t *fifo) +{ + return FIFO_GET_SIZE(fifo); +} +void fifo_flush(circular_fifo_t *fifo) +{ + fifo->tail = fifo->head = 0; +} + +static uint8_t _fifo_put(circular_fifo_t *fifo, uint16_t size, const uint8_t *buffer, uint16_t index) +{ + uint16_t size_aligned = FIFO_ALIGN(size, FIFO_ALIGNMENT); + if ((FIFO_GET_SIZE(fifo) + size_aligned) < fifo->max_size) { /* <= */ + Osal_MemCpy(&fifo->buffer[index], buffer, size); + fifo->tail = ADVANCE_QUEUE(fifo->tail, size_aligned, fifo->max_size); + return 0; + } + return 1; +} + +//static uint8_t fifo_put_no_wrap(circular_fifo_t *fifo, uint16_t size, uint8_t *buffer) +//{ +// uint16_t index = (fifo->tail == 0) ? fifo->max_size : fifo->tail; +// return (_fifo_put(fifo, size, buffer, index)); +//} + +/** +* @brief Put the buffer in the fifo (no wrapping) +* @retval None +*/ +uint8_t fifo_put(circular_fifo_t *fifo, uint16_t size, const uint8_t *buffer) +{ + return (_fifo_put(fifo, size, buffer, fifo->tail)); +} + +static uint8_t _fifo_get(circular_fifo_t *fifo, uint16_t size, uint8_t *buffer, uint16_t index) +{ + uint16_t size_aligned = FIFO_ALIGN(size, FIFO_ALIGNMENT); + if (FIFO_GET_SIZE(fifo) >= size_aligned) { + Osal_MemCpy(buffer, &fifo->buffer[index], size); + fifo->head = ADVANCE_QUEUE(fifo->head, size_aligned, fifo->max_size); + + return 0; + } + return 1; +} + +static uint8_t fifo_get_no_wrap(circular_fifo_t *fifo, uint16_t size, uint8_t *buffer) +{ + uint16_t index = (fifo->head == 0) ? fifo->max_size : fifo->head; + return (_fifo_get(fifo, size, buffer, index)); +} + +uint8_t fifo_get(circular_fifo_t *fifo, uint16_t size, uint8_t *buffer) +{ + return (_fifo_get(fifo, size, buffer, fifo->head)); +} + +void fifo_roll_back(circular_fifo_t *fifo, uint16_t size) +{ + uint16_t size_aligned = FIFO_ALIGN(size, FIFO_ALIGNMENT); + uint16_t var_le_item_size_aligned = FIFO_ALIGN(VAR_LEN_ITEM_SIZE_LENGTH, FIFO_ALIGNMENT); + fifo->head = ROLLBACK_QUEUE(fifo->head, size_aligned+var_le_item_size_aligned, fifo->max_size); +} + +uint8_t fifo_put_var_len_item(circular_fifo_t *fifo, uint16_t size1, const uint8_t *buffer1, uint16_t size2, const uint8_t *buffer2) +{ + uint8_t ret_val = 0; + uint16_t size = size1 + size2; + uint16_t size_aligned = FIFO_ALIGN(size, FIFO_ALIGNMENT); + uint8_t length_size_aligned = FIFO_ALIGN(VAR_LEN_ITEM_SIZE_LENGTH, FIFO_ALIGNMENT); + + if ((FIFO_GET_SIZE(fifo) + size_aligned + length_size_aligned) < fifo->max_size) { + Osal_MemCpy(&fifo->buffer[fifo->tail], &size, VAR_LEN_ITEM_SIZE_LENGTH); + + Osal_MemCpy(&fifo->buffer[fifo->tail + length_size_aligned], buffer1, size1); + Osal_MemCpy(&fifo->buffer[fifo->tail + length_size_aligned + size1], buffer2, size2); + + fifo->tail = ADVANCE_QUEUE(fifo->tail, size_aligned + length_size_aligned, fifo->max_size); + + } else { + ret_val = 1; + } + return ret_val; +} + +uint8_t fifo_discard(circular_fifo_t *fifo, uint16_t size) +{ + uint16_t size_aligned = FIFO_ALIGN(size, FIFO_ALIGNMENT); + if (FIFO_GET_SIZE(fifo) >= size_aligned) { + fifo->head = ADVANCE_QUEUE(fifo->head, size_aligned, fifo->max_size); + return 0; + } + return 1; +} + +uint8_t fifo_get_ptr(circular_fifo_t *fifo, uint16_t size, uint8_t **ptr) +{ + uint16_t size_aligned = FIFO_ALIGN(size, FIFO_ALIGNMENT); + if (FIFO_GET_SIZE(fifo) >= size_aligned) { + *ptr = &fifo->buffer[fifo->head]; + return 0; + } + return 1; +} + +uint8_t fifo_get_var_len_item(circular_fifo_t *fifo, uint16_t *size, uint8_t *buffer) +{ + uint8_t ret_val = fifo_get(fifo, VAR_LEN_ITEM_SIZE_LENGTH, (uint8_t *) size); + if (ret_val == 0) { + ret_val = fifo_get_no_wrap(fifo, *size, buffer); + } + return ret_val; +} + +uint8_t fifo_get_ptr_var_len_item(circular_fifo_t *fifo, uint16_t *size, uint8_t **ptr) +{ + uint8_t ret_val = fifo_get_ptr(fifo, VAR_LEN_ITEM_SIZE_LENGTH, ptr); + if (ret_val == 0) { + *size = *((uint16_t *) *ptr); + } + return ret_val; +} +uint8_t fifo_discard_var_len_item(circular_fifo_t *fifo) +{ + uint16_t size; + uint8_t ret_val = fifo_get(fifo, VAR_LEN_ITEM_SIZE_LENGTH, (uint8_t *) &size); + if (ret_val == 0) { + ret_val = fifo_discard(fifo, size); + } + return ret_val; +} diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/fifo.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/fifo.h new file mode 100644 index 000000000..b3914c812 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/fifo.h @@ -0,0 +1,47 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file fifo.h + * @author VMA RF Application Team + * @version V1.0.0 + * @date July-2015 + * @brief + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include +#ifndef __FIFO_H__ +#define __FIFO_H__ + +typedef struct circular_fifo_s { + uint16_t tail; + uint16_t head; + uint16_t max_size; + uint8_t *buffer; + uint8_t alignment; +} circular_fifo_t; + +void fifo_init(circular_fifo_t *fifo, uint16_t max_size, uint8_t *buffer, uint8_t alignment); +uint16_t fifo_size(circular_fifo_t *fifo); +uint8_t fifo_put(circular_fifo_t *fifo, uint16_t size, const uint8_t *buffer); +uint8_t fifo_put_var_len_item(circular_fifo_t *fifo, uint16_t size1, const uint8_t *buffer1, uint16_t size2, const uint8_t *buffer2); +uint8_t fifo_get(circular_fifo_t *fifo, uint16_t size, uint8_t *buffer); +uint8_t fifo_discard(circular_fifo_t *fifo, uint16_t size); +uint8_t fifo_get_ptr(circular_fifo_t *fifo, uint16_t size, uint8_t **ptr); +uint8_t fifo_get_var_len_item(circular_fifo_t *fifo, uint16_t *size, uint8_t *buffer); +uint8_t fifo_get_ptr_var_len_item(circular_fifo_t *fifo, uint16_t *size, uint8_t **ptr); +uint8_t fifo_discard_var_len_item(circular_fifo_t *fifo); +void fifo_flush(circular_fifo_t *fifo); +void fifo_roll_back(circular_fifo_t *fifo, uint16_t size); +#endif /* __FIFO_H__ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/hci_parser.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/hci_parser.c new file mode 100644 index 000000000..ff3a414f5 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/hci_parser.c @@ -0,0 +1,234 @@ +/* USER CODE BEGIN Header */ +/** +****************************************************************************** +* @file hci_parser.c +* @author VMA RF Application Team + * @version V1.2.0 + * @date April-2018 +* @brief Transport layer file + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wb0x.h" +#include "ble.h" +#include "hci_parser.h" +#include "transport_layer.h" +#include "osal.h" +#include "dtm_cmd_en.h" +#include "board_cmd.h" +#include "app_common.h" + +/* Private macro -------------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ + +#ifndef DTM_DEBUG +/* Macro for debug purposes: not relevant x application */ +#define DTM_DEBUG 0 +#endif + +#define HCI_PACKET_SIZE 536 // Maximum size of HCI packets are 255 bytes + the HCI header (3 bytes) + 1 byte for transport layer. +#define MAX_ISO_DATA_LOAD_LENGTH 512 // This value should be less than FIFO_VAR_LEN_ITEM_MAX_SIZE - 5 + +/* Private typedef -----------------------------------------------------------*/ + +/* Private variables ---------------------------------------------------------*/ +static uint8_t hci_buffer[HCI_PACKET_SIZE]; +static volatile uint16_t hci_pckt_len = 0; + +uint8_t buffer_out[HCI_PACKET_SIZE]; +uint16_t buffer_out_len=0; + +/* Private function prototypes -----------------------------------------------*/ +void packet_received(void); + +hci_state hci_input(uint8_t *buff, uint16_t len) +{ + static hci_state state = WAITING_TYPE; + + static uint16_t collected_payload_len = 0; + static uint16_t payload_len; + static uint16_t header_len; + uint8_t byte; + uint16_t i = 0; + + while(hci_pckt_len < HCI_PACKET_SIZE && i++ < len){ + + byte = *buff++; + + if(state == WAITING_TYPE) + hci_pckt_len = 0; + + hci_buffer[hci_pckt_len++] = byte; + + if(state == WAITING_TYPE){ + + state = WAITING_HEADER; + + if(byte == HCI_COMMAND_PKT){ + header_len = 4; + } + else if(byte == HCI_COMMAND_EXT_PKT){ + header_len = 5; + } + else if(byte == HCI_ACLDATA_PKT || byte == HCI_ISO_DATA_PKT){ + header_len = 5; + } + else if(byte == HCI_VENDOR_PKT){ + header_len = 4; + } + else { + state = WAITING_TYPE; + } + } + else if(state == WAITING_HEADER){ + + if(hci_pckt_len == header_len){ + + // The entire header has been received + uint8_t pckt_type = hci_buffer[0]; + collected_payload_len = 0; + payload_len = 0; + + if(pckt_type == HCI_COMMAND_PKT){ + hci_cmd_hdr *hdr = (hci_cmd_hdr *)hci_buffer; + payload_len = hdr->param_len; + } + else if(pckt_type == HCI_COMMAND_EXT_PKT){ + hci_cmd_ext_hdr *hdr = (hci_cmd_ext_hdr *)hci_buffer; + payload_len = hdr->param_len; + } + else if(pckt_type == HCI_ACLDATA_PKT){ + hci_acl_hdr *hdr = (hci_acl_hdr *)hci_buffer; + payload_len = hdr->dlen; + } + else if(pckt_type == HCI_ISO_DATA_PKT){ + hci_iso_data_hdr *hdr = (hci_iso_data_hdr *)hci_buffer; + payload_len = hdr->dlen & 0x3FFF; + } + else if(pckt_type == HCI_VENDOR_PKT){ + hci_vendor_hdr *hdr = (hci_vendor_hdr *)hci_buffer; + payload_len = hdr->param_len; + } + if(payload_len == 0){ + state = WAITING_TYPE; + packet_received(); + } + else { + state = WAITING_PAYLOAD; + } + } + } + else if(state == WAITING_PAYLOAD){ + collected_payload_len++; + if(collected_payload_len >= payload_len){ + state = WAITING_TYPE; + packet_received(); + } + } + } + + return state; +} + +void packet_received(void) +{ + switch(hci_buffer[HCI_TYPE_OFFSET]) { + case HCI_VENDOR_PKT: + /* Need to give a response for this type for backward compatibility with BlueNRG GUI. */ + buffer_out_len = parse_cmd(hci_buffer, hci_pckt_len, buffer_out); + send_event(buffer_out, buffer_out_len, 1); + break; + case HCI_ACLDATA_PKT: + { + uint16_t connHandle; + uint16_t dataLen; + uint8_t* pduData; + uint8_t pb_flag; + uint8_t bc_flag; + + connHandle = ((hci_buffer[2] & 0x0F) << 8) + hci_buffer[1]; + dataLen = (hci_buffer[4] << 8) + hci_buffer[3]; + pduData = hci_buffer+5; + pb_flag = (hci_buffer[2] >> 4) & 0x3; + bc_flag = (hci_buffer[2] >> 6) & 0x3; + hci_tx_acl_data(connHandle, pb_flag, bc_flag, dataLen, pduData); + } + break; +#if HCI_TX_ISO_DATA_ENABLED + case HCI_ISO_DATA_PKT: + { + uint16_t connection_hanlde; + uint16_t iso_data_load_len; + uint8_t* iso_data_load; + uint8_t pb_flag; + uint8_t ts_flag; + + connection_hanlde = LE_TO_HOST_16(hci_buffer+1) & 0x0FFF; + iso_data_load_len = LE_TO_HOST_16(hci_buffer+3) & 0x3FFF; + pb_flag = (hci_buffer[2] >> 4) & 0x3; + ts_flag = (hci_buffer[2] >> 6) & 0x1; + iso_data_load = &hci_buffer[5]; + hci_tx_iso_data(connection_hanlde, pb_flag, ts_flag, iso_data_load_len, iso_data_load); + } + break; +#endif + case HCI_COMMAND_PKT: + case HCI_COMMAND_EXT_PKT: + command_received(hci_buffer, hci_pckt_len); + break; + default: + // Error case not allowed TBR + break; + } +} + +tBleStatus hci_rx_acl_data_event(uint16_t connHandle, uint8_t pb_flag, uint8_t bc_flag, uint16_t dataLen, uint8_t* pduData) +{ + uint8_t buffer_out[251+5]; + + buffer_out[0] = 0x02; + buffer_out[1] = connHandle & 0xFF; + buffer_out[2] = (connHandle >> 8 & 0x0F) | (pb_flag << 4) | (bc_flag << 6) ; + Osal_MemCpy(buffer_out+3, &dataLen, 2); + Osal_MemCpy(buffer_out+5, pduData, dataLen); + send_event(buffer_out, dataLen+2+2+1, -1); + return 0; +} + +tBleStatus hci_le_rx_iso_data_event(uint16_t Connection_Handle, uint8_t PB_Flag, uint8_t TS_Flag, uint16_t ISO_Data_Load_Length, uint8_t *ISO_Data_Load) +{ + uint8_t buffer_out[MAX_ISO_DATA_LOAD_LENGTH+5]; + + if(ISO_Data_Load_Length + 5 > sizeof(buffer_out)) // Header is 5 bytes + return 0; + + buffer_out[0] = HCI_ISO_DATA_PKT; + Connection_Handle &= 0x0FFF; + HOST_TO_LE_16(buffer_out+1, Connection_Handle); + + PB_Flag &= 0x03; + buffer_out[2] |= (PB_Flag << 4); + + TS_Flag &= 0x01; + buffer_out[2] |= (TS_Flag << 6); + + HOST_TO_LE_16(buffer_out+3, ISO_Data_Load_Length); + + Osal_MemCpy(buffer_out+5, ISO_Data_Load, ISO_Data_Load_Length); + + send_event(buffer_out, ISO_Data_Load_Length + 5, -1); + + return 0; +} diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/hci_parser.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/hci_parser.h new file mode 100644 index 000000000..3f5dd2ad1 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/hci_parser.h @@ -0,0 +1,112 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file hci_parser.h + * @author VMA RF Application Team + * @version V1.0.0 + * @date July-2015 + * @brief + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef HCI_PARSER_H +#define HCI_PARSER_H + +/* Includes ------------------------------------------------------------------*/ +#include +#include "compiler.h" +/* Exported macro ------------------------------------------------------------*/ + +/* HCI Packet types */ +#define HCI_COMMAND_PKT 0x01 +#define HCI_ACLDATA_PKT 0x02 +#define HCI_SCODATA_PKT 0x03 +#define HCI_EVENT_PKT 0x04 +#define HCI_ISO_DATA_PKT 0x05 +#define HCI_COMMAND_EXT_PKT 0x81 +#define HCI_EVENT_EXT_PKT 0x82 +#define HCI_VENDOR_PKT 0xFF + +#define HCI_TYPE_OFFSET 0 +#define HCI_VENDOR_CMDCODE_OFFSET 1 +#define HCI_VENDOR_LEN_OFFSET 2 +#define HCI_VENDOR_PARAM_OFFSET 4 + +/* Exported constants --------------------------------------------------------*/ + +/* Exported types ------------------------------------------------------------*/ + +typedef enum { + WAITING_TYPE, + WAITING_HEADER, + WAITING_PAYLOAD +}hci_state; + +typedef PACKED(struct) _hci_uart_pckt{ + uint8_t type; + uint8_t data[0]; +} hci_uart_pckt; +#define HCI_TYPE_SIZE 1 + +typedef PACKED(struct) _hci_cmd_hdr{ + uint8_t type; + uint16_t opcode; + uint8_t param_len; +} hci_cmd_hdr; + +typedef PACKED(struct) _hci_acl_hdr{ + uint8_t type; + uint16_t handle; /* Connection handle & Flags(PB, BC) */ + uint16_t dlen; +} hci_acl_hdr; + +typedef PACKED(struct) _hci_iso_data_hdr{ + uint8_t type; + uint16_t handle; /* Connection handle & Flags(PB, TS) */ + uint16_t dlen; /* ISO Data Load Length (2 msb are reserved) */ +} hci_iso_data_hdr; + +typedef PACKED(struct) _hci_cmd_ext_hdr{ + uint8_t type; + uint16_t opcode; + uint16_t param_len; +} hci_cmd_ext_hdr; + +typedef PACKED(struct) _hci_vendor_hdr{ + uint8_t type; + uint8_t opcode; + uint16_t param_len; +} hci_vendor_hdr; + +#define EVT_LE_META_EVENT 0x3E +typedef PACKED(struct) _evt_le_meta_event{ + uint8_t subevent; + uint8_t data[0]; +} evt_le_meta_event; +#define EVT_LE_META_EVENT_SIZE 1 + +typedef PACKED(struct) _evt_blue_aci{ + uint16_t ecode; /**< One of the BlueNRG event codes. */ + uint8_t data[0]; +} evt_blue_aci; + +/* Exported functions ------------------------------------------------------- */ + +/* HCI library functions. */ +extern hci_state hci_input(uint8_t *buff, uint16_t len); + +extern uint8_t buffer_out[]; +extern uint16_t buffer_out_len; + +#endif /* HCI_PARSER_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/pawr_buff_alloc.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/pawr_buff_alloc.c new file mode 100644 index 000000000..c77fb1d30 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/pawr_buff_alloc.c @@ -0,0 +1,177 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file adv_buff_alloc.c + * @author AMS - RF Application team + * @brief Module providing buffer allocation for advertising data. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +#include +#include +#include "ble.h" +#include "pawr_buff_alloc.h" + +#if (CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) + +static uint8_t pawr_subevent_buf[CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX][MAX_PAWR_SUBEVENT_DATA_SIZE]; + +static uint8_t pawr_resp_buff[MAX_PAWR_RESPONSE_SUBEVENT_COUNT][MAX_PAWR_SUBEVENT_DATA_SIZE]; + +#if CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX < 33 +/* Variable used to keep which buffer is used and which one is not in use by the link layer. + Up to 32 buffers can be handled. */ +static uint32_t used_subevent_buff_msk; + +#elif CFG_BLE_PAWR_SUBEVENT_DATA_COUNT_MAX < 65 + +static uint64_t used_subevent_buff_msk; + +#else + +#error "This implementation does not allow to handle more than 64 buffers for subevents." + +#endif + +#if MAX_PAWR_RESPONSE_SUBEVENT_COUNT < 9 +/* Variable used to keep which buffer is used and which one is not in use by the link layer. + Up to 32 buffers can be handled. */ +static uint8_t used_resp_buff_msk; + +#else + +#error "This implementation does not allow to handle more than 8 buffers for pawr responses." + +#endif + +#define BUFFER_IN_USE(mask, i) (mask & (1<= LEGACY_ADV_OPCODE_LOW && opcode <= LEGACY_ADV_OPCODE_HIGH){ + if(extended_cmd_issued) + allowed = FALSE; // Error + else { + legacy_cmd_issued = TRUE; + allowed = TRUE; // OK + } + } + else if(opcode >= EXTENDED_ADV_OPCODE_LOW && opcode <= EXTENDED_ADV_OPCODE_HIGH){ + if(legacy_cmd_issued) + allowed = FALSE; // Error + else { + extended_cmd_issued = TRUE; + allowed = TRUE; // OK + } + } + + if(!allowed){ + if(opcode == HCI_LE_CREATE_CONNECTION_OPCODE || + opcode == HCI_LE_EXTENDED_CREATE_CONNECTION_OPCODE|| + opcode == HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_OPCODE){ + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = 0x04; + buffer_out[3] = 0x0C; + buffer_out[4] = 0x01; + HOST_TO_LE_16(buffer_out+5,opcode); + return 7; + } + else { + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = 0x04; + buffer_out[3] = 0x01; + HOST_TO_LE_16(buffer_out+4,opcode); + buffer_out[6] = 0x0C; + return 7; + } + } + + return 0; +} + +/* Process Commands */ +uint16_t process_command(uint16_t op_code, uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + uint32_t i; + uint16_t ret_val; + + ret_val = check_legacy_extended_call(op_code, buffer_out); + if(ret_val != 0){ + return ret_val; + } + + for (i = 0; hci_command_table[i].opcode != 0; i++) { + if (op_code == hci_command_table[i].opcode) { + ret_val = hci_command_table[i].execute(buffer_in, buffer_in_length, buffer_out, buffer_out_max_length); + /* add get crash handler */ + return ret_val; + } + } + + // Unknown command length + buffer_out[0] = 0x04; + buffer_out[1] = 0x0F; + buffer_out[2] = 0x04; + buffer_out[3] = 0x01; + buffer_out[4] = 0x01; + HOST_TO_LE_16(buffer_out+5, op_code); + return 7; +} + +/** +* @brief Transport Layer Init. +* Init the transport layer. +* @param None +* @retval None +*/ +void transport_layer_init(void) +{ + /* Queue index init */ + fifo_init(&event_fifo, EVENT_BUFFER_SIZE, event_buffer, FIFO_ALIGNMENT); + fifo_init(&command_fifo, COMMAND_BUFFER_SIZE, command_buffer, FIFO_ALIGNMENT); + + /* event_lost_register init */ + event_lost_register.event_lost = 0; + event_lost_register.event_register[0] = 0x04; + event_lost_register.event_register[1] = 0xFF; + event_lost_register.event_register[2] = 0x0A; + event_lost_register.event_register[3] = 0x02; + event_lost_register.event_register[4] = 0x00; + event_lost_register.event_lost_code = 0; + + HAL_UARTEx_ReceiveToIdle_DMA(&huart1, DMA_RX_Buffer, DMA_RX_BUFFER_SIZE); +} + +static void transport_layer_send_data(uint8_t *data, uint16_t data_length) +{ + if (dma_state == DMA_IDLE) { + dma_state = DMA_IN_PROGRESS; + DEBUG_NOTES(DMA_REARM); + HAL_UART_Transmit_DMA(&huart1, data, data_length); + } +} + +static void transport_layer_DMA_RX_Data(uint16_t dma_counter) +{ + static uint16_t rx_index = 0; + + if(rx_index != dma_counter) + { + if(dma_counter > rx_index) + { + hci_input(&DMA_RX_Buffer[rx_index], dma_counter - rx_index); + } + else + { + hci_input(&DMA_RX_Buffer[rx_index], DMA_RX_BUFFER_SIZE - rx_index); + if(dma_counter != 0) + { + hci_input(&DMA_RX_Buffer[0], dma_counter); + } + } + rx_index = dma_counter; + if(rx_index == DMA_RX_BUFFER_SIZE) + { + rx_index = 0; + } + } +} + +/** +* @brief Advance transport layer state machine +* @param None +* @retval Desired sleep level +*/ +void transport_layer_tick(void) +{ + uint8_t buffer[COMMAND_BUFFER_SIZE], buffer_out[FIFO_VAR_LEN_ITEM_MAX_SIZE]; + uint16_t len; + uint16_t size = 0; + + /* Event queue */ + if ((fifo_size(&event_fifo) > 0) && (dma_state == DMA_IDLE)) { + uint8_t *ptr; + DEBUG_NOTES(SEND_DATA); + if (fifo_get_ptr_var_len_item(&event_fifo, &size, &ptr) == 0) { + transport_layer_send_data(ptr+FIFO_ALIGNMENT, size); + } + } + + /* Command FIFO */ + if (fifo_size(&command_fifo) > 0) { + uint16_t opcode; + uint8_t offset; + + fifo_get_var_len_item(&command_fifo, &size, buffer); + /* */ + if(buffer[0] == HCI_COMMAND_PKT){ + hci_cmd_hdr *hdr = (hci_cmd_hdr *)buffer; + opcode = hdr->opcode; + offset = sizeof(hci_cmd_hdr); + } + else if(buffer[0] == HCI_COMMAND_EXT_PKT){ + hci_cmd_ext_hdr *hdr = (hci_cmd_ext_hdr *)buffer; + opcode = hdr->opcode; + offset = sizeof(hci_cmd_ext_hdr); + } + else { + /* Unknown packet type */ + fifo_flush(&command_fifo); + return; + } + + if(opcode == HCI_RESET_OPCODE) + { + while(dma_state == DMA_IN_PROGRESS); + while(LL_USART_IsActiveFlag_TXE_TXFNF(USART1) == RESET); + while(LL_USART_IsActiveFlag_TC(USART1) == RESET); + TL_ResetReqCallback(); + } + + len=process_command(opcode, buffer+offset, size-offset, buffer_out, sizeof(buffer_out)); + +#if (BUFFER_CMDS_ON_BUSY == 1) + uint8_t status_offset = (buffer_out[1] == 0x0E) ? 6 : 3; /* 0x0E: command complete, 0x0F: command status */ + /* Apply command buffering in case of CONTROLLER BUSY error with the exception of the + * aci_l2cap_connection_parameter_update_resp command (see req_pbs #990070) + */ + if ((*(buffer_out+status_offset) != BLE_ERROR_CONTROLLER_BUSY) || (opcode == 0xfd82)) + { + DEBUG_NOTES(COMMAND_PROCESSED); + /* Set user events back to normal queue */ + send_event(buffer_out, len, 1); + fifo_flush(&command_fifo); + } + else + { + fifo_roll_back(&command_fifo, size); + } +#else + DEBUG_NOTES(COMMAND_PROCESSED); + /* Set user events back to normal queue */ + send_event(buffer_out, len, 1); + fifo_flush(&command_fifo); +#endif + } + + if(event_lost_register.event_lost==1) { + if (fifo_put_var_len_item(&event_fifo, 13, event_lost_register.event_register,0,NULL) == 0) { + event_lost_register.event_lost = 0; + event_lost_register.event_lost_code = 0; + } + } +} + +void command_received(uint8_t *cmd, uint16_t len) +{ + fifo_put_var_len_item(&command_fifo, len, cmd, 0, NULL); + TL_ProcessReqCallback(); +} + +void enqueue_event(circular_fifo_t *fifo, uint16_t buff_len1, const uint8_t *buff_evt1, uint16_t buff_len2, const uint8_t *buff_evt2, int8_t overflow_index) +{ + if (fifo_put_var_len_item(fifo, buff_len1, buff_evt1, buff_len2, buff_evt2) != 0) { + /* Event queue overflow */ + if ((overflow_index >=0) && (overflow_index < 64)) { + event_lost_register.event_lost = 1; + event_lost_register.event_lost_code |= (1 << overflow_index); + } else { + /* assert */ + } + } + TL_ProcessReqCallback(); +} + +void send_event(const uint8_t *buffer_out, uint16_t buffer_out_length, int8_t overflow_index) +{ + if(buffer_out_length != 0) { + DEBUG_NOTES(ENQUEUE_EVENT); + enqueue_event(&event_fifo, buffer_out_length, buffer_out, 0, NULL, overflow_index); + } +} + +void send_event_2buffers(const uint8_t *buffer_out1, uint16_t buffer_out_length1, const uint8_t *buffer_out2, uint16_t buffer_out_length2, int8_t overflow_index) +{ + if(buffer_out_length1 != 0) { + DEBUG_NOTES(ENQUEUE_EVENT); + enqueue_event(&event_fifo, buffer_out_length1, buffer_out1, buffer_out_length2, buffer_out2, overflow_index); + } +} + +void advance_dma(void) +{ + uint8_t *ptr; + uint16_t size; + fifo_discard_var_len_item(&event_fifo); + + if (fifo_size(&event_fifo) > 0) { + if (fifo_get_ptr_var_len_item(&event_fifo, &size, &ptr) == 0) { + transport_layer_send_data(ptr+FIFO_ALIGNMENT, size); + } + } +} + +void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) +{ + /* DMA1 finished the transfer of SrcBuffer */ + dma_state = DMA_IDLE; + + DEBUG_NOTES(DMA_TC); + + advance_dma(); +} + +void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) +{ + transport_layer_DMA_RX_Data(Size); +} + +__weak void TL_ProcessReqCallback(void){} + +__weak void TL_ResetReqCallback(void){} + +#endif /* __ZEPHYR__ */ + +void BLE_STACK_Event(hci_pckt *hci_pckt, uint16_t length) +{ + uint16_t i; + int ret = 0; + + if(hci_pckt->type == HCI_EVENT_PKT) + { + hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data; + + if(event_pckt->evt == EVT_LE_META_EVENT) + { + evt_le_meta_event *evt = (evt_le_meta_event *)event_pckt->data; + + for (i = 0; hci_le_meta_events_table[i].evt_code != 0; i++) + { + if (evt->subevent == hci_le_meta_events_table[i].evt_code) + { + ret = hci_le_meta_events_table[i].process((void *)evt->data); + goto send_event; + } + } + } + else if(event_pckt->evt != HCI_VENDOR_PKT) + { + for (i = 0; hci_events_table[i].evt_code != 0; i++) + { + if (event_pckt->evt == hci_events_table[i].evt_code) + { + ret = hci_events_table[i].process(event_pckt->data); + goto send_event; + } + } + } + } + if(hci_pckt->type == HCI_EVENT_PKT || hci_pckt->type == HCI_EVENT_EXT_PKT) + { + uint8_t evt_code; + uint8_t *evt_payload; + + if(hci_pckt->type == HCI_EVENT_PKT) + { + hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data; + evt_code = event_pckt->evt; + evt_payload = event_pckt->data; + } + else + { + hci_event_ext_pckt *event_pckt = (hci_event_ext_pckt*)hci_pckt->data; + evt_code = event_pckt->evt; + evt_payload = event_pckt->data; + } + + if(evt_code == HCI_VENDOR_PKT) + { + evt_blue_aci *blue_evt = (evt_blue_aci *)evt_payload; + + for (i = 0; hci_vendor_specific_events_table[i].evt_code != 0; i++) + { + if (blue_evt->ecode == hci_vendor_specific_events_table[i].evt_code) + { + ret = hci_vendor_specific_events_table[i].process((void *)blue_evt->data); + break; + } + } + } + } + +send_event: + + if(ret == 0) + { + send_event((uint8_t *)hci_pckt, length, -1); + } +} + diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.h new file mode 100644 index 000000000..bc984a663 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.h @@ -0,0 +1,148 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file transport_layer.h + * @author VMA RF Application Team + * @version V1.0.0 + * @date July-2015 + * @brief + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef TRANSPORT_LAYER_H +#define TRANSPORT_LAYER_H + +/* Includes ------------------------------------------------------------------*/ +#include +#include "crash_handler.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +#define BLUE_FLAG_RAM_RESET 0x01010101 + +#define DMA_IDLE 0 +#define DMA_IN_PROGRESS 1 + +#define DMA_RX_BUFFER_SIZE 64 + +typedef enum { + SPI_PROT_INIT_STATE = 0, /* Initialization phase */ + SPI_PROT_CONFIGURED_STATE, /* Configuration phase */ + SPI_PROT_SLEEP_STATE, /* Sleep phase */ + SPI_PROT_CONFIGURED_HOST_REQ_STATE, /* Host request phase */ + SPI_PROT_CONFIGURED_EVENT_PEND_STATE, /* Event pending phase */ + SPI_PROT_WAITING_HEADER_STATE, /* Waiting header phase */ + SPI_PROT_HEADER_RECEIVED_STATE, /* Header received phase */ + SPI_PROT_WAITING_DATA_STATE, /* Waiting data phase */ + SPI_PROT_TRANS_COMPLETE_STATE, /* Transaction complete phase */ +} SpiProtoType; + +extern SpiProtoType spi_proto_state; + +#ifdef DEBUG_DTM +typedef enum { + EMPTY = 0, /* Initialization phase */ + GPIO_IRQ = 1000, /* Initialization phase */ + GPIO_CS_FALLING, /* Configuration phase */ + GPIO_CS_RISING, /* Event pending phase */ + PARSE_HOST_REQ, /* Host request phase */ + PARSE_EVENT_PEND, /* Sleep phase */ + ADVANCE_DMA_WRITE, /* Waiting header phase */ + ADVANCE_DMA_READ, /* Header received phase */ + ADVANCE_DMA_EVENT_PEND, /* Waiting data phase */ + ADVANCE_DMA_RESTORE_0, + ADVANCE_DMA_RESTORE_1, + ADVANCE_DMA_RESTORE, + RESTORE_SAVE, + ADVANCE_DMA_DISCARD, + ENQUEUE_EVENT, + SEND_DATA, + RECEIVE_DATA, + BTLE_STACK_TICK_ON, + BTLE_STACK_TICK_OFF, + HEADER_RECEIVED, + HEADER_NOT_RECEIVED, + ENTER_SLEEP_FUNC, + EXIT_SLEEP_FUNC, + COMMAND_PROCESSED, + CPU_HALT0, + CPU_HALT1, + CPU_HALT2, + CPU_RUNNING0, + CPU_RUNNING1, + DEEP_SLEEP0, + DEEP_SLEEP1, + SPI_PROT_TRANS_COMPLETE, + SPI_PROT_WAITING_DATA, + EDGE_SENSITIVE, + SLEEP_CHECK_PERFORMED, + DISABLE_IRQ0, + DISABLE_IRQ1, + DMA_REARM, + DMA_TC, + IRQ_FALL, + IRQ_RISE, + TXFIFO_NE, + SPI_PROT_INIT_STATE_ANN, /* Initialization phase */ + SPI_PROT_CONFIGURED_STATE_ANN, /* Configuration phase */ + SPI_PROT_SLEEP_STATE_ANN, /* Sleep phase */ + SPI_PROT_CONFIGURED_HOST_REQ_STATE_ANN, /* Host request phase */ + SPI_PROT_CONFIGURED_EVENT_PEND_STATE_ANN, /* Event pending phase */ + SPI_PROT_WAITING_HEADER_STATE_ANN, /* Waiting header phase */ + SPI_PROT_HEADER_RECEIVED_STATE_ANN, /* Header received phase */ + SPI_PROT_WAITING_DATA_STATE_ANN, /* Waiting data phase */ + SPI_PROT_TRANS_COMPLETE_STATE_ANN, /* Transaction complete phase */ +} DebugLabel; + +#define DEBUG_ARRAY_LEN 1000 +extern DebugLabel debug_buf[DEBUG_ARRAY_LEN]; +extern uint32_t debug_cnt; +#define DEBUG_NOTES(NOTE) do{\ + debug_buf[debug_cnt] = NOTE; debug_cnt = (debug_cnt+1)%DEBUG_ARRAY_LEN;\ + }while(0) + +#define SPI_STATE_TRANSACTION(NEWSTATE) do{ \ + spi_proto_state = NEWSTATE; \ + DEBUG_NOTES(NEWSTATE ## _ANN); \ + LL_GPIO_SetOutputPin(DEBUG_GPIO_PORT, DEBUG_TEST_1_PIN); __NOP;\ + LL_GPIO_ResetOutputPin(DEBUG_GPIO_PORT, DEBUG_TEST_1_PIN);\ + }while(0) + +#else + +#define DEBUG_NOTES(NOTE) + +#define SPI_STATE_TRANSACTION(NEWSTATE) (spi_proto_state = NEWSTATE) + +#endif + +#define SPI_STATE_CHECK(STATE) (spi_proto_state==STATE) +#define SPI_STATE_FROM(STATE) (spi_proto_state>=STATE) + +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +extern void transport_layer_init(void); +extern void transport_layer_tick (void); +extern void command_received(uint8_t *cmd, uint16_t len); +extern void send_event(const uint8_t *buffer_out, uint16_t buffer_out_length, int8_t overflow_index); +extern void send_event_2buffers(const uint8_t *buffer_out1, uint16_t buffer_out_length1, const uint8_t *buffer_out2, uint16_t buffer_out_length2, int8_t overflow_index); +extern void advance_dma(void); +/* The transport layer request to process a command or event in the queue. */ +void TL_ProcessReqCallback(void); +/* A request to reset the devie has been received. */ +void TL_ResetReqCallback(void); + +#endif /* TRANSPORT_LAYER_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/blenvm.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/blenvm.c new file mode 100644 index 000000000..fa4774a60 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/blenvm.c @@ -0,0 +1,279 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file blenvm.c + * @author GPM WBL Application Team + * @brief Adaptation layer between NVM database manager and Bluetooth LE stack + * interface for NVM data. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include +#include "blenvm.h" +#include "stm32wb0x.h" +#include "nvm_db.h" +#include "nvm_db_conf.h" +#include "bleplat.h" +#include "ble_stack.h" +#include "ble_const.h" + +/** @defgroup NVM_UpperLayer NVM Upper layer + * @{ + */ + +/** @defgroup NVM_UpperLayer_TypesDefinitions Private Type Definitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup NVM_UpperLayer_Private_Defines Private Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup NVM_UpperLayer_Private_Macros Private Macros + * @{ + */ + +#define DEBUG_GPIO2_HIGH() +#define DEBUG_GPIO2_LOW() + +#ifdef DEBUG +#include +#define PRINTF(...) printf(__VA_ARGS__) +#else +#define PRINTF(...) +#endif + +/** + * @} + */ + +/** @defgroup NVM_UpperLayer_Private_Variables Private Variables + * @{ + */ + +static NVMDB_HandleType sec_gatt_db_h, device_id_db_h, *curr_handle_p; + +/** + * @} + */ + +/** @defgroup NVM_UpperLayer_External_Variables External Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup NVM_UpperLayer_Private_FunctionPrototypes Private Function Prototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup NVM_UpperLayer_Private_Functions Private Functions + * @{ + */ + +/* Implementation of the function needed by NVM manager to safely execute Flash + * operations while radio is active. */ +uint8_t NVMDB_TimeCheck(int32_t time) +{ + uint32_t current_time, next_radio_activity_time; + + current_time = HAL_RADIO_TIMER_GetCurrentSysTime(); + + if(BLE_STACK_ReadNextRadioActivity(&next_radio_activity_time) == LL_IDLE) + return TRUE; + + if((int32_t)(next_radio_activity_time - current_time) > time) + return TRUE; + + return FALSE; + +} + +/** + * @} + */ + +/** @defgroup NVM_UpperLayer_Public_Functions Public Functions + * @{ + */ + +void BLENVM_Init(void) +{ + NVMDB_Init(); + + NVMDB_HandleInit(SEC_GATT_BD, &sec_gatt_db_h); + NVMDB_HandleInit(DEVICE_ID_DB, &device_id_db_h); + curr_handle_p = &sec_gatt_db_h; +} + +BLEPLAT_NvmStatusTypeDef BLEPLAT_NvmAdd(BLEPLAT_NvmRecordTypeDef Type, + const uint8_t* pData, + uint16_t Size, + const uint8_t* pExtraData, + uint16_t ExtraSize) +{ + NVMDB_status_t ret; + + if(Type == BLEPLAT_NVM_REC_DEVICE_ID) + { + curr_handle_p = &device_id_db_h; + } + else + { + curr_handle_p = &sec_gatt_db_h; + } + + DEBUG_GPIO2_HIGH(); + + ret = NVMDB_AppendRecord(curr_handle_p, Type, Size, pData, ExtraSize, pExtraData); + + DEBUG_GPIO2_LOW(); + + if(ret == NVMDB_STATUS_OK) + { + return BLEPLAT_OK; + } + + if(ret == NVMDB_STATUS_FULL_DB) + { + return BLEPLAT_FULL; + } + + return BLEPLAT_BUSY; +} + +BLEPLAT_NvmStatusTypeDef BLEPLAT_NvmGet(BLEPLAT_NvmSeekModeTypeDef Mode, + BLEPLAT_NvmRecordTypeDef Type, + uint16_t Offset, + uint8_t* pData, + uint16_t Size) +{ + NVMDB_RecordSizeType size_out; + NVMDB_status_t ret; + NVMDB_IdType db_id; + + if(Type == BLEPLAT_NVM_REC_DEVICE_ID) + { + curr_handle_p = &device_id_db_h; + db_id = 1; + } + else + { + curr_handle_p = &sec_gatt_db_h; + db_id = 0; + } + + if(Mode == BLEPLAT_NVM_CURRENT) + { + ret = NVMDB_ReadCurrentRecord(curr_handle_p, Offset, pData, Size, &size_out); + } + else + { + if(Mode == BLEPLAT_NVM_FIRST) + { + NVMDB_HandleInit(db_id, curr_handle_p); + } + ret = NVMDB_ReadNextRecord(curr_handle_p, Type, Offset, pData, Size, &size_out); + } + + if(ret == NVMDB_STATUS_OK) + { + return BLEPLAT_OK; + } + + if(ret == NVMDB_STATUS_END_OF_DB) + { + return BLEPLAT_EOF; + } + + return BLEPLAT_BUSY; +} + +int BLEPLAT_NvmCompare(uint16_t Offset, const uint8_t* pData, uint16_t Size) +{ + int ret; + + ret = NVMDB_CompareCurrentRecord(curr_handle_p, Offset, pData, Size); + + if(ret == 0) + { + return BLEPLAT_OK; + } + else if(ret < 0) + { + return Size; + } + else + { + return BLEPLAT_EOF; + } +} + +void BLEPLAT_NvmDiscard(BLEPLAT_NvmSeekModeTypeDef Mode) +{ + DEBUG_GPIO2_HIGH(); + if(Mode == BLEPLAT_NVM_CURRENT) + { + if(curr_handle_p == &device_id_db_h) // Do not allow to erase device ID data. + { + return; + } + NVMDB_DeleteRecord(curr_handle_p); + } + else if(Mode == BLEPLAT_NVM_ALL) + { + + NVMDB_Erase(SEC_GATT_BD); + + /* Implementation that does not cause an immediate flash erase. + NVMDB_HandleInit(SEC_GATT_BD, &sec_gatt_db_h); + + while(1) + { + NVMDB_RecordSizeType size_out; + NVMDB_status_t ret; + + ret = NVMDB_ReadNextRecord(&sec_gatt_db_h, ALL_TYPES, 0, NULL, 0, &size_out); + if(ret == NVMDB_STATUS_OK) + NVMDB_DeleteRecord(&sec_gatt_db_h); + else + return; + }*/ + } + DEBUG_GPIO2_LOW(); +} + +/** + * @} + */ + +/** + * @} + */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/blenvm.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/blenvm.h new file mode 100644 index 000000000..f1883a514 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/blenvm.h @@ -0,0 +1,29 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file blenvm.h + * @author GPM WBL Application Team + * @brief Header file for NVM database manager and Bluetooth LE stack + * interface for NVM data. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef BLENVM_H +#define BLENVM_H + +void BLENVM_Init(void); + +#endif /* BLENVM_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat.c new file mode 100644 index 000000000..b61b79b9d --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat.c @@ -0,0 +1,269 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file ble_plat.c + * @author GPM WBL Application Team + * @brief Bluetooth LE stack v3.x platform interface for pka, rng, aes, + * radio timer, controller. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "bleplat.h" +#include "pka_manager.h" +#include "hw_aes.h" +#include "hw_rng.h" +#if (BLESTACK_CONTROLLER_ONLY == 0) +#include "crypto.h" +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ +#include "miscutil.h" +#include "RADIO_utils.h" +#include "osal.h" +#include "stm32wb0x.h" +#include "stm32wb0x_ll_radio.h" + +#define PLL_ADC_CALIB_CORR 2 +#define CP_ISEL_Msk (0x07UL) +#define SYNTH0_ANA_ENG (*(volatile uint32_t *)0x60001610) +#define SYNTHCAL3_ANA_TST (*(volatile uint32_t *)0x600015A4) +#define LL_DUMMY_ACCESS_ADDRESS (0x00000000U) +#define LL_DTM_ACCESS_ADDRESS (0x71764129U) + +#if defined(STM32WB06) || defined(STM32WB07) || defined(STM32WB09) +uint32_t SYNTH0_ANA_ENG_bak, PWR_ENGTRIM_bak; +#endif + +void BLEPLAT_MemCpy(void *Dest, const void *Src, unsigned int Size) +{ + Osal_MemCpy(Dest, Src, Size); +} + +void BLEPLAT_MemSet(void *Ptr, int Value, unsigned int Size) +{ + memset(Ptr, Value, Size); +} + +int BLEPLAT_MemCmp(void *S1, void *S2, unsigned int Size) +{ + return memcmp(S1, S2, Size); +} + +/** + * @brief Get Device ID, Version and Revision numbers + */ +void BLEPLAT_GetPartInfo(uint8_t *pDeviceId, uint8_t *pMajorCut, uint8_t *pMinorCut) +{ + PartInfoType partInfo; + + /* get partInfo */ + GetPartInfo(&partInfo); + + /* Set device ID */ + *pDeviceId = partInfo.die_id; + + /* Set major cut */ + *pMajorCut = partInfo.die_major; + + /* Set minor cut */ + *pMinorCut = partInfo.die_cut; +} + +BLEPLAT_PkaStatusTypeDef BLEPLAT_PkaStartP256Key(const uint32_t *private_key, BLEPLAT_PkaFuncCb funcCb) +{ + return (BLEPLAT_PkaStatusTypeDef)PKAMGR_StartP256PublicKeyGeneration(private_key, (PKAMGR_funcCB)funcCb); +} + +BLEPLAT_PkaStatusTypeDef BLEPLAT_PkaStartDHkey(uint32_t* private_key, + uint32_t* public_key, + BLEPLAT_PkaFuncCb funcCb) +{ + return (BLEPLAT_PkaStatusTypeDef)HW_PKA_StartP256DHkeyGeneration(private_key, public_key, (PKAMGR_funcCB)funcCb); +} + +void BLEPLAT_AesEcbEncrypt(const uint32_t *plainTextData, + const uint32_t *key, + uint32_t *encryptedData) +{ + HW_AES_Encrypt(plainTextData, key, encryptedData); +} +#if (BLESTACK_CONTROLLER_ONLY == 0) +int32_t BLEPLAT_AesCMACEncryptInit(BLEPLAT_AESCMACctxTypeDef *pAESCMACctx) +{ + return AES_CMAC_Encrypt_Init((AESCMACctx_stt*)pAESCMACctx); +} + +int32_t BLEPLAT_AesCMACEncryptAppend(BLEPLAT_AESCMACctxTypeDef *pAESCMACctx, + const uint8_t *pInputBuffer, + int32_t InputSize) +{ + return AES_CMAC_Encrypt_Append((AESCMACctx_stt*)pAESCMACctx, pInputBuffer, InputSize); +} + +int32_t BLEPLAT_AesCMACEncryptFinish(BLEPLAT_AESCMACctxTypeDef *pAESCMACctx, + uint8_t *pOutputBuffer, + int32_t *pOutputSize) +{ + return AES_CMAC_Encrypt_Finish((AESCMACctx_stt*)pAESCMACctx, pOutputBuffer, pOutputSize); +} +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +void BLEPLAT_RngGetRandom16(uint16_t* num) +{ + HW_RNG_GetRandom16(num); +} + +void BLEPLAT_RngGetRandom32(uint32_t* num) +{ + HW_RNG_GetRandom32(num); +} + +uint8_t BLEPLAT_DBmToPALevel(int8_t TX_dBm) +{ + return RADIO_DBmToPALevel(TX_dBm); +} + +uint8_t BLEPLAT_DBmToPALevelGe(int8_t TX_dBm) +{ + return RADIO_DBmToPALevelGe(TX_dBm); +} + +int8_t BLEPLAT_PALevelToDBm(uint8_t PA_Level) +{ + return RADIO_PALevelToDBm(PA_Level); +} + +void BLEPLAT_ReadTransmitPower(int8_t *Min_Tx_Power, int8_t *Max_Tx_Power) +{ + RADIO_ReadTransmitPower(Min_Tx_Power, Max_Tx_Power); +} + +uint8_t BLEPLAT_GetMaxPALevel(void) +{ + return RADIO_GetMaxPALevel(); +} + +uint8_t BLEPLAT_GetDefaultPALevel(void) +{ + return RADIO_GetDefaultPALevel(); +} + +void BLEPLAT_SetHighPower(uint8_t enable) +{ + RADIO_SetHighPower((FunctionalState)enable); +} + +int8_t BLEPLAT_CalculateRSSI(void) +{ + return HAL_RADIO_ReadRSSI(); +} + +int8_t BLEPLAT_UpdateAvgRSSI(int8_t avg_rssi, int8_t rssi, uint8_t rssi_filter_coeff) +{ + return RADIO_UpdateAvgRSSI(avg_rssi, rssi, rssi_filter_coeff); +} + +uint8_t BLEPLAT_GetDemodCI(void) +{ + return GetDemodCI(); +} + +void BLEPLAT_InitCTE(uint8_t smNo) +{ +#if defined(STM32WB06) || defined(STM32WB07) || defined(STM32WB09) + SYNTH0_ANA_ENG_bak = SYNTH0_ANA_ENG; + PWR_ENGTRIM_bak = PWR->ENGTRIM; + + SYNTHCAL3_ANA_TST = 0; + // Set RFD_PLL_CP_ISEL = 0 in RRM->SYNTH0_ANA_ENG + SYNTH0_ANA_ENG &= ~CP_ISEL_Msk; + PWR->ENGTRIM = 0x00000001; + + /* First packet does not have the fix, so it needs to be discarded. Set an + invalid Access Address. */ + LL_RADIO_SetAccessAddress(smNo, LL_DUMMY_ACCESS_ADDRESS); +#endif +} + +void BLEPLAT_DeinitCTE(void) +{ +#if defined(STM32WB06) || defined(STM32WB07) || defined(STM32WB09) + PWR->ENGTRIM = PWR_ENGTRIM_bak; + SYNTH0_ANA_ENG = SYNTH0_ANA_ENG_bak; + SYNTHCAL3_ANA_TST = 0; +#endif +} + +void BLEPLAT_CalibrateCTE(uint8_t smNo) +{ +#if defined(STM32WB06) || defined(STM32WB07) || defined(STM32WB09) + uint32_t dac_word = RRM->SYNTHCAL4_DIG_OUT & RRM_SYNTHCAL4_DIG_OUT_MOD_REF_DAC_WORD_OUT_Msk; + dac_word += PLL_ADC_CALIB_CORR; + dac_word &= RRM_SYNTHCAL4_DIG_OUT_MOD_REF_DAC_WORD_OUT_Msk; + // Set SYNTHCAL3_ANA_TST + SYNTHCAL3_ANA_TST = dac_word | 0x80; + + /* Restore access address. */ + LL_RADIO_SetAccessAddress(smNo, LL_DTM_ACCESS_ADDRESS); +#endif +} + +void BLEPLAT_AntIdxRemap(uint8_t AntPattLen, uint8_t *pAntRamTable, const uint8_t* pAntPatt) +{ + RADIO_AntIdxRemap(AntPattLen, pAntRamTable, pAntPatt); +} + +uint64_t BLEPLAT_GetCurrentSysTime(void) +{ + return HAL_RADIO_TIMER_GetCurrentSysTime(); + +} +uint64_t BLEPLAT_GetFutureSysTime64(uint32_t SysTime) +{ + return HAL_RADIO_TIMER_GetFutureSysTime64(SysTime); +} + +int BLEPLAT_StartTimer(BLEPLAT_TimerHandleTypeDef *TimerHandle, uint64_t Time) +{ + return HAL_RADIO_TIMER_StartVirtualTimerSysTime((VTIMER_HandleType*)TimerHandle, Time); +} + +void BLEPLAT_StopTimer(BLEPLAT_TimerHandleTypeDef *TimerHandle) +{ + HAL_RADIO_TIMER_StopVirtualTimer((VTIMER_HandleType*)TimerHandle); +} + +uint8_t BLEPLAT_SetRadioTimerValue(uint32_t Time, uint8_t EventType, uint8_t CalReq) +{ + return HAL_RADIO_TIMER_SetRadioTimerValue(Time, EventType, CalReq); +} + +uint8_t BLEPLAT_ClearRadioTimerValue(void) +{ + return HAL_RADIO_TIMER_ClearRadioTimerValue(); +} + +uint64_t BLEPLAT_GetAnchorPoint(uint64_t *pCurrentSysTime) +{ + return HAL_RADIO_TIMER_GetAnchorPoint(pCurrentSysTime); +} + +void BLEPLAT_SetRadioCloseTimeout(void) +{ + HAL_RADIO_TIMER_SetRadioCloseTimeout(); +} + +uint8_t BLEPLAT_SetRadioTimerRelativeUsValue(uint32_t RelTimeoutUs, uint8_t Tx, uint8_t PLLCal) +{ + return HAL_RADIO_TIMER_SetRadioTimerRelativeUsValue(RelTimeoutUs, Tx, PLLCal); +} diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c new file mode 100644 index 000000000..6ca286c8b --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c @@ -0,0 +1,1206 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file bleplat_cntr.c + * @author GPM WBL Application Team + * @brief This file provides implementation of BLE controller interface. + * WARNING: This module is used by Bluetooth LE stack. Do not use this + * module while Bluetooth LE stack is active. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wb0x.h" +#include "bleplat_cntr.h" +#include + +/** @defgroup BLE_Platform_Controller BLE Manager +* @{ +*/ + +/** @defgroup BLE_Platform_Controller_TypesDefinitions Private Type Definitions +* @{ +*/ +/** +* @} +*/ + +/** @defgroup BLE_Platform_Controller_Private_Defines Private Defines +* @{ +*/ + +#define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \ +__disable_irq(); \ + /* Must be called in the same or in a lower scope of ATOMIC_SECTION_BEGIN */ +#define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit) + +#define MAX_PA_LEVEL 31 +#define HP_PA_LEVEL 32 /* Fake PA level that can be reached in high power mode. */ + +#ifndef CONV_ADR +#define CONV_ADR(ADDR) ((uint8_t*)(ADDR)) +#endif + +#ifndef LL_PHY_CODED +#define LL_PHY_CODED 0x04U +#endif + +#define ANY_HW_ERROR_INTERRUPT_Msk ( \ + BLUE_STATUSREG_ADDPOINTERROR_Msk | \ + BLUE_STATUSREG_RXOVERFLOWERROR_Msk | \ + BLUE_STATUSREG_TXERROR_0_Msk | \ + BLUE_STATUSREG_TXERROR_1_Msk | \ + BLUE_STATUSREG_TXERROR_2_Msk | \ + BLUE_STATUSREG_TXERROR_3_Msk | \ + BLUE_STATUSREG_TXERROR_4_Msk | \ + BLUE_STATUSREG_ALLTABLEREADYERROR_Msk | \ + BLUE_STATUSREG_TXDATAREADYERROR_Msk | \ + BLUE_STATUSREG_NOACTIVELERROR_Msk | \ + BLUE_STATUSREG_SEMATIMEOUTERROR_Msk | \ + BLUE_STATUSREG_ACTIVE2ERROR_Msk | \ + BLUE_STATUSREG_CONFIGERROR_Msk \ + ) + +#define WAKEUPINITDELAY_MT (64U) +#define TIMER12_INIT_DELAY_CAL (63U) +#define TIMER2_INIT_DELAY_NO_CAL (9U) +#define RCV_LEN_MARGIN_US (16U) +#define TX_DELAY_START (16U) +#define TX_DELAY_END (16U) + +#define RADIO_FSM_RX_DELAY_CAL (90U) +#define RADIO_FSM_RX_DELAY_NO_CAL (50U) +#define RADIO_FSM_TX_DELAY_CAL (92U) +#define RADIO_FSM_TX_DELAY_NO_CAL (52U) + +#define RECEIVE_CAL_DELAY_CHECK (RADIO_FSM_RX_DELAY_CAL) +#define RECEIVE_NO_CAL_DELAY_CHECK (RADIO_FSM_RX_DELAY_NO_CAL) +#define TRANSMIT_CAL_DELAY_CHECK (RADIO_FSM_TX_DELAY_CAL - 2U) +#define TRANSMIT_NO_CAL_DELAY_CHECK (RADIO_FSM_TX_DELAY_NO_CAL - 2U) + +#define CONFIG_END_DURATION (20U) +#define TX_DATA_READY_CHECK (5U) +#define TX_READY_TIMEOUT (4U) + +#ifndef LL_PHY_CODED +#define LL_PHY_CODED 0x04U +#endif + +#ifndef CONV_ADR +#define CONV_ADR(ADDR) ((uint8_t*)(ADDR)) +#endif + +#ifndef BLUE_TRANS_STRUCT_PTR_CAST +#define BLUE_TRANS_STRUCT_PTR_CAST(PTR) ((BlueTransStruct*)(void*)(uint8_t*)(PTR)) +#endif + +#define PHY_1MBPS (0x0U) +#define PHY_2MBPS (0x1U) +#define PHY_CODED_S2 (0x6U) +#define PHY_CODED_S8 (0x4U) + +#define BIT_TX_SKIP (0x0UL) + +/** +* @} +*/ + +/** @defgroup BLE_Platform_Controller_Private_Variables Private Variables +* @{ +*/ + +/** +* @} +*/ + +/** @defgroup BLE_Platform_Controller_External_Variables External Variables +* @{ +*/ +/** +* @} +*/ + +/** @defgroup BLE_Platform_Controller_Private_FunctionPrototypes Private Function Prototypes +* @{ +*/ + +/** +* @} +*/ + +/** @defgroup BLE_Platform_Controller_Private_Functions Private Functions +* @{ +*/ + +/** +* @} +*/ + +/** @defgroup BLE_Platform_Controller_Public_Functions Public Functions +* @{ +*/ + +BLEPLAT_CNTR_ResultStatus BLEPLAT_CNTR_Init(void) +{ + + return BLEPLAT_CNTR_SUCCESS; +} + +BLEPLAT_CNTR_ResultStatus BLEPLAT_CNTR_Deinit(void) +{ + + return BLEPLAT_CNTR_SUCCESS; +} + +/* Moved from the Stack library to the application environment + * + */ +/* Calculate the Timeout to be programmed on Timer2 to obtain a give T_IFS + * when the next packet is a transmit one +*/ +uint32_t BLEPLAT_CNTR_GetTimer2TimeoutForIfs(uint32_t T_Ifs, BLEPLAT_CNTR_Transaction Transaction, uint8_t Cal_Enabled) +{ + uint32_t Timeout = T_Ifs; + uint32_t Tx_Delay_Comp; + uint32_t Init_Delay=0; + + if(Transaction == BLEPLAT_CNTR_RxTx) + { + /* The correction values below have been determined by sniffer + * T_IFS measurements in connection, initiating and active + * scanning + */ +#ifdef STM32WB05 + const int32_t Adjust_Value = 4; +#else + const int32_t Adjust_Value = 6; +#endif + Tx_Delay_Comp = (TX_DELAY_START>>3) + Adjust_Value; + } + else if(Transaction == BLEPLAT_CNTR_TxRx) + { + /* The correction values below have been set to correspond to the hardcoded + * values used in prrevious versions of the stack. + * They could be optimized after careful analysis of timing margins and + * AGC behavior. + */ +#ifdef STM32WB05 + const int32_t Adjust_Value = 4; +#else + const int32_t Adjust_Value = 4; +#endif + Tx_Delay_Comp = (TX_DELAY_END>>3) + Adjust_Value; + } + else if(Transaction == BLEPLAT_CNTR_TxTx) + { + /* The correction values below have been determined by sniffer + * T_IFS measurements in extended advertising (AUX_CHAIN_IND) + */ +#ifdef STM32WB05 + const int32_t Adjust_Value = 1; +#else + const int32_t Adjust_Value = 2; +#endif + Tx_Delay_Comp = ((TX_DELAY_START + TX_DELAY_END)>>3) + Adjust_Value; + } + else + { + Tx_Delay_Comp = 0; + } + + if((Transaction == BLEPLAT_CNTR_RxTx) || (Transaction == BLEPLAT_CNTR_TxTx)) + { + if(Cal_Enabled == TRUE) + { + Init_Delay = TIMER12_INIT_DELAY_CAL + RADIO_FSM_TX_DELAY_CAL; + } + else + { + Init_Delay = TIMER2_INIT_DELAY_NO_CAL + RADIO_FSM_TX_DELAY_NO_CAL; + } + } + else if((Transaction == BLEPLAT_CNTR_TxRx) || (Transaction == BLEPLAT_CNTR_RxRx)) + { + /* The calculation below is based on the following sequence: + * - When Timer2 expires the sequencer performs the 1st initialization step and sends + * a take_req to the radio + * - When TIMER12_INIT_DELAY_CAL or TIMER2_INIT_DELAY_NO_CAL expire the sequencer sends + * a tx_rx_req to the radio + * - When the radio FSM reaches the RX state (after RADIO_FSM_RX_DELAY_CAL or + * RADIO_FSM_RX_DELAY_NO_CAL) the demodulator is turned on + * + * The sum of Timer2 timeout + TIMER(1)2_INIT_DELAY(_NO)_CAL + RADIO_FSM_RX_DELAY(_NO)_CAL + * must be equal to the T IFS. + * + * The current calculation of Timer2 for TX-RX events is slightly conservative + * since it soes not consider the delay from digital modulator to antenna and from + * antenna to digital demodulator. As a consequence the demodulator is turned on + * a few microseconds earlier than stricty needed. + */ + if(Cal_Enabled == TRUE) + { + Init_Delay = TIMER12_INIT_DELAY_CAL + RADIO_FSM_RX_DELAY_CAL; + } + else + { + Init_Delay = TIMER2_INIT_DELAY_NO_CAL + RADIO_FSM_RX_DELAY_NO_CAL; + } + } + else + { + } + + Timeout -= (Init_Delay + Tx_Delay_Comp); + + return Timeout; +} + +void BLEPLAT_CNTR_ClearInterrupt(uint32_t x) +{ + LL_RADIO_BlueSetInterrupt1RegRegister(x); +} + +void BLEPLAT_CNTR_ClearSemareq(void) +{ + LL_RADIO_BlueSetClearSemaphoreRequest(0x1U); +} + +void BLEPLAT_CNTR_TxRxSkip(void) +{ + LL_RADIO_BlueSetTxRxSkip(0x1U); +} + +uint32_t* BLEPLAT_CNTR_GetCipherTextPtr() +{ + return (uint32_t*)&BLUE->MANAESCIPHERTEXT0REG; +} + +uint32_t* BLEPLAT_CNTR_GetClrTextPtr() +{ + return (uint32_t*)&BLUE->MANAESCLEARTEXT0REG; +} + +uint32_t* BLEPLAT_CNTR_GetEncKeyPtr() +{ + return (uint32_t*)&BLUE->MANAESKEY0REG; +} + +uint8_t BLEPLAT_CNTR_GetEncryptDoneStatus() +{ + return (uint8_t)!LL_RADIO_BlueGetManAESStatusBusy(); +} + +uint8_t BLEPLAT_CNTR_GetIqsamplesMissingError(void) +{ +#if defined(STM32WB09) || defined(STM32WB05) + return (uint8_t)LL_RADIO_GetIQSamplesMissingError(); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif +} + +uint8_t BLEPLAT_CNTR_GetIqsamplesNumber(void) +{ +#if defined(STM32WB09) || defined(STM32WB05) + return (uint8_t)LL_RADIO_GetIQSamplesNumber(); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif +} + +uint8_t BLEPLAT_CNTR_getIqsamplesReady(void) +{ +#if defined(STM32WB09) || defined(STM32WB05) + return (uint8_t)LL_RADIO_GetIQSamplesReady(); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif +} + +uint8_t BLEPLAT_CNTR_GetIsrLatency() +{ + return (uint8_t)LL_RADIO_BlueGetInterrupt1Latency(); +} + +uint32_t BLEPLAT_CNTR_GetTimercapture() +{ + return LL_RADIO_BlueGetTimerCapture(); +} + +void BLEPLAT_CNTR_GlobDisableBlue() +{ + LL_RADIO_GlobalDisableBlue(); +} + +void BLEPLAT_CNTR_GlobEnableBlue() +{ + LL_RADIO_GlobalEnableBlue(); +} + +void BLEPLAT_CNTR_GlobEnableIntnoactivelerrorInt() +{ + LL_RADIO_NoActiveLErrorInterrupt_Enable(); +} + +void BLEPLAT_CNTR_GlobEnableOverrunAct2Int() +{ + LL_RADIO_Active2ErrorInterrupt_Enable(); +} + +uint8_t BLEPLAT_CNTR_GlobGetDefaultAntennaid() +{ +#if defined(GLOBAL_WORD6_DEFAULTANTENNAID_Msk) + return (uint8_t)LL_RADIO_GetDefaultAntennaID(); +#else + return (uint8_t)0; +#endif +} + +uint8_t BLEPLAT_CNTR_GlobGetWakeupinitdelay() +{ + return (uint8_t) LL_RADIO_GetWakeupInitDelay(); +} + +void BLEPLAT_CNTR_GlobReloadRadioConfigP() +{ + *(uint32_t*)(RRM_BASE + 0x10U) = 0x01U; +} + +void BLEPLAT_CNTR_GlobSetChkflagautoclearena() +{ + LL_RADIO_ChkFlagAutoclearEnable_Enable(); +} + +void BLEPLAT_CNTR_GlobSetDefaultAntennaid(uint8_t x) +{ +#if defined(GLOBAL_WORD6_DEFAULTANTENNAID_Msk) + LL_RADIO_SetDefaultAntennaID((uint32_t)x); +#else + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_GlobSetInitRadioDelayTxCal(uint8_t x) +{ + LL_RADIO_SetTransmitCalDelayChk((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobSetInitRadioDelayTxNocal(uint8_t x) +{ + LL_RADIO_SetTransmitNoCalDelayChk((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobSetRadioConfigP(volatile uint32_t* x) +{ + LL_RADIO_SetRadioConfigurationAddressPointer(x[0]); +} + +void BLEPLAT_CNTR_GlobSetWakeupinitdelay(uint8_t x) +{ + LL_RADIO_SetWakeupInitDelay((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWriteConfigEnd(uint8_t x) +{ + LL_RADIO_SetConfigurationEndDuration((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWritePeriodslow(uint16_t x) +{ + /* nothing to do */ +} + +void BLEPLAT_CNTR_GlobWriteRcvdelay(uint8_t x) +{ + LL_RADIO_SetReceivedCalDelayChk((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWriteRcvdelay1(uint8_t x) +{ + LL_RADIO_SetReceivedNoCalDelayChk((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWriteSlot(uint8_t slotNo) +{ + LL_RADIO_SetCurrentConnectionMachineNumber((uint32_t) slotNo); +} + +void BLEPLAT_CNTR_GlobWriteTimer12initdelaycal(uint8_t x) +{ + LL_RADIO_SetTimer12InitDelayCal((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWriteTimer2initdelaynocal(uint8_t x) +{ + LL_RADIO_SetTimer12InitDelayNoCal((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWriteTxDataReadyCheck(uint8_t x) +{ + LL_RADIO_SetTxDataReadyCheck((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWriteTxReadyTimeout(uint8_t x) +{ + LL_RADIO_SetTransmissionReadyTimeout((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWriteTxdelay(uint8_t x) +{ + LL_RADIO_SetTxDelayStart((uint32_t) x); +} + +void BLEPLAT_CNTR_GlobWriteTxdelayEnd(uint8_t x) +{ + LL_RADIO_SetTxDelayEnd((uint32_t) x); +} + +uint32_t BLEPLAT_CNTR_IntGetIntStatusAnyHwError(uint32_t x) +{ + return (uint32_t)(x & ANY_HW_ERROR_INTERRUPT_Msk); +} + +uint32_t BLEPLAT_CNTR_IntGetIntStatusRxOverflowError(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_RXOVERFLOWERROR_Msk); +} + +uint32_t BLEPLAT_CNTR_IntGetIntStatusBitAct2Error(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_ACTIVE2ERROR_Msk); +} + +uint32_t BLEPLAT_CNTR_IntGetIntStatusBitTimerOverrun(uint32_t x) +{ + return 0; +} + +#if defined(BLUE_STATUSREG_RCVCRCERR_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusCrcErr(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_RCVCRCERR_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_DONE_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusDone(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_DONE_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_ENCERROR_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusEncErr(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_ENCERROR_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_RCVLENGTHERROR_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusLenErr(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_RCVLENGTHERROR_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_NOACTIVELERROR_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusNoactiveError(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_NOACTIVELERROR_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_TXRXSKIP_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxRxSkip(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_TXRXSKIP_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_TXERROR_1_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxError1(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_TXERROR_1_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_TXERROR_3_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxError3(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_TXERROR_3_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_RCVOK_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusRxOk(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_RCVOK_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_RCVTIMEOUT_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusTimeout(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_RCVTIMEOUT_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_TIMECAPTURETRIG_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusTrigRcv(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_TIMECAPTURETRIG_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_PREVTRANSMIT_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxDone(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_PREVTRANSMIT_Msk); +} +#endif + +#if defined(BLUE_STATUSREG_TXOK_Msk) +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxOk(uint32_t x) +{ + return (uint32_t)(x & BLUE_STATUSREG_TXOK_Msk); +} +#endif + +void BLEPLAT_CNTR_PacketClrCrcinitSel(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetCRCInitializationSelector((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x0); +} + +void BLEPLAT_CNTR_PacketClrCteSamplingEn(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetCTEAndSamplingEnable((TXRXPACK_TypeDef*)packetP, 0x0); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_PacketClrIncChan(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_IncrementerChannel_Disable((TXRXPACK_TypeDef*)packetP); +} + +void BLEPLAT_CNTR_PacketClrPllTrig(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetCalibrationRequest((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x0); +} + +void BLEPLAT_CNTR_PacketDisableWhitening(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetDisableWhitening((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +uint8_t BLEPLAT_CNTR_PacketGetCteSamplingEn(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ +#if defined(STM32WB05) || defined(STM32WB09) + return (uint8_t)LL_RADIO_GetCTEAndSamplingEnable((TXRXPACK_TypeDef *)packetP); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif + +} + +uint8_t* BLEPLAT_CNTR_PacketGetDataPtr(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + return (uint8_t*)CONV_ADR(LL_RADIO_GetDataPointer((TXRXPACK_TypeDef*)packetP)); +} + +void BLEPLAT_CNTR_PacketInitTo0(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + memset((void*)packetP, 0, sizeof(TXRXPACK_WORD_TypeDef)); +} + +void BLEPLAT_CNTR_PacketSetAdvPduFormat(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetAdvertise((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetCrcinitSel(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetCRCInitializationSelector((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetCteSamplingEn(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetCTEAndSamplingEnable((TXRXPACK_TypeDef*)packetP, 0x01); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_PacketSetDataPduFormat(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetAdvertise((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x0); +} + +void BLEPLAT_CNTR_PacketSetDataPtr(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, void* dataP) +{ + LL_RADIO_SetDataPointer((TXRXPACK_TypeDef*)packetP, BLUE_DATA_PTR_CAST(dataP)); +} + +void BLEPLAT_CNTR_PacketSetIncChan(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_IncrementerChannel_Enable((TXRXPACK_TypeDef*)packetP); +} + +void BLEPLAT_CNTR_PacketSetIntCrcErr(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_IntRcvCRCErr_Enable((TXRXPACK_TypeDef*)packetP); +} + +void BLEPLAT_CNTR_PacketSetIntDone(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_IntDone_Enable((TXRXPACK_TypeDef*)packetP); +} + +void BLEPLAT_CNTR_PacketSetIntRcvOk(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_IntRcvOk_Enable((TXRXPACK_TypeDef*)packetP); +} + +void BLEPLAT_CNTR_PacketSetIntTimeout(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_IntRcvTimeout_Enable((TXRXPACK_TypeDef*)packetP); +} + +void BLEPLAT_CNTR_PacketSetIntTrigRcv(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetIntTimeCapture((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1U); +} + +void BLEPLAT_CNTR_PacketSetIntTxOk(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetIntTxOk((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetKeepsemareq(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetKeepSemaRequest((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetNextPtr(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, BLEPLAT_CNTR_TXRXPACK_TypeDef* packetNextP) +{ + LL_RADIO_SetNextPointer((TXRXPACK_TypeDef*)packetP, (uint32_t) BLUE_STRUCT_PTR_CAST((TXRXPACK_TypeDef*)packetNextP)); +} + +void BLEPLAT_CNTR_PacketSetNextRxMode(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetNextTxMode((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x0); +} + +void BLEPLAT_CNTR_PacketSetNextSlot(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, uint8_t slot) +{ + /* nothing to do */ +} + +void BLEPLAT_CNTR_PacketSetNextTxMode(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetNextTxMode((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetNsEn(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_AutomaticSnNesnHardwareMechanism_Enable((TXRXPACK_TypeDef*)packetP); +} + +void BLEPLAT_CNTR_PacketSetPllTrig(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetCalibrationRequest((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetRxReady(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetAllTableDataReady((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetTimeout(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, uint32_t x) +{ + LL_RADIO_SetTimer2Triggering((TXRXPACK_TypeDef*)packetP, x); +} + +void BLEPLAT_CNTR_PacketSetTimer2Active(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_Timer2_Enable((TXRXPACK_TypeDef*)packetP); +} + +void BLEPLAT_CNTR_PacketSetTimerTrigDone(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetTrigDone((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetTimerTrigRcv(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetTrigRcv((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_PacketSetTxReady(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetTransmissionDataReady((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); + LL_RADIO_SetAllTableDataReady((TXRXPACK_TypeDef*)packetP, (uint32_t) 0x1); +} + +void BLEPLAT_CNTR_SetRadioConfig(uint8_t* value) +{ + /* nothing to do */ +} + +void BLEPLAT_CNTR_SetRcvLen(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, uint32_t rcvLen) +{ + (void)packetP; + LL_RADIO_SetReceiveWindowTimeout((uint32_t) (rcvLen & 0xFFFFFU)); +} + +void BLEPLAT_CNTR_SmCteOff(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetCTEDisable(smNo, 0x01); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmCteOn(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetCTEDisable(smNo, 0x00); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmEnRadioConfig(uint8_t smNo, uint32_t enable) +{ + if(enable) + LL_RADIO_RadioCommandList_Enable(smNo); + else + LL_RADIO_RadioCommandList_Disable(smNo); +} + +void BLEPLAT_CNTR_SmEncOff(uint8_t smNo) +{ + LL_RADIO_Encryption_Disable(smNo); + LL_RADIO_ReceiveEncryptionErrorInterrupt_Disable(smNo); +} + +void BLEPLAT_CNTR_SmEncOn(uint8_t smNo) +{ + LL_RADIO_Encryption_Enable(smNo); + LL_RADIO_ReceiveEncryptionErrorInterrupt_Enable(smNo); +} + +uint32_t BLEPLAT_CNTR_SmGetAccessAddr(uint8_t smNo) +{ + return LL_RADIO_GetAccessAddress(smNo); +} + +void BLEPLAT_CNTR_SmGetChannelMap(uint8_t smNo, uint8_t* chanMap) +{ + chanMap[0] = (uint8_t)(LL_RADIO_GetUsedChannelFlags_15_0(smNo)); + chanMap[1] = (uint8_t)(LL_RADIO_GetUsedChannelFlags_15_0(smNo) >> 8U); + chanMap[2] = (uint8_t)(LL_RADIO_GetUsedChannelFlags_36_16(smNo)); + chanMap[3] = (uint8_t)(LL_RADIO_GetUsedChannelFlags_36_16(smNo) >> 8U); + chanMap[4] = (uint8_t)(LL_RADIO_GetUsedChannelFlags_36_16(smNo) >> 16U); +} + +uint8_t BLEPLAT_CNTR_SmGetCteAntennaPatternLen(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + return (uint8_t)LL_RADIO_GetAntennaPatternLength(smNo); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif +} + +uint8_t BLEPLAT_CNTR_SmGetCteAodNaoa(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + return (uint8_t)LL_RADIO_GetAodNaoa(smNo); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif +} + +uint8_t BLEPLAT_CNTR_SmGetCteSlotWidth(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + return (uint8_t)LL_RADIO_GetCTESlotWidth(smNo); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif +} + +uint8_t BLEPLAT_CNTR_SmGetCteStatus(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + return (uint8_t)LL_RADIO_GetCTEDisable(smNo); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif +} + +uint8_t BLEPLAT_CNTR_SmGetCteTime(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + return (uint8_t)LL_RADIO_GetCTETime(smNo); +#elif defined(STM32WB06) || defined(STM32WB07) + return (uint8_t)0; +#endif +} + +uint32_t* BLEPLAT_CNTR_SmGetEncIvPtr(uint8_t smNo) +{ + return (uint32_t*)&(bluedata + smNo)->ENCRYPTIV[0]; +} + +uint32_t* BLEPLAT_CNTR_SmGetEncKeyPtr(uint8_t smNo) +{ + return (uint32_t*)&(bluedata + smNo)->ENCRYPTK[0]; +} + +uint8_t BLEPLAT_CNTR_SmGetEncStatus(uint8_t smNo) +{ + return (uint8_t)LL_RADIO_Encryption_IsEnabled(smNo); +} + +uint8_t BLEPLAT_CNTR_SmGetHopIncr(uint8_t smNo) +{ + return (uint8_t)LL_RADIO_GetHopIncrement(smNo); +} + +uint8_t BLEPLAT_CNTR_SmGetMode(uint8_t smNo) +{ + return LL_RADIO_TxMode_IsEnabled(smNo); +} + +uint8_t* BLEPLAT_CNTR_SmGetPrevRxPacketDataPtr(uint8_t smNo) +{ + return (uint8_t*)CONV_ADR(BLUE_TRANS_STRUCT_PTR_CAST(LL_RADIO_GetRcvPointPrevious(smNo))->DATAPTR); +} + +BLEPLAT_CNTR_TXRXPACK_TypeDef* BLEPLAT_CNTR_SmGetPrevRxPacketPtr(uint8_t smNo) +{ + return (BLEPLAT_CNTR_TXRXPACK_TypeDef*)BLUE_TRANS_STRUCT_PTR_CAST(CONV_ADR(LL_RADIO_GetRcvPointPrevious(smNo))); +} + +uint8_t* BLEPLAT_CNTR_SmGetPrevTxPacketDataPtr(uint8_t smNo) +{ + return (uint8_t*)CONV_ADR(BLUE_TRANS_STRUCT_PTR_CAST(LL_RADIO_GetTxPointPrevious(smNo))->DATAPTR); +} + +BLEPLAT_CNTR_TXRXPACK_TypeDef* BLEPLAT_CNTR_SmGetPrevTxPacketPtr(uint8_t smNo) +{ + return (BLEPLAT_CNTR_TXRXPACK_TypeDef*)BLUE_TRANS_STRUCT_PTR_CAST(CONV_ADR(LL_RADIO_GetTxPointPrevious(smNo))); +} + +uint8_t BLEPLAT_CNTR_SmGetRemapChan(uint8_t smNo) +{ + return (uint8_t)LL_RADIO_GetRemapChannel(smNo); +} + +void BLEPLAT_CNTR_SmGetRxCount(uint8_t smNo, uint32_t* packetCount) +{ + + packetCount[0] = LL_RADIO_GetPacketCounterRx_23_0(smNo); + packetCount[0] = packetCount[0] | ((uint32_t)LL_RADIO_GetPacketCounterRx_39_24(smNo) << 24U); + packetCount[1] = LL_RADIO_GetPacketCounterRx_39_24(smNo) >> 8U; +} + +uint8_t BLEPLAT_CNTR_SmGetRxPhy(uint8_t smNo) +{ + return (uint8_t)LL_RADIO_GetReceptionPhy(smNo); +} + +BLEPLAT_CNTR_TXRXPACK_TypeDef* BLEPLAT_CNTR_SmGetTxPacketPtr(uint8_t smNo) +{ + return (BLEPLAT_CNTR_TXRXPACK_TypeDef*)BLUE_TRANS_STRUCT_PTR_CAST(CONV_ADR(LL_RADIO_GetTxPoint(smNo))); +} + +uint8_t BLEPLAT_CNTR_SmGetTxPhy(uint8_t smNo) +{ + return (uint8_t)LL_RADIO_GetTransmissionPhy(smNo); +} + +uint8_t BLEPLAT_CNTR_SmGetTxPwr(uint8_t smNo) +{ + uint8_t pa_level = LL_RADIO_GetPAPower(smNo); + +#if defined(STM32WB09) + if (LL_RADIO_TxHp_IsEnabled(smNo) && (pa_level == MAX_PA_LEVEL)) + { + pa_level = HP_PA_LEVEL; + } +#endif + return pa_level; +} + +uint8_t BLEPLAT_CNTR_SmGetUnmappedChan(uint8_t smNo) +{ + return (uint8_t)LL_RADIO_GetUnmappedChannel(smNo); +} + +void BLEPLAT_CNTR_SmInitTo0(uint8_t smNo) +{ + memset((void*)&bluedata[smNo], 0, sizeof(STATMACH_TypeDef)); + BLEPLAT_CNTR_SmEnRadioConfig(smNo, 0x01); +} + +void BLEPLAT_CNTR_SmSetAccessAddr(uint8_t smNo, uint32_t x) +{ + LL_RADIO_SetAccessAddress(smNo, x); +} + +void BLEPLAT_CNTR_SmSetChannelMap(uint8_t smNo, uint8_t* chanMap) +{ + uint32_t value = (uint32_t)chanMap[0] | ((uint32_t)chanMap[1] << 8U); + LL_RADIO_SetUsedChannelFlags_15_0(smNo, value); + value = (uint32_t)chanMap[2] | ((uint32_t)chanMap[3] << 8U) | ((uint32_t)chanMap[4] << 16U); + LL_RADIO_SetUsedChannelFlags_36_16(smNo, value); +} + +void BLEPLAT_CNTR_SmSetCrcInit(uint8_t smNo, uint32_t x) +{ + LL_RADIO_SetCRCInitializationValue(smNo, x); +} + +void BLEPLAT_CNTR_SmSetCteAntennaPatternLen(uint8_t smNo, uint8_t antPattLen) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetAntennaPatternLength(smNo, (uint32_t) antPattLen); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +uint32_t BLEPLAT_CNTR_SmGetCteAntennaPatternPtr(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + return LL_RADIO_GetAntennaPatternPtr(smNo); +#elif defined(STM32WB06) || defined(STM32WB07) + return 0x00UL; +#endif +} + +void BLEPLAT_CNTR_SmSetCteAntennaPatternPtr(uint8_t smNo, uint8_t* antPattP) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetAntennaPatternPtr(smNo, (uint32_t)(uintptr_t)antPattP); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmSetCteAoa(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetAodNaoa(smNo, 0x0); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmSetCteAod(uint8_t smNo) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetAodNaoa(smNo, 0x01); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmSetCteIqsamplesPtr(uint8_t smNo, uint32_t* iqSamplesP) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetIQSamplesPtr(smNo, (uint32_t)(uintptr_t)iqSamplesP); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmSetCteMaxIqsamplesNumb(uint8_t smNo, uint8_t iqsamplesNumb) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetMaximumIQSamplesNumber(smNo, (uint32_t) iqsamplesNumb); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmSetCteSlotWidth(uint8_t smNo, uint32_t cteSlot) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetCTESlotWidth(smNo, cteSlot); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmSetCteTime(uint8_t smNo, uint8_t cteTime) +{ +#if defined(STM32WB05) || defined(STM32WB09) + LL_RADIO_SetCTETime(smNo, (uint32_t) cteTime); +#elif defined(STM32WB06) || defined(STM32WB07) + /* nothing to do */ +#endif +} + +void BLEPLAT_CNTR_SmSetDataLength(uint8_t smNo, uint8_t length) +{ + LL_RADIO_SetMaximumReceiveLength(smNo, (uint32_t) length); +} + +void BLEPLAT_CNTR_SmSetDataLengthExtnEn(uint8_t smNo) +{ + /* nothing to do */ +} + +void BLEPLAT_CNTR_SmSetHopIncr(uint8_t smNo, uint8_t x) +{ + LL_RADIO_SetHopIncrement(smNo, (uint32_t) x); +} + +void BLEPLAT_CNTR_SmSetRemapChan(uint8_t smNo, uint8_t chan) +{ + LL_RADIO_SetRemapChannel(smNo, chan); +} + +void BLEPLAT_CNTR_SmSetRxCount(uint8_t smNo, uint32_t* packetCount) +{ + LL_RADIO_SetPacketCounterRx_23_0(smNo, (uint32_t) packetCount[0]); + uint32_t value = (uint32_t)(packetCount[1] << 8U) | (uint32_t)(packetCount[0] >> 24U); + LL_RADIO_SetPacketCounterRx_39_24(smNo, value); +} + +void BLEPLAT_CNTR_SmSetRxCountDirectionBit(uint8_t smNo) +{ + uint32_t value = LL_RADIO_GetPacketCounterRx_39_24(smNo) | 0x8000U; + LL_RADIO_SetPacketCounterRx_39_24(smNo, value); +} + +void BLEPLAT_CNTR_SmSetRxMode(uint8_t smNo) +{ + LL_RADIO_TxMode_Disable(smNo); +} + +void BLEPLAT_CNTR_SmSetRxPacketPtr(uint8_t smNo, BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetRcvPoint(smNo, (uint32_t) BLUE_STRUCT_PTR_CAST((TXRXPACK_TypeDef*)packetP)); +} + +void BLEPLAT_CNTR_SmSetRxPhy(uint8_t smNo, uint8_t rxPhy) +{ + LL_RADIO_SetReceptionPhy(smNo, (uint32_t) rxPhy); +} + +void BLEPLAT_CNTR_SmSetTxCount(uint8_t smNo, uint32_t* packetCount) +{ + LL_RADIO_SetPacketCounterTx_31_0(smNo, (uint32_t) packetCount[0]); + LL_RADIO_SetPacketCounterTx_39_32(smNo, (uint32_t) packetCount[1]); +} + +void BLEPLAT_CNTR_SmSetTxCountDirectionBit(uint8_t smNo) +{ + uint32_t value = (LL_RADIO_GetPacketCounterTx_39_32(smNo) | 0x00000080U); + LL_RADIO_SetPacketCounterTx_39_32(smNo, value); +} + +void BLEPLAT_CNTR_SmSetTxMode(uint8_t smNo) +{ + LL_RADIO_TxMode_Enable(smNo); +} + +void BLEPLAT_CNTR_SmSetTxPacketPtr(uint8_t smNo, BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP) +{ + LL_RADIO_SetTxPoint(smNo, (uint32_t) BLUE_STRUCT_PTR_CAST((TXRXPACK_TypeDef*)packetP)); +} + +void BLEPLAT_CNTR_SmSetTxPhy(uint8_t smNo, uint8_t txPhy) +{ + LL_RADIO_SetTransmissionPhy(smNo, (uint32_t) txPhy); +} + +void BLEPLAT_CNTR_SmEnTxHp(uint8_t smNo, uint8_t enable) +{ +#if defined(STM32WB09) + if(enable) + { + LL_RADIO_TxHp_Enable(smNo); + } + else + { + LL_RADIO_TxHp_Disable(smNo); + } +#endif +} + +/* Consider PA Level 32 the one used to enable high power. */ +void BLEPLAT_CNTR_SmSetTxPwr(uint8_t smNo, uint8_t paLevel) +{ +#if defined(STM32WB09) + if(paLevel == HP_PA_LEVEL) + { + LL_RADIO_TxHp_Enable(smNo); + paLevel = MAX_PA_LEVEL; + } + else + { + LL_RADIO_TxHp_Disable(smNo); + } +#endif + + LL_RADIO_SetPAPower(smNo, (uint32_t) paLevel); +} + +void BLEPLAT_CNTR_SmSetUnmappedChan(uint8_t smNo, uint8_t chan) +{ + LL_RADIO_SetUnmappedChannel(smNo, (uint32_t) chan); +} + +void BLEPLAT_CNTR_SmToggleNesn(uint8_t smNo) +{ + LL_RADIO_ToggleNextExpectedSequenceNumber(smNo); +} + +void BLEPLAT_CNTR_SmToggleSn(uint8_t smNo) +{ + LL_RADIO_ToggleSequenceNumber(smNo); +} + +void BLEPLAT_CNTR_StartEncrypt() +{ + LL_RADIO_BlueSetManAESCmdStart(0x1U); +} + +uint32_t BLEPLAT_CNTR_TimeDiff(uint32_t x, uint32_t y) +{ + return (uint32_t)(x - y); +} + +uint8_t BLEPLAT_CNTR_DemodDelaySt(uint8_t RxPHY) +{ + return (uint8_t)((LL_PHY_CODED == RxPHY) ? 0x9DU : 0x12U); +} + +/** +* @} +*/ + +/** +* @} +*/ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Config/Debug_GPIO/app_debug.c b/lib/stm32wb0/BLE_TransparentMode/System/Config/Debug_GPIO/app_debug.c new file mode 100644 index 000000000..b3e4e24bd --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Config/Debug_GPIO/app_debug.c @@ -0,0 +1,71 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file app_debug.c + * @author GPM WBL Application Team + * @brief Real Time Debug module application side APIs + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include "app_debug.h" + +/****************************/ +/** Application debug APIs **/ +/****************************/ + +void APP_DEBUG_SIGNAL_SET(app_debug_signal_t signal) +{ +#if(RT_DEBUG_GPIO_MODULE == 1) + GENERIC_DEBUG_GPIO_SET(signal, app_debug_table); +#endif /* RT_DEBUG_GPIO_MODULE */ +} +void APP_DEBUG_SIGNAL_RESET(app_debug_signal_t signal) +{ +#if(RT_DEBUG_GPIO_MODULE == 1) + GENERIC_DEBUG_GPIO_RESET(signal, app_debug_table); +#endif /* RT_DEBUG_GPIO_MODULE */ +} + +void APP_DEBUG_SIGNAL_TOGGLE(app_debug_signal_t signal) +{ +#if(RT_DEBUG_GPIO_MODULE == 1) + GENERIC_DEBUG_GPIO_TOGGLE(signal, app_debug_table); +#endif /* RT_DEBUG_GPIO_MODULE */ +} + +/*******************************/ +/** Debug GPIO Initialization **/ +/*******************************/ + +void RT_DEBUG_GPIO_Init(void) +{ +#if(RT_DEBUG_GPIO_MODULE == 1) + GPIO_InitTypeDef GPIO_InitStruct = {0}; + uint32_t general_table_size = sizeof(general_debug_table)/sizeof(general_debug_table[0]); + + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.Alternate = 0; + + for(unsigned int cpt = 0; cptMANAESKEY0REG = key[0]; + BLUE->MANAESKEY1REG = key[1]; + BLUE->MANAESKEY2REG = key[2]; + BLUE->MANAESKEY3REG = key[3]; + + /* Write the plain text data in the BLE register */ + BLUE->MANAESCLEARTEXT0REG = plainTextData[0]; + BLUE->MANAESCLEARTEXT1REG = plainTextData[1]; + BLUE->MANAESCLEARTEXT2REG = plainTextData[2]; + BLUE->MANAESCLEARTEXT3REG = plainTextData[3]; + + HW_AES_Start(); + + /* Read the plain text data in the BLE register */ + encryptedData[0] = BLUE->MANAESCIPHERTEXT0REG; + encryptedData[1] = BLUE->MANAESCIPHERTEXT1REG; + encryptedData[2] = BLUE->MANAESCIPHERTEXT2REG; + encryptedData[3] = BLUE->MANAESCIPHERTEXT3REG; + + } while (priv_start_cnt != start_cnt); + + return HW_AES_SUCCESS; +} + +/** + * @brief Function to start the AES 128 encryption in blocking mode. + * @param None + * + * @retval i + */ +__STATIC_INLINE uint8_t HW_AES_Start(void) +{ + volatile uint8_t i = 100U; + + /* Start AES encryption */ + LL_AES_StartManualEncription(BLUE); + do + { + i--; + if( !LL_AES_IsBusy(BLUE) ) + { + break; + } + } while (i != 0U); + + return i; +} + +/** +* @} +*/ + +/** @defgroup AES_Manager_Private_Functions Private Functions +* @{ +*/ + +/** + * @brief AES manual encryption Start function. + * @rmtoll MANAESCMDREG START LL_AES_StartManualEncription + * @param BLUEx BLUE Instance + * @retval None + */ +__STATIC_INLINE void LL_AES_StartManualEncription(BLUE_TypeDef *BLUEx) +{ + SET_BIT(BLUEx->MANAESCMDREG, BLUE_MANAESCMDREG_START); +} + +/** + * @brief Indicate if AES is busy + * @rmtoll MANAESSTATREG BUSY LL_AES_IsBusy + * @param BLUEx BLUE Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_AES_IsBusy(BLUE_TypeDef *BLUEx) +{ + return ((READ_BIT(BLUEx->MANAESSTATREG, BLUE_MANAESSTATREG_BUSY) == (BLUE_MANAESSTATREG_BUSY)) ? 1U : 0U); +} + +/** +* @} +*/ + +/** +* @} +*/ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_aes.h b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_aes.h new file mode 100644 index 000000000..b28e95cfe --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_aes.h @@ -0,0 +1,90 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file hw_aes.h + * @author GPM WBL Application Team + * @brief This file contains all the functions prototypes for the AES MANAGER + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef HW_AES_H +#define HW_AES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include + +/** @addtogroup HW_AES_Peripheral AES MANAGER + * @{ + */ + +/** @defgroup HW_AES_Exported_Types Exported Types + * @{ + */ + +/* Enumerated values used to report the AES result status after a process */ +typedef enum +{ + HW_AES_SUCCESS = 0, + HW_AES_ERROR +} HW_AES_ResultStatus; + +/** + * @} + */ + +/** @defgroup HW_AES_Exported_Constants Exported Constants + * @{ + */ +/** + * @} + */ + +/** @defgroup HW_AES_Exported_Macros Exported Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup HW_AES_Exported_Functions Exported Functions + * @{ + */ +HW_AES_ResultStatus HW_AES_Init(void); + +HW_AES_ResultStatus HW_AES_Deinit(void); + +HW_AES_ResultStatus HW_AES_Encrypt(const uint32_t *plainTextData, const uint32_t *key, uint32_t *encryptedData); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* HW_AES_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.c b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.c new file mode 100644 index 000000000..70737556e --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.c @@ -0,0 +1,1118 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file hw_pka.c + * @author GPM WBL Application Team + * @brief This file implements utility functions for PKA on stm32wb09 + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wb0x.h" +#include "pka_manager.h" +#include "stm32wb0x_ll_pka.h" +#include "hw_pka.h" + +/** @defgroup PKA_Manager PKA Manager +* @{ +*/ + +#if defined(STM32WB09) || defined(STM32WB05) +/** @defgroup PKA_Manager_TypesDefinitions Private Type Definitions +* @{ +*/ +/* Internal state*/ +typedef enum +{ + HW_PKA_STEP_0 = 0x0, + HW_PKA_STEP_1, + HW_PKA_STEP_2, + HW_PKA_STEP_3, + HW_PKA_STEP_4, + HW_PKA_STEP_5, + HW_PKA_STEP_6, + HW_PKA_STEP_7, + HW_PKA_STEP_8, + HW_PKA_STEP_9, + HW_PKA_STEP_10, + HW_PKA_STEP_11, + HW_PKA_STEP_12, + HW_PKA_STEP_13, + HW_PKA_STEP_END_SUCCESS +} StateMachine_Step; + +typedef enum +{ + HW_PKA_OPERATION_NONE = 0, + HW_PKA_OPERATION_P256 +} StateMachine_operation; + +/** +* @} +*/ +#endif /* STM32WB09 STM32WB05 */ + +/** @defgroup PKA_Manager_Private_Macros Private Macros +* @{ +*/ +static uint32_t ret[24] = {0}; + +#ifdef STM32WB05 +static uint32_t T[4][8] = {0}; +#endif /* STM32WB05 */ + +#if defined(STM32WB06) || defined(STM32WB07) +/* 0b0000 00XY. X: PKA_DATA_PCX error Y: PKA_DATA_PCY error */ +static uint8_t PKA_SetDataError = 0x00; + +#define HW_PKA_RAM_ECC_ADDR_KP_ERROR (PKA_RAM_BASE) +#define HW_PKA_RAM_ECC_ADDR_K (PKA_RAM_BASE + 0x6C) +#define HW_PKA_RAM_ECC_ADDR_PX (PKA_RAM_BASE + 0x90) +#define HW_PKA_RAM_ECC_ADDR_PY (PKA_RAM_BASE + 0xB4) + +#define HW_PKA_DATA_SK 0x01 /* PKA select data for K value */ +#define HW_PKA_DATA_PCX 0x02 /* PKA select data for Point X coordinate value */ +#define HW_PKA_DATA_PCY 0x03 /* PKA select data for Point Y coordinate value */ +#endif /* STM32WB06 STM32WB07 */ + +#if defined(STM32WB09) || defined(STM32WB05) +static volatile uint32_t internalStateMachine_Operation = HW_PKA_OPERATION_NONE; +static volatile uint32_t internalStateMachine_Step = 0; + +static volatile uint32_t bufferSecretKey[8] = {0}; +static volatile uint32_t bufferPublicKey[16] = {0}; + +#define VERIFY_ECC_SCALAR_MUL_RESULT 1 + +static const uint32_t HW_PKA_oplen[2] = { +0x100, +0x0 +}; + +static const uint32_t HW_PKA_nbits_k[2] = { +0x100, +0x0 +}; + +static const uint32_t HW_PKA_nbits_m[2] = { +0x100, +0x0 +}; + +static const uint32_t HW_PKA_a_coeff_sign[2] = { +0x1, +0x0 +}; + +static const uint32_t HW_PKA_P256_gfp[8] = +{ + 0xFFFFFFFF, /* LSB */ + 0xFFFFFFFF, + 0xFFFFFFFF, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000001, + 0xFFFFFFFF, +}; + +static const uint32_t HW_PKA_P256_r2[8] = +{ + 0x00000002, /* LSB */ + 0x00000005, + 0x00000003, + 0xFFFFFFFE, + 0xFFFFFFF9, + 0xFFFFFFFB, + 0xFFFFFFFC, + 0xFFFFFFFC, +}; + +static const uint32_t HW_PKA_P256_a[8] = +{ + 0x00000003, /* LSB */ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, +}; + +static const uint32_t HW_PKA_P256_b[8] = +{ + 0x27D2604B, /* LSB */ + 0x3BCE3C3E, + 0xCC53B0F6, + 0x651D06B0, + 0x769886BC, + 0xB3EBBD55, + 0xAA3A93E7, + 0x5AC635D8, +}; + +/** +* @} +*/ +#endif /* STM32WB09 STM32WB05 */ + +/** @defgroup PKA_Manager_External_Variables External Variables +* @{ +*/ + +extern PKA_HandleTypeDef hpka; + +/** +* @} +*/ + +/** @defgroup PKA_Manager_Private_FunctionPrototypes Private Function Prototypes +* @{ +*/ +void HW_PKA_ExitWithError(uint32_t errorCode); +void HW_PKA_ProcEnd_StateMachine(void); +void (*HW_PKA_funcCB_LP)(PKAMGR_ResultStatus error_code, void *args_p); +#if defined(STM32WB09) || defined(STM32WB05) +void HW_PKA_Comparison( const uint32_t* opLen, const uint32_t* op1 , const uint32_t* op2 ); +void HW_PKA_P256_StartPointCheck( const uint32_t* x, const uint32_t* y ); +uint32_t HW_PKA_IsPointCheckOk(void); +uint32_t HW_PKA_IsRangeCheckOk(void); +void HW_PKA_P256_StartEccScalarMul( const uint32_t* k, const uint32_t* pX, const uint32_t* pY ); +void HW_PKA_P256_ReadEccScalarMul(uint32_t* pX, uint32_t* pY); +uint32_t HW_PKA_isStartPoint(const uint32_t* p); +#endif /* STM32WB09 STM32WB05 */ +#ifdef STM32WB05 +void HW_PKA_MontgomeryMultiplication( uint32_t opLen, const uint32_t* op1, const uint32_t* op2, const uint32_t* p); +#endif /* STM32WB05 */ +/** +* @} +*/ + +/** @defgroup PKA_Manager_Private_Functions Private Functions +* @{ +*/ + +#if defined STM32WB09 + +void HW_PKA_WriteSingleInput( uint32_t index, int size, const uint32_t* word ) +{ + /* Write the single word into PKA RAM */ + for(int i=0; iRAM[index++] = *word++; + } +} + +#elif defined STM32WB05 + +void HW_PKA_WriteSingleInput( uint32_t index, uint32_t word ) +{ + /* Write the single word into PKA RAM */ + PKA->RAM[index] = word; +} + +#endif + +#if defined STM32WB09 + +void HW_PKA_WriteOperand( uint32_t index, int size, const uint32_t* in ) + { + uint32_t* pka_ram = (uint32_t*)&PKA->RAM[index]; + /* Write the input data into PKA RAM */ + for ( ; size > 0; size-- ) + { + *pka_ram++ = *in++; + } + /* Write extra zeros into PKA RAM */ + *pka_ram++ = 0; + *pka_ram = 0; +} + +#elif defined STM32WB05 + +void HW_PKA_WriteOperand( uint32_t index, int size, const uint32_t* in ) +{ + uint32_t* pka_ram = (uint32_t*)&PKA->RAM[index]; + /* Write the input data into PKA RAM */ + for ( ; size > 0; size-- ) + { + *pka_ram++ = *in++; + } + /* Write extra zeros into PKA RAM */ + *pka_ram = 0; +} + +#endif + +#if defined(STM32WB05) || defined(STM32WB09) +void HW_PKA_ReadResult( uint32_t index, int size, uint32_t* out ) +{ + uint32_t* pka_ram = (uint32_t*)&PKA->RAM[index]; + /* Read from PKA RAM */ + for ( ; size > 0; size-- ) + { + *out++ = *pka_ram++; + } +} +#endif /* STM32WB05 STM32WB09 */ + +#if defined STM32WB09 + +/** + * @brief + * @param index PKA RAM index at 32 bit + * @param out must be 64bit + * + */ +void HW_PKA_ReadSingleOutput( uint32_t index, uint32_t* out) +{ + HW_PKA_ReadResult(index, 2, out); +} + +#elif defined STM32WB05 + +/** + * @brief + * @param + * @param + * + */ +uint32_t HW_PKA_ReadSingleOutput( uint32_t index ) +{ + /* Read a single word from PKA RAM */ + return PKA_RAM->RAM[index]; +} + +#endif /* STM32WB09 elif STM32WB05 */ + +#if defined(STM32WB06) || defined(STM32WB07) + +void HAL_PKA_OperationCpltCallback(PKA_HandleTypeDef *hpka) +{ + PKAMGR_Unlock(); + HW_PKA_IRQHandler(); + PKAMGR_IRQCallback(); +} + +void HAL_PKA_ErrorCallback(PKA_HandleTypeDef *hpka) +{ + PKAMGR_Unlock(); + PKAMGR_IRQCallback(); +} + +/** @defgroup PKA_SELECT_DATA_VALUE Select Data for PKA operation + * @{ + */ +/** + * @} + */ + +/** + * @brief Internal Utility for PKA key range check + * @param a: pka key + * b: reference key + * bufferSize: key size + * @retval check result + */ +static int rev_memcmp(uint8_t *a, const uint8_t *b, uint8_t bufferSize) +{ + uint_fast8_t i = bufferSize; + int retval = 0; + + do + { + i--; + retval = (int)a[i] - (int)b[i]; + if (retval !=0) + { + break; + } + } while (i != 0U); + + return retval; +} + +/** + * @brief Write the PKA RAM with the input data. + * @param dataType: select the region of PKA RAM to write: + * @arg HW_PKA_DATA_SK is the K value + * @arg HW_PKA_DATA_PCX is the point X coordinate + * @arg HW_PKA_DATA_PCY is the point Y coordinate + * @param srcData Source Data + * @retval ErrorStatus + */ +ErrorStatus HW_PKA_SetData(uint8_t dataType, uint32_t* srcData) +{ + const uint8_t P256_P_LE[32] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff,0xff}; + const uint8_t BLE_P256_ABELIAN_ORDER_R_LE[32] = {0x51,0x25,0x63,0xFC,0xC2,0xCA,0xB9,0xF3,0x84,0x9E,0x17,0xA7,0xAD,0xFA,0xE6,0xBC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF}; + uint32_t StartAddress; + uint8_t idx; + + /* Check the parameters */ + assert_param(IS_LL_PKA_CMD(dataType)); + + if (dataType == HW_PKA_DATA_SK) { + if (rev_memcmp((uint8_t *) srcData, (uint8_t *)BLE_P256_ABELIAN_ORDER_R_LE, 32) >= 0) { + PKA_SetDataError |= 0x04; + return ERROR; + } + else { + PKA_SetDataError &= ~0x04; + } + StartAddress = HW_PKA_RAM_ECC_ADDR_K; + } + + else if (dataType == HW_PKA_DATA_PCX) { + if (rev_memcmp((uint8_t *) srcData, (uint8_t *)P256_P_LE, 32) >= 0) { + PKA_SetDataError |= 0x01; + return ERROR; + } + else { + PKA_SetDataError &= ~0x01; + } + StartAddress = HW_PKA_RAM_ECC_ADDR_PX; + + } + + else if (dataType == HW_PKA_DATA_PCY) { + if (rev_memcmp((uint8_t *) srcData, (uint8_t *)P256_P_LE, 32) >= 0) { + PKA_SetDataError |= 0x02; + return ERROR; + } + else { + PKA_SetDataError &= ~0x02; + } + StartAddress = HW_PKA_RAM_ECC_ADDR_PY; + } + else + return ERROR; + + /* Write the source data to target PKA RAM address. */ + for (idx = 0; idx<8; idx++) + { + *(uint32_t *)(StartAddress + 4*idx) = srcData[idx]; + } + + /* A 9th word of zeros must be added */ + *(uint32_t *)(StartAddress + 32UL) = 0x00000000; + + return SUCCESS; +} + +/** + * @brief Get from the PKA RAM the output data. + * @param dataType: select the region of PKA RAM to read: + * @arg HW_PKA_DATA_SK is the K value + * @arg HW_PKA_DATA_PCX is the point X coordinate + * @arg HW_PKA_DATA_PCY is the point Y coordinate + * @param dataTarget PKA RAM output data + * @retval ErrorStatus + */ +ErrorStatus HW_PKA_GetData(uint8_t dataType, uint8_t* dataTarget) +{ + uint32_t StartAddress; + + /* Check the parameters */ + assert_param(IS_LL_PKA_CMD(dataType)); + + if (dataType == HW_PKA_DATA_SK) + StartAddress = HW_PKA_RAM_ECC_ADDR_K; + else if (dataType == HW_PKA_DATA_PCX) + StartAddress = HW_PKA_RAM_ECC_ADDR_PX; + else if (dataType == HW_PKA_DATA_PCY) + StartAddress = HW_PKA_RAM_ECC_ADDR_PY; + else return ERROR; + + /* Read the data to target PKA RAM address. */ + for(uint8_t i=0;i<32;i++) { + dataTarget[i] = ((uint8_t *)StartAddress)[i]; + } + + return SUCCESS; +} + +#endif /* STM32WB06 STM32WB07 */ + +void HW_PKA_Init(void) +{ + PKAMGR_Init(); + /* Activate interrupts */ + LL_PKA_EnableIT_ADDRERR(PKA); + LL_PKA_EnableIT_RAMERR(PKA); + LL_PKA_EnableIT_PROCEND(PKA); +} + +uint8_t HW_PKA_PowerSaveLevelCheck(void) +{ + if(PKAMGR_SleepCheck()==PKAMGR_SUCCESS) + { + return POWER_SAVE_LEVEL_STOP; + } + else // PKA on going + { + return POWER_SAVE_LEVEL_CPU_HALT; + } +} + +/** + * @brief + * @param + * @param + * + */ +PKAMGR_ResultStatus HW_PKA_StartP256DHkeyGeneration(const uint32_t* secretKey, const uint32_t* publicKey, PKAMGR_funcCB funcCB) +{ + /* Set the PKA internal state to busy */ + if(PKAMGR_Lock()!=PKAMGR_SUCCESS) + return PKAMGR_ERR_BUSY; + + HW_PKA_funcCB_LP = funcCB; +#if defined(STM32WB09) || defined(STM32WB05) + /* Save input data */ + for(int i=0;i<8;i++) + bufferSecretKey[i] = secretKey[i]; + for(int i=0;i<16;i++) + bufferPublicKey[i] = publicKey[i]; + + if(HW_PKA_isStartPoint(publicKey)) + { + /* p256 public key generation */ + internalStateMachine_Step = HW_PKA_STEP_3; + internalStateMachine_Operation = HW_PKA_OPERATION_P256; + HW_PKA_P256_StartEccScalarMul( secretKey, (uint32_t *)&publicKey[0], (uint32_t *)&publicKey[8] ); + } + else + { + /* p256 dhkey generation */ + internalStateMachine_Step = HW_PKA_STEP_0; + internalStateMachine_Operation = HW_PKA_OPERATION_P256; + /* Call the PKA range check operation for public key X coordinate */ + HW_PKA_Comparison(HW_PKA_oplen, (uint32_t *)&publicKey[0], HW_PKA_P256_gfp); + +#if !defined(ASYNC_MODE) + // blocking mode (initial check steps interval time: 0.476ms) + while(internalStateMachine_Step!=HW_PKA_STEP_1); + + /* Test result of range check operation for public key X coordinate */ + if( !HW_PKA_IsRangeCheckOk() ) + { + internalStateMachine_Operation = HW_PKA_OPERATION_NONE; + internalStateMachine_Step = HW_PKA_STEP_0; + PKAMGR_Unlock(); + return PKAMGR_ERR_PARAM; + } + else + { + /* Call the PKA range check operation for public key Y coordinate */ + HW_PKA_Comparison(HW_PKA_oplen, (uint32_t *)&bufferPublicKey[8], HW_PKA_P256_gfp); + } + + while(internalStateMachine_Step!=HW_PKA_STEP_2); + + /* Test result of range check operation for public key X coordinate */ + if( !HW_PKA_IsRangeCheckOk() ) + { + internalStateMachine_Operation = HW_PKA_OPERATION_NONE; + internalStateMachine_Step = HW_PKA_STEP_0; + PKAMGR_Unlock(); + return PKAMGR_ERR_PARAM; + } + else + { + /* Call the PKA point check operation for remote public key */ + HW_PKA_P256_StartPointCheck( (uint32_t *)&bufferPublicKey[0], (uint32_t *)&bufferPublicKey[8] ); + } + + while(internalStateMachine_Step!=HW_PKA_STEP_3); + + /* Test result of point check operation for remote public key */ + if ( !HW_PKA_IsPointCheckOk() ) + { + internalStateMachine_Operation = HW_PKA_OPERATION_NONE; + internalStateMachine_Step = HW_PKA_STEP_0; + PKAMGR_Unlock(); + return PKAMGR_ERR_PARAM; + } + else + { + /* Call the PKA scalar multiplication with the local private key + as k and the remote public key as starting point, + in order to compute the DH key */ + HW_PKA_P256_StartEccScalarMul( (uint32_t *)&bufferSecretKey[0], (uint32_t *)&bufferPublicKey[0], (uint32_t *)&bufferPublicKey[8] ); + } + +#endif /* !defined(ASYNC_MODE) */ + } +#endif /* STM32WB09 STM32WB05 */ + +#if defined(STM32WB06) || defined(STM32WB07) + /* ***** PROCEDURE FOR NewPoint ***** */ + + /* Insert the random K for NewPoint */ + if(HW_PKA_SetData(HW_PKA_DATA_SK, (uint32_t*) secretKey) == ERROR) + { + PKAMGR_Unlock(); + return PKAMGR_ERR_PARAM; + } + + /* Insert the initial starting point coordinates */ + if(HW_PKA_SetData(HW_PKA_DATA_PCX, (uint32_t *)&publicKey[0]) == ERROR) + { + PKAMGR_Unlock(); + return PKAMGR_ERR_PARAM; + } + + if( HW_PKA_SetData(HW_PKA_DATA_PCY, (uint32_t *)&publicKey[8]) == ERROR) + { + PKAMGR_Unlock(); + return PKAMGR_ERR_PARAM; + } + + /* Launch the computation in interrupt mode */ + LL_PKA_Start(PKA); +#endif /* STM32WB06 STM32WB07 */ + + return PKAMGR_SUCCESS; +} + +#if defined(STM32WB09) || defined(STM32WB05) +/** + * @brief + * @param + * @param + * + */ +void HW_PKA_ExitWithError(uint32_t errorCode) +{ + internalStateMachine_Operation = 0; + internalStateMachine_Step = 0; + PKAMGR_Unlock(); + ret[0]=errorCode; + for(int i=0; i<8; i++) + { + ret[i+16] = bufferSecretKey[i]; + } + HW_PKA_funcCB_LP(PKAMGR_ERROR, ret); +} + +/** + * @brief + * @param + * @param + * + */ +void HW_PKA_ProcEnd_StateMachine(void) +{ + if(internalStateMachine_Operation == HW_PKA_OPERATION_P256) + { + switch(internalStateMachine_Step) + { + case HW_PKA_STEP_0: + internalStateMachine_Step = HW_PKA_STEP_1; + + break; + case HW_PKA_STEP_1: + internalStateMachine_Step = HW_PKA_STEP_2; + break; + case HW_PKA_STEP_2: + internalStateMachine_Step = HW_PKA_STEP_3; + break; + case HW_PKA_STEP_3: + /* Read the PKA scalar multiplication result which is the DH key */ + for(int i=0;i<8;i++) + ret[i] = bufferSecretKey[i]; + HW_PKA_P256_ReadEccScalarMul( (uint32_t *)&ret[8], (uint32_t *)&ret[16] ); +#ifdef STM32WB09 + internalStateMachine_Step = HW_PKA_STEP_END_SUCCESS; + HW_PKA_ProcEnd_StateMachine(); +#endif /* STM32WB09 */ + +#ifdef STM32WB05 + if( VERIFY_ECC_SCALAR_MUL_RESULT ) + { + internalStateMachine_Step = HW_PKA_STEP_4; + HW_PKA_ReadResult( 739, 8, &ret[0] ); + HW_PKA_MontgomeryMultiplication( 256, &ret[0], &ret[0], HW_PKA_P256_gfp); + } + else + { + internalStateMachine_Step = HW_PKA_STEP_END_SUCCESS; + HW_PKA_ProcEnd_StateMachine(); + } + break; + case HW_PKA_STEP_4: + HW_PKA_ReadResult( 500, 8, &T[0][0] ); + + internalStateMachine_Step = HW_PKA_STEP_5; + + /* Set the point coordinate X1 */ + HW_PKA_ReadResult( 634, 8, &ret[0]); + HW_PKA_MontgomeryMultiplication( 256, &ret[0], &T[0][0], HW_PKA_P256_gfp); + + break; + case HW_PKA_STEP_5: + HW_PKA_ReadResult( 500, 8, &T[1][0] ); + + internalStateMachine_Step = HW_PKA_STEP_6; + /* Set the point coordinate Z1 */ + HW_PKA_ReadResult( 676, 8, &ret[0] ); + HW_PKA_MontgomeryMultiplication( 256, &ret[0], &ret[0], HW_PKA_P256_gfp); + break; + case HW_PKA_STEP_6: + HW_PKA_ReadResult( 500, 8, &T[2][0] ); + + internalStateMachine_Step = HW_PKA_STEP_7; + /* Set the point coordinate X2 */ + HW_PKA_ReadResult( 697, 8, &ret[0] ); + HW_PKA_MontgomeryMultiplication( 256, &ret[0], &T[2][0], HW_PKA_P256_gfp); + break; + case HW_PKA_STEP_7: + HW_PKA_ReadResult( 500, 8, &T[3][0] ); + + internalStateMachine_Step = HW_PKA_STEP_8; + HW_PKA_Comparison(HW_PKA_oplen, &T[1][0], &T[3][0]); + break; + case HW_PKA_STEP_8: + internalStateMachine_Step = HW_PKA_STEP_9; + if(HW_PKA_ReadSingleOutput(500)!=0) + { + HW_PKA_ExitWithError(0xFF00+HW_PKA_STEP_8); + } + else + { + /* Set the point coordinate Z2 */ + HW_PKA_ReadResult( 739, 8, &ret[0] ); + HW_PKA_MontgomeryMultiplication( 256, &ret[0], &T[0][0], HW_PKA_P256_gfp); + } + break; + case HW_PKA_STEP_9: + HW_PKA_ReadResult( 500, 8, &T[3][0] ); + + internalStateMachine_Step = HW_PKA_STEP_10; + /* Set the point coordinate Y1 */ + HW_PKA_ReadResult( 655, 8, &ret[0] ); + HW_PKA_MontgomeryMultiplication( 256, &ret[0], &T[3][0], HW_PKA_P256_gfp); + break; + case HW_PKA_STEP_10: + HW_PKA_ReadResult( 500, 8, &T[0][0] ); + + internalStateMachine_Step = HW_PKA_STEP_11; + /* Set the point coordinate Z1 */ + HW_PKA_ReadResult( 676, 8, &ret[0] ); + HW_PKA_MontgomeryMultiplication( 256, &ret[0], &T[2][0], HW_PKA_P256_gfp); + break; + case HW_PKA_STEP_11: + HW_PKA_ReadResult( 500, 8, &T[1][0] ); + + internalStateMachine_Step = HW_PKA_STEP_12; + /* Set the point coordinate Y2 */ + HW_PKA_ReadResult( 718, 8, &ret[0] ); + HW_PKA_MontgomeryMultiplication( 256, &ret[0], &T[1][0], HW_PKA_P256_gfp); + break; + case HW_PKA_STEP_12: + HW_PKA_ReadResult( 500, 8, &T[2][0] ); + + internalStateMachine_Step = HW_PKA_STEP_13; + HW_PKA_Comparison(HW_PKA_oplen, &T[0][0], &T[2][0]); + break; + case HW_PKA_STEP_13: + if(HW_PKA_ReadSingleOutput(500)!=0) + { + HW_PKA_ExitWithError(0xFF00+HW_PKA_STEP_13); + } + else + { + internalStateMachine_Step = HW_PKA_STEP_END_SUCCESS; + HW_PKA_ProcEnd_StateMachine(); + } +#endif /* STM32WB05 */ + break; + case HW_PKA_STEP_END_SUCCESS: + internalStateMachine_Operation = HW_PKA_OPERATION_NONE; + internalStateMachine_Step = HW_PKA_STEP_0; + PKAMGR_Unlock(); + for(int i=0;i<8;i++) + ret[i] = bufferSecretKey[i]; + HW_PKA_funcCB_LP(PKAMGR_SUCCESS, ret); + break; + default: + HW_PKA_ExitWithError(0xA0); + } + } +} + +/** + * Brief This function handles PKA Instance interrupt request. + * Param None + * Retval None + */ +void HW_PKA_IRQHandler(void) +{ + /* Manage the PKA RAM error flag */ + if(LL_PKA_IsActiveFlag_RAMERR(PKA) == 1) + { + LL_PKA_ClearFlag_RAMERR(PKA); + HW_PKA_ExitWithError(0xB1); + } + + /* Manage the Address error flag */ + if(LL_PKA_IsActiveFlag_ADDRERR(PKA) == 1) + { + LL_PKA_ClearFlag_ADDRERR(PKA); + HW_PKA_ExitWithError(0xB2); + } + + /* Manage the PKA End of Operation flag */ + if(LL_PKA_IsActiveFlag_PROCEND(PKA) == 1) + { + LL_PKA_ClearFlag_PROCEND(PKA); + HW_PKA_ProcEnd_StateMachine(); + } +} + +void HAL_PKA_OperationCpltCallback(PKA_HandleTypeDef *hpka) +{ + HW_PKA_ProcEnd_StateMachine(); + PKAMGR_IRQCallback(); +} + +void HAL_PKA_ErrorCallback(PKA_HandleTypeDef *hpka) +{ + HW_PKA_ExitWithError(hpka->ErrorCode); + PKAMGR_IRQCallback(); +} + +/** + * @brief + * @param + * @param + * + */ +uint32_t HW_PKA_IsPointCheckOk(void) +{ +#ifdef STM32WB09 + uint32_t result[2] = {0}; + HW_PKA_ReadResult( PKA_POINT_CHECK_OUT_ERROR, 2, &result[0] ); + return ( result[0] == 0xD60D); +#endif /* STM32WB09 */ + +#ifdef STM32WB05 + return (HW_PKA_ReadSingleOutput( 0 ) == 0); +#endif /* STM32WB05 */ +} + +/** + * @brief + * @param + * @param + * + */ +uint32_t HW_PKA_IsRangeCheckOk(void) +{ +#ifdef STM32WB09 + uint32_t result[2] = {0}; + HW_PKA_ReadResult( PKA_COMPARISON_OUT_RESULT, 2, &result[0] ); + return ( result[0] == 0x916A); +#endif /* STM32WB09 */ + +#ifdef STM32WB05 + return (HW_PKA_ReadSingleOutput( 500 ) == 2); +#endif /* STM32WB05 */ +} + +/** + * @brief + * @param + * @param + * + */ +void HW_PKA_P256_StartEccScalarMul( const uint32_t* k, const uint32_t* pX, const uint32_t* pY ) +{ + /* Set the configuration */ + LL_PKA_Config( PKA, LL_PKA_MODE_ECC_KP_PRIMITIVE ); + + /* Enable the Security level */ + LL_PKA_SetSecurityLevel(PKA, LL_PKA_SECURITY_LEVEL_ENABLE); + +#ifdef STM32WB09 + /* Set the scalar multiplier k length */ + HW_PKA_WriteSingleInput( PKA_ECC_SCALAR_MUL_IN_EXP_NB_BITS, 2, HW_PKA_nbits_k); + /* Set the modulus length */ + HW_PKA_WriteSingleInput( PKA_ECC_SCALAR_MUL_IN_OP_NB_BITS, 2, HW_PKA_nbits_m); + /* Set the coefficient a sign */ + HW_PKA_WriteSingleInput( PKA_ECC_SCALAR_MUL_IN_A_COEFF_SIGN, 2, HW_PKA_a_coeff_sign); + /* Set the coefficient |a| */ + HW_PKA_WriteOperand( PKA_ECC_SCALAR_MUL_IN_A_COEFF, 8, HW_PKA_P256_a ); + /* Set the modulus value p */ + HW_PKA_WriteOperand( PKA_ECC_SCALAR_MUL_IN_MOD_GF, 8, HW_PKA_P256_gfp ); + /* Set the Montgomery parameter */ + HW_PKA_WriteOperand( PKA_ECC_SCALAR_MUL_IN_MONTGOMERY_PARAM, 8, HW_PKA_P256_r2 ); + /* Set the scalar multiplier k */ + HW_PKA_WriteOperand( PKA_ECC_SCALAR_MUL_IN_K, 8, k ); + /* Set the point P coordinate x */ + HW_PKA_WriteOperand( PKA_ECC_SCALAR_MUL_IN_INITIAL_POINT_X, 8, pX ); + /* Set the point P coordinate y */ + HW_PKA_WriteOperand( PKA_ECC_SCALAR_MUL_IN_INITIAL_POINT_Y, 8, pY ); +#endif /* STM32WB09 */ + +#ifdef STM32WB05 + /* Set the scalar multiplier k length */ + HW_PKA_WriteSingleInput( 0, HW_PKA_nbits_k[0] ); + /* Set the modulus length */ + HW_PKA_WriteSingleInput( 1, HW_PKA_nbits_m[0] ); + /* Set the coefficient a sign */ + HW_PKA_WriteSingleInput( 2, HW_PKA_a_coeff_sign[0] ); + /* Set the coefficient |a| */ + HW_PKA_WriteOperand( 3, 8, HW_PKA_P256_a ); + /* Set the modulus value p */ + HW_PKA_WriteOperand( 24, 8, HW_PKA_P256_gfp ); + /* Set the Montgomery parameter */ + HW_PKA_WriteOperand( 45, 8, HW_PKA_P256_r2 ); + /* Set the scalar multiplier k */ + HW_PKA_WriteOperand( 66, 8, k ); + /* Set the point P coordinate x */ + HW_PKA_WriteOperand( 87, 8, pX ); + /* Set the point P coordinate y */ + HW_PKA_WriteOperand( 108, 8, pY ); +#endif /* STM32WB05 */ + + /* Wait for PKA busy flag equal to 0 */ + while(LL_PKA_IsActiveFlag_BUSY(PKA)); + + /* Start the PKA processing */ + LL_PKA_Start( PKA ); +} + +/** + * @brief + * @param + * @param + * + */ +void HW_PKA_Comparison( const uint32_t* opLen, const uint32_t* op1 , const uint32_t* op2 ) +{ + LL_PKA_SetMode(PKA, LL_PKA_MODE_COMPARISON ); +#ifdef STM32WB09 + /* Loads the input buffers to PKA RAM */ + /* Set the muber of bits of P */ + HW_PKA_WriteSingleInput( PKA_COMPARISON_NB_BITS, 2, opLen ); + /* Set the op1 */ + HW_PKA_WriteOperand( PKA_COMPARISON_IN_OP1, 8, op1 ); + /* Set the op2 */ + HW_PKA_WriteOperand( PKA_COMPARISON_IN_OP2, 8, op2 ); +#endif /* STM32WB09 */ + +#ifdef STM32WB05 + /* Loads the input buffers to PKA RAM */ + /* Set the muber of bits of P */ + HW_PKA_WriteSingleInput( 1, opLen[0] ); + /* Set the op1 */ + HW_PKA_WriteOperand( 301, 8, op1 ); + /* Set the op2 */ + HW_PKA_WriteOperand( 401, 8, op2 ); +#endif /* STM32WB05 */ + /* Wait for PKA busy flag equal to 0 */ + while(LL_PKA_IsActiveFlag_BUSY(PKA)); + + /* Launch the computation in interrupt mode */ + LL_PKA_Start(PKA); +} + +void HW_PKA_P256_StartPointCheck( const uint32_t* x, const uint32_t* y ) +{ + /* Set the configuration */ + LL_PKA_Config( PKA, LL_PKA_MODE_POINT_CHECK ); +#ifdef STM32WB09 + /* Set the muber of bits of p */ + HW_PKA_WriteSingleInput( PKA_POINT_CHECK_IN_MOD_NB_BITS, 2, HW_PKA_nbits_m); + /* Set the coefficient a sign */ + HW_PKA_WriteSingleInput( PKA_POINT_CHECK_IN_A_COEFF_SIGN, 2, HW_PKA_a_coeff_sign); + /* Set the coefficient |a| */ + HW_PKA_WriteOperand( PKA_POINT_CHECK_IN_A_COEFF, 8, HW_PKA_P256_a ); + /* Set the modulus value p */ + HW_PKA_WriteOperand( PKA_POINT_CHECK_IN_MOD_GF, 8, HW_PKA_P256_gfp ); + /* Set the point coordinate x */ + HW_PKA_WriteOperand( PKA_POINT_CHECK_IN_INITIAL_POINT_X, 8, x ); + /* Set the point coordinate y */ + HW_PKA_WriteOperand( PKA_POINT_CHECK_IN_INITIAL_POINT_Y, 8, y ); + /* Set the Montgomery parameter */ + HW_PKA_WriteOperand( PKA_ECC_SCALAR_MUL_IN_MONTGOMERY_PARAM, 8, HW_PKA_P256_r2 ); + /* Set the coefficient |b| */ + HW_PKA_WriteOperand( PKA_POINT_CHECK_IN_B_COEFF, 8, HW_PKA_P256_b ); +#endif /* STM32WB09 */ + +#ifdef STM32WB05 + /* Set the muber of bits of p */ + HW_PKA_WriteSingleInput( 1, 256 ); + /* Set the coefficient a sign */ + HW_PKA_WriteSingleInput( 2, 1 ); + /* Set the coefficient |a| */ + HW_PKA_WriteOperand( 3, 8, HW_PKA_P256_a ); + /* Set the modulus value p */ + HW_PKA_WriteOperand( 24, 8, HW_PKA_P256_gfp ); + /* Set the point coordinate x */ + HW_PKA_WriteOperand( 87, 8, x ); + /* Set the point coordinate y */ + HW_PKA_WriteOperand( 108, 8, y ); + /* Set the coefficient |b| */ + HW_PKA_WriteOperand( 255, 8, HW_PKA_P256_b ); +#endif /* STM32WB05 */ + + /* Wait for PKA busy flag equal to 0 */ + while(LL_PKA_IsActiveFlag_BUSY(PKA)); + + /* Start the PKA processing */ + LL_PKA_Start( PKA ); +} + +#ifdef STM32WB05 +void HW_PKA_MontgomeryMultiplication( uint32_t opLen, const uint32_t* op1, const uint32_t* op2, const uint32_t* p) +{ + /* Set the configuration */ + LL_PKA_Config( PKA, LL_PKA_MODE_MONTGOMERY_MUL ); + + /* Loads the input buffers to PKA RAM */ + /* Set the operand length */ + HW_PKA_WriteSingleInput( 1, opLen); + /* Set the op1 */ + HW_PKA_WriteOperand( 301, 8, op1); + /* Set the op2 */ + HW_PKA_WriteOperand( 401, 8, op2); + /* Set the modulus value p */ + HW_PKA_WriteOperand( 599, 8, p ); + + /* Wait for PKA busy flag equal to 0 */ + while(LL_PKA_IsActiveFlag_BUSY(PKA)); + + /* Start the PKA processing */ + LL_PKA_Start( PKA ); +} +#endif /* STM32WB05 */ + +/** + * @brief + * @param + * @param + * + */ +void HW_PKA_P256_ReadEccScalarMul( uint32_t* pX, uint32_t* pY ) +{ +#ifdef STM32WB09 + /* Read the output point X */ + if( pX ) + { + HW_PKA_ReadResult( PKA_ECC_SCALAR_MUL_OUT_RESULT_X, 8, pX ); + } + /* Read the output point Y as the second half of the result */ + if( pY ) + { + HW_PKA_ReadResult( PKA_ECC_SCALAR_MUL_OUT_RESULT_Y, 8, pY ); + } +#endif /* STM32WB09 */ + +#ifdef STM32WB05 + /* Read the output point X */ + if( pX ) + { + HW_PKA_ReadResult( 87, 8, pX ); + } + /* Read the output point Y as the second half of the result */ + if( pY ) + { + HW_PKA_ReadResult( 108, 8, pY ); + } +#endif /* STM32WB05 */ +} + +/** + * Brief This function checks if the param p is equal to the Start Point. + * Param Publick key p + * Retval 1 if p is equal to the Start Point. 0 in other cases. + */ +uint32_t HW_PKA_isStartPoint(const uint32_t* p) +{ + for(int i=0; i<16; i++) + { + if(PKAStartPoint[i]!=p[i]) + return 0; + } + return 1; +} + +/** +* @} +*/ + +#endif /* STM32WB09 STM32WB05 */ + +#if defined(STM32WB06) || defined(STM32WB07) + +/** + * @brief PKA verification of process command. + * @param None + * @retval ErrorStatus +*/ +ErrorStatus HW_PKA_VerifyProcess(void) +{ + uint32_t errorCode; + + if(PKA_SetDataError != 0x00) + return ERROR; + + errorCode = *(uint32_t *)(HW_PKA_RAM_ECC_ADDR_KP_ERROR); + + if (errorCode == 0) { + return SUCCESS; + } + else { + return ERROR; + } +} + +/** + * Brief This function handles PKA Instance interrupt request. + * Param None + * Retval None +*/ +void HW_PKA_IRQHandler(void) +{ + /* Compare to expected results */ + if (HW_PKA_VerifyProcess() == ERROR) + { + PKAMGR_Unlock(); + ret[0] = 0x03; + HW_PKA_funcCB_LP(PKAMGR_ERR_PROCESS, ret); + } + else + { + for(int i=0; i<24; i++) + ret[i] = 0; + /* | Secret Key | Public Key X-coord | Public Key Y-coord | */ + /* | (32 octets) | (32 octets) | (32 octets) | */ + /* Get the new calculated point NewPoint of the ellipse */ + HW_PKA_GetData(HW_PKA_DATA_SK, (uint8_t *)&ret[0]); + HW_PKA_GetData(HW_PKA_DATA_PCX, (uint8_t *)&ret[8]); + HW_PKA_GetData(HW_PKA_DATA_PCY, (uint8_t *)&ret[16]); + + PKAMGR_Unlock(); + HW_PKA_funcCB_LP(PKAMGR_SUCCESS, ret); + } +} + +#endif /* STM32WB06 STM32WB07 */ + +/** +* @} +*/ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.h b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.h new file mode 100644 index 000000000..5c49d0a0d --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.h @@ -0,0 +1,95 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file hw_pka.h + * @author GPM WBL Application Team + * @brief This file contains all the functions prototypes for PKA stm32wb09 + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef HW_PKA_H +#define HW_PKA_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include + +/** @defgroup HW_PKA PKA Manager +* @{ +*/ + +/** @defgroup HW_PKA_Exported_Types Exported Types +* @{ +*/ +/** +* @} +*/ + +/** @defgroup HW_PKA_Exported_Constants Exported Constants + * @{ + */ +/** + * @} + */ + +/** @defgroup HW_PKA_Exported_Macros Exported Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup HW_PKA_Exported_Functions Exported Functions + * @{ + */ +#if defined STM32WB09 +void HW_PKA_WriteSingleInput( uint32_t index, int size, const uint32_t* word ); +#elif defined STM32WB05 +void HW_PKA_WriteSingleInput( uint32_t index, uint32_t word ); +#endif + +#if defined STM32WB09 +void HW_PKA_ReadSingleOutput( uint32_t index, uint32_t* out); +#elif defined STM32WB05 +uint32_t HW_PKA_ReadSingleOutput( uint32_t index ); +#endif /* STM32WB09 elif STM32WB05 */ + +#if defined(STM32WB06) || defined(STM32WB07) +ErrorStatus HW_PKA_SetData(uint8_t dataType, uint32_t* srcData); +ErrorStatus HW_PKA_GetData(uint8_t dataType, uint8_t* dataTarget); +ErrorStatus HW_PKA_VerifyProcess(void); +#endif + +void HW_PKA_WriteOperand( uint32_t index, int size, const uint32_t* in ); +void HW_PKA_ReadResult( uint32_t index, int size, uint32_t* out ); +uint8_t HW_PKA_PowerSaveLevelCheck(void); +void HW_PKA_Init(void); +void HW_PKA_IRQHandler(void); +/** +* @} +*/ + +/** +* @} +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* HW_PKA_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.c b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.c new file mode 100644 index 000000000..6c2741f11 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.c @@ -0,0 +1,184 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file hw_rng.c + * @author GPM WBL Application Team + * @brief This file provides functions implementation for RNG Manager. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "hw_rng.h" +#include "stm32wb0x_ll_rng.h" +#include "stm32wb0x_ll_bus.h" + +/** @defgroup RNG_Manager RNG Manager +* @{ +*/ + +/** @defgroup RNG_Manager_TypesDefinitions Private Type Definitions +* @{ +*/ +/** +* @} +*/ + +/** @defgroup RNG_Manager_Private_Defines Private Defines +* @{ +*/ +/** +* @} +*/ + +/** @defgroup RNG_Manager_Private_Variables Private Variables +* @{ +*/ +/** +* @} +*/ + +/** @defgroup RNG_Manager_External_Variables External Variables +* @{ +*/ +/** +* @} +*/ + +/** @defgroup RNG_Manager_Public_Functions Public Functions +* @{ +*/ + +HW_RNG_ResultStatus HW_RNG_Init(void) +{ +#ifdef STM32WB09 + /* Peripheral clock enable */ + LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_RNG); + + uint32_t SamplingClockDivider = 0; + + /* Check that the divider value is equal to the one to configure. If not, it must redo the write and checking. */ + while( LL_RNG_GetSamplingClockEnableDivider(RNG) != SamplingClockDivider) + { + /* While the new divider value is being resynchronized with the TRNG core clock domain, it is not possible to write another new value. */ + LL_RNG_SetSamplingClockEnableDivider(RNG, SamplingClockDivider); + } + + /* Initialize random numbers generation */ + LL_RNG_Enable(RNG); + + /* Wait for RNG enable operation */ + while (LL_RNG_IsActiveFlag_DISABLED(RNG)); + + /* Check if internal clock error occurs */ + if (LL_RNG_IsActiveFlag_REVEAL_CLK_ERR(RNG)) + { + return HW_RNG_ERROR; + } +#endif /* STM32WB09 */ + +#if defined (STM32WB07) || defined (STM32WB06) || defined(STM32WB05) + /* Peripheral clock enable */ + LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_RNG); + + /* Initialize random numbers generation */ + LL_RNG_Enable(RNG); + + /* Wait for DRDY flag to be raised */ + while (!LL_RNG_IsActiveFlag_RNGRDY(RNG)); + + /* Check if error occurs */ + if ( LL_RNG_IsActiveFlag_FAULT(RNG) ) + { + /* Clock or Seed Error detected. Set LED to blinking mode (Error type)*/ + return HW_RNG_ERROR; + } + + /* Values of Generated Random numbers are now available in num array. */ + +#endif /* STM32WB07 || STM32WB06 || STM32WB05*/ + return HW_RNG_SUCCESS; +} + +HW_RNG_ResultStatus HW_RNG_Deinit(void) +{ + /* Stop random numbers generation */ + LL_RNG_Disable(RNG); + return HW_RNG_SUCCESS; +} + +/** + * @brief Provide a 16-bit true random number + * @param num: pointer to the random value returned + * @return error status: 0 = No error + */ +HW_RNG_ResultStatus HW_RNG_GetRandom16(uint16_t* num) +{ +#ifdef STM32WB09 + /* Wait for VAL_READY signal */ + while (!LL_RNG_IsActiveFlag_VAL_READY(RNG)); + + *num = LL_RNG_READRANDDATA32(RNG); + +#endif /* STM32WB09 */ + +#if defined (STM32WB07) || defined (STM32WB06) || defined(STM32WB05) + /* Wait for RNGRDY signal */ + while (!LL_RNG_IsActiveFlag_RNGRDY(RNG)); + + *num = (uint16_t)LL_RNG_ReadRandData16(RNG); + +#endif /* STM32WB07 || STM32WB06 || STM32WB05*/ + + return HW_RNG_SUCCESS; +} + +/** + * @brief Provide a 32-bit true random number + * @param num: pointer to the random value returned + * + * @return error status: 0 = No error + */ +HW_RNG_ResultStatus HW_RNG_GetRandom32(uint32_t* num) +{ +#ifdef STM32WB09 + /* Wait for VAL_READY signal */ + while (!LL_RNG_IsActiveFlag_VAL_READY(RNG)); + + *num = LL_RNG_READRANDDATA32(RNG); +#endif /* STM32WB09 */ + +#if defined (STM32WB07) || defined (STM32WB06) || defined(STM32WB05) + uint16_t *num_16 = (uint16_t *) num; + + /* Wait for RNGRDY signal */ + while (!LL_RNG_IsActiveFlag_RNGRDY(RNG)); + + num_16[0] = (uint16_t)LL_RNG_ReadRandData16(RNG); + + /* Wait for RNGRDY signal */ + while (!LL_RNG_IsActiveFlag_RNGRDY(RNG)); + + num_16[1] = (uint16_t)LL_RNG_ReadRandData16(RNG); +#endif /* STM32WB07 || STM32WB06 || STM32WB05*/ + + return HW_RNG_SUCCESS; +} + +/** +* @} +*/ + +/** +* @} +*/ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.h b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.h new file mode 100644 index 000000000..7f7b9662d --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.h @@ -0,0 +1,93 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file hw_rng.h + * @author GPM WBL Application Team + * @brief This file contains all the functions prototypes for the RNG MANAGER. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef HW_RNG_H +#define HW_RNG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stdint.h" + +/** @addtogroup HW_RNG_Peripheral RNG MANAGER + * @{ + */ + +/** @defgroup HW_RNG_Exported_Types Exported Types + * @{ + */ + +/* Enumerated values used to report the RNG result status after a process */ +typedef enum +{ + HW_RNG_SUCCESS = 0, + HW_RNG_ERROR, + HW_RNG_ERROR_TIMEOUT +} HW_RNG_ResultStatus; + +/** + * @} + */ + +/** @defgroup HW_RNG_Exported_Constants Exported Constants + * @{ + */ +/** + * @} + */ + +/** @defgroup HW_RNG_Exported_Macros Exported Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup HW_RNG_Exported_Functions Exported Functions + * @{ + */ +HW_RNG_ResultStatus HW_RNG_Init(void); + +HW_RNG_ResultStatus HW_RNG_Deinit(void); + +HW_RNG_ResultStatus HW_RNG_GetRandom16(uint16_t* num); + +HW_RNG_ResultStatus HW_RNG_GetRandom32(uint32_t* num); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* HW_RNG_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/stm32_lpm_if.c b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/stm32_lpm_if.c new file mode 100644 index 000000000..85168838e --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/stm32_lpm_if.c @@ -0,0 +1,381 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32_lpm_if.c + * @author GPM WBL Application Team + * @brief Low layer function to enter/exit low power modes (stop, sleep) + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32_lpm.h" +#include "stm32_lpm_if.h" +#include "device_context_switch.h" +#include "RTDebug.h" + +/** @addtogroup TINY_LPM_IF + * @{ + */ + +/* USER CODE BEGIN include */ +#include "stm32wb0x_hal.h" +/* USER CODE END include */ + +/* Exported variables --------------------------------------------------------*/ +/** @defgroup TINY_LPM_IF_Exported_variables TINY LPM IF exported variables + * @{ + */ + +/** + * @brief variable to provide all the functions corresponding to the different low power modes. + */ +const struct UTIL_LPM_Driver_s UTIL_PowerDriver = +{ + PWR_EnterSleepMode, + PWR_ExitSleepMode, + + PWR_EnterStopMode, + PWR_ExitStopMode, + + PWR_EnterOffMode, + PWR_ExitOffMode, +}; + +/** + * @} + */ +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN Private_Function_Prototypes */ + +/* USER CODE END Private_Function_Prototypes */ +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN Private_Typedef */ + +/* USER CODE END Private_Typedef */ +/* Private define ------------------------------------------------------------*/ +typedef struct clockContextS +{ + uint8_t directHSEenabled; + uint8_t LSEenabled; + uint8_t LSIenabled; + uint32_t clkDiv; +} clockContextT; + +/* USER CODE BEGIN Private_Define */ + +/* USER CODE END Private_Define */ +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Private_Macro */ + +/* USER CODE END Private_Macro */ +/* Private variables ---------------------------------------------------------*/ +static apb0PeriphT apb0={0}; +static apb1PeriphT apb1={0}; +static apb2PeriphT apb2={0}; +static ahb0PeriphT ahb0={0}; +static cpuPeriphT cpuPeriph={0}; +static uint32_t cStackPreamble[CSTACK_PREAMBLE_NUMBER]; +static clockContextT clockContext; + +/* USER CODE BEGIN Private_Variables */ +extern void CPUcontextSave(void); + +/* USER CODE END Private_Variables */ + +/** @addtogroup TINY_LPM_IF_Exported_functions + * @{ + */ + +void PWR_EnterOffMode( void ) +{ + PWR_DEEPSTOPTypeDef configDS; + + SYSTEM_DEBUG_SIGNAL_SET(LOW_POWER_STANDBY_MODE_ENTER); + + /* USER CODE BEGIN PWR_EnterOffMode_1 */ + + /* USER CODE END PWR_EnterOffMode_1 */ + + /* Save the clock configuration */ + clockContext.directHSEenabled = FALSE; + clockContext.LSEenabled = FALSE; + clockContext.LSIenabled = FALSE; + if (LL_RCC_DIRECT_HSE_IsEnabled()) + { + clockContext.directHSEenabled = TRUE; + } +#if defined(STM32WB07) + clockContext.clkDiv = LL_RCC_GetRC64MPLLPrescaler(); +#else + clockContext.clkDiv = LL_RCC_GetCLKSYSPrescalerStatus(); +#endif + if (LL_RCC_LSE_IsEnabled()) + { + clockContext.LSEenabled = TRUE; + /* Enable pull down for LSE pins */ + HAL_PWREx_EnableGPIOPullDown(PWR_GPIO_B, PWR_GPIO_BIT_12); + HAL_PWREx_EnableGPIOPullDown(PWR_GPIO_B, PWR_GPIO_BIT_13); + } + if (LL_RCC_LSI_IsEnabled()) + { + clockContext.LSIenabled = TRUE; + } + + /* This signal cannot be reset later otherwise the GPIO output will be + automatically restored to high at wakeup. */ + SYSTEM_DEBUG_SIGNAL_RESET(LOW_POWER_STANDBY_MODE_ENTER); + + /* Save all the peripheral registers and CPU peripipheral configuration */ + apb0.deepstop_wdg_state = ENABLE; + prepareDeviceLowPower(&apb0, &apb1, &apb2, &ahb0, &cpuPeriph, cStackPreamble); + + /* DEEPSTOP configuration */ + configDS.deepStopMode = PWR_DEEPSTOP_WITH_SLOW_CLOCK_OFF; + HAL_PWR_ConfigDEEPSTOP(&configDS); + + /* Clear all the wake-up pin flags */ + LL_PWR_ClearWakeupSource(LL_PWR_WAKEUP_ALL); + + /* Enable the device DEEPSTOP configuration */ + LL_PWR_SetPowerMode(LL_PWR_MODE_DEEPSTOP); + + /* Set SLEEPDEEP bit of Cortex System Control Register */ + SET_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); + + /* Setup the SYS CLK DIV with the reset value */ + if (clockContext.clkDiv == LL_RCC_RC64MPLL_DIV_1) + { + LL_RCC_SetRC64MPLLPrescaler(LL_RCC_RC64MPLL_DIV_4); + } + + SYSTEM_DEBUG_SIGNAL_SET(LOW_POWER_STANDBY_MODE_ACTIVE); + + /* Save the CPU context & Wait for Interrupt Request to enter in DEEPSTOP */ + CPUcontextSave(); + + /* USER CODE BEGIN PWR_EnterOffMode_2 */ + + /* USER CODE END PWR_EnterOffMode_2 */ +} + +void PWR_ExitOffMode( void ) +{ + /* USER CODE BEGIN PWR_ExitOffMode_1 */ + + /* USER CODE END PWR_ExitOffMode_1 */ + + /* Restore low speed clock configuration */ + if (clockContext.LSEenabled == TRUE) + { + LL_PWR_SetNoPullB(LL_PWR_GPIO_BIT_12 | LL_PWR_GPIO_BIT_13); + LL_RCC_LSE_Enable(); + } + if (clockContext.LSIenabled == TRUE) + { + LL_RCC_LSI_Enable(); + } + + /* Clear SLEEPDEEP bit of Cortex System Control Register */ + CLEAR_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); + + /* Restore all the peripheral registers and CPU peripipheral configuration */ + restoreDeviceLowPower(&apb0, &apb1, &apb2, &ahb0, &cpuPeriph, cStackPreamble); + + SYSTEM_DEBUG_SIGNAL_RESET(LOW_POWER_STANDBY_MODE_ACTIVE); + SYSTEM_DEBUG_SIGNAL_SET(LOW_POWER_STANDBY_MODE_EXIT); + +#if defined(PWR_CR2_GPIORET) + /* Disable the GPIO retention at wake DEEPSTOP configuration */ + LL_PWR_DisableGPIORET(); +#endif + + /* Restore the CLK SYS DIV */ + if (clockContext.clkDiv == LL_RCC_RC64MPLL_DIV_1) + { + LL_RCC_SetRC64MPLLPrescaler(LL_RCC_RC64MPLL_DIV_1); + } + + /* Wait until the HSE is ready */ + while(LL_RCC_HSE_IsReady() == 0U); + + /* Restore the DIRECT_HSE configuration */ + if (clockContext.directHSEenabled == TRUE) + { + LL_RCC_DIRECT_HSE_Enable(); + LL_RCC_RC64MPLL_Disable(); + } + if (clockContext.LSEenabled == TRUE) + { + /* Wait until the LSE is ready */ + while(LL_RCC_LSE_IsReady() == 0U); + } + if (clockContext.LSIenabled == TRUE) + { + /* Wait until the LSI is ready */ + while(LL_RCC_LSI_IsReady() == 0U); + } + if (LL_APB2_GRP1_IsEnabledClock(LL_APB2_GRP1_PERIPH_MRBLE)) + { + /* Wait untile the ABSOLUTE TIME clock correctly */ + while(WAKEUP->ABSOLUTE_TIME == 0xF); + } + + /* Handler to manage the IOs IRQ if needed */ + HAL_PWR_WKUP_IRQHandler(); + + /* USER CODE BEGIN PWR_ExitOffMode_2 */ + + /* USER CODE END PWR_ExitOffMode_2 */ + + SYSTEM_DEBUG_SIGNAL_RESET(LOW_POWER_STANDBY_MODE_EXIT); +} + +void PWR_EnterStopMode( void ) +{ + PWR_DEEPSTOPTypeDef configDS; + + SYSTEM_DEBUG_SIGNAL_SET(LOW_POWER_STOP_MODE_ENTER); + + /* USER CODE BEGIN PWR_EnterStopMode_1 */ + + /* USER CODE END PWR_EnterStopMode_1 */ + + /* Save the clock configuration */ + clockContext.directHSEenabled = FALSE; + clockContext.LSEenabled = FALSE; + clockContext.LSIenabled = FALSE; + if (LL_RCC_DIRECT_HSE_IsEnabled()) + { + clockContext.directHSEenabled = TRUE; + } +#if defined(STM32WB07) + clockContext.clkDiv = LL_RCC_GetRC64MPLLPrescaler(); +#else + clockContext.clkDiv = LL_RCC_GetCLKSYSPrescalerStatus(); +#endif + + /* Setup the wakeup sources */ + HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_BLEHOST|PWR_WAKEUP_BLE, 0); + + /* This signal cannot be reset later otherwise the GPIO output will be + automatically restored to high at wakeup. */ + SYSTEM_DEBUG_SIGNAL_RESET(LOW_POWER_STOP_MODE_ENTER); + + /* Save all the peripheral registers and CPU peripipheral configuration */ + apb0.deepstop_wdg_state = ENABLE; + prepareDeviceLowPower(&apb0, &apb1, &apb2, &ahb0, &cpuPeriph, cStackPreamble); + + /* Clear all the wake-up pin flags */ + LL_PWR_ClearWakeupSource(LL_PWR_WAKEUP_ALL); + + /* DEEPSTOP configuration */ + configDS.deepStopMode = PWR_DEEPSTOP_WITH_SLOW_CLOCK_ON; + HAL_PWR_ConfigDEEPSTOP(&configDS); + + /* Enable the device DEEPSTOP configuration */ + LL_PWR_SetPowerMode(LL_PWR_MODE_DEEPSTOP); + + /* Set SLEEPDEEP bit of Cortex System Control Register */ + SET_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); + + /* Setup the SYS CLK DIV with the reset value */ + if (clockContext.clkDiv == LL_RCC_RC64MPLL_DIV_1) + { + LL_RCC_SetRC64MPLLPrescaler(LL_RCC_RC64MPLL_DIV_4); + } + + SYSTEM_DEBUG_SIGNAL_SET(LOW_POWER_STOP_MODE_ACTIVE); + + /* Save the CPU context & Wait for Interrupt Request to enter in DEEPSTOP */ + CPUcontextSave(); + + SYSTEM_DEBUG_SIGNAL_RESET(LOW_POWER_STOP_MODE_ACTIVE); + + /* USER CODE BEGIN PWR_EnterStopMode_2 */ + + /* USER CODE END PWR_EnterStopMode_2 */ +} + +void PWR_ExitStopMode( void ) +{ + /* USER CODE BEGIN PWR_ExitStopMode_1 */ + + /* USER CODE END PWR_ExitStopMode_1 */ + + /* Clear SLEEPDEEP bit of Cortex System Control Register */ + CLEAR_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); + + /* Restore all the peripheral registers and CPU peripipheral configuration */ + restoreDeviceLowPower(&apb0, &apb1, &apb2, &ahb0, &cpuPeriph, cStackPreamble); + + SYSTEM_DEBUG_SIGNAL_SET(LOW_POWER_STOP_MODE_EXIT); + +#if defined(PWR_CR2_GPIORET) + /* Disable the GPIO retention at wake DEEPSTOP configuration */ + LL_PWR_DisableGPIORET(); +#endif + + /* Restore the CLK SYS DIV */ + if (clockContext.clkDiv == LL_RCC_RC64MPLL_DIV_1) + { + LL_RCC_SetRC64MPLLPrescaler(LL_RCC_RC64MPLL_DIV_1); + } + + /* Wait until the HSE is ready */ + while(LL_RCC_HSE_IsReady() == 0U); + + /* Restore the DIRECT_HSE configuration */ + if (clockContext.directHSEenabled == TRUE) + { + LL_RCC_DIRECT_HSE_Enable(); + LL_RCC_RC64MPLL_Disable(); + } + + /* Handler to manage the IOs IRQ if needed */ + HAL_PWR_WKUP_IRQHandler(); + + /* USER CODE BEGIN PWR_ExitStopMode_2 */ + + /* USER CODE END PWR_ExitStopMode_2 */ + + SYSTEM_DEBUG_SIGNAL_RESET(LOW_POWER_STOP_MODE_EXIT); +} + +void PWR_EnterSleepMode( void ) +{ + /* USER CODE BEGIN PWR_EnterSleepMode */ + HAL_SuspendTick(); + HAL_PWR_EnterSLEEPMode(); + /* USER CODE END PWR_EnterSleepMode */ +} + +void PWR_ExitSleepMode( void ) +{ + /* USER CODE BEGIN PWR_ExitSleepMode */ + HAL_ResumeTick(); + /* USER CODE END PWR_ExitSleepMode */ +} + +/* USER CODE BEGIN Private_Functions */ + +/* USER CODE END Private_Functions */ + +/** + * @} + */ + +/** + * @} + */ + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/stm32_lpm_if.h b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/stm32_lpm_if.h new file mode 100644 index 000000000..ccf2b0f5f --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/stm32_lpm_if.h @@ -0,0 +1,82 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32_lpm_if.h + * @author GPM WBL Application Team + * @brief Header for stm32_lpm_f.c module (device specific LP management) + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32_TINY_LPM_IF_H +#define STM32_TINY_LPM_IF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + +/** @defgroup TINY_LPM_IF TINY LPM IF + * @{ + */ + +/* Exported Functions ------------------------------------------------------------------*/ + +/** @defgroup TINY_LPM_IF_Exported_functions TINY LPM IF Exported functions + * @{ + */ + +/** + * @brief Enters Low Power Off Mode + */ +void PWR_EnterOffMode( void ); +/** + * @brief Exits Low Power Off Mode + */ +void PWR_ExitOffMode( void ); + +/** + * @brief Enters Low Power Stop Mode + */ +void PWR_EnterStopMode( void ); +/** + * @brief Exits Low Power Stop Mode + */ +void PWR_ExitStopMode( void ); + +/** + * @brief Enters Low Power Sleep Mode + */ +void PWR_EnterSleepMode( void ); + +/** + * @brief Exits Low Power Sleep Mode + */ +void PWR_ExitSleepMode( void ); + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32_TINY_LPM_IF_H */ + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/usart_if.c b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/usart_if.c new file mode 100644 index 000000000..9fd2d386a --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/usart_if.c @@ -0,0 +1,351 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file usart_if.c + * @author GPM WBL Application Team + * @brief : Source file for interfacing the stm32_adv_trace to hardware + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32_adv_trace.h" +#include "usart_if.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ +#define RECEIVE_AFTER_TRANSMIT 0 /* Whether the UART should be in RX after a Transmit */ + +/* USER CODE END PD */ + +/* External variables --------------------------------------------------------*/ +/** + * @brief USART1 handle + */ +extern UART_HandleTypeDef huart1; + +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ + +/** + * @brief trace tracer definition. + * + * list all the driver interface used by the trace application. + */ +const UTIL_ADV_TRACE_Driver_s UTIL_TraceDriver = +{ + UART_Init, + UART_DeInit, + UART_StartRx, + UART_TransmitDMA +}; + +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Private variables ---------------------------------------------------------*/ + +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + +/** + * @brief buffer to receive 1 character + */ +uint8_t charRx; + +/** + * @brief TX complete callback + * @return none + */ +static void (*TxCpltCallback)(void *); +static void (*RxCpltCallback)(uint8_t *pdata, uint16_t size, uint8_t error); + +#endif /* (CFG_DEBUG_APP_ADV_TRACE != 0) */ + +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Private function prototypes -----------------------------------------------*/ + +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + +static void USART1_DMA_MspDeInit(void); + +#endif /* (CFG_DEBUG_APP_ADV_TRACE != 0) */ + +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +UTIL_ADV_TRACE_Status_t UART_Init( void (*cb)(void *)) +{ + +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + + /* USER CODE BEGIN UART_Init 1 */ + + /* USER CODE END UART_Init 1 */ + + /* Init done in main : GPIO */ + HAL_UART_MspInit(&huart1); + MX_USART1_UART_Init(); + + /* USER CODE BEGIN UART_Init 2 */ + + /* USER CODE END UART_Init 2 */ + + TxCpltCallback = cb; + + /* USER CODE BEGIN UART_Init 3 */ + + /* USER CODE END UART_Init 3 */ + +#endif /* (CFG_DEBUG_APP_ADV_TRACE != 0) */ + + return UTIL_ADV_TRACE_OK; + + /* USER CODE BEGIN UART_Init 4 */ + + /* USER CODE END UART_Init 4 */ +} + +UTIL_ADV_TRACE_Status_t UART_DeInit( void ) +{ +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + + /* USER CODE BEGIN UART_DeInit 1 */ + + /* USER CODE END UART_DeInit 1 */ + + HAL_StatusTypeDef result; + + USART1_DMA_MspDeInit(); + + /* USER CODE BEGIN UART_DeInit 2 */ + + /* USER CODE END UART_DeInit 2 */ + + result = HAL_UART_DeInit(&huart1); + if (result != HAL_OK) + { + TxCpltCallback = NULL; + return UTIL_ADV_TRACE_UNKNOWN_ERROR; + } + + /* USER CODE BEGIN UART_DeInit 3 */ + + /* USER CODE END UART_DeInit 3 */ + + if(huart1.hdmatx) + { + result = HAL_DMA_DeInit(huart1.hdmatx); + if (result != HAL_OK) + { + return UTIL_ADV_TRACE_UNKNOWN_ERROR; + } + } + + /* USER CODE BEGIN UART_DeInit 4 */ + + /* USER CODE END UART_DeInit 4 */ + + if(huart1.hdmarx) + { + result = HAL_DMA_DeInit(huart1.hdmarx); + if (result != HAL_OK) + { + return UTIL_ADV_TRACE_UNKNOWN_ERROR; + } + } + + /* USER CODE BEGIN UART_DeInit 5 */ + + /* USER CODE END UART_DeInit 5 */ + +#endif /* (CFG_DEBUG_APP_ADV_TRACE != 0) */ + + return UTIL_ADV_TRACE_OK; + + /* USER CODE BEGIN UART_DeInit 6 */ + + /* USER CODE END UART_DeInit 6 */ +} + +UTIL_ADV_TRACE_Status_t UART_StartRx(void (*cb)(uint8_t *pdata, uint16_t size, uint8_t error)) +{ +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + + /* USER CODE BEGIN UART_StartRx 1 */ + + /* USER CODE END UART_StartRx 1 */ + + /* Configure USART1 in Receive mode */ + HAL_UART_Receive_IT(&huart1, &charRx, 1); + + if (cb != NULL) + { + RxCpltCallback = cb; + } + + /* USER CODE BEGIN UART_StartRx 2 */ + + /* USER CODE END UART_StartRx 2 */ + +#endif /* (CFG_DEBUG_APP_ADV_TRACE != 0) */ + + return UTIL_ADV_TRACE_OK; + + /* USER CODE BEGIN UART_StartRx 3 */ + + /* USER CODE END UART_StartRx 3 */ +} + +UTIL_ADV_TRACE_Status_t UART_TransmitDMA ( uint8_t *pdata, uint16_t size ) +{ + /* USER CODE BEGIN UART_TransmitDMA 1 */ + + /* USER CODE END UART_TransmitDMA 1 */ + + UTIL_ADV_TRACE_Status_t status = UTIL_ADV_TRACE_OK; + +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + + /* USER CODE BEGIN UART_TransmitDMA 2 */ + + /* USER CODE END UART_TransmitDMA 2 */ + + HAL_StatusTypeDef result; + + if(huart1.hdmatx) + { + result = HAL_UART_Transmit_DMA(&huart1, pdata, size); + } + else + { + result = HAL_UART_Transmit_IT(&huart1, pdata, size); + } + + if (result != HAL_OK) + { + status = UTIL_ADV_TRACE_HW_ERROR; + } + +#if RECEIVE_AFTER_TRANSMIT + HAL_UART_Receive_IT(&huart1, &charRx, 1); +#endif + + /* USER CODE BEGIN UART_TransmitDMA 3 */ + + /* USER CODE END UART_TransmitDMA 3 */ + +#endif /* (CFG_DEBUG_APP_ADV_TRACE != 0) */ + + return status; + + /* USER CODE BEGIN UART_TransmitDMA 4 */ + + /* USER CODE END UART_TransmitDMA 4 */ +} + +#if (CFG_DEBUG_APP_ADV_TRACE != 0) + +static void USART1_DMA_MspDeInit(void) +{ + /* USER CODE BEGIN USART1_DMA_MspDeInit 1 */ + + /* USER CODE END USART1_DMA_MspDeInit 1 */ + + /* Disable USART1 clock */ + __HAL_RCC_USART1_CLK_DISABLE(); + + /* Disable interrupts for USART1 */ + HAL_NVIC_DisableIRQ(USART1_IRQn); + + /* GPDMA1 controller clock disable */ + __HAL_RCC_DMA_CLK_DISABLE(); + + /* DMA interrupt init */ + HAL_NVIC_DisableIRQ(DMA_IRQn); + + /* USER CODE BEGIN USART1_DMA_MspDeInit 2 */ + + /* USER CODE END USART1_DMA_MspDeInit 2 */ +} + +void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) +{ + /* USER CODE BEGIN UsartIf_TxCpltCallback 1 */ + + /* USER CODE END UsartIf_TxCpltCallback 1 */ + + /* ADV Trace callback */ + if(TxCpltCallback) + TxCpltCallback(NULL); + + /* USER CODE BEGIN UsartIf_TxCpltCallback 2 */ + + /* USER CODE END UsartIf_TxCpltCallback 2 */ + +} + +void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) +{ + /* USER CODE BEGIN UsartIf_RxCpltCallback 1 */ + + /* USER CODE END UsartIf_RxCpltCallback 1 */ + + RxCpltCallback(&charRx, 1, 0); + HAL_UART_Receive_IT(&huart1, &charRx, 1); + + /* USER CODE BEGIN UsartIf_RxCpltCallback 2 */ + + /* USER CODE END UsartIf_RxCpltCallback 2 */ +} + +#endif /* (CFG_DEBUG_APP_ADV_TRACE != 0) */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/usart_if.h b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/usart_if.h new file mode 100644 index 000000000..c4938a75f --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/usart_if.h @@ -0,0 +1,114 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file usart_if.h + * @author GPM WBL Application Team + * @brief : Header file for stm32_adv_trace interface file + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef USART_IF_H +#define USART_IF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32_adv_trace.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* External variables --------------------------------------------------------*/ +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Exported functions prototypes ---------------------------------------------*/ +/** +* @brief Init the UART and associated DMA. +* @param cb tx function callback. +* @return @ref UTIL_ADV_TRACE_Status_t +*/ +UTIL_ADV_TRACE_Status_t UART_Init(void (*cb)(void *)); + +/** +* @brief DeInit the UART and associated DMA. +* @return @ref UTIL_ADV_TRACE_Status_t +*/ +UTIL_ADV_TRACE_Status_t UART_DeInit(void); + +/** +* @brief send buffer to UART using DMA +* @param pdata data to be sent +* @param size of buffer p_data to be sent +* @return @ref UTIL_ADV_TRACE_Status_t +*/ +UTIL_ADV_TRACE_Status_t UART_TransmitDMA(uint8_t *pdata, uint16_t size); + +/** +* @brief start Rx process +* @param cb callback to receive the data +* @return @ref UTIL_ADV_TRACE_Status_t +*/ +UTIL_ADV_TRACE_Status_t UART_StartRx(void (*cb)(uint8_t *pdata, uint16_t size, uint8_t error)); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* USART_IF_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_driver.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_driver.c new file mode 100644 index 000000000..d831cae7e --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_driver.c @@ -0,0 +1,204 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file flash_driver.c + * @author MCD Application Team + * @brief The Flash Driver module is the interface layer between Flash + * management modules and HAL Flash drivers + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "utilities_conf.h" +#include "flash_driver.h" +#include "stm32wb0x_hal_flash.h" +#include "ble.h" + +/* Global variables ----------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private defines -----------------------------------------------------------*/ + +#define FD_CTRL_NO_BIT_SET (0UL) /* value used to reset the Flash Control status */ + +#define WORD_WRITE_TIME_US 60 // In microsecond units +#define WORD_WRITE_TIME_SYS ((int)(WORD_WRITE_TIME_US * 256 / 625) + 1) // In system time units +#define QUAD_WORD_WRITE_TIME_US 180 // In microsecond units +#define QUAD_WORD_WRITE_TIME_SYS ((int)(QUAD_WORD_WRITE_TIME_US * 256 / 625) + 1)// In system time units +#define PAGE_ERASE_TIME_US 22000 // In microsecond units +#define PAGE_ERASE_TIME_SYS ((int)(PAGE_ERASE_TIME_US * 256 / 625) + 1) // In system time units + +#define DEBUG_GPIO 0 + +/* Private macros ------------------------------------------------------------*/ +#define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \ + __disable_irq(); \ +/* Must be called in the same scope of ATOMIC_SECTION_BEGIN */ +#define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit) + +#if DEBUG_GPIO +#define DEBUG_GPIO_HIGH() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET) +#define DEBUG_GPIO_LOW() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET) +#else +#define DEBUG_GPIO_HIGH() +#define DEBUG_GPIO_LOW() +#endif +/* Private variables ---------------------------------------------------------*/ + +/** + * @brief variable used to represent the Flash Control status + */ +static volatile FD_Flash_ctrl_bm_t FD_Flash_Control_status = FD_CTRL_NO_BIT_SET; + +/* Private function prototypes -----------------------------------------------*/ +static uint8_t FD_TimeCheck(int32_t time); + +/* Functions Definition ------------------------------------------------------*/ + +/** + * @brief Update Flash Control status + * @param Flags_bm: Bit mask identifying the caller (1 bit per user) + * @param Status: Action requested + * @retval None + */ +void FD_SetStatus(FD_FlashAccess_bm_t Flags_bm, FD_FLASH_Status_t Status) +{ + UTILS_ENTER_CRITICAL_SECTION(); + + switch (Status) + { + case FD_FLASH_ENABLE: + { + FD_Flash_Control_status |= (1u << Flags_bm); + break; + } + case FD_FLASH_DISABLE: + { + FD_Flash_Control_status &= ~(1u << Flags_bm); + break; + } + default : + { + break; + } + } + + UTILS_EXIT_CRITICAL_SECTION(); +} + +static uint8_t FD_TimeCheck(int32_t time) +{ + uint32_t current_time, next_radio_activity_time; + + current_time = HAL_RADIO_TIMER_GetCurrentSysTime(); + + if(BLE_STACK_ReadNextRadioActivity(&next_radio_activity_time) == LL_IDLE) + return TRUE; + + if((int32_t)(next_radio_activity_time - current_time) > time) + return TRUE; + + return FALSE; +} + +/** + * @brief Write a word (32-bit) in Flash + * @param Dest: Address where to write in Flash (128-bit aligned) + * @param Payload: Address of data to be written in Flash (32-bit aligned) + * @retval FD_FlashOp_Status_t: Success or failure of Flash write operation + */ +FD_FlashOp_Status_t FD_WriteData32(uint32_t Dest, uint32_t *Payload) +{ + FD_FlashOp_Status_t status = FD_FLASHOP_FAILURE; + + ATOMIC_SECTION_BEGIN(); + + DEBUG_GPIO_HIGH(); + + if(FD_Flash_Control_status & (1u << FD_FLASHACCESS_RFTS_BYPASS) || FD_TimeCheck(QUAD_WORD_WRITE_TIME_SYS)) + { + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Dest, *Payload) == HAL_OK) + { + status = FD_FLASHOP_SUCCESS; + } + } + + DEBUG_GPIO_LOW(); + + ATOMIC_SECTION_END(); + + return status; +} + +/** + * @brief Write a block of 128 bits (4 32-bit words) in Flash + * @param Dest: Address where to write in Flash (128-bit aligned) + * @param Payload: Address of data to be written in Flash (32-bit aligned) + * @retval FD_FlashOp_Status_t: Success or failure of Flash write operation + */ +FD_FlashOp_Status_t FD_WriteData128(uint32_t Dest, uint32_t *Payload) +{ + FD_FlashOp_Status_t status = FD_FLASHOP_FAILURE; + + ATOMIC_SECTION_BEGIN(); + + DEBUG_GPIO_HIGH(); + + if(FD_Flash_Control_status & (1u << FD_FLASHACCESS_RFTS_BYPASS) || FD_TimeCheck(QUAD_WORD_WRITE_TIME_SYS)) + { + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_BURST, Dest, (uint32_t) Payload) == HAL_OK) + { + status = FD_FLASHOP_SUCCESS; + } + } + + DEBUG_GPIO_LOW(); + + ATOMIC_SECTION_END(); + + return status; +} + +/** + * @brief Erase one sector of Flash + * @param Sect: Identifier of the sector to erase + * @retval FD_FlashOp_Status_t: Success or failure of Flash erase operation + */ +FD_FlashOp_Status_t FD_EraseSectors(uint32_t Sect) +{ + FD_FlashOp_Status_t status = FD_FLASHOP_FAILURE; + uint32_t page_error; + FLASH_EraseInitTypeDef p_erase_init; + + p_erase_init.TypeErase = FLASH_TYPEERASE_PAGES; + p_erase_init.Page = Sect; + p_erase_init.NbPages = 1; + + ATOMIC_SECTION_BEGIN(); + + DEBUG_GPIO_HIGH(); + + if(FD_TimeCheck(PAGE_ERASE_TIME_SYS)) + { + if (HAL_FLASHEx_Erase(&p_erase_init, &page_error) == HAL_OK) + { + status = FD_FLASHOP_SUCCESS; + } + } + + DEBUG_GPIO_LOW(); + + ATOMIC_SECTION_END(); + + return status; +} diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_driver.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_driver.h new file mode 100644 index 000000000..ba22fec96 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_driver.h @@ -0,0 +1,80 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file flash_driver.h + * @author MCD Application Team + * @brief Header for flash_driver.c module + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef FLASH_DRIVER_H +#define FLASH_DRIVER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "utilities_common.h" + +/* Exported types ------------------------------------------------------------*/ + +/* Bit mask to modify Flash Control status */ +typedef uint32_t FD_Flash_ctrl_bm_t; + +/* Flash operation status */ +typedef enum +{ + FD_FLASHOP_SUCCESS, + FD_FLASHOP_FAILURE +} FD_FlashOp_Status_t; + +/* Flash Driver commands to enable or disable flash access */ +typedef enum +{ + FD_FLASH_ENABLE, + FD_FLASH_DISABLE, +} FD_FLASH_Status_t; + +/** + * @brief Bit mask to modify Flash Control status + * + * @details Those bitmasks are used to enable/disable access to the flash: + * - RFTS: + * -# FD_FLASHACCESS_RFTS_BYPASS: Bypass check of radio activity before Flash operation. + * This means that every Flash operation will start even if + * a system is close to a radio activity. + * + */ +typedef enum FD_FlashAccess_bm +{ + /* Bypass of RF Timing Synchro flash access bitfield */ + FD_FLASHACCESS_RFTS_BYPASS, +}FD_FlashAccess_bm_t; + +/* Exported constants --------------------------------------------------------*/ +/* Exported variables --------------------------------------------------------*/ +/* Exported macros -----------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +void FD_SetStatus(FD_FlashAccess_bm_t Flags_bm, FD_FLASH_Status_t Status); +FD_FlashOp_Status_t FD_WriteData32(uint32_t Dest, uint32_t *Payload); +FD_FlashOp_Status_t FD_WriteData128(uint32_t Dest, uint32_t *Payload); +FD_FlashOp_Status_t FD_EraseSectors(uint32_t Sect); + +#ifdef __cplusplus +} +#endif + +#endif /*FLASH_DRIVER_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_manager.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_manager.c new file mode 100644 index 000000000..96a8947b8 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_manager.c @@ -0,0 +1,387 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file flash_manager.c + * @author MCD Application Team + * @brief The Flash Manager module provides an interface to write raw data + * from SRAM to FLASH + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include +#include "utilities_conf.h" +#include "flash_manager.h" +#include "flash_driver.h" +#include "stm32wb0x_hal.h" + +/* Global variables ----------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ + +/* Flash operation type */ +typedef enum +{ + FM_NO_OP, + FM_WRITE_OP, + FM_ERASE_OP +} FM_FlashOp_t; + +/** + * @brief Flash operation configuration struct + */ +typedef struct FM_FlashOpConfig +{ + uint32_t *writeSrc; + uint32_t *writeDest; + int32_t writeSize; + uint32_t eraseFirstSect; + uint32_t eraseNbrSect; +}FM_FlashOpConfig_t; + +/* Private defines -----------------------------------------------------------*/ + +#define FLASH_WRITE_BLOCK_SIZE 4U +#define ALIGNMENT_32 0x00000003 +#define ALIGNMENT_128 0x0000000F + +/* Private macros ------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +/** + * @brief Semaphore on Flash + */ +static bool busy_flash_sem = FALSE; + +/** + * @brief Indicates if the flash manager module is available or not + */ +static bool flash_manager_busy = FALSE; + +/** + * @brief Callback node list for pending flash operation request + */ +static tListNode fm_cb_pending_list; + +/** + * @brief Flag indicating if pending node list has been initialized + */ +static bool fm_cb_pending_list_init = FALSE; + +/** + * @brief Pointer to current flash operation requester's callback + */ +static void (*fm_running_cb)(FM_FlashOp_Status_t); + +/** + * @brief Type of current flash operation (Write/Erase) + */ +static FM_FlashOp_t fm_flashop = FM_NO_OP; + +/** + * @brief Parameters for Flash operation + */ +static FM_FlashOpConfig_t fm_flashop_parameters; + +/* Private function prototypes -----------------------------------------------*/ + +static FM_Cmd_Status_t FM_CheckFlashManagerState(FM_CallbackNode_t *CallbackNode); + +/* Functions Definition ------------------------------------------------------*/ + +/** + * @brief Request the Flash Manager module to initiate a Flash Write operation + * @param Src: Address of the data to be stored in FLASH. It shall be 32bits aligned + * @param Dest: Address where the data shall be written. It shall be 128bits aligned + * @param Size: This is the number of words to be written in Flash. + * @param CallbackNode: Pointer to the callback node for storage in list + * @retval FM_Cmd_Status_t: Status of the Flash Manager module + */ +FM_Cmd_Status_t FM_Write(uint32_t *Src, uint32_t *Dest, int32_t Size, FM_CallbackNode_t *CallbackNode) +{ + FM_Cmd_Status_t status; + + if (((uint32_t)Dest < FLASH_START_ADDR) || ((uint32_t)Dest > (FLASH_START_ADDR + FLASH_SIZE)) + || (((uint32_t)Dest + Size) > (FLASH_START_ADDR + FLASH_SIZE))) + {/* Destination address not part of the flash */ + return FM_ERROR; + } + + if (((uint32_t) Src & ALIGNMENT_32) || ((uint32_t) Dest & ALIGNMENT_32)) + { /* Source or destination address not properly aligned */ + return FM_ERROR; + } + + status = FM_CheckFlashManagerState(CallbackNode); + + if (status == FM_OK) + { /* Flash manager is available */ + + /* Save Write parameters */ + fm_flashop_parameters.writeSrc = Src; + fm_flashop_parameters.writeDest = Dest; + fm_flashop_parameters.writeSize = Size; + + fm_flashop = FM_WRITE_OP; + + /* Window request to be executed in background */ + FM_ProcessRequest(TRUE); + } + return status; +} + +/** + * @brief Request the Flash Manager module to initiate a Flash Erase operation + * @param FirstSect: Index of the first sector to erase + * @param NbrSect: Number of sector to erase + * @param CallbackNode: Pointer to the callback node for storage in list + * @retval FM_Cmd_Status_t: Status of the Flash Manager module + */ +FM_Cmd_Status_t FM_Erase(uint32_t FirstSect, uint32_t NbrSect, FM_CallbackNode_t *CallbackNode) +{ + FM_Cmd_Status_t status; + + if ((FirstSect > FLASH_PAGE_NUMBER) || ((FirstSect + NbrSect) > FLASH_PAGE_NUMBER)) + { /* Inconsistent request */ + return FM_ERROR; + } + + if (NbrSect == 0) + { /* Inconsistent request */ + return FM_ERROR; + } + + status = FM_CheckFlashManagerState(CallbackNode); + + if (status == FM_OK) + { /* Flash manager is available */ + + /* Save Erase parameters */ + fm_flashop_parameters.eraseFirstSect = FirstSect; + fm_flashop_parameters.eraseNbrSect = NbrSect; + + fm_flashop = FM_ERASE_OP; + + /* Window request to be executed in background */ + FM_ProcessRequest(TRUE); + } + return status; +} + +/** + * @brief Execute Flash Manager background tasks + * @param None + * @retval None + */ +void FM_BackgroundProcess (void) +{ + bool flashop_complete = false; + FD_FlashOp_Status_t fdReturnValue = FD_FLASHOP_SUCCESS; + FM_CallbackNode_t *pCbNode = NULL; + + if (fm_flashop == FM_WRITE_OP) + { + + /* Write first non-aligned bytes */ + while(fm_flashop_parameters.writeSize > 0 && ((uint32_t)fm_flashop_parameters.writeDest & ALIGNMENT_128) && + fdReturnValue == FD_FLASHOP_SUCCESS) + { + /* Write single words */ + fdReturnValue = FD_WriteData32((uint32_t) fm_flashop_parameters.writeDest, + fm_flashop_parameters.writeSrc); + if (fdReturnValue == FD_FLASHOP_SUCCESS) + { + fm_flashop_parameters.writeDest += 1; + fm_flashop_parameters.writeSrc += 1; + fm_flashop_parameters.writeSize -= 1; + } + } + + /* Write aligned block */ + while((fm_flashop_parameters.writeSize >= 4) && + (fdReturnValue == FD_FLASHOP_SUCCESS)) + { + fdReturnValue = FD_WriteData128((uint32_t) fm_flashop_parameters.writeDest, + fm_flashop_parameters.writeSrc); + + if (fdReturnValue == FD_FLASHOP_SUCCESS) + { + fm_flashop_parameters.writeDest += FLASH_WRITE_BLOCK_SIZE; + fm_flashop_parameters.writeSrc += FLASH_WRITE_BLOCK_SIZE; + fm_flashop_parameters.writeSize -= FLASH_WRITE_BLOCK_SIZE; + } + } + + /* Write remaining words, if any */ + while(fm_flashop_parameters.writeSize > 0 && + fdReturnValue == FD_FLASHOP_SUCCESS) + { + /* Write single words */ + fdReturnValue = FD_WriteData32((uint32_t) fm_flashop_parameters.writeDest, + fm_flashop_parameters.writeSrc); + if (fdReturnValue == FD_FLASHOP_SUCCESS) + { + fm_flashop_parameters.writeDest += 1; + fm_flashop_parameters.writeSrc += 1; + fm_flashop_parameters.writeSize -= 1; + } + } + + /* Is write over ? */ + if (fm_flashop_parameters.writeSize <= 0) + { + flashop_complete = true; + } + } + else if (fm_flashop == FM_ERASE_OP) + { + + while((fm_flashop_parameters.eraseNbrSect > 0) && + (fdReturnValue == FD_FLASHOP_SUCCESS)) + { + fdReturnValue = FD_EraseSectors(fm_flashop_parameters.eraseFirstSect); + + if (fdReturnValue == FD_FLASHOP_SUCCESS) + { + fm_flashop_parameters.eraseNbrSect--; + fm_flashop_parameters.eraseFirstSect++; + } + } + + if (fm_flashop_parameters.eraseNbrSect == 0) + { + flashop_complete = true; + } + } + + if (flashop_complete == true) + { + fm_flashop = FM_NO_OP; + + UTILS_ENTER_CRITICAL_SECTION(); + + /* Release semaphore on flash */ + busy_flash_sem = false; + + /* Set Flash Manager busy */ + flash_manager_busy = false; + + UTILS_EXIT_CRITICAL_SECTION(); + + /* Invoke the running callback if present */ + if (fm_running_cb != NULL) + { + fm_running_cb(FM_OPERATION_COMPLETE); + } + + /* notify pending requesters */ + while((LST_is_empty (&fm_cb_pending_list) == false) && + (busy_flash_sem == false) && (flash_manager_busy == false)) + { + LST_remove_head (&fm_cb_pending_list, (tListNode**)&pCbNode); + pCbNode->Callback(FM_OPERATION_AVAILABLE); + } + } + else + { + FM_ProcessRequest(FALSE); + } + +} + +/** + * @brief Check if the Flash Manager is busy or available + * @param CallbackNode: Pointer to the callback node for storage in list + * @retval FM_Cmd_Status_t: Status of the Flash Manager module + */ +static FM_Cmd_Status_t FM_CheckFlashManagerState(FM_CallbackNode_t *CallbackNode) +{ + bool fm_process_cmd = false; + FM_Cmd_Status_t status = FM_ERROR; + + /* Check if semaphore on flash is available */ + UTILS_ENTER_CRITICAL_SECTION(); + + /* Initialize pending list if not done */ + if (fm_cb_pending_list_init == false) + { + LST_init_head(&fm_cb_pending_list); + fm_cb_pending_list_init = true; + } + /* Check if semaphore on flash is available */ + if (busy_flash_sem == false) + { /* Check if Flash Manager is already busy */ + if (flash_manager_busy == false) + { + busy_flash_sem = true; /* Get semaphore on flash */ + flash_manager_busy = true; /* Set Flash Manager busy */ + fm_process_cmd = true; + } + else + { + fm_process_cmd = false; + } + } + else + { + fm_process_cmd = false; + } + UTILS_EXIT_CRITICAL_SECTION(); + + if (fm_process_cmd == false) + { /* Flash manager busy */ + + /* Append callback to the pending list */ + if ((CallbackNode != NULL) && (CallbackNode->Callback != NULL)) + { + LST_insert_tail(&fm_cb_pending_list, &(CallbackNode->NodeList)); + } + + status = FM_BUSY; + } + else + { /* Flash manager is available */ + + if ((CallbackNode != NULL) && (CallbackNode->Callback != NULL)) + { + UTILS_ENTER_CRITICAL_SECTION(); + + fm_running_cb = CallbackNode->Callback; + + UTILS_EXIT_CRITICAL_SECTION(); + } + else + { + UTILS_ENTER_CRITICAL_SECTION(); + + fm_running_cb = NULL; + + UTILS_EXIT_CRITICAL_SECTION(); + } + + status = FM_OK; + } + return status; +} + +/** + * @brief This is the function called by the module when it is requested to call + * FM_BackgroundProcess(). + * @param immediate: if 1, FM_BackgroundProcess() should be called as soon as possible, + * otherwise it may be called after a while. + * @retval None + */ +__weak void FM_ProcessRequest(uint8_t immediate) +{ + UNUSED(immediate); +} diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_manager.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_manager.h new file mode 100644 index 000000000..e0feed126 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Flash/flash_manager.h @@ -0,0 +1,72 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file flash_manager.h + * @author MCD Application Team + * @brief Header for flash_manager.c module + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef FLASH_MANAGER_H +#define FLASH_MANAGER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "utilities_common.h" +#include "stm_list.h" + +/* Exported types ------------------------------------------------------------*/ + +/* Flash Manager command status */ +typedef enum +{ + FM_OK, /* The Flash Manager is available and a window request is scheduled */ + FM_BUSY, /* The Flash Manager is busy and the caller will be called back when it is available */ + FM_ERROR /* An error occurred while processing the command */ +} FM_Cmd_Status_t; + +/* Flash operation status */ +typedef enum +{ + FM_OPERATION_COMPLETE, /* The requested flash operation is complete */ + FM_OPERATION_AVAILABLE /* A flash operation can be requested */ +} FM_FlashOp_Status_t; + +/** + * @brief Flash Manager callback node type to store them in a chained list + */ +typedef struct FM_CallbackNode +{ + tListNode NodeList; /* Next and previous nodes in the list */ + void (*Callback)(FM_FlashOp_Status_t Status); /* Callback function pointer for Flash Manager caller */ +}FM_CallbackNode_t; + +/* Exported constants --------------------------------------------------------*/ +/* Exported variables --------------------------------------------------------*/ +/* Exported macros -----------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +FM_Cmd_Status_t FM_Write(uint32_t *Src, uint32_t *Dest, int32_t Size, FM_CallbackNode_t *CallbackNode); +FM_Cmd_Status_t FM_Erase(uint32_t FirstSect, uint32_t NbrSect, FM_CallbackNode_t *CallbackNode); +void FM_BackgroundProcess (void); +void FM_ProcessRequest(uint8_t immediate); + +#ifdef __cplusplus +} +#endif + +#endif /*FLASH_MANAGER_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm.h new file mode 100644 index 000000000..9fe28553c --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm.h @@ -0,0 +1,51 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file nvm.h + * @author GPM WBL Application Team + * @brief Header file of NVM module. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef NVM_H +#define NVM_H + +typedef enum +{ + NVM_STATUS_OK = 0, + NVM_STATUS_FULL = -1, + NVM_STATUS_BUSY = -2, + NVM_STATUS_EOF = -3 +} NVM_StatusTypeDef; + +/* Enumerated values used for the 'type' of NVM functions: */ + +typedef enum +{ + NVM_TYPE_SEC = 0, + NVM_TYPE_GATT = 1, + NVM_TYPE_DEVICE_ID = 2, +} NVM_RecordTypeDef; + +/* Enumerated values used for the 'mode' of NVM functions: */ + +typedef enum +{ + NVM_RECORD_FIRST = 0, + NVM_RECORD_NEXT = 1, + NVM_RECORD_CURRENT = 2, + NVM_RECORD_ALL = 3 +} NVM_ModeTypeDef; + +#endif /* NVM_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm_db.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm_db.h new file mode 100644 index 000000000..700fb514c --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm_db.h @@ -0,0 +1,142 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file nvm_db.h + * @author GPM WBL Application Team + * @brief This file contains all the functions prototypes for the NVM Manager. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef NVM_DB_H +#define NVM_DB_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + +/** @addtogroup NVM_Manager_Peripheral NVM Manager + * @{ + */ + +/** @defgroup NVM_Manager_Exported_Types Exported Types + * @{ + */ + +typedef uint8_t NVMDB_status_t; + +typedef uint8_t NVMDB_IdType; + +typedef struct _NVMDB_HandleType +{ + NVMDB_IdType id; + uint32_t address; + uint32_t end_address; // This info may also be retrieved from id. + uint8_t first_read; + uint8_t cache; // If TRUE, the handle points in cache + uint16_t cache_index; // If cache is TRUE, cache_index is the index of the current write operation. +}NVMDB_HandleType; + +typedef uint16_t NVMDB_RecordSizeType; + +/** + * @} + */ + +/** @defgroup NVM_Manager_Exported_Constants Exported Constants + * @{ + */ + +/** + * @name Return codes + * @{ + */ +#define NVMDB_STATUS_OK 0 +#define NVMDB_STATUS_INVALID_ID 1 +#define NVMDB_STATUS_FULL_DB 2 +#define NVMDB_STATUS_CORRUPTED_DB 3 +#define NVMDB_STATUS_END_OF_DB 4 +#define NVMDB_STATUS_INVALID_RECORD 5 +#define NVMDB_STATUS_INVALID_OFFSET 6 +#define NVMDB_STATUS_NOT_ENOUGH_TIME 7 +#define NVMDB_STATUS_CACHE_FULL 8 +#define NVMDB_STATUS_CACHE_OP_PENDING 9 +#define NVMDB_STATUS_LOCKED 10 +#define NVMDB_STATUS_CLEAN_NEEDED 11 +#define NVMDB_STATUS_CACHE_ERROR 12 +/** + * @} + */ + +/** + * Record type. If set to ALL_TYPES, all record types are returned. Values are + * defined by application. + */ +#define ALL_TYPES 0xFF + +/** + * @} + */ + +/** @defgroup NVM_Manager_Exported_Macros Exported Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup NVM_Manager_Exported_Functions Exported Functions + * @{ + */ + +NVMDB_status_t NVMDB_Init(void); + +NVMDB_status_t NVMDB_HandleInit(NVMDB_IdType NVMDB_id, NVMDB_HandleType *handle_p); + +NVMDB_status_t NVMDB_ReadNextRecord(NVMDB_HandleType *handle_p, uint8_t record_type, NVMDB_RecordSizeType data_offset, uint8_t *data_p, NVMDB_RecordSizeType max_size, NVMDB_RecordSizeType *size_p); + +NVMDB_status_t NVMDB_ReadCurrentRecord(NVMDB_HandleType *handle_p, NVMDB_RecordSizeType offset, uint8_t *data_p, NVMDB_RecordSizeType max_size, NVMDB_RecordSizeType *size_p); + +NVMDB_status_t NVMDB_FindNextRecord(NVMDB_HandleType *handle_p, uint8_t type, NVMDB_RecordSizeType pattern_offset, const uint8_t *pattern_p, NVMDB_RecordSizeType pattern_length, NVMDB_RecordSizeType data_offset, uint8_t *data_p, NVMDB_RecordSizeType max_size, NVMDB_RecordSizeType *size_p); + +NVMDB_status_t NVMDB_AppendRecord(NVMDB_HandleType *handle_p, uint8_t record_type, uint16_t header_length, const void *header, uint16_t data_length, const void *data); + +NVMDB_status_t NVMDB_DeleteRecord(const NVMDB_HandleType *handle_p); + +NVMDB_status_t NVMDB_CleanDB(NVMDB_IdType NVMDB_id); + +NVMDB_status_t NVMDB_Erase(NVMDB_IdType NVMDB_id); + +NVMDB_status_t NVMDB_Tick(void); + +uint8_t NVMDB_TimeCheck(int32_t time); + +int NVMDB_CompareCurrentRecord(NVMDB_HandleType *handle_p, NVMDB_RecordSizeType offset, const uint8_t *data_p, NVMDB_RecordSizeType size); + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* NVM_DB_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm_db_conf.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm_db_conf.h new file mode 100644 index 000000000..cb1387d69 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Inc/nvm_db_conf.h @@ -0,0 +1,151 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file nvm_db_conf.h + * @author GPM WBL Application Team + * @brief Header file for NVM manager, that can be customized. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef NVM_DB_CONF_H +#define NVM_DB_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include "stm32wb0x.h" + +#ifndef AUTO_CLEAN +#define AUTO_CLEAN 1 +#endif + +/** @addtogroup NVM_Manager_Peripheral NVM Manager + * @{ + */ + +/** @defgroup NVM_Manager_Exported_Types Exported Types + * @{ + */ + +typedef struct +{ + uint8_t id; // Database id. + uint32_t offset; // Offset of the database in the page. +#if AUTO_CLEAN + uint16_t clean_threshold; // Threshold of free space under which a clean operation is triggered. Set to 0 to disable. +#endif +} NVMDB_SmallDBType; + +typedef struct +{ + uint32_t page_address; // Start address of the page where the databases are located. + uint8_t num_db; // Number of databases inside the page. + const NVMDB_SmallDBType *dbs; // Pointer to an array, where each element is the offset of each database in the page. +} NVMDB_SmallDBContainerType; + +typedef struct +{ + uint32_t address; + uint16_t size; + uint8_t id; +#if AUTO_CLEAN + uint16_t clean_threshold; // Threshold of free space under which a clean operation is triggered. Set to 0 to disable. +#endif +} NVMDB_StaticInfoType; + +/** + * @} + */ + +/** @defgroup NVM_Manager_Exported_Constants Exported Constants + * @{ + */ + +#define PAGE_SIZE _MEMORY_BYTES_PER_PAGE_ // It specifies the minimum size that can be erased. It must be multiple of 2. + +/* Change the following macros in order to match the desired database set. */ + +#define SEC_GATT_BD 0 +#define DEVICE_ID_DB 1 + +#define PRESET1 1 + +#if PRESET1 + +#define NUM_SMALL_DB_PAGES 0 +#define NUM_SMALL_DBS 0 +#define NUM_LARGE_DBS 2 + +#elif PRESET2 + +#define NUM_SMALL_DB_PAGES 1 +#define NUM_SMALL_DBS 2 +#define NUM_LARGE_DBS 0 + +#endif + +#define NUM_DB (NUM_SMALL_DBS + NUM_LARGE_DBS) + +/** + * @} + */ + +/** @defgroup NVM_Manager_Exported_Macros Exported Macros + * @{ + */ + +#define WORD_WRITE_TIME_US 65 // In microsecond units +#define WORD_WRITE_TIME_SYS ((int)(WORD_WRITE_TIME_US * 256 / 625) + 1) // In system time units +#define PAGE_ERASE_TIME_US 22000 // In microsecond units +#define PAGE_ERASE_TIME_SYS ((int)(PAGE_ERASE_TIME_US * 256 / 625) + 1) // In system time units + +#define PAGE_WRITE_TIME_MS ((PAGE_SIZE / 4 * WORD_WRITE_TIME_US) / 1000 + 1) +#define MARGIN_TIME_SYS 10 // In system time units + +#define NVMDB_FLASH_WRITE(address, word) HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, word) +#define NVMDB_FLASH_ERASE_PAGE(page_num, num_pages) do { \ + FLASH_EraseInitTypeDef EraseInit = { \ + .TypeErase = FLASH_TYPEERASE_PAGES, \ + .Page = (page_num), \ + .NbPages = (num_pages) \ + }; \ + uint32_t PageError; \ + HAL_FLASHEx_Erase(&EraseInit, &PageError); \ + }while(0) + +/** + * @} + */ + +/** @defgroup NVM_Manager_Exported_Functions Exported Functions + * @{ + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* NVM_DB_CONF_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Src/nvm_db.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Src/nvm_db.c new file mode 100644 index 000000000..20696401f --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Src/nvm_db.c @@ -0,0 +1,2336 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file nvm_db.c + * @author GPM WBL Application Team + * @brief This file provides functions to implement sequential databases. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include +#include +#include "stm32wb0x.h" +#include "nvm_db.h" +#include "nvm_db_conf.h" + +/* Process all commands in cache till there is time to do it. */ +#define PROCESS_CACHE_AT_ONCE 1 +#define NVM_CACHE 0 + +/** @defgroup NVM_Manager NVM Manager + * @{ + */ + +/** @defgroup NVM_Manager_TypesDefinitions Private Type Definitions + * @{ + */ + +typedef struct +{ + uint8_t valid_flag; + uint8_t record_id; + NVMDB_RecordSizeType length; +} NVMDB_RecordHeaderType; + +#define RECORD_HEADER_SIZE 4 + +typedef struct +{ + NVMDB_RecordHeaderType header; + uint8_t data[]; +} NVMDB_RecordType, *NVMDB_RecordType_ptr; + +typedef struct +{ + uint32_t start_address; + uint32_t end_address; + uint16_t valid_records; + uint16_t invalid_records; + uint16_t free_space; // Free space at the end of last record. It is a real free space, not virtual. After a clean, the free space may increase. It takes also into account all the records in cache. + uint8_t locked; + uint16_t clean_threshold; +} NVMDB_info; + +typedef struct +{ + uint8_t move_to_next_record; + NVMDB_RecordSizeType record_offset; + NVMDB_RecordSizeType record_length; +}ReadStateType; + +// Generic structure +typedef struct +{ + uint16_t length; + uint8_t op; + NVMDB_IdType id; +}CacheOperationType; + +typedef struct +{ + uint16_t length; + uint8_t op; + NVMDB_IdType id; +}CacheNoOperationType; + +typedef struct +{ + uint16_t length; + uint8_t op; + NVMDB_IdType id; + uint8_t record_type; +}CacheWriteOperationType; + +typedef struct +{ + uint16_t length; + uint8_t op; + NVMDB_IdType id; + uint32_t address; +}CacheDeleteOperationType; + +typedef struct +{ + uint16_t length; + uint8_t op; + NVMDB_HandleType handle; // NVMDB_IdType id is first field of NVMDB_HandleType structure + uint32_t flash_address; + ReadStateType read_state; +}CacheCleanLargeOperationType; + +typedef struct +{ + uint16_t length; + uint8_t op; + NVMDB_IdType id; + uint8_t page_num_start; + uint8_t num_pages; +}CachePageEraseOperationType; + +typedef struct +{ + uint16_t length; + uint8_t op; + NVMDB_IdType id; + const NVMDB_SmallDBContainerType *smallDBContainer_p; +}CacheSmallDBEraseOperationType; + +/** + * @} + */ + +/** @defgroup NVM_Manager_Private_Defines Private Defines + * @{ + */ +#define DEBUG_GPIO_HIGH() +#define DEBUG_GPIO_LOW() + +#define NO_RECORD 0xFF +#define VALID_RECORD 0xFE +#define INVALID_RECORD 0x00 + +#define NVM_CACHE_SIZE 256 + +/* If 1 the buffer used to temporarily store data is static, otherwise it is allocated in CSTACK. */ +#define NVMDB_STATIC_BUFF 0 + +#define CACHE_NOP 0 +#define CACHE_WRITE_OP 1 +#define CACHE_DELETE_OP 2 +#define CACHE_CLEAN_LARGE_DB_OP 3 +#define CACHE_PAGE_ERASE_OP 4 +#define CACHE_SMALL_DB_ERASE_OP 5 +#define CACHE_ALL 6 + +#define SMALL_DB 1 +#define LARGE_DB 2 + +#ifdef DEBUG +#include +#define PRINTF(...) printf(__VA_ARGS__) +#else +#define PRINTF(...) +#endif + +#define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \ + __disable_irq(); \ +/* Must be called in the same or in a lower scope of ATOMIC_SECTION_BEGIN */ +#define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit) + +/** + * @} + */ + +/** @defgroup NVM_Manager_Private_Macros Private Macros + * @{ + */ + +#define PAGE_OFFSET_MASK (PAGE_SIZE - 1) + +#define MIN_RECORD_SIZE (RECORD_HEADER_SIZE + 1) +#define MAX_RECORD_SIZE ((NVMDB_RecordSizeType)(-1)) + +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +#define ROUND4_L(a) (((a) >> 2) << 2) // Round to previous multiple of 4. +#define ROUND_R(a, b) ((((a) - 1) | (b - 1)) + 1) // Round 'a' to next multiple of 'b', being 'b' a power of 2. +#define ROUND4_R(a) ROUND_R(a, 4)// Round to next multiple of 4 +#define ROUNDPAGE_R(a) ROUND_R(a, PAGE_SIZE)// Round to next right multiple of page size +#define BEGIN_OF_PAGE(a) ((a) & (~PAGE_OFFSET_MASK)) + +#define CACHE_EMPTY() (cache_head == cache_tail) + +/** + * @} + */ + +/** @defgroup NVM_Manager_Private_Variables Private Variables + * @{ + */ +#if NVMDB_STATIC_BUFF +static uint8_t NVM_buffer[PAGE_SIZE]; +#endif +static NVMDB_info DBInfo[NUM_DB]; +#if NVM_CACHE +static uint8_t NVM_cache[NVM_CACHE_SIZE]; +static uint16_t cache_head = 0, cache_tail = 0; +#endif + +/** + * @} + */ + +/** @defgroup NVM_Manager_External_Variables External Variables + * @{ + */ + +extern const NVMDB_SmallDBContainerType NVM_SMALL_DB_STATIC_INFO[]; +extern const NVMDB_StaticInfoType NVM_LARGE_DB_STATIC_INFO[]; + +/** + * @} + */ + +/** @defgroup NVM_Manager_Private_FunctionPrototypes Private Function Prototypes + * @{ + */ +#if NVM_CACHE +static NVMDB_status_t ScheduleCleanLargeDBOperation(NVMDB_HandleType handle, uint32_t flash_address, ReadStateType state); +static NVMDB_status_t SchedulePageEraseOperation(NVMDB_IdType NVMDB_id, uint8_t page_num_start, uint8_t num_pages); +static uint8_t CacheRequestBuffer(uint16_t length); +static uint8_t CacheInsertData(const void *data, uint16_t length); +static uint16_t CacheGetDataSize(void); +#endif + +#if AUTO_CLEAN +static int8_t NVMDB_CleanCheck(void); +#endif + +/** + * @} + */ + +/** @defgroup NVM_Manager_Private_Functions Private Functions + * @{ + */ + +#if NVM_CACHE + +static void CacheAdvanceHead(uint16_t length) +{ + cache_head += length; + if(cache_head == cache_tail) + { + cache_head = cache_tail = 0; + } +} + +// If advance_to_next is true, it advances to next record before searching for the given operation. +static uint8_t CacheFindOperation(NVMDB_IdType NVMDB_id, uint8_t op, uint16_t index_in, uint16_t *index_out_p, uint8_t advance_to_next) +{ + uint16_t i = index_in; + uint8_t skip_record = advance_to_next; + + while(1) + { + + if(i == cache_tail) + { + return FALSE; + } + + CacheOperationType cache_op; + memcpy(&cache_op, &NVM_cache[i], sizeof(cache_op)); + + if(!skip_record && cache_op.id == NVMDB_id && (op == CACHE_ALL || op == cache_op.op)) + { + break; + } + i += cache_op.length; + + skip_record = FALSE; + } + + if(index_out_p != NULL) + { + *index_out_p = i; + } + + return TRUE; +} + +// If advance_to_next is true, read next record. If false, read current record. If handle does not point in cache, always read first record in cache. +static NVMDB_status_t ReadRecordInCache(NVMDB_HandleType *handle_p, uint8_t **data_p, NVMDB_RecordSizeType *data_len, uint8_t advance_to_next, uint8_t *type) +{ + uint16_t index_in, index_out; + //uint8_t advance_to_next; + + if(!handle_p->cache) + { + index_in = cache_head; + advance_to_next = FALSE; + } + else + { + index_in = handle_p->cache_index; + //advance_to_next = TRUE; + } + + if(!CacheFindOperation(handle_p->id, CACHE_WRITE_OP, index_in, &index_out, advance_to_next)) + { + return NVMDB_STATUS_END_OF_DB; + } + + handle_p->cache = TRUE; + handle_p->cache_index = index_out; + + CacheWriteOperationType write_op; + memcpy(&write_op, &NVM_cache[index_out], sizeof(write_op)); + *data_p = &NVM_cache[index_out] + sizeof(write_op); + *data_len = write_op.length - sizeof(write_op); + *type = write_op.record_type; + + return NVMDB_STATUS_OK; +} + +static void RemoveCacheOp(NVMDB_IdType NVMDB_id) +{ + uint16_t index = cache_head; + uint8_t advance_to_next = FALSE; + + while(CacheFindOperation(NVMDB_id, CACHE_ALL, index, &index, advance_to_next)) + { + + CacheOperationType cache_op; + memcpy(&cache_op, &NVM_cache[index], sizeof(cache_op)); + // Shift cache content. Another solution that avoids this memory operation is to write CACHE_NOP inside op field. + memmove(NVM_cache + index, NVM_cache + index + cache_op.length, CacheGetDataSize() - cache_op.length); + cache_tail -= cache_op.length; + + advance_to_next = TRUE; + } +} + +static int32_t CalculateFlashTimeOperation(uint16_t write_length, uint8_t num_pages_to_be_erased) +{ + return PAGE_ERASE_TIME_SYS * num_pages_to_be_erased + (write_length / 4 + 1) * WORD_WRITE_TIME_SYS + MARGIN_TIME_SYS; +} + +static NVMDB_status_t EraseWithTimeCheck(uint8_t *page_num_start, uint8_t *num_pages_p) +{ + int32_t needed_time; + + while(*num_pages_p > 0) + { + + needed_time = CalculateFlashTimeOperation(0, 1); + + ATOMIC_SECTION_BEGIN(); + if(NVMDB_TimeCheck(needed_time)) + { + DEBUG_GPIO_HIGH(); + NVMDB_FLASH_ERASE_PAGE(*page_num_start, 1); // Erase one page at a time. Check if there is time before each erase. + DEBUG_GPIO_LOW(); + ATOMIC_SECTION_END(); + (*page_num_start)++; + (*num_pages_p)--; + } + else + { + ATOMIC_SECTION_END(); + return NVMDB_STATUS_NOT_ENOUGH_TIME; + } + } + + return NVMDB_STATUS_OK; +} + +#endif + +static NVMDB_status_t NVMDB_get_info(NVMDB_info *info) +{ + uint32_t address = info->start_address; + NVMDB_RecordType_ptr record_p; + + info->valid_records = 0; + info->invalid_records = 0; + info->free_space = 0; + info->locked = FALSE; + + while(1) + { + + record_p = (NVMDB_RecordType_ptr)address; + + if(record_p->header.valid_flag == NO_RECORD) + { + info->free_space = info->end_address - address - RECORD_HEADER_SIZE; + return NVMDB_STATUS_OK; + } + else if(record_p->header.valid_flag == VALID_RECORD) + { + info->valid_records++; + } + else if(record_p->header.valid_flag == INVALID_RECORD) + { + info->invalid_records++; + } + else + { + // Wrong flag + return NVMDB_STATUS_CORRUPTED_DB; + } + + address += ROUND4_R(record_p->header.length + RECORD_HEADER_SIZE); + + if(address + MIN_RECORD_SIZE >= info->end_address) // End of DB reached + { + return NVMDB_STATUS_OK; + } + } +} + +/* Current_record_length is used to read the next record when the current record + is no more present (because, for example, a clean operation has canceled it). */ +static NVMDB_status_t NextRecordNoLock(NVMDB_HandleType *handle_p, uint8_t type, uint8_t **data_p, NVMDB_RecordSizeType *data_len, NVMDB_RecordSizeType current_record_length, uint8_t *record_type) +{ + NVMDB_RecordHeaderType header; + NVMDB_RecordType_ptr record_p; + +#if NVM_CACHE + + if(handle_p->cache) // Handle points to records in cache + { + if(ReadRecordInCache(handle_p, data_p, data_len, TRUE, record_type) == NVMDB_STATUS_OK) + { + // A record to be written has been found in cache + return NVMDB_STATUS_OK; + } + else + { + return NVMDB_STATUS_END_OF_DB; + } + } +#endif + + if(current_record_length) + { + header.length = current_record_length; + header.valid_flag = VALID_RECORD; + record_p = (NVMDB_RecordType_ptr) & header; + } + else + { + record_p = (NVMDB_RecordType_ptr)handle_p->address; + } + + if(handle_p->address >= handle_p->end_address || record_p->header.valid_flag == NO_RECORD) + { + return NVMDB_STATUS_END_OF_DB; + } + + // If we are not at the end we can move to next record. + + while(1) + { + + // If it is the first read, the pointer already points to first record. + // If it is not the first read, advance the pointer to the next record (word aligned). + if(handle_p->first_read) + { + handle_p->first_read = FALSE; + } + else + { + handle_p->address += ROUND4_R(record_p->header.length + RECORD_HEADER_SIZE); + record_p = (NVMDB_RecordType_ptr)handle_p->address; + + if(handle_p->address >= handle_p->end_address || record_p->header.valid_flag == NO_RECORD) + { +#if NVM_CACHE + // Check records in cache. + if(ReadRecordInCache(handle_p, data_p, data_len, TRUE, record_type) == NVMDB_STATUS_OK) + { + // A record to be written has been found in cache + return NVMDB_STATUS_OK; + } +#endif + return NVMDB_STATUS_END_OF_DB; + } + } + + if(record_p->header.valid_flag == INVALID_RECORD) + { + // If record is invalidated, address is updated in next cycle. + continue; + } + + if(record_p->header.valid_flag != VALID_RECORD) + { + return NVMDB_STATUS_CORRUPTED_DB; + } + + if(type == ALL_TYPES || record_p->header.record_id == type) + { + +#if NVM_CACHE + uint16_t index = cache_head; + uint8_t record_is_deleted_in_cache = FALSE; + uint8_t advance_to_next_record = FALSE; + + // Check if there is a delete operation in cache on this record. + while(CacheFindOperation(handle_p->id, CACHE_DELETE_OP, index, &index, advance_to_next_record)) + { + CacheDeleteOperationType del_op; + memcpy(&del_op, &NVM_cache[index], sizeof(del_op)); + if(del_op.address == handle_p->address) + { + // Record will be deleted + record_is_deleted_in_cache = TRUE; + break; + } + advance_to_next_record = TRUE; + } + if(record_is_deleted_in_cache) + { + continue; + } +#endif + + *data_p = (uint8_t *)handle_p->address + RECORD_HEADER_SIZE; + *data_len = record_p->header.length; + + if(record_type != NULL) + { + *record_type = record_p->header.record_id; + } + + //memcpy(data_p, (uint8_t*)handle_p->address + RECORD_HEADER_SIZE + offset, MIN(record_p->header.length - offset, max_size)); + //*size_p = record_p->header.length; + + return NVMDB_STATUS_OK; + } + } +} + +static NVMDB_status_t ReadNextRecordNoLock(NVMDB_HandleType *handle_p, uint8_t record_type, NVMDB_RecordSizeType offset, uint8_t *data_p, NVMDB_RecordSizeType max_size, NVMDB_RecordSizeType *size_p, NVMDB_RecordSizeType current_record_length, uint8_t *record_type_out) +{ + NVMDB_status_t status; + + uint8_t *data; + NVMDB_RecordSizeType data_len; + + *size_p = 0; + + status = NextRecordNoLock(handle_p, record_type, &data, &data_len, current_record_length, record_type_out); + + if(status != NVMDB_STATUS_OK) + { + return status; + } + + if(offset >= data_len) + { + return NVMDB_STATUS_INVALID_OFFSET; + } + + memcpy(data_p, data + offset, MIN(data_len - offset, max_size)); + *size_p = data_len; + + return NVMDB_STATUS_OK; +} + +/** + * @brief Estimate if there is time to perform operations on DBs. + * + * This is a weak function. Application has to implement it, so that + * the NVM manager can safely execute Flash operations while radio is + * active. Weak definition always return TRUEe. + * + * @param time This is the time (in system time units) required for the operation + * @retval It returns TRUE is there is enough time, otherwise FALSE. + */ +__weak uint8_t NVMDB_TimeCheck(int32_t time) +{ + return TRUE; +} + +/* flash_address must be word aligned. */ +static void write_data(uint32_t flash_address, uint16_t data_length, const void *data) +{ + uint32_t word; + uint16_t length_word; + uint8_t rest; + const uint8_t *data_8 = data; + + length_word = (data_length >> 2) << 2; + rest = data_length - length_word; + + for(int i = 0; i < length_word; i += 4) + { + memcpy(&word, data_8 + i, sizeof(word)); + NVMDB_FLASH_WRITE(flash_address + i, word); + } + word = 0xFFFFFFFF; + memcpy(&word, data_8 + length_word, rest); + NVMDB_FLASH_WRITE(flash_address + length_word, word); +} + +static NVMDB_status_t WriteRecord(uint32_t flash_address, uint8_t record_id, uint16_t data1_length, const void *data1, uint16_t data2_length, const void *data2) +{ + uint32_t word; + NVMDB_RecordHeaderType *header_p = (NVMDB_RecordHeaderType *)&word; +#if NVM_CACHE + int32_t needed_time; +#endif + + data1_length = ROUND4_R(data1_length); // Make sure data1_length is multiple of 4. + + header_p->valid_flag = VALID_RECORD; + header_p->record_id = record_id; + header_p->length = data1_length + data2_length; + +#if NVM_CACHE + needed_time = CalculateFlashTimeOperation(data1_length + data2_length + 4, 0); + + // Disable interrupts, to be sure that there are no additional delays while writing, which can cause writes to happen during + // radio activity. + ATOMIC_SECTION_BEGIN(); + if(!NVMDB_TimeCheck(needed_time)) + { + // Not enough time + ATOMIC_SECTION_END(); + return NVMDB_STATUS_NOT_ENOUGH_TIME; + } +#endif + + DEBUG_GPIO_HIGH(); + + NVMDB_FLASH_WRITE(flash_address, word); + + write_data(flash_address + 4, data1_length, data1); + write_data(flash_address + 4 + data1_length, data2_length, data2); + + DEBUG_GPIO_LOW(); +#if NVM_CACHE + ATOMIC_SECTION_END(); +#endif + + return NVMDB_STATUS_OK; +} + +int NVMDB_CompareCurrentRecord(NVMDB_HandleType *handle_p, NVMDB_RecordSizeType offset, const uint8_t *data_p, NVMDB_RecordSizeType size) +{ + NVMDB_RecordType_ptr record_p; + +#if NVM_CACHE + + NVMDB_RecordSizeType record_size; + NVMDB_RecordSizeType remaining_size; + + if(handle_p->cache) // Handle points to records in cache + { + uint8_t *data_src; + + if(ReadRecordInCache(handle_p, &data_src, &record_size, FALSE, NULL) == NVMDB_STATUS_OK) + { + remaining_size = record_size - offset; + if(size <= remaining_size && memcmp(data_p, data_src + offset, size) == 0) + { + return NVMDB_STATUS_OK; + } + else + { + return -1; + } + } + else + { + return NVMDB_STATUS_INVALID_RECORD; + } + } + +#endif + + record_p = (NVMDB_RecordType_ptr)handle_p->address; + + if(handle_p->address >= handle_p->end_address || record_p->header.valid_flag == NO_RECORD) + { + return NVMDB_STATUS_END_OF_DB; + } + + if(handle_p->first_read || record_p->header.valid_flag != VALID_RECORD) + { + return NVMDB_STATUS_INVALID_RECORD; + } + +#if NVM_CACHE + // Check if there is a delete operation in cache on this record. + uint16_t index = cache_head; + + while(CacheFindOperation(handle_p->id, CACHE_DELETE_OP, index, &index, TRUE)) + { + CacheDeleteOperationType del_op; + memcpy(&del_op, &NVM_cache[index], sizeof(del_op)); + if(del_op.address == handle_p->address) + { + // Record will be deleted + return NVMDB_STATUS_INVALID_RECORD; + } + } +#endif + + if(offset >= record_p->header.length) + { + return NVMDB_STATUS_INVALID_OFFSET; + } + + handle_p->first_read = FALSE; + + if(memcmp(data_p, (uint8_t *)handle_p->address + RECORD_HEADER_SIZE + offset, size) == 0) + { + return NVMDB_STATUS_OK; + } + else + { + return -1; + } +} + +static NVMDB_status_t ReadCurrentRecordNoLock(NVMDB_HandleType *handle_p, NVMDB_RecordSizeType offset, uint8_t *data_p, NVMDB_RecordSizeType max_size, NVMDB_RecordSizeType *size_p, NVMDB_RecordSizeType current_record_length) +{ + NVMDB_RecordHeaderType header; + NVMDB_RecordType_ptr record_p; + + *size_p = 0; + +#if NVM_CACHE + if(handle_p->cache) // Handle points to records in cache + { + uint8_t *data_src; + + if(ReadRecordInCache(handle_p, &data_src, size_p, FALSE, NULL) == NVMDB_STATUS_OK) + { + // A record to be written has been found in cache + memcpy(data_p, data_src + offset, MIN(*size_p - offset, max_size)); + return NVMDB_STATUS_OK; + } + else + { + return NVMDB_STATUS_INVALID_RECORD; + } + } +#endif + + if(current_record_length) + { + header.length = current_record_length; + header.valid_flag = VALID_RECORD; + record_p = (NVMDB_RecordType_ptr) & header; + } + else + { + record_p = (NVMDB_RecordType_ptr)handle_p->address; + } + + if(handle_p->address >= handle_p->end_address || record_p->header.valid_flag == NO_RECORD) + { + return NVMDB_STATUS_END_OF_DB; + } + + if(handle_p->first_read || record_p->header.valid_flag != VALID_RECORD) + { + return NVMDB_STATUS_INVALID_RECORD; + } + +#if NVM_CACHE + // Check if there is a delete operation in cache on this record. + uint16_t index = cache_head; + + while(CacheFindOperation(handle_p->id, CACHE_DELETE_OP, index, &index, TRUE)) + { + CacheDeleteOperationType del_op; + memcpy(&del_op, &NVM_cache[index], sizeof(del_op)); + if(del_op.address == handle_p->address) + { + // Record will be deleted + return NVMDB_STATUS_INVALID_RECORD; + } + } +#endif + + if(offset >= record_p->header.length) + { + return NVMDB_STATUS_INVALID_OFFSET; + } + + handle_p->first_read = FALSE; + + memcpy(data_p, (uint8_t *)handle_p->address + RECORD_HEADER_SIZE + offset, MIN(record_p->header.length - offset, max_size)); + *size_p = record_p->header.length; + + return NVMDB_STATUS_OK; +} + +static NVMDB_status_t InvalidateRecord(uint32_t address) +{ + uint32_t word = 0xFFFFFF00; + +#if NVM_CACHE + int32_t needed_time; + + needed_time = CalculateFlashTimeOperation(4, 0); + + ATOMIC_SECTION_BEGIN(); + if(!NVMDB_TimeCheck(needed_time)) + { + // Not enough time + ATOMIC_SECTION_END(); + return NVMDB_STATUS_NOT_ENOUGH_TIME; + } +#endif + DEBUG_GPIO_HIGH(); + NVMDB_FLASH_WRITE(address, word); + DEBUG_GPIO_LOW(); + +#if NVM_CACHE + ATOMIC_SECTION_END(); +#endif + + return NVMDB_STATUS_OK; +} + +static NVMDB_status_t NVMDB_DeleteRecordNoCache(const NVMDB_HandleType *handle_p) +{ + NVMDB_RecordType *record_p; + NVMDB_status_t status; + + record_p = (NVMDB_RecordType_ptr)handle_p->address; + + if(handle_p->address >= handle_p->end_address || record_p->header.valid_flag == NO_RECORD) + { + return NVMDB_STATUS_END_OF_DB; + } + if(record_p->header.valid_flag == VALID_RECORD) + { + + status = InvalidateRecord((uint32_t)record_p); + if(status) + { + return status; + } + + DBInfo[handle_p->id].valid_records--; + DBInfo[handle_p->id].invalid_records++; + + return NVMDB_STATUS_OK; + } + else + { + return NVMDB_STATUS_INVALID_RECORD; + } +} + +static void ErasePage(uint32_t address, uint8_t num_pages) +{ + int page_num = (address - _MEMORY_FLASH_BEGIN_) / PAGE_SIZE; + + DEBUG_GPIO_HIGH(); + NVMDB_FLASH_ERASE_PAGE(page_num, num_pages); + DEBUG_GPIO_LOW(); +} + +/* Size of data must be multiple of 4. This function also erases the page if needed. */ +static void WriteBufferToFlash(uint32_t address, uint32_t *data, uint32_t size) +{ + /* Check if we are writing the same data in entire pages. + If size is less than a page size, we need to erase the page to clean it. */ + if((size % PAGE_SIZE) == 0 && memcmp((uint8_t *)address, data, size) == 0) + { + return; + } + + ErasePage(address, ROUNDPAGE_R(size) / PAGE_SIZE); + + DEBUG_GPIO_HIGH(); + for(int i = 0; i < size; i += 4) + { + NVMDB_FLASH_WRITE(address + i, data[i / 4]); + } + DEBUG_GPIO_LOW(); +} + +static void InitReadState(ReadStateType *state_p) +{ + state_p->move_to_next_record = TRUE; + state_p->record_offset = 0; + state_p->record_length = 0; +} + +/* Call InitReadState() to initialize read_state before passing it to the function to start loading data from the database. + This function returns NVMDB_STATUS_OK if other calls must be done to the same function to continue reading the database. + Pass the same read_state variable to the function if calling it again to continue reading from the same database. */ + +static NVMDB_status_t LoadDBToRAM(NVMDB_HandleType *handle_p, uint8_t *buff, uint16_t buff_size, uint16_t *num_read_bytes_p, ReadStateType *read_state) +{ + NVMDB_status_t status; + uint16_t free_buffer_size; + NVMDB_RecordSizeType record_size, remaining_record_bytes; + NVMDB_RecordHeaderType header; + uint16_t index = 0; + + memset(buff, 0xFF, buff_size); + + header.valid_flag = VALID_RECORD; + + while(1) + { + + free_buffer_size = buff_size - index - RECORD_HEADER_SIZE; + + // Read the record + if(read_state->move_to_next_record) + { + /* Passing read_state->record_length to the function because we do not want + the function to retrieve the info from the header of the current record, + since it may not be anymore in the same position in flash. */ + status = ReadNextRecordNoLock(handle_p, ALL_TYPES, 0, buff + index + RECORD_HEADER_SIZE, free_buffer_size, &record_size, read_state->record_length, &header.record_id); + read_state->record_length = record_size; + + if(status != NVMDB_STATUS_OK) + { + *num_read_bytes_p = index; + return status; + } + + // Prepare the header and copy it to buffer + header.length = record_size; + memcpy(buff + index, &header, RECORD_HEADER_SIZE); + index += ROUND4_R(header.length + RECORD_HEADER_SIZE); + } + else + { + + status = ReadCurrentRecordNoLock(handle_p, read_state->record_offset, buff + index, free_buffer_size, &record_size, read_state->record_length); // It will not read record in cache because this operation is not allowed if there are any. + + if(status != NVMDB_STATUS_OK) + { + // This should not happen + return status; + } + index = ROUND4_R(record_size - read_state->record_offset); + } + + // The number of remaining bytes for the current record that were to be read before calling last NVMDB_ReadNextRecord(). + // Rounded to the next multiple of 4 to find out if buffer can now be written inside the page or not. + remaining_record_bytes = ROUND4_R(record_size - read_state->record_offset); + + if(remaining_record_bytes > free_buffer_size) + { + // Not able to read the entire record. + read_state->move_to_next_record = FALSE; + read_state->record_offset += free_buffer_size; + *num_read_bytes_p = buff_size; + return NVMDB_STATUS_OK; + } + else if(remaining_record_bytes == free_buffer_size) + { + read_state->move_to_next_record = TRUE; + read_state->record_offset = 0; + *num_read_bytes_p = buff_size; + return NVMDB_STATUS_OK; + } + else if(remaining_record_bytes < free_buffer_size) + { + read_state->move_to_next_record = TRUE; + read_state->record_offset = 0; + } + } +} +// No inline to avoid allocating NVM_buffer multiple times at the same time. +__NOINLINE static NVMDB_status_t CleanLargeDB(NVMDB_IdType NVMDB_id) +{ + NVMDB_status_t status; + uint32_t flash_write_address; + uint16_t num_read_bytes; + NVMDB_HandleType handle; + ReadStateType state; +#if NVM_CACHE + NVMDB_HandleType previous_handle; + ReadStateType previous_state; + int32_t needed_time; + uint8_t clean_started = FALSE; +#endif + + if(!DBInfo[NVMDB_id].invalid_records) + { + return NVMDB_STATUS_OK; + } + +#if NVM_CACHE + // Check if there are any operations in cache + if(CacheFindOperation(NVMDB_id, CACHE_ALL, cache_head, NULL, FALSE)) + { + return NVMDB_STATUS_CACHE_OP_PENDING; + } + + //Check if there is enough space in cache for a potential clean or erase operation. + if(!CacheRequestBuffer(MAX(sizeof(CacheCleanLargeOperationType), sizeof(CachePageEraseOperationType)))) + { + return NVMDB_STATUS_CACHE_FULL; + } +#endif + + status = NVMDB_HandleInit(NVMDB_id, &handle); + flash_write_address = (uint32_t)handle.address; + + InitReadState(&state); + + while(1) + { +#if !NVMDB_STATIC_BUFF + uint8_t NVM_buffer[PAGE_SIZE]; +#endif + +#if NVM_CACHE + previous_state = state; + previous_handle = handle; +#endif + + status = LoadDBToRAM(&handle, NVM_buffer, sizeof(NVM_buffer), &num_read_bytes, &state); + if(status != NVMDB_STATUS_END_OF_DB && status != NVMDB_STATUS_OK) // No other error codes are expected. This should not happen. + { + return status; + } + + if(num_read_bytes == sizeof(NVM_buffer) || status != NVMDB_STATUS_OK) + { + if(num_read_bytes == 0) + { + // This can happen if the end of the database is reached at the beginning of the LoadDBToRAM() function. + break; + } + +#if NVM_CACHE + needed_time = CalculateFlashTimeOperation(num_read_bytes, 1); + + ATOMIC_SECTION_BEGIN(); + + if(!NVMDB_TimeCheck(needed_time)) + { + /* Not enough time. Do not schedule clean operation if it is the first write. NVMDB_Tick() will try again later. + This avoids locking the database. */ + ATOMIC_SECTION_END(); + if(!clean_started) + { + return NVMDB_STATUS_NOT_ENOUGH_TIME; + } + else + { + return ScheduleCleanLargeDBOperation(previous_handle, flash_write_address, previous_state); + } + } +#endif + + // Write buffer to flash + WriteBufferToFlash(flash_write_address, (uint32_t *)NVM_buffer, num_read_bytes); +#if NVM_CACHE + ATOMIC_SECTION_END(); + + clean_started = TRUE; +#endif + flash_write_address += sizeof(NVM_buffer); + if(status != NVMDB_STATUS_OK) + { + break; + } + } + } + // Erase remaining pages. A possible optimization could be to erase the page only if it is not already erased. + uint8_t num_pages = (ROUNDPAGE_R(handle.end_address) - flash_write_address) / PAGE_SIZE; + uint8_t page_num_start = (flash_write_address - _MEMORY_FLASH_BEGIN_) / PAGE_SIZE; + +#if NVM_CACHE + + if(EraseWithTimeCheck(&page_num_start, &num_pages) == NVMDB_STATUS_NOT_ENOUGH_TIME) + { + return SchedulePageEraseOperation(NVMDB_id, page_num_start, num_pages); + } +#else + NVMDB_FLASH_ERASE_PAGE(page_num_start, num_pages); +#endif + + // Update free space. + return NVMDB_get_info(&DBInfo[NVMDB_id]); +} + +#if NVM_CACHE +__NOINLINE static NVMDB_status_t ContinueCleanLargeDB(CacheCleanLargeOperationType *op) +{ + NVMDB_status_t status; + NVMDB_HandleType previous_handle; + uint16_t num_read_bytes; + ReadStateType previous_state; + int32_t needed_time; + +#if !NVMDB_STATIC_BUFF + uint8_t NVM_buffer[PAGE_SIZE]; +#endif + + while(1) + { + + previous_state = op->read_state; + previous_handle = op->handle; + status = LoadDBToRAM(&op->handle, NVM_buffer, sizeof(NVM_buffer), &num_read_bytes, &op->read_state); + if(num_read_bytes == sizeof(NVM_buffer) || status != NVMDB_STATUS_OK) + { + if(num_read_bytes == 0) + { + // This can happen if the end of the database is reached at the beginning of the LoadDBToRAM() function. + break; + } + + needed_time = CalculateFlashTimeOperation(num_read_bytes, 0); + + ATOMIC_SECTION_BEGIN(); + + if(!NVMDB_TimeCheck(needed_time)) + { + // Not enough time. Restore state to the one before the load. + ATOMIC_SECTION_END(); + op->handle = previous_handle; + op->read_state = previous_state; + return NVMDB_STATUS_NOT_ENOUGH_TIME; + } + + // Write buffer to flash + WriteBufferToFlash(op->flash_address, (uint32_t *)NVM_buffer, num_read_bytes); + + ATOMIC_SECTION_END(); + + op->flash_address += sizeof(NVM_buffer); + if(status != NVMDB_STATUS_OK) + { + break; + } + } + } + + // Erase remaining pages. A possible optimization could be to erase the page only if it is not already erased. + uint8_t num_pages = (ROUNDPAGE_R(op->handle.end_address) - op->flash_address) / PAGE_SIZE; + uint8_t page_num_start = (op->flash_address - _MEMORY_FLASH_BEGIN_) / PAGE_SIZE; + + if(EraseWithTimeCheck(&page_num_start, &num_pages) == NVMDB_STATUS_NOT_ENOUGH_TIME) + { + return SchedulePageEraseOperation(op->handle.id, page_num_start, num_pages); + } + + // Update free space. + return NVMDB_get_info(&DBInfo[op->handle.id]); +} +#endif + +__NOINLINE static NVMDB_status_t CleanPage(const NVMDB_SmallDBContainerType *smallDBContainer_p) +{ + NVMDB_status_t status; + NVMDB_status_t ret = NVMDB_STATUS_OK; + uint8_t NVMDB_id; + NVMDB_HandleType handle; + uint32_t page_offset; + uint16_t num_bytes; + ReadStateType state; + int i; + uint8_t found = FALSE; +#if NVM_CACHE + int32_t needed_time; +#endif + +#if !NVMDB_STATIC_BUFF + uint8_t NVM_buffer[PAGE_SIZE]; +#endif + + /* Check if there are invalids record in the page and if there are pending operations on the databases. */ + for(i = 0; i < smallDBContainer_p->num_db; i++) + { + NVMDB_id = smallDBContainer_p->dbs[i].id; + if(DBInfo[NVMDB_id].invalid_records) + { + found = TRUE; + } +#if NVM_CACHE + if(CacheFindOperation(NVMDB_id, CACHE_ALL, cache_head, NULL, FALSE)) + { + return NVMDB_STATUS_CACHE_OP_PENDING; + } +#endif + } + if(!found) + { + /* No invalid records found. */ + return NVMDB_STATUS_OK; + } + + memset(NVM_buffer, 0xFF, sizeof(NVM_buffer)); + + for(i = 0; i < smallDBContainer_p->num_db; i++) + { + NVMDB_id = smallDBContainer_p->dbs[i].id; + page_offset = smallDBContainer_p->dbs[i].offset; + + status = NVMDB_HandleInit(NVMDB_id, &handle); + if(status) // This should not happen + { + return NVMDB_STATUS_OK; + } + + InitReadState(&state); + // It cannot happen that the database does not fill inside the buffer. So we call LoadDBToRAM() just once for each db. + LoadDBToRAM(&handle, NVM_buffer + page_offset, sizeof(NVM_buffer) - page_offset, &num_bytes, &state); + } + +#if NVM_CACHE + + needed_time = CalculateFlashTimeOperation(sizeof(NVM_buffer), 1); + + ATOMIC_SECTION_BEGIN(); + + if(!NVMDB_TimeCheck(needed_time)) + { + // Not enough time + ATOMIC_SECTION_END(); + return NVMDB_STATUS_NOT_ENOUGH_TIME; + } +#endif + + WriteBufferToFlash(smallDBContainer_p->page_address, (uint32_t *)NVM_buffer, sizeof(NVM_buffer)); + +#if NVM_CACHE + ATOMIC_SECTION_END(); +#endif + + for(i = 0; i < smallDBContainer_p->num_db; i++) + { + NVMDB_id = smallDBContainer_p->dbs[i].id; + // Update free space. + status = NVMDB_get_info(&DBInfo[NVMDB_id]); + if(status) + { + ret = status; // Return last error if any. + } + } + + return ret; +} + +static uint8_t GetDBType(NVMDB_IdType NVMDB_id, const NVMDB_SmallDBContainerType **smallDBContainer) +{ + uint8_t id; + + /* Check if it is a large DB. */ + + for(int i = 0; i < NUM_LARGE_DBS; i++) + { + + id = NVM_LARGE_DB_STATIC_INFO[i].id; + + if(id == NVMDB_id) + { + return LARGE_DB; + } + } + + for(int i = 0; i < NUM_SMALL_DB_PAGES; i++) + { + + for(int j = 0; j < NVM_SMALL_DB_STATIC_INFO[i].num_db; j++) + { + id = NVM_SMALL_DB_STATIC_INFO[i].dbs[j].id; + + if(id == NVMDB_id) + { + // DB found inside this small db container. + *smallDBContainer = &NVM_SMALL_DB_STATIC_INFO[i]; + return SMALL_DB; + } + } + } + + return 0; +} + +#if NVM_CACHE + +static uint16_t CacheGetDataSize(void) +{ + return cache_tail - cache_head; +} + +static uint8_t CacheRequestBuffer(uint16_t length) +{ + uint16_t data_size = CacheGetDataSize(); + + if(length > NVM_CACHE_SIZE - data_size) + { + return FALSE; + } + + if(NVM_CACHE_SIZE - cache_tail < length) + { + /* Shift buffer content */ + memmove(NVM_cache, NVM_cache + cache_head, data_size); + cache_head = 0; + cache_tail = data_size; + } + return TRUE; +} + +static uint8_t CacheInsertData(const void *data, uint16_t length) +{ + if(length > NVM_CACHE_SIZE - cache_tail) + { + return FALSE; + } + + memcpy(NVM_cache + cache_tail, data, length); + cache_tail += length; + + return TRUE; +} + +static NVMDB_status_t ScheduleWriteOperation(NVMDB_IdType NVMDB_id, uint8_t record_type, uint32_t flash_address, uint16_t data1_length, const void *data1, uint16_t data2_length, const void *data2) +{ + CacheWriteOperationType write_op; + + data1_length = ROUND4_R(data1_length); + + if(!CacheRequestBuffer(sizeof(CacheWriteOperationType) + data1_length + data2_length)) + { + // Not enough space in cache + return NVMDB_STATUS_CACHE_FULL; + } + + write_op.op = CACHE_WRITE_OP; + write_op.length = data1_length + data2_length + sizeof(write_op); + //write_op.address = flash_address; + write_op.id = NVMDB_id; + write_op.record_type = record_type; + + CacheInsertData(&write_op, sizeof(write_op)); + CacheInsertData(data1, data1_length); + CacheInsertData(data2, data2_length); + + return NVMDB_STATUS_OK; +} + +static NVMDB_status_t ScheduleDeleteOperation(NVMDB_IdType NVMDB_id, uint32_t flash_address) +{ + CacheDeleteOperationType del_op; + + if(!CacheRequestBuffer(sizeof(CacheDeleteOperationType))) + { + // Not enough space in cache + return NVMDB_STATUS_CACHE_FULL; + } + + del_op.length = sizeof(del_op); + del_op.op = CACHE_DELETE_OP; + del_op.id = NVMDB_id; + del_op.address = flash_address; + + CacheInsertData(&del_op, sizeof(del_op)); + + return NVMDB_STATUS_OK; +} + +static NVMDB_status_t ScheduleSmallDBEraseOperation(NVMDB_IdType NVMDB_id, const NVMDB_SmallDBContainerType *smallDBContainer_p) +{ + CacheSmallDBEraseOperationType erase_op; + + if(!CacheRequestBuffer(sizeof(CacheSmallDBEraseOperationType))) + { + // Not enough space in cache + return NVMDB_STATUS_CACHE_FULL; + } + + // We can remove all the cache operations for this DB. They are no more needed. Save space for other DB operations. + RemoveCacheOp(NVMDB_id); + + erase_op.length = sizeof(erase_op); + erase_op.op = CACHE_SMALL_DB_ERASE_OP; + erase_op.id = NVMDB_id; + erase_op.smallDBContainer_p = smallDBContainer_p; + + CacheInsertData(&erase_op, sizeof(erase_op)); + + // Lock operations on erased DB. + + DBInfo[NVMDB_id].locked = TRUE; + + return NVMDB_STATUS_OK; +} + +static NVMDB_status_t ScheduleCleanLargeDBOperation(NVMDB_HandleType handle, uint32_t flash_address, ReadStateType state) +{ + CacheCleanLargeOperationType clean_op; + + if(!CacheRequestBuffer(sizeof(clean_op))) + { + // Not enough space in cache + return NVMDB_STATUS_CACHE_FULL; + } + + clean_op.length = sizeof(clean_op); + clean_op.op = CACHE_CLEAN_LARGE_DB_OP; + clean_op.handle = handle; + clean_op.flash_address = flash_address; + clean_op.read_state = state; + + CacheInsertData(&clean_op, sizeof(clean_op)); + + DBInfo[handle.id].locked = TRUE; + + return NVMDB_STATUS_OK; +} + +static NVMDB_status_t SchedulePageEraseOperation(NVMDB_IdType NVMDB_id, uint8_t page_num_start, uint8_t num_pages) +{ + CachePageEraseOperationType erase_op; + + if(!CacheRequestBuffer(sizeof(erase_op))) + { + // Not enough space in cache + return NVMDB_STATUS_CACHE_FULL; + } + + erase_op.length = sizeof(erase_op); + erase_op.op = CACHE_PAGE_ERASE_OP; + erase_op.id = NVMDB_id; + erase_op.page_num_start = page_num_start; + erase_op.num_pages = num_pages; + + CacheInsertData(&erase_op, sizeof(erase_op)); + + DBInfo[NVMDB_id].locked = TRUE; + + return NVMDB_STATUS_OK; +} + +#endif + +__NOINLINE static NVMDB_status_t EraseSmallDB(NVMDB_IdType NVMDB_id, const NVMDB_SmallDBContainerType *smallDBContainer_p) +{ +#if NVM_CACHE + int32_t needed_time; +#endif +#if !NVMDB_STATIC_BUFF + uint8_t NVM_buffer[PAGE_SIZE]; +#endif + + memset(NVM_buffer, 0xFF, sizeof(NVM_buffer)); + + // Search other databases in the same page + for(int i = 0; i < smallDBContainer_p->num_db; i++) + { + NVMDB_HandleType handle; + uint16_t num_read_bytes; + ReadStateType state; + NVMDB_IdType id = smallDBContainer_p->dbs[i].id; + if(id != NVMDB_id) + { + // This is not the db to be erased. Save it. + NVMDB_HandleInit(id, &handle); + uint32_t offset = smallDBContainer_p->dbs[i].offset; + InitReadState(&state); + LoadDBToRAM(&handle, NVM_buffer + offset, sizeof(NVM_buffer) - offset, &num_read_bytes, &state); + } + } + + // All other databases are saved in RAM +#if NVM_CACHE + needed_time = CalculateFlashTimeOperation(sizeof(NVM_buffer), 1); + + ATOMIC_SECTION_BEGIN(); + + if(!NVMDB_TimeCheck(needed_time)) + { + // Not enough time. Restore state to the one before the load. + ATOMIC_SECTION_END(); + //return ScheduleSmallDBEraseOperation(NVMDB_id, smallDBContainer_p); + return NVMDB_STATUS_NOT_ENOUGH_TIME; + } +#endif + + // Write buffer to flash + WriteBufferToFlash(smallDBContainer_p->page_address, (uint32_t *)NVM_buffer, sizeof(NVM_buffer)); + +#if NVM_CACHE + ATOMIC_SECTION_END(); +#endif + + return NVMDB_STATUS_OK; +} + +static NVMDB_status_t NVMDB_AppendRecordNoCache(NVMDB_HandleType *handle_p, uint8_t record_id, uint16_t data1_length, const void *data1, uint16_t data2_length, const void *data2) +{ + NVMDB_RecordType *record_p; + NVMDB_RecordSizeType available_size; + NVMDB_status_t status; + + data1_length = ROUND4_R(data1_length); + + /* Check if there is space in the db. Not strictly needed. But this check is faster in case the db is full (instead of parsing every records). */ +// if(length > DBInfo[handle_p->id].free_space){ +// if(DBInfo[handle_p->id].invalid_records) +// return NVMDB_STATUS_CLEAN_NEEDED; +// return NVMDB_STATUS_FULL_DB; +// } + + /* Search for first available entry. */ + + while(1) + { + + if(handle_p->address + MIN_RECORD_SIZE >= handle_p->end_address) + { + /* End of DB reached. This should not happen since the free space has been checked before. + Should we remove this code or keep it to be safer? */ + if(DBInfo[handle_p->id].invalid_records) + { + return NVMDB_STATUS_CLEAN_NEEDED; + } + return NVMDB_STATUS_FULL_DB; + } + + record_p = (NVMDB_RecordType_ptr)handle_p->address; + + if(record_p->header.valid_flag == NO_RECORD) + { + available_size = MIN(handle_p->end_address - handle_p->address, MAX_RECORD_SIZE); + break; + } + else if(record_p->header.valid_flag != VALID_RECORD && record_p->header.valid_flag != INVALID_RECORD) + { + return NVMDB_STATUS_CORRUPTED_DB; + } + + handle_p->address += ROUND4_R(record_p->header.length + RECORD_HEADER_SIZE); + } + + if(available_size < data1_length + data2_length + RECORD_HEADER_SIZE) + { + /* End of DB reached. This should not happen since the free space has been checked before. + Should we remove this code or keep it to be safer? */ + if(DBInfo[handle_p->id].invalid_records) + { + return NVMDB_STATUS_CLEAN_NEEDED; + } + return NVMDB_STATUS_FULL_DB; + } + + status = WriteRecord(handle_p->address, record_id, data1_length, data1, data2_length, data2); + if(status) + { + return status; + } + + DBInfo[handle_p->id].valid_records++; + + return NVMDB_STATUS_OK; +} + +/** + * @} + */ + +/** @defgroup NVM_Manager_Public_Functions Public Functions + * @{ + */ + +/** + * @brief Initialize the NVM Manager. + * + * Function to be called before using the library. + * + * @param None + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_Init(void) +{ + // Checks DB consistency. Reads number of records. + + NVMDB_status_t status; + uint32_t page_address, offset; + uint16_t clean_threshold; + uint8_t id; + + /* Parse small DBs. */ + for(int i = 0; i < NUM_SMALL_DB_PAGES; i++) + { + + page_address = NVM_SMALL_DB_STATIC_INFO[i].page_address; + + for(int j = 0; j < NVM_SMALL_DB_STATIC_INFO[i].num_db; j++) + { + id = NVM_SMALL_DB_STATIC_INFO[i].dbs[j].id; + offset = NVM_SMALL_DB_STATIC_INFO[i].dbs[j].offset; +#if AUTO_CLEAN + clean_threshold = NVM_SMALL_DB_STATIC_INFO[i].dbs[j].clean_threshold; +#endif + if(DBInfo[id].start_address || id >= NUM_DB) + { + // ID already used. + return NVMDB_STATUS_INVALID_ID; + } + DBInfo[id].start_address = page_address + offset; + + if(j == NVM_SMALL_DB_STATIC_INFO[i].num_db - 1) + { + // If it is the last db of the page, end address is the last address of the page + DBInfo[id].end_address = page_address + PAGE_SIZE; + } + else + { + // If it is not the last db of the page, end address is the start address of the next db + DBInfo[id].end_address = page_address + NVM_SMALL_DB_STATIC_INFO[i].dbs[j + 1].offset; + } + DBInfo[id].clean_threshold = clean_threshold; + + status = NVMDB_get_info(&DBInfo[id]); + if(status) + { + return status; + } + } + } + + /* Parse large DBs. */ + for(int i = 0; i < NUM_LARGE_DBS; i++) + { + + id = NVM_LARGE_DB_STATIC_INFO[i].id; + + if(DBInfo[id].start_address || id >= NUM_DB) + { + // ID already used. + return NVMDB_STATUS_INVALID_ID; + } + + DBInfo[id].start_address = NVM_LARGE_DB_STATIC_INFO[i].address; + DBInfo[id].end_address = NVM_LARGE_DB_STATIC_INFO[i].address + NVM_LARGE_DB_STATIC_INFO[i].size; +#if AUTO_CLEAN + DBInfo[id].clean_threshold = NVM_LARGE_DB_STATIC_INFO[i].clean_threshold; +#endif + + status = NVMDB_get_info(&DBInfo[id]); + if(status) + { + return status; + } + } + + return NVMDB_STATUS_OK; +} + +/** + * @brief Initialize the handle that points to the given database. + * + * NVMDB_HandleInit has to be called before using functions that + * need an handle. + * + * @param NVMDB_id ID of the database. This is a number that uniquely identifies + * the database. The IDs are decided when declaring the database structure + * through NVM_SMALL_DB_STATIC_INFO and NVM_LARGE_DB_STATIC_INFO variables. + * @param[out] handle_p Pointer to the handle to be initialized. + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_HandleInit(NVMDB_IdType NVMDB_id, NVMDB_HandleType *handle_p) +{ + if(NVMDB_id >= NUM_DB) + { + return NVMDB_STATUS_INVALID_ID; + } + + handle_p->address = DBInfo[NVMDB_id].start_address; + handle_p->end_address = DBInfo[NVMDB_id].end_address; + handle_p->first_read = TRUE; + handle_p->id = NVMDB_id; + handle_p->cache = FALSE; + + return NVMDB_STATUS_OK; +} + +/** + * @brief Read data from the next record in the database. + * + * Retrieve data from the next valid record in the database. + * Each time NVMDB_ReadNextRecord is called, the handle is firstly + * moved forward in order to point to the next valid record in the database. + * Record data is copied into the provided buffer. + * + * @param[in,out] handle_p Handle pointing to the database. It must have been previously + * initialized with NVMDB_HandleInit. After calling the function, the + * handle can be used again to read the next record. + * @param record_type Type of the record. This value is application-specific. Use + * ALL_TYPES to read every records, regardless of the type. + * @param data_offset Offset inside the record from which data has to be copied. + * Normally it is set to 0. + * @param[out] data_p Array in which data will be copied. + * @param max_size Size of the buffer pointed by data_p. + * @param[out] size_p Size of the read record. + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_ReadNextRecord(NVMDB_HandleType *handle_p, uint8_t record_type, NVMDB_RecordSizeType data_offset, uint8_t *data_p, NVMDB_RecordSizeType max_size, NVMDB_RecordSizeType *size_p) +{ + if(DBInfo[handle_p->id].locked) + { + return NVMDB_STATUS_LOCKED; + } + + return ReadNextRecordNoLock(handle_p, record_type, data_offset, data_p, max_size, size_p, 0, NULL); +} + +/** + * @brief Read data from the current record in the database. + * + * Retrieve data from the current valid record in the database. + * Handle is not moved before retrieving the data. + * + * @param[in,out] handle_p Handle pointing to the database. It must have been previously + * initialized with NVMDB_HandleInit. + * @param data_offset Offset inside the record from which data has to be copied. + * Normally it is set to 0. + * @param[out] data_p Array in which data will be copied. + * @param max_size Size of the buffer pointed by data_p. + * @param[out] size_p Size of the read record. + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_ReadCurrentRecord(NVMDB_HandleType *handle_p, NVMDB_RecordSizeType data_offset, uint8_t *data_p, NVMDB_RecordSizeType max_size, NVMDB_RecordSizeType *size_p) +{ + if(DBInfo[handle_p->id].locked) + { + return NVMDB_STATUS_LOCKED; + } + + return ReadCurrentRecordNoLock(handle_p, data_offset, data_p, max_size, size_p, 0); +} + +/** + * @brief Find next record in the database that matches the given pattern. + * + * NVMDB_FindNextRecord searches inside the database starting from the + * record pointed by the given handle. If the pattern is found starting + * from pattern_offset, the function returns NVMDB_STATUS_OK and the + * handle points to the found record. The value of the record can be + * retrieved by providing a buffer where data will be copied. + * + * @note The handle is moved while searching inside the database. + * + * @param[in,out] handle_p Handle pointing to the database. It must have been previously + * initialized with NVMDB_HandleInit. After calling the function, the + * handle can be used again to search the pattern, starting from the next record. + * @param record_type Type of the record to search for. This value is application-specific. Use + * ALL_TYPES to read every records, regardless of the type. + * @param pattern_offset Offset at which the pattern has to be located inside the record. + * @param[in] pattern_p The pattern that has to be found inside the database. + * @param pattern_length Length of the pattern. + * @param data_offset Offset inside the record from which data has to be copied. + * Normally it is set to 0. + * @param data_offset Length of the pattern. + * @param[out] data_p Array in which data will be copied. If NULL, no data is copied. + * @param max_size Size of the buffer pointed by data_p. + * @param[out] size_p Size of the read record. + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_FindNextRecord(NVMDB_HandleType *handle_p, uint8_t record_type, NVMDB_RecordSizeType pattern_offset, const uint8_t *pattern_p, NVMDB_RecordSizeType pattern_length, NVMDB_RecordSizeType data_offset, uint8_t *data_p, NVMDB_RecordSizeType max_size, NVMDB_RecordSizeType *size_p) +{ + NVMDB_status_t status; + uint8_t *data; + NVMDB_RecordSizeType record_len; + + if(DBInfo[handle_p->id].locked) + { + return NVMDB_STATUS_CACHE_OP_PENDING; + } + + while(1) + { + + status = NextRecordNoLock(handle_p, record_type, &data, &record_len, 0, NULL); + + if(status != NVMDB_STATUS_OK) + { + return status; + } + + if(pattern_offset >= record_len || pattern_length > record_len - pattern_offset) + { + continue; + } + + if(memcmp(data + pattern_offset, pattern_p, pattern_length) == 0) + { + // Record has been found + if(data_p != NULL) + { + *size_p = record_len; + if(data_offset >= record_len) + { + return NVMDB_STATUS_INVALID_OFFSET; + } + memcpy(data_p, data + data_offset, MIN(record_len - data_offset, max_size)); + } + + return NVMDB_STATUS_OK; + } + } +} + +/** + * @brief Add a record in the database. + * + * The record is added at the end of the database pointed by the given handle. + * @note If the handle points to the last record in the database, the append + * operation is faster. + * @note A write or erase operation on the Flash prevents access to the + * Flash for a certain amount of time, potentially delaying execution + * of the time-critical radio interrupt service routine. Thus, it is checked + * that enough time is present before the next scheduled radio activity + * will start. If there is no enough time, this operation is scheduled. A + * cache is used to temporarily store the record. + * + * @param[in,out] handle_p Handle pointing to the database. It must have been previously + * initialized with NVMDB_HandleInit. If the function returns NVMDB_STATUS_OK, + * the handle points to the added record. + * @note If the returned value is not NVMDB_STATUS_OK, the handle my points to + * any record in the database. + * @param record_type One byte that can be used by the application to identify the type + * of record. + * @param header_length Length of bytes in header. It must be a multiple of 4. Set it to 0 + * if header is NULL. + * @param[in] header Data to be stored at the beginning of the record. It can be used by the + * application to add an header to the record. The number of bytes must be a + * multiple of 4. Set it to NULL if no header has to be added to the record. + * @param header_length Length of bytes in data. + * @param[in] data Data to be stored inside the record. + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_AppendRecord(NVMDB_HandleType *handle_p, uint8_t record_type, uint16_t header_length, const void *header, uint16_t data_length, const void *data) +{ + NVMDB_status_t status; + +#if NVM_CACHE + + if(DBInfo[handle_p->id].locked) + { + return NVMDB_STATUS_CACHE_OP_PENDING; + } + + header_length = ROUND4_R(header_length); + + /* Check if there is space in the db. + free_space is the real free space in Flash, taking also into account all the record to be added that are currently in cache. */ + if(header_length + data_length > DBInfo[handle_p->id].free_space) + { + if(DBInfo[handle_p->id].invalid_records) + { + return NVMDB_STATUS_CLEAN_NEEDED; + } + return NVMDB_STATUS_FULL_DB; + } + + /* Check if there are other operations in cache for that db. In fact, if + there is already a record in cache, that record must be written before this one. + If there is also an erase pending, this record cannot be written and must be stored + temporarily in cache. Instead, if there are delete record operations in cache it + should be possible to try to write immediately the record (this case is not checked now). + A future improvement could be to try to perform some operations in cache (in case we have time now). */ + if(CacheFindOperation(handle_p->id, CACHE_ALL, cache_head, NULL, FALSE)) + { + status = ScheduleWriteOperation(handle_p->id, record_type, handle_p->address, header_length, header, data_length, data); + if(status == NVMDB_STATUS_OK) + { + goto success; + } + else + { + return status; + } + } + + status = NVMDB_AppendRecordNoCache(handle_p, record_type, header_length, header, data_length, data); + + if(status == NVMDB_STATUS_OK) + { + goto success; + } + + if(status != NVMDB_STATUS_NOT_ENOUGH_TIME) + { + return status; + } + + /* No time to complete the operation immediately. */ + status = ScheduleWriteOperation(handle_p->id, record_type, handle_p->address, header_length, header, data_length, data); + + if(status != NVMDB_STATUS_OK) + { + return status; + } + +success: + +#else /* NVM_CACHE */ + status = NVMDB_AppendRecordNoCache(handle_p, record_type, header_length, header, data_length, data); + + if(status != NVMDB_STATUS_OK) + { + return status; + } + +#endif + + /* Take into account that the free space is reduced, even if the record is actually in cache. */ + DBInfo[handle_p->id].free_space -= ROUND4_R(header_length + data_length) + RECORD_HEADER_SIZE; + + return NVMDB_STATUS_OK; +} + +/** + * @brief Delete a record. + * + * NVMDB_DeleteRecord deletes the record pointed by the given handle. + * Since the database is in Flash, the record is actually invalidated + * and cannot be read by other functions. + * A clean operation of the database definitively removes the record. + * + * @note A write operation on the Flash prevents access to the + * Flash for a certain amount of time, potentially delaying execution + * of the time-critical radio interrupt service routine. Thus, it is checked + * that enough time is present before the next scheduled radio activity + * will start. If there is no enough time, this operation is scheduled. A + * cache is used to temporarily store the operation. + * + * @param[in,out] handle_p Handle pointing to the record to be deleted. + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_DeleteRecord(const NVMDB_HandleType *handle_p) +{ +#if NVM_CACHE + + NVMDB_status_t status; + + if(DBInfo[handle_p->id].locked) + { + return NVMDB_STATUS_CACHE_OP_PENDING; + } + + /* Try to delete the record, even if there are other operations in cache. + In fact there is no reason to keep the order of this delete operation with + respect to other delete or write operations. Instead it is important not to have + clean operation pending, since the address of the record to be deleted would + change. + */ + if(handle_p->cache) // Handle points to records in cache + { + CacheWriteOperationType write_op; + memcpy(&write_op, &NVM_cache[handle_p->cache_index], sizeof(write_op)); + write_op.op = CACHE_NOP; + memcpy(&NVM_cache[handle_p->cache_index], &write_op, sizeof(write_op)); + return NVMDB_STATUS_OK; + } + + status = NVMDB_DeleteRecordNoCache(handle_p); + + if(status == NVMDB_STATUS_OK) + { + return NVMDB_STATUS_OK; + } + + if(status != NVMDB_STATUS_NOT_ENOUGH_TIME) + { + return status; + } + + /* No time to complete the operation immediately. */ + return ScheduleDeleteOperation(handle_p->id, handle_p->address); + +#else /* NVM_CACHE */ + + return NVMDB_DeleteRecordNoCache(handle_p); + +#endif +} + +/** + * @brief Erase a database. + * + * NVMDB_Erase removes all the records from the database, bringing it + * back to the original state when no records have been written. + * + * @note An erase operation on the Flash prevents access to the + * Flash for a certain amount of time, potentially delaying execution + * of the time-critical radio interrupt service routine. Thus, it is checked + * that enough time is present before the next scheduled radio activity + * will start. If there is no enough time, this operation is scheduled. A + * cache is used to temporarily store the operation. + * + * @param NVMDB_id The ID of the record to be erased. + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_Erase(NVMDB_IdType NVMDB_id) +{ + /* This function schedules a flash erase. Another possible implementation can + * invalidate all the records of the database and let a clean operation erase the page. + */ + const NVMDB_SmallDBContainerType *smallDBContainer_p; + uint8_t type; + NVMDB_status_t status; + +#if NVM_CACHE + if(DBInfo[NVMDB_id].locked) + { + return NVMDB_STATUS_CACHE_OP_PENDING; + } +#endif + + type = GetDBType(NVMDB_id, &smallDBContainer_p); + + if(type == LARGE_DB) + { + uint8_t page_num_start, num_pages; + uint32_t start_address = DBInfo[NVMDB_id].start_address; + uint32_t end_address = DBInfo[NVMDB_id].end_address; + + page_num_start = (start_address - _MEMORY_FLASH_BEGIN_) / PAGE_SIZE; + num_pages = (ROUNDPAGE_R(end_address) - start_address) / PAGE_SIZE; + +#if NVM_CACHE + + RemoveCacheOp(NVMDB_id); + + if(EraseWithTimeCheck(&page_num_start, &num_pages) == NVMDB_STATUS_NOT_ENOUGH_TIME) + { + return SchedulePageEraseOperation(NVMDB_id, page_num_start, num_pages); + } + +#else + + NVMDB_FLASH_ERASE_PAGE(page_num_start, num_pages); + +#endif + + NVMDB_get_info(&DBInfo[NVMDB_id]); + + return NVMDB_STATUS_OK; + } + + if(type == SMALL_DB) + { + + status = EraseSmallDB(NVMDB_id, smallDBContainer_p); + + if(status == NVMDB_STATUS_OK) + { + // Remove any operations in cache for all the DBs in the page. This means write and delete operations. + // Cache operations for all the DBs in the same page have been executed by LoadDBToRAM(). + for(int i = 0; i < smallDBContainer_p->num_db; i++) + { + NVMDB_IdType id = smallDBContainer_p->dbs[i].id; +#if NVM_CACHE + RemoveCacheOp(id); +#endif + NVMDB_get_info(&DBInfo[id]); + } + } + else if(status == NVMDB_STATUS_NOT_ENOUGH_TIME) + { +#if NVM_CACHE + return ScheduleSmallDBEraseOperation(NVMDB_id, smallDBContainer_p); +#endif + } + + return status; + } + + return NVMDB_STATUS_INVALID_ID; +} + +/** + * @brief Clean the database. + * + * It reads the entire database and writes back only valid records. + * + * @note Erase and write operations on the Flash prevents access to the + * Flash for a certain amount of time, potentially delaying execution + * of the time-critical radio interrupt service routine. Thus, it is checked + * that enough time is present before the next scheduled radio activity + * will start. If there is no enough time to clean a small DB, + * NVMDB_STATUS_NOT_ENOUGH_TIME is returned. In this case the operation + * should be retried again later. In case a clean operation is requested + * for a large DB, NVMDB_STATUS_NOT_ENOUGH_TIME is returned only if there is + * no time to write the first Flash page. If there is time to write this + * page, the other write an erase operations are scheduled. Scheduled + * operations are temporarily stored in cache. While a clean operation + * is scheduled in cache, no other operations are allowed. + * + * @param NVMDB_id The ID of the record to be cleaned. + * @retval Indicates if the function executed successfully. + */ +NVMDB_status_t NVMDB_CleanDB(NVMDB_IdType NVMDB_id) +{ + const NVMDB_SmallDBContainerType *smallDBContainer; + uint8_t type; + + type = GetDBType(NVMDB_id, &smallDBContainer); + if(type == LARGE_DB) + { + return CleanLargeDB(NVMDB_id); + } + if(type == SMALL_DB) + { + return CleanPage(smallDBContainer); + } + + return NVMDB_STATUS_INVALID_ID; +} + +/** + * @brief Function performing maintenance operations. + * + * This function must be called periodically. Its main task is to + * perform scheduled operations. + * + * @retval Returned values is NVMDB_STATUS_OK if no other operations are scheduled. + * The value NVMDB_STATUS_NOT_ENOUGH_TIME indicates that some operations + * cannot be performed because there is not enough time. Other values + * indicates unexpected conditions of the database. + */ +NVMDB_status_t NVMDB_Tick(void) +{ +#if AUTO_CLEAN + int8_t dirty_db_id; +#endif + +#if NVM_CACHE + + NVMDB_status_t status; + + /* Check if there are operations in cache. */ +#if PROCESS_CACHE_AT_ONCE + while(!CACHE_EMPTY()) + { +#else + if(!CACHE_EMPTY()) + { +#endif + CacheOperationType cache_op; + memcpy(&cache_op, &NVM_cache[cache_head], sizeof(cache_op)); + + switch(cache_op.op) + { + + case CACHE_WRITE_OP: + { + NVMDB_HandleType handle; + CacheWriteOperationType write_op; + memcpy(&write_op, &NVM_cache[cache_head], sizeof(write_op)); + NVMDB_HandleInit(write_op.id, &handle); + status = NVMDB_AppendRecordNoCache(&handle, write_op.record_type, write_op.length - sizeof(write_op), NVM_cache + cache_head + sizeof(write_op), 0, NULL); + PRINTF("Write operation from cache. Handle possibly not valid anymore!\r\n"); + if(status != NVMDB_STATUS_OK) + { + return status; + } + } + break; + case CACHE_DELETE_OP: + { + CacheDeleteOperationType del_op; + memcpy(&del_op, &NVM_cache[cache_head], sizeof(del_op)); + + status = InvalidateRecord(del_op.address); + if(status == NVMDB_STATUS_OK) + { + DBInfo[del_op.id].valid_records--; + DBInfo[del_op.id].invalid_records++; + } + else + { + return status; + } + } + break; + case CACHE_CLEAN_LARGE_DB_OP: /* A clean operation has started on a large multipage db. */ + { + CacheCleanLargeOperationType clean_large_op; + memcpy(&clean_large_op, &NVM_cache[cache_head], sizeof(clean_large_op)); + status = ContinueCleanLargeDB(&clean_large_op); + if(status != NVMDB_STATUS_OK) + { + return status; + } + } + break; + case CACHE_PAGE_ERASE_OP: + { + CachePageEraseOperationType erase_op; + memcpy(&erase_op, &NVM_cache[cache_head], sizeof(erase_op)); + status = EraseWithTimeCheck(&erase_op.page_num_start, &erase_op.num_pages); + memcpy(&NVM_cache[cache_head], &erase_op, sizeof(erase_op)); + if(status == NVMDB_STATUS_OK) + { + NVMDB_get_info(&DBInfo[erase_op.id]); + } + else + { + return status; + } + } + break; + case CACHE_SMALL_DB_ERASE_OP: + { + CacheSmallDBEraseOperationType erase_op; + memcpy(&erase_op, &NVM_cache[cache_head], sizeof(erase_op)); + status = EraseSmallDB(erase_op.id, erase_op.smallDBContainer_p); // This also removes lock + if(status == NVMDB_STATUS_OK) + { + // Remove any operations in cache for all the DBs in the page. This means write and delete operations. + // Cache operations for all the DBs in the same page have been executed by LoadDBToRAM(). + for(int i = 0; i < erase_op.smallDBContainer_p->num_db; i++) + { + NVMDB_IdType id = erase_op.smallDBContainer_p->dbs[i].id; + // Except the DB that has been erased, otherwise it will remove also current cache operation. + // cache operations for the erased DB has been removed by the ScheduleSmallDBEraseOperation. + if(id != erase_op.id) + { + RemoveCacheOp(id); + } + NVMDB_get_info(&DBInfo[id]); // This also removes lock + } + } + if(status != NVMDB_STATUS_OK) + { + return status; + } + } + break; +// case CACHE_NOP: +// { +// CacheNoOperationType nop; +// memcpy(&nop, &NVM_cache[cache_head], sizeof(nop)); +// } +// break; + default: + // Something wrong + return NVMDB_STATUS_CACHE_ERROR; + } + CacheAdvanceHead(cache_op.length); + } + +#if !PROCESS_CACHE_AT_ONCE + if(!CACHE_EMPTY()) + { + return NVMDB_STATUS_CACHE_OP_PENDING; + } +#endif + +#endif /* NVM_CACHE */ + +#if AUTO_CLEAN + dirty_db_id = NVMDB_CleanCheck(); + if(dirty_db_id >= 0) + { + NVMDB_CleanDB((NVMDB_IdType)dirty_db_id); + PRINTF("Handle possibly not valid anymore!\r\n"); + } +#endif + + return NVMDB_STATUS_OK; +} + +#if AUTO_CLEAN +// Checks if it is a good time to perform a clean operation +static int8_t NVMDB_CleanCheck(void) +{ + static int8_t db_start_index = 0; + uint8_t i = db_start_index; + + do + { + if(DBInfo[i].invalid_records) + { + if(DBInfo[i].free_space < DBInfo[i].clean_threshold) + { + // Next time do not start from this db. + // There may be time to clean another one if this one has not been successfully cleaned. + db_start_index = i + 1; + if(db_start_index == NUM_DB) + { + db_start_index = 0; + } + return i; + } + } + + i++; + if(i == NUM_DB) + { + i = 0; + } + } + while(i != db_start_index); + + // All databases have been checked. We can start from first position next time (but not strictly needed). + db_start_index = 0; + + return -1; // No db to clean +} + +#endif + +/** + * @} + */ + +/** + * @} + */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Src/nvm_db_conf.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Src/nvm_db_conf.c new file mode 100644 index 000000000..6ab8c7e80 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/NVMDB/Src/nvm_db_conf.c @@ -0,0 +1,129 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file nvm_db_conf.c + * @author GPM WBL Application Team + * @brief This file provides the structure of the database. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "nvm_db_conf.h" +#include + +/** @defgroup NVM_Manager NVM Manager + * @{ + */ + +/** @defgroup NVM_Manager_TypesDefinitions Private Type Definitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup NVM_Manager_Private_Defines Private Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup NVM_Manager_Conf_Private_Macros NVM Manager Configuration Private Macros + * @{ + */ + +#if PRESET1 + +#define FLASH_NVM_DATASIZE (2 * PAGE_SIZE) // Make sure this space is reserved in the linker script. +#define NVM_START_ADDRESS (_MEMORY_FLASH_END_ - FLASH_NVM_DATASIZE + 1) + +#define DB0_SIZE (PAGE_SIZE) +#define DB1_SIZE (PAGE_SIZE - 8) // Last 8 bytes in Flash are reserved for the lock/unlock word. + +#elif PRESET2 + +#define FLASH_NVM_DATASIZE (1 * PAGE_SIZE) // Make sure this space is reserved in the linker script. +#define NVM_START_ADDRESS (_MEMORY_FLASH_END_ - FLASH_NVM_DATASIZE + 1) + +#define DB0_SIZE (PAGE_SIZE - 8 - 64) // Last 8 bytes in Flash are reserved for the lock/unlock word. +#define DB1_SIZE (64) + +#endif + +/** + * @} + */ + +/** @defgroup NVM_Manager_Conf_Constants NVM Manager Configuration Constants + * @{ + */ + +#if PRESET1 + +const NVMDB_SmallDBContainerType *NVM_SMALL_DB_STATIC_INFO = NULL; +const NVMDB_StaticInfoType NVM_LARGE_DB_STATIC_INFO[NUM_LARGE_DBS] = +{ + { + .address = NVM_START_ADDRESS, + .size = DB0_SIZE, + .id = 0, +#if AUTO_CLEAN + .clean_threshold = DB0_SIZE / 3 +#endif + }, + { + .address = NVM_START_ADDRESS + DB0_SIZE, + .size = DB1_SIZE, + .id = 1, +#if AUTO_CLEAN + .clean_threshold = 0 +#endif + }, +}; + +#elif PRESET2 + +const NVMDB_SmallDBType dbs[NUM_SMALL_DBS] = +{ + { + .id = 0, + .offset = 0, +#if AUTO_CLEAN + .clean_threshold = DB0_SIZE / 3 +#endif + }, + { + .id = 1, + .offset = DB0_SIZE, +#if AUTO_CLEAN + .clean_threshold = 0 +#endif + } +}; + +const NVMDB_SmallDBContainerType NVM_SMALL_DB_STATIC_INFO[NUM_SMALL_DB_PAGES] = { { .page_address = NVM_START_ADDRESS, .num_db = NUM_SMALL_DBS, .dbs = dbs } }; +const NVMDB_StaticInfoType *NVM_LARGE_DB_STATIC_INFO = NULL; + +#endif /* PRESET2 */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Inc/pka_manager.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Inc/pka_manager.h new file mode 100644 index 000000000..e598a6cef --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Inc/pka_manager.h @@ -0,0 +1,172 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file pka_manager.h + * @author GPM WBL Application Team + * @brief This file contains all the functions prototypes for the PKA Manager. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef PKAMGR_H +#define PKAMGR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stdint.h" + +/** @addtogroup PKA_Manager_Peripheral PKA Manager + * @{ + */ + +/** @defgroup PKA_Manager_Exported_Types Exported Types + * @{ + */ +/* Enumerated values used to report the PKA result status after a process */ +typedef enum +{ + PKAMGR_SUCCESS = 0, + PKAMGR_ERROR = -1, + PKAMGR_ERR_BUSY = -2, + PKAMGR_ERR_PARAM = -3, + PKAMGR_ERR_PROCESS = -4 +} PKAMGR_ResultStatus; +/** + * @} + */ + +/** @defgroup PKA_Manager_Public_Variables Public Variables +* @{ +*/ +static const uint32_t PKAStartPoint[16] = { 0xd898c296U, 0xf4a13945U, 0x2deb33a0U, 0x77037d81U, + 0x63a440f2U, 0xf8bce6e5U, 0xe12c4247U, 0x6b17d1f2U, + 0x37bf51f5U, 0xcbb64068U, 0x6b315eceU, 0x2bce3357U, + 0x7c0f9e16U, 0x8ee7eb4aU, 0xfe1a7f9bU, 0x4fe342e2U}; + +/** +* @} +*/ + +/** @defgroup PKA_Manager_Exported_Functions Exported Functions + * @{ + */ + +/** + * @brief PKA Callback pointer definition + * + * @param errorCode - indicates the status of the PKA operation just completed. + * + * @param args - reference to a copy of the output/result of the PKA operation. + * It may be either: + * a) an array of 3x32 octets long, containing the Local Public Key, in case of P256 Public Key generation, + * formatted as follows: + * | Secret Key | Public Key X-coord | Public Key Y-coord | + * | (32 octets) | (32 octets) | (32 octets) | + * b) an array of 32 octets long, containing the DHKey-check result, in case of DHKey check operation, + * formatted as follows: + * | DHKey check | + * | (32 octets) | + * | N.A. | DHKey check | N.A. | + * | (32 octets) | (32 octets) | (32 octets) | + * The PKA processing output/result is reported as a linear array of octets, + * without any indication of the data length. + * The caller of the PKA operations shall read/decode the result, including the data length, + * based on the last operation requested. + * + * + * @note 1 - ERROR_PARAMETERS should not be reported to the callback, + * assuming that the input parameters (passed for DHKey computation) + * are checked when calling HW_PKA_StartP256DHkeyGeneration. + * + * @note 2 This model is based on a unique and generic callback function, that reports the PKA output/result + * without enforcing a specific function argument typing (preferred option). + * Otherwise, 2 specific function callbacks may be defined, each one with specific function arguments + * depending on the specific operation requested. + */ +typedef void (*PKAMGR_funcCB)(PKAMGR_ResultStatus errorCode, void *args); /*!< Pointer to a PKA callback function */ + +PKAMGR_ResultStatus PKAMGR_Init(void); + +PKAMGR_ResultStatus PKAMGR_Deinit(void); + +PKAMGR_ResultStatus PKAMGR_SleepCheck(void); + +uint8_t PKAMGR_PowerSaveLevelCheck(uint8_t x); + +PKAMGR_ResultStatus PKAMGR_Lock(void); + +PKAMGR_ResultStatus PKAMGR_Unlock(void); + +void PKAMGR_IRQCallback(void); + +/** + * @name PKAMGR_StartP256PublicKeyGeneration. + * + * @brief Function used to request the generation of a new ECC Public Key. + * + * @param[in] privateKey The private key used to generate the public key. + * + * @param funcCB - callback function that BLEPS Library makes available to BLEPLAT HAL, + * that is called when the PKA operation requested has been completed (either successfully or not). + * + * @return Status of the PKA peripheral w.r.t. the requested operation + * - SUCCESS in case the PKA peripheral is available and ready to execute the operation. + * - ERROR_BUSY in case the PKA peripheral is BUSY with another operation that could + * have been requested by the BLEPS Library or by the End-User Application. + * + * @note Called by BLEPS Library function: hci_le_read_local_p256_publicKey<\c>. + * + */ +PKAMGR_ResultStatus PKAMGR_StartP256PublicKeyGeneration(const uint32_t *privateKey, PKAMGR_funcCB funcCB); + +/** + * @name pka_manager_Start_ECDH_P256_DHKey_Generation + * + * @brief Function which configures the PKA to perform the computation of DHKey check value. + * + * @param secretKey - the Secret Key of the Local device (LE format). + * @param publicKey - the Public Key of the peer remote device for which the DHKey will be computed (LE format). + * @param funcCB - callback function that BLEPS Library makes available to BLEPLAT HAL, + * that is called when the PKA operation requested has been completed (either successfully or not). + * + * @return Status of the preliminary checks performed on input parameters and PKA peripheral status + * made beofre to configure the PKA for DHKey computation. + * - SUCCESS in case the PKA peripheral is available and ready to execute the operation + * and the input parameters are correct! + * - ERROR_BUSY in case the PKA peripheral is BUSY with another operation that could + * have been requested by the BLEPS Library or by the End-User Application. + * - ERROR_PARAMETERS in case the input parameters are invalid; either the Secret key or the + * remote P256 public key may be wrong (when the peer remote public key is not a valid ECC point) + * + */ +PKAMGR_ResultStatus HW_PKA_StartP256DHkeyGeneration(const uint32_t *secretKey, + const uint32_t *publicKey, + PKAMGR_funcCB funcCB); + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* PKAMGR_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c new file mode 100644 index 000000000..6973244c3 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c @@ -0,0 +1,168 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file pka_manager.c + * @author GPM WBL Application Team + * @brief This file provides utility functions for concurrent access to PKA + * peripheral. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "pka_manager.h" +#include "stm32wb0x.h" + +/** @defgroup PKA_Manager PKA Manager +* @{ +*/ + +/** @defgroup PKA_Manager_Private_Variables Private Variables +* @{ +*/ + +/** +* @} +*/ + +/** @defgroup PKA_Manager_TypesDefinitions Private Type Definitions +* @{ +*/ + +/* Internal state of the PKA */ +typedef enum +{ + PKAMGR_STATE_READY = 0, + PKAMGR_STATE_IDLE, + PKAMGR_STATE_RESET, + PKAMGR_STATE_BUSY +} PKAMGR_State; + +/** +* @} +*/ + +/** @defgroup PKA_Manager_Private_Defines Private Defines +* @{ +*/ +#define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \ +__disable_irq(); \ + /* Must be called in the same or in a lower scope of ATOMIC_SECTION_BEGIN */ +#define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit) +/** +* @} +*/ + +/** @defgroup PKA_Manager_Private_Variables Private Variables +* @{ +*/ +static volatile uint32_t internalState = PKAMGR_STATE_RESET; +/** +* @} +*/ + +/** @defgroup PKA_Manager_Private_FunctionPrototypes Private Function Prototypes +* @{ +*/ +PKAMGR_ResultStatus HW_PKA_PrivateInit(void); + +PKAMGR_ResultStatus HW_PKA_PrivateDeinit(void); + +PKAMGR_ResultStatus PKAMGR_Status(void); +/** +* @} +*/ + +/** @defgroup PKA_Manager_Public_Functions Public Functions +* @{ +*/ +PKAMGR_ResultStatus PKAMGR_Init(void) +{ + internalState = PKAMGR_STATE_IDLE; + + return PKAMGR_SUCCESS; +} + +PKAMGR_ResultStatus PKAMGR_Deinit(void) +{ + internalState = PKAMGR_STATE_RESET; + + return PKAMGR_SUCCESS; +} + +PKAMGR_ResultStatus PKAMGR_SleepCheck(void) +{ + PKAMGR_ResultStatus return_value = PKAMGR_ERR_BUSY; + + if(internalState == PKAMGR_STATE_IDLE) + return_value = PKAMGR_SUCCESS; + + return return_value; +} + +PKAMGR_ResultStatus PKAMGR_Lock() +{ + PKAMGR_ResultStatus return_value = PKAMGR_SUCCESS; + + /* Only one consumer (Application layer or Stack) can use the PKA at the time */ + ATOMIC_SECTION_BEGIN(); + if(internalState != PKAMGR_STATE_IDLE) + { + return_value = PKAMGR_ERR_BUSY; + } + else + { + /* Lock mechanism to access concurrently at the PKA resource */ + internalState = PKAMGR_STATE_BUSY; + } + ATOMIC_SECTION_END(); + + return return_value; +} + +PKAMGR_ResultStatus PKAMGR_Unlock() +{ + PKAMGR_ResultStatus return_value = PKAMGR_SUCCESS; + + /* Only one consumer (Application layer or Stack) can use the PKA at the time */ + ATOMIC_SECTION_BEGIN(); + if(internalState != PKAMGR_STATE_BUSY) + { + return_value = PKAMGR_ERR_BUSY; + } + else + { + /* Unlock mechanism to access concurrently at the PKA resource */ + internalState = PKAMGR_STATE_IDLE; + } + ATOMIC_SECTION_END(); + + return return_value; +} + +PKAMGR_ResultStatus PKAMGR_StartP256PublicKeyGeneration(const uint32_t *privateKey, PKAMGR_funcCB funcCB) +{ + return HW_PKA_StartP256DHkeyGeneration(privateKey, (uint32_t *)&PKAStartPoint[0], funcCB); +} + +__weak void PKAMGR_IRQCallback(void) +{ +} + +/** +* @} +*/ + +/** +* @} +*/ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Inc/gap_profile.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Inc/gap_profile.h new file mode 100644 index 000000000..36c3b797d --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Inc/gap_profile.h @@ -0,0 +1,162 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file gap_profile.h + * @author GPM WBL Application Team + * @brief Header file for Generic Access Profile Service (GAP) + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef GAP_PROFILE_H +#define GAP_PROFILE_H + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ble_status.h" +#include "ble_api.h" +/****************************************************************************** + * CONSTANT SYMBOLS + *****************************************************************************/ +#define GAP_CHR_DEVICE_NAME_VAL_LEN_MAX (50U) +#define GAP_CHR_APPEARANCE_VAL_LEN (2U) +#define GAP_CHR_PERIPH_PREF_CONN_PARAMS_LEN (8U) +#define GAP_CHR_CENTRAL_ADDR_RESOLUTION_LEN (1U) + +/****************************************************************************** + * FUNCTION PROTOTYPES + *****************************************************************************/ + +/** + * @brief Initialize GAP Profile + */ +tBleStatus aci_gap_profile_init(uint8_t Role, + uint8_t Privacy_Type, + uint16_t *Dev_Name_Char_Handle, + uint16_t *Appearance_Char_Handle, + uint16_t *Periph_Pref_Conn_Param_Char_Handle); + +/** + * @brief Set device name value. + * + * @param offset Offset from which start to write the device name. + * @param length Data length. + * @param[in] dev_name_p Pointer to the data to write. + * + * @return + * - BLE_STATUS_SUCCESS: the characteristic value is updated correctly + * - BLE_STATUS_INVALID_PARAMS: invalid parameter. + * + */ +tBleStatus Gap_profile_set_dev_name(uint16_t offset, + uint16_t length, + uint8_t *dev_name_p); + +/** + * @brief Set appearance value. + * + * @param offset Offset from which start to write appearance value. + * @param length Data length. + * @param[in] appearance_p Pointer to the data to write. + * + * @return + * - BLE_STATUS_SUCCESS: the characteristic value is updated correctly + * - BLE_STATUS_INVALID_PARAMS: invalid parameter. + * + */ +tBleStatus Gap_profile_set_appearance(uint16_t offset, + uint16_t length, + uint8_t *appearance_p); + +/** + * @brief Set preferred connection parameter value. + * + * @param offset Offset from which start to write value. + * @param length Data length. + * @param[in] pref_conn_param_p Pointer to the data to write. + * + * @return + * - BLE_STATUS_SUCCESS: the characteristic value is updated correctly + * - BLE_STATUS_INVALID_PARAMS: invalid parameter. + * + */ +tBleStatus Gap_profile_set_pref_conn_par(uint16_t offset, + uint16_t length, + uint8_t *pref_conn_param_p); + +/** + * @brief Set GAP characteristic value. + * + * @param attr_h Attribute handle to write. + * @param val_offset Offset from which start to write the device name. + * @param val_length Data length. + * @param[in] val_p Pointer to the data to write. + * + * @return + * - BLE_STATUS_SUCCESS: the characteristic value is updated correctly + * - BLE_STATUS_INVALID_PARAMS: invalid parameter. + * + */ +tBleStatus Gap_profile_set_char_value(uint16_t attr_h, + uint16_t val_offset, + uint16_t val_length, + uint8_t *val_p); + +/** + * @brief Change access permission for the provided attribute handle. + * + * @param attr_h The requested attribute handle to change. + * @param perm the new permission value. + * + * @return: + * - BLE_STATUS_SUCCESS: the access permission are set + * - BLE_STATUS_FAILED: the requested attribute is not in the GAP service group + * or the attribute can't be altered. + * + */ +tBleStatus Gap_profile_set_access_permission(uint16_t attr_h, uint8_t perm); + +/** + * @brief Change security permission for the provided attribute handle. + * + * @param attr_h The requested attribute handle to change. + * @param perm the new permission value. + * + * @return: + * - BLE_STATUS_SUCCESS: the security permission are set. + * - BLE_STATUS_NOT_ALLOWED: the requested permissions are not allowed. + * - BLE_STATUS_FAILED: the requested attribute is not in the GAP service group + * or the attribute can't be altered. + * + */ +tBleStatus Gap_profile_set_security_permission(uint16_t attr_h, uint8_t perm); + +/** + * @brief Retrieve GAP profile service handle. + * + * @return: service handle. + * + */ +uint16_t Gap_profile_get_service_handle(void); + +/** + * @brief Retrieve GAP service definition pointer. + * + * @return: service definition pointer. + * + */ +ble_gatt_srv_def_t *Gap_profile_get_service_definition_p(void); + +#endif + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Inc/gatt_profile.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Inc/gatt_profile.h new file mode 100644 index 000000000..8101eff07 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Inc/gatt_profile.h @@ -0,0 +1,103 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file gatt_profile.h + * @author GPM WBL Application Team + * @brief Header file for Generic Attribute Profile Service (GATT) + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef GATT_PROFILE_H +#define GATT_PROFILE_H + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "stdint.h" +#include "ble_status.h" +#include "ble_api.h" +/****************************************************************************** + * CONSTANT SYMBOLS + *****************************************************************************/ +#if defined(CONFIG_NUM_MAX_LINKS) +#define GATT_SRV_MAX_CONN (CONFIG_NUM_MAX_LINKS) +#else +#define GATT_SRV_MAX_CONN (8U) +#endif + +#define GATT_CHR_SERVICE_CHANGED_VALUE_LEN (4U) + +#define GATT_INIT_SERVICE_CHANGED_BIT (0x01) + +/****************************************************************************** + * FUNCTION PROTOTYPES + *****************************************************************************/ + +/** + * @brief Initialize GATT Profile + * + * @return: + * - BLE_STATUS_SUCCESS: the service is correctly loaded + * + */ +tBleStatus aci_gatt_srv_profile_init(uint8_t Characteristics, + uint16_t *Service_Changed_Handle); + +/** + * @brief Change access permission for the provided attribute handle. + * + * @param attr_h The requested attribute handle to change. + * @param perm the new permission value. + * + * @return: + * - BLE_STATUS_SUCCESS: the access permission are set + * - BLE_STATUS_FAILED: the requested attribute is not in the GATT service group + * or the attribute can't be altered. + * + */ +tBleStatus Gatt_profile_set_access_permission(uint16_t attr_h, uint8_t perm); + +/** + * @brief Change security permission for the provided attribute handle. + * + * @param attr_h The requested attribute handle to change. + * @param perm the new permission value. + * + * @return: + * - BLE_STATUS_SUCCESS: the security permission are set. + * - BLE_STATUS_NOT_ALLOWED: the requested permissions are not allowed. + * - BLE_STATUS_FAILED: the requested attribute is not in the GATT service group + * or the attribute can't be altered. + * + */ +tBleStatus Gatt_profile_set_security_permission(uint16_t attr_h, uint8_t perm); + +/** + * @brief Retrieve GATT profile service handle. + * + * @return: service handle. + * + */ +uint16_t Gatt_profile_get_service_handle(void); + +/** + * @brief Retrieve GATT service definition pointer. + * + * @return: service definition pointer. + * + */ +ble_gatt_srv_def_t *Gatt_profile_get_service_definition_p(void); + +#endif + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Src/gap_profile.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Src/gap_profile.c new file mode 100644 index 000000000..9b0e99443 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Src/gap_profile.c @@ -0,0 +1,424 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file gap_profile.c + * @author GPM WBL Application Team + * @brief Generic Access Profile Service (GAP) + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "gap_profile.h" +#include +#include "osal.h" +#include "ble.h" + +#if (CFG_BLE_CONNECTION_ENABLED==1) + +/****************************************************************************** + * LOCAL VARIABLES + *****************************************************************************/ +/** + * Default device name. + */ +static const uint8_t default_dev_name[] = { 'S', 'T', 'M', '3', '2', 'W', 'B', '0' }; + +/** + *@defgroup Device Name Characteristic value. + *@{ + */ +/** + * Characteristic value buffer. + */ +static uint8_t gap_device_name_buff[GAP_CHR_DEVICE_NAME_VAL_LEN_MAX]; + +static ble_gatt_val_buffer_def_t gap_device_name_val_buff = { + .buffer_len = GAP_CHR_DEVICE_NAME_VAL_LEN_MAX, + .op_flags = BLE_GATT_SRV_OP_VALUE_VAR_LENGTH_FLAG | BLE_GATT_SRV_OP_MODIFIED_EVT_ENABLE_FLAG, + .buffer_p = gap_device_name_buff, +}; +/** + *@} + */ + +/** + *@defgroup Appearance Characteristic value. + *@{ + */ +/** + * Characteristic value buffer. + */ +static uint8_t gap_appearance_buff[GAP_CHR_APPEARANCE_VAL_LEN]; + +static const ble_gatt_val_buffer_def_t gap_appearance_val_buff = { + .buffer_len = GAP_CHR_APPEARANCE_VAL_LEN, + .buffer_p = gap_appearance_buff, +}; +/** + *@} + */ + +/** + *@defgroup Peripheral Preferred Connection Parameters Characteristic value. + *@{ + */ +/** + * Characteristic value buffer. + */ +static uint8_t gap_peripheral_preferred_con_params_buff[GAP_CHR_PERIPH_PREF_CONN_PARAMS_LEN] = { + 0xFFU, 0xFFU, 0xFFU, 0xFFU, + 0x00U, 0x00U, 0xFFU, 0xFFU +}; +static const ble_gatt_val_buffer_def_t gap_peripheral_preferred_con_params_val_buff = { + .buffer_len = GAP_CHR_PERIPH_PREF_CONN_PARAMS_LEN, + .buffer_p = gap_peripheral_preferred_con_params_buff, +}; +/** + *@} + */ + +/** + *@defgroup Central Address Resolution Characteristic value. + *@{ + */ +/** + * Characteristic value buffer. + */ +static uint8_t gap_central_address_resolution_buff[GAP_CHR_CENTRAL_ADDR_RESOLUTION_LEN] = { 1U }; +static const ble_gatt_val_buffer_def_t gap_central_address_resolution_val_buff = { + .buffer_len = GAP_CHR_CENTRAL_ADDR_RESOLUTION_LEN, + .buffer_p = gap_central_address_resolution_buff, +}; +/** + *@} + */ + +static ble_gatt_chr_def_t gap_chrs[] = { + { /**< Device Name Characteristic. */ + .properties = BLE_GATT_SRV_CHAR_PROP_READ, + .permissions = BLE_GATT_SRV_PERM_NONE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_DEVICE_NAME_CHR_UUID), + .min_key_size = 7U, + .val_buffer_p = (ble_gatt_val_buffer_def_t *)&gap_device_name_val_buff, + }, { /**< Appearance Characteristic. */ + .properties = BLE_GATT_SRV_CHAR_PROP_READ, + .permissions = BLE_GATT_SRV_PERM_NONE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_APPEARANCE_CHR_UUID), + .min_key_size = 7U, + .val_buffer_p = (ble_gatt_val_buffer_def_t *)&gap_appearance_val_buff, + }, { /**< Peripheral Preferred Connection Parameters Characteristic. */ + .properties = BLE_GATT_SRV_CHAR_PROP_READ, + .permissions = BLE_GATT_SRV_PERM_NONE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_PERIPHERAL_PREFERRED_CONN_PARAMS_UUID), + .min_key_size = 7U, + .val_buffer_p = (ble_gatt_val_buffer_def_t *)&gap_peripheral_preferred_con_params_val_buff, + }, { /**< Central Address Resolution Characteristic. */ + .properties = BLE_GATT_SRV_CHAR_PROP_READ, + .permissions = BLE_GATT_SRV_PERM_NONE, + .min_key_size = 7U, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_CENTRAL_ADDRESS_RESOLUTION_UUID), + .val_buffer_p = (ble_gatt_val_buffer_def_t *)&gap_central_address_resolution_val_buff, + } +}; + +static ble_gatt_srv_def_t gap_srvc = { + .type = BLE_GATT_SRV_PRIMARY_SRV_TYPE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_GAP_SERVICE_UUID), + .chrs = { + .chrs_p = gap_chrs, + .chr_count = 2U, + }, +}; + +tBleStatus aci_gap_profile_init(uint8_t Role, + uint8_t Privacy_Type, + uint16_t *Dev_Name_Char_Handle, + uint16_t *Appearance_Char_Handle, + uint16_t *Periph_Pref_Conn_Param_Char_Handle) +{ + tBleStatus ret; + uint16_t gap_srvc_handle; + + *Dev_Name_Char_Handle = 0x0000; + *Appearance_Char_Handle= 0x0000; + *Periph_Pref_Conn_Param_Char_Handle = 0x0000; + + if ((Role & (GAP_PERIPHERAL_ROLE | GAP_CENTRAL_ROLE)) != 0x0U) + { + + /** + * Register GAP service. + * Device Name and Appearance Characteristics will be also registered. + */ + ret = aci_gatt_srv_add_service(&gap_srvc); + if (ret != BLE_STATUS_SUCCESS) + { + return ret; + } + + *Dev_Name_Char_Handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[0U]); + *Appearance_Char_Handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[1U]); + + gap_srvc_handle = aci_gatt_srv_get_service_handle(&gap_srvc); + if ((Role & GAP_PERIPHERAL_ROLE) != 0x0U) + { + /** + * Register Peripheral Preferred Connection Parameters Characteristic. + */ + ret = aci_gatt_srv_add_char(&gap_chrs[2U], gap_srvc_handle); + if (ret != BLE_STATUS_SUCCESS) + { + return ret; + } + } + + *Periph_Pref_Conn_Param_Char_Handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[2U]); + + if (Privacy_Type == 2U) + { + /** + * Register Central Address Resolution Characteristic. + */ + ret = aci_gatt_srv_add_char(&gap_chrs[3U], gap_srvc_handle); + if (ret != BLE_STATUS_SUCCESS) + { + return ret; + } + } + + /** + * Set default device name. + */ + Gap_profile_set_dev_name(0U, sizeof(default_dev_name), + (uint8_t *)default_dev_name); + + } + + return BLE_STATUS_SUCCESS; +} + +tBleStatus Gap_profile_set_dev_name(uint16_t offset, + uint16_t length, + uint8_t *dev_name_p) +{ + uint16_t handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[0U]) + 1U; + + return Gap_profile_set_char_value(handle, offset, length, dev_name_p); +} + +tBleStatus Gap_profile_set_appearance(uint16_t offset, + uint16_t length, + uint8_t *appearance_p) +{ + uint16_t handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[1U]) + 1U; + + return Gap_profile_set_char_value(handle, offset, length, appearance_p); +} + +tBleStatus Gap_profile_set_pref_conn_par(uint16_t offset, + uint16_t length, + uint8_t *pref_conn_param_p) +{ + uint16_t handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[2U]) + 1U; + + return Gap_profile_set_char_value(handle, offset, length, pref_conn_param_p); +} + +tBleStatus Gap_profile_set_char_value(uint16_t attr_h, + uint16_t val_offset, + uint16_t val_length, + uint8_t *val_p) +{ + uint8_t i; + uint16_t handle; + + /** + * Search for GAP characteristic. + */ + for (i = 0U; i < (sizeof(gap_chrs) / sizeof(gap_chrs[0U])); i++) + { + handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[i]); + if ((handle != BLE_ATT_INVALID_ATTR_HANDLE) && + ((handle + 1U) == attr_h)) + { + break; + } + } + + if (i == (sizeof(gap_chrs) / sizeof(gap_chrs[0U]))) + { + /** + * The given attribute handle is not registered for GAP service. + */ + return BLE_STATUS_INVALID_PARAMS; + } + + if ((val_offset + val_length) > gap_chrs[i].val_buffer_p->buffer_len) + { + /** + * Invalid value length. + */ + return BLE_STATUS_INVALID_PARAMS; + } + + /** + * Write characteristic value. + */ + memcpy(&gap_chrs[i].val_buffer_p->buffer_p[val_offset], val_p, val_length); + if ((gap_chrs[i].val_buffer_p->op_flags & BLE_GATT_SRV_OP_VALUE_VAR_LENGTH_FLAG) != 0U) + { + gap_chrs[i].val_buffer_p->val_len = val_length; + } + + return BLE_STATUS_SUCCESS; +} + +tBleStatus Gap_profile_set_access_permission(uint16_t attr_h, uint8_t perm) +{ + uint16_t handle; + + perm &= BLE_GATT_SRV_CHAR_PROP_ACCESS_PERM_MASK; + + /** + * Check if it is the device name char; + */ + handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[0U]); + if ((handle != BLE_ATT_INVALID_ATTR_HANDLE) && ((handle + 1U) == attr_h)) + { + gap_chrs[0U].properties &= ~BLE_GATT_SRV_CHAR_PROP_ACCESS_PERM_MASK; + gap_chrs[0U].properties |= perm; + + return BLE_STATUS_SUCCESS; + } + + /** + * Check if it is the appearance char; + */ + handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[1U]); + if ((handle != BLE_ATT_INVALID_ATTR_HANDLE) && ((handle + 1U) == attr_h)) + { + gap_chrs[1U].properties &= ~BLE_GATT_SRV_CHAR_PROP_ACCESS_PERM_MASK; + gap_chrs[1U].properties |= perm; + + return BLE_STATUS_SUCCESS; + } + + return BLE_STATUS_FAILED; +} + +tBleStatus Gap_profile_set_security_permission(uint16_t attr_h, uint8_t perm) +{ + uint16_t handle; + + /** + * Check if it is the device name char; + */ + handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[0U]); + if ((handle != BLE_ATT_INVALID_ATTR_HANDLE) && ((handle + 1U) == attr_h)) + { + if ((perm & (BLE_GATT_SRV_PERM_ENCRY_READ | + BLE_GATT_SRV_PERM_AUTHEN_READ)) != 0U) + { + /** + * <> + * + * Table 12.3: Device Name characteristic + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C page 1395 + */ + return BLE_STATUS_NOT_ALLOWED; + } + gap_chrs[0U].permissions = perm; + + return BLE_STATUS_SUCCESS; + } + + /** + * Check if it is the appearance char; + */ + handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[1U]); + if ((handle != BLE_ATT_INVALID_ATTR_HANDLE) && ((handle + 1U) == attr_h)) + { + if ((perm & (BLE_GATT_SRV_PERM_ENCRY_READ | + BLE_GATT_SRV_PERM_AUTHEN_READ)) != 0U) + { + /** + * <> + * + * Table 12.4: Appearance characteristic + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C page 1395 + */ + return BLE_STATUS_NOT_ALLOWED; + } + gap_chrs[1U].permissions = perm; + + return BLE_STATUS_SUCCESS; + } + + /** + * Check if it is the Peripheral Preferred Connection Parameters characteristic + */ + handle = aci_gatt_srv_get_char_decl_handle(&gap_chrs[2U]); + if ((handle != BLE_ATT_INVALID_ATTR_HANDLE) && ((handle + 1U) == attr_h)) + { + if ((perm & (BLE_GATT_SRV_PERM_AUTHEN_WRITE | + BLE_GATT_SRV_PERM_ENCRY_WRITE)) != 0U) + { + /** + * <> + * + * Table 12.5: Peripheral Preferred Connection Parameters characteristic + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C page 1396 + */ + return BLE_STATUS_NOT_ALLOWED; + } + gap_chrs[2U].permissions = perm; + + return BLE_STATUS_SUCCESS; + } + + return BLE_STATUS_FAILED; +} + +uint16_t Gap_profile_get_service_handle(void) +{ + return aci_gatt_srv_get_service_handle((ble_gatt_srv_def_t *)&gap_srvc); +} + +ble_gatt_srv_def_t *Gap_profile_get_service_definition_p(void) +{ + return (ble_gatt_srv_def_t *)&gap_srvc; +} + +#else /* (CFG_BLE_CONNECTION_ENABLED == 0) */ + +tBleStatus aci_gap_profile_init(uint8_t Role, + uint8_t Privacy_Type, + uint16_t *Dev_Name_Char_Handle, + uint16_t *Appearance_Char_Handle, + uint16_t *Periph_Pref_Conn_Param_Char_Handle) +{ + if ((Role & (GAP_PERIPHERAL_ROLE | GAP_CENTRAL_ROLE)) != 0x0U) + { + return BLE_ERROR_UNSUPPORTED_FEATURE; + } + else + { + return BLE_STATUS_SUCCESS; + } +} + +#endif + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Src/gatt_profile.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Src/gatt_profile.c new file mode 100644 index 000000000..fbaa04b21 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/Profiles/Src/gatt_profile.c @@ -0,0 +1,268 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file gatt_profile.c + * @author GPM WBL Application Team + * @brief Generic Attribute Profile Service (GATT) + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "gatt_profile.h" +#include +#include "osal.h" +#include "ble.h" + +#if (CFG_BLE_CONNECTION_ENABLED==1) + +/****************************************************************************** + * LOCAL VARIABLES + *****************************************************************************/ +/** + *@defgroup Service Changed Characteristic value. + *@{ + */ +/** + * Characteristic value buffer. + */ +static const uint8_t gatt_chr_srv_changed_buff[GATT_CHR_SERVICE_CHANGED_VALUE_LEN] = + {0x00U, 0x00U, 0xffU, 0xffU}; + +static const ble_gatt_val_buffer_def_t gatt_chr_srv_changed_value_buff = { + .buffer_len = GATT_CHR_SERVICE_CHANGED_VALUE_LEN, + .buffer_p = (uint8_t *)gatt_chr_srv_changed_buff, +}; +/** + *@} + */ + +/** + *@defgroup Client Supported Feature Characteristic value. + *@{ + */ +/** + * The following buffer store the Client Supported Feature characteristic + * value, as described in 7.2 CLIENT SUPPORTED FEATURES - BLUETOOTH CORE + * SPECIFICATION Version 5.1 | Vol 3, Part G page 2403. + * The assigned bits are reported in Table 7.6: Client Supported Features + * bit assignments. + */ +static uint8_t gatt_client_supp_feature_buff[BLE_GATT_SRV_CLIENT_SUP_FEATURE_SIZE_X_CONN(GATT_SRV_MAX_CONN)]; + +static const ble_gatt_val_buffer_def_t gatt_client_supp_feature_val_buff = { + .buffer_len = BLE_GATT_SRV_CLIENT_SUP_FEATURE_SIZE_X_CONN(GATT_SRV_MAX_CONN), + .buffer_p = gatt_client_supp_feature_buff, +}; +/** + *@} + */ + +/** + *@defgroup Server Supported Feature Characteristic value. + *@{ + */ +/** + * The following buffer store the Server Supported Feature characteristic + * value, as described in 7.4 SERVER SUPPORTED FEATURES - BLUETOOTH CORE + * SPECIFICATION Version 5.2 | Vol 3, Part G page 1605. + * The assigned bits are reported in Table 7.11: Server Supported Features + * bit assignments. + */ +static const uint8_t gatt_server_supp_feature_buff = 1U; + +static const ble_gatt_val_buffer_def_t gatt_server_supp_feature_val_buff = { + .buffer_len = BLE_GATT_SRV_SUPPORTED_FEATURES_VAL_LEN, + .buffer_p = (uint8_t *)&gatt_server_supp_feature_buff, +}; +/** + *@} + */ + +/** + * Service Changed CCCD. + */ +BLE_GATT_SRV_CCCD_DECLARE(gatt_chr_srv_changed, + GATT_SRV_MAX_CONN, + BLE_GATT_SRV_CCCD_PERM_DEFAULT, + BLE_GATT_SRV_OP_MODIFIED_EVT_ENABLE_FLAG); + +static const ble_gatt_chr_def_t gatt_srvc_changed_chr = +{ + /**< Service Changed Characteristic. */ + .properties = BLE_GATT_SRV_CHAR_PROP_INDICATE, + .permissions = BLE_GATT_SRV_PERM_NONE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_SERVICE_CHANGE_CHR_UUID), + .val_buffer_p = (ble_gatt_val_buffer_def_t *)&gatt_chr_srv_changed_value_buff, + .descrs = { + .descrs_p = &BLE_GATT_SRV_CCCD_DEF_NAME(gatt_chr_srv_changed), + .descr_count = 1U, + } +}; + +static const ble_gatt_chr_def_t gatt_clt_supp_feat_chr = +{ + /**< Client Supported Features Characteristic. */ + .properties = BLE_GATT_SRV_CHAR_PROP_READ | BLE_GATT_SRV_CHAR_PROP_WRITE, + .permissions = BLE_GATT_SRV_PERM_NONE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_CLIENT_SUPP_FEATURE_CHR_UUID), + .val_buffer_p = (ble_gatt_val_buffer_def_t *)&gatt_client_supp_feature_val_buff, +}; + +static const ble_gatt_chr_def_t gatt_db_hash_chr = +{ + /**< Database Hash Characteristic. Value buffer is allocated into the stack. */ + .properties = BLE_GATT_SRV_CHAR_PROP_READ, + .permissions = BLE_GATT_SRV_PERM_NONE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_DB_HASH_CHR_UUID), +}; + +static const ble_gatt_chr_def_t gatt_srv_supp_feat_chr = +{ + /**< Server Supported Feature Characteristic. */ + .properties = BLE_GATT_SRV_CHAR_PROP_READ, + .permissions = BLE_GATT_SRV_PERM_NONE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_SUPPORTED_FEATURES_CHR_UUID), + .val_buffer_p = (ble_gatt_val_buffer_def_t *)&gatt_server_supp_feature_val_buff, +}; + +static ble_gatt_srv_def_t gatt_srvc = { + .type = BLE_GATT_SRV_PRIMARY_SRV_TYPE, + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_GATT_SERVICE_UUID), + .chrs = {0, NULL}, +}; + +tBleStatus aci_gatt_srv_profile_init(uint8_t Characteristics, + uint16_t *Service_Changed_Handle) +{ + tBleStatus ret; + uint16_t gatt_srvc_handle; + + *Service_Changed_Handle = 0x0000; + + ret = aci_gatt_srv_add_service(&gatt_srvc); + if (ret != BLE_STATUS_SUCCESS) + { + return ret; + } + + gatt_srvc_handle = aci_gatt_srv_get_service_handle(&gatt_srvc); + + if(Characteristics & GATT_INIT_SERVICE_CHANGED_BIT) + { + ret = aci_gatt_srv_add_char((ble_gatt_chr_def_t*)&gatt_srvc_changed_chr, gatt_srvc_handle); + if (ret != BLE_STATUS_SUCCESS) + { + return ret; + } + } + *Service_Changed_Handle = aci_gatt_srv_get_char_decl_handle((ble_gatt_chr_def_t*)&gatt_srvc_changed_chr); + + ret = aci_gatt_srv_add_char((ble_gatt_chr_def_t*)&gatt_clt_supp_feat_chr, gatt_srvc_handle); + if (ret != BLE_STATUS_SUCCESS) + { + return ret; + } + + ret = aci_gatt_srv_add_char((ble_gatt_chr_def_t*)&gatt_db_hash_chr, gatt_srvc_handle); + if (ret != BLE_STATUS_SUCCESS) + { + return ret; + } + + ret = aci_gatt_srv_add_char((ble_gatt_chr_def_t*)&gatt_srv_supp_feat_chr, gatt_srvc_handle); + if (ret != BLE_STATUS_SUCCESS) + { + return ret; + } + + return BLE_STATUS_SUCCESS; +} + +tBleStatus Gatt_profile_set_access_permission(uint16_t attr_h, uint8_t perm) +{ + uint16_t cccd_handle; + + cccd_handle = aci_gatt_srv_get_descriptor_handle( + &BLE_GATT_SRV_CCCD_DEF_NAME(gatt_chr_srv_changed)); + if ((cccd_handle != BLE_ATT_INVALID_ATTR_HANDLE) && (cccd_handle == attr_h)) + { + /** + * Clear previous set access permissions. + */ + BLE_GATT_SRV_CCCD_DEF_NAME(gatt_chr_srv_changed).properties &= + ~BLE_GATT_SRV_CHAR_PROP_ACCESS_PERM_MASK; + BLE_GATT_SRV_CCCD_DEF_NAME(gatt_chr_srv_changed).properties |= (perm & + BLE_GATT_SRV_CHAR_PROP_ACCESS_PERM_MASK); + + return BLE_STATUS_SUCCESS; + } + else + { + return BLE_STATUS_FAILED; + } +} + +tBleStatus Gatt_profile_set_security_permission(uint16_t attr_h, uint8_t perm) +{ + uint16_t cccd_handle; + + cccd_handle = aci_gatt_srv_get_descriptor_handle( + &BLE_GATT_SRV_CCCD_DEF_NAME(gatt_chr_srv_changed)); + if ((cccd_handle != BLE_ATT_INVALID_ATTR_HANDLE) && (cccd_handle == attr_h)) + { + if ((perm & (BLE_GATT_SRV_PERM_ENCRY_READ | + BLE_GATT_SRV_PERM_AUTHEN_READ)) != 0U) + { + /** + * <> + * + * Table 3.10: Client Characteristic Configuration declaration + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part G page 1556 + */ + return BLE_STATUS_NOT_ALLOWED; + } + + BLE_GATT_SRV_CCCD_DEF_NAME(gatt_chr_srv_changed).permissions = perm; + + return BLE_STATUS_SUCCESS; + } + else + { + return BLE_STATUS_FAILED; + } +} + +uint16_t Gatt_profile_get_service_handle(void) +{ + return aci_gatt_srv_get_service_handle((ble_gatt_srv_def_t *)&gatt_srvc); +} + +ble_gatt_srv_def_t *Gatt_profile_get_service_definition_p(void) +{ + return (ble_gatt_srv_def_t *)&gatt_srvc; +} + +#else /* (CFG_BLE_CONNECTION_ENABLED == 0) */ + +tBleStatus aci_gatt_srv_profile_init(uint8_t Characteristics, + uint16_t *Service_Changed_Handle) +{ + return BLE_ERROR_UNSUPPORTED_FEATURE; +} + +#endif + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Inc/RADIO_utils.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Inc/RADIO_utils.h new file mode 100644 index 000000000..e56ea9ad4 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Inc/RADIO_utils.h @@ -0,0 +1,186 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file RADIO_utils.h + * @author GPM WBL Application Team + * @brief Header file for HW miscellaneous utilities. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef __RADIO_UTILS_H__ +#define __RADIO_UTILS_H__ + +#include "stm32wb0x.h" +#include "ble_status.h" + +#define RSSI_INVALID 127 +#define DEFAULT_TX_PA_LEVEL 31 + +#ifndef ANTENNA_ID_BIT_SHIFT +#define ANTENNA_ID_BIT_SHIFT (0) +#endif + +/** + * @brief Convert power level expressed in dBm into driver + * coded PALevel + * @param TX_dBm value of Tx power in dBm unit + * @retval PA Level table index + */ +uint8_t RADIO_DBmToPALevel(int8_t TX_dBm); + +/** + * @brief Convert power level expressed in dBm into driver + * coded PALevel + * @param TX_dBm value of Tx power in dBm unit + * @retval PA Level table index + */ +uint8_t RADIO_DBmToPALevelGe(int8_t TX_dBm); + +/** + * @brief Convert power level index into dBm unit tx power + * @param PA Level table index (0 to 31) + * @retval power in dBm unit + */ +int8_t RADIO_PALevelToDBm(uint8_t PA_Level); + +/** + * @brief Get Max PA Level index + * @param None + * @retval power level index + */ +uint8_t RADIO_GetMaxPALevel(void); + +/** + * @brief Get default PA Level set into the driver + * @param None + * @retval power level index + */ +uint8_t RADIO_GetDefaultPALevel(void); + +/** + * @brief Get minimum and maximum transmission power in dBm + * @param [out] Min_Tx_Power minimum transmission power in dBm + * @param [out] Max_Tx_Power maximum transmission power in dBm + * @retval None + */ +void RADIO_ReadTransmitPower(int8_t *Min_Tx_Power, int8_t *Max_Tx_Power); + +int8_t RADIO_UpdateAvgRSSI(int8_t avg_rssi, int8_t rssi, uint8_t rssi_filter_coeff); + +/** + * @brief Configure the radio to be able to reach 8dbm output power + * @note This function should not be called by the the application if the + * BLE stack is used. Instead, user must call + * aci_hal_set_tx_power_level() to change output power mode. + * This function enables RADIO_TXRX_SEQ_IRQn interrupt: HAL_RADIO_TXRX_SEQ_IRQHandler() + * must be called by RADIO_TXRX_SEQ_IRQHandler(). + * @param state Enable or disable the ability to reach 8 dBm. This parameter + * can be set either to ENABLE or DISABLE. + * @retval None + */ +void RADIO_SetHighPower(FunctionalState state); + +/** + * @brief Executes antenna id pattern remap + * @param AntPattLen Antenna ID pattern length + * @param pAntRamTable Antenna ID Ram table reference + * @param pAntPatt Antenna ID pattern + * @retval None + */ +void RADIO_AntIdxRemap(uint8_t AntPattLen, uint8_t *pAntRamTable, const uint8_t* pAntPatt); + +void RADIO_ToneStart(uint8_t RF_Channel, uint8_t Offset, uint8_t PA_Level); +void RADIO_ToneStop(void); +tBleStatus aci_hal_set_tx_power_level_preprocess(uint8_t En_High_Power, uint8_t PA_Level); + +/** + * @brief This command is used to enable ANTENNA_ID signal by enabling the + * Alternate Function on the corresponding pins. Some IOs may not be + * enabled, depending on resources availability (e.g. IOs used for + * communication). + * @param Antenna_IDs ANTENNA_ID pins to be enabled. Each bit in the mask + * enables the corresponding bit of the ANTENNA_ID signal, which is + * output on PB[0:7]. + * Flags: + * - 0x01: ANTENNA_ID_0 + * - 0x02: ANTENNA_ID_1 + * - 0x04: ANTENNA_ID_2 + * - 0x08: ANTENNA_ID_3 + * - 0x10: ANTENNA_ID_4 + * - 0x20: ANTENNA_ID_5 + * - 0x40: ANTENNA_ID_6 + * @param Antenna_ID_Shift This parameter can be set to a value different from + * zero to shift the ANTENNA_ID signal by the given number of bits. This + * number does not affect the pin selected by Antenna_IDs parameter. E.g. + * to have the ANTENNA_ID signal output on PB[2:4], set Antenna_IDs to + * enable ANTENNA_ID[2:4] (Antenna_IDs = 0x1C) and Antenna_ID_Shift to 2. + * Values: + * - 0 ... 6 + * @param Default_Antenna_ID The ID of antenna that the controller will select + * for regular communication. The antenna to be used when sending or + * receiving the CTE field needs to be specified through the Antenna_IDs + * parameter of the dedicated HCI commands (i.e. + * hci_le_set_connectionless_cte_transmit_parameters, + * hci_le_set_connectionless_iq_sampling_enable, + * hci_le_set_connection_cte_receive_parameters and + * hci_le_set_connection_cte_transmit_parameters). + * Values: + * - 0x00 ... 0x7F + * @param RF_Activity_Enable Enable or disable the RF Activity signal, if + * supported by the device. This signal can be used to enable the antenna + * switch only when necessary. + * Values: + * - 0x00: DISABLED + * - 0x01: ENABLED + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_set_antenna_switch_parameters(uint8_t Antenna_IDs, + uint8_t Antenna_ID_Shift, + uint8_t Default_Antenna_ID, + uint8_t RF_Activity_Enable); + +/** + * @brief This command starts a carrier frequency, i.e. a tone, on a specific + * channel. The frequency sine wave at the specific channel may be used + * for debugging purpose only. The channel ID is a parameter from 0x00 to + * 0x27 for the 40 BLE channels, e.g. 0x00 for 2.402 GHz, 0x01 for 2.404 + * GHz etc. This command should not be used when normal Bluetooth + * activities are ongoing. The tone should be stopped by @ref + * aci_hal_tone_stop command. + * @param RF_Channel BLE Channel ID, from 0x00 to 0x27 meaning (2.402 + 2*0xXX) + * GHz. + * Values: + * - 0x00 ... 0x27 + * @param Offset Specify if the tone must be emitted with an offset from the + * channel center frequency. If 0, the tone is emitted at the channel + * center frequency. If 1 or 2, the device will continuously emit the + * tone at the center frequency plus or minus 250 kHz respectively. + * Values: + * - 0x00: 0 kHz offset + * - 0x01: +250 kHz offset + * - 0x02: -250 kHz offset + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_tone_start(uint8_t RF_Channel, + uint8_t Offset); +/** + * @brief This command is used to stop the previously started @ref + * aci_hal_tone_start command. + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_tone_stop(void); + +#endif /* __RADIO_UTILS_H__ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c new file mode 100644 index 000000000..4f09cc043 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c @@ -0,0 +1,521 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file RADIO_utils.c + * @author GPM WBL Application Team + * @brief Miscellaneous utilities for interfacing to HW. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "RADIO_utils.h" +#include "stm32wb0x_ll_pwr.h" +#include "stm32wb0x_ll_gpio.h" +#include "ble.h" + +/* Private typedef -----------------------------------------------------------*/ + +/* Private define ------------------------------------------------------------*/ +#define TX_POWER_LEVELS (32U) +#if defined(STM32WB09) +#define HP_TX_POWER_LEVELS (TX_POWER_LEVELS+1) +#else +#define HP_TX_POWER_LEVELS (TX_POWER_LEVELS) +#endif + +#define LOWEST_TX_POWER_LEVEL_INDEX (1U) +#if defined(STM32WB09) +#define HIGH_POWER_LEVEL_INDEX (HP_TX_POWER_LEVELS - 1) +#endif + +/** Minimum supported TX power in dBm. */ +#define MIN_TX_POWER_LOW (normal_pa_level_table[LOWEST_TX_POWER_LEVEL_INDEX]) /* high power mode disabled */ +#define MIN_TX_POWER_HIGH (high_power_pa_level_table[LOWEST_TX_POWER_LEVEL_INDEX]) /* high power mode enabled */ + +/** Maximum supported TX power in dBm. */ +#define MAX_TX_POWER_LOW (normal_pa_level_table[TX_POWER_LEVELS-1]) /* high power mode disabled */ +#define MAX_TX_POWER_HIGH (high_power_pa_level_table[HP_TX_POWER_LEVELS-1]) /* high power mode enabled */ + +/* Parameters of the RSSI Exponential Moving Average algorithm */ +#define MAX_RSSI_FILTER_COEFF (4U) +#define RSSI_EMA_SMOOTH_FACTOR_BITS (3) + +#if defined(STM32WB09) +#define LDO_ANA_TST (*(&RRM->RXADC_ANA_USR + 0x02)) +#define RRM_LDO_ANA_TST_RFD_LDO_TRANSFO_BYPASS_Msk 0x08 +#define RRM_LDO_ANA_TST_LDO_ANA_TST_SEL_Msk 0x01 +#endif +#define RRM_TEST (*(&RRM->RRM_CTRL + 0x01)) + +/* This macro can be set to avoid breaking communication by changing the function + of pins with aci_set_antenna_switch_parameters(). */ +#define RESERVED_GPIOS 0x00 + +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +/* Expected TX output power (dBm) for each PA level when SMPS voltage is 1.4V */ +static const int8_t normal_pa_level_table[TX_POWER_LEVELS] = { + -54, -21, -20, -19, -17, -16, -15, -14, + -13, -12, -11, -10, -9, -8, -7, -6, + -6, -4, -3, -3, -2, -2, -1, -1, + 0, 0, 1, 2, 3, 4, 5, 6 +}; + +#if defined(STM32WB09) +static const int8_t high_power_pa_level_table[HP_TX_POWER_LEVELS] = { + -54, -21, -20, -19, -17, -16, -15, -14, + -13, -12, -11, -10, -9, -8, -7, -6, + -6, -4, -3, -3, -2, -2, -1, -1, + 0, 0, 1, 2, 3, 4, 5, 6, + 8 +}; +#else +/* Expected TX output power (dBm) for each PA level when SMPS voltage is 1.9V + (high power mode). */ +static const int8_t high_power_pa_level_table[HP_TX_POWER_LEVELS] = { + -54, -19, -18, -17, -16, -15, -14, -13, + -12, -11, -10, -9, -8, -7, -6, -5, + -4, -3, -3, -2, -1, 0, 1, 2, + 3, 8, 8, 8, 8, 8, 8, 8 +}; +#endif + +struct antenna_conf_s { + uint8_t Antenna_IDs; + uint8_t Antenna_ID_Shift; + uint8_t Default_Antenna_ID; + uint8_t RF_Activity_Enable; +}antenna_conf = {0, ANTENNA_ID_BIT_SHIFT, 0, 0}; + +uint8_t high_power = FALSE; +uint8_t tone_started = FALSE; +uint8_t pa_level = DEFAULT_TX_PA_LEVEL; + +uint8_t RADIO_DBmToPALevel(int8_t TX_dBm) +{ + uint8_t i; + const int8_t *pa_level_table = high_power ? high_power_pa_level_table : normal_pa_level_table; + const uint8_t tx_power_levels = high_power ? HP_TX_POWER_LEVELS : TX_POWER_LEVELS; + + for(i = 0; i < tx_power_levels; i++) + { + if(pa_level_table[i] >= TX_dBm) + break; + } + if (((pa_level_table[i] > TX_dBm) && (i > LOWEST_TX_POWER_LEVEL_INDEX)) || + (i == tx_power_levels)) + { + i--; + } + + return i; +} + +uint8_t RADIO_DBmToPALevelGe(int8_t TX_dBm) +{ + const int8_t *pa_level_table = high_power ? high_power_pa_level_table : normal_pa_level_table; + const uint8_t tx_power_levels = high_power ? HP_TX_POWER_LEVELS : TX_POWER_LEVELS; + uint8_t i; + + for(i = LOWEST_TX_POWER_LEVEL_INDEX; i < tx_power_levels; i++) + { + if (pa_level_table[i] >= TX_dBm) + break; + } + + if(i == tx_power_levels) + { + i--; + } + + return i; +} + +int8_t RADIO_PALevelToDBm(uint8_t PA_Level) +{ + const int8_t *pa_level_table = high_power ? high_power_pa_level_table : normal_pa_level_table; + const uint8_t tx_power_levels = high_power ? HP_TX_POWER_LEVELS : TX_POWER_LEVELS; + + if(PA_Level < LOWEST_TX_POWER_LEVEL_INDEX || PA_Level >= tx_power_levels) + { + return 127; + } + + return pa_level_table[PA_Level]; +} + +uint8_t RADIO_GetMaxPALevel(void) +{ + return HP_TX_POWER_LEVELS - 1; +} + +uint8_t RADIO_GetDefaultPALevel(void) +{ + return DEFAULT_TX_PA_LEVEL; +} + +void RADIO_ReadTransmitPower(int8_t *Min_Tx_Power, int8_t *Max_Tx_Power) +{ + if (high_power) + { + *Min_Tx_Power = MIN_TX_POWER_HIGH; + *Max_Tx_Power = MAX_TX_POWER_HIGH; + } + else + { + *Min_Tx_Power = MIN_TX_POWER_LOW; + *Max_Tx_Power = MAX_TX_POWER_LOW; + } +} + +void RADIO_SetHighPower(FunctionalState state) +{ + if(state != DISABLE) + { + if(high_power == FALSE) + { + high_power = TRUE; +#if defined(RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS) + LL_APB0_GRP1_EnableClock(LL_APB0_GRP1_PERIPH_SYSCFG); + LL_SYSCFG_BLERXTX_SetTrigger(LL_SYSCFG_BLERXTX_TRIGGER_BOTH_EDGE, LL_SYSCFG_BLE_TX_EVENT); + LL_SYSCFG_BLERXTX_SetType(LL_SYSCFG_BLERXTX_DET_TYPE_EDGE, LL_SYSCFG_BLE_TX_EVENT); + LL_SYSCFG_BLERXTX_EnableIT(LL_SYSCFG_BLE_TX_EVENT); + LL_SYSCFG_BLERXTX_ClearInterrupt(LL_SYSCFG_BLE_TX_EVENT); + NVIC_EnableIRQ(RADIO_TXRX_SEQ_IRQn); +#endif + } + } + else + { + if(high_power == TRUE) + { + high_power = FALSE; +#if defined(RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS) + LL_SYSCFG_BLERXTX_DisableIT(LL_SYSCFG_BLE_TX_EVENT); + NVIC_DisableIRQ(RADIO_TXRX_SEQ_IRQn); + LL_SYSCFG_BLERXTX_ClearInterrupt(LL_SYSCFG_BLE_TX_EVENT); +#endif + } + } + + if (LL_PWR_IsEnabledSMPSPrechargeMode() || (LL_PWR_GetSMPSMode() == LL_PWR_NO_SMPS)) + return; + + /* Bypass SMPS */ + LL_PWR_SetSMPSPrechargeMode(LL_PWR_SMPS_PRECHARGE); + while(LL_PWR_IsSMPSReady()); + /* Change level */ + if(state != DISABLE) + { + LL_PWR_SMPS_SetOutputVoltageLevel(PWR_SMPS_OUTPUT_VOLTAGE_1V90); + } + else + { + LL_PWR_SMPS_SetOutputVoltageLevel(PWR_SMPS_OUTPUT_VOLTAGE_1V40); + } + /* Disable bypass*/ + LL_PWR_SetSMPSPrechargeMode(LL_PWR_NO_SMPS_PRECHARGE); + while(!LL_PWR_IsSMPSReady()); +} + +void HAL_RADIO_TxRxSeqCallback(void) +{ +#if defined(RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS) + if(high_power == FALSE) + return; + + if(LL_SYSCFG_BLERXTX_IsInterruptPending(LL_SYSCFG_BLE_TX_EVENT)){ + if(RRM->FSM_STATUS_DIG_OUT & RRM_FSM_STATUS_DIG_OUT_STATUS_4) + { + // Rising edge + MODIFY_REG_FIELD(RRM->LDO_ANA_ENG, RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS, 1); + } + else + { + // Falling edge + MODIFY_REG_FIELD(RRM->LDO_ANA_ENG, RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS, 0); + } + LL_SYSCFG_BLERXTX_ClearInterrupt(LL_SYSCFG_BLE_TX_EVENT); + } +#endif +} + +/* ------------ Section for tone generation functions ------------------------*/ + +void RADIO_ToneStart(uint8_t RF_Channel, uint8_t Offset, uint8_t PA_Level) +{ + uint8_t internal_pa_level = PA_Level; + + /* Calculate the synt divide factor for 16 MHz quarts and +250 kHz offset wrt the channel center frequency + * Algorithmically MAK = F_rf*(2^20)/35 = F_rf*(2^15) + * With F_rf = (2402+2*RF_Channel)+0.25 MHz + * K corresponds to b19-b0 of MAK + * A corresponds to b22-b20 of MAK + * M corresponds to b27-b23 of MAK + */ + uint32_t kHz_250_scaled = 8192; /* = 0.250*2^20/32 */ + uint32_t MAK = ((2402UL + 2UL * RF_Channel) << 15); + + if (Offset == 1U) + { + MAK += kHz_250_scaled; + } + else if (Offset == 2U) + { + MAK -= kHz_250_scaled; + } + else + { + /* MISRAC2012-Rule-15.7: explicit else; no action required */ + } + + uint8_t M = ((uint8_t)(MAK >> 23) & 0x1FU); + uint8_t A = ((uint8_t)(MAK >> 20) & 0x07U); + uint32_t K = (MAK & 0x000FFFFFUL) + 1UL; + +#if defined(STM32WB09) + if(PA_Level == HIGH_POWER_LEVEL_INDEX) + { + internal_pa_level = HIGH_POWER_LEVEL_INDEX - 1; + LDO_ANA_TST = RRM_LDO_ANA_TST_RFD_LDO_TRANSFO_BYPASS_Msk|RRM_LDO_ANA_TST_LDO_ANA_TST_SEL_Msk; + } +#endif + RRM->RADIO_FSM_USR = ((uint32_t)internal_pa_level << 3) | RRM_RADIO_FSM_USR_EN_CALIB_SYNTH_Msk | RRM_RADIO_FSM_USR_EN_CALIB_CBP_Msk; + RRM->MOD3_DIG_TST = ((uint32_t)M << 3) | ((uint32_t)A & 0x7UL); + RRM->MOD2_DIG_TST = (K >> 12) & 0xFFU; + RRM->MOD1_DIG_TST = (K >> 4) & 0xFFU; + RRM->MOD0_DIG_TST = ((K & 0x0FU) << 4) | 0x09U; + + /* Take control of the radio FSM through the test bus */ + RRM->DTB5_DIG_ENG = 0x09; + RRM_TEST = 0x03; + RRM->DTB5_DIG_ENG = 0x39; + while (RRM->FSM_STATUS_DIG_OUT != 0x04UL); + RRM->DTB5_DIG_ENG = 0x3B; +} + +void RADIO_ToneStop(void) +{ + /* Release control of the radio FSM through the test bus */ + RRM->DTB5_DIG_ENG = 0x00; + volatile uint32_t *rrm_udra_test = &RRM->RRM_CTRL + 0x01; + *rrm_udra_test = 0x00; + RRM->MOD0_DIG_TST = 0; +#if defined(STM32WB09) + LDO_ANA_TST = 0; +#endif +} + +/* Review with the use of linear values instead of dBm values to have more precision */ +static const int8_t rssi_ema_smoothing_factor_table[MAX_RSSI_FILTER_COEFF + 1] = { + 7, 5, 3, 2, 1 +}; + +int8_t RADIO_UpdateAvgRSSI(int8_t avg_rssi, int8_t rssi, uint8_t rssi_filter_coeff) +{ + if (avg_rssi == RSSI_INVALID) + { + return rssi; + } + + if ((rssi == RSSI_INVALID) || (rssi_filter_coeff > MAX_RSSI_FILTER_COEFF)) + { + return avg_rssi; + } + + return (avg_rssi + + (((rssi - avg_rssi) * rssi_ema_smoothing_factor_table[rssi_filter_coeff]) + >> RSSI_EMA_SMOOTH_FACTOR_BITS)); +} + +/* ---------- Utility functions for antenna switching ------------------------*/ + +void RADIO_AntIdxRemap(uint8_t AntPattLen, uint8_t *pAntRamTable, const uint8_t* pAntPatt) +{ +#if defined(STM32WB07) || defined(STM32WB06) || defined(STM32WB09) + for (uint8_t i=0; i 0x7F || Antenna_IDs & RESERVED_GPIOS || Antenna_ID_Shift > 7 || + Default_Antenna_ID > 0x7F || RF_Activity_Enable > 1) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + antenna_conf.Antenna_IDs = Antenna_IDs; + antenna_conf.Antenna_ID_Shift = Antenna_ID_Shift; + antenna_conf.Default_Antenna_ID = Default_Antenna_ID; + antenna_conf.RF_Activity_Enable = RF_Activity_Enable; + + LL_RADIO_SetDefaultAntennaID(Default_Antenna_ID); + + if(RF_Activity_Enable) + { + GPIO_Init.Pin |= GPIO_PIN_7; + } + + HAL_GPIO_Init(GPIOB, &GPIO_Init); + HAL_GPIO_WritePin(GPIOB, Antenna_IDs, GPIO_PIN_RESET); + + return BLE_STATUS_SUCCESS; +} +#else +tBleStatus aci_hal_set_antenna_switch_parameters(uint8_t Antenna_IDs, + uint8_t Antenna_ID_Shift, + uint8_t Default_Antenna_ID, + uint8_t RF_Activity_Enable) +{ + return BLE_ERROR_UNKNOWN_HCI_COMMAND; +} +#endif + +tBleStatus aci_hal_set_tx_power_level_preprocess(uint8_t En_High_Power, + uint8_t PA_Level) +{ + if((PA_Level > RADIO_GetMaxPALevel()) || (En_High_Power > 1)) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + + pa_level = PA_Level; + + return BLE_STATUS_SUCCESS; +} + +/* ---------- Utility functions for star ttone ------------------------*/ + +static bool LL_busy(void) +{ + uint8_t n_banks = ((CFG_BLE_NUM_RADIO_TASKS-1)/8+1); + uint8_t link_status[8]; + uint16_t link_connection_handles[8]; + + for(int i = 0; i < n_banks; i++) + { + aci_hal_get_link_status(i, link_status, link_connection_handles); + + for(int j = 0; j < 8; j++) + { + if(link_status[j] != LL_IDLE) + { + return TRUE; + } + } + } + + return FALSE; +} + +tBleStatus aci_hal_tone_start(uint8_t RF_Channel, uint8_t Offset) +{ + tBleStatus status; + + if (tone_started) /* already started before */ + { + status = BLE_ERROR_COMMAND_DISALLOWED; + } + else + { + if ((RF_Channel >= 40U) || (Offset > 2U)) + { /* channel ID must be from 0-39 */ + status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + else + { + if (LL_busy() == FALSE) + { + +#if defined(STM32WB07) || defined(STM32WB06) || defined(STM32WB09) + /* Set GPIOs for antenna switch in output mode. */ + GPIO_InitTypeDef GPIO_Init = { + .Pin = antenna_conf.Antenna_IDs, + .Mode = GPIO_MODE_OUTPUT_PP, + .Pull = GPIO_NOPULL, + .Speed = GPIO_SPEED_FREQ_LOW, + }; + + if(antenna_conf.RF_Activity_Enable) + { + GPIO_Init.Pin |= GPIO_PIN_7; + } + + HAL_GPIO_Init(GPIOB, &GPIO_Init); + + HAL_GPIO_WritePin(GPIOB, antenna_conf.Antenna_IDs, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, antenna_conf.Default_Antenna_ID & antenna_conf.Antenna_IDs, GPIO_PIN_SET); + + if(antenna_conf.RF_Activity_Enable) + { + /* Drive RF activity pin to enable the antenna switch. */ + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); + } +#endif + + RADIO_ToneStart(RF_Channel, Offset, pa_level); + tone_started = TRUE; + + status = BLE_STATUS_SUCCESS; + }else + { + status = BLE_ERROR_COMMAND_DISALLOWED; + } + } + } + + return status; +} + +tBleStatus aci_hal_tone_stop() +{ + tBleStatus status; + + if (tone_started) + { + RADIO_ToneStop(); + tone_started = FALSE; + +#if defined(STM32WB07) || defined(STM32WB06) || defined(STM32WB09) + aci_hal_set_antenna_switch_parameters(antenna_conf.Antenna_IDs, + antenna_conf.Antenna_ID_Shift, + antenna_conf.Default_Antenna_ID, + antenna_conf.RF_Activity_Enable); +#endif + status = BLE_STATUS_SUCCESS; + } + else + { + status = BLE_ERROR_COMMAND_DISALLOWED; + } + + return status; +} diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/RTDebug.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/RTDebug.c new file mode 100644 index 000000000..69731833b --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/RTDebug.c @@ -0,0 +1,55 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file RTDebug.c + * @author GPM WBL Application Team + * @brief Real Time Debug module API definition + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include "RTDebug.h" +#include "local_debug_tables.h" +#include "stm32wb0x_hal.h" +#include + +#if(RT_DEBUG_GPIO_MODULE == 1) +static_assert((sizeof(general_debug_table)/sizeof(st_gpio_debug_t)) == RT_DEBUG_SIGNALS_TOTAL_NUM, + "Debug signals number is different from debug signal table size." +); +#endif /* RT_DEBUG_GPIO_MODULE */ + +/***********************/ +/** System debug APIs **/ +/***********************/ + +void SYSTEM_DEBUG_SIGNAL_SET(system_debug_signal_t signal) +{ +#if(RT_DEBUG_GPIO_MODULE == 1) + GENERIC_DEBUG_GPIO_SET(signal, system_debug_table); +#endif /* RT_DEBUG_GPIO_MODULE */ +} + +void SYSTEM_DEBUG_SIGNAL_RESET(system_debug_signal_t signal) +{ +#if(RT_DEBUG_GPIO_MODULE == 1) + GENERIC_DEBUG_GPIO_RESET(signal, system_debug_table); +#endif /* RT_DEBUG_GPIO_MODULE */ +} + +void SYSTEM_DEBUG_SIGNAL_TOGGLE(system_debug_signal_t signal) +{ +#if(RT_DEBUG_GPIO_MODULE == 1) + GENERIC_DEBUG_GPIO_TOGGLE(signal, system_debug_table); +#endif /* RT_DEBUG_GPIO_MODULE */ +} diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/RTDebug.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/RTDebug.h new file mode 100644 index 000000000..72c4209e5 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/RTDebug.h @@ -0,0 +1,69 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file RTDebug.h + * @author GPM WBL Application Team + * @brief Real Time Debug module API declaration + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef SYSTEM_DEBUG_H +#define SYSTEM_DEBUG_H + +#include "debug_config.h" + +#if(RT_DEBUG_GPIO_MODULE == 1) + +/**************************************************************/ +/** Generic macros for local signal table index recuperation **/ +/** and global signal table GPIO manipulation **/ +/**************************************************************/ + +#define GENERIC_DEBUG_GPIO_SET(signal, table) do { \ + uint32_t debug_table_idx = table[signal]; \ + if(debug_table_idx != RT_DEBUG_SIGNAL_UNUSED) \ + { \ + HAL_GPIO_WritePin(general_debug_table[debug_table_idx].GPIO_port, \ + general_debug_table[debug_table_idx].GPIO_pin, \ + GPIO_PIN_SET); \ + } \ +} while(0) + +#define GENERIC_DEBUG_GPIO_RESET(signal, table) do { \ + uint32_t debug_table_idx = table[signal]; \ + if(debug_table_idx != RT_DEBUG_SIGNAL_UNUSED) \ + { \ + HAL_GPIO_WritePin(general_debug_table[debug_table_idx].GPIO_port, \ + general_debug_table[debug_table_idx].GPIO_pin, \ + GPIO_PIN_RESET); \ + } \ +} while(0) + +#define GENERIC_DEBUG_GPIO_TOGGLE(signal, table) do { \ + uint32_t debug_table_idx = table[signal]; \ + if(debug_table_idx != RT_DEBUG_SIGNAL_UNUSED) \ + { \ + HAL_GPIO_TogglePin(general_debug_table[debug_table_idx].GPIO_port, \ + general_debug_table[debug_table_idx].GPIO_pin); \ + } \ +} while(0) + +#endif /* RT_DEBUG_GPIO_MODULE */ + +/* System debug API definition */ +void SYSTEM_DEBUG_SIGNAL_SET(system_debug_signal_t signal); +void SYSTEM_DEBUG_SIGNAL_RESET(system_debug_signal_t signal); +void SYSTEM_DEBUG_SIGNAL_TOGGLE(system_debug_signal_t signal); + +#endif /* SYSTEM_DEBUG_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/debug_signals.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/debug_signals.h new file mode 100644 index 000000000..3f3799713 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/debug_signals.h @@ -0,0 +1,80 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file debug_signals.h + * @author GPM WBL Application Team + * @brief Real Time Debug module System and Link Layer signal definition + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef DEBUG_SIGNALS_H +#define DEBUG_SIGNALS_H + +/**********************************************/ +/** Specific System debug signals definition **/ +/**********************************************/ +typedef enum { + LOW_POWER_STOP_MODE_ENTER, + LOW_POWER_STOP_MODE_EXIT, + LOW_POWER_STOP_MODE_ACTIVE, + LOW_POWER_STANDBY_MODE_ENTER, + LOW_POWER_STANDBY_MODE_EXIT, + LOW_POWER_STANDBY_MODE_ACTIVE, +} system_debug_signal_t; + +#if(RT_DEBUG_GPIO_MODULE == 1) + +/*************************************/ +/** Global debug signals definition **/ +/*************************************/ + +typedef enum { + RT_DEBUG_SIGNAL_UNUSED = 0x0, + +/********************/ +/** System signals **/ +/********************/ + +#if (USE_RT_DEBUG_LOW_POWER_STOP_MODE_ENTER == 1) + RT_DEBUG_LOW_POWER_STOP_MODE_ENTER, +#endif /* USE_RT_DEBUG_LOW_POWER_STOP_MODE_ENTER */ + +#if (USE_RT_DEBUG_LOW_POWER_STOP_MODE_EXIT == 1) + RT_DEBUG_LOW_POWER_STOP_MODE_EXIT, +#endif /* USE_RT_DEBUG_LOW_POWER_STOP_MODE_EXIT */ + +#if (USE_RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE == 1) + RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE, +#endif /* USE_RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE */ + +#if (USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ENTER == 1) + RT_DEBUG_LOW_POWER_STANDBY_MODE_ENTER, +#endif /* USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ENTER */ + +#if (USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_EXIT == 1) + RT_DEBUG_LOW_POWER_STANDBY_MODE_EXIT, +#endif /* USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_EXIT */ + +#if (USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE == 1) + RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE, +#endif /* USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE */ + +#include "app_debug_signal_def.h" + + RT_DEBUG_SIGNALS_TOTAL_NUM +} rt_debug_signal_t; + +#endif /* RT_DEBUG_GPIO_MODULE */ + +#endif /* DEBUG_SIGNALS_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/local_debug_tables.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/local_debug_tables.h new file mode 100644 index 000000000..e6997beb1 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/RTDebug/local_debug_tables.h @@ -0,0 +1,72 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file local_debug_tables.h + * @author GPM WBL Application Team + * @brief Real Time Debug module System and Link Layer signal + correspondence tables + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef LOCAL_DEBUG_TABLES_H +#define LOCAL_DEBUG_TABLES_H + +#if(RT_DEBUG_GPIO_MODULE == 1) + +/*******************************/ +/** System local signal table **/ +/*******************************/ + +static const rt_debug_signal_t system_debug_table[] = { + +#if (USE_RT_DEBUG_LOW_POWER_STOP_MODE_ENTER == 1) + [LOW_POWER_STOP_MODE_ENTER] = RT_DEBUG_LOW_POWER_STOP_MODE_ENTER, +#else + [LOW_POWER_STOP_MODE_ENTER] = RT_DEBUG_SIGNAL_UNUSED, +#endif /* USE_RT_DEBUG_LOW_POWER_STOP_MODE_ENTER */ + +#if (USE_RT_DEBUG_LOW_POWER_STOP_MODE_EXIT == 1) + [LOW_POWER_STOP_MODE_EXIT] = RT_DEBUG_LOW_POWER_STOP_MODE_EXIT, +#else + [LOW_POWER_STOP_MODE_EXIT] = RT_DEBUG_SIGNAL_UNUSED, +#endif /* USE_RT_DEBUG_LOW_POWER_STOP_MODE_EXIT */ + +#if (USE_RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE == 1) + [LOW_POWER_STOP_MODE_ACTIVE] = RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE, +#else + [LOW_POWER_STOP_MODE_ACTIVE] = RT_DEBUG_SIGNAL_UNUSED, +#endif /* USE_RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE */ + +#if (USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ENTER == 1) + [LOW_POWER_STANDBY_MODE_ENTER] = RT_DEBUG_LOW_POWER_STANDBY_MODE_ENTER, +#else + [LOW_POWER_STANDBY_MODE_ENTER] = RT_DEBUG_SIGNAL_UNUSED, +#endif /* USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ENTER */ + +#if (USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_EXIT == 1) + [LOW_POWER_STANDBY_MODE_EXIT] = RT_DEBUG_LOW_POWER_STANDBY_MODE_EXIT, +#else + [LOW_POWER_STANDBY_MODE_EXIT] = RT_DEBUG_SIGNAL_UNUSED, +#endif /* USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_EXIT */ + +#if (USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE == 1) + [LOW_POWER_STANDBY_MODE_ACTIVE] = RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE, +#else + [LOW_POWER_STANDBY_MODE_ACTIVE] = RT_DEBUG_SIGNAL_UNUSED, +#endif /* USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE */ +}; + +#endif /* RT_DEBUG_GPIO_MODULE */ + +#endif /* LOCAL_DEBUG_TABLES_H*/ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/asm.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/asm.h new file mode 100644 index 000000000..641b73202 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/asm.h @@ -0,0 +1,77 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file asm.h + * @author GPM WBL Application Team + * @brief ASM Compiler-dependent macros. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef __ASM_H__ +#define __ASM_H__ + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +#if defined(__ICCARM__) || defined(__IAR_SYSTEMS_ASM__) +#define __CODE__ SECTION .text:CODE:REORDER:NOROOT(2) +#define __BSS__ SECTION .bss:DATA:NOROOT(2) +#define __EXPORT__ EXPORT +#define __IMPORT__ IMPORT +#define __THUMB__ THUMB +#define EXPORT_FUNC(f) f: +#define __END__ END +#define __SPACE__ DS8 +#define GLOBAL_VAR(val) val: +#define ENDFUNC +#define ALIGN_MEM(n) +#define LABEL(label) label: + +#elif defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)) +#define __CODE__ AREA |.text|, CODE, READONLY +#define __THUMB__ +#define EXPORT_FUNC(f) f PROC +#define __BSS__ AREA |.bss|, DATA, READWRITE, NOINIT +#define __EXPORT__ EXPORT +#define __IMPORT__ IMPORT +#define __SPACE__ SPACE +#define GLOBAL_VAR(val) val +#define __END__ END +#define ENDFUNC ENDP +#define ALIGN_MEM(n) ALIGN n +#define LABEL(label) label + +#elif defined(__GNUC__) +.syntax unified +.cpu cortex-m0 +.fpu softvfp +.thumb +#define __CODE__ .text +#define __BSS__ .bss +#define __EXPORT__ .global +#define __IMPORT__ .extern +#define __THUMB__ .thumb_func +#define __END__ .end +#define __SPACE__ .space +#define EXPORT_FUNC(f) f: +#define GLOBAL_VAR(val) val: +#define ENDFUNC +#define ALIGN_MEM(n) .align n>>1 +#define LABEL(label) label: + +#endif + +#endif /* DOXYGEN_SHOULD_SKIP_THIS */ +#endif /* __ASM_H__ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/blue_unit_conversion.s b/lib/stm32wb0/BLE_TransparentMode/System/Modules/blue_unit_conversion.s new file mode 100644 index 000000000..32a9b5d84 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/blue_unit_conversion.s @@ -0,0 +1,84 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file blue_unit_conversion.s + * @author GPM WBL Application Team + * @brief blue_unit_conversion implements the conversion from low speed oscillator + * independent units (STU) to low speed oscillator dependent units (MTU) and + * vice-versa according to the input parameters. + * The first parameter is the quantity to be translated expressed in STU or MTU. + * The second parameter is the frequency or the period. + * The third parameter is a threshold to switch to 32 bit multiplication. + * This routine avoids floating divisions exploiting only integer math, maintaining + * a good rounding error as well. + * It embeds a long multiplication algorithm suited for this purpose. + * The threshold passed as parameter allows performing a simple 32bit multiplication + * instead of long multiplication, saving computational time for small quantities + * (when it is needed that the conversion is done as fast as possible). + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "asm.h" + + __CODE__ + __THUMB__ + __EXPORT__ blue_unit_conversion + +EXPORT_FUNC(blue_unit_conversion) + PUSH {r4, lr} + CMP r0, r2 + BLS mul32 + UXTH r2, r1 + LSRS r3, r0, #16 + LSRS r1, r1, #16 + MOV r4, r1 + MULS r1, r3, r1 + UXTH r0, r0 + MULS r3, r2, r3 + MULS r4, r0, r4 + MULS r0, r2, r0 + ADDS r3, r3, r4 + LSLS r2, r3, #16 + LSRS r3, r3, #16 + ADDS r0, r2, r0 + ADCS r1, r3 + + MOVS r2, #128 + LSLS r2, r2, #13 + MOVS r3, #0 + ADDS r2, r2, r0 + ADCS r3, r1 + LSRS r2, r2, #21 + LSLS r0, r3, #11 + ORRS r0, r2 + + POP {r4, pc} + + ENDFUNC + +EXPORT_FUNC(mul32) + MULS r0, r1, r0 + MOVS r2, #128 + LSLS r2, r2, #13 + ADDS r2, r2, r0 + LSRS r2, r2, #21 + MOV r0, r2 + + POP {r4, pc} + + ENDFUNC + + ALIGN_MEM(4) + __END__ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/compiler.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/compiler.h new file mode 100644 index 000000000..f31e17b31 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/compiler.h @@ -0,0 +1,384 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file compiler.h + * @author GPM WBL Application Team + * @brief Compiler-dependent macros. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef __COMPILER_H__ +#define __COMPILER_H__ + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +#define QUOTEME(a) #a + +#define FUNCTION_PROTOTYPE(func_name, ret_type, ...) ret_type func_name(__VA_ARGS__); + +/** @addtogroup compiler_macros compiler macros + * @{ + */ + +/** @addtogroup IAR_toolchain_macros IAR toolchain macros + * @{ + */ + +/** + * @brief This is the section dedicated to IAR toolchain + */ +#if defined(__ICCARM__) || defined(__IAR_SYSTEMS_ASM__) + +/** + * @brief PACKED + * Use the PACKED macro for variables that needs to be packed. + * Usage: PACKED(struct) myStruct_s + * PACKED(union) myStruct_s + */ +#define PACKED(decl) __packed decl + +/** + * @brief REQUIRED + * Use the REQUIRED macro for variables that must be always included. + * Usage: REQUIRED(static uint8_t my_array[16]) + * REQUIRED(static int my_int) + */ +#define REQUIRED(decl) __root decl + +/** + * @brief NORETURN_FUNCTION + * Use the NORETURN_FUNCTION macro to declare a no return function. + * Usage: NORETURN_FUNCTION(void my_noretrun_function(void)) + */ +#define NORETURN_FUNCTION(function) __noreturn function + +/** + * @brief NOSTACK_FUNCTION + * Use the NOSTACK_FUNCTION macro to indicate that function should not use any stack. + * Typical usage is for hard fault handler, to avoid altering the value of the stack pointer. + * Usage: NOSTACK_FUNCTION(void my_noretrun_function(void)) + */ +#define NOSTACK_FUNCTION(function) __stackless function + +/** + * @brief SECTION + * Use the SECTION macro to assign data or code in a specific section. + * Usage: SECTION(".my_section") + */ +#define SECTION(name) _Pragma(QUOTEME(location=name)) + +/** + * @brief ALIGN + * Use the ALIGN macro to specify the alignment of a variable. + * Usage: ALIGN(4) + */ +#define ALIGN(v) _Pragma(QUOTEME(data_alignment=v)) + +/** + * @brief WEAK_FUNCTION + * Use the WEAK_FUNCTION macro to declare a weak function. + * Usage: WEAK_FUNCTION(int my_weak_function(void)) + */ +#define WEAK_FUNCTION(function) __weak function + +/** + * @brief WEAK_ALIAS_FUNCTION + * Use the WEAK_ALIAS_FUNCTION macro to declare a weak alias of a function. + * Usage: WEAK_ALIAS_FUNCTION(my_weak_alias_function, my_function, , ) + */ +#define WEAK_ALIAS_FUNCTION(new_name, old_name, ...) _Pragma(QUOTEME(weak new_name=old_name)) + +/** + * @brief NO_INIT + * Use the NO_INIT macro to declare a not initialized variable in RAM + * Usage: NO_INIT(int my_no_init_var) + * Usage: NO_INIT(uint16_t my_no_init_array[10]) + */ +#define NO_INIT(var) __no_init var + +/** + * @brief NO_INIT_SECTION + * Use the NO_INIT_SECTION macro to declare a not initialized variable in RAM in + * in a specific section. + * Usage: NO_INIT_SECTION(int my_no_init_var, "MySection") + * Usage: NO_INIT_SECTION(uint16_t my_no_init_array[10], "MySection") + */ +#define NO_INIT_SECTION(var, sect) SECTION(sect) __no_init var + +/** + * @brief NO_INLINE + * This function attribute suppresses the inlining of a function at the call points of the function. + * Usage: NO_INLINE(void my_noinline_function(void)) + */ +#define NO_INLINE(function) _Pragma(QUOTEME(optimize=no_inline)) function + +#define VARIABLE_SIZE 0 +#pragma segment = "CSTACK" +#define _INITIAL_SP __sfe( "CSTACK" ) /* Stack address */ +extern void __iar_program_start(void); +#define RESET_HANDLER __iar_program_start + +/** + * @} + */ + +/** @addtogroup Keil_toolchain_macros Keil toolchain macros + * @{ + */ + +/** + * @brief This is the section dedicated to Keil toolchain + */ +#else +#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)) + +/** + * @brief PACKED + * Use the PACKED macro for variables that needs to be packed. + * Usage: PACKED(struct) myStruct_s + * PACKED(union) myStruct_s + */ +#define PACKED(decl) decl __attribute__((packed)) + +/** + * @brief REQUIRED + * Use the REQUIRED macro for variables that must be always included. + * Usage: REQUIRED(static uint8_t my_array[16]) + * REQUIRED(static int my_int) + */ +#ifndef REQUIRED + #define REQUIRED(decl) decl __attribute__((used)) +#endif + +/** + * @brief SECTION + * Use the SECTION macro to assign data or code in a specific section. + * Usage: SECTION(".my_section") + */ +#define SECTION(name) __attribute__((section(name))) + +/** + * @brief ALIGN + * Use the ALIGN macro to specify the alignment of a variable. + * Usage: ALIGN(4) + */ +#define ALIGN(N) __attribute__((aligned(N))) + +/** + * @brief WEAK_ALIAS_FUNCTION + * Use the WEAK_ALIAS_FUNCTION macro to declare a weak alias of a function. + * Usage: WEAK_ALIAS_FUNCTION(my_weak_alias_function, my_function, , ) + */ +#define WEAK_ALIAS_FUNCTION(new_name, old_name, ...) \ + __attribute__((weak, alias(QUOTEME(old_name)))) FUNCTION_PROTOTYPE(new_name, __VA_ARGS__) + +/** + * @brief NORETURN_FUNCTION + * Use the NORETURN_FUNCTION macro to declare a no return function. + * Usage: NORETURN_FUNCTION(void my_noretrun_function(void)) + */ +#define NORETURN_FUNCTION(function) __attribute__((noreturn)) function + +/** + * @brief NOSTACK_FUNCTION + * Use the NOSTACK_FUNCTION macro to indicate that function should not use any stack. + * Typical usage is for hard fault handler, to avoid altering the value of the stack pointer. + * In keil this is a dummy implementation since no equivalent function is available + * Usage: NOSTACK_FUNCTION(void my_noretrun_function(void)) + */ +#define NOSTACK_FUNCTION(function) function + +/** + * @brief NO_INLINE + * This function attribute suppresses the inlining of a function at the call points of the function. + * Usage: NO_INLINE(void my_noinline_function(void)) + */ +#define NO_INLINE(function) __attribute__((noinline)) function + +#if defined(__CC_ARM) +/** + * @brief WEAK_FUNCTION + * Use the WEAK_FUNCTION macro to declare a weak function. + * Usage: WEAK_FUNCTION(int my_weak_function(void)) + */ +#define WEAK_FUNCTION(function) __weak function + +/** + * @brief NO_INIT + * Use the NO_INIT macro to declare a not initialized variable. + * Usage: NO_INIT(int my_no_init_var) + * Usage: NO_INIT(uint16_t my_no_init_array[10]) + */ +#define NO_INIT(var) var __attribute__((section( ".noinit.data" ), zero_init)) + +/** + * @brief NO_INIT_SECTION + * Use the NO_INIT_SECTION macro to declare a not initialized variable that should be placed in a specific section. + * Linker script is in charge of placing that section in RAM. + * Usage: NO_INIT_SECTION(int my_no_init_var, "MySection") + * Usage: NO_INIT_SECTION(uint16_t my_no_init_array[10], "MySection") + */ +#define NO_INIT_SECTION(var, sect) var __attribute__((section( sect ), zero_init)) +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) +/** + * @brief WEAK_FUNCTION + * Use the WEAK_FUNCTION macro to declare a weak function. + * Usage: WEAK_FUNCTION(int my_weak_function(void)) + */ +#define WEAK_FUNCTION(function) __attribute__((weak)) function + +/** + * @brief NO_INIT + * Use the NO_INIT macro to declare a not initialized variable. + * Usage: NO_INIT(int my_no_init_var) + * Usage: NO_INIT(uint16_t my_no_init_array[10]) + */ +#define NO_INIT(var) var __attribute__((section(".bss.noinit.data"))) + +/** + * @brief NO_INIT_SECTION + * Use the NO_INIT_SECTION macro to declare a not initialized variable that should be placed in a specific section. + * Linker script is in charge of placing that section in RAM. + * Usage: NO_INIT_SECTION(int my_no_init_var, "MySection") + * Usage: NO_INIT_SECTION(uint16_t my_no_init_array[10], "MySection") + */ +#define NO_INIT_SECTION(var, sect) var __attribute__((section(".bss" sect))) + +#endif + +extern void __main(void); +extern int main(void); +extern unsigned int Image$$ARM_LIB_STACK$$ZI$$Limit; +#define _INITIAL_SP (void(*)(void))&Image$$ARM_LIB_STACK$$ZI$$Limit /* Stack address */ +#define VARIABLE_SIZE 1 + +/** + * @} + */ + +/** @addtogroup GCC_toolchain_macros GCC toolchain macros + * @{ + */ + +/** + * @brief This is the section dedicated to GCC toolchain + */ +#else +#ifdef __GNUC__ + +/** + * @brief PACKED + * Use the PACKED macro for variables that needs to be packed. + * Usage: PACKED(struct) myStruct_s + * PACKED(union) myStruct_s + */ +#define PACKED(decl) decl __attribute__((packed)) + +/** + * @brief REQUIRED + * Use the REQUIRED macro for variables that must be always included. + * Usage: REQUIRED(static uint8_t my_array[16]) + * REQUIRED(static int my_int) + */ +#define REQUIRED(var) var __attribute__((used)) + +/** + * @brief SECTION + * Use the SECTION macro to assign data or code in a specific section. + * Usage: SECTION(".my_section") + */ +#define SECTION(name) __attribute__((section(name))) + +/** + * @brief ALIGN + * Use the ALIGN macro to specify the alignment of a variable. + * Usage: ALIGN(4) + */ +#define ALIGN(N) __attribute__((aligned(N))) + +/** + * @brief WEAK_FUNCTION + * Use the WEAK_FUNCTION macro to declare a weak function. + * Usage: WEAK_FUNCTION(int my_weak_function(void)) + */ +#define WEAK_FUNCTION(function) __attribute__((weak)) function + +/** + * @brief WEAK_ALIAS_FUNCTION + * Use the WEAK_ALIAS_FUNCTION macro to declare a weak alias of a function. + * Usage: WEAK_ALIAS_FUNCTION(my_weak_alias_function, my_function, , ) + */ +#define WEAK_ALIAS_FUNCTION(new_name, old_name, ...) \ + __attribute__((weak, alias(QUOTEME(old_name)))) FUNCTION_PROTOTYPE(new_name, __VA_ARGS__) + +/** + * @brief NORETURN_FUNCTION + * Use the NORETURN_FUNCTION macro to declare a no return function. + * Usage: NORETURN_FUNCTION(void my_noretrun_function(void)) + */ +#define NORETURN_FUNCTION(function) __attribute__((noreturn)) function + +/** + * @brief NOSTACK_FUNCTION + * Use the NOSTACK_FUNCTION macro to indicate that function should not use any stack. + * Typical usage is for hard fault handler, to avoid altering the value of the stack pointer. + * In keil this is a dummy implementation since no equivalent function is available + * Usage: NOSTACK_FUNCTION(void my_noretrun_function(void)) + */ +#define NOSTACK_FUNCTION(function) function + +/** + * @brief NO_INIT + * Use the NO_INIT macro to declare a not initialized variable placed in RAM + * Linker script has to make sure that section ".noinit" is not initialized + * Usage: NO_INIT(int my_no_init_var) + * Usage: NO_INIT(uint16_t my_no_init_array[10]) + */ +#define NO_INIT(var) var __attribute__((section(".noinit"))) + +/** + * @brief NO_INIT_SECTION + * Use the NO_INIT_SECTION macro to declare a not initialized variable. + * In order to work properly this macro should be aligned with the linker file. + * Usage: NO_INIT_SECTION(int my_no_init_var, "MySection") + * Usage: NO_INIT_SECTION(uint16_t my_no_init_array[10], "MySection") + */ +#define NO_INIT_SECTION(var, sect) var __attribute__((section(sect))) + +/** + * @brief NO_INLINE + * This function attribute suppresses the inlining of a function at the call points of the function. + * Usage: NO_INIT_SECTION(void my_noinline_function(void)) + */ +#define NO_INLINE(function) __attribute__((noinline)) function + +#define _INITIAL_SP (void(*)(void))(&_estack) +#define VARIABLE_SIZE 0 + +#else + +#error Neither ICCARM, CC ARM nor GNUC C detected. Define your macros. + +#endif +#endif +#endif + +/** + * @} + */ + +#endif /* DOXYGEN_SHOULD_SKIP_THIS */ +#endif /* __COMPILER_H__ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/crash_handler.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/crash_handler.h new file mode 100644 index 000000000..aa9f3db34 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/crash_handler.h @@ -0,0 +1,147 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file crash_handler.h + * @author GPM WBL Application Team + * @brief This header file defines the crash handler framework useful for + * application issues debugging + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef __CRASH_HANDLER_H_ +#define __CRASH_HANDLER_H_ + +#include +#include +#include "cmsis_compiler.h" + +/** + * @brief Number of word for the Exception RAM Locations + */ +#define NMB_OF_EXCEP_RAM_WORD 10 + +/** + * @brief Base address to store the Crash Information + */ +#define CRASH_RAM_SIZE 40 + +/** + * @brief Signature Information: CRASH_SIGNATURE_BASE + */ +#define CRASH_SIGNATURE_BASE 0xBCEC0000 +/** + * @brief Signature Information: ASSERT_SIGNATURE + */ +#define ASSERT_SIGNATURE (CRASH_SIGNATURE_BASE + 0) +/** + * @brief Signature Information: NMI_SIGNATURE + */ +#define NMI_SIGNATURE (CRASH_SIGNATURE_BASE + 1) +/** + * @brief Signature Information: HARD_FAULT_SIGNATURE + */ +#define HARD_FAULT_SIGNATURE (CRASH_SIGNATURE_BASE + 2) +/** + * @brief Signature Information: WATCHDOG_SIGNATURE + */ +#define WATCHDOG_SIGNATURE (CRASH_SIGNATURE_BASE +3) + +/** + * @brief Typedef for the overall crash information (stack pointer, program counter, registers, ...) + */ +typedef struct crash_infoS { + uint32_t signature; + uint32_t SP; + uint32_t R0; + uint32_t R1; + uint32_t R2; + uint32_t R3; + uint32_t R12; + uint32_t LR; + uint32_t PC; + uint32_t xPSR; +} crash_info_t; + +extern crash_info_t crash_info_ram; + +/** + * @brief Macro to store in RAM the register information where an assert is verified. + * + * All the information stored are words (32 bit): + * - Assert Signature + * - SP + * - R0 + * - R1 + * - R2 + * - R3 + * - R12 + * - LR + * - PC + * - xPSR + */ +#define ASSERT_HANDLER(expression) { \ + volatile uint32_t * crash_info = (volatile uint32_t *)&crash_info_ram; \ + register uint32_t reg_content; \ + if (!(expression)) { \ + /* Init to zero the crash_info RAM locations */ \ + for (reg_content=0; reg_contentdie_id = DIE_SW_ID_UNKOWN; + + jtag_id = LL_SYSCFG_GetDeviceJTAG_ID(); + +#if defined(STM32WB09) + if(jtag_id == JTAG_ID_CODE_STM32WB09XX) + { + partInfo->die_id = DIE_SW_ID_STM32WB09XX; + } +#elif defined(STM32WB07) || defined(STM32WB06) + if(jtag_id == JTAG_ID_CODE_STM32WB07XX) + { + partInfo->die_id = DIE_SW_ID_STM32WB07XX; + } +#elif defined(STM32WB05) + if(jtag_id == JTAG_ID_CODE_STM32WB05XX) + { + partInfo->die_id = DIE_SW_ID_STM32WB05XX; + } +#endif + + partInfo->die_major = LL_SYSCFG_GetDeviceVersion(); + partInfo->die_cut = LL_SYSCFG_GetDeviceRevision(); + partInfo->jtag_id_code = LL_SYSCFG_GetDeviceJTAG_ID(); // Duplicated + partInfo->flash_size = (LL_GetFlashSize() + 1) * 4; + + if (LL_GetRAMSize() != LL_UTILS_RAMSIZE_24K) + { + partInfo->ram_size = (LL_GetRAMSize() + 1) * 16 * 1024; + } + else + { + partInfo->ram_size = 24*1024; + } + +} + +/** + * @brief Get Crash Information utility + */ +void GetCrashInfo(crash_info_t *crashInfo) +{ + *crashInfo = CrashInfoRam; + /* Reset crash info value */ + CrashInfoRam.signature = 0; +} +void CrashHandler(uint32_t msp, uint32_t signature) +{ + volatile uint32_t * crash_info = (volatile uint32_t *)&CrashInfoRam; + register uint32_t reg_content; + /* Init to zero the crash_info RAM locations */ + for (reg_content=0; reg_content= ((uint32_t *) _MEMORY_RAM_BEGIN_)) && + (ptr <= ((uint32_t *) _MEMORY_RAM_END_))) + crash_info[reg_content] = *ptr; + } + NVIC_SystemReset(); +} + +uint8_t GetDemodCI(void) +{ + /* Read the CI from the demodulator register */ + uint8_t demod_ci = (RRM->DEMOD_DIG_OUT) & 0x03U; + + /* Remap to the standard compliant values */ + uint8_t std_ci = (demod_ci == 0x02U ? 0x01U : 0x00U); + + return std_ci; +} + +/** + *@ +} */ /* End of group Miscellaneous_Utilities */ + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/miscutil.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/miscutil.h new file mode 100644 index 000000000..d2e8ba308 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/miscutil.h @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file miscutil.h + * @author GPM WBL Application Team + * @brief Header file for HW miscellaneous utilities. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef __MISCUTIL_H__ +#define __MISCUTIL_H__ + +#include +#include "crash_handler.h" +#include "stm32wb0x.h" + +#if defined(STM32WB09) +#define DIE_SW_ID_STM32WB09XX ((uint8_t)6) +#define JTAG_ID_CODE_STM32WB09XX ((uint32_t)0x02032041) +#elif defined(STM32WB07) || defined(STM32WB06) +#define DIE_SW_ID_STM32WB07XX ((uint8_t)3) +#define JTAG_ID_CODE_STM32WB07XX ((uint32_t)0x0201E041) +#elif defined(STM32WB05) +#define DIE_SW_ID_STM32WB05XX ((uint8_t)5) +#define JTAG_ID_CODE_STM32WB05XX ((uint32_t)0x02028041) +#endif + +#define DIE_SW_ID_UNKOWN ((uint8_t)0xFF) + +/** + * @brief A structure that represents part information details + * + */ +typedef struct PartInfoS { + /** DIE ID number */ + uint8_t die_id; + /** Die major number */ + uint8_t die_major; + /** Die cut number */ + uint8_t die_cut; + /** JTAG ID */ + uint32_t jtag_id_code; + /** Flash size in bytes */ + uint32_t flash_size; + /** Flash size in bytes */ + uint32_t ram_size; +} PartInfoType; + +/** + * @brief This function return a structure with information about the device + * + * @param[out] partInfo Pointer to a PartInfoType structure + * + * @retval None + */ +void GetPartInfo(PartInfoType *partInfo); +/** + * @brief Get Crash Information utility + * + * This function return the crash information that are stored in RAM, by hard + * handler, nmi handler and assert handler. + * This function reset the crash information stored in RAM before it returns. + * So it avoid to report the same crash information after a normal reboot. + * + * @param[out] crashInfo Pointer to a crash_info_t structure + * + * @retval None + */ +void GetCrashInfo(crash_info_t *crashInfo); +/** + * @brief Set Crash Information utility + * + * This function stores crash information in RAM and reset the device + * Crash information can be retrieved by using API HAL_GetCrashInfo + * + * @param[in] msp Stack pointer containing crash info + * @param[out] signature CRash reason signature + * + * @retval None + */ +void CrashHandler(uint32_t msp, uint32_t signature); + +/** + * @brief Read CI field from demodulation register + * + * @param[in] None + * + * @retval CI value + */ +uint8_t GetDemodCI(void); + +#endif /* __MISCUTIL_H__ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal.c new file mode 100644 index 000000000..c9bff0995 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal.c @@ -0,0 +1,38 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file osal.c + * @author GPM WBL Application Team + * @brief osal APIs + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifdef __GNUC__ +#pragma GCC optimize ("-Os") +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include "osal.h" + +/** + * A version of the memcpy that only uses 32-bit accesses. + * dest and src must be 32-bit aligned and size must be a multiple of 4. + */ +void Osal_MemCpy4(uint32_t *dest, const uint32_t *src, unsigned int size) +{ + for (unsigned int i = 0; i < size/4; i++) + dest[i] = src[i]; +} + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal.h new file mode 100644 index 000000000..0e342fdf0 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal.h @@ -0,0 +1,63 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file osal.h + * @author GPM WBL Application Team + * @brief This header file defines the OS abstraction layer. OSAL defines the + * set of functions which needs to be ported to target operating + * system and target platform. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __OSAL_H__ +#define __OSAL_H__ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Function Prototypes + *****************************************************************************/ + +/** + * @brief This function copies size number of bytes from a + * memory location pointed by src to a destination + * memory location pointed by dest. The locations must not overlap. + * + * @param[out] dest Destination address + * @param[in] src Source address + * @param[in] size Number of bytes to copy + */ + +extern void Osal_MemCpy(void *dest, const void *src, unsigned int size); + +/** + * @brief This function copies a given number of bytes, multiple of 4, from a + * memory location pointed by src to a destination memory location pointed by + * dest, by using only 32-bit accesses. The locations must not overlap. + * + * @param[out] dest Destination address. It must be 32-bit aligned. + * @param[in] src Source address. It must be 32-bit aligned. + * @param[in] size Number of bytes to copy. It must be a multiple of 4. + */ +extern void Osal_MemCpy4(uint32_t *dest, const uint32_t *src, unsigned int size); + +#endif /* __OSAL_H__ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal_memcpy.s b/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal_memcpy.s new file mode 100644 index 000000000..2aa0ca557 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal_memcpy.s @@ -0,0 +1,140 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file osal_memcpy.s + * @author GPM WBL Application Team + * @brief osal memcpy utilities + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "asm.h" + + __CODE__ + __THUMB__ + __EXPORT__ Osal_MemCpy + +EXPORT_FUNC(Osal_MemCpy) + LSLS R3, R1, #30 + BEQ memcpy_1 +LABEL(memcpy_byte) /* Copy bytes until src is aligned */ + SUBS R2, R2, #1 + BCC memcpy_exit + LDRB R3, [R1] + ADDS R1, R1, #1 + STRB R3, [R0] + ADDS R0, R0, #1 + LSLS R3, R1, #30 + BNE memcpy_byte +LABEL(memcpy_1) + LSLS R3, R0, #30 + BEQ memcpy4 + CMN R3, R3 + BEQ memcpy_7 + SUBS R0, R0, #1 + SUBS R2, R2, #4 + BCC memcpy_3 +LABEL(memcpy_2) /* Load one word from src and write one byte, one half-word and another byte to dst */ + LDM R1!, {R3} + STRB R3, [R0, #1] + LSRS R3, R3, #8 + STRH R3, [R0, #2] + LSRS R3, R3, #16 + STRB R3, [R0, #4] + ADDS R0, R0, #4 + SUBS R2, R2, #4 + BCS memcpy_2 +LABEL(memcpy_3) + LSLS R2, R2, #31 + BCC memcpy_5 + LDRH R3, [R1] + STRB R3, [R0, #1] + BEQ memcpy_4 + LDRB R2, [R1, #2] + STRB R2, [R0, #3] +LABEL(memcpy_4) + LSRS R3, R3, #8 + STRB R3, [R0, #2] + BX LR +LABEL(memcpy_5) + BEQ memcpy_exit + LDRB R3, [R1] + STRB R3, [R0, #1] +LABEL(memcpy_exit) + BX LR +LABEL(memcpy_7) + SUBS R2, R2, #4 + BCC memcpy_9 +LABEL(memcpy_8) /* Load one word from src and write half-words to dst */ + LDM R1!, {R3} + STRH R3, [R0] + LSRS R3, R3, #16 + STRH R3, [R0, #2] + ADDS R0, R0, #4 + SUBS R2, R2, #4 + BCS memcpy_8 +LABEL(memcpy_9) + LSLS R2, R2, #31 + BCC memcpy_10 + LDRH R3, [R1] + STRH R3, [R0] + BEQ memcpy_11 + LDRB R3, [R1, #2] + STRB R3, [R0, #2] + BX LR +LABEL(memcpy_10) + BEQ memcpy_11 + LDRB R3, [R1] + STRB R3, [R0] +LABEL(memcpy_11) + BX LR + +LABEL(memcpy4) + PUSH {R4-R6} + SUBS R2, #16 + BCC memcpy4_2words +LABEL(memcpy4_4words) + LDM R1!, {R3-R6} + STM R0!, {R3-R6} + SUBS R2, #16 + BCS memcpy4_4words +LABEL(memcpy4_2words) + LSLS R3, R2, #29 + BCC memcpy4_word + LDM R1!, {R3, R4} + STM R0!, {R3, R4} +LABEL(memcpy4_word) + BPL memcpy4_halfword + LDM R1!, {R3} + STM R0!, {R3} +LABEL(memcpy4_halfword) + LSLS R2, R2, #31 + BCC memcpy4_byte + LDRH R3, [R1] + STRH R3, [R0] + ADDS R0, R0, #2 + ADDS R1, R1, #2 + CMP R2, #0 +LABEL(memcpy4_byte) + BPL memcpy4_exit + LDRB R3, [R1] + STRB R3, [R0] +LABEL(memcpy4_exit) + POP {R4-R6} + BX LR + + ENDFUNC + + ALIGN_MEM(4) + __END__ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/stm_list.c b/lib/stm32wb0/BLE_TransparentMode/System/Modules/stm_list.c new file mode 100644 index 000000000..e8a1371c5 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/stm_list.c @@ -0,0 +1,200 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm_list.c + * @author GPM WBL Application Team + * @brief Circular Linked List Implementation. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/****************************************************************************** + * Include Files + ******************************************************************************/ +#include "utilities_common.h" + +#include "stm_list.h" + +/****************************************************************************** + * Function Definitions + ******************************************************************************/ +void LST_init_head (tListNode * listHead) +{ + listHead->next = listHead; + listHead->prev = listHead; +} + +uint8_t LST_is_empty (tListNode * listHead) +{ + uint32_t primask_bit; + uint8_t return_value; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + if(listHead->next == listHead) + { + return_value = TRUE; + } + else + { + return_value = FALSE; + } + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return return_value; +} + +void LST_insert_head (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead->next; + node->prev = listHead; + listHead->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +void LST_insert_tail (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead; + node->prev = listHead->prev; + listHead->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +void LST_remove_node (tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + (node->prev)->next = node->next; + (node->next)->prev = node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +void LST_remove_head (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->next; + LST_remove_node (listHead->next); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +void LST_remove_tail (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->prev; + LST_remove_node (listHead->prev); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +void LST_insert_node_after (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node->next; + node->prev = ref_node; + ref_node->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +void LST_insert_node_before (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node; + node->prev = ref_node->prev; + ref_node->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +int LST_get_size (tListNode * listHead) +{ + int size = 0; + tListNode * temp; + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + temp = listHead->next; + while (temp != listHead) + { + size++; + temp = temp->next; + } + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return (size); +} + +void LST_get_next_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->next; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +void LST_get_prev_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/stm_list.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/stm_list.h new file mode 100644 index 000000000..c701286e2 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/stm_list.h @@ -0,0 +1,56 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm_list.h + * @author GPM WBL Application Team + * @brief Header file for linked list library. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef STM_LIST_H +#define STM_LIST_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32_ble_common.h" + +typedef __PACKED_STRUCT _tListNode { + struct _tListNode * next; + struct _tListNode * prev; +} tListNode; + +void LST_init_head (tListNode * listHead); + +uint8_t LST_is_empty (tListNode * listHead); + +void LST_insert_head (tListNode * listHead, tListNode * node); + +void LST_insert_tail (tListNode * listHead, tListNode * node); + +void LST_remove_node (tListNode * node); + +void LST_remove_head (tListNode * listHead, tListNode ** node ); + +void LST_remove_tail (tListNode * listHead, tListNode ** node ); + +void LST_insert_node_after (tListNode * node, tListNode * ref_node); + +void LST_insert_node_before (tListNode * node, tListNode * ref_node); + +int LST_get_size (tListNode * listHead); + +void LST_get_next_node (tListNode * ref_node, tListNode ** node); + +void LST_get_prev_node (tListNode * ref_node, tListNode ** node); + +#endif /* STM_LIST_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/utilities_common.h b/lib/stm32wb0/BLE_TransparentMode/System/Modules/utilities_common.h new file mode 100644 index 000000000..ede3af71c --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Modules/utilities_common.h @@ -0,0 +1,137 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file utilities_common.h + * @author GPM WBL Application Team + * @brief Common file to utilities + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UTILITIES_COMMON_H +#define UTILITIES_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +#include "app_conf.h" + + /* -------------------------------- * + * Basic definitions * + * -------------------------------- */ + +#undef NULL +#define NULL 0 + +#undef FALSE +#define FALSE 0 + +#undef TRUE +#define TRUE (!0) + + /* -------------------------------- * + * Critical Section definition * + * -------------------------------- */ +#undef BACKUP_PRIMASK +#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK() + +#undef DISABLE_IRQ +#define DISABLE_IRQ() __disable_irq() + +#undef RESTORE_PRIMASK +#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit) + + /* -------------------------------- * + * Macro delimiters * + * -------------------------------- */ +#undef M_BEGIN +#define M_BEGIN do { + +#undef M_END +#define M_END } while(0) + + /* -------------------------------- * + * Some useful macro definitions * + * -------------------------------- */ +#undef MAX +#define MAX( x, y ) (((x)>(y))?(x):(y)) + +#undef MIN +#define MIN( x, y ) (((x)<(y))?(x):(y)) + +#undef MODINC +#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END + +#undef MODDEC +#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END + +#undef MODADD +#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END + +#undef MODSUB +#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m ) + +#undef PAUSE +#define PAUSE( t ) M_BEGIN \ + volatile int _i; \ + for ( _i = t; _i > 0; _i -- ); \ + M_END +#undef DIVF +#define DIVF( x, y ) ((x)/(y)) + +#undef DIVC +#define DIVC( x, y ) (((x)+(y)-1)/(y)) + +#undef DIVR +#define DIVR( x, y ) (((x)+((y)/2))/(y)) + +#undef SHRR +#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1) + +#undef BITN +#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1) + +#undef BITNSET +#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END + +/* -------------------------------- * + * Section attribute * + * -------------------------------- */ +#define PLACE_IN_SECTION( __x__ ) __attribute__((used, section (__x__))) + +#ifdef __cplusplus +} +#endif + +#define SYS_WAITING_CYCLES_25() do {\ + __asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");\ + __asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");\ + __asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");\ + __asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");\ + __asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");__asm("mov r0, r0");\ + } while(0) + +#define SYS_WAITING_RNGCLK_DEACTIVATION() do {\ + for(volatile unsigned int cpt = 178 ; cpt!=0 ; --cpt);\ + } while(0) + +#endif /* UTILITIES_COMMON_H */ + diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Startup/cpu_context_switch.s b/lib/stm32wb0/BLE_TransparentMode/System/Startup/cpu_context_switch.s new file mode 100644 index 000000000..68b50ada5 --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Startup/cpu_context_switch.s @@ -0,0 +1,100 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file cpu_context_switch.s + * @author GPM WBL Application Team + * @brief cpu_context_switch implements the CPU context switch + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#include "../Modules/asm.h" + +//------------------------------------------------------------------------------ +// void CS_contextSave(void) +// void CS_contextRestore(void) +// +// These two functions are needed for the context switch during the power +// save procedure. The purpose of the CS_contextSave() function is to +// either save the current context and trigger sleeping through the 'WFI' +// instruction. +// The CS_contextRestore() function restores the context saved before +// to go in deep sleep. +// All the Cortex M0+ registers are saved and restored plus after wakeup +// ----------------------------------------------------------------------------- + __CODE__ + __THUMB__ + __EXPORT__ CPUcontextSave + __EXPORT__ CPUcontextRestore + __IMPORT__ RAM_VR +EXPORT_FUNC(CPUcontextSave) + MRS R2, CONTROL /* load the CONTROL register into R2 */ + MRS R1, PSP /* load the process stack pointer into R1 */ + LDR R0, =0 + MSR CONTROL, R0 /* Switch to Main Stack Pointer */ + ISB + + PUSH { r4 - r7, lr } /* store R4-R7 and LR (5 words) onto the stack */ + MOV R3, R8 /* mov thread {r8 - r12} to {r3 - r7} */ + MOV R4, R9 + MOV R5, R10 + MOV R6, R11 + MOV R7, R12 + PUSH {R3-R7} /* store R8-R12 (5 words) onto the stack */ + + LDR R4, =RAM_VR /* load address of struct RAM_VR into R4 */ + MRS R3, MSP /* load the stack pointer into R3 */ + STR R3, [R4,#4] /* store the MSP into RAM_VR.SavedMSP (second word of the structure) */ + + PUSH { r1, r2 } /* store PSP, CONTROL */ + + DSB + WFI /* all saved, trigger deep sleep */ + + NOP /* NOP instructions added if an interrupt (NOT WAKEUP SOURCE) is raised */ + NOP /* the device gates/stop the CPU clock 2 system clock cycles after this WFI */ + /* this can be a blind window */ + + ENDFUNC + +EXPORT_FUNC(CPUcontextRestore) + /* Even if we fall through the WFI instruction, we will immediately + * execute a context restore and end up where we left off with no + * ill effects. Normally at this point the core will either be + * powered off or reset (depending on the deep sleep level). */ + LDR R4, =RAM_VR /* load address of RAM_VR into R4 */ + LDR R4, [R4,#4] /* load the MSP from RAM_VR.SavedMSP (second word of the structure) */ + MSR MSP, R4 /* restore the MSP from R4 */ + + SUB SP, #0x8 + POP { R0, R1 } /* load PSP from the stack in R0, and load CONTROL register from the stack in R1 */ + + POP { R3-R7 } /* load R8-R12 (5 words) from the stack */ + MOV R8, R3 /* mov {r3 - r7} to {r8 - r12} */ + MOV R9, R4 + MOV R10, R5 + MOV R11, R6 + MOV R12, R7 + POP { R4 - R7 } /* load R4-R7 (4 words) from the stack */ + POP { R2 } /* load LR from the stack */ + + MSR PSP, R0 /* restore PSP from R0 */ + MSR CONTROL , R1 /* restore CONTROL register from R1 */ + ISB + + BX R2 /*load PC (1 words) from the stack */ + + ENDFUNC + + ALIGN_MEM(4) + __END__ diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Startup/device_context_switch.c b/lib/stm32wb0/BLE_TransparentMode/System/Startup/device_context_switch.c new file mode 100644 index 000000000..a523caaef --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Startup/device_context_switch.c @@ -0,0 +1,554 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file device_context_switch.c + * @author GPM WBL Application Team + * @brief STM32WB09 context switch + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifdef __GNUC__ +#pragma GCC optimize ("-Os") +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "device_context_switch.h" + +/* Private includes ----------------------------------------------------------*/ + +/* Private typedef -----------------------------------------------------------*/ + +/* Private define ------------------------------------------------------------*/ + +/* System Tick Priority register */ +#define SHPR3_REG 0xE000ED20 + +/* Private macro -------------------------------------------------------------*/ + +/* Private variables ---------------------------------------------------------*/ + +/* Private function prototypes -----------------------------------------------*/ +static void APB0periphContextSave(apb0PeriphT *apb0); +static void APB1periphContextSave(apb1PeriphT *apb1); +static void AHB0periphContextSave(ahb0PeriphT *ahb0); +static void cstackContextSave(uint32_t *cStackPreamble); +static void cpuPeriphContextSave(cpuPeriphT *cpuPeriph); +static void APB0periphContextRestore(apb0PeriphT *apb0); +static void APB1periphContextRestore(apb1PeriphT *apb1); +static void AHB0periphContextRestore(ahb0PeriphT *ahb0); +static void cstackContextRestore(uint32_t *cStackPreamble); +static void cpuPeriphContextRestore(cpuPeriphT *cpuPeriph); + +/* Private user code ---------------------------------------------------------*/ + +/** + * @brief Save the APB0 peripheral registers content. + * @param apb0 Pointer to a APB0 structure + * @retval None + */ +static void APB0periphContextSave(apb0PeriphT *apb0) +{ + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_SYSCFG)) + { + Osal_MemCpy4((uint32_t *)&apb0->SYSCFG_vr, (uint32_t *)SYSCFG, sizeof(SYSCFG_TypeDef)); + } + +#if defined(TIM1) + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_TIM1)) + { + Osal_MemCpy4((uint32_t *)&apb0->TIM1_vr, (uint32_t *)TIM1, sizeof(TIM_TypeDef)); + } +#endif +#if defined(TIM2) + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_TIM2)) + { + Osal_MemCpy4((uint32_t *)&apb0->TIM2_vr, (uint32_t *)TIM2, sizeof(TIM_TypeDef)); + } +#endif +#if defined(TIM16) + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_TIM16)) + { + Osal_MemCpy4((uint32_t *)&apb0->TIM16_vr, (uint32_t *)TIM16, sizeof(TIM_TypeDef)); + } +#endif +#if defined(TIM17) + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_TIM17)) + { + Osal_MemCpy4((uint32_t *)&apb0->TIM17_vr, (uint32_t *)TIM17, sizeof(TIM_TypeDef)); + } +#endif + + apb0->wdg_to_be_enabled = FALSE; + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_WDG)) + { + if (apb0->deepstop_wdg_state == DISABLE) + { + apb0->wdg_to_be_enabled = TRUE; + LL_APB0_GRP1_DisableClock(LL_APB0_GRP1_PERIPH_WDG); + } + } + + apb0->FLASH_CONFIG_vr = FLASH->CONFIG; +} + +/** + * @brief Save the APB1 peripheral registers content. + * @param apb1 Pointer to a APB1 structure + * @retval None + */ +static void APB1periphContextSave(apb1PeriphT *apb1) +{ + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_SPI3)) + { + Osal_MemCpy4((uint32_t *)&apb1->SPI3_vr, (uint32_t *)SPI3, sizeof(SPI_TypeDef)); + } + + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_ADCDIG)) + { + Osal_MemCpy4((uint32_t *)&apb1->ADC_vr, (uint32_t *)ADC1, sizeof(ADC_TypeDef)); + } + +#if defined(STM32WB06) || defined(STM32WB07) + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_LPUART1)) +#else + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_LPUART1) && + (LL_RCC_GetLPUARTClockSource() == LL_RCC_LPUCLKSEL_CLK16M)) +#endif + { + Osal_MemCpy4((uint32_t *)&apb1->LPUART_vr, (uint32_t *)LPUART1, sizeof(USART_TypeDef)); + } + + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_USART1)) + { + Osal_MemCpy4((uint32_t *)&apb1->USART_vr, (uint32_t *)USART1, sizeof(USART_TypeDef)); + } + + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_I2C1)) + { + Osal_MemCpy4((uint32_t *)&apb1->I2C1_vr, (uint32_t *)I2C1, sizeof(I2C_TypeDef)); + } +} + +/** + * @brief Save the APB2 peripheral registers content. + * @param apb2 Pointer to a APB2 structure + * @retval None + */ +static void APB2periphContextSave(apb2PeriphT *apb2) +{ + if (LL_APB2_GRP1_IsEnabledClock(LL_APB2_GRP1_PERIPH_MRBLE)) + { +#if defined(RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS) + apb2->LDO_TRANSFO_vr = READ_BIT(RRM->LDO_ANA_ENG, RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS); +#endif + } +} + +/** + * @brief Save the AHB0 peripheral registers content. + * @param ahb0 Pointer to a AHB0 structure + * @retval None + */ +static void AHB0periphContextSave(ahb0PeriphT *ahb0) +{ + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_DMA)) { + Osal_MemCpy4((uint32_t *)ahb0->DMAMUX_vr, (uint32_t *)DMAMUX1, 8*sizeof(DMAMUX_Channel_TypeDef)); + Osal_MemCpy4((uint32_t *)ahb0->DMA_vr, (uint32_t *)DMA1, 8*sizeof(DMA_Channel_TypeDef)); + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_RNG)) { + Osal_MemCpy4((uint32_t *)&ahb0->RNG_vr, (uint32_t *)RNG, sizeof(RNG_TypeDef)); + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_PKA)) { +#if defined(STM32WB06) || defined(STM32WB07) + ahb0->PKA_CSR_vr = PKA->CSR; + ahb0->PKA_ISR_vr = PKA->ISR; + ahb0->PKA_IEN_vr = PKA->IEN; +#else + ahb0->PKA_CR_vr = PKA->CR; +#endif + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_CRC)) { + Osal_MemCpy4((uint32_t *)&ahb0->CRC_vr, (uint32_t *)CRC, sizeof(CRC_TypeDef)); + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_GPIOA)) { + Osal_MemCpy4((uint32_t *)&ahb0->GPIOA_vr, (uint32_t *)GPIOA, sizeof(GPIO_TypeDef)); + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_GPIOB)) { + Osal_MemCpy4((uint32_t *)&ahb0->GPIOB_vr, (uint32_t *)GPIOB, sizeof(GPIO_TypeDef)); + } + + ahb0->RCC_AHBRSTR_vr = RCC->AHBRSTR; + ahb0->RCC_APB1RSTR_vr = RCC->APB1RSTR; + ahb0->RCC_AHBENR_vr = RCC->AHBENR; + ahb0->RCC_APB1ENR_vr = RCC->APB1ENR; +} + +/** + * @brief Save the first N c-stack location that will be restored at wakeup reset. + * @param cStackPreamble Pointer to store the c-stack location + * @retval None + */ +static void cstackContextSave(uint32_t *cStackPreamble) +{ + uint8_t i; + volatile uint32_t *ptr; + + i = 0; + ptr = __vector_table[0].__ptr ; + ptr -= CSTACK_PREAMBLE_NUMBER; + do + { + cStackPreamble[i] = *ptr; + i++; + ptr++; + } while (i < CSTACK_PREAMBLE_NUMBER); + +} + +/** + * @brief Save the CPU peripheral configuration (NVIC, SysTick, Vector Table). + * @param cpuPeriph Pointer to a cpu peripheral structure + * @retval None + */ +static void cpuPeriphContextSave(cpuPeriphT *cpuPeriph) +{ + uint8_t i; + + cpuPeriph->SCB_VTOR_vr = SCB->VTOR; + cpuPeriph->NVIC_ISER_vr = NVIC->ISER[0]; + for (i=0; i<8; i++) + { + cpuPeriph->NVIC_IPR_vr[i] = NVIC->IP[i]; + } + cpuPeriph->SYSTICK_IPR_vr = *(volatile uint32_t *)SHPR3_REG; + cpuPeriph->SYST_CSR_vr = SysTick->CTRL; + cpuPeriph->SYST_RVR_vr = SysTick->LOAD; +} + +/** + * @brief Restore the APB0 peripheral registers content. + * @param apb0 Pointer to a APB0 structure + * @retval None + */ +static void APB0periphContextRestore(apb0PeriphT *apb0) +{ + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_SYSCFG)) + { + Osal_MemCpy4((uint32_t *)SYSCFG, (uint32_t *)&apb0->SYSCFG_vr, sizeof(SYSCFG_TypeDef)); + } + +#if defined(TIM1) + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_TIM1)) + { + uint32_t app; + app = apb0->TIM1_vr.CR1; + apb0->TIM1_vr.CR1 &= ~TIM_CR1_CEN; + Osal_MemCpy4((uint32_t *)TIM1, (uint32_t *)&apb0->TIM1_vr, sizeof(TIM_TypeDef)); + TIM1->CR1 = app; + } +#endif + +#if defined(TIM2) + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_TIM2)) + { + uint32_t app; + app = apb0->TIM2_vr.CR1; + apb0->TIM2_vr.CR1 &= ~TIM_CR1_CEN; + Osal_MemCpy4((uint32_t *)TIM2, (uint32_t *)&apb0->TIM2_vr, sizeof(TIM_TypeDef)); + TIM2->CR1 = app; + } +#endif + +#if defined(TIM16) + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_TIM16)) + { + uint32_t app; + app = apb0->TIM16_vr.CR1; + apb0->TIM16_vr.CR1 &= ~TIM_CR1_CEN; + Osal_MemCpy4((uint32_t *)TIM16, (uint32_t *)&apb0->TIM16_vr, sizeof(TIM_TypeDef)); + TIM16->CR1 = app; + } +#endif + +#if defined(TIM17) + if (LL_APB0_GRP1_IsEnabledClock(LL_APB0_GRP1_PERIPH_TIM17)) + { + uint32_t app; + app = apb0->TIM17_vr.CR1; + apb0->TIM17_vr.CR1 &= ~TIM_CR1_CEN; + Osal_MemCpy4((uint32_t *)TIM17, (uint32_t *)&apb0->TIM17_vr, sizeof(TIM_TypeDef)); + TIM17->CR1 = app; + } +#endif + + apb0->FLASH_CONFIG_vr = FLASH->CONFIG; +} + +/** + * @brief Restore the APB1 peripheral registers content. + * @param apb1 Pointer to a APB1 structure + * @retval None + */ +static void APB1periphContextRestore(apb1PeriphT *apb1) +{ + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_SPI3)) + { + uint32_t app; + app = apb1->SPI3_vr.CR1; + apb1->SPI3_vr.CR1 &= ~SPI_CR1_SPE; + Osal_MemCpy4((uint32_t *)SPI3, (uint32_t *)&apb1->SPI3_vr, 12); /* Skip DR */ + Osal_MemCpy4((uint32_t *)(&(SPI3->CRCPR)), (uint32_t *)(&apb1->SPI3_vr.CRCPR), 20); + SPI3->CR1 = app; + } + + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_ADCDIG)) + { + Osal_MemCpy4((uint32_t *)ADC1, (uint32_t *)&apb1->ADC_vr, sizeof(ADC_TypeDef)); + } + +#if defined(STM32WB06) || defined(STM32WB07) + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_LPUART1)) +#else + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_LPUART1) && + (LL_RCC_GetLPUARTClockSource() == LL_RCC_LPUCLKSEL_CLK16M)) +#endif + { + uint32_t app; + app = apb1->LPUART_vr.CR1; + apb1->LPUART_vr.CR1 &= ~USART_CR1_UE; + Osal_MemCpy4((uint32_t *)LPUART1, (uint32_t *)&apb1->LPUART_vr, 36); /* Skip RDR and TDR */ + LPUART1->PRESC = apb1->LPUART_vr.PRESC; + LPUART1->CR1 = app; + } + + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_USART1)) + { + uint32_t app; + app = apb1->USART_vr.CR1; + apb1->USART_vr.CR1 &= ~USART_CR1_UE; + Osal_MemCpy4((uint32_t *)USART1, (uint32_t *)&apb1->USART_vr, 36); /* Skip RDR and TDR */ + USART1->PRESC = apb1->USART_vr.PRESC; + USART1->CR1 = app; + } + + if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_I2C1)) + { + uint32_t app; + app = apb1->I2C1_vr.CR1; + apb1->I2C1_vr.CR1 &= ~I2C_CR1_PE; + Osal_MemCpy4((uint32_t *)I2C1, (uint32_t *)&apb1->I2C1_vr, 32); /* Skip PECR, RDR and TDR */ + I2C1->CR1 = app; + } +} + +/** + * @brief Restore the APB2 peripheral registers content. + * @param apb2 Pointer to a APB2 structure + * @retval None + */ +static void APB2periphContextRestore(apb2PeriphT *apb2) +{ + if (LL_APB2_GRP1_IsEnabledClock(LL_APB2_GRP1_PERIPH_MRBLE)) + { +#if defined(RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS) + if (apb2->LDO_TRANSFO_vr) + { + SET_BIT(RRM->LDO_ANA_ENG, RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS); + } +#endif + } +} + +/** + * @brief Restore the AHB0 peripheral registers content. + * @param ahb0 Pointer to a AHB0 structure + * @retval None + */ +static void AHB0periphContextRestore(ahb0PeriphT *ahb0) +{ + RCC->AHBRSTR = ahb0->RCC_AHBRSTR_vr; + RCC->APB1RSTR = ahb0->RCC_APB1RSTR_vr; + RCC->AHBENR = ahb0->RCC_AHBENR_vr; + RCC->APB1ENR = ahb0->RCC_APB1ENR_vr; + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_DMA)) { + Osal_MemCpy4((uint32_t *)DMAMUX1, (uint32_t *)ahb0->DMAMUX_vr, 8*sizeof(DMAMUX_Channel_TypeDef)); + ahb0->DMA_vr[0].CNDTR = 0; + ahb0->DMA_vr[1].CNDTR = 0; + ahb0->DMA_vr[2].CNDTR = 0; + ahb0->DMA_vr[3].CNDTR = 0; + ahb0->DMA_vr[4].CNDTR = 0; + ahb0->DMA_vr[5].CNDTR = 0; + ahb0->DMA_vr[6].CNDTR = 0; + ahb0->DMA_vr[7].CNDTR = 0; + Osal_MemCpy4((uint32_t *)DMA1, (uint32_t *)ahb0->DMA_vr, 8*sizeof(DMA_Channel_TypeDef)); + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_RNG)) { + Osal_MemCpy4((uint32_t *)RNG, (uint32_t *)&ahb0->RNG_vr, sizeof(RNG_TypeDef)); + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_PKA)) { +#if defined(STM32WB06) || defined(STM32WB07) + PKA->CSR = ahb0->PKA_CSR_vr; + PKA->ISR = ahb0->PKA_ISR_vr; + PKA->IEN = ahb0->PKA_IEN_vr; +#else + PKA->CLRFR = 0x1A0000; + PKA->CR = ahb0->PKA_CR_vr; +#endif + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_CRC)) { + Osal_MemCpy4((uint32_t *)CRC, (uint32_t *)&ahb0->CRC_vr, sizeof(CRC_TypeDef)); + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_GPIOA)) { + GPIOA->AFR[0] = ahb0->GPIOA_vr.AFR[0]; /* To avoid glitch in the line when an AF is set */ + GPIOA->AFR[1] = ahb0->GPIOA_vr.AFR[1]; + GPIOA->ODR = ahb0->GPIOA_vr.ODR; /* To avoid glitch in the line when GPIO_MODE_OUTPUT is set */ + Osal_MemCpy4((uint32_t *)GPIOA, (uint32_t *)&ahb0->GPIOA_vr, sizeof(GPIO_TypeDef)); + } + + if (LL_AHB1_GRP1_IsEnabledClock(LL_AHB1_GRP1_PERIPH_GPIOB)) { + GPIOB->AFR[0] = ahb0->GPIOB_vr.AFR[0]; /* To avoid glitch in the line when an AF is set */ + GPIOB->AFR[1] = ahb0->GPIOB_vr.AFR[1]; + GPIOB->ODR = ahb0->GPIOB_vr.ODR; /* To avoid glitch in the line when GPIO_MODE_OUTPUT is set */ + Osal_MemCpy4((uint32_t *)GPIOB, (uint32_t *)&ahb0->GPIOB_vr, sizeof(GPIO_TypeDef)); + } +} + +/** + * @brief Restore the first N c-stack location after wake-up reset. + * @param cStackPreamble Pointer to store the c-stack location + * @retval None + */ +static void cstackContextRestore(uint32_t *cStackPreamble) +{ + uint8_t i; + volatile uint32_t *ptr; + + i = 0; + ptr = __vector_table[0].__ptr ; + ptr -= CSTACK_PREAMBLE_NUMBER; + do + { + *ptr = cStackPreamble[i]; + i++; + ptr++; + } while (i < CSTACK_PREAMBLE_NUMBER); + +} + +/** + * @brief Restore the CPU peripheral configuration (NVIC, SysTick, Vector Table). + * @param cpuPeriph Pointer to a cpu peripheral structure + * @retval None + */ +static void cpuPeriphContextRestore(cpuPeriphT *cpuPeriph) +{ + uint8_t i; + + SCB->VTOR = cpuPeriph->SCB_VTOR_vr; + NVIC->ISER[0] = cpuPeriph->NVIC_ISER_vr; + for (i=0; i<8; i++) + { + NVIC->IP[i] = cpuPeriph->NVIC_IPR_vr[i]; + } + *(volatile uint32_t *)SHPR3_REG = cpuPeriph->SYSTICK_IPR_vr; + SysTick->LOAD = cpuPeriph->SYST_RVR_vr; + SysTick->VAL = 0; + SysTick->CTRL = cpuPeriph->SYST_CSR_vr; +} + +/** + * @brief Prepare the device for the low power mode. All peripheral registers + * and some CPU configuration registers are saved in a + * context and retained in RAM. + * @param Structure to save the peripherals configuration + * @retval None + */ +void prepareDeviceLowPower(apb0PeriphT *apb0, apb1PeriphT *apb1, + apb2PeriphT *apb2, ahb0PeriphT *ahb0, + cpuPeriphT *cpuPeriph, uint32_t *cStackPreamble) +{ + /* Reset the wakeup flag before the low power mode */ + RAM_VR.WakeupFromSleepFlag = 0; + + /* Save the APB0 peripheral configuration */ + APB0periphContextSave(apb0); + + /* Save the APB1 peripheral configuration */ + APB1periphContextSave(apb1); + + /* Save the APB2 peripheral configuration */ + APB2periphContextSave(apb2); + + /* Save the AHB0 peripheral configuration */ + AHB0periphContextSave(ahb0); + + /* Save the first N c-stack location that will be restored at wakeup reset */ + cstackContextSave(cStackPreamble); + + /* Save the CPU peripheral configuration (NVIC, SysTick, Vector Table) */ + cpuPeriphContextSave(cpuPeriph); +} + +/** + * @brief Restore the device configuration after wake-up from low power mode. + * All peripheral registers and CPU configuration registers + * are restored. + * @param Structure with the stored peripherals configuration + * @retval None + */ +void restoreDeviceLowPower(apb0PeriphT *apb0, apb1PeriphT *apb1, + apb2PeriphT *apb2, ahb0PeriphT *ahb0, + cpuPeriphT *cpuPeriph, uint32_t *cStackPreamble) +{ + /* Enable Watchdog IP if previous disabled */ + if (apb0->wdg_to_be_enabled) + { + apb0->wdg_to_be_enabled = FALSE; + LL_APB0_GRP1_EnableClock(LL_APB0_GRP1_PERIPH_WDG); + } + + /* No Wakeup from DEEPSTOP, so the peripehral configuration is not lost */ + if (RAM_VR.WakeupFromSleepFlag == 0) + { + return; + } + + /* Restore the first N c-stack location that will be restored at wakeup reset */ + cstackContextRestore(cStackPreamble); + + /* Restore the CPU peripheral configuration (NVIC, SysTick, Vector Table) */ + cpuPeriphContextRestore(cpuPeriph); + + /* Restore the AHB0 peripheral configuration */ + AHB0periphContextRestore(ahb0); + + /* Restore the APB0 peripheral configuration */ + APB0periphContextRestore(apb0); + + /* Restore the APB1 peripheral configuration */ + APB1periphContextRestore(apb1); + + /* Restore the APB2 peripheral configuration */ + APB2periphContextRestore(apb2); +} diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Startup/device_context_switch.h b/lib/stm32wb0/BLE_TransparentMode/System/Startup/device_context_switch.h new file mode 100644 index 000000000..7cddd956e --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/System/Startup/device_context_switch.h @@ -0,0 +1,133 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file device_context_switch.h + * @author GPM WBL Application Team + * @brief Header file of Device Context Switch module. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef DEVICE_CONTEXT_SWITCH_H +#define DEVICE_CONTEXT_SWITCH_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wb0x_hal.h" +#include "osal.h" + +/* Exported types ------------------------------------------------------------*/ +/* APB0 structure with all the virtual register + used in low power to save the context */ +typedef struct apb0PeriphS +{ + SYSCFG_TypeDef SYSCFG_vr; + uint32_t FLASH_CONFIG_vr; +#if defined (STM32WB06) || defined(STM32WB07) + TIM_TypeDef TIM1_vr; +#else + TIM_TypeDef TIM2_vr; + TIM_TypeDef TIM16_vr; + TIM_TypeDef TIM17_vr; +#endif + uint32_t wdg_to_be_enabled; + uint32_t deepstop_wdg_state; +} apb0PeriphT; + +/* APB1 structure with all the virtual register + used in low power to save the context */ +typedef struct apb1PeriphS +{ + I2C_TypeDef I2C1_vr; + USART_TypeDef USART_vr; + USART_TypeDef LPUART_vr; + ADC_TypeDef ADC_vr; + SPI_TypeDef SPI3_vr; +} apb1PeriphT; + +/* APB2 structure with all the virtual register + used in low power to save the context */ +typedef struct apb2PeriphS +{ +#if defined(RRM_LDO_ANA_ENG_RFD_LDO_TRANSFO_BYPASS) + uint32_t LDO_TRANSFO_vr; +#else + uint32_t dummy; +#endif +} apb2PeriphT; + +/* AHB0 structure with all the virtual register + used in low power to save the context */ +typedef struct ahb0PeriphS +{ + GPIO_TypeDef GPIOA_vr; + GPIO_TypeDef GPIOB_vr; + CRC_TypeDef CRC_vr; +#if defined(STM32WB06) || defined(STM32WB07) + uint32_t PKA_CSR_vr; + uint32_t PKA_ISR_vr; + uint32_t PKA_IEN_vr; +#else + uint32_t PKA_CR_vr; +#endif + RNG_TypeDef RNG_vr; + DMA_Channel_TypeDef DMA_vr[8]; + DMAMUX_Channel_TypeDef DMAMUX_vr[8]; + uint32_t RCC_AHBRSTR_vr; + uint32_t RCC_APB1RSTR_vr; + uint32_t RCC_AHBENR_vr; + uint32_t RCC_APB1ENR_vr; + uint32_t RCC_CR_vr; +} ahb0PeriphT; + +typedef struct cpuPeriphS +{ + uint32_t SCB_VTOR_vr; + uint32_t NVIC_ISER_vr; + uint32_t NVIC_IPR_vr[8]; + uint32_t SYSTICK_IPR_vr; + uint32_t SYST_CSR_vr; + uint32_t SYST_RVR_vr; +} cpuPeriphT; + +/* Exported constants --------------------------------------------------------*/ + +/* Important note: The SystemInit() function is critical for waking up from + deep sleep and it should not use more that 20 stack positions + otherwise a stack corruption will occur when waking up from deep sleep. + For this reason we are saving and restoring the first 20 words of the stack that + will be corrupted during the wake-up procedure from deep sleep. + If the SystemInit() will be modified, this define shall be modified according + the new function implementation +*/ +#define CSTACK_PREAMBLE_NUMBER 20 + +/* Exported macros -----------------------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +void prepareDeviceLowPower(apb0PeriphT *apb0, apb1PeriphT *apb1, + apb2PeriphT *apb2, ahb0PeriphT *ahb0, + cpuPeriphT *cpuPeriph, uint32_t *cStackPreamble); + +void restoreDeviceLowPower(apb0PeriphT *apb0, apb1PeriphT *apb1, + apb2PeriphT *apb2, ahb0PeriphT *ahb0, + cpuPeriphT *cpuPeriph, uint32_t *cStackPreamble); +#ifdef __cplusplus +} +#endif + +#endif /* DEVICE_CONTEXT_SWITCH_H */ diff --git a/lib/stm32wb0/CMakeLists.txt b/lib/stm32wb0/CMakeLists.txt new file mode 100644 index 000000000..4fe0fe882 --- /dev/null +++ b/lib/stm32wb0/CMakeLists.txt @@ -0,0 +1,304 @@ +# Copyright (c) 2024 STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() + +# Set the correct directory +zephyr_include_directories(STM32_BLE) +zephyr_include_directories(STM32_BLE/stack/include) +zephyr_include_directories(BLE_TransparentMode/System/Modules/PKAMGR/Inc) +zephyr_include_directories(BLE_TransparentMode/System/Modules) +zephyr_include_directories(BLE_TransparentMode/System/Interfaces) +zephyr_include_directories(BLE_TransparentMode/System/Modules/RADIO_utils/Inc) +zephyr_include_directories(BLE_TransparentMode/System/Config/Debug_GPIO) +zephyr_include_directories(BLE_TransparentMode/System/Modules/RTDebug) +zephyr_include_directories(BLE_TransparentMode/Core/Inc) +zephyr_include_directories(BLE_TransparentMode/STM32_BLE/App) + +target_link_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/stm32wb0/lib) +target_link_libraries(app PUBLIC -l:stm32wb0x_ble_stack_controller_only.a) + +function(min OUT_VAR) + list(SORT ARGN COMPARE NATURAL ORDER ASCENDING) + list(GET ARGN 0 MIN_ELEMENT) + set(${OUT_VAR} ${MIN_ELEMENT} PARENT_SCOPE) +endfunction() + +########### Begining of modularity selection ########### +set(CFG_BLE_CONTROLLER_MASTER_ENABLED "0") +set(CFG_BLE_CONTROLLER_SCAN_ENABLED "0") +set(CFG_BLE_CONTROLLER_PRIVACY_ENABLED "0") +set(CFG_BLE_SECURE_CONNECTIONS_ENABLED "0") +set(CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED "0") +set(CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED "1") +set(CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED "0") +set(CFG_BLE_L2CAP_COS_ENABLED "0") +set(CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED "0") +set(CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED "0") +set(CFG_BLE_CONTROLLER_CTE_ENABLED "0") +set(CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED "0") +set(CFG_BLE_CONNECTION_ENABLED "0") +set(CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED "0") +set(CFG_BLE_CONTROLLER_BIS_ENABLED "0") +set(CFG_BLE_CONNECTION_SUBRATING_ENABLED "0") +set(CFG_BLE_CONTROLLER_CIS_ENABLED "0") + +zephyr_compile_definitions( + -DBLESTACK_CONTROLLER_ONLY=1 + -DACI_HAL_GET_FIRMWARE_DETAILS_ENABLED=0 + -DACI_HAL_GET_FIRMWARE_DETAILS_V2_ENABLED=0 + -DACI_HAL_UPDATER_START_ENABLED=0 + -DACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED=0 + -DACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED=0 + -DACI_HAL_WRITE_RADIO_REG_ENABLED=0 + -DACI_HAL_READ_RADIO_REG_ENABLED=0 +) + +if(CONFIG_BT_OBSERVER) + set(CFG_BLE_CONTROLLER_SCAN_ENABLED "1") +endif() + +if(CONFIG_BT_PRIVACY) + set(CFG_BLE_CONTROLLER_PRIVACY_ENABLED "1") +endif() + +if(CONFIG_BT_SMP) + set(CFG_BLE_SECURE_CONNECTIONS_ENABLED "1") +endif() + +if(CONFIG_BT_CTLR_DATA_LENGTH GREATER 27) + set(CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED "1") +endif() + +if(CONFIG_BT_EXT_ADV) + set(CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED "1") +endif() + +if(CONFIG_BT_L2CAP_ECRED) + set(CFG_BLE_L2CAP_COS_ENABLED "1") +endif() + +if(CONFIG_BT_PER_ADV OR CONFIG_BT_PER_ADV_SYNC) + set(CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED "1") +endif() + +if(CONFIG_BT_PER_ADV_RSP) + set(CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED "1") +endif() + +if(CONFIG_BT_DF) + set(CFG_BLE_CONTROLLER_CTE_ENABLED "1") +endif() + +if(CONFIG_BT_TRANSMIT_POWER_CONTROL) + set(CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED "1") +endif() + +if(CONFIG_BT_CONN) + set(CFG_BLE_CONNECTION_ENABLED "1") +endif() + +if(CONFIG_BT_ISO_BROADCAST) + set(CFG_BLE_CONTROLLER_BIS_ENABLED "1") +endif() + +if(CONFIG_BT_ISO_UNICAST) + set(CFG_BLE_CONTROLLER_CIS_ENABLED "1") +endif() + +message(STATUS "BLE Stack modularity configuration:") +message(STATUS "CONTROLLER_SCAN_ENABLED=${CFG_BLE_CONTROLLER_SCAN_ENABLED}") +message(STATUS "CONTROLLER_PRIVACY_ENABLED=${CFG_BLE_CONTROLLER_PRIVACY_ENABLED}") +message(STATUS "SECURE_CONNECTIONS_ENABLED=${CFG_BLE_SECURE_CONNECTIONS_ENABLED}") +message(STATUS "CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED=${CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED}") +message(STATUS "CONTROLLER_2M_CODED_PHY_ENABLED=${CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED}") +message(STATUS "CONTROLLER_EXT_ADV_SCAN_ENABLED=${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED}") +message(STATUS "L2CAP_COS_ENABLED=${CFG_BLE_L2CAP_COS_ENABLED}") +message(STATUS "CONTROLLER_PERIODIC_ADV_ENABLED=${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED}") +message(STATUS "CONTROLLER_PERIODIC_ADV_WR_ENABLED=${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED}") +message(STATUS "CONTROLLER_CTE_ENABLED=${CFG_BLE_CONTROLLER_CTE_ENABLED}") +message(STATUS "CONTROLLER_POWER_CONTROL_ENABLED=${CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED}") +message(STATUS "CONNECTION_ENABLED=${CFG_BLE_CONNECTION_ENABLED}") +message(STATUS "CONTROLLER_CHAN_CLASS_ENABLED=${CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED}") +message(STATUS "CONTROLLER_BIS_ENABLED=${CFG_BLE_CONTROLLER_BIS_ENABLED}") +message(STATUS "CONNECTION_SUBRATING_ENABLED=${CFG_BLE_CONNECTION_SUBRATING_ENABLED}") +message(STATUS "CONTROLLER_CIS_ENABLED=${CFG_BLE_CONTROLLER_CIS_ENABLED}") + +zephyr_compile_definitions( + -DCFG_BLE_CONTROLLER_SCAN_ENABLED=${CFG_BLE_CONTROLLER_SCAN_ENABLED} + -DCFG_BLE_CONTROLLER_PRIVACY_ENABLED=${CFG_BLE_CONTROLLER_PRIVACY_ENABLED} + -DCFG_BLE_SECURE_CONNECTIONS_ENABLED=${CFG_BLE_SECURE_CONNECTIONS_ENABLED} + -DCFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED=${CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED} + -DCFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED=${CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED} + -DCFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED=${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED} + -DCFG_BLE_L2CAP_COS_ENABLED=${CFG_BLE_L2CAP_COS_ENABLED} + -DCFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED=${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED} + -DCFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED=${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} + -DCFG_BLE_CONTROLLER_CTE_ENABLED=${CFG_BLE_CONTROLLER_CTE_ENABLED} + -DCFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED=${CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED} + -DCFG_BLE_CONNECTION_ENABLED=${CFG_BLE_CONNECTION_ENABLED} + -DCFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED=${CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED} + -DCFG_BLE_CONTROLLER_BIS_ENABLED=${CFG_BLE_CONTROLLER_BIS_ENABLED} + -DCFG_BLE_CONNECTION_SUBRATING_ENABLED=${CFG_BLE_CONNECTION_SUBRATING_ENABLED} + -DCFG_BLE_CONTROLLER_CIS_ENABLED=${CFG_BLE_CONTROLLER_CIS_ENABLED} +) +########### End of modularity selection ########### + +########### Beginning of numeric value section ########### +set(CFG_BLE_NUM_SYNC_SLOTS "0") +set(CFG_BLE_NUM_ADV_SETS "1") +set(CFG_BLE_NUM_EATT_CHANNELS "0") +set(CFG_BLE_NUM_BRC_BIG_MAX "0") +set(CFG_BLE_NUM_SYNC_BIG_MAX "0") +set(CFG_BLE_NUM_SYNC_BIS_MAX "0") +set(CFG_BLE_NUM_BRC_BIS_MAX "0") +set(CFG_BLE_NUM_CIG_MAX "0") +set(CFG_BLE_NUM_CIS_MAX "0") +set(CFG_BLE_NUM_AUX_SCAN_SLOTS "4") + +set(bt_max_conn "0") + +if(CONFIG_BT_PER_ADV_SYNC_MAX) + set(CFG_BLE_NUM_SYNC_SLOTS "${CONFIG_BT_PER_ADV_SYNC_MAX}") +endif() + +if(CONFIG_BT_EXT_ADV_MAX_ADV_SET) + set(CFG_BLE_NUM_ADV_SETS "${CONFIG_BT_EXT_ADV_MAX_ADV_SET}") +endif() + +if (CONFIG_BT_MAX_CONN) + #Maximum number of simultaneous connections + set(bt_max_conn "${CONFIG_BT_MAX_CONN}") +endif() + +if (CONFIG_BT_EATT_MAX) + # Maximum number of Enhanced ATT bearers + set(CFG_BLE_NUM_EATT_CHANNELS "${CONFIG_BT_EATT_MAX}") +endif() + +if (CONFIG_BT_ISO_MAX_BIG) + # Maximum number of Broadcast Isochronous Groups (BIGs) to support + # A BIG can be used for either transmitting or receiving, but not at the same time. + if (CONFIG_BT_ISO_BROADCASTER) + set(CFG_BLE_NUM_BRC_BIG_MAX "${CONFIG_BT_ISO_MAX_BIG}") + endif() + if (CONFIG_BT_ISO_SYNC_RECEIVER) + set(CFG_BLE_NUM_SYNC_BIG_MAX "${CONFIG_BT_ISO_MAX_BIG}") + endif() +endif() + +if (CONFIG_BT_ISO_MAX_CHAN) + # Maximum number of simultaneous Bluetooth isochronous channels supported. + if (CONFIG_BT_ISO_BROADCASTER) + set(CFG_BLE_NUM_BRC_BIS_MAX "${CONFIG_BT_ISO_MAX_BIG}") + endif() + if (CONFIG_BT_ISO_SYNC_RECEIVER) + set(CFG_BLE_NUM_SYNC_BIS_MAX "${CONFIG_BT_ISO_MAX_BIG}") + endif() +endif() + +if (CONFIG_BT_ISO_MAX_CIG) + # Maximum number of CIGs that are supported by the host. + # A CIG can be used for either transmitting or receiving. + set(CFG_BLE_NUM_CIG_MAX "${CONFIG_BT_ISO_MAX_CIG}") +endif() + +if (CONFIG_BT_ISO_MAX_CHAN) + # Maximum number of simultaneous Bluetooth isochronous channels supported. + set(CFG_BLE_NUM_CIS_MAX "${CONFIG_BT_ISO_MAX_CHAN}") +endif() + +zephyr_compile_definitions( + -DCFG_BLE_NUM_SYNC_SLOTS=${CFG_BLE_NUM_SYNC_SLOTS} + -DCFG_BLE_NUM_ADV_SETS=${CFG_BLE_NUM_ADV_SETS} + -DCFG_BLE_NUM_EATT_CHANNELS=${CFG_BLE_NUM_EATT_CHANNELS} + -DCFG_BLE_NUM_BRC_BIG_MAX=${CFG_BLE_NUM_BRC_BIG_MAX} + -DCFG_BLE_NUM_SYNC_BIG_MAX=${CFG_BLE_NUM_SYNC_BIG_MAX} + -DCFG_BLE_NUM_SYNC_BIS_MAX=${CFG_BLE_NUM_SYNC_BIS_MAX} + -DCFG_BLE_NUM_BRC_BIS_MAX=${CFG_BLE_NUM_BRC_BIS_MAX} + -DCFG_BLE_NUM_CIG_MAX=${CFG_BLE_NUM_CIG_MAX} + -DCFG_BLE_NUM_CIS_MAX=${CFG_BLE_NUM_CIS_MAX} + -DCFG_BLE_NUM_AUX_SCAN_SLOTS=${CFG_BLE_NUM_AUX_SCAN_SLOTS} +) +########### End of numeric value section ########### + +########### Beginning of number of radio tasks calculation ########### +set(tasks "1") + +if(${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED}) + MATH(EXPR tasks "2 * ${CFG_BLE_NUM_ADV_SETS}") + if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED}) + MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_ADV_SETS}") + if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) + MATH(EXPR tasks "${tasks} + 2 * ${CFG_BLE_NUM_ADV_SETS}") + endif() + if(${CFG_BLE_CONTROLLER_BIS_ENABLED}) + #radio_tasks += min(NUM_ADV_SETS_CONF, MAX_NUM_BRC_BIG) + min(temp ${CFG_BLE_NUM_ADV_SETS} ${CFG_BLE_NUM_BRC_BIG_MAX}) + MATH(EXPR tasks "${tasks} + ${temp}") + endif() + endif() +endif() + +if(${CFG_BLE_CONTROLLER_CIS_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) + MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_CIG_MAX}") +endif() + +if(${CFG_BLE_CONTROLLER_SCAN_ENABLED}) + MATH(EXPR tasks "${tasks} + 1") + if(${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED}) + MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_AUX_SCAN_SLOTS}") + if (${CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED}) + MATH(EXPR tasks "${tasks} + 1") + endif() + if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED}) + # radio_tasks += min(NUM_AUX_SCAN_SLOTS_CONF, NUM_SYNC_SLOTS_CONF) + min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_SLOTS}) + MATH(EXPR tasks "${tasks} + ${temp}") + if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) + # radio_tasks += 2 * min(NUM_AUX_SCAN_SLOTS_CONF, NUM_SYNC_SLOTS_CONF) + min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_SLOTS}) + MATH(EXPR tasks "${tasks} + 2*${temp}") + endif() + if(${CFG_BLE_CONTROLLER_BIS_ENABLED}) + #radio_tasks += min(NUM_AUX_SCAN_SLOTS_CONF, MAX_NUM_SYNC_BIG) + min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_BIG_MAX}) + MATH(EXPR tasks "${tasks} +${temp}") + endif() + endif() + endif() # ${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED} + if(${CFG_BLE_CONTROLLER_CIS_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) + MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_CIG_MAX}") + endif() +endif() + +message(STATUS "Number of computed radio tasks: ${tasks}") +zephyr_compile_definitions(-DCFG_BLE_NUM_RADIO_TASKS=${tasks}) + +########### End of number of radio tasks calculation ########### + +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/dm_alloc.c) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c) + +set_source_files_properties(BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c PROPERTIES COMPILE_FLAGS -Wno-array-bounds) +set_source_files_properties(STM32_BLE/stack/config/ble_stack_user_cfg.c PROPERTIES COMPILE_FLAGS -Wno-array-parameter) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/Target/bleplat.c) +zephyr_library_sources(BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c) +zephyr_library_sources(BLE_TransparentMode/System/Interfaces/hw_aes.c) +zephyr_library_sources(BLE_TransparentMode/System/Interfaces/hw_pka.c) +zephyr_library_sources(BLE_TransparentMode/System/Interfaces/hw_rng.c) +zephyr_library_sources(BLE_TransparentMode/System/Modules/blue_unit_conversion.s) +zephyr_library_sources(BLE_TransparentMode/System/Modules/osal_memcpy.s) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc_tiny.c) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/transport_layer.c) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.c) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.c) +zephyr_library_sources(BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c) +zephyr_library_sources(BLE_TransparentMode/System/Modules/miscutil.c) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/pawr_buff_alloc.c) +zephyr_library_sources(STM32_BLE/stack/config/ble_stack_user_cfg.c) +zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c) +zephyr_library_sources(BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c) diff --git a/lib/stm32wb0/LICENSE.md b/lib/stm32wb0/LICENSE.md new file mode 100644 index 000000000..06b212251 --- /dev/null +++ b/lib/stm32wb0/LICENSE.md @@ -0,0 +1,27 @@ +Copyright 2019-2021 STMicroelectronics. +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 copyright holder 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 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; +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/lib/stm32wb0/README b/lib/stm32wb0/README new file mode 100644 index 000000000..d62937439 --- /dev/null +++ b/lib/stm32wb0/README @@ -0,0 +1,123 @@ +STM32WB0 BLE controller interfacing library +########################################### + +Origin: + STMicroelectronics + https://github.com/STMicroelectronics/STM32CubeWB0 + +Status: + version v1.0.0 + +Purpose: + This library is used on STM32WB0 series to port BLE controller library in + a hosting environment (Zephyr RTOS in current case). + +Description: + + This library is using the following files extracted from the STM32CubeWB0 package: + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dm_alloc.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/osal.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/compiler.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/Core/Inc/app_common.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/aci_l2cap_nwk.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/RADIO_utils/Inc/RADIO_utils.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/transport_layer.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc_tiny.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/pawr_buff_alloc.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/PKAMGR/Incpka_manager.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_aes.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_rng.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/miscutil.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_pka.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/fifo.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/hci_parser.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_burst.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/app_ble.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/Core/Inc/app_conf.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/crash_handler.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/ble_conf.h + Middlewares/ST/STM32_BLE/stack/include/ble_gatt.h + Middlewares/ST/STM32_BLE/stack/include/uuid.h + Middlewares/ST/STM32_BLE/stack/include/ble_stack.h + Middlewares/ST/STM32_BLE/ble.h + Middlewares/ST/STM32_BLE/stack/include/bleplat_cntr.h + Middlewares/ST/STM32_BLE/stack/include/bleplat.h + Middlewares/ST/STM32_BLE/stack/include/ble_const.h + Middlewares/ST/STM32_BLE/stack/include/ble_status.h + Middlewares/ST/STM32_BLE/stack/include/ble_stack_user_cfg.h + Middlewares/ST/STM32_BLE/stack/include/ble_api.h + Middlewares/ST/STM32_BLE/stack/include/ble_events.h + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dm_alloc.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/Target/bleplat.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_aes.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_pka.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_rng.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/blue_unit_conversion.s + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/osal_memcpy.s + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc_tiny.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/transport_layer.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/miscutil.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/pawr_buff_alloc.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c + Middlewares/ST/STM32_BLE/stack/config/ble_stack_user_cfg.c + +Dependencies: + This library depends on STM32Cube HAL API. + It is available in stm32cube/stm32wb0x/drivers + +URL: + https://github.com/STMicroelectronics/STM32CubeWB0 + +Commit: + 61d80e00cdb6136a58a33b95d2137e3bc9baa28e + +Maintained-by: + Internal + +License: + ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT + +License Link: + https://github.com/STMicroelectronics/STM32CubeWB0/blob/v1.0.0/Middlewares/ST/STM32_BLE/LICENSE.md + +Patch List: + + * Changes from the official delivery: + - Removed "gatt_profile.h" and "gap_profile.h": + Impacted file: dtm_cmd_db.c + - Added "#if (BLESTACK_CONTROLLER_ONLY == 0)" to hci_events_table: + Impacted file: dtm_preprocess_events.c + - Added "#ifndef __ZEPHYR__": + Impacted file: transport_layer.c + - Added "#ifndef __ZEPHYR__": + Impacted file: app_conf.h + - Defined Error_Handler function: + Impacted file: stm32wb0x_hal_msp.c + - Removed RT_DEBUG_GPIO_Init: + Impacted file: stm32wb0x_hal_msp.c + - Replaced "main.h" with "stm32wb0x_hal.h": + Impacted file: stm32wb0x_hal_msp.c + - Initialized Init_Delay to 0: + Impacted file: bleplat_cntr.c + - Removed cryptolib directory + - Removed lib directory + - Removed doc directory + - Added "#ifndef __ZEPHYR__": + Impacted file: dtm_cmd_en.h + - Added "#if (BLESTACK_CONTROLLER_ONLY == 0)": + Impacted file: bleplat.c diff --git a/lib/stm32wb0/STM32_BLE/ble.h b/lib/stm32wb0/STM32_BLE/ble.h new file mode 100644 index 000000000..48a1b2bd7 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/ble.h @@ -0,0 +1,46 @@ +/** + ****************************************************************************** + * @file ble.h + * @author GPM WBL Application Team + * @brief BLE interface + ***************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ***************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __BLE_H +#define __BLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Includes ------------------------------------------------------------------*/ +#include "ble_conf.h" + +/**< core */ +#include "ble_stack.h" +#include "ble_const.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* External variables --------------------------------------------------------*/ +/* Exported macros -----------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +#ifdef __cplusplus +} +#endif + +#endif /*__BLE_H */ diff --git a/lib/stm32wb0/STM32_BLE/evt_handler/inc/ble_evt.h b/lib/stm32wb0/STM32_BLE/evt_handler/inc/ble_evt.h new file mode 100644 index 000000000..7ee7f0646 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/evt_handler/inc/ble_evt.h @@ -0,0 +1,118 @@ +/** + ****************************************************************************** + * @file ble_evt.h + * @author GPM WBL Application Team + * @brief Header for BLE Event Dispatcher module + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + + +/** + * The BLE Controller supports the application to handle services and clients. + * It provides an API to initialize the BLE core Device and a handler mechanism to rout the GATT/GAP events to the + * application. When the ble_controller is used (recommended), the application shall register a callback for each + * Service and each Client implemented. This is already done with the Services and Clients provided in that delivery. + * + A GATT event is relevant to only one Service and/or one Client. When a GATT event is received, it is notified to + * the registered handlers to the BLE controller. When no registered handler acknowledges positively the GATT event, + * it is reported to the application. + * + A GAP event is not relevant to either a Service or a Client. It is sent to the application + * + In case the application does not want to take benefit from the ble_controller, it could bypass it. In that case, + * the application shall: + * - call SVCCTL_Init() to initialize the BLE core device (or implement on its own what is inside that function + * - implement TLHCI_UserEvtRx() which is the notification from the HCI layer to report all events (GATT/GAP). + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef BLE_EVT_H +#define BLE_EVT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "ble_events.h" +/* Exported types ------------------------------------------------------------*/ + + +typedef enum +{ + BLEEVT_NoAck, + BLEEVT_Ack, +} BLEEVT_EvtAckStatus_t; + +typedef BLEEVT_EvtAckStatus_t (*BLEEVT_HciPcktHandlerFunc_t)(hci_pckt *hci_pckt_p); +typedef BLEEVT_EvtAckStatus_t (*BLEEVT_GattEvtHandlerFunc_t)(aci_blecore_event *evt_p); + + + /* Exported constants --------------------------------------------------------*/ + /* External variables --------------------------------------------------------*/ + /* Exported macros -----------------------------------------------------------*/ + + /* Exported functions ------------------------------------------------------- */ +/** +* @brief It initializes the BLE Event Handler library. +* +* @param None +* @retval None +*/ +void BLEEVT_Init(void); + +/** + * @brief This API registers a handler to be called when a GATT user event is received from the BLE core device. When + * a Service is created, it shall register a callback to be notified when a GATT event is received from the + * BLE core device. When a GATT event is received, it shall be checked in the handler if the GATT events belongs + * to the Service or not. As soon as one Service handler acknowledges positively the GATT event, no other registered + * Service handlers will be called. + * The maximum number of registered handlers is controlled by BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS macros. + * This handler is called from BLEStack_Process() context. + * + * @param EvtHandlerFunc This is the Service handler that is called to report a GATT event. + * If the GATT event exclusively belongs to that Service, the callback should return positively with + * BLEEVT_Ack. + * @retval 0 Success + * @retval -1 Not able to register the handler. Increase number of supported event handlers with BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS. + */ +int BLEEVT_RegisterGattEvtHandler(BLEEVT_GattEvtHandlerFunc_t EvtHandlerFunc); + +/** + * @brief This API registers a handler to be called when a generic non-GATT event is received from the BLE core stack. + * A Bluetooth profile may use this function to be notified when an event is received. + * The maximum number of registered handlers is controlled by BLE_CFG_MAX_NBR_EVT_HANDLERS macros. + * If the handler returns BLEEVT_Ack, no other registered handlers will be called. + * This handler is called from BLEStack_Process() context. + * + * @param EvtHandlerFunc This is the Service handler that is called to report a non-GATT event. + * @retval 0 Success + * @retval -1 Not able to register the handler. Increase number of supported event handlers with BLE_CFG_MAX_NBR_EVT_HANDLERS. + */ +int BLEEVT_RegisterHandler(BLEEVT_HciPcktHandlerFunc_t EvtHandlerFunc); + +/** + * @brief This callback is triggered when either + * + a standard HCI event is received from the BLE core device. + * + a proprietary event not positively acknowledged by the registered handler is received from the + * BLE core device. + * This callback is triggered in the BLEStack_Process() context. + * + * @param hci_pckt: The user event received from the BLE core device + * @retval None + */ +void BLEEVT_App_Notification(const hci_pckt *hci_pckt); + +#ifdef __cplusplus +} +#endif + +#endif /*BLE_EVT_H */ + diff --git a/lib/stm32wb0/STM32_BLE/evt_handler/src/ble_evt.c b/lib/stm32wb0/STM32_BLE/evt_handler/src/ble_evt.c new file mode 100644 index 000000000..1182154c2 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/evt_handler/src/ble_evt.c @@ -0,0 +1,197 @@ +/** + ****************************************************************************** + * @file ble_evt.c + * @author GPM WBL Application Team + * @brief BLE Event Dispatcher + ***************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ***************************************************************************** + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "ble.h" +#include "ble_evt.h" + +#ifndef BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS +#define BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS 0 +#endif + +#ifndef BLE_CFG_MAX_NBR_EVT_HANDLERS +#define BLE_CFG_MAX_NBR_EVT_HANDLERS 0 +#endif + +/* Private typedef -----------------------------------------------------------*/ +typedef struct +{ +#if (BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS > 0) +BLEEVT_GattEvtHandlerFunc_t BLEEVT_SvcHandlerTab[BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS]; +#endif +uint8_t NbrOfRegisteredHandlers; +} BLEEVT_GattEvtHandler_t; + +typedef struct +{ +#if (BLE_CFG_MAX_NBR_EVT_HANDLERS > 0) +BLEEVT_HciPcktHandlerFunc_t BLEEVT_GenericHandlerTable[BLE_CFG_MAX_NBR_EVT_HANDLERS]; +#endif +uint8_t NbrOfRegisteredHandlers; +} BLEEVT_GenericHandler_t; + +/* Private defines -----------------------------------------------------------*/ +#define BLEEVT_EGID_EVT_MASK 0xFC00 +#define BLEEVT_GATT_EVT_TYPE (3<<10) + +/* Private macros ------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +BLEEVT_GattEvtHandler_t BLEEVT_GattEvtHandler; +BLEEVT_GenericHandler_t BLEEVT_GenericHandler; + +/* Private functions ---------------------------------------------------------*/ +/* Weak functions ------------------------------------------------------------*/ + +/* Functions Definition ------------------------------------------------------*/ + +void BLEEVT_Init(void) +{ + + /** + * Initialize the number of registered Handler + */ + BLEEVT_GattEvtHandler.NbrOfRegisteredHandlers = 0; + BLEEVT_GenericHandler.NbrOfRegisteredHandlers = 0; + + return; +} + +int BLEEVT_RegisterGattEvtHandler(BLEEVT_GattEvtHandlerFunc_t EvtHandlerFunc) +{ + if(BLEEVT_GattEvtHandler.NbrOfRegisteredHandlers == BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS) + { + return -1; + } +#if (BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS > 0) + BLEEVT_GattEvtHandler.BLEEVT_SvcHandlerTab[BLEEVT_GattEvtHandler.NbrOfRegisteredHandlers] = EvtHandlerFunc; + BLEEVT_GattEvtHandler.NbrOfRegisteredHandlers++; +#else + (void)(EvtHandlerFunc); +#endif + + return 0; +} + +int BLEEVT_RegisterHandler(BLEEVT_HciPcktHandlerFunc_t EvtHandlerFunc) +{ + if(BLEEVT_GenericHandler.NbrOfRegisteredHandlers == BLE_CFG_MAX_NBR_EVT_HANDLERS) + { + return -1; + } +#if (BLE_CFG_MAX_NBR_EVT_HANDLERS > 0) + BLEEVT_GenericHandler.BLEEVT_GenericHandlerTable[BLEEVT_GenericHandler.NbrOfRegisteredHandlers] = EvtHandlerFunc; + BLEEVT_GenericHandler.NbrOfRegisteredHandlers++; +#else + (void)(EvtHandlerFunc); +#endif + + return 0; +} + +void BLE_STACK_Event(hci_pckt *hci_pckt, uint16_t length) +{ + BLEEVT_EvtAckStatus_t event_notification_status = BLEEVT_NoAck; + + if(hci_pckt->type == HCI_EVENT_PKT_TYPE || hci_pckt->type == HCI_EVENT_EXT_PKT_TYPE) + { + void *data; + hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data; + + if(hci_pckt->type == HCI_EVENT_PKT_TYPE){ + data = event_pckt->data; + } + else { /* hci_pckt->type == HCI_EVENT_EXT_PKT_TYPE */ + hci_event_ext_pckt *event_pckt = (hci_event_ext_pckt*)hci_pckt->data; + data = event_pckt->data; + } + + if(event_pckt->evt == HCI_VENDOR_EVT_CODE) /* evt fields is at same offset in hci_event_pckt and hci_event_ext_pckt */ + { + aci_blecore_event * blecore_evt = (aci_blecore_event*) data; + + if((blecore_evt->ecode & BLEEVT_EGID_EVT_MASK) == BLEEVT_GATT_EVT_TYPE) + { + /* GATT events */ + +#if (BLE_CFG_MAX_NBR_GATT_EVT_HANDLERS > 0) + /* For GATT event handler */ + for (uint8_t index = 0; index < BLEEVT_GattEvtHandler.NbrOfRegisteredHandlers; index++) + { + event_notification_status = BLEEVT_GattEvtHandler.BLEEVT_SvcHandlerTab[index](blecore_evt); + /** + * When a GATT event has been acknowledged by application, do not call other registered handler. + * a GATT event may be relevant for only one Service + */ + if (event_notification_status == BLEEVT_Ack) + { + /** + * The event has been managed. The Event processing should be stopped + */ + break; + } + } +#endif + } + else + { + /* Proprietary non-GATT events */ + +#if (BLE_CFG_MAX_NBR_EVT_HANDLERS > 0) + /* For generic event handler */ + for(uint8_t index = 0; index 0) + /* For generic event handler () */ + for(uint8_t index = 0; index +/****************************************************************************** + * LOCAL TYPES + *****************************************************************************/ +/** + * @brief Prepare Write Context. + */ +static struct ATT_pwrq_ctx_s { + uint16_t wr_buffer_size; /**< Written buffer size. */ + uint16_t buffer_length; /**< Total buffer length. */ + uint8_t *buffer_p; /**< Buffer pointer. */ +} ATT_pwrq_ctx = { 0 }; + +/** + * Header of each stored prepared write entry. + */ +struct ATT_pwrq_entry_s { + uint16_t conn_handle; /**< Connection handle from which the prepare write was received. */ + uint16_t att_handle; /**< Attribute handle to write. */ + uint16_t pwr_offset; /**< Attribute value offset from where start to write the data. */ + uint16_t pwr_size; /**< Data size. */ +}; + +/****************************************************************************** + * LOCAL MACROS + *****************************************************************************/ +#define SIZE_32BITS_ALIGNED(VAL) ((VAL)&(~(sizeof(uint32_t) - 1U))) +#define ALIGN_UPTO_32BITS(VAL) (((((unsigned int)(VAL)) - 1U) | \ + (sizeof(uint32_t) - 1U)) + 1U) +#define ADDRESS_32BITS_ALIGNED(ADDR) ALIGN_UPTO_32BITS(ADDR) +#define PWRQ_GET_AVAILABLE_SPACE() (ATT_pwrq_ctx.buffer_length - ATT_pwrq_ctx.wr_buffer_size) +#define INVALID_ATTR_HANDLE (0x0000U) +#define INVALID_CONN_HANDLE_BIT (0x8000U) +#define CONN_HANDLE_ALL_MASK (INVALID_CONN_HANDLE_BIT - 1U) +#define CONN_HANDLE_VALID_MASK (0xFFFFU) +/******************************************************************************* + * PRIVATE PROTOTYPES + ******************************************************************************/ + +/** + * @brief Optimized function to move up fifo data. + * + * @param dest_p[in] Destination pointer. + * @param src_p[in] Source pointer. + * @param length[in] Data length. + * + * @return void + * + */ +static void ATT_pwrq_cp32align_blk_left_move(uint32_t *dest_p, + uint32_t *src_p, + uint16_t length); + +/** + * @brief Find a prepared write entry in the queue. + * + * @param conn_handle[in] The connection handle of the prepare write to find. + * @param conn_handle_mask[in] The mask to apply to connection handle value for + * matching. + * @param idx[in] The prepare write index in the queue. + * @param entry_pp[out] The entry pointer. + * + * @return + * - BLE_STATUS_SUCCESS: a prepare write was found. + * - BLE_STATUS_ERROR: no prepare write was found. + * + */ +static tBleStatus ATT_pwrq_get_entry(uint16_t conn_handle, + uint16_t conn_handle_mask, uint16_t idx, + struct ATT_pwrq_entry_s **entry_pp); + +/** + * @brief Remove a prepared write entry from the queue. + * + * @param entry_pp[in] The entry to remove. + * + * @return void. + * + */ +static void ATT_pwrq_rm_entry(struct ATT_pwrq_entry_s *entry_p); + +void ATT_pwrq_reset() +{ + ATT_pwrq_ctx.wr_buffer_size = 0U; +} + +tBleStatus ATT_pwrq_init(uint16_t queue_length, + uint8_t *queue_buffer_p) +{ + /** + * Align buffer to 32 bits. + */ + ATT_pwrq_ctx.buffer_length = (uint16_t)SIZE_32BITS_ALIGNED(queue_length); + ATT_pwrq_ctx.buffer_p = (uint8_t *)ADDRESS_32BITS_ALIGNED((uintptr_t)queue_buffer_p); + + ATT_pwrq_reset(); + + return BLE_STATUS_SUCCESS; +} + +void ATT_pwrq_flush(uint16_t conn_handle) +{ + tBleStatus ret; + struct ATT_pwrq_entry_s *entry_p; + + while (1U) + { + ret = ATT_pwrq_get_entry(conn_handle, CONN_HANDLE_ALL_MASK, 0U, &entry_p); + if (ret == BLE_STATUS_SUCCESS) + { + ATT_pwrq_rm_entry(entry_p); + } + else + { + break; + } + } +} + +tBleStatus ATT_pwrq_read(uint16_t conn_handle, uint16_t idx, + ble_gatt_clt_write_ops_t *wr_ops_p) +{ + tBleStatus ret; + struct ATT_pwrq_entry_s *entry_p; + + ret = ATT_pwrq_get_entry(conn_handle, CONN_HANDLE_VALID_MASK, idx, &entry_p); + if (ret == BLE_STATUS_SUCCESS) + { + wr_ops_p->attr_h = entry_p->att_handle; + wr_ops_p->attr_offset = entry_p->pwr_offset; + wr_ops_p->data_len = entry_p->pwr_size; + wr_ops_p->data_p = (uint8_t *)(((uint8_t *)entry_p) + sizeof(struct ATT_pwrq_entry_s)); + } + + return ret; +} + +tBleStatus ATT_pwrq_pop(uint16_t conn_handle, uint16_t attr_handle, + ble_gatt_clt_write_ops_t *wr_ops_p) +{ + tBleStatus ret; + uint16_t idx; + struct ATT_pwrq_entry_s *entry_p; + + idx = 0U; + while(1U) + { + ret = ATT_pwrq_get_entry(conn_handle, CONN_HANDLE_VALID_MASK, idx, &entry_p); + if (ret == BLE_STATUS_SUCCESS) + { + if ((attr_handle == INVALID_ATTR_HANDLE) || + (entry_p->att_handle == attr_handle)) + { + wr_ops_p->attr_h = entry_p->att_handle; + wr_ops_p->attr_offset = entry_p->pwr_offset; + wr_ops_p->data_len = entry_p->pwr_size; + wr_ops_p->data_p = (uint8_t *)(((uint8_t *)entry_p) + sizeof(struct ATT_pwrq_entry_s)); + entry_p->conn_handle |= INVALID_CONN_HANDLE_BIT; + + break; + } + idx++; + } + else + { + break; + } + } + + return ret; +} + +tBleStatus ATT_pwrq_push(uint16_t conn_handle, + uint16_t attr_h, + uint16_t data_offset, + uint16_t data_length, + uint8_t *data) +{ + tBleStatus ret; + uint16_t avail_space; + uint8_t *pwrq_data_p; + struct ATT_pwrq_entry_s *entry_p; + + ret = BLE_STATUS_ERROR; + if (ATT_pwrq_ctx.buffer_length != 0U) + { + avail_space = PWRQ_GET_AVAILABLE_SPACE(); + if (avail_space >= (sizeof(struct ATT_pwrq_entry_s) + data_length)) + { + /** + * Extract prepare write entry from the buffer. + */ + entry_p = (struct ATT_pwrq_entry_s *)(void *) + &ATT_pwrq_ctx.buffer_p[ATT_pwrq_ctx.wr_buffer_size]; + + /** + * Extract entry buffer to write received data. + */ + pwrq_data_p = &ATT_pwrq_ctx.buffer_p[ATT_pwrq_ctx.wr_buffer_size + + sizeof(struct ATT_pwrq_entry_s)]; + + /** + * Write entry parameters. + */ + entry_p->conn_handle = conn_handle; + entry_p->att_handle = attr_h; + entry_p->pwr_offset = data_offset; + entry_p->pwr_size = data_length; + + /** + * Write received data in the entry buffer. + */ + Osal_MemCpy(pwrq_data_p, data, data_length); + + /** + * Prepare entry is added. Update written buffer size. + */ + ATT_pwrq_ctx.wr_buffer_size += (uint16_t)ALIGN_UPTO_32BITS(data_length + + sizeof(struct ATT_pwrq_entry_s)); + + ret = BLE_STATUS_SUCCESS; + } + } + + return ret; +} + +static tBleStatus ATT_pwrq_get_entry(uint16_t conn_handle, + uint16_t conn_handle_mask, uint16_t idx, + struct ATT_pwrq_entry_s **entry_pp) +{ + struct ATT_pwrq_entry_s *entry_p; + uint16_t offset; + + offset = 0U; + while (offset < ATT_pwrq_ctx.wr_buffer_size) + { + /** + * Extract prepare write entry from the buffer. + */ + entry_p = (struct ATT_pwrq_entry_s *)(void *) + &ATT_pwrq_ctx.buffer_p[offset]; + + /** + * Check if the pointed prepare write entry has the requested connection + * handle. + */ + if ((entry_p->conn_handle & conn_handle_mask) == conn_handle) + { + if (idx == 0U) + { + *entry_pp = entry_p; + + return BLE_STATUS_SUCCESS; + } + idx--; + } + offset += (uint16_t)ALIGN_UPTO_32BITS(sizeof(struct ATT_pwrq_entry_s) + + entry_p->pwr_size); + } + + return BLE_STATUS_ERROR; +} + +static void ATT_pwrq_cp32align_blk_left_move(uint32_t *dest_p, + uint32_t *src_p, + uint16_t length) +{ + register uint16_t i; + + for (i = (length >> 2U); i > 0U; i--) + { + *dest_p = *src_p; + dest_p++; + src_p++; + } +} + +static void ATT_pwrq_rm_entry(struct ATT_pwrq_entry_s *entry_p) +{ + uint16_t pwrq_offset, pwrq_todel_size; + uint32_t *desti, *srci; + + pwrq_offset = (uintptr_t)(uint8_t *)entry_p - (uintptr_t)ATT_pwrq_ctx.buffer_p; + + /** + * Compute released fifo size. + */ + pwrq_todel_size = (uint16_t)ALIGN_UPTO_32BITS(sizeof(struct ATT_pwrq_entry_s) + + entry_p->pwr_size); + + /** + * Compute destination and source pointers for copy. + */ + desti = (uint32_t *)(void *)entry_p; + srci = (uint32_t *)(void *)&ATT_pwrq_ctx.buffer_p[pwrq_offset + + pwrq_todel_size]; + + /** + * Move data. + */ + ATT_pwrq_cp32align_blk_left_move(desti, srci, + ATT_pwrq_ctx.wr_buffer_size - + pwrq_todel_size - pwrq_offset); + + /** + * Remove released fifo from written buffer size. + */ + ATT_pwrq_ctx.wr_buffer_size -= pwrq_todel_size; +} + diff --git a/lib/stm32wb0/STM32_BLE/queued_writes/src/eatt_pwrq.c b/lib/stm32wb0/STM32_BLE/queued_writes/src/eatt_pwrq.c new file mode 100644 index 000000000..8a8dcf159 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/queued_writes/src/eatt_pwrq.c @@ -0,0 +1,352 @@ +/** + ****************************************************************************** + * @file att_pwrq.c + * @author GPM WBL Application Team + * @brief EATT Prepare Write Queue implementation + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +/****************************************************************************** + * INCLUDE HEADER FILES + *****************************************************************************/ +#include "ble_api.h" +#include "eatt_pwrq.h" +#include "osal.h" +#include +/****************************************************************************** + * LOCAL TYPES + *****************************************************************************/ +/** + * @brief Prepare Write Context. + */ +static struct EATT_pwrq_ctx_s { + uint16_t wr_buffer_size; /**< Written buffer size. */ + uint16_t buffer_length; /**< Total buffer length. */ + uint8_t *buffer_p; /**< Buffer pointer. */ +} EATT_pwrq_ctx = { 0 }; + +/** + * Header of each stored prepared write entry. + */ +struct EATT_pwrq_entry_s { + uint16_t conn_handle; /**< Connection handle from which the prepare write was received. */ + uint16_t cid; /**< Channel ID from which the prepare write was received. */ + uint16_t att_handle; /**< Attribute handle to write. */ + uint16_t pwr_offset; /**< Attribute value offset from where start to write the data. */ + uint16_t pwr_size; /**< Data size. */ +}; + +/****************************************************************************** + * LOCAL MACROS + *****************************************************************************/ +#define SIZE_32BITS_ALIGNED(VAL) ((VAL)&(~(sizeof(uint32_t) - 1U))) +#define ALIGN_UPTO_32BITS(VAL) (((((unsigned int)(VAL)) - 1U) | \ + (sizeof(uint32_t) - 1U)) + 1U) +#define ADDRESS_32BITS_ALIGNED(ADDR) ALIGN_UPTO_32BITS(ADDR) +#define PWRQ_GET_AVAILABLE_SPACE() (EATT_pwrq_ctx.buffer_length - EATT_pwrq_ctx.wr_buffer_size) +#define INVALID_CONN_HANDLE_BIT (0x8000U) +#define CONN_HANDLE_ALL_MASK (INVALID_CONN_HANDLE_BIT - 1U) +#define CONN_HANDLE_VALID_MASK (0xFFFFU) +/******************************************************************************* + * PRIVATE PROTOTYPES + ******************************************************************************/ + +/** + * @brief Optimized function to move up fifo data. + * + * @param dest_p[in] Destination pointer. + * @param src_p[in] Source pointer. + * @param length[in] Data length. + * + * @return void + * + */ +static void EATT_pwrq_cp32align_blk_left_move(uint32_t *dest_p, + uint32_t *src_p, + uint16_t length); + +/** + * @brief Find a prepared write entry in the queue. + * + * @param conn_handle[in] The connection handle of the prepare write to find. + * @param conn_handle_mask[in] The mask to apply to connection handle value for + * matching. + * @param cid[in] The channel ID of the prepare write. If set to 0 means the + * channel id is not checket. + * @param idx[in] The prepare write index in the queue. + * @param entry_pp[out] The entry pointer. + * + * @return + * - BLE_STATUS_SUCCESS: a prepare write was found. + * - BLE_STATUS_ERROR: no prepare write was found. + * + */ +static tBleStatus EATT_pwrq_get_entry(uint16_t conn_handle, + uint16_t conn_handle_mask, + uint16_t cid, + uint16_t idx, + struct EATT_pwrq_entry_s **entry_pp); + +/** + * @brief Remove a prepared write entry from the queue. + * + * @param entry_pp[in] The entry to remove. + * + * @return void. + * + */ +static void EATT_pwrq_rm_entry(struct EATT_pwrq_entry_s *entry_p); + +void EATT_pwrq_reset() +{ + EATT_pwrq_ctx.wr_buffer_size = 0U; +} + +tBleStatus EATT_pwrq_init(uint16_t queue_length, + uint8_t *queue_buffer_p) +{ + /** + * Align buffer to 32 bits. + */ + EATT_pwrq_ctx.buffer_length = (uint16_t)SIZE_32BITS_ALIGNED(queue_length); + EATT_pwrq_ctx.buffer_p = (uint8_t *)ADDRESS_32BITS_ALIGNED((uintptr_t)queue_buffer_p); + + EATT_pwrq_reset(); + + return BLE_STATUS_SUCCESS; +} + +void EATT_pwrq_flush(uint16_t conn_handle, + uint16_t cid) +{ + tBleStatus ret; + struct EATT_pwrq_entry_s *entry_p; + + while (1U) + { + ret = EATT_pwrq_get_entry(conn_handle, CONN_HANDLE_ALL_MASK, cid, 0U, &entry_p); + if (ret == BLE_STATUS_SUCCESS) + { + EATT_pwrq_rm_entry(entry_p); + } + else + { + break; + } + } +} + +tBleStatus EATT_pwrq_read(uint16_t conn_handle, + uint16_t cid, + uint16_t idx, + ble_gatt_clt_write_ops_t *wr_ops_p) +{ + tBleStatus ret; + struct EATT_pwrq_entry_s *entry_p; + + ret = EATT_pwrq_get_entry(conn_handle, CONN_HANDLE_VALID_MASK, cid, idx, &entry_p); + if (ret == BLE_STATUS_SUCCESS) + { + wr_ops_p->attr_h = entry_p->att_handle; + wr_ops_p->attr_offset = entry_p->pwr_offset; + wr_ops_p->data_len = entry_p->pwr_size; + wr_ops_p->data_p = (uint8_t *)(((uint8_t *)entry_p) + sizeof(struct EATT_pwrq_entry_s)); + } + + return ret; +} + +tBleStatus EATT_pwrq_pop(uint16_t conn_handle, + uint16_t cid, + uint16_t attr_handle, + ble_gatt_clt_write_ops_t *wr_ops_p) +{ + tBleStatus ret; + uint16_t idx; + struct EATT_pwrq_entry_s *entry_p; + + idx = 0U; + while (1U) + { + ret = EATT_pwrq_get_entry(conn_handle, CONN_HANDLE_VALID_MASK, cid, idx, &entry_p); + if (ret == BLE_STATUS_SUCCESS) + { + if ((attr_handle == EATT_PWRQ_ATTR_HANDLE_INVALID) || + (entry_p->att_handle == attr_handle)) + { + wr_ops_p->attr_h = entry_p->att_handle; + wr_ops_p->attr_offset = entry_p->pwr_offset; + wr_ops_p->data_len = entry_p->pwr_size; + wr_ops_p->data_p = (uint8_t *)(((uint8_t *)entry_p) + sizeof(struct EATT_pwrq_entry_s)); + entry_p->conn_handle |= INVALID_CONN_HANDLE_BIT; + + break; + } + idx++; + } + else + { + break; + } + } + + return ret; +} + +tBleStatus EATT_pwrq_push(uint16_t conn_handle, + uint16_t cid, + uint16_t attr_h, + uint16_t data_offset, + uint16_t data_length, + uint8_t *data) +{ + tBleStatus ret; + uint16_t avail_space; + uint8_t *pwrq_data_p; + struct EATT_pwrq_entry_s *entry_p; + + ret = BLE_STATUS_ERROR; + if (EATT_pwrq_ctx.buffer_length != 0U) + { + avail_space = PWRQ_GET_AVAILABLE_SPACE(); + if (avail_space >= (sizeof(struct EATT_pwrq_entry_s) + data_length)) + { + /** + * Extract prepare write entry from the buffer. + */ + entry_p = (struct EATT_pwrq_entry_s *)(void *) + &EATT_pwrq_ctx.buffer_p[EATT_pwrq_ctx.wr_buffer_size]; + + /** + * Extract entry buffer to write received data. + */ + pwrq_data_p = &EATT_pwrq_ctx.buffer_p[EATT_pwrq_ctx.wr_buffer_size + + sizeof(struct EATT_pwrq_entry_s)]; + + /** + * Write entry parameters. + */ + entry_p->conn_handle = conn_handle; + entry_p->cid = cid; + entry_p->att_handle = attr_h; + entry_p->pwr_offset = data_offset; + entry_p->pwr_size = data_length; + + /** + * Write received data in the entry buffer. + */ + Osal_MemCpy(pwrq_data_p, data, data_length); + + /** + * Prepare entry is added. Update written buffer size. + */ + EATT_pwrq_ctx.wr_buffer_size += (uint16_t)ALIGN_UPTO_32BITS(data_length + + sizeof(struct EATT_pwrq_entry_s)); + + ret = BLE_STATUS_SUCCESS; + } + } + + return ret; +} + +static tBleStatus EATT_pwrq_get_entry(uint16_t conn_handle, + uint16_t conn_handle_mask, + uint16_t cid, + uint16_t idx, + struct EATT_pwrq_entry_s **entry_pp) +{ + struct EATT_pwrq_entry_s *entry_p; + uint16_t offset; + + offset = 0U; + while (offset < EATT_pwrq_ctx.wr_buffer_size) + { + /** + * Extract prepare write entry from the buffer. + */ + entry_p = (struct EATT_pwrq_entry_s *)(void *) + &EATT_pwrq_ctx.buffer_p[offset]; + + /** + * Check if the pointed prepare write entry has the requested connection + * handle. + */ + if ((entry_p->conn_handle & conn_handle_mask) == conn_handle) + { + if (idx == 0U) + { + if (((cid != EATT_PWRQ_CID_ALL) && (cid == entry_p->cid)) || /** Filter CID */ + (cid == EATT_PWRQ_CID_ALL)) /** Any CID */ + { + *entry_pp = entry_p; + + return BLE_STATUS_SUCCESS; + } + } + idx--; + } + offset += (uint16_t)ALIGN_UPTO_32BITS(sizeof(struct EATT_pwrq_entry_s) + + entry_p->pwr_size); + } + + return BLE_STATUS_ERROR; +} + +static void EATT_pwrq_cp32align_blk_left_move(uint32_t *dest_p, + uint32_t *src_p, + uint16_t length) +{ + register uint16_t i; + + for (i = (length >> 2U); i > 0U; i--) + { + *dest_p = *src_p; + dest_p++; + src_p++; + } +} + +static void EATT_pwrq_rm_entry(struct EATT_pwrq_entry_s *entry_p) +{ + uint16_t pwrq_offset, pwrq_todel_size; + uint32_t *desti, *srci; + + pwrq_offset = (uintptr_t)(uint8_t *)entry_p - (uintptr_t)EATT_pwrq_ctx.buffer_p; + + /** + * Compute released fifo size. + */ + pwrq_todel_size = (uint16_t)ALIGN_UPTO_32BITS(sizeof(struct EATT_pwrq_entry_s) + + entry_p->pwr_size); + + /** + * Compute destination and source pointers for copy. + */ + desti = (uint32_t *)(void *)entry_p; + srci = (uint32_t *)(void *)&EATT_pwrq_ctx.buffer_p[pwrq_offset + + pwrq_todel_size]; + + /** + * Move data. + */ + EATT_pwrq_cp32align_blk_left_move(desti, srci, + EATT_pwrq_ctx.wr_buffer_size - + pwrq_todel_size - pwrq_offset); + + /** + * Remove released fifo from written buffer size. + */ + EATT_pwrq_ctx.wr_buffer_size -= pwrq_todel_size; +} + diff --git a/lib/stm32wb0/STM32_BLE/stack/config/ble_stack_user_cfg.c b/lib/stm32wb0/STM32_BLE/stack/config/ble_stack_user_cfg.c new file mode 100644 index 000000000..f88ab7d80 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/config/ble_stack_user_cfg.c @@ -0,0 +1,6237 @@ + +/** + ****************************************************************************** + * @file stack_user_cfg.c + * @author GPM WBL Application Team + * @brief BLE stack modular configuration options file + * @details BLE_Config BLE stack configuration options + * - The BLE stack v4.0 or later supports the following outstanding features: + * -- Controller Privacy + * -- LE Secure Connections + * -- Controller Scan + * -- Controller Data Length Extension + * -- LE 2M/Coded PHY + * -- Extended Advertising + * -- Periodic Advertising and Synchronizer + * -- Periodic Advertising with Responses + * -- L2CAP Connection Oriented Channels + * -- Constant Tone Extension + * -- Power Control & Path Loss Monitoring + * -- Connection Support + * -- LE Channel Classification + * -- Broadcast Isochronous Streams + * -- Connected Isochronous Streams + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + + +#include "ble_stack_user_cfg.h" + +/* check whether all the configuration flag macros are defined */ +#if !defined(CFG_BLE_CONTROLLER_PRIVACY_ENABLED) +# error "CFG_BLE_CONTROLLER_PRIVACY_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_SECURE_CONNECTIONS_ENABLED) +# error "CFG_BLE_SECURE_CONNECTIONS_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_SCAN_ENABLED) +# error "CFG_BLE_CONTROLLER_SCAN_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED) +# error "CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED) +# error "CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED) +# error "CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_L2CAP_COS_ENABLED) +# error "CFG_BLE_L2CAP_COS_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED) +# error "CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_CTE_ENABLED) +# error "CFG_BLE_CONTROLLER_CTE_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED) +# error "CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONNECTION_ENABLED) +# error "CFG_BLE_CONNECTION_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED) +# error "CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_BIS_ENABLED) +# error "CFG_BLE_CONTROLLER_BIS_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONNECTION_SUBRATING_ENABLED) +# error "CFG_BLE_CONNECTION_SUBRATING_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_CIS_ENABLED) +# error "(CFG_BLE_CONTROLLER_CIS_ENABLED is not defined" +#endif +#if !defined(CONTROLLER_ISO_ENABLED) +# error "CONTROLLER_ISO_ENABLED is not defined" +#endif +#if !defined(CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED) +# error "CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED is not defined" +#endif + +/* check whether all the dependencies between the configuration flag macros are met */ +#if (SECURE_CONNECTIONS_ENABLED == 1) && \ + (CONNECTION_ENABLED == 0) +# error "SECURE_CONNECTIONS_ENABLED cannot be 1" +#endif +#if (L2CAP_COS_ENABLED == 1) && \ + (CONNECTION_ENABLED == 0) +# error "L2CAP_COS_ENABLED cannot be 1" +#endif +#if (CONTROLLER_PERIODIC_ADV_ENABLED == 1) && \ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 0) +# error "CONTROLLER_PERIODIC_ADV_ENABLED cannot be 1" +#endif +#if (CONTROLLER_POWER_CONTROL_ENABLED == 1) && \ + (CONNECTION_ENABLED == 0) +# error "CONTROLLER_POWER_CONTROL_ENABLED cannot be 1" +#endif +#if (CONTROLLER_CHAN_CLASS_ENABLED == 1) && \ + (CONNECTION_ENABLED == 0) +# error "CONTROLLER_CHAN_CLASS_ENABLED cannot be 1" +#endif +#if (CONTROLLER_BIS_ENABLED == 1) && \ + ((CONTROLLER_EXT_ADV_SCAN_ENABLED == 0) || \ + (CONTROLLER_PERIODIC_ADV_ENABLED == 0) || \ + (CONTROLLER_ISO_ENABLED == 0)) +# error "CONTROLLER_BIS_ENABLED cannot be 1" +#endif +#if (CONNECTION_SUBRATING_ENABLED == 1) && \ + (CONNECTION_ENABLED == 0) +# error "CONNECTION_SUBRATING_ENABLED cannot be 1" +#endif +#if (CONTROLLER_CIS_ENABLED == 1) && \ + ((CONNECTION_ENABLED == 0) || \ + (CONTROLLER_ISO_ENABLED == 0)) +# error "CONTROLLER_CIS_ENABLED cannot be 1" +#endif +#if (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1) && \ + ((CONTROLLER_EXT_ADV_SCAN_ENABLED == 0) || \ + (CONTROLLER_PERIODIC_ADV_ENABLED == 0) || \ + (CONNECTION_ENABLED == 0)) +# error "CONTROLLER_PERIODIC_ADV_WR_ENABLED cannot be 1" +#endif + + +/* +* ***************************************************************************** +* BLE Stack INTERNAL core functions +* ***************************************************************************** +*/ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_set_advertising_configuration_ucfg(uint8_t Advertising_Handle, + uint8_t Discoverability_Mode, + uint16_t Advertising_Event_Properties, + uint32_t Primary_Advertising_Interval_Min, + uint32_t Primary_Advertising_Interval_Max, + uint8_t Primary_Advertising_Channel_Map, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable) +{ + return GAP_set_extended_advertising_configuration(Advertising_Handle, + Discoverability_Mode, + Advertising_Event_Properties, + Primary_Advertising_Interval_Min, + Primary_Advertising_Interval_Max, + Primary_Advertising_Channel_Map, + Peer_Address_Type, + Peer_Address, + Advertising_Filter_Policy, + Advertising_Tx_Power, + Primary_Advertising_PHY, + Secondary_Advertising_Max_Skip, + Secondary_Advertising_PHY, + Advertising_SID, + Scan_Request_Notification_Enable); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_set_scan_response_data_ucfg(uint8_t Advertising_Handle, + uint16_t Scan_Response_Data_Length, + uint8_t* Scan_Response_Data) +{ + return GAP_set_extended_scan_response_data(Advertising_Handle, + Scan_Response_Data_Length, + Scan_Response_Data); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_set_advertising_data_ucfg(uint8_t Advertising_Handle, + uint8_t Operation, + uint16_t Advertising_Data_Length, + uint8_t* Advertising_Data) +{ + return GAP_set_extended_advertising_data(Advertising_Handle, + Operation, + Advertising_Data_Length, + Advertising_Data); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_set_advertising_enable_ucfg(uint8_t Enable, + uint8_t Num_Of_Sets, + Advertising_Set_Parameters_t* Advertising_Set_Parameters) +{ + return GAP_set_extended_advertising_enable(Enable, + Num_Of_Sets, + Advertising_Set_Parameters); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus GAP_create_connection_ucfg(uint8_t* peer_address, + uint8_t peer_address_type, + uint8_t own_address_type, + uint8_t initiator_filter_policy, + uint8_t phys) +{ + return GAP_create_connection_ext(peer_address, + peer_address_type, + own_address_type, + initiator_filter_policy, + phys); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_set_scan_parameters_ucfg(uint8_t own_address_type, + uint8_t phys) +{ + return GAP_set_scan_parameters_ext(own_address_type, + phys); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_enable_disable_scan_ucfg(uint8_t enable, + uint8_t duplicate_filtering) +{ + return GAP_enable_disable_scan_ext(enable, + duplicate_filtering); +} +#else +tBleStatus GAP_enable_disable_scan_ucfg(uint8_t enable, + uint8_t duplicate_filtering) +{ + return GAP_enable_disable_scan_legacy(enable, + duplicate_filtering); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus GAP_connection_procedure_ucfg(uint8_t procedure_code, + uint8_t phys, + uint8_t peer_address_type, + uint8_t peer_address[6]) +{ + return GAP_connection_procedure(procedure_code, + phys, + peer_address_type, + peer_address); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus GAP_terminate_gap_procedure_ucfg(uint8_t procedure_code) +{ + return GAP_terminate_gap_procedure(procedure_code); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus GAP_discover_peer_name_ucfg(void) +{ + return GAP_discover_peer_name(); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void GAP_name_disc_proc_connected_check_ucfg(uint16_t task_idx) +{ + GAP_name_disc_proc_connected_check(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +void GAP_central_connection_complete_handler_ucfg(uint8_t status, + uint16_t connectionHandle) +{ + GAP_central_connection_complete_handler(status, + connectionHandle); +} +#endif +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +uint8_t GAP_parse_connectable_advertising_report_ucfg(uint8_t* adv_buf, + uint8_t extended) +{ + return GAP_parse_connectable_advertising_report(adv_buf, + extended); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) +uint8_t GAP_parse_advertising_report_ucfg(uint8_t* adv_buf, + uint8_t extended) +{ + return GAP_parse_advertising_report(adv_buf, + extended); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void GAP_DiscProcTimeoutcb_ucfg(uint8_t timer_id) +{ + GAP_DiscProcTimeoutcb(timer_id); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void GAP_LimDiscTimeoutcb_ucfg(uint8_t timer_id) +{ + GAP_LimDiscTimeoutcb(timer_id); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +void GAP_hci_le_advertising_set_terminated_evt_hndl_ucfg(uint8_t status, + uint8_t Advertising_Handle) +{ + GAP_hci_le_advertising_set_terminated_evt_hndl(status, + Advertising_Handle); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void GAP_peripheral_connection_complete_handler_ucfg(uint16_t connectionHandle) +{ + GAP_peripheral_connection_complete_handler(connectionHandle); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus GAP_enable_controller_privacy_ucfg(uint8_t* gapRole, + uint8_t* numServiceRec) +{ + return GAP_enable_controller_privacy(gapRole, + numServiceRec); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus GAP_add_device_to_filter_accept_and_resolving_list_ucfg(uint8_t lists, + uint8_t addr_type, + uint8_t addr[6]) +{ + return GAP_add_device_to_filter_accept_and_resolving_list_full(lists, + addr_type, + addr); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus GAP_clear_filter_accept_and_resolving_list_ucfg(uint8_t lists) +{ + return GAP_clear_filter_accept_and_resolving_list_full(lists); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_set_controller_random_address_ucfg(uint8_t random_address[6]) +{ + return GAP_set_controller_random_address_extended(random_address); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_init_advertising_sets_ucfg(uint8_t own_address_type) +{ + return GAP_init_advertising_sets(own_address_type); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus GAP_suspend_resume_active_advertising_sets_ucfg(uint8_t resume) +{ + return GAP_suspend_resume_active_advertising_sets_extended(resume); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +void GAP_ResumeAdvertising_ucfg(uint16_t task_idx) +{ + GAP_ResumeAdvertising(task_idx); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_acl_data_tx_cmpl_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_acl_data_tx_cmpl_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_acl_data_ind_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_acl_data_ind_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint32_t chc_csr_ucfg(void) +{ + return chc_csr(); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONNECTION_ENABLED == 1) +void Controller_Process_Q_ucfg(uint16_t task_idx) +{ + Controller_Process_Q(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +void LLC_offline_control_procedures_processing_ucfg(uint16_t task_idx) +{ + LLC_offline_control_procedures_processing(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +uint32_t cte_csr_ucfg(void) +{ + return cte_csr(); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +uint8_t hci_le_check_own_address_type_max_value_ucfg(void) +{ + return hci_le_check_own_address_type_max_value(); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) +uint32_t data_length_extension_csr_ucfg(void) +{ + return data_length_extension_csr(); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint32_t pcl_csr_ucfg(void) +{ + return pcl_csr(); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) +uint32_t phy_upd_csr_ucfg(void) +{ + return phy_upd_csr(); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) +uint32_t scan_csr_ucfg(void) +{ + return scan_csr(); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +uint32_t conn_supp_csr_ucfg(void) +{ + return conn_supp_csr(); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint32_t subrate_csr_ucfg(void) +{ + return subrate_csr(); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +tBleStatus LLC_test_check_cte_params_ucfg(void* params) +{ + return LLC_test_check_cte_params(params); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus ACL_pkt_init_ucfg(void) +{ + return ACL_pkt_init(); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_disconnection_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_disconnection_complete_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_encryption_change_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_encryption_change_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_encryption_key_refresh_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_encryption_key_refresh_complete_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_connection_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_connection_complete_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_enhanced_connection_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_enhanced_connection_complete_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_long_term_key_request_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_long_term_key_request_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_read_local_p256_public_key_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_read_local_p256_public_key_complete_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_generate_dhkey_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_generate_dhkey_complete_event_int_cb(header_p, + buff_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_advertising_report_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_advertising_report_event_int_cb(header_p, + buff_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_directed_advertising_report_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_directed_advertising_report_event_int_cb(header_p, + buff_p); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_extended_advertising_report_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_extended_advertising_report_event_int_cb(header_p, + buff_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_scan_timeout_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_scan_timeout_event_int_cb(header_p, + buff_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_advertising_set_terminated_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_advertising_set_terminated_event_int_cb(header_p, + buff_p); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_enhanced_connection_complete_v2_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return hci_le_enhanced_connection_complete_v2_event_int_cb(header_p, + buff_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) ||\ + (CONTROLLER_ISO_ENABLED == 1) +tBleStatus MBM_init_ucfg(void) +{ + return MBM_init(); +} +#endif /* (CONNECTION_ENABLED == 1) ||\ + (CONTROLLER_ISO_ENABLED == 1) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint32_t secure_connections_csr_ucfg(void) +{ + return secure_connections_csr(); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus smp_sap_scp_force_debug_key_usage_ucfg(uint8_t config_val) +{ + return smp_sap_scp_force_debug_key_usage(config_val); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_sap_hci_le_read_local_p256_public_key_complete_evt_hndl_ucfg(uint8_t status, + uint8_t local_p256_public_key[64]) +{ + smp_sap_hci_le_read_local_p256_public_key_complete_evt_hndl(status, + local_p256_public_key); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_sap_hci_le_generate_dhkey_complete_evt_hndl_ucfg(uint8_t status, + uint8_t dhkey[32]) +{ + smp_sap_hci_le_generate_dhkey_complete_evt_hndl(status, + dhkey); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint32_t l2c_cos_csr_ucfg(void) +{ + return l2c_cos_csr(); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus L2C_cos_cfc_init_ucfg(void) +{ + return L2C_cos_cfc_init(); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void l2c_cos_process_pending_actions_tsk_ucfg(uint16_t task_idx) +{ + l2c_cos_process_pending_actions_tsk(task_idx); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void L2C_cos_physical_link_disconnection_hndl_ucfg(uint16_t connection_handle) +{ + L2C_cos_physical_link_disconnection_hndl(connection_handle); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus L2C_cos_process_cfc_mode_command_ucfg(void* params) +{ + return L2C_cos_process_cfc_mode_command(params); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint8_t L2C_cos_is_pdu_cframe_cfc_command_opcode_ucfg(uint8_t opCode) +{ + return L2C_cos_is_pdu_cframe_cfc_command_opcode(opCode); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus l2c_cos_hndl_incoming_le_frame_ucfg(void* params) +{ + return l2c_cos_hndl_incoming_le_frame(params); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void l2c_cos_sdu_reassembly_tsk_ucfg(uint16_t task_idx) +{ + l2c_cos_sdu_reassembly_tsk(task_idx); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus l2c_cos_sdu_enqueue_for_segmentation_ucfg(void* params) +{ + return l2c_cos_sdu_enqueue_for_segmentation(params); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void l2c_cos_sdu_segmentation_tsk_ucfg(uint16_t task_idx) +{ + l2c_cos_sdu_segmentation_tsk(task_idx); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1)) +void l2c_cos_transmit_pdu_packets_tsk_ucfg(uint16_t task_idx) +{ + l2c_cos_transmit_pdu_packets_tsk(task_idx); +} +#endif /* ((L2CAP_COS_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus L2C_init_ucfg(uint8_t cos_enabled) +{ + return L2C_init(cos_enabled); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void llc_conn_check_subrate_and_set_params_ucfg(void* cntxt_p, + void* params_p) +{ + llc_conn_check_subrate_and_set_params(cntxt_p, + params_p); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint32_t llc_conn_calc_skip_ucfg(void* cntxt_p, + uint16_t event_counter, + uint16_t latency) +{ + return llc_conn_calc_skip(cntxt_p, + event_counter, + latency); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus llc_conn_multi_link_connection_ucfg(uint8_t enable) +{ + return llc_conn_multi_link_connection(enable); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +void llc_conn_peripheral_latency_cancellation_tsk_ucfg(uint16_t task_idx) +{ + llc_conn_peripheral_latency_cancellation_tsk(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +uint8_t llc_check_sreq_or_creq_tx_addr_ucfg(void* tx_addr7_p, + uint8_t pdu_type, + uint8_t adv_event_prop, + uint8_t adv_filter_policy, + void* peer_id_addr7_p, + void* res_peer_id_addr7_p, + uint8_t* rl_index_p) +{ + return llc_check_sreq_or_creq_tx_addr(tx_addr7_p, + pdu_type, + adv_event_prop, + adv_filter_policy, + peer_id_addr7_p, + res_peer_id_addr7_p, + rl_index_p); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +uint8_t llc_check_adv_or_srsp_or_crsp_tx_addr_ucfg(uint8_t* tx_addr7_p, + uint8_t adv_pdu, + uint8_t filter_policy, + uint8_t* peer_id_addr7_p, + uint8_t* rl_index_p, + uint8_t* res_peer_id_addr7_p) +{ + return llc_check_adv_or_srsp_or_crsp_tx_addr(tx_addr7_p, + adv_pdu, + filter_policy, + peer_id_addr7_p, + rl_index_p, + res_peer_id_addr7_p); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +uint8_t llc_check_adv_or_crsp_rx_addr_ucfg(uint8_t* rx_addr7_p, + uint8_t adv_pdu, + uint8_t filter_policy, + uint8_t* local_addr7_p, + uint8_t local_addr_type, + uint8_t rl_index) +{ + return llc_check_adv_or_crsp_rx_addr(rx_addr7_p, + adv_pdu, + filter_policy, + local_addr7_p, + local_addr_type, + rl_index); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +uint32_t bis_csr_ucfg(void) +{ + return bis_csr(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +uint32_t cis_csr_ucfg(void) +{ + return cis_csr(); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +void llc_isoal_mem_alloc_ucfg(void) +{ + llc_isoal_mem_alloc(); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +uint32_t iso_csr_ucfg(void) +{ + return iso_csr(); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus iso_rx_bn_pdu_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return iso_rx_bn_pdu_event_int_cb(header_p, + buff_p); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus iso_terminate_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return iso_terminate_event_int_cb(header_p, + buff_p); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus iso_tx_bn_pdu_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p) +{ + return iso_tx_bn_pdu_event_int_cb(header_p, + buff_p); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void llc_big_brc_mem_alloc_ucfg(void) +{ + llc_big_brc_mem_alloc(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_big_brc_alloc_streams_ucfg(void* ctx, + uint8_t stream_count) +{ + return llc_big_brc_alloc_streams(ctx, + stream_count); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void llc_big_brc_add_biginfo_to_periodic_sync_packet_ucfg(void* pointer, + uint8_t* packet_p) +{ + llc_big_brc_add_biginfo_to_periodic_sync_packet(pointer, + packet_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void* llc_big_brc_get_group_descr_of_adv_ucfg(uint8_t adv_handle) +{ + return llc_big_brc_get_group_descr_of_adv(adv_handle); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_big_brc_enqueue_pdu_ucfg(void* ctx_p, + uint32_t iso_interval_idx, + uint16_t conn_handle, + void* pdu_p) +{ + return llc_big_brc_enqueue_pdu(ctx_p, + iso_interval_idx, + conn_handle, + pdu_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +uint32_t llc_big_brc_get_own_big_event_time_ucfg(void* ctx_p, + uint16_t conn_handle, + uint16_t num_enq_packet) +{ + return llc_big_brc_get_own_big_event_time(ctx_p, + conn_handle, + num_enq_packet); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void llc_big_sync_mem_alloc_ucfg(void) +{ + llc_big_sync_mem_alloc(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_big_sync_alloc_streams_ucfg(void* ctx, + uint8_t stream_count) +{ + return llc_big_sync_alloc_streams(ctx, + stream_count); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +void llc_big_sync_deploy_sync_ucfg(uint8_t* biginfo, + uint16_t sync_handle, + uint32_t periodic_reference_anchor, + uint8_t sca_value) +{ + llc_big_sync_deploy_sync(biginfo, + sync_handle, + periodic_reference_anchor, + sca_value); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus llc_big_sync_decrypt_bis_packet_ucfg(void* ctx_p, + void* pdu_p) +{ + return llc_big_sync_decrypt_bis_packet(ctx_p, + pdu_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +uint32_t llc_big_sync_get_sdu_synchronization_us_ucfg(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset) +{ + return llc_big_sync_get_sdu_synchronization_us(conn_handle, + framed, + anchor_us, + time_offset); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_big_cmn_get_iso_params_ucfg(uint8_t direction, + uint16_t conn_handle, + void* param_p) +{ + return llc_big_cmn_get_iso_params(direction, + conn_handle, + param_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +uint32_t llc_cig_cen_get_cis_offset_from_acl_us_ucfg(void* ctx_p, + void* cis_p, + uint8_t conn_idx, + uint16_t* event_count_p, + uint32_t* cig_anchor_st_p) +{ + return llc_cig_cen_get_cis_offset_from_acl_us(ctx_p, + cis_p, + conn_idx, + event_count_p, + cig_anchor_st_p); +} +#endif + +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +uint32_t llc_cig_cen_get_sdu_synchronization_us_ucfg(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset) +{ + return llc_cig_cen_get_sdu_synchronization_us(conn_handle, + framed, + anchor_us, + time_offset); +} +#endif + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +uint32_t llc_cig_per_get_sdu_synchronization_us_ucfg(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset) +{ + return llc_cig_per_get_sdu_synchronization_us(conn_handle, + framed, + anchor_us, + time_offset); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_cig_cmn_disconnect_ucfg(uint16_t cis_handle, + uint8_t reason) +{ + return llc_cig_cmn_disconnect(cis_handle, + reason); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void llc_cig_cmn_mem_alloc_ucfg(void) +{ + llc_cig_cmn_mem_alloc(); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_cig_cmn_alloc_streams_ucfg(void* ctx, + uint8_t stream_count, + uint8_t group_type) +{ + return llc_cig_cmn_alloc_streams(ctx, + stream_count, + group_type); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void llc_cig_cmn_terminate_stream_ucfg(void* cig_p, + void* cis_p, + uint8_t reason) +{ + llc_cig_cmn_terminate_stream(cig_p, + cis_p, + reason); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +uint32_t llc_cig_cmn_get_own_cig_event_time_ucfg(void* ctx_p, + uint16_t conn_handle, + uint16_t num_enq_packet) +{ + return llc_cig_cmn_get_own_cig_event_time(ctx_p, + conn_handle, + num_enq_packet); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_cig_cmn_enqueue_pdu_to_tx_ucfg(void* ctx_p, + uint32_t iso_interval_idx, + uint16_t conn_handle, + void* pdu_p) +{ + return llc_cig_cmn_enqueue_pdu_to_tx(ctx_p, + iso_interval_idx, + conn_handle, + pdu_p); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_cig_cmn_decrypt_packet_ucfg(void* ctx_p, + void* pdu_p) +{ + return llc_cig_cmn_decrypt_packet(ctx_p, + pdu_p); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void llc_cig_cmn_start_cis_ucfg(uint8_t conn_idx, + uint16_t instant) +{ + llc_cig_cmn_start_cis(conn_idx, + instant); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +uint8_t llc_cig_cmn_is_active_cis_on_acl_ucfg(uint16_t acl_conn_handle) +{ + return llc_cig_cmn_is_active_cis_on_acl(acl_conn_handle); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void llc_cig_cmn_terminate_cises_on_acl_ucfg(uint16_t acl_conn_handle) +{ + llc_cig_cmn_terminate_cises_on_acl(acl_conn_handle); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void llc_cig_cmn_cis_established_event_gen_ucfg(void* cig_p, + void* cis_p, + uint8_t status) +{ + llc_cig_cmn_cis_established_event_gen(cig_p, + cis_p, + status); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_cig_cmn_get_iso_params_ucfg(uint8_t direction, + uint16_t conn_handle, + void* param_p) +{ + return llc_cig_cmn_get_iso_params(direction, + conn_handle, + param_p); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus llc_cig_cmn_read_iso_link_quality_ucfg(uint16_t conn_handle, + uint32_t* tx_unacked_packets_p, + uint32_t* tx_flushed_packets_p, + uint32_t* tx_last_subevent_packets_p, + uint32_t* retransmitted_packets_p, + uint32_t* crc_error_packets_p, + uint32_t* rx_unreceived_packets_p, + uint32_t* duplicate_packets_p) +{ + return llc_cig_cmn_read_iso_link_quality(conn_handle, + tx_unacked_packets_p, + tx_flushed_packets_p, + tx_last_subevent_packets_p, + retransmitted_packets_p, + crc_error_packets_p, + rx_unreceived_packets_p, + duplicate_packets_p); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +void llc_iso_cmn_mem_alloc_ucfg(void) +{ + llc_iso_cmn_mem_alloc(); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +#if ((CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +void llc_padv_mem_allocate_ucfg(uint8_t eadv_en, + uint8_t padv_en, + uint8_t nr_of_adv_sets, + uint8_t* more_info_p) +{ + llc_padv_wr_mem_allocate(eadv_en, + padv_en, + nr_of_adv_sets, + more_info_p); +} +#else +void llc_padv_mem_allocate_ucfg(uint8_t eadv_en, + uint8_t padv_en, + uint8_t nr_of_adv_sets, + uint8_t* more_info_p) +{ + llc_padv_mem_allocate(eadv_en, + padv_en, + nr_of_adv_sets, + more_info_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +void llc_padv_init_ucfg(void) +{ + llc_padv_init(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +tBleStatus llc_padv_set_periodic_advertising_data_ucfg(uint16_t advertising_handle, + uint8_t operation, + uint16_t data_length, + uint8_t* data_p) +{ + return llc_padv_set_periodic_advertising_data(advertising_handle, + operation, + data_length, + data_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +uint8_t llc_padv_check_if_syncinfo_is_included_and_start_periodic_advertising_ucfg(void* context_p) +{ + return llc_padv_check_if_syncinfo_is_included_and_start_periodic_advertising(context_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +uint8_t llc_padv_update_sync_info_ucfg(void* padv_per_p, + uint32_t aux_adv_ind_anchor) +{ + return llc_padv_update_sync_info(padv_per_p, + aux_adv_ind_anchor); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +void llc_padv_prepare_periodic_advertising_payload_ucfg(void* padv_per_p, + uint8_t extended_header_flags, + uint8_t* payload_p) +{ + llc_padv_prepare_periodic_advertising_payload(padv_per_p, + extended_header_flags, + payload_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +uint32_t llc_padv_periodic_adv_sync_csr_ucfg(void) +{ + return llc_padv_periodic_adv_sync_csr(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +uint8_t llc_padv_wr_create_connection_cancel_ucfg(void* _padv_per_p, + uint8_t advertising_handle) +{ + return llc_padv_wr_create_connection_cancel(_padv_per_p, + advertising_handle); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +void llc_padv_wr_set_start_parameters_ucfg(void* set_padv_wr_start_parameters_p) +{ + llc_padv_wr_set_start_parameters(set_padv_wr_start_parameters_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus llc_padv_wr_set_periodic_advertising_subevent_data_ucfg(void* set_padv_wr_data_p) +{ + return llc_padv_wr_set_periodic_advertising_subevent_data(set_padv_wr_data_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +uint8_t llc_padv_wr_set_ctrdata_ucfg(void* padv_per_p, + uint8_t* ctrdata_p) +{ + return llc_padv_wr_set_ctrdata(padv_per_p, + ctrdata_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +void llc_padv_wr_set_acad_ucfg(void* padv_per_p, + uint8_t* ext_hdr_p) +{ + llc_padv_wr_set_acad(padv_per_p, + ext_hdr_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +void llc_padv_wr_init_anchors_and_counters_ucfg(void* padv_per_p) +{ + llc_padv_wr_init_anchors_and_counters(padv_per_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +uint32_t llc_padv_periodic_adv_sync_wr_csr_ucfg(void) +{ + return llc_padv_periodic_adv_sync_wr_csr(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +void llc_padv_wr_disable_ext_ucfg(void* _padv_per_p) +{ + llc_padv_wr_disable_ext(_padv_per_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_generate_peer_rpa_from_peer_id_ucfg(void* peer_p, + uint8_t in_isr) +{ + llc_priv_generate_peer_rpa_from_peer_id(peer_p, + in_isr); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_init_ucfg(uint8_t first_call) +{ + llc_priv_init(first_call); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_generate_local_rpa_from_peer_id_ucfg(void* peer_id_p, + void* local_rpa_p) +{ + llc_priv_generate_local_rpa_from_peer_id(peer_id_p, + local_rpa_p); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_offline_rpa_resolution_ucfg(uint16_t task_idx) +{ + llc_priv_offline_rpa_resolution(task_idx); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +uint32_t llc_priv_controller_privacy_csr_ucfg(void) +{ + return llc_priv_controller_privacy_csr(); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_set_filter_accept_list_flag_in_resolving_list_ucfg(void* addr8_p, + uint8_t set) +{ + llc_priv_set_filter_accept_list_flag_in_resolving_list(addr8_p, + set); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_clr_all_filter_accept_list_flags_in_resolving_list_ucfg(void) +{ + llc_priv_clr_all_filter_accept_list_flags_in_resolving_list(); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_start_privacy_timer_ucfg(void) +{ + llc_priv_start_privacy_timer(); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_stop_privacy_timer_ucfg(void) +{ + llc_priv_stop_privacy_timer(); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_init_random_part_of_one_local_rpa_ucfg(void* peer_id_p) +{ + llc_priv_init_random_part_of_one_local_rpa(peer_id_p); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) +void llc_pscan_cancel_slot_cte_ucfg(void* cntxt_per_p) +{ + llc_pscan_cancel_slot_cte(cntxt_per_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +uint8_t llc_pscan_isr_ucfg(void* cntxt_per_p) +{ + return llc_pscan_isr(cntxt_per_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +void llc_pscan_init_ucfg(void) +{ + llc_pscan_init(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +void llc_pscan_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en) +{ + llc_pscan_mem_allocate(scan_en, + ext_en, + pscan_en); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +uint8_t llc_pscan_create_sync_pending_ucfg(void) +{ + return llc_pscan_create_sync_pending(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) +void llc_pscan_enable_adv_addr_ucfg(void* list_p) +{ + llc_pscan_enable_adv_addr(list_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_push_padv_report_event_ucfg(void* params) +{ + llc_pscan_push_padv_report_event(params); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_push_past_received_event_ucfg(void* params) +{ + llc_pscan_push_past_received_event(params); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_push_sync_established_event_ucfg(void* params) +{ + llc_pscan_push_sync_established_event(params); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +uint8_t llc_pscan_check_address_ucfg(void* addr_p) +{ + return llc_pscan_check_address(addr_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +void llc_pscan_synchronizing_ucfg(void* params_p) +{ + llc_pscan_synchronizing(params_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) +void llc_pscan_wrong_cte_type_ucfg(void* cntxt_p) +{ + llc_pscan_wrong_cte_type(cntxt_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_wr_init_ucfg(void) +{ + llc_pscan_wr_init(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_wr_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t pscan_wr_en, + uint8_t conn_en) +{ + llc_pscan_wr_mem_allocate(scan_en, + ext_en, + pscan_en, + pscan_wr_en, + conn_en); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_wr_per_init_ucfg(uint8_t sync_idx) +{ + llc_pscan_wr_per_init(sync_idx); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_wr_config_tx_blue_sm_ucfg(void* params_p, + uint8_t pawr_feat) +{ + llc_pscan_wr_config_tx_blue_sm(params_p, + pawr_feat); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +uint8_t llc_pscan_wr_get_pawr_info_ucfg(uint8_t acad_size, + uint8_t* acad_p, + uint8_t* pawr_info_p) +{ + return llc_pscan_wr_get_pawr_info(acad_size, + acad_p, + pawr_info_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +uint8_t llc_pscan_wr_check_pawr_active_ucfg(uint8_t conn_idx) +{ + return llc_pscan_wr_check_pawr_active(conn_idx); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +uint8_t llc_pscan_wr_check_pawr_info_ucfg(void* params_p) +{ + return llc_pscan_wr_check_pawr_info(params_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +uint8_t llc_pscan_wr_reserve_taskslots_ucfg(void* params_p, + uint8_t pawr_feat) +{ + return llc_pscan_wr_reserve_taskslots(params_p, + pawr_feat); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_wr_set_pscan_cntxt_ucfg(void* cntxt_p, + void* params_p) +{ + llc_pscan_wr_set_pscan_cntxt(cntxt_p, + params_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_pscan_wr_set_scheduler_params_ucfg(void* params_p) +{ + llc_pscan_wr_set_scheduler_params(params_p); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_scan_conn_ind_sent_ucfg(void* ptr, + uint8_t idx) +{ + llc_scan_conn_ind_sent(ptr, + idx); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +uint8_t llc_scan_process_ext_adv_ucfg(void* scan_p, + void* params_p, + uint32_t direct_addr[2], + uint8_t idx, + uint8_t advertiser_addr_flag, + uint8_t* send_report_p) +{ + return llc_scan_process_ext_adv(scan_p, + params_p, + direct_addr, + idx, + advertiser_addr_flag, + send_report_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_scan_aux_conn_rsp_rcvd_ucfg(void* scan_p, + void* aux_p, + uint8_t idx) +{ + llc_scan_aux_conn_rsp_rcvd(scan_p, + aux_p, + idx); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) +void llc_scan_init_ucfg(uint8_t ext_en) +{ + llc_scan_init(ext_en); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) +void llc_scan_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en) +{ + llc_scan_mem_allocate(scan_en, + ext_en); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_scan_prepare_conn_ind_req_ucfg(void* ptr, + uint8_t idx, + uint8_t aux_conn_req) +{ + llc_scan_prepare_conn_ind_req(ptr, + idx, + aux_conn_req); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +void llc_scan_enable_extended_ucfg(void* scan_p) +{ + llc_scan_enable_extended(scan_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +void llc_scan_push_ext_adv_report_ucfg(void* ptr, + uint8_t data_len, + uint8_t data_offset, + uint8_t event_type) +{ + llc_scan_push_ext_adv_report(ptr, + data_len, + data_offset, + event_type); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus llc_scan_reserve_taskslots_ucfg(void* scan_en_p, + void* scan_p) +{ + return llc_scan_reserve_taskslots(scan_en_p, + scan_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_scan_set_conn_params_ucfg(Extended_Create_Connection_Parameters_t ext_create_conn_params, + uint8_t initiating_phy) +{ + llc_scan_set_conn_params(ext_create_conn_params, + initiating_phy); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +void llc_scan_disable_ucfg(void* scan_p) +{ + llc_scan_disable(scan_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint8_t llc_subrate_get_active_sr_req_proc_ucfg(uint8_t conn_idx) +{ + return llc_subrate_get_active_sr_req_proc(conn_idx); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void llc_subrate_new_sr_base_event_ucfg(uint16_t sr_factor, + uint16_t* sr_base_event_p) +{ + llc_subrate_new_sr_base_event(sr_factor, + sr_base_event_p); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void llc_subrate_update_cont_counter_ucfg(void* cntxt_p) +{ + llc_subrate_update_cont_counter(cntxt_p); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint8_t llc_subrate_offline_processing_ucfg(void* cntxt_p) +{ + return llc_subrate_offline_processing(cntxt_p); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +void llc_mngm_csa2_select_subevent_channel_ucfg(uint8_t subevent_counter, + uint8_t* subevent_index_p, + uint16_t prn_s, + uint8_t remapping_index_of_last_used_channel, + uint16_t* prn_subevent_lu_p, + uint16_t channel_identifier, + void* _csa2_table_p, + uint8_t* channel_index_p) +{ + llc_mngm_csa2_select_subevent_channel(subevent_counter, + subevent_index_p, + prn_s, + remapping_index_of_last_used_channel, + prn_subevent_lu_p, + channel_identifier, + _csa2_table_p, + channel_index_p); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_cpe_init_length_update_ucfg(void) +{ + LL_cpe_init_length_update(); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_cpe_init_phy_update_ucfg(void) +{ + LL_cpe_init_phy_update(); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_cpe_init_cte_ucfg(void) +{ + LL_cpe_init_cte(); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +void LL_cpe_init_past_ucfg(void) +{ + LL_cpe_init_past(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LL_cpe_init_pcl_ucfg(void) +{ + LL_cpe_init_pcl(); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONNECTION_ENABLED == 1) +void LL_cpe_init_conn_update_ucfg(void) +{ + LL_cpe_init_conn_update(); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +void LL_cpe_init_chmap_update_ucfg(void) +{ + LL_cpe_init_chmap_update(); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LL_cpe_init_chc_enable_ucfg(void) +{ + LL_cpe_init_chc_enable(); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LL_cpe_init_chc_reporting_ucfg(void) +{ + LL_cpe_init_chc_reporting(); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LL_cpe_init_subrate_ucfg(void) +{ + LL_cpe_init_subrate(); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void LL_cpe_init_sca_upd_ucfg(void) +{ + LL_cpe_init_sca_upd(); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void LL_cpe_init_cis_ucfg(void) +{ + LL_cpe_init_cis(); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if (CONNECTION_ENABLED == 1) +void LL_cpe_init_ucfg(void) +{ + LL_cpe_init(); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LLC_channel_map_copy_to_cpf_context_ucfg(void* cntxt_p, + uint8_t conn_idx) +{ + LLC_channel_map_copy_to_cpf_context(cntxt_p, + conn_idx); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +uint8_t LLC_channel_map_update_offline_processing_ucfg(uint8_t conn_idx) +{ + return LLC_channel_map_update_offline_processing(conn_idx); +} +#endif + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LLC_conn_init_chc_ctxt_ucfg(uint8_t conn_idx) +{ + LLC_conn_init_chc_ctxt(conn_idx); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LLC_chc_ll_cntxt_init_ucfg(void) +{ + LLC_chc_ll_cntxt_init(); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint8_t LLC_chc_reporting_offline_processing_ucfg(uint8_t conn_idx) +{ + return LLC_chc_reporting_offline_processing(conn_idx); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +void LL_cpf_cis_processing_ucfg(uint16_t task_idx) +{ + LL_cpf_cis_processing(task_idx); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_conn_upd_max_tx_time_coded_ucfg(void* params) +{ + LL_conn_upd_max_tx_time_coded(params); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_conn_upd_data_length_change_event_ucfg(void* params) +{ + LL_conn_upd_data_length_change_event(params); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_conn_init_cte_ctxt_ucfg(uint8_t conn_idx) +{ + llc_conn_init_cte_ctxt(conn_idx); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +uint8_t LLC_cte_request_procedure_ucfg(void* params) +{ + return LLC_cte_request_procedure(params); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LLC_connection_cte_response_pause_resume_ucfg(uint8_t conn_idx, + uint8_t tx_phy) +{ + LLC_connection_cte_response_pause_resume(conn_idx, + tx_phy); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LLC_connection_cte_response_disable_ucfg(uint8_t conn_idx, + uint8_t taskslot_no) +{ + LLC_connection_cte_response_disable(conn_idx, + taskslot_no); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +void llc_cte_process_rx_cte_ucfg(void* params, + uint8_t cte_type) +{ + llc_cte_process_rx_cte(params, + cte_type); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +void LLC_authenticated_payload_timeout_processing_ucfg(uint16_t task_idx) +{ + LLC_authenticated_payload_timeout_processing(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void llc_past_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t conn_en) +{ + llc_past_mem_allocate(scan_en, + ext_en, + pscan_en, + conn_en); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_past_load_txctrl_packet_from_scanner_ucfg(void* params, + uint8_t* pdu_p, + uint32_t instant_anchor, + uint32_t connect_interval, + uint16_t connect_event_count, + uint16_t connect_event_cnt) +{ + LL_past_load_txctrl_packet_from_scanner(params, + pdu_p, + instant_anchor, + connect_interval, + connect_event_count, + connect_event_cnt); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_periodicscan_deploy_scanner_from_past_ucfg(void* params, + uint8_t conn_idx, + uint8_t pawr_feat) +{ + LL_periodicscan_deploy_scanner_from_past(params, + conn_idx, + pawr_feat); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_past_initialize_connect_context_ucfg(uint8_t conn_idx) +{ + LL_past_initialize_connect_context(conn_idx); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_past_default_params_ucfg(uint8_t conn_idx) +{ + LL_past_default_params(conn_idx); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void llc_conn_init_pcl_ctxt_ucfg(uint8_t conn_idx) +{ + llc_conn_init_pcl_ctxt(conn_idx); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LLC_pcl_hal_cntxt_init_ucfg(uintptr_t pcl_cntxt_p) +{ + LLC_pcl_hal_cntxt_init(pcl_cntxt_p); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LLC_pcl_incr_rx_packets_ucfg(uint8_t conn_idx) +{ + LLC_pcl_incr_rx_packets(conn_idx); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LLC_pcl_update_avg_rssi_ucfg(void* params) +{ + LLC_pcl_update_avg_rssi(params); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LLC_pcl_set_radio_tx_power_conn_start_ucfg(uint8_t conn_idx) +{ + LLC_pcl_set_radio_tx_power_conn_start(conn_idx); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint8_t LLC_pcl_get_radio_tx_power_ucfg(uint8_t conn_idx, + uint8_t phy_idx) +{ + return LLC_pcl_get_radio_tx_power(conn_idx, + phy_idx); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void LLC_pcl_set_radio_tx_power_and_eval_indication_ucfg(uint8_t conn_idx, + uint8_t send_ind, + int8_t ind_delta, + uint8_t change_txpower) +{ + LLC_pcl_set_radio_tx_power_and_eval_indication(conn_idx, + send_ind, + ind_delta, + change_txpower); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +uint8_t LLC_pcl_offline_processing_ucfg(uint8_t conn_idx) +{ + return LLC_pcl_offline_processing(conn_idx); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus LL_Read_RSSI_ucfg(int8_t* rssiVal, + uint16_t connHandle) +{ + return LL_Read_RSSI(rssiVal, + connHandle); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +uint8_t LLC_pcl_get_number_of_phys_ucfg(void) +{ + return LLC_pcl_get_number_of_phys(); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_phy_upd_compute_data_PDU_length_params_ucfg(void* params) +{ + LL_phy_upd_compute_data_PDU_length_params(params); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) +uint8_t LL_phy_upd_pending_ucfg(uint8_t conn_idx) +{ + return LL_phy_upd_pending(conn_idx); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus LL_phy_update_init_ucfg(void) +{ + return LL_phy_update_init(); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus LL_phy_update_init_per_st_data_ucfg(uint8_t conn_idx) +{ + return LL_phy_update_init_per_st_data(conn_idx); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +void LL_phy_upd_evt_pending_check_isr_ucfg(uint8_t conn_idx) +{ + LL_phy_upd_evt_pending_check_isr(conn_idx); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) +void LLC_blueapi_cte_ucfg(void* params) +{ + LLC_blueapi_cte(params); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) +void LLC_connless_process_rx_cte_ucfg(uint8_t iq_samples_ready, + void* params, + uint8_t iq_samples_number, + uint8_t rx_cte_type, + uint8_t channel) +{ + LLC_connless_process_rx_cte(iq_samples_ready, + params, + iq_samples_number, + rx_cte_type, + channel); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) +uint8_t LLC_check_iq_samples_ready_ucfg(uint8_t* iq_samples_number, + uint8_t* channel, + uint8_t taskslot_no) +{ + return LLC_check_iq_samples_ready(iq_samples_number, + channel, + taskslot_no); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) +void llc_cte_init_ucfg(void) +{ + llc_cte_init(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +void llc_cte_mem_allocate_ucfg(uint8_t cte_en, + uint8_t scan_en, + uint8_t ext_en, + uint8_t periodic_en) +{ + llc_cte_mem_allocate(cte_en, + scan_en, + ext_en, + periodic_en); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) +void llc_cte_timer_error_ucfg(void) +{ + llc_cte_timer_error(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) +void llc_cte_timer_start_ucfg(void* params) +{ + llc_cte_timer_start(params); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) +uint8_t llc_cte_timer_stop_ucfg(void) +{ + return llc_cte_timer_stop(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +void LLC_test_process_rx_cte_ucfg(void* params) +{ + LLC_test_process_rx_cte(params); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +void LLC_test_set_cte_ucfg(void* params) +{ + LLC_test_set_cte(params); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +void ADV_ISR_connect_request_received_ucfg(void* pointer, + uint8_t* packet, + void* PeerIDAddress_p) +{ + ADV_ISR_connect_request_received(pointer, + packet, + PeerIDAddress_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +void LL_eadv_EauxIsr_connect_response_sent_ucfg(void* pointer) +{ + LL_eadv_EauxIsr_connect_response_sent(pointer); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +void LL_eadv_EauxIsr_connect_request_received_ucfg(void* pointer, + uint8_t* calibration_required) +{ + LL_eadv_EauxIsr_connect_request_received(pointer, + calibration_required); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +uint8_t EADV_start_request_radio_tasks_ucfg(void* pointer) +{ + return EADV_start_request_radio_tasks(pointer); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus llc_eadv_max_supported_data_check_ucfg(uint16_t data_length, + void* pointer) +{ + return llc_eadv_max_supported_data_check(data_length, + pointer); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +void LL_eadv_start_extended_ucfg(void* pointer) +{ + LL_eadv_start_extended(pointer); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +uint8_t ext_adv_scan_enabled_ucfg(void) +{ + return ext_adv_scan_enabled(); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +tBleStatus LL_Clear_Advertising_Sets_ucfg(void) +{ + return LL_Clear_Advertising_Sets(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +tBleStatus LL_Remove_Advertising_Set_ucfg(uint16_t Advertising_Handle) +{ + return LL_Remove_Advertising_Set(Advertising_Handle); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +uint8_t Data_Len_Update_Offline_Processing_ucfg(void* params, + uint32_t ctrl_flds) +{ + return Data_Len_Update_Offline_Processing(params, + ctrl_flds); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) +tBleStatus ll_write_supported_data_ucfg(uint16_t Supported_Max_Tx_Octets, + uint16_t Supported_Max_Tx_Time, + uint16_t Supported_Max_Rx_Octets, + uint16_t Supported_Max_Rx_Time) +{ + return ll_write_supported_data(Supported_Max_Tx_Octets, + Supported_Max_Tx_Time, + Supported_Max_Rx_Octets, + Supported_Max_Rx_Time); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +void LL_init_ucfg(uint8_t dataLenExt, + uint8_t PhyUpd, + uint8_t ExtAdvScan, + uint8_t CtrlPriv, + uint8_t ScanSupp, + uint8_t PerAdvScan, + uint8_t PerAdvScanWr, + uint8_t Cte, + uint8_t Pcl, + uint8_t Cns, + uint8_t Chc) +{ + LL_init(dataLenExt, + PhyUpd, + ExtAdvScan, + CtrlPriv, + ScanSupp, + PerAdvScan, + PerAdvScanWr, + Cte, + Pcl, + Cns, + Chc); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus smp_debug_trudy__set_config_ucfg(uint32_t config) +{ + return smp_debug_trudy__set_config(config); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus smp_start_encryption_ucfg(void* params) +{ + return smp_start_encryption(params); +} +#endif +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus smp_pp1_cei_send_pairing_request_ucfg(void* params) +{ + return smp_pp1_cei_send_pairing_request(params); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus smp_pp1_cei_rxp_pairing_response_excerpt_scp_ucfg(void* params) +{ + return smp_pp1_cei_rxp_pairing_response_excerpt_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_pp2_cei_auth_stage1_start_excerpt_scp_ucfg(void* params) +{ + smp_pp2_cei_auth_stage1_start_excerpt_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_pp2_per_auth_stage1_start_excerpt_scp_ucfg(void* params) +{ + smp_pp2_per_auth_stage1_start_excerpt_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_pp2_cei_send_pairing_confirm_excerpt_scp_ucfg(void* params) +{ + smp_pp2_cei_send_pairing_confirm_excerpt_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus smp_pp2_cei_rx_process_pairing_random_excerpt1_scp_ucfg(void* params) +{ + return smp_pp2_cei_rx_process_pairing_random_excerpt1_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_pp2_cei_rx_process_pairing_random_excerpt2_scp_ucfg(void* params) +{ + smp_pp2_cei_rx_process_pairing_random_excerpt2_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_pp2_per_rx_process_pairing_confirm_excerpt_scp_ucfg(void* params) +{ + smp_pp2_per_rx_process_pairing_confirm_excerpt_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_pp2_per_rx_process_pairing_random_excerpt_scp_ucfg(void* params) +{ + smp_pp2_per_rx_process_pairing_random_excerpt_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_scp_init_ucfg(uint8_t use_debug_key) +{ + smp_scp_init(use_debug_key); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus smp_scp_continue_on_exclusive_sc_pairing_ucfg(void* params) +{ + return smp_scp_continue_on_exclusive_sc_pairing(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus smp_scp_public_key_prepare_and_exchange_ucfg(void* params) +{ + return smp_scp_public_key_prepare_and_exchange(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus smp_scp_oob_generate_new_local_data_ucfg(void) +{ + return smp_scp_oob_generate_new_local_data(); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_scp_stats_update_on_pairing_complete_ucfg(void* params) +{ + smp_scp_stats_update_on_pairing_complete(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void smp_fsm_process_actions_wrt_state_tsk_ucfg(uint16_t task_idx) +{ + smp_fsm_process_actions_wrt_state_tsk(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1)) +void smp_fsm_execute_actions_scp_phase2as2_ucfg(void* params) +{ + smp_fsm_execute_actions_scp_phase2as2(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +void smp_fsm_execute_actions_excerpt_cei_ucfg(void* params) +{ + smp_fsm_execute_actions_excerpt_cei(params); +} +#endif +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +void smp_pka_process_ecc_computation_tsk_ucfg(uint16_t task_idx) +{ + smp_pka_process_ecc_computation_tsk(task_idx); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void smp_rxp_process_rxed_packets_tsk_ucfg(uint16_t task_idx) +{ + smp_rxp_process_rxed_packets_tsk(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus smp_rxp_process_exception_cases_excerpt_scp_ucfg(void* params) +{ + return smp_rxp_process_exception_cases_excerpt_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus smp_rxp_process_wrt_current_fsm_excerpt_scp_ucfg(void* params) +{ + return smp_rxp_process_wrt_current_fsm_excerpt_scp(params); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus smp_rxp_process_wrt_current_fsm_excerpt_cei_ucfg(void* params) +{ + return smp_rxp_process_wrt_current_fsm_excerpt_cei(params); +} +#endif +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void smp_init_ucfg(void) +{ + smp_init(); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void GAT_att_cmn_init_ucfg(void) +{ + GAT_att_cmn_init(); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void GAT_att_cmn_timer_expire_tsk_ucfg(uint16_t task_idx) +{ + GAT_att_cmn_timer_expire_tsk(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void GAT_att_cmn_tx_pool_evt_tsk_ucfg(uint16_t task_idx) +{ + GAT_att_cmn_tx_pool_evt_tsk(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void GAT_att_srv_process_rx_pckt_tsk_ucfg(uint16_t task_idx) +{ + GAT_att_srv_process_rx_pckt_tsk(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void GAT_srv_db_hash_tsk_ucfg(uint16_t task_idx) +{ + GAT_srv_db_hash_tsk(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +void GAT_srv_send_srv_change_tsk_ucfg(uint16_t task_idx) +{ + GAT_srv_send_srv_change_tsk(task_idx); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + + +/* +* ***************************************************************************** +* BLE Stack API functions +* ***************************************************************************** +*/ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_terminate(uint16_t Connection_Handle, + uint8_t Reason) +{ + return aci_gap_terminate_api(Connection_Handle, + Reason); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus aci_gap_start_connection_update(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length) +{ + return aci_gap_start_connection_update_api(Connection_Handle, + Connection_Interval_Min, + Connection_Interval_Max, + Max_Latency, + Supervision_Timeout, + Min_CE_Length, + Max_CE_Length); +} +#endif +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus aci_gap_set_scan_configuration(uint8_t duplicate_filtering, + uint8_t scanning_filter_policy, + uint8_t phy, + uint8_t scan_type, + uint16_t scan_interval, + uint16_t scan_window) +{ + return aci_gap_set_scan_configuration_api(duplicate_filtering, + scanning_filter_policy, + phy, + scan_type, + scan_interval, + scan_window); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_set_connection_configuration(uint8_t phy, + uint16_t connection_interval_min, + uint16_t connection_interval_max, + uint16_t max_latency, + uint16_t supervision_timeout, + uint16_t min_ce_length, + uint16_t max_ce_length) +{ + return aci_gap_set_connection_configuration_api(phy, + connection_interval_min, + connection_interval_max, + max_latency, + supervision_timeout, + min_ce_length, + max_ce_length); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_create_connection(uint8_t Initiating_PHY, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]) +{ + return aci_gap_create_connection_api(Initiating_PHY, + Peer_Address_Type, + Peer_Address); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus aci_gap_start_procedure(uint8_t procedure_code, + uint8_t phys, + uint16_t duration, + uint16_t period) +{ + return aci_gap_start_procedure_api(procedure_code, + phys, + duration, + period); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_discover_name(uint8_t PHYs, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]) +{ + return aci_gap_discover_name_api(PHYs, + Peer_Address_Type, + Peer_Address); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus aci_gap_terminate_proc(uint8_t Procedure_Code) +{ + return aci_gap_terminate_proc_api(Procedure_Code); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_create_periodic_advertising_connection(uint8_t Advertising_Handle, + uint8_t Subevent, + uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length) +{ + return aci_gap_create_periodic_advertising_connection_api(Advertising_Handle, + Subevent, + Initiator_Filter_Policy, + Own_Address_Type, + Peer_Address_Type, + Peer_Address, + Connection_Interval_Min, + Connection_Interval_Max, + Max_Latency, + Supervision_Timeout, + Min_CE_Length, + Max_CE_Length); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus aci_gap_remove_advertising_set(uint8_t Advertising_Handle) +{ + return aci_gap_remove_advertising_set_api(Advertising_Handle); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus aci_gap_clear_advertising_sets(void) +{ + return aci_gap_clear_advertising_sets_api(); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_set_io_capability(uint8_t IO_Capability) +{ + return aci_gap_set_io_capability_api(IO_Capability); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_set_security_requirements(uint8_t Bonding_Mode, + uint8_t MITM_Mode, + uint8_t SC_Support, + uint8_t KeyPress_Notification_Support, + uint8_t Min_Encryption_Key_Size, + uint8_t Max_Encryption_Key_Size, + uint8_t Pairing_Response) +{ + return aci_gap_set_security_requirements_api(Bonding_Mode, + MITM_Mode, + SC_Support, + KeyPress_Notification_Support, + Min_Encryption_Key_Size, + Max_Encryption_Key_Size, + Pairing_Response); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_set_security(uint16_t Connection_Handle, + uint8_t Security_Level, + uint8_t Force_Pairing) +{ + return aci_gap_set_security_api(Connection_Handle, + Security_Level, + Force_Pairing); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_pairing_resp(uint16_t Connection_Handle, + uint8_t Accept) +{ + return aci_gap_pairing_resp_api(Connection_Handle, + Accept); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_passkey_resp(uint16_t Connection_Handle, + uint32_t Passkey) +{ + return aci_gap_passkey_resp_api(Connection_Handle, + Passkey); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_gap_passkey_input(uint16_t Connection_Handle, + uint8_t Input_Type) +{ + return aci_gap_passkey_input_api(Connection_Handle, + Input_Type); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_get_oob_data(uint8_t OOB_Data_Type, + uint8_t* Address_Type, + uint8_t Address[6], + uint8_t* OOB_Data_Len, + uint8_t OOB_Data[16]) +{ + return aci_gap_get_oob_data_api(OOB_Data_Type, + Address_Type, + Address, + OOB_Data_Len, + OOB_Data); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_set_oob_data(uint8_t Device_Type, + uint8_t Address_Type, + uint8_t Address[6], + uint8_t OOB_Data_Type, + uint8_t OOB_Data_Len, + uint8_t OOB_Data[16]) +{ + return aci_gap_set_oob_data_api(Device_Type, + Address_Type, + Address, + OOB_Data_Type, + OOB_Data_Len, + OOB_Data); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_gap_numeric_comparison_value_confirm_yesno(uint16_t Connection_Handle, + uint8_t Confirm_Yes_No) +{ + return aci_gap_numeric_comparison_value_confirm_yesno_api(Connection_Handle, + Confirm_Yes_No); +} +#endif /* ((SECURE_CONNECTIONS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_get_security_level(uint16_t Connection_Handle, + uint8_t* Security_Mode, + uint8_t* Security_Level) +{ + return aci_gap_get_security_level_api(Connection_Handle, + Security_Mode, + Security_Level); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_clear_security_db(void) +{ + return aci_gap_clear_security_db_api(); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_get_bonded_devices(uint8_t Offset, + uint8_t Max_Num_Of_Addresses, + uint8_t* Num_of_Addresses, + Bonded_Device_Entry_t* Bonded_Device_Entry) +{ + return aci_gap_get_bonded_devices_api(Offset, + Max_Num_Of_Addresses, + Num_of_Addresses, + Bonded_Device_Entry); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_is_device_bonded(uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]) +{ + return aci_gap_is_device_bonded_api(Peer_Address_Type, + Peer_Address); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gap_remove_bonded_device(uint8_t peerIdentityAddressType, + uint8_t peerIdentityDeviceAddress[6]) +{ + return aci_gap_remove_bonded_device_api(peerIdentityAddressType, + peerIdentityDeviceAddress); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_add_service(ble_gatt_srv_def_t* Serv_p) +{ + return aci_gatt_srv_add_service_api(Serv_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_rm_service(uint16_t Serv_Attr_H) +{ + return aci_gatt_srv_rm_service_api(Serv_Attr_H); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +uint16_t aci_gatt_srv_get_service_handle(ble_gatt_srv_def_t* Serv_p) +{ + return aci_gatt_srv_get_service_handle_api(Serv_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_include_service(uint16_t Serv_Attr_H, + uint16_t Incl_Serv_Attr_H) +{ + return aci_gatt_srv_include_service_api(Serv_Attr_H, + Incl_Serv_Attr_H); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_rm_include_service(uint16_t Incl_Serv_Attr_H) +{ + return aci_gatt_srv_rm_include_service_api(Incl_Serv_Attr_H); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +uint16_t aci_gatt_srv_get_include_service_handle(uint16_t Serv_Attr_H, + ble_gatt_srv_def_t* Included_Srv_p) +{ + return aci_gatt_srv_get_include_service_handle_api(Serv_Attr_H, + Included_Srv_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_add_char(ble_gatt_chr_def_t* Char_p, + uint16_t Serv_Attr_H) +{ + return aci_gatt_srv_add_char_api(Char_p, + Serv_Attr_H); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_rm_char(uint16_t Char_Decl_Attr_H) +{ + return aci_gatt_srv_rm_char_api(Char_Decl_Attr_H); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +uint16_t aci_gatt_srv_get_char_decl_handle(ble_gatt_chr_def_t* Char_p) +{ + return aci_gatt_srv_get_char_decl_handle_api(Char_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_add_char_desc(ble_gatt_descr_def_t* Descr_p, + uint16_t Char_Attr_H) +{ + return aci_gatt_srv_add_char_desc_api(Descr_p, + Char_Attr_H); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +uint16_t aci_gatt_srv_get_descriptor_handle(ble_gatt_descr_def_t* Descr_p) +{ + return aci_gatt_srv_get_descriptor_handle_api(Descr_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_notify(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Flags, + uint16_t Val_Length, + uint8_t* Val_p) +{ + return aci_gatt_srv_notify_api(Connection_Handle, + CID, + Attr_Handle, + Flags, + Val_Length, + Val_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_multi_notify(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Flags, + uint8_t Num_Of_Attr, + Gatt_Srv_Notify_Attr_t* Gatt_Srv_Notify_Attr) +{ + return aci_gatt_srv_multi_notify_api(Connection_Handle, + CID, + Flags, + Num_Of_Attr, + Gatt_Srv_Notify_Attr); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_resp(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Error_Code, + uint16_t Data_Len, + uint8_t* Data_p) +{ + return aci_gatt_srv_resp_api(Connection_Handle, + CID, + Attr_Handle, + Error_Code, + Data_Len, + Data_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_read_handle_value(uint16_t Attr_Handle, + uint16_t* Val_Length_p, + uint8_t** Val_pp) +{ + return aci_gatt_srv_read_handle_value_api(Attr_Handle, + Val_Length_p, + Val_pp); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_read_multiple_instance_handle_value(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t* Val_Length_p, + uint8_t** Val_pp) +{ + return aci_gatt_srv_read_multiple_instance_handle_value_api(Connection_Handle, + Attr_Handle, + Val_Length_p, + Val_pp); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_srv_write_multiple_instance_handle_value(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Char_Value_Length, + uint8_t* Char_Value) +{ + return aci_gatt_srv_write_multiple_instance_handle_value_api(Connection_Handle, + Attr_Handle, + Char_Value_Length, + Char_Value); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_set_event_mask(uint32_t GATT_Evt_Mask) +{ + return aci_gatt_set_event_mask_api(GATT_Evt_Mask); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_exchange_config(uint16_t Connection_Handle) +{ + return aci_gatt_clt_exchange_config_api(Connection_Handle); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_disc_all_primary_services(uint16_t Connection_Handle, + uint16_t CID) +{ + return aci_gatt_clt_disc_all_primary_services_api(Connection_Handle, + CID); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_disc_primary_service_by_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint8_t UUID_Type, + UUID_t* UUID) +{ + return aci_gatt_clt_disc_primary_service_by_uuid_api(Connection_Handle, + CID, + UUID_Type, + UUID); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_disc_all_char_of_service(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle) +{ + return aci_gatt_clt_disc_all_char_of_service_api(Connection_Handle, + CID, + Start_Handle, + End_Handle); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_disc_char_by_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle, + uint8_t UUID_Type, + UUID_t* UUID) +{ + return aci_gatt_clt_disc_char_by_uuid_api(Connection_Handle, + CID, + Start_Handle, + End_Handle, + UUID_Type, + UUID); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_disc_all_char_desc(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Char_Handle, + uint16_t End_Handle) +{ + return aci_gatt_clt_disc_all_char_desc_api(Connection_Handle, + CID, + Char_Handle, + End_Handle); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_find_included_services(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle) +{ + return aci_gatt_clt_find_included_services_api(Connection_Handle, + CID, + Start_Handle, + End_Handle); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_read(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle) +{ + return aci_gatt_clt_read_api(Connection_Handle, + CID, + Attr_Handle); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_read_long(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset) +{ + return aci_gatt_clt_read_long_api(Connection_Handle, + CID, + Attr_Handle, + Val_Offset); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_read_using_char_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle, + uint8_t UUID_Type, + UUID_t* UUID) +{ + return aci_gatt_clt_read_using_char_uuid_api(Connection_Handle, + CID, + Start_Handle, + End_Handle, + UUID_Type, + UUID); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_read_multiple_char_value(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Number_of_Handles, + uint16_t* Handle_Entry) +{ + return aci_gatt_clt_read_multiple_char_value_api(Connection_Handle, + CID, + Number_of_Handles, + Handle_Entry); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_read_multiple_var_len_char_value(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Number_of_Handles, + uint16_t* Handle_Entry) +{ + return aci_gatt_clt_read_multiple_var_len_char_value_api(Connection_Handle, + CID, + Number_of_Handles, + Handle_Entry); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_write_without_resp(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t* Attribute_Val) +{ + return aci_gatt_clt_write_without_resp_api(Connection_Handle, + CID, + Attr_Handle, + Attribute_Val_Length, + Attribute_Val); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_signed_write_without_resp(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t* Attribute_Val) +{ + return aci_gatt_clt_signed_write_without_resp_api(Connection_Handle, + Attr_Handle, + Attribute_Val_Length, + Attribute_Val); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_write(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t* Attribute_Val) +{ + return aci_gatt_clt_write_api(Connection_Handle, + CID, + Attr_Handle, + Attribute_Val_Length, + Attribute_Val); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_write_long(uint16_t Connection_Handle, + uint16_t CID, + ble_gatt_clt_write_ops_t* Write_Ops_p) +{ + return aci_gatt_clt_write_long_api(Connection_Handle, + CID, + Write_Ops_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_write_char_reliable(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Num_Attrs, + ble_gatt_clt_write_ops_t* Write_Ops_p) +{ + return aci_gatt_clt_write_char_reliable_api(Connection_Handle, + CID, + Num_Attrs, + Write_Ops_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_prepare_write_req(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t* Attribute_Val) +{ + return aci_gatt_clt_prepare_write_req_api(Connection_Handle, + CID, + Attr_Handle, + Val_Offset, + Attribute_Val_Length, + Attribute_Val); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_execute_write_req(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Execute) +{ + return aci_gatt_clt_execute_write_req_api(Connection_Handle, + CID, + Execute); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_confirm_indication(uint16_t Connection_Handle, + uint16_t CID) +{ + return aci_gatt_clt_confirm_indication_api(Connection_Handle, + CID); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_hal_peripheral_latency_enable(uint16_t Connection_Handle, + uint8_t Enable) +{ + return aci_hal_peripheral_latency_enable_api(Connection_Handle, + Enable); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_hal_set_le_power_control(uint8_t Enable, + uint8_t PHY, + int8_t RSSI_Target, + uint8_t RSSI_Hysteresis, + int8_t Initial_TX_Power, + uint8_t RSSI_Filtering_Coefficient) +{ + return aci_hal_set_le_power_control_api(Enable, + PHY, + RSSI_Target, + RSSI_Hysteresis, + Initial_TX_Power, + RSSI_Filtering_Coefficient); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_hal_get_anchor_point(uint16_t connection_handle, + uint16_t* event_counter, + uint32_t* anchor_point) +{ + return aci_hal_get_anchor_point_api(connection_handle, + event_counter, + anchor_point); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_l2cap_connection_parameter_update_req(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Peripheral_Latency, + uint16_t Timeout_Multiplier) +{ + return aci_l2cap_connection_parameter_update_req_api(Connection_Handle, + Connection_Interval_Min, + Connection_Interval_Max, + Peripheral_Latency, + Timeout_Multiplier); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus aci_l2cap_connection_parameter_update_resp(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Peripheral_Latency, + uint16_t Timeout_Multiplier, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length, + uint8_t Identifier, + uint8_t Accept) +{ + return aci_l2cap_connection_parameter_update_resp_api(Connection_Handle, + Connection_Interval_Min, + Connection_Interval_Max, + Peripheral_Latency, + Timeout_Multiplier, + Min_CE_Length, + Max_CE_Length, + Identifier, + Accept); +} +#endif +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_l2cap_cos_connection_req(uint16_t connection_handle, + uint16_t spsm, + uint16_t mtu, + uint16_t mps, + uint8_t channel_type, + uint8_t cid_count) +{ + return aci_l2cap_cos_connection_req_api(connection_handle, + spsm, + mtu, + mps, + channel_type, + cid_count); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_l2cap_cos_connection_resp(uint16_t connection_handle, + uint8_t identifier, + uint16_t mtu, + uint16_t mps, + uint16_t result, + uint8_t cid_count, + uint16_t* local_cid) +{ + return aci_l2cap_cos_connection_resp_api(connection_handle, + identifier, + mtu, + mps, + result, + cid_count, + local_cid); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_l2cap_cos_disconnect_req(uint16_t Connection_Handle, + uint16_t CID) +{ + return aci_l2cap_cos_disconnect_req_api(Connection_Handle, + CID); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_l2cap_cos_reconfigure_req(uint16_t connection_handle, + uint16_t mtu, + uint16_t mps, + uint8_t cid_count, + uint16_t* local_cid_array) +{ + return aci_l2cap_cos_reconfigure_req_api(connection_handle, + mtu, + mps, + cid_count, + local_cid_array); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_l2cap_cos_reconfigure_resp(uint16_t connection_handle, + uint8_t identifier, + uint16_t result) +{ + return aci_l2cap_cos_reconfigure_resp_api(connection_handle, + identifier, + result); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_l2cap_cos_sdu_data_transmit(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Length, + uint8_t* SDU_Data) +{ + return aci_l2cap_cos_sdu_data_transmit_api(Connection_Handle, + CID, + SDU_Length, + SDU_Data); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_l2cap_cos_sdu_data_extract(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Data_Buffer_Size, + void* SDU_Data_Buffer, + uint16_t* SDU_Length) +{ + return aci_l2cap_cos_sdu_data_extract_api(Connection_Handle, + CID, + SDU_Data_Buffer_Size, + SDU_Data_Buffer, + SDU_Length); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_read_buffer_size_v2(uint16_t* HC_LE_ACL_Data_Packet_Length, + uint8_t* HC_Total_Num_LE_ACL_Data_Packets, + uint16_t* HC_LE_ISO_Data_Packet_Length, + uint8_t* HC_Total_Num_LE_ISO_Data_Packets) +{ + return hci_le_read_buffer_size_v2_api(HC_LE_ACL_Data_Packet_Length, + HC_Total_Num_LE_ACL_Data_Packets, + HC_LE_ISO_Data_Packet_Length, + HC_Total_Num_LE_ISO_Data_Packets); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus hci_le_create_big_test(uint8_t big_handle, + uint8_t advertising_handle, + uint8_t num_bis, + uint8_t* sdu_interval_us, + uint16_t iso_interval_1_25ms, + uint8_t nse, + uint16_t max_sdu, + uint16_t max_pdu, + uint8_t phy, + uint8_t packing_interleaved, + uint8_t framing, + uint8_t bn, + uint8_t irc, + uint8_t pto, + uint8_t encryption, + uint8_t* broadcast_code_ext) +{ + return hci_le_create_big_test_api(big_handle, + advertising_handle, + num_bis, + sdu_interval_us, + iso_interval_1_25ms, + nse, + max_sdu, + max_pdu, + phy, + packing_interleaved, + framing, + bn, + irc, + pto, + encryption, + broadcast_code_ext); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_big_create_sync(uint8_t BIG_Handle, + uint16_t Sync_Handle, + uint8_t Encryption, + uint8_t* Broadcast_Code, + uint8_t MSE, + uint16_t BIG_Sync_Timeout, + uint8_t Num_BIS, + uint8_t* BIS) +{ + return hci_le_big_create_sync_api(BIG_Handle, + Sync_Handle, + Encryption, + Broadcast_Code, + MSE, + BIG_Sync_Timeout, + Num_BIS, + BIS); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus hci_le_terminate_big(uint8_t Terminate_Big, + uint8_t Reason) +{ + return hci_le_terminate_big_api(Terminate_Big, + Reason); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_big_terminate_sync(uint8_t Big_handle) +{ + return hci_le_big_terminate_sync_api(Big_handle); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus hci_le_create_big(uint8_t big_handle, + uint8_t advertising_handle, + uint8_t num_bis, + uint8_t* sdu_interval_us, + uint16_t max_sdu, + uint16_t Max_Transport_Latency, + uint8_t RTN, + uint8_t phy, + uint8_t packing_interleaved, + uint8_t framing, + uint8_t encryption, + uint8_t* broadcast_code_ext) +{ + return hci_le_create_big_api(big_handle, + advertising_handle, + num_bis, + sdu_interval_us, + max_sdu, + Max_Transport_Latency, + RTN, + phy, + packing_interleaved, + framing, + encryption, + broadcast_code_ext); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_read_afh_channel_assessment_mode(uint8_t* AFH_Channel_Assessment_Mode) +{ + return hci_read_afh_channel_assessment_mode_api(AFH_Channel_Assessment_Mode); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_write_afh_channel_assessment_mode(uint8_t AFH_Channel_Assessment_Mode) +{ + return hci_write_afh_channel_assessment_mode_api(AFH_Channel_Assessment_Mode); +} +#endif /* ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (\ + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (CONTROLLER_CHAN_CLASS_ENABLED == 1)\ + )\ + )\ + ||\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)\ + ) +tBleStatus hci_le_set_host_channel_classification(uint8_t Channel_Map[LLC_MIN_NUM_DATA_CHAN_MAP_BYTES]) +{ + return hci_le_set_host_channel_classification_api(Channel_Map); +} +#endif + +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus hci_le_set_cig_parameters(uint8_t CIG_ID, + uint8_t SDU_Interval_C_To_P[3], + uint8_t SDU_Interval_P_To_C[3], + uint8_t Worst_Case_SCA, + uint8_t Packing, + uint8_t Framing, + uint16_t Max_Transport_Latency_C_To_P, + uint16_t Max_Transport_Latency_P_To_C, + uint8_t CIS_Count, + CIS_Param_t* CIS_params, + uint16_t* CIS_Conn_Handles) +{ + return hci_le_set_cig_parameters_api(CIG_ID, + SDU_Interval_C_To_P, + SDU_Interval_P_To_C, + Worst_Case_SCA, + Packing, + Framing, + Max_Transport_Latency_C_To_P, + Max_Transport_Latency_P_To_C, + CIS_Count, + CIS_params, + CIS_Conn_Handles); +} +#endif + +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus hci_le_set_cig_parameters_test(uint8_t CIG_ID, + uint8_t SDU_Interval_C_To_P[3], + uint8_t SDU_Interval_P_To_C[3], + uint8_t FT_C_To_P, + uint8_t FT_P_To_C, + uint16_t ISO_Interval, + uint8_t Worst_Case_SCA, + uint8_t Packing, + uint8_t Framing, + uint8_t CIS_Count, + CIS_Param_Test_t* CIS_Param_test, + uint16_t* CIS_Conn_Handles) +{ + return hci_le_set_cig_parameters_test_api(CIG_ID, + SDU_Interval_C_To_P, + SDU_Interval_P_To_C, + FT_C_To_P, + FT_P_To_C, + ISO_Interval, + Worst_Case_SCA, + Packing, + Framing, + CIS_Count, + CIS_Param_test, + CIS_Conn_Handles); +} +#endif + +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus hci_le_create_cis(uint8_t CIS_Count, + CIS_Handles_t* create_cis_connection_params) +{ + return hci_le_create_cis_api(CIS_Count, + create_cis_connection_params); +} +#endif + +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)\ + )\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus hci_le_remove_cig(uint8_t CIG_ID) +{ + return hci_le_remove_cig_api(CIG_ID); +} +#endif + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus hci_le_accept_cis_request(uint16_t Connection_Handle) +{ + return hci_le_accept_cis_request_api(Connection_Handle); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus hci_le_reject_cis_request(uint16_t Connection_Handle, + uint8_t Reason) +{ + return hci_le_reject_cis_request_api(Connection_Handle, + Reason); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus hci_read_connection_accept_timeout(uint16_t* Connection_Accept_Timeout) +{ + return hci_read_connection_accept_timeout_api(Connection_Accept_Timeout); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus hci_write_connection_accept_timeout(uint16_t Connection_Accept_Timeout) +{ + return hci_write_connection_accept_timeout_api(Connection_Accept_Timeout); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) ||\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_host_feature(uint8_t Bit_Number, + uint8_t Bit_Value) +{ + return hci_le_set_host_feature_api(Bit_Number, + Bit_Value); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) ||\ + (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_read_remote_version_information(uint16_t Connection_Handle) +{ + return hci_read_remote_version_information_api(Connection_Handle); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_read_remote_features(uint16_t Connection_Handle) +{ + return hci_le_read_remote_features_api(Connection_Handle); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_read_transmit_power_level(uint16_t Connection_Handle, + uint8_t Type, + int8_t* Transmit_Power_Level) +{ + return hci_read_transmit_power_level_api(Connection_Handle, + Type, + Transmit_Power_Level); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_read_rssi(uint16_t Connection_Handle, + int8_t* RSSI) +{ + return hci_read_rssi_api(Connection_Handle, + RSSI); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_read_channel_map(uint16_t Connection_Handle, + uint8_t LE_Channel_Map[LLC_MIN_NUM_DATA_CHAN_MAP_BYTES]) +{ + return hci_le_read_channel_map_api(Connection_Handle, + LE_Channel_Map); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_disconnect(uint16_t Connection_Handle, + uint8_t Reason) +{ + return hci_disconnect_api(Connection_Handle, + Reason); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_create_connection(uint16_t LE_Scan_Interval, + uint16_t LE_Scan_Window, + uint8_t Initiator_Filter_Policy, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Own_Address_Type, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length) +{ + return hci_le_create_connection_api(LE_Scan_Interval, + LE_Scan_Window, + Initiator_Filter_Policy, + Peer_Address_Type, + Peer_Address, + Own_Address_Type, + Connection_Interval_Min, + Connection_Interval_Max, + Max_Latency, + Supervision_Timeout, + Min_CE_Length, + Max_CE_Length); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_create_connection_cancel(void) +{ + return hci_le_create_connection_cancel_api(); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_extended_create_connection(uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Initiating_PHYs, + Extended_Create_Connection_Parameters_t* Extended_Create_Connection_Parameters) +{ + return hci_le_extended_create_connection_api(Initiator_Filter_Policy, + Own_Address_Type, + Peer_Address_Type, + Peer_Address, + Initiating_PHYs, + Extended_Create_Connection_Parameters); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_extended_create_connection_v2(uint8_t Advertising_Handle, + uint8_t Subevent, + uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Initiating_PHYs, + Extended_Create_Connection_Parameters_t* Extended_Create_Connection_Parameters) +{ + return hci_le_extended_create_connection_v2_api(Advertising_Handle, + Subevent, + Initiator_Filter_Policy, + Own_Address_Type, + Peer_Address_Type, + Peer_Address, + Initiating_PHYs, + Extended_Create_Connection_Parameters); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) +tBleStatus hci_le_set_connectionless_cte_transmit_parameters(uint8_t Advertising_Handle, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t CTE_Count, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs) +{ + return hci_le_set_connectionless_cte_transmit_parameters_api(Advertising_Handle, + CTE_Length, + CTE_Type, + CTE_Count, + Switching_Pattern_Length, + Antenna_IDs); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) +tBleStatus hci_le_set_connectionless_cte_transmit_enable(uint8_t Advertising_Handle, + uint8_t CTE_Enable) +{ + return hci_le_set_connectionless_cte_transmit_enable_api(Advertising_Handle, + CTE_Enable); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) +tBleStatus hci_le_set_connectionless_iq_sampling_enable(uint16_t Sync_Handle, + uint8_t Sampling_Enable, + uint8_t Slot_Durations, + uint8_t Max_Sampled_CTEs, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs) +{ + return hci_le_set_connectionless_iq_sampling_enable_api(Sync_Handle, + Sampling_Enable, + Slot_Durations, + Max_Sampled_CTEs, + Switching_Pattern_Length, + Antenna_IDs); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_connection_cte_receive_parameters(uint16_t Connection_Handle, + uint8_t Sampling_Enable, + uint8_t Slot_Durations, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs) +{ + return hci_le_set_connection_cte_receive_parameters_api(Connection_Handle, + Sampling_Enable, + Slot_Durations, + Switching_Pattern_Length, + Antenna_IDs); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_connection_cte_transmit_parameters(uint16_t Connection_Handle, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs) +{ + return hci_le_set_connection_cte_transmit_parameters_api(Connection_Handle, + CTE_Type, + Switching_Pattern_Length, + Antenna_IDs); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_connection_cte_request_enable(uint16_t Connection_Handle, + uint8_t Enable, + uint16_t CTE_Request_Interval, + uint8_t Requested_CTE_Length, + uint8_t Requested_CTE_Type) +{ + return hci_le_connection_cte_request_enable_api(Connection_Handle, + Enable, + CTE_Request_Interval, + Requested_CTE_Length, + Requested_CTE_Type); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_connection_cte_response_enable(uint16_t Connection_Handle, + uint8_t Enable) +{ + return hci_le_connection_cte_response_enable_api(Connection_Handle, + Enable); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +tBleStatus hci_le_read_antenna_information(uint8_t* Supported_Switching_Sampling_Rates, + uint8_t* Num_Antennae, + uint8_t* Max_Switching_Pattern_Length, + uint8_t* Max_CTE_Length) +{ + return hci_le_read_antenna_information_api(Supported_Switching_Sampling_Rates, + Num_Antennae, + Max_Switching_Pattern_Length, + Max_CTE_Length); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) +tBleStatus hci_le_enable_encryption(uint16_t Connection_Handle, + uint8_t Random_Number[8], + uint16_t Encrypted_Diversifier, + uint8_t Long_Term_Key[16]) +{ + return hci_le_enable_encryption_api(Connection_Handle, + Random_Number, + Encrypted_Diversifier, + Long_Term_Key); +} +#endif + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_long_term_key_request_reply(uint16_t Connection_Handle, + uint8_t Long_Term_Key[16]) +{ + return hci_le_long_term_key_request_reply_api(Connection_Handle, + Long_Term_Key); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_long_term_key_request_negative_reply(uint16_t Connection_Handle) +{ + return hci_le_long_term_key_request_negative_reply_api(Connection_Handle); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_read_local_p256_public_key(void) +{ + return hci_le_read_local_p256_public_key_api(); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_generate_dhkey(uint8_t Remote_P256_Public_Key[64]) +{ + return hci_le_generate_dhkey_api(Remote_P256_Public_Key); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_read_authenticated_payload_timeout(uint16_t Connection_Handle, + uint16_t* Authenticated_Payload_Timeout) +{ + return hci_read_authenticated_payload_timeout_api(Connection_Handle, + Authenticated_Payload_Timeout); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_write_authenticated_payload_timeout(uint16_t Connection_Handle, + uint16_t Authenticated_Payload_Timeout) +{ + return hci_write_authenticated_payload_timeout_api(Connection_Handle, + Authenticated_Payload_Timeout); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_set_extended_advertising_parameters(uint8_t Advertising_Handle, + uint16_t Advertising_Event_Properties, + uint8_t Primary_Advertising_Interval_Min[3], + uint8_t Primary_Advertising_Interval_Max[3], + uint8_t Primary_Advertising_Channel_Map, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable, + int8_t* Selected_Tx_Power) +{ + return hci_le_set_extended_advertising_parameters_api(Advertising_Handle, + Advertising_Event_Properties, + Primary_Advertising_Interval_Min, + Primary_Advertising_Interval_Max, + Primary_Advertising_Channel_Map, + Own_Address_Type, + Peer_Address_Type, + Peer_Address, + Advertising_Filter_Policy, + Advertising_Tx_Power, + Primary_Advertising_PHY, + Secondary_Advertising_Max_Skip, + Secondary_Advertising_PHY, + Advertising_SID, + Scan_Request_Notification_Enable, + Selected_Tx_Power); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_set_extended_advertising_parameters_v2(uint8_t Advertising_Handle, + uint16_t Advertising_Event_Properties, + uint8_t Primary_Advertising_Interval_Min[3], + uint8_t Primary_Advertising_Interval_Max[3], + uint8_t Primary_Advertising_Channel_Map, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable, + uint8_t Primary_Advertising_PHY_Options, + uint8_t Secondary_Advertising_PHY_Options, + int8_t* Selected_Tx_Power) +{ + return hci_le_set_extended_advertising_parameters_v2_api(Advertising_Handle, + Advertising_Event_Properties, + Primary_Advertising_Interval_Min, + Primary_Advertising_Interval_Max, + Primary_Advertising_Channel_Map, + Own_Address_Type, + Peer_Address_Type, + Peer_Address, + Advertising_Filter_Policy, + Advertising_Tx_Power, + Primary_Advertising_PHY, + Secondary_Advertising_Max_Skip, + Secondary_Advertising_PHY, + Advertising_SID, + Scan_Request_Notification_Enable, + Primary_Advertising_PHY_Options, + Secondary_Advertising_PHY_Options, + Selected_Tx_Power); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_set_advertising_set_random_address(uint8_t Advertising_Handle, + uint8_t Advertising_Random_Address[6]) +{ + return hci_le_set_advertising_set_random_address_api(Advertising_Handle, + Advertising_Random_Address); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_set_extended_advertising_enable(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t* Advertising_Set_Parameters) +{ + return hci_le_set_extended_advertising_enable_api(Enable, + Number_of_Sets, + Advertising_Set_Parameters); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_read_number_of_supported_advertising_sets(uint8_t* Num_Supported_Advertising_Sets) +{ + return hci_le_read_number_of_supported_advertising_sets_api(Num_Supported_Advertising_Sets); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_remove_advertising_set(uint8_t Advertising_Handle) +{ + return hci_le_remove_advertising_set_api(Advertising_Handle); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_clear_advertising_sets(void) +{ + return hci_le_clear_advertising_sets_api(); +} +#endif /* (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_default_periodic_advertising_sync_transfer_parameters(uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type) +{ + return hci_le_set_default_periodic_advertising_sync_transfer_parameters_api(Mode, + Skip, + Sync_Timeout, + CTE_Type); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_periodic_advertising_sync_transfer_parameters(uint16_t Connection_Handle, + uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type) +{ + return hci_le_set_periodic_advertising_sync_transfer_parameters_api(Connection_Handle, + Mode, + Skip, + Sync_Timeout, + CTE_Type); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_periodic_advertising_set_info_transfer(uint16_t Connection_Handle, + uint16_t Service_Data, + uint8_t Advertising_Handle) +{ + return hci_le_periodic_advertising_set_info_transfer_api(Connection_Handle, + Service_Data, + Advertising_Handle); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_periodic_advertising_sync_transfer(uint16_t Connection_Handle, + uint16_t Service_Data, + uint16_t Sync_Handle) +{ + return hci_le_periodic_advertising_sync_transfer_api(Connection_Handle, + Service_Data, + Sync_Handle); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_iso_transmit_test(uint16_t Connection_Handle, + uint8_t Payload_Type) +{ + return hci_le_iso_transmit_test_api(Connection_Handle, + Payload_Type); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_iso_receive_test(uint16_t Connection_Handle, + uint8_t Payload_Type) +{ + return hci_le_iso_receive_test_api(Connection_Handle, + Payload_Type); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_iso_read_test_counters(uint16_t Connection_Handle, + uint32_t* Received_Packet_Count, + uint32_t* Missed_Packet_Count, + uint32_t* Failed_Packet_Count) +{ + return hci_le_iso_read_test_counters_api(Connection_Handle, + Received_Packet_Count, + Missed_Packet_Count, + Failed_Packet_Count); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_iso_test_end(uint16_t Connection_Handle, + uint32_t* Received_Packet_Count, + uint32_t* Missed_Packet_Count, + uint32_t* Failed_Packet_Count) +{ + return hci_le_iso_test_end_api(Connection_Handle, + Received_Packet_Count, + Missed_Packet_Count, + Failed_Packet_Count); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_setup_iso_data_path(uint16_t Connection_Handle, + uint8_t Data_Path_Direction, + uint8_t Data_Path_ID, + uint8_t* CODEC_ID, + uint8_t* Controller_Delay, + uint8_t Codec_Configuration_Length, + uint8_t* Codec_Configuration) +{ + return hci_le_setup_iso_data_path_api(Connection_Handle, + Data_Path_Direction, + Data_Path_ID, + CODEC_ID, + Controller_Delay, + Codec_Configuration_Length, + Codec_Configuration); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_remove_iso_data_path(uint16_t Connection_Handle, + uint8_t Data_Path_Direction) +{ + return hci_le_remove_iso_data_path_api(Connection_Handle, + Data_Path_Direction); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_read_iso_link_quality(uint16_t connection_handle, + uint32_t* tx_unacked_packets, + uint32_t* tx_flushed_packets, + uint32_t* tx_last_subevent_packets, + uint32_t* retransmitted_packets, + uint32_t* CRC_error_packets, + uint32_t* rx_unreceived_packets, + uint32_t* duplicate_packets) +{ + return hci_le_read_iso_link_quality_api(connection_handle, + tx_unacked_packets, + tx_flushed_packets, + tx_last_subevent_packets, + retransmitted_packets, + CRC_error_packets, + rx_unreceived_packets, + duplicate_packets); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_le_read_iso_tx_sync(uint16_t connection_handle, + uint16_t* packet_sequence_number, + uint32_t* timestamp, + uint8_t* timeoffset) +{ + return hci_le_read_iso_tx_sync_api(connection_handle, + packet_sequence_number, + timestamp, + timeoffset); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_ISO_ENABLED == 1) +tBleStatus hci_tx_iso_data(uint16_t connection_handle, + uint8_t pb_flag, + uint8_t ts_flag, + uint16_t iso_data_load_len, + uint8_t* iso_data_load_p) +{ + return hci_tx_iso_data_api(connection_handle, + pb_flag, + ts_flag, + iso_data_load_len, + iso_data_load_p); +} +#endif /* (CONTROLLER_ISO_ENABLED == 1) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_data_length(uint16_t Connection_Handle, + uint16_t Tx_Octets, + uint16_t Tx_Time) +{ + return hci_le_set_data_length_api(Connection_Handle, + Tx_Octets, + Tx_Time); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_read_suggested_default_data_length(uint16_t* Suggested_Max_Tx_Octets, + uint16_t* Suggested_Max_Tx_Time) +{ + return hci_le_read_suggested_default_data_length_api(Suggested_Max_Tx_Octets, + Suggested_Max_Tx_Time); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_write_suggested_default_data_length(uint16_t Suggested_Max_Tx_Octets, + uint16_t Suggested_Max_Tx_Time) +{ + return hci_le_write_suggested_default_data_length_api(Suggested_Max_Tx_Octets, + Suggested_Max_Tx_Time); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_read_maximum_data_length(uint16_t* Supported_Max_Tx_Octets, + uint16_t* Supported_Max_Tx_Time, + uint16_t* Supported_Max_Rx_Octets, + uint16_t* Supported_Max_Rx_Time) +{ + return hci_le_read_maximum_data_length_api(Supported_Max_Tx_Octets, + Supported_Max_Tx_Time, + Supported_Max_Rx_Octets, + Supported_Max_Rx_Time); +} +#endif /* (CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +tBleStatus hci_le_set_periodic_advertising_parameters(uint8_t Advertising_Handle, + uint16_t Periodic_Advertising_Interval_Min, + uint16_t Periodic_Advertising_Interval_Max, + uint16_t Periodic_Advertising_Properties) +{ + return hci_le_set_periodic_advertising_parameters_api(Advertising_Handle, + Periodic_Advertising_Interval_Min, + Periodic_Advertising_Interval_Max, + Periodic_Advertising_Properties); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) +tBleStatus hci_le_set_periodic_advertising_enable(uint8_t Enable, + uint8_t Advertising_Handle) +{ + return hci_le_set_periodic_advertising_enable_api(Enable, + Advertising_Handle); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_periodic_advertising_parameters_v2(uint8_t Advertising_Handle, + uint16_t Periodic_Advertising_Interval_Min, + uint16_t Periodic_Advertising_Interval_Max, + uint16_t Periodic_Advertising_Properties, + uint8_t Num_Subevents, + uint8_t Subevent_Interval, + uint8_t Response_Slot_Delay, + uint8_t Response_Slot_Spacing, + uint8_t Num_Response_Slots) +{ + return hci_le_set_periodic_advertising_parameters_v2_api(Advertising_Handle, + Periodic_Advertising_Interval_Min, + Periodic_Advertising_Interval_Max, + Periodic_Advertising_Properties, + Num_Subevents, + Subevent_Interval, + Response_Slot_Delay, + Response_Slot_Spacing, + Num_Response_Slots); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_le_enhanced_read_transmit_power_level(uint16_t Connection_Handle, + uint8_t PHY, + int8_t* Current_TX_Power_Level, + int8_t* Max_TX_Power_Level) +{ + return hci_le_enhanced_read_transmit_power_level_api(Connection_Handle, + PHY, + Current_TX_Power_Level, + Max_TX_Power_Level); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_le_read_remote_transmit_power_level(uint16_t Connection_Handle, + uint8_t PHY) +{ + return hci_le_read_remote_transmit_power_level_api(Connection_Handle, + PHY); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_le_set_path_loss_reporting_parameters(uint16_t Connection_Handle, + uint8_t High_Threshold, + uint8_t High_Hysteresis, + uint8_t Low_Threshold, + uint8_t Low_Hysteresis, + uint16_t Min_Time_Spent) +{ + return hci_le_set_path_loss_reporting_parameters_api(Connection_Handle, + High_Threshold, + High_Hysteresis, + Low_Threshold, + Low_Hysteresis, + Min_Time_Spent); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_le_set_path_loss_reporting_enable(uint16_t Connection_Handle, + uint8_t Enable) +{ + return hci_le_set_path_loss_reporting_enable_api(Connection_Handle, + Enable); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_le_set_transmit_power_reporting_enable(uint16_t Connection_Handle, + uint8_t Local_Enable, + uint8_t Remote_Enable) +{ + return hci_le_set_transmit_power_reporting_enable_api(Connection_Handle, + Local_Enable, + Remote_Enable); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_read_phy(uint16_t Connection_Handle, + uint8_t* TX_PHY, + uint8_t* RX_PHY) +{ + return hci_le_read_phy_api(Connection_Handle, + TX_PHY, + RX_PHY); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) +tBleStatus hci_le_set_default_phy(uint8_t ALL_PHYS, + uint8_t TX_PHYS, + uint8_t RX_PHYS) +{ + return hci_le_set_default_phy_api(ALL_PHYS, + TX_PHYS, + RX_PHYS); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_phy(uint16_t Connection_Handle, + uint8_t ALL_PHYS, + uint8_t TX_PHYS, + uint8_t RX_PHYS, + uint16_t PHY_options) +{ + return hci_le_set_phy_api(Connection_Handle, + ALL_PHYS, + TX_PHYS, + RX_PHYS, + PHY_options); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_add_device_to_resolving_list(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Peer_IRK[16], + uint8_t Local_IRK[16]) +{ + return hci_le_add_device_to_resolving_list_api(Peer_Identity_Address_Type, + Peer_Identity_Address, + Peer_IRK, + Local_IRK); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_remove_device_from_resolving_list(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6]) +{ + return hci_le_remove_device_from_resolving_list_api(Peer_Identity_Address_Type, + Peer_Identity_Address); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_clear_resolving_list(void) +{ + return hci_le_clear_resolving_list_api(); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_read_resolving_list_size(uint8_t* Resolving_List_Size) +{ + return hci_le_read_resolving_list_size_api(Resolving_List_Size); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_read_peer_resolvable_address(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Peer_Resolvable_Address[6]) +{ + return hci_le_read_peer_resolvable_address_api(Peer_Identity_Address_Type, + Peer_Identity_Address, + Peer_Resolvable_Address); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_read_local_resolvable_address(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Local_Resolvable_Address[6]) +{ + return hci_le_read_local_resolvable_address_api(Peer_Identity_Address_Type, + Peer_Identity_Address, + Local_Resolvable_Address); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_set_address_resolution_enable(uint8_t Address_Resolution_Enable) +{ + return hci_le_set_address_resolution_enable_api(Address_Resolution_Enable); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_set_resolvable_private_address_timeout(uint16_t RPA_Timeout) +{ + return hci_le_set_resolvable_private_address_timeout_api(RPA_Timeout); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_set_privacy_mode(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Privacy_Mode) +{ + return hci_le_set_privacy_mode_api(Peer_Identity_Address_Type, + Peer_Identity_Address, + Privacy_Mode); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +tBleStatus hci_le_set_data_related_address_changes(uint8_t Advertising_Handle, + uint8_t Change_Reasons) +{ + return hci_le_set_data_related_address_changes_api(Advertising_Handle, + Change_Reasons); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_add_device_to_periodic_advertiser_list(uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint8_t Advertising_SID) +{ + return hci_le_add_device_to_periodic_advertiser_list_api(Advertiser_Address_Type, + Advertiser_Address, + Advertising_SID); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_clear_periodic_advertiser_list(void) +{ + return hci_le_clear_periodic_advertiser_list_api(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_periodic_advertising_create_sync(uint8_t Options, + uint8_t Advertising_SID, + uint8_t Advertising_Address_Type, + uint8_t Advertiser_Address[6], + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t Sync_CTE_Type) +{ + return hci_le_periodic_advertising_create_sync_api(Options, + Advertising_SID, + Advertising_Address_Type, + Advertiser_Address, + Skip, + Sync_Timeout, + Sync_CTE_Type); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_periodic_advertising_create_sync_cancel(void) +{ + return hci_le_periodic_advertising_create_sync_cancel_api(); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_periodic_advertising_terminate_sync(uint16_t Sync_Handle) +{ + return hci_le_periodic_advertising_terminate_sync_api(Sync_Handle); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_read_periodic_advertiser_list_size(uint8_t* Periodic_Advertiser_List_Size) +{ + return hci_le_read_periodic_advertiser_list_size_api(Periodic_Advertiser_List_Size); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_remove_device_from_periodic_advertiser_list(uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint8_t Advertising_SID) +{ + return hci_le_remove_device_from_periodic_advertiser_list_api(Advertiser_Address_Type, + Advertiser_Address, + Advertising_SID); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_set_periodic_advertising_receive_enable(uint16_t Sync_Handle, + uint8_t Enable) +{ + return hci_le_set_periodic_advertising_receive_enable_api(Sync_Handle, + Enable); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) */ + +#if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) +tBleStatus hci_le_set_periodic_sync_subevent(uint16_t Sync_Handle, + uint16_t Periodic_Advertising_Properties, + uint8_t Num_Subevents, + uint8_t* Subevent) +{ + return hci_le_set_periodic_sync_subevent_api(Sync_Handle, + Periodic_Advertising_Properties, + Num_Subevents, + Subevent); +} +#endif /* ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)) &&\ + (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) */ + +#if ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) +tBleStatus hci_le_request_peer_sca(uint16_t Connection_Handle) +{ + return hci_le_request_peer_sca_api(Connection_Handle); +} +#endif /* ((CONTROLLER_CIS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_ISO_ENABLED == 1)) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_set_scan_parameters(uint8_t LE_Scan_Type, + uint16_t LE_Scan_Interval, + uint16_t LE_Scan_Window, + uint8_t Own_Address_Type, + uint8_t Scanning_Filter_Policy) +{ + return hci_le_set_scan_parameters_api(LE_Scan_Type, + LE_Scan_Interval, + LE_Scan_Window, + Own_Address_Type, + Scanning_Filter_Policy); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) +tBleStatus hci_le_set_scan_enable(uint8_t LE_Scan_Enable, + uint8_t Filter_Duplicates) +{ + return hci_le_set_scan_enable_api(LE_Scan_Enable, + Filter_Duplicates); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_set_extended_scan_parameters(uint8_t Own_Address_Type, + uint8_t Scanning_Filter_Policy, + uint8_t Scanning_PHYs, + Extended_Scan_Parameters_t* Extended_Scan_Parameters) +{ + return hci_le_set_extended_scan_parameters_api(Own_Address_Type, + Scanning_Filter_Policy, + Scanning_PHYs, + Extended_Scan_Parameters); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +tBleStatus hci_le_set_extended_scan_enable(uint8_t Enable, + uint8_t Filter_Duplicates, + uint16_t Duration, + uint16_t Period) +{ + return hci_le_set_extended_scan_enable_api(Enable, + Filter_Duplicates, + Duration, + Period); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + +#if (CONNECTION_ENABLED == 1) +tBleStatus hci_le_connection_update(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length) +{ + return hci_le_connection_update_api(Connection_Handle, + Connection_Interval_Min, + Connection_Interval_Max, + Max_Latency, + Supervision_Timeout, + Min_CE_Length, + Max_CE_Length); +} +#endif /* (CONNECTION_ENABLED == 1) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_le_set_default_subrate(uint16_t Subrate_Min, + uint16_t Subrate_Max, + uint16_t Max_Latency, + uint16_t Continuation_Number, + uint16_t Supervision_Timeout) +{ + return hci_le_set_default_subrate_api(Subrate_Min, + Subrate_Max, + Max_Latency, + Continuation_Number, + Supervision_Timeout); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus hci_le_subrate_request(uint16_t Connection_Handle, + uint16_t Subrate_Min, + uint16_t Subrate_Max, + uint16_t Max_Latency, + uint16_t Continuation_Number, + uint16_t Supervision_Timeout) +{ + return hci_le_subrate_request_api(Connection_Handle, + Subrate_Min, + Subrate_Max, + Max_Latency, + Continuation_Number, + Supervision_Timeout); +} +#endif /* ((CONNECTION_SUBRATING_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) +tBleStatus hci_le_receiver_test_v2(uint8_t RX_Frequency, + uint8_t Phy, + uint8_t Modulation_index) +{ + return hci_le_receiver_test_v2_api(RX_Frequency, + Phy, + Modulation_index); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +tBleStatus hci_le_receiver_test_v3(uint8_t RX_Channel, + uint8_t PHY, + uint8_t Modulation_Index, + uint8_t Expected_CTE_Length, + uint8_t Expected_CTE_Type, + uint8_t Slot_Durations, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs) +{ + return hci_le_receiver_test_v3_api(RX_Channel, + PHY, + Modulation_Index, + Expected_CTE_Length, + Expected_CTE_Type, + Slot_Durations, + Switching_Pattern_Length, + Antenna_IDs); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if (CONTROLLER_2M_CODED_PHY_ENABLED == 1) +tBleStatus hci_le_transmitter_test_v2(uint8_t TX_Frequency, + uint8_t Length_Of_Test_Data, + uint8_t Packet_Payload, + uint8_t Phy) +{ + return hci_le_transmitter_test_v2_api(TX_Frequency, + Length_Of_Test_Data, + Packet_Payload, + Phy); +} +#endif /* (CONTROLLER_2M_CODED_PHY_ENABLED == 1) */ + +#if (CONTROLLER_CTE_ENABLED == 1) +tBleStatus hci_le_transmitter_test_v3(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs) +{ + return hci_le_transmitter_test_v3_api(TX_Channel, + Test_Data_Length, + Packet_Payload, + PHY, + CTE_Length, + CTE_Type, + Switching_Pattern_Length, + Antenna_IDs); +} +#endif /* (CONTROLLER_CTE_ENABLED == 1) */ + +#if ((CONTROLLER_POWER_CONTROL_ENABLED == 1)) ||\ + (CONTROLLER_CTE_ENABLED == 1) +tBleStatus hci_le_transmitter_test_v4(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs, + int8_t Transmit_Power_Level) +{ + return hci_le_transmitter_test_v4_api(TX_Channel, + Test_Data_Length, + Packet_Payload, + PHY, + CTE_Length, + CTE_Type, + Switching_Pattern_Length, + Antenna_IDs, + Transmit_Power_Level); +} +#endif /* ((CONTROLLER_POWER_CONTROL_ENABLED == 1)) ||\ + (CONTROLLER_CTE_ENABLED == 1) */ + diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_api.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_api.h new file mode 100644 index 000000000..d5b2d9369 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_api.h @@ -0,0 +1,7874 @@ +/** + ****************************************************************************** + * @file ble_api.h + * @author GPM WBL Application Team + * @brief Header file for Bluetooth Low Energy stack APIs. + * Autogenerated files, do not edit!! + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef _BLE_API_H_ +#define _BLE_API_H_ + +#include "ble_gatt.h" +#include +#include "ble_status.h" + +/** Documentation for C struct Advertising_Set_Parameters_t */ +typedef struct Advertising_Set_Parameters_t_s { + /** It is used to identify an advertising set. + * Values: + * - 0x00 ... 0xEF + */ + uint8_t Advertising_Handle; + /** The Duration[i] parameter indicates the duration for which that advertising set + * is enabled. The duration begins at the start of the first advertising + * event of this advertising set. The Controller should not start an extended + * advertising event that it cannot complete within the duration. Time = N * + * 10 ms 0x00 means no advertising duration: advertising will continue until + * the Host disables it. + * Values: + * - 0x0000 (0 ms) : No advertising duration + * - 0x0001 (10 ms) ... 0xFFFF (655350 ms) + */ + uint16_t Duration; + /** The Max_Extended_Advertising_Events[i] parameter, if non-zero, indicates the + * maximum number of extended advertising events that shall be sent prior to + * disabling the extended advertising set even if the Duration[i] parameter + * has not expired. + * Values: + * - 0x00: No maximum number of advertising events. + * - 0x01 ... 0xFF: Maximum number of extended advertising events. + */ + uint8_t Max_Extended_Advertising_Events; +} Advertising_Set_Parameters_t; + +/** Documentation for C struct Extended_Scan_Parameters_t */ +typedef struct Extended_Scan_Parameters_t_s { + /** The Scan_Type parameter specifies the type of scan to perform. 0: Passive + * Scanning. No scan request PDUs shall be sent. 1: Active Scanning. Scan + * request PDUs may be sent. + * Values: + * - 0x00: Passive Scanning + * - 0x01: Active Scanning + */ + uint8_t Scan_Type; + /** Time interval from when the Controller started its last scan until it begins the + * subsequent scan on the primary advertising channel. Time = N * 0.625 ms + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Scan_Interval; + /** Duration of the scan on the primary advertising channel. Time = N * 0.625 ms + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Scan_Window; +} Extended_Scan_Parameters_t; + +/** Documentation for C struct Extended_Create_Connection_Parameters_t */ +typedef struct Extended_Create_Connection_Parameters_t_s { + /** Time interval from when the Controller started its last scan until it begins the + * subsequent scan on the primary advertising channel. Time = N * 0.625 ms; + * Time Range: 2.5 ms to 40.959375 s. + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Scan_Interval; + /** Duration of the scan on the primary advertising channel. Time = N * 0.625 ms; + * Time Range: 2.5 ms to 40.959375 s. + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Scan_Window; + /** Minimum value for the connection interval. This shall be less than or equal to + * Connection_Interval_Max[i]. Time = N * 1.25 ms; Time Range: 7.5 ms to 4 s. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ + uint16_t Connection_Interval_Min; + /** Maximum value for the connection interval. This shall be less than or equal to + * Connection_Interval_Max[i]. Time = N * 1.25 ms; Time Range: 7.5 ms to 4 s. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ + uint16_t Connection_Interval_Max; + /** Peripheral latency for the connection in number of connection events + * Values: + * - 0x0000 ... 0x01F3 + */ + uint16_t Max_Latency; + /** Supervision timeout for the LE Link. (See [Vol 6] Part B, Section 4.5.2) Time = + * N * 10 ms; Time Range: 100 ms to 32 s. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + */ + uint16_t Supervision_Timeout; + /** Informative parameter recommending the minimum length of connection event needed + * for this LE connection. Time = N * 0.625 ms. + * Values: + * - 0x0000 (0.000 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Min_CE_Length; + /** Informative parameter recommending the maximum length of connection event needed + * for this LE connection. Time = N * 0.625 ms. + * Values: + * - 0x0000 (0.000 ms) ... 0xFFFF (40959.375 ms) + */ + uint16_t Max_CE_Length; +} Extended_Create_Connection_Parameters_t; + +/** Documentation for C struct CIS_Param_t */ +typedef struct CIS_Param_t_s { + /** Used to identify a CIS. + * Values: + * - 0x00 ... 0xEF + */ + uint8_t CIS_ID; + /** Maximum size, in octets, of the payload from the Central's Host. + * Values: + * - 0x0000 ... 0x0FFF + */ + uint16_t Max_SDU_C_To_P; + /** Maximum size, in octets, of the payload from the Peripheral's Host. + * Values: + * - 0x0000 ... 0x0FFF + */ + uint16_t Max_SDU_P_To_C; + /** PHY to use for transmission from the Central to the Peripheral. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + */ + uint8_t PHY_C_To_P; + /** PHY to use for transmission from the Peripheral to the Central. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + */ + uint8_t PHY_P_To_C; + /** Number of times every CIS Data PDU should be retransmitted from the Central to + * the Peripheral. + */ + uint8_t RTN_C_To_P; + /** Number of times every CIS Data PDU should be retransmitted from the Peripheral + * to the Central. + */ + uint8_t RTN_P_To_C; +} CIS_Param_t; + +/** Documentation for C struct CIS_Param_Test_t */ +typedef struct CIS_Param_Test_t_s { + /** Used to identify a CIS. + * Values: + * - 0x00 ... 0xEF + */ + uint8_t CIS_ID; + /** Maximum number of subevents in each CIS event. + * Values: + * - 0x01 ... 0x1F + */ + uint8_t NSE; + /** Maximum size, in octets, of the payload from the Central's Host. + * Values: + * - 0x0000 ... 0x0FFF + */ + uint16_t Max_SDU_C_To_P; + /** Maximum size, in octets, of the payload from the Peripheral's Host. + * Values: + * - 0x0000 ... 0x0FFF + */ + uint16_t Max_SDU_P_To_C; + /** Maximum size, in octets, of the payload from the Central's Link Layer to the + * Peripheral's Link Layer. + * Values: + * - 0x0000 ... 0x00FB + */ + uint16_t Max_PDU_C_To_P; + /** Maximum size, in octets, of the payload from the Peripheral's Link Layer to the + * Central's Link Layer. + * Values: + * - 0x0000 ... 0x00FB + */ + uint16_t Max_PDU_P_To_C; + /** PHY to use for transmission from the Central to the Peripheral. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + */ + uint8_t PHY_C_To_P; + /** PHY to use for transmission from the Peripheral to the Central. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + */ + uint8_t PHY_P_To_C; + /** The burst number for Central to Peripheral. + * Values: + * - 0x00: No data + * - 0x01 ... 0x0F + */ + uint8_t BN_C_To_P; + /** The burst number for Peripheral to Central. + * Values: + * - 0x00: No data + * - 0x01 ... 0x0F + */ + uint8_t BN_P_To_C; +} CIS_Param_Test_t; + +/** Documentation for C struct CIS_Handles_t */ +typedef struct CIS_Handles_t_s { + /** Connection handle of a CIS. + * Values: + * - 0x0000 ... 0x0EFF + */ + uint16_t CIS_Connection_Handle; + /** Connection handle of an ACL connection. + * Values: + * - 0x0000 ... 0x0EFF + */ + uint16_t ACL_Connection_Handle; +} CIS_Handles_t; + +/** Documentation for C struct Bonded_Device_Entry_t */ +typedef struct Bonded_Device_Entry_t_s { + /** Address type. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + */ + uint8_t Address_Type; + /** Identity Address (Public or Random) of the device. + */ + uint8_t Address[6]; +} Bonded_Device_Entry_t; + +/** Documentation for C struct List_Entry_t */ +typedef struct List_Entry_t_s { + /** Address type. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + */ + uint8_t Peer_Address_Type; + /** Public Device Address or Random Device Address of the device to be added to the + * list. + */ + uint8_t Peer_Address[6]; +} List_Entry_t; + +/** Documentation for C union UUID_t */ +typedef union UUID_t_s { + /** 16-bit UUID + */ + uint16_t UUID_16; + /** 128-bit UUID + */ + uint8_t UUID_128[16]; +} UUID_t; + +/** Documentation for C struct Gatt_Srv_Notify_Attr_t */ +typedef struct Gatt_Srv_Notify_Attr_t_s { + /** + */ + uint16_t Handle; + /** + */ + uint16_t Val_Length; + /** + */ + uint8_t *Val; +} Gatt_Srv_Notify_Attr_t; + +/** Documentation for C struct Subevent_Data_Ptr_Parameters_t */ +typedef struct Subevent_Data_Ptr_Parameters_t_s { + /** The number of octets in the Subevent_Data parameter. + * Values: + * - 0x00 ... 0xFB + */ + uint8_t Subevent; + /** The number of response slots to be used. + */ + uint8_t Response_Slot_Start; + /** The number of response slots to be used. + */ + uint8_t Response_Slot_Count; + /** The number of octets in buffer pointed by Subevent_Data parameter. + * Values: + * - 0x00 ... 0xFB + */ + uint8_t Subevent_Data_Length; + /** Pointer to advertising data formatted as defined in [Vol 3] Part C, Section 11. + */ + uint8_t* Subevent_Data; +} Subevent_Data_Ptr_Parameters_t; + + +/** + *@addtogroup HCI HCI + *@brief Host Controller Interface. + *@{ + */ +/** + *@defgroup HCI_Commands HCI Commands + *@brief Standard HCI Commands. + *@{ + */ +/** + * @brief The @ref hci_disconnect is used to terminate an existing connection. + * The Connection_Handle command parameter indicates which connection is + * to be disconnected. The Reason command parameter indicates the reason + * for ending the connection. The remote Controller will receive the + * Reason command parameter in the @ref hci_disconnection_complete_event + * event. All synchronous connections on a physical link should be + * disconnected before the ACL connection on the same physical connection + * is disconnected. (See Bluetooth Specification v.4.1, Vol. 2, Part E, + * 7.1.6) It is important to leave an 100 ms blank window before sending + * any new command (including system hardware reset), since immediately + * after @ref hci_disconnection_complete_event event, system could save + * important information in non volatile memory. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Reason The reason for ending the connection. + * Values: + * - 0x05: Authentication Failure + * - 0x13: Remote User Terminated Connection + * - 0x14: Remote Device Terminated Connection due to Low Resources + * - 0x15: Remote Device Terminated Connection due to Power Off + * - 0x1A: Unsupported Remote Feature + * - 0x3B: Unacceptable Connection Parameters + * @retval Value indicating success or error code. + */ +tBleStatus hci_disconnect(uint16_t Connection_Handle, + uint8_t Reason); +/** + * @brief This command will obtain the values for the version information for + * the remote device identified by the Connection_Handle parameter. The + * Connection_Handle must be a Connection_Handle for an ACL or LE + * connection. (See Bluetooth Specification v.4.1, Vol. 2, Part E, + * 7.1.23) + * @param Connection_Handle Specifies which Connection_Handle's version + * information to get. + * Values: + * - 0x0000 ... 0x0EFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_remote_version_information(uint16_t Connection_Handle); +/** + * @brief The Set_Event_Mask command is used to control which events are + * generated by the HCI for the Host. If the bit in the Event_Mask is + * set to a one, then the event associated with that bit will be enabled. + * For an LE Controller, the LE Meta Event bit in the Event_Mask shall + * enable or disable all LE events in the LE Meta Event (see Section + * 7.7.65). The Host has to deal with each event that occurs. The event + * mask allows the Host to control how much it is interrupted. (See + * Bluetooth Specification v.4.1, Vol. 2, Part E, 7.3.1) + * @param Event_Mask Event mask. Default: 0x00001FFFFFFFFFFF + * Flags: + * - 0x0000000000000000: No events specified + * - 0x0000000000000001: Inquiry Complete Event + * - 0x0000000000000002: Inquiry Result Event + * - 0x0000000000000004: Connection Complete Event + * - 0x0000000000000008: Connection Request Event + * - 0x0000000000000010: Disconnection Complete Event + * - 0x0000000000000020: Authentication Complete Event + * - 0x0000000000000040: Remote Name Request Complete Event + * - 0x0000000000000080: Encryption Change Event + * - 0x0000000000000100: Change Connection Link Key Complete Event + * - 0x0000000000000200: Central Link Key Complete Event + * - 0x0000000000000400: Read Remote Supported Features Complete Event + * - 0x0000000000000800: Read Remote Version Information Complete Event + * - 0x0000000000001000: QoS Setup Complete Event + * - 0x0000000000008000: Hardware Error Event + * - 0x0000000000010000: Flush Occurred Event + * - 0x0000000000020000: Role Change Event + * - 0x0000000000080000: Mode Change Event + * - 0x0000000000100000: Return Link Keys Event + * - 0x0000000000200000: PIN Code Request Event + * - 0x0000000000400000: Link Key Request Event + * - 0x0000000000800000: Link Key Notification Event + * - 0x0000000001000000: Loopback Command Event + * - 0x0000000002000000: Data Buffer Overflow Event + * - 0x0000000004000000: Max Slots Change Event + * - 0x0000000008000000: Read Clock Offset Complete Event + * - 0x0000000010000000: Connection Packet Type Changed Event + * - 0x0000000020000000: QoS Violation Event + * - 0x0000000040000000: Page Scan Mode Change Event + * - 0x0000000080000000: Page Scan Repetition Mode Change Event + * - 0x0000000100000000: Flow Specification Complete Event + * - 0x0000000200000000: Inquiry Result with RSSI Event + * - 0x0000000400000000: Read Remote Extended Features Complete Event + * - 0x0000080000000000: Synchronous Connection Complete Event + * - 0x0000100000000000: Synchronous Connection Changed Event + * - 0x0000200000000000: Sniff Subrating Event + * - 0x0000400000000000: Extended Inquiry Result Event + * - 0x0000800000000000: Encryption Key Refresh Complete Event + * - 0x0001000000000000: IO Capability Request Event + * - 0x0002000000000000: IO Capability Request Reply Event + * - 0x0004000000000000: User Confirmation Request Event + * - 0x0008000000000000: User Passkey Request Event + * - 0x0010000000000000: Remote OOB Data Request Event + * - 0x0020000000000000: Simple Pairing Complete Event + * - 0x0080000000000000: Link Supervision Timeout Changed Event + * - 0x0100000000000000: Enhanced Flush Complete Event + * - 0x0400000000000000: User Passkey Notification Event + * - 0x0800000000000000: Keypress Notification Event + * - 0x1000000000000000: Remote Host Supported Features Notification Event + * - 0x2000000000000000: LE Meta-Event + * @retval Value indicating success or error code. + */ +tBleStatus hci_set_event_mask(uint8_t Event_Mask[8]); +/** + * @brief The HCI_Read_Connection_Accept_Timeout command will read the value for + * the Connection Accept Timeout configuration parameter, which allows + * the Controller to automatically deny a connection request after a + * specified period has occurred, and to refuse a new connection. + * @param[out] Connection_Accept_Timeout Connection Accept Timeout. Interval + * Length = N * 0.625 ms + * Values: + * - 0x0001 (0.625 ms) ... 0xB540 (29000.000 ms) + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_connection_accept_timeout(uint16_t *Connection_Accept_Timeout); +/** + * @brief The HCI_Write_Connection_Accept_Timeout command will write the value + * for the Connection Accept Timeout configuration parameter, which + * allows the Controller to automatically deny a connection request after + * a specified period has occurred, and to refuse a new connection. + * @param Connection_Accept_Timeout Connection Accept Timeout. Interval Length = + * N * 0.625 ms Default: 0x1FA0 Time = 5.06 s Mandatory Range for + * Controller: 0x00A0 to 0xB540 + * Values: + * - 0x0001 (0.625 ms) ... 0xB540 (29000.000 ms) + * @retval Value indicating success or error code. + */ +tBleStatus hci_write_connection_accept_timeout(uint16_t Connection_Accept_Timeout); +/** + * @brief This command reads the values for the Transmit_Power_Level parameter + * for the specified Connection_Handle. The Connection_Handle shall be a + * Connection_Handle for an ACL connection. (See Bluetooth Specification + * v.4.1, Vol. 2, Part E, 7.3.35) + * @param Connection_Handle Specifies which Connection_Handle's Transmit Power + * Level setting to read. + * Values: + * - 0x0000 ... 0x0EFF + * @param Type Current or maximum transmit power level. + * Values: + * - 0x00: Read Current Transmit Power Level. + * - 0x01: Read Maximum Transmit Power Level. + * @param[out] Transmit_Power_Level Size: 1 Octet (signed integer) Units: dBm + * Values: + * - -30 ... 20 + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_transmit_power_level(uint16_t Connection_Handle, + uint8_t Type, + int8_t *Transmit_Power_Level); +/** + * @brief The HCI_Read_AFH_Channel_Assessment_Mode command reads the value for + * the AFH_Channel_Assessment_Mode parameter. The + * AFH_Channel_Assessment_Mode parameter controls whether the + * Controller's channel assessment scheme is enabled or disabled. + * @param[out] AFH_Channel_Assessment_Mode Enable or disable channel assessment + * scheme. + * Values: + * - 0x00: DISABLED + * - 0x01: ENABLED + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_afh_channel_assessment_mode(uint8_t *AFH_Channel_Assessment_Mode); +/** + * @brief The HCI_Write_AFH_Channel_Assessment_Mode command writes the value for + * the AFH_Channel_Assessment_Mode parameter. The + * AFH_Channel_Assessment_Mode parameter controls whether the + * Controller's channel assessment scheme is enabled or disabled. + * @param AFH_Channel_Assessment_Mode + * Values: + * - 0x00: DISABLED + * - 0x01: ENABLED + * @retval Value indicating success or error code. + */ +tBleStatus hci_write_afh_channel_assessment_mode(uint8_t AFH_Channel_Assessment_Mode); +/** + * @brief The HCI_Set_Event_Mask_Page_2 command is used to control which events + * are generated by the HCI for the Host. The Event_Mask_Page_2 is a + * logical extension to the Event_Mask parameter of the + * HCI_Set_Event_Mask command. If the bit in the Event_Mask_Page_2 is set + * to a one, then the event associated with that bit shall be enabled. + * The event mask allows the Host to control how much it is interrupted. + * The Controller shall ignore those bits which are reserved for future + * use or represent events which it does not support. If the Host sets + * any of these bits to 1, the Controller shall act as if they were set + * to 0. + * @param Event_Mask_Page_2 For the complete list of bits that can be set, see + * Core v5.1, Vol 2, part E, chapter 7.3.69. The only bit that is not + * ignored is: Bit 23: Authenticated Payload Timeout Expired event. + * Flags: + * - 0x0000000000800000: AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED_EVENT + * @retval Value indicating success or error code. + */ +tBleStatus hci_set_event_mask_page_2(uint8_t Event_Mask_Page_2[8]); +/** + * @brief This command reads the Authenticated_Payload_Timeout parameter in the + * Primary Controller on the specified Connection_Handle. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] Authenticated_Payload_Timeout Maximum amount of time specified + * between packets authenticated by a MIC. Time = N * 10 ms. + * Values: + * - 0x0001 (10 ms) ... 0xFFFF (655350 ms) + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_authenticated_payload_timeout(uint16_t Connection_Handle, + uint16_t *Authenticated_Payload_Timeout); +/** + * @brief This command writes the Authenticated_Payload_Timeout parameter in the + * Primary Controller for the specified Connection_Handle. The + * Authenticated_Payload_Timeout shall be equal to or greater than + * connInterval * (1 + connPeripheralLatency). The Link Layer will use + * this parameter to determine when to use the LE ping sequence. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Authenticated_Payload_Timeout Maximum amount of time specified between + * packets authenticated by a valid MIC. Time = N * 10 ms. + * Values: + * - 0x0001 (10 ms) ... 0xFFFF (655350 ms) + * @retval Value indicating success or error code. + */ +tBleStatus hci_write_authenticated_payload_timeout(uint16_t Connection_Handle, + uint16_t Authenticated_Payload_Timeout); +/** + * @brief This command reads the values for the version information for the + * local Controller. The HCI Version information defines the version + * information of the HCI layer. The LMP/PAL Version information defines + * the version of the LMP or PAL. The Manufacturer_Name information + * indicates the manufacturer of the local device. The HCI Revision and + * LMP/PAL Subversion are implementation dependent. (See Bluetooth + * Specification v.4.1, Vol. 2, Part E, 7.4.1) + * @param[out] HCI_Version See Bluetooth Assigned Numbers + * (https://www.bluetooth.org/en-us/specification/assigned-numbers) + * @param[out] HCI_Revision Revision of the Current HCI in the BR/EDR + * Controller. + * @param[out] LMP_PAL_Version Version of the Current LMP or PAL in the + * Controller. See Bluetooth Assigned Numbers + * (https://www.bluetooth.org/en-us/specification/assigned-numbers) + * @param[out] Manufacturer_Name Manufacturer Name of the BR/EDR Controller. See + * Bluetooth Assigned Numbers (https://www.bluetooth.org/en- + * us/specification/assigned-numbers) + * @param[out] LMP_PAL_Subversion Subversion of the Current LMP or PAL in the + * Controller. This value is implementation dependent. + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_local_version_information(uint8_t *HCI_Version, + uint16_t *HCI_Revision, + uint8_t *LMP_PAL_Version, + uint16_t *Manufacturer_Name, + uint16_t *LMP_PAL_Subversion); +/** + * @brief This command reads the list of HCI commands supported for the local + * Controller. This command shall return the Supported_Commands + * configuration parameter. It is implied that if a command is listed as + * supported, the feature underlying that command is also supported. (See + * Bluetooth Specification v.4.1, Vol. 2, Part E, 7.4.2) + * @param[out] Supported_Commands Bit mask for each HCI Command. If a bit is 1, + * the Controller supports the corresponding command and the + * features required for the command. Unsupported or undefined + * commands shall be set to 0. + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_local_supported_commands(uint8_t Supported_Commands[64]); +/** + * @brief This command requests a list of the supported features for the local + * Controller. This command will return a list of the LMP features. For + * details see Part C, Link Manager Protocol Specification on page 227. + * (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.4.3) + * @param[out] LMP_Features Bit Mask List of LMP features. + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_local_supported_features(uint8_t LMP_Features[8]); +/** + * @brief On an LE Controller, this command shall read the Public Device Address + * as defined in [Vol 6] Part B, Section 1.3, Device Address. If this + * Controller does not have a Public Device Address, the value + * 0x000000000000 shall be returned. On an LE Controller, the public + * address shall be the same as the BD_ADDR. (See Bluetooth Specification + * v.4.1, Vol. 2, Part E, 7.4.6) + * @param[out] BD_ADDR BD_ADDR ( Bluetooth Device Address) of the Device. + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_bd_addr(uint8_t BD_ADDR[6]); +/** + * @brief This command reads the Received Signal Strength Indication (RSSI) + * value from a Controller. For an LE transport, a Connection_Handle is + * used as the Handle command parameter and return parameter. The meaning + * of the RSSI metric is an absolute receiver signal strength value in + * dBm to +/- 6 dB accuracy. If the RSSI cannot be read, the RSSI metric + * shall be set to 127. (See Bluetooth Specification v.4.1, Vol. 2, Part + * E, 7.5.4) + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] RSSI N Size: 1 Octet (signed integer) Units: dBm + * Values: + * - -127 ... 20 + * - 127: RSSI not available + * @retval Value indicating success or error code. + */ +tBleStatus hci_read_rssi(uint16_t Connection_Handle, + int8_t *RSSI); +/** + * @brief The LE_Set_Event_Mask command is used to control which LE events are + * generated by the HCI for the Host. If the bit in the LE_Event_Mask is + * set to a one, then the event associated with that bit will be enabled. + * The Host has to deal with each event that is generated by an LE + * Controller. The event mask allows the Host to control which events + * will interrupt it. For LE events to be generated, the LE Meta-Event + * bit in the Event_Mask shall also be set. If that bit is not set, then + * LE events shall not be generated, regardless of how the LE_Event_Mask + * is set. (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.1) + * @param LE_Event_Mask LE event mask. Default: 0x000000000000001F. + * Flags: + * - 0x0000000000000000: No LE events specified + * - 0x0000000000000001: LE Connection Complete Event + * - 0x0000000000000002: LE Advertising Report Event + * - 0x0000000000000004: LE Connection Update Complete Event + * - 0x0000000000000008: LE Read Remote Used Features Complete Event + * - 0x0000000000000010: LE Long Term Key Request Event + * - 0x0000000000000020: LE Remote Connection Parameter Request Event + * - 0x0000000000000040: LE Data Length Change Event + * - 0x0000000000000080: LE Read Local P-256 Public Key Complete Event + * - 0x0000000000000100: LE Generate DHKey Complete Event + * - 0x0000000000000200: LE Enhanced Connection Complete Event + * - 0x0000000000000400: LE Directed Advertising Report Event + * - 0x0000000000000800: LE PHY Update Complete event + * - 0x0000000000001000: LE Extended Advertising Report event + * - 0x0000000000002000: LE Periodic Advertising Sync Established event + * - 0x0000000000004000: LE Periodic Advertising Report event + * - 0x0000000000008000: LE Periodic Advertising Sync Lost event + * - 0x0000000000010000: LE Scan Timeout event + * - 0x0000000000020000: LE Advertising Set Terminated event + * - 0x0000000000040000: LE Scan Request Received event + * - 0x0000000000080000: LE Channel Selection Algorithm event + * - 0x0000000000100000: LE Connectionless IQ Report event + * - 0x0000000000200000: LE Connection IQ Report event + * - 0x0000000000400000: LE CTE Request Failed event + * - 0x0000000000800000: LE Periodic Advertising Sync Transfer Received event + * - 0x0000000001000000: LE CIS Established event + * - 0x0000000002000000: LE CIS Request event + * - 0x0000000004000000: LE Create BIG Complete event + * - 0x0000000008000000: LE Terminate BIG Complete event + * - 0x0000000010000000: LE BIG Sync Established event + * - 0x0000000020000000: LE BIG Sync Lost event + * - 0x0000000040000000: LE Request Peer SCA Complete event + * - 0x0000000080000000: LE Path Loss Threshold event + * - 0x0000000100000000: LE Transmit Power Reporting event + * - 0x0000000200000000: LE BIGInfo Advertising Report event + * - 0x0000000400000000: LE Subrate Change event + * - 0x0000000800000000: LE Periodic Advertising Sync Established event [v2] + * - 0x0000001000000000: LE Periodic Advertising Report event [v2] + * - 0x0000002000000000: LE Periodic Advertising Sync Transfer Received event [v2] + * - 0x0000004000000000: LE Periodic Advertising Subevent Data Request event + * - 0x0000008000000000: LE Periodic Advertising Response Report event + * - 0x0000010000000000: LE Enhanced Connection Complete event [v2] + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_event_mask(uint8_t LE_Event_Mask[8]); +/** + * @brief The LE_Read_Buffer_Size command is used to read the maximum size of + * the data portion of HCI LE ACL Data Packets sent from the Host to the + * Controller. The Host will segment the data transmitted to the + * Controller according to these values, so that the HCI Data Packets + * will contain data with up to this size. The LE_Read_Buffer_Size + * command also returns the total number of HCI LE ACL Data Packets that + * can be stored in the data buffers of the Controller. The + * LE_Read_Buffer_Size command must be issued by the Host before it sends + * any data to an LE Controller (see Section 4.1.1). If the Controller + * returns a length value of zero, the Host shall use the + * Read_Buffer_Size command to determine the size of the data buffers + * Note: Both the Read_Buffer_Size and LE_Read_Buffer_Size commands may + * return buffer length and number of packets parameter values that are + * nonzero. The HC_LE_ACL_Data_Packet_Length return parameter shall be + * used to determine the size of the L2CAP PDU segments contained in ACL + * Data Packets, which are transferred from the Host to the Controller to + * be broken up into packets by the Link Layer. Both the Host and the + * Controller shall support command and event packets, where the data + * portion (excluding header) contained in the packets is 255 octets in + * size. The HC_Total_Num_LE_ACL_Data_Packets return parameter contains + * the total number of HCI ACL Data Packets that can be stored in the + * data buffers of the Controller. The Host determines how the buffers + * are to be divided between different Connection Handles. Note: The + * HC_LE_ACL_Data_Packet_Length return parameter does not include the + * length of the HCI Data Packet header. (See Bluetooth Specification + * v.4.1, Vol. 2, Part E, 7.8.2) + * @param[out] HC_LE_ACL_Data_Packet_Length 0x0000: No dedicated LE Buffer + * exists. Use the HCI_Read_Buffer_Size command. 0x001B - 0xFFFF + * Maximum length (in octets) of the data portion of each HCI ACL + * data packet. + * Values: + * - 0x0000: NO_BUFFER + * - 0x001B ... 0xFFFF + * @param[out] HC_Total_Num_LE_ACL_Data_Packets 0x00: No dedicated LE Buffer + * exists. Use the HCI_Read_Buffer_Size command. 0x01 - 0xFF: Total + * number of HCI ACL Data Packets that can be stored in the data + * buffers of the Controller. + * Values: + * - 0x00: NO_BUFFER + * - 0x01 ... 0xFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_buffer_size(uint16_t *HC_LE_ACL_Data_Packet_Length, + uint8_t *HC_Total_Num_LE_ACL_Data_Packets); +/** + * @brief This command requests the list of the supported LE features for the + * Controller. (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.3) + * @param[out] LE_Features Bit Mask List of LE features. See Core v4.1, Vol. 6, + * Part B, Section 4.6. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_local_supported_features(uint8_t LE_Features[8]); +/** + * @brief The LE_Set_Random_Address command is used by the Host to set the LE + * Random Device Address in the Controller (see [Vol 6] Part B, Section + * 1.3). (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.4) + * @param Random_Address Random Device Address. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_random_address(uint8_t Random_Address[6]); +/** + * @brief The LE_Set_Advertising_Parameters command is used by the Host to set + * the advertising parameters. The Advertising_Interval_Min shall be less + * than or equal to the Advertising_Interval_Max. The + * Advertising_Interval_Min and Advertising_Interval_Max should not be + * the same value to enable the Controller to determine the best + * advertising interval given other activities. For high duty cycle + * directed advertising, i.e. when Advertising_Type is 0x01 + * (ADV_DIRECT_IND, high duty cycle), the Advertising_Interval_Min and + * Advertising_Interval_Max parameters are not used and shall be ignored. + * The Advertising_Type is used to determine the packet type that is used + * for advertising when advertising is enabled. Own_Address_Type + * parameter indicates the type of address being used in the advertising + * packets. If Own_Address_Type equals 0x02 or 0x03, the Peer_Address + * parameter contains the peer's Identity Address and the + * Peer_Address_Type parameter contains the Peer's Identity Type (i.e. + * 0x00 or 0x01). These parameters are used to locate the corresponding + * local IRK in the resolving list; this IRK is used to generate the own + * address used in the advertisement. If directed advertising is + * performed, i.e. when Advertising_Type is set to 0x01 (ADV_DIRECT_IND, + * high duty cycle) or 0x04 (ADV_DIRECT_IND, low duty cycle mode), then + * the Peer_Address_Type and Peer_Address shall be valid. If + * Own_Address_Type equals 0x02 or 0x03, the Controller generates the + * peer's Resolvable Private Address using the peer's IRK corresponding + * to the peer's Identity Address contained in the Peer_Address parameter + * and peer's Identity Address Type (i.e. 0x00 or 0x01) contained in the + * Peer_Address_Type parameter. The Advertising_Channel_Map is a bit + * field that indicates the advertising channels that shall be used when + * transmitting advertising packets. At least one channel bit shall be + * set in the Advertising_Channel_Map parameter. The + * Advertising_Filter_Policy parameter shall be ignored when directed + * advertising is enabled. The Host shall not issue this command when + * advertising is enabled in the Controller; if it is the Command + * Disallowed error code shall be used. If the advertising interval range + * provided by the Host (Advertising_Interval_Min, + * Advertising_Interval_Max) is outside the advertising interval range + * supported by the Controller, then the Controller shall return the + * Unsupported Feature or Parameter Value (0x11) error code. + * @param Advertising_Interval_Min Minimum advertising interval for undirected + * and low duty cycle directed advertising. Time = N * 0.625 msec. + * Values: + * - 0x0020 (20.000 ms) ... 0x4000 (10240.000 ms) + * @param Advertising_Interval_Max Maximum advertising interval. Time = N * + * 0.625 msec. + * Values: + * - 0x0020 (20.000 ms) ... 0x4000 (10240.000 ms) + * @param Advertising_Type Advertising type. + * Values: + * - 0x00: ADV_IND (Connectable undirected advertising) + * - 0x01: ADV_DIRECT_IND, high duty cycle (Connectable high duty cycle directed advertising) + * - 0x02: ADV_SCAN_IND (Scannable undirected advertising) + * - 0x03: ADV_NONCONN_IND (Non connectable undirected advertising) + * - 0x04: ADV_DIRECT_IND, low duty cycle (Connectable low duty cycle directed advertising) + * @param Own_Address_Type Own address type. - 0x00: Public Device Address - + * 0x01 Random Device Address - 0x02: Controller generates Resolvable + * Private Address based on the local IRK from resolving list. + * If resolving list contains no matching entry, use public + * address. - 0x03: Controller generates Resolvable Private Address + * based on the local IRK from resolving list. If resolving list + * contains no matching entry, use random address from + * LE_Set_Random_Address. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Resolvable Private Address or Public Address + * - 0x03: Resolvable Private Address or Random Address + * @param Peer_Address_Type Peer Address type. + * Values: + * - 0x00: Public Device Address or Public Identity Address + * - 0x01: Random Device Address or Random (static) Identity Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address or Random (static) Identity Address of the device to + * be connected. + * @param Advertising_Channel_Map Advertising channel map. Default: 00000111b + * (all channels enabled). + * Flags: + * - 0x01: ch 37 + * - 0x02: ch 38 + * - 0x04: ch 39 + * @param Advertising_Filter_Policy Advertising Filter Policy. This parameter is + * ignored when directed advertising is enabled. 0x00 Process scan and + * connection requests from all devices (i.e., the Filter Accept List is + * not in use) 0x01 Process connection requests from all devices and scan + * requests only from devices that are in the Filter Accept List 0x02 + * Process scan requests from all devices and connection requests only + * from devices that are in the Filter Accept List. 0x03 Process scan and + * connection requests only from devices in the Filter Accept List. All + * other values are reserved for future use + * Values: + * - 0x00: HCI_ADV_FILTER_NONE + * - 0x01: HCI_ADV_FILTER_ACCEPT_LIST_SCAN + * - 0x02: HCI_ADV_FILTER_ACCEPT_LIST_CONNECT + * - 0x03: HCI_ADV_FILTER_ACCEPT_LIST_SCAN_CONNECT + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_advertising_parameters(uint16_t Advertising_Interval_Min, + uint16_t Advertising_Interval_Max, + uint8_t Advertising_Type, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Channel_Map, + uint8_t Advertising_Filter_Policy); +/** + * @brief The LE_Read_Advertising_Physical_Channel_Tx_Power command is used by + * the Host to read the transmit power level used for LE advertising + * channel packets. (See Bluetooth Specification v.4.1, Vol. 2, Part E, + * 7.8.6) + * @param[out] Transmit_Power_Level Size: 1 Octet (signed integer) Units: dBm + * Accuracy: +/- 4 dBm + * Values: + * - -20 ... 10 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_advertising_physical_channel_tx_power(int8_t *Transmit_Power_Level); +/** + * @brief The LE_Set_Advertise_Enable command is used to request the Controller + * to start or stop advertising. The Controller manages the timing of + * advertisements as per the advertising parameters given in the + * LE_Set_Advertising_Parameters command. The Controller shall continue + * advertising until the Host issues an LE_Set_Advertise_Enable command + * with Advertising_Enable set to 0x00 (Advertising is disabled) or until + * a connection is created or until the Advertising is timed out due to + * high duty cycle Directed Advertising. In these cases, advertising is + * then disabled. (See Bluetooth Specification v.4.1, Vol. 2, Part E, + * 7.8.9) + * @param Advertising_Enable Enable/disable advertise. Default is 0 (disabled). + * Values: + * - 0x00: Disable + * - 0x01: Enable + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_advertising_enable(uint8_t Advertising_Enable); +/** + * @brief The LE_Set_Scan_Parameters command is used to set the scan parameters. + * The LE_Scan_Type parameter controls the type of scan to perform. The + * LE_Scan_Interval and LE_Scan_Window parameters are recommendations + * from the Host on how long (LE_Scan_Window) and how frequently + * (LE_Scan_Interval) the Controller should scan (See [Vol 6] Part B, + * Section 4.5.3). The LE_Scan_Window parameter shall always be set to a + * value smaller or equal to the value set for the LE_Scan_Interval + * parameter. If they are set to the same value scanning should be run + * continuously. The Own_Address_Type parameter determines the address + * used (Public or Random Device Address) when performing active scan. + * The Host shall not issue this command when scanning is enabled in the + * Controller; if it is the Command Disallowed error code shall be used. + * (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.10) + * @param LE_Scan_Type Passive or active scanning. With active scanning SCAN_REQ + * packets are sent. + * Values: + * - 0x00: Passive Scanning + * - 0x01: Active scanning + * @param LE_Scan_Interval This is defined as the time interval from when the + * Controller started its last LE scan until it begins the subsequent LE + * scan. Time = N * 0.625 msec. + * Values: + * - 0x0004 (2.500 ms) ... 0x4000 (10240.000 ms) + * @param LE_Scan_Window The duration of the LE scan. LE_Scan_Window shall be + * less than or equal to LE_Scan_Interval. Time = N * 0.625 msec. + * Values: + * - 0x0004 (2.500 ms) ... 0x4000 (10240.000 ms) + * @param Own_Address_Type Own address type. - 0x00: Public Device Address - + * 0x01 Random Device Address - 0x02: Controller generates Resolvable + * Private Address based on the local IRK from resolving list. + * If resolving list contains no matching entry, use public + * address. - 0x03: Controller generates Resolvable Private Address + * based on the local IRK from resolving list. If resolving list + * contains no matching entry, use random address from + * LE_Set_Random_Address. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Resolvable Private Address or Public Address + * - 0x03: Resolvable Private Address or Random Address + * @param Scanning_Filter_Policy See Scanning filter policy in Bluetooth Core + * specification. + * Values: + * - 0x00: Basic unfiltered scanning filter policy + * - 0x01: Basic filtered scanning filter policy + * - 0x02: Extended unfiltered scanning filter policy + * - 0x03: Extended filtered scanning filter policy + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_scan_parameters(uint8_t LE_Scan_Type, + uint16_t LE_Scan_Interval, + uint16_t LE_Scan_Window, + uint8_t Own_Address_Type, + uint8_t Scanning_Filter_Policy); +/** + * @brief The LE_Set_Scan_Enable command is used to start scanning. Scanning is + * used to discover advertising devices nearby. The Filter_Duplicates + * parameter controls whether the Link Layer shall filter duplicate + * advertising reports to the Host, or if the Link Layer should generate + * advertising reports for each packet received. (See Bluetooth + * Specification v.4.1, Vol. 2, Part E, 7.8.11) + * @param LE_Scan_Enable Enable/disable scan. Default is 0 (disabled). + * Values: + * - 0x00: Scanning disabled + * - 0x01: Scanning enabled + * @param Filter_Duplicates Enable/disable duplicate filtering. + * Values: + * - 0x00: Duplicate filtering disabled + * - 0x01: Duplicate filtering enabled + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_scan_enable(uint8_t LE_Scan_Enable, + uint8_t Filter_Duplicates); +/** + * @brief The LE_Create_Connection command is used to create a Link Layer + * connection to a connectable advertiser. The LE_Scan_Interval and + * LE_Scan_Window parameters are recommendations from the Host on how + * long (LE_Scan_Window) and how frequently (LE_Scan_Interval) the + * Controller should scan. The LE_Scan_Window parameter shall be set to a + * value smaller or equal to the value set for the LE_Scan_Interval + * parameter. If both are set to the same value, scanning should run + * continuously. The Initiator_Filter_Policy is used to determine whether + * the Filter Accept List is used. If the Filter Accept List is not used, + * the Peer_Address_Type and the Peer_Address parameters specify the + * address type and address of the advertising device to connect to. The + * Link Layer shall set the address in the CONNECT_REQ packets to either + * the Public Device Address or the Random Device Addressed based on the + * Own_Address_Type parameter. The Connection_Interval_Min and + * Connection_Interval_Max parameters define the minimum and maximum + * allowed connection interval. The Connection_Interval_Min parameter + * shall not be greater than the Connection_Interval_Max parameter. The + * Max_Latency parameter defines the maximum allowed connection latency + * (see [Vol 6] Part B, Section 4.5.1). The Supervision_Timeout parameter + * defines the link supervision timeout for the connection. The + * Supervision_Timeout in milliseconds shall be larger than (1 + + * Max_Latency) * Connection_Interval_Max * 2, where + * Connection_Interval_Max is given in milliseconds. (See [Vol 6] Part B, + * Section 4.5.2). The Min_CE_Length and Max_CE_Length parameters are + * informative parameters providing the Controller with the expected + * minimum and maximum length of the connection events. The Min_CE_Length + * parameter shall be less than or equal to the Max_CE_Length parameter. + * The Host shall not issue this command when another + * LE_Create_Connection is pending in the Controller; if this does occur + * the Controller shall return the Command Disallowed error code shall be + * used. (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.12) + * @param LE_Scan_Interval This is defined as the time interval from when the + * Controller started its last LE scan until it begins the subsequent LE + * scan. Time = N * 0.625 msec. + * Values: + * - 0x0004 (2.500 ms) ... 0x4000 (10240.000 ms) + * @param LE_Scan_Window The duration of the LE scan. LE_Scan_Window shall be + * less than or equal to LE_Scan_Interval. Time = N * 0.625 msec. + * Values: + * - 0x0004 (2.500 ms) ... 0x4000 (10240.000 ms) + * @param Initiator_Filter_Policy 0x00 Filter Accept List is not used to + * determine which advertiser to connect to. Peer_Address_Type and + * Peer_Address shall be used. 0x01 Filter Accept List is used to + * determine which advertiser to connect to. Peer_Address_Type and + * Peer_Address shall be ignored. + * Values: + * - 0x00: Filter Accept List not used + * - 0x01: Filter Accept List used + * @param Peer_Address_Type 0x00 Public Device Address 0x01 Random Device + * Address 0x02 Public Identity Address (Corresponds to Resolved Private + * Address) 0x03 Random (Static) Identity Address (Corresponds to + * Resolved Private Address) + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address + * - 0x03: Random (Static) Identity Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address or Random (static) Identity Address of the + * advertising device. + * @param Own_Address_Type Own address type. - 0x00: Public Device Address - + * 0x01 Random Device Address - 0x02: Controller generates Resolvable + * Private Address based on the local IRK from resolving list. + * If resolving list contains no matching entry, use public + * address. - 0x03: Controller generates Resolvable Private Address + * based on the local IRK from resolving list. If resolving list + * contains no matching entry, use random address from + * LE_Set_Random_Address. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Resolvable Private Address or Public Address + * - 0x03: Resolvable Private Address or Random Address + * @param Connection_Interval_Min Minimum value for the connection event + * interval. This shall be less than or equal to Connection_Interval_Max. + * Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Connection_Interval_Max Maximum value for the connection event + * interval. This shall be greater than or equal to + * Connection_Interval_Min. Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Max_Latency Maximum Peripheral latency for the connection in number of + * connection events. + * Values: + * - 0x0000 ... 0x01F3 + * @param Supervision_Timeout Supervision timeout for the LE Link. It shall be a + * multiple of 10 ms and larger than (1 + connPeripheralLatency) * + * connInterval * 2. Time = N * 10 msec. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + * @param Min_CE_Length The minimum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @param Max_CE_Length The maximum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_create_connection(uint16_t LE_Scan_Interval, + uint16_t LE_Scan_Window, + uint8_t Initiator_Filter_Policy, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Own_Address_Type, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); +/** + * @brief The LE_Create_Connection_Cancel command is used to cancel the + * LE_Create_Connection command. This command shall only be issued after + * the LE_Create_Connection command has been issued, a Command Status + * event has been received for the LE Create Connection command and + * before the LE Connection Complete event. (See Bluetooth Specification + * v.4.1, Vol. 2, Part E, 7.8.13) + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_create_connection_cancel(void); +/** + * @brief The LE_Read_Filter_Accept_List_Size command is used to read the total + * number of Filter Accept list entries that can be stored in the + * Controller. + * @param[out] Filter_Accept_List_Size Total number of Filter Accept List + * entries that can be stored in the Controller. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_filter_accept_list_size(uint8_t *Filter_Accept_List_Size); +/** + * @brief The LE_Clear_Filter_Accept_List command is used to clear the Filter + * Accept list stored in the Controller. This command can be used at any + * time except when: - the advertising filter policy uses the Filter + * Accept list and advertising is enabled. - the scanning filter policy + * uses the Filter Accept list and scanning is enabled. - the initiator + * filter policy uses the Filter Accept list and an LE_Create_Connection + * command is outstanding. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_clear_filter_accept_list(void); +/** + * @brief The LE_Add_Device_To_Filter_Accept_List command is used to add a + * single device to the Filter Accept list stored in the Controller. This + * command can be used at any time except when: - the advertising filter + * policy uses the Filter Accept list and advertising is enabled. - the + * scanning filter policy uses the Filter Accept list and scanning is + * enabled. - the initiator filter policy uses the Filter Accept list and + * a create connection command is outstanding. + * @param Address_Type Address type. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * @param Address Public Device Address or Random Device Address of the device + * to be added to the list. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_add_device_to_filter_accept_list(uint8_t Address_Type, + uint8_t Address[6]); +/** + * @brief The LE_Remove_Device_From_Filter_Accept_List command is used to remove + * a single device from the Filter Accept list stored in the Controller. + * This command can be used at any time except when: - the advertising + * filter policy uses the Filter Accept list and advertising is enabled. + * - the scanning filter policy uses the Filter Accept list and scanning + * is enabled. - the initiator filter policy uses the Filter Accept list + * and a create connection command is outstanding. + * @param Address_Type Address type. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * @param Address Public Device Address or Random Device Address of the device + * to be removed from the Filter Accept List. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_remove_device_from_filter_accept_list(uint8_t Address_Type, + uint8_t Address[6]); +/** + * @brief The LE_Connection_Update command is used to change the Link Layer + * connection parameters of a connection. This command is supported only + * on central side. The Connection_Interval_Min and + * Connection_Interval_Max parameters are used to define the minimum and + * maximum allowed connection interval. The Connection_Interval_Min + * parameter shall not be greater than the Connection_Interval_Max + * parameter. The Max_Latency parameter shall define the maximum allowed + * connection latency. The Supervision_Timeout parameter shall define the + * link supervision timeout for the LE link. The Supervision_Timeout in + * milliseconds shall be larger than (1 + Max_Latency) * + * Connection_Interval_Max * 2, where Connection_Interval_Max is given in + * milliseconds. The Min_CE_Length and Max_CE_Length are information + * parameters providing the Controller with a hint about the expected + * minimum and maximum length of the connection events. The Min_CE_Length + * shall be less than or equal to the Max_CE_Length. The actual parameter + * values selected by the Link Layer may be different from the parameter + * values provided by the Host through this command. (See Bluetooth + * Specification v.4.1, Vol. 2, Part E, 7.8.18) + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Connection_Interval_Min Minimum value for the connection event + * interval. This shall be less than or equal to Connection_Interval_Max. + * Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Connection_Interval_Max Maximum value for the connection event + * interval. This shall be greater than or equal to + * Connection_Interval_Min. Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Max_Latency Maximum Peripheral latency for the connection in number of + * connection events. + * Values: + * - 0x0000 ... 0x01F3 + * @param Supervision_Timeout Supervision timeout for the LE Link. It shall be a + * multiple of 10 ms and larger than (1 + connPeripheralLatency) * + * connInterval * 2. Time = N * 10 msec. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + * @param Min_CE_Length The minimum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @param Max_CE_Length The maximum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_connection_update(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); +/** + * @brief The HCI_LE_Set_Host_Channel_Classification command allows the Host to + * specify a channel classification for the data, secondary advertising, + * periodic, and isochronous physical channels based on its local + * information. This classification persists until overwritten with a + * subsequent HCI_LE_Set_Host_Channel_Classification command or until the + * Controller is reset using the HCI_Reset command. If this command is + * used, the Host should send it within 10 seconds of knowing that the + * channel classification has changed. The interval between two + * successive commands sent shall be at least one second. + * @param LE_Channel_Map This parameter contains 37 1-bit fields. The nth such + * field (in the range 0 to 36) contains the value for the link layer + * channel index n. Channel n is bad = 0. Channel n is unknown = 1. The + * most significant bits are reserved and shall be set to 0. At least one + * channel shall be marked as unknown. + * Flags: + * - 0x0000000000 ... 0x1FFFFFFFFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_host_channel_classification(uint8_t LE_Channel_Map[5]); +/** + * @brief The LE_Read_Channel_Map command returns the current Channel_Map for + * the specified Connection_Handle. The returned value indicates the + * state of the Channel_Map specified by the last transmitted or received + * Channel_Map (in a CONNECT_REQ or LL_CHANNEL_MAP_REQ message) for the + * specified Connection_Handle, regardless of whether the Central has + * received an acknowledgement. (See Bluetooth Specification v.4.1, Vol. + * 2, Part E, 7.8.20) + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] LE_Channel_Map This parameter contains 37 1-bit fields. The nth + * such field (in the range 0 to 36) contains the value for the link + * layer channel index n. Channel n is unused = 0. Channel n is used + * = 1. The most significant bits are reserved and shall be set to + * 0. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_channel_map(uint16_t Connection_Handle, + uint8_t LE_Channel_Map[5]); +/** + * @brief This command requests a list of the used LE features from the remote + * device. This command shall return a list of the used LE features. For + * details see [Vol 6] Part B, Section 4.6. This command may be issued on + * both the central and peripheral. (See Bluetooth Specification v.4.1, + * Vol. 2, Part E, 7.8.21) + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_remote_features(uint16_t Connection_Handle); +/** + * @brief The LE_Encrypt command is used to request the Controller to encrypt + * the Plaintext_Data in the command using the Key given in the command + * and returns the Encrypted_Data to the Host. The AES-128 bit block + * cypher is defined in NIST Publication FIPS-197 + * (http://csrc.nist.gov/publications/fips/ fips197/fips-197.pdf). (See + * Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.22) + * @param Key 128 bit key for the encryption of the data given in the command. + * @param Plaintext_Data 128 bit data block that is requested to be encrypted. + * @param[out] Encrypted_Data 128 bit encrypted data block. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_encrypt(uint8_t Key[16], + uint8_t Plaintext_Data[16], + uint8_t Encrypted_Data[16]); +/** + * @brief The LE_Rand command is used to request the Controller to generate 8 + * octets of random data to be sent to the Host. The Random_Number shall + * be generated according to [Vol 2] Part H, Section 2 if the LE Feature + * (LL Encryption) is supported. (See Bluetooth Specification v.4.1, Vol. + * 2, Part E, 7.8.23) + * @param[out] Random_Number Random Number + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_rand(uint8_t Random_Number[8]); +/** + * @brief The LE_Enable_Encryption command is used to authenticate the given + * encryption key associated with the remote device specified by the + * connection handle, and once authenticated will encrypt the connection. + * The parameters are as defined in [Vol 3] Part H, Section 2.4.4. If the + * connection is already encrypted then the Controller shall pause + * connection encryption before attempting to authenticate the given + * encryption key, and then re-encrypt the connection. While encryption + * is paused no user data shall be transmitted. On an authentication + * failure, the connection shall be automatically disconnected by the + * Link Layer. If this command succeeds, then the connection shall be + * encrypted. This command shall only be used when the local device's + * role is Central. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Random_Number 64 bit random number. + * @param Encrypted_Diversifier 16 bit encrypted diversifier. + * @param Long_Term_Key 128 bit long term key. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_enable_encryption(uint16_t Connection_Handle, + uint8_t Random_Number[8], + uint16_t Encrypted_Diversifier, + uint8_t Long_Term_Key[16]); +/** + * @brief The LE_Long_Term_Key_Request_Reply command is used to reply to an LE + * Long Term Key Request event from the Controller, and specifies the + * Long_Term_Key parameter that shall be used for this Connection_Handle. + * The Long_Term_Key is used as defined in [Vol 6] Part B, Section 5.1.3. + * (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.25) + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Long_Term_Key 128 bit long term key. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_long_term_key_request_reply(uint16_t Connection_Handle, + uint8_t Long_Term_Key[16]); +/** + * @brief The LE_Long_Term_Key_Request_Negative_Reply command is used to reply + * to an LE Long Term Key Request event from the Controller if the Host + * cannot provide a Long Term Key for this Connection_Handle. (See + * Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.26) + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_long_term_key_request_negative_reply(uint16_t Connection_Handle); +/** + * @brief The LE_Read_Supported_States command reads the states and state + * combinations that the link layer supports. See [Vol 6] Part B, Section + * 1.1.1. LE_States is an 8-octet bit field. If a bit is set to 1 then + * this state or state combination is supported by the Controller. + * Multiple bits in LE_States may be set to 1 to indicate support for + * multiple state and state combinations. All the Advertising type with + * the Initiate State combinations shall be set only if the corresponding + * Advertising types and Central Role combination are set. All the + * Scanning types and the Initiate State combinations shall be set only + * if the corresponding Scanning types and Central Role combination are + * set. (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.8.27) + * @param[out] LE_States State or state combination is supported by the + * Controller. See Core v4.1, Vol.2, part E, Ch. 7.8.27. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_supported_states(uint8_t LE_States[8]); +/** + * @brief The LE_Set_Data_Length command allows the Host to suggest maximum + * transmission packet size and maximum packet transmission time + * (connMaxTxOctets and connMaxTxTime - see [Vol 6] Part B, Section + * 4.5.10) to be used for a given connection. The Controller may use + * smaller or larger values based on local information. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param TxOctets Preferred maximum number of payload octets that the local + * Controller should include in a single Link Layer Data Channel PDU. + * Range 0x001B-0x00FB (0x0000 - 0x001A and 0x00FC - 0xFFFF) Reserved for + * future use). Default: 27 bytes. + * Values: + * - 0x001B ... 0x00FB + * @param TxTime Preferred maximum number of microseconds that the local + * Controller should use to transmit a single Link Layer Data Channel + * PDU. Range 0x0148-0x0848 (0x0000 - 0x0147 and 0x0849 - 0xFFFF Reserved + * for future use). Default: 328 bytes. + * Values: + * - 0x0148 ... 0x0848 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_data_length(uint16_t Connection_Handle, + uint16_t TxOctets, + uint16_t TxTime); +/** + * @brief The LE_Read_Suggested_Default_Data_Length command allows the Host to + * read the Host preferred values for the Controller maximum transmitted + * number of payload octets and maximum packet transmission time to be + * used for new connections (connInitialMaxTxOctets and + * connInitialMaxTxTime - see ([Vol 6] Part B, Section 4.5.10). + * @param[out] SuggestedMaxTxOctets The Host suggested value for the Controller + * maximum transmitted number of payload octets to be used for new + * connections - connInitialMaxTxOctets. Range 0x001B-0x00FB (0x0000 + * - 0x001A and 0x00FC - 0xFFFF Reserved for future use) Default: + * 0x001B + * @param[out] SuggestedMaxTxTime The Host suggested value for the Controller + * maximum packet transmission time to be used for new connections - + * connInitialMaxTx-Time. Range 0x0148-0x0848 (0x0000 - 0x0147 and + * 0x0849 - 0xFFFF Reserved for future use) Default: 0x0148 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_suggested_default_data_length(uint16_t *SuggestedMaxTxOctets, + uint16_t *SuggestedMaxTxTime); +/** + * @brief The LE_Write_Suggested_Default_Data_Length command allows the Host to + * specify its preferred values for the Controller maximum transmission + * number of payload octets and maximum packet transmission time to be + * used for new connections (connInitialMaxTxOctets and + * connInitialMaxTxTime - see [Vol 6] Part B, Section 4.5.10). The + * Controller may use smaller or larger values based on local + * information. + * @param SuggestedMaxTxOctets The Host suggested value for the Controller + * maximum transmitted number of payload octets to be used for new + * connections - connInitialMaxTxOctets. Range 0x001B-0x00FB (0x0000 - + * 0x001A and 0x00FC - 0xFFFF Reserved for future use) + * Values: + * - 0x001B ... 0x00FB + * @param SuggestedMaxTxTime The Host suggested value for the Controller maximum + * packet transmission time to be used for new connections - + * connInitialMaxTx-Time. Range 0x0148-0x0848 (0x0000 - 0x0147 and 0x0849 + * - 0xFFFF Reserved for future use) + * Values: + * - 0x0148 ... 0x0848 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_write_suggested_default_data_length(uint16_t SuggestedMaxTxOctets, + uint16_t SuggestedMaxTxTime); +/** + * @brief The LE_Read_Local_P-256_Public_Key command is used to return the local + * P-256 public key from the Controller. The Controller shall generate a + * new P-256 public/private key pair upon receipt of this command. (See + * Bluetooth Specification v.4.2, Vol. 2, Part E, 7.8.36) + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_local_p256_public_key(void); +/** + * @brief The LE_Generate_DHKey command is used to initiate generation of a + * Diffie- Hellman key in the Controller for use over the LE transport. + * This command takes the remote P-256 public key as input. The Diffie- + * Hellman key generation uses the private key generated by + * LE_Read_Local_P256_Public_Key command. (See Bluetooth Specification + * v.4.2, Vol. 2, Part E, 7.8.37) + * @param Remote_P256_Public_Key The remote P-256 public key: X, Y format Octets + * 31-0: X coordinate Octets 63-32: Y coordinate Little Endian Format + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_generate_dhkey(uint8_t Remote_P256_Public_Key[64]); +/** + * @brief The LE_Add_Device_To_Resolving_List command is used to add one device + * to the list of address translations used to resolve Resolvable Private + * Addresses in the Controller. This command cannot be used when address + * translation is enabled in the Controller and: - Advertising is enabled + * - Scanning is enabled - Create connection command is outstanding This + * command can be used at any time when address translation is disabled + * in the Controller. When a Controller cannot add a device to the + * resolving list because the list is full, it shall respond with error + * code 0x07 (Memory Capacity Exceeded). (See Bluetooth Specification + * v.4.2, Vol. 2, Part E, 7.8.38) + * @param Peer_Identity_Address_Type Identity address type. + * Values: + * - 0x00: Public Identity Address + * - 0x01: Random (static) Identity Address + * @param Peer_Identity_Address Public or Random (static) Identity address of + * the peer device + * @param Peer_IRK IRK of the peer device + * @param Local_IRK IRK of the local device + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_add_device_to_resolving_list(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Peer_IRK[16], + uint8_t Local_IRK[16]); +/** + * @brief The LE_Remove_Device_From_Resolving_List command is used to remove one + * device from the list of address translations used to resolve + * Resolvable Private Addresses in the controller. This command cannot be + * used when address translation is enabled in the Controller and: - + * Advertising is enabled - Scanning is enabled - Create connection + * command is outstanding This command can be used at any time when + * address translation is disabled in the Controller. When a Controller + * cannot remove a device from the resolving list because it is not + * found, it shall respond with error code 0x02 (Unknown Connection + * Identifier). (See Bluetooth Specification v.4.2, Vol. 2, Part E, + * 7.8.39) + * @param Peer_Identity_Address_Type Identity address type. + * Values: + * - 0x00: Public Identity Address + * - 0x01: Random (static) Identity Address + * @param Peer_Identity_Address Public or Random (static) Identity address of + * the peer device + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_remove_device_from_resolving_list(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6]); +/** + * @brief The LE_Clear_Resolving_List command is used to remove all devices from + * the list of address translations used to resolve Resolvable Private + * Addresses in the Controller. This command cannot be used when address + * translation is enabled in the Controller and: - Advertising is enabled + * - Scanning is enabled - Create connection command is outstanding This + * command can be used at any time when address translation is disabled + * in the Controller. (See Bluetooth Specification v.4.2, Vol. 2, Part E, + * 7.8.40) + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_clear_resolving_list(void); +/** + * @brief The LE_Read_Resolving_List_Size command is used to read the total + * number of address translation entries in the resolving list that can + * be stored in the Controller. (See Bluetooth Specification v.4.2, Vol. + * 2, Part E, 7.8.41) + * @param[out] Resolving_List_Size Number of address translation entries in the + * resolving list + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_resolving_list_size(uint8_t *Resolving_List_Size); +/** + * @brief The LE_Read_Peer_Resolvable_Address command is used to get the current + * peer Resolvable Private Address being used for the corresponding peer + * Public and Random (static) Identity Address. The peer's resolvable + * address being used may change after the command is called. This + * command can be used at any time. When a Controller cannot find a + * Resolvable Private Address associated with the Peer Identity Address, + * it shall respond with error code 0x02 (Unknown Connection Identifier). + * (See Bluetooth Specification v.4.2, Vol. 2, Part E, 7.8.42) + * @param Peer_Identity_Address_Type Identity address type. + * Values: + * - 0x00: Public Identity Address + * - 0x01: Random (static) Identity Address + * @param Peer_Identity_Address Public or Random (static) Identity address of + * the peer device + * @param[out] Peer_Resolvable_Address Resolvable Private Address being used by + * the peer device + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_peer_resolvable_address(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Peer_Resolvable_Address[6]); +/** + * @brief The LE_Read_Local_Resolvable_Address command is used to get the + * current local Resolvable Private Address being used for the + * corresponding peer Identity Address. The local's resolvable address + * being used may change after the command is called. This command can be + * used at any time. When a Controller cannot find a Resolvable Private + * Address associated with the Peer Identity Address, it shall respond + * with error code 0x02 (Unknown Connection Identifier). (See Bluetooth + * Specification v.4.2, Vol. 2, Part E, 7.8.43) + * @param Peer_Identity_Address_Type Identity address type. + * Values: + * - 0x00: Public Identity Address + * - 0x01: Random (static) Identity Address + * @param Peer_Identity_Address Public or Random (static) Identity address of + * the peer device + * @param[out] Local_Resolvable_Address Resolvable Private Address being used by + * the local device + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_local_resolvable_address(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Local_Resolvable_Address[6]); +/** + * @brief The LE_Set_Address_Resolution_Enable command is used to enable + * resolution of Resolvable Private Addresses in the Controller. This + * causes the Controller to use the resolving list whenever the + * Controller receives a local or peer Resolvable Private Address. This + * command can be used at any time except when: - Advertising is enabled + * - Scanning is enabled - Create connection command is outstanding (See + * Bluetooth Specification v.4.2, Vol. 2, Part E, 7.8.44) + * @param Address_Resolution_Enable Enable/disable address resolution in the + * controller. 0x00: Address Resolution in controller disabled (default), + * 0x01: Address Resolution in controller enabled + * Values: + * - 0x00: Address Resolution in controller disabled (default) + * - 0x01: Address Resolution in controller enabled + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_address_resolution_enable(uint8_t Address_Resolution_Enable); +/** + * @brief The LE_Set_Resolvable_Private_Address_Timeout command set the length + * of time the controller uses a Resolvable Private Address before a new + * resolvable private address is generated and starts being used. This + * timeout applies to all addresses generated by the controller. (See + * Bluetooth Specification v.4.2, Vol. 2, Part E, 7.8.45) + * @param RPA_Timeout RPA_Timeout measured in seconds. Range for N: 0x0001 - + * 0xA1B8 (1 sec - approximately 11.5 hours) Default: N= 0x0384 (900 secs + * or 15 minutes) + * Values: + * - 0x0001 ... 0xA1B8 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_resolvable_private_address_timeout(uint16_t RPA_Timeout); +/** + * @brief The LE_Read_Maximum_Data_Length command allows the Host to read the + * Controller maximum supported payload octets and packet duration times + * for transmission and reception (supportedMaxTxOctets and + * supportedMaxTxTime, supportedMaxRxOctets, and supportedMaxRxTime, see + * [Vol 6] Part B, Section 4.5.10). + * @param[out] supportedMaxTxOctets Maximum number of payload octets that the + * local Controller supports for transmission of a single Link Layer + * Data Channel PDU. Range 0x001B-0x00FB (0x0000 - 0x001A and 0x00FC + * - 0xFFFF Reserved for future use) + * @param[out] supportedMaxTxTime Maximum time, in microseconds, that the local + * Controller supports for transmission of a single Link Layer Data + * Channel PDU. Range 0x0148-0x0848 (0x0000 - 0x0147 and 0x0849 - + * 0xFFFF Reserved for future use) + * @param[out] supportedMaxRxOctets Maximum number of payload octets that the + * local Controller supports for reception of a single Link Layer + * Data Channel PDU. Range 0x001B-0x00FB (0x0000 - 0x001A and 0x00FC + * - 0xFFFF Reserved for future use) + * @param[out] supportedMaxRxTime Maximum time, in microseconds, that the local + * Controller supports for reception of a single Link Layer Data + * Channel PDU. Range 0x0148-0x0848 (0x0000 - 0x0147 and 0x0849 - + * 0xFFFF Reserved for future use) + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_maximum_data_length(uint16_t *supportedMaxTxOctets, + uint16_t *supportedMaxTxTime, + uint16_t *supportedMaxRxOctets, + uint16_t *supportedMaxRxTime); +/** + * @brief The LE_Read_PHY command is used to read the current transmitter PHY + * and receiver PHY on the connection identified by the + * Connection_Handle. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] TX_PHY Transmitter PHY for the connection 0x01: The transmitter + * PHY for the connection is LE 1M 0x02: The transmitter PHY for the + * connection is LE 2M 0x03: The transmitter PHY for the connection + * is LE Coded + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + * @param[out] RX_PHY Receiver PHY for the connection. 0x01: The receiver PHY + * for the connection is LE 1M 0x02: The receiver PHY for the + * connection is LE 2M 0x03: The receiver PHY for the connection is + * LE Coded All other values: Reserved for future use + * Values: + * - 0x01: The receiver PHY for the connection is LE 1M + * - 0x02: The receiver PHY for the connection is LE 2M + * - 0x03: The receiver PHY for the connection is LE Coded + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_phy(uint16_t Connection_Handle, + uint8_t *TX_PHY, + uint8_t *RX_PHY); +/** + * @brief The LE_Set_Default_PHY command allows the Host to specify its + * preferred values for the transmitter PHY and receiver PHY to be used + * for all subsequent connections over the LE transport. + * @param ALL_PHYS The ALL_PHYS parameter is a bit field that allows the Host to + * specify, for each direction, whether it has no preference among the + * PHYs that the Controller supports in a given direction or whether it + * has specified particular PHYs that it prefers in the TX_PHYS or + * RX_PHYS parameter. Bits: 0: The Host has no preference among the + * transmitter PHYs supported by the Controller 1: The Host has no + * preference among the receiver PHYs supported by the Controller + * Flags: + * - 0x01: No preference for TX + * - 0x02: No preference for RX + * @param TX_PHYS The TX_PHYS parameter is a bit field that indicates the + * transmitter PHYs that the Host prefers the Controller to use. If the + * ALL_PHYS parameter specifies that the Host has no preference, the + * TX_PHYS parameter is ignored; otherwise at least one bit shall be set + * to 1. Bits: 0: The Host prefers to use the LE 1M transmitter PHY + * (possibly among others) 1: The Host prefers to use the LE 2M + * transmitter PHY (possibly among others) 2: The Host prefers to use the + * LE Coded transmitter PHY (possibly among others) 3-7: Reserved for + * future use + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param RX_PHYS The RX_PHYS parameter is a bit field that indicates the + * receiver PHYs that the Host prefers the Controller to use. If the + * ALL_PHYS parameter specifies that the Host has no preference, the + * RX_PHYS parameter is ignored; otherwise at least one bit shall be set + * to 1. Bits: 0: The Host prefers to use the LE 1M receiver PHY + * (possibly among others) 1: The Host prefers to use the LE 2M receiver + * PHY (possibly among others) 2: The Host prefers to use the LE Coded + * receiver PHY (possibly among others) 3-7: Reserved for future use + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_default_phy(uint8_t ALL_PHYS, + uint8_t TX_PHYS, + uint8_t RX_PHYS); +/** + * @brief The LE_Set_PHY command is used to set the PHY preferences for the + * connection identified by the Connection_Handle. The Controller might + * not be able to make the change (e.g. because the peer does not support + * the requested PHY) or may decide that the current PHY is preferable. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param ALL_PHYS The ALL_PHYS parameter is a bit field that allows the Host to + * specify, for each direction, whether it has no preference among the + * PHYs that the Controller supports in a given direction or whether it + * has specified particular PHYs that it prefers in the TX_PHYS or + * RX_PHYS parameter. Bits: 0: The Host has no preference among the + * transmitter PHYs supported by the Controller 1: The Host has no + * preference among the receiver PHYs supported by the Controller + * Flags: + * - 0x01: No preference for TX + * - 0x02: No preference for RX + * @param TX_PHYS The TX_PHYS parameter is a bit field that indicates the + * transmitter PHYs that the Host prefers the Controller to use. If the + * ALL_PHYS parameter specifies that the Host has no preference, the + * TX_PHYS parameter is ignored; otherwise at least one bit shall be set + * to 1. Bits: 0: The Host prefers to use the LE 1M transmitter PHY + * (possibly among others) 1: The Host prefers to use the LE 2M + * transmitter PHY (possibly among others) 2: The Host prefers to use the + * LE Coded transmitter PHY (possibly among others) 3-7: Reserved for + * future use + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param RX_PHYS The RX_PHYS parameter is a bit field that indicates the + * receiver PHYs that the Host prefers the Controller to use. If the + * ALL_PHYS parameter specifies that the Host has no preference, the + * RX_PHYS parameter is ignored; otherwise at least one bit shall be set + * to 1. Bits: 0: The Host prefers to use the LE 1M receiver PHY + * (possibly among others) 1: The Host prefers to use the LE 2M receiver + * PHY (possibly among others) 2: The Host prefers to use the LE Coded + * receiver PHY (possibly among others) 3-7: Reserved for future use + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param PHY_options The PHY_options parameter is a bit field that allows the + * Host to specify options for PHYs. The default value for a new + * connection shall be all zero bits. The Controller may override any + * preferred coding for transmitting on the LE Coded PHY. The Host may + * specify a preferred coding even if it prefers not to use the LE Coded + * transmitter PHY since the Controller may override the PHY preference. + * 0 = the Host has no preferred coding when transmitting on the LE Coded + * PHY 1 = the Host prefers that S=2 coding be used when transmitting on + * the LE Coded PHY 2 = the Host prefers that S=8 coding be used when + * transmitting on the LE Coded PHY + * Values: + * - 0: No preferred LE Coded PHY + * - 1: S=2 preferred on LE Coded PHY + * - 2: S=8 preferred on LE Coded PHY + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_phy(uint16_t Connection_Handle, + uint8_t ALL_PHYS, + uint8_t TX_PHYS, + uint8_t RX_PHYS, + uint16_t PHY_options); +/** + * @brief The LE_Set_Advertising_Set_Random_Address command is used by the Host + * to set the random device address specified by the Random_Address + * parameter. This address is used in the Controller (see [Vol 6] Part B, + * Section 1.3.2) for the advertiser's address contained in the + * advertising PDUs for the advertising set specified by the + * Advertising_Handle parameter. If the Host issues this command while an + * advertising set using connectable advertising is enabled, the + * Controller shall return the error code Command Disallowed (0x0C). The + * Host may issue this command at any other time. If this command is used + * to change the address, the new random address shall take effect for + * advertising no later than the next successful LE Extended Set + * Advertising Enable Command and for periodic advertising no later than + * the next successful LE Periodic Advertising Enable Command. + * @param Advertising_Handle It is used to identify an advertising set + * Values: + * - 0x00 ... 0xEF + * @param Advertising_Random_Address Random Device Address as defined by [Vol 6] + * Part B, Section 1.3.2 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_advertising_set_random_address(uint8_t Advertising_Handle, + uint8_t Advertising_Random_Address[6]); +/** + * @brief The LE_Set_Extended_Advertising_Parameters command is used by the Host + * to set the advertising parameters. The Advertising_Handle parameter + * identifies the advertising set whose parameters are being configured. + * The Advertising_Event_Properties parameter describes the type of + * advertising event that is being configured and its basic properties. + * The type shall be one supported by the Controller. + * @param Advertising_Handle The Advertising_Handle parameter identifies the + * advertising set whose parameters are being configured. + * Values: + * - 0x00 ... 0xEF + * @param Advertising_Event_Properties The Advertising_Event_Properties + * parameter describes the type of advertising event that is being + * configured and its basic properties. The type shall be one supported + * by the Controller. Bits: 0 Connectable advertising 1 Scannable + * advertising 2 Directed advertising 3 High Duty Cycle Directed + * Connectable advertising (<= 3.75 ms Advertising Interval) 4 Use legacy + * advertising PDUs 5 Omit advertiser's address from all PDUs ("anonymous + * advertising") 6 Include TxPower in the extended header of the + * advertising PDU + * Flags: + * - 0x0001: Connectable + * - 0x0002: Scannable + * - 0x0004: Directed + * - 0x0008: HDC Directed Connectable + * - 0x0010: Legacy + * - 0x0020: Anonymous + * - 0x0040: TxPower in ext header + * @param Primary_Advertising_Interval_Min Minimum advertising interval for + * undirected and low duty cycle directed advertising. Time = N * 0.625 + * ms; Time Range: 20 ms to 10,485.759375 s. + * Values: + * - 0x000020 (20.000 ms) ... 0xFFFFFF (10485759.375 ms) + * @param Primary_Advertising_Interval_Max Maximum advertising interval for + * undirected and low duty cycle directed advertising. Time = N * 0.625 + * ms; Time Range: 20 ms to 10,485.759375 s. + * Values: + * - 0x000020 (20.000 ms) ... 0xFFFFFF (10485759.375 ms) + * @param Primary_Advertising_Channel_Map The Primary_Advertising_Channel_Map is + * a bit field that indicates the advertising channels that shall be used + * when transmitting advertising packets. At least one channel bit shall + * be set in the Primary_Advertising_Channel_Map parameter. + * Flags: + * - 0x01: CH_37 + * - 0x02: CH_38 + * - 0x04: CH_39 + * @param Own_Address_Type The Own_Address_Type parameter specifies the type of + * address being used in the advertising packets. For random addresses, + * the address is specified by the LE_Set_Advertising_Set_Random_Address + * command. 0x00 Public Device Address 0x01 Random Device Address 0x02 + * Controller generates the Resolvable Private Address based on the local + * IRK from the resolving list. If the resolving list contains no + * matching entry, use the public address. 0x03 Controller generates the + * Resolvable Private Address based on the local IRK from the resolving + * list. If the resolving list contains no matching entry, use the random + * address from LE_Set_Advertising_Set_Random_Address. All other values + * Reserved for future use + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Resolvable Private Address / Public Address + * - 0x03: Resolvable Private Address / Random Address + * @param Peer_Address_Type Peer Address type + * Values: + * - 0x00: Public Device Address or Public Identity Address + * - 0x01: Random Device Address or Random (static) Identity Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address, or Random (static) Identity Address of the device to + * be connected. + * @param Advertising_Filter_Policy Advertising Filter Policy. This parameter is + * ignored when directed advertising is enabled. 0x00 Process scan and + * connection requests from all devices (i.e., the Filter Accept List is + * not in use) 0x01 Process connection requests from all devices and scan + * requests only from devices that are in the Filter Accept List 0x02 + * Process scan requests from all devices and connection requests only + * from devices that are in the Filter Accept List. 0x03 Process scan and + * connection requests only from devices in the Filter Accept List. All + * other values are reserved for future use + * Values: + * - 0x00: HCI_ADV_FILTER_NONE + * - 0x01: HCI_ADV_FILTER_ACCEPT_LIST_SCAN + * - 0x02: HCI_ADV_FILTER_ACCEPT_LIST_CONNECT + * - 0x03: HCI_ADV_FILTER_ACCEPT_LIST_SCAN_CONNECT + * @param Advertising_Tx_Power Units: dBm The Advertising_Tx_Power parameter + * indicates the maximum power level at which the advertising packets are + * to be transmitted on the advertising channels. The Controller shall + * choose a power level lower than or equal to the one specified by the + * Host. + * Values: + * - -127 ... 126 + * - 127: No preference + * @param Primary_Advertising_PHY The Primary_Advertising_PHY parameter + * indicates the PHY on which the advertising packets are transmitted on + * the primary advertising channel. If legacy advertising PDUs are being + * used, the Primary_Advertising_PHY shall indicate the LE 1M PHY. + * Values: + * - 0x01: LE_1M_PHY + * - 0x03: LE_CODED_PHY + * @param Secondary_Advertising_Max_Skip The Secondary_Advertising_Max_Skip + * parameter is the maximum number of advertising events that can be + * skipped before the AUX_ADV_IND can be sent. 0x00 AUX_ADV_IND shall be + * sent prior to the next advertising event 0x01-0xFF Maximum advertising + * events the Controller can skip before sending the AUX_ADV_IND packets + * on the secondary advertising channel + * Values: + * - 0x00 ... 0xFF + * @param Secondary_Advertising_PHY The Secondary_Advertising_PHY parameter + * indicates the PHY on which the advertising packets are transmitted on + * the secondary advertising channel. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + * @param Advertising_SID The Advertising_SID parameter specifies the value to + * be transmitted in the Advertising SID subfield of the ADI field of the + * Extended Header of those advertising channel PDUs that have an ADI + * field. If the advertising set only uses PDUs that do not contain an + * ADI field, Advertising_SID is ignored. + * Values: + * - 0x00 ... 0x0F + * @param Scan_Request_Notification_Enable The Scan_Request_Notification_Enable + * parameter indicates whether the Controller shall send notifications + * upon the receipt of a scan request PDU that is in response to an + * advertisement from the specified advertising set that contains its + * device address and is from a scanner that is allowed by the + * advertising filter policy. + * Values: + * - 0x00: Scan request notifications disabled + * - 0x01: Scan request notifications enabled + * @param[out] Selected_Tx_Power Units: dBm. The Selected_Tx_Power return + * parameter indicates the transmit power selected by the + * Controller. The Controller shall not change the transmit power + * for this advertising set without being directed to by the Host. + * Values: + * - -127 ... 126 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_extended_advertising_parameters(uint8_t Advertising_Handle, + uint16_t Advertising_Event_Properties, + uint8_t Primary_Advertising_Interval_Min[3], + uint8_t Primary_Advertising_Interval_Max[3], + uint8_t Primary_Advertising_Channel_Map, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable, + int8_t *Selected_Tx_Power); +/** + * @brief The LE_Set_Extended_Advertising_Enable command is used to request the + * Controller to enable or disable one or more advertising sets using the + * advertising sets identified by the Advertising_Handle[i] parameter. + * The Controller manages the timing of advertisements in accordance with + * the advertising parameters given in the + * LE_Set_Extended_Advertising_Parameters command. + * @param Enable It allows to enable or disable one or more advertising sets + * using the advertising sets identified by the Advertising_Handle[i] + * parameter. + * Values: + * - 0x00: Disable + * - 0x01: Enable + * @param Number_of_Sets The Number_of_Sets parameter is the number of + * advertising sets contained in the parameter arrays. + * Values: + * - 0x00: Disable all advertising sets + * - 0x01 ... 0x3F: Number of advertising sets to enable or disable + * @param Advertising_Set_Parameters See @ref Advertising_Set_Parameters_t + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_extended_advertising_enable(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]); +/** + * @brief The LE_Read_Number_of_Supported_Advertising_Sets command is used to + * read the maximum number of advertising sets supported by the + * advertising Controller at the same time. Note: The number of + * advertising sets that can be supported is not fixed and the Controller + * can change it at any time because the memory used to store advertising + * sets can also be used for other purposes. + * @param[out] Num_Supported_Advertising_Sets Maximum number of advertising sets + * supported by the advertising Controller at the same time. + * Values: + * - 0x01 ... 0xF0: Number of advertising sets supported at the same time + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_number_of_supported_advertising_sets(uint8_t *Num_Supported_Advertising_Sets); +/** + * @brief The LE_Remove_Advertising_Set command is used to remove an advertising + * set from the Controller. If the advertising set corresponding to the + * Advertising_Handle parameter does not exist, then the Controller shall + * return the error code Unknown Advertising Identifier (0x42). If + * advertising on the advertising set is enabled, then the Controller + * shall return the error code Command Disallowed (0x0C). + * @param Advertising_Handle It is used to identify an advertising set + * Values: + * - 0x00 ... 0xEF: Used to identify an advertising set + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_remove_advertising_set(uint8_t Advertising_Handle); +/** + * @brief The LE_Clear_Advertising_Sets command is used to remove all existing + * advertising sets from the Controller. If advertising is enabled on any + * advertising set, then the Controller shall return the error code + * Command Disallowed (0x0C). Note: All advertising sets are cleared on + * HCI reset. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_clear_advertising_sets(void); +/** + * @brief The LE_Set_Periodic_Advertising_Parameters command is used by the Host + * to set the parameters for periodic advertising. The Advertising_Handle + * parameter identifies the advertising set whose periodic advertising + * parameters are being configured. If the corresponding advertising set + * does not already exist, then the Controller shall return the error + * code Unknown Advertising Identifier (0x42). The + * Periodic_Advertising_Interval_Min parameter shall be less than or + * equal to the Periodic_Advertising_Interval_Max parameter. The + * Periodic_Advertising_Interval_Min and + * Periodic_Advertising_Interval_Max parameters should not be the same + * value to enable the Controller to determine the best advertising + * interval given other activities. The Periodic_Advertising_Properties + * parameter indicates which fields should be included in the advertising + * packet. If the advertising set identified by the Advertising_Handle + * specified anonymous advertising, the Controller shall return the error + * code Invalid HCI Parameters (0x12). If the Host issues this command + * when periodic advertising is enabled for the specified advertising + * set, the Controller shall return the error code Command Disallowed + * (0x0C). If the Advertising_Handle does not identify an advertising set + * that is already configured for periodic advertising and the Controller + * is unable to support more periodic advertising at present, the + * Controller shall return the error code Memory Capacity Exceeded (0x07) + * @param Advertising_Handle It is used to identify an advertising set + * Values: + * - 0x00 ... 0xEF: Used to identify a periodic advertisement + * @param Periodic_Advertising_Interval_Min Minimum advertising interval for + * periodic advertising. Time = N * 1.25 ms; Time Range: 7.5ms to + * 81.91875 s. + * Values: + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + * @param Periodic_Advertising_Interval_Max Maximum advertising interval for + * periodic advertising. Time = N * 1.25 ms; Time Range: 7.5ms to + * 81.91875 s. + * Values: + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + * @param Periodic_Advertising_Properties The Periodic_Advertising_Properties + * parameter indicates which fields should be included in the advertising + * packet. + * Flags: + * - 0x0040: Include TxPower in the advertising PDU + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_periodic_advertising_parameters(uint8_t Advertising_Handle, + uint16_t Periodic_Advertising_Interval_Min, + uint16_t Periodic_Advertising_Interval_Max, + uint16_t Periodic_Advertising_Properties); +/** + * @brief The HCI_LE_Set_Periodic_Advertising_Enable command is used to request + * the Controller to enable or disable the periodic advertising for the + * advertising set specified by the Advertising_Handle parameter + * (ordinary advertising is not affected). If the advertising set is not + * currently enabled (see the HCI_LE_Set_Extended_Advertising_Enable + * command), the periodic advertising is not started until the + * advertising set is enabled. Once the advertising set has been enabled, + * the Controller shall continue periodic advertising until the Host + * issues an HCI_LE_Set_Periodic_Advertising_Enable command with bit 0 of + * Enable set to 0 (periodic advertising is disabled). Disabling the + * advertising set has no effect on the periodic advertising once the + * advertising set has been enabled. The Controller manages the timing of + * advertisements in accordance with the advertising parameters given in + * the HCI_LE_Set_Periodic_Advertising_Parameters command. If the + * advertising set corresponding to the Advertising_Handle parameter does + * not exist, the Controller shall return the error code Unknown + * Advertising Identifier (0x42). If bit 0 of Enable is set to 1 + * (periodic advertising is enabled) and the advertising set contains + * partial periodic advertising data, the Controller shall return the + * error code Command Disallowed (0x0C). If bit 0 of Enable is set to 1 + * and the Host has not issued the + * HCI_LE_Set_Periodic_Advertising_Parameters command for the advertising + * set, the Controller shall either use vendor-specified parameters or + * return the error code Command Disallowed (0x0C). If bit 0 of Enable is + * set to 1 and the length of the periodic advertising data is greater + * than the maximum that the Controller can transmit within the chosen + * periodic advertising interval, the Controller shall return the error + * code Packet Too Long (0x45). If advertising on the LE Coded PHY, the + * S=8 coding shall be assumed. If bit 0 of Enable is set to 1 and the + * advertising set identified by the Advertising_Handle specified + * scannable, connectable, legacy, or anonymous (0x0C). If bit 0 of + * Enable is set to 0 and the Controller supports the Periodic + * Advertising ADI Support feature, then the Controller shall ignore bit + * 1. If bit 1 of Enable is set to 1 and the Controller does not support + * the Periodic Advertising ADI Support feature, the Controller shall + * return an error which should use the error code Unsupported Feature or + * Parameter Value (0x11). Enabling periodic advertising when it is + * already enabled can cause the random address to change. Disabling + * periodic advertising when it is already disabled has no effect. + * @param Enable It is used to enabled advertising and include ADI field. If bit + * 0 is set, enable periodic advertising. if bit 1 is set, Include the + * ADI field in AUX_SYNC_IND PDUs. + * Flags: + * - 0x01: ENABLE_PERIODIC_ADV + * - 0x02: INCLUDE_ADI_FIELD + * @param Advertising_Handle Used to identify an advertising set. + * Values: + * - 0x00 ... 0xEF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_periodic_advertising_enable(uint8_t Enable, + uint8_t Advertising_Handle); +/** + * @brief The LE_Set_Extended_Scan_Parameters command is used to set the + * extended scan parameters to be used on the advertising channels. The + * Scanning_PHYs parameter indicates the PHY(s) on which the advertising + * packets should be received on the primary advertising channel. The + * Host may enable one or more scanning PHYs. The Scan_Type[i], + * Scan_Interval[i], and Scan_Window[i] parameters array elements are + * ordered in the same order as the set bits in the Scanning_PHY + * parameter, starting from bit 0. The number of array elements is + * determined by the number of bits set in the Scanning_PHY parameter. + * The Scan_Type[i] parameter specifies the type of scan to perform. The + * Scan_Interval[i] and Scan_Window[i] parameters are recommendations + * from the Host on how long (Scan_Window[i]) and how frequently + * (Scan_Interval[i]) the Controller should scan (see [Vol 6] Part B, + * Section 4.5.3); however the frequency and length of the scan is + * implementation specific. If the requested scan cannot be supported by + * the implementation, the Controller shall return the error code Invalid + * HCI Command Parameters (0x12). The Own_Address_Type parameter + * indicates the type of address being used in the scan request packets. + * If the Host issues this command when scanning is enabled in the + * Controller, the Controller shall return the error code Command + * Disallowed (0x0C). + * @param Own_Address_Type The Own_Address_Type parameter indicates the type of + * address being used in the scan request packets. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Controller generates the Resolvable Private Address based on the local +IRK from the resolving list. If the resolving list contains no matching +entry, then use the public address. + * - 0x03: Controller generates the Resolvable Private Address based on the local +IRK from the resolving list. If the resolving list contains no matching +entry, then use the random address from LE_Set_Random_Address. + * @param Scanning_Filter_Policy 0x00 Accept all advertisement packets. Directed + * advertising packets which are not addressed for this device shall be + * ignored. 0x01 Ignore advertisement packets from devices not in the + * Filter Accept List Only. Directed advertising packets which are not + * addressed for this device shall be ignored 0x02 Accept all undirected + * advertisement packets. Directed advertisement packets where initiator + * address is a RPA and Directed advertisement packets addressed to this + * device shall be accepted. 0x03 Accept all undirected advertisement + * packets from devices that are in the Filter Accept List.Directed + * advertisement packets where initiator address is RPA and Directed + * advertisement packets addressed to this device shall be accepted. + * Values: + * - 0x00: Accept all + * - 0x01: Ignore devices not in the Filter Accept List + * - 0x02: Accept all (use resolving list) + * - 0x03: Ignore devices not in the Filter Accept List (use resolving list) + * @param Scanning_PHYs The Scanning_PHYs parameter indicates the PHY(s) on + * which the advertising packets should be received on the primary + * advertising channel. The Host may enable one or more scanning PHYs. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Extended_Scan_Parameters See @ref Extended_Scan_Parameters_t + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_extended_scan_parameters(uint8_t Own_Address_Type, + uint8_t Scanning_Filter_Policy, + uint8_t Scanning_PHYs, + Extended_Scan_Parameters_t Extended_Scan_Parameters[]); +/** + * @brief The LE_Set_Extended_Scan_Enable command is used to enable or disable + * scanning. The Enable parameter determines whether scanning is enabled + * or disabled. If it is disabled, the remaining parameters are ignored. + * The Filter_Duplicates parameter controls whether the Link Layer should + * filter out duplicate advertising reports (filtering duplicates + * enabled) to the Host or if the Link Layer should generate advertising + * reports for each packet received (filtering duplicates disabled). See + * [Vol 6] Part B, Section 4.4.3.5. If the Filter_Duplicates parameter is + * set to 0x00, all advertisements received from advertisers shall be + * sent to the Host in advertising report events. If the + * Filter_Duplicates parameter is set to 0x01, duplicate advertisements + * should not be sent to the Host in advertising report events until + * scanning is disabled. If the Filter_Duplicates parameter is set to + * 0x02, duplicate advertisements in a single scan period should not be + * sent to the Host in advertising report events; this setting shall only + * be used if Period is non-zero. If Filter_Duplicates is set to 0x2 and + * Period to zero, the Controller shall return the Invalid error code HCI + * Command Parameters (0x12). If the Duration parameter is zero or both + * the Duration parameter and Period parameter are non-zero, the + * Controller shall continue scanning until scanning is disabled by the + * Host issuing an LE_Set_Extended_Scan_Enable command with the Enable + * parameter set to 0x00 (Scanning is disabled). The Period parameter is + * ignored when the Duration parameter is zero. If the Duration parameter + * is non-zero and the Period parameter is zero, the Controller shall + * continue scanning until the duration specified in the Duration + * parameter has expired. If both the Duration and Period parameters are + * non-zero and the Duration parameter is greater than or equal to the + * Period parameter, the Controller shall return the error code Invalid + * HCI Command Parameters (0x12). When the Duration and Period parameters + * are non-zero, the Controller shall scan for the duration of the + * Duration parameter within a scan period specified by the Period + * parameter. After the scan period has expired, a new scan period shall + * begin and scanning shall begin again for the duration specified. The + * scan periods continue until the Host disables scanning. If the + * LE_Set_Extended_Scan_Enable command is sent while scanning is enabled, + * the timers used for duration and period are reset to the new parameter + * values and a new scan period is started. Any change to the + * Filter_Duplicates setting or the random address shall take effect. + * Note: Disabling scanning when it is disabled has no effect. Note: The + * duration of a scan period refers to the time spent scanning on both + * the primary and secondary advertising channels. However, expiry of the + * duration does not prevent the Link Layer from scanning for and + * receiving auxiliary packets of received advertisements. If the + * scanning parameters' Own_Address_Type parameter is set to 0x01 or 0x03 + * and the random address for the device has not been initialized, the + * Controller shall return the error code Invalid HCI Command Parameters + * (0x12). + * @param Enable The Enable parameter determines whether scanning is enabled or + * disabled. If it is disabled, the remaining parameters are ignored. + * Values: + * - 0x00: Scanning disabled + * - 0x01: Scanning enabled + * @param Filter_Duplicates The Filter_Duplicates parameter controls whether the + * Link Layer should filter out duplicate advertising reports (filtering + * duplicates enabled) to the Host or if the Link Layer should generate + * advertising reports for each packet received (filtering duplicates + * disabled). See [Vol 6] Part B, Section 4.4.3.5. + * Values: + * - 0x00: Duplicate filtering disabled + * - 0x01: Duplicate filtering enabled + * - 0x02: Duplicate filtering enabled, reset for each scan period + * @param Duration Scan duration. Time = N * 10 ms; Time Range: 10 ms to 655.35 + * s. + * Values: + * - 0x0000 (0.000 ms) : Scan continuously until explicitly disable + * - 0x0001 (0.625 ms) ... 0xFFFF (40959.375 ms) : Scan duration + * @param Period Time interval from when the Controller started its last + * Scan_Duration until it begins the subsequent Scan_Duration. Time = N * + * 1.28 sec; Time Range: 1.28 s to 83,884.8 s. + * Values: + * - 0x0000: Periodic scanning disabled + * - 0x0001 ... 0xFFFF: Time interval from when the Controller started its last Scan_Duration +until it begins the subsequent Scan_Duration + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_extended_scan_enable(uint8_t Enable, + uint8_t Filter_Duplicates, + uint16_t Duration, + uint16_t Period); +/** + * @brief The LE_Extended_Create_Connection command is used to create a Link + * Layer connection to a connectable advertiser. + * LE_Extended_Create_Connection command can be used in place of + * LE_Create_Connection command. + * @param Initiator_Filter_Policy The Initiator_Filter_Policy parameter is used + * to determine whether the Filter Accept List is used. If the Filter + * Accept List is not used, the Peer_Address_Type and the Peer_Address + * parameters specify the address type and address of the advertising + * device to connect to. 0x00 - Filter Accept List is not used to + * determine which advertiser to connect to. Peer_Address_Type and + * Peer_Address shall be used. 0x01 - Filter Accept List is used to + * determine which advertiser to connect to. Peer_Address_Type and + * Peer_Address shall be ignored. + * Values: + * - 0x00: FILTER_ACCEPT_LIST_NOT_USED + * - 0x01: FILTER_ACCEPT_LIST_USED + * @param Own_Address_Type The Own_Address_Type parameter indicates the type of + * address being used in the connection request packets. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Controller generates the Resolvable Private Address based on the local +IRK from the resolving list. If the resolving list contains no matching +entry, then use the public address. + * - 0x03: Controller generates the Resolvable Private Address based on the local +IRK from the resolving list. If the resolving list contains no matching +entry, then use the random address from the most recent successful +LE_Set_Random_Address Command. + * @param Peer_Address_Type The Peer_Address_Type parameter indicates the type + * of address used in the connectable advertisement sent by the peer. + * 0x00: Public Device Address or Public Identity Address 0x01: Random + * Device Address or Random (static) Identity Address + * Values: + * - 0x00: Public Address + * - 0x01: Random Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address, or Random (static) Identity Address of the device to + * be connected. + * @param Initiating_PHYs The Initiating_PHYs parameter indicates the PHY(s) on + * which the advertising packets should be received on the primary + * advertising channel and the PHYs for which connection parameters have + * been specified. The Host may enable one or more initiating PHYs. 0x01: + * Scan connectable advertisements on the LE 1M PHY. Connection + * parameters for the LE 1M PHY are provided. 0x02: Connection parameters + * for the LE 2M PHY are provided 0x04: Scan connectable advertisements + * on the LE Coded PHY. Connection parameters for the LE Coded PHY are + * provided. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Extended_Create_Connection_Parameters See @ref + * Extended_Create_Connection_Parameters_t + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_extended_create_connection(uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Initiating_PHYs, + Extended_Create_Connection_Parameters_t Extended_Create_Connection_Parameters[]); +/** + * @brief The HCI_LE_Periodic_Advertising_Create_Sync command is used to + * synchronize with a periodic advertising train from an advertiser and + * begin receiving periodic advertising packets. This command may be + * issued whether or not scanning is enabled and scanning may be enabled + * and disabled (see the LE Set Extended Scan Enable command) while this + * command is pending. However, synchronization can only occur when + * scanning is enabled. While scanning is disabled, no attempt to + * synchronize will take place. The Options parameter is used to + * determine whether the Periodic Advertiser List is used, whether + * HCI_LE_Periodic_Advertising_Report events for this periodic + * advertising train are initially enabled or disabled, and whether + * duplicate reports are filtered or not. If the Periodic Advertiser List + * is not used, the Advertising_SID, Advertiser Address_Type, and + * Advertiser Address parameters specify the periodic advertising device + * to listen to; otherwise they shall be ignored. The Advertising_SID + * parameter, if used, specifies the value that must match the + * Advertising SID subfield in the ADI field of the received + * advertisement for it to be used to synchronize. The Skip parameter + * specifies the maximum number of consecutive periodic advertising + * events that the receiver may skip after successfully receiving a + * periodic advertising packet. The Sync_Timeout parameter specifies the + * maximum permitted time between successful receives. If this time is + * exceeded, synchronization is lost. The Sync_CTE_Type parameter + * specifies whether to only synchronize to periodic advertising with + * certain types of Constant Tone Extension (a value of 0 indicates that + * the presence or absence of a Constant Tone Extension is irrelevant). + * If the periodic advertising has the wrong type of Constant Tone + * Extension then: - If bit 0 of Options is set, the Controller shall + * ignore this address and SID and continue to search for other periodic + * advertisements. - Otherwise, the Controller shall cancel the + * synchronization with the error code Unsupported Remote Feature (0x1A). + * If the periodic advertiser changes the type of Constant Tone Extension + * after the scanner has synchronized with the periodic advertising, the + * scanner's Link Layer shall remain synchronized. If the Host sets all + * the non-reserved bits of the Sync_CTE_Type parameter to 1, the + * Controller shall return the error code Command Disallowed (0x0C). + * Irrespective of the value of the Skip parameter, the Controller should + * stop skipping packets before the Sync_Timeout would be exceeded. If + * the Host issues this command when another + * HCI_LE_Periodic_Advertising_- Create_Sync command is pending, the + * Controller shall return the error code Command Disallowed (0x0C). If + * the Host issues this command with bit 0 of Options not set and with + * Advertising_SID, Advertiser_Address_Type, and Advertiser_Address the + * same as those of a periodic advertising train that the Controller is + * already synchronized to, the Controller shall return the error code + * Connection Already Exists (0x0B). If the Host issues this command and + * the Controller has insufficient resources to handle any more periodic + * advertising trains, the Controller shall return the error code Memory + * Capacity Exceeded (0x07). If bit 1 of Options is set to 1 and the + * Controller supports the Periodic Advertising ADI Support feature, then + * the Controller shall ignore bit 2. If bit 1 of Options is set to 0, + * bit 2 is set to 1, and the Controller does not support the Periodic + * Advertising ADI Support feature, then the Controller shall return an + * error which should use the error code Unsupported Feature or Parameter + * Value (0x11). If bit 1 of the Options parameter is set to 1 and the + * Controller does not support the + * HCI_LE_Set_Periodic_Advertising_Receive_Enable command, the Controller + * shall return the error code Connection Failed to be Established / + * Synchronization Timeout (0x3E). + * @param Options The Options parameter is a bitmask used to determine whether + * the Periodic Advertiser List is used, whether + * HCI_LE_Periodic_Advertising_Report events for this periodic + * advertising train are initially enabled or disabled, and whether + * duplicate reports are filtered or not. If bit 0 is 0: use the + * Advertising_SID, Advertiser_Address_Type, and Advertiser_Address + * parameters to determine which advertiser to listen to. If bit 0 is 1: + * use the Periodic Advertiser List to determine which advertiser to + * listen to. If bit 1 is 0, reporting is initially enabled, otherwise it + * is enabled. If bit 2 is 0, duplicate filtering is initially disabled, + * otherwise it is enabled. + * Flags: + * - 0x01: USE_PERIODIC_ADV_LIST + * - 0x02: DISABLE_REPORTING + * - 0x04: ENABLE_DUPLICATE_FILTERING + * @param Advertising_SID The Advertising_SID parameter, if used, specifies the + * value that must match the Advertising SID subfield in the ADI field of + * the received advertisement for it to be used to synchronize. + * Values: + * - 0x00 ... 0x0F: Advertising SID subfield in the ADI field used to identify the Periodic +Advertising + * @param Advertiser_Address_Type Advertising address type + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * @param Advertiser_Address Public Device Address, Random Device Address, + * Public Identity Address, or Random (static) Identity Address of the + * advertiser + * @param Skip The Skip parameter specifies the number of consecutive periodic + * advertising packets that the receiver may skip after successfully + * receiving a periodic advertising packet. + * Values: + * - 0x0000 ... 0x01F3 + * @param Sync_Timeout Synchronization timeout for the periodic advertising + * train. Time = N*10 ms. + * Values: + * - 0x000A (100 ms) ... 0x4000 (163840 ms) + * @param Sync_CTE_Type The Sync_CTE_Type parameter specifies whether to only + * synchronize to periodic advertising with certain types of Constant + * Tone Extension (a value of 0 indicates that the presence or absence of + * a Constant Tone Extension is irrelevant). If the periodic advertising + * has the wrong type of Constant Tone Extension then: - If bit 0 of + * Options is set, the Controller shall ignore this address and SID and + * continue to search for other periodic advertisements. - Otherwise, the + * Controller shall cancel the synchronization with the error code + * Unsupported Remote Feature/Unsupported LMP Feature (0x1A). + * Flags: + * - 0x01: Do not sync to packets with an AoA Constant Tone Extension + * - 0x02: Do not sync to packets with an AoD Constant Tone Extension with 1 microsecondslots + * - 0x04: Do not sync to packets with an AoD Constant Tone Extension with 2 microsecondsslots + * - 0x08: Do not sync to packets with a type 3 Constant Tone Extension (currentlyreserved for future use) + * - 0x10: Do not sync to packets without a Constant Tone Extension + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_periodic_advertising_create_sync(uint8_t Options, + uint8_t Advertising_SID, + uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t Sync_CTE_Type); +/** + * @brief The LE_Periodic_Advertising_Create_Sync_Cancel command is used to + * cancel the LE_Periodic_Advertising_Create_Sync command while it is + * pending. If the Host issues this command while no + * LE_Periodic_Advertising_Create_Sync command is pending, the Controller + * shall return the error code Command Disallowed (0x0C). + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_periodic_advertising_create_sync_cancel(void); +/** + * @brief The LE_Periodic_Advertising_Terminate_Sync command is used to stop + * reception of the periodic advertising identified by the Sync_Handle + * parameter. If the Host issues this command when another + * LE_Periodic_Advertising_Create_Sync command is pending (see below), + * the Controller shall return the error code Command Disallowed (0x0C). + * If the periodic advertising corresponding to the Sync_Handle parameter + * does not exist, then the Controller shall return the error code + * Unknown Advertising Identifier (0x42). + * @param Sync_Handle It is used to identify the periodic advertiser + * Values: + * - 0x0000 ... 0x0EFF: Sync_Handle to be used to identify the periodic advertiser + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_periodic_advertising_terminate_sync(uint16_t Sync_Handle); +/** + * @brief The LE_Add_Device_To_Periodic_Advertiser_List command is used to add a + * single device to the Periodic Advertiser list stored in the + * Controller. Any additions to the Periodic Advertiser list take effect + * immediately. If the device is already on the list, the Controller + * shall return the error code Invalid HCI Command Parameters (0x12). If + * the Host issues this command when an + * LE_Periodic_Advertising_Create_Sync command is pending, the Controller + * shall return the error code Command Disallowed (0x0C). When a + * Controller cannot add a device to the Periodic Advertiser list because + * the list is full, the Controller shall return the error code Memory + * Capacity Exceeded (0x07). + * @param Advertiser_Address_Type Advertiser Address Type + * Values: + * - 0x00: Public Device Address or Public Identity Address + * - 0x01: Random Device Address or Random (static) Identity Address + * @param Advertiser_Address Public Device Address, Random Device Address, + * Public Identity Address, or Random (static) Identity Address of the + * advertiser + * @param Advertising_SID Advertising SID subfield in the ADI field used to + * identify the Periodic Advertising + * Values: + * - 0x00 ... 0x0F: Advertising SID subfield in the ADI field used to identify the Periodic +Advertising + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_add_device_to_periodic_advertiser_list(uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint8_t Advertising_SID); +/** + * @brief The LE_Remove_Device_From_Periodic_Advertiser_List command is used to + * remove one device from the list of Periodic Advertisers stored in the + * Controller. Removals from the Periodic Advertisers List take effect + * immediately. If the Host issues this command when an + * LE_Periodic_Advertising_Create_Sync command is pending, the Controller + * shall return the error code Command Disallowed (0x0C). When a + * Controller cannot remove a device from the Periodic Advertiser list + * because it is not found, the Controller shall return the error code + * Unknown Advertising Identifier (0x42). + * @param Advertiser_Address_Type Advertising Address type + * Values: + * - 0x00: Public Device Address or Public Identity Address + * - 0x01: Random Device Address or Random (static) Identity Address + * @param Advertiser_Address Public Device Address, Random Device Address, + * Public Identity Address, or Random (static) Identity Address of the + * advertiser + * @param Advertising_SID It is used to identify the Periodic Advertising + * Values: + * - 0x00 ... 0x0F: Advertising SID subfield in the ADI field used to identify the Periodic +Advertising +All other values Reserved for future + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_remove_device_from_periodic_advertiser_list(uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint8_t Advertising_SID); +/** + * @brief The LE_Clear_Periodic_Advertiser_List command is used to remove all + * devices from the list of Periodic Advertisers in the Controller. If + * this command is used when an LE_Periodic_Advertising_Create_Sync + * command is pending, the Controller shall return the error code Command + * Disallowed (0x0C). + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_clear_periodic_advertiser_list(void); +/** + * @brief The LE_Read_Periodic_Advertiser_List_Size command is used to read the + * total number of Periodic Advertiser list entries that can be stored in + * the Controller. Note: The number of entries that can be stored is not + * fixed and the Controller can change it at any time (e.g., because the + * memory used to store the list can also be used for other purposes). + * @param[out] Periodic_Advertiser_List_Size Total number of Periodic Advertiser + * list entries that can be stored in the Controller + * Values: + * - 0x1F ... 0xFF: Total number of Periodic Advertiser list entries that can be stored in the +Controller + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_periodic_advertiser_list_size(uint8_t *Periodic_Advertiser_List_Size); +/** + * @brief The HCI_LE_Read_Transmit_Power command is used to read the minimum and + * maximum transmit powers supported by the Controller. + * @param[out] Min_Tx_Power Minimum supported TX power (units: dBm). + * Values: + * - -127 ... 20 + * @param[out] Max_Tx_Power Maximum supported TX power (units: dBm). + * Values: + * - -127 ... 20 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_transmit_power(int8_t *Min_Tx_Power, + int8_t *Max_Tx_Power); +/** + * @brief The HCI_LE_Read_RF_Path_Compensation command is used to read the RF + * Path Compensation Values parameter used in the Tx Power Level and RSSI + * calculation. + * @param[out] RF_TX_Path_Compensation_Value + * @param[out] RF_RX_Path_Compensation_Value + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_rf_path_compensation(int16_t *RF_TX_Path_Compensation_Value, + int16_t *RF_RX_Path_Compensation_Value); +/** + * @brief The HCI_LE_Write_RF_Path_Compensation command is used to indicate the + * RF path gain or loss between the RF transceiver and the antenna + * contributed by intermediate components. A positive value means a net + * RF path gain and a negative value means a net RF path loss. The RF Tx + * Path Compensation Value parameter shall be used by the Controller to + * calculate radiative Tx Power Level used in HCI commands, HCI events, + * Advertising physical channel PDUs, and Link Layer Control PDUs using + * the following equation: Radiative Tx Power Level = Tx Power Level at + * RF transceiver output + RF Tx Path Compensation Value. For example, if + * the Tx Power Level is +4 (dBm) at RF transceiver output and the RF + * Path Compensation Value is -1.5 (dB), the radiative Tx Power Level is + * +4+(-1.5) = 2.5 (dBm). The RF Rx Path Compensation Value parameter + * shall be used by the Controller to calculate the RSSI value reported + * to the Host. + * @param RF_TX_Path_Compensation_Value + * @param RF_RX_Path_Compensation_Value + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_write_rf_path_compensation(int16_t RF_TX_Path_Compensation_Value, + int16_t RF_RX_Path_Compensation_Value); +/** + * @brief The HCI_LE_Set_Privacy_Mode command is used to allow the Host to + * specify the privacy mode to be used for a given entry on the resolving + * list. The effect of this setting is specified in [Vol 6] Part B, + * Section 4.7. When an entry on the resolving list is removed, the mode + * associated with that entry shall also be removed. This command cannot + * be used when address translation is enabled in the Controller and: + * Advertising is enabled Scanning is enabled Create connection command + * is outstanding This command can be used at any time when address + * translation is disabled in the Controller. If the device is not on the + * resolving list, the Controller shall return the error code Unknown + * Connection Identifier (0x02). + * @param Peer_Identity_Address_Type Peer Address type + * Values: + * - 0x00: Public Identity Address + * - 0x01: Random (static) Identity Address + * @param Peer_Identity_Address Public Identity Address or Random (static) + * Identity Address of the advertiser + * @param Privacy_Mode 0x00 Use Network Privacy Mode for this peer device + * (default) 0x01 Use Device Privacy Mode for this peer device + * Values: + * - 0x00: Network Privacy Mode + * - 0x01: Device Privacy Mode + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_privacy_mode(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Privacy_Mode); +/** + * @brief The HCI_LE_Set_Connectionless_CTE_Transmit_Parameters command is used + * to set the type, length, and antenna switching pattern for the + * transmission of Constant Tone Extensions in any periodic advertising + * on the advertising set identified by the Advertising_Handle parameter. + * The CTE_Count parameter specifies how many packets with a Constant + * Tone Extension are to be transmitted in each periodic advertising + * event. If the number of packets that would otherwise be transmitted is + * less than this, the Controller shall transmit sufficient AUX_CHAIN_IND + * PDUs with no AdvData to make up the number. However, if a change in + * circumstances since this command was issued means that the Controller + * can no longer schedule all of these packets, it should transmit as + * many as possible. If the Host issues this command when Constant Tone + * Extensions have been enabled in the advertising set, the Controller + * shall return the error code Command Disallowed (0x0C). The + * Switching_Pattern_Length and Antenna_IDs[i] parameters are only used + * when transmitting an AoD Constant Tone Extension and shall be ignored + * if CTE_Type specifies an AoA Constant Tone Extension. If the + * CTE_Length parameter is greater than the maximum length of Constant + * Tone Extension supported, the Controller shall return the error code + * Unsupported Feature or Parameter Value (0x11). If the Host requests a + * type of Constant Tone Extension that the Controller does not support, + * the Controller shall return the error code Unsupported Feature or + * Parameter Value (0x11). If the Controller is unable to schedule + * CTE_Count packets in each event, the Controller shall return the error + * code Unsupported Feature or Parameter Value (0x11). If the advertising + * set corresponding to the Advertising_Handle parameter does not exist, + * the Controller shall return the error code Unknown Advertising + * Identifier (0x42). If Switching_Pattern_Length is greater than the + * maximum length of switching pattern supported by the Controller (see + * Section 7.8.87), the Controller shall return the error code + * Unsupported Feature or Parameter Value (0x11). If the Controller + * determines that any of the Antenna_IDs[i] values do not identify an + * antenna in the device's antenna array, it shall return the error code + * Unsupported Feature or Parameter Value (0x11). Note: Some Controllers + * may be unable to determine which values do or do not identify an + * antenna. + * @param Advertising_Handle It is used to identify an advertising set + * Values: + * - 0x00 ... 0xEF + * @param CTE_Length + * Values: + * - 0x02 ... 0x14: Constant Tone Extension length in 8 microseconds units + * @param CTE_Type + * Values: + * - 0x00: AoA Constant Tone Extension + * - 0x01: AoD Constant Tone Extension with 1 microsecond slots + * - 0x02: AoD Constant Tone Extension with 2 microseconds slots + * @param CTE_Count The CTE_Count parameter specifies how many packets with a + * Constant Tone Extension are to be transmitted in each periodic + * advertising event. If the number of packets that would otherwise be + * transmitted is less than this, the Controller shall transmit + * sufficient AUX_CHAIN_IND PDUs with no AdvData to make up the number. + * However, if a change in circumstances since this command was issued + * means that the Controller can no longer schedule all of these packets, + * it should transmit as many as possible. + * Values: + * - 0x01 ... 0x10: The number of Constant Tone Extensions to transmit in each periodic advertising interval + * @param Switching_Pattern_Length + * Values: + * - 0x02 ... 0x4B: The number of Antenna IDs in the pattern. + * @param Antenna_IDs List of Antenna IDs in the pattern + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_connectionless_cte_transmit_parameters(uint8_t Advertising_Handle, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t CTE_Count, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); +/** + * @brief The HCI_LE_Set_Connectionless_CTE_Transmit_Enable command is used to + * request that the Controller enables or disables the use of Constant + * Tone Extensions in any periodic advertising on the advertising set + * identified by Advertising_Handle. In order to start sending periodic + * advertisements containing a Constant Tone Extension, the Host must + * also enable periodic advertising using the + * HCI_LE_Set_Periodic_Advertising_Enable command (see Section 7.8.63). + * Note: Periodic advertising can only be enabled when advertising is + * enabled on the same advertising set, but can continue after + * advertising has been disabled. If the Host issues this command before + * it has issued the HCI_LE_Set_Periodic_Advertising_Parameters command + * (see Section 7.8.61) for the advertising set, the Controller shall + * return the error code Command Disallowed (0x0C). Once enabled, the + * Controller shall continue advertising with Constant Tone Extensions + * until either one of the following occurs: - The Host issues an + * HCI_LE_Set_Connectionless_CTE_Transmit_Enable command with CTE_Enable + * set to 0x00 (disabling Constant Tone Extensions but allowing periodic + * advertising to continue). - The Host issues an + * HCI_LE_Set_Periodic_Advertising_Enable command (see Section 7.8.63) + * with Enable set to 0x00 (disabling periodic advertising). If periodic + * advertising is re-enabled then it shall continue to contain Constant + * Tone Extensions. If the Host issues this command before it has issued + * the HCI_LE_Set_Connectionless_CTE_Transmit_Parameters command for the + * advertising set, the Controller shall return the error code Command + * Disallowed (0x0C). If the periodic advertising is on a PHY that does + * not allow Constant Tone Extensions, the Controller shall return the + * error code Command Disallowed (0x0C). + * @param Advertising_Handle Identifier for the advertising set in which + * Constant Tone Extension is being enabled or disabled + * Values: + * - 0x00 ... 0xEF + * @param CTE_Enable It enables or disables the use of Constant Tone Extensions. + * Values: + * - 0x00: Advertising with Constant Tone Extension is disabled (default) + * - 0x01: Advertising with Constant Tone Extension is enabled + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_connectionless_cte_transmit_enable(uint8_t Advertising_Handle, + uint8_t CTE_Enable); +/** + * @brief The HCI_LE_Set_Connectionless_IQ_Sampling_Enable command is used to + * request that the Controller enables or disables capturing IQ samples + * from the Constant Tone Extension of periodic advertising packets in + * the periodic advertising train identified by the Sync_Handle + * parameter. If that periodic advertising train does not exist, then the + * Controller shall return the error code Unknown Advertising Identifier + * (0x42). The Max_Sampled_CTEs parameter specifies the maximum number of + * Constant Tone Extensions in each periodic advertising event that the + * Controller should collect and report IQ samples from. The Controller + * should sample all Constant Tone Extensions up to this number. If the + * Sampling_Enable parameter is set to 0x01 (sampling is enabled), the + * Controller starts attempting to capture IQ samples from the periodic + * advertisements. Once sampling has been enabled, the Controller shall + * continue taking IQ samples until the Host issues an + * HCI_LE_Set_Connectionless_IQ_Enable command with Sampling_Enable set + * to 0x00 (sampling is disabled) or synchronization with the periodic + * advertising train is lost. If Sampling_Enable is set to 0x00, + * Slot_Durations, Max_Sampled_CTEs, Switching_Pattern_Length, and + * Antenna_IDs shall be ignored. The command is also used to set the + * antenna switching pattern and switching and sampling slot durations to + * be used while receiving the Constant Tone Extension. If Slot_Durations + * is set to 0x01 and the Controller does not support 1 microsecond + * switching and sampling, the Controller shall return the error code + * Unsupported Feature or Parameter Value (0x11). The Slot_Durations, + * Switching_Pattern_Length, and Antenna_IDs parameters are only used + * when receiving an AoA Constant Tone Extension and do not affect the + * reception of an AoD Constant Tone Extension. If + * Switching_Pattern_Length is greater than the maximum length of + * switching pattern supported by the Controller, the Controller shall + * return the error code Unsupported Feature or Parameter Value (0x11). + * If the Controller determines that any of the Antenna_IDs[i] values do + * not identify an antenna in the device's antenna array, it shall return + * the error code Unsupported Feature or Parameter Value (0x11). Note: + * Some Controllers may be unable to determine which values do or do not + * identify an antenna. If Sampling_Enable is set to 0x01 and the + * periodic advertising is on a PHY that does not allow Constant Tone + * Extensions, the Controller shall return the error code Command + * Disallowed (0x0C). + * @param Sync_Handle Sync handle that identifies the synchronization + * information about the periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + * @param Sampling_Enable If the Sampling_Enable parameter is set to 0x01 + * (sampling is enabled), the Controller starts attempting to capture IQ + * samples from the periodic advertisements. + * Values: + * - 0x00: DISABLE + * - 0x01: ENABLE + * @param Slot_Durations Sampling rate used by the Controller. + * Values: + * - 0x01: CTE_SLOT_1us + * - 0x02: CTE_SLOT_2us + * @param Max_Sampled_CTEs It specifies the maximum number of Constant Tone + * Extensions in each periodic advertising event that the Controller + * should collect and report IQ samples from. The Controller should + * sample all Constant Tone Extensions up to this number. + * Values: + * - 0x00: REPORT_ALL_CTES + * - 0x01 ... 0x10 + * @param Switching_Pattern_Length The number of Antenna IDs in the pattern. + * Values: + * - 0x02 ... 0x4B + * @param Antenna_IDs List of Antenna IDs in the pattern + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_connectionless_iq_sampling_enable(uint16_t Sync_Handle, + uint8_t Sampling_Enable, + uint8_t Slot_Durations, + uint8_t Max_Sampled_CTEs, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); +/** + * @brief The HCI_LE_Set_Connection_CTE_Receive_Parameters command is used to + * enable or disable sampling received Constant Tone Extension fields on + * the connection identified by the Connection_Handle parameter and to + * set the antenna switching pattern and switching and sampling slot + * durations to be used. If the Sampling_Enable parameter is set to 0x01, + * the Controller shall sample Constant Tone Extensions on the specified + * connection and report the samples to the Host. If it is set to 0x00, + * the Controller shall cease sampling on the specified connection; the + * remaining parameters shall be ignored. If Slot_Durations is set to + * 0x01 and the Controller does not support 1 microsecond switching and + * sampling, the Controller shall return the error code Unsupported + * Feature or Parameter Value (0x11). The Slot_Durations, + * Switching_Pattern_Length, and Antenna_IDs parameters are only used + * when receiving an AoA Constant Tone Extension and do not affect the + * reception of an AoD Constant Tone Extension. If + * Switching_Pattern_Length is greater than the maximum length of + * switching pattern supported by the Controller, the Controller shall + * return the error code Unsupported Feature or Parameter Value (0x11). + * If the Controller determines that any of the Antenna_IDs[i] values do + * not identify an antenna in the device's antenna array, it shall return + * the error code Unsupported Feature or Parameter Value (0x11). Note: + * Some Controllers may be unable to determine which values do or do not + * identify an antenna. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Sampling_Enable + * Values: + * - 0x00: Connection IQ sampling is disabled (default) + * - 0x01: Connection IQ sampling is enabled + * @param Slot_Durations Sampling rate used by the Controller. + * Values: + * - 0x01: CTE_SLOT_1us + * - 0x02: CTE_SLOT_2us + * @param Switching_Pattern_Length + * Values: + * - 0x02 ... 0x4B: The number of Antenna IDs in the pattern. + * @param Antenna_IDs List of Antenna IDs in the pattern + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_connection_cte_receive_parameters(uint16_t Connection_Handle, + uint8_t Sampling_Enable, + uint8_t Slot_Durations, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); +/** + * @brief The HCI_LE_Set_Connection_CTE_Transmit_Parameters command is used to + * set the antenna switching pattern and permitted Constant Tone + * Extension types used for transmitting Constant Tone Extensions + * requested by the peer device on the connection identified by the + * Connection_Handle parameter. If the Host issues this command when + * Constant Tone Extension responses have been enabled on the connection, + * the Controller shall return the error code Command Disallowed (0x0C). + * If the CTE_Types parameter has a bit set for a type of Constant Tone + * Extension that the Controller does not support, the Controller shall + * return the error code Unsupported Feature or Parameter Value (0x11). + * The Switching_Pattern_Length and Antenna_IDs[i] parameters are only + * used when transmitting an AoD Constant Tone Extension and shall be + * ignored when CTE_Types does not have a bit set for an AoD Constant + * Tone Extension; they do not affect the transmission of an AoA Constant + * Tone Extension. If Switching_Pattern_Length is greater than the + * maximum length of switching pattern supported by the Controller, the + * Controller shall return the error code Unsupported Feature or + * Parameter Value (0x11). If the Controller determines that any of the + * Antenna_IDs[i] values do not identify an antenna in the device's + * antenna array, it shall return the error code Unsupported Feature or + * Parameter Value (0x11). Note: Some Controllers may be unable to + * determine which values do or do not identify an antenna. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CTE_Type + * Flags: + * - 0x01: Allow AoA Constant Tone Extension Response + * - 0x02: Allow AoD Constant Tone Extension Response with 1 microsecond slots + * - 0x04: Allow AoD Constant Tone Extension Response with 2 microseconds slots + * @param Switching_Pattern_Length + * Values: + * - 0x02 ... 0x4B: The number of Antenna IDs in the pattern. + * @param Antenna_IDs List of Antenna IDs in the pattern + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_connection_cte_transmit_parameters(uint16_t Connection_Handle, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); +/** + * @brief The HCI_LE_Connection_CTE_Request_Enable command is used to request + * the Controller to start or stop initiating the Constant Tone Extension + * Request procedure (see [Vol 6] Part B, Section 5.1.12) on a connection + * identified by the Connection_Handle parameter. If the Host issues this + * command when the Controller is aware (e.g. through a previous feature + * exchange) that the peer device's Link Layer does not support the + * Connection CTE Response feature, the Controller shall return the error + * code Unsupported Remote Feature / Unsupported LMP Feature (0x1A). If + * the Host issues this command when the Controller is aware that the + * peer device's Link Layer does not support the requested CTE type, the + * Controller should return the error code Unsupported Remote Feature / + * Unsupported LMP Feature (0x1A). If Enable is set to 0x00, the + * remaining parameters shall be ignored. The CTE_Request_Interval + * parameter defines whether the Constant Tone Extension Request + * procedure is initiated only once or periodically. In the case of + * periodic operation, the procedure is initiated every + * CTE_Request_Interval. However, the Controller may delay initiating the + * procedure beyond the requested interval (e.g., in order to prioritize + * other activities). The Requested_CTE_Length parameter indicates the + * minimum length of the Constant Tone Extension and the + * Requested_CTE_Type parameter indicates the type of Constant Tone + * Extension that the Controller shall request from the remote device. A + * request is active on a connection from when the Host issues a + * successful command with Enable set to 0x01 until the single procedure + * has been performed, the period specified by CTE_Request_Interval has + * ended, or a command with Enable set to 0x00 has succeeded, whichever + * happens first. If the Host issues this command with Enable set to 0x01 + * while a request is active for the specified connection, the Controller + * shall return the error code Command Disallowed (0x0C). Note: The + * failed command will not affect the behavior of the Link Layer in + * respect of the currently-active request. If the Host issues this + * command before issuing the + * HCI_LE_Set_Connection_CTE_Receive_Parameters command at least once on + * the connection, the Controller shall return the error code Command + * Disallowed (0x0C). If the Host issues this command when the receiver + * PHY for the connection is not a PHY that allows Constant Tone + * Extensions, the Controller shall return the error code Command + * Disallowed (0x0C). If the Host sets CTE_Request_Interval to a non-zero + * value less than or equal to connPeripheralLatency, the Controller + * shall return the error code Command Disallowed (0x0C). If Enable is + * set to 0x01 and the receiver PHY for the connection changes to a PHY + * that does not allow Constant Tone Extensions, then the Controller + * shall automatically disable Constant Tone Extension requests as if the + * Host had issued this command with Enable set to 0x00. Note: If the PHY + * changes back to a PHY that allows Constant Tone Extensions, then the + * Controller will not automatically re-enable Constant Tone Extension + * requests. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Enable If it is set to 0x00, the remaining parameters shall be + * ignored. + * Values: + * - 0x00: Disable Constant Tone Extension Request for the connection (default) + * - 0x01: Enable Constant Tone Extension Request for the connection + * @param CTE_Request_Interval It defines whether the Constant Tone Extension + * Request procedure is initiated only once or periodically. In the case + * of periodic operation, the procedure is initiated every + * CTE_Request_Interval. However, the Controller may delay initiating the + * procedure beyond the requested interval (e.g., in order to prioritize + * other activities). + * Values: + * - 0x0000: Initiate the Constant Tone Extension Request procedure once, at the nearliest practical opportunity. + * - 0x0001 ... 0xFFFF: Requested interval for initiating the Constant Tone Extension Request procedure in number of connection events. + * @param Requested_CTE_Length It indicates the minimum length of the Constant + * Tone Extension and the Requested_CTE_Type parameter indicates the type + * of Constant Tone Extension that the Controller shall request from the + * remote device. + * Values: + * - 0x02 ... 0x14: Minimum length of the Constant Tone Extension being requested in 8 nmicroseconds units + * @param Requested_CTE_Type + * Flags: + * - 0x00: AoA Constant Tone Extension + * - 0x01: AoD Constant Tone Extension with 1 microsecond slots + * - 0x02: AoD Constant Tone Extension with 2 microseconds slots + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_connection_cte_request_enable(uint16_t Connection_Handle, + uint8_t Enable, + uint16_t CTE_Request_Interval, + uint8_t Requested_CTE_Length, + uint8_t Requested_CTE_Type); +/** + * @brief The HCI_LE_Connection_CTE_Response_Enable command is used to request + * the Controller to respond to LL_CTE_REQ PDUs with LL_CTE_RSP PDUs on + * the specified connection. If the Host issues this command before + * issuing the HCI_LE_Set_Connection_CTE_Transmit_Parameters command at + * least once on the connection, the Controller shall return the error + * code Command Disallowed (0x0C). If the Host issues this command when + * the transmitter PHY for the connection is not a PHY that allows + * Constant Tone Extensions, the Controller shall return the error code + * Command Disallowed (0x0C). If the transmitter PHY for the connection + * changes to a PHY that does not allow Constant Tone Extensions, then + * the Controller shall automatically disable Constant Tone Extension + * responses. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Enable + * Values: + * - 0x00: Disable Constant Tone Extension Response for the connection (default) + * - 0x01: Enable Constant Tone Extension Response for the connection + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_connection_cte_response_enable(uint16_t Connection_Handle, + uint8_t Enable); +/** + * @brief The HCI_LE_Read_Antenna_Information command allows the Host to read + * the switching rates, the sampling rates, the number of antennae, and + * the maximum length of a transmitted Constant Tone Extension supported + * by the Controller. + * @param[out] Supported_Switching_Sampling_Rates + * Flags: + * - 0x00: 1 microsecond switching supported for AoD transmission + * - 0x02: 1 microsecond switching supported for AoD reception + * - 0x04: 1 microsecond switching and sampling supported for AoA reception + * @param[out] Num_Antennae + * Values: + * - 0x01 ... 0x4B: The number of antennae supported by the Controller + * @param[out] Max_Switching_Pattern_Length + * Values: + * - 0x02 ... 0x4B: Maximum length of antenna switching pattern supported by the Controller + * @param[out] Max_CTE_Length + * Values: + * - 0x02 ... 0x14: Maximum length of a transmitted Constant Tone Extension supported in 8 microseconds units + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_antenna_information(uint8_t *Supported_Switching_Sampling_Rates, + uint8_t *Num_Antennae, + uint8_t *Max_Switching_Pattern_Length, + uint8_t *Max_CTE_Length); +/** + * @brief The HCI_LE_Set_Periodic_Advertising_Receive_Enable command will enable + * or disable reports for the periodic advertising train identified by + * the Sync_Handle parameter. The Enable parameter determines whether + * reporting and duplicate filtering are enabled or disabled. If the + * value is the same as the current state, the command has no effect. If + * the periodic advertising train corresponding to the Sync_Handle + * parameter does not exist, the Controller shall return the error code + * Unknown Advertising Identifier (0x42). + * @param Sync_Handle Sync_Handle identifying the periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + * @param Enable Bit 0 to enable reporting. Bit 1 to enable duplicate filtering. + * Flags: + * - 0x01: ENABLE_REPORTING + * - 0x02: ENABLE_DUPLICATE_FILTERING + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_periodic_advertising_receive_enable(uint16_t Sync_Handle, + uint8_t Enable); +/** + * @brief The HCI_LE_Periodic_Advertising_Sync_Transfer command is used to + * instruct the Controller to send synchronization information about the + * periodic advertising train identified by the Sync_Handle parameter to + * a connected device. The Service_Data parameter is a value provided by + * the Host for use by the Host of the peer device. It is not used by the + * Controller. The connected device is identified by the + * Connection_Handle parameter. If the periodic advertising train + * corresponding to the Sync_Handle parameter does not exist, the + * Controller shall return the error code Unknown Advertising Identifier + * (0x42). If the Connection_Handle parameter does not identify a current + * connection, the Controller shall return the error code Unknown + * Connection Identifier (0x02). If the remote device has not indicated + * support for the Periodic Advertising Sync Transfer - Recipient + * feature, the Controller shall return the error code Unsupported Remote + * Feature / Unsupported LMP Feature (0x1A). Note: This command may + * complete before the periodic advertising synchronization information + * is sent. No indication is given as to how the recipient handled the + * information. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Service_Data The Service_Data parameter is a value provided by the + * Host for use by the Host of the peer device. It is not used by the + * Controller. + * @param Sync_Handle Sync handle that identifies the synchronization + * information about the periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_periodic_advertising_sync_transfer(uint16_t Connection_Handle, + uint16_t Service_Data, + uint16_t Sync_Handle); +/** + * @brief The HCI_LE_Periodic_Advertising_Set_Info_Transfer command is used to + * instruct the Controller to send synchronization information about the + * periodic advertising in an advertising set to a connected device. The + * Advertising_Handle parameter identifies the advertising set. If the + * parameters in the advertising set have changed since the periodic + * advertising was first enabled, the current parameters - not the + * original ones - are sent. The Service_Data parameter is a value + * provided by the Host to identify the periodic advertising train to the + * peer device. It is not used by the Controller. The connected device is + * identified by the Connection_Handle parameter. If the advertising set + * corresponding to the Advertising_Handle parameter does not exist, the + * Controller shall return the error code Unknown Advertising Identifier + * (0x42). If periodic advertising is not currently in progress for the + * advertising set, the Controller shall return the error code Command + * Disallowed (0x0C). If the Connection_Handle parameter does not + * identify a current connection, the Controller shall return the error + * code Unknown Connection Identifier (0x02). If the remote device has + * not indicated support for the Periodic Advertising Sync Transfer - + * Recipient feature, the Controller shall return the error code + * Unsupported Remote Feature / Unsupported LMP Feature (0x1A). Note: + * This command may complete before the periodic advertising + * synchronization information is sent. No indication is given as to how + * the recipient handled the information. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Service_Data It is a value provided by the Host to identify the + * periodic advertising train to the peer device. It is not used by the + * Controller. + * @param Advertising_Handle It is used to identify an advertising set + * Values: + * - 0x00 ... 0xEF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_periodic_advertising_set_info_transfer(uint16_t Connection_Handle, + uint16_t Service_Data, + uint8_t Advertising_Handle); +/** + * @brief The HCI_LE_Set_Periodic_Advertising_Sync_Transfer_Parameters command + * is used to specify how the Controller will process periodic + * advertising synchronization information received from the device + * identified by the Connection_Handle parameter (the "transfer mode"). + * The Mode parameter specifies the action to be taken when periodic + * advertising synchronization information is received. If Mode is 0x00, + * the Controller will ignore the information. Otherwise it will notify + * the Host and synchronize to the periodic advertising. Mode also + * specifies whether periodic advertising reports are initially enabled + * or disabled and whether duplicates are filtered. The Skip parameter + * specifies the number of consecutive periodic advertising packets that + * the receiver may skip after successfully receiving a periodic + * advertising packet. The Sync_Timeout parameter specifies the maximum + * permitted time between successful receives. If this time is exceeded, + * synchronization is lost. Irrespective of the value of the Skip + * parameter, the Controller should stop skipping packets before the + * Sync_Timeout would be exceeded. The CTE_Type parameter specifies + * whether to only synchronize to periodic advertising with certain types + * of Constant Tone Extension. If the periodic advertiser changes the + * type of the Constant Tone Extension after the Controller has + * synchronized with the periodic advertising, it shall remain + * synchronized. Note: A value of 0 (i.e. all bits clear) indicates that + * the presence or absence of a Constant Tone Extension is irrelevant. + * This command does not affect any processing of any periodic + * advertising synchronization information already received from the peer + * device, whether or not the Controller has yet synchronized to the + * periodic advertising train it describes. The parameter values provided + * by this command override those provided via the HCI_LE_Set_Default_Per + * iodic_Advertising_Sync_Transfer_Parameterscommand or any preferences + * previously set using the + * HCI_LE_Set_Periodic_Advertising_Sync_Transfer_Parameters command on + * the same connection. If the Connection_Handle parameter does not + * identify a current connection, the Controller shall return the error + * code Unknown Connection Identifier (0x02). + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Mode The action to be taken when periodic advertising synchronization + * information is received. If 0, no attempt is made to synchronize to + * the periodic advertising and no + * HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is sent to + * the Host. If 1, an HCI_LE_Periodic_Advertising_Sync_Transfer_Received + * event is sent to the Host. HCI_LE_Periodic_Advertising_Report events + * will be disabled. If 2, an + * HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is sent to + * the Host. HCI_LE_Periodic_Advertising_Report events will be enabled + * with duplicate filtering disabled. If 3, an + * HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is sent to + * the Host. HCI_LE_Periodic_Advertising_Report events will be enabled + * with duplicate filtering enabled. + * Values: + * - 0x00: NO_SYNC + * - 0x01: REPORTS_DISABLED + * - 0x02: REPORTS_ENABLED + * - 0x03: REPORTS_ENABLED_WITH_DUPLICATE_FILTERING + * @param Skip The number of periodic advertising packets that can be skipped + * after a successful receive. + * Values: + * - 0x0000 ... 0x01F3 + * @param Sync_Timeout Synchronization timeout for the periodic advertising + * train. Time = N*10 ms. + * Values: + * - 0x000A (100 ms) ... 0x4000 (163840 ms) + * @param CTE_Type It specifies whether to only synchronize to periodic + * advertising with certain types of Constant Tone Extension. If bit 0 + * is set: do not sync to packets with an AoA Constant Tone Extension. If + * bit 1 is set: Do not sync to packets with an AoD Constant Tone + * Extension with 1 us slots. If bit 2 is set: Do not sync to packets + * with an AoD Constant Tone Extension with 2 us slots. If bit 3 is set: + * Do not sync to packets without a Constant Tone Extension. + * Flags: + * - 0x01: DO_NOT_SYNC_WITH_AOA + * - 0x02: DO_NOT_SYNC_WITH_AOD_1US + * - 0x04: DO_NOT_SYNC_WITH_AOD_2US + * - 0x10: DO_NOT_SYNC_WITHOUT_CTE + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_periodic_advertising_sync_transfer_parameters(uint16_t Connection_Handle, + uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type); +/** + * @brief The HCI_LE_Set_Default_Periodic_Advertising_Sync_Transfer_Parameters + * command is used to specify the initial value for the mode, skip, + * timeout, and Constant Tone Extension type (set by the + * HCI_LE_Set_Periodic_Advertising_Sync_Transfer_Parameters command; see + * Section 7.8.91) to be used for all subsequent connections over the LE + * transport. The Mode parameter specifies the initial action to be + * taken. If Mode is 0x00, the Controller will ignore the information. + * Otherwise it will notify the Host and synchronize to the periodic + * advertising. Mode also specifies whether periodic advertising reports + * are initially enabled or disabled. The Skip parameter specifies the + * number of consecutive periodic advertising packets that the receiver + * may skip after successfully receiving a periodic advertising packet. + * The Sync_Timeout parameter specifies the maximum permitted time + * between successful receives. If this time is exceeded, synchronization + * is lost. The CTE_Type parameter specifies whether to only synchronize + * to periodic advertising with certain types of Constant Tone Extension. + * If the periodic advertiser changes the type of the Constant Tone + * Extension after the Controller has synchronized with the periodic + * advertising, it shall remain synchronized. Note: A value of 0 (i.e. + * all bits clear) indicates that the presence or absence of a Constant + * Tone Extension is irrelevant. This command does not affect any + * existing connection. + * @param Mode The action to be taken when periodic advertising synchronization + * information is received. If 0, no attempt is made to synchronize to + * the periodic advertising and no + * HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is sent to + * the Host. If 1, an HCI_LE_Periodic_Advertising_Sync_Transfer_Received + * event is sent to the Host. HCI_LE_Periodic_Advertising_Report events + * will be disabled. If 2, an + * HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is sent to + * the Host. HCI_LE_Periodic_Advertising_Report events will be enabled + * with duplicate filtering disabled. If 3, an + * HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is sent to + * the Host. HCI_LE_Periodic_Advertising_Report events will be enabled + * with duplicate filtering enabled. + * Values: + * - 0x00: NO_SYNC + * - 0x01: REPORTS_DISABLED + * - 0x02: REPORTS_ENABLED + * - 0x03: REPORTS_ENABLED_WITH_DUPLICATE_FILTERING + * @param Skip The number of periodic advertising packets that can be skipped + * after a successful receive. + * Values: + * - 0x0000 ... 0x01F3 + * @param Sync_Timeout Synchronization timeout for the periodic advertising + * train. Time = N*10 ms. + * Values: + * - 0x000A (100 ms) ... 0x4000 (163840 ms) + * @param CTE_Type It specifies whether to only synchronize to periodic + * advertising with certain types of Constant Tone Extension. If bit 0 + * is set: do not sync to packets with an AoA Constant Tone Extension. If + * bit 1 is set: Do not sync to packets with an AoD Constant Tone + * Extension with 1 us slots. If bit 2 is set: Do not sync to packets + * with an AoD Constant Tone Extension with 2 us slots. If bit 3 is set: + * Do not sync to packets without a Constant Tone Extension. + * Flags: + * - 0x01: DO_NOT_SYNC_WITH_AOA + * - 0x02: DO_NOT_SYNC_WITH_AOD_1US + * - 0x04: DO_NOT_SYNC_WITH_AOD_2US + * - 0x10: DO_NOT_SYNC_WITHOUT_CTE + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_default_periodic_advertising_sync_transfer_parameters(uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type); +/** + * @brief This command is used to read the maximum size of the data portion of + * ACL data packets and isochronous data packets sent from the Host to + * the Controller. The Host shall segment the data transmitted to the + * Controller according to these values so that the HCI Data packets and + * isochronous data packets will contain data up to this size. The + * HCI_LE_Read_Buffer_Size command also returns the total number of HCI + * LE ACL Data packets and isochronous data packets that can be stored in + * the data buffers of the Controller. The HCI_LE_Read_Buffer_Size + * command shall be issued by the Host before it sends any data to an LE + * Controller (see Section 4.1.1). If the Controller supports HCI ISO + * Data packets, it shall return non-zero values for the + * ISO_Data_Packet_Length and Total_Num_ISO_Data_Packets parameters. + * @param[out] HC_LE_ACL_Data_Packet_Length 0x0000: No dedicated LE Buffer + * exists. Use the HCI_Read_Buffer_Size command. 0x001B - 0xFFFF + * Maximum length (in octets) of the data portion of each HCI ACL + * data packet. + * Values: + * - 0x0000: NO_BUFFER + * - 0x001B ... 0xFFFF + * @param[out] HC_Total_Num_LE_ACL_Data_Packets 0x00: No dedicated LE Buffer + * exists. Use the HCI_Read_Buffer_Size command. 0x01 - 0xFF: Total + * number of HCI ACL Data Packets that can be stored in the data + * buffers of the Controller. + * Values: + * - 0x00: NO_BUFFER + * - 0x01 ... 0xFF + * @param[out] ISO_Data_Packet_Length 0x0000: No dedicated ISO Buffer exists. + * 0x0001 to 0xFFFF: The maximum length (in octets) of the data + * portion of each HCI ISO data packet. + * Values: + * - 0x0000: NO_BUFFER + * - 0x0001 ... 0xFFFF + * @param[out] Total_Num_ISO_Data_Packets 0x00: No dedicated ISO Buffer exists. + * 0x01 to 0xFF: The total number of HCI ISO data packets that can + * be stored in the ISO buffers of the Controller. + * Values: + * - 0x00: NO_BUFFER + * - 0x01 ... 0xFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_buffer_size_v2(uint16_t *HC_LE_ACL_Data_Packet_Length, + uint8_t *HC_Total_Num_LE_ACL_Data_Packets, + uint16_t *ISO_Data_Packet_Length, + uint8_t *Total_Num_ISO_Data_Packets); +/** + * @brief transmitted SDU identified by the Packet_Sequence_Number on a CIS or + * BIS identified by the Connection_Handle parameter on the Central or + * Peripheral. The Packet_Sequence_Number parameter contains the sequence + * number of a transmitted SDU. The TX_Time_Stamp and Time_Offset + * parameters are described in [Vol 6] Part G, Section 3.3 and [Vol 6] + * Part G, Section 3.1 respectively. When the Connection_Handle + * identifies a CIS or BIS that is transmitting unframed PDUs, the value + * of Time_Offset returned shall be zero. If the Host issues this command + * with a connection handle that does not exist, or the connection handle + * is not associated with a CIS or BIS, the Controller shall return the + * error code Unknown Connection Identifier (0x02). If the Host issues + * this command on an existing connection handle for a CIS or BIS that is + * not configured for transmitting SDUs, the Controller shall return the + * error code Command Disallowed (0x0C). If the Host issues this command + * before an SDU has been transmitted by the Controller, the Controller + * shall return the error code Command Disallowed (0x0C). + * @param Connection_Handle Connection handle of the CIS or BIS. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] Packet_Sequence_Number The packet sequence number of an SDU. + * @param[out] TX_Time_Stamp The CIG reference point or BIG anchor point of a + * transmitted SDU derived using the Controller's free running + * reference clock (in microseconds). + * @param[out] Time_Offset The time offset, in microseconds, that is associated + * with a transmitted SDU. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_iso_tx_sync(uint16_t Connection_Handle, + uint16_t *Packet_Sequence_Number, + uint32_t *TX_Time_Stamp, + uint8_t Time_Offset[3]); +/** + * @brief The HCI_LE_Set_CIG_Parameters command is used by a Central's Host to + * create a CIG and to set the parameters of one or more CISes that are + * associated with a CIG in the Controller. The CIG_ID parameter + * identifies a CIG. This parameter is allocated by the Central's Host + * and passed to the Peripheral's Host through the Link Layers during the + * process of creating a CIS. If the CIG_ID does not exist, then the + * Controller shall first create a new CIG. Once the CIG is created + * (whether through this command or previously), the Controller shall + * modify or add CIS configurations in the CIG that is identified by the + * CIG_ID and update all the parameters that apply to the CIG. The + * SDU_Interval_C_To_P parameter specifies the time interval between the + * start of consecutive SDUs from the Central's Host for all the CISes in + * the CIG. This parameter shall be ignored for all CISes that are + * unidirectional from Peripheral to Central. The SDU_Interval_P_To_C + * parameter specifies the time interval between the start of consecutive + * SDUs from the Peripheral's Host for all the CISes in the CIG. This + * parameter shall be ignored for all CISes that are unidirectional from + * Central to Peripheral. The Worst_Case_SCA parameter shall be the + * worst-case sleep clock accuracy of all the Peripherals that will + * participate in the CIG. The Host should get the sleep clock accuracy + * from all the Peripherals before issuing this command. If the Host + * cannot get the sleep clock accuracy from all the Peripherals, it shall + * set the Worst_Case_SCA parameter to zero. Note: The Worst_Case_SCA + * parameter can be used by the Link Layer to better allow for clock + * drift when scheduling the CISes in the CIG. For example, if a CIS has + * more than two subevents, the Link Layer of the Central can set the + * timing of the subevents such that the worst case drift in the + * Peripheral's clock will not exceed 2 x Sub_Interval. This prevents the + * Peripheral from synchronizing its timing to the wrong subevent + * (adjacent subevents cannot be on the same channel). The Packing + * parameter indicates the preferred method of arranging subevents of + * multiple CISes. The subevents can be arranged in Sequential or + * Interleaved arrangement (see [Vol 6] Part B, Section 4.5.14.2). This + * is a recommendation to the Controller which the Controller may ignore. + * This parameter shall be ignored when there is only one CIS in the CIG. + * The Framing parameter indicates the format of the CIS Data PDUs of the + * specified CISes. If the Framing parameter is set to 1 then the CIS + * Data PDUs of the specified CISes shall be framed. If the Framing + * parameter is set to 0 the CIS Data PDUs of a given CIS may be either + * unframed or framed (determined separately for each specified CIS) (see + * [Vol 6] Part G, Section 1). The Max_Transport_Latency_C_To_P parameter + * contains the maximum transport latency from the Central to the + * Peripheral, in milliseconds, as described in [Vol 6] Part G, Section + * 3.2.1 and [Vol 6] Part G, Section 3.2.2. This parameter shall be + * ignored for all CISes that are unidirectional from Peripheral to + * Central. The Max_Transport_Latency_P_To_C parameter contains the + * maximum transport latency from the Peripheral to the Central, in + * milliseconds, as described in [Vol 6] Part G, Section 3.2.1 and [Vol + * 6] Part G, Section 3.2.2. This parameter shall be ignored for all + * CISes that are unidirectional from Central to Peripheral. The + * CIS_Count parameter indicates the number of CIS configurations being + * modified or added by this command. The Controller shall set the + * CIS_Count return parameter equal to this. The CIS_ID[i] parameter + * identifies a CIS and is set by the Central's Host and passed to the + * Peripheral's Host through the Link Layers during the process of + * establishing a CIS. The Max_SDU_C_To_P[i] parameter identifies the + * maximum size of an SDU from the Central's Host. If the CIS is + * unidirectional from Peripheral to Central, this parameter shall be set + * to 0. If a CIS configuration that is being modified has a data path + * set in the Central to Peripheral direction and the Host has specified + * that Max_SDU_C_To_P[i] shall be set to zero, the Controller shall + * return the error code Command Disallowed (0x0C). The Max_SDU_P_To_C[i] + * parameter identifies the maximum size of an SDU from the Peripheral's + * Host. If the CIS is unidirectional from Central to Peripheral, this + * parameter shall be set to 0. If a CIS configuration that is being + * modified has a data path set in the Peripheral to Central direction + * and the Host has specified that Max_SDU_P_To_C[i] shall be set to + * zero, the Controller shall return the error code Command Disallowed + * (0x0C). The PHY_C_To_P[i] parameter identifies which PHY to use for + * transmission from the Central to the Peripheral. The Host shall set at + * least one bit in this parameter and the Controller shall pick a PHY + * from the bits that are set. The PHY_P_To_C[i] parameter identifies + * which PHY to use for transmission from the Peripheral to the Central. + * The Host shall set at least one bit in this parameter and the + * Controller shall pick a PHY from the bits that are set. The + * RTN_C_To_P[i] (Retransmission Number) parameter contains the number of + * times that a CIS Data PDU should be retransmitted from the Central to + * Peripheral before being acknowledged or flushed (irrespective of which + * isochronous events the retransmission opportunities occur in). If the + * CIS is unidirectional from Peripheral to Central, this parameter shall + * be ignored. Otherwise, this parameter is a recommendation to the + * Controller which the Controller may ignore. The RTN_P_To_C[i] + * parameter contains the number of times that a CIS Data PDU should be + * retransmitted from the Peripheral to Central before being acknowledged + * or flushed (irrespective of which isochronous events the + * retransmission opportunities occur in). If the CIS is unidirectional + * from Central to Peripheral, this parameter shall be ignored. + * Otherwise, this parameter is a recommendation to the Controller which + * the Controller may ignore. If the Status return parameter is non-zero, + * then the state of the CIG and its CIS configurations shall not be + * changed by the command. If the CIG did not already exist, it shall not + * be created. If the Status return parameter is zero, then the + * Controller shall set the Connection_Handle arrayed return parameter to + * the connection handle(s) corresponding to the CIS configurations + * specified in the CIS_IDs command parameter, in the same order. If the + * same CIS_ID is being reconfigured, the same connection handle shall be + * returned. The connection handle of a CIS shall refer to the CIS when + * it exists and to the configuration of the CIS stored in a CIG when the + * CIG exists but the CIS with that CIS_ID does not. If the Host issues + * this command when the CIG is not in the configurable state, the + * Controller shall return the error code Command Disallowed (0x0C). If + * the Host attempts to create a CIG or set parameters that exceed the + * maximum supported resources in the Controller, the Controller shall + * return the error code Memory Capacity Exceeded (0x07). If the Host + * attempts to set CIS parameters that exceed the maximum supported + * connections in the Controller, the Controller shall return the error + * code Connection Limit Exceeded (0x09). If the Host sets, in the + * PHY_C_To_P[i] or PHY_P_To_C[i] parameters, a bit for a PHY that the + * Controller does not support, including a bit that is reserved for + * future use, the Controller shall return the error code Unsupported + * Feature or Parameter Value (0x11). If the Controller does not support + * asymmetric PHYs and the Host sets PHY_C_To_P[i] to a different value + * than PHY_P_To_C[i], the Controller shall return the error code + * Unsupported Feature or Parameter Value (0x11). If the Host specifies + * an invalid combination of CIS parameters, the Controller shall return + * the error code Unsupported Feature or Parameter Value (0x11). + * @param CIG_ID Used to identify the CIG. + * Values: + * - 0x00 ... 0xEF + * @param SDU_Interval_C_To_P The interval, in microseconds, of periodic SDUs. + * Values: + * - 0x0000FF ... 0x0FFFFF + * @param SDU_Interval_P_To_C The interval, in microseconds, of periodic SDUs. + * Values: + * - 0x0000FF ... 0x0FFFFF + * @param Worst_Case_SCA Worst-case sleep clock accuracy of all the Peripherals. + * Values: + * - 0x00: 251 ppm to 500 ppm + * - 0x01: 151 ppm to 250 ppm + * - 0x02: 101 ppm to 150 ppm + * - 0x03: 76 ppm to 100 ppm + * - 0x04: 51 ppm to 75 ppm + * - 0x05: 31 ppm to 50 ppm + * - 0x06: 21 ppm to 30 ppm + * - 0x07: 0 ppm to 20 ppm + * @param Packing Preferred method of arranging subevents of multiple CISes. + * Values: + * - 0x00: Sequential + * - 0x01: Interleaved + * @param Framing Format of the CIS Data PDUs of the specified CISes. + * Values: + * - 0x00: Unframed + * - 0x01: Framed + * @param Max_Transport_Latency_C_To_P Maximum transport latency, in + * milliseconds, from the Central's Controller to the Peripheral's + * Controller. + * Values: + * - 0x0005 ... 0x0FA0 + * @param Max_Transport_Latency_P_To_C Maximum transport latency, in + * milliseconds, from the Peripheral's Controller to the Central's + * Controller. + * Values: + * - 0x0005 ... 0x0FA0 + * @param CIS_Count Total number of CIS configurations in the CIG being added or + * modified. + * Values: + * - 0x00 ... 0x1F + * @param CIS_Param See @ref CIS_Param_t + * @param[out] Connection_Handle Connection handle of the CIS in the CIG. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_cig_parameters(uint8_t CIG_ID, + uint8_t SDU_Interval_C_To_P[3], + uint8_t SDU_Interval_P_To_C[3], + uint8_t Worst_Case_SCA, + uint8_t Packing, + uint8_t Framing, + uint16_t Max_Transport_Latency_C_To_P, + uint16_t Max_Transport_Latency_P_To_C, + uint8_t CIS_Count, + CIS_Param_t CIS_Param[], + uint16_t Connection_Handle[]); +/** + * @brief The HCI_LE_Set_CIG_Parameters_Test command should only be used for + * testing purposes. The command is used by a Central's Host to create a + * CIG and to set the parameters of one or more CISes that are associated + * with a CIG in the Controller. The CIG_ID parameter identifies a CIG. + * This parameter is allocated by the Central's Host and passed to the + * Peripheral's Host through the Link Layers during the process of + * creating a CIS. If the CIG_ID does not exist, then the Controller + * shall first create a new CIG. Once the CIG is created (whether through + * this command or previously), the Controller shall modify or add CIS + * configurations in the CIG that is identified by the CIG_ID and update + * all the parameters that apply to the CIG. The SDU_Interval_C_To_P + * parameter specifies the time interval of periodic SDUs from the + * Central's Host. The SDU_Interval_P_To_C parameter specifies the time + * interval of periodic SDUs from the Peripheral's Host. The FT_C_To_P + * parameter identifies the maximum time for a payload from the Central + * to Peripheral to be transmitted and re-transmitted, after which it is + * flushed (see [Vol 6] Part B, Section 4.5.13.5). This parameter is + * expressed in multiples of ISO_Interval. The FT_P_To_C parameter + * identifies the maximum time for a payload from the Peripheral to + * Central to be transmitted and re-transmitted, after which it is + * flushed (see[Vol 6] Part B, Section 4.5.13.5). This parameter is + * expressed in multiples of ISO_Interval. The ISO_Interval parameter + * specifies the time between two consecutive CIS anchor points. The + * CIS_Count parameter contains the number of CIS configurations being + * added or modified by this command. The Controller shall set the + * CIS_Count return parameter equal to this. The CIS_ID[i] parameter + * identifies the CIS and is set by the Central's Host and passed to the + * Peripheral's Host through the Link Layers during the process of + * establishing a CIS. The Worst_Case_SCA parameter is the worst-case + * sleep clock accuracy of all the Peripherals that will participate in + * the CIG. The Host should get the sleep clock accuracy from all the + * Peripherals before issuing this command. In case the Host cannot get + * the sleep clock accuracy from all the Peripherals, it shall set the + * Worst_Case_SCA parameter to zero. Note: The Worst_Case_SCA parameter + * can be used by the Link Layer to better allow for clock drift when + * scheduling the CISes in the CIG. For example, if a CIS has more than + * two subevents, the Link Layer of the Central can set the timing of the + * subevents such that the worst case drift in the Peripheral's clock + * will not exceed 2 x Sub_Interval. This prevents the Peripheral from + * synchronizing its timing to the wrong subevent (adjacent subevents + * cannot be on the same channel). The Packing parameter is used to + * indicate the preferred method of arranging subevents of multiple + * CISes. The subevents can be arranged in Sequential or Interleaved + * arrangement. This is a recommendation to the Controller which it may + * ignore. This parameter shall be ignored when there is only one CIS in + * the CIG. The Framing parameter indicates the format of the CIS Data + * PDUs of all the CISes. If the Framing parameter is set to 1 then the + * CIS Data PDUs of the specified CISes shall be framed, and when set to + * 0 they shall be unframed (see [Vol 6] Part G, Section 1). The + * CIS_ID[i] parameter is used to identify a CIS. The NSE[i] parameter + * identifies the maximum number of subevents for each CIS in a CIG + * event. The Max_SDU_C_To_P[i] parameter identifies the maximum size of + * SDU from the Central's Host. If the CIS is unidirectional from + * Peripheral to Central, this parameter shall be set to 0. If a CIS + * configuration that is being modified has a data path set in the + * Central to Peripheral direction and the Host has specified that + * Max_SDU_C_To_P[i] shall be set to zero, the Controller shall return + * the error code Command Disallowed (0x0C). The minimum value of the + * Max_SDU_Size parameter in the ISO Transmit Test mode when the + * Payload_Type = 1 or 2 shall be 4 octets. The Max_SDU_P_To_C[i] + * parameter identifies the maximum size of SDU from the Peripheral's + * Host. If the CIS is unidirectional from Central to Peripheral, this + * parameter shall be set to 0. If a CIS configuration that is being + * modified has a data path set in the Peripheral to Central direction + * and the Host has specified that Max_SDU_P_To_C[i] shall be set to + * zero, the Controller shall return the error code Command Disallowed + * (0x0C).The minimum value of the Max_SDU parameter in the ISO Transmit + * Test mode when the Payload_Type = 1 or 2 shall be 4 octets. The + * Max_PDU_C_To_P[i] parameter identifies the maximum size PDU from the + * Central to Peripheral. The Max_PDU_P_To_C[i] parameter identifies the + * maximum size PDU from the Peripheral to Central. The PHY_C_To_P[i] + * parameter identifies the PHY to be used for transmission of packets + * from the Central to the Peripheral. The Host shall set only one bit in + * this parameter and the Controller shall use the PHY set by the Host. + * The PHY_P_To_C[i] parameter identifies the PHY to be used for + * transmission of packets from the Peripheral to the Central. The Host + * shall set only one bit in this parameter and the Controller shall use + * the PHY set by the Host. The BN_C_To_P[i] parameter identifies the + * burst number for Central to Peripheral (see [Vol 6] Part B, Section + * 4.5.13). If the CIS is unidirectional from Peripheral to Central, this + * parameter shall be set to zero. The BN_P_To_C[i] parameter identifies + * the burst number for Peripheral to Central (see [Vol 6] Part B, + * Section 4.5.13). If the CIS is unidirectional from Central to + * Peripheral, this parameter shall be set to zero. If the Status return + * parameter is non-zero, then the state of the CIG and its CIS + * configurations shall not be changed by the command. If the CIG did not + * already exist, it shall not be created. If the Status return parameter + * is zero, then the Controller shall set the Connection_Handle arrayed + * return parameter to the connection handle(s) corresponding to the CIS + * configurations specified in the CIS_IDs command parameter, in the same + * order. If the same CIS_ID is being reconfigured, the same connection + * handle shall be returned. If the Host issues this command when the CIG + * is not in the configurable state, the Controller shall return the + * error code Command Disallowed (0x0C). If the Host attempts to create a + * CIG or set parameters that exceed the maximum supported resources in + * the Controller, the Controller shall return the error code Memory + * Capacity Exceeded (0x07). If the Host attempts to set CIS parameters + * that exceed the maximum supported connections in the Controller, the + * Controller shall return the error code Connection Limit Exceeded + * (0x09). If the Host attempts to set an invalid combination of CIS + * parameters, the Controller shall return the error code Unsupported + * Feature or Parameter Value (0x11). If the Host sets, in the + * PHY_C_To_P[i] or PHY_P_To_C[i] parameters, a bit for a PHY that the + * Controller does not support, including a bit that is reserved for + * future use, the Controller shall return the error code Unsupported + * Feature or Parameter Value (0x11). If the Controller does not support + * asymmetric PHYs and the Host sets PHY_C_To_P[i] to a different value + * than PHY_P_To_C[i], the Controller shall return the error code + * Unsupported Feature or Parameter Value (0x11). + * @param CIG_ID Used to identify the CIG. + * Values: + * - 0x00 ... 0xEF + * @param SDU_Interval_C_To_P The interval, in microseconds, of periodic SDUs. + * Values: + * - 0x0000FF ... 0x0FFFFF + * @param SDU_Interval_P_To_C The interval, in microseconds, of periodic SDUs. + * Values: + * - 0x0000FF ... 0x0FFFFF + * @param FT_C_To_P The flush timeout in multiples of ISO_Interval for each + * payload sent from the Central to Peripheral. + * Values: + * - 0x01 ... 0xFF + * @param FT_P_To_C The flush timeout in multiples of ISO_Interval for each + * payload sent from the Peripheral to Central. + * Values: + * - 0x01 ... 0xFF + * @param ISO_Interval Time between consecutive CIS anchor points. Time = N * + * 1.25 ms + * Values: + * - 0x0004 (5.00 ms) ... 0x0C80 (4000.00 ms) + * @param Worst_Case_SCA Worst-case sleep clock accuracy of all the Peripherals. + * Values: + * - 0x00: 251 ppm to 500 ppm + * - 0x01: 151 ppm to 250 ppm + * - 0x02: 101 ppm to 150 ppm + * - 0x03: 76 ppm to 100 ppm + * - 0x04: 51 ppm to 75 ppm + * - 0x05: 31 ppm to 50 ppm + * - 0x06: 21 ppm to 30 ppm + * - 0x07: 0 ppm to 20 ppm + * @param Packing Preferred method of arranging subevents of multiple CISes. + * Values: + * - 0x00: Sequential + * - 0x01: Interleaved + * @param Framing Format of the CIS Data PDUs of the specified CISes. + * Values: + * - 0x00: Unframed + * - 0x01: Framed + * @param CIS_Count Total number of CIS configurations in the CIG being added or + * modified. + * Values: + * - 0x00 ... 0x1F + * @param CIS_Param_Test See @ref CIS_Param_Test_t + * @param[out] Connection_Handle Connection handle of the CIS in the CIG. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_cig_parameters_test(uint8_t CIG_ID, + uint8_t SDU_Interval_C_To_P[3], + uint8_t SDU_Interval_P_To_C[3], + uint8_t FT_C_To_P, + uint8_t FT_P_To_C, + uint16_t ISO_Interval, + uint8_t Worst_Case_SCA, + uint8_t Packing, + uint8_t Framing, + uint8_t CIS_Count, + CIS_Param_Test_t CIS_Param_Test[], + uint16_t Connection_Handle[]); +/** + * @brief The HCI_LE_Create_CIS command is used by the Central's Host to create + * one or more CISes using the connections identified by the + * ACL_Connection_Handle arrayed parameter. The CIS_Count parameter is + * the total number of CISes created by this command. The + * CIS_Connection_Handle[i] parameter specifies the connection handle + * corresponding to the configuration of the CIS to be created and whose + * configuration is already stored in a CIG. The ACL_Connection_Handle[i] + * parameter specifies the connection handle of the ACL connection + * associated with each CIS to be created. The list of the + * ACL_Connection_Handles shall be in the same order as the list of the + * CIS_Connection_Handles e.g., CIS_Connection_Handle[1] will connect to + * the Peripheral associated with the ACL_Connection_Handle[1]. If any + * ACL_Connection_Handle[i] is not the handle of an existing ACL + * connection or any CIS_Connection_Handle[i] is not the handle of a CIS + * or CIS configuration, the Controller shall return the error code + * Unknown Connection Identifier (0x02). If the Host attempts to create a + * CIS that has already been created, the Controller shall return the + * error code Connection Already Exists (0x0B). If two different elements + * of the CIS_Connection_Handle arrayed parameter identify the same CIS, + * the Controller shall return the error code Invalid HCI Command + * Parameters (0x12). If the Host issues this command before all the + * HCI_LE_CIS_Established events from the previous use of the command + * have been generated, the Controller shall return the error code + * Command Disallowed (0x0C). If the Host issues this command on an + * ACL_Connection_Handle where the Controller is the Peripheral, the + * Controller shall return the error code Command Disallowed (0x0C). + * Note: The order of the CIS connection handles in this command does not + * relate to the order of connection handles in the return parameters of + * the HCI_LE_Set_CIG_Parameters command or the + * HCI_LE_Set_CIG_Parameters_Test command. If the Host issues this + * command when the Connected Isochronous Stream (Host Support) feature + * bit (see [Vol 6] Part B, Section 4.6.27) is not set, the Controller + * shall return the error code Command Disallowed (0x0C). + * @param CIS_Count Total number of CISes to be created. + * Values: + * - 0x01 ... 0x1F + * @param CIS_Handles See @ref CIS_Handles_t + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_create_cis(uint8_t CIS_Count, + CIS_Handles_t CIS_Handles[]); +/** + * @brief The HCI_LE_Remove_CIG command is used by the Central's Host to remove + * the CIG identified by CIG_ID. The CIG_ID parameter contains the + * identifier of the CIG. This command shall delete the CIG_ID and also + * delete the Connection_Handles of the CIS configurations stored in the + * CIG. This command shall also remove the isochronous data paths that + * are associated with the Connection_Handles of the CIS configurations, + * which is equivalent to issuing the HCI_LE_Remove_ISO_Data_Path command + * (see Section 7.8.109). If the Host tries to remove a CIG which is in + * the active state, then the Controller shall return the error code + * Command Disallowed (0x0C). If the Host issues this command with a + * CIG_ID that does not exist, the Controller shall return the error code + * Unknown Connection Identifier (0x02). + * @param CIG_ID Identifier of a CIG. + * Values: + * - 0x00 ... 0xEF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_remove_cig(uint8_t CIG_ID); +/** + * @brief The HCI_LE_Accept_CIS_Request command is used by the Peripheral's Host + * to inform the Controller to accept the request for the CIS that is + * identified by the Connection_Handle. The command shall only be issued + * after an HCI_LE_CIS_Request event has occurred. The event contains the + * Connection_Handle of the CIS. If the Peripheral's Host issues this + * command with a Connection_Handle that does not exist, or the + * Connection_Handle is not for a CIS, the Controller shall return the + * error code Unknown Connection Identifier (0x02). If the Peripheral's + * Host issues this command with a Connection_Handle for a CIS that has + * already been established or that already has an + * HCI_LE_Accept_CIS_Request or HCI_LE_Reject_CIS_Request command in + * progress, the Controller shall return the error code Command + * Disallowed (0x0C). If the Central's Host issues this command, the + * Controller shall return the error code Command Disallowed (0x0C). + * @param Connection_Handle Connection handle of the CIS. + * Values: + * - 0x0000 ... 0x0EFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_accept_cis_request(uint16_t Connection_Handle); +/** + * @brief The HCI_LE_Reject_CIS_Request command is used by the Peripheral's Host + * to inform the Controller to reject the request for the CIS that is + * identified by the Connection_Handle. The command shall only be issued + * after an HCI_LE_CIS_Request event has occurred. The event contains the + * Connection_Handle of the CIS. When this command succeeds, the + * Controller shall delete the Connection_Handle of the requested CIS. + * The Reason command parameter indicates the reason for rejecting the + * CIS request. If the Peripheral's Host issues this command with a + * Connection_Handle that is not for a CIS, the Controller shall return + * the error code Unknown Connection Identifier (0x02). If the + * Peripheral's Host issues this command with a Connection_Handle for a + * CIS that has already been established or that already has an HCI_LE_- + * Accept_CIS_Request or HCI_LE_Reject_CIS_Request command in progress, + * the Controller shall return the error code Command Disallowed (0x0C). + * If the Central's Host issues this command, the Controller shall return + * the error code Command Disallowed (0x0C). + * @param Connection_Handle Reason the CIS request was rejected. See [Vol 1] + * Part F, Controller Error Codes for a list of error codes and + * descriptions. + * @param Reason Reason the CIS request was rejected. See [Vol 1] Part F, + * Controller Error Codes for a list of error codes and descriptions. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_reject_cis_request(uint16_t Connection_Handle, + uint8_t Reason); +/** + * @brief The HCI_LE_Create_BIG command is used to create a BIG with one or more + * BISes (see [Vol 6] Part B, Section 4.4.6). All BISes in a BIG have the + * same value for all parameters. The BIG_Handle contains the identifier + * of the BIG. This parameter is allocated by the Host and used by the + * Controller and the Host to identify a BIG. The Advertising_Handle + * identifies the associated periodic advertising train of the BIG (see + * [Vol 6] Part B, Section 4.4.5.1). The Num_BIS parameter contains the + * total number of BISes in the BIG. The SDU_Interval parameter contains + * the time interval of the periodic SDUs. The Max_SDU parameter contains + * the maximum size of an SDU. The Max_Transport_Latency parameter is the + * maximum transport latency (in milliseconds) as described in [Vol 6] + * Part G, Section 3.2.1 and [Vol 6] Part G, Section 3.2.2. This includes + * pre-transmissions. The RTN (Retransmission Number) parameter contains + * the number of times every PDU should be retransmitted, irrespective of + * which isochronous events the retransmissions occur in. This is a + * recommendation to the Controller which the Controller may ignore. The + * PHY parameter is a bit field that indicates the PHY used for + * transmission of PDUs of BISes in the BIG. The Host shall set at least + * one bit in this parameter and the Controller shall pick a PHY from the + * bits set. If the Host sets, in the PHY parameter, a bit for a PHY that + * the Controller does not support, including a bit that is reserved for + * future use, the Controller shall return the error code Unsupported + * Feature or Parameter Value (0x11). The Packing parameter is used to + * indicate the preferred method of arranging subevents of multiple + * BISes. The subevents can be arranged in Sequential or Interleaved + * arrangement. This is a recommendation to the Controller which it may + * ignore. This parameter shall be ignored when there is only one BIS in + * the BIG. The Framing parameter indicates the format for sending BIS + * Data PDUs. If the Framing parameter is set to 1 then BIS Data PDUs + * shall be Framed and when set to 0 they may be unframed (see [Vol 6] + * Part G, Section 1). The Encryption parameter identifies the encryption + * mode of the BISes. If the Encryption parameter is set to 1 + * (encrypted), the Broadcast_Code is used in the encryption of payloads + * (see [Vol 6] Part B, Section 4.4.6.10). The Broadcast_Code parameter + * is used to generate the encryption key for encrypting payloads of all + * BISes. When the Encryption parameter is set to 0 (unencrypted), the + * Broadcast_Code parameter shall be set to zero by the Host and ignored + * by the Controller. If the Controller cannot create all BISes of the + * BIG or if Num_BIS exceeds the maximum value supported by the + * Controller, it shall return the error code Connection Rejected due to + * Limited Resources (0x0D). If the Advertising_Handle does not identify + * a periodic advertising train or the periodic advertising train is + * associated with another BIG, the Controller shall return the error + * code Unknown Advertising Identifier (0x42). If the Host issues this + * command with a BIG_Handle for a BIG that is already created, the + * Controller shall return the error code Command Disallowed (0x0C). If + * the Host specifies an invalid combination of BIG parameters, the + * Controller shall return an error which should use the error code + * Unsupported Feature or Parameter Value (0x11). + * @param BIG_Handle Used to identify the BIG. + * Values: + * - 0x00 ... 0xEF + * @param Advertising_Handle Used to identify the periodic advertising train. + * Values: + * - 0x00 ... 0xEF + * @param Num_BIS Total number of BISes in the BIG. + * Values: + * - 0x01 ... 0x1F + * @param SDU_Interval The interval, in microseconds, of periodic SDUs. + * Values: + * - 0x0000FF ... 0x0FFFFF + * @param Max_SDU Maximum size of an SDU, in octets. + * Values: + * - 0x0001 ... 0x0FFF + * @param Max_Transport_Latency Maximum transport latency, in milliseconds. + * Values: + * - 0x0005 ... 0x0FA0 + * @param RTN The number of times that every BIS Data PDU should be + * retransmitted. + * Values: + * - 0x00 ... 0x1E + * @param PHY Transmitter PHY of packets. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Packing Used to indicate the preferred method of arranging subevents + * of multiple BISes. + * Values: + * - 0x00: Sequential + * - 0x01: Interleaved + * @param Framing The format for sending BIS Data PDUs. + * Values: + * - 0x00: Unframed + * - 0x01: Framed + * @param Encryption The encryption mode of the BISes. + * Values: + * - 0x00: Unencrypted + * - 0x01: Encrypted + * @param Broadcast_Code 128-bit code used for deriving the session key for + * decrypting payloads of BISes in the BIG. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_create_big(uint8_t BIG_Handle, + uint8_t Advertising_Handle, + uint8_t Num_BIS, + uint8_t SDU_Interval[3], + uint16_t Max_SDU, + uint16_t Max_Transport_Latency, + uint8_t RTN, + uint8_t PHY, + uint8_t Packing, + uint8_t Framing, + uint8_t Encryption, + uint8_t Broadcast_Code[16]); +/** + * @brief The HCI_LE_Create_BIG_Test command should only be used for testing + * purposes. The command is used to create one or more BISes of a BIG. + * All BISes in the BIG have the same values for all parameters. + * @param BIG_Handle Used to identify the BIG. + * Values: + * - 0x00 ... 0xEF + * @param Advertising_Handle Used to identify the periodic advertising train. + * Values: + * - 0x00 ... 0xEF + * @param Num_BIS Total number of BISes in the BIG. + * Values: + * - 0x01 ... 0x1F + * @param SDU_Interval The interval, in microseconds, of periodic SDUs. + * Values: + * - 0x0000FF ... 0x0FFFFF + * @param ISO_Interval The time between consecutive BIG anchor points. Time = N + * * 1.25 ms Time Range: 5 ms to 4 s + * Values: + * - 0x0004 (5.00 ms) ... 0x0C80 (4000.00 ms) + * @param NSE The total number of subevents in each interval of each BIS in the + * BIG. + * Values: + * - 0x01 ... 0x1F + * @param Max_SDU Maximum size of an SDU, in octets. + * Values: + * - 0x0001 ... 0x0FFF + * @param Max_PDU Maximum size, in octets, of payload + * Values: + * - 0x0001 ... 0x00FB + * @param PHY Transmitter PHY of packets. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Packing Used to indicate the preferred method of arranging subevents + * of multiple BISes. + * Values: + * - 0x00: Sequential + * - 0x01: Interleaved + * @param Framing The format for sending BIS Data PDUs. + * Values: + * - 0x00: Unframed + * - 0x01: Framed + * @param BN The number of new payloads in each interval for each BIS. + * Values: + * - 0x01 ... 0x07 + * @param IRC The number of times the scheduled payload(s) are transmitted in a + * given event. + * Values: + * - 0x01 ... 0x0F + * @param PTO Offset used for pre-transmissions. + * Values: + * - 0x00 ... 0x0F + * @param Encryption The encryption mode of the BISes. + * Values: + * - 0x00: Unencrypted + * - 0x01: Encrypted + * @param Broadcast_Code 128-bit code used for deriving the session key for + * decrypting payloads of BISes in the BIG. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_create_big_test(uint8_t BIG_Handle, + uint8_t Advertising_Handle, + uint8_t Num_BIS, + uint8_t SDU_Interval[3], + uint16_t ISO_Interval, + uint8_t NSE, + uint16_t Max_SDU, + uint16_t Max_PDU, + uint8_t PHY, + uint8_t Packing, + uint8_t Framing, + uint8_t BN, + uint8_t IRC, + uint8_t PTO, + uint8_t Encryption, + uint8_t Broadcast_Code[16]); +/** + * @brief The HCI_LE_Terminate_BIG command is used to terminate a BIG identified + * by the BIG_Handle parameter. The command also terminates the + * transmission of all BISes of the BIG, destroys the associated + * connection handles of the BISes in the BIG and removes the data paths + * for all BISes in the BIG. + * @param BIG_Handle Used to identify the BIG. + * Values: + * - 0x00 ... 0xEF + * @param Reason Reason for disconnection. See Error Codes. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_terminate_big(uint8_t BIG_Handle, + uint8_t Reason); +/** + * @brief The HCI_LE_BIG_Create_Sync command is used to synchronize to a BIG + * described in the periodic advertising train specified by the + * Sync_Handle parameter. + * @param BIG_Handle Used to identify the BIG. + * Values: + * - 0x00 ... 0xEF + * @param Sync_Handle Identifier of the periodic advertising train. + * Values: + * - 0x0000 ... 0x00EF + * @param Encryption The encryption mode of the BIG. + * Values: + * - 0x00: Unencrypted + * - 0x01: Encrypted + * @param Broadcast_Code 128-bit code used for deriving the session key for + * decrypting payloads of BISes in the BIG. + * @param MSE The MSE (Maximum Subevents) parameter is the maximum number of + * subevents that a Controller should use to receive data payloads in + * each interval for a BIS. The Host should set MSE to reduce the maximum + * continuous radio receiving time for a Synchronized Receiver with + * limited battery capacity. + * Values: + * - 0x00: Any number of subevents + * - 0x01 ... 0x1F + * @param BIG_Sync_Timeout The BIG_Sync_Timeout parameter specifies the maximum + * permitted time between successful receptions of BIS PDUs. If this time + * is exceeded, synchronization is lost. When the Controller establishes + * synchronization and if the BIG_Sync_Timeout set by the Host is less + * than 6 * ISO_Interval, the Controller shall set the timeout to 6 * + * ISO_Interval. + * Values: + * - 0x000A (100 ms) ... 0x4000 (163840 ms) + * @param Num_BIS Total number of BISes to synchronize. + * Values: + * - 0x01 ... 0x1F + * @param BIS List of indices of BISes. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_big_create_sync(uint8_t BIG_Handle, + uint16_t Sync_Handle, + uint8_t Encryption, + uint8_t Broadcast_Code[16], + uint8_t MSE, + uint16_t BIG_Sync_Timeout, + uint8_t Num_BIS, + uint8_t BIS[]); +/** + * @brief The HCI_LE_BIG_Terminate_Sync command is used to stop synchronizing or + * cancel the process of synchronizing to the BIG identified by the + * BIG_Handle parameter. The command also terminates the reception of + * BISes in the BIG specified in the HCI_LE_BIG_Create_Sync command, + * destroys the associated connection handles of the BISes in the BIG and + * removes the data paths for all BISes in the BIG. + * @param BIG_Handle Used to identify the BIG. + * Values: + * - 0x00 ... 0xEF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_big_terminate_sync(uint8_t BIG_Handle); +/** + * @brief This command is used to read the Sleep Clock Accuracy (SCA) of the + * peer device. The Connection_Handle parameter is the connection handle + * of the ACL connection. If the Host sends this command with a + * Connection_Handle that does not exist, or the Connection_Handle is not + * for an ACL the Controller shall return the error code Unknown + * Connection Identifier (0x02). If the Host sends this command and the + * peer device does not support the Sleep Clock Accuracy Updates feature, + * the Controller shall return the error code Unsupported Feature or + * Parameter Value (0x11) in the HCI_LE_Request_Peer_SCA_Complete event. + * If the Host issues this command when the Controller is aware (e.g., + * through a previous feature exchange) that the peer device's Link Layer + * does not support the Sleep Clock Accuracy Updates feature, the + * Controller shall return the error code Unsupported Remote Feature + * (0x1A). When the HCI_LE_Request_Peer_SCA command has completed, the + * HCI_LE_Request_Peer_SCA_Complete event shall be generated. + * @param Connection_Handle Connection handle of the ACL. + * Values: + * - 0x0000 ... 0x0EFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_request_peer_sca(uint16_t Connection_Handle); +/** + * @brief The HCI_LE_Setup_ISO_Data_Path command is used to identify and create + * the isochronous data path between the Host and the Controller for an + * established CIS or BIS identified by the Connection_Handle parameter. + * This command can also be used to configure a codec for each data path. + * @param Connection_Handle Connection handle of the CIS or BIS. + * Values: + * - 0x0000 ... 0x0EFF + * @param Data_Path_Direction The Data_Path_Direction parameter specifies the + * direction for which the data path is being configured. The input and + * output directions are defined from the perspective of the Controller, + * so "input" refers to data flowing from the Host to the Controller. + * Values: + * - 0x00: Input + * - 0x01: Output + * @param Data_Path_ID The Data_Path_ID parameter specifies the data transport + * path used. When set to 0x00, the data path shall be over the HCI + * transport. When set to 0xFF the path shall be disabled. When set to a + * value in the range 0x01 to 0xFE, the data path shall use a vendor- + * specific transport interface (e.g., a PCM interface) with logical + * transport numbers. The meanings of these logical transport numbers are + * vendor-specific. + * Values: + * - 0x00: HCI + * - 0x01 ... 0xFE + * - 0xFF: Disabled + * @param Codec_ID The Codec_ID parameter specifies the coding format used over + * the air. Octet 0: See Assigned Numbers for Coding Format. Octets 1 to + * 2: Company ID, see Assigned Numbers for Company Identifier. Shall be + * ignored if octet 0 is not 0xFF. Octets 3 to 4: Vendor-defined codec + * ID. Shall be ignored if octet 0 is not 0xFF. + * @param Controller_Delay Controller delay in microseconds. When + * Data_Path_Direction is set to 0x00 (input), the Controller_Delay + * parameter specifies the delay at the data source from the reference + * time of an SDU to the CIG reference point (see Bluetooth Core v5.2 + * [Vol 6] Part B, Section 4.5.14.1) or BIG anchor point (see Core v5.2 + * [Vol 6] Part B, Section 4.4.6.4). When Data_Path_Direction is set to + * 0x01 (output), Controller_Delay specifies the delay from the CIG + * synchronization point or BIG synchronization point to the point in + * time at which the Controller begins to transfer the corresponding data + * to the data path interface. + * Values: + * - 0x000000 ... 0x3D0900 + * @param Codec_Configuration_Length Length of codec configuration. + * @param Codec_Configuration The Codec_Configuration parameter specifies codec- + * specific configuration information for the specified direction. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_setup_iso_data_path(uint16_t Connection_Handle, + uint8_t Data_Path_Direction, + uint8_t Data_Path_ID, + uint8_t Codec_ID[5], + uint8_t Controller_Delay[3], + uint8_t Codec_Configuration_Length, + uint8_t Codec_Configuration[]); +/** + * @brief The HCI_LE_Remove_ISO_Data_Path command is used to remove the input + * and/or output data path(s) associated with a CIS or BIS identified by + * the Connection_Handle parameter. + * @param Connection_Handle Connection handle of the CIS or BIS. + * Values: + * - 0x0000 ... 0x0EFF + * @param Data_Path_Direction The Data_Path_Direction parameter specifies which + * directions are to have the data path removed. + * Flags: + * - 0x01: Input + * - 0x02: Output + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_remove_iso_data_path(uint16_t Connection_Handle, + uint8_t Data_Path_Direction); +/** + * @brief The HCI_LE_ISO_Transmit_Test command should only be used in the ISO + * Test mode and only for testing purposes. The command is used to + * configure an established CIS or BIS specified by the Connection_Handle + * parameter, and transmit test payloads which are generated by the + * Controller. When using this command for a CIS, the Host shall set up a + * CIG before invoking this command. When using this command for a BIS, + * the Host shall create the BIG before invoking this command. This + * command applies to all BISes in the BIG. + * @param Connection_Handle Connection handle of the CIS or BIS. + * Values: + * - 0x0000 ... 0x0EFF + * @param Payload_Type The Payload_Type parameter defines the configuration of + * SDUs in the payload. + * Values: + * - 0x00: ZERO_LENGTH_PAYLOAD + * - 0x01: VARIABLE_LENGTH_PAYLOAD + * - 0x02: MAXIMUM_LENGTH_PAYLOAD + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_iso_transmit_test(uint16_t Connection_Handle, + uint8_t Payload_Type); +/** + * @brief The HCI_LE_ISO_Receive_Test command should only be used in the ISO + * Test mode and only for testing purposes. The command is used to + * configure an established CIS or a synchronized BIG specified by the + * Connection_Handle parameter to receive payloads. When using this + * command for a BIS, the Host shall synchronize with a BIG using the + * HCI_LE_BIG_Create_Sync command before invoking this command. + * @param Connection_Handle Connection handle of the CIS or BIS. + * Values: + * - 0x0000 ... 0x0EFF + * @param Payload_Type The Payload_Type parameter defines the configuration of + * SDUs in the payload. + * Values: + * - 0x00: ZERO_LENGTH_PAYLOAD + * - 0x01: VARIABLE_LENGTH_PAYLOAD + * - 0x02: MAXIMUM_LENGTH_PAYLOAD + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_iso_receive_test(uint16_t Connection_Handle, + uint8_t Payload_Type); +/** + * @brief The HCI_LE_ISO_Read_Test_Counters command should only be used in the + * ISO Test mode and only for testing purposes. The command is used to + * read the test counters (see Core 5.2 [Vol 6] Part B, Section 7) in the + * Controller which is configured in ISO Receive Test mode for a CIS or + * BIS specified by the Connection_Handle. Reading the test counters does + * not reset the test counters. + * @param Connection_Handle Connection handle of the CIS or BIS. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] Received_Packet_Count Number in the Received_Packet_Count. + * @param[out] Missed_Packet_Count Number in the Missed_Packet_Count. + * @param[out] Failed_Packet_Count Number in the Failed_Packet_Count. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_iso_read_test_counters(uint16_t Connection_Handle, + uint32_t *Received_Packet_Count, + uint32_t *Missed_Packet_Count, + uint32_t *Failed_Packet_Count); +/** + * @brief The HCI_LE_ISO_Test_End command should only be used in the ISO Test + * mode and only for testing purposes. The command is used to terminate + * the ISO Transmit and/or Receive Test mode for a CIS or BIS specified + * by the Connection_Handle parameter but does not terminate the CIS or + * BIS. When the Host terminates the ISO Test mode for a CIS or BIS that + * is set to ISO Transmit Test mode only, the test counters in the return + * parameters shall be set to zero. When the Host terminates the ISO Test + * mode for a CIS or BIS that is set to the ISO Receive Test mode, the + * return parameters contain the values of the test counters as defined + * in [Vol 6] Part B, Section 7. + * @param Connection_Handle Connection handle of the CIS or BIS. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] Received_Packet_Count Number in the Received_Packet_Count. + * @param[out] Missed_Packet_Count Number in the Missed_Packet_Count. + * @param[out] Failed_Packet_Count Number in the Failed_Packet_Count. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_iso_test_end(uint16_t Connection_Handle, + uint32_t *Received_Packet_Count, + uint32_t *Missed_Packet_Count, + uint32_t *Failed_Packet_Count); +/** + * @brief The HCI_LE_Set_Host_Feature command is used by the Host to set or + * clear a bit controlled by the Host in the Link Layer FeatureSet stored + * in the Controller (see [Vol 6] Part B, Section 4.6). The Bit_Number + * parameter specifies the bit position in the FeatureSet. The Bit_Value + * parameter specifies whether the feature is enabled or disabled. If + * Bit_Number specifies a feature bit that is not controlled by the Host, + * the Controller shall return the error code Unsupported Feature or + * Parameter Value (0x11). If Bit_Value is set to 0x01 and Bit_Number + * specifies a feature bit that requires support of a feature that the + * Controller does not support, the Controller shall return the error + * code Unsupported Feature or Parameter Value (0x11). If the Host issues + * this command while the Controller has a connection to another device, + * the Controller shall return the error code Command Disallowed (0x0C). + * @param Bit_Number Bit position in the FeatureSet. + * Values: + * - 0x00 ... 0x3F + * @param Bit_Value If 0, the Host feature is disabled, if 1 the Host feature is + * enablded. + * Values: + * - 0x00: DISABLED + * - 0x01: ENABLED + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_host_feature(uint8_t Bit_Number, + uint8_t Bit_Value); +/** + * @brief This command returns the values of various counters related to link + * quality that are associated with the isochronous stream specified by + * the Connection_Handle parameter. This command may be issued on both + * the central and peripheral if the connection handle identifies a CIS + * and on the Synchronized Receiver if the connection handle identifies a + * BIS. + * @param Connection_Handle Connection handle of the CIS or BIS. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] Tx_UnACKed_Packets Value of the Tx_UnACKed_Packets counter. + * Incremented when the Link Layer does not receive an + * acknowledgment for a CIS Data PDU that it transmitted at least + * once by its flush point (see Core 5.2 [Vol 6] Part B, Section + * 4.5.13.5). + * @param[out] Tx_Flushed_Packets Value of the Tx_Flushed_Packets counter. + * Incremented when the Link Layer does not transmit a specific + * payload by its flush point. + * @param[out] Tx_Last_Subevent_Packets Value of the Tx_Last_Subevent_Packets + * counter. Incremented when the Link Layer transmits a CIS Data PDU + * in the last subevent of a CIS event. + * @param[out] Retransmitted_Packets Value of the Retransmitted_Packets counter. + * Incremented when the Link Layer retransmits a CIS Data PDU. + * @param[out] CRC_Error_Packets Value of the CRC_Error_Packets counter. + * Incremented when the Link Layer receives a packet with a CRC + * error. + * @param[out] Rx_Unreceived_Packets Value of the Rx_Unreceived_Packets counter. + * Incremented when the Link Layer does not receive a specific + * payload by its flush point (on a CIS) or the end of the event it + * is associated with (on a BIS; see Core v5.2 [Vol 6] Part B, + * Section 4.4.6.6). + * @param[out] Duplicate_Packets Value of the Duplicate_Packets counter. + * Incremented when the Link Layer receives a retransmission of a + * CIS Data PDU. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_iso_link_quality(uint16_t Connection_Handle, + uint32_t *Tx_UnACKed_Packets, + uint32_t *Tx_Flushed_Packets, + uint32_t *Tx_Last_Subevent_Packets, + uint32_t *Retransmitted_Packets, + uint32_t *CRC_Error_Packets, + uint32_t *Rx_Unreceived_Packets, + uint32_t *Duplicate_Packets); +/** + * @brief Read the current and maximum transmit power levels of the local + * Controller on the ACL connection identified by the Connection_Handle + * parameter and the PHY indicated by the PHY parameter. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param PHY PHY associated with the connection (not necessarily the currently + * used one). + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY_S8 + * - 0x04: LE_CODED_PHY_S2 + * @param[out] Current_Transmit_Power_Level Current TX power level (dBm). + * Values: + * - -127 ... 20 + * - 127: NA + * @param[out] Max_Transmit_Power_Level Maximum TX power level (dBm). + * Values: + * - -127 ... 20 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_enhanced_read_transmit_power_level(uint16_t Connection_Handle, + uint8_t PHY, + int8_t *Current_Transmit_Power_Level, + int8_t *Max_Transmit_Power_Level); +/** + * @brief Read the transmit power level used by the remote Controller on the ACL + * connection that is identified by the Connection_Handle parameter and + * the PHY indicated by the PHY parameter. Initiate a Power Control + * Request procedure to obtain the remote transmit power level if no + * prior value is available or used. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param PHY PHY associated with the connection (not necessarily the currently + * used one). + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY_S8 + * - 0x04: LE_CODED_PHY_S2 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_read_remote_transmit_power_level(uint16_t Connection_Handle, + uint8_t PHY); +/** + * @brief Set the path loss threshold reporting parameters for the ACL + * connection identified by the Connection_Handle parameter. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param High_Threshold High threshold for the path loss. Units: dB. + * Values: + * - 0 ... 254 + * - 255: UNUSED + * @param High_Hysteresis Hysteresis value for the high threshold. Units: dB. + * @param Low_Threshold Low threshold for the path loss. Units: dB. + * @param Low_Hysteresis Hysteresis value for the low threshold. Units: dB. + * @param Min_Time_Spent Minimum time in number of connection events to be + * observed once the path crosses the threshold before an event is + * generated. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_path_loss_reporting_parameters(uint16_t Connection_Handle, + uint8_t High_Threshold, + uint8_t High_Hysteresis, + uint8_t Low_Threshold, + uint8_t Low_Hysteresis, + uint16_t Min_Time_Spent); +/** + * @brief Enable or disable path loss reporting for the ACL connection + * identified by the Connection_Handle parameter. Initiate a new Power + * Control Request procedure to obtain the remote transmit power level if + * no prior value is available or used and no prior Power Control Request + * procedure has been initiated. Path loss reporting is disabled when the + * connection is first created. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Enable Enable (1) or disable (0) reportinig. + * Values: + * - 0x00: DISABLE + * - 0x01: ENABLE + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_path_loss_reporting_enable(uint16_t Connection_Handle, + uint8_t Enable); +/** + * @brief Enable or disable the reporting of transmit power level changes in the + * local and remote Controllers for the ACL connection identified by the + * Connection_Handle parameter. Initiate a new Power Control Request + * procedure to obtain the remote transmit power level if Remote_Enable + * is 0x01, and no prior value is available or used, and no prior Power + * Control Request procedure has been initiated. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Local_Enable Enable (1) or disable (0) local transmit power reports. + * Values: + * - 0x00: DISABLE + * - 0x01: ENABLE + * @param Remote_Enable Enable (1) or disable (0) remote transmit power reports. + * Values: + * - 0x00: DISABLE + * - 0x01: ENABLE + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_transmit_power_reporting_enable(uint16_t Connection_Handle, + uint8_t Local_Enable, + uint8_t Remote_Enable); +/** + * @brief The HCI_LE_Set_Data_Related_Address_Changes command specifies + * circumstances when the Controller shall refresh any Resolvable Private + * Address used by the advertising set identified by the + * Advertising_Handle parameter, whether or not the address timeout + * period has been reached. This command may be used while advertising is + * enabled. The Change_Reasons parameter specifies the reason(s) for + * refreshing addresses. The default when an advertising set is created, + * or if legacy advertising commands (see Section 3.1.1) are used, is for + * all bits to be clear. If extended advertising commands (see Section + * 3.1.1) are being used and the advertising set corresponding to the + * Advertising_Handle parameter does not exist, or if no command + * specified in Table 3.2 has been used, then the Controller shall return + * the error code Unknown Advertising Identifier (0x42). If legacy + * advertising commands are being used, the Controller shall ignore the + * Advertising_Handle parameter. + * @param Advertising_Handle Used to identify an advertising set. + * Values: + * - 0x00 ... 0xEF + * @param Change_Reasons Bitmap associated with the reasons to refresh the + * Resolvable Private Addresses used by the advertising set. If bit 0 is + * set, change the address whenever the advertising data changes. If bit + * 1 is set, change the address whenever the scan response data changes. + * Flags: + * - 0x01: ADV_DATA_CHANGES + * - 0x02: SCAN_RESP_DATA_CHANGES + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_data_related_address_changes(uint8_t Advertising_Handle, + uint8_t Change_Reasons); +/** + * @brief The HCI_LE_Set_Default_Subrate command is used by the Host to set the + * initial values for the acceptable parameters for subrating requests, + * as defined by the HCI_LE Subrate_Request command, for all future ACL + * connections where the Controller is the Central. This command does not + * affect any existing connection. The parameters have the same meanings + * and restrictions as those in the HCI_LE_Subrate_Request command. + * @param Subrate_Min Minimum subrate factor allowed in requests by a + * Peripheral. + * Values: + * - 0x0001 ... 0x01F4 + * @param Subrate_Max Maximum subrate factor allowed in requests by a + * Peripheral. + * Values: + * - 0x0001 ... 0x01F4 + * @param Max_Latency Maximum Peripheral latency allowed in requests by a + * Peripheral, in units of subrated connection intervals. + * Values: + * - 0x0000 ... 0x01F3 + * @param Continuation_Number Minimum number of underlying connection events to + * remain active after a packet containing a Link Layer PDU with a non- + * zero Length field is sent or received in requests by a Peripheral. + * Values: + * - 0x0000 ... 0x01F3 + * @param Supervision_Timeout Maximum supervision timeout allowed in requests by + * a Peripheral. Time = N x 10 ms. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_default_subrate(uint16_t Subrate_Min, + uint16_t Subrate_Max, + uint16_t Max_Latency, + uint16_t Continuation_Number, + uint16_t Supervision_Timeout); +/** + * @brief The HCI_LE_Subrate_Request command is used by a Central or a + * Peripheral to request a change to the subrating factor and/or other + * parameters (see Core Vol 6 Part B, Section 4.5.1) applied to an + * existing connection using the Connection Subrate Update procedure. The + * Subrate_Min and Subrate_Max parameters specify the range of acceptable + * subrating factors being requested. The Max_Latency parameter specifies + * the maximum Peripheral latency in units of subrated connection events. + * The same maximum shall apply irrespective of the subrating factor + * actually chosen. The Continuation_Number parameter specifies the + * number of underlying connection intervals to remain active after a + * packet (other than an empty packet) is transmitted or received. The + * Supervision_Timeout parameter specifies the link supervision timeout + * for the connection. The Supervision_Timeout, in milliseconds, shall be + * greater than 2 x current connection interval x Subrate_Max x + * (Max_Latency + 1). If this command is issued on the Central, the + * following rules shall apply when the Controller initiates the + * Connection Subrate Update procedure (see Core Vol 6 Part B, Section + * 5.1.19): * The Peripheral latency shall be less than or equal to + * Max_Latency. * The subrate factor shall be between Subrate_Min and + * Subrate_Max. * The continuation number shall be equal to the lesser of + * Continuation_- Number and (subrate factor - 1). * The connection + * supervision timeout shall be equal to Supervision_Timeout. If this + * command is issued on the Central, it also sets the acceptable + * parameters for requests from the Peripheral (see Core Vol 6 Part B, + * Section 5.1.20). The acceptable parameters set by this command + * override those provided via the HCI_LE_Set_Default_Subrate command or + * any values set by previous uses of this command on the same + * connection. If this command is issued on the Peripheral, the + * following rules shall apply when the Controller initiates the + * Connection Subrate Request procedure: * The Peripheral latency shall + * be less than or equal to Max_Latency. * The minimum and maximum + * subrate factors shall be between Subrate_Min and Subrate_Max. * The + * continuation number shall be equal to the lesser of + * Continuation_Number and (maximum subrate factor - 1). * The connection + * supervision timeout shall be equal to Supervision_Timeout. If the + * Connection_Handle parameter does not identify a current ACL + * connection, the Controller shall return the error code Unknown + * Connection Identifier (0x02). If the Host issues this command with + * parameters such that Subrate_Max x (Max_Latency + 1) is greater than + * 500 or the current connection interval x Subrate_ Max x (Max_Latency + + * 1) is greater than or equal to half the Supervision_ Timeout + * parameter, the Controller shall return the error code Invalid HCI + * Command Parameters (0x12). If the Host issues this command with + * Subrate_Max less than Subrate_Min, the Controller shall return the + * error code Invalid HCI Command Parameters (0x12). If the Host issues + * this command with Continuation_Number greater than or equal to + * Subrate_Max, then the Controller shall return the error code Invalid + * HCI Command Parameters (0x12). If the Central's Host issues this + * command when the Connection Subrating (Host Support) bit is not set in + * the Peripheral's FeatureSet, the Controller shall return the error + * code Unsupported Remote Feature (0x1A). + * @param Connection_Handle Connection handle of the ACL. + * Values: + * - 0x0000 ... 0x0EFF + * @param Subrate_Min Minimum subrate factor to be applied to the underlying + * connection interval. + * Values: + * - 0x0001 ... 0x01F4 + * @param Subrate_Max Maximum subrate factor to be applied to the underlying + * connection interval. + * Values: + * - 0x0001 ... 0x01F4 + * @param Max_Latency Maximum Peripheral latency for the connection in units of + * subrated connection intervals. + * Values: + * - 0x0000 ... 0x01F3 + * @param Continuation_Number Minimum number of underlying connection events to + * remain active after a packet containing a Link Layer PDU with a non- + * zero Length field is sent or received. + * Values: + * - 0x0000 ... 0x01F3 + * @param Supervision_Timeout Supervision timeout for this connection. Time = N + * x 10 ms. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_subrate_request(uint16_t Connection_Handle, + uint16_t Subrate_Min, + uint16_t Subrate_Max, + uint16_t Max_Latency, + uint16_t Continuation_Number, + uint16_t Supervision_Timeout); +/** + * @brief The LE_Set_Extended_Advertising_Parameters command is used by the Host + * to set the advertising parameters. The Advertising_Handle parameter + * identifies the advertising set whose parameters are being configured. + * The Advertising_Event_Properties parameter describes the type of + * advertising event that is being configured and its basic properties. + * The type shall be one supported by the Controller. + * @param Advertising_Handle The Advertising_Handle parameter identifies the + * advertising set whose parameters are being configured. + * Values: + * - 0x00 ... 0xEF + * @param Advertising_Event_Properties The Advertising_Event_Properties + * parameter describes the type of advertising event that is being + * configured and its basic properties. The type shall be one supported + * by the Controller. Bits: 0 Connectable advertising 1 Scannable + * advertising 2 Directed advertising 3 High Duty Cycle Directed + * Connectable advertising (<= 3.75 ms Advertising Interval) 4 Use legacy + * advertising PDUs 5 Omit advertiser's address from all PDUs ("anonymous + * advertising") 6 Include TxPower in the extended header of the + * advertising PDU + * Flags: + * - 0x0001: Connectable + * - 0x0002: Scannable + * - 0x0004: Directed + * - 0x0008: HDC Directed Connectable + * - 0x0010: Legacy + * - 0x0020: Anonymous + * - 0x0040: TxPower in ext header + * @param Primary_Advertising_Interval_Min Minimum advertising interval for + * undirected and low duty cycle directed advertising. Time = N * 0.625 + * ms; Time Range: 20 ms to 10,485.759375 s. + * Values: + * - 0x000020 (20.000 ms) ... 0xFFFFFF (10485759.375 ms) + * @param Primary_Advertising_Interval_Max Maximum advertising interval for + * undirected and low duty cycle directed advertising. Time = N * 0.625 + * ms; Time Range: 20 ms to 10,485.759375 s. + * Values: + * - 0x000020 (20.000 ms) ... 0xFFFFFF (10485759.375 ms) + * @param Primary_Advertising_Channel_Map The Primary_Advertising_Channel_Map is + * a bit field that indicates the advertising channels that shall be used + * when transmitting advertising packets. At least one channel bit shall + * be set in the Primary_Advertising_Channel_Map parameter. + * Flags: + * - 0x01: CH_37 + * - 0x02: CH_38 + * - 0x04: CH_39 + * @param Own_Address_Type The Own_Address_Type parameter specifies the type of + * address being used in the advertising packets. For random addresses, + * the address is specified by the LE_Set_Advertising_Set_Random_Address + * command. 0x00 Public Device Address 0x01 Random Device Address 0x02 + * Controller generates the Resolvable Private Address based on the local + * IRK from the resolving list. If the resolving list contains no + * matching entry, use the public address. 0x03 Controller generates the + * Resolvable Private Address based on the local IRK from the resolving + * list. If the resolving list contains no matching entry, use the random + * address from LE_Set_Advertising_Set_Random_Address. All other values + * Reserved for future use + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Resolvable Private Address / Public Address + * - 0x03: Resolvable Private Address / Random Address + * @param Peer_Address_Type Peer Address type + * Values: + * - 0x00: Public Device Address or Public Identity Address + * - 0x01: Random Device Address or Random (static) Identity Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address, or Random (static) Identity Address of the device to + * be connected. + * @param Advertising_Filter_Policy Advertising Filter Policy. This parameter is + * ignored when directed advertising is enabled. 0x00 Process scan and + * connection requests from all devices (i.e., the Filter Accept List is + * not in use) 0x01 Process connection requests from all devices and scan + * requests only from devices that are in the Filter Accept List 0x02 + * Process scan requests from all devices and connection requests only + * from devices that are in the Filter Accept List. 0x03 Process scan and + * connection requests only from devices in the Filter Accept List. All + * other values are reserved for future use + * Values: + * - 0x00: HCI_ADV_FILTER_NONE + * - 0x01: HCI_ADV_FILTER_ACCEPT_LIST_SCAN + * - 0x02: HCI_ADV_FILTER_ACCEPT_LIST_CONNECT + * - 0x03: HCI_ADV_FILTER_ACCEPT_LIST_SCAN_CONNECT + * @param Advertising_Tx_Power Units: dBm The Advertising_Tx_Power parameter + * indicates the maximum power level at which the advertising packets are + * to be transmitted on the advertising channels. The Controller shall + * choose a power level lower than or equal to the one specified by the + * Host. + * Values: + * - -127 ... 126 + * - 127: No preference + * @param Primary_Advertising_PHY The Primary_Advertising_PHY parameter + * indicates the PHY on which the advertising packets are transmitted on + * the primary advertising channel. If legacy advertising PDUs are being + * used, the Primary_Advertising_PHY shall indicate the LE 1M PHY. + * Values: + * - 0x01: LE_1M_PHY + * - 0x03: LE_CODED_PHY + * @param Secondary_Advertising_Max_Skip The Secondary_Advertising_Max_Skip + * parameter is the maximum number of advertising events that can be + * skipped before the AUX_ADV_IND can be sent. 0x00 AUX_ADV_IND shall be + * sent prior to the next advertising event 0x01-0xFF Maximum advertising + * events the Controller can skip before sending the AUX_ADV_IND packets + * on the secondary advertising channel + * Values: + * - 0x00 ... 0xFF + * @param Secondary_Advertising_PHY The Secondary_Advertising_PHY parameter + * indicates the PHY on which the advertising packets are transmitted on + * the secondary advertising channel. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + * @param Advertising_SID The Advertising_SID parameter specifies the value to + * be transmitted in the Advertising SID subfield of the ADI field of the + * Extended Header of those advertising channel PDUs that have an ADI + * field. If the advertising set only uses PDUs that do not contain an + * ADI field, Advertising_SID is ignored. + * Values: + * - 0x00 ... 0x0F + * @param Scan_Request_Notification_Enable The Scan_Request_Notification_Enable + * parameter indicates whether the Controller shall send notifications + * upon the receipt of a scan request PDU that is in response to an + * advertisement from the specified advertising set that contains its + * device address and is from a scanner that is allowed by the + * advertising filter policy. + * Values: + * - 0x00: Scan request notifications disabled + * - 0x01: Scan request notifications enabled + * @param Primary_Advertising_PHY_Options Preference or requirements on coding + * scheme when transmitting on Primary Advertising Physical Channel. + * Values: + * - 0x00: CODED_PHY_NO_PREFERENCE + * - 0x01: CODED_PHY_S2_PREFERRED + * - 0x02: CODED_PHY_S8_PREFERRED + * - 0x03: CODED_PHY_S2_REQUIRED + * - 0x04: CODED_PHY_S8_REQUIRED + * @param Secondary_Advertising_PHY_Options Preference or requirements on coding + * scheme when transmitting on Secondary Advertising Physical Channel. + * Values: + * - 0x00: CODED_PHY_NO_PREFERENCE + * - 0x01: CODED_PHY_S2_PREFERRED + * - 0x02: CODED_PHY_S8_PREFERRED + * - 0x03: CODED_PHY_S2_REQUIRED + * - 0x04: CODED_PHY_S8_REQUIRED + * @param[out] Selected_Tx_Power Units: dBm. The Selected_Tx_Power return + * parameter indicates the transmit power selected by the + * Controller. The Controller shall not change the transmit power + * for this advertising set without being directed to by the Host. + * Values: + * - -127 ... 126 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_extended_advertising_parameters_v2(uint8_t Advertising_Handle, + uint16_t Advertising_Event_Properties, + uint8_t Primary_Advertising_Interval_Min[3], + uint8_t Primary_Advertising_Interval_Max[3], + uint8_t Primary_Advertising_Channel_Map, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable, + uint8_t Primary_Advertising_PHY_Options, + uint8_t Secondary_Advertising_PHY_Options, + int8_t *Selected_Tx_Power); +/** + * @brief The HCI_LE_Set_Periodic_Sync_Subevent command is used to instruct the + * Controller to synchronize with a subset of the subevents within a PAwR + * train identified by the Sync_Handle parameter, listen for packets sent + * by the peer device and pass any received data up to the Host. If the + * Controller is synchronized with any subevents that are not in the + * subset of subevents in this command, then the Controller shall no + * longer synchronize with those subevents. The + * Periodic_Advertising_Properties parameter indicates which fields + * should be included in the AUX_SYNC_SUBEVENT_RSP PDUs. The + * Num_Subevents parameter identifies the number of values in the + * subevents parameter. The Subevents arrayed parameter identifies the + * subevents that the Controller shall synchronize with. + * @param Sync_Handle Sync_Handle identifying the PAwR train. + * Values: + * - 0x0000 ... 0x0EFF + * @param Periodic_Advertising_Properties If bit 6 is set, include TxPower in + * the advertising PDU. + * Flags: + * - 0x0040: TX_POWER + * @param Num_Subevents Number of subevent data in the command. + * Values: + * - 0x01 ... 0x0F + * @param Subevent The subevent to synchronize with. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_periodic_sync_subevent(uint16_t Sync_Handle, + uint16_t Periodic_Advertising_Properties, + uint8_t Num_Subevents, + uint8_t Subevent[]); +/** + * @brief The LE_Extended_Create_Connection command is used to create a Link + * Layer connection to a connectable advertiser. + * LE_Extended_Create_Connection command can be used in place of + * LE_Create_Connection command. + * @param Advertising_Handle Advertising_Handle identifying the periodic + * advertising train. + * Values: + * - 0x00 ... 0xEF + * - 0xFF: Not specified + * @param Subevent Subevent where the connection request is to be sent. + * Values: + * - 0x00 ... 0x7F + * - 0xFF: Not specified + * @param Initiator_Filter_Policy The Initiator_Filter_Policy parameter is used + * to determine whether the Filter Accept List is used. If the Filter + * Accept List is not used, the Peer_Address_Type and the Peer_Address + * parameters specify the address type and address of the advertising + * device to connect to. 0x00 - Filter Accept List is not used to + * determine which advertiser to connect to. Peer_Address_Type and + * Peer_Address shall be used. 0x01 - Filter Accept List is used to + * determine which advertiser to connect to. Peer_Address_Type and + * Peer_Address shall be ignored. + * Values: + * - 0x00: FILTER_ACCEPT_LIST_NOT_USED + * - 0x01: FILTER_ACCEPT_LIST_USED + * @param Own_Address_Type The Own_Address_Type parameter indicates the type of + * address being used in the connection request packets. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Controller generates the Resolvable Private Address based on the local +IRK from the resolving list. If the resolving list contains no matching +entry, then use the public address. + * - 0x03: Controller generates the Resolvable Private Address based on the local +IRK from the resolving list. If the resolving list contains no matching +entry, then use the random address from the most recent successful +LE_Set_Random_Address Command. + * @param Peer_Address_Type The Peer_Address_Type parameter indicates the type + * of address used in the connectable advertisement sent by the peer. + * 0x00: Public Device Address or Public Identity Address 0x01: Random + * Device Address or Random (static) Identity Address + * Values: + * - 0x00: Public Address + * - 0x01: Random Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address, or Random (static) Identity Address of the device to + * be connected. + * @param Initiating_PHYs The Initiating_PHYs parameter indicates the PHY(s) on + * which the advertising packets should be received on the primary + * advertising channel and the PHYs for which connection parameters have + * been specified. The Host may enable one or more initiating PHYs. 0x01: + * Scan connectable advertisements on the LE 1M PHY. Connection + * parameters for the LE 1M PHY are provided. 0x02: Connection parameters + * for the LE 2M PHY are provided 0x04: Scan connectable advertisements + * on the LE Coded PHY. Connection parameters for the LE Coded PHY are + * provided. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Extended_Create_Connection_Parameters See @ref + * Extended_Create_Connection_Parameters_t + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_extended_create_connection_v2(uint8_t Advertising_Handle, + uint8_t Subevent, + uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Initiating_PHYs, + Extended_Create_Connection_Parameters_t Extended_Create_Connection_Parameters[]); +/** + * @brief The HCI_LE_Set_Periodic_Advertising_Parameters command is used by the + * Host to set the parameters for periodic advertising. The + * Advertising_Handle parameter identifies the advertising set whose + * periodic advertising parameters are being configured. If the + * corresponding advertising set does not already exist, then the + * Controller shall return the error code Unknown Advertising Identifier + * (0x42). The Periodic_Advertising_Interval_Min parameter shall be less + * than or equal to the Periodic_Advertising_Interval_Max parameter. The + * Periodic_Advertising_- Interval_Min and + * Periodic_Advertising_Interval_Max parameters should not be the same + * value to enable the Controller to determine the best advertising + * interval given other activities. If the periodic advertising interval + * range provided by the Host (Periodic_Advertising_Interval_Min, + * Periodic_Advertising_Interval_Max) does not overlap with the periodic + * advertising interval range supported by the Controller, then the + * Controller shall return an error which should use the error code + * Unsupported Feature or Parameter Value (0x11). The + * Periodic_Advertising_Properties parameter indicates which fields + * should be included in the advertising packet. The Num_Subevents + * parameter identifies the number of subevents that shall be transmitted + * for each periodic advertising event. If the Num_Subevents parameter + * value is 0x00, then the Subevent_Interval, Response_Slot_Delay, + * Response_Slot_Spacing, and Num_Response_Slots parameters shall be + * ignored. The Subevent_Interval parameter identifies the time between + * the subevents of PAwR. The Subevent_Interval shall be less than or + * equal to the Periodic_Advertising_Interval_Min divided by the + * Num_Subevents of the advertising set. The Response_Slot_Delay + * parameter identifies the time between the start of the advertising + * packet at the start of a subevent and the start of the first response + * slot. The Response_Slot_Delay shall be less than the + * Subevent_Interval. The Response_Slot_Spacing parameter identifies the + * time between the start of two consecutive response slots. The + * Response_Slot_Spacing shall be less than or equal to 10 x + * (Subevent_Interval - Response_Slot_Delay) / Num_Response_Slots. If the + * Num_Response_Slots parameter is set to 1, then the Controller shall + * ignore the Response_Slot_Spacing parameter. The Num_Response_Slots + * parameter identifies the number of response slots in a subevent. If + * the Num_Response_Slots parameter value is 0x00, then the + * Response_Slot_Delay and Response_Slot_Spacing parameters shall be + * ignored. If the advertising set identified by the Advertising_Handle + * specified scannable, connectable, legacy, or anonymous advertising, + * the Controller shall return the error code Invalid HCI Command + * Parameters (0x12). If the Host issues this command when periodic + * advertising is enabled for the specified advertising set, the + * Controller shall return the error code Command Disallowed (0x0C). If + * the Advertising_Handle does not identify an advertising set that is + * already configured for periodic advertising and the Controller is + * unable to support more periodic advertising at present, the Controller + * shall return the error code Memory Capacity Exceeded (0x07). If the + * advertising set already contains periodic advertising data and the + * length of the data is greater than the maximum that the Controller can + * transmit within a periodic advertising interval of + * Periodic_Advertising_Interval_Max, the Controller shall return the + * error code Packet Too Long (0x45). If advertising on the LE Coded PHY, + * the S=8 coding shall be assumed unless the current advertising + * parameters require the use of S=2 for an advertising physical channel, + * in which case the S=2 coding shall be assumed for that advertising + * physical channel. + * @param Advertising_Handle Used to identify a periodic advertising train. + * Values: + * - 0x00 ... 0xEF + * @param Periodic_Advertising_Interval_Min Minimum advertising interval for + * periodic advertising. Time = N * 1.25 ms; Time Range: 7.5ms to + * 81.91875 s. + * Values: + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + * @param Periodic_Advertising_Interval_Max Maximum advertising interval for + * periodic advertising. Time = N * 1.25 ms; Time Range: 7.5ms to + * 81.91875 s. + * Values: + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + * @param Periodic_Advertising_Properties The Periodic_Advertising_Properties + * parameter indicates which fields should be included in the advertising + * packet. + * Flags: + * - 0x0040 + * @param Num_Subevents Number of subevents. + * Values: + * - 0x00 ... 0x80 + * @param Subevent_Interval Interval between subevents. Time = N x 1.25 ms. + * Values: + * - 0x06 (7.50 ms) ... 0xFF (318.75 ms) + * @param Response_Slot_Delay Time between the advertising packet in a subevent + * and the first response slot. Time = N x 1.25 ms. + * Values: + * - 0x00 (NaN) : No response slots + * - 0x01 (1.25 ms) ... 0xFE (317.50 ms) + * @param Response_Slot_Spacing Time between response slots. Time = N x 0.125 ms + * Values: + * - 0x00 (0.000 ms) : No response slots + * - 0x02 (0.250 ms) ... 0xFF (31.875 ms) + * @param Num_Response_Slots Number of subevent response slots. + * Values: + * - 0x00 ... 0xFF + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_set_periodic_advertising_parameters_v2(uint8_t Advertising_Handle, + uint16_t Periodic_Advertising_Interval_Min, + uint16_t Periodic_Advertising_Interval_Max, + uint16_t Periodic_Advertising_Properties, + uint8_t Num_Subevents, + uint8_t Subevent_Interval, + uint8_t Response_Slot_Delay, + uint8_t Response_Slot_Spacing, + uint8_t Num_Response_Slots); +/** + * @brief API used to send HCI ACL Data Packets to exchange data between the Host and Controller. + * + * @note The API name is only available in link layer only mode. + * + * @param Connection_Handle Connection handle for which the command is given. Range: 0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use) + * @param PB_Flag Packet boundary flag + * @param BC_Flag Broadcast flag + * @param Data_Length Length of PDU data in octets. + * @param[in] PDU_Data PDU data pointer + * + * @return Error code + */ +tBleStatus hci_tx_acl_data(uint16_t Connection_Handle, + uint8_t PB_Flag, + uint8_t BC_Flag, + uint16_t Data_Length, + uint8_t* PDU_Data); +/** +* @brief Function to send isochronous data to the Controller. + * + * @param Connection_Handle Connection handle. Range: 0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use) + * @param PB_Flag Packet boundary flag + * @param TS_Flag Timestamp flag. Set if the ISO_Data_Load field contains a Time_Stamp field. + * @param ISO_Data_Load_Length Length of ISO_Data_Load in octets. + * @param[in] ISO_Data_Load The format of the ISO_Data_Load is described in Core v5.3 Vol. 4, part E, section 5.4.5 + * + * @return Error code + */ +tBleStatus hci_tx_iso_data(uint16_t Connection_Handle, + uint8_t PB_Flag, + uint8_t TS_Flag, + uint16_t ISO_Data_Load_Length, + uint8_t *ISO_Data_Load); +/** + * @} + */ + +/** + * @} + */ + + +/** + *@addtogroup HCI HCI + *@brief Host Controller Interface. + *@{ + */ +/** + *@defgroup HCI_Test_Commands HCI Test Commands + *@brief Standard HCI commands for testing. + *@{ + */ +/** + * @brief This command is used to start a test where the DUT receives test + * reference packets at a fixed interval. The tester generates the test + * reference packets. (See Bluetooth Specification v.4.1, Vol. 2, Part E, + * 7.8.28) + * @param RX_Frequency + * Values: + * - 0x00 ... 0x27: N = (F - 2402) / 2.Frequency Range : 2402 MHz to 2480 MHz + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_receiver_test(uint8_t RX_Frequency); +/** + * @brief This command is used to start a test where the DUT generates test + * reference packets at a fixed interval. The Controller shall transmit + * at maximum power. An LE Controller supporting the LE_Transmitter_Test + * command shall support Packet_Payload values 0x00, 0x01 and 0x02. An LE + * Controller may support other values of Packet_Payload. (See Bluetooth + * Specification v.4.1, Vol. 2, Part E, 7.8.29) + * @param TX_Frequency N = (F - 2402) / 2. Frequency Range : 2402 MHz to 2480 + * MHz + * Values: + * - 0x00 ... 0x27 + * @param Length_Of_Test_Data Length in bytes of payload data in each packet. + * Supported ranges: - (0x00,0x25) if data length extension is + * disabled. - (0x00,0xFF) if data length extension is enabled. + * Values: + * - 0x00 ... 0xFF + * @param Packet_Payload Content of the Payload of the test reference packets. + * 0: PRBS9 sequence '11111111100000111101...' (in transmission order) 1: + * Repeated '11110000' (in transmission order) sequence 2: Repeated + * '10101010' (in transmission order) sequence 3: PRBS15 sequence 4: + * Repeated '11111111' (in transmission order) sequence 5: Repeated + * '00000000' (in transmission order) sequence 6: Repeated '00001111' (in + * transmission order) sequence 7: Repeated '01010101' (in transmission + * order) sequence + * Values: + * - 0x00: PRBS9 + * - 0x01: Repeated '11110000' + * - 0x02: Repeated '10101010' + * - 0x03: PRBS15 + * - 0x04: Repeated '11111111' + * - 0x05: Repeated '00000000' + * - 0x06: Repeated '00001111' + * - 0x07: Repeated '01010101' + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_transmitter_test(uint8_t TX_Frequency, + uint8_t Length_Of_Test_Data, + uint8_t Packet_Payload); +/** + * @brief This command is used to stop any test which is in progress. The + * Number_Of_Packets for a transmitter test shall be reported as 0x0000. + * The Number_Of_Packets is an unsigned number and contains the number of + * received packets. (See Bluetooth Specification v.4.1, Vol. 2, Part E, + * 7.8.30) + * @param[out] Number_Of_Packets Number of packets received. + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_test_end(uint16_t *Number_Of_Packets); +/** + * @brief This command is used to start a test where the DUT receives test + * reference packets at a fixed interval. The tester generates the test + * reference packets. + * @param RX_Channel Frequency Range : 2402 MHz to 2480 MHz N = (F - 2402) / 2. + * Values: + * - 0x00 ... 0x27: Frequency Range : 2402 MHz to 2480 MHz + * @param PHY PHY to be used by the receiver. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + * @param Modulation_index The Modulation_Index parameter specifies whether or + * not the Controller should assume the receiver has a stable modulation + * index. + * Values: + * - 0x00: Standard modulation index + * - 0x01: Stable modulation index + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_receiver_test_v2(uint8_t RX_Channel, + uint8_t PHY, + uint8_t Modulation_index); +/** + * @brief This command is used to start a test where the DUT generates test + * reference packets at a fixed interval. The Controller shall transmit + * at maximum power. An LE Controller supporting the LE_Enhanced + * Transmitter_Test command shall support Packet_Payload values 0x00, + * 0x01 and 0x02. An LE Controller supporting the LE Coded PHY shall also + * support Packet_Payload value 0x04. An LE Controller may support other + * values of Packet_Payload. + * @param TX_Channel Frequency Range: 2402 MHz to 2480 MHz N = (F-2402) / 2 + * Values: + * - 0x00 ... 0x27: Frequency Range: 2402 MHz to 2480 MHz + * @param Length_Of_Test_Data Length in bytes of payload data in each packet. + * Supported ranges: - (0x00,0x25) if data length extension is + * disabled. - (0x00,0xFF) if data length extension is enabled. + * Values: + * - 0x00 ... 0xFF + * @param Packet_Payload Content of the Payload of the test reference packets. + * 0: PRBS9 sequence '11111111100000111101...' (in transmission order) 1: + * Repeated '11110000' (in transmission order) sequence 2: Repeated + * '10101010' (in transmission order) sequence 3: PRBS15 sequence 4: + * Repeated '11111111' (in transmission order) sequence 5: Repeated + * '00000000' (in transmission order) sequence 6: Repeated '00001111' (in + * transmission order) sequence 7: Repeated '01010101' (in transmission + * order) sequence + * Values: + * - 0x00: PRBS9 + * - 0x01: Repeated '11110000' + * - 0x02: Repeated '10101010' + * - 0x03: PRBS15 + * - 0x04: Repeated '11111111' + * - 0x05: Repeated '00000000' + * - 0x06: Repeated '00001111' + * - 0x07: Repeated '01010101' + * @param PHY PHY to be used by the transmitter. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY_S8 + * - 0x04: LE_CODED_PHY_S2 + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_transmitter_test_v2(uint8_t TX_Channel, + uint8_t Length_Of_Test_Data, + uint8_t Packet_Payload, + uint8_t PHY); +/** + * @brief This command is used to start a test where the DUT receives test + * reference packets at a fixed interval. The tester generates the test + * reference packets. The RX_Channel and PHY parameters specify the RF + * channel and PHY to be used by the receiver. If the Host sets the PHY + * parameter to a PHY that the Controller does not support, including a + * value that is reserved for future use, the Controller shall return the + * error code Unsupported Feature or Parameter Value (0x11). The + * Modulation_Index parameter specifies whether or not the Controller + * should assume the receiver has a stable modulation index. The + * Expected_CTE_Length and Expected_CTE_Type parameters specify the + * expected length and type of the Constant Tone Extensions in received + * test reference packets. When receiving on a PHY that allows Constant + * Tone Extensions, if the Constant Tone Extension in a received test + * reference packet does not match both of these, the DUT shall discard + * that packet. If Expected_CTE_Length is not zero and PHY specifies a + * PHY that does not allow Constant Tone Extensions, the Controller shall + * return the error code Command Disallowed (0x0C). If the Slot_Durations + * parameter is set to 0x01 and the Controller does not support 1 + * microsecond switching and sampling, the Controller shall return the + * error code Unsupported Feature or Parameter Value (0x11). + * Slot_Durations, Switching_Pattern_Length, and Antenna_IDs[i] are only + * used when expecting an AoA Constant Tone Extension and shall be + * ignored when expecting an AoD Constant Tone Extension. If the + * Controller determines that any of the Antenna_IDs[i] values do not + * identify an antenna in the device's antenna array, it shall return the + * error code Unsupported Feature or Parameter Value (0x11). Note: Some + * Controllers may be unable to determine which values do or do not + * identify an antenna. + * @param RX_Channel + * Values: + * - 0x00 ... 0x27: N = (F - 2402) / 2.Frequency Range : 2402 MHz to 2480 MHz + * @param PHY PHY to be used by the receiver. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + * @param Modulation_Index + * Values: + * - 0x00: Assume transmitter will have a standard modulation index + * - 0x01: Assume transmitter will have a stable modulation index + * @param Expected_CTE_Length + * Values: + * - 0x00: No Constant Tone Extension expected (default) + * - 0x02 ... 0x14: Expected length of the Constant Tone Extension in 8 microseconds units. + * @param Expected_CTE_Type + * Values: + * - 0x00: Expect AoA Constant Tone Extension + * - 0x01: Expect AoD Constant Tone Extension with 1 microsecond slots + * - 0x02: Expect AoD Constant Tone Extension with 2 microseconds slots + * @param Slot_Durations Sampling rate used by the Controller. + * Values: + * - 0x01: CTE_SLOT_1us + * - 0x02: CTE_SLOT_2us + * @param Switching_Pattern_Length + * Values: + * - 0x02 ... 0x4B: The number of Antenna IDs in the pattern. + * @param Antenna_IDs List of Antenna IDs in the pattern + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_receiver_test_v3(uint8_t RX_Channel, + uint8_t PHY, + uint8_t Modulation_Index, + uint8_t Expected_CTE_Length, + uint8_t Expected_CTE_Type, + uint8_t Slot_Durations, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); +/** + * @brief This command is used to start a test where the DUT generates test + * reference packets at a fixed interval. The Controller shall transmit + * at the power level indicated by the Transmit_Power_Level parameter. + * The TX_Channel and PHY parameters specify the RF channel and PHY to be + * used by the transmitter. If the Host sets the PHY parameter to a PHY + * that the Controller does not support, including a value that is + * reserved for future use, the Controller shall return the error code + * Unsupported Feature or Parameter Value (0x11). The Test_Data_Length + * and Packet_Payload parameters specify the length and contents of the + * Payload of the test reference packets. An LE Controller supporting the + * HCI_LE_Transmitter_Test command shall support Packet_Payload values + * 0x00, 0x01 and 0x02. An LE Controller supporting the LE Coded PHY + * shall also support Packet_Payload value 0x04. An LE Controller may + * support other values of Packet_Payload. The CTE_Length and CTE_Type + * parameters specify the length and type of the Constant Tone Extension + * in the test reference packets. If the CTE_Type parameter is set to + * 0x01 and the Controller does not support 1 microsecond switching, the + * Controller shall return the error code Unsupported Feature or + * Parameter Value (0x11). If CTE_Length is not zero and PHY specifies a + * PHY that does not allow Constant Tone Extensions, the Controller shall + * return the error code Command Disallowed (0x0C). The + * Switching_Pattern_Length and Antenna_IDs[i] parameters specify the + * antenna switching pattern. They are only used when transmitting an AoD + * Constant Tone Extension and shall be ignored when transmitting an AoA + * Constant Tone Extension. If the Controller determines that any of the + * Antenna_IDs[i] values do not identify an antenna in the device's + * antenna array, it shall return the error code Unsupported Feature or + * Parameter Value (0x11). Note: Some Controllers may be unable to + * determine which values do or do not identify an antenna. The + * Transmit_Power_Level parameter specifies the transmit power level to + * be used by the transmitter. If the parameter is set to a value other + * than 0x7E or 0x7F, then the Controller shall make the requested change + * or shall make the nearest change that it is capable of doing. + * @param TX_Channel N = (F - 2402) / 2. Frequency Range : 2402 MHz to 2480 MHz + * Values: + * - 0x00 ... 0x27 + * @param Test_Data_Length Length in bytes of payload data in each packet. + * Supported ranges: - (0x00,0x25) if data length extension is + * disabled. - (0x00,0xFF) if data length extension is enabled. + * Values: + * - 0x00 ... 0xFF + * @param Packet_Payload Content of the Payload of the test reference packets. + * 0: PRBS9 sequence '11111111100000111101...' (in transmission order) 1: + * Repeated '11110000' (in transmission order) sequence 2: Repeated + * '10101010' (in transmission order) sequence 3: PRBS15 sequence 4: + * Repeated '11111111' (in transmission order) sequence 5: Repeated + * '00000000' (in transmission order) sequence 6: Repeated '00001111' (in + * transmission order) sequence 7: Repeated '01010101' (in transmission + * order) sequence + * Values: + * - 0x00: PRBS9 + * - 0x01: Repeated '11110000' + * - 0x02: Repeated '10101010' + * - 0x03: PRBS15 + * - 0x04: Repeated '11111111' + * - 0x05: Repeated '00000000' + * - 0x06: Repeated '00001111' + * - 0x07: Repeated '01010101' + * @param PHY PHY to be used by the transmitter. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY_S8 + * - 0x04: LE_CODED_PHY_S2 + * @param CTE_Length + * Values: + * - 0x00: No Constant Tone Extension expected (default) + * - 0x02 ... 0x14: Expected length of the Constant Tone Extension in 8 microseconds units. + * @param CTE_Type + * Values: + * - 0x00: Expect AoA Constant Tone Extension + * - 0x01: Expect AoD Constant Tone Extension with 1 microsecond slots + * - 0x02: Expect AoD Constant Tone Extension with 2 microseconds slots + * @param Switching_Pattern_Length The number of Antenna IDs in the pattern. + * Values: + * - 0x02 ... 0x4B + * @param Antenna_IDs List of Antenna IDs in the pattern + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_transmitter_test_v3(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[]); +/** + * @brief This command is used to start a test where the DUT generates test + * reference packets at a fixed interval. The Controller shall transmit + * at the power level indicated by the Transmit_Power_Level parameter. + * The TX_Channel and PHY parameters specify the RF channel and PHY to be + * used by the transmitter. If the Host sets the PHY parameter to a PHY + * that the Controller does not support, including a value that is + * reserved for future use, the Controller shall return the error code + * Unsupported Feature or Parameter Value (0x11). The Test_Data_Length + * and Packet_Payload parameters specify the length and contents of the + * Payload of the test reference packets. An LE Controller supporting the + * HCI_LE_Transmitter_Test command shall support Packet_Payload values + * 0x00, 0x01 and 0x02. An LE Controller supporting the LE Coded PHY + * shall also support Packet_Payload value 0x04. An LE Controller may + * support other values of Packet_Payload. The CTE_Length and CTE_Type + * parameters specify the length and type of the Constant Tone Extension + * in the test reference packets. If the CTE_Type parameter is set to + * 0x01 and the Controller does not support 1 microsecond switching, the + * Controller shall return the error code Unsupported Feature or + * Parameter Value (0x11). If CTE_Length is not zero and PHY specifies a + * PHY that does not allow Constant Tone Extensions, the Controller shall + * return the error code Command Disallowed (0x0C). The + * Switching_Pattern_Length and Antenna_IDs[i] parameters specify the + * antenna switching pattern. They are only used when transmitting an AoD + * Constant Tone Extension and shall be ignored when transmitting an AoA + * Constant Tone Extension. If the Controller determines that any of the + * Antenna_IDs[i] values do not identify an antenna in the device's + * antenna array, it shall return the error code Unsupported Feature or + * Parameter Value (0x11). Note: Some Controllers may be unable to + * determine which values do or do not identify an antenna. The + * Transmit_Power_Level parameter specifies the transmit power level to + * be used by the transmitter. If the parameter is set to a value other + * than 0x7E or 0x7F, then the Controller shall make the requested change + * or shall make the nearest change that it is capable of doing. + * @param TX_Channel N = (F - 2402) / 2. Frequency Range : 2402 MHz to 2480 MHz + * Values: + * - 0x00 ... 0x27 + * @param Test_Data_Length Length in bytes of payload data in each packet. + * Supported ranges: - (0x00,0x25) if data length extension is + * disabled. - (0x00,0xFF) if data length extension is enabled. + * Values: + * - 0x00 ... 0xFF + * @param Packet_Payload Content of the Payload of the test reference packets. + * 0: PRBS9 sequence '11111111100000111101...' (in transmission order) 1: + * Repeated '11110000' (in transmission order) sequence 2: Repeated + * '10101010' (in transmission order) sequence 3: PRBS15 sequence 4: + * Repeated '11111111' (in transmission order) sequence 5: Repeated + * '00000000' (in transmission order) sequence 6: Repeated '00001111' (in + * transmission order) sequence 7: Repeated '01010101' (in transmission + * order) sequence + * Values: + * - 0x00: PRBS9 + * - 0x01: Repeated '11110000' + * - 0x02: Repeated '10101010' + * - 0x03: PRBS15 + * - 0x04: Repeated '11111111' + * - 0x05: Repeated '00000000' + * - 0x06: Repeated '00001111' + * - 0x07: Repeated '01010101' + * @param PHY PHY to be used by the transmitter. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY_S8 + * - 0x04: LE_CODED_PHY_S2 + * @param CTE_Length + * Values: + * - 0x00: No Constant Tone Extension expected (default) + * - 0x02 ... 0x14: Expected length of the Constant Tone Extension in 8 microseconds units. + * @param CTE_Type + * Values: + * - 0x00: Expect AoA Constant Tone Extension + * - 0x01: Expect AoD Constant Tone Extension with 1 microsecond slots + * - 0x02: Expect AoD Constant Tone Extension with 2 microseconds slots + * @param Switching_Pattern_Length + * Values: + * - 0x02 ... 0x4B: The number of Antenna IDs in the pattern. + * @param Antenna_IDs List of Antenna IDs in the pattern + * @param Transmit_Power_Level + * Values: + * - -127 ... 20: Set transmitter to the specified or the nearest transmit power level. + * - 126: Set transmitter to minimum transmit power level + * - 127: Set transmitter to maximum transmit power level + * @retval Value indicating success or error code. + */ +tBleStatus hci_le_transmitter_test_v4(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t Antenna_IDs[], + int8_t Transmit_Power_Level); +/** + * @} + */ + +/** + * @} + */ + + +/** + *@addtogroup HAL_LL HAL/LL + *@brief HAL and proprietary LL API layer. + *@{ + */ +/** + *@defgroup ACI_HAL_Commands ACI HAL Commands + *@brief Commands for HAL and proprietary LL. + *@{ + */ +/** + * @brief This command returns the build number associated with the firmware + * version currently running + * @param[out] Build_Number Build number of the firmware. + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_get_fw_build_number(uint16_t *Build_Number); +/** + * @brief This command writes a value to a low level configure data structure. + * It is useful to setup directly some low level parameters for the + * system in the runtime.NOTE: This command shall not be called if a + * command different than Stack Init, HCI_RESET, + * ACI_HAL_WRITE_CONFIG_DATA or ACI_HAL_READ_CONFIG_DATA has already been + * called. + * @param Offset Offset of the element in the configuration data structure which + * has to be written. The valid offsets are: - 0x00: Bluetooth public + * address, Value length to be written: 6 bytes - 0x08: Encryption root + * key used to derive LTK and CSRK, Value length to be written: 16 bytes + * - 0x18: Identity root key used to derive LTK and CSRK, Value length to + * be written: 16 bytes - 0x2C: Link layer without host (for + * certification purposes), Value length to be written: 1 byte - 0x2E: If + * set, the stack uses this address as the static random address instead + * of the one stored in NVM. - 0x2F: Value is a bit field that indicates + * the advertising channel indices that shall be used when scanning. At + * least one channel bit shall be set. Bit 0: ch. 37; bit 1: ch. 38; bit + * 2: ch 39. - 0xD0: Use debug key for Secure connection: 1 byte - 0xD1: + * Set the maximum allowed parameter values for Data Length Extension: 8 + * bytes, 2 bytes for each of the following parameters: + * supportedMaxTxOctets, supportedMaxTxTime, supportedMaxRxOctets, + * supportedMaxRxTime, in little-endian order. (default + * 251,2120,251,2120). + * Values: + * - 0x00: CONFIG_DATA_PUBADDR_OFFSET + * - 0x08: CONFIG_DATA_ER_OFFSET + * - 0x18: CONFIG_DATA_IR_OFFSET + * - 0x2C: LL_WITHOUT_HOST + * - 0x2E: CONFIG_DATA_STATIC_RANDOM_ADDRESS + * - 0x2F: CONFIG_DATA_SCAN_CH_MAP + * - 0xD0: CONFIG_DATA_DEBUG_KEY + * - 0xD1: CONFIG_DATA_DLE + * @param Length Length of data to be written + * @param Value Data to be written + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_write_config_data(uint8_t Offset, + uint8_t Length, + uint8_t Value[]); +/** + * @brief This command requests the value in the low level configure data + * structure. The number of read bytes changes for different Offset. + * @param Offset Offset of the element in the configuration data structure which + * has to be read. The valid offsets are: - 0x00: Bluetooth public + * address, Value length returned: 6 bytes - 0x08: Encryption root key + * used to derive LTK and CSRK, Value length returned: 16 bytes - 0x18: + * Identity root key used to derive LTK and CSRK, Value length returned: + * 16 bytes - 0x2C: Link layer without host (for certification purposes), + * Value length returned: 1 byte - 0x80: The static random address stored + * in NVM. Value length returned: 6 bytes (read-only) + * Values: + * - 0x00: CONFIG_DATA_PUBADDR_OFFSET + * - 0x08: CONFIG_DATA_ER_OFFSET + * - 0x18: CONFIG_DATA_IR_OFFSET + * - 0x2C: LL_WITHOUT_HOST + * - 0x80: CONFIG_DATA_STORED_STATIC_RANDOM_ADDRESS + * @param[out] Data_Length Length of Data in octets + * @param[out] Data Data field associated with Offset parameter + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_read_config_data(uint8_t Offset, + uint8_t *Data_Length, + uint8_t Data[]); +/** + * @brief This command sets the TX power level of the device for all the radio + * activities, unless explicitly defined by other commands. The + * combination of En_High_Power and PA_Level parameters determines the + * output power level (dBm). When the system starts up or reboots, the + * default TX power level will be used, which is En_High_Power = 0 and + * PA_Level = 31. The En_High_Power is used to change the SMPS level. + * When the parameter is set to 0, SMPS level is set to 1.4V. When the + * parameter is set to 1, SMPS level is set to 1.9V. However, if SMPS is + * disabled, no action is done on the SMPS level, since the voltage must + * be applied externally on the VFBSD pin. To reach 8 dBm of TX power, + * En_High_Power must be set to 1. If SMPS is not used, this voltage + * level must be applied to the VFBSD pin. On devices other then + * STM32WB09, setting En_High_Power to 1 also bypasses the LDO_TRANSFO + * during transmission. On STM32WB09 device, PA_Level 32 is used to + * specify the configuration to reach 8 dBm, to be used only when + * En_High_Power is set to 1. In this configuration, LDO_TRANSFO is + * bypassed during transmission, by setting TxHp bit. The output power + * for other PA levels will remain almost equal to the case when + * En_High_Power is set to 0, since LDO_TRANSFO is not bypassed (TxHp bit + * set to 0). On devices other than STM32WB09, (i.e. where TxHp bit is + * not present), PA level 32 cannot be used. The 8 dBm configuration can + * be selected by using PA_Level 31, with En_High_Power set to 1. + * However, when setting En_High_Power to 1, also the output power of + * other PA levels less than 31 will change (especially for the higher + * ones) since LDO_TRANSFO is always bypassed during transmission for all + * the PA levels. Note that, if En_High_Power = 1 and SMPS is disabled, + * when LDO_TRANSFO is bypassed the actual output power will depend on + * the voltage applied to the VFBSD pin. In case the voltage is not 1.9V, + * it is recommended to change the TX output levels specified in the + * high_power_pa_level_table. The real output power may also depend on + * PCB layout and associated components. After this command is given, + * the new output power will be used only for new Link Layer state + * machines, i.e. for new Bluetooth activities, i.e. new advertising + * sets, new connections, new scanning procedures. For current activities + * the output power will not change. The only exception is for + * AUX_SCAN_REQ and AUX_CONNECT_REQ PDUs, for which the new output power + * will immediately take effect also for the current scanning procedure. + * @param En_High_Power Enable High Power mode, by changing SMPS level. High + * power mode should be enabled only to reach the maximum output power. + * Normal power (0x00) is the default. + * Values: + * - 0x00: Normal Power + * - 0x01: High Power + * @param PA_Level Power amplifier output level. PA_Level 32 is available only + * for STM32WB09, to select 8 dBm of output power. + * Values: + * - 0: -54/-54 dBm + * - 1: -21/-19 dBm + * - 2: -20/-18 dBm + * - 3: -19/-17 dBm + * - 4: -17/-16 dBm + * - 5: -16/-15 dBm + * - 6: -15/-14 dBm + * - 7: -14/-13 dBm + * - 8: -13/-12 dBm + * - 9: -12/-11 dBm + * - 10: -11/-10 dBm + * - 11: -10/-9 dBm + * - 12: -9/-8 dBm + * - 13: -8/-7 dBm + * - 14: -7/-6 dBm + * - 15: -6/-5 dBm + * - 16: -6/-4 dBm + * - 17: -4/-3 dBm + * - 18: -3/-3 dBm + * - 19: -3/-2 dBm + * - 20: -2/-1 dBm + * - 21: -2/+0 dBm + * - 22: -1/+1 dBm + * - 23: -1/+2 dBm + * - 24: +0/+3 dBm + * - 25: +0/+8 dBm + * - 26: +1/+8 dBm + * - 27: +2/+8 dBm + * - 28: +3/+8 dBm + * - 29: +4/+8 dBm + * - 30: +5/+8 dBm + * - 31: +6/+8 dBm + * - 32: +8 dBm + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_set_tx_power_level(uint8_t En_High_Power, + uint8_t PA_Level); +/** + * @brief This command returns the number of packets sent in Direct Test Mode. + * When the Direct TX test is started, a 32-bit counter is used to count + * how many packets have been transmitted. This command can be used to + * check how many packets have been sent during the Direct TX test. The + * counter starts from 0 and counts upwards. The counter can wrap and + * start from 0 again. The counter is not cleared until the next Direct + * TX test starts. + * @param[out] Number_Of_Packets Number of packets sent during the last Direct + * TX test. + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_le_tx_test_packet_number(uint32_t *Number_Of_Packets); +/** + * @brief This command returns the status of the Bluetooth low energy links + * managed by the device. + * @param Bank_index Index that identifies the link bank. Each bank is made by 8 + * links. Set Bank_Index to 0 to retrieve the status of the first 8 + * links, Bank_Index 1 to retrieve the status of the second 8 links and + * so on. + * Values: + * - 0x00 ... 0x15 + * @param[out] Link_Status Array of link status (8 links). Each link status is 1 + * byte. - 0x00: Idle - 0x01: Advertising - 0x02: Connected as + * peripheral - 0x03: Scanning - 0x04: Initiating - 0x05: Connected + * as central - 0x06: TX test mode - 0x07: RX test mode + * @param[out] Link_Connection_Handle Array of connection handles (2 bytes) for + * 8 links. + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_get_link_status(uint8_t Bank_index, + uint8_t Link_Status[8], + uint16_t Link_Connection_Handle[16 / 2]); +/** + * @brief This command set the bitmask associated to @ref + * aci_hal_end_of_radio_activity_event. Only the radio activities + * enabled in the mask will be reported to application by @ref + * aci_hal_end_of_radio_activity_event + * @param Radio_Activity_Mask Bitmask of radio events + * Flags: + * - 0x0001: Idle + * - 0x0002: Advertising + * - 0x0004: Connection event peripheral + * - 0x0008: Scanning + * - 0x0010: Connection request + * - 0x0020: Connection event central + * - 0x0040: TX test mode + * - 0x0080: RX test mode + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_set_radio_activity_mask(uint16_t Radio_Activity_Mask); +/** + * @brief This command is used to enable or disable the LE Power Control feature + * and procedure for a given PHY on the later established connections. It + * also provides the parameters that let the Controller initiate the LE + * Power Control procedure. In particular, the procedure will be + * initiated when the current (average) RSSI (say Curr_Avg_RSSI) gets: 1) + * less than (RSSI_Target - RSSI_Hysteresis) and the Controller will + * request the peer to increase its TX power level for the given PHY by + * (RSSI_Target - Curr_Avg_RSSI); 2) greater than (RSSI_Target + + * RSSI_Hysteresis) and the Controller will request the peer to decrease + * its TX power level for the given PHY by (Curr_Avg_RSSI - RSSI_Target). + * The Controller will start transmitting on the connections for which + * the power control is enabled and for the given PHY using the + * Initial_Tx_Power value. It will change its TX power based on the + * requests or feedbacks from the peer: 1) if the peer initiates an LE + * Power Control procedure and requests to increase or decrease the TX + * power of a given delta, the TX power will be increased or reduced by + * the requested delta within the acceptable limits; 2) if the peer + * reports that it can accept a TX power reduction of a given delta, the + * TX power will be reduced by the reported delta within the acceptable + * limits. If this command is not issued, the Controller will use the + * parameter default values. + * @param Enable Enable (1) or disable (0) LE power control on following + * connections. Default: 1. + * Values: + * - 0x00: DISABLE + * - 0x01: ENABLE + * @param PHY PHY on which the power control must be enabled or disabled. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY_S8 + * - 0x04: LE_CODED_PHY_S2 + * @param RSSI_Target Target RSSI in dBm. Default: -55 dBm. + * @param RSSI_Hysteresis Hysteresis applied on the target RSSI in dB. Default: + * 15 dB. + * @param Initial_TX_Power Initial TX power in dBm. Default: max TX power + * supported by the platform. + * @param RSSI_Filtering_Coefficient Coefficient used for the filtering of the + * RSSI samples and the calculation of the average RSSI. Allowed values + * are from 0 (fast moving average, low accuracy, max weight of last + * RSSI) to 4 (slow moving average, high accuracy, min weight of last + * RSSI). Default: 2. + * Values: + * - 0x00 ... 0x04 + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_set_le_power_control(uint8_t Enable, + uint8_t PHY, + int8_t RSSI_Target, + uint8_t RSSI_Hysteresis, + int8_t Initial_TX_Power, + uint8_t RSSI_Filtering_Coefficient); +/** + * @brief Command used on the peripheral to force the Link Layer to keep the + * peripheral latency disabled. Peripheral latency is enabled by default + * on a connection where peripheral latency has been set to a value + * greaten than zero by the Central when connection is established. + * Disabling the peripheral latency is useful to immediately reduce + * latency from Central to Peripheral. Note that when peripheral latency + * is enabled, the Link Layer will use the first available connection + * event to transfer the queued data, so there is no need to force the + * disabling of the peripheral latency to reduce latency from Peripheral + * to Central. This command returns BLE_ERROR_UNKNOWN_CONNECTION_ID if + * the connection handle does not exist. BLE_ERROR_COMMAND_DISALLOWED is + * returned if the command is given when the device is not in the + * peripheral role on the connection handle. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Enable Enable (1) or disable (0) the peripheral latency. Default value + * is Enabled (1). + * Values: + * - 0x00: DISABLED + * - 0x01: ENABLED + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_peripheral_latency_enable(uint16_t Connection_Handle, + uint8_t Enable); +/** + * @brief This command can be used to get the maximum used size of the stack's + * internal FIFO queues: isr1_fifo, isr2_fifo and user_fifo. These values + * can be used to chose the maximum correct size for the queues, which + * can be set through the BLE_STACK_Init() function. If one of these + * queues reaches the maximum size, an hci_hardware_error_event is + * raised, with error code 0x03. + * @param[out] ISR0_FIFO_Max_Level Maximum size reached by the FIFO used for + * critical controller events produced by the ISR (e.g. rx data + * packets). See isr0_fifo_size parameter field of + * BLE_STACK_InitTypeDef structure, used by BLE_STACK_Init(). + * @param[out] ISR1_FIFO_Max_Level Maximum size reached by the FIFO used for + * non-critical controller events produced by the ISR (e.g. + * advertising or IQ sampling reports). See isr1_fifo_size parameter + * field of BLE_STACK_InitTypeDef structure, used by + * BLE_STACK_Init(). + * @param[out] User_FIFO_Max_Level Maximum size reached by the FIFO used for + * controller and host events produced outside the ISR. See + * user_fifo_size parameter field of BLE_STACK_InitTypeDef + * structure, used by BLE_STACK_Init(). + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_get_evt_fifo_max_level(uint16_t *ISR0_FIFO_Max_Level, + uint16_t *ISR1_FIFO_Max_Level, + uint16_t *User_FIFO_Max_Level); +/** + * @brief Set data pointer for legacy advertising data. + * @param Data_Length + * @param Data + * @retval Value indicating success or error code. + */ +tBleStatus ll_set_legacy_advertising_data_ptr(uint8_t Data_Length, + uint8_t * Data); +/** + * @brief Set data pointer for legacy scan response data. + * @param Data_Length + * @param Data + * @retval Value indicating success or error code. + */ +tBleStatus ll_set_legacy_scan_reponse_data_ptr(uint8_t Data_Length, + uint8_t * Data); +/** + * @brief Set data pointer for extended advertising data. + * @param Advertising_Handle Used to identify an advertising set. This parameter + * is only meaningful if Extended Advertising Feature is enabled. + * Values: + * - 0x0000 ... 0x00EF + * @param Operation If set to Unchanged data, just update the Advertising DID. + * Values: + * - 0x03: Complete data + * - 0x04: Unchanged data + * @param Advertising_Data_Length Length of advertising data. + * @param Advertising_Data Pointer to the buffer containing properly formatted + * advertising data (see Core v5.2 Vol 3, part C, chapter 11). Its + * content must not change, until an + * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * application that the buffer is no more used by the Bluetooth stack. + * @retval Value indicating success or error code. + */ +tBleStatus ll_set_advertising_data_ptr(uint16_t Advertising_Handle, + uint8_t Operation, + uint16_t Advertising_Data_Length, + uint8_t Advertising_Data[]); +/** + * @brief Set data pointer for extended scan response data. + * @param Advertising_Handle Used to identify an advertising set. This parameter + * is only meaningful if Extended Advertising Feature is enabled. + * Values: + * - 0x0000 ... 0x00EF + * @param Scan_Response_Data_Length Length of scan response data. If the + * advertising set uses scannable legacy advertising PDUs maximum length + * is 31 octets. + * @param Scan_Response_Data Pointer to the buffer containing properly formatted + * scan response data (see Core v5.1 Vol 3, part C, chapter 11). Its + * content must not change, until an + * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * application that the buffer is no more used by the Bluetooth stack. + * @retval Value indicating success or error code. + */ +tBleStatus ll_set_scan_reponse_data_ptr(uint16_t Advertising_Handle, + uint16_t Scan_Response_Data_Length, + uint8_t Scan_Response_Data[]); +/** + * @brief Retrieves info about an existing advertising set. + * @param Advertising_Handle Used to identify an advertising set. + * Values: + * - 0x0000 ... 0x00EF + * @param[out] Adv_Enabled It is 1 (TRUE) if advertising is enabled for the + * given advertising handle, 0 (FALSE) otherwise. + * @param[out] Periodic_Adv_Configured It is 1 (TRUE) if periodic advertising + * has been configured for the given advertising handle, 0 (FALSE) + * otherwise. + * @param[out] Periodic_Adv_Enabled It is 1 (TRUE) if periodic advertising has + * been enabled for the given advertising handle, 0 (FALSE) + * otherwise. Note: periodic advertising may be enabled but not + * started; in this case Adv_Enabled is false and + * Periodic_Adv_Enable is true. + * @param[out] Advertising_Event_Properties Advertising event properties that + * have been previously set for the advertising set. + * @retval Value indicating success or error code. + */ +tBleStatus ll_get_advertising_info(uint16_t Advertising_Handle, + uint8_t *Adv_Enabled, + uint8_t *Periodic_Adv_Configured, + uint8_t *Periodic_Adv_Enabled, + uint16_t *Advertising_Event_Properties); +/** + * @brief Set data pointer for periodic extended advertising data. + * @param Advertising_Handle Used to identify an advertising set. This parameter + * is only meaningful if Extended Advertising Feature is enabled. + * Values: + * - 0x0000 ... 0x00EF + * @param Operation If set to Unchanged data, just update the Advertising DID. + * Values: + * - 0x03: Complete data + * - 0x04: Unchanged data + * @param Advertising_Data_Length Length of periodic advertising data. + * @param Advertising_Data Pointer to the buffer containing properly formatted + * periodic advertising data (see Core v5.2 Vol 3, part C, chapter 11). + * Its content must not change, until an + * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * application that the buffer is no more used by the Bluetooth stack. + * @retval Value indicating success or error code. + */ +tBleStatus ll_set_periodic_advertising_data_ptr(uint16_t Advertising_Handle, + uint8_t Operation, + uint16_t Advertising_Data_Length, + uint8_t Advertising_Data[]); +/** + * @brief Function to get the value of the last anchor point for the given + * connection. + * @param Connection_Handle + * @param[out] Event_Counter + * @param[out] Anchor_Point + * @retval Value indicating success or error code. + */ +tBleStatus aci_hal_get_anchor_point(uint16_t Connection_Handle, + uint16_t *Event_Counter, + uint32_t *Anchor_Point); +/** + * @brief + * @param Advertising_Handle It is used to identify an advertising set + * Values: + * - 0x00 ... 0xEF: Used to identify an advertising set + * @param Num_Subevents Number of subevent data in the command. + * Values: + * - 0x01 ... 0x0F + * @param Subevent_Data_Ptr_Parameters See @ref Subevent_Data_Ptr_Parameters_t + * @retval Value indicating success or error code. + */ +tBleStatus ll_set_periodic_advertising_subevent_data_ptr(uint8_t Advertising_Handle, + uint8_t Num_Subevents, + Subevent_Data_Ptr_Parameters_t Subevent_Data_Ptr_Parameters[]); +/** + * @brief The LL_Set_Periodic_Advertising_Response_Data_Ptr command is used by + * the Host to set the data for a response slot in a specific subevent of + * the PAwR identified by the Sync_Handle. The data for a response slot + * shall be transmitted only once. The Request_Event parameter identifies + * the periodic advertising event in which the periodic advertising + * packet that the Host is responding to was received. The + * Request_Subevent parameter identifies the subevent in which the + * periodic advertising packet that the Host is responding to was + * received. The Response_Subevent parameter identifies the subevent that + * the response shall be sent in. The Response_Slot parameter identifies + * the response slot in the subevent identified by the Response_Subevent + * parameter in which this response data is to be transmitted. The + * Response_Data_Length specifies the length of the Response_Data that is + * significant. The Response_Data contains the advertising data to be + * transmitted in the response slot. If the Response_Data_Length is + * greater than the maximum that the Controller can transmit within the + * response slot, then the Response_Data shall be discarded and the + * Controller shall return the error code Packet Too Long (0x45). If + * advertising on the LE Coded PHY, then the S=8 coding shall be assumed + * unless the current advertising parameters require the use of S=2 for + * an advertising physical channel, in which case the S=2 coding shall be + * assumed for that advertising physical channel. If the response slot + * identified by the Response_Slot parameter has passed by the time this + * command is received by the Controller, the Controller shall return the + * error code Too Late (0x46) and discard the Response_Data parameter. + * @param Sync_Handle Sync_Handle identifying the PAwR train. + * Values: + * - 0x0000 ... 0x0EFF + * @param Request_Event The value of paEventCounter (see [Vol 6] Part B, Section + * 4.4.2.1) for the periodic advertising packet that the Host is + * responding to. + * @param Request_Subevent Used to identify the subevent of the PAwR train. + * Values: + * - 0x00 ... 0x7F + * @param Response_Subevent Used to identify the response slot of the PAwR + * train. + * @param Response_Slot Used to identify the response slot of the PAwR train. + * @param Response_Data_Length The number of octets in the Response_Data + * parameter. + * Values: + * - 0x00 ... 0xFB + * @param Response_Data Pointer to response data formatted as defined in [Vol 3] + * Part C, Section 11. + * @retval Value indicating success or error code. + */ +tBleStatus ll_set_periodic_advertising_response_data_ptr(uint16_t Sync_Handle, + uint16_t Request_Event, + uint8_t Request_Subevent, + uint8_t Response_Subevent, + uint8_t Response_Slot, + uint8_t Response_Data_Length, + uint8_t* Response_Data); +/** + * @} + */ + +/** + * @} + */ + + +/** + *@addtogroup GAP GAP + *@brief Generic Access Profile. + *@{ + */ +/** + *@defgroup ACI_GAP_Commands ACI GAP Commands + *@brief Commands for GAP layer. + *@{ + */ +/** + * @brief Initialize the GAP layer. WARNING: A section of the Flash memory is + * used by this procedure. When this section is empty, data are written + * inside. This normally happens once during the lifetime of the device, + * when the command is executed for the first time (unless the section is + * erased). Do not power off the device while this function is writing + * into Flash memory. + * @param Privacy_Type Specify if privacy is enabled or not and which one . + * Values: + * - 0x00: Privacy disabled + * - 0x01: Privacy host enabled + * - 0x02: Privacy controller enabled + * @param Identity_Address_Type Specify which address has to be used as Identity + * Address. 0x00: The public address is used as identity address 0x01: + * The static random address is used as identity address + * Values: + * - 0x00: Public Address + * - 0x01: Static Random Address + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_init(uint8_t Privacy_Type, + uint8_t Identity_Address_Type); +/** + * @brief Set the IO capabilities of the device. This command cannot be sent + * during a pairing procedure. + * @param IO_Capability IO capability of the device. + * Values: + * - 0x00: IO_CAP_DISPLAY_ONLY + * - 0x01: IO_CAP_DISPLAY_YES_NO + * - 0x02: IO_CAP_KEYBOARD_ONLY + * - 0x03: IO_CAP_NO_INPUT_NO_OUTPUT + * - 0x04: IO_CAP_KEYBOARD_DISPLAY + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_io_capability(uint8_t IO_Capability); +/** + * @brief This command shall be given to set security requirements at device + * level. MITM_Mode setting will be used only when responding to an + * incoming Peripheral Security Request or Pairing Request received from + * peer device. It is recommended to force the use of Secure + * Connections for pairing by using Secure Connections Only Mode, since + * it is the only way to protect the pairing from passive eavesdropping. + * The Pairing_Response parameter is used to control the way a pairing is + * accepted. If set to 0 (pairing response not required), pairing is + * always accepted, even for bonded devices, and no user interaction is + * required, since the response is automatically handled by the Stack + * Library. If set to 1 (pairing response required for bonded devices + * only), the pairing is automatically accepted (no user interaction) + * except when the request comes from an already bonded device; in this + * case aci_gap_pairing_event is notified and the application has to give + * a confirmation through aci_gap_pairing_resp to accept the request to + * rebond. If Pairing_Response is set to 2 (explicit pairing response) a + * pairing confirmation is always required since aci_gap_pairing_event is + * always raised when a Pairing Request from a Central or a Peripheral + * Security Request form a Peripheral is received. If the command is + * given during pairing, the command returns BLE_STATUS_NOT_ALLOWED. The + * command returns BLE_STATUS_INVALID_PARAMS if some of the parameters + * are out of admitted range. If KeyPress_Notification_Support is set to + * 1 but Secure Connection feature is not supported, + * BLE_ERROR_UNSUPPORTED_FEATURE is returned. + * @param Bonding_Mode Bonding mode. Only if bonding is enabled (0x01), the + * bonding information is stored in flash + * Values: + * - 0x00: NO_BONDING + * - 0x01: BONDING + * @param MITM_Mode MITM mode. + * Values: + * - 0x00: MITM_PROTECTION_NOT_REQUIRED + * - 0x01: MITM_PROTECTION_REQUIRED + * @param SC_Support LE Secure connections support. Secure Connections Only Mode + * (0x02) is the recommended value. However it is no compatible with old + * devices not supporting LE Secure Connections. - 0x00: Secure + * Connections Pairing not supported. - 0x01: Secure Connections Pairing + * supported but optional. - 0x02: Secure Connections Pairing supported + * and mandatory (SC Only Mode). This is the recommended value. + * Values: + * - 0x00: SC_IS_NOT_SUPPORTED + * - 0x01: SC_IS_SUPPORTED + * - 0x02: SC_IS_MANDATORY + * @param KeyPress_Notification_Support Keypress notification support + * Values: + * - 0x00: KEYPRESS_IS_NOT_SUPPORTED + * - 0x01: KEYPRESS_IS_SUPPORTED + * @param Min_Encryption_Key_Size Minimum encryption key size to be used during + * pairing + * Values: + * - 7 ... 16 + * @param Max_Encryption_Key_Size Maximum encryption key size to be used during + * pairing + * Values: + * - 7 ... 16 + * @param Pairing_Response This parameter controls how pairing confirmation is + * managed. + * Values: + * - 0x00: GAP_PAIRING_RESP_NONE + * - 0x01: GAP_PAIRING_RESP_FOR_BONDED_DEVICES + * - 0x02: GAP_PAIRING_RESP_FOR_ALL + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_security_requirements(uint8_t Bonding_Mode, + uint8_t MITM_Mode, + uint8_t SC_Support, + uint8_t KeyPress_Notification_Support, + uint8_t Min_Encryption_Key_Size, + uint8_t Max_Encryption_Key_Size, + uint8_t Pairing_Response); +/** + * @brief This command should be send by the host in response to @ref + * aci_gap_passkey_req_event event. The command parameter contains the + * pass key which will be used during the pairing process. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Passkey Pass key that will be used during the pairing process. Must + * be a six-digit decimal number. + * Values: + * - 0 ... 999999 + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_passkey_resp(uint16_t Connection_Handle, + uint32_t Passkey); +/** + * @brief This command sets the security level for the given connection (LE + * security mode 1), by enabling encryption if needed. It will just + * enable encryption on the link if the peer is bonded with at least the + * specified security level. Otherwise, it will start a pairing with the + * peer device. This command may be given either on a Central or on a + * Peripheral device. The Security_Level indicates the minimum Security + * Level to be achieved: 1 for no security (no authentication or + * encryption), 2 for unauthenticated pairing with encryption, 3 for + * authenticated pairing with encryption, 4 for authenticated LE Secure + * Connections pairing with encryption using a 128-bit strength + * encryption key. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Security_Level Indicates the minimum Security Level to be achieved. + * Values: + * - 0x01: GAP_SECURITY_LEVEL_1 + * - 0x02: GAP_SECURITY_LEVEL_2 + * - 0x03: GAP_SECURITY_LEVEL_3 + * - 0x04: GAP_SECURITY_LEVEL_4 + * @param Force_Pairing + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_security(uint16_t Connection_Handle, + uint8_t Security_Level, + uint8_t Force_Pairing); +/** + * @brief This command can be used to get the current security settings of the + * device. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param[out] Security_Mode Security mode. + * Values: + * - 0x01: Security Mode 1 + * - 0x02: Security Mode 2 + * @param[out] Security_Level Security Level. + * Values: + * - 0x01: Security Level 1 + * - 0x02: Security Level 2 + * - 0x03: Security Level 3 + * - 0x04: Security Level 4 + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_get_security_level(uint16_t Connection_Handle, + uint8_t *Security_Mode, + uint8_t *Security_Level); +/** + * @brief + * @param LE_Event_Mask LE event mask. Default: 0x000000000000001F. + * Flags: + * - 0x0000000000000000: No LE events specified + * - 0x0000000000000001: LE Connection Complete Event + * - 0x0000000000000002: LE Advertising Report Event + * - 0x0000000000000004: LE Connection Update Complete Event + * - 0x0000000000000008: LE Read Remote Used Features Complete Event + * - 0x0000000000000010: LE Long Term Key Request Event + * - 0x0000000000000020: LE Remote Connection Parameter Request Event + * - 0x0000000000000040: LE Data Length Change Event + * - 0x0000000000000080: LE Read Local P-256 Public Key Complete Event + * - 0x0000000000000100: LE Generate DHKey Complete Event + * - 0x0000000000000200: LE Enhanced Connection Complete Event + * - 0x0000000000000400: LE Directed Advertising Report Event + * - 0x0000000000000800: LE PHY Update Complete event + * - 0x0000000000001000: LE Extended Advertising Report event + * - 0x0000000000002000: LE Periodic Advertising Sync Established event + * - 0x0000000000004000: LE Periodic Advertising Report event + * - 0x0000000000008000: LE Periodic Advertising Sync Lost event + * - 0x0000000000010000: LE Scan Timeout event + * - 0x0000000000020000: LE Advertising Set Terminated event + * - 0x0000000000040000: LE Scan Request Received event + * - 0x0000000000080000: LE Channel Selection Algorithm event + * - 0x0000000000100000: LE Connectionless IQ Report event + * - 0x0000000000200000: LE Connection IQ Report event + * - 0x0000000000400000: LE CTE Request Failed event + * - 0x0000000000800000: LE Periodic Advertising Sync Transfer Received event + * - 0x0000000001000000: LE CIS Established event + * - 0x0000000002000000: LE CIS Request event + * - 0x0000000004000000: LE Create BIG Complete event + * - 0x0000000008000000: LE Terminate BIG Complete event + * - 0x0000000010000000: LE BIG Sync Established event + * - 0x0000000020000000: LE BIG Sync Lost event + * - 0x0000000040000000: LE Request Peer SCA Complete event + * - 0x0000000080000000: LE Path Loss Threshold event + * - 0x0000000100000000: LE Transmit Power Reporting event + * - 0x0000000200000000: LE BIGInfo Advertising Report event + * - 0x0000000400000000: LE Subrate Change event + * - 0x0000000800000000: LE Periodic Advertising Sync Established event [v2] + * - 0x0000001000000000: LE Periodic Advertising Report event [v2] + * - 0x0000002000000000: LE Periodic Advertising Sync Transfer Received event [v2] + * - 0x0000004000000000: LE Periodic Advertising Subevent Data Request event + * - 0x0000008000000000: LE Periodic Advertising Response Report event + * - 0x0000010000000000: LE Enhanced Connection Complete event [v2] + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_le_event_mask(uint8_t LE_Event_Mask[8]); +/** + * @brief Command the controller to terminate the connection. A @ref + * hci_disconnection_complete_event will be generated when the link is + * disconnected. After this event is received, the Bluetooth stack may + * request to save GATT database information in non-volatile memory. So + * it is important not to reset or power off the system immediately after + * @ref hci_disconnection_complete_event is received. This operation is + * normally completed within less than few milliseconds. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Reason The reason for ending the connection. + * Values: + * - 0x05: Authentication Failure + * - 0x13: Remote User Terminated Connection + * - 0x14: Remote Device Terminated Connection due to Low Resources + * - 0x15: Remote Device Terminated Connection due to Power Off + * - 0x1A: Unsupported Remote Feature + * - 0x3B: Unacceptable Connection Parameters + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_terminate(uint16_t Connection_Handle, + uint8_t Reason); +/** + * @brief Clear the security database. All the devices in the security database + * will be removed. ATTENTION: It is strongly recommended not to give + * this command during intense radio activity (e.g. during advertising or + * connection with short intervals, i.e. less than 30 ms, or during + * scanning), since it will trigger an erase of a Flash sector. After + * this command, all devices previously recorded in the bonding table and + * connected when command has been submitted will remain connected, + * preserving authentication and encryption of the link. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_clear_security_db(void); +/** + * @brief This command shall be given in response to an aci_gap_paring_event, to + * allow or reject either the pairing request from the Central or the + * security request from the Peripheral. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Accept + * Values: + * - 0x00: REJECT + * - 0x01: ACCEPT + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_pairing_resp(uint16_t Connection_Handle, + uint8_t Accept); +/** + * @brief Creates a direct connection to a device. + * @param Initiating_PHY PHYs that will be used for initiating the connection. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Peer_Address_Type The Peer_Address_Type parameter indicates the type + * of address used in the connectable advertisement sent by the peer. 0: + * Public Device Address or Public Identity Address 1: Random Device + * Address or Random (static) Identity Address + * Values: + * - 0x00: Public Address + * - 0x01: Random Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address, or Random (static) Identity Address of the device to + * be connected. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_create_connection(uint8_t Initiating_PHY, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); +/** + * @brief Terminate the specified GAP procedure. An @ref + * aci_gap_proc_complete_event event is generated when the procedure has + * been completed, with the procedure code set to the corresponding + * procedure. + * @param Procedure_Code Code identifying the procedure. + * Values: + * - 0x00: GAP_LIMITED_DISCOVERY_PROC + * - 0x01: GAP_GENERAL_DISCOVERY_PROC + * - 0x02: GAP_AUTO_CONNECTION_ESTABLISHMENT_PROC + * - 0x03: GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC + * - 0x04: GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC + * - 0x05: GAP_OBSERVATION_PROC + * - 0x06: GAP_DIRECT_CONNECTION_ESTABLISHMENT_PROC + * - 0x07: GAP_NAME_DISCOVERY_PROC + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_terminate_proc(uint8_t Procedure_Code); +/** + * @brief Start the connection update procedure (only when role is Central). A + * @ref hci_le_connection_update is called. On completion of the + * procedure, an @ref hci_le_connection_update_complete_event event is + * returned to the upper layer. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Connection_Interval_Min Minimum value for the connection event + * interval. This shall be less than or equal to Connection_Interval_Max. + * Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Connection_Interval_Max Maximum value for the connection event + * interval. This shall be greater than or equal to + * Connection_Interval_Min. Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Max_Latency Maximum Peripheral latency for the connection in number of + * connection events. + * Values: + * - 0x0000 ... 0x01F3 + * @param Supervision_Timeout Supervision timeout for the LE Link. It shall be a + * multiple of 10 ms and larger than (1 + connPeripheralLatency) * + * connInterval * 2. Time = N * 10 msec. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + * @param Min_CE_Length The minimum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @param Max_CE_Length The maximum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_start_connection_update(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); +/** + * @brief This command tries to resolve the address provided with the IRKs + * present in its database. If the address is resolved successfully with + * any one of the IRKs present in the database, it returns success and + * also the corresponding public/static random address stored with the + * IRK in the database. + * @param Address Address to be resolved + * @param[out] Actual_Address The public or static random address of the peer + * device, distributed during pairing phase. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_resolve_private_addr(uint8_t Address[6], + uint8_t Actual_Address[6]); +/** + * @brief This command returns the identity addresses of the bonded devices. + * @param Offset Index of the first record to be returned. + * @param Max_Num_Of_Addresses Used to specify the maximum number of devices to + * be returned. + * @param[out] Num_of_Addresses The number of bonded devices returned by this + * command. + * @param[out] Bonded_Device_Entry See @ref Bonded_Device_Entry_t + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_get_bonded_devices(uint8_t Offset, + uint8_t Max_Num_Of_Addresses, + uint8_t *Num_of_Addresses, + Bonded_Device_Entry_t Bonded_Device_Entry[]); +/** + * @brief The command finds whether the device, whose address is specified in + * the command, is bonded. If the device is using a resolvable private + * address and it has been bonded, then the command will return + * BLE_STATUS_SUCCESS. + * @param Peer_Address_Type Address type. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * @param Peer_Address Address used by the peer device while advertising + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_is_device_bonded(uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); +/** + * @brief This command allows the User to validate/confirm or not the Numeric + * Comparison value showed through the + * ACI_GAP_Numeric_Comparison_Value_Event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Confirm_Yes_No 0 : The Numeric Values showed on both local and peer + * device are different! 1 : The Numeric Values showed on both local and + * peer device are equal! + * Values: + * - 0x00: No + * - 0x01: YES + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_numeric_comparison_value_confirm_yesno(uint16_t Connection_Handle, + uint8_t Confirm_Yes_No); +/** + * @brief This command permits to signal to the Stack the input type detected + * during Passkey input. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Input_Type Passkey input type detected + * Values: + * - 0x00: Passkey entry started + * - 0x01: Passkey digit entered + * - 0x02: Passkey digit erased + * - 0x03: Passkey cleared + * - 0x04: Passkey entry completed + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_passkey_input(uint16_t Connection_Handle, + uint8_t Input_Type); +/** + * @brief This command can be used to get the local OOB authentication for LE + * Secure connections or the remote Temporary Key for Legacy Pairing set + * through aci_gap_set_oob_data(). This command is particularly useful in + * case of LE Secure Connections to retrieve the local OOB data generated + * with aci_gap_set_oob_data(). This data should then be sent to the peer + * through the OOB channel. + * @param OOB_Data_Type OOB Data type. - 0x00: Legacy Pairing (LP) v.4.1 TK + * (Temporary Key) - 0x01: Secure Connections (SC) v.4.2 Random value r + * used for generation of Confirm value - 0x02: Secure Connections (SC) + * v.4.2 Confirm value C generated through AES-CMAC-128 based + * cryptographic function: C=f4(PKx, PKx, r, 0) + * Values: + * - 0x00: SM_TK + * - 0x01: SM_RANDOM_VALUE + * - 0x02: SM_CONFIRM_VALUE + * @param[out] Address_Type Identity address type. + * Values: + * - 0x00: Public Identity Address + * - 0x01: Random (static) Identity Address + * @param[out] Address Public or Random (static) address of this device + * @param[out] OOB_Data_Len Length of OOB Data carried by next data field + * @param[out] OOB_Data OOB Data to be exported via OOB. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_get_oob_data(uint8_t OOB_Data_Type, + uint8_t *Address_Type, + uint8_t Address[6], + uint8_t *OOB_Data_Len, + uint8_t OOB_Data[16]); +/** + * @brief This command can be used to input the Authentication data exchanged + * via OOB channel: either local authentication data to be sent to the + * peer device through the OOB channel or the peer device authentication + * data received through OOB channel. Moreover, it can also be used to + * generate authentication data for LE Secure Connections. Device_Type + * must be set to 0x00 (Local Device) to provide or generate local + * authentication data that will be sent to the peer through OOB channel. + * In this case Address_Type and Address parameters are ignored. With + * Device_Type=0 and OOB_Data_Len=0x00, OOB_Data_Type is ignored and the + * command triggers an automatic generation of OOB Authentication data r + * and C (that can be read with aci_gap_get_oob_data()), used for Secure + * Connections, otherwise the OOB_Data carried by the command will + * overwrite the current local authentication OOB Data. To generate OOB + * authentication data, the stack requires the availability of the local + * Public Key, to be previously generated with + * hci_le_read_local_p256_public_key command. When peer authentication + * data are received through OOB channel for either Legacy Pairing or + * Secure Connections, aci_gap_set_oob_data() must be called with + * Device_Type set to 0x01 (Remote Device): the command will set the OOB + * data for the specified remote device (only one device at a time is + * supported). For Legacy pairing, the TK must be provided as both local + * and remote data. + * @param Device_Type If Device_Type is 0x00 (Local Device), it sets the local + * OOB authentication data. If Device_Type is 0x01 (Remote Device), the + * command sets the OOB data for the specified remote device (only one + * device at a time is supported). + * Values: + * - 0x00: Local device + * - 0x01: Remote device + * @param Address_Type Identity address type of the remote device. Ignored if + * Device_Type is 0. + * Values: + * - 0x00: Public Identity Address + * - 0x01: Random (static) Identity Address + * @param Address Public or Random (static) address of the peer device. Ignored + * if Device_Type is 0. + * @param OOB_Data_Type OOB Data type. - 0x00: Legacy Pairing (LP) v.4.1 TK + * (Temporary Key) - 0x01: Secure Connections (SC) v.4.2 Random value r + * used for generation of Confirm value - 0x02: Secure Connections (SC) + * v.4.2 Confirm value C generated through AES-CMAC-128 based + * cryptographic function: C=f4(PKx, PKx, r, 0) + * Values: + * - 0x00: SM_TK + * - 0x01: SM_RANDOM_VALUE + * - 0x02: SM_CONFIRM_VALUE + * @param OOB_Data_Len Length of OOB Data carried by next data field. It may be + * set to 0x00 to trigger the automatic generation of local Random and + * Confirm values for LE Secure Connections pairing. + * Values: + * - 0x00 ... 0x10 + * @param OOB_Data OOB Data to be exported via OOB. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_oob_data(uint8_t Device_Type, + uint8_t Address_Type, + uint8_t Address[6], + uint8_t OOB_Data_Type, + uint8_t OOB_Data_Len, + uint8_t OOB_Data[16]); +/** + * @brief This command can be used to remove a specified device from the bonding + * table. ATTENTION: the device removed from the Bonding Table will + * preserve its connection and authentication, until explicit + * disconnection is requested by the user. + * @param Peer_Identity_Address_Type Identity address type. + * Values: + * - 0x00: Public Identity Address + * - 0x01: Random (static) Identity Address + * @param Peer_Identity_Address Public or Random (static) Identity address of + * the peer device + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_remove_bonded_device(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6]); +/** + * @brief This commands configures the advertising parameters for the legacy + * advertising or for a given extended advertising set. For general or + * limited discoverable mode or connectable advertising, Flags AD type + * must be present in advertising data. See also Bluetooth Core + * specifications, Vol. 4, part E, section 7.8.53 (LE Set Extended + * Advertising Parameters command). + * @param Advertising_Handle Used to identify an advertising set. This parameter + * is only meaningful if Extended Advertising Feature is enabled. + * Values: + * - 0x00 ... 0xEF + * @param Discoverable_Mode Specifies the discoverable mode of the device. + * Values: + * - 0: Not Discoverable + * - 1: Limited Discoverable + * - 2: General Discoverable + * - 3: Broadcast + * @param Advertising_Event_Properties The Advertising_Event_Properties + * parameter describes the type of advertising event that is being + * configured and its basic properties according to V5.1, Vol 2, Part E, + * section 7.8.53. + * Flags: + * - 0x0001: Connectable + * - 0x0002: Scannable + * - 0x0004: Directed + * - 0x0008: High Duty Cycle Directed Connectable + * - 0x0010: Legacy + * - 0x0020: Anonymous + * - 0x0040: Include TX Power + * @param Primary_Advertising_Interval_Min Minimum advertising interval for + * undirected and low duty cycle directed advertising. Time = N * 0.625 + * msec. + * Values: + * - 0x00000020 (20.000 ms) ... 0x00FFFFFF (10485759.375 ms) + * @param Primary_Advertising_Interval_Max Maximum advertising interval for + * undirected and low duty cycle directed advertising. Time = N * 0.625 + * msec. + * Values: + * - 0x00000020 (20.000 ms) ... 0x00FFFFFF (10485759.375 ms) + * @param Primary_Advertising_Channel_Map It is a bit field that indicates the + * advertising channels that shall be used when transmitting advertising + * packets. + * Flags: + * - 0x01: CH_37 + * - 0x02: CH_38 + * - 0x04: CH_39 + * @param Peer_Address_Type The peer address type. + * Values: + * - 0x00: Public + * - 0x01: Random + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address, or Random (static) Identity Address of the device to + * be connected. + * @param Advertising_Filter_Policy Advertising Filter Policy. If Directed + * advertising is selected, the Peer_Address_Type and Peer_Address shall + * be valid and the Advertising_Filter_Policy parameter shall be ignored. + * 0x00 Process scan and connection requests from all devices (i.e., the + * Filter Accept List is not in use) 0x01 Process connection requests + * from all devices and scan requests only from devices that are in the + * Filter Accept List 0x02 Process scan requests from all devices and + * connection requests only from devices that are in the Filter Accept + * List. 0x03 Process scan and connection requests only from devices in + * the Filter Accept List. All other values Reserved for future use + * Values: + * - 0x00: Scan and Connection requests from any + * - 0x01: Connection requests from any, scan requests from Filter Accept List only + * - 0x02: Scan requests from any, connection requests from Filter Accept List only + * - 0x03: Scan and connection requests from Filter Accept List only + * @param Advertising_Tx_Power The Advertising_Tx_Power parameter indicates the + * maximum power level at which the advertising packets are to be + * transmitted on the advertising channels. The Controller shall choose a + * power level lower than or equal to the one specified by the Host. + * (Units: dBm). This parameter is ignored if extended advertising is not + * enabled. + * Values: + * - -127 ... 126 + * - 127: No preference + * @param Primary_Advertising_PHY The Primary_Advertising_PHY parameter + * indicates the PHY on which the advertising packets are transmitted on + * the primary advertising channel. If legacy advertising PDUs are being + * used, the Primary_Advertising_PHY shall indicate the LE 1M PHY. This + * parameter is ignored if extended advertising is not enabled. + * Values: + * - 0x01: LE_1M_PHY + * - 0x03: LE_CODED_PHY + * @param Secondary_Advertising_Max_Skip The Secondary_Advertising_Max_Skip + * parameter is the maximum number of advertising events that can be + * skipped before the AUX_ADV_IND can be sent. This parameter is ignored + * if extended advertising is not enabled. 0x00 AUX_ADV_IND shall be sent + * prior to the next advertising event 0x01-0xFF Maximum advertising + * events the Controller can skip before sending the AUX_ADV_IND packets + * on the secondary advertising channel + * @param Secondary_Advertising_PHY The Secondary_Advertising_PHY parameter + * indicates the PHY on which the advertising packets are be transmitted + * on the secondary advertising channel. This parameter is ignored if + * extended advertising is not enabled. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + * @param Advertising_SID The Advertising_SID parameter specifies the value to + * be transmitted in the Advertising SID subfield of the ADI field of the + * Extended Header of those advertising channel PDUs that have an ADI + * field. If the advertising set only uses PDUs that do not contain an + * ADI field, Advertising_SID is ignored. This parameter is ignored if + * extended advertising is not enabled. + * Values: + * - 0x00 ... 0x0F + * @param Scan_Request_Notification_Enable The Scan_Request_Notification_Enable + * parameter indicates whether the Controller shall send notifications + * upon the receipt of a scan request PDU that is in response to an + * advertisement from the specified advertising set that contains its + * device address and is from a scanner that is allowed by the + * advertising filter policy. This parameter is ignored if extended + * advertising is not enabled. + * Values: + * - 0x00: Scan request notifications disabled + * - 0x01: Scan request notifications enabled + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_advertising_configuration(uint8_t Advertising_Handle, + uint8_t Discoverable_Mode, + uint16_t Advertising_Event_Properties, + uint32_t Primary_Advertising_Interval_Min, + uint32_t Primary_Advertising_Interval_Max, + uint8_t Primary_Advertising_Channel_Map, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable); +/** + * @brief This command is used to request the Controller to enable or disable + * one or more advertising sets using the advertising sets identified by + * the Advertising_Handle[i] parameter. The Controller manages the timing + * of advertisements in accordance with the advertising parameters given + * with @ref aci_gap_set_advertising_configuration command. Only the + * Enable parameter is used if extended advertising feature is disabled + * through modular configuration (CONTROLLER_EXT_ADV_SCAN_ENABLED=0), + * others are ignored. The command returns an error if adverting data are + * not set properly, according to the used discoverable mode: Flags AD + * type may be required (see @ref aci_gap_set_advertising_data). An error + * is also returned if either the length of advertising data is greater + * than 245 octets and advertising type is connectable, or if no scan + * response data is set and advertising type is scannable. See also + * Bluetooth Core specifications, Vol. 4, part E, section 7.8.56 (LE Set + * Extended Advertising Enable command). + * @param Enable It allows to enable or disable one or more advertising sets + * using the advertising sets identified by the Advertising_Handle[i] + * parameter. + * Values: + * - 0x00: Disable + * - 0x01: Enable + * @param Number_of_Sets The Number_of_Sets parameter is the number of + * advertising sets contained in the parameter arrays. 0x00: Disable all + * advertising sets 0x01 to 0x3F: Number of advertising sets to enable or + * disable. Ignored if extended advertising feature is disabled through + * modular configuration (CONTROLLER_EXT_ADV_SCAN_ENABLED=0). + * Values: + * - 0x00: Disable all sets + * - 0x01 ... 0x3F + * @param Advertising_Set_Parameters See @ref Advertising_Set_Parameters_t + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_advertising_enable(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t Advertising_Set_Parameters[]); +/** + * @brief The ACI_GAP_SET_SCAN_CONFIGURATION function configures the scan + * parameters for a given PHY. To configure more than one PHY, this + * function must be called more times. + * @param Filter_Duplicates The Filter_Duplicates parameter controls whether the + * Link Layer should filter out duplicate advertising reports (filtering + * duplicates enabled) to the Host or if the Link Layer should generate + * advertising reports for each packet received (filtering duplicates + * disabled). See [Vol 6] Part B, Section 4.4.3.5. + * Values: + * - 0x00: Duplicate filtering disabled + * - 0x01: Duplicate filtering enabled + * - 0x02: Duplicate filtering enabled, reset for each scan period + * @param Scanning_Filter_Policy 0x00 Accept all advertisement packets. Directed + * advertising packets which are not addressed for this device shall be + * ignored. 0x01 Ignore advertisement packets from devices not in the + * Filter Accept List Only. Directed advertising packets which are not + * addressed for this device shall be ignored 0x02 Accept all undirected + * advertisement packets. Directed advertisement packets where initiator + * address is a RPA and Directed advertisement packets addressed to this + * device shall be accepted. 0x03 Accept all undirected advertisement + * packets from devices that are in the Filter Accept List.Directed + * advertisement packets where initiator address is RPA and Directed + * advertisement packets addressed to this device shall be accepted. + * Values: + * - 0x00: Accept All + * - 0x01: Filter Accept List Only + * - 0x02: Accept All (use resolving list) + * - 0x03: Filter Accept List Only (use resolving list) + * @param Scanning_PHY PHY that is going to be configured. Only one bit can be + * set. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Scan_Type The Scan_Type parameter specifies the type of scan to + * perform. 0: Passive Scanning. No scan request PDUs shall be sent. 1: + * Active Scanning. Scan request PDUs may be sent. + * Values: + * - 0x00: Passive Scanning + * - 0x01: Active Scanning + * @param Scan_Interval Time interval from when the Controller started its last + * scan until it begins the subsequent scan on the primary advertising + * physical channel. Time = N * 0.625 ms + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + * @param Scan_Window Time interval from when the Controller started its last + * scan until it begins the subsequent scan on the primary advertising + * physical channel. Time = N * 0.625 msec. + * Values: + * - 0x0004 (2.500 ms) ... 0xFFFF (40959.375 ms) + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_scan_configuration(uint8_t Filter_Duplicates, + uint8_t Scanning_Filter_Policy, + uint8_t Scanning_PHY, + uint8_t Scan_Type, + uint16_t Scan_Interval, + uint16_t Scan_Window); +/** + * @brief This function configures the connection parameters. To configure more + * than one PHY, this function must be called more times. + * @param Initiating_PHY PHY that is going to be configured. Only one bit can be + * set. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x02: LE_2M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Connection_Interval_Min Minimum value for the connection event + * interval. This shall be less than or equal to Connection_Interval_Max. + * Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Connection_Interval_Max Maximum value for the connection event + * interval. This shall be greater than or equal to + * Connection_Interval_Min. Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Max_Latency Maximum Peripheral latency for the connection in number of + * connection events. + * Values: + * - 0x0000 ... 0x01F3 + * @param Supervision_Timeout Supervision timeout for the LE Link. It shall be a + * multiple of 10 ms and larger than (1 + connPeripheralLatency) * + * connInterval * 2. Time = N * 10 msec. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + * @param Min_CE_Length The minimum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @param Max_CE_Length The maximum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_connection_configuration(uint8_t Initiating_PHY, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); +/** + * @brief Starts a GAP procedure according to the procedure code. + * @param Procedure_Code Procedure to be started. + * Values: + * - 0x00: GAP_LIMITED_DISCOVERY_PROC + * - 0x01: GAP_GENERAL_DISCOVERY_PROC + * - 0x02: GAP_AUTO_CONNECTION_ESTABLISHMENT_PROC + * - 0x03: GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC + * - 0x04: GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC + * - 0x05: GAP_OBSERVATION_PROC + * @param PHYs PHYs that will be used for Scanning or Initiating . + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Duration Ignored. Reserved for future use. + * @param Period Ignored. Reserved for future use. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_start_procedure(uint8_t Procedure_Code, + uint8_t PHYs, + uint16_t Duration, + uint16_t Period); +/** + * @brief Creates a direct connection to a device and read the name + * characteristic. + * @param PHYs PHYs that will be used for initiating the connection. + * Flags: + * - 0x01: LE_1M_PHY_BIT + * - 0x04: LE_CODED_PHY_BIT + * @param Peer_Address_Type The Peer_Address_Type parameter indicates the type + * of address used in the connectable advertisement sent by the peer. 0: + * Public Device Address or Public Identity Address 1: Random Device + * Address or Random (static) Identity Address + * Values: + * - 0x00: Public Address + * - 0x01: Random Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address, or Random (static) Identity Address of the device to + * be connected. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_discover_name(uint8_t PHYs, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); +/** + * @brief Add specific device addresses to the Filter Accept and/or resolving + * list. + * @param Lists Select in which list the device addresses will be added: Filter + * Accept List, resolving list or both. + * Flags: + * - 0x01: Filter Accept List + * - 0x02: Resolving List + * @param Clear_Lists Clear the selected lists before adding the device + * addresses. + * Values: + * - 0x00: Do not clear + * - 0x01: Clear before adding + * @param Num_of_List_Entries Number of devices that have to be added to the + * Filter Accept List. + * Values: + * - 0x00 ... 0xFF + * @param List_Entry See @ref List_Entry_t + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_add_devices_to_filter_accept_and_resolving_list(uint8_t Lists, + uint8_t Clear_Lists, + uint8_t Num_of_List_Entries, + List_Entry_t List_Entry[]); +/** + * @brief Clear the specified lists and add all bonded devices. + * @param Lists Select in which list the device addresses will be added: Filter + * Accept List, resolving list or both. + * Flags: + * - 0x01: Filter Accept List + * - 0x02: Resolving List + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_configure_filter_accept_and_resolving_list(uint8_t Lists); +/** + * @brief The GAP_Remove_Advertising_Set command is used to remove an + * advertising set from the Controller. If the advertising set + * corresponding to the Advertising_Handle parameter does not exist, then + * the Controller shall return the error code Unknown Advertising + * Identifier (0x42). If advertising on the advertising set is enabled, + * then the Controller shall return the error code Command Disallowed + * (0x0C). + * @param Advertising_Handle It is used to identify an advertising set + * Values: + * - 0x00 ... 0xEF: Used to identify an advertising set + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_remove_advertising_set(uint8_t Advertising_Handle); +/** + * @brief The GAP_Clear_Advertising_Sets command is used to remove all existing + * advertising sets from the Controller. If advertising is enabled on any + * advertising set, then the Controller shall return the error code + * Command Disallowed (0x0C). Note: All advertising sets are cleared on + * HCI reset. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_clear_advertising_sets(void); +/** + * @brief The aci_gap_clear_advertising_sets + * @param Advertising_Handle + * @param Subevent + * @param Initiator_Filter_Policy + * @param Own_Address_Type + * @param Peer_Address_Type + * @param Peer_Address + * @param Connection_Interval_Min + * @param Connection_Interval_Max + * @param Max_Latency + * @param Supervision_Timeout + * @param Min_CE_Length + * @param Max_CE_Length + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_create_periodic_advertising_connection(uint8_t Advertising_Handle, + uint8_t Subevent, + uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); +/** + * @brief The ACI_GAP_SET_ADVERTISING_DATA function is used to set the data in + * advertising PDUs. Data must be formatted as defined in Bluetooth Core + * spec Vol. 3 Part C, Section 11. If the device is in Limited + * Discoverable Mode, Flags data type (0x06) in advertising data must + * have the flags set as described: - The LE Limited Discoverable Mode + * flag set to one. - The 'BR/EDR Not Supported' flag set to one. - All + * other flags set to zero. If the device is in General Discoverable + * Mode, Flags data type (0x06) in advertising data must have the flags + * set as described: - The LE General Discoverable Mode flag set to one. + * - The 'BR/EDR Not Supported' flag set to one. - All other flags set to + * zero. If the device is in one of the other modes, Flags data type + * (0x06) in advertising data must have the flags set as described: - The + * 'BR/EDR Not Supported' flag set to one. - All other flags set to zero. + * In this case (none of the discoverable modes is used), Flags data type + * may be omitted in advertising data if a device is sending non + * connectable events, otherwise it must be present. For non-legacy + * PDUs, length of advertising data is limited to 245 octets in case of + * connectable advertising and cannot be present for scannable + * advertising. See also Bluetooth Core specifications, Vol. 4, part E, + * section 7.8.54 (LE Set Extended Advertising Data command). + * @param Advertising_Handle Used to identify an advertising set. This parameter + * is only meaningful if Extended Advertising Feature is enabled. + * Values: + * - 0x00 ... 0xEF + * @param Operation If set to Unchanged data, just update the Advertising DID. + * Values: + * - 0x03: Complete data + * - 0x04: Unchanged data + * @param Advertising_Data_Length Length of advertising data. For legacy PDUs + * which supports advertising data maximum value is 31 octets. Data must + * be formatted as defined in Bluetooth Core spec Vol. 3 Part C, Section + * 11. + * @param Advertising_Data Pointer to the buffer containing properly formatted + * advertising data (see Core v5.1 Vol 3, part C, chapter 11). Its + * content must not change, until an + * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * application that the buffer is no more used by the Bluetooth stack. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_advertising_data(uint8_t Advertising_Handle, + uint8_t Operation, + uint16_t Advertising_Data_Length, + uint8_t Advertising_Data[]); +/** + * @brief The ACI_GAP_SET_SCAN_RESPONSE_DATA function configures the scan + * response data as requested by the application. + * @param Advertising_Handle Used to identify an advertising set. This parameter + * is only meaningful if Extended Advertising Feature is enabled. + * Values: + * - 0x00 ... 0xEF + * @param Scan_Response_Data_Length Length of scan response data. If the + * advertising set uses scannable legacy advertising PDUs maximum length + * is 31 octets. + * @param Scan_Response_Data Pointer to the buffer containing properly formatted + * scan response data (see Core v5.1 Vol 3, part C, chapter 11). Its + * content must not change, until an + * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * application that the buffer is no more used by the Bluetooth stack. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_set_scan_response_data(uint8_t Advertising_Handle, + uint16_t Scan_Response_Data_Length, + uint8_t Scan_Response_Data[]); +/** + * @brief + * @param Session_Key + * @param IV + * @param Data_Length + * @param Data + * @param[out] Encrypted_Data + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_encrypt_adv_data(uint8_t Session_Key[16], + uint8_t IV[8], + uint8_t Data_Length, + uint32_t * Data, + uint8_t *Encrypted_Data); +/** + * @brief + * @param Session_Key + * @param IV + * @param Encrypted_Data_Length + * @param Encrypted_Data + * @param[out] Decrypted_Data + * @retval Value indicating success or error code. + */ +tBleStatus aci_gap_decrypt_adv_data(uint8_t Session_Key[16], + uint8_t IV[8], + uint8_t Encrypted_Data_Length, + uint8_t * Encrypted_Data, + uint32_t *Decrypted_Data); +/** + * @} + */ + +/** + * @} + */ + + +/** + *@addtogroup GATT GATT + *@brief Generic Attribute Profile. + *@{ + */ +/** + *@defgroup ACI_GATT_Commands ACI GATT Commands + *@brief Commands for GATT layer. + *@{ + */ +/** + * @brief Masks events from the GATT. The default configuration is all the + * events unmasked (enabled). + * @param GATT_Evt_Mask GATT/ATT event mask. + * Values: + * - 0x00000001: ACI_GATT_ATTRIBUTE_MODIFIED_EVENT + * - 0x00000002: ACI_GATT_PROC_TIMEOUT_EVENT + * - 0x00000004: ACI_ATT_EXCHANGE_MTU_RESP_EVENT + * - 0x00000008: ACI_ATT_FIND_INFO_RESP_EVENT + * - 0x00000010: ACI_ATT_FIND_BY_TYPE_VALUE_RESP_EVENT + * - 0x00000020: ACI_ATT_READ_BY_TYPE_RESP_EVENT + * - 0x00000040: ACI_ATT_READ_RESP_EVENT + * - 0x00000080: ACI_ATT_READ_BLOB_RESP_EVENT + * - 0x00000100: ACI_ATT_READ_MULTIPLE_RESP_EVENT + * - 0x00000200: ACI_ATT_READ_BY_GROUP_TYPE_RESP_EVENT + * - 0x00000800: ACI_ATT_PREPARE_WRITE_RESP_EVENT + * - 0x00001000: ACI_ATT_EXEC_WRITE_RESP_EVENT + * - 0x00002000: ACI_GATT_INDICATION_EVENT + * - 0x00004000: ACI_GATT_NOTIFICATION_EVENT + * - 0x00008000: ACI_GATT_ERROR_RESP_EVENT + * - 0x00010000: ACI_GATT_PROC_COMPLETE_EVENT + * - 0x00020000: ACI_GATT_DISC_READ_CHAR_BY_UUID_RESP_EVENT + * - 0x00040000: ACI_GATT_TX_POOL_AVAILABLE_EVENT + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_set_event_mask(uint32_t GATT_Evt_Mask); +/** + * @brief Performs an ATT MTU exchange procedure. When the ATT MTU exchange + * procedure is completed, a @ref aci_att_exchange_mtu_resp_event event + * is generated. A @ref aci_gatt_clt_proc_complete_event event is also + * generated to indicate the end of the procedure. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_exchange_config(uint16_t Connection_Handle); +/** + * @brief Sends a Prepare Write Request. The Prepare Write Request is used to + * request the server to prepare to write the value of an attribute. The + * responses of the procedure are given through the @ref + * aci_att_clt_prepare_write_resp_event event. The end of the procedure + * is indicated by a @ref aci_gatt_clt_proc_complete_event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Attr_Handle Handle of the attribute to be written + * Values: + * - 0x0001 ... 0xFFFF + * @param Val_Offset The offset of the first octet to be written + * Values: + * - 0 ... 511 + * @param Attribute_Val_Length Length of attribute value (maximum value is + * ATT_MTU - 5). + * @param Attribute_Val The value of the attribute to be written + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_prepare_write_req(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); +/** + * @brief Sends an Execute Write Request. The Execute Write Request is used to + * request the server to write or cancel the write of all the prepared + * values currently held in the prepare queue from this client. The + * result of the procedure is given through the @ref + * aci_att_clt_exec_write_resp_event event. The end of the procedure is + * indicated by a @ref aci_gatt_clt_proc_complete_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Execute Execute or cancel writes. + * Values: + * - 0x00: Cancel all prepared writes + * - 0x01: Immediately write all pending prepared values + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_execute_write_req(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Execute); +/** + * @brief Starts the GATT client procedure to discover all primary services on + * the server. The responses of the procedure are given through the @ref + * aci_att_clt_read_by_group_type_resp_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_disc_all_primary_services(uint16_t Connection_Handle, + uint16_t CID); +/** + * @brief Starts the procedure to discover the primary services of the specified + * UUID on the server. The responses of the procedure are given through + * the @ref aci_att_clt_find_by_type_value_resp_event event. The end of + * the procedure is indicated by a @ref aci_gatt_clt_proc_complete_event + * event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param UUID_Type UUID type. + * Values: + * - 0x01: 16-bit UUID + * - 0x02: 128-bit UUID + * @param UUID See @ref UUID_t + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_disc_primary_service_by_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint8_t UUID_Type, + UUID_t *UUID); +/** + * @brief Starts the procedure to find all included services. The responses of + * the procedure are given through the @ref + * aci_att_clt_read_by_type_resp_event event. The end of the procedure is + * indicated by a @ref aci_gatt_clt_proc_complete_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Start_Handle Start attribute handle of the service + * Values: + * - 0x0001 ... 0xFFFF + * @param End_Handle End attribute handle of the service + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_find_included_services(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle); +/** + * @brief Starts the procedure to discover all the characteristics of a given + * service. When the procedure is completed, a @ref + * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * completion the response packets are given through @ref + * aci_att_clt_read_by_type_resp_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Start_Handle Start attribute handle of the service + * Values: + * - 0x0001 ... 0xFFFF + * @param End_Handle End attribute handle of the service + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_disc_all_char_of_service(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle); +/** + * @brief Starts the procedure to discover all the characteristics specified by + * a UUID. When the procedure is completed, a @ref + * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * completion the response packets are given through @ref + * aci_gatt_clt_disc_read_char_by_uuid_resp_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Start_Handle Start attribute handle of the service + * Values: + * - 0x0001 ... 0xFFFF + * @param End_Handle End attribute handle of the service + * Values: + * - 0x0001 ... 0xFFFF + * @param UUID_Type UUID type. + * Values: + * - 0x01: 16-bit UUID + * - 0x02: 128-bit UUID + * @param UUID See @ref UUID_t + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_disc_char_by_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle, + uint8_t UUID_Type, + UUID_t *UUID); +/** + * @brief Starts the procedure to discover all characteristic descriptors on the + * server. When the procedure is completed, a @ref + * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * completion the response packets are given through @ref + * aci_att_clt_find_info_resp_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Char_Handle Handle of the characteristic value + * Values: + * - 0x0001 ... 0xFFFF + * @param End_Handle End handle of the characteristic + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_disc_all_char_desc(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Char_Handle, + uint16_t End_Handle); +/** + * @brief Starts the procedure to read an attribute value. When the procedure is + * completed, a @ref aci_gatt_clt_proc_complete_event event is generated. + * Before procedure completion the response packet is given through @ref + * aci_att_clt_read_resp_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Attr_Handle Handle of the attribute to be read + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_read(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle); +/** + * @brief Starts the procedure to read all the characteristics specified by the + * UUID. When the procedure is completed, a @ref + * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * completion the response packets are given through @ref + * aci_gatt_clt_disc_read_char_by_uuid_resp_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Start_Handle Starting handle of the range to be searched + * Values: + * - 0x0001 ... 0xFFFF + * @param End_Handle End handle of the range to be searched + * Values: + * - 0x0001 ... 0xFFFF + * @param UUID_Type UUID type. + * Values: + * - 0x01: 16-bit UUID + * - 0x02: 128-bit UUID + * @param UUID See @ref UUID_t + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_read_using_char_uuid(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle, + uint8_t UUID_Type, + UUID_t *UUID); +/** + * @brief Starts the procedure to read a long attribute value. the procedure is + * completed, a @ref aci_gatt_clt_proc_complete_event event is generated. + * Before procedure completion the response packets are given through + * @ref aci_att_clt_read_blob_resp_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Attr_Handle Handle of the attribute to be read + * Values: + * - 0x0001 ... 0xFFFF + * @param Val_Offset Offset from which the value needs to be read + * Values: + * - 0 ... 511 + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_read_long(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset); +/** + * @brief Starts a procedure to read multiple characteristic values from a + * server. This sub-procedure is used to read multiple Characteristic + * Values from a server when the client knows the Characteristic Value + * Handles. Only values that have a known fixed size can be read, with + * the exception of the last value that can have a variable length. When + * the procedure is completed, a @ref aci_gatt_clt_proc_complete_event + * event is generated. Before procedure completion the response packets + * are given through @ref aci_att_clt_read_multiple_resp_event event. The + * response only contains a set of Characteristic Values that is less + * than or equal to (ATT_MTU - 1) octets in length. If the Set Of Values + * is greater than (ATT_MTU - 1) octets in length, only the first + * (ATT_MTU - 1) octets are included in the response. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Number_of_Handles The number of handles for which the value has to be + * read. From 2 to (ATT_MTU-1)/2 + * Values: + * - 0x02 ... 0xFF + * @param Handle The handles for which the attribute value has to be read + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_read_multiple_char_value(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Number_of_Handles, + uint16_t Handle[]); +/** + * @brief Starts the procedure to write a characteristic value without waiting + * for any response from the server. No events are generated after this + * command is executed. Writing attributes using this function is not + * considered reliable by the standard: packets may be discarded by the + * peer if too many write commands are received. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Attr_Handle Handle of the attribute to be written + * Values: + * - 0x0001 ... 0xFFFF + * @param Attribute_Val_Length Length of the value to be written (maximum value + * is ATT_MTU - 3) + * @param Attribute_Val Value to be written + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_write_without_resp(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); +/** + * @brief Starts a signed write without response from the server. The procedure + * is used to write a characteristic value with an authentication + * signature without waiting for any response from the server. It cannot + * be used when the link is encrypted, and therefore it cannot be used on + * enhanced ATT bearers. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Attr_Handle Handle of the attribute to be written + * Values: + * - 0x0001 ... 0xFFFF + * @param Attribute_Val_Length Length of the value to be written (up to ATT_MTU + * - 13) + * @param Attribute_Val Value to be written + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_signed_write_without_resp(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); +/** + * @brief Allow application to confirm indication. This command has to be sent + * when the application receives the event @ref + * aci_gatt_clt_indication_event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_confirm_indication(uint16_t Connection_Handle, + uint16_t CID); +/** + * @brief Send an indication or notification for the provided attribute handle. + * The Flags parameter indicates what kind of message will be sent: -) + * 0x00 Send a notification -) 0x02 Send an indication + * @param Connection_Handle Connection handle to be used to identify the + * connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Attr_Handle Handle of the attribute to be notified + * Values: + * - 0x0001 ... 0xFFFF + * @param Flags Select the notification type. + * Values: + * - 0x00: GATT_NOTIFICATION + * - 0x02: GATT_INDICATION + * @param Val_Length Length of the Val field. + * @param Val + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_notify(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Flags, + uint16_t Val_Length, + uint8_t Val[]); +/** + * @brief Updates an attribute value for that kind of attributes that have + * different values for each connection, i.e. the Client Characteristic + * Configuration Descriptors. WARNING: use of this function can affect + * interoperability. Do not use the function unless you are aware of what + * you are doing. + * @param Connection_Handle Connection handle for which the attribute value will + * be written. + * @param Attr_Handle Handle of the attribute + * Values: + * - 0x0001 ... 0xFFFF + * @param Value_Length Length of the attribute value in octets. + * @param Value Attribute value. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_write_multiple_instance_handle_value(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Value_Length, + uint8_t Value[]); +/** + * @brief Notify multiple characteristic values to a client. + * @param Connection_Handle Connection handle for which the attribute value will + * be read. + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Flags Reserved for future use. Its value must be set to 0. + * Values: + * - 0x00 + * @param Num_Of_Attr + * @param Gatt_Srv_Notify_Attr See @ref Gatt_Srv_Notify_Attr_t + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_multi_notify(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Flags, + uint8_t Num_Of_Attr, + Gatt_Srv_Notify_Attr_t Gatt_Srv_Notify_Attr[]); +/** + * @brief This sub-procedure is used to read multiple Characteristic Values from + * a server when the client knows the Characteristic Value Handles. This + * procedure is useful when the attributes to read have a variable or + * unknown value length (otherwise aci_gatt_clt_read_multiple_char_value + * may be used). When the procedure is completed, a @ref + * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * completion the response packets are given through @ref + * aci_att_clt_read_multiple_var_len_resp_event event. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Number_of_Handles The number of handles for which the value has to be + * read. From 2 to (ATT_MTU-1)/2 + * Values: + * - 0x02 ... 0xFF + * @param Handle The handles for which the attribute value has to be read + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_read_multiple_var_len_char_value(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Number_of_Handles, + uint16_t Handle[]); +/** + * @brief Adds a service to the GATT database. When a service is created, the + * host may reserve a range of handles for this service. + * @param Service_p The pointer to the service definition. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_add_service(ble_gatt_srv_def_t * Service_p); +/** + * @brief Includes a service given by Included_Service_Handle to another service + * given by Service_Handle. Attribute server creates an Include + * definition attribute and returns the handle of this attribute. + * @param Service_Handle Handle of the Service to which another service has to + * be included. + * Values: + * - 0x0001 ... 0xFFFF + * @param Included_Service_Handle Attribute Handle of the Service which has to + * be included in service + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_include_service(uint16_t Service_Handle, + uint16_t Included_Service_Handle); +/** + * @brief Adds a characteristic to a service. + * @param Char_p The pointer to the Characteristic definition. + * @param Service_Handle Handle of the Service to which the characteristic will + * be added. + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_add_char(ble_gatt_chr_def_t * Char_p, + uint16_t Service_Handle); +/** + * @brief Adds a characteristic descriptor to a characteristic. + * @param Descr_p The pointer to the Descriptor definition. + * @param Char_Handle The Characteristic handle. + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_add_char_desc(ble_gatt_descr_def_t * Descr_p, + uint16_t Char_Handle); +/** + * @brief Deletes the specified service from the GATT server database. + * @param Serv_Handle Handle of the service to be deleted + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_rm_service(uint16_t Serv_Handle); +/** + * @brief Deletes the include definition from the service. + * @param Include_Handle Handle of the included service which has to be deleted + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_rm_include_service(uint16_t Include_Handle); +/** + * @brief Deletes the specified characteristic from the service. + * @param Char_Handle Handle of the characteristic which has to be deleted + * Values: + * - 0x0001 ... 0xFFFF + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_rm_char(uint16_t Char_Handle); +/** + * @brief This function retrieve the Attribute Handle assigned to the Service + * registered using the provided definition structure. + * @param Serv_p The Service definition structure. + * @return Attribute Handle of Service or BLE_ATT_INVALID_ATTR_HANDLE on error. + */ +uint16_t aci_gatt_srv_get_service_handle(ble_gatt_srv_def_t * Serv_p); +/** + * @brief This function retrieve the Attribute Handle assigned to the Include + * Service. + * @param Serv_Attr_Handle The Handle of the including Service. + * @param Included_Srv_p The Included Service definition structure. + * @return Attribute Handle of Service or BLE_ATT_INVALID_ATTR_HANDLE on error. + */ +uint16_t aci_gatt_srv_get_include_service_handle(uint16_t Serv_Attr_Handle, + ble_gatt_srv_def_t * Included_Srv_p); +/** + * @brief This function retrieve the Attribute Handle assigned to the + * Characteristic registered using the provided definition structure. + * @param Char_p The Characteristic definition structure. + * @return Attribute Handle of Service or BLE_ATT_INVALID_ATTR_HANDLE on error. + */ +uint16_t aci_gatt_srv_get_char_decl_handle(ble_gatt_chr_def_t * Char_p); +/** + * @brief This function retrieve the Attribute Handle assigned to the + * Characteristic Descriptor registered using the provided definition + * structure. + * @param Descr_p The Characteristic Descriptor definition structure. + * @return Attribute Handle of Service or BLE_ATT_INVALID_ATTR_HANDLE on error. + */ +uint16_t aci_gatt_srv_get_descriptor_handle(ble_gatt_descr_def_t * Descr_p); +/** + * @brief Reads the value of the attribute handle specified from the local GATT + * database. This command cannot be used to read attributes that have + * different values for each connection, e.g. the Client Characteristic + * Configuration Descriptors or Client Supported Features Characteristic + * (in this case, aci_gatt_srv_read_multiple_instance_handle_value needs + * to be used). + * @param Attr_Handle Handle of the attribute to read + * Values: + * - 0x0001 ... 0xFFFF + * @param[out] Length Length of the attribute value + * @param[out] Value Pointer to the Attribute Value. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_read_handle_value(uint16_t Attr_Handle, + uint16_t *Length, + uint8_t * *Value); +/** + * @brief Command to be given in response to aci_gatt_srv_read_event, + * aci_gatt_srv_write_event, aci_att_srv_prepare_write_req_event or + * aci_att_srv_exec_write_req_event. It ends the ATT transaction + * initiated by the remote client. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Attr_Handle Attribute handle for which the response command is issued. + * @param Error_Code The reason why the request has generated an error response + * (ATT error codes) + * Values: + * - 0x01: Invalid handle + * - 0x02: Read not permitted + * - 0x03: Write not permitted + * - 0x04: Invalid PDU + * - 0x05: Insufficient authentication + * - 0x06: Request not supported + * - 0x07: Invalid offset + * - 0x08: Insufficient authorization + * - 0x09: Prepare queue full + * - 0x0A: Attribute not found + * - 0x0B: Attribute not long + * - 0x0C: Insufficient encryption key size + * - 0x0D: Invalid attribute value length + * - 0x0E: Unlikely error + * - 0x0F: Insufficient encryption + * - 0x10: Unsupported group type + * - 0x11: Insufficient resources + * @param Val_Length Length of the Val field. + * @param Val Pointer to the value that must be returned in the response, in + * case this is a reply to an aci_gatt_srv_read_event(). In other cases + * it is ignored. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_resp(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Error_Code, + uint16_t Val_Length, + uint8_t Val[]); +/** + * @brief Starts the procedure to write an attribute (characteristic value or + * descriptor). When the procedure is completed, a @ref + * aci_gatt_clt_proc_complete_event event is generated. Note: the buffer + * containing the value to be written must be kept valid until the @ref + * aci_gatt_clt_proc_complete_event is received + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Attr_Handle Handle of the attribute to be written + * Values: + * - 0x0001 ... 0xFFFF + * @param Attribute_Val_Length Length of the value to be written + * @param Attribute_Val + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_write(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t Attribute_Val[]); +/** + * @brief This procedure is used to write an Attribute Value to a Server when + * the Client knows the Attribute Handle but the length of the Value is + * longer than what can be sent in a single Write Request Attribute + * Protocol message. During the procedure, + * aci_att_clt_prepare_write_resp_event and + * aci_att_clt_exec_write_resp_event are raised. Note: The memory + * pointed by Write_Ops_p parameter and the buffer containing the value + * to be written must be kept valid while the procedure is running. They + * can be released (or their content can be changed) when the + * aci_gatt_clt_proc_complete_event is emitted indicating that the + * procedure is completed, or an error was received. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Write_Ops_p The pointer to structure that holds the write information. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_write_long(uint16_t Connection_Handle, + uint16_t CID, + ble_gatt_clt_write_ops_t * Write_Ops_p); +/** + * @brief Starts the procedure to write a characteristic reliably (a check is + * made on the written values). When the procedure is completed, a @ref + * aci_gatt_clt_proc_complete_event event is generated. During the + * procedure, @ref aci_att_clt_prepare_write_resp_event and @ref + * aci_att_clt_exec_write_resp_event events are raised. Note: The memory + * pointed by Write_Ops_p parameter and the buffer containing the value + * to be written must be kept valid while the procedure is running. They + * can be released (or their content can be changed) when the + * aci_gatt_clt_proc_complete_event is emitted indicating that the + * procedure is completed, or an error was received. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID Channel Identifier of the ATT bearer. It must be set to 0x0004 for + * unenhanced ATT bearer. + * @param Num_Attrs The number of attributes to write, i.e. the number of + * elements in the list pointed by Write_Ops_p. + * @param Write_Ops_p The pointer to the list of structures that hold the write + * information. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_write_char_reliable(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Num_Attrs, + ble_gatt_clt_write_ops_t * Write_Ops_p); +/** + * @brief Read the value for that kind of attributes that have different values + * for each connection, i.e. Client Characteristic Configuration + * Descriptors or Client Supported Features Characteristic. + * @param Connection_Handle Connection handle for which the attribute value will + * be read. + * @param Attr_Handle Handle of the attribute + * Values: + * - 0x0001 ... 0xFFFF + * @param[out] Value_Length + * @param[out] Value Pointer to the buffer containing the value. Content may no + * more be valid after another call to this function or to + * BLE_STACK_Tick(). + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_srv_read_multiple_instance_handle_value(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t *Value_Length, + uint8_t * *Value); +/** + * @} + */ + +/** + * @} + */ + + +/** + *@addtogroup L2CAP L2CAP + *@brief Logical Link Control and Adaptation Protocol. + *@{ + */ +/** + *@defgroup ACI_L2CAP_Commands ACI L2CAP Commands + *@brief Commands for L2CAP layer. + *@{ + */ +/** + * @brief Send an L2CAP connection parameter update request from the peripheral + * to the central. An @ref aci_l2cap_connection_update_resp_event event + * will be raised when the central will respond to the request (accepts + * or rejects). + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Connection_Interval_Min Minimum value for the connection event + * interval. This shall be less than or equal to Connection_Interval_Max. + * Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Connection_Interval_Max Maximum value for the connection event + * interval. This shall be greater than or equal to + * Connection_Interval_Min. Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Peripheral_Latency Maximum Peripheral latency for the connection in + * number of connection events. + * Values: + * - 0x0000 ... 0x01F3 + * @param Timeout_Multiplier Defines connection timeout parameter in the + * following manner: Timeout Multiplier * 10ms. + * Values: + * - 10 (100 ms) ... 3200 (32000 ms) + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_connection_parameter_update_req(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Peripheral_Latency, + uint16_t Timeout_Multiplier); +/** + * @brief Accept or reject a connection update. This command should be sent in + * response to a @ref aci_l2cap_connection_update_req_event event from + * the controller. The accept parameter has to be set if the connection + * parameters given in the event are acceptable. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Connection_Interval_Min Minimum value for the connection event + * interval. This shall be less than or equal to Connection_Interval_Max. + * Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Connection_Interval_Max Maximum value for the connection event + * interval. This shall be greater than or equal to + * Connection_Interval_Min. Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + * @param Peripheral_Latency Maximum Peripheral latency for the connection in + * number of connection events. + * Values: + * - 0x0000 ... 0x01F3 + * @param Timeout_Multiplier Defines connection timeout parameter in the + * following manner: Timeout Multiplier * 10ms. + * Values: + * - 10 (100 ms) ... 3200 (32000 ms) + * @param Min_CE_Length The minimum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @param Max_CE_Length The maximum length of connection event recommended for + * this LE connection. Time = N * 0.625 msec. + * @param Identifier Identifier received in ACI_L2CAP_Connection_Update_Req + * event. + * @param Accept Specify if connection update parameters are acceptable or not. + * Values: + * - 0x00: Reject + * - 0x01: Accept + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_connection_parameter_update_resp(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Peripheral_Latency, + uint16_t Timeout_Multiplier, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length, + uint8_t Identifier, + uint8_t Accept); +/** + * @brief Create and configure an L2CAP channel between two devices using either + * LE Credit Based Flow Control Mode or Enhanced Credit Based Flow + * Control Mode. + * @param Connection_Handle Handle identifying the connection. + * @param SPSM Simplified Protocol/Service Multiplexer + * Values: + * - 0x0001 ... 0x00FF + * @param MTU The maximum SDU size (in octets) that the L2CAP layer entity + * sending the L2CAP_LE_CREDIT_BASED_CONNECTION_REQ can receive on this + * channel. + * Values: + * - 23 ... 65535 + * @param MPS The maximum PDU payload size (in octets) that the L2CAP layer + * entity sending the L2CAP_LE_CREDIT_BASED_CONNECTION_REQ is capable of + * receiving on this channel. + * Values: + * - 23 ... 65533 + * @param Channel_Type + * @param CID_Count + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_cos_connection_req(uint16_t Connection_Handle, + uint16_t SPSM, + uint16_t MTU, + uint16_t MPS, + uint8_t Channel_Type, + uint8_t CID_Count); +/** + * @brief Command to be sent to respond to a request to open an L2CAP channel + * using LE Credit based Flow Control or Enhanced Credit Based Flow + * Control Mode. The request is notified through + * aci_l2cap_cos_connection_req_event(). + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param Identifier Identifier of the request. + * @param MTU The MTU field specifies the maximum SDU size (in octets) that the + * L2CAP layer entity sending the L2CAP_LE_CREDIT_BASED_CONNECTION_RSP + * can receive on this channel. + * Values: + * - 23 ... 65535 + * @param MPS The MPS field specifies the maximum PDU payload size (in octets) + * that the L2CAP layer entity sending the + * L2CAP_LE_CREDIT_BASED_CONNECTION_RSP is capable of receiving on this + * channel. + * Values: + * - 23 ... 65533 + * @param Result It indicates the outcome of the connection request. A result + * value of 0x0000 indicates success while a non-zero value indicates a + * fail. + * Values: + * - 0x0000: L2CAP_CONNECTION_SUCCESSFUL + * - 0x0002: L2CAP_CONN_FAIL_SPSM_NOT_SUPPORTED + * - 0x0004: L2CAP_CONN_FAIL_INSUFFICIENT_RESOURCES + * - 0x0005: L2CAP_CONN_FAIL_INSUFFICIENT_AUTHENTICATION + * - 0x0006: L2CAP_CONN_FAIL_INSUFFICIENT_AUTHORIZATION + * - 0x0007: L2CAP_CONN_FAIL_KEY_SIZE_TOO_SHORT + * - 0x0008: L2CAP_CONN_FAIL_INSUFFICIENT_ENCRYPTION + * - 0x0009: L2CAP_CONN_FAIL_INVALID_SOURCE_CID + * - 0x000A: L2CAP_CONN_FAIL_SOURCE_CID_ALREADY_ALLOCATED + * - 0x000B: L2CAP_CONN_FAIL_UNACCEPTABLE_PARAMETERS + * @param CID_Count + * @param[out] CID + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_cos_connection_resp(uint16_t Connection_Handle, + uint8_t Identifier, + uint16_t MTU, + uint16_t MPS, + uint16_t Result, + uint8_t CID_Count, + uint16_t CID[]); +/** + * @brief Command to terminate an L2CAP channel. + * @param Connection_Handle + * @param CID Local endpoint of the channel to be disconnected. + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_cos_disconnect_req(uint16_t Connection_Handle, + uint16_t CID); +/** + * @brief Function to be called to send an SDU using an L2CAP channel in LE + * Credit Based Flow Control mode or Enhanced Credit Based Flow Control + * Mode. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID The local channel endpoint that identifies the L2CAP channel. + * @param SDU_Length Length of the SDU to be transmitted. + * @param SDU_Data Data contained in the SDU to be transmitted. Data must be + * valid until the SDU is transmitted. + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_cos_sdu_data_transmit(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Length, + uint8_t SDU_Data[]); +/** + * @brief Command to send an L2CAP_CREDIT_BASED_RECONFIGURE_REQ packet in order + * to request to change its receive MTU or MPS values compared to when + * the channels were created or last reconfigured. + * @param Connection_Handle Identifier received in the + * aci_eatt_connection_event. + * @param MTU The maximum SDU size (in octets) that the L2CAP layer entity can + * receive on each of the Source CID channels (represented by Local_CID + * array parameter). This is equal to the maximum size of an ATT packet + * on the Enhanced ATT bearer. + * Values: + * - 0x0040 ... 0xFFFF + * @param MPS The maximum PDU payload size (in octets) that the local L2CAP + * layer is capable of receiving on each of the Source CID channels + * (represented by Local_CID array parameter). + * Values: + * - 0x0040 ... 0xFFFF + * @param CID_Count The number of potential Enhanced ATT bearers that are going + * to be opened. This is the number of L2CAP channels to be opened in + * Enhanced Credit Based Flow Control mode. + * Values: + * - 0x01 ... 0x05 + * @param CID List of CID values representing the channel endpoints on the local + * device. Each entry in the array shall be non-zero and represents a + * request for a channel. The value of each CID shall be from the + * dynamically allocated range for LE devices (0x0040-0x007F) and shall + * not be already allocated to a different channel on the device sending + * the request. + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_cos_reconfigure_req(uint16_t Connection_Handle, + uint16_t MTU, + uint16_t MPS, + uint8_t CID_Count, + uint16_t CID[]); +/** + * @brief Command to send an L2CAP_CREDIT_BASED_RECONFIGURE_RSP packet in order + * to respond to an incoming L2CAP_CREDIT_BASED_RECONFIGURE_REQ. It has + * to be used upon the reception of an + * ACI_L2CAP_ECFC_RECONFIGURATION_EVENT. + * @param Connection_Handle Identifier received in the + * aci_eatt_connection_event. + * @param Identifier Identifier received in the aci_eatt_connection_event. + * @param Result It indicates the outcome of the connection request. A result + * value of 0x0000 indicates success while a non-zero value indicates the + * connection request was refused. + * Values: + * - 0x0000: L2CAP_RECONFIG_SUCCESSFUL + * - 0x0001: L2CAP_MTU_REDUCTION_NOT_ALLOWED + * - 0x0002: L2CAP_MPS_REDUCTION_NOT_ALLOWED + * - 0x0003: L2CAP_INVALID_DESTINATION_CID + * - 0x0004: L2CAP_UNACCEPTABLE_PARAMETERS + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_cos_reconfigure_resp(uint16_t Connection_Handle, + uint8_t Identifier, + uint16_t Result); +/** + * @brief Function to be used to extract an SDU from receiving buffer. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID The local channel endpoint that identifies the L2CAP channel. + * @param SDU_Data_Buffer_Size Size of the buffer where SDU will be copied. + * @param[in] SDU_Data_Buffer Buffer where the extracted SDU will be copied. + * @param[out] SDU_Length Length of the extracted SDU. + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_cos_sdu_data_extract(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Data_Buffer_Size, + void * SDU_Data_Buffer, + uint16_t *SDU_Length); +/** + * @} + */ + +/** + * @} + */ + +#endif /* _BLE_API_H_ */ diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_const.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_const.h new file mode 100644 index 000000000..8697fc760 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_const.h @@ -0,0 +1,1090 @@ +/** + ****************************************************************************** + * @file ble_const.h + * @author GPM WBL Application Team + * @brief Header file that includes Bluetooth LE stack defines for APIs + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef __BLE_CONST_H__ +#define __BLE_CONST_H__ + +#include "ble_gatt.h" +#include "uuid.h" +#include "compiler.h" +/** + *@addtogroup HCI HCI + *@{ + */ + +/** + * @defgroup Link_Layer Link Layer constants and types + * @brief Constants and types related to Link Layer functions + * @{ + */ + +/* Macros for Enable parameters in HCI commands. */ +#define HCI_DISABLE 0x00 +#define HCI_ENABLE 0x01 + +#define BD_ADDR_SIZE 0x06U + +/* Address types */ +#define HCI_ADDR_PUBLIC 0x00U +#define HCI_ADDR_RANDOM_ADDR 0x01U +#define HCI_ADDR_STATIC_RANDOM_ADDR 0x01U +#define HCI_ADDR_RESOLVABLE_PRIVATE_ADDR 0x02U +#define HCI_ADDR_NON_RESOLVABLE_PRIVATE_ADDR 0x03U + +/* HCI_LE_Set_Advertising_Parameters: Advertising_Type */ +#define HCI_ADV_TYPE_ADV_IND 0x00U +#define HCI_ADV_TYPE_ADV_DIRECT_IND_HDC 0x01U +#define HCI_ADV_TYPE_ADV_SCAN_IND 0x02U +#define HCI_ADV_TYPE_ADV_NONCONN_IND 0x03U +#define HCI_ADV_TYPE_ADV_DIRECT_IND_LDC 0x04U + +/* HCI_LE_Set_Advertising_Parameters: Advertising_Filter_Policy */ +#define HCI_ADV_FILTER_NONE 0x00U +#define HCI_ADV_FILTER_ACCEPT_LIST_SCAN 0x01U +#define HCI_ADV_FILTER_ACCEPT_LIST_CONNECT 0x02U +#define HCI_ADV_FILTER_ACCEPT_LIST_SCAN_CONNECT 0x03U + +#define HCI_ADV_CH_37 0x01U +#define HCI_ADV_CH_38 0x02U +#define HCI_ADV_CH_39 0x04U +#define HCI_ADV_CH_ALL 0x07U + +/* HCI_LE_Set_[Advertising/Scan]_Parameters: Own_Address_Type */ +#define HCI_OWN_ADDR_TYPE_PUBLIC 0x00U +#define HCI_OWN_ADDR_TYPE_RANDOM 0x01U +#define HCI_OWN_ADDR_TYPE_RP_OR_PUBLIC 0x02U +#define HCI_OWN_ADDR_TYPE_RP_OR_RANDOM 0x03U + +/* HCI_LE_Set_Scan_Parameters: LE_Scan_Type */ +#define HCI_SCAN_TYPE_PASSIVE 0x00U +#define HCI_SCAN_TYPE_ACTIVE 0x01U + +/* HCI_LE_Set_Scan_Parameters: Scanning_Filter_Policy */ +#define HCI_SCAN_FILTER_BASIC_UNFILTERED 0x00U +#define HCI_SCAN_FILTER_BASIC_FILTERED 0x01U +#define HCI_SCAN_FILTER_EXTENDED_UNFILTERED 0x02U +#define HCI_SCAN_FILTER_EXTENDED_FILTERED 0x03U + +/* HCI_LE_Create_Connection: Initiator_Filter_Policy */ +#define HCI_INIT_FILTER_ACCEPT_LIST_NONE 0x00U +#define HCI_INIT_FILTER_ACCEPT_LIST 0x01U + +/* HCI_LE_Read_PHY: TX_PHY */ +#define HCI_TX_PHY_LE_1M 0x01U +#define HCI_TX_PHY_LE_2M 0x02U +#define HCI_TX_PHY_LE_CODED 0x03U + +/* HCI_LE_Read_PHY: RX_PHY */ +#define HCI_RX_PHY_LE_1M 0x01U +#define HCI_RX_PHY_LE_2M 0x02U +#define HCI_RX_PHY_LE_CODED 0x03U + +/* HCI_LE_Set_PHY: ALL_PHYS */ +#define HCI_ALL_PHYS_TX_NO_PREF 0x01U +#define HCI_ALL_PHYS_RX_NO_PREF 0x02U + +/* HCI_LE_Set_PHY: TX_PHYS */ +#define HCI_TX_PHYS_LE_1M_PREF 0x01U +#define HCI_TX_PHYS_LE_2M_PREF 0x02U +#define HCI_TX_PHYS_LE_CODED_PREF 0x04U + +/* HCI_LE_Set_PHY: RX_PHYS */ +#define HCI_RX_PHYS_LE_1M_PREF 0x01U +#define HCI_RX_PHYS_LE_2M_PREF 0x02U +#define HCI_RX_PHYS_LE_CODED_PREF 0x04U + +/* HCI_LE_Set_Extended_Advertising_Parameters: Advertising_Event_Properties */ +#define HCI_ADV_EVENT_PROP_NONE 0x0000U +#define HCI_ADV_EVENT_PROP_CONNECTABLE 0x0001U +#define HCI_ADV_EVENT_PROP_SCANNABLE 0x0002U +#define HCI_ADV_EVENT_PROP_DIRECTED 0x0004U +#define HCI_ADV_EVENT_PROP_HDC_DIRECTED 0x0008U +#define HCI_ADV_EVENT_PROP_LEGACY 0x0010U +#define HCI_ADV_EVENT_PROP_ANONYMOUS 0x0020U +#define HCI_ADV_EVENT_PROP_TXPOWER_INC 0x0040U + +/* HCI_LE_Set_Extended_Advertising_Parameters: Primary_Advertising_PHY and Secondary_Advertising_PHY */ +#define HCI_ADV_PHY_LE_1M 0x01U +#define HCI_ADV_PHY_LE_2M 0x02U +#define HCI_ADV_PHY_LE_CODED 0x03U + +/* HCI_LE_Set_Extended_Advertising_Data: Operation */ +#define HCI_SET_ADV_DATA_OPERATION_INTERMEDIATE 0x00U +#define HCI_SET_ADV_DATA_OPERATION_FIRST 0x01U +#define HCI_SET_ADV_DATA_OPERATION_LAST 0x02U +#define HCI_SET_ADV_DATA_OPERATION_COMPLETE 0x03U +#define HCI_SET_ADV_DATA_OPERATION_UNCHANGED 0x04U + +/* HCI_LE_Advertising_Report: Event_Type */ +#define HCI_ADV_EVT_TYPE_ADV_IND 0x00U +#define HCI_ADV_EVT_TYPE_ADV_DIRECT_IND 0x01U +#define HCI_ADV_EVT_TYPE_ADV_SCAN_IND 0x02U +#define HCI_ADV_EVT_TYPE_ADV_NONCONN_IND 0x03U +#define HCI_ADV_EVT_TYPE_SCAN_RSP 0x04U + +/* HCI_LE_Extended_Advertising_Report: Event_Type */ +#define HCI_EXT_ADV_EVT_TYPE_CONNECTABLE 0x0001U +#define HCI_EXT_ADV_EVT_TYPE_SCANNABLE 0x0002U +#define HCI_EXT_ADV_EVT_TYPE_DIRECTED 0x0004U +#define HCI_EXT_ADV_EVT_TYPE_SCAN_RESP 0x0008U +#define HCI_EXT_ADV_EVT_TYPE_LEGACY 0x0010U +#define HCI_EXT_ADV_EVT_TYPE_DATA_STATUS_MASK 0x0060U +#define HCI_EXT_ADV_EVT_TYPE_DATA_STATUS_COMPLETE 0x0000U +#define HCI_EXT_ADV_EVT_TYPE_DATA_STATUS_MORE_DATA 0x0020U +#define HCI_EXT_ADV_EVT_TYPE_DATA_STATUS_TRUNCATED 0x0040U + +/* HCI_LE_Set_Extended_Scan_Parameters: Scanning_PHYs */ +#define HCI_SCANNING_PHYS_LE_1M 0x01U +#define HCI_SCANNING_PHYS_LE_CODED 0x04U + +/* HCI_LE_Extended_Create_Connection: Initiating_PHYs */ +#define HCI_INIT_PHYS_SCAN_CONN_LE_1M 0x01U +#define HCI_INIT_PHYS_CONN_LE_2M 0x02U +#define HCI_INIT_PHYS_SCAN_CONN_LE_CODED 0x04U + +/* HCI_LE_Receiver_Test/HCI_LE_Transmitter_Test [v2]: PHY */ +#define HCI_TEST_PHY_LE_1M 0x01U +#define HCI_TEST_PHY_LE_2M 0x02U + +/* HCI_LE_Connection_Complete/HCI_LE_Enhanced_Connection_Complete: Role */ +#define HCI_ROLE_CENTRAL 0x00U +#define HCI_ROLE_PERIPHERAL 0x01U + +/* HCI_LE_Set_Privacy_Mode: Privacy_Mode */ +#define HCI_PRIV_MODE_NETWORK 0x00U +#define HCI_PRIV_MODE_DEVICE 0x01U + +/* HCI_LE_Periodic_Advertising_Report: Data_Status */ +#define HCI_PADV_DATA_STATUS_COMPLETE 0x00U +#define HCI_PADV_DATA_STATUS_MORE_DATA 0x01U +#define HCI_PADV_DATA_STATUS_TRUNCATED 0x02U +#define HCI_PADV_DATA_STATUS_FAILED 0xFFU + + +/** + * @name Duplicate filtering + * @{ + */ +#define DUPLICATE_FILTER_DISABLED 0 +#define DUPLICATE_FILTER_ENABLED 1 +#define DUPLICATE_FILTER_ENABLED_FOR_SCAN_PERIOD 2 +/** + * @} + */ + +/** + * @name Bitmasks for Link Layer PHYs + * @{ + */ +#define LE_1M_PHY_BIT 0x01 +#define LE_2M_PHY_BIT 0x02 +#define LE_CODED_PHY_BIT 0x04 + +/** + * @} + */ + +/** + * @name Values for Link Layer PHYs + * @{ + */ +#define HCI_PHY_LE_1M 0x01 +#define HCI_PHY_LE_2M 0x02 +#define HCI_PHY_LE_CODED 0x03 +#define HCI_PHY_LE_CODED_S8 0x03 +#define HCI_PHY_LE_CODED_S2 0x04 + +/** + * @} + */ + +/** + * @name Link Layer State + * @{ + */ +#define LL_IDLE 0x00 +#define LL_ADV 0x01 +#define LL_CONN_SLAVE 0x02 +#define LL_SCAN 0x03 +#define LL_CONN_REQ 0x04 +#define LL_CONN_MASTER 0x05 +#define LL_TX_TEST 0x06 +#define LL_RX_TEST 0x07 +/** + * @} + */ + +/** + * @name CTE Type + * @{ + */ +#define CTE_AOA 0x00 +#define CTE_AOD_1us 0x01 +#define CTE_AOD_2us 0x02 +/** + * @} + */ + +/** + * @name CTE Type bitmask + * @{ + */ +#define CTE_AOA_BIT 0x01 +#define CTE_AOD_1us_BIT 0x02 +#define CTE_AOD_2us_BIT 0x04 +/** + * @} + */ + +/** + * @name CTE Slot Duration + * @{ + */ +#define CTE_SLOT_1us 0x01 +#define CTE_SLOT_2us 0x02 +/** + * @} + */ + +/** + * @name Reason for hci_le_transmit_power_reporting_event() + * @{ + */ +#define LOCAL_TX_POWER_CHANGE 0x00 +#define REMOTE_TX_POWER_CHANGE 0x01 +#define READ_REMOTE_TX_POWER_COMPLETE 0x02 +/** + * @} + */ + +/** + * @name Transmit_Power_Level value + * @{ + */ +#define POWER_NOT_MANAGED 0x7E +#define POWER_NA 0x7F +/** + * @} + */ + +/** + * @name Transmit_Power_Level_Flag values + * @{ + */ +#define MIN_TX_POWER_BIT 0x01 +#define MAX_TX_POWER_BIT 0x02 +/** + * @} + */ + +/** + * @name LE Event Mask + * @see hci_le_set_event_mask() + * @{ + */ +#define HCI_LE_EVT_MASK_BYTE0_CONNECTION_COMPLETE (0x01U) +#define HCI_LE_EVT_MASK_BYTE0_ADVERTISING_REPORT (0x02U) +#define HCI_LE_EVT_MASK_BYTE0_CONNECTION_UPDATE_COMPLETE (0x04U) +#define HCI_LE_EVT_MASK_BYTE0_READ_REMOTE_FEATURES_COMPLETE (0x08U) +#define HCI_LE_EVT_MASK_BYTE0_LTK_REQUEST (0x10U) +#define HCI_LE_EVT_MASK_BYTE0_REMOTE_CONNECTION_PARAMETER_REQUEST (0x20U) +#define HCI_LE_EVT_MASK_BYTE0_DATA_LEN_CHANGE (0x40U) +#define HCI_LE_EVT_MASK_BYTE0_READ_LOCAL_P256_COMPLETE (0x80U) +#define HCI_LE_EVT_MASK_BYTE1_GENERATE_DHKEY_COMPLETE (0x01U) +#define HCI_LE_EVT_MASK_BYTE1_ENHANCED_CONNECTION_COMPLETE (0x02U) +#define HCI_LE_EVT_MASK_BYTE1_DIRECTED_ADVERTISING_REPORT (0x04U) +#define HCI_LE_EVT_MASK_BYTE1_PHY_UPDATE_COMPLETE (0x08U) +#define HCI_LE_EVT_MASK_BYTE1_EXTENDED_ADVERTISING_REPORT (0x10U) +#define HCI_LE_EVT_MASK_BYTE1_PERIODIC_ADVERTISING_SYNC_ESTABLISHED (0x20U) +#define HCI_LE_EVT_MASK_BYTE1_PERIODIC_ADVERTISING_REPORT (0x40U) +#define HCI_LE_EVT_MASK_BYTE1_PERIODIC_ADVERTISING_SYNC_LOST (0x80U) +#define HCI_LE_EVT_MASK_BYTE2_SCAN_TIMEOUT (0x01U) +#define HCI_LE_EVT_MASK_BYTE2_ADVERTISING_SET_TERMINATED (0x02U) +#define HCI_LE_EVT_MASK_BYTE2_SCAN_REQUEST_RECEIVED (0x04U) +#define HCI_LE_EVT_MASK_BYTE2_CHANNEL_SELECTION_ALGORITHM (0x08U) +#define HCI_LE_EVT_MASK_BYTE2_CONNECTIONLESS_IQ_REPORT (0x10U) +#define HCI_LE_EVT_MASK_BYTE2_CONNECTION_IQ_REPORT (0x20U) +#define HCI_LE_EVT_MASK_BYTE2_CTE_REQUEST_FAILED (0x40U) +#define HCI_LE_EVT_MASK_BYTE2_PERIODIC_ADVERTISING_SYNC_TRANSFER (0x80U) +#define HCI_LE_EVT_MASK_BYTE3_CIS_ESTABLISHED (0x01U) +#define HCI_LE_EVT_MASK_BYTE3_CIS_REQUEST (0x02U) +#define HCI_LE_EVT_MASK_BYTE3_CREATE_BIG_COMPLETE (0x04U) +#define HCI_LE_EVT_MASK_BYTE3_TERMINATE_BIG_COMPLETE (0x08U) +#define HCI_LE_EVT_MASK_BYTE3_BIG_SYNC_ESTABLISHED (0x10U) +#define HCI_LE_EVT_MASK_BYTE3_BIG_SYNC_LOST (0x20U) +#define HCI_LE_EVT_MASK_BYTE3_REQUEST_PEER_SCA_COMPLETE (0x40U) +#define HCI_LE_EVT_MASK_BYTE3_PATH_LOSS_THRESHOLD (0x80U) +#define HCI_LE_EVT_MASK_BYTE4_TRANSMIT_POWER_REPORTING (0x01U) +#define HCI_LE_EVT_MASK_BYTE4_BIG_INFO_ADVERTISING_REPORT (0x02U) +#define HCI_LE_EVT_MASK_BYTE4_SUBRATE_CHANGE (0x04U) +#define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_SYNC_ESTABLISHED_V2 (0x08U) +#define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_REPORT_V2 (0x10U) +#define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_SYNC_TRANSFER_V2 (0x20U) +#define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_SUBEVENT_DATA_REQ (0x40U) +#define HCI_LE_EVT_MASK_BYTE4_PERIODIC_ADVERTISING_RESPONSE_REPORT (0x80U) +#define HCI_LE_EVT_MASK_BYTE5_ENHANCED_CONNECTION_COMPLETE_V2 (0x01U) + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + *@addtogroup HAL_LL HAL/LL + *@{ + */ +/** + *@addtogroup HAL_constants HAL/LL Constants + *@brief Constants for Hardware abstraction Layer and Link Layer. + *@{ + */ + +/** + * @name Configuration values. + * See @ref aci_hal_write_config_data() and @ref aci_hal_read_config_data(). + * @{ + */ +#define CONFIG_DATA_PUBADDR_OFFSET (0x00) /**< Bluetooth public address */ +#define CONFIG_DATA_ER_OFFSET (0x08) /**< Encryption root key used to derive LTK and CSRK */ +#define CONFIG_DATA_IR_OFFSET (0x18) /**< Identity root key used to derive LTK and CSRK */ +#define CONFIG_DATA_LL_WITHOUT_HOST (0x2C) /**< Switch on/off Link Layer only mode. Set to 1 to disable Host. + It can be written only if aci_hal_write_config_data() is the first command + after reset. */ +#define CONFIG_DATA_STATIC_RANDOM_ADDRESS (0x2E) /**< To set the static random address used by the stack, instead of the one stored in NVM. */ +#define CONFIG_DATA_SCAN_CH_MAP (0x2F) /**< To set the channel map for scanning. */ +#define CONFIG_DATA_STORED_STATIC_RANDOM_ADDRESS (0x80) /**< The static random address stored in NVM. */ +#define CONFIG_DATA_DEBUG_KEY (0xD0) /**< Use debug key for secure connections. */ +#define CONFIG_DATA_DLE (0xD1) /**< To set the maximum allowed parameter values for Data Length Extension */ +/** + * @} + */ + +/** + * @name Length for configuration values. + * See @ref aci_hal_write_config_data() and @ref aci_hal_read_config_data(). + * @{ + */ +#define CONFIG_DATA_PUBADDR_LEN (6) +#define CONFIG_DATA_ER_LEN (16) +#define CONFIG_DATA_IR_LEN (16) +#define CONFIG_DATA_LL_WITHOUT_HOST_LEN (1) +#define CONFIG_DATA_STATIC_RANDOM_ADDRESS_LEN (6) +#define CONFIG_DATA_SCAN_CH_MAP_LEN (1) +#define CONFIG_DATA_DEBUG_KEY_LEN (1) +#define CONFIG_DATA_DLE_LEN (1) +/** + * @} + */ + + +/** + * @name Types for fw error event + * @brief See aci_hal_fw_error_event(). + * @{ + */ + +#define HAL_FW_L2CAP_RECOMBINATION_ERROR 0x01 /**< L2CAP layer failed recombining a PDU */ +#define HAL_FW_GATT_UNEXPECTED_RESPONSE_ERROR 0x02 /**< GATT layer received an unexpteced response. Peer probably violated the ATT protocol. */ +#define HAL_FW_GATT_SEQUENTIAL_PROTOCOL_ERROR 0x03 /**< GATT layer received an unexpteced request. Peer probably violated the sequentiality of ATT protocol. */ +#define HAL_FW_BONDING_DB_FULL_GATTSERVICE_ERROR 0x04 /**< No space to store info GATT database info in NVM. Database needs to be cleaned up (remove invalidated records) or some bonding entries need to be removed. */ +#define HAL_FW_BONDING_DB_FULL_PAIRING_ERROR 0x05 /**< No space to store bonding info in NVM. Database needs to be cleaned up (remove invalidated records) or some bonding entries need to be removed. */ +#define HAL_FW_SCHEDULER_OVERRUN_ERROR 0x06 /**< Link Layer scheduler failed to reschedule slots for too many times. This may indicate an unrecoverable situation. A system reset is recommended. */ +#define HAL_FW_MEMBUF_NOT_AVAILABLE 0x07 /**< Out of memory resources for isochronous channels. */ +#define HAL_FW_CTE_TIMER_PROGRAM_ERROR 0x08 /**< Error in programming timer for CTE reception functionality. */ +#define HAL_FW_MBM_RESOURCE_MISS 0x09 /**< Requested resources are not available. */ + +/** + * @} + */ + + /** + * @name Types for aci_hal_pawr_data_free_event() + * @brief See aci_hal_pawr_data_free_event(). + * @{ + */ + +#define HAL_PAWR_DATA_TYPE_SUBEVENT 0x00 /**< PAwR subevevent data */ +#define HAL_PAWR_DATA_TYPE_RESPONSE 0x01 /**< PAwR response data */ + +/** + * @} + */ + +/** + * @} + */ +/** + * @} + */ + + +/** + *@addtogroup GAP GAP + *@brief Generic Access Profile + *@{ + */ + +/** + *@addtogroup GAP_constants GAP Constants + *@brief Constants for GAP layer + *@{ + */ + +/** + * @name Characteristic value lengths + * @{ + */ +#define APPEARANCE_CHAR_LEN (2) +#define PERIPHERAL_PREFERRED_CONN_PARAMS_CHAR_LEN (8) +#define CENTRAL_ADDRESS_RESOLUTION_CHAR_LEN (1) +/** + * @} + */ + +/** + * @name AD Types + * @brief AD types for adv data and scan response data + * @{ + */ + +#define AD_TYPE_FLAGS (0x01) + +#define AD_TYPE_16_BIT_SERV_UUID (0x02) +#define AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST (0x03) +#define AD_TYPE_32_BIT_SERV_UUID (0x04) +#define AD_TYPE_32_BIT_SERV_UUID_CMPLT_LIST (0x05) +#define AD_TYPE_128_BIT_SERV_UUID (0x06) +#define AD_TYPE_128_BIT_SERV_UUID_CMPLT_LIST (0x07) + +#define AD_TYPE_SHORTENED_LOCAL_NAME (0x08) +#define AD_TYPE_COMPLETE_LOCAL_NAME (0x09) + +/** TX power level AD type*/ +#define AD_TYPE_TX_POWER_LEVEL (0x0A) + +/** Class of device */ +#define AD_TYPE_CLASS_OF_DEVICE (0x0D) + +/** Security manager TK value AD type */ +#define AD_TYPE_SEC_MGR_TK_VALUE (0x10) + +/** Security manager OOB flags */ +#define AD_TYPE_SEC_MGR_OOB_FLAGS (0x11) + +/** Slave connection interval AD type */ +#define AD_TYPE_SLAVE_CONN_INTERVAL (0x12) + +#define AD_TYPE_SERV_SOLICIT_16_BIT_UUID_LIST (0x14) +#define AD_TYPE_SERV_SOLICIT_32_BIT_UUID_LIST (0x1F) +#define AD_TYPE_SERV_SOLICIT_128_BIT_UUID_LIST (0x15) + +#define AD_TYPE_16_BIT_UUID_SERVICE_DATA (0x16) +#define AD_TYPE_32_BIT_UUID_SERVICE_DATA (0x20) +#define AD_TYPE_128_BIT_UUID_SERVICE_DATA (0x21) + +/** Manufaturer specific data AD type */ +#define AD_TYPE_MANUFACTURER_SPECIFIC_DATA (0xFF) + +/** + * @} + */ + +/** + * @name Flags AD Type bits + * @brief Bits for Flags AD Type + * @{ + */ +#define FLAG_BIT_LE_LIMITED_DISCOVERABLE_MODE (0x01) +#define FLAG_BIT_LE_GENERAL_DISCOVERABLE_MODE (0x02) +#define FLAG_BIT_BR_EDR_NOT_SUPPORTED (0x04) +#define FLAG_BIT_LE_BR_EDR_CONTROLLER (0x08) +#define FLAG_BIT_LE_BR_EDR_HOST (0x10) +/** + * @} + */ + + +/** + * @name GAP modes + * @{ + */ +#define GAP_MODE_NON_DISCOVERABLE 0 +#define GAP_MODE_LIMITED_DISCOVERABLE 1 +#define GAP_MODE_GENERAL_DISCOVERABLE 2 +#define GAP_MODE_BROADCAST 3 +/** + * @} + */ + +/** + * @name Privacy type + * @{ + */ +#define PRIVACY_DISABLED (0x00) +#define PRIVACY_HOST_ENABLED (0x01) +#define PRIVACY_CONTROLLER_ENABLED (0x02) +/** + * @} + */ + +/** + * @name Operation + * Values for Operation parameter (see aci_gap_set_advertising_data()). + * @{ + */ +#define ADV_COMPLETE_DATA (0x03) +#define ADV_UNCHANGED_DATA (0x04) +/** + * @} + */ + +/** + * @name Recommended advertising intervals + * Intervals in terms of 625 micro seconds + * @{ + */ +#define GAP_ADV_INT_MIN_USER_INITIATED_CONN (48) /* 30 ms */ +#define GAP_ADV_INT_MAX_USER_INITIATED_CONN (96) /* 60 ms */ +#define GAP_ADV_INT_MIN_USER_INITIATED_NONCONN (160) /* 100 ms */ +#define GAP_ADV_INT_MAX_USER_INITIATED_NONCONN (240) /* 150 ms */ +#define GAP_ADV_INT_MIN_BACKGROUND (1600) /* 1 s */ +#define GAP_ADV_INT_MAX_BACKGROUND (1920) /* 1.2 s */ +/** + * @} + */ + +/** + * @anchor gap_roles + * @name GAP Roles + * @{ +*/ +#define GAP_PERIPHERAL_ROLE (0x01) +#define GAP_BROADCASTER_ROLE (0x02) +#define GAP_CENTRAL_ROLE (0x04) +#define GAP_OBSERVER_ROLE (0x08) +/** + * @} + */ + +/** + * @anchor gap_procedure_codes + * @name GAP procedure codes + * Procedure codes for aci_gap_start_procedure() + * and aci_gap_terminate_proc() commands. + * @{ + */ +#define GAP_LIMITED_DISCOVERY_PROC (0x00) +#define GAP_GENERAL_DISCOVERY_PROC (0x01) +#define GAP_AUTO_CONNECTION_ESTABLISHMENT_PROC (0x02) +#define GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC (0x03) +#define GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC (0x04) +#define GAP_OBSERVATION_PROC (0x05) +#define GAP_DIRECT_CONNECTION_ESTABLISHMENT_PROC (0x06) +#define GAP_NAME_DISCOVERY_PROC (0x07) + +/** + * @} + */ + +/** + * @anchor gap_appearance_values + * @name GAP Appearance values + * Values for GAP Appearance characteristic. + * @{ + */ +#define GAP_APPEARANCE_UNKNOWN 0x0000 +#define GAP_APPEARANCE_GENERIC_PHONE 0x0040 +#define GAP_APPEARANCE_GENERIC_COMPUTER 0x0080 +#define GAP_APPEARANCE_GENERIC_WATCH 0x00C0 +#define GAP_APPEARANCE_WATCH_SPORT_WATCH 0x00C1 +#define GAP_APPEARANCE_GENERIC_CLOCK 0x0100 +#define GAP_APPEARANCE_GENERIC_DISPLAY 0x0140 +#define GAP_APPEARANCE_GENERIC_REMOTE_CONTROL 0x0180 +#define GAP_APPEARANCE_GENERIC_EYE_GLASSES 0x01C0 +#define GAP_APPEARANCE_GENERIC_TAG 0x0200 +#define GAP_APPEARANCE_GENERIC_KEYRING 0x0240 +#define GAP_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280 +#define GAP_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0 +#define GAP_APPEARANCE_GENERIC_THERMOMETER 0x0300 +#define GAP_APPEARANCE_THERMOMETER_EAR 0x0301 +#define GAP_APPEARANCE_GENERIC_HEART_RATE_SENSOR 0x0340 +#define GAP_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 0x0341 +#define GAP_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380 +#define GAP_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381 +#define GAP_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382 +#define GAP_APPEARANCE_HUMAN_INTERFACE_DEVICE 0x03C0 +#define GAP_APPEARANCE_KEYBOARD 0x03C1 +#define GAP_APPEARANCE_MOUSE 0x03C2 +#define GAP_APPEARANCE_JOYSTICK 0x03C3 +#define GAP_APPEARANCE_GAMEPAD 0x03C4 +#define GAP_APPEARANCE_DIGITIZER_TABLET 0x03C5 +#define GAP_APPEARANCE_CARD_READER 0x03C6 +#define GAP_APPEARANCE_DIGITAL_PEN 0x03C7 +#define GAP_APPEARANCE_BARCODE_SCANNER 0x03C8 +#define GAP_APPEARANCE_GENERIC_GLUCOSE_METER 0x0400 +#define GAP_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 0x0440 +#define GAP_APPEARANCE_RUNNING_WALKING_IN_SHOE 0x0441 +#define GAP_APPEARANCE_RUNNING_WALKING_ON_SHOE 0x0442 +#define GAP_APPEARANCE_RUNNING_WALKING_ON_HIP 0x0443 +#define GAP_APPEARANCE_GENERIC_CYCLING 0x0480 +#define GAP_APPEARANCE_CYCLING_CYCLING_COMPUTER 0x0481 +#define GAP_APPEARANCE_CYCLING_SPEED_SENSOR 0x0482 +#define GAP_APPEARANCE_CYCLING_CADENCE_SENSOR 0x0483 +#define GAP_APPEARANCE_CYCLING_POWER_SENSOR 0x0484 +#define GAP_APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR 0x0485 +#define GAP_APPEARANCE_GENERIC_PULSE_OXYMETER 0x0C40 +#define GAP_APPEARANCE_FINGERTIP 0x0C41 +#define GAP_APPEARANCE_WRIST_WORN 0x0C42 +#define GAP_APPEARANCE_GENERIC_WEIGHT_SCALE 0x0C80 +#define GAP_APPEARANCE_GENERIC_OUTDOOR_SPORT_ACTIVITY 0x1440 +#define GAP_APPEARANCE_LOCATION_DISPLAY_DEVICE 0x1441 +#define GAP_APPEARANCE_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE 0x1442 +#define GAP_APPEARANCE_LOCATION_POD 0x1443 +#define GAP_APPEARANCE_LOCATION_AND_NAVIGATION_POD 0x1444 +#define GAP_APPEARANCE_GENERIC_ENVIRONMENTAL_SENSOR 0x1640 + +/** + * @} + */ + +/** + * @anchor IO_capabilities + * @name IO capabilities + * @{ + */ +#define GAP_IO_CAP_DISPLAY_ONLY 0x00 +#define GAP_IO_CAP_DISPLAY_YES_NO 0x01 +#define GAP_IO_CAP_KEYBOARD_ONLY 0x02 +#define GAP_IO_CAP_NO_INPUT_NO_OUTPUT 0x03 +#define GAP_IO_CAP_KEYBOARD_DISPLAY 0x04 +/** + * @} + */ + +/** + * @anchor Auth_req + * @name Authentication requirements + * @{ + */ +#define BONDING (0x01) +#define NO_BONDING (0x00) +/** + * @} + */ + +/** + * @anchor MITM_req + * @name MITM protection requirements + * @{ + */ +#define GAP_MITM_PROTECTION_NOT_REQUIRED 0x00 +#define GAP_MITM_PROTECTION_REQUIRED 0x01 +/** + * @} + */ + +/** + * @anchor OOB_Data + * @name Out-Of-Band data + * @{ + */ +#define OOB_AUTH_DATA_ABSENT (0x00) +#define OOB_AUTH_DATA_PRESENT (0x01) +/** + * @} + */ + +/** + * @anchor Author_req + * @name Authorization requirements + * @{ + */ +#define AUTHORIZATION_NOT_REQUIRED (0x00) +#define AUTHORIZATION_REQUIRED (0x01) +/** + * @} + */ + +/** + * @anchor Conn_authorization + * @name Connection authorization + * @{ + */ +#define CONNECTION_AUTHORIZED (0x01) +#define CONNECTION_REJECTED (0x02) +/** + * @} + */ + +/** + * @anchor link_security_status + * @name Link security status + * @{ + */ +#define SM_LINK_AUTHENTICATED (0x01) +#define SM_LINK_AUTHORIZED (0x02) +#define SM_LINK_ENCRYPTED (0x04) +/** + * @} + */ + +/** + * @anchor SMP_pairing_failed_codes + * @name SMP pairing failed reason codes + * @{ + */ +#define PASSKEY_ENTRY_FAILED (0x01) +#define OOB_NOT_AVAILABLE (0x02) +#define AUTH_REQ_CANNOT_BE_MET (0x03) +#define CONFIRM_VALUE_FAILED (0x04) +#define PAIRING_NOT_SUPPORTED (0x05) +#define INSUFF_ENCRYPTION_KEY_SIZE (0x06) +#define CMD_NOT_SUPPORTED (0x07) +#define UNSPECIFIED_REASON (0x08) +#define VERY_EARLY_NEXT_ATTEMPT (0x09) +#define SM_INVALID_PARAMS (0x0A) +/** + * @} + */ + +/** + * @anchor pairing_failed_codes + * @name Pairing failed error codes + * Error codes in @ref aci_gap_pairing_complete_event event + * @{ + */ +#define SM_PAIRING_SUCCESS (0x00) +#define SM_PAIRING_TIMEOUT (0x01) +#define SM_PAIRING_FAILED (0x02) +/** + * @} + */ + +/** + * @anchor secure_connections_support + * @name Secure connection support option code + * Error codes in @ref aci_gap_set_authentication_requirement API + * @{ + */ +#define GAP_SC_NOT_SUPPORTED (0x00) /* Not supported */ +#define GAP_SC_OPTIONAL (0x01) /* Supported but optional (i.e. a Legacy Pairing may be accepted) */ +#define GAP_SC_MANDATORY (0x02) /* Supported but mandatory (i.e. do not accept Legacy Pairing but only Secure Connections v.4.2 Pairing) */ + +/** + * @} + */ + +/** + * @anchor keypress_support + * @name Secure connection key press notification option code + * Error codes in @ref aci_gap_set_authentication_requirement API + * @{ + */ +#define GAP_KEYPRESS_NOT_SUPPORTED (0x00) +#define GAP_KEYPRESS_SUPPORTED (0x01) + +/** + * @} + */ + +/** + * @anchor gap_pairing_resp + * @name Values for Pairing_Response parameter of aci_gap_set_security_requirements + * @{ + */ +#define GAP_PAIRING_RESP_NONE (0x00) +#define GAP_PAIRING_RESP_FOR_BONDED_DEVICES (0x01) +#define GAP_PAIRING_RESP_FOR_ALL (0x02) + + +/** + * @} + */ + + /** + * @anchor gap_security_level + * @name Values for Security_Level parameter of aci_gap_set_security + * @{ + */ +#define GAP_SECURITY_LEVEL_1 (0x01) +#define GAP_SECURITY_LEVEL_2 (0x02) +#define GAP_SECURITY_LEVEL_3 (0x03) +#define GAP_SECURITY_LEVEL_4 (0x04) + + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +/** + *@addtogroup GATT GATT + *@{ + */ +/** + *@defgroup GATT_constants GATT Constants + *@{ + */ + +/** + * @anchor Access_permissions + * @name Access permissions + * Access permissions for an attribute + * @{ + */ +#define ATTR_NO_ACCESS (0x00) +#define ATTR_ACCESS_READ_ONLY (0x01) +#define ATTR_ACCESS_WRITE_REQ_ONLY (0x02) +#define ATTR_ACCESS_READ_WRITE (0x03) +#define ATTR_ACCESS_WRITE_WITHOUT_RESPONSE (0x04) +#define ATTR_ACCESS_SIGNED_WRITE_ALLOWED (0x08) +/** + * Allows all write procedures + */ +#define ATTR_ACCESS_WRITE_ANY (0x0E) +/** + * @} + */ + +/** + * @anchor Char_properties + * @name Characteristic properties. + * @{ + */ +#define CHAR_PROP_BROADCAST (0x01) +#define CHAR_PROP_READ (0x02) +#define CHAR_PROP_WRITE_WITHOUT_RESP (0x04) +#define CHAR_PROP_WRITE (0x08) +#define CHAR_PROP_NOTIFY (0x10) +#define CHAR_PROP_INDICATE (0x20) +#define CHAR_PROP_SIGNED_WRITE (0x40) +#define CHAR_PROP_EXT (0x80) +/** + * @} + */ + + +/** + * @anchor Security_permissions + * @name Security permissions for an attribute. + * @{ + */ +#define ATTR_PERMISSION_NONE (0x00) /**< No security. */ +#define ATTR_PERMISSION_AUTHEN_READ (0x01) /**< Need authentication to read */ +#define ATTR_PERMISSION_AUTHOR_READ (0x02) /**< Need authorization to read */ +#define ATTR_PERMISSION_ENCRY_READ (0x04) /**< Link must be encrypted to read */ +#define ATTR_PERMISSION_AUTHEN_WRITE (0x08) /**< Need authentication to write */ +#define ATTR_PERMISSION_AUTHOR_WRITE (0x10) /**< Need authorization to write */ +#define ATTR_PERMISSION_ENCRY_WRITE (0x20) /**< Link must be encrypted for write */ +/** + * @} + */ + +/** + * @anchor UUID_Types + * @name Type of UUID (16 bit or 128 bit). + * @{ + */ +#define UUID_TYPE_16 (0x01) +#define UUID_TYPE_128 (0x02) +/** + * @} + */ + +/** + * @anchor Service_type + * @name Type of service (primary or secondary) + * @{ + */ +#define PRIMARY_SERVICE (0x01) +#define SECONDARY_SERVICE (0x02) +/** + * @} + */ + +/** + * @anchor Notification_type + * @name Type of notification + * @{ + */ +#define GATT_NOTIFICATION (0x00) +#define GATT_INDICATION (0x02) +/** + * @} + */ + +/** + * @anchor Gatt_Event_Mask + * @name Gatt Event Mask + * Type of event generated by GATT server + * @{ + */ +#define GATT_DONT_NOTIFY_EVENTS (0x00) /**< Do not notify events. */ +#define GATT_NOTIFY_ATTRIBUTE_WRITE (0x01) /**< The application will be notified when a client writes to this attribute. + An @ref aci_gatt_srv_attribute_modified_event will be issued. */ +#define GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP (0x02) /**< The application will be notified when a write request, a write cmd + or a signed write cmd are received by the server for this attribute.*/ +#define GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP (0x04) /**< The application will be notified when a read request of any type is + received for this attribute. */ +/** + * @} + */ + +/** + * @name Type of characteristic length + * See aci_gatt_add_char() + * @{ + */ +#define CHAR_VALUE_LEN_CONSTANT (0x00) +#define CHAR_VALUE_LEN_VARIABLE (0x01) +/** + * @} + */ + + +/** + * @name Encryption key size + * @{ + */ +/** + * Minimum encryption key size + */ +#define MIN_ENCRY_KEY_SIZE (7) + +/** + * Maximum encryption key size + */ +#define MAX_ENCRY_KEY_SIZE (0x10) +/** + * @} + */ + +/** + * @name Characteristic Presentation Format + * @{ + */ +typedef PACKED(struct) _charactFormat { + uint8_t format; + int8_t exp; + uint16_t unit; + uint8_t name_space; + uint16_t desc; +} charactFormat; + +/** + * @} + */ + +/** + * @name Format + * @{ + */ +#define FORMAT_UINT8 0x04 +#define FORMAT_UINT16 0x06 +#define FORMAT_SINT16 0x0E +#define FORMAT_SINT24 0x0F +/** + * @} + */ + +/** + * @name Unit + * @{ + */ +#define UNIT_UNITLESS 0x2700 +#define UNIT_TEMP_CELSIUS 0x272F +#define UNIT_PRESSURE_BAR 0x2780 +/** + * @} + */ + + +/** + * @} + */ +/** + * @} + */ + + +/** + *@addtogroup L2CAP L2CAP + *@{ + */ +/** + *@addtogroup L2CAP_constants L2CAP Constants + *@brief Constants for L2CAP layer. + *@{ + */ + +/** + *@name L2CAP Connection Event Type + *@see aci_l2cap_cfc_connection_event + *@{ + */ +#define L2CAP_CONN_REQ 0 +#define L2CAP_CONN_RESP 1 +/** + *@} + */ + +#define L2CAP_CHANNEL_TYPE_LE_CFC 0x00 +#define L2CAP_CHANNEL_TYPE_ECFC 0x01 + +#define L2CAP_CONN_SUCCESSFUL 0x0000 +#define L2CAP_CONN_FAIL_SPSM_NOT_SUPPORTED 0x0002 +#define L2CAP_CONN_FAIL_INSUFFICIENT_RESOURCES 0x0004 +#define L2CAP_CONN_FAIL_INSUFFICIENT_AUTHENTICATION 0x0005 +#define L2CAP_CONN_FAIL_INSUFFICIENT_AUTHORIZATION 0x0006 +#define L2CAP_CONN_FAIL_KEY_SIZE_TOO_SHORT 0x0007 +#define L2CAP_CONN_FAIL_INSUFFICIENT_ENCRYPTION 0x0008 +#define L2CAP_CONN_FAIL_INVALID_SOURCE_CID 0x0009 +#define L2CAP_CONN_FAIL_SOURCE_CID_ALREADY_ALLOCATED 0x000A +#define L2CAP_CONN_FAIL_UNACCEPTABLE_PARAMETERS 0x000B +#define L2CAP_CONN_FAIL_INVALID_PARAMETERS 0x000C +#define L2CAP_CONN_FAIL_NO_INFO 0x000D +#define L2CAP_CONN_FAIL_AUTHENTICATION_PENDING 0x000E +#define L2CAP_CONN_FAIL_AUTHORIZATION_PENDING 0x000F + +#define L2CAP_CFC_MANUAL 0x00 +#define L2CAP_CFC_AUTO 0x01 + +/** + *@} + */ +/** + *@} + */ + + +#endif /* __BLE_CONST_H__ */ diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_events.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_events.h new file mode 100644 index 000000000..07e7fdee1 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_events.h @@ -0,0 +1,999 @@ +/** + ****************************************************************************** + * @file ble_events.h + * @author GPM WBL Application team + * @brief Header file for Bluetooth Low Energy stack events callbacks + * Autogenerated files, do not edit!! + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef _BLE_EVENTS_H_ +#define _BLE_EVENTS_H_ + +#include "compiler.h" +#include "ble_types.h" + +/** + * @brief Format of packets coming from BLE Stack. + */ +typedef PACKED(struct) _hci_pckt{ + uint8_t type; /*!< Type of packet. For possible values see @ref HCI_pckt_type */ + uint8_t data[0]; /*!< HCI data packets. Format depends on type field. + It can be casted to one of @ref HCI_data_pckt_structs */ +} hci_pckt; + +/** @defgroup HCI_pckt_type HCI packet type + * @{ + */ +#define HCI_COMMAND_PKT_TYPE 0x01U /*!< Not used. */ +#define HCI_ACLDATA_PKT_TYPE 0x02U +#define HCI_EVENT_PKT_TYPE 0x04U +#define HCI_ISODATA_PKT_TYPE 0x05U +#define HCI_COMMAND_EXT_PKT_TYPE 0x81U /*!< Not used. */ +#define HCI_EVENT_EXT_PKT_TYPE 0x82U +#define HCI_VENDOR_PKT_TYPE 0xFFU /*!< Not used. */ +/** + * @} + */ + +/** @defgroup HCI_data_pckt_structs Structures for HCI data packets + * @{ + */ + +/** + * @brief Packet format of events. + * + * This is data field of hci_pckt if type field is equal to HCI_EVENT_PKT_TYPE. + */ +typedef PACKED(struct) _hci_event_pckt{ + uint8_t evt; /*!< One of @ref HCI_evt_code */ + uint8_t plen; /*!< Parameter Total Length, i.e. length of data field. */ + uint8_t data[0]; /*!< Event payload. To be casted to one of event struct types of @ref HCI_evt_structs. */ +} hci_event_pckt; + +/** + * @brief Packet format of extended proprietary events. + * + * This is data field of hci_pckt if type field is equal to HCI_EVENT_EXT_PKT_TYPE. + */ +typedef PACKED(struct) _hci_event_ext_pckt{ + uint8_t evt; /*!< HCI_VENDOR_EVT_CODE is the only allowed value. */ + uint16_t plen; /*!< Parameter Total Length, i.e. length of data field. */ + uint8_t data[0]; /*!< Event payload. To be casted to one of event struct types of @ref HCI_evt_structs. + Current possible type is only aci_blecore_event. */ +} hci_event_ext_pckt; + +/** + * @brief Packet format of ACL data packets. + * + * This is data field of hci_pckt if type field is equal to HCI_ACLDATA_PKT_TYPE. + */ +typedef PACKED(struct) _hci_acl_data_pckt{ + uint16_t handle_flags; /*!< This field includes Handle (12 bits), PB Flag (2 bits) and BC Flag (2 bits). */ + uint16_t dlen; /*!< Data Total Length. */ + uint8_t data[0]; /*!< Data. */ +} hci_acl_data_pckt; + +/** + * @brief Packet format of ISO data packets. + * + * This is data field of hci_pckt if type field is equal to HCI_ISODATA_PKT_TYPE. + */ +typedef PACKED(struct) _hci_iso_data_pckt{ + uint16_t handle_flags; /*!< This field includes Handle (12 bits), PB Flag (2 bits) and TS Flag (1 bit). */ + uint16_t dlen; /*!< Data Total Length (14 bits used, 2 msb are reserved). */ + uint8_t data[0]; /*!< Data. Format is described in Core v5.4 Vol. 4, part E, section 5.4.5. */ +} hci_iso_data_pckt; + +/** + * @} + */ + + +/** @defgroup HCI_evt_code HCI event codes + * @{ + */ + +#define HCI_DISCONNECTION_COMPLETE_EVT_CODE 0x05 +#define HCI_ENCRYPTION_CHANGE_EVT_CODE 0x08 +#define HCI_READ_REMOTE_VERSION_INFORMATION_COMPLETE_EVT_CODE 0x0C +#define HCI_HARDWARE_ERROR_EVT_CODE 0x10 +#define HCI_NUMBER_OF_COMPLETED_PACKETS_EVT_CODE 0x13 +#define HCI_DATA_BUFFER_OVERFLOW_EVT_CODE 0x1A +#define HCI_ENCRYPTION_KEY_REFRESH_COMPLETE_EVT_CODE 0x30 +#define HCI_AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED_EVT_CODE 0x57 +#define HCI_LE_META_EVT_CODE 0x3E +#define HCI_VENDOR_EVT_CODE 0xFF + +/** + * @} + */ + +/* Structs for events are never allocated. They are only used to cast a specific + event type. For this reason, this macro has no much importance for events. */ +#define HCI_MAX_PAYLOAD_SIZE 532 + +/** @defgroup HCI_evt_structs HCI event structures + * Types to be used to cast data field of @ref hci_event_pckt type + * @{ + */ +typedef PACKED(struct) hci_disconnection_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t Reason; +} hci_disconnection_complete_event_rp0; + +typedef PACKED(struct) hci_encryption_change_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t Encryption_Enabled; +} hci_encryption_change_event_rp0; + +typedef PACKED(struct) hci_read_remote_version_information_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t Version; + uint16_t Manufacturer_Name; + uint16_t Subversion; +} hci_read_remote_version_information_complete_event_rp0; + +typedef PACKED(struct) hci_hardware_error_event_rp0_s { + uint8_t Hardware_Code; +} hci_hardware_error_event_rp0; + +typedef PACKED(struct) hci_number_of_completed_packets_event_rp0_s { + uint8_t Number_of_Handles; + packed_Handle_Packets_Pair_Entry_t Handle_Packets_Pair_Entry[(HCI_MAX_PAYLOAD_SIZE - 1)/sizeof(packed_Handle_Packets_Pair_Entry_t)]; +} hci_number_of_completed_packets_event_rp0; + +typedef PACKED(struct) hci_data_buffer_overflow_event_rp0_s { + uint8_t Link_Type; +} hci_data_buffer_overflow_event_rp0; + +typedef PACKED(struct) hci_encryption_key_refresh_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_encryption_key_refresh_complete_event_rp0; + +typedef PACKED(struct) hci_authenticated_payload_timeout_expired_event_rp0_s { + uint16_t Connection_Handle; +} hci_authenticated_payload_timeout_expired_event_rp0; + +/** + * @brief Format of Standard LE Meta Events + * + * This is data field of @ref hci_event_pckt if evt field is equal to HCI_LE_META_EVT_CODE. + */ +typedef PACKED(struct) hci_le_meta_event_s { + uint8_t subevent; /*!< A value of @ref HCI_le_meta_evt_code. */ + uint8_t data[0]; /*!< LE Meta event. To be casted to a struct of @ref HCI_le_meta_evt_structs. */ +} hci_le_meta_event; + +/** + * @brief Format of proprietary events. + * + * This is data field of @ref hci_event_pckt or @ref hci_event_ext_pckt if evt field is equal to HCI_VENDOR_EVT_CODE. + */ +typedef PACKED(struct) aci_blecore_event_s { + uint16_t ecode; /*!< A value of @ref ACI_evt_code. */ + uint8_t data[0]; /*!< Proprietary event parameters. To be casted to a struct of @ref ACI_evt_structs. */ +} aci_blecore_event; + +/** + * @} + */ + + +/** @defgroup HCI_le_meta_evt_code HCI LE Meta subevent codes + * Codes found in subevent field of hci_le_meta_event struct. + * @{ + */ +#define HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE 0x01 +#define HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE 0x02 +#define HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE 0x03 +#define HCI_LE_READ_REMOTE_FEATURES_COMPLETE_SUBEVT_CODE 0x04 +#define HCI_LE_LONG_TERM_KEY_REQUEST_SUBEVT_CODE 0x05 +#define HCI_LE_DATA_LENGTH_CHANGE_SUBEVT_CODE 0x07 +#define HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_COMPLETE_SUBEVT_CODE 0x08 +#define HCI_LE_GENERATE_DHKEY_COMPLETE_SUBEVT_CODE 0x09 +#define HCI_LE_ENHANCED_CONNECTION_COMPLETE_SUBEVT_CODE 0x0A +#define HCI_LE_DIRECTED_ADVERTISING_REPORT_SUBEVT_CODE 0x0B +#define HCI_LE_PHY_UPDATE_COMPLETE_SUBEVT_CODE 0x0C +#define HCI_LE_EXTENDED_ADVERTISING_REPORT_SUBEVT_CODE 0x0D +#define HCI_LE_PERIODIC_ADVERTISING_SYNC_ESTABLISHED_SUBEVT_CODE 0x0E +#define HCI_LE_PERIODIC_ADVERTISING_REPORT_SUBEVT_CODE 0x0F +#define HCI_LE_PERIODIC_ADVERTISING_SYNC_LOST_SUBEVT_CODE 0x10 +#define HCI_LE_SCAN_TIMEOUT_SUBEVT_CODE 0x11 +#define HCI_LE_ADVERTISING_SET_TERMINATED_SUBEVT_CODE 0x12 +#define HCI_LE_SCAN_REQUEST_RECEIVED_SUBEVT_CODE 0x13 +#define HCI_LE_CHANNEL_SELECTION_ALGORITHM_SUBEVT_CODE 0x14 +#define HCI_LE_CONNECTIONLESS_IQ_REPORT_SUBEVT_CODE 0x15 +#define HCI_LE_CONNECTION_IQ_REPORT_SUBEVT_CODE 0x16 +#define HCI_LE_CTE_REQUEST_FAILED_SUBEVT_CODE 0x17 +#define HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED_SUBEVT_CODE 0x18 +#define HCI_LE_CIS_ESTABLISHED_SUBEVT_CODE 0x19 +#define HCI_LE_CIS_REQUEST_SUBEVT_CODE 0x1A +#define HCI_LE_CREATE_BIG_COMPLETE_SUBEVT_CODE 0x1B +#define HCI_LE_TERMINATE_BIG_COMPLETE_SUBEVT_CODE 0x1C +#define HCI_LE_BIG_SYNC_ESTABLISHED_SUBEVT_CODE 0x1D +#define HCI_LE_BIG_SYNC_LOST_SUBEVT_CODE 0x1E +#define HCI_LE_REQUEST_PEER_SCA_COMPLETE_SUBEVT_CODE 0x1F +#define HCI_LE_PATH_LOSS_THRESHOLD_SUBEVT_CODE 0x20 +#define HCI_LE_TRANSMIT_POWER_REPORTING_SUBEVT_CODE 0x21 +#define HCI_LE_BIGINFO_ADVERTISING_REPORT_SUBEVT_CODE 0x22 +#define HCI_LE_SUBRATE_CHANGE_SUBEVT_CODE 0x23 +#define HCI_LE_PERIODIC_ADVERTISING_SYNC_ESTABLISHED_V2_SUBEVT_CODE 0x24 +#define HCI_LE_PERIODIC_ADVERTISING_REPORT_V2_SUBEVT_CODE 0x25 +#define HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED_V2_SUBEVT_CODE 0x26 +#define HCI_LE_PERIODIC_ADVERTISING_SUBEVENT_DATA_REQUEST_SUBEVT_CODE 0x27 +#define HCI_LE_PERIODIC_ADVERTISING_RESPONSE_REPORT_SUBEVT_CODE 0x28 +#define HCI_LE_ENHANCED_CONNECTION_COMPLETE_V2_SUBEVT_CODE 0x29 +/** + * @} + */ + +/** @defgroup HCI_le_meta_evt_structs HCI LE Meta event structures + * Types to be used to cast data field of hci_le_meta_event type + * @{ + */ +typedef PACKED(struct) hci_le_connection_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t Role; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint16_t Connection_Interval; + uint16_t Peripheral_Latency; + uint16_t Supervision_Timeout; + uint8_t Central_Clock_Accuracy; +} hci_le_connection_complete_event_rp0; + +typedef PACKED(struct) hci_le_advertising_report_event_rp0_s { + uint8_t Num_Reports; + packed_Advertising_Report_t Advertising_Report; /* N elements of variable size */ +} hci_le_advertising_report_event_rp0; + +typedef PACKED(struct) hci_le_connection_update_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint16_t Connection_Interval; + uint16_t Peripheral_Latency; + uint16_t Supervision_Timeout; +} hci_le_connection_update_complete_event_rp0; + +typedef PACKED(struct) hci_le_read_remote_features_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t LE_Features[8]; +} hci_le_read_remote_features_complete_event_rp0; + +typedef PACKED(struct) hci_le_long_term_key_request_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Random_Number[8]; + uint16_t Encrypted_Diversifier; +} hci_le_long_term_key_request_event_rp0; + +typedef PACKED(struct) hci_le_data_length_change_event_rp0_s { + uint16_t Connection_Handle; + uint16_t MaxTxOctets; + uint16_t MaxTxTime; + uint16_t MaxRxOctets; + uint16_t MaxRxTime; +} hci_le_data_length_change_event_rp0; + +typedef PACKED(struct) hci_le_read_local_p256_public_key_complete_event_rp0_s { + uint8_t Status; + uint8_t Local_P256_Public_Key[64]; +} hci_le_read_local_p256_public_key_complete_event_rp0; + +typedef PACKED(struct) hci_le_generate_dhkey_complete_event_rp0_s { + uint8_t Status; + uint8_t DHKey[32]; +} hci_le_generate_dhkey_complete_event_rp0; + +typedef PACKED(struct) hci_le_enhanced_connection_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t Role; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Local_Resolvable_Private_Address[6]; + uint8_t Peer_Resolvable_Private_Address[6]; + uint16_t Connection_Interval; + uint16_t Peripheral_Latency; + uint16_t Supervision_Timeout; + uint8_t Central_Clock_Accuracy; +} hci_le_enhanced_connection_complete_event_rp0; + +typedef PACKED(struct) hci_le_directed_advertising_report_event_rp0_s { + uint8_t Num_Reports; + packed_Direct_Advertising_Report_t Direct_Advertising_Report[(HCI_MAX_PAYLOAD_SIZE - 1)/sizeof(packed_Direct_Advertising_Report_t)]; +} hci_le_directed_advertising_report_event_rp0; + +typedef PACKED(struct) hci_le_phy_update_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t TX_PHY; + uint8_t RX_PHY; +} hci_le_phy_update_complete_event_rp0; + +typedef PACKED(struct) hci_le_extended_advertising_report_event_rp0_s { + uint8_t Num_Reports; + packed_Extended_Advertising_Report_t Extended_Advertising_Report; /* N elements of variable size */ +} hci_le_extended_advertising_report_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_sync_established_event_rp0_s { + uint8_t Status; + uint16_t Sync_Handle; + uint8_t Advertising_SID; + uint8_t Advertiser_Address_Type; + uint8_t Advertiser_Address[6]; + uint8_t Advertiser_PHY; + uint16_t Periodic_Advertising_Interval; + uint8_t Advertiser_Clock_Accuracy; +} hci_le_periodic_advertising_sync_established_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_report_event_rp0_s { + uint16_t Sync_Handle; + int8_t TX_Power; + int8_t RSSI; + uint8_t CTE_Type; + uint8_t Data_Status; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} hci_le_periodic_advertising_report_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_sync_lost_event_rp0_s { + uint16_t Sync_Handle; +} hci_le_periodic_advertising_sync_lost_event_rp0; + +typedef PACKED(struct) hci_le_advertising_set_terminated_event_rp0_s { + uint8_t Status; + uint8_t Advertising_Handle; + uint16_t Connection_Handle; + uint8_t Num_Completed_Extended_Advertising_Events; +} hci_le_advertising_set_terminated_event_rp0; + +typedef PACKED(struct) hci_le_scan_request_received_event_rp0_s { + uint8_t Advertising_Handle; + uint8_t Scanner_Address_Type; + uint8_t Scanner_Address[6]; +} hci_le_scan_request_received_event_rp0; + +typedef PACKED(struct) hci_le_channel_selection_algorithm_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Channel_Selection_Algorithm; +} hci_le_channel_selection_algorithm_event_rp0; + +typedef PACKED(struct) hci_le_connectionless_iq_report_event_rp0_s { + uint16_t Sync_Handle; + uint8_t Channel_Index; + int16_t RSSI; + uint8_t RSSI_Antenna_ID; + uint8_t CTE_Type; + uint8_t Slot_Durations; + uint8_t Packet_Status; + uint16_t Periodic_Event_Counter; + uint8_t Sample_Count; + packed_Samples_t Samples[(HCI_MAX_PAYLOAD_SIZE - 12)/sizeof(packed_Samples_t)]; +} hci_le_connectionless_iq_report_event_rp0; + +typedef PACKED(struct) hci_le_connection_iq_report_event_rp0_s { + uint16_t Connection_Handle; + uint8_t RX_PHY; + uint8_t Data_Channel_Index; + int16_t RSSI; + uint8_t RSSI_Antenna_ID; + uint8_t CTE_Type; + uint8_t Slot_Durations; + uint8_t Packet_Status; + uint16_t Connection_Event_Counter; + uint8_t Sample_Count; + packed_Samples_t Samples[(HCI_MAX_PAYLOAD_SIZE - 13)/sizeof(packed_Samples_t)]; +} hci_le_connection_iq_report_event_rp0; + +typedef PACKED(struct) hci_le_cte_request_failed_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; +} hci_le_cte_request_failed_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_sync_transfer_received_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint16_t Service_data; + uint16_t Sync_Handle; + uint8_t Advertising_SID; + uint8_t Advertiser_Address_Type; + uint8_t Advertiser_Address[6]; + uint8_t Advertiser_PHY; + uint16_t Periodic_Advertising_Interval; + uint8_t Advertiser_Clock_Accuracy; +} hci_le_periodic_advertising_sync_transfer_received_event_rp0; + +typedef PACKED(struct) hci_le_cis_established_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t CIG_Sync_Delay[3]; + uint8_t CIS_Sync_Delay[3]; + uint8_t Transport_Latency_C_To_P[3]; + uint8_t Transport_Latency_P_To_C[3]; + uint8_t PHY_C_To_P; + uint8_t PHY_P_To_C; + uint8_t NSE; + uint8_t BN_C_To_P; + uint8_t BN_P_To_C; + uint8_t FT_C_To_P; + uint8_t FT_P_To_C; + uint16_t Max_PDU_C_To_P; + uint16_t Max_PDU_P_To_C; + uint16_t ISO_Interval; +} hci_le_cis_established_event_rp0; + +typedef PACKED(struct) hci_le_cis_request_event_rp0_s { + uint16_t ACL_Connection_Handle; + uint16_t CIS_Connection_Handle; + uint8_t CIG_ID; + uint8_t CIS_ID; +} hci_le_cis_request_event_rp0; + +typedef PACKED(struct) hci_le_create_big_complete_event_rp0_s { + uint8_t Status; + uint8_t BIG_Handle; + uint8_t BIG_Sync_Delay[3]; + uint8_t Transport_Latency_BIG[3]; + uint8_t PHY; + uint8_t NSE; + uint8_t BN; + uint8_t PTO; + uint8_t IRC; + uint16_t Max_PDU; + uint16_t ISO_Interval; + uint8_t Num_BIS; + uint16_t Connection_Handle[(HCI_MAX_PAYLOAD_SIZE - 18)/sizeof(uint16_t)]; +} hci_le_create_big_complete_event_rp0; + +typedef PACKED(struct) hci_le_terminate_big_complete_event_rp0_s { + uint8_t BIG_Handle; + uint8_t Reason; +} hci_le_terminate_big_complete_event_rp0; + +typedef PACKED(struct) hci_le_big_sync_established_event_rp0_s { + uint8_t Status; + uint8_t BIG_Handle; + uint8_t Transport_Latency_BIG[3]; + uint8_t NSE; + uint8_t BN; + uint8_t PTO; + uint8_t IRC; + uint16_t Max_PDU; + uint16_t ISO_Interval; + uint8_t Num_BIS; + uint16_t Connection_Handle[(HCI_MAX_PAYLOAD_SIZE - 14)/sizeof(uint16_t)]; +} hci_le_big_sync_established_event_rp0; + +typedef PACKED(struct) hci_le_big_sync_lost_event_rp0_s { + uint8_t BIG_Handle; + uint8_t Reason; +} hci_le_big_sync_lost_event_rp0; + +typedef PACKED(struct) hci_le_request_peer_sca_complete_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t Peer_Clock_Accuracy; +} hci_le_request_peer_sca_complete_event_rp0; + +typedef PACKED(struct) hci_le_path_loss_threshold_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Current_Path_Loss; + uint8_t Zone_Entered; +} hci_le_path_loss_threshold_event_rp0; + +typedef PACKED(struct) hci_le_transmit_power_reporting_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t Reason; + uint8_t PHY; + int8_t Transmit_Power_Level; + uint8_t Transmit_Power_Level_Flag; + int8_t Delta; +} hci_le_transmit_power_reporting_event_rp0; + +typedef PACKED(struct) hci_le_biginfo_advertising_report_event_rp0_s { + uint16_t Sync_Handle; + uint8_t Num_BIS; + uint8_t NSE; + uint16_t ISO_Interval; + uint8_t BN; + uint8_t PTO; + uint8_t IRC; + uint16_t Max_PDU; + uint8_t SDU_Interval[3]; + uint16_t Max_SDU; + uint8_t PHY; + uint8_t Framing; + uint8_t Encryption; +} hci_le_biginfo_advertising_report_event_rp0; + +typedef PACKED(struct) hci_le_subrate_change_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint16_t Subrate_Factor; + uint16_t Peripheral_Latency; + uint16_t Continuation_Number; + uint16_t Supervision_Timeout; +} hci_le_subrate_change_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_sync_established_v2_event_rp0_s { + uint8_t Status; + uint16_t Sync_Handle; + uint8_t Advertising_SID; + uint8_t Advertiser_Address_Type; + uint8_t Advertiser_Address[6]; + uint8_t Advertiser_PHY; + uint16_t Periodic_Advertising_Interval; + uint8_t Advertiser_Clock_Accuracy; + uint8_t Num_Subevents; + uint8_t Subevent_Interval; + uint8_t Response_Slot_Delay; + uint8_t Response_Slot_Spacing; +} hci_le_periodic_advertising_sync_established_v2_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_report_v2_event_rp0_s { + uint16_t Sync_Handle; + int8_t TX_Power; + int8_t RSSI; + uint8_t CTE_Type; + uint16_t Periodic_Event_Counter; + uint8_t Subevent; + uint8_t Data_Status; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; +} hci_le_periodic_advertising_report_v2_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_sync_transfer_received_v2_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint16_t Service_data; + uint16_t Sync_Handle; + uint8_t Advertising_SID; + uint8_t Advertiser_Address_Type; + uint8_t Advertiser_Address[6]; + uint8_t Advertiser_PHY; + uint16_t Periodic_Advertising_Interval; + uint8_t Advertiser_Clock_Accuracy; + uint8_t Num_Subevents; + uint8_t Subevent_Interval; + uint8_t Response_Slot_Delay; + uint8_t Response_Slot_Spacing; +} hci_le_periodic_advertising_sync_transfer_received_v2_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_subevent_data_request_event_rp0_s { + uint8_t Advertising_Handle; + uint8_t Subevent_Start; + uint8_t Subevent_Data_Count; +} hci_le_periodic_advertising_subevent_data_request_event_rp0; + +typedef PACKED(struct) hci_le_periodic_advertising_response_report_event_rp0_s { + uint8_t Advertising_Handle; + uint8_t Subevent; + uint8_t Tx_Status; + uint8_t Num_Responses; + packed_Periodic_Advertising_Response_t Periodic_Advertising_Response; /* N elements of variable size */ +} hci_le_periodic_advertising_response_report_event_rp0; + +typedef PACKED(struct) hci_le_enhanced_connection_complete_v2_event_rp0_s { + uint8_t Status; + uint16_t Connection_Handle; + uint8_t Role; + uint8_t Peer_Address_Type; + uint8_t Peer_Address[6]; + uint8_t Local_Resolvable_Private_Address[6]; + uint8_t Peer_Resolvable_Private_Address[6]; + uint16_t Connection_Interval; + uint16_t Peripheral_Latency; + uint16_t Supervision_Timeout; + uint8_t Central_Clock_Accuracy; + uint8_t Advertising_Handle; + uint16_t Sync_Handle; +} hci_le_enhanced_connection_complete_v2_event_rp0; + +/** + * @} + */ + +/** @defgroup ACI_evt_code ACI proprietary event codes + * Codes found in ecode field of aci_blecore_event struct. + * @{ + */ + +/* Vendor specific codes of ACI GAP events */ + +#define ACI_HAL_END_OF_RADIO_ACTIVITY_VSEVT_CODE 0x0004 +#define ACI_HAL_FW_ERROR_VSEVT_CODE 0x0006 +#define ACI_HAL_ADV_SCAN_RESP_DATA_UPDATE_VSEVT_CODE 0x0010 +#define ACI_HAL_PAWR_DATA_FREE_VSEVT_CODE 0x0011 +#define ACI_GAP_LIMITED_DISCOVERABLE_VSEVT_CODE 0x0400 +#define ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE 0x0401 +#define ACI_GAP_PASSKEY_REQ_VSEVT_CODE 0x0402 +#define ACI_GAP_PROC_COMPLETE_VSEVT_CODE 0x0407 +#define ACI_GAP_ADDR_NOT_RESOLVED_VSEVT_CODE 0x0408 +#define ACI_GAP_NUMERIC_COMPARISON_VALUE_VSEVT_CODE 0x0409 +#define ACI_GAP_KEYPRESS_NOTIFICATION_VSEVT_CODE 0x040A +#define ACI_GAP_PAIRING_VSEVT_CODE 0x040B +#define ACI_L2CAP_CONNECTION_UPDATE_RESP_VSEVT_CODE 0x0800 +#define ACI_L2CAP_PROC_TIMEOUT_VSEVT_CODE 0x0801 +#define ACI_L2CAP_CONNECTION_UPDATE_REQ_VSEVT_CODE 0x0802 +#define ACI_L2CAP_COS_DISCONNECTION_COMPLETE_VSEVT_CODE 0x0804 +#define ACI_L2CAP_COS_FLOW_CONTROL_CREDIT_VSEVT_CODE 0x0805 +#define ACI_L2CAP_COS_SDU_DATA_TX_VSEVT_CODE 0x0806 +#define ACI_L2CAP_COS_RECONFIGURATION_VSEVT_CODE 0x0809 +#define ACI_L2CAP_COMMAND_REJECT_VSEVT_CODE 0x080A +#define ACI_L2CAP_COS_SDU_DATA_RX_VSEVT_CODE 0x080D +#define ACI_L2CAP_COS_CONNECTION_REQ_VSEVT_CODE 0x080E +#define ACI_L2CAP_COS_CONNECTION_RESP_VSEVT_CODE 0x080F +#define ACI_GATT_SRV_ATTRIBUTE_MODIFIED_VSEVT_CODE 0x0C01 +#define ACI_GATT_PROC_TIMEOUT_VSEVT_CODE 0x0C02 +#define ACI_ATT_EXCHANGE_MTU_RESP_VSEVT_CODE 0x0C03 +#define ACI_ATT_CLT_FIND_INFO_RESP_VSEVT_CODE 0x0C04 +#define ACI_ATT_CLT_FIND_BY_TYPE_VALUE_RESP_VSEVT_CODE 0x0C05 +#define ACI_ATT_CLT_READ_BY_TYPE_RESP_VSEVT_CODE 0x0C06 +#define ACI_ATT_CLT_READ_RESP_VSEVT_CODE 0x0C07 +#define ACI_ATT_CLT_READ_BLOB_RESP_VSEVT_CODE 0x0C08 +#define ACI_ATT_CLT_READ_MULTIPLE_RESP_VSEVT_CODE 0x0C09 +#define ACI_ATT_CLT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE 0x0C0A +#define ACI_ATT_CLT_PREPARE_WRITE_RESP_VSEVT_CODE 0x0C0C +#define ACI_ATT_CLT_EXEC_WRITE_RESP_VSEVT_CODE 0x0C0D +#define ACI_GATT_CLT_INDICATION_VSEVT_CODE 0x0C0E +#define ACI_GATT_CLT_NOTIFICATION_VSEVT_CODE 0x0C0F +#define ACI_GATT_CLT_PROC_COMPLETE_VSEVT_CODE 0x0C10 +#define ACI_GATT_CLT_ERROR_RESP_VSEVT_CODE 0x0C11 +#define ACI_GATT_CLT_DISC_READ_CHAR_BY_UUID_RESP_VSEVT_CODE 0x0C12 +#define ACI_GATT_TX_POOL_AVAILABLE_VSEVT_CODE 0x0C16 +#define ACI_GATT_SRV_CONFIRMATION_VSEVT_CODE 0x0C17 +#define ACI_GATT_SRV_READ_VSEVT_CODE 0x0C19 +#define ACI_GATT_SRV_WRITE_VSEVT_CODE 0x0C1A +#define ACI_ATT_SRV_PREPARE_WRITE_REQ_VSEVT_CODE 0x0C1B +#define ACI_ATT_SRV_EXEC_WRITE_REQ_VSEVT_CODE 0x0C1C +#define ACI_ATT_CLT_READ_MULTIPLE_VAR_LEN_RESP_VSEVT_CODE 0x0C1E + +/** + * @} + */ + +/** @defgroup ACI_evt_structs Proprietary ACI event structures + * Types to be used to cast data field of hci_event_pckt type or + * hci_event_ext_pckt type. + * @{ + */ +typedef PACKED(struct) aci_hal_end_of_radio_activity_event_rp0_s { + uint8_t Last_State; + uint8_t Next_State; + uint32_t Next_State_SysTime; +} aci_hal_end_of_radio_activity_event_rp0; + +typedef PACKED(struct) aci_hal_fw_error_event_rp0_s { + uint8_t FW_Error_Type; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint8_t)]; +} aci_hal_fw_error_event_rp0; + +typedef PACKED(struct) aci_hal_adv_scan_resp_data_update_event_rp0_s { + void * Old_Pointer; + void * New_Pointer; +} aci_hal_adv_scan_resp_data_update_event_rp0; + +typedef PACKED(struct) aci_hal_pawr_data_free_event_rp0_s { + void * Buffer; + uint8_t Type; +} aci_hal_pawr_data_free_event_rp0; + +typedef PACKED(struct) aci_gap_pairing_complete_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Status; + uint8_t Reason; +} aci_gap_pairing_complete_event_rp0; + +typedef PACKED(struct) aci_gap_passkey_req_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Display_Input; +} aci_gap_passkey_req_event_rp0; + +typedef PACKED(struct) aci_gap_proc_complete_event_rp0_s { + uint8_t Procedure_Code; + uint8_t Status; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint8_t)]; +} aci_gap_proc_complete_event_rp0; + +typedef PACKED(struct) aci_gap_addr_not_resolved_event_rp0_s { + uint16_t Connection_Handle; +} aci_gap_addr_not_resolved_event_rp0; + +typedef PACKED(struct) aci_gap_numeric_comparison_value_event_rp0_s { + uint16_t Connection_Handle; + uint32_t Numeric_Value; +} aci_gap_numeric_comparison_value_event_rp0; + +typedef PACKED(struct) aci_gap_keypress_notification_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Notification_Type; +} aci_gap_keypress_notification_event_rp0; + +typedef PACKED(struct) aci_gap_pairing_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Bonded; +} aci_gap_pairing_event_rp0; + +typedef PACKED(struct) aci_l2cap_connection_update_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t Result; +} aci_l2cap_connection_update_resp_event_rp0; + +typedef PACKED(struct) aci_l2cap_proc_timeout_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint8_t)]; +} aci_l2cap_proc_timeout_event_rp0; + +typedef PACKED(struct) aci_l2cap_connection_update_req_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Identifier; + uint16_t L2CAP_Length; + uint16_t Connection_Interval_Min; + uint16_t Connection_Interval_Max; + uint16_t Max_Latency; + uint16_t Timeout_Multiplier; +} aci_l2cap_connection_update_req_event_rp0; + +typedef PACKED(struct) aci_l2cap_cos_disconnection_complete_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; +} aci_l2cap_cos_disconnection_complete_event_rp0; + +typedef PACKED(struct) aci_l2cap_cos_flow_control_credit_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t TX_Credits; + uint16_t TX_Credit_Balance; +} aci_l2cap_cos_flow_control_credit_event_rp0; + +typedef PACKED(struct) aci_l2cap_cos_sdu_data_tx_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t SDU_Length; + uint16_t TX_Credit_Balance; +} aci_l2cap_cos_sdu_data_tx_event_rp0; + +typedef PACKED(struct) aci_l2cap_cos_reconfiguration_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Event_Type; + uint16_t Result; + uint8_t Identifier; + uint16_t Peer_MTU; + uint16_t Peer_MPS; + uint8_t CID_Count; + uint16_t Local_CID[(HCI_MAX_PAYLOAD_SIZE - 11)/sizeof(uint16_t)]; +} aci_l2cap_cos_reconfiguration_event_rp0; + +typedef PACKED(struct) aci_l2cap_command_reject_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Identifier; + uint16_t Reason; + uint8_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_l2cap_command_reject_event_rp0; + +typedef PACKED(struct) aci_l2cap_cos_sdu_data_rx_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t RX_Credit_Balance; + uint16_t SDU_Length; +} aci_l2cap_cos_sdu_data_rx_event_rp0; + +typedef PACKED(struct) aci_l2cap_cos_connection_req_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Channel_Type; + uint8_t Identifier; + uint16_t SPSM; + uint16_t Peer_MTU; + uint16_t Peer_MPS; + uint16_t Initial_Credits; + uint8_t CID_Count; +} aci_l2cap_cos_connection_req_event_rp0; + +typedef PACKED(struct) aci_l2cap_cos_connection_resp_event_rp0_s { + uint16_t Connection_Handle; + uint8_t Channel_Type; + uint16_t Peer_MTU; + uint16_t Peer_MPS; + uint16_t Initial_Credits; + uint16_t Result; + uint8_t CID_Count; + uint16_t CID[(HCI_MAX_PAYLOAD_SIZE - 12)/sizeof(uint16_t)]; +} aci_l2cap_cos_connection_resp_event_rp0; + +typedef PACKED(struct) aci_gatt_srv_attribute_modified_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attr_Handle; + uint16_t Attr_Data_Length; + uint8_t Attr_Data[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; +} aci_gatt_srv_attribute_modified_event_rp0; + +typedef PACKED(struct) aci_gatt_proc_timeout_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; +} aci_gatt_proc_timeout_event_rp0; + +typedef PACKED(struct) aci_att_exchange_mtu_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t MTU; +} aci_att_exchange_mtu_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_find_info_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Format; + uint16_t Event_Data_Length; + uint8_t Handle_UUID_Pair[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} aci_att_clt_find_info_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_find_by_type_value_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Num_of_Handle_Pair; + packed_Attribute_Group_Handle_Pair_t Attribute_Group_Handle_Pair[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(packed_Attribute_Group_Handle_Pair_t)]; +} aci_att_clt_find_by_type_value_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_read_by_type_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Handle_Value_Pair_Length; + uint16_t Data_Length; + uint8_t Handle_Value_Pair_Data[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} aci_att_clt_read_by_type_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_read_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Event_Data_Length; + uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_att_clt_read_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_read_blob_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Event_Data_Length; + uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_att_clt_read_blob_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_read_multiple_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Event_Data_Length; + uint8_t Set_Of_Values[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_att_clt_read_multiple_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_read_by_group_type_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Attribute_Data_Length; + uint16_t Data_Length; + uint8_t Attribute_Data_List[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} aci_att_clt_read_by_group_type_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_prepare_write_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attribute_Handle; + uint16_t Offset; + uint16_t Part_Attribute_Value_Length; + uint8_t Part_Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; +} aci_att_clt_prepare_write_resp_event_rp0; + +typedef PACKED(struct) aci_att_clt_exec_write_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; +} aci_att_clt_exec_write_resp_event_rp0; + +typedef PACKED(struct) aci_gatt_clt_indication_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attribute_Handle; + uint16_t Attribute_Value_Length; + uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; +} aci_gatt_clt_indication_event_rp0; + +typedef PACKED(struct) aci_gatt_clt_notification_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attribute_Handle; + uint16_t Attribute_Value_Length; + uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; +} aci_gatt_clt_notification_event_rp0; + +typedef PACKED(struct) aci_gatt_clt_proc_complete_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Error_Code; +} aci_gatt_clt_proc_complete_event_rp0; + +typedef PACKED(struct) aci_gatt_clt_error_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Req_Opcode; + uint16_t Attribute_Handle; + uint8_t Error_Code; +} aci_gatt_clt_error_resp_event_rp0; + +typedef PACKED(struct) aci_gatt_clt_disc_read_char_by_uuid_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attribute_Handle; + uint8_t Attribute_Value_Length; + uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; +} aci_gatt_clt_disc_read_char_by_uuid_resp_event_rp0; + +typedef PACKED(struct) aci_gatt_tx_pool_available_event_rp0_s { + uint16_t Connection_Handle; + uint16_t Available_Buffers; +} aci_gatt_tx_pool_available_event_rp0; + +typedef PACKED(struct) aci_gatt_srv_confirmation_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; +} aci_gatt_srv_confirmation_event_rp0; + +typedef PACKED(struct) aci_gatt_srv_read_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attribute_Handle; + uint16_t Data_Offset; +} aci_gatt_srv_read_event_rp0; + +typedef PACKED(struct) aci_gatt_srv_write_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Resp_Needed; + uint16_t Attribute_Handle; + uint16_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 9)/sizeof(uint8_t)]; +} aci_gatt_srv_write_event_rp0; + +typedef PACKED(struct) aci_att_srv_prepare_write_req_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Attribute_Handle; + uint16_t Data_Offset; + uint16_t Data_Length; + uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; +} aci_att_srv_prepare_write_req_event_rp0; + +typedef PACKED(struct) aci_att_srv_exec_write_req_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint8_t Flags; +} aci_att_srv_exec_write_req_event_rp0; + +typedef PACKED(struct) aci_att_clt_read_multiple_var_len_resp_event_rp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t Event_Data_Length; + uint8_t Set_Of_Values[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; +} aci_att_clt_read_multiple_var_len_resp_event_rp0; + +/** + * @} + */ + +#endif /* _BLE_EVENTS_H_ */ diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_gatt.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_gatt.h new file mode 100644 index 000000000..b08bdd8b4 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_gatt.h @@ -0,0 +1,552 @@ +/** + ****************************************************************************** + * @file ble_gatt.h + * @author GPM WBL Application team + * @brief Header file for Bluetooth LE GATT + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef BLE_GATT_H +#define BLE_GATT_H + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include + +/****************************************************************************** + * CONSTANT SYMBOLS + *****************************************************************************/ +/** + *@addtogroup GATT GATT + *@brief Generic Attribute Profile + *@{ + */ + +/** + *@addtogroup GATT_constants GATT Constants + *@brief Constants for GATT layer + *@{ + */ + +/** + *@name BLE ATT + * Constants for connection handles + *@{ + */ +#define BLE_ATT_INVALID_ATTR_HANDLE (0x0000U) /**< Invalid attribute handle */ +#define BLE_ATT_MIN_ATTR_HANDLE (0x0001U) /**< Minimum valid attribute handle */ +#define BLE_ATT_MAX_ATTR_HANDLE (0xFFFFU) /**< Maximum valid attribute handle */ +#define BLE_ATT_ATTR_HANDLE_SIZE (2U) /**< Size of an attribute handle value */ +#define BLE_GATT_MAX_ATTR_VALUE_SIZE (512U) /**< Max size of an attribute value. @see 3.2.9 Long + * attribute values - BLUETOOTH CORE SPECIFICATION + * Version 5.1 | Vol 3, Part F page 2297 */ +/** + *@} + */ + +/** + *@anchor GATT_SRV_TYPE + *@name GATT_SRV_TYPE + *@{ + */ +#define BLE_GATT_SRV_PRIMARY_SRV_TYPE (1U) +#define BLE_GATT_SRV_SECONDARY_SRV_TYPE (2U) +/** + *@} + */ + +/** + *@anchor GATT_SRV_KEY_SIZE + *@name GATT_SRV_KEY_SIZE + *@{ + */ +#define BLE_GATT_SRV_MIN_ENCRY_KEY_SIZE (7U) +#define BLE_GATT_SRV_MAX_ENCRY_KEY_SIZE (16U) +/** + *@} + */ + +/** + *@name GATT_SRV_UUID + *@{ + */ +#define BLE_GATT_SRV_PRIM_SERV_DECL_TYPE_UUID (0x2800U) +#define BLE_GATT_SRV_SEC_SERV_DECL_TYPE_UUID (0x2801U) +#define BLE_GATT_SRV_INCL_SERV_DECL_TYPE_UUID (0x2802U) +#define BLE_GATT_SRV_CHAR_DECL_TYPE_UUID (0x2803U) +#define BLE_GATT_SRV_CHAR_EXT_PROP_DESCR_TYPE_UUID (0x2900U) +#define BLE_GATT_SRV_CHAR_USER_DESCR_TYPE_UUID (0x2901U) +#define BLE_GATT_SRV_CLIENT_CHAR_CONF_DESCR_TYPE_UUID (0x2902U) +#define BLE_GATT_SRV_SERVER_CHAR_CONF_DESCR_TYPE_UUID (0x2903U) +#define BLE_GATT_SRV_CHAR_PRES_FORMAT_DESCR_TYPE_UUID (0x2904U) +#define BLE_GATT_SRV_CHAR_AGGR_FORMAT_DESCR_TYPE_UUID (0x2905U) +#define BLE_GATT_SRV_DEVICE_NAME_CHR_UUID (0x2A00U) +#define BLE_GATT_SRV_APPEARANCE_CHR_UUID (0x2A01U) +#define BLE_GATT_SRV_PERIPHERAL_PREFERRED_CONN_PARAMS_UUID (0x2A04U) +#define BLE_GATT_SRV_SERVICE_CHANGE_CHR_UUID (0x2A05U) +#define BLE_GATT_SRV_CENTRAL_ADDRESS_RESOLUTION_UUID (0x2AA6U) +#define BLE_GATT_SRV_CLIENT_SUPP_FEATURE_CHR_UUID (0x2B29U) +#define BLE_GATT_SRV_DB_HASH_CHR_UUID (0x2B2AU) +#define BLE_GATT_SRV_SUPPORTED_FEATURES_CHR_UUID (0x2B3AU) +#define BLE_GATT_SRV_ENCRYPTED_DATA_KEY_MATERIAL_UUID (0x2B88U) + +#define BLE_GATT_SRV_GATT_SERVICE_UUID (0x1801U) +#define BLE_GATT_SRV_GAP_SERVICE_UUID (0x1800U) + +/** + *@} + */ + +/** + *@name GATT_SRV_CHAR_PROP + * @brief The following macro are used to define the characteristic properties as + * defined in BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G, 3.3.1.1 + * Table 3.5. + *@{ + */ +#define BLE_GATT_SRV_CHAR_PROP_NONE (0x00U) +/** If set, it permits broadcasts of the + * Characteristic Value using Server Characteristic Configuration Descriptor. + * If set, the Server Characteristic Configuration Descriptor shall exist. */ +#define BLE_GATT_SRV_CHAR_PROP_BROADCAST (0x01U) +/** If set, it permits reads of the Characteristic Value. */ +#define BLE_GATT_SRV_CHAR_PROP_READ (0x02U) +/** If set, it permit writes of the Characteristic Value without response. */ +#define BLE_GATT_SRV_CHAR_PROP_WRITE_NO_RESP (0x04U) +/** If set, it permits writes of the Characteristic Value with response. */ +#define BLE_GATT_SRV_CHAR_PROP_WRITE (0x08U) +/** If set, it permits notifications of a + * Characteristic Value without acknowledgment. If set, the Client + * Characteristic Configuration Descriptor shall exist. */ +#define BLE_GATT_SRV_CHAR_PROP_NOTIFY (0x10U) +/** If set, it permits indications of a + * Characteristic Value with acknowledgment. If set, the Client Characteristic + * Configuration Descriptor shall exist. */ +#define BLE_GATT_SRV_CHAR_PROP_INDICATE (0x20U) +/** If set, it permits signed writes to the + * Characteristic Value. */ +#define BLE_GATT_SRV_CHAR_PROP_AUTH_SIGN_WRITE (0x40U) +/** If set, additional characteristic + * properties are defined in the Characteristic Extended Properties Descriptor. + * If set, the Characteristic Extended Properties Descriptor shall exist. */ +#define BLE_GATT_SRV_CHAR_PROP_EXTENDED_PROP (0x80U) + +#define BLE_GATT_SRV_CHAR_PROP_ACCESS_PERM_MASK (BLE_GATT_SRV_CHAR_PROP_READ | \ + BLE_GATT_SRV_CHAR_PROP_WRITE | \ + BLE_GATT_SRV_CHAR_PROP_WRITE_NO_RESP | \ + BLE_GATT_SRV_CHAR_PROP_AUTH_SIGN_WRITE) +/** + *@} + */ + +/** + *@anchor GATT_SRV_DESCR_PROP + *@name GATT_SRV_DESCR_PROP constants + * The following macro are used to define the descriptor access properties. + *@{ + */ +#define BLE_GATT_SRV_DESCR_PROP_READ (0x01U) +#define BLE_GATT_SRV_DESCR_PROP_WRITE (0x02U) +/** + *@} + */ + +/** + *@anchor SRV_VALBUFFER_OP_FLAGS + *@name SRV_VALBUFFER_OP_FLAGS + * The following flags enable some behaviour on how to handle the value + * buffers used in the profile definition structures. + *@{ + */ +#define BLE_GATT_SRV_OP_MODIFIED_EVT_ENABLE_FLAG (0x01U) +#define BLE_GATT_SRV_OP_VALUE_VAR_LENGTH_FLAG (0x02U) +/** + *@} + */ + +/** + *@name ATT_ERROR_CODES + * Available Error Codes as reported in: + * Table 3.3 | Vol 3, Part F. + *@{ + */ +#define BLE_ATT_ERR_NONE (0x00U) /**< Not an error! */ +#define BLE_ATT_ERR_INVALID_HANDLE (0x01U) /**< The attribute handle given was not valid on this server. */ +#define BLE_ATT_ERR_READ_NOT_PERM (0x02U) /**< The attribute cannot be read. */ +#define BLE_ATT_ERR_WRITE_NOT_PERM (0x03U) /**< The attribute cannot be written. */ +#define BLE_ATT_ERR_INVALID_PDU (0x04U) /**< The attribute PDU was invalid. */ +#define BLE_ATT_ERR_INSUFF_AUTHENTICATION (0x05U) /**< The attribute requires authentication before it can be read or written. */ +#define BLE_ATT_ERR_REQ_NOT_SUPP (0x06U) /**< Attribute server does not support the request received from the client. */ +#define BLE_ATT_ERR_INVALID_OFFSET (0x07U) /**< Offset specified was past the end of the attribute. */ +#define BLE_ATT_ERR_INSUFF_AUTHORIZATION (0x08U) /**< The attribute requires authorization before it can be read or written. */ +#define BLE_ATT_ERR_PREP_QUEUE_FULL (0x09U) /**< Too many prepare writes have been queued. */ +#define BLE_ATT_ERR_ATTR_NOT_FOUND (0x0AU) /**< No attribute found within the given attribute handle range. */ +#define BLE_ATT_ERR_ATTR_NOT_LONG (0x0BU) /**< The attribute cannot be read using the Read Blob Request. */ +#define BLE_ATT_ERR_INSUFF_ENCR_KEY_SIZE (0x0CU) /**< The Encryption Key Size used for encrypting this link is insufficient. */ +#define BLE_ATT_ERR_INVAL_ATTR_VALUE_LEN (0x0DU) /**< The attribute value length is invalid for the operation. */ +#define BLE_ATT_ERR_UNLIKELY (0x0EU) /**< The attribute request that was requested has encountered an error + * that was unlikely, and therefore could not be completed as requested. */ +#define BLE_ATT_ERR_INSUFF_ENCRYPT (0x0FU) /**< The attribute requires encryption before it can be read or written. */ +#define BLE_ATT_ERR_UNSUPP_GRP_TYPE (0x10U) /**< The attribute type is not a supported grouping attribute as defined by + * a higher layer specification. */ +#define BLE_ATT_ERR_INSUFF_RESOURCES (0x11U) /**< Insufficient Resources to complete the request. */ +#define BLE_ATT_ERR_DB_OUT_OF_SYNC (0x12U) /**< The server requests the client to rediscover the database. */ +#define BLE_ATT_ERR_VALUE_NOT_ALLOWED (0x13U) /**< The attribute parameter value was not allowed. */ +#define BLE_ATT_ERR_APPL_MIN (0x80U) /**< Application error code defined by a higher layer specification. + * Lower error value. + */ +#define BLE_ATT_ERR_APPL_MAX (0x9FU) /**< Application error code defined by a higher layer specification. + * Higher error value. + */ +#define BLE_ATT_ERR_CMN_PROF_SRVC_MIN (0xE0U) /**< Common profile and service error codes defined in [Core Specification + * Supplement], Part B. + * Lower error value. + */ +#define BLE_ATT_ERR_CCCD_IMPROPERLY_CONFIGURED (0xFDU) /**< The Client Characteristic Configuration Descriptor Improperly Configured error + * code is used when a Client Characteristic Configuration descriptor is not + * configured according to the requirements of the profile or service. + * 2.3 CLIENT CHARACTERISTIC CONFIGURATION DESCRIPTOR IMPROPERLY CONFIGURED (0xFD) + * Supplement to the Bluetooth Core Specification | CSS v10, Part B page 34 + */ +#define BLE_ATT_ERR_CMN_PROF_SRVC_MAX (0xFFU) /**< Common profile and service error codes defined in [Core Specification + * Supplement], Part B. + * Higher error value. */ +/** + *@} + */ + +/** + *@anchor GATT_SRV_PERMS + *@name GATT_SRV_PERMS + * The following macro define the attribute permissions. + *@{ + */ +/** Read and Write can be performed on the attribute with no requirements. */ +#define BLE_GATT_SRV_PERM_NONE (0x00U) +/** Attribute can be read only on authenticated links (MITM on). */ +#define BLE_GATT_SRV_PERM_AUTHEN_READ (0x01U) +/** Attribute can be read only on encrypted links. */ +#define BLE_GATT_SRV_PERM_ENCRY_READ (0x04U) +/** Attribute can be written only on authenticated links (MITM on). */ +#define BLE_GATT_SRV_PERM_AUTHEN_WRITE (0x08U) +/** Attribute can be written only on encrypted links. */ +#define BLE_GATT_SRV_PERM_ENCRY_WRITE (0x20U) +#define BLE_GATT_SRV_PERM_ALL (BLE_GATT_SRV_PERM_AUTHEN_READ | \ + BLE_GATT_SRV_PERM_ENCRY_READ | \ + BLE_GATT_SRV_PERM_AUTHEN_WRITE | \ + BLE_GATT_SRV_PERM_ENCRY_WRITE) +/** + *@} + */ + +/** + *@name GATT_SRV_CCCD + *@brief The Client Characteristic Configuration is a special descriptor that + * has to store the subscription of each client to receive notification + * and indication value. + *@{ + */ +#define BLE_GATT_SRV_CCCD_VALUE_LEN (2U) +#define BLE_GATT_SRV_CCCD_NOTIFICATION_BIT (0U) +#define BLE_GATT_SRV_CCCD_INDICATION_BIT (1U) +#define BLE_GATT_SRV_CCCD_NOTIFICATION (1U << BLE_GATT_SRV_CCCD_NOTIFICATION_BIT) +#define BLE_GATT_SRV_CCCD_INDICATION (1U << BLE_GATT_SRV_CCCD_INDICATION_BIT) + +#define BLE_GATT_SRV_CCCD_NUM_BITS_PER_CONN (2U) +#define BLE_GATT_SRV_CCCD_VAL_MASK (BLE_GATT_SRV_CCCD_NUM_BITS_PER_CONN | \ + (BLE_GATT_SRV_CCCD_NUM_BITS_PER_CONN - 1)) +#define BLE_GATT_SRV_CCCD_NUM_CONN_PER_BYTE (8U / BLE_GATT_SRV_CCCD_NUM_BITS_PER_CONN) +/** Return the number of bytes needed to store a CCCD giving the number of connections. */ +#define BLE_GATT_SRV_CCCD_BUFF_SIZE(NUM_CONN) (((NUM_CONN) / BLE_GATT_SRV_CCCD_NUM_CONN_PER_BYTE) + 1U) +/** Declare a storage buffer with the giving name to store the CCCD. */ +#define BLE_GATT_SRV_CCCD_BUFF_DECLARE(NAME, NUM_CONN) uint8_t(NAME)[BLE_GATT_SRV_CCCD_BUFF_SIZE(NUM_CONN)] + +#define BLE_GATT_SRV_CCCD_BUFFER_NAME(NAME) NAME##_cccd_buffer +#define BLE_GATT_SRV_CCCD_VAL_BUFFER_NAME(NAME) NAME##_cccd_val_buffer + +#define BLE_GATT_SRV_CCCD_BUFFER_DECLARE(NAME, NUM_CONN, OP_FLAGS) \ + static uint8_t BLE_GATT_SRV_CCCD_BUFFER_NAME(NAME)[BLE_GATT_SRV_CCCD_BUFF_SIZE(NUM_CONN)]; \ + static const ble_gatt_val_buffer_def_t BLE_GATT_SRV_CCCD_VAL_BUFFER_NAME(NAME) = { \ + .op_flags = (OP_FLAGS & BLE_GATT_SRV_OP_MODIFIED_EVT_ENABLE_FLAG), \ + .buffer_len = BLE_GATT_SRV_CCCD_BUFF_SIZE(NUM_CONN), \ + .buffer_p = BLE_GATT_SRV_CCCD_BUFFER_NAME(NAME), \ + } + +#define BLE_GATT_SRV_CCCD_DEF_NAME(NAME) NAME##_cccd +#define BLE_GATT_SRV_CCCD_DEF_STR_FIELDS(NAME, NUM_CONN, PERM) \ + .val_buffer_p = (ble_gatt_val_buffer_def_t *)&BLE_GATT_SRV_CCCD_VAL_BUFFER_NAME(NAME), \ + .properties = BLE_GATT_SRV_DESCR_PROP_WRITE | BLE_GATT_SRV_DESCR_PROP_READ, \ + .permissions = (PERM), \ + .min_key_size = BLE_GATT_SRV_MIN_ENCRY_KEY_SIZE, \ + .uuid = BLE_UUID_INIT_16(BLE_GATT_SRV_CLIENT_CHAR_CONF_DESCR_TYPE_UUID) + +#define BLE_GATT_SRV_CCCD_DEF_STR_DECLARE(NAME, NUM_CONN, PERM) \ + ble_gatt_descr_def_t BLE_GATT_SRV_CCCD_DEF_NAME(NAME) = { \ + BLE_GATT_SRV_CCCD_DEF_STR_FIELDS(NAME, NUM_CONN, PERM), \ + } + +#define BLE_GATT_SRV_CCCD_PERM_DEFAULT (BLE_GATT_SRV_PERM_NONE) +#define BLE_GATT_SRV_CCCD_DECLARE(NAME, NUM_CONN, PERM, OP_FLAGS) \ + BLE_GATT_SRV_CCCD_BUFFER_DECLARE(NAME, NUM_CONN, OP_FLAGS); \ + BLE_GATT_SRV_CCCD_DEF_STR_DECLARE(NAME, NUM_CONN, PERM) +/** + *@} + */ + +/** + *@name GATT_SRV_CLIENT_SUP_FEATURE + * Use 1 bit for each Client to store Client Supported Feature, since just one + * bit is defined in the spec.: + * @see Table 7.6: Client Supported Features bit assignments, 7.2 CLIENT + * SUPPORTED FEATURES, BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G + *@{ + */ + +/** + * Bit assigned for Robust Caching Support + * + * 7.2 CLIENT SUPPORTED FEATURES, Table 7.6: Client Supported Features bit + * assignments, BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2404 + */ +#define BLE_GATT_SRV_CSF_ROBUST_CACHING (0x01U) + +/** + * Bit assigned for Enhanced ATT bearer + * + * Table 7.6: Client Supported Features bit assignments + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part G page 1602 + */ +#define BLE_GATT_SRV_CSF_EATT (0x02U) + +/** + * Bit assigned for Multiple Handle Value Notifications + * + * Table 7.6: Client Supported Features bit assignments + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part G page 1603 + */ +#define BLE_GATT_SRV_CSF_MULTI_HANDLE_VAL_NOTIFICATION (0x04U) + +#define BLE_GATT_SRV_CLIENT_SUP_FEATURE_NUM_BITS_PER_CONN (4U) + +#define BLE_GATT_SRV_CLIENT_SUP_FEATURE_VAL_MASK (0x07U) + +#define BLE_GATT_SRV_CLIENT_SUP_FEATURE_VALUE_LEN (1U) +#define BLE_GATT_SRV_CLIENT_SUP_FEATURE_NUM_CONN_PER_BYTE (8U / BLE_GATT_SRV_CLIENT_SUP_FEATURE_NUM_BITS_PER_CONN) +#define BLE_GATT_SRV_CLIENT_SUP_FEATURE_SIZE_X_CONN(NUM_CONN) (((NUM_CONN) / \ + BLE_GATT_SRV_CLIENT_SUP_FEATURE_NUM_CONN_PER_BYTE) + 1U) +/** + *@} + */ + +/** + *@name GATT_SRV_SUPPORTED_FEATURES + * Server Supported Features Characteristic is used to indicate support for + * server features. The server shall set a bit only if the corresponding + * feature is supported. + * + * Table 7.11: Server Supported Features bit assignments + * 7.4 SERVER SUPPORTED FEATURES + * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part G page 1605 + *@{ + */ +#define BLE_GATT_SRV_SUPPORTED_FEATURES_EATT (1U) /**< Enhanced ATT bearer supported. */ + +#define BLE_GATT_SRV_SUPPORTED_FEATURES_VAL_LEN (1U) +/** + *@} + */ + +/** + *@name GATT_SRV_CLIENT_SUP_FEATURE + * Flags for aci_gatt_srv_notify + *@{ + */ +#define BLE_GATT_SRV_NOTIFY_FLAG_NOTIFICATION (0x00U) +#define BLE_GATT_SRV_NOTIFY_FLAG_FLUSHABLE_NOTIFICATION (0x01U) +#define BLE_GATT_SRV_NOTIFY_FLAG_INDICATION (0x02U) +/** + *@} + */ + +#define BLE_GATT_UNENHANCED_ATT_L2CAP_CID (0x0004) + +/** + *@name UUID_TYPE + * The following macro are used to define the type of an UUID: + * @def BLE_UUID_TYPE_16BITS used for short 16 bits UUIDs. These are SIG defined. + * @def BLE_UUID_TYPE_32BITS used for 32 bits UUIDs. These are SIG defined. + * @def BLE_UUID_TYPE_128BITS used for long 128 bits UUIDs. + *@{ + */ +/** Used for short 16 bits UUIDs. These are SIG defined. */ +#define BLE_UUID_TYPE_16BITS (16U) +/** Used for 32 bits UUIDs. These are SIG defined. */ +#define BLE_UUID_TYPE_32BITS (32U) +/** Used for long 128 bits UUIDs. */ +#define BLE_UUID_TYPE_128BITS (128U) +/** + *@} + */ + +/** + *@name UUID_LENGTH + *@{ + */ +#define BLE_UUID_128_LENGTH (16U) +#define BLE_UUID_16_LENGTH (2U) +/** + *@} + */ + +/** + *@name UUID_BASE + *@{ + */ +#define BLE_UUID_BASE_LENGTH (12U) +#define BLE_UUID_BASE 0xFB, 0x34, 0x9B, 0x5F, \ + 0x80, 0x00, 0x00, 0x80, \ + 0x00, 0x10, 0x00, 0x00 +/** + *@} + */ + +/** + *@anchor BLE_UUID_INIT + *@name BLE_UUID_INIT Macros + *@{ + */ +#define BLE_UUID_INIT_128(UUID) { \ + .v_128.v = { UUID }, \ + .uuid_type = BLE_UUID_TYPE_128BITS, \ +} +#define BLE_UUID_INIT_32(UUID) { \ + .v_32.base = { BLE_UUID_BASE }, \ + .v_32.v = UUID, \ + .uuid_type = BLE_UUID_TYPE_128BITS, \ +} +#define BLE_UUID_INIT_16(UUID) { \ + .v_16.base = { BLE_UUID_BASE }, \ + .v_16.v = UUID, \ + .v_16.empty = 0x0000U, \ + .uuid_type = BLE_UUID_TYPE_16BITS, \ +} + +#define BLE_COPY_UUID_16(p, UUID) do{ \ + const uint8_t uuid_base[] = {BLE_UUID_BASE}; \ + memcpy((p).v_16.base,uuid_base,sizeof((p).v_16.base)); \ + (p).v_16.v = UUID; \ + (p).v_16.empty = 0x0000U; \ + (p).uuid_type = BLE_UUID_TYPE_16BITS; \ +}while(0); +/** + *@} + */ +/** + *@} + */ +/****************************************************************************** + * TYPES + *****************************************************************************/ +typedef struct ble_uuid_s { +#if defined(__CC_ARM) + #pragma anon_unions +#endif + union + { + struct { + uint8_t v[BLE_UUID_128_LENGTH]; + } v_128; + struct { + uint8_t base[BLE_UUID_BASE_LENGTH]; + uint32_t v; + } v_32; + struct { + uint8_t base[BLE_UUID_BASE_LENGTH]; + uint16_t v; + uint16_t empty; + } v_16; + }; + uint8_t uuid_type; +} ble_uuid_t; + +/** + * @brief The following structure hold the information needed to write an + * attribute. These information shall be valid for all the time the procedure is + * in execution and can be freed on the reception of PROCEDURE COMPLETE event. + */ +typedef struct { + uint16_t attr_h; /**< Attribute handle to write. */ + uint16_t attr_offset; /**< Offset from which start to write the attribute value */ + uint16_t data_len; /**< Length of data to write. */ + uint8_t *data_p; /**< Pointer to the data to write. */ +} ble_gatt_clt_write_ops_t; + +typedef struct ble_gatt_val_buffer_def_s { + uint8_t op_flags; /**< See @ref SRV_VALBUFFER_OP_FLAGS */ + uint16_t val_len; /**< Actual value length. It can differ from buffer_len if BLE_GATT_SRV_PERM_ENCRY_READ the BLE_GATT_SRV_OP_VALUE_VAR_LENGTH_FLAG is set in op_flags */ + uint16_t buffer_len; /**< Buffer length. */ + uint8_t *buffer_p; /**< Pointer to the storage buffer. */ +} ble_gatt_val_buffer_def_t; + +typedef struct ble_gatt_descr_def_s { + uint8_t properties; /**< See @ref GATT_SRV_DESCR_PROP. */ + /** Minimum key size required to access descriptor value. Valid only if permissions are + * BLE_GATT_SRV_PERM_ENCRY_READ or BLE_GATT_SRV_PERM_ENCRY_WRITE, otherwise ignored. + * See @ref GATT_SRV_KEY_SIZE for minimum and maximum values. + */ + uint8_t min_key_size; + uint8_t permissions; /**< Access permissions. See @ref GATT_SRV_PERMS. */ + ble_uuid_t uuid; /**< UUID for this descriptor */ + ble_gatt_val_buffer_def_t *val_buffer_p; /**< Pointer to the value buffer structure. */ +} ble_gatt_descr_def_t; + +typedef struct ble_gatt_chr_def_s { + uint8_t properties; /**< @see GATT_SRV_CHAR_PROP */ + /** Minimum key size required to access characteristic value. Valid only if permissions are + * BLE_GATT_SRV_PERM_ENCRY_READ or BLE_GATT_SRV_PERM_ENCRY_WRITE, otherwise ignored. + * @see GATT_SRV_KEY_SIZE for minimum and maximum values. + */ + uint8_t min_key_size; + uint8_t permissions; /**< Access permissions. See @ref GATT_SRV_PERMS. */ + ble_uuid_t uuid; /**< UUID for this characteristic. Macros can be used to initialize the UUID: see @ref BLE_UUID_INIT. */ + struct { + uint8_t descr_count; /**< Number of descriptors. */ + ble_gatt_descr_def_t *descrs_p; /**< Pointer to the descriptors vector. */ + } descrs; /**< List of descriptors. */ + ble_gatt_val_buffer_def_t *val_buffer_p; /**< Pointer to the value buffer structure. */ +} ble_gatt_chr_def_t; + +typedef struct ble_gatt_srv_def_s { + ble_uuid_t uuid; /**< UUID for this service. Macros can be used to initialize the UUID: see @ref BLE_UUID_INIT. */ + uint8_t type; /**< primary/secondary. See @ref GATT_SRV_TYPE */ + uint16_t group_size; /**< Define the number of attribute handles reserved for this service. */ + struct { + uint8_t incl_srv_count; /**< Number of services. */ + struct ble_gatt_srv_def_s **included_srv_pp; /**< List of pointers to the included service definition. */ + } included_srv; + struct { + uint8_t chr_count; /**< Number of characteristics. */ + ble_gatt_chr_def_t *chrs_p; /**< Pointer to characteristics vector. */ + } chrs; /**< List of characteristics. */ +} ble_gatt_srv_def_t; + +/****************************************************************************** + * FUNCTION PROTOTYPES + *****************************************************************************/ + +/** + *@} + */ + +#endif /* BLE_GATT_H */ diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_stack.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack.h new file mode 100644 index 000000000..1cdece094 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack.h @@ -0,0 +1,840 @@ +/** + ****************************************************************************** + * @file ble_stack.h + * @author GPM WBL Application team + * @brief Header file for Bluetooth LE stack configuration + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + + /* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef BLE_STACK_H +#define BLE_STACK_H + +/* Includes ------------------------------------------------------------------*/ +#include +#include "ble_status.h" +#include "ble_stack_user_cfg.h" +#include "ble_api.h" +#include "ble_events.h" + + +#ifndef MIN +#define MIN(a,b) (((a) < (b))? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a,b) (((a) > (b))? (a) : (b)) +#endif +#define DIV_CEIL(x, y) (((x) + (y) - 1U) / (y)) +#define ALIGN_32(x) ((((x) - 1U) | 3U) + 1U) + +/** + * BLE_STACK_DEFAULT_ATT_MTU: minimum mtu value that GATT must support. + * 5.2.1 ATT_MTU, BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] + */ +#define BLE_STACK_DEFAULT_ATT_MTU (23U) + +#define BLE_STACK_MEM_BLOCK_SIZE (32U) + +#define BLE_STACK_DEFAULT_NUM_EATT_CHANNELS (0U) + +/** + * @name BLE_STACK_L2CAP_MPS_OCTETS + * @brief Minimum and Maximum supported MPS values for L2CAP component. + * @see BLE Spec. v.5.2, Vol.3, Part A, Sec.4.1, Table 4.1 + * @{ + */ +#define BLE_STACK_L2CAP_MPS_OCTETS_MIN (23U) +#define BLE_STACK_L2CAP_MPS_OCTETS_MAX (1024U) /* MPS limited to 1KB */ +/** + * @} + */ + + +/** + * BLE_STACK_SM_SECURE_CONN_MTU: mtu size needed for Security Manager Channel Configuration + * Parameters with LE Secure Connections. + * 3.2 SECURITY MANAGER CHANNEL OVER L2CAP, BLUETOOTH SPECIFICATION Version 4.2 + * [Vol 3, Part H] + */ +#define BLE_STACK_SM_SECURE_CONN_MTU (65U) + +/* + * BLE_STACK_MAX_ATT_MTU: maximum supported ATT_MTU size. + */ +#define BLE_STACK_MAX_ATT_MTU (1024U - 6U) // (6 bytes for L2CAP header) + +/** + * BLE_STACK_DEFAULT_MAX_ATT_MTU: default max ATT_MTU size. + */ +#define BLE_STACK_DEFAULT_MAX_ATT_MTU (251U - 6U) // (6 bytes for L2CAP header) + +/** + * BLE_STACK_DEFAULT_MAX_ATT_SIZE: maximum attribute size. + */ +#define BLE_STACK_DEFAULT_MAX_ATT_SIZE (512U) + +/** + * BLE_STACK_MEM_BLOCK_X_MTU(mtu, n_links): compute how many memory blocks are needed to + * support a maximum number (n_links) of simultaneous connections that use ATT + * packet with ATT_MTU=mtu. + * 7.2 FRAGMENTATION AND RECOMBINATION, BLUETOOTH SPECIFICATION Version 4.2 + * [Vol 3, Part A] + */ + +#define BLE_STACK_MEM_BLOCK_X_TX(mtu) (DIV_CEIL((mtu) + 6U, BLE_STACK_MEM_BLOCK_SIZE) + 1U) +#define BLE_STACK_MEM_BLOCK_X_RX(mtu, n_link) ((DIV_CEIL((mtu) + 6U, BLE_STACK_MEM_BLOCK_SIZE) + 2U) * (n_link) + 1U) +#define BLE_STACK_MEM_BLOCK_X_MTU(mtu, n_link) (BLE_STACK_MEM_BLOCK_X_TX(mtu) + BLE_STACK_MEM_BLOCK_X_RX(mtu, n_link)) + +/** + * Minimum number of blocks required for secure connections + */ +#define BLE_STACK_MBLOCKS_SECURE_CONNECTIONS (4U) + +/** + * BLE_STACK_MBLOCKS_CALC(mtu, n_link): minimum number of buffers needed by the stack. + * This is the minimum racomanded value and depends on: + * - mtu: ATT_MTU size + * - n_link: maximum number of simultaneous connections + * - n_eatt_ch: number of EATT channels + */ +#define BLE_STACK_MBLOCKS_CALC(mtu, n_link, n_eatt_ch) MAX(BLE_STACK_MEM_BLOCK_X_MTU(mtu, (n_link) + (n_eatt_ch)), \ + BLE_STACK_MBLOCKS_SECURE_CONNECTIONS) + +/** + * Default memory blocks count + */ +#define BLE_STACK_DEFAULT_MBLOCKS_COUNT BLE_STACK_MBLOCKS_CALC(BLE_STACK_DEFAULT_MAX_ATT_MTU, \ + BLE_STACK_NUM_LINKS, \ + BLE_STACK_DEFAULT_NUM_EATT_CHANNELS) + +/** + * Amount of memory used for each GATT attribute entry. + */ +#define BLE_STACK_GATT_ATTRIBUTE_SIZE (8U) + +/** + * Number of GATT attributes used for mandatory profiles (GATT and GAP). + */ +#define BLE_STACK_NUM_GATT_MANDATORY_ATTRIBUTES (19U) + +/** + * Amount of memory needed by each GATT Client procedure context + */ +#define COEFF_NUM_GATT_CLIENT_PROCS (36U) + +/** + * Amount of memory needed by each EATT channel. + */ +#define COEFF_NUM_EATT_CHANNELS (32U) + +#define LL_TX_MAX_BUFFER_SIZE (292UL) +#define LL_TX_DEFAULT_BUFFER_SIZE (68UL) +#define LL_RX_MAX_BUFFER_SIZE (260UL) +#define LL_RX_DEFAULT_BUFFER_SIZE (44UL) +#define BLE_STACK_TX_BUFFER_SIZE(EXT_ADV_SCAN_EN, DL_EXT_EN, NUM_BRC_BIG, NUM_SYNC_BIG, NUM_CIG) \ + ((((EXT_ADV_SCAN_EN) == 1U) || ((DL_EXT_EN) == 1U) || ((NUM_CIG) > 0U) || ((NUM_BRC_BIG) > 0U) || ((NUM_SYNC_BIG) > 0U)) ? LL_TX_MAX_BUFFER_SIZE : LL_TX_DEFAULT_BUFFER_SIZE) +#define BLE_STACK_RX_BUFFER_SIZE(EXT_ADV_SCAN_EN, DL_EXT_EN, NUM_BRC_BIG, NUM_SYNC_BIG, NUM_CIG) \ + ((((EXT_ADV_SCAN_EN) == 1U) || ((DL_EXT_EN) == 1U) || ((NUM_CIG) > 0U) || ((NUM_BRC_BIG) > 0U) || ((NUM_SYNC_BIG) > 0U)) ? LL_RX_MAX_BUFFER_SIZE : LL_RX_DEFAULT_BUFFER_SIZE) + +/** + * Amount of memory needed to support ISO feature + */ +#define BLE_STACK_ISO_CMN_SIZE(NUM_BRC_BIG, NUM_SYNC_BIG, NUM_CIG) ((((NUM_BRC_BIG) + (NUM_SYNC_BIG) + (NUM_CIG)) > 0U) ? \ + (12U + 4U) \ + : 0U) + +#define BLE_STACK_BIG_SIZE(NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS) ((((NUM_BRC_BIG) + (NUM_SYNC_BIG)) > 0U) ? \ + (248U * (NUM_BRC_BIG) + \ + 8U * (NUM_BRC_BIG) * (NUM_BRC_BIS) + \ + 296U * (NUM_SYNC_BIG) + \ + 20U * (NUM_SYNC_BIS) * (NUM_SYNC_BIG)) \ + : 0U) + +#define BLE_STACK_CIG_SIZE(NUM_CIG, NUM_CIS) (((NUM_CIG) > 0U) ? \ + (16U + 56U + \ + 168U * (NUM_CIG) + \ + 192U * (NUM_CIS)) \ + : 0U) + +#define BLE_STACK_ISOAL_SIZE(NUM_TX_STREAMS, NUM_RX_STREAMS) ((((NUM_TX_STREAMS) + (NUM_RX_STREAMS)) > 0U) ? \ + (20U + \ + 12U * ((NUM_TX_STREAMS) + (NUM_RX_STREAMS)) + \ + 52U * (NUM_TX_STREAMS) + \ + 28U * (NUM_RX_STREAMS)) \ + : 0U) + +#define BLE_STACK_ISO_SIZE(NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS, NUM_CIG, NUM_CIS) \ + (BLE_STACK_ISO_CMN_SIZE(NUM_BRC_BIG, NUM_SYNC_BIG, NUM_CIG) + \ + BLE_STACK_BIG_SIZE(NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS) + \ + BLE_STACK_CIG_SIZE(NUM_CIG, NUM_CIS) + \ + BLE_STACK_ISOAL_SIZE((NUM_BRC_BIG) * (NUM_BRC_BIS) + (NUM_CIS), \ + (NUM_SYNC_BIG) * (NUM_SYNC_BIS) + (NUM_CIS))) + + +#if (BLESTACK_CONTROLLER_ONLY == 0) + +/** + * A part of the RAM, is dynamically allocated by initializing all the pointers + * defined in a global context variable "mem_alloc_ctx_p". + * This initialization is made in the Dynamic_allocator functions, which + * assign a portion of RAM given by the external application to the above + * mentioned "global pointers". + * + * The size of this Dynamic RAM is made of 2 main components: + * - a part that is parameters-dependent (num of links, GATT buffers, ...), + * and whose value is made explicit by the following macros BLE_STACK_*_SIZE; + * - a part, that may be considered "fixed", i.e., independent from the above + * mentioned parameters. +*/ +# define BLE_STACK_FIXED_BUFFER_SIZE_BYTES (970U) + +/** + * Amount of memory needed by each radio link + */ +# define COEFF_CONN_SUPP_EN (840U + BLE_STACK_GATT_ATTRIBUTE_SIZE * BLE_STACK_NUM_GATT_MANDATORY_ATTRIBUTES) +# define COEFF_NUM_OF_LINKS_0 (48U) +# define COEFF_NUM_OF_LINKS_1 (656U) +# define BLE_STACK_LINKS_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) \ + (((CONN_SUPP_EN) == 1U) || ((NUM_OF_LINKS) > 0U) ? COEFF_CONN_SUPP_EN * (CONN_SUPP_EN) + COEFF_NUM_OF_LINKS_0 * (NUM_OF_LINKS) + COEFF_NUM_OF_LINKS_1 * (CONN_SUPP_EN) * (NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed for mem. blocks allocated for connections + */ +# define BLE_STACK_MBLOCK_SIZE(MEM_BLOCK_COUNT) ((4U + BLE_STACK_MEM_BLOCK_SIZE) * (MEM_BLOCK_COUNT)) + +/** + * Amount of memory needed to support PHY Update feature + */ +# define BLE_STACK_PHY_UPD_SIZE(CONN_SUPP_EN, PHY_UPD_EN, NUM_OF_LINKS) (((PHY_UPD_EN) == 1U) ? 8U + 48U * (CONN_SUPP_EN) * (NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed to support extended advertising and scanning feature. Note that if + * extended advertising is enabled the memory required by the legacy advertising set must be + * subtracted from the total + */ +# define BLE_STACK_CONTROLLER_EXT_ADV_SIZE(ENABLED, NUM_ADV_SET, NUM_AUX_EVENT, NUM_OF_LINKS) \ + (((ENABLED) == 1U) ? -276U + 368U * (NUM_ADV_SET) + 0U * (NUM_AUX_EVENT) + 0U * (NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed for the Filter Accept List and, if connections are supported, also for connection ID list + */ +# define BLE_STACK_FILTER_ACCEPT_LIST_SIZE(WL_SIZE_LOG2) (8U * (1U << (WL_SIZE_LOG2))) +# define BLE_STACK_CONN_ID_LIST_SIZE(CONN_SUPP_EN, WL_SIZE_LOG2) (((CONN_SUPP_EN) == 1U) ? BLE_STACK_FILTER_ACCEPT_LIST_SIZE(WL_SIZE_LOG2) : 0U) + +/** + * Amount of memory needed to support L2CAP COCs (Connection Oriented Channels) + */ +# define BLE_STACK_L2C_COCS_SIZE(CONN_SUPP_EN, L2C_COS_EN, NUM_OF_COCS) (((CONN_SUPP_EN) == 1U) && ((L2C_COS_EN) == 1U) ? 84U * (NUM_OF_COCS) : 0U) + +/** + * Amount of memory needed to support Data Length Extension feature + */ +# define BLE_STACK_D_LEN_EXT_SIZE(LEN_EXT_ENABLED, ADV_EXT_ENABLED) ((((LEN_EXT_ENABLED) == 1U) || ((ADV_EXT_ENABLED) == 1U)) ? 0U : 0U) + +/** + * Amount of memory needed to support periodic advertising and synchronizing feature + */ +# define BLE_STACK_CONTROLLER_PERIODIC_ADV_WR_SIZE(PER_ADV_WR_EN, CONN_SUPP_EN, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) \ + ((((PER_ADV_WR_EN) == 1U) && ((CONN_SUPP_EN) == 1U)) ? (132U + 8U * (NUM_SUBEVENTS_PAWR) + 16U * (MAX_SUBEVENT_DATA_COUNT_PAWR)) * (NUM_ADV_SET) : 0U) + +# define BLE_STACK_CONTROLLER_PERIODIC_ADV_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_LINKS, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) \ + (((PER_ADV_EN) == 1U) ? (156U * (NUM_ADV_SET) + 32U * (NUM_LINKS) + \ + BLE_STACK_CONTROLLER_PERIODIC_ADV_WR_SIZE(PER_ADV_WR_EN, CONN_SUPP_EN, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR)) : \ + 0U) + +/** + * Amount of memory needed to support the scan feature + */ +# define BLE_STACK_BASE_SIZE(CONN_SUPP_EN) (((CONN_SUPP_EN) == 1U) ? 32U : 20U) + +# define BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) ? 24U * (NUM_OF_LINKS) : 0U) + +# define BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE)\ + (((PER_ADV_EN) == 1U) ? BLE_STACK_BASE_SIZE(CONN_SUPP_EN) + 144U * (NUM_SYNC_SLOTS) + 8U * (1U << (ADV_LIST_LIZE)) + BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) : 0U) + +# define BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)\ + (((PER_ADV_WR_EN & PER_ADV_EN & CONN_SUPP_EN) == 1U) ? 176U * (NUM_SYNC_SLOTS) + ALIGN_32(NUM_SYNC_SUBEVENTS) : 0U) + +# define BLE_STACK_CONTROLLER_SCAN_SIZE(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_AUX_EVENT,\ + NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE, NUM_SYNC_SUBEVENTS) \ + (((SCAN_EN) == 1U) ? 320U + (192U + 48U * (NUM_AUX_EVENT) + \ + BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE) + \ + BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)) * (EXT_ADV_EN) : 0U) + + +/** + * Amount of memory needed to support controller privacy feature + */ +# define BLE_STACK_CONTROLLER_PRIV_SIZE(ENABLED, FILTER_ACCEPT_LIST_SIZE_LOG2) (((ENABLED) == 1U) ? 104U + 80U * (1U << (FILTER_ACCEPT_LIST_SIZE_LOG2)) : 0U) + +/** + * Amount of memory needed to support CTE feature + */ +# define BLE_STACK_CTE_NUM_OF_LINKS(CONN_SUPP_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) ? 8U * (NUM_OF_LINKS) : 0U) +# define BLE_STACK_CTE_NUM_OF_ANT_IDS(CONN_SUPP_EN, NUM_OF_LINKS, NUM_OF_ANT_IDS)\ + (((NUM_OF_ANT_IDS) > 0U) ? (1U + 0U * (CONN_SUPP_EN) * (NUM_OF_LINKS)) * ALIGN_32(NUM_OF_ANT_IDS) : 0U) + /** In the macro above, note that: + * - the contribution associated with the nr. of links is 0 because the macro CONN_ANT_PATT is not defined + * - the contribution associated with the nr. of antenna IDs is adapted to the word alignment + */ +# define BLE_STACK_CTE_NUM_OF_IQ_SAMPLES(NUM_OF_IQSAMPLES) (4U * (NUM_OF_IQSAMPLES)) +# define BLE_STACK_CTE_TIMER(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, NUM_OF_IQSAMPLES) \ + ((((SCAN_EN) == 1U) && ((EXT_ADV_EN) == 1U) && ((PER_ADV_EN) == 1U) && ((NUM_OF_IQSAMPLES) > 0U)) ? 24U : 0U) + +# define BLE_STACK_CTE_SIZE(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, CONN_SUPP_EN, CTE_EN, NUM_OF_LINKS, NUM_OF_ANT_IDS, NUM_OF_IQSAMPLES) \ + (((CTE_EN) == 1U) ? 12U + \ + BLE_STACK_CTE_NUM_OF_LINKS(CONN_SUPP_EN, NUM_OF_LINKS) + \ + BLE_STACK_CTE_NUM_OF_ANT_IDS(CONN_SUPP_EN, NUM_OF_LINKS, NUM_OF_ANT_IDS) + \ + BLE_STACK_CTE_NUM_OF_IQ_SAMPLES(NUM_OF_IQSAMPLES) + \ + BLE_STACK_CTE_TIMER(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, NUM_OF_IQSAMPLES) : \ + 0U) + +/** + * Amount of memory needed to support PCL feature + */ +# define BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) (32U * (NUM_OF_LINKS)) +# define BLE_STACK_PCL_SIZE(CONN_SUPP_EN, PCL_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((PCL_EN) == 1U) ? 20U + BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed to support the LE Channel Classification feature + */ +# define BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) (28U * (NUM_OF_LINKS)) +# define BLE_STACK_CHC_SIZE(CONN_SUPP_EN, CHC_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((CHC_EN) == 1U) ? BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed by FIFOs + */ +# define CALC_FIFO_SIZE(FS) ((((FS) + 3U) >> 2U) << 2U) +# define BLE_STACK_FIFO_SIZE(ISR0_FS, ISR1_FS, USER_FS) (CALC_FIFO_SIZE(ISR0_FS) + CALC_FIFO_SIZE(ISR1_FS) + CALC_FIFO_SIZE(USER_FS)) + +/** + * Amount of memory needed by GATT when connection support is enabled + */ +# define BLE_STACK_GATT_SIZE(CONN_SUPP_EN, GATT_ATTRIBUTES, GATT_CLIENT_PROCS, GATT_NUM_EATT_CHANNELS) \ + (((CONN_SUPP_EN) == 1U) ? (BLE_STACK_GATT_ATTRIBUTE_SIZE * (GATT_ATTRIBUTES) + \ + COEFF_NUM_GATT_CLIENT_PROCS * (GATT_CLIENT_PROCS) + \ + COEFF_NUM_EATT_CHANNELS * (GATT_NUM_EATT_CHANNELS)) \ + : 0U) + + +#else // (BLESTACK_CONTROLLER_ONLY == 1) + +# define BLE_STACK_FIXED_BUFFER_SIZE_BYTES (828U) + +/** + * Amount of memory needed by each radio link + */ +# define COEFF_CONN_SUPP_EN (180U) +# define COEFF_NUM_OF_LINKS_0 (48U) // [DB] NOTE: scheduler's tasks +# define COEFF_NUM_OF_LINKS_1 (484U) +# define BLE_STACK_LINKS_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) \ + (((CONN_SUPP_EN) == 1U) || ((NUM_OF_LINKS) > 0U) ? COEFF_CONN_SUPP_EN * (CONN_SUPP_EN) + COEFF_NUM_OF_LINKS_0 * (NUM_OF_LINKS) + COEFF_NUM_OF_LINKS_1 * (CONN_SUPP_EN) * (NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed for mem. blocks allocated for connections + */ +# define BLE_STACK_MBLOCK_SIZE(MEM_BLOCK_COUNT) ((4U + BLE_STACK_MEM_BLOCK_SIZE) * (MEM_BLOCK_COUNT)) + +/** + * Amount of memory needed to support PHY Update feature + */ +# define BLE_STACK_PHY_UPD_SIZE(CONN_SUPP_EN, PHY_UPD_EN, NUM_OF_LINKS) (((PHY_UPD_EN) == 1U) ? 16U * (CONN_SUPP_EN) * (NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed to support extended advertising and scanning feature. Note that if + * extended advertising is enabled the memory required by the legacy advertising set must be + * subtracted from the total + */ +# define BLE_STACK_CONTROLLER_EXT_ADV_SIZE(ENABLED, NUM_ADV_SET, NUM_AUX_EVENT, NUM_OF_LINKS) \ + (((ENABLED) == 1U) ? -256U + 348U * (NUM_ADV_SET) + 0U * (NUM_AUX_EVENT) + 0U * (NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed for the Filter Accept List and, if connections are supported, also for connection ID list + */ +# define BLE_STACK_FILTER_ACCEPT_LIST_SIZE(WL_SIZE_LOG2) (8U * (1U << (WL_SIZE_LOG2))) +# define BLE_STACK_CONN_ID_LIST_SIZE(CONN_SUPP_EN, WL_SIZE_LOG2) (((CONN_SUPP_EN) == 1U) ? BLE_STACK_FILTER_ACCEPT_LIST_SIZE(WL_SIZE_LOG2) : 0U) + +/** + * Amount of memory needed to support L2CAP COCs (Connection Oriented Channels) + */ +# define BLE_STACK_L2C_COCS_SIZE(CONN_SUPP_EN, L2C_COS_EN, NUM_OF_COCS) (0U) + +/** + * Amount of memory needed to support Data Length Extension feature + */ +# define BLE_STACK_D_LEN_EXT_SIZE(LEN_EXT_ENABLED, ADV_EXT_ENABLED) ((((LEN_EXT_ENABLED) == 1U) || ((ADV_EXT_ENABLED) == 1U)) ? 0U : 0U) + +/** + * Amount of memory needed to support periodic advertising and synchronizing feature + */ +# define BLE_STACK_CONTROLLER_PERIODIC_ADV_WR_SIZE(PER_ADV_WR_EN, CONN_SUPP_EN, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) \ + ((((PER_ADV_WR_EN) == 1U) && ((CONN_SUPP_EN) == 1U)) ? (132U + 8U * (NUM_SUBEVENTS_PAWR) + 16U * (MAX_SUBEVENT_DATA_COUNT_PAWR)) * (NUM_ADV_SET) : 0U) + +# define BLE_STACK_CONTROLLER_PERIODIC_ADV_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_LINKS, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) \ + (((PER_ADV_EN) == 1U) ? (156U * (NUM_ADV_SET) + 32U * (NUM_LINKS) + \ + BLE_STACK_CONTROLLER_PERIODIC_ADV_WR_SIZE(PER_ADV_WR_EN, CONN_SUPP_EN, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR)) : \ + 0U) + +/** + * Amount of memory needed to support the scan feature + */ +# define BLE_STACK_BASE_SIZE(CONN_SUPP_EN) (((CONN_SUPP_EN) == 1U) ? 32U : 20U) + +# define BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) ? 24U * (NUM_OF_LINKS) : 0U) + +# define BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE)\ + (((PER_ADV_EN) == 1U) ? BLE_STACK_BASE_SIZE(CONN_SUPP_EN) + 144U * (NUM_SYNC_SLOTS) + 8U * (1U << (ADV_LIST_LIZE)) + BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) : 0U) + +# define BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)\ + (((PER_ADV_WR_EN & PER_ADV_EN & CONN_SUPP_EN) == 1U) ? 176U * (NUM_SYNC_SLOTS) + ALIGN_32(NUM_SYNC_SUBEVENTS) : 0U) + +# define BLE_STACK_CONTROLLER_SCAN_SIZE(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_AUX_EVENT,\ + NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE, NUM_SYNC_SUBEVENTS) \ + (((SCAN_EN) == 1U) ? 320U + (164U + 48U * (NUM_AUX_EVENT) + \ + BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE) + \ + BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)) * (EXT_ADV_EN) : 0U) + +/** + * Amount of memory needed to support controller privacy feature + */ +# define BLE_STACK_CONTROLLER_PRIV_SIZE(ENABLED, FILTER_ACCEPT_LIST_SIZE_LOG2) (((ENABLED) == 1U) ? 104U + 80U * (1U << (FILTER_ACCEPT_LIST_SIZE_LOG2)) : 0U) + +/** + * Amount of memory needed to support CTE feature + */ +# define BLE_STACK_CTE_NUM_OF_LINKS(CONN_SUPP_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) ? 8U * (NUM_OF_LINKS) : 0U) +# define BLE_STACK_CTE_NUM_OF_ANT_IDS(CONN_SUPP_EN, NUM_OF_LINKS, NUM_OF_ANT_IDS)\ + (((NUM_OF_ANT_IDS) > 0U) ? (1U + 0U * (CONN_SUPP_EN) * (NUM_OF_LINKS)) * (1U + (((NUM_OF_ANT_IDS) - 1U) | 3U)) : 0U) + /** In the macro above, note that: + * - the contribution associated with the nr. of links is 0 because the macro CONN_ANT_PATT is not defined + * - the contribution associated with the nr. of antenna IDs is adapted to the word alignment + */ +# define BLE_STACK_CTE_NUM_OF_IQ_SAMPLES(NUM_OF_IQSAMPLES) (4U * (NUM_OF_IQSAMPLES)) + +# define BLE_STACK_CTE_TIMER(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, NUM_OF_IQSAMPLES) \ + ((((SCAN_EN) == 1U) && ((EXT_ADV_EN) == 1U) && ((PER_ADV_EN) == 1U) && ((NUM_OF_IQSAMPLES) > 0U)) ? 24U : 0U) + +# define BLE_STACK_CTE_SIZE(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, CONN_SUPP_EN, CTE_EN, NUM_OF_LINKS, NUM_OF_ANT_IDS, NUM_OF_IQSAMPLES) \ + (((CTE_EN) == 1U) ? 12U + \ + BLE_STACK_CTE_NUM_OF_LINKS(CONN_SUPP_EN, NUM_OF_LINKS) + \ + BLE_STACK_CTE_NUM_OF_ANT_IDS(CONN_SUPP_EN, NUM_OF_LINKS, NUM_OF_ANT_IDS) + \ + BLE_STACK_CTE_NUM_OF_IQ_SAMPLES(NUM_OF_IQSAMPLES) + \ + BLE_STACK_CTE_TIMER(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, NUM_OF_IQSAMPLES) : \ + 0U) + +/** + * Amount of memory needed to support PCL feature + */ +# define BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) (32U * (NUM_OF_LINKS)) +# define BLE_STACK_PCL_SIZE(CONN_SUPP_EN, PCL_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((PCL_EN) == 1U) ? 20U + BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed to support the LE Channel Classification feature + */ +# define BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) (28U * (NUM_OF_LINKS)) +# define BLE_STACK_CHC_SIZE(CONN_SUPP_EN, CHC_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((CHC_EN) == 1U) ? BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) + +/** + * Amount of memory needed by FIFOs + */ +# define CALC_FIFO_SIZE(FS) ((((FS) + 3U) >> 2U) << 2U) +# define BLE_STACK_FIFO_SIZE(ISR0_FS, ISR1_FS, USER_FS) (CALC_FIFO_SIZE(ISR0_FS) + CALC_FIFO_SIZE(ISR1_FS) + CALC_FIFO_SIZE(USER_FS)) + +/** + * Amount of memory needed by GATT when connection support is enabled + */ +# define BLE_STACK_GATT_SIZE(CONN_SUPP_EN, GATT_ATTRIBUTES, GATT_CLIENT_PROCS, NUM_EATT_CHANNELS) (0U) + +#endif // BLESTACK_CONTROLLER_ONLY + +/** + * + * This macro returns the amount of memory, in bytes, needed for the storage of GATT database elements + * and other data structures whose size depends on the number of supported connections. + * + * @param BLE_STACK_NUM_LINKS: Maximum number of simultaneous connections that the device will support. + * @param BLE_STACK_NUM_EATT_CHANNELS: Maximum number of simultaneous EATT active channels that the device will support. + * @param BLE_STACK_NUM_GATT_ATTRIBUTES: Maximum number of Attributes (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) that can be stored in the GATT database. Note that certain characteristics and relative descriptors are added automatically during device initialization so this parameters should be 9 plus the number of user Attributes + * @param BLE_STACK_NUM_GATT_CLIENT_PROCS: Maximum number of concurrent GATT Client Procedures. + * @param BLE_STACK_MBLOCKS_COUNT: Number of memory blocks allocated for packets. + * @param BLE_STACK_D_LEN_EXT_EN: Enable or disable the Extended Packet length feature. Valid values are 0 or 1. + * @param BLE_STACK_PHY_UPD_EN: Enable or disable the PHY Update feature. Valid values are 0 or 1. + * @param BLE_STACK_EXT_ADV_SCAN_EN: Enable or disable the Extended Advertising and Scanning feature. Valid values are 0 or 1. + * @param BLE_STACK_CTRL_PRIV_EN: Enable or disable the Controller privacy feature. Valid values are 0 or 1. + * @param BLE_STACK_SEC_CONN_EN: Enable or disable the secure connection feature. Valid values are 0 or 1. + * @param BLE_STACK_SCAN_EN: Enable or disable the Scan feature. Valid values are 0 or 1. + * @param NUM_ADV_SET: Number of advertising sets. Valid values are > 0. + * @param NUM_SUBEVENTS_PAWR: Number of periodic advertising with responses (PAwR) subevents. Valid values are > 0 if PAwR is supported. + * @param MAX_SUBEVENT_DATA_COUNT_PAWR: Maximum number of periodic advertising with responses (PAwR) subevents that data can be requested for. Valid values are > 0 if PAwR is supported. + * @param NUM_SUBEVENTS_PAWR: Maximum number of PAwR subevents. + * @param NUM_AUX_EVENT: Number of radio tasks to allocate for secondary channels scanning (i.e., auxiliary events). + * @param FILTER_ACCEPT_LIST_SIZE_LOG2: log2 ceiling of Filter Accept List size. + * @param BLE_STACK_L2CAP_COS_EN: Enable or disable the L2CAP Channel Oriented Stream feature. Valid values are 0 or 1. + * @param NUM_L2CAP_COCS: Number of L2CAP COS channels. + * @param CONTROLLER_PERIODIC_ADV_EN: Enable or disable the Periodic Advertising and Synchronization feature. Valid values are 0 or 1. + * @param CONTROLLER_PERIODIC_ADV_WR_EN: Enable or disable the Periodic Advertising and Synchronization with Responses feature. Valid values are 0 or 1. + * @param NUM_SYNC_SLOTS: Number of radio tasks to allocate for synchronizing to periodic advertisements. + * @param BLE_STACK_CTE_EN: Enable or disable the CTE feature. Valid values are 0 or 1. + * @param NUM_CTE_ANT_IDS: Maximum antenna switching pattern length + * @param NUM_CTE_IQSAMPLES: Maximum number of IQ-Samples in the buffer + * @param BLE_STACK_PCL_EN: Enable or disable the Power Control & Path Loss Monitoring feature. Valid values are 0 or 1. + * @param BLE_STACK_CONN_SUPP_EN: Enable or disable the support of ACL connections. + * @param BLE_STACK_CHC_EN: Enable or disable the LE Channel Classification feature. Valid values are 0 or 1. + * @param BLE_STACK_NUM_SYNC_BIG: Number of BIG Synchronous groups to support. + * @param BLE_STACK_NUM_BRC_BIG: Number of BIG Broadcaster groups to support. + * @param BLE_STACK_NUM_SYNC_BIS: Number of BIG Synchronous streams per group to support. + * @param BLE_STACK_NUM_BRC_BIS: Number of BIG Broadcaster streams per group to support. + * @param BLE_STACK_NUM_CIG: Number of CIG groups to support. + * @param BLE_STACK_NUM_CIS: Number of CIS streams to support. + * @param BLE_STACK_CIS_EN: Enable or disable the Connected Isochronous Streams feature. Valid values are 0 or 1. + * @param ISR0_FIFO_SIZE: Size of the internal FIFO used for critical controller events produced by the ISR (e.g. rx data packets) + * @param ISR1_FIFO_SIZE: Size of the internal FIFO used for non-critical controller events produced by the ISR (e.g. advertising or IQ sampling reports) + * @param USER_FIFO_SIZE: Size of the internal FIFO used for controller and host events produced outside the ISR + */ +#define BLE_STACK_TOTAL_BUFFER_SIZE_EXT(\ + BLE_STACK_NUM_LINKS,\ + BLE_STACK_NUM_EATT_CHANNELS,\ + BLE_STACK_NUM_GATT_ATTRIBUTES,\ + BLE_STACK_NUM_GATT_CLIENT_PROCS,\ + BLE_STACK_MBLOCKS_COUNT,\ + BLE_STACK_D_LEN_EXT_EN,\ + BLE_STACK_PHY_UPD_EN,\ + BLE_STACK_EXT_ADV_SCAN_EN,\ + BLE_STACK_CTRL_PRIV_EN,\ + BLE_STACK_SEC_CONN_EN,\ + BLE_STACK_SCAN_EN,\ + NUM_ADV_SET,\ + NUM_SUBEVENTS_PAWR,\ + MAX_SUBEVENT_DATA_COUNT_PAWR,\ + NUM_AUX_EVENT,\ + FILTER_ACCEPT_LIST_SIZE_LOG2,\ + BLE_STACK_L2CAP_COS_EN,\ + NUM_L2CAP_COCS,\ + CONTROLLER_PERIODIC_ADV_EN,\ + CONTROLLER_PERIODIC_ADV_WR_EN,\ + NUM_SYNC_SLOTS,\ + BLE_STACK_CTE_EN,\ + NUM_CTE_ANT_IDS,\ + NUM_CTE_IQSAMPLES,\ + BLE_STACK_PCL_EN,\ + BLE_STACK_CONN_SUPP_EN,\ + BLE_STACK_CHC_EN,\ + BLE_STACK_NUM_SYNC_BIG,\ + BLE_STACK_NUM_BRC_BIG,\ + BLE_STACK_NUM_SYNC_BIS,\ + BLE_STACK_NUM_BRC_BIS,\ + BLE_STACK_NUM_CIG,\ + BLE_STACK_NUM_CIS,\ + ISR0_FIFO_SIZE,\ + ISR1_FIFO_SIZE,\ + USER_FIFO_SIZE)\ +(\ + BLE_STACK_FIXED_BUFFER_SIZE_BYTES + \ + BLE_STACK_LINKS_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_NUM_LINKS) + \ + BLE_STACK_GATT_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_NUM_GATT_ATTRIBUTES, BLE_STACK_NUM_GATT_CLIENT_PROCS, \ + BLE_STACK_NUM_EATT_CHANNELS) + \ + BLE_STACK_MBLOCK_SIZE(BLE_STACK_MBLOCKS_COUNT) + \ + BLE_STACK_D_LEN_EXT_SIZE(BLE_STACK_D_LEN_EXT_EN, BLE_STACK_EXT_ADV_SCAN_EN) + \ + BLE_STACK_PHY_UPD_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_PHY_UPD_EN, BLE_STACK_NUM_LINKS) + \ + BLE_STACK_TX_BUFFER_SIZE(BLE_STACK_EXT_ADV_SCAN_EN, BLE_STACK_D_LEN_EXT_EN, BLE_STACK_NUM_SYNC_BIG, \ + BLE_STACK_NUM_BRC_BIG, BLE_STACK_NUM_CIG) + \ + BLE_STACK_RX_BUFFER_SIZE(BLE_STACK_EXT_ADV_SCAN_EN, BLE_STACK_D_LEN_EXT_EN, BLE_STACK_NUM_SYNC_BIG, \ + BLE_STACK_NUM_BRC_BIG, BLE_STACK_NUM_CIG) + \ + BLE_STACK_CONTROLLER_EXT_ADV_SIZE(BLE_STACK_EXT_ADV_SCAN_EN, NUM_ADV_SET, NUM_AUX_EVENT, BLE_STACK_NUM_LINKS) + \ + BLE_STACK_FILTER_ACCEPT_LIST_SIZE(FILTER_ACCEPT_LIST_SIZE_LOG2) + \ + BLE_STACK_CONN_ID_LIST_SIZE(BLE_STACK_CONN_SUPP_EN, FILTER_ACCEPT_LIST_SIZE_LOG2) + \ + BLE_STACK_CONTROLLER_PRIV_SIZE(BLE_STACK_CTRL_PRIV_EN, FILTER_ACCEPT_LIST_SIZE_LOG2) + \ + (0U * (BLE_STACK_SEC_CONN_EN)) + \ + BLE_STACK_CONTROLLER_SCAN_SIZE( \ + BLE_STACK_SCAN_EN, BLE_STACK_EXT_ADV_SCAN_EN, CONTROLLER_PERIODIC_ADV_EN, CONTROLLER_PERIODIC_ADV_WR_EN, \ + BLE_STACK_CONN_SUPP_EN, NUM_AUX_EVENT, NUM_SYNC_SLOTS, BLE_STACK_NUM_LINKS, FILTER_ACCEPT_LIST_SIZE_LOG2, \ + NUM_SUBEVENTS_PAWR) + \ + BLE_STACK_L2C_COCS_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_L2CAP_COS_EN, NUM_L2CAP_COCS) + \ + BLE_STACK_CONTROLLER_PERIODIC_ADV_SIZE( \ + CONTROLLER_PERIODIC_ADV_EN, CONTROLLER_PERIODIC_ADV_WR_EN, BLE_STACK_CONN_SUPP_EN, \ + BLE_STACK_NUM_LINKS, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) + \ + BLE_STACK_CTE_SIZE( \ + BLE_STACK_SCAN_EN, BLE_STACK_EXT_ADV_SCAN_EN, CONTROLLER_PERIODIC_ADV_EN, BLE_STACK_CONN_SUPP_EN, \ + BLE_STACK_CTE_EN, BLE_STACK_NUM_LINKS, NUM_CTE_ANT_IDS, NUM_CTE_IQSAMPLES) + \ + BLE_STACK_PCL_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_PCL_EN, BLE_STACK_NUM_LINKS) + \ + BLE_STACK_CHC_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_CHC_EN, BLE_STACK_NUM_LINKS) + \ + BLE_STACK_ISO_SIZE(BLE_STACK_NUM_BRC_BIG, BLE_STACK_NUM_BRC_BIS, \ + BLE_STACK_NUM_SYNC_BIG, BLE_STACK_NUM_SYNC_BIS, \ + BLE_STACK_NUM_CIG, BLE_STACK_NUM_CIS) + \ + BLE_STACK_FIFO_SIZE(ISR0_FIFO_SIZE, ISR1_FIFO_SIZE, USER_FIFO_SIZE) \ +) + +/** + * + * This macro acts like the BLE_STACK_TOTAL_BUFFER_SIZE_EXT macro while makes use of the + * modularity parameters defined in the app_conf.h file + * + * @param BLE_STACK_NUM_LINKS: Maximum number of simultaneous radio tasks that the device will support (Radio controller supports up to 128 simultaneous radio tasks, but actual usable max value depends +on the available device RAM) + * @param BLE_STACK_NUM_EATT_CHANNELS: Maximum number of simultaneous EATT active channels that the device will support. + * @param BLE_STACK_NUM_GATT_ATTRIBUTES: Maximum number of Attributes (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) that can be stored in the GATT database. Note that certain characteristics and relative descriptors are added automatically during device initialization so this parameters should be 9 plus the number of user Attributes + * @param BLE_STACK_NUM_GATT_CLIENT_PROCS: Maximum number of concurrent GATT Client Procedures. + * @param BLE_STACK_MBLOCKS_COUNT: Number of memory blocks allocated for packets. + * @param BLE_STACK_NUM_ADV_SET: Number of advertising sets. + * @param BLE_STACK_NUM_ADV_SET_PAWR: Number of advertising sets for periodic advertising with responses. + * @param BLE_STACK_NUM_SUBEVENTS_PAWR: Number of periodic advertising with responses subevents. + * @param BLE_STACK_SUBEVENT_DATA_COUNT_PAWR: Maximum number of periodic advertising with responses subevents that data can be requested for + * @param BLE_STACK_NUM_AUX_EVENT: Number of auxiliary scan slots. + * @param BLE_STACK_FILTER_ACCEPT_LIST_SIZE_LOG2: log2 ceiling of Filter Accept List size. + * @param BLE_STACK_NUM_L2CAP_COCS: number of L2CAP Connection Oriented Channels supported. + * @param NUM_SYNC_SLOTS: Number of radio tasks to allocate for synchronizing to periodic advertisements. + * @param BLE_STACK_NUM_CTE_ANT_IDS: Maximum antenna switching pattern length . + * @param BLE_STACK_NUM_IQSAMPLES: Maximum number of IQ-Samples in the buffer. + * @param ISR0_FIFO_SIZE: Size of the internal FIFO used for critical controller events produced by the ISR (e.g. rx data packets). + * @param ISR1_FIFO_SIZE: Size of the internal FIFO used for non-critical controller events produced by the ISR (e.g. advertising or IQ sampling reports). + * @param USER_FIFO_SIZE: Size of the internal FIFO used for controller and host events produced outside the ISR. + */ +#define BLE_STACK_TOTAL_BUFFER_SIZE(\ + BLE_STACK_NUM_LINKS,\ + BLE_STACK_NUM_EATT_CHANNELS,\ + BLE_STACK_NUM_GATT_ATTRIBUTES,\ + BLE_STACK_NUM_GATT_CLIENT_PROCS,\ + BLE_STACK_MBLOCKS_COUNT,\ + BLE_STACK_NUM_ADV_SET,\ + BLE_STACK_NUM_SUBEVENTS_PAWR,\ + BLE_STACK_SUBEVENT_DATA_COUNT_PAWR,\ + BLE_STACK_NUM_AUX_EVENT,\ + BLE_STACK_FILTER_ACCEPT_LIST_SIZE_LOG2,\ + BLE_STACK_NUM_L2CAP_COCS,\ + NUM_SYNC_SLOTS,\ + BLE_STACK_NUM_CTE_ANT_IDS,\ + BLE_STACK_NUM_IQSAMPLES,\ + BLE_STACK_NUM_SYNC_BIG,\ + BLE_STACK_NUM_BRC_BIG,\ + BLE_STACK_NUM_SYNC_BIS,\ + BLE_STACK_NUM_BRC_BIS,\ + BLE_STACK_NUM_CIG,\ + BLE_STACK_NUM_CIS,\ + ISR0_FIFO_SIZE,\ + ISR1_FIFO_SIZE,\ + USER_FIFO_SIZE)\ +(\ + BLE_STACK_TOTAL_BUFFER_SIZE_EXT(\ + BLE_STACK_NUM_LINKS,\ + BLE_STACK_NUM_EATT_CHANNELS,\ + BLE_STACK_NUM_GATT_ATTRIBUTES,\ + BLE_STACK_NUM_GATT_CLIENT_PROCS,\ + BLE_STACK_MBLOCKS_COUNT,\ + CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED,\ + CONTROLLER_2M_CODED_PHY_ENABLED,\ + CONTROLLER_EXT_ADV_SCAN_ENABLED,\ + CONTROLLER_PRIVACY_ENABLED,\ + SECURE_CONNECTIONS_ENABLED,\ + CONTROLLER_SCAN_ENABLED,\ + BLE_STACK_NUM_ADV_SET,\ + BLE_STACK_NUM_SUBEVENTS_PAWR,\ + BLE_STACK_SUBEVENT_DATA_COUNT_PAWR,\ + BLE_STACK_NUM_AUX_EVENT,\ + BLE_STACK_FILTER_ACCEPT_LIST_SIZE_LOG2,\ + L2CAP_COS_ENABLED,\ + BLE_STACK_NUM_L2CAP_COCS,\ + CONTROLLER_PERIODIC_ADV_ENABLED,\ + CONTROLLER_PERIODIC_ADV_WR_ENABLED,\ + NUM_SYNC_SLOTS,\ + CONTROLLER_CTE_ENABLED,\ + BLE_STACK_NUM_CTE_ANT_IDS,\ + BLE_STACK_NUM_IQSAMPLES,\ + CONTROLLER_POWER_CONTROL_ENABLED,\ + CONNECTION_ENABLED,\ + CONTROLLER_CHAN_CLASS_ENABLED,\ + BLE_STACK_NUM_SYNC_BIG,\ + BLE_STACK_NUM_BRC_BIG,\ + BLE_STACK_NUM_SYNC_BIS,\ + BLE_STACK_NUM_BRC_BIS,\ + BLE_STACK_NUM_CIG,\ + BLE_STACK_NUM_CIS,\ + ISR0_FIFO_SIZE,\ + ISR1_FIFO_SIZE,\ + USER_FIFO_SIZE\ +)) + +/** +* +* This structure contains memory and low level hardware configuration data for the device +*/ +typedef struct { + uint8_t* BLEStartRamAddress; /**< Start address of the RAM buffer required by the Bluetooth stack. It must be 32-bit aligned. Use BLE_STACK_TOTAL_BUFFER_SIZE to calculate the correct size. */ + uint32_t TotalBufferSize; /**< BLE_STACK_TOTAL_BUFFER_SIZE return value, used to check the MACRO correctness*/ + uint16_t NumAttrRecords; /**< Maximum number of attributes that can be stored in the GATT database. */ + uint8_t MaxNumOfClientProcs; /**< Maximum number of concurrent client's procedures. This value shall be less or equal to NumOfRadioTasks. */ + uint8_t NumOfRadioTasks; /**< Maximum number of simultaneous radio tasks. Radio controller supports up to 128 simultaneous radio tasks, but actual usable max value depends on the available device RAM (NUM_LINKS used in the calculation of BLE_STACK_TOTAL_BUFFER_SIZE). */ + uint8_t NumOfEATTChannels; /**< Maximum number of simultaneous EATT active channels */ + uint16_t NumBlockCount; /**< Number of allocated memory blocks */ + uint16_t ATT_MTU; /**< Maximum supported ATT_MTU size [23-1020]*/ + uint32_t MaxConnEventLength; /**< Maximum duration of the connection event when the device is peripheral, in units of 625/256 us (~2.44 us) */ + uint16_t SleepClockAccuracy; /**< Sleep clock accuracy (ppm value)*/ + uint8_t NumOfAdvDataSet; /**< Maximum number of advertising data sets, valid only when Advertising Extension Feature is enabled */ + uint8_t NumOfSubeventsPAwR; /**< Maximum number of Periodic Advertising with Responses subevents */ + uint8_t MaxPAwRSubeventDataCount; /**< Maximum number of Periodic Advertising with Responses subevents that data can be requested for */ + uint8_t NumOfAuxScanSlots; /**< Maximum number of slots for scanning on the secondary advertising channel, valid only when Advertising Extension Feature is enabled */ + uint8_t NumOfSyncSlots; /**< Maximum number of slots for synchronizing to a periodic advertising train, valid only when Periodic Advertising and Synchronizing Feature is enabled */ + uint8_t FilterAcceptListSizeLog2; /**< Two's logarithm of Filter Accept, Resolving and advertiser list size. */ + uint16_t L2CAP_MPS; /**< The maximum size of payload data in octets that the L2CAP layer entity is capable of accepting [0-1024].*/ + uint8_t L2CAP_NumChannels; /**< Maximum number of channels in LE Credit Based Flow Control mode [0-255].*/ + uint8_t CTE_MaxNumAntennaIDs; /**< Maximum number of Antenna IDs in the antenna pattern used in CTE connection oriented mode. */ + uint8_t CTE_MaxNumIQSamples; /**< Maximum number of IQ samples in the buffer used in CTE connection oriented mode. */ + uint8_t NumOfSyncBIG; /**< Maximum number of ISO Synchronizer groups. */ + uint8_t NumOfBrcBIG; /**< Maximum number of ISO Broadcaster groups. */ + uint8_t NumOfSyncBIS; /**< Maximum number of ISO Synchronizer streams. */ + uint8_t NumOfBrcBIS; /**< Maximum number of ISO Broadcaster streams. */ + uint8_t NumOfCIG; /**< Maximum number of Connected Isochronous Groups. */ + uint8_t NumOfCIS; /**< Maximum number of Connected Isochronous Streams. */ + uint16_t isr0_fifo_size; /**< Size of the internal FIFO used for critical controller events produced by the ISR (e.g. rx data packets)*/ + uint16_t isr1_fifo_size; /**< Size of the internal FIFO used for non-critical controller events produced by the ISR (e.g. advertising or IQ sampling reports)*/ + uint16_t user_fifo_size; /**< Size of the internal FIFO used for controller and host events produced outside the ISR */ +} BLE_STACK_InitTypeDef; + + +/** + * @brief This function executes the processing of all Host Stack layers. + * + * The BLE Stack Tick function has to be executed regularly to process incoming Link Layer packets and to process Host Layers procedures. All + * stack callbacks are called by this function. + * + * If Low Speed Ring Oscillator is used instead of the LS Crystal oscillator this function performs also the LS RO calibration and hence must + * be called at least once at every system wake-up in order to keep the 500 ppm accuracy (at least 500 ppm accuracy is mandatory if acting as a Central). + * + * No BLE stack function must be called while the BLE_STACK_Tick is running. For example, if a BLE stack function may be called inside an + * interrupt routine, that interrupt must be disabled during the execution of BLE_STACK_Tick(). Example (if a stack function may be called inside + * UART ISR): + * @code + * NVIC_DisableIRQ(UART_IRQn); + * BLE_STACK_Tick(); + * NVIC_EnableIRQ(UART_IRQn); + * @endcode + + * @note The API name and parameters are subject to change in future releases. + * @return None + */ +void BLE_STACK_Tick(void); + +/** + * @brief The BLE Stack initialization routine + * + * @note The API name and parameters are subject to change in future releases. + * + * @param[in] BLE_STACK_InitStruct pointer to the const structure containing memory and low level + * hardware configuration data for the device + * + * @return Value indicating success or error code. + * + */ +tBleStatus BLE_STACK_Init(const BLE_STACK_InitTypeDef *BLE_STACK_InitStruct); + +/** + * @brief This function is called when an event is coming from the BLE stack + * + * @param hci_pckt: The user event received from the BLE stack + * @param length: Length of the event + * @retval None + */ +void BLE_STACK_Event(hci_pckt *hci_pckt, uint16_t length); + + +/** + * @brief Returns the BLE Stack matching sleep mode + * + * @note The API name and parameters are subject to change in future releases. + * + * @return + * SLEEPMODE_RUNNING = 0, + * SLEEPMODE_NOTIMER = 3, + */ +uint8_t BLE_STACK_SleepCheck(void); + +/** + * + * @brief Radio ISR routine. + * + * This is the base function called for any radio ISR. + * + * @param[in] BlueInterrupt value of the radio interrupt register + * + * @return None + */ +void BLE_STACK_RadioHandler(uint32_t BlueInterrupt); + +/** + * @brief This function provide information when a new radio activity will be performed. +Information provided includes type of radio activity and absolute time in system ticks when a new radio activity is schedule, if any. + * @param NextStateSysTime 32bit absolute current time expressed in internal time units. + * @retval Value indicating the next state: + - 0x00: Idle + - 0x01: Advertising + - 0x02: Connection event Peripheral + - 0x03: Scanning + - 0x04: Connection request + - 0x05: Connection event Central + - 0x06: TX test mode + - 0x07: RX test mode + */ +uint8_t BLE_STACK_ReadNextRadioActivity(uint32_t *NextStateSysTime); + +/* Statistics per link */ +typedef struct llc_conn_per_statistic_s { + + uint16_t num_pkts; /**< The number of received packets, valid or with CRC errors. */ + uint16_t num_crc_err; /**< The number of packets received with CRC errors. */ + uint16_t num_evts; /**< The number of past connection events, including missed ones. */ + uint16_t num_miss_evts; /**< The number of missed RX packets, because of RX timeout or invalid packet length. */ + +} llc_conn_per_statistic_st; + +/** + * @brief LLC function to collect statistics per link: + * - statistics are stored in a buffer allocated by the application + * - counters are reset every time the function is called + * - counters are stopped when the function is called with a pointer to NULL + * + * @param[in] conn_handle Connection handle that identifies the connection + * @param[in] statistics_p pointer to the structure where statistics will be noted + * @return BLE_ERROR_UNKNOWN_CONNECTION_ID in case of invalid conn_handle + * BLE_STATUS_SUCCESS otherwise + */ +tBleStatus llc_conn_per_statistic(uint16_t conn_handle, + llc_conn_per_statistic_st *statistics_p); + + +/* Statistics per link and per channel */ +#if !defined(LLC_MAX_NUM_DATA_CHAN) +# define LLC_MAX_NUM_DATA_CHAN (37U) +#endif + +typedef struct llc_conn_per_statistic_by_channel_s { + uint16_t num_pkts[LLC_MAX_NUM_DATA_CHAN]; /**< The number of received packets, valid or with CRC errors. */ + uint16_t num_crc_err[LLC_MAX_NUM_DATA_CHAN]; /**< The number of packets received with CRC errors. */ + uint16_t num_miss_evts[LLC_MAX_NUM_DATA_CHAN]; /**< The number of missed RX events, because of RX timeout or invalid packet length. */ +} llc_conn_per_statistic_by_channel_st; + +/** + * @brief LLC function to collect statistics per link and per channel: + * - statistics are stored in a buffer allocated by the application + * - counters are reset every time the function is called + * - counters are stopped when the function is called with a pointer to NULL + * + * @param[in] conn_handle - connection handle that identifies the connection + * @param[in] statistics_p - pointer to the structure where statistics will be noted + * @return BLE_ERROR_UNKNOWN_CONNECTION_ID in case of invalid conn_handle + * BLE_STATUS_SUCCESS otherwise + */ +tBleStatus llc_conn_per_statistic_by_channel(uint16_t conn_handle, + llc_conn_per_statistic_by_channel_st *statistics_p); + + +#endif /* BLE_STACK_H */ + diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h new file mode 100644 index 000000000..67cc2dba8 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h @@ -0,0 +1,2750 @@ + +/** + ****************************************************************************** + * @file ble_stack_user_cfg.h + * @author GPM WBL Application team + * @brief Bluetooth LE stack modular configuration options header file + * @details BLE_Config BLE stack configuration options + * - The BLE stack v4.0 or later supports the following outstanding features: + * -- Controller Privacy + * -- LE Secure Connections + * -- Controller Scan + * -- Controller Data Length Extension + * -- LE 2M/Coded PHY + * -- Extended Advertising + * -- Periodic Advertising and Synchronizer + * -- Periodic Advertising with Responses + * -- L2CAP Connection Oriented Channels + * -- Constant Tone Extension + * -- Power Control & Path Loss Monitoring + * -- Connection Support + * -- LE Channel Classification + * -- Broadcast Isochronous Streams + * -- Connected Isochronous Streams + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef BLE_STACK_USER_CFG_H +#define BLE_STACK_USER_CFG_H + +#include +#include +#include "app_conf.h" + +#define CONTROLLER_SCAN_ENABLED CFG_BLE_CONTROLLER_SCAN_ENABLED +#define CONTROLLER_PRIVACY_ENABLED CFG_BLE_CONTROLLER_PRIVACY_ENABLED +#define SECURE_CONNECTIONS_ENABLED CFG_BLE_SECURE_CONNECTIONS_ENABLED +#define CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED +#define CONTROLLER_2M_CODED_PHY_ENABLED CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED +#define CONTROLLER_EXT_ADV_SCAN_ENABLED CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED +#define L2CAP_COS_ENABLED CFG_BLE_L2CAP_COS_ENABLED +#define CONTROLLER_PERIODIC_ADV_ENABLED CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED +#define CONTROLLER_PERIODIC_ADV_WR_ENABLED CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED +#define CONTROLLER_CTE_ENABLED CFG_BLE_CONTROLLER_CTE_ENABLED +#define CONTROLLER_POWER_CONTROL_ENABLED CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED +#define CONNECTION_ENABLED CFG_BLE_CONNECTION_ENABLED +#define CONTROLLER_CHAN_CLASS_ENABLED CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED +#define CONTROLLER_BIS_ENABLED CFG_BLE_CONTROLLER_BIS_ENABLED +#define CONNECTION_SUBRATING_ENABLED CFG_BLE_CONNECTION_SUBRATING_ENABLED +#define CONTROLLER_CIS_ENABLED CFG_BLE_CONTROLLER_CIS_ENABLED + + +/** + * @} + */ + +/* --------------------- Derived defines --------------------- */ +#if (CONTROLLER_BIS_ENABLED == 1U) || (CONTROLLER_CIS_ENABLED == 1U) +# define CONTROLLER_ISO_ENABLED (1U) /* ISO Support: ENABLED */ +#else +# define CONTROLLER_ISO_ENABLED (0U) /* ISO Support: DISABLED */ +#endif + +/* --------------------- Defines used by function prototypes -------------------- */ + +#if !defined(LLC_MAX_NUM_DATA_CHAN) +# define LLC_MAX_NUM_DATA_CHAN (37U) +#endif +#define LLC_MIN_NUM_DATA_CHAN_MAP_BYTES (((LLC_MAX_NUM_DATA_CHAN - 1U) >> 3U) + 1U) +#define LLC_MIN_NUM_DATA_CHAN_CLASS_BYTES (((LLC_MAX_NUM_DATA_CHAN - 1U) >> 2U) + 1U) + +tBleStatus GAP_set_advertising_configuration_ucfg(uint8_t Advertising_Handle, + uint8_t Discoverability_Mode, + uint16_t Advertising_Event_Properties, + uint32_t Primary_Advertising_Interval_Min, + uint32_t Primary_Advertising_Interval_Max, + uint8_t Primary_Advertising_Channel_Map, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable); +tBleStatus GAP_set_advertising_configuration_ucfg_weak(uint8_t Advertising_Handle, + uint8_t Discoverability_Mode, + uint16_t Advertising_Event_Properties, + uint32_t Primary_Advertising_Interval_Min, + uint32_t Primary_Advertising_Interval_Max, + uint8_t Primary_Advertising_Channel_Map, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable); +tBleStatus GAP_set_extended_advertising_configuration(uint8_t Advertising_Handle, + uint8_t Discoverability_Mode, + uint16_t Advertising_Event_Properties, + uint32_t Primary_Advertising_Interval_Min, + uint32_t Primary_Advertising_Interval_Max, + uint8_t Primary_Advertising_Channel_Map, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable); + +tBleStatus GAP_set_scan_response_data_ucfg(uint8_t Advertising_Handle, + uint16_t Scan_Response_Data_Length, + uint8_t* Scan_Response_Data); +tBleStatus GAP_set_scan_response_data_ucfg_weak(uint8_t Advertising_Handle, + uint16_t Scan_Response_Data_Length, + uint8_t* Scan_Response_Data); +tBleStatus GAP_set_extended_scan_response_data(uint8_t Advertising_Handle, + uint16_t Scan_Response_Data_Length, + uint8_t* Scan_Response_Data); + +tBleStatus GAP_set_advertising_data_ucfg(uint8_t Advertising_Handle, + uint8_t Operation, + uint16_t Advertising_Data_Length, + uint8_t* Advertising_Data); +tBleStatus GAP_set_advertising_data_ucfg_weak(uint8_t Advertising_Handle, + uint8_t Operation, + uint16_t Advertising_Data_Length, + uint8_t* Advertising_Data); +tBleStatus GAP_set_extended_advertising_data(uint8_t Advertising_Handle, + uint8_t Operation, + uint16_t Advertising_Data_Length, + uint8_t* Advertising_Data); + +tBleStatus GAP_set_advertising_enable_ucfg(uint8_t Enable, + uint8_t Num_Of_Sets, + Advertising_Set_Parameters_t* Advertising_Set_Parameters); +tBleStatus GAP_set_advertising_enable_ucfg_weak(uint8_t Enable, + uint8_t Num_Of_Sets, + Advertising_Set_Parameters_t* Advertising_Set_Parameters); +tBleStatus GAP_set_extended_advertising_enable(uint8_t Enable, + uint8_t Num_Of_Sets, + Advertising_Set_Parameters_t* Advertising_Set_Parameters); + +tBleStatus GAP_create_connection_ucfg(uint8_t* peer_address, + uint8_t peer_address_type, + uint8_t own_address_type, + uint8_t initiator_filter_policy, + uint8_t phys); +tBleStatus GAP_create_connection_ucfg_weak(uint8_t* peer_address, + uint8_t peer_address_type, + uint8_t own_address_type, + uint8_t initiator_filter_policy, + uint8_t phys); +tBleStatus GAP_create_connection_ext(uint8_t* peer_address, + uint8_t peer_address_type, + uint8_t own_address_type, + uint8_t initiator_filter_policy, + uint8_t phys); + +tBleStatus GAP_set_scan_parameters_ucfg(uint8_t own_address_type, + uint8_t phys); +tBleStatus GAP_set_scan_parameters_ucfg_weak(uint8_t own_address_type, + uint8_t phys); +tBleStatus GAP_set_scan_parameters_ext(uint8_t own_address_type, + uint8_t phys); + +tBleStatus GAP_enable_disable_scan_ucfg(uint8_t enable, + uint8_t duplicate_filtering); +tBleStatus GAP_enable_disable_scan_ucfg_weak(uint8_t enable, + uint8_t duplicate_filtering); +tBleStatus GAP_enable_disable_scan_legacy(uint8_t enable, + uint8_t duplicate_filtering); +tBleStatus GAP_enable_disable_scan_ext(uint8_t enable, + uint8_t duplicate_filtering); + +tBleStatus GAP_connection_procedure_ucfg(uint8_t procedure_code, + uint8_t phys, + uint8_t peer_address_type, + uint8_t peer_address[6]); +tBleStatus GAP_connection_procedure_ucfg_weak(uint8_t procedure_code, + uint8_t phys, + uint8_t peer_address_type, + uint8_t peer_address[6]); +tBleStatus GAP_connection_procedure(uint8_t procedure_code, + uint8_t phys, + uint8_t peer_address_type, + uint8_t peer_address[6]); + +tBleStatus GAP_terminate_gap_procedure_ucfg(uint8_t procedure_code); +tBleStatus GAP_terminate_gap_procedure_ucfg_weak(uint8_t procedure_code); +tBleStatus GAP_terminate_gap_procedure(uint8_t procedure_code); + +tBleStatus GAP_discover_peer_name_ucfg(void); +tBleStatus GAP_discover_peer_name_ucfg_weak(void); +tBleStatus GAP_discover_peer_name(void); + +void GAP_name_disc_proc_connected_check_ucfg(uint16_t task_idx); +void GAP_name_disc_proc_connected_check_ucfg_weak(uint16_t task_idx); +void GAP_name_disc_proc_connected_check(uint16_t task_idx); + +void GAP_central_connection_complete_handler_ucfg(uint8_t status, + uint16_t connectionHandle); +void GAP_central_connection_complete_handler_ucfg_weak(uint8_t status, + uint16_t connectionHandle); +void GAP_central_connection_complete_handler(uint8_t status, + uint16_t connectionHandle); + +uint8_t GAP_parse_connectable_advertising_report_ucfg(uint8_t* adv_buf, + uint8_t extended); +uint8_t GAP_parse_connectable_advertising_report_ucfg_weak(uint8_t* adv_buf, + uint8_t extended); +uint8_t GAP_parse_connectable_advertising_report(uint8_t* adv_buf, + uint8_t extended); + +uint8_t GAP_parse_advertising_report_ucfg(uint8_t* adv_buf, + uint8_t extended); +uint8_t GAP_parse_advertising_report_ucfg_weak(uint8_t* adv_buf, + uint8_t extended); +uint8_t GAP_parse_advertising_report(uint8_t* adv_buf, + uint8_t extended); + +void GAP_DiscProcTimeoutcb_ucfg(uint8_t timer_id); +void GAP_DiscProcTimeoutcb_ucfg_weak(uint8_t timer_id); +void GAP_DiscProcTimeoutcb(uint8_t timer_id); + +void GAP_LimDiscTimeoutcb_ucfg(uint8_t timer_id); +void GAP_LimDiscTimeoutcb_ucfg_weak(uint8_t timer_id); +void GAP_LimDiscTimeoutcb(uint8_t timer_id); + +void GAP_hci_le_advertising_set_terminated_evt_hndl_ucfg(uint8_t status, + uint8_t Advertising_Handle); +void GAP_hci_le_advertising_set_terminated_evt_hndl_ucfg_weak(uint8_t status, + uint8_t Advertising_Handle); +void GAP_hci_le_advertising_set_terminated_evt_hndl(uint8_t status, + uint8_t Advertising_Handle); + +void GAP_peripheral_connection_complete_handler_ucfg(uint16_t connectionHandle); +void GAP_peripheral_connection_complete_handler_ucfg_weak(uint16_t connectionHandle); +void GAP_peripheral_connection_complete_handler(uint16_t connectionHandle); + +tBleStatus GAP_enable_controller_privacy_ucfg(uint8_t* gapRole, + uint8_t* numServiceRec); +tBleStatus GAP_enable_controller_privacy_ucfg_weak(uint8_t* gapRole, + uint8_t* numServiceRec); +tBleStatus GAP_enable_controller_privacy(uint8_t* gapRole, + uint8_t* numServiceRec); + +tBleStatus GAP_add_device_to_filter_accept_and_resolving_list_ucfg(uint8_t lists, + uint8_t addr_type, + uint8_t addr[6]); +tBleStatus GAP_add_device_to_filter_accept_and_resolving_list_ucfg_weak(uint8_t lists, + uint8_t addr_type, + uint8_t addr[6]); +tBleStatus GAP_add_device_to_filter_accept_and_resolving_list_full(uint8_t lists, + uint8_t addr_type, + uint8_t addr[6]); + +tBleStatus GAP_clear_filter_accept_and_resolving_list_ucfg(uint8_t lists); +tBleStatus GAP_clear_filter_accept_and_resolving_list_ucfg_weak(uint8_t lists); +tBleStatus GAP_clear_filter_accept_and_resolving_list_full(uint8_t lists); + +tBleStatus GAP_set_controller_random_address_ucfg(uint8_t random_address[6]); +tBleStatus GAP_set_controller_random_address_ucfg_weak(uint8_t random_address[6]); +tBleStatus GAP_set_controller_random_address_extended(uint8_t random_address[6]); + +tBleStatus GAP_init_advertising_sets_ucfg(uint8_t own_address_type); +tBleStatus GAP_init_advertising_sets_ucfg_weak(uint8_t own_address_type); +tBleStatus GAP_init_advertising_sets(uint8_t own_address_type); + +tBleStatus GAP_suspend_resume_active_advertising_sets_ucfg(uint8_t resume); +tBleStatus GAP_suspend_resume_active_advertising_sets_ucfg_weak(uint8_t resume); +tBleStatus GAP_suspend_resume_active_advertising_sets_extended(uint8_t resume); + +void GAP_ResumeAdvertising_ucfg(uint16_t task_idx); +void GAP_ResumeAdvertising_ucfg_weak(uint16_t task_idx); +void GAP_ResumeAdvertising(uint16_t task_idx); + +tBleStatus hci_acl_data_tx_cmpl_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_acl_data_tx_cmpl_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_acl_data_tx_cmpl_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_acl_data_ind_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_acl_data_ind_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_acl_data_ind_event_int_cb(void* header_p, + uint8_t* buff_p); + +uint32_t chc_csr_ucfg(void); +uint32_t chc_csr_ucfg_weak(void); +uint32_t chc_csr(void); + +void Controller_Process_Q_ucfg(uint16_t task_idx); +void Controller_Process_Q_ucfg_weak(uint16_t task_idx); +void Controller_Process_Q(uint16_t task_idx); + +void LLC_offline_control_procedures_processing_ucfg(uint16_t task_idx); +void LLC_offline_control_procedures_processing_ucfg_weak(uint16_t task_idx); +void LLC_offline_control_procedures_processing(uint16_t task_idx); + +uint32_t cte_csr_ucfg(void); +uint32_t cte_csr_ucfg_weak(void); +uint32_t cte_csr(void); + +uint8_t hci_le_check_own_address_type_max_value_ucfg(void); +uint8_t hci_le_check_own_address_type_max_value_ucfg_weak(void); +uint8_t hci_le_check_own_address_type_max_value(void); + +uint32_t data_length_extension_csr_ucfg(void); +uint32_t data_length_extension_csr_ucfg_weak(void); +uint32_t data_length_extension_csr(void); + +uint32_t pcl_csr_ucfg(void); +uint32_t pcl_csr_ucfg_weak(void); +uint32_t pcl_csr(void); + +uint32_t phy_upd_csr_ucfg(void); +uint32_t phy_upd_csr_ucfg_weak(void); +uint32_t phy_upd_csr(void); + +uint32_t scan_csr_ucfg(void); +uint32_t scan_csr_ucfg_weak(void); +uint32_t scan_csr(void); + +uint32_t conn_supp_csr_ucfg(void); +uint32_t conn_supp_csr_ucfg_weak(void); +uint32_t conn_supp_csr(void); + +uint32_t subrate_csr_ucfg(void); +uint32_t subrate_csr_ucfg_weak(void); +uint32_t subrate_csr(void); + +tBleStatus LLC_test_check_cte_params_ucfg(void* params); +tBleStatus LLC_test_check_cte_params_ucfg_weak(void* params); +tBleStatus LLC_test_check_cte_params(void* params); + +tBleStatus ACL_pkt_init_ucfg(void); +tBleStatus ACL_pkt_init_ucfg_weak(void); +tBleStatus ACL_pkt_init(void); + +tBleStatus hci_disconnection_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_disconnection_complete_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_disconnection_complete_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_encryption_change_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_encryption_change_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_encryption_change_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_encryption_key_refresh_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_encryption_key_refresh_complete_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_encryption_key_refresh_complete_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_connection_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_connection_complete_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_connection_complete_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_enhanced_connection_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_enhanced_connection_complete_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_enhanced_connection_complete_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_long_term_key_request_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_long_term_key_request_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_long_term_key_request_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_read_local_p256_public_key_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_read_local_p256_public_key_complete_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_read_local_p256_public_key_complete_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_generate_dhkey_complete_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_generate_dhkey_complete_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_generate_dhkey_complete_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_advertising_report_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_advertising_report_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_advertising_report_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_directed_advertising_report_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_directed_advertising_report_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_directed_advertising_report_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_extended_advertising_report_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_extended_advertising_report_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_extended_advertising_report_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_scan_timeout_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_scan_timeout_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_scan_timeout_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_advertising_set_terminated_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_advertising_set_terminated_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_advertising_set_terminated_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus hci_le_enhanced_connection_complete_v2_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_enhanced_connection_complete_v2_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus hci_le_enhanced_connection_complete_v2_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus MBM_init_ucfg(void); +tBleStatus MBM_init_ucfg_weak(void); +tBleStatus MBM_init(void); + +uint32_t secure_connections_csr_ucfg(void); +uint32_t secure_connections_csr_ucfg_weak(void); +uint32_t secure_connections_csr(void); + +tBleStatus smp_sap_scp_force_debug_key_usage_ucfg(uint8_t config_val); +tBleStatus smp_sap_scp_force_debug_key_usage_ucfg_weak(uint8_t config_val); +tBleStatus smp_sap_scp_force_debug_key_usage(uint8_t config_val); + +void smp_sap_hci_le_read_local_p256_public_key_complete_evt_hndl_ucfg(uint8_t status, + uint8_t local_p256_public_key[64]); +void smp_sap_hci_le_read_local_p256_public_key_complete_evt_hndl_ucfg_weak(uint8_t status, + uint8_t local_p256_public_key[64]); +void smp_sap_hci_le_read_local_p256_public_key_complete_evt_hndl(uint8_t status, + uint8_t local_p256_public_key[64]); + +void smp_sap_hci_le_generate_dhkey_complete_evt_hndl_ucfg(uint8_t status, + uint8_t dhkey[32]); +void smp_sap_hci_le_generate_dhkey_complete_evt_hndl_ucfg_weak(uint8_t status, + uint8_t dhkey[32]); +void smp_sap_hci_le_generate_dhkey_complete_evt_hndl(uint8_t status, + uint8_t dhkey[32]); + +uint32_t l2c_cos_csr_ucfg(void); +uint32_t l2c_cos_csr_ucfg_weak(void); +uint32_t l2c_cos_csr(void); + +tBleStatus L2C_cos_cfc_init_ucfg(void); +tBleStatus L2C_cos_cfc_init_ucfg_weak(void); +tBleStatus L2C_cos_cfc_init(void); + +void l2c_cos_process_pending_actions_tsk_ucfg(uint16_t task_idx); +void l2c_cos_process_pending_actions_tsk_ucfg_weak(uint16_t task_idx); +void l2c_cos_process_pending_actions_tsk(uint16_t task_idx); + +void L2C_cos_physical_link_disconnection_hndl_ucfg(uint16_t connection_handle); +void L2C_cos_physical_link_disconnection_hndl_ucfg_weak(uint16_t connection_handle); +void L2C_cos_physical_link_disconnection_hndl(uint16_t connection_handle); + +tBleStatus L2C_cos_process_cfc_mode_command_ucfg(void* params); +tBleStatus L2C_cos_process_cfc_mode_command_ucfg_weak(void* params); +tBleStatus L2C_cos_process_cfc_mode_command(void* params); + +uint8_t L2C_cos_is_pdu_cframe_cfc_command_opcode_ucfg(uint8_t opCode); +uint8_t L2C_cos_is_pdu_cframe_cfc_command_opcode_ucfg_weak(uint8_t opCode); +uint8_t L2C_cos_is_pdu_cframe_cfc_command_opcode(uint8_t opCode); + +tBleStatus l2c_cos_hndl_incoming_le_frame_ucfg(void* params); +tBleStatus l2c_cos_hndl_incoming_le_frame_ucfg_weak(void* params); +tBleStatus l2c_cos_hndl_incoming_le_frame(void* params); + +void l2c_cos_sdu_reassembly_tsk_ucfg(uint16_t task_idx); +void l2c_cos_sdu_reassembly_tsk_ucfg_weak(uint16_t task_idx); +void l2c_cos_sdu_reassembly_tsk(uint16_t task_idx); + +tBleStatus l2c_cos_sdu_enqueue_for_segmentation_ucfg(void* params); +tBleStatus l2c_cos_sdu_enqueue_for_segmentation_ucfg_weak(void* params); +tBleStatus l2c_cos_sdu_enqueue_for_segmentation(void* params); + +void l2c_cos_sdu_segmentation_tsk_ucfg(uint16_t task_idx); +void l2c_cos_sdu_segmentation_tsk_ucfg_weak(uint16_t task_idx); +void l2c_cos_sdu_segmentation_tsk(uint16_t task_idx); + +void l2c_cos_transmit_pdu_packets_tsk_ucfg(uint16_t task_idx); +void l2c_cos_transmit_pdu_packets_tsk_ucfg_weak(uint16_t task_idx); +void l2c_cos_transmit_pdu_packets_tsk(uint16_t task_idx); + +tBleStatus L2C_init_ucfg(uint8_t cos_enabled); +tBleStatus L2C_init_ucfg_weak(uint8_t cos_enabled); +tBleStatus L2C_init(uint8_t cos_enabled); + +void llc_conn_check_subrate_and_set_params_ucfg(void* cntxt_p, + void* params_p); +void llc_conn_check_subrate_and_set_params_ucfg_weak(void* cntxt_p, + void* params_p); +void llc_conn_check_subrate_and_set_params(void* cntxt_p, + void* params_p); + +uint32_t llc_conn_calc_skip_ucfg(void* cntxt_p, + uint16_t event_counter, + uint16_t latency); +uint32_t llc_conn_calc_skip_ucfg_weak(void* cntxt_p, + uint16_t event_counter, + uint16_t latency); +uint32_t llc_conn_calc_skip(void* cntxt_p, + uint16_t event_counter, + uint16_t latency); + +tBleStatus llc_conn_multi_link_connection_ucfg(uint8_t enable); +tBleStatus llc_conn_multi_link_connection_ucfg_weak(uint8_t enable); +tBleStatus llc_conn_multi_link_connection(uint8_t enable); + +void llc_conn_peripheral_latency_cancellation_tsk_ucfg(uint16_t task_idx); +void llc_conn_peripheral_latency_cancellation_tsk_ucfg_weak(uint16_t task_idx); +void llc_conn_peripheral_latency_cancellation_tsk(uint16_t task_idx); + +uint8_t llc_check_sreq_or_creq_tx_addr_ucfg(void* tx_addr7_p, + uint8_t pdu_type, + uint8_t adv_event_prop, + uint8_t adv_filter_policy, + void* peer_id_addr7_p, + void* res_peer_id_addr7_p, + uint8_t* rl_index_p); +uint8_t llc_check_sreq_or_creq_tx_addr_ucfg_weak(void* tx_addr7_p, + uint8_t pdu_type, + uint8_t adv_event_prop, + uint8_t adv_filter_policy, + void* peer_id_addr7_p, + void* res_peer_id_addr7_p, + uint8_t* rl_index_p); +uint8_t llc_check_sreq_or_creq_tx_addr(void* tx_addr7_p, + uint8_t pdu_type, + uint8_t adv_event_prop, + uint8_t adv_filter_policy, + void* peer_id_addr7_p, + void* res_peer_id_addr7_p, + uint8_t* rl_index_p); + +uint8_t llc_check_adv_or_srsp_or_crsp_tx_addr_ucfg(uint8_t* tx_addr7_p, + uint8_t adv_pdu, + uint8_t filter_policy, + uint8_t* peer_id_addr7_p, + uint8_t* rl_index_p, + uint8_t* res_peer_id_addr7_p); +uint8_t llc_check_adv_or_srsp_or_crsp_tx_addr_ucfg_weak(uint8_t* tx_addr7_p, + uint8_t adv_pdu, + uint8_t filter_policy, + uint8_t* peer_id_addr7_p, + uint8_t* rl_index_p, + uint8_t* res_peer_id_addr7_p); +uint8_t llc_check_adv_or_srsp_or_crsp_tx_addr(uint8_t* tx_addr7_p, + uint8_t adv_pdu, + uint8_t filter_policy, + uint8_t* peer_id_addr7_p, + uint8_t* rl_index_p, + uint8_t* res_peer_id_addr7_p); + +uint8_t llc_check_adv_or_crsp_rx_addr_ucfg(uint8_t* rx_addr7_p, + uint8_t adv_pdu, + uint8_t filter_policy, + uint8_t* local_addr7_p, + uint8_t local_addr_type, + uint8_t rl_index); +uint8_t llc_check_adv_or_crsp_rx_addr_ucfg_weak(uint8_t* rx_addr7_p, + uint8_t adv_pdu, + uint8_t filter_policy, + uint8_t* local_addr7_p, + uint8_t local_addr_type, + uint8_t rl_index); +uint8_t llc_check_adv_or_crsp_rx_addr(uint8_t* rx_addr7_p, + uint8_t adv_pdu, + uint8_t filter_policy, + uint8_t* local_addr7_p, + uint8_t local_addr_type, + uint8_t rl_index); + +uint32_t bis_csr_ucfg(void); +uint32_t bis_csr_ucfg_weak(void); +uint32_t bis_csr(void); + +uint32_t cis_csr_ucfg(void); +uint32_t cis_csr_ucfg_weak(void); +uint32_t cis_csr(void); + +void llc_isoal_mem_alloc_ucfg(void); +void llc_isoal_mem_alloc_ucfg_weak(void); +void llc_isoal_mem_alloc(void); + +uint32_t iso_csr_ucfg(void); +uint32_t iso_csr_ucfg_weak(void); +uint32_t iso_csr(void); + +tBleStatus iso_rx_bn_pdu_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus iso_rx_bn_pdu_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus iso_rx_bn_pdu_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus iso_terminate_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus iso_terminate_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus iso_terminate_event_int_cb(void* header_p, + uint8_t* buff_p); + +tBleStatus iso_tx_bn_pdu_event_int_cb_ucfg(void* header_p, + uint8_t* buff_p); +tBleStatus iso_tx_bn_pdu_event_int_cb_ucfg_weak(void* header_p, + uint8_t* buff_p); +tBleStatus iso_tx_bn_pdu_event_int_cb(void* header_p, + uint8_t* buff_p); + +void llc_big_brc_mem_alloc_ucfg(void); +void llc_big_brc_mem_alloc_ucfg_weak(void); +void llc_big_brc_mem_alloc(void); + +tBleStatus llc_big_brc_alloc_streams_ucfg(void* ctx, + uint8_t stream_count); +tBleStatus llc_big_brc_alloc_streams_ucfg_weak(void* ctx, + uint8_t stream_count); +tBleStatus llc_big_brc_alloc_streams(void* ctx, + uint8_t stream_count); + +void llc_big_brc_add_biginfo_to_periodic_sync_packet_ucfg(void* pointer, + uint8_t* packet_p); +void llc_big_brc_add_biginfo_to_periodic_sync_packet_ucfg_weak(void* pointer, + uint8_t* packet_p); +void llc_big_brc_add_biginfo_to_periodic_sync_packet(void* pointer, + uint8_t* packet_p); + +void* llc_big_brc_get_group_descr_of_adv_ucfg(uint8_t adv_handle); +void* llc_big_brc_get_group_descr_of_adv_ucfg_weak(uint8_t adv_handle); +void* llc_big_brc_get_group_descr_of_adv(uint8_t adv_handle); + +tBleStatus llc_big_brc_enqueue_pdu_ucfg(void* ctx_p, + uint32_t iso_interval_idx, + uint16_t conn_handle, + void* pdu_p); +tBleStatus llc_big_brc_enqueue_pdu_ucfg_weak(void* ctx_p, + uint32_t iso_interval_idx, + uint16_t conn_handle, + void* pdu_p); +tBleStatus llc_big_brc_enqueue_pdu(void* ctx_p, + uint32_t iso_interval_idx, + uint16_t conn_handle, + void* pdu_p); + +uint32_t llc_big_brc_get_own_big_event_time_ucfg(void* ctx_p, + uint16_t conn_handle, + uint16_t num_enq_packet); +uint32_t llc_big_brc_get_own_big_event_time_ucfg_weak(void* ctx_p, + uint16_t conn_handle, + uint16_t num_enq_packet); +uint32_t llc_big_brc_get_own_big_event_time(void* ctx_p, + uint16_t conn_handle, + uint16_t num_enq_packet); + +void llc_big_sync_mem_alloc_ucfg(void); +void llc_big_sync_mem_alloc_ucfg_weak(void); +void llc_big_sync_mem_alloc(void); + +tBleStatus llc_big_sync_alloc_streams_ucfg(void* ctx, + uint8_t stream_count); +tBleStatus llc_big_sync_alloc_streams_ucfg_weak(void* ctx, + uint8_t stream_count); +tBleStatus llc_big_sync_alloc_streams(void* ctx, + uint8_t stream_count); + +void llc_big_sync_deploy_sync_ucfg(uint8_t* biginfo, + uint16_t sync_handle, + uint32_t periodic_reference_anchor, + uint8_t sca_value); +void llc_big_sync_deploy_sync_ucfg_weak(uint8_t* biginfo, + uint16_t sync_handle, + uint32_t periodic_reference_anchor, + uint8_t sca_value); +void llc_big_sync_deploy_sync(uint8_t* biginfo, + uint16_t sync_handle, + uint32_t periodic_reference_anchor, + uint8_t sca_value); + +tBleStatus llc_big_sync_decrypt_bis_packet_ucfg(void* ctx_p, + void* pdu_p); +tBleStatus llc_big_sync_decrypt_bis_packet_ucfg_weak(void* ctx_p, + void* pdu_p); +tBleStatus llc_big_sync_decrypt_bis_packet(void* ctx_p, + void* pdu_p); + +uint32_t llc_big_sync_get_sdu_synchronization_us_ucfg(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); +uint32_t llc_big_sync_get_sdu_synchronization_us_ucfg_weak(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); +uint32_t llc_big_sync_get_sdu_synchronization_us(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); + +tBleStatus llc_big_cmn_get_iso_params_ucfg(uint8_t direction, + uint16_t conn_handle, + void* param_p); +tBleStatus llc_big_cmn_get_iso_params_ucfg_weak(uint8_t direction, + uint16_t conn_handle, + void* param_p); +tBleStatus llc_big_cmn_get_iso_params(uint8_t direction, + uint16_t conn_handle, + void* param_p); + +uint32_t llc_cig_cen_get_cis_offset_from_acl_us_ucfg(void* ctx_p, + void* cis_p, + uint8_t conn_idx, + uint16_t* event_count_p, + uint32_t* cig_anchor_st_p); +uint32_t llc_cig_cen_get_cis_offset_from_acl_us_ucfg_weak(void* ctx_p, + void* cis_p, + uint8_t conn_idx, + uint16_t* event_count_p, + uint32_t* cig_anchor_st_p); +uint32_t llc_cig_cen_get_cis_offset_from_acl_us(void* ctx_p, + void* cis_p, + uint8_t conn_idx, + uint16_t* event_count_p, + uint32_t* cig_anchor_st_p); + +uint32_t llc_cig_cen_get_sdu_synchronization_us_ucfg(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); +uint32_t llc_cig_cen_get_sdu_synchronization_us_ucfg_weak(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); +uint32_t llc_cig_cen_get_sdu_synchronization_us(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); + +uint32_t llc_cig_per_get_sdu_synchronization_us_ucfg(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); +uint32_t llc_cig_per_get_sdu_synchronization_us_ucfg_weak(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); +uint32_t llc_cig_per_get_sdu_synchronization_us(uint16_t conn_handle, + uint8_t framed, + uint32_t anchor_us, + uint32_t time_offset); + +tBleStatus llc_cig_cmn_disconnect_ucfg(uint16_t cis_handle, + uint8_t reason); +tBleStatus llc_cig_cmn_disconnect_ucfg_weak(uint16_t cis_handle, + uint8_t reason); +tBleStatus llc_cig_cmn_disconnect(uint16_t cis_handle, + uint8_t reason); + +void llc_cig_cmn_mem_alloc_ucfg(void); +void llc_cig_cmn_mem_alloc_ucfg_weak(void); +void llc_cig_cmn_mem_alloc(void); + +tBleStatus llc_cig_cmn_alloc_streams_ucfg(void* ctx, + uint8_t stream_count, + uint8_t group_type); +tBleStatus llc_cig_cmn_alloc_streams_ucfg_weak(void* ctx, + uint8_t stream_count, + uint8_t group_type); +tBleStatus llc_cig_cmn_alloc_streams(void* ctx, + uint8_t stream_count, + uint8_t group_type); + +void llc_cig_cmn_terminate_stream_ucfg(void* cig_p, + void* cis_p, + uint8_t reason); +void llc_cig_cmn_terminate_stream_ucfg_weak(void* cig_p, + void* cis_p, + uint8_t reason); +void llc_cig_cmn_terminate_stream(void* cig_p, + void* cis_p, + uint8_t reason); + +uint32_t llc_cig_cmn_get_own_cig_event_time_ucfg(void* ctx_p, + uint16_t conn_handle, + uint16_t num_enq_packet); +uint32_t llc_cig_cmn_get_own_cig_event_time_ucfg_weak(void* ctx_p, + uint16_t conn_handle, + uint16_t num_enq_packet); +uint32_t llc_cig_cmn_get_own_cig_event_time(void* ctx_p, + uint16_t conn_handle, + uint16_t num_enq_packet); + +tBleStatus llc_cig_cmn_enqueue_pdu_to_tx_ucfg(void* ctx_p, + uint32_t iso_interval_idx, + uint16_t conn_handle, + void* pdu_p); +tBleStatus llc_cig_cmn_enqueue_pdu_to_tx_ucfg_weak(void* ctx_p, + uint32_t iso_interval_idx, + uint16_t conn_handle, + void* pdu_p); +tBleStatus llc_cig_cmn_enqueue_pdu_to_tx(void* ctx_p, + uint32_t iso_interval_idx, + uint16_t conn_handle, + void* pdu_p); + +tBleStatus llc_cig_cmn_decrypt_packet_ucfg(void* ctx_p, + void* pdu_p); +tBleStatus llc_cig_cmn_decrypt_packet_ucfg_weak(void* ctx_p, + void* pdu_p); +tBleStatus llc_cig_cmn_decrypt_packet(void* ctx_p, + void* pdu_p); + +void llc_cig_cmn_start_cis_ucfg(uint8_t conn_idx, + uint16_t instant); +void llc_cig_cmn_start_cis_ucfg_weak(uint8_t conn_idx, + uint16_t instant); +void llc_cig_cmn_start_cis(uint8_t conn_idx, + uint16_t instant); + +uint8_t llc_cig_cmn_is_active_cis_on_acl_ucfg(uint16_t acl_conn_handle); +uint8_t llc_cig_cmn_is_active_cis_on_acl_ucfg_weak(uint16_t acl_conn_handle); +uint8_t llc_cig_cmn_is_active_cis_on_acl(uint16_t acl_conn_handle); + +void llc_cig_cmn_terminate_cises_on_acl_ucfg(uint16_t acl_conn_handle); +void llc_cig_cmn_terminate_cises_on_acl_ucfg_weak(uint16_t acl_conn_handle); +void llc_cig_cmn_terminate_cises_on_acl(uint16_t acl_conn_handle); + +void llc_cig_cmn_cis_established_event_gen_ucfg(void* cig_p, + void* cis_p, + uint8_t status); +void llc_cig_cmn_cis_established_event_gen_ucfg_weak(void* cig_p, + void* cis_p, + uint8_t status); +void llc_cig_cmn_cis_established_event_gen(void* cig_p, + void* cis_p, + uint8_t status); + +tBleStatus llc_cig_cmn_get_iso_params_ucfg(uint8_t direction, + uint16_t conn_handle, + void* param_p); +tBleStatus llc_cig_cmn_get_iso_params_ucfg_weak(uint8_t direction, + uint16_t conn_handle, + void* param_p); +tBleStatus llc_cig_cmn_get_iso_params(uint8_t direction, + uint16_t conn_handle, + void* param_p); + +tBleStatus llc_cig_cmn_read_iso_link_quality_ucfg(uint16_t conn_handle, + uint32_t* tx_unacked_packets_p, + uint32_t* tx_flushed_packets_p, + uint32_t* tx_last_subevent_packets_p, + uint32_t* retransmitted_packets_p, + uint32_t* crc_error_packets_p, + uint32_t* rx_unreceived_packets_p, + uint32_t* duplicate_packets_p); +tBleStatus llc_cig_cmn_read_iso_link_quality_ucfg_weak(uint16_t conn_handle, + uint32_t* tx_unacked_packets_p, + uint32_t* tx_flushed_packets_p, + uint32_t* tx_last_subevent_packets_p, + uint32_t* retransmitted_packets_p, + uint32_t* crc_error_packets_p, + uint32_t* rx_unreceived_packets_p, + uint32_t* duplicate_packets_p); +tBleStatus llc_cig_cmn_read_iso_link_quality(uint16_t conn_handle, + uint32_t* tx_unacked_packets_p, + uint32_t* tx_flushed_packets_p, + uint32_t* tx_last_subevent_packets_p, + uint32_t* retransmitted_packets_p, + uint32_t* crc_error_packets_p, + uint32_t* rx_unreceived_packets_p, + uint32_t* duplicate_packets_p); + +void llc_iso_cmn_mem_alloc_ucfg(void); +void llc_iso_cmn_mem_alloc_ucfg_weak(void); +void llc_iso_cmn_mem_alloc(void); + +void llc_padv_mem_allocate_ucfg(uint8_t eadv_en, + uint8_t padv_en, + uint8_t nr_of_adv_sets, + uint8_t* more_info_p); +void llc_padv_mem_allocate_ucfg_weak(uint8_t eadv_en, + uint8_t padv_en, + uint8_t nr_of_adv_sets, + uint8_t* more_info_p); +void llc_padv_mem_allocate(uint8_t eadv_en, + uint8_t padv_en, + uint8_t nr_of_adv_sets, + uint8_t* more_info_p); +void llc_padv_wr_mem_allocate(uint8_t eadv_en, + uint8_t padv_en, + uint8_t nr_of_adv_sets, + uint8_t* more_info_p); + +void llc_padv_init_ucfg(void); +void llc_padv_init_ucfg_weak(void); +void llc_padv_init(void); + +tBleStatus llc_padv_set_periodic_advertising_data_ucfg(uint16_t advertising_handle, + uint8_t operation, + uint16_t data_length, + uint8_t* data_p); +tBleStatus llc_padv_set_periodic_advertising_data_ucfg_weak(uint16_t advertising_handle, + uint8_t operation, + uint16_t data_length, + uint8_t* data_p); +tBleStatus llc_padv_set_periodic_advertising_data(uint16_t advertising_handle, + uint8_t operation, + uint16_t data_length, + uint8_t* data_p); + +uint8_t llc_padv_check_if_syncinfo_is_included_and_start_periodic_advertising_ucfg(void* context_p); +uint8_t llc_padv_check_if_syncinfo_is_included_and_start_periodic_advertising_ucfg_weak(void* context_p); +uint8_t llc_padv_check_if_syncinfo_is_included_and_start_periodic_advertising(void* context_p); + +uint8_t llc_padv_update_sync_info_ucfg(void* padv_per_p, + uint32_t aux_adv_ind_anchor); +uint8_t llc_padv_update_sync_info_ucfg_weak(void* padv_per_p, + uint32_t aux_adv_ind_anchor); +uint8_t llc_padv_update_sync_info(void* padv_per_p, + uint32_t aux_adv_ind_anchor); + +void llc_padv_prepare_periodic_advertising_payload_ucfg(void* padv_per_p, + uint8_t extended_header_flags, + uint8_t* payload_p); +void llc_padv_prepare_periodic_advertising_payload_ucfg_weak(void* padv_per_p, + uint8_t extended_header_flags, + uint8_t* payload_p); +void llc_padv_prepare_periodic_advertising_payload(void* padv_per_p, + uint8_t extended_header_flags, + uint8_t* payload_p); + +uint32_t llc_padv_periodic_adv_sync_csr_ucfg(void); +uint32_t llc_padv_periodic_adv_sync_csr_ucfg_weak(void); +uint32_t llc_padv_periodic_adv_sync_csr(void); + +uint8_t llc_padv_wr_create_connection_cancel_ucfg(void* _padv_per_p, + uint8_t advertising_handle); +uint8_t llc_padv_wr_create_connection_cancel_ucfg_weak(void* _padv_per_p, + uint8_t advertising_handle); +uint8_t llc_padv_wr_create_connection_cancel(void* _padv_per_p, + uint8_t advertising_handle); + +void llc_padv_wr_set_start_parameters_ucfg(void* set_padv_wr_start_parameters_p); +void llc_padv_wr_set_start_parameters_ucfg_weak(void* set_padv_wr_start_parameters_p); +void llc_padv_wr_set_start_parameters(void* set_padv_wr_start_parameters_p); + +tBleStatus llc_padv_wr_set_periodic_advertising_subevent_data_ucfg(void* set_padv_wr_data_p); +tBleStatus llc_padv_wr_set_periodic_advertising_subevent_data_ucfg_weak(void* set_padv_wr_data_p); +tBleStatus llc_padv_wr_set_periodic_advertising_subevent_data(void* set_padv_wr_data_p); + +uint8_t llc_padv_wr_set_ctrdata_ucfg(void* padv_per_p, + uint8_t* ctrdata_p); +uint8_t llc_padv_wr_set_ctrdata_ucfg_weak(void* padv_per_p, + uint8_t* ctrdata_p); +uint8_t llc_padv_wr_set_ctrdata(void* padv_per_p, + uint8_t* ctrdata_p); + +void llc_padv_wr_set_acad_ucfg(void* padv_per_p, + uint8_t* ext_hdr_p); +void llc_padv_wr_set_acad_ucfg_weak(void* padv_per_p, + uint8_t* ext_hdr_p); +void llc_padv_wr_set_acad(void* padv_per_p, + uint8_t* ext_hdr_p); + +void llc_padv_wr_init_anchors_and_counters_ucfg(void* padv_per_p); +void llc_padv_wr_init_anchors_and_counters_ucfg_weak(void* padv_per_p); +void llc_padv_wr_init_anchors_and_counters(void* padv_per_p); + +uint32_t llc_padv_periodic_adv_sync_wr_csr_ucfg(void); +uint32_t llc_padv_periodic_adv_sync_wr_csr_ucfg_weak(void); +uint32_t llc_padv_periodic_adv_sync_wr_csr(void); + +void llc_padv_wr_disable_ext_ucfg(void* _padv_per_p); +void llc_padv_wr_disable_ext_ucfg_weak(void* _padv_per_p); +void llc_padv_wr_disable_ext(void* _padv_per_p); + +void llc_priv_generate_peer_rpa_from_peer_id_ucfg(void* peer_p, + uint8_t in_isr); +void llc_priv_generate_peer_rpa_from_peer_id_ucfg_weak(void* peer_p, + uint8_t in_isr); +void llc_priv_generate_peer_rpa_from_peer_id(void* peer_p, + uint8_t in_isr); + +void llc_priv_init_ucfg(uint8_t first_call); +void llc_priv_init_ucfg_weak(uint8_t first_call); +void llc_priv_init(uint8_t first_call); + +void llc_priv_generate_local_rpa_from_peer_id_ucfg(void* peer_id_p, + void* local_rpa_p); +void llc_priv_generate_local_rpa_from_peer_id_ucfg_weak(void* peer_id_p, + void* local_rpa_p); +void llc_priv_generate_local_rpa_from_peer_id(void* peer_id_p, + void* local_rpa_p); + +void llc_priv_offline_rpa_resolution_ucfg(uint16_t task_idx); +void llc_priv_offline_rpa_resolution_ucfg_weak(uint16_t task_idx); +void llc_priv_offline_rpa_resolution(uint16_t task_idx); + +uint32_t llc_priv_controller_privacy_csr_ucfg(void); +uint32_t llc_priv_controller_privacy_csr_ucfg_weak(void); +uint32_t llc_priv_controller_privacy_csr(void); + +void llc_priv_set_filter_accept_list_flag_in_resolving_list_ucfg(void* addr8_p, + uint8_t set); +void llc_priv_set_filter_accept_list_flag_in_resolving_list_ucfg_weak(void* addr8_p, + uint8_t set); +void llc_priv_set_filter_accept_list_flag_in_resolving_list(void* addr8_p, + uint8_t set); + +void llc_priv_clr_all_filter_accept_list_flags_in_resolving_list_ucfg(void); +void llc_priv_clr_all_filter_accept_list_flags_in_resolving_list_ucfg_weak(void); +void llc_priv_clr_all_filter_accept_list_flags_in_resolving_list(void); + +void llc_priv_start_privacy_timer_ucfg(void); +void llc_priv_start_privacy_timer_ucfg_weak(void); +void llc_priv_start_privacy_timer(void); + +void llc_priv_stop_privacy_timer_ucfg(void); +void llc_priv_stop_privacy_timer_ucfg_weak(void); +void llc_priv_stop_privacy_timer(void); + +void llc_priv_init_random_part_of_one_local_rpa_ucfg(void* peer_id_p); +void llc_priv_init_random_part_of_one_local_rpa_ucfg_weak(void* peer_id_p); +void llc_priv_init_random_part_of_one_local_rpa(void* peer_id_p); + +void llc_pscan_cancel_slot_cte_ucfg(void* cntxt_per_p); +void llc_pscan_cancel_slot_cte_ucfg_weak(void* cntxt_per_p); +void llc_pscan_cancel_slot_cte(void* cntxt_per_p); + +uint8_t llc_pscan_isr_ucfg(void* cntxt_per_p); +uint8_t llc_pscan_isr_ucfg_weak(void* cntxt_per_p); +uint8_t llc_pscan_isr(void* cntxt_per_p); + +void llc_pscan_init_ucfg(void); +void llc_pscan_init_ucfg_weak(void); +void llc_pscan_init(void); + +void llc_pscan_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en); +void llc_pscan_mem_allocate_ucfg_weak(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en); +void llc_pscan_mem_allocate(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en); + +uint8_t llc_pscan_create_sync_pending_ucfg(void); +uint8_t llc_pscan_create_sync_pending_ucfg_weak(void); +uint8_t llc_pscan_create_sync_pending(void); + +void llc_pscan_enable_adv_addr_ucfg(void* list_p); +void llc_pscan_enable_adv_addr_ucfg_weak(void* list_p); +void llc_pscan_enable_adv_addr(void* list_p); + +void llc_pscan_push_padv_report_event_ucfg(void* params); +void llc_pscan_push_padv_report_event_ucfg_weak(void* params); +void llc_pscan_push_padv_report_event(void* params); + +void llc_pscan_push_past_received_event_ucfg(void* params); +void llc_pscan_push_past_received_event_ucfg_weak(void* params); +void llc_pscan_push_past_received_event(void* params); + +void llc_pscan_push_sync_established_event_ucfg(void* params); +void llc_pscan_push_sync_established_event_ucfg_weak(void* params); +void llc_pscan_push_sync_established_event(void* params); + +uint8_t llc_pscan_check_address_ucfg(void* addr_p); +uint8_t llc_pscan_check_address_ucfg_weak(void* addr_p); +uint8_t llc_pscan_check_address(void* addr_p); + +void llc_pscan_synchronizing_ucfg(void* params_p); +void llc_pscan_synchronizing_ucfg_weak(void* params_p); +void llc_pscan_synchronizing(void* params_p); + +void llc_pscan_wrong_cte_type_ucfg(void* cntxt_p); +void llc_pscan_wrong_cte_type_ucfg_weak(void* cntxt_p); +void llc_pscan_wrong_cte_type(void* cntxt_p); + +void llc_pscan_wr_init_ucfg(void); +void llc_pscan_wr_init_ucfg_weak(void); +void llc_pscan_wr_init(void); + +void llc_pscan_wr_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t pscan_wr_en, + uint8_t conn_en); +void llc_pscan_wr_mem_allocate_ucfg_weak(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t pscan_wr_en, + uint8_t conn_en); +void llc_pscan_wr_mem_allocate(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t pscan_wr_en, + uint8_t conn_en); + +void llc_pscan_wr_per_init_ucfg(uint8_t sync_idx); +void llc_pscan_wr_per_init_ucfg_weak(uint8_t sync_idx); +void llc_pscan_wr_per_init(uint8_t sync_idx); + +void llc_pscan_wr_config_tx_blue_sm_ucfg(void* params_p, + uint8_t pawr_feat); +void llc_pscan_wr_config_tx_blue_sm_ucfg_weak(void* params_p, + uint8_t pawr_feat); +void llc_pscan_wr_config_tx_blue_sm(void* params_p, + uint8_t pawr_feat); + +uint8_t llc_pscan_wr_get_pawr_info_ucfg(uint8_t acad_size, + uint8_t* acad_p, + uint8_t* pawr_info_p); +uint8_t llc_pscan_wr_get_pawr_info_ucfg_weak(uint8_t acad_size, + uint8_t* acad_p, + uint8_t* pawr_info_p); +uint8_t llc_pscan_wr_get_pawr_info(uint8_t acad_size, + uint8_t* acad_p, + uint8_t* pawr_info_p); + +uint8_t llc_pscan_wr_check_pawr_active_ucfg(uint8_t conn_idx); +uint8_t llc_pscan_wr_check_pawr_active_ucfg_weak(uint8_t conn_idx); +uint8_t llc_pscan_wr_check_pawr_active(uint8_t conn_idx); + +uint8_t llc_pscan_wr_check_pawr_info_ucfg(void* params_p); +uint8_t llc_pscan_wr_check_pawr_info_ucfg_weak(void* params_p); +uint8_t llc_pscan_wr_check_pawr_info(void* params_p); + +uint8_t llc_pscan_wr_reserve_taskslots_ucfg(void* params_p, + uint8_t pawr_feat); +uint8_t llc_pscan_wr_reserve_taskslots_ucfg_weak(void* params_p, + uint8_t pawr_feat); +uint8_t llc_pscan_wr_reserve_taskslots(void* params_p, + uint8_t pawr_feat); + +void llc_pscan_wr_set_pscan_cntxt_ucfg(void* cntxt_p, + void* params_p); +void llc_pscan_wr_set_pscan_cntxt_ucfg_weak(void* cntxt_p, + void* params_p); +void llc_pscan_wr_set_pscan_cntxt(void* cntxt_p, + void* params_p); + +void llc_pscan_wr_set_scheduler_params_ucfg(void* params_p); +void llc_pscan_wr_set_scheduler_params_ucfg_weak(void* params_p); +void llc_pscan_wr_set_scheduler_params(void* params_p); + +void llc_scan_conn_ind_sent_ucfg(void* ptr, + uint8_t idx); +void llc_scan_conn_ind_sent_ucfg_weak(void* ptr, + uint8_t idx); +void llc_scan_conn_ind_sent(void* ptr, + uint8_t idx); + +uint8_t llc_scan_process_ext_adv_ucfg(void* scan_p, + void* params_p, + uint32_t direct_addr[2], + uint8_t idx, + uint8_t advertiser_addr_flag, + uint8_t* send_report_p); +uint8_t llc_scan_process_ext_adv_ucfg_weak(void* scan_p, + void* params_p, + uint32_t direct_addr[2], + uint8_t idx, + uint8_t advertiser_addr_flag, + uint8_t* send_report_p); +uint8_t llc_scan_process_ext_adv(void* scan_p, + void* params_p, + uint32_t direct_addr[2], + uint8_t idx, + uint8_t advertiser_addr_flag, + uint8_t* send_report_p); + +void llc_scan_aux_conn_rsp_rcvd_ucfg(void* scan_p, + void* aux_p, + uint8_t idx); +void llc_scan_aux_conn_rsp_rcvd_ucfg_weak(void* scan_p, + void* aux_p, + uint8_t idx); +void llc_scan_aux_conn_rsp_rcvd(void* scan_p, + void* aux_p, + uint8_t idx); + +void llc_scan_init_ucfg(uint8_t ext_en); +void llc_scan_init_ucfg_weak(uint8_t ext_en); +void llc_scan_init(uint8_t ext_en); + +void llc_scan_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en); +void llc_scan_mem_allocate_ucfg_weak(uint8_t scan_en, + uint8_t ext_en); +void llc_scan_mem_allocate(uint8_t scan_en, + uint8_t ext_en); + +void llc_scan_prepare_conn_ind_req_ucfg(void* ptr, + uint8_t idx, + uint8_t aux_conn_req); +void llc_scan_prepare_conn_ind_req_ucfg_weak(void* ptr, + uint8_t idx, + uint8_t aux_conn_req); +void llc_scan_prepare_conn_ind_req(void* ptr, + uint8_t idx, + uint8_t aux_conn_req); + +void llc_scan_enable_extended_ucfg(void* scan_p); +void llc_scan_enable_extended_ucfg_weak(void* scan_p); +void llc_scan_enable_extended(void* scan_p); + +void llc_scan_push_ext_adv_report_ucfg(void* ptr, + uint8_t data_len, + uint8_t data_offset, + uint8_t event_type); +void llc_scan_push_ext_adv_report_ucfg_weak(void* ptr, + uint8_t data_len, + uint8_t data_offset, + uint8_t event_type); +void llc_scan_push_ext_adv_report(void* ptr, + uint8_t data_len, + uint8_t data_offset, + uint8_t event_type); + +tBleStatus llc_scan_reserve_taskslots_ucfg(void* scan_en_p, + void* scan_p); +tBleStatus llc_scan_reserve_taskslots_ucfg_weak(void* scan_en_p, + void* scan_p); +tBleStatus llc_scan_reserve_taskslots(void* scan_en_p, + void* scan_p); + +void llc_scan_set_conn_params_ucfg(Extended_Create_Connection_Parameters_t ext_create_conn_params, + uint8_t initiating_phy); +void llc_scan_set_conn_params_ucfg_weak(Extended_Create_Connection_Parameters_t ext_create_conn_params, + uint8_t initiating_phy); +void llc_scan_set_conn_params(Extended_Create_Connection_Parameters_t ext_create_conn_params, + uint8_t initiating_phy); + +void llc_scan_disable_ucfg(void* scan_p); +void llc_scan_disable_ucfg_weak(void* scan_p); +void llc_scan_disable(void* scan_p); + +uint8_t llc_subrate_get_active_sr_req_proc_ucfg(uint8_t conn_idx); +uint8_t llc_subrate_get_active_sr_req_proc_ucfg_weak(uint8_t conn_idx); +uint8_t llc_subrate_get_active_sr_req_proc(uint8_t conn_idx); + +void llc_subrate_new_sr_base_event_ucfg(uint16_t sr_factor, + uint16_t* sr_base_event_p); +void llc_subrate_new_sr_base_event_ucfg_weak(uint16_t sr_factor, + uint16_t* sr_base_event_p); +void llc_subrate_new_sr_base_event(uint16_t sr_factor, + uint16_t* sr_base_event_p); + +void llc_subrate_update_cont_counter_ucfg(void* cntxt_p); +void llc_subrate_update_cont_counter_ucfg_weak(void* cntxt_p); +void llc_subrate_update_cont_counter(void* cntxt_p); + +uint8_t llc_subrate_offline_processing_ucfg(void* cntxt_p); +uint8_t llc_subrate_offline_processing_ucfg_weak(void* cntxt_p); +uint8_t llc_subrate_offline_processing(void* cntxt_p); + +void llc_mngm_csa2_select_subevent_channel_ucfg(uint8_t subevent_counter, + uint8_t* subevent_index_p, + uint16_t prn_s, + uint8_t remapping_index_of_last_used_channel, + uint16_t* prn_subevent_lu_p, + uint16_t channel_identifier, + void* _csa2_table_p, + uint8_t* channel_index_p); +void llc_mngm_csa2_select_subevent_channel_ucfg_weak(uint8_t subevent_counter, + uint8_t* subevent_index_p, + uint16_t prn_s, + uint8_t remapping_index_of_last_used_channel, + uint16_t* prn_subevent_lu_p, + uint16_t channel_identifier, + void* _csa2_table_p, + uint8_t* channel_index_p); +void llc_mngm_csa2_select_subevent_channel(uint8_t subevent_counter, + uint8_t* subevent_index_p, + uint16_t prn_s, + uint8_t remapping_index_of_last_used_channel, + uint16_t* prn_subevent_lu_p, + uint16_t channel_identifier, + void* _csa2_table_p, + uint8_t* channel_index_p); + +void LL_cpe_init_length_update_ucfg(void); +void LL_cpe_init_length_update_ucfg_weak(void); +void LL_cpe_init_length_update(void); + +void LL_cpe_init_phy_update_ucfg(void); +void LL_cpe_init_phy_update_ucfg_weak(void); +void LL_cpe_init_phy_update(void); + +void LL_cpe_init_cte_ucfg(void); +void LL_cpe_init_cte_ucfg_weak(void); +void LL_cpe_init_cte(void); + +void LL_cpe_init_past_ucfg(void); +void LL_cpe_init_past_ucfg_weak(void); +void LL_cpe_init_past(void); + +void LL_cpe_init_pcl_ucfg(void); +void LL_cpe_init_pcl_ucfg_weak(void); +void LL_cpe_init_pcl(void); + +void LL_cpe_init_conn_update_ucfg(void); +void LL_cpe_init_conn_update_ucfg_weak(void); +void LL_cpe_init_conn_update(void); + +void LL_cpe_init_chmap_update_ucfg(void); +void LL_cpe_init_chmap_update_ucfg_weak(void); +void LL_cpe_init_chmap_update(void); + +void LL_cpe_init_chc_enable_ucfg(void); +void LL_cpe_init_chc_enable_ucfg_weak(void); +void LL_cpe_init_chc_enable(void); + +void LL_cpe_init_chc_reporting_ucfg(void); +void LL_cpe_init_chc_reporting_ucfg_weak(void); +void LL_cpe_init_chc_reporting(void); + +void LL_cpe_init_subrate_ucfg(void); +void LL_cpe_init_subrate_ucfg_weak(void); +void LL_cpe_init_subrate(void); + +void LL_cpe_init_sca_upd_ucfg(void); +void LL_cpe_init_sca_upd_ucfg_weak(void); +void LL_cpe_init_sca_upd(void); + +void LL_cpe_init_cis_ucfg(void); +void LL_cpe_init_cis_ucfg_weak(void); +void LL_cpe_init_cis(void); + +void LL_cpe_init_ucfg(void); +void LL_cpe_init_ucfg_weak(void); +void LL_cpe_init(void); + +void LLC_channel_map_copy_to_cpf_context_ucfg(void* cntxt_p, + uint8_t conn_idx); +void LLC_channel_map_copy_to_cpf_context_ucfg_weak(void* cntxt_p, + uint8_t conn_idx); +void LLC_channel_map_copy_to_cpf_context(void* cntxt_p, + uint8_t conn_idx); + +uint8_t LLC_channel_map_update_offline_processing_ucfg(uint8_t conn_idx); +uint8_t LLC_channel_map_update_offline_processing_ucfg_weak(uint8_t conn_idx); +uint8_t LLC_channel_map_update_offline_processing(uint8_t conn_idx); + +void LLC_conn_init_chc_ctxt_ucfg(uint8_t conn_idx); +void LLC_conn_init_chc_ctxt_ucfg_weak(uint8_t conn_idx); +void LLC_conn_init_chc_ctxt(uint8_t conn_idx); + +void LLC_chc_ll_cntxt_init_ucfg(void); +void LLC_chc_ll_cntxt_init_ucfg_weak(void); +void LLC_chc_ll_cntxt_init(void); + +uint8_t LLC_chc_reporting_offline_processing_ucfg(uint8_t conn_idx); +uint8_t LLC_chc_reporting_offline_processing_ucfg_weak(uint8_t conn_idx); +uint8_t LLC_chc_reporting_offline_processing(uint8_t conn_idx); + +void LL_cpf_cis_processing_ucfg(uint16_t task_idx); +void LL_cpf_cis_processing_ucfg_weak(uint16_t task_idx); +void LL_cpf_cis_processing(uint16_t task_idx); + +void LL_conn_upd_max_tx_time_coded_ucfg(void* params); +void LL_conn_upd_max_tx_time_coded_ucfg_weak(void* params); +void LL_conn_upd_max_tx_time_coded(void* params); + +void LL_conn_upd_data_length_change_event_ucfg(void* params); +void LL_conn_upd_data_length_change_event_ucfg_weak(void* params); +void LL_conn_upd_data_length_change_event(void* params); + +void llc_conn_init_cte_ctxt_ucfg(uint8_t conn_idx); +void llc_conn_init_cte_ctxt_ucfg_weak(uint8_t conn_idx); +void llc_conn_init_cte_ctxt(uint8_t conn_idx); + +uint8_t LLC_cte_request_procedure_ucfg(void* params); +uint8_t LLC_cte_request_procedure_ucfg_weak(void* params); +uint8_t LLC_cte_request_procedure(void* params); + +void LLC_connection_cte_response_pause_resume_ucfg(uint8_t conn_idx, + uint8_t tx_phy); +void LLC_connection_cte_response_pause_resume_ucfg_weak(uint8_t conn_idx, + uint8_t tx_phy); +void LLC_connection_cte_response_pause_resume(uint8_t conn_idx, + uint8_t tx_phy); + +void LLC_connection_cte_response_disable_ucfg(uint8_t conn_idx, + uint8_t taskslot_no); +void LLC_connection_cte_response_disable_ucfg_weak(uint8_t conn_idx, + uint8_t taskslot_no); +void LLC_connection_cte_response_disable(uint8_t conn_idx, + uint8_t taskslot_no); + +void llc_cte_process_rx_cte_ucfg(void* params, + uint8_t cte_type); +void llc_cte_process_rx_cte_ucfg_weak(void* params, + uint8_t cte_type); +void llc_cte_process_rx_cte(void* params, + uint8_t cte_type); + +void LLC_authenticated_payload_timeout_processing_ucfg(uint16_t task_idx); +void LLC_authenticated_payload_timeout_processing_ucfg_weak(uint16_t task_idx); +void LLC_authenticated_payload_timeout_processing(uint16_t task_idx); + +void llc_past_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t conn_en); +void llc_past_mem_allocate_ucfg_weak(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t conn_en); +void llc_past_mem_allocate(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t conn_en); + +void LL_past_load_txctrl_packet_from_scanner_ucfg(void* params, + uint8_t* pdu_p, + uint32_t instant_anchor, + uint32_t connect_interval, + uint16_t connect_event_count, + uint16_t connect_event_cnt); +void LL_past_load_txctrl_packet_from_scanner_ucfg_weak(void* params, + uint8_t* pdu_p, + uint32_t instant_anchor, + uint32_t connect_interval, + uint16_t connect_event_count, + uint16_t connect_event_cnt); +void LL_past_load_txctrl_packet_from_scanner(void* params, + uint8_t* pdu_p, + uint32_t instant_anchor, + uint32_t connect_interval, + uint16_t connect_event_count, + uint16_t connect_event_cnt); + +void LL_periodicscan_deploy_scanner_from_past_ucfg(void* params, + uint8_t conn_idx, + uint8_t pawr_feat); +void LL_periodicscan_deploy_scanner_from_past_ucfg_weak(void* params, + uint8_t conn_idx, + uint8_t pawr_feat); +void LL_periodicscan_deploy_scanner_from_past(void* params, + uint8_t conn_idx, + uint8_t pawr_feat); + +void LL_past_initialize_connect_context_ucfg(uint8_t conn_idx); +void LL_past_initialize_connect_context_ucfg_weak(uint8_t conn_idx); +void LL_past_initialize_connect_context(uint8_t conn_idx); + +void LL_past_default_params_ucfg(uint8_t conn_idx); +void LL_past_default_params_ucfg_weak(uint8_t conn_idx); +void LL_past_default_params(uint8_t conn_idx); + +void llc_conn_init_pcl_ctxt_ucfg(uint8_t conn_idx); +void llc_conn_init_pcl_ctxt_ucfg_weak(uint8_t conn_idx); +void llc_conn_init_pcl_ctxt(uint8_t conn_idx); + +void LLC_pcl_hal_cntxt_init_ucfg(uintptr_t pcl_cntxt_p); +void LLC_pcl_hal_cntxt_init_ucfg_weak(uintptr_t pcl_cntxt_p); +void LLC_pcl_hal_cntxt_init(uintptr_t pcl_cntxt_p); + +void LLC_pcl_incr_rx_packets_ucfg(uint8_t conn_idx); +void LLC_pcl_incr_rx_packets_ucfg_weak(uint8_t conn_idx); +void LLC_pcl_incr_rx_packets(uint8_t conn_idx); + +void LLC_pcl_update_avg_rssi_ucfg(void* params); +void LLC_pcl_update_avg_rssi_ucfg_weak(void* params); +void LLC_pcl_update_avg_rssi(void* params); + +void LLC_pcl_set_radio_tx_power_conn_start_ucfg(uint8_t conn_idx); +void LLC_pcl_set_radio_tx_power_conn_start_ucfg_weak(uint8_t conn_idx); +void LLC_pcl_set_radio_tx_power_conn_start(uint8_t conn_idx); + +uint8_t LLC_pcl_get_radio_tx_power_ucfg(uint8_t conn_idx, + uint8_t phy_idx); +uint8_t LLC_pcl_get_radio_tx_power_ucfg_weak(uint8_t conn_idx, + uint8_t phy_idx); +uint8_t LLC_pcl_get_radio_tx_power(uint8_t conn_idx, + uint8_t phy_idx); + +void LLC_pcl_set_radio_tx_power_and_eval_indication_ucfg(uint8_t conn_idx, + uint8_t send_ind, + int8_t ind_delta, + uint8_t change_txpower); +void LLC_pcl_set_radio_tx_power_and_eval_indication_ucfg_weak(uint8_t conn_idx, + uint8_t send_ind, + int8_t ind_delta, + uint8_t change_txpower); +void LLC_pcl_set_radio_tx_power_and_eval_indication(uint8_t conn_idx, + uint8_t send_ind, + int8_t ind_delta, + uint8_t change_txpower); + +uint8_t LLC_pcl_offline_processing_ucfg(uint8_t conn_idx); +uint8_t LLC_pcl_offline_processing_ucfg_weak(uint8_t conn_idx); +uint8_t LLC_pcl_offline_processing(uint8_t conn_idx); + +tBleStatus LL_Read_RSSI_ucfg(int8_t* rssiVal, + uint16_t connHandle); +tBleStatus LL_Read_RSSI_ucfg_weak(int8_t* rssiVal, + uint16_t connHandle); +tBleStatus LL_Read_RSSI(int8_t* rssiVal, + uint16_t connHandle); + +uint8_t LLC_pcl_get_number_of_phys_ucfg(void); +uint8_t LLC_pcl_get_number_of_phys_ucfg_weak(void); +uint8_t LLC_pcl_get_number_of_phys(void); + +void LL_phy_upd_compute_data_PDU_length_params_ucfg(void* params); +void LL_phy_upd_compute_data_PDU_length_params_ucfg_weak(void* params); +void LL_phy_upd_compute_data_PDU_length_params(void* params); + +uint8_t LL_phy_upd_pending_ucfg(uint8_t conn_idx); +uint8_t LL_phy_upd_pending_ucfg_weak(uint8_t conn_idx); +uint8_t LL_phy_upd_pending(uint8_t conn_idx); + +tBleStatus LL_phy_update_init_ucfg(void); +tBleStatus LL_phy_update_init_ucfg_weak(void); +tBleStatus LL_phy_update_init(void); + +tBleStatus LL_phy_update_init_per_st_data_ucfg(uint8_t conn_idx); +tBleStatus LL_phy_update_init_per_st_data_ucfg_weak(uint8_t conn_idx); +tBleStatus LL_phy_update_init_per_st_data(uint8_t conn_idx); + +void LL_phy_upd_evt_pending_check_isr_ucfg(uint8_t conn_idx); +void LL_phy_upd_evt_pending_check_isr_ucfg_weak(uint8_t conn_idx); +void LL_phy_upd_evt_pending_check_isr(uint8_t conn_idx); + +void LLC_blueapi_cte_ucfg(void* params); +void LLC_blueapi_cte_ucfg_weak(void* params); +void LLC_blueapi_cte(void* params); + +void LLC_connless_process_rx_cte_ucfg(uint8_t iq_samples_ready, + void* params, + uint8_t iq_samples_number, + uint8_t rx_cte_type, + uint8_t channel); +void LLC_connless_process_rx_cte_ucfg_weak(uint8_t iq_samples_ready, + void* params, + uint8_t iq_samples_number, + uint8_t rx_cte_type, + uint8_t channel); +void LLC_connless_process_rx_cte(uint8_t iq_samples_ready, + void* params, + uint8_t iq_samples_number, + uint8_t rx_cte_type, + uint8_t channel); + +uint8_t LLC_check_iq_samples_ready_ucfg(uint8_t* iq_samples_number, + uint8_t* channel, + uint8_t taskslot_no); +uint8_t LLC_check_iq_samples_ready_ucfg_weak(uint8_t* iq_samples_number, + uint8_t* channel, + uint8_t taskslot_no); +uint8_t LLC_check_iq_samples_ready(uint8_t* iq_samples_number, + uint8_t* channel, + uint8_t taskslot_no); + +void llc_cte_init_ucfg(void); +void llc_cte_init_ucfg_weak(void); +void llc_cte_init(void); + +void llc_cte_mem_allocate_ucfg(uint8_t cte_en, + uint8_t scan_en, + uint8_t ext_en, + uint8_t periodic_en); +void llc_cte_mem_allocate_ucfg_weak(uint8_t cte_en, + uint8_t scan_en, + uint8_t ext_en, + uint8_t periodic_en); +void llc_cte_mem_allocate(uint8_t cte_en, + uint8_t scan_en, + uint8_t ext_en, + uint8_t periodic_en); + +void llc_cte_timer_error_ucfg(void); +void llc_cte_timer_error_ucfg_weak(void); +void llc_cte_timer_error(void); + +void llc_cte_timer_start_ucfg(void* params); +void llc_cte_timer_start_ucfg_weak(void* params); +void llc_cte_timer_start(void* params); + +uint8_t llc_cte_timer_stop_ucfg(void); +uint8_t llc_cte_timer_stop_ucfg_weak(void); +uint8_t llc_cte_timer_stop(void); + +void LLC_test_process_rx_cte_ucfg(void* params); +void LLC_test_process_rx_cte_ucfg_weak(void* params); +void LLC_test_process_rx_cte(void* params); + +void LLC_test_set_cte_ucfg(void* params); +void LLC_test_set_cte_ucfg_weak(void* params); +void LLC_test_set_cte(void* params); + +void ADV_ISR_connect_request_received_ucfg(void* pointer, + uint8_t* packet, + void* PeerIDAddress_p); +void ADV_ISR_connect_request_received_ucfg_weak(void* pointer, + uint8_t* packet, + void* PeerIDAddress_p); +void ADV_ISR_connect_request_received(void* pointer, + uint8_t* packet, + void* PeerIDAddress_p); + +void LL_eadv_EauxIsr_connect_response_sent_ucfg(void* pointer); +void LL_eadv_EauxIsr_connect_response_sent_ucfg_weak(void* pointer); +void LL_eadv_EauxIsr_connect_response_sent(void* pointer); + +void LL_eadv_EauxIsr_connect_request_received_ucfg(void* pointer, + uint8_t* calibration_required); +void LL_eadv_EauxIsr_connect_request_received_ucfg_weak(void* pointer, + uint8_t* calibration_required); +void LL_eadv_EauxIsr_connect_request_received(void* pointer, + uint8_t* calibration_required); + +uint8_t EADV_start_request_radio_tasks_ucfg(void* pointer); +uint8_t EADV_start_request_radio_tasks_ucfg_weak(void* pointer); +uint8_t EADV_start_request_radio_tasks(void* pointer); + +tBleStatus llc_eadv_max_supported_data_check_ucfg(uint16_t data_length, + void* pointer); +tBleStatus llc_eadv_max_supported_data_check_ucfg_weak(uint16_t data_length, + void* pointer); +tBleStatus llc_eadv_max_supported_data_check(uint16_t data_length, + void* pointer); + +void LL_eadv_start_extended_ucfg(void* pointer); +void LL_eadv_start_extended_ucfg_weak(void* pointer); +void LL_eadv_start_extended(void* pointer); + +uint8_t ext_adv_scan_enabled_ucfg(void); +uint8_t ext_adv_scan_enabled_ucfg_weak(void); +uint8_t ext_adv_scan_enabled(void); + +tBleStatus LL_Clear_Advertising_Sets_ucfg(void); +tBleStatus LL_Clear_Advertising_Sets_ucfg_weak(void); +tBleStatus LL_Clear_Advertising_Sets(void); + +tBleStatus LL_Remove_Advertising_Set_ucfg(uint16_t Advertising_Handle); +tBleStatus LL_Remove_Advertising_Set_ucfg_weak(uint16_t Advertising_Handle); +tBleStatus LL_Remove_Advertising_Set(uint16_t Advertising_Handle); + +uint8_t Data_Len_Update_Offline_Processing_ucfg(void* params, + uint32_t ctrl_flds); +uint8_t Data_Len_Update_Offline_Processing_ucfg_weak(void* params, + uint32_t ctrl_flds); +uint8_t Data_Len_Update_Offline_Processing(void* params, + uint32_t ctrl_flds); + +tBleStatus ll_write_supported_data_ucfg(uint16_t Supported_Max_Tx_Octets, + uint16_t Supported_Max_Tx_Time, + uint16_t Supported_Max_Rx_Octets, + uint16_t Supported_Max_Rx_Time); +tBleStatus ll_write_supported_data_ucfg_weak(uint16_t Supported_Max_Tx_Octets, + uint16_t Supported_Max_Tx_Time, + uint16_t Supported_Max_Rx_Octets, + uint16_t Supported_Max_Rx_Time); +tBleStatus ll_write_supported_data(uint16_t Supported_Max_Tx_Octets, + uint16_t Supported_Max_Tx_Time, + uint16_t Supported_Max_Rx_Octets, + uint16_t Supported_Max_Rx_Time); + +void LL_init_ucfg(uint8_t dataLenExt, + uint8_t PhyUpd, + uint8_t ExtAdvScan, + uint8_t CtrlPriv, + uint8_t ScanSupp, + uint8_t PerAdvScan, + uint8_t PerAdvScanWr, + uint8_t Cte, + uint8_t Pcl, + uint8_t Cns, + uint8_t Chc); +void LL_init_ucfg_weak(uint8_t dataLenExt, + uint8_t PhyUpd, + uint8_t ExtAdvScan, + uint8_t CtrlPriv, + uint8_t ScanSupp, + uint8_t PerAdvScan, + uint8_t PerAdvScanWr, + uint8_t Cte, + uint8_t Pcl, + uint8_t Cns, + uint8_t Chc); +void LL_init(uint8_t dataLenExt, + uint8_t PhyUpd, + uint8_t ExtAdvScan, + uint8_t CtrlPriv, + uint8_t ScanSupp, + uint8_t PerAdvScan, + uint8_t PerAdvScanWr, + uint8_t Cte, + uint8_t Pcl, + uint8_t Cns, + uint8_t Chc); + +tBleStatus smp_debug_trudy__set_config_ucfg(uint32_t config); +tBleStatus smp_debug_trudy__set_config_ucfg_weak(uint32_t config); +tBleStatus smp_debug_trudy__set_config(uint32_t config); + +tBleStatus smp_start_encryption_ucfg(void* params); +tBleStatus smp_start_encryption_ucfg_weak(void* params); +tBleStatus smp_start_encryption(void* params); + +tBleStatus smp_pp1_cei_send_pairing_request_ucfg(void* params); +tBleStatus smp_pp1_cei_send_pairing_request_ucfg_weak(void* params); +tBleStatus smp_pp1_cei_send_pairing_request(void* params); + +tBleStatus smp_pp1_cei_rxp_pairing_response_excerpt_scp_ucfg(void* params); +tBleStatus smp_pp1_cei_rxp_pairing_response_excerpt_scp_ucfg_weak(void* params); +tBleStatus smp_pp1_cei_rxp_pairing_response_excerpt_scp(void* params); + +void smp_pp2_cei_auth_stage1_start_excerpt_scp_ucfg(void* params); +void smp_pp2_cei_auth_stage1_start_excerpt_scp_ucfg_weak(void* params); +void smp_pp2_cei_auth_stage1_start_excerpt_scp(void* params); + +void smp_pp2_per_auth_stage1_start_excerpt_scp_ucfg(void* params); +void smp_pp2_per_auth_stage1_start_excerpt_scp_ucfg_weak(void* params); +void smp_pp2_per_auth_stage1_start_excerpt_scp(void* params); + +void smp_pp2_cei_send_pairing_confirm_excerpt_scp_ucfg(void* params); +void smp_pp2_cei_send_pairing_confirm_excerpt_scp_ucfg_weak(void* params); +void smp_pp2_cei_send_pairing_confirm_excerpt_scp(void* params); + +tBleStatus smp_pp2_cei_rx_process_pairing_random_excerpt1_scp_ucfg(void* params); +tBleStatus smp_pp2_cei_rx_process_pairing_random_excerpt1_scp_ucfg_weak(void* params); +tBleStatus smp_pp2_cei_rx_process_pairing_random_excerpt1_scp(void* params); + +void smp_pp2_cei_rx_process_pairing_random_excerpt2_scp_ucfg(void* params); +void smp_pp2_cei_rx_process_pairing_random_excerpt2_scp_ucfg_weak(void* params); +void smp_pp2_cei_rx_process_pairing_random_excerpt2_scp(void* params); + +void smp_pp2_per_rx_process_pairing_confirm_excerpt_scp_ucfg(void* params); +void smp_pp2_per_rx_process_pairing_confirm_excerpt_scp_ucfg_weak(void* params); +void smp_pp2_per_rx_process_pairing_confirm_excerpt_scp(void* params); + +void smp_pp2_per_rx_process_pairing_random_excerpt_scp_ucfg(void* params); +void smp_pp2_per_rx_process_pairing_random_excerpt_scp_ucfg_weak(void* params); +void smp_pp2_per_rx_process_pairing_random_excerpt_scp(void* params); + +void smp_scp_init_ucfg(uint8_t use_debug_key); +void smp_scp_init_ucfg_weak(uint8_t use_debug_key); +void smp_scp_init(uint8_t use_debug_key); + +tBleStatus smp_scp_continue_on_exclusive_sc_pairing_ucfg(void* params); +tBleStatus smp_scp_continue_on_exclusive_sc_pairing_ucfg_weak(void* params); +tBleStatus smp_scp_continue_on_exclusive_sc_pairing(void* params); + +tBleStatus smp_scp_public_key_prepare_and_exchange_ucfg(void* params); +tBleStatus smp_scp_public_key_prepare_and_exchange_ucfg_weak(void* params); +tBleStatus smp_scp_public_key_prepare_and_exchange(void* params); + +tBleStatus smp_scp_oob_generate_new_local_data_ucfg(void); +tBleStatus smp_scp_oob_generate_new_local_data_ucfg_weak(void); +tBleStatus smp_scp_oob_generate_new_local_data(void); + +void smp_scp_stats_update_on_pairing_complete_ucfg(void* params); +void smp_scp_stats_update_on_pairing_complete_ucfg_weak(void* params); +void smp_scp_stats_update_on_pairing_complete(void* params); + +void smp_fsm_process_actions_wrt_state_tsk_ucfg(uint16_t task_idx); +void smp_fsm_process_actions_wrt_state_tsk_ucfg_weak(uint16_t task_idx); +void smp_fsm_process_actions_wrt_state_tsk(uint16_t task_idx); + +void smp_fsm_execute_actions_scp_phase2as2_ucfg(void* params); +void smp_fsm_execute_actions_scp_phase2as2_ucfg_weak(void* params); +void smp_fsm_execute_actions_scp_phase2as2(void* params); + +void smp_fsm_execute_actions_excerpt_cei_ucfg(void* params); +void smp_fsm_execute_actions_excerpt_cei_ucfg_weak(void* params); +void smp_fsm_execute_actions_excerpt_cei(void* params); + +void smp_pka_process_ecc_computation_tsk_ucfg(uint16_t task_idx); +void smp_pka_process_ecc_computation_tsk_ucfg_weak(uint16_t task_idx); +void smp_pka_process_ecc_computation_tsk(uint16_t task_idx); + +void smp_rxp_process_rxed_packets_tsk_ucfg(uint16_t task_idx); +void smp_rxp_process_rxed_packets_tsk_ucfg_weak(uint16_t task_idx); +void smp_rxp_process_rxed_packets_tsk(uint16_t task_idx); + +tBleStatus smp_rxp_process_exception_cases_excerpt_scp_ucfg(void* params); +tBleStatus smp_rxp_process_exception_cases_excerpt_scp_ucfg_weak(void* params); +tBleStatus smp_rxp_process_exception_cases_excerpt_scp(void* params); + +tBleStatus smp_rxp_process_wrt_current_fsm_excerpt_scp_ucfg(void* params); +tBleStatus smp_rxp_process_wrt_current_fsm_excerpt_scp_ucfg_weak(void* params); +tBleStatus smp_rxp_process_wrt_current_fsm_excerpt_scp(void* params); + +tBleStatus smp_rxp_process_wrt_current_fsm_excerpt_cei_ucfg(void* params); +tBleStatus smp_rxp_process_wrt_current_fsm_excerpt_cei_ucfg_weak(void* params); +tBleStatus smp_rxp_process_wrt_current_fsm_excerpt_cei(void* params); + +void smp_init_ucfg(void); +void smp_init_ucfg_weak(void); +void smp_init(void); + +void GAT_att_cmn_init_ucfg(void); +void GAT_att_cmn_init_ucfg_weak(void); +void GAT_att_cmn_init(void); + +void GAT_att_cmn_timer_expire_tsk_ucfg(uint16_t task_idx); +void GAT_att_cmn_timer_expire_tsk_ucfg_weak(uint16_t task_idx); +void GAT_att_cmn_timer_expire_tsk(uint16_t task_idx); + +void GAT_att_cmn_tx_pool_evt_tsk_ucfg(uint16_t task_idx); +void GAT_att_cmn_tx_pool_evt_tsk_ucfg_weak(uint16_t task_idx); +void GAT_att_cmn_tx_pool_evt_tsk(uint16_t task_idx); + +void GAT_att_srv_process_rx_pckt_tsk_ucfg(uint16_t task_idx); +void GAT_att_srv_process_rx_pckt_tsk_ucfg_weak(uint16_t task_idx); +void GAT_att_srv_process_rx_pckt_tsk(uint16_t task_idx); + +void GAT_srv_db_hash_tsk_ucfg(uint16_t task_idx); +void GAT_srv_db_hash_tsk_ucfg_weak(uint16_t task_idx); +void GAT_srv_db_hash_tsk(uint16_t task_idx); + +void GAT_srv_send_srv_change_tsk_ucfg(uint16_t task_idx); +void GAT_srv_send_srv_change_tsk_ucfg_weak(uint16_t task_idx); +void GAT_srv_send_srv_change_tsk(uint16_t task_idx); + +tBleStatus aci_gap_terminate_api(uint16_t Connection_Handle, + uint8_t Reason); + +tBleStatus aci_gap_start_connection_update_api(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + +tBleStatus aci_gap_set_scan_configuration_api(uint8_t duplicate_filtering, + uint8_t scanning_filter_policy, + uint8_t phy, + uint8_t scan_type, + uint16_t scan_interval, + uint16_t scan_window); + +tBleStatus aci_gap_set_connection_configuration_api(uint8_t phy, + uint16_t connection_interval_min, + uint16_t connection_interval_max, + uint16_t max_latency, + uint16_t supervision_timeout, + uint16_t min_ce_length, + uint16_t max_ce_length); + +tBleStatus aci_gap_create_connection_api(uint8_t Initiating_PHY, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); + +tBleStatus aci_gap_start_procedure_api(uint8_t procedure_code, + uint8_t phys, + uint16_t duration, + uint16_t period); + +tBleStatus aci_gap_discover_name_api(uint8_t PHYs, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); + +tBleStatus aci_gap_terminate_proc_api(uint8_t Procedure_Code); + +tBleStatus aci_gap_create_periodic_advertising_connection_api(uint8_t Advertising_Handle, + uint8_t Subevent, + uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + +tBleStatus aci_gap_remove_advertising_set_api(uint8_t Advertising_Handle); + +tBleStatus aci_gap_clear_advertising_sets_api(void); + +tBleStatus aci_gap_set_io_capability_api(uint8_t IO_Capability); + +tBleStatus aci_gap_set_security_requirements_api(uint8_t Bonding_Mode, + uint8_t MITM_Mode, + uint8_t SC_Support, + uint8_t KeyPress_Notification_Support, + uint8_t Min_Encryption_Key_Size, + uint8_t Max_Encryption_Key_Size, + uint8_t Pairing_Response); + +tBleStatus aci_gap_set_security_api(uint16_t Connection_Handle, + uint8_t Security_Level, + uint8_t Force_Pairing); + +tBleStatus aci_gap_pairing_resp_api(uint16_t Connection_Handle, + uint8_t Accept); + +tBleStatus aci_gap_passkey_resp_api(uint16_t Connection_Handle, + uint32_t Passkey); + +tBleStatus aci_gap_passkey_input_api(uint16_t Connection_Handle, + uint8_t Input_Type); + +tBleStatus aci_gap_get_oob_data_api(uint8_t OOB_Data_Type, + uint8_t* Address_Type, + uint8_t Address[6], + uint8_t* OOB_Data_Len, + uint8_t OOB_Data[16]); + +tBleStatus aci_gap_set_oob_data_api(uint8_t Device_Type, + uint8_t Address_Type, + uint8_t Address[6], + uint8_t OOB_Data_Type, + uint8_t OOB_Data_Len, + uint8_t OOB_Data[16]); + +tBleStatus aci_gap_numeric_comparison_value_confirm_yesno_api(uint16_t Connection_Handle, + uint8_t Confirm_Yes_No); + +tBleStatus aci_gap_get_security_level_api(uint16_t Connection_Handle, + uint8_t* Security_Mode, + uint8_t* Security_Level); + +tBleStatus aci_gap_clear_security_db_api(void); + +tBleStatus aci_gap_get_bonded_devices_api(uint8_t Offset, + uint8_t Max_Num_Of_Addresses, + uint8_t* Num_of_Addresses, + Bonded_Device_Entry_t* Bonded_Device_Entry); + +tBleStatus aci_gap_is_device_bonded_api(uint8_t Peer_Address_Type, + uint8_t Peer_Address[6]); + +tBleStatus aci_gap_remove_bonded_device_api(uint8_t peerIdentityAddressType, + uint8_t peerIdentityDeviceAddress[6]); + +tBleStatus aci_gatt_srv_add_service_api(ble_gatt_srv_def_t* Serv_p); + +tBleStatus aci_gatt_srv_rm_service_api(uint16_t Serv_Attr_H); + +uint16_t aci_gatt_srv_get_service_handle_api(ble_gatt_srv_def_t* Serv_p); + +tBleStatus aci_gatt_srv_include_service_api(uint16_t Serv_Attr_H, + uint16_t Incl_Serv_Attr_H); + +tBleStatus aci_gatt_srv_rm_include_service_api(uint16_t Incl_Serv_Attr_H); + +uint16_t aci_gatt_srv_get_include_service_handle_api(uint16_t Serv_Attr_H, + ble_gatt_srv_def_t* Included_Srv_p); + +tBleStatus aci_gatt_srv_add_char_api(ble_gatt_chr_def_t* Char_p, + uint16_t Serv_Attr_H); + +tBleStatus aci_gatt_srv_rm_char_api(uint16_t Char_Decl_Attr_H); + +uint16_t aci_gatt_srv_get_char_decl_handle_api(ble_gatt_chr_def_t* Char_p); + +tBleStatus aci_gatt_srv_add_char_desc_api(ble_gatt_descr_def_t* Descr_p, + uint16_t Char_Attr_H); + +uint16_t aci_gatt_srv_get_descriptor_handle_api(ble_gatt_descr_def_t* Descr_p); + +tBleStatus aci_gatt_srv_notify_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Flags, + uint16_t Val_Length, + uint8_t* Val_p); + +tBleStatus aci_gatt_srv_multi_notify_api(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Flags, + uint8_t Num_Of_Attr, + Gatt_Srv_Notify_Attr_t* Gatt_Srv_Notify_Attr); + +tBleStatus aci_gatt_srv_resp_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint8_t Error_Code, + uint16_t Data_Len, + uint8_t* Data_p); + +tBleStatus aci_gatt_srv_read_handle_value_api(uint16_t Attr_Handle, + uint16_t* Val_Length_p, + uint8_t** Val_pp); + +tBleStatus aci_gatt_srv_read_multiple_instance_handle_value_api(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t* Val_Length_p, + uint8_t** Val_pp); + +tBleStatus aci_gatt_srv_write_multiple_instance_handle_value_api(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Char_Value_Length, + uint8_t* Char_Value); + +tBleStatus aci_gatt_set_event_mask_api(uint32_t GATT_Evt_Mask); + +tBleStatus aci_gatt_clt_exchange_config_api(uint16_t Connection_Handle); + +tBleStatus aci_gatt_clt_disc_all_primary_services_api(uint16_t Connection_Handle, + uint16_t CID); + +tBleStatus aci_gatt_clt_disc_primary_service_by_uuid_api(uint16_t Connection_Handle, + uint16_t CID, + uint8_t UUID_Type, + UUID_t* UUID); + +tBleStatus aci_gatt_clt_disc_all_char_of_service_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle); + +tBleStatus aci_gatt_clt_disc_char_by_uuid_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle, + uint8_t UUID_Type, + UUID_t* UUID); + +tBleStatus aci_gatt_clt_disc_all_char_desc_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Char_Handle, + uint16_t End_Handle); + +tBleStatus aci_gatt_clt_find_included_services_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle); + +tBleStatus aci_gatt_clt_read_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle); + +tBleStatus aci_gatt_clt_read_long_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset); + +tBleStatus aci_gatt_clt_read_using_char_uuid_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Start_Handle, + uint16_t End_Handle, + uint8_t UUID_Type, + UUID_t* UUID); + +tBleStatus aci_gatt_clt_read_multiple_char_value_api(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Number_of_Handles, + uint16_t* Handle_Entry); + +tBleStatus aci_gatt_clt_read_multiple_var_len_char_value_api(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Number_of_Handles, + uint16_t* Handle_Entry); + +tBleStatus aci_gatt_clt_write_without_resp_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t* Attribute_Val); + +tBleStatus aci_gatt_clt_signed_write_without_resp_api(uint16_t Connection_Handle, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t* Attribute_Val); + +tBleStatus aci_gatt_clt_write_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Attribute_Val_Length, + uint8_t* Attribute_Val); + +tBleStatus aci_gatt_clt_write_long_api(uint16_t Connection_Handle, + uint16_t CID, + ble_gatt_clt_write_ops_t* Write_Ops_p); + +tBleStatus aci_gatt_clt_write_char_reliable_api(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Num_Attrs, + ble_gatt_clt_write_ops_t* Write_Ops_p); + +tBleStatus aci_gatt_clt_prepare_write_req_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t Attr_Handle, + uint16_t Val_Offset, + uint16_t Attribute_Val_Length, + uint8_t* Attribute_Val); + +tBleStatus aci_gatt_clt_execute_write_req_api(uint16_t Connection_Handle, + uint16_t CID, + uint8_t Execute); + +tBleStatus aci_gatt_clt_confirm_indication_api(uint16_t Connection_Handle, + uint16_t CID); + +tBleStatus aci_hal_peripheral_latency_enable_api(uint16_t Connection_Handle, + uint8_t Enable); + +tBleStatus aci_hal_set_le_power_control_api(uint8_t Enable, + uint8_t PHY, + int8_t RSSI_Target, + uint8_t RSSI_Hysteresis, + int8_t Initial_TX_Power, + uint8_t RSSI_Filtering_Coefficient); + +tBleStatus aci_hal_get_anchor_point_api(uint16_t connection_handle, + uint16_t* event_counter, + uint32_t* anchor_point); + +tBleStatus aci_l2cap_connection_parameter_update_req_api(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Peripheral_Latency, + uint16_t Timeout_Multiplier); + +tBleStatus aci_l2cap_connection_parameter_update_resp_api(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Peripheral_Latency, + uint16_t Timeout_Multiplier, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length, + uint8_t Identifier, + uint8_t Accept); + +tBleStatus aci_l2cap_cos_connection_req_api(uint16_t connection_handle, + uint16_t spsm, + uint16_t mtu, + uint16_t mps, + uint8_t channel_type, + uint8_t cid_count); + +tBleStatus aci_l2cap_cos_connection_resp_api(uint16_t connection_handle, + uint8_t identifier, + uint16_t mtu, + uint16_t mps, + uint16_t result, + uint8_t cid_count, + uint16_t* local_cid); + +tBleStatus aci_l2cap_cos_flow_control_credits_ind_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credits, + uint8_t CFC_Policy, + uint16_t* RX_Credit_Balance); + +tBleStatus aci_l2cap_cos_disconnect_req_api(uint16_t Connection_Handle, + uint16_t CID); + +tBleStatus aci_l2cap_cos_reconfigure_req_api(uint16_t connection_handle, + uint16_t mtu, + uint16_t mps, + uint8_t cid_count, + uint16_t* local_cid_array); + +tBleStatus aci_l2cap_cos_reconfigure_resp_api(uint16_t connection_handle, + uint8_t identifier, + uint16_t result); + +tBleStatus aci_l2cap_cos_sdu_data_transmit_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Length, + uint8_t* SDU_Data); + +tBleStatus aci_l2cap_cos_sdu_data_extract_api(uint16_t Connection_Handle, + uint16_t CID, + uint16_t SDU_Data_Buffer_Size, + void* SDU_Data_Buffer, + uint16_t* SDU_Length); + +tBleStatus hci_le_read_buffer_size_v2_api(uint16_t* HC_LE_ACL_Data_Packet_Length, + uint8_t* HC_Total_Num_LE_ACL_Data_Packets, + uint16_t* HC_LE_ISO_Data_Packet_Length, + uint8_t* HC_Total_Num_LE_ISO_Data_Packets); + +tBleStatus hci_le_create_big_test_api(uint8_t big_handle, + uint8_t advertising_handle, + uint8_t num_bis, + uint8_t* sdu_interval_us, + uint16_t iso_interval_1_25ms, + uint8_t nse, + uint16_t max_sdu, + uint16_t max_pdu, + uint8_t phy, + uint8_t packing_interleaved, + uint8_t framing, + uint8_t bn, + uint8_t irc, + uint8_t pto, + uint8_t encryption, + uint8_t* broadcast_code_ext); + +tBleStatus hci_le_big_create_sync_api(uint8_t BIG_Handle, + uint16_t Sync_Handle, + uint8_t Encryption, + uint8_t* Broadcast_Code, + uint8_t MSE, + uint16_t BIG_Sync_Timeout, + uint8_t Num_BIS, + uint8_t* BIS); + +tBleStatus hci_le_terminate_big_api(uint8_t Terminate_Big, + uint8_t Reason); + +tBleStatus hci_le_big_terminate_sync_api(uint8_t Big_handle); + +tBleStatus hci_le_create_big_api(uint8_t big_handle, + uint8_t advertising_handle, + uint8_t num_bis, + uint8_t* sdu_interval_us, + uint16_t max_sdu, + uint16_t Max_Transport_Latency, + uint8_t RTN, + uint8_t phy, + uint8_t packing_interleaved, + uint8_t framing, + uint8_t encryption, + uint8_t* broadcast_code_ext); + +tBleStatus hci_read_afh_channel_assessment_mode_api(uint8_t* AFH_Channel_Assessment_Mode); + +tBleStatus hci_write_afh_channel_assessment_mode_api(uint8_t AFH_Channel_Assessment_Mode); + +tBleStatus hci_le_set_host_channel_classification_api(uint8_t Channel_Map[LLC_MIN_NUM_DATA_CHAN_MAP_BYTES]); + +tBleStatus hci_le_set_cig_parameters_api(uint8_t CIG_ID, + uint8_t SDU_Interval_C_To_P[3], + uint8_t SDU_Interval_P_To_C[3], + uint8_t Worst_Case_SCA, + uint8_t Packing, + uint8_t Framing, + uint16_t Max_Transport_Latency_C_To_P, + uint16_t Max_Transport_Latency_P_To_C, + uint8_t CIS_Count, + CIS_Param_t* CIS_params, + uint16_t* CIS_Conn_Handles); + +tBleStatus hci_le_set_cig_parameters_test_api(uint8_t CIG_ID, + uint8_t SDU_Interval_C_To_P[3], + uint8_t SDU_Interval_P_To_C[3], + uint8_t FT_C_To_P, + uint8_t FT_P_To_C, + uint16_t ISO_Interval, + uint8_t Worst_Case_SCA, + uint8_t Packing, + uint8_t Framing, + uint8_t CIS_Count, + CIS_Param_Test_t* CIS_Param_test, + uint16_t* CIS_Conn_Handles); + +tBleStatus hci_le_create_cis_api(uint8_t CIS_Count, + CIS_Handles_t* create_cis_connection_params); + +tBleStatus hci_le_remove_cig_api(uint8_t CIG_ID); + +tBleStatus hci_le_accept_cis_request_api(uint16_t Connection_Handle); + +tBleStatus hci_le_reject_cis_request_api(uint16_t Connection_Handle, + uint8_t Reason); + +tBleStatus hci_read_connection_accept_timeout_api(uint16_t* Connection_Accept_Timeout); + +tBleStatus hci_write_connection_accept_timeout_api(uint16_t Connection_Accept_Timeout); + +tBleStatus hci_le_set_host_feature_api(uint8_t Bit_Number, + uint8_t Bit_Value); + +tBleStatus hci_read_remote_version_information_api(uint16_t Connection_Handle); + +tBleStatus hci_le_read_remote_features_api(uint16_t Connection_Handle); + +tBleStatus hci_read_transmit_power_level_api(uint16_t Connection_Handle, + uint8_t Type, + int8_t* Transmit_Power_Level); + +tBleStatus hci_read_rssi_api(uint16_t Connection_Handle, + int8_t* RSSI); + +tBleStatus hci_le_read_channel_map_api(uint16_t Connection_Handle, + uint8_t LE_Channel_Map[LLC_MIN_NUM_DATA_CHAN_MAP_BYTES]); + +tBleStatus hci_disconnect_api(uint16_t Connection_Handle, + uint8_t Reason); + +tBleStatus hci_le_create_connection_api(uint16_t LE_Scan_Interval, + uint16_t LE_Scan_Window, + uint8_t Initiator_Filter_Policy, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Own_Address_Type, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + +tBleStatus hci_le_create_connection_cancel_api(void); + +tBleStatus hci_le_extended_create_connection_api(uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Initiating_PHYs, + Extended_Create_Connection_Parameters_t* Extended_Create_Connection_Parameters); + +tBleStatus hci_le_extended_create_connection_v2_api(uint8_t Advertising_Handle, + uint8_t Subevent, + uint8_t Initiator_Filter_Policy, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Initiating_PHYs, + Extended_Create_Connection_Parameters_t* Extended_Create_Connection_Parameters); + +tBleStatus hci_le_set_connectionless_cte_transmit_parameters_api(uint8_t Advertising_Handle, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t CTE_Count, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs); + +tBleStatus hci_le_set_connectionless_cte_transmit_enable_api(uint8_t Advertising_Handle, + uint8_t CTE_Enable); + +tBleStatus hci_le_set_connectionless_iq_sampling_enable_api(uint16_t Sync_Handle, + uint8_t Sampling_Enable, + uint8_t Slot_Durations, + uint8_t Max_Sampled_CTEs, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs); + +tBleStatus hci_le_set_connection_cte_receive_parameters_api(uint16_t Connection_Handle, + uint8_t Sampling_Enable, + uint8_t Slot_Durations, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs); + +tBleStatus hci_le_set_connection_cte_transmit_parameters_api(uint16_t Connection_Handle, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs); + +tBleStatus hci_le_connection_cte_request_enable_api(uint16_t Connection_Handle, + uint8_t Enable, + uint16_t CTE_Request_Interval, + uint8_t Requested_CTE_Length, + uint8_t Requested_CTE_Type); + +tBleStatus hci_le_connection_cte_response_enable_api(uint16_t Connection_Handle, + uint8_t Enable); + +tBleStatus hci_le_read_antenna_information_api(uint8_t* Supported_Switching_Sampling_Rates, + uint8_t* Num_Antennae, + uint8_t* Max_Switching_Pattern_Length, + uint8_t* Max_CTE_Length); + +tBleStatus hci_le_enable_encryption_api(uint16_t Connection_Handle, + uint8_t Random_Number[8], + uint16_t Encrypted_Diversifier, + uint8_t Long_Term_Key[16]); + +tBleStatus hci_le_long_term_key_request_reply_api(uint16_t Connection_Handle, + uint8_t Long_Term_Key[16]); + +tBleStatus hci_le_long_term_key_request_negative_reply_api(uint16_t Connection_Handle); + +tBleStatus hci_le_read_local_p256_public_key_api(void); + +tBleStatus hci_le_generate_dhkey_api(uint8_t Remote_P256_Public_Key[64]); + +tBleStatus hci_read_authenticated_payload_timeout_api(uint16_t Connection_Handle, + uint16_t* Authenticated_Payload_Timeout); + +tBleStatus hci_write_authenticated_payload_timeout_api(uint16_t Connection_Handle, + uint16_t Authenticated_Payload_Timeout); + +tBleStatus hci_le_set_extended_advertising_parameters_api(uint8_t Advertising_Handle, + uint16_t Advertising_Event_Properties, + uint8_t Primary_Advertising_Interval_Min[3], + uint8_t Primary_Advertising_Interval_Max[3], + uint8_t Primary_Advertising_Channel_Map, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable, + int8_t* Selected_Tx_Power); + +tBleStatus hci_le_set_extended_advertising_parameters_v2_api(uint8_t Advertising_Handle, + uint16_t Advertising_Event_Properties, + uint8_t Primary_Advertising_Interval_Min[3], + uint8_t Primary_Advertising_Interval_Max[3], + uint8_t Primary_Advertising_Channel_Map, + uint8_t Own_Address_Type, + uint8_t Peer_Address_Type, + uint8_t Peer_Address[6], + uint8_t Advertising_Filter_Policy, + int8_t Advertising_Tx_Power, + uint8_t Primary_Advertising_PHY, + uint8_t Secondary_Advertising_Max_Skip, + uint8_t Secondary_Advertising_PHY, + uint8_t Advertising_SID, + uint8_t Scan_Request_Notification_Enable, + uint8_t Primary_Advertising_PHY_Options, + uint8_t Secondary_Advertising_PHY_Options, + int8_t* Selected_Tx_Power); + +tBleStatus hci_le_set_advertising_set_random_address_api(uint8_t Advertising_Handle, + uint8_t Advertising_Random_Address[6]); + +tBleStatus hci_le_set_extended_advertising_enable_api(uint8_t Enable, + uint8_t Number_of_Sets, + Advertising_Set_Parameters_t* Advertising_Set_Parameters); + +tBleStatus hci_le_read_number_of_supported_advertising_sets_api(uint8_t* Num_Supported_Advertising_Sets); + +tBleStatus hci_le_remove_advertising_set_api(uint8_t Advertising_Handle); + +tBleStatus hci_le_clear_advertising_sets_api(void); + +tBleStatus hci_le_set_default_periodic_advertising_sync_transfer_parameters_api(uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type); + +tBleStatus hci_le_set_periodic_advertising_sync_transfer_parameters_api(uint16_t Connection_Handle, + uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type); + +tBleStatus hci_le_periodic_advertising_set_info_transfer_api(uint16_t Connection_Handle, + uint16_t Service_Data, + uint8_t Advertising_Handle); + +tBleStatus hci_le_periodic_advertising_sync_transfer_api(uint16_t Connection_Handle, + uint16_t Service_Data, + uint16_t Sync_Handle); + +tBleStatus hci_le_iso_transmit_test_api(uint16_t Connection_Handle, + uint8_t Payload_Type); + +tBleStatus hci_le_iso_receive_test_api(uint16_t Connection_Handle, + uint8_t Payload_Type); + +tBleStatus hci_le_iso_read_test_counters_api(uint16_t Connection_Handle, + uint32_t* Received_Packet_Count, + uint32_t* Missed_Packet_Count, + uint32_t* Failed_Packet_Count); + +tBleStatus hci_le_iso_test_end_api(uint16_t Connection_Handle, + uint32_t* Received_Packet_Count, + uint32_t* Missed_Packet_Count, + uint32_t* Failed_Packet_Count); + +tBleStatus hci_le_setup_iso_data_path_api(uint16_t Connection_Handle, + uint8_t Data_Path_Direction, + uint8_t Data_Path_ID, + uint8_t* CODEC_ID, + uint8_t* Controller_Delay, + uint8_t Codec_Configuration_Length, + uint8_t* Codec_Configuration); + +tBleStatus hci_le_remove_iso_data_path_api(uint16_t Connection_Handle, + uint8_t Data_Path_Direction); + +tBleStatus hci_le_read_iso_link_quality_api(uint16_t connection_handle, + uint32_t* tx_unacked_packets, + uint32_t* tx_flushed_packets, + uint32_t* tx_last_subevent_packets, + uint32_t* retransmitted_packets, + uint32_t* CRC_error_packets, + uint32_t* rx_unreceived_packets, + uint32_t* duplicate_packets); + +tBleStatus hci_le_read_iso_tx_sync_api(uint16_t connection_handle, + uint16_t* packet_sequence_number, + uint32_t* timestamp, + uint8_t* timeoffset); + +tBleStatus hci_tx_iso_data_api(uint16_t connection_handle, + uint8_t pb_flag, + uint8_t ts_flag, + uint16_t iso_data_load_len, + uint8_t* iso_data_load_p); + +tBleStatus hci_le_set_data_length_api(uint16_t Connection_Handle, + uint16_t Tx_Octets, + uint16_t Tx_Time); + +tBleStatus hci_le_read_suggested_default_data_length_api(uint16_t* Suggested_Max_Tx_Octets, + uint16_t* Suggested_Max_Tx_Time); + +tBleStatus hci_le_write_suggested_default_data_length_api(uint16_t Suggested_Max_Tx_Octets, + uint16_t Suggested_Max_Tx_Time); + +tBleStatus hci_le_read_maximum_data_length_api(uint16_t* Supported_Max_Tx_Octets, + uint16_t* Supported_Max_Tx_Time, + uint16_t* Supported_Max_Rx_Octets, + uint16_t* Supported_Max_Rx_Time); + +tBleStatus hci_le_set_periodic_advertising_parameters_api(uint8_t Advertising_Handle, + uint16_t Periodic_Advertising_Interval_Min, + uint16_t Periodic_Advertising_Interval_Max, + uint16_t Periodic_Advertising_Properties); + +tBleStatus hci_le_set_periodic_advertising_enable_api(uint8_t Enable, + uint8_t Advertising_Handle); + +tBleStatus hci_le_set_periodic_advertising_parameters_v2_api(uint8_t Advertising_Handle, + uint16_t Periodic_Advertising_Interval_Min, + uint16_t Periodic_Advertising_Interval_Max, + uint16_t Periodic_Advertising_Properties, + uint8_t Num_Subevents, + uint8_t Subevent_Interval, + uint8_t Response_Slot_Delay, + uint8_t Response_Slot_Spacing, + uint8_t Num_Response_Slots); + +tBleStatus hci_le_enhanced_read_transmit_power_level_api(uint16_t Connection_Handle, + uint8_t PHY, + int8_t* Current_TX_Power_Level, + int8_t* Max_TX_Power_Level); + +tBleStatus hci_le_read_remote_transmit_power_level_api(uint16_t Connection_Handle, + uint8_t PHY); + +tBleStatus hci_le_set_path_loss_reporting_parameters_api(uint16_t Connection_Handle, + uint8_t High_Threshold, + uint8_t High_Hysteresis, + uint8_t Low_Threshold, + uint8_t Low_Hysteresis, + uint16_t Min_Time_Spent); + +tBleStatus hci_le_set_path_loss_reporting_enable_api(uint16_t Connection_Handle, + uint8_t Enable); + +tBleStatus hci_le_set_transmit_power_reporting_enable_api(uint16_t Connection_Handle, + uint8_t Local_Enable, + uint8_t Remote_Enable); + +tBleStatus hci_le_read_phy_api(uint16_t Connection_Handle, + uint8_t* TX_PHY, + uint8_t* RX_PHY); + +tBleStatus hci_le_set_default_phy_api(uint8_t ALL_PHYS, + uint8_t TX_PHYS, + uint8_t RX_PHYS); + +tBleStatus hci_le_set_phy_api(uint16_t Connection_Handle, + uint8_t ALL_PHYS, + uint8_t TX_PHYS, + uint8_t RX_PHYS, + uint16_t PHY_options); + +tBleStatus hci_le_add_device_to_resolving_list_api(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Peer_IRK[16], + uint8_t Local_IRK[16]); + +tBleStatus hci_le_remove_device_from_resolving_list_api(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6]); + +tBleStatus hci_le_clear_resolving_list_api(void); + +tBleStatus hci_le_read_resolving_list_size_api(uint8_t* Resolving_List_Size); + +tBleStatus hci_le_read_peer_resolvable_address_api(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Peer_Resolvable_Address[6]); + +tBleStatus hci_le_read_local_resolvable_address_api(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Local_Resolvable_Address[6]); + +tBleStatus hci_le_set_address_resolution_enable_api(uint8_t Address_Resolution_Enable); + +tBleStatus hci_le_set_resolvable_private_address_timeout_api(uint16_t RPA_Timeout); + +tBleStatus hci_le_set_privacy_mode_api(uint8_t Peer_Identity_Address_Type, + uint8_t Peer_Identity_Address[6], + uint8_t Privacy_Mode); + +tBleStatus hci_le_set_data_related_address_changes_api(uint8_t Advertising_Handle, + uint8_t Change_Reasons); + +tBleStatus hci_le_add_device_to_periodic_advertiser_list_api(uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint8_t Advertising_SID); + +tBleStatus hci_le_clear_periodic_advertiser_list_api(void); + +tBleStatus hci_le_periodic_advertising_create_sync_api(uint8_t Options, + uint8_t Advertising_SID, + uint8_t Advertising_Address_Type, + uint8_t Advertiser_Address[6], + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t Sync_CTE_Type); + +tBleStatus hci_le_periodic_advertising_create_sync_cancel_api(void); + +tBleStatus hci_le_periodic_advertising_terminate_sync_api(uint16_t Sync_Handle); + +tBleStatus hci_le_read_periodic_advertiser_list_size_api(uint8_t* Periodic_Advertiser_List_Size); + +tBleStatus hci_le_remove_device_from_periodic_advertiser_list_api(uint8_t Advertiser_Address_Type, + uint8_t Advertiser_Address[6], + uint8_t Advertising_SID); + +tBleStatus hci_le_set_periodic_advertising_receive_enable_api(uint16_t Sync_Handle, + uint8_t Enable); + +tBleStatus hci_le_set_periodic_sync_subevent_api(uint16_t Sync_Handle, + uint16_t Periodic_Advertising_Properties, + uint8_t Num_Subevents, + uint8_t* Subevent); + +tBleStatus hci_le_request_peer_sca_api(uint16_t Connection_Handle); + +tBleStatus hci_le_set_scan_parameters_api(uint8_t LE_Scan_Type, + uint16_t LE_Scan_Interval, + uint16_t LE_Scan_Window, + uint8_t Own_Address_Type, + uint8_t Scanning_Filter_Policy); + +tBleStatus hci_le_set_scan_enable_api(uint8_t LE_Scan_Enable, + uint8_t Filter_Duplicates); + +tBleStatus hci_le_set_extended_scan_parameters_api(uint8_t Own_Address_Type, + uint8_t Scanning_Filter_Policy, + uint8_t Scanning_PHYs, + Extended_Scan_Parameters_t* Extended_Scan_Parameters); + +tBleStatus hci_le_set_extended_scan_enable_api(uint8_t Enable, + uint8_t Filter_Duplicates, + uint16_t Duration, + uint16_t Period); + +tBleStatus hci_le_connection_update_api(uint16_t Connection_Handle, + uint16_t Connection_Interval_Min, + uint16_t Connection_Interval_Max, + uint16_t Max_Latency, + uint16_t Supervision_Timeout, + uint16_t Min_CE_Length, + uint16_t Max_CE_Length); + +tBleStatus hci_le_set_default_subrate_api(uint16_t Subrate_Min, + uint16_t Subrate_Max, + uint16_t Max_Latency, + uint16_t Continuation_Number, + uint16_t Supervision_Timeout); + +tBleStatus hci_le_subrate_request_api(uint16_t Connection_Handle, + uint16_t Subrate_Min, + uint16_t Subrate_Max, + uint16_t Max_Latency, + uint16_t Continuation_Number, + uint16_t Supervision_Timeout); + +tBleStatus hci_le_receiver_test_v2_api(uint8_t RX_Frequency, + uint8_t Phy, + uint8_t Modulation_index); + +tBleStatus hci_le_receiver_test_v3_api(uint8_t RX_Channel, + uint8_t PHY, + uint8_t Modulation_Index, + uint8_t Expected_CTE_Length, + uint8_t Expected_CTE_Type, + uint8_t Slot_Durations, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs); + +tBleStatus hci_le_transmitter_test_v2_api(uint8_t TX_Frequency, + uint8_t Length_Of_Test_Data, + uint8_t Packet_Payload, + uint8_t Phy); + +tBleStatus hci_le_transmitter_test_v3_api(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs); + +tBleStatus hci_le_transmitter_test_v4_api(uint8_t TX_Channel, + uint8_t Test_Data_Length, + uint8_t Packet_Payload, + uint8_t PHY, + uint8_t CTE_Length, + uint8_t CTE_Type, + uint8_t Switching_Pattern_Length, + uint8_t* Antenna_IDs, + int8_t Transmit_Power_Level); + + +void Get_Random_Addr(uint8_t *randBdAddr); + +#endif /* BLE_STACK_USER_CFG_H */ + diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_status.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_status.h new file mode 100644 index 000000000..c2eeda640 --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_status.h @@ -0,0 +1,350 @@ +/** + ****************************************************************************** + * @file ble_status.h + * @author GPM WBL Application team + * @brief Header file which contains definition of Bluetooth status and error codes. + * @note Error Codes are defined according to Bluetooth Specifications + * Vol.2 Part D. + * - HCI/Controller standard codes range is [0x00 : 0x3F]. + * Their name is prefixed by "BLE_ERROR_" + * - Host specific (and proprietary) error codes range is [0x80 : 0xFF]. + * Their name is prefixed by "BLE_STATUS_" and they're grouped by Layer + * - BLE_STATUS_SUCCESS value is 0x00 and is the unique error code + * used by both Controller and Host layers. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef __BLE_STATUS_H__ +#define __BLE_STATUS_H__ + +#include +typedef uint8_t tBleStatus; + +/* @brief Standard Error Codes as specified by the Bluetooth Specifications + * Vol.2, Part D ("Error Codes"). + * According to the spec the error codes range is from 0x00 to 0x3F. + */ +#define BLE_STATUS_SUCCESS ((tBleStatus)(0x00)) + +#define BLE_ERROR_UNKNOWN_HCI_COMMAND ((tBleStatus)(0x01)) +#define BLE_ERROR_UNKNOWN_CONNECTION_ID ((tBleStatus)(0x02)) + +#define BLE_ERROR_HARDWARE_FAILURE ((tBleStatus)(0x03)) + +#define BLE_ERROR_AUTHENTICATION_FAILURE ((tBleStatus)(0x05)) +#define BLE_ERROR_KEY_MISSING ((tBleStatus)(0x06)) +#define BLE_ERROR_MEMORY_CAPACITY_EXCEEDED ((tBleStatus)(0x07)) +#define BLE_ERROR_CONNECTION_TIMEOUT ((tBleStatus)(0x08)) +#define BLE_ERROR_CONN_LIMIT ((tBleStatus)(0x09)) + +#define BLE_ERROR_CONNECTION_ALREADY_EXISTS ((tBleStatus)(0x0B)) +#define BLE_ERROR_COMMAND_DISALLOWED ((tBleStatus)(0x0C)) + +#define BLE_ERROR_CONN_REJECT_DUE_TO_LIMITED_RESOURCES ((tBleStatus)(0x0D)) + +#define BLE_ERROR_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED ((tBleStatus)(0x10)) + +#define BLE_ERROR_UNSUPPORTED_FEATURE ((tBleStatus)(0x11)) + +#define BLE_ERROR_INVALID_HCI_CMD_PARAMS ((tBleStatus)(0x12)) + +#define BLE_ERROR_TERMINATED_REMOTE_USER ((tBleStatus)(0x13)) + +#define BLE_ERROR_TERMINATED_LOCAL_HOST ((tBleStatus)(0x16)) + +#define BLE_ERROR_UNSUPP_RMT_FEATURE ((tBleStatus)(0x1A)) + +#define BLE_ERROR_INVALID_LMP_LL_PARAMS ((tBleStatus)(0x1E)) + +#define BLE_ERROR_UNSPECIFIED ((tBleStatus)(0x1F)) + +#define BLE_ERROR_UNSUPP_LMP_LL_PARAM_VALUE ((tBleStatus)(0x20)) + +#define BLE_ERROR_LL_RESPONSE_TIMEOUT ((tBleStatus)(0x22)) + +#define BLE_ERROR_LL_PROCEDURE_COLLISION ((tBleStatus)(0x23)) + +#define BLE_ERROR_LMP_PDU_NOT_ALLOWED ((tBleStatus)(0x24)) + +#define BLE_ERROR_ENC_MODE_NOT_ACCEPTABLE ((tBleStatus)(0x25)) + +#define BLE_ERROR_INSTANT_PASSED ((tBleStatus)(0x28)) + +#define BLE_ERROR_DIFFERENT_TRANSACTION_COLLISION ((tBleStatus)(0x2A)) + +#define BLE_ERROR_CHANNEL_ASSESSMENT_NOT_SUPPORTED ((tBleStatus)(0x2E)) + +#define BLE_ERROR_PARAMETER_OUT_OF_RANGE ((tBleStatus)(0x30)) + +#define BLE_ERROR_HOST_BUSY_PAIRING ((tBleStatus)(0x38)) + +#define BLE_ERROR_CONTROLLER_BUSY ((tBleStatus)(0x3A)) + +#define BLE_ERROR_UNACCEPTABLE_CONNECTION_PARAMS ((tBleStatus)(0x3B)) + +#define BLE_ERROR_ADVERTISING_TIMEOUT ((tBleStatus)(0x3C)) + +#define BLE_ERROR_CONNECTION_END_WITH_MIC_FAILURE ((tBleStatus)(0x3D)) + +#define BLE_ERROR_CONNECTION_FAILED_TO_ESTABLISH ((tBleStatus)(0x3E)) + +#define BLE_ERROR_COARSE_CLOCK_ADJ_REJECTED ((tBleStatus)(0x40)) + +#define BLE_ERROR_TYPE0_SUBMAP_NOT_DEFINED ((tBleStatus)(0x41)) + +#define BLE_ERROR_UNKNOWN_ADVERTISING_IDENTIFIER ((tBleStatus)(0x42)) + +#define BLE_ERROR_LIMIT_REACHED ((tBleStatus)(0x43)) + +#define BLE_ERROR_OPERATION_CANCELLED_BY_HOST ((tBleStatus)(0x44)) + +#define BLE_ERROR_PACKET_TOO_LONG ((tBleStatus)(0x45)) + +#define BLE_ERROR_TOO_LATE ((tBleStatus)(0x46)) + +#define BLE_ERROR_TOO_EARLY ((tBleStatus)(0x47)) + + + +/** +* @name Generic/System error codes +* @brief The error codes as reported by the different Protocol layers. +* They start with 0x80 +* @{ +*/ + +/** + * @brief The Connection Identifier does not exist. + * Temporary remapped to corresponding Controller Error. + */ +#define BLE_STATUS_UNKNOWN_CONNECTION_ID ((tBleStatus)(BLE_ERROR_UNKNOWN_CONNECTION_ID)) + +/** + * @brief The Host failed while performing the requested operation. + */ +#define BLE_STATUS_FAILED ((tBleStatus)(0x81)) + +/** + * @brief Invalid parameters passed at Host layer. + */ +#define BLE_STATUS_INVALID_PARAMS ((tBleStatus)(BLE_ERROR_INVALID_HCI_CMD_PARAMS)) + + +/** + * @brief The Host is already processing another request received in advance. + */ +#define BLE_STATUS_BUSY ((tBleStatus)(0x83)) + +/** + * @brief The operation requested cannot be completed immediately by the Host + * (usually because of lack of resources). + * The operation is generally put on hold by the caller and it's usually + * retried on later time. + */ +#define BLE_STATUS_PENDING ((tBleStatus)(0x84)) + +/** + * @brief The requested operation cannot be performed by the Host in the current status. + */ +#define BLE_STATUS_NOT_ALLOWED ((tBleStatus)(BLE_ERROR_COMMAND_DISALLOWED)) + + +/** + * @brief The requested operation violates the logic of the called layer/function or + * the format of the data to be processed during the operation. + */ +#define BLE_STATUS_ERROR ((tBleStatus)(0x86)) + +/** + * @brief The requested operation failed because of lack of memory. + * Out of memory shall be returned for situations where memory will never + * become available again + */ +#define BLE_STATUS_OUT_OF_MEMORY ((tBleStatus)(0x87)) + +/** + * @brief The requested operation failed for a temporary lack of resources + * (e.g. packet pool or timers), but it may be retried later when resources may + * become available (packets or timers may have been released by other consumers). + */ +#define BLE_STATUS_INSUFFICIENT_RESOURCES ((tBleStatus)(0x88)) + +/** + * @brief A NULL pointer was passed as function parameter + */ +#define BLE_STATUS_NULL_PARAM ((tBleStatus)(BLE_ERROR_INVALID_HCI_CMD_PARAMS)) + +/** + * @brief The Host is temporarily waiting for user response, usually required + * through a (vendor specific) event that notifies the required action/response + * that shall be typically provided through a (vendor specific) command. + */ +#define BLE_STATUS_WAITING_FOR_USER_RESPONSE ((tBleStatus)(0x90)) + +/** + * @brief Indicate that the requested Security Level cannot be achieved based + * on available IO Capabilities and Authentication requirements. + */ +#define BLE_STATUS_SECURITY_REQUIREMENTS_NOT_ACHIEVABLE ((tBleStatus)(0x91)) + +/** +*@} +*/ + + +/** + * @name L2CAP error codes, start with 0xA0 +* @brief Error codes returned by the L2CAP, start at 0xA0 + * @{ + */ + +/** + * @brief An invalid L2CAP CID/channel has been selected to send data over. + */ +#define BLE_STATUS_INVALID_CID ((tBleStatus)(0xA0)) + +/** +*@} +*/ + + +/** +* @name Security Manager error codes +* @brief Error codes returned by the Security Manager Protocol (SMP), start at +* 0xB0 +* @{ +*/ + +/** + * @brief The remote device in in the Blacklist and the pairing operation it requested + * cannot be performed. + */ +#define BLE_STATUS_DEV_IN_BLACKLIST ((tBleStatus)(0xB0)) + +/** + * @brief CSRK not found during validation of an incoming signed packet + */ +#define BLE_STATUS_CSRK_NOT_FOUND ((tBleStatus)(0xB1)) + +/** + * @brief Currently not used! + */ +#define BLE_STATUS_IRK_NOT_FOUND ((tBleStatus)(0xB2)) + +/** + * @brief A search for a specific remote device was unsuccessful because no entry exists + * either into Security/GATT Database (flash-based) or in volatile database. + */ +#define BLE_STATUS_DEV_NOT_FOUND ((tBleStatus)(0xB3)) + +/** + * @brief The security database is full and no more records can be added. + */ +#define BLE_STATUS_SEC_DB_FULL ((tBleStatus)(0xB4)) + +/** + * @brief The remote device is not bonded, and no operations related to bonded devices + * may be performed (e.g. writing Gatt Client data). + */ +#define BLE_STATUS_DEV_NOT_BONDED ((tBleStatus)(0xB5)) + +/** + * @brief The encryption key size used for encrypting the link is insufficient\n + */ +#define BLE_INSUFFICIENT_ENC_KEYSIZE ((tBleStatus)(0xB6)) + +/** + * @brief The security database is temporarily unaccessible because the + * underlying physical NVM module is busy with other operations. + */ +#define BLE_STATUS_SEC_DB_BUSY ((tBleStatus)(0xB7)) + +/** +*@} +*/ + + +/** +* @name Gatt layer Error Codes +* @brief Error codes returned by the Gatt layer, start at 0xC0 +* @{ +*/ + +/** + * @brief Notification/Indication can't be sent to the requested remote device because + * it doesn't satisfy the needed security permission. + */ +#define BLE_STATUS_SEC_PERMISSION_ERROR ((tBleStatus)(0xC0)) + +/** +*@} +*/ + + +/** +* @name GAP layer Error Codes +* @brief Error codes returned by the GAP layer. start at 0xD0 +* @{ +*/ + +/** + * @brief The address of the device could not be resolved using the IRK stored + */ +#define BLE_STATUS_ADDRESS_NOT_RESOLVED ((tBleStatus)(0xD0)) + +/** + * @brief The configuration set by the aci_gap_set_scan_configuration command + * is not coherent with the GAP procedure that is requested to be started + */ +#define BLE_STATUS_INVALID_SCAN_CONFIGURATION ((tBleStatus)(0xD1)) + +/** + * @brief The configuration set by the aci_gap_set_connect_configuration command + * is not coherent with the GAP procedure that is requested to be started + */ +#define BLE_STATUS_INVALID_CONNECT_CONFIGURATION ((tBleStatus)(0xD2)) + +/** + * @brief The configuration set by the aci_gap_set_advertising_configuration command + * is not valid + */ +#define BLE_STATUS_INVALID_ADV_CONFIGURATION ((tBleStatus)(0xD3)) + +/** + * @brief The discoverability flags in the advertising data are not coherent + * with the discoverability mode set in the advertising configuration + */ +#define BLE_STATUS_INVALID_ADV_FLAGS ((tBleStatus)(0xD4)) +/** +*@} +*/ + + +/** +* @name flash error codes +* @brief Flash sector read write error codes, start at 0xF0 +* and are currently remapped from 0xFA to 0xFC +* @{ +*/ +#define BLE_STATUS_NVM_READ_FAILED ((tBleStatus)(0xF0)) +#define BLE_STATUS_NVM_WRITE_FAILED ((tBleStatus)(0xF1)) +#define BLE_STATUS_NVM_ERASE_FAILED ((tBleStatus)(0xF2)) + +/** +*@} +*/ + +#define BLE_STATUS_TIMEOUT ((tBleStatus)(0xFF)) + + +#endif diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_types.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_types.h new file mode 100644 index 000000000..1314f8b9c --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_types.h @@ -0,0 +1,272 @@ +/** + ****************************************************************************** + * @file ble_types.h + * @author GPM WBL Application Team + * @brief Header file for Bluetooth Low Energy stack types. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +#ifndef _BLE_TYPES_H_ +#define _BLE_TYPES_H_ + +#include + +/** Documentation for C struct Handle_Packets_Pair_Entry_t */ +typedef PACKED(struct) packed_Handle_Packets_Pair_Entry_t_s { + /** Connection handle + */ + uint16_t Connection_Handle; + /** The number of HCI Data Packets that have been completed (transmitted or flushed) + * for the associated Connection_Handle since the previous time the event was + * returned. + */ + uint16_t HC_Num_Of_Completed_Packets; +} packed_Handle_Packets_Pair_Entry_t; + +/** Documentation for C struct Attribute_Group_Handle_Pair_t */ +typedef PACKED(struct) packed_Attribute_Group_Handle_Pair_t_s { + /** Found Attribute handle + */ + uint16_t Found_Attribute_Handle; + /** Group End handle + */ + uint16_t Group_End_Handle; +} packed_Attribute_Group_Handle_Pair_t; + +/** Documentation for C struct Advertising_Report_t */ +typedef PACKED(struct) packed_Advertising_Report_t_s { + /** Type of advertising report event: ADV_IND: Connectable undirected advertising', + * ADV_DIRECT_IND: Connectable directed advertising, ADV_SCAN_IND: Scannable + * undirected advertising, ADV_NONCONN_IND: Non connectable undirected + * advertising, SCAN_RSP: Scan response. + * Values: + * - 0x00: ADV_IND + * - 0x01: ADV_DIRECT_IND + * - 0x02: ADV_SCAN_IND + * - 0x03: ADV_NONCONN_IND + * - 0x04: SCAN_RSP + */ + uint8_t Event_Type; + /** 0x00 Public Device Address 0x01 Random Device Address 0x02 Public Identity + * Address (Corresponds to Resolved Private Address) 0x03 Random (Static) + * Identity Address (Corresponds to Resolved Private Address) + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address + * - 0x03: Random (Static) Identity Address + */ + uint8_t Address_Type; + /** Public Device Address, Random Device Address, Public Identity Address or Random + * (static) Identity Address of the advertising device. + */ + uint8_t Address[6]; + /** Length of the Data[i] field for each device which responded. + * Values: + * - 0 ... 31 + */ + uint8_t Data_Length; + /** Data_Length octets of advertising or scan response data formatted as defined in + * [Vol 3] Part C, Section 8, plus one byte for RSSI (signed integer, dBm units). + */ + uint8_t Data_RSSI[0]; +} packed_Advertising_Report_t; + +/** Documentation for C struct Direct_Advertising_Report_t */ +typedef PACKED(struct) packed_Direct_Advertising_Report_t_s { + /** Advertising type + * Values: + * - 0x01: Connectable directed advertising (ADV_DIRECT_IND) + */ + uint8_t Event_Type; + /** 0x00 Public Device Address 0x01 Random Device Address 0x02 Public Identity + * Address (Corresponds to Resolved Private Address) 0x03 Random (Static) + * Identity Address (Corresponds to Resolved Private Address) + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address + * - 0x03: Random (Static) Identity Address + */ + uint8_t Address_Type; + /** Public Device Address, Random Device Address, Public Identity Address or Random + * (static) Identity Address of the advertising device. + */ + uint8_t Address[6]; + /** 0x01 Random Device Address + * Values: + * - 0x01: Random Device Address + */ + uint8_t Direct_Address_Type; + /** Random Device Address + */ + uint8_t Direct_Address[6]; + /** N Size: 1 Octet (signed integer) Units: dBm + * Values: + * - -127 ... 20 + * - 127: RSSI not available + */ + int8_t RSSI; +} packed_Direct_Advertising_Report_t; + +/** Documentation for C struct Extended_Advertising_Report_t */ +typedef PACKED(struct) packed_Extended_Advertising_Report_t_s { + /** Event Type parameter. Bits from 0 to 4: 0 Connectable advertising 1 Scannable + * advertising 2 Directed advertising 3 Scan response 4 Legacy advertising + * PDUs used Bits 5-6 Data status: 00b = Complete 01b = Incomplete, more data + * to come 10b = Incomplete, data truncated, no more to come 11b = Reserved + * for future use + * Flags: + * - 0x0001: Connectable advertising + * - 0x0002: Scannable advertising + * - 0x0004: Directed advertising + * - 0x0008: Scan response + * - 0x0010: Legacy advertising PDUs used + */ + uint16_t Event_Type; + /** Address Type + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address (corresponds to Resolved Private Address) + * - 0x03: Random (static) Identity Address (corresponds to Resolved Private +Address) + * - 0xFF: No address provided (anonymous advertisement) + */ + uint8_t Address_Type; + /** Public Device Address, Random Device Address, Public Identity Address or Random + * (static) Identity Address of the advertising device. + */ + uint8_t Address[6]; + /** PHY used to send the advertising PDU on the primary advertising physical + * channel. + * Values: + * - 0x01: LE_1M_PHY + * - 0x03: LE_CODED_PHY + */ + uint8_t Primary_PHY; + /** This parameter indicates the PHY used to send the advertising PDU(s), if any, on + * the secondary advertising physical channel. + * Values: + * - 0x00: No packets + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + */ + uint8_t Secondary_PHY; + /** Advertising SID subfield in the ADI field of the PDU + * Values: + * - 0x00 ... 0x0F + * - 0xFF: NA + */ + uint8_t Advertising_SID; + /** Tx Power. Units: dBm. + * Values: + * - -127 ... 126 + * - 127: NA + */ + int8_t TX_Power; + /** RSSI value; Units: dBm; All other values Reserved for future use. + * Values: + * - -127 ... 20 + * - 127: NA + */ + int8_t RSSI; + /** Interval of the periodic advertising. Time = N * 1.25 ms; Time Range: 7.5 ms to + * 81,918.75 s. + * Values: + * - 0x0000 (NaN) : NA + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + */ + uint16_t Periodic_Advertising_Interval; + /** Direct address type + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address (Corresponds to Resolved PrivateAddress) + * - 0x03: Random (static) Identity Address (Corresponds to Resolved PrivateAddress) + * - 0x04 ... 0xFD: Reserved for future use + * - 0xFE: Random Device Address (Controller unable to resolve) + * - 0xFF: Reserved for future use + */ + uint8_t Direct_Address_Type; + /** Public Device Address, Random Device Address, Public Identity Address or Random + * (static) Identity Address of the target device + */ + uint8_t Direct_Address[6]; + /** Length of the Data[i] field for each device which responded + * Values: + * - 0 ... 229 + */ + uint8_t Data_Length; + /** Data_Length[i] octets of advertising or scan response data formatted as defined + * in [Vol 3] Part C, Section 11. Note: Each element of this array has a + * variable length. + */ + uint8_t Data[0]; +} packed_Extended_Advertising_Report_t; + +/** Documentation for C struct Samples_t */ +typedef PACKED(struct) packed_Samples_t_s { + /** The list of I samples for the reported packet. Each sample is a signed integer. + * The list is in the order of the sampling points within the packet. + */ + int8_t I_Sample; + /** The list of Q samples for the reported packet. Each sample is a signed integer. + * The list is in the order of the sampling points within the packet. + */ + int8_t Q_Sample; +} packed_Samples_t; + +/** Documentation for C struct Periodic_Advertising_Response_t */ +typedef PACKED(struct) packed_Periodic_Advertising_Response_t_s { + /** Range: -127 to +20 (units: dBm). If 0x7F, Tx Power information is not available. + * Values: + * - -127 ... 20 + * - 127: NA + */ + int8_t TX_Power; + /** Range: -127 to +20 (units: dBm) If 0x7F, RSSI is not available. + * Values: + * - -127 ... 20 + * - 127: NA + */ + int8_t RSSI; + /** CTE type in the response. + * Values: + * - 0x00: AoA + * - 0x01: AoD_1us + * - 0x02: AoD_2us + * - 0xFF: NO_CTE + */ + uint8_t CTE_Type; + /** The response slot the data was received in. + */ + uint8_t Response_Slot; + /** 0x00: Data complete 0x01: Data incomplete, more data to come 0xFF: Failed to + * receive an AUX_SYNC_SUBEVENT_RSP PDU + * Values: + * - 0x00: DATA_COMPLETE + * - 0x01: MORE_DATA + * - 0xFF: RX_FAILED + */ + uint8_t Data_Status; + /** Length of the Data field. + */ + uint8_t Data_Length; + /** Periodic advertising response data formatted as defined in [Vol 3] Part C, + * Section 11. Note: Each element of this array has a variable length. + */ + uint8_t Data[0]; +} packed_Periodic_Advertising_Response_t; + +#endif /* _BLE_TYPES_H_ */ diff --git a/lib/stm32wb0/STM32_BLE/stack/include/bleplat.h b/lib/stm32wb0/STM32_BLE/stack/include/bleplat.h new file mode 100644 index 000000000..058d111db --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/bleplat.h @@ -0,0 +1,308 @@ +/** + ****************************************************************************** + * @file bleplat.h + * @author GPM WBL Application team + * @brief This file contains the interface of the Bluetooth LE platform layer + * (lower interface of the Bluetooth LE stack library). + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef BLEPLAT_H__ +#define BLEPLAT_H__ + +#include +#include "bleplat_cntr.h" + +#define RSSI_INVALID 127 + +/* Enumerated values used for the return of the functions: */ + +typedef enum +{ + BLEPLAT_OK = 0, + BLEPLAT_FULL = -1, + BLEPLAT_BUSY = -2, + BLEPLAT_EOF = -3 +} BLEPLAT_NvmStatusTypeDef; + + +/* Enumerated values used for the 'type' of NVM functions: */ + +typedef enum +{ + BLEPLAT_NVM_REC_SEC = 0, + BLEPLAT_NVM_REC_GATT = 1, + BLEPLAT_NVM_REC_DEVICE_ID = 2, +} BLEPLAT_NvmRecordTypeDef; + + +/* Enumerated values used for the 'mode' of NVM functions: */ + +typedef enum +{ + BLEPLAT_NVM_FIRST = 0, + BLEPLAT_NVM_NEXT = 1, + BLEPLAT_NVM_CURRENT = 2, + BLEPLAT_NVM_ALL = 3 +} BLEPLAT_NvmSeekModeTypeDef; + +typedef enum +{ + BLEPLAT_PKA_SUCCESS = 0, + BLEPLAT_PKA_ERROR = -1, + BLEPLAT_PKA_ERR_BUSY = -2, + BLEPLAT_PKA_ERR_PARAM = -3, + BLEPLAT_PKA_ERR_PROCESS = -4 +} BLEPLAT_PkaStatusTypeDef; + +typedef void (*BLEPLAT_PkaFuncCb)(BLEPLAT_PkaStatusTypeDef errorCode, void *args); + +typedef enum { + BLEPLAT_AES_FLAGS_DEFAULT = (uint32_t) (0x00000000), /*!< User Flag: No flag specified. This is the default value that should be set to this flag */ + BLEPLAT_AES_FLAGS_DONT_PERFORM_KEY_SCHEDULE = (uint32_t) (0x00000001), /*!< User Flag: Used to force the init to not reperform key schedule.\n + The classic example is where the same key is used on a new message, in this case to redo key scheduling is + a useless waste of computation, could be particularly useful on GCM, where key schedule is very complicated. */ + BLEPLAT_AES_FLAGS_FINAL_APPEND = (uint32_t) (0x00000020), /*!< User Flag: Must be set in CMAC mode before the final Append call occurs. */ + BLEPLAT_AES_FLAGS_OPERATION_COMPLETED = (uint32_t) (0x00000002), /*!< Internal Flag (not to be set/read by user): used to check that the Finish function has been already called */ + BLEPLAT_AES_FLAGS_NO_MORE_APPEND_ALLOWED = (uint32_t) (0x00000004), /*!< Internal Flag (not to be set/read by user): it is set when the last append has been called. Used where the append is called with an InputSize not + multiple of the block size, which means that is the last input.*/ + BLEPLAT_AES_FLAGS_NO_MORE_HEADER_APPEND_ALLOWED = (uint32_t) (0x00000010), /*!< Internal Flag (not to be set/read by user): only for authenticated encryption modes. \n + It is set when the last header append has been called. Used where the header append is called with an InputSize not + multiple of the block size, which means that is the last input.*/ + BLEPLAT_AES_FLAGS_APPEND_DONE = (uint32_t) (0x00000040), /*!< Internal Flag (not to be set/read by user): only for CMAC.It is set when the first append has been called */ + BLEPLAT_AES_FLAGS_SET_COUNTER = (uint32_t)(0x00000080), /*!< User Flag: With ChaCha20 this is used to indicate a value for the counter, used to process non contiguous blocks (i.e. jump ahead)*/ + +} AESflagsTypeDef; /*!< Type definitation for Symmetric Key Flags */ + +#define BLEPLAT_AES_MAX_EXPKEY_SIZE 44 /*!< The max size of the AES expanded key (in uint32_t) */ +#define BLEPLAT_AES128_KEY_SIZE 16 /*!< Number of bytes (uint8_t) necessary to store an AES key of 128 bits. */ + + +typedef struct +{ + uint32_t mContextId; /*!< Unique ID of this context. \b Not \b used in current implementation. */ + AESflagsTypeDef mFlags; /*!< 32 bit mFlags, used to perform keyschedule and future use */ + const uint8_t *pmKey; /*!< Pointer to original Key buffer */ + const uint8_t *pmIv; /*!< Pointer to original Initialization Vector buffer */ + int32_t mIvSize; /*!< Size of the Initialization Vector in bytes */ + uint32_t amIv[4]; /*!< Temporary result/IV */ + int32_t mKeySize; /*!< Key length in bytes */ + uint32_t amExpKey[BLEPLAT_AES_MAX_EXPKEY_SIZE]; /*!< Expanded AES key */ + const uint8_t *pmTag; /*!< Pointer to Authentication TAG. This value must be set in decryption, and this TAG will be verified */ + int32_t mTagSize; /*!< Size of the Tag to return. This must be set by the caller prior to calling Init */ +} BLEPLAT_AESCMACctxTypeDef; /* + +/** @addtogroup BLEPLAT_CNTR_Peripheral BLE CONTROLLER + * @{ + */ + +/** @defgroup BLEPLAT_CNTR_Exported_Types Exported Types + * @{ + */ + + +/* Enumerated values used to report the RNG result status after a process */ +typedef enum +{ + BLEPLAT_CNTR_SUCCESS = 0, + BLEPLAT_CNTR_ERROR, + BLEPLAT_CNTR_ERROR_TIMEOUT +} BLEPLAT_CNTR_ResultStatus; + + +typedef struct { + volatile uint32_t WORD0; + volatile uint32_t WORD1; + volatile uint32_t WORD2; + volatile uint32_t WORD3; + volatile uint32_t WORD4; +} BLEPLAT_CNTR_TXRXPACK_TypeDef; + +typedef enum +{ + BLEPLAT_CNTR_TxRx = 0, + BLEPLAT_CNTR_RxTx, + BLEPLAT_CNTR_TxTx, + BLEPLAT_CNTR_RxRx +} BLEPLAT_CNTR_Transaction; +/** + * @} + */ + +/** @defgroup BLEPLAT_CNTR_Exported_Constants Exported Constants + * @{ + */ + +/** + * @} + */ + +/** @defgroup BLEPLAT_CNTR_Exported_Macros Exported Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup BLEPLAT_CNTR_Exported_Functions Exported Functions + * @{ + */ +BLEPLAT_CNTR_ResultStatus BLEPLAT_CNTR_Init(void); + +BLEPLAT_CNTR_ResultStatus BLEPLAT_CNTR_Deinit(void); + +void BLEPLAT_CNTR_ClearInterrupt(uint32_t x); +void BLEPLAT_CNTR_ClearSemareq(void); +void BLEPLAT_CNTR_TxRxSkip(void); +uint32_t* BLEPLAT_CNTR_GetCipherTextPtr(void); +uint32_t* BLEPLAT_CNTR_GetClrTextPtr(void); +uint32_t* BLEPLAT_CNTR_GetEncKeyPtr(void); +uint8_t BLEPLAT_CNTR_GetEncryptDoneStatus(void); +uint8_t BLEPLAT_CNTR_GetIqsamplesMissingError(void); +uint8_t BLEPLAT_CNTR_GetIqsamplesNumber(void); +uint8_t BLEPLAT_CNTR_getIqsamplesReady(void); +uint8_t BLEPLAT_CNTR_GetIsrLatency(void); +uint32_t BLEPLAT_CNTR_GetTimercapture(void); +void BLEPLAT_CNTR_GlobDisableBlue(void); +void BLEPLAT_CNTR_GlobEnableBlue(void); +void BLEPLAT_CNTR_GlobEnableIntnoactivelerrorInt(void); +void BLEPLAT_CNTR_GlobEnableTxRxSkipInt(void); +void BLEPLAT_CNTR_GlobEnableOverrunAct2Int(void); +uint8_t BLEPLAT_CNTR_GlobGetDefaultAntennaid(void); +uint8_t BLEPLAT_CNTR_GlobGetWakeupinitdelay(void); +void BLEPLAT_CNTR_GlobReloadRadioConfigP(void); +void BLEPLAT_CNTR_GlobSetChkflagautoclearena(void); +void BLEPLAT_CNTR_GlobSetDefaultAntennaid(uint8_t x); +void BLEPLAT_CNTR_GlobSetInitRadioDelayTxCal(uint8_t x); +void BLEPLAT_CNTR_GlobSetInitRadioDelayTxNocal(uint8_t x); +void BLEPLAT_CNTR_GlobSetRadioConfigP(volatile uint32_t* x); +void BLEPLAT_CNTR_GlobSetWakeupinitdelay(uint8_t x); +void BLEPLAT_CNTR_GlobWriteConfigEnd(uint8_t x); +void BLEPLAT_CNTR_GlobWritePeriodslow(uint16_t x); +void BLEPLAT_CNTR_GlobWriteRcvdelay(uint8_t x); +void BLEPLAT_CNTR_GlobWriteRcvdelay1(uint8_t x); +void BLEPLAT_CNTR_GlobWriteSlot(uint8_t slotNo); +void BLEPLAT_CNTR_GlobWriteTimer12initdelaycal(uint8_t x); +void BLEPLAT_CNTR_GlobWriteTimer2initdelaynocal(uint8_t x); +void BLEPLAT_CNTR_GlobWriteTxDataReadyCheck(uint8_t x); +void BLEPLAT_CNTR_GlobWriteTxReadyTimeout(uint8_t x); +void BLEPLAT_CNTR_GlobWriteTxdelay(uint8_t x) ; +void BLEPLAT_CNTR_GlobWriteTxdelayEnd(uint8_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusAnyHwError(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusRxOverflowError(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusBitAct2Error(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusBitTimerOverrun(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusCrcErr(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusDone(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusEncErr(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusLenErr(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusNoactiveError(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusRxOk(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusTimeout(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusTrigRcv(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxDone(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxOk(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxRxSkip(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxError1(uint32_t x); +uint32_t BLEPLAT_CNTR_IntGetIntStatusTxError3(uint32_t x); +void BLEPLAT_CNTR_PacketClrCrcinitSel(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketClrCteSamplingEn(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketClrIncChan(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketClrPllTrig(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketDisableWhitening(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +uint8_t BLEPLAT_CNTR_PacketGetCteSamplingEn(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +uint8_t* BLEPLAT_CNTR_PacketGetDataPtr(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketInitTo0(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetAdvPduFormat(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetCrcinitSel(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetCteSamplingEn(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetDataPduFormat(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetDataPtr(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, void* dataP); +void BLEPLAT_CNTR_PacketSetIncChan(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetIntCrcErr(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetIntDone(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetIntRcvOk(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetIntTimeout(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetIntTrigRcv(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetIntTxOk(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetKeepsemareq(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetNextPtr(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, BLEPLAT_CNTR_TXRXPACK_TypeDef* packetNextP); +void BLEPLAT_CNTR_PacketSetNextRxMode(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetNextSlot(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, uint8_t slot); +void BLEPLAT_CNTR_PacketSetNextTxMode(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetNsEn(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetPllTrig(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetRxReady(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetTimeout(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, uint32_t x); +void BLEPLAT_CNTR_PacketSetTimer2Active(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetTimerTrigDone(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetTimerTrigRcv(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_PacketSetTxReady(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_SetRadioConfig(uint8_t* value); +void BLEPLAT_CNTR_SetRcvLen(BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP, uint32_t rcvLen); +void BLEPLAT_CNTR_SmCteOff(uint8_t smNo); +void BLEPLAT_CNTR_SmCteOn(uint8_t smNo); +void BLEPLAT_CNTR_SmEnRadioConfig(uint8_t smNo, uint32_t enable); +void BLEPLAT_CNTR_SmEncOff(uint8_t smNo); +void BLEPLAT_CNTR_SmEncOn(uint8_t smNo); +uint32_t BLEPLAT_CNTR_SmGetAccessAddr(uint8_t smNo); +void BLEPLAT_CNTR_SmGetChannelMap(uint8_t smNo, uint8_t* chanMap); +uint8_t BLEPLAT_CNTR_SmGetCteAntennaPatternLen(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetCteAodNaoa(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetCteSlotWidth(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetCteStatus(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetCteTime(uint8_t smNo); +uint32_t* BLEPLAT_CNTR_SmGetEncIvPtr(uint8_t smNo); +uint32_t* BLEPLAT_CNTR_SmGetEncKeyPtr(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetEncStatus(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetHopIncr(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetMode(uint8_t smNo); +uint8_t* BLEPLAT_CNTR_SmGetPrevRxPacketDataPtr(uint8_t smNo); +BLEPLAT_CNTR_TXRXPACK_TypeDef* BLEPLAT_CNTR_SmGetPrevRxPacketPtr(uint8_t smNo) ; +uint8_t* BLEPLAT_CNTR_SmGetPrevTxPacketDataPtr(uint8_t smNo); +BLEPLAT_CNTR_TXRXPACK_TypeDef* BLEPLAT_CNTR_SmGetPrevTxPacketPtr(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetRemapChan(uint8_t smNo); +void BLEPLAT_CNTR_SmGetRxCount(uint8_t smNo, uint32_t* packetCount); +uint8_t BLEPLAT_CNTR_SmGetRxPhy(uint8_t smNo); +BLEPLAT_CNTR_TXRXPACK_TypeDef* BLEPLAT_CNTR_SmGetTxPacketPtr(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetTxPhy(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetTxPwr(uint8_t smNo); +uint8_t BLEPLAT_CNTR_SmGetUnmappedChan(uint8_t smNo); +void BLEPLAT_CNTR_SmInitTo0(uint8_t smNo); +void BLEPLAT_CNTR_SmSetAccessAddr(uint8_t smNo, uint32_t x); +void BLEPLAT_CNTR_SmSetChannelMap(uint8_t smNo, uint8_t* chanMap); +void BLEPLAT_CNTR_SmSetCrcInit(uint8_t smNo, uint32_t x); +void BLEPLAT_CNTR_SmSetCteAntennaPatternLen(uint8_t smNo, uint8_t antPattLen); +void BLEPLAT_CNTR_SmSetCteAntennaPatternPtr(uint8_t smNo, uint8_t* antPattP); +uint32_t BLEPLAT_CNTR_SmGetCteAntennaPatternPtr(uint8_t smNo); +void BLEPLAT_CNTR_SmSetCteAoa(uint8_t smNo); +void BLEPLAT_CNTR_SmSetCteAod(uint8_t smNo); +void BLEPLAT_CNTR_SmSetCteIqsamplesPtr(uint8_t smNo, uint32_t* iqSamplesP); +void BLEPLAT_CNTR_SmSetCteMaxIqsamplesNumb(uint8_t smNo, uint8_t iqsamplesNumb); +void BLEPLAT_CNTR_SmSetCteSlotWidth(uint8_t smNo, uint32_t cteSlot); +void BLEPLAT_CNTR_SmSetCteTime(uint8_t smNo, uint8_t cteTime); +void BLEPLAT_CNTR_SmSetDataLength(uint8_t smNo, uint8_t length); +void BLEPLAT_CNTR_SmSetDataLengthExtnEn(uint8_t smNo); +void BLEPLAT_CNTR_SmSetHopIncr(uint8_t smNo, uint8_t x); +void BLEPLAT_CNTR_SmSetRemapChan(uint8_t smNo, uint8_t chan); +void BLEPLAT_CNTR_SmSetRxCount(uint8_t smNo, uint32_t* packetCount); +void BLEPLAT_CNTR_SmSetRxCountDirectionBit(uint8_t smNo); +void BLEPLAT_CNTR_SmSetRxMode(uint8_t smNo); +void BLEPLAT_CNTR_SmSetRxPacketPtr(uint8_t smNo, BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_SmSetRxPhy(uint8_t smNo, uint8_t rxPhy); +void BLEPLAT_CNTR_SmSetTxCount(uint8_t smNo, uint32_t* packetCount); +void BLEPLAT_CNTR_SmSetTxCountDirectionBit(uint8_t smNo); +void BLEPLAT_CNTR_SmSetTxMode(uint8_t smNo); +void BLEPLAT_CNTR_SmSetTxPacketPtr(uint8_t smNo, BLEPLAT_CNTR_TXRXPACK_TypeDef* packetP); +void BLEPLAT_CNTR_SmSetTxPhy(uint8_t smNo, uint8_t txPhy); +void BLEPLAT_CNTR_SmEnTxHp(uint8_t smNo, uint8_t enable); +void BLEPLAT_CNTR_SmSetTxPwr(uint8_t smNo, uint8_t paLevel); +void BLEPLAT_CNTR_SmSetUnmappedChan(uint8_t smNo, uint8_t chan); +void BLEPLAT_CNTR_SmToggleNesn(uint8_t smNo); +void BLEPLAT_CNTR_SmToggleSn(uint8_t smNo); +void BLEPLAT_CNTR_StartEncrypt(void); +uint32_t BLEPLAT_CNTR_TimeDiff(uint32_t x, uint32_t y); +uint8_t BLEPLAT_CNTR_DemodDelaySt(uint8_t RxPHY); +uint32_t BLEPLAT_CNTR_GetTimer2TimeoutForIfs(uint32_t T_Ifs, BLEPLAT_CNTR_Transaction Transaction, uint8_t Cal_Enabled); + + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + + +#endif /* ! BLEPLAT_H__ */ diff --git a/lib/stm32wb0/STM32_BLE/stack/include/uuid.h b/lib/stm32wb0/STM32_BLE/stack/include/uuid.h new file mode 100644 index 000000000..c7b8d0f4a --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stack/include/uuid.h @@ -0,0 +1,345 @@ +/** + ****************************************************************************** + * @file uuid.h + * @author GPM WBL Application Team + * @brief Header containing the UUIDs of all the services and characteristics + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef _UUID_H_ +#define _UUID_H_ + +/* Descriptor UUIDs */ +#define CHAR_EXTENDED_PROPERTIES_DESCRIPTOR_UUID (0x2900) +#define CHAR_USER_DESCRIPTION_DESCRIPTOR_UUID (0x2901) +#define CLIENT_CHAR_CONFIG_DESCRIPTOR_UUID (0x2902) +#define SERVER_CHAR_CONFIG_DESCRIPTOR_UUID (0x2903) +#define CHAR_PRESENTATION_FORMAT_DESCRIPTOR_UUID (0x2904) +#define CHAR_AGGREGATE_FORMAT_DESCRIPTOR_UUID (0x2905) +#define VALID_RANGE_DESCRIPTOR_UUID (0x2906) +#define EXTERNAL_REPORT_REFERENCE_DESCRIPTOR_UUID (0x2907) +#define REPORT_REFERENCE_DESCRIPTOR_UUID (0x2908) +#define NUMBER_OF_DIGITALS_DESCRIPTOR_UUID (0x2909) +#define VALUE_TRIGGER_SETTING_DESCRIPTOR_UUID (0x290A) +#define ES_CONFIGURATION_DESCRIPTOR_UUID (0x290B) +#define ES_MEASUREMENT_DESCRIPTOR_UUID (0x290C) +#define ES_TRIGGER_SETTING_DESCRIPTOR_UUID (0x290D) +#define TIME_TRIGGER_SETTING_DESCRIPTOR_UUID (0x290E) + +/* UUIDs of Generic Attribute service */ +#define GATT_SERVICE_UUID (0x1801U) +#define PRIMARY_SERVICE_UUID (0x2800U) +#define SECONDARY_SERVICE_UUID (0x2801U) +#define INCLUDE_SERVICE_UUID (0x2802U) +#define CHARACTERISTIC_UUID (0x2803U) +#define CHAR_EXTENDED_PROP_DESC_UUID (0x2900U) +#define CHAR_USER_DESC_UUID (0x2901U) +#define CHAR_CLIENT_CONFIG_DESC_UUID (0x2902U) +#define CHAR_SERVER_CONFIG_DESC_UUID (0x2903U) +#define CHAR_FORMAT_DESC_UUID (0x2904U) +#define CHAR_AGGR_FMT_DESC_UUID (0x2905U) +#define SERVICE_CHANGED_UUID (0x2A05U) +#define CLIENT_SUPPORTED_FEATURES_UUID (0x2B29U) +#define DATABASE_HASH_UUID (0x2B2AU) +#define SERVER_SUPPORTED_FEATURES_UUID (0x2B3AU) + +/* UUIDs of Generic Access Profile */ +#define GAP_SERVICE_UUID (0x1800U) +#define DEVICE_NAME_UUID (0x2A00U) +#define APPEARANCE_UUID (0x2A01U) +#define PERIPHERAL_PRIVACY_FLAG_UUID (0x2A02U) +#define RECONNECTION_ADDR_UUID (0x2A03U) +#define PERIPHERAL_PREFERRED_CONN_PARAMS_UUID (0x2A04U) +#define CENTRAL_ADDRESS_RESOLUTION_UUID (0x2AA6U) +#define RESOLVABLE_PRIVATE_ADDRESS_ONLY_UUID (0x2AC9U) + +/* UUIDs of immediate alert service */ +#define IMMEDIATE_ALERT_SERVICE_UUID (0x1802) +#define ALERT_LEVEL_CHARACTERISTIC_UUID (0x2A06) + +/* UUIDs for Link Loss service */ +#define LINK_LOSS_SERVICE_UUID (0x1803) +#define LINK_LOSS_ALERT_LEVEL_CHARACTERISTIC_UUID (0x2A06) + +/* UUIDs for TX Power service */ +#define TX_POWER_SERVICE_UUID (0x1804) +#define TX_POWER_LEVEL_CHARACTERISTIC_UUID (0x2A07) + +/* UUIDs for Time service */ +#define CURRENT_TIME_SERVICE_UUID (0x1805) +#define CURRENT_TIME_CHAR_UUID (0x2A2B) +#define LOCAL_TIME_INFORMATION_CHAR_UUID (0x2A0F) +#define REFERENCE_TIME_INFORMATION_CHAR_UUID (0x2A14) + +/* UUIDs for Reference Time Update service */ +#define REFERENCE_UPDATE_TIME_SERVICE_UUID (0x1806) +#define TIME_UPDATE_CONTROL_POINT_CHAR_UUID (0x2A16) +#define TIME_UPDATE_STATE_CHAR_UUID (0x2A17) + +/* UUIDs for Next DST Change service */ +#define NEXT_DST_CHANGE_SERVICE_UUID (0x1807) +#define TIME_WITH_DST_CHAR_UUID (0x2A11) + +/* UUIDs for glucose profile */ +#define GLUCOSE_SERVICE_UUID (0x1808) +#define GLUCOSE_MEASUREMENT_CHAR_UUID (0x2A18) +#define GLUCOSE_MEASUREMENT_CONTEXT_CHAR_UUID (0x2A34) +#define GLUCOSE_FEATURE_CHAR_UUID (0x2A51) +/* Record Access Control Point (RACP) */ +#define GLUCOSE_RACP_CHAR_UUID (0x2A52) + +/* UUIDs for health thermometer profile */ +#define HEALTH_THERMOMETER_SERVICE_UUID (0x1809) +#define TEMPERATURE_MEASUREMENT_CHAR_UUID (0x2A1C) +#define TEMPERATURE_TYPE_CHAR_UUID (0x2A1D) +#define INTERMEDIATE_TEMPERATURE_CHAR_UUID (0x2A1E) +#define MEASUREMENT_INTERVAL_CHAR_UUID (0x2A21) + +/* UUIDs for Device Information Service */ +#define DEVICE_INFORMATION_SERVICE_UUID (0x180A) +#define SYSTEM_ID_UUID (0x2A23) +#define MODEL_NUMBER_UUID (0x2A24) +#define SERIAL_NUMBER_UUID (0x2A25) +#define FIRMWARE_REVISION_UUID (0x2A26) +#define HARDWARE_REVISION_UUID (0x2A27) +#define SOFTWARE_REVISION_UUID (0x2A28) +#define MANUFACTURER_NAME_UUID (0x2A29) +#define IEEE_CERTIFICATION_UUID (0x2A2A) +#define PNP_ID_UUID (0x2A50) + +/* UUIDs for Heart Rate Service */ +#define HEART_RATE_SERVICE_UUID (0x180D) +#define CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID (0x2902) +#define HEART_RATE_MEASURMENT_UUID (0x2A37) +#define SENSOR_LOCATION_UUID (0x2A38) +#define CONTROL_POINT_UUID (0x2A39) + +/* UUIDs for Phone Alert status profile */ +#define PHONE_ALERT_SERVICE_UUID (0x180E) +#define PHONE_ALERT_STATUS_CHARAC_UUID (0x2A3F) +#define RINGER_CNTRL_POINT_CHARAC_UUID (0x2A40) +#define RINGER_SETTING_CHARAC_UUID (0x2A41) + +/* UUIDs for battery service */ +#define BATTERY_SERVICE_UUID (0x180F) +#define BATTERY_LEVEL_CHAR_UUID (0x2A19) + +/* UUIDs for Blood Pressure profile */ +#define BLOOD_PRESSURE_SERVICE_UUID (0x1810) +#define BLOOD_PRESSURE_MEASUREMENT_CHAR_UUID (0x2A35) +#define INTERMEDIATE_CUFF_PRESSURE_CHAR_UUID (0x2A36) +#define BLOOD_PRESSURE_FEATURE_CHAR_UUID (0x2A49) + +/* UUIDs for alert notification profile */ +#define ALERT_NOTIFICATION_SERVICE_UUID (0x1811) +#define SUPPORTED_NEW_ALERT_CATEGORY_CHAR_UUID (0x2A47) +#define NEW_ALERT_CHAR_UUID (0x2A46) +#define SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR_UUID (0x2A48) +#define UNREAD_ALERT_STATUS_CHAR_UUID (0x2A45) +#define ALERT_NOTIFICATION_CONTROL_POINT_CHAR_UUID (0x2A44) + +/* UUIDs for human interface device */ +#define HUMAN_INTERFACE_DEVICE_SERVICE_UUID (0x1812) +#define PROTOCOL_MODE_CHAR_UUID (0x2A4E) +#define REPORT_CHAR_UUID (0x2A4D) +#define REPORT_MAP_CHAR_UUID (0x2A4B) +#define BOOT_KEYBOARD_INPUT_REPORT_CHAR_UUID (0x2A22) +#define BOOT_KEYBOARD_OUTPUT_REPORT_CHAR_UUID (0x2A32) +#define BOOT_MOUSE_INPUT_REPORT_CHAR_UUID (0x2A33) +#define HID_INFORMATION_CHAR_UUID (0x2A4A) +#define HID_CONTROL_POINT_CHAR_UUID (0x2A4C) + +/* UUIDs for scan parameter service */ +#define SCAN_PARAMETER_SERVICE_UUID (0x1813) +#define SCAN_INTERVAL_WINDOW_CHAR_UUID (0x2A4F) +#define SCAN_REFRESH_CHAR_UUID (0x2A31) + +/* UUIDs for running speed and cadence service */ +#define RUNNING_SPEED_CADENCE_SERVICE_UUID (0x1814) +#define RUNNING_SPEED_CADENCE_MEASUREMENT_CHAR_UUID (0x2A53) +#define RUNNING_SPEED_CADENCE_FEATURE_CHAR_UUID (0x2A54) + +/* UUIDs for automation IO service */ +#define AUTOMATION_IO_SERVICE_UUID (0x1815) +#define AUTOMATION_IO_DIGITAL_CHAR_UUID (0x2A56) +#define AUTOMATION_IO_ANALOG_CHAR_UUID (0x2A58) +#define AUTOMATION_IO_AGGREGATE_CHAR_UUID (0x2A5A) + +/* UUIDs for cycling speed and cadence service */ +#define CYCLING_SPEED_CADENCE_SERVICE_UUID (0x1816) +#define CYCLING_SPEED_CADENCE_MEASUREMENT_CHAR_UUID (0x2A5B) +#define CYCLING_SPEED_CADENCE_FEATURE_CHAR_UUID (0x2A5C) + +/* UUIDs for cycling power service */ +#define CYCLING_POWER_SERVICE_UUID (0x1818) +#define CYCLING_POWER_MEASUREMENT_CHAR_UUID (0x2A63) +#define CYCLING_POWER_FEATURE_CHAR_UUID (0x2A65) +#define CYCLING_POWER_SENSOR_LOCATION_CHAR_UUID (0x2A5D) + +/* UUIDs for location and navigation device */ +#define LOCATION_NAVIGATION_SERVICE_UUID (0x1819) +#define LN_FEATURE_UUID (0x2A6A) +#define LOCATION_SPEED_UUID (0x2A67) +#define POSITION_QUALITY_UUID (0x2A69) +#define LN_CONTROL_POINT_UUID (0x2A6B) +#define NAVIGATION_UUID (0x2A68) + +/* UUIDs for environmental sensing profile */ +#define ENVIRONMENTAL_SENSING_SERVICE_UUID (0x181A) +#define DESCRIPTOR_VALUE_CHANGED_UUID (0x2A7D) +#define APPARENT_WIND_DIRECTION_UUID (0x2A73) +#define APPARENT_WIND_SPEED_UUID (0x2A72) +#define DEW_POINT_UUID (0x2A7B) +#define ELEVATION_UUID (0x2A6C) +#define GUST_FACTOR_UUID (0x2A74) +#define HEAT_INDEX_UUID (0x2A7A) +#define HUMIDITY_UUID (0x2A6F) +#define IRRADIANCE_UUID (0x2A77) +#define POLLEN_CONCENTRATION_UUID (0x2A75) +#define RAINFALL_UUID (0x2A78) +#define PRESSURE_UUID (0x2A6D) +#define TEMPERATURE_UUID (0x2A6E) +#define TRUE_WIND_DIRECTION_UUID (0x2A71) +#define TRUE_WIND_SPEED_UUID (0x2A70) +#define UV_INDEX_UUID (0x2A76) +#define WIND_CHILL_UUID (0x2A79) +#define BAROMETRIC_PRESSURE_TREND_UUID (0x2AA3) +#define MAGNETIC_DECLINATION_UUID (0x2A2C) +#define MAGNETIC_FLUX_DENSITY_2D_UUID (0x2AA0) +#define MAGNETIC_FLUX_DENSITY_3D_UUID (0x2AA1) + +/* UUIDs for body composition service */ +#define BODY_COMPOSITION_SERVICE_UUID (0x181B) +#define BODY_COMPOSITION_MEASUREMENT_CHAR_UUID (0x2A9C) +#define BODY_COMPOSITION_FEATURE_CHARAC (0x2A9B) + +/* UUIDs for user data service */ +#define USER_DATA_SERVICE_UUID (0x181C) +#define AERO_HR_LOWER_LIMIT_CHAR_UUID (0x2A7E) +#define AEROBIC_THRESHOLD_CHAR_UUID (0x2A7F) +#define AGE_CHAR_UUID (0x2A80) +#define ANAERO_HR_LOWER_LIMIT_CHAR_UUID (0x2A81) +#define ANAERO_HR_UPPER_LIMIT_CHAR_UUID (0x2A82) +#define ANAEROBIC_THRESHOLD_CHAR_UUID (0x2A83) +#define AERO_HR_UPPER_LIMIT_CHAR_UUID (0x2A84) +#define BIRTH_DATE_CHAR_UUID (0x2A85) +#define DATE_THRESHOLD_ASSESSMENT_CHAR_UUID (0x2A86) +#define EMAIL_ADDRESS_CHAR_UUID (0x2A87) +#define FAT_BURN_HR_LOWER_LIMIT_CHAR_UUID (0x2A88) +#define FAT_BURN_HR_UPPER_LIMIT_CHAR_UUID (0x2A89) +#define FIRST_NAME_CHAR_UUID (0x2A8A) +#define FIVE_ZONE_HR_LIMIT_CHAR_UUID (0x2A8B) +#define GENDER_CHAR_UUID (0x2A8C) +#define HEART_RATE_MAX_CHAR_UUID (0x2A8D) +#define HEIGHT_CHAR_UUID (0x2A8E) +#define HIP_CIRC_CHAR_UUID (0x2A8F) +#define LAST_NAME_CHAR_UUID (0x2A90) +#define MAX_RECO_HEART_RATE_CHAR_UUID (0x2A91) +#define RESTING_HEART_RATE_CHAR_UUID (0x2A92) +#define SPORT_TYPE_CHAR_UUID (0x2A93) +#define THREE_ZONE_HR_LIMIT_CHAR_UUID (0x2A94) +#define TWO_ZONE_HR_LIMIT_CHAR_UUID (0x2A95) +#define VO2_MAX_CHAR_UUID (0x2A96) +#define WAIST_CIRC_CHAR_UUID (0x2A97) +#define WEIGHT_CHAR_UUID (0x2A98) +#define DATABASE_CHANGE_INCREMENT_CHAR_UUID (0x2A99) +#define USER_INDEX_CHAR_UUID (0x2A9A) +#define USER_CONTROL_POINT_CHAR_UUID (0x2A9F) +#define LANGUAGE_CHAR_UUID (0x2AA2) + +/* UUIDs for weight scale profile */ +#define WEIGHT_SCALE_SERVICE_UUID (0x181D) +#define WEIGHT_SCALE_MEASUREMENT_CHAR_UUID (0x2A9D) +#define WEIGHT_SCALE_FEATURE_CHAR_UUID (0x2A9E) + +/* UUIDs for weight scale profile */ +#define BOND_MANAGEMENT_SERVICE_UUID (0x181E) +#define BM_CONTROL_POINT_CHAR_UUID (0x2AA4) +#define BM_FEATURE_CHAR_UUID (0x2AA5) + +/* UUIDs for Internet Support Service */ +#define INTERNET_SUPPORT_SERVICE_UUID (0x1820) + +/* UUIDs for Indoor Positioning Service */ +#define INDOOR_POSITIONING_SERVICE_UUID (0x1821) +#define IP_CONFIGURATION_CHAR_UUID (0x2AAD) +#define IP_LATITUDE_CHAR_UUID (0x2AAE) +#define IP_LONGITUDE_CHAR_UUID (0x2AAF) + +/* UUIDs for HTTP proxy Service */ +#define HTTP_PROXY_SERVICE_UUID (0x1823) +#define HTTP_URI_CHAR_UUID (0x2AB6) +#define HTTP_HEADERS_CHAR_UUID (0x2AB7) +#define HTTP_STATUS_CODE_CHAR_UUID (0x2AB8) +#define HTTP_ENTITY_BODY_CHAR_UUID (0x2AB9) +#define HTTP_CONTROL_POINT_CHAR_UUID (0x2ABA) +#define HTTP_SECURITY_CHAR_UUID (0x2ABB) + +/* UUIDs for Object Transfer Service */ +#define OBJECT_TRANSFER_SERVICE_UUID (0x1825) +#define OTS_FEATURE_CHAR_UUID (0x2ABD) +#define OBJECT_NAME_CHAR_UUID (0x2ABE) +#define OBJECT_TYPE_CHAR_UUID (0x2ABF) +#define OBJECT_SIZE_CHAR_UUID (0x2AC0) +#define OBJECT_PROPERTIES_CHAR_UUID (0x2AC4) +#define OBJECT_ACTION_CONTROL_POINT_CHAR_UUID (0x2AC5) +#define OBJECT_LIST_CONTROL_POINT_CHAR_UUID (0x2AC6) + +/* Custom Services*/ +/* UUIDs for data transfer service */ +#define DATA_TRANSFER_SERVICE_UUID (0xFE80) +#define DATA_TRANSFER_TX_CHAR_UUID (0xFE81) +#define DATA_TRANSFER_RX_CHAR_UUID (0xFE82) + +/* UUIDs for custom battery service */ +#define CUSTOM_BATTERY_SERVICE_UUID (0xF2F0) +#define CUSTOM_BATTERY_LEVEL_CHAR_UUID (0xF2F1) + +/* Custom Services*/ +/* UUIDs for data transfer service */ +#define LED_BUTTON_SERVICE_UUID (0x1A30) +#define LED_CHAR_UUID (0x2B50) +#define BUTTON_CHAR_UUID (0x2B51) +/*UUIDs for End Device Management Service*/ +#define END_DEVICE_MGT_SERVICE_UUID (0x1A40) +#define END_DEVICE_STATUS_CHAR_UUID (0x2B60) + +#define P2P_SERVICE_UUID (0xFE40) +#define P2P_WRITE_CHAR_UUID (0xFE41) +#define P2P_NOTIFY_CHAR_UUID (0xFE42) + +#define HOME_SERVICE_UUID (0xFE90) +#define HOME_WRITE_CHAR_UUID (0xFE91) +#define HOME_NOTIFY_CHAR_UUID (0xFE92) + +#define CAM_SERVICE_UUID (0xFEA0) +#define CAM_WRITE_CHAR_UUID (0xFEA1) +#define CAM_NOTIFY_CHAR_UUID (0xFEA2) + +/* UUIDs for Cable Replacement Service */ +#define CRS_SERVICE_UUID (0xFE60) +#define CRS_TX_CHAR_UUID (0xFE61) +#define CRS_RX_CHAR_UUID (0xFE62) + +/* UUIDs for Apple Notification Center Service */ +#define ANCS_SERVICE_UUID (0xF431) +#define ANCS_NOTIFICATION_SOURCE_CHAR_UUID (0x120D) +#define ANCS_CONTROL_POINT_CHAR_UUID (0xD8F3) +#define ANCS_DATA_SOURCE_CHAR_UUID (0xC6E9) + +/* UUIDs for Apple Media Service start from iOS 8*/ +#define AMS_SERVICE_UUID (0x502B) +#define AMS_REMOTE_COMMAND_CHAR_UUID (0x81D8) +#define AMS_ENTITY_UPDATE_CHAR_UUID (0xABCE) +#define AMS_ENTITY_ATTRIBUTE_CHAR_UUID (0xF38C) +#endif /* _UUID_H_ */ diff --git a/lib/stm32wb0/STM32_BLE/stm32_ble_common.h b/lib/stm32wb0/STM32_BLE/stm32_ble_common.h new file mode 100644 index 000000000..adc73687d --- /dev/null +++ b/lib/stm32wb0/STM32_BLE/stm32_ble_common.h @@ -0,0 +1,124 @@ +/** + ****************************************************************************** + * @file stm32_ble_common.h + * @author GPM WBL Application Team + * @brief Common file to utilities + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32_BLE_COMMON_H +#define __STM32_BLE_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include "cmsis_compiler.h" + + /* -------------------------------- * + * Basic definitions * + * -------------------------------- */ + +#undef NULL +#define NULL 0U + +#undef FALSE +#define FALSE 0U + +#undef TRUE +#define TRUE (!0U) + + /* -------------------------------- * + * Critical Section definition * + * -------------------------------- */ +#undef BACKUP_PRIMASK +#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK() + +#undef DISABLE_IRQ +#define DISABLE_IRQ() __disable_irq() + +#undef RESTORE_PRIMASK +#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit) + + /* -------------------------------- * + * Macro delimiters * + * -------------------------------- */ +#undef M_BEGIN +#define M_BEGIN do { + +#undef M_END +#define M_END } while(0) + + /* -------------------------------- * + * Some useful macro definitions * + * -------------------------------- */ +#undef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +#undef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +#undef MODINC +#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END + +#undef MODDEC +#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END + +#undef MODADD +#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END + +#undef MODSUB +#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m ) + +#undef ALIGN +#ifdef WIN32 +#define ALIGN(n) +#else +#define ALIGN(n) __attribute__((aligned(n))) +#endif + +#undef PAUSE +#define PAUSE( t ) M_BEGIN \ + volatile int _i; \ + for ( _i = t; _i > 0; _i -- ); \ + M_END +#undef DIVF +#define DIVF( x, y ) ((x)/(y)) + +#undef DIVC +#define DIVC( x, y ) (((x)+(y)-1)/(y)) + +#undef DIVR +#define DIVR( x, y ) (((x)+((y)/2))/(y)) + +#undef SHRR +#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1) + +#undef BITN +#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1) + +#undef BITNSET +#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32_BLE_COMMON_H */ diff --git a/lib/stm32wba/CMakeLists.txt b/lib/stm32wba/CMakeLists.txt new file mode 100644 index 000000000..50d0ec7bb --- /dev/null +++ b/lib/stm32wba/CMakeLists.txt @@ -0,0 +1,53 @@ +# Copyright (c) 2024 STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 + +if(DEFINED CONFIG_BOARD_NUCLEO_WBA52CG) + message(FATAL_ERROR "BLE library is not compatible with nucleo_wba52cg") +endif() + +zephyr_compile_definitions( -DBLE ) + +zephyr_include_directories(hci) +zephyr_include_directories(hci/ll) + +zephyr_sources(hci/ll_sys_cs.c) +zephyr_sources(hci/ll_sys_intf.c) +zephyr_sources(hci/ll_sys_dp_slp.c) +zephyr_sources(hci/ll_sys_startup.c) +zephyr_sources(hci/RTDebug.c) +zephyr_sources(hci/hw_pka.c) +zephyr_sources(hci/pka_p256.c) +zephyr_sources(hci/bpka.c) +zephyr_sources(hci/power_table.c) +zephyr_sources(hci/scm.c) +zephyr_sources(hci/log_module.c) +if(CONFIG_FLASH) + zephyr_sources(hci/flash_manager.c) + zephyr_sources(hci/flash_driver.c) + zephyr_sources(hci/stm_list.c) + zephyr_sources(hci/rf_timing_synchro.c) +endif() + +set(STM32WBA_BLE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/stm32wba/lib) +set(STM32WBA_BLE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hci) + +add_library(stm32wba_ble_lib STATIC IMPORTED GLOBAL) +add_library(stm32wba_ll_lib STATIC IMPORTED GLOBAL) + +add_dependencies( + stm32wba_ble_lib + stm32wba_ll_lib +) +set_target_properties( + stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/stm32wba_ble_stack_llo.a +) +set_target_properties( + stm32wba_ll_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/LinkLayer_BLE_Full_lib.a +) + +set_target_properties(stm32wba_ble_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_INCLUDE_DIR}) +set_target_properties(stm32wba_ll_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_INCLUDE_DIR}) + +target_link_libraries(app PUBLIC stm32wba_ble_lib) +target_link_libraries(app PUBLIC stm32wba_ll_lib) diff --git a/zephyr/blobs/stm32wb0/lib/license.md b/zephyr/blobs/stm32wb0/lib/license.md new file mode 100644 index 000000000..1af523307 --- /dev/null +++ b/zephyr/blobs/stm32wb0/lib/license.md @@ -0,0 +1,80 @@ +SLA0044 Rev5/February 2018 + +## Software license agreement + +### __ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT__ + +BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE +OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS +INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES +(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON +BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES +TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT. + +Under STMicroelectronics’ intellectual property rights, the redistribution, +reproduction and use in source and binary forms of the software or any part +thereof, with or without modification, are permitted provided that the following +conditions are met: + +1. Redistribution of source code (modified or not) must retain any copyright +notice, this list of conditions and the disclaimer set forth below as items 10 +and 11. + +2. Redistributions in binary form, except as embedded into microcontroller or +microprocessor device manufactured by or for STMicroelectronics or a software +update for such device, must reproduce any copyright notice provided with the +binary code, this list of conditions, and the disclaimer set forth below as +items 10 and 11, in documentation and/or other materials provided with the +distribution. + +3. Neither the name of STMicroelectronics nor the names of other contributors to +this software may be used to endorse or promote products derived from this +software or part thereof without specific written permission. + +4. This software or any part thereof, including modifications and/or derivative +works of this software, must be used and execute solely and exclusively on or in +combination with a microcontroller or microprocessor device manufactured by or +for STMicroelectronics. + +5. No use, reproduction or redistribution of this software partially or totally +may be done in any manner that would subject this software to any Open Source +Terms. “Open Source Terms” shall mean any open source license which requires as +part of distribution of software that the source code of such software is +distributed therewith or otherwise made available, or open source license that +substantially complies with the Open Source definition specified at +www.opensource.org and any other comparable open source license such as for +example GNU General Public License (GPL), Eclipse Public License (EPL), Apache +Software License, BSD license or MIT license. + +6. STMicroelectronics has no obligation to provide any maintenance, support or +updates for the software. + +7. The software is and will remain the exclusive property of STMicroelectronics +and its licensors. The recipient will not take any action that jeopardizes +STMicroelectronics and its licensors' proprietary rights or acquire any rights +in the software, except the limited rights specified hereunder. + +8. The recipient shall comply with all applicable laws and regulations affecting +the use of the software or any part thereof including any applicable export +control law or regulation. + +9. Redistribution and use of this software or any part thereof other than as +permitted under this license is void and will automatically terminate your +rights under this license. + +10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE +DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL +STMICROELECTRONICS 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. + +11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER +EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY +RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY. diff --git a/zephyr/module.yml b/zephyr/module.yml index 9118f3cdb..ff820cce2 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -18,3 +18,10 @@ blobs: license-path: zephyr/blobs/stm32wba/lib/license.md url: https://github.com/STMicroelectronics/STM32CubeWBA/raw/v1.3.1/Middlewares/ST/STM32_WPAN/ble/stack/lib/stm32wba_ble_stack_llo.a description: "Binary Stack library for the STM32WBA Bluetooth subsystem" + - path: stm32wb0/lib/stm32wb0x_ble_stack_controller_only.a + sha256: 54bf69acaa59afc368132f8170e9910858a2c801538494d8de96fa567c02e233 + type: lib + version: '1.0.0' + license-path: zephyr/blobs/stm32wb0/lib/license.md + url: https://github.com/STMicroelectronics/STM32CubeWB0/raw/v1.0.0/Middlewares/ST/STM32_BLE/stack/lib/stm32wb0x_ble_stack_controller_only.a + description: "Binary Stack library for the STM32WB0 Bluetooth subsystem"