/**
  ******************************************************************************
  * @file           : app_aliro.h
  * @brief          : Header for app_aliro.c file.
  *                   This file contains the public declarations for the Aliro demo.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 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 _APP_ALIRO_H_
#define _APP_ALIRO_H_

#ifdef __cplusplus
extern "C" {
#endif

/** @addtogroup NFCBLE
  * @{
  */

/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include "st_errno.h"
#include "ACWG_Security.h"
#include "provisioning.h"
#if defined(STM32U545xx) || defined(STM32U585xx)
#include "stm32u5xx_hal.h"
#include "stm32u5xx_nucleo.h"
#include "log_module_u5.h"
void Log_Module_Print(Log_Verbose_Level_t VerboseLevel, Log_Region_t Region, const char * Text, ...);
#endif //defined(STM32U545xx) || defined(STM32U585xx)
#if defined(STM32U385xx) 
#include "stm32u3xx_hal.h"
#include "stm32u3xx_nucleo.h"
#include "log_module_u3.h"
void Log_Module_Print(Log_Verbose_Level_t VerboseLevel, Log_Region_t Region, const char * Text, ...);
#endif //defined(STM32U385xx)
#if defined(STM32WBA52xx) || defined(STM32WBA55xx) || defined(STM32WBA65xx)
#include "stm32wbaxx_hal.h"
#include "stm32wbaxx_nucleo.h"
#include "log_module.h"
#endif //defined(STM32WBA52xx) || defined(STM32WBA55xx) || defined(STM32WBA65xx)

/** @addtogroup Aliro_app_Exported_Types
  * @{
  */

/* Exported types ------------------------------------------------------------*/

/**
 * @enum verblevel_t
 * @brief Verbosity levels for logging.
 */
typedef enum _verblevel
{
  VERB_NULL=0,         /**< No output */
  VERB_ALWAYS=1,       /**< Always output */
  VERB_CRITICAL=2,     /**< Critical output */
  VERB_ERROR=3,        /**< Error output */
  VERB_NORMAL=4,       /**< Normal output */
  VERB_VERBOSE=5,      /**< Verbose output */
  VERB_INFO=6          /**< Informational output */
}verblevel_t;


/**
 * @enum timeStampsPos_t
 * @brief Timestamp positions for performance measurement.
 */
typedef enum _timeStampsPos
{
  SELECT_APP_POS,                /**< Application selection */
  END_SELECT_APP_POS,            /**< End of application selection */
  AUTH0_POS,                     /**< Start authentication 0 */
  END_AUTH0_POS,                 /**< End authentication 0 */
  LOADCERT_POS,                  /**< Certificate loading */
  END_LOADCERT_POS,              /**< End certificate loading */
  AUTH1_POS,                     /**< Start authentication 1 */
  END_AUTH1_POS,                 /**< End authentication 1 */
  CONTROL_FLOW_POS,              /**< Control flow */
  END_CONTROL_FLOW_POS,          /**< End control flow */
  EXCHANGE_POS,                  /**< Data exchange */
  END_EXCHANGE_POS,              /**< End data exchange */
  STEPUP_POS,                    /**< Step-up */
  END_STEPUP_POS,                /**< End step-up */
  DOOR_IS_OPENED_POS,            /**< Door opened */
  DOOR_IS_CLOSED_POS,            /**< Door closed */
  DOOR_IS_DISARMED_POS,          /**< Door disarmed */
  DON_T_KNOW_POS,                /**< Unknown state */

  DERIVE_PERSISTENT_KEYS_POS,    /**< Derivation of persistent keys */
  END_DERIVE_PERSISTENT_KEYS_POS,/**< End derivation of persistent keys */

  ELAPSED_TIME_POS,              /**< Elapsed time */
  
  NUM_TIMESTAMPS                 /**< Total number of timestamps (do not change) */
}timeStampsPos_t;


/**
 * @struct statItem_t
 * @brief Structure for managing timestamps and statistics.
 */
typedef struct _statItem
{
  timeStampsPos_t pos;   /**< Timestamp position */
  char title[10];        /**< Title */
  uint8_t toPrint;       /**< Print flag */
  uint32_t ts;           /**< Timestamp value */
}statItem_t;


/**
 * @struct alirosvc_param_t
 * @brief Aliro service parameters.
 */
typedef struct _alirosvc_param
{
  uint8_t   proposedSPSM[2];                /**< Proposed SPSM */
  uint8_t   protVerSupportedLen;             /**< Supported protocol version length */
  uint8_t   supportedProtocolVersion[4];     /**< Supported protocol versions */
  uint8_t   selectedProtocolVersion[2];      /**< Selected protocol version */
  uint8_t   featuresSupportedLen;            /**< Supported features length */
  uint8_t   featuresSupported[1];            /**< Supported features */
}
alirosvc_param_t;

/**
  * @}
  */

/** @addtogroup Aliro_app_Exported_Variables
  * @{
  */

/* Exported variables ------------------------------------------------------------*/

/**
 * @brief Aliro protocol versions supported.
 */
extern uint32_t xProtocolVersionSupported;

/**
 * @brief Current verbosity level.
 */
extern verblevel_t nVerbosityLevel;

/**
 * @brief NFC session context.
 */
extern ACWG_SessionContext_t context_nfc;

/**
 * @brief NFC session context.
 */
extern ACWG_SessionContext_t context_ble;

/**
  * @}
  */

/** @addtogroup Aliro_app_Exported_Constants
  * @{
  */

/* Exported constants --------------------------------------------------------*/
#define VERBOSITY_SET   nVerbosityLevel /**< Macro to get the current verbosity level */
#define ALIRO_MEASURE_PERFORMANCE       0 /**< Enable performance measurement */
#define ALIRO_CERTIFICATION_TEST        1 /**< Enable certification test */

//0x40 --> Bit 6: Bluetooth LE-Only Aliro flow supported. 
//0x80 --> Bit 7: Bluetooth LE + UWB Aliro flow supported.
#define BLE_RKE_ALIRO_FLOW_SUPPORTED    0x40 /**< Bit 6: BLE-only Aliro flow supported */
#define BLE_UWB_ALIRO_FLOW_SUPPORTED    0x80 /**< Bit 7: BLE + UWB Aliro flow supported */

#define BLE_ALIRO_FLOWS_SUPPORTED               (BLE_UWB_ALIRO_FLOW_SUPPORTED | BLE_RKE_ALIRO_FLOW_SUPPORTED) /**< Macro for supported Aliro flows */

#define ALIRO_RTC_SET_STATUS_IAR        0x00F4 /**< RTC IAR status */
#define ALIRO_RTC_SET_STATUS_GOOD       0x34F4 /**< RTC good status */

#define TIMEOUT_PREPARE_RANGING_DEFAULT     20000 /** Default timeout (ms) for prepare ranging operation. */
#define TIMEOUT_EXECUTE_RANGING_DEFAULT     70000 /** Default timeout (ms) for execute ranging operation. */
#define TIMEOUT_SUSPEND_RANGING_DEFAULT     10000 /** Default timeout (ms) for suspend ranging operation. */
#define TIMEOUT_RESUME_RANGING_DEFAULT      20000 /** Default timeout (ms) for resume ranging operation. */
#define TIMEOUT_DOOR_OPERATION_DEFAULT      20000 /** Default timeout (ms) for door operation. */

#if defined (ST25R200)
#define X_NUCLEO_NFC_NAME       "X-NUCLEO-NFC09A1/NFC10A1"
#endif //defined (ST25R200)

#if defined (ST25R500)
#define X_NUCLEO_NFC_NAME       "X-NUCLEO-NFC12A1"
#endif //defined (ST25R200)

#if USE_GEN2

    #define ALIRO_BLE       1

    #define H_ALIRO_UART    huart1
    #define HH_ALIRO_UART   &H_ALIRO_UART
    #define H_TIM			htim2

    extern RTC_HandleTypeDef hrtc;
    
    #define ALIRO_HRTC              hrtc
    #define ALIRO_RTC_BKP_TIME      RTC_BKP_DR10

    #define LD3_Pin GPIO_PIN_0
    #define LD3_GPIO_Port GPIOE
    #define LD2_Pin GPIO_PIN_1
    #define LD2_GPIO_Port GPIOE

    //sector 125
    #define PROVISIONING_SECTOR                     253
    #define PROVISIONING_START_ADDRESS              (0x08000000+PROVISIONING_SECTOR*0x2000) //0x081fa000

    //sector 124
    #define PROVISIONING_JSON_SECTOR                252
    #define PROVISIONING_JSON_START_ADDRESS         (0x08000000+PROVISIONING_JSON_SECTOR*0x2000) //0x081f8000
#else //USE_GEN2

    #if defined(STM32WBA52xx)||defined(STM32WBA55xx)

      #define ALIRO_BLE       1

      #define H_ALIRO_UART    huart1
      #define HH_ALIRO_UART   &H_ALIRO_UART
      #define H_TIM			htim2
      extern RTC_HandleTypeDef hrtc;

      #define ALIRO_HRTC              hrtc
      #define ALIRO_RTC_BKP_TIME      RTC_BKP_DR10

      #define LD3_Pin GPIO_PIN_8
      #define LD3_GPIO_Port GPIOB
      #define LD2_Pin GPIO_PIN_9
      #define LD2_GPIO_Port GPIOA

      //sector 125
      #define PROVISIONING_SECTOR                     123
      #define PROVISIONING_START_ADDRESS              (0x08000000+PROVISIONING_SECTOR*0x2000) //0x080fa000

      //sector 124
      #define PROVISIONING_JSON_SECTOR                122
      #define PROVISIONING_JSON_START_ADDRESS         (0x08000000+PROVISIONING_JSON_SECTOR*0x2000) //0x080f8000
    #endif //defined(STM32WBA52xx)||defined(STM32WBA55xx)
    

    #ifdef STM32WBA65xx
      
      #define ALIRO_BLE       1
      
      #define H_ALIRO_UART    huart1
      #define HH_ALIRO_UART   &H_ALIRO_UART
      #define H_TIM			htim2
      extern RTC_HandleTypeDef hrtc;
      
      #define ALIRO_HRTC              hrtc
      #define ALIRO_RTC_BKP_TIME      RTC_BKP_DR10
      
      #define LD3_Pin GPIO_PIN_0
      #define LD3_GPIO_Port GPIOE
      #define LD2_Pin GPIO_PIN_1
      #define LD2_GPIO_Port GPIOE

      //sector 125
      #define PROVISIONING_SECTOR                     253
      #define PROVISIONING_START_ADDRESS              (0x08000000+PROVISIONING_SECTOR*0x2000) //0x081fa000

      //sector 124
      #define PROVISIONING_JSON_SECTOR                252
      #define PROVISIONING_JSON_START_ADDRESS         (0x08000000+PROVISIONING_JSON_SECTOR*0x2000) //0x081f8000
    #endif //STM32WBA65xx



    #if defined(STM32U545xx) || defined(STM32U585xx) || defined(STM32U385xx)
      extern  EXTI_HandleTypeDef H_EXTI_13;
      extern UART_HandleTypeDef huart1;
      #define HH_ALIRO_UART           &huart1
      #define H_ALIRO_UART    huart1
      #define H_TIM			htim2

      #define LD3_Pin GPIO_PIN_8
      #define LD3_GPIO_Port GPIOB
      #define LD2_Pin GPIO_PIN_4
      #define LD2_GPIO_Port GPIOC

      //sector 125
      #define PROVISIONING_SECTOR                     63
      #define PROVISIONING_START_ADDRESS              (0x08000000+PROVISIONING_SECTOR*0x2000) //0x081fa000

      //sector 124
      #define PROVISIONING_JSON_SECTOR                62
      #define PROVISIONING_JSON_START_ADDRESS         (0x08000000+PROVISIONING_JSON_SECTOR*0x2000) //0x081f8000
    #endif //defined(STM32U545xx) || defined(STM32U585xx) || defined(STM32U385xx)
      
#endif //USE_GEN2

#if defined ALIRO_HRTC
#define USE_RTC         1
#endif //defined ALIRO_HRTC

#define CLEAR_SCREEN_COMMAND    "\033[2J\r\n"
#define TEXT_COLOR_1            "\033[0;32m" //green
#define TEXT_COLOR_GREEN        "\033[0;32m" //green
#define TEXT_COLOR_2            "\033[0;33m"
#define TEXT_COLOR_YELLOW       "\033[0;33m"
#define TEXT_COLOR_3            "\033[0;31m"
#define TEXT_COLOR_RED          "\033[0;31m"
#define TEXT_COLOR_4            "\033[0;36m"
#define TEXT_COLOR_CYAN         "\033[0;36m"
#define TEXT_COLOR_BLU          "\033[0;34m"     
#define TEXT_COLOR_VIOLET       "\033[0;35m"     
#define TEXT_COLOR_GRAY         "\033[0;37m"
#define TEXT_COLOR_NOIR           "\033[0;30m"     
#define TEXT_COLOR_DEFAULT      "\033[0;39m"

//Background
#define TEXT_BACKGROUND_COLOR_BLACK         "\033[40m"
#define TEXT_BACKGROUND_COLOR_RED           "\033[41m"
#define TEXT_BACKGROUND_COLOR_GREEN         "\033[42m"
#define TEXT_BACKGROUND_COLOR_YELLOW        "\033[43m"
#define TEXT_BACKGROUND_COLOR_BLUE          "\033[44m"
#define TEXT_BACKGROUND_COLOR_PURPLE        "\033[45m"
#define TEXT_BACKGROUND_COLOR_CYAN          "\033[46m"
#define TEXT_BACKGROUND_COLOR_WHITE         "\033[47m"

#define TEXT_TEST_COLOR         "\033[7;34m"

#define TEXT_RESET       "\033[0m"
#define TEXT_BOLD        "\033[1m" //used to make ligth color
#define TEXT_UNDERSCORE  "\033[4m"
#define TEXT_BLINK       "\033[5m"
#define TEXT_REVERSE     "\033[7m"
#define TEXT_CONCEALED   "\033[8m"

#define TEXT_COLOR_ESCAPE_CHAR  '\033'

#define VERB_STATISTICS                 VERB_INFO
#define VERB_STATISTICS_REPORT          VERB_CRITICAL
#define VERB_STATE_TITLE                VERB_NORMAL
#define VERB_FN_NAME                    VERB_VERBOSE
#define VERB_TERMINAL                   VERB_NORMAL

/**
  * @}
  */

/** @addtogroup Aliro_app_Exported_Macros
  * @{
  */

/* Exported macro ------------------------------------------------------------*/
#if ALIRO_MEASURE_PERFORMANCE
#define RESET_TIME_STAMP()              do{ ResetTimeStamp();ResetAllSavedTimeStamps(); }while(0)
#define PRINT_TIME_STAMP(pos)           do{ SaveTimeStamp(pos);/*PrintTimeStamp(label);*/ }while(0)
#define TIME_STAMP_REPORT()             do{ PrintTimeStampReport(); }while(0)
#else //ALIRO_MEASURE_PERFORMANCE
#define RESET_TIME_STAMP()
#define PRINT_TIME_STAMP(pos)
#define TIME_STAMP_REPORT()
#endif //ALIRO_MEASURE_PERFORMANCE
   
#define countof(_A_) (sizeof(_A_) / sizeof(*(_A_)))     /**< Macro to count array elements */

#define PLATFORM_LOG(VERBOSITY, ...)    do{if((uint8_t)VERBOSITY <= (uint8_t)nVerbosityLevel)LOG_INFO_APP(__VA_ARGS__);}while(0)
#define DELAY_CONDITIONAL(D)            do{if( nVerbosityLevel > VERB_VERBOSE)HAL_Delay(D);}while(0)

#define HIGH_BYTE(A)    ((A&0xFF00)>>8)
#define LOW_BYTE(A)     (A&0x00FF)

#define HEX(C)          (((C>='0') && (C<='9'))?(C-'0'):((C>='A') && (C<='F'))?(C-'A'+0xA):(0))

#define GET_IAR_YEAR_DEC(D)     ((HEX(D[7])*1000 + HEX(D[8])*100 + HEX(D[9])*10 + HEX(D[10])*1) - 2000)
#define GET_IAR_YEAR(D)         (GET_IAR_YEAR_DEC(D)%10 + (GET_IAR_YEAR_DEC(D)/10)*16 - 0x30)
#define GET_IAR_DATE(D)     (HEX(D[4])*16 + HEX(D[5])*1)
#define GET_IAR_HOURS(T)    (HEX(T[0])*16 + HEX(T[1])*1)
#define GET_IAR_MINUTES(T)  (HEX(T[3])*16 + HEX(T[4])*1)
#define GET_IAR_SECONDS(T)  (HEX(T[6])*16 + HEX(T[7])*1)
#define GET_IAR_MONTH(D)    (\
    (D[0]==JAN[0] && D[1] == JAN[1] && D[2] == JAN[2])?0x1:\
    (D[0]==FEB[0] && D[1] == FEB[1] && D[2] == FEB[2])?0x2:\
    (D[0]==MAR[0] && D[1] == MAR[1] && D[2] == MAR[2])?0x3:\
    (D[0]==APR[0] && D[1] == APR[1] && D[2] == APR[2])?0x4:\
    (D[0]==MAY[0] && D[1] == MAY[1] && D[2] == MAY[2])?0x5:\
    (D[0]==JUN[0] && D[1] == JUN[1] && D[2] == JUN[2])?0x6:\
    (D[0]==JUL[0] && D[1] == JUL[1] && D[2] == JUL[2])?0x7:\
    (D[0]==AUG[0] && D[1] == AUG[1] && D[2] == AUG[2])?0x8:\
    (D[0]==SEP[0] && D[1] == SEP[1] && D[2] == SEP[2])?0x9:\
    (D[0]==OCT[0] && D[1] == OCT[1] && D[2] == OCT[2])?0x10:\
    (D[0]==NOV[0] && D[1] == NOV[1] && D[2] == NOV[2])?0x11:\
    (D[0]==DEC[0] && D[1] == DEC[1] && D[2] == DEC[2])?0x12:\
    1)

#define TRANSACTION_SUCCESS_OPEN()      AliroPort_TRANSACTION_SUCCESS_OPEN()
#define TRANSACTION_SUCCESS_CLOSE()     AliroPort_TRANSACTION_SUCCESS_CLOSE()
#define TRANSACTION_FAILURE()           AliroPort_TRANSACTION_FAILURE()

/**
  * @}
  */

/** @addtogroup Aliro_app_Exported_Functions
  * @{
  */

/* Exported functions ------------------------------------------------------- */

/**
 * @brief Returns the current timestamp.
 * @return Timestamp value.
 */
uint32_t GetTimeStamp(void);

/**
 * @brief Prints the timestamp associated with a string.
 * @param pstr Descriptive string.
 * @return Printed timestamp value.
 */
uint32_t PrintTimeStamp(char *pstr);


/**
 * @brief Gets the current date and time.
 * @param timeDate Pointer to struct tm to store the date and time.
 */
 void GetTimeDate(struct tm *timeDate);

/**
 * @brief Shows current date and time.
 */
void ShowTimeDate(void);

#if defined(STM32WBA52xx) || defined(STM32WBA55xx) || defined(STM32WBA65xx)
/**
 * @brief Sets the RTC configuration status.
 * @param nStatus Status to set.
 */
void SetRtcSettingStatus(uint32_t nStatus);
#endif //defined(STM32WBA52xx) || defined(STM32WBA55xx) || defined(STM32WBA65xx)


/**
 * @brief Resets all saved timestamps.
 */
void ResetAllSavedTimeStamps(void);

/**
 * @brief Searches for the position of a timestamp.
 * @param pos Position to search.
 * @return Pointer to the found statItem_t structure.
 */
statItem_t *SearchPos(timeStampsPos_t pos);

/**
 * @brief Saves the timestamp in a specific position.
 * @param pos Timestamp position.
 */
void SaveTimeStamp(timeStampsPos_t pos);

/**
 * @brief Prints the timestamp report.
 */
void PrintTimeStampReport(void);

/**
 * @brief Resets the current timestamp.
 */
void ResetTimeStamp(void);

/**
 * @brief Prints a buffer in hexadecimal format.
 * @param pstr Descriptive string.
 * @param pBuf Buffer to print.
 * @param nSize Buffer size.
 */
void PrintBufferHex(const char *pstr, const uint8_t *pBuf, const uint32_t nSize);

/**
 * @brief Always prints a buffer in hexadecimal format.
 * @param pstr Descriptive string.
 * @param pBuf Buffer to print.
 * @param nSize Buffer size.
 */
void PrintBufferHexAlways(const char *pstr, const uint8_t *pBuf, const uint32_t nSize);

/**
 * @brief Prints an error string.
 * @param errstr Error string.
 * @param retval Return code.
 */
void PrintErrorString(char*errstr, ACWG_Status_t retval);

/**
 * @brief Receives a character from USART.
 * @param buf Buffer to store the character.
 * @return Number of received characters.
 */
uint16_t UsartGetChar(uint8_t *buf);

/**
 * @brief Receives a character from USART in blocking mode.
 * @param buf Buffer to store the character.
 * @return Number of received characters.
 */
uint16_t UsartGetCharBlocking(uint8_t *buf);

/**
 * @brief Initializes the Aliro module.
 * @return true if initialization is successful, false otherwise.
 */
bool aliro_init();

/**
 * @brief Executes the main Aliro process.
 */
void aliro_process();

/**
 * @brief Hook for successful transaction - Door open
 */
__weak void AliroPort_TRANSACTION_SUCCESS_OPEN(void);

/**
 * @brief Hook for successful transaction - Door close
 */
__weak void AliroPort_TRANSACTION_SUCCESS_CLOSE(void);

/**
 * @brief Hook for transaction failure
 */
__weak void AliroPort_TRANSACTION_FAILURE(void);

/**
 * @brief Delay porting for Aliro.
 * @param Delay Delay time in ms.
 */
void AliroPort_Delay(uint32_t Delay);

/**
 * @brief Writes the state of a GPIO pin.
 * @param GPIOx Pointer to GPIO.
 * @param GPIO_Pin Pin to write.
 * @param PinState State to set.
 */
void AliroPort_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);

/**
 * @brief Transmits data via UART.
 * @param huart UART handle.
 * @param pData Data to transmit.
 * @param Size Data size.
 * @param Timeout Operation timeout.
 * @return HAL status.
 */
HAL_StatusTypeDef AliroPort_UART_Transmit(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size, uint32_t Timeout);

/**
 * @brief Receives data via UART.
 * @param huart UART handle.
 * @param pData Data buffer.
 * @param Size Pointer to data size.
 * @param Timeout Operation timeout.
 * @return HAL status.
 */
HAL_StatusTypeDef AliroPort_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t *Size, uint32_t Timeout);

/**
 * @brief Interrupt Service Routine for button 1.
 */
void Button1_isr( void );

/**
 * @brief Board reset.
 */
void board_reset();

/**
 * @brief Checks if the selected SPSM is valid.
 * @param selected Selected SPSM.
 * @return 1 if valid, 0 otherwise.
 */
uint8_t isValidSPSM(uint16_t selected);

/**
 * @brief Gets dynamic SPSM.
 * @param old_spsm Previous SPSM.
 * @return Dynamic SPSM.
 */
uint16_t get_dynamic_spsm(uint8_t old_spsm);

/**
 * @brief Fills the advertising buffer.
 * @param advbuf Advertising buffer.
 * @param psize Pointer to size.
 */
void fillAdvBuffer(uint8_t *advbuf, uint8_t *psize);

/**
 * @brief Gets the initial length of Aliro service parameters.
 * @param pLen Pointer to length.
 * @return Length.
 */
uint8_t AliroSvcParamGetInitLen(uint8_t *pLen);

/**
 * @brief Gets the initial buffer of Aliro service parameters.
 * @param DataBuf Pointer to data buffer.
 * @return Buffer length.
 */
uint8_t AliroSvcParamGetInitBuf(uint8_t **DataBuf);

/**
 * @brief Verifies the Aliro protocol version.
 * @param selectedProtocolVersion_16 Selected version.
 * @return 1 if valid, 0 otherwise.
 */
uint8_t AliroSvcVerifyProtVer(uint16_t selectedProtocolVersion_16);

/**
 * @brief Gets the saved selected protocol version.
 * @return Selected version.
 */
uint16_t AliroGetSavedSelectedProtocolVersion();

/**
 * @brief BLE Aliro initialization complete callback.
 */
void AliroBLE_Init_complete_cb();

/**
 * @brief BLE Aliro disconnection complete callback.
 */
void AliroBleDisconnection_complete_cb();

/**
 * @brief BLE CoC Aliro disconnection complete callback.
 */
void AliroBleCocDisconnection_complete_cb();

/**
 * @brief Fills techs2find for Aliro.
 * @param techs2find Pointer to techs2find.
 */
void AliroFilltechs2Find(uint16_t *techs2find);

/**
 * @brief Set the timeout for the prepare ranging operation.
 *
 * @param timeout_ms Timeout value in milliseconds.
 */
 void Set_timeout_prepare_ranging(uint32_t timeout_ms);

/**
 * @brief Set the timeout for the execute ranging operation.
 *
 * @param timeout_ms Timeout value in milliseconds.
 */
 void Set_timeout_execute_ranging(uint32_t timeout_ms);

/**
 * @brief Set the timeout for the suspend ranging operation.
 *
 * @param timeout_ms Timeout value in milliseconds.
 */
 void Set_timeout_suspend_ranging(uint32_t timeout_ms);

/**
 * @brief Set the timeout for the resume ranging operation.
 *
 * @param timeout_ms Timeout value in milliseconds.
 */
 void Set_timeout_resume_ranging(uint32_t timeout_ms);

/**
 * @brief Set the timeout for the door operation.
 *
 * @param timeout_ms Timeout value in milliseconds.
 */
void Set_timeout_door_operation(uint32_t timeout_ms);

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* _APP_ALIRO_H_ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
