Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_MeshLightingDemo/STM32_WPAN/app/appli_mesh.c')
-rw-r--r--Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_MeshLightingDemo/STM32_WPAN/app/appli_mesh.c528
1 files changed, 466 insertions, 62 deletions
diff --git a/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_MeshLightingDemo/STM32_WPAN/app/appli_mesh.c b/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_MeshLightingDemo/STM32_WPAN/app/appli_mesh.c
index 1a2dd1342..7d500a353 100644
--- a/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_MeshLightingDemo/STM32_WPAN/app/appli_mesh.c
+++ b/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_MeshLightingDemo/STM32_WPAN/app/appli_mesh.c
@@ -17,6 +17,7 @@
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
+#include "ble_common.h"
#include "app_conf.h"
#include "hal_common.h"
#include "appli_mesh.h"
@@ -27,9 +28,13 @@
#include <string.h>
#include "models_if.h"
#include "mesh_cfg.h"
+#include "generic.h"
+#include "serial_if.h"
+#include "appli_nvm.h"
+//#include "gp_timer.h"
#include "stm32_seq.h"
-
+#include "PWM_config.h"
/** @addtogroup BLE_Mesh
* @{
@@ -46,10 +51,13 @@
#define LONG_PRESS_THRESHOLD 1000U
#define MANUAL_UNPROVISION_TIMER 3000U
#define FLASH_ERASE_TIME 100U
-#define DISCOVER_TIMER 10*60*1000 /* 10 minutes */
+//#define DISCOVER_TIMER 10*60*1000 /* 10 minutes */
+#define DISCOVER_TIMER_INTERVAL /*10*60**/(1000000/CFG_TS_TICK_VAL) /* 10 minutes */
#define DEFAULT_DELAY_PACKET_FROM 500U
#define DEFAULT_DELAY_PACKET_RANDOM_TIME 500U
-
+#define USER_OUTPUT_OOB_APPLI_PROCESS 0U
+#define INPUT_OOB_TIMEOUT 300U /* input Oob30 Sec timeout*/
+#define PBADV_UNPROV_DEV_BEACON_INTERVAL 100U /* 100 ms */
/* Private macro -------------------------------------------------------------*/
#define MAX_APPLI_BUFF_SIZE 8
#define MAX_PENDING_PACKETS_QUE_SIZE 2
@@ -69,17 +77,60 @@ enum ButtonState
BS_OFF,
BS_DEBOUNCE,
BS_SHORT_PRESS,
- BS_LONG_PRESS
+ BS_SHORT_PRESS2,
+ BS_LONG_PRESS,
+ BS_LONG_PRESS2
};
enum ButtonState buttonState = BS_OFF;
tClockTime tBounce = 0;
MOBLEUINT8 Appli_LedState = 0;
+MOBLEUINT16 IntensityValue = INTENSITY_LEVEL_ZERO;
+MOBLEUINT8 IntensityFlag = FALSE;
MOBLEUINT8 ProxyFlag = 0;
MOBLEUINT8 ProvisionFlag = 0;
+
+#ifdef ENABLE_AUTH_TYPE_OUTPUT_OOB
+static MOBLEUINT8 PrvngInProcess = 0;
+static MOBLEUINT32 OutputOobData = 0;
+static MOBLEUINT32 OutputOobBlinkCount = 0;
+#endif
+#ifdef ENABLE_AUTH_TYPE_INPUT_OOB
+MOBLEUINT8 InputOobData[8] = {0};
+MOBLEUINT8 inputOOBDataReady = 0;
+#endif
/*Number Of Elements selected per Node. Maximum Elements supported = 3*/
MOBLEUINT8 NumberOfElements = APPLICATION_NUMBER_OF_ELEMENTS;
+
+#ifdef ENABLE_AUTH_TYPE_STATIC_OOB
+/* 16 octets Static OOB information to be input here. Used during provisioning by Library */
+const MOBLEUINT8 StaticOobBuff[STATIC_OOB_SIZE] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
+#else
+const MOBLEUINT8 StaticOobBuff[] = {0};
+#endif
+#ifdef PUB_KEY_TYPE_OOB
+/* 64 octets Public Key information to be input here. It is only required for Public Key OOB case.
+Used during provisioning by Library */
+const MOBLEUINT8 PubKeyBuff[64] = {0xF4, 0x65, 0xE4, 0x3F, 0xF2, 0x3D, 0x3F, 0x1B, 0x9D, 0xC7,
+0xDF, 0xC0, 0x4D, 0xA8, 0x75, 0x81, 0x84, 0xDB, 0xC9, 0x66, 0x20, 0x47, 0x96, 0xEC, 0xCF,
+0x0D, 0x6C, 0xF5, 0xE1, 0x65, 0x00, 0xCC, 0x02, 0x01, 0xD0, 0x48, 0xBC, 0xBB, 0xD8, 0x99,
+0xEE, 0xEF, 0xC4, 0x24, 0x16, 0x4E, 0x33, 0xC2, 0x01, 0xC2, 0xB0, 0x10, 0xCA, 0x6B, 0x4D,
+0x43, 0xA8, 0xA1, 0x55, 0xCA, 0xD8, 0xEC, 0xB2, 0x79};
+
+/* 32 octets Private Key information to be input here. It is only required for Public Key OOB case.
+Used during provisioning by Library */
+const MOBLEUINT8 PrivKeyBuff[32] = {0x52, 0x9A, 0xA0, 0x67, 0x0D, 0x72, 0xCD, 0x64, 0x97, 0x50,
+0x2E, 0xD4, 0x73, 0x50, 0x2B, 0x03, 0x7E, 0x88, 0x03, 0xB5, 0xC6, 0x08, 0x29, 0xA5, 0xA3,
+0xCA, 0xA2, 0x19, 0x50, 0x55, 0x30, 0xBA};
+#else
+const MOBLEUINT8 PubKeyBuff[] = NULL;
+const MOBLEUINT8 PrivKeyBuff[] = NULL;
+#endif
+
+
+
/*Select Node as Sniffer, Means able to sniff all the packets*/
MOBLEUINT8 DisableFilter = 0;
@@ -93,24 +144,43 @@ MOBLEUINT8 nvm_operation;
MOBLEUINT8 nvm_flash_page;
MOBLEUINT8 provisioning_completion;
+/* Timer to control unprovisioned device beacons */
+#if PB_ADV_SUPPORTED
+MOBLEUINT8 discoverTimer_Id;
+#endif
+
/********************* Application configuration **************************/
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__) || defined(__CC_ARM)
MOBLEUINT8 bdaddr[8];
-extern const MOBLEUINT8 _bdaddr[];
+/* Mesh application data 1 sector used 125 */
+//extern const MOBLEUINT8 _bdaddr[];
+//const void *appNvmBase = _bdaddr;
+
+/* Mesh library configuration 2 sectors used: 126 and 127 */
+//extern const char* _bleNvmBase_data[];
+//const void *mobleNvmBase = _bleNvmBase_data;
#ifdef INTERNAL_UNIQUE_NUMBER_MAC
static void Appli_GetMACfromUniqueNumber(void);
-#endif
+#endif /* INTERNAL_UNIQUE_NUMBER_MAC */
+
+/* NVM addresses for Nucleo 1Mb */
+const void *mobleNvmBase = (const void *)0x0807E000; /* 2 sectors used: 126 and 127 */
+const void *appNvmBase = (const void *)0x0807D000; /* 1 sector used: 125 */
+/* NVM addresses for Nucleo 512Kb */
+//const void *mobleNvmBase = (const void *)0x08056000; /* 2 sectors used: 86 and 87 */
+//const void *appNvmBase = (const void *)0x08055000; /* 1 sector used: 85 */
-extern const char _mobleNvmBase_data[];
-const void *mobleNvmBase = (const void *)0x0807E000;
#else
#error "Unknown compiler"
#endif /* __GNUC__ || defined(__IAR_SYSTEMS_ICC__) || defined(__CC_ARM) */
/* Private function prototypes -----------------------------------------------*/
-static void Appli_LongButtonPress(void);
+//static void Appli_LongButtonPress(void);
static void Appli_ShortButtonPress(void);
+void Appli_OobAuthenticationProcess(void);
+void BLEMesh_UnprovisionCallback(MOBLEUINT8 reason);
+void Appli_LowPowerProcess(void);
/* Private functions ---------------------------------------------------------*/
@@ -125,6 +195,7 @@ static void Appli_ShortButtonPress(void)
BLEMesh_ModelsCommand();
}
+#if 0
/**
* @brief Function calls when a button is pressed for Long duration
* @param void
@@ -134,6 +205,7 @@ static void Appli_LongButtonPress(void)
{
/* User Implementation */
}
+#endif
/**
* @brief Updates the button status
@@ -147,15 +219,14 @@ static void Appli_UpdateButtonState(int isPressed)
{
/* Case for Button State off */
case BS_OFF:
- /* if button is pressed */
if (isPressed)
{
+ /* move to debounce state */
buttonState = BS_DEBOUNCE;
tBounce = Clock_Time();
}
break;
-
- /* Case for Button Debouncing */
+ /* Case for Button Debounce */
case BS_DEBOUNCE:
if (isPressed)
{
@@ -167,33 +238,45 @@ static void Appli_UpdateButtonState(int isPressed)
}
else
{
- break;
+ /* continue to be in BS_DEBOUNCE */
}
}
else
{
buttonState = BS_OFF;
+ }
break;
- }
- /* Case if Button is pressed for small duration */
+ /* Case if Button 1 is pressed for duration > BOUNCE_THRESHOLD */
case BS_SHORT_PRESS:
- if (isPressed && ((Clock_Time() - tBounce) > LONG_PRESS_THRESHOLD))
+ if (isPressed)
+ {
+ if ((Clock_Time() - tBounce) > LONG_PRESS_THRESHOLD)
{
+ /* If Button 1 is pressed for duration > LONG_PRESS_THRESHOLD */
buttonState = BS_LONG_PRESS;
}
else
{
- if (!isPressed)
+ /* continue in same state */
+ }
+ }
+ else
{
+ /* Button 1 short press action */
Appli_ShortButtonPress();
+
+ buttonState = BS_OFF;
}
break;
+ case BS_LONG_PRESS:
+ if (isPressed)
+ {
+ /* Long press action */
+ Appli_IntensityControlPublishing();
}
- /* Case if Button is pressed for long duration */
- case BS_LONG_PRESS:
- if (!isPressed)
+ else
{
- Appli_LongButtonPress();
+ buttonState = BS_OFF;
}
break;
/* Default case */
@@ -201,10 +284,6 @@ static void Appli_UpdateButtonState(int isPressed)
buttonState = BS_OFF;
break;
}
- if (!isPressed)
- {
- buttonState = BS_OFF;
- }
}
/**
@@ -352,6 +431,7 @@ MOBLE_RESULT Appli_BleSetUUIDCb(MOBLEUINT8 *uuid_prefix_data)
memcpy(uuid_prefix_data,uuid_buff,sizeof(uuid_buff));
memcpy(&uuid_prefix_data[10],bdaddr,6); /* Copy bdaddr to last 6 bytes of UUID */
+
return MOBLE_RESULT_SUCCESS;
}
@@ -389,9 +469,13 @@ void Appli_BleGattConnectionCompleteCb(void)
{
ProvisionFlag = 1;
/* Proxy Node, will be called whenever Gatt connection is established */
+ /* Turn ON Red LED*/
ProxyFlag = 1;
-// BSP_LED_On(LED_GREEN);
-
+#if LOW_POWER_FEATURE
+ /* do nothing */
+#else
+ BSP_LED_On(LED_GREEN);
+#endif
}
/**
@@ -403,10 +487,13 @@ void Appli_BleGattDisconnectionCompleteCb(void)
{
ProvisionFlag = 0;
/* Proxy Node, will be called whenever Gatt disconnected */
-
+ /* Turn Off Red LED*/
ProxyFlag = 0;
-// BSP_LED_Off(LED_GREEN);
-
+#if LOW_POWER_FEATURE
+ /* do nothing */
+#else
+ BSP_LED_Off(LED_GREEN);
+#endif
}
/**
@@ -416,9 +503,10 @@ void Appli_BleGattDisconnectionCompleteCb(void)
*/
void Appli_BleUnprovisionedIdentifyCb(MOBLEUINT8 data)
{
-#ifndef DISABLE_TRACES
- printf("Unprovisioned Node Identifier received: %02x\n\r", data);
+#ifdef ENABLE_AUTH_TYPE_OUTPUT_OOB
+ PrvngInProcess = 1;
#endif
+ TRACE_M(TF_PROVISION,"Unprovisioned Node Identifier received: %02x\n\r", data);
}
/**
@@ -430,9 +518,7 @@ MOBLEUINT8 Appli_BleSetNumberOfElementsCb(void)
{
if(NumberOfElements > MAX_NUMB_ELEMENTS)
{
-#ifndef DISABLE_TRACES
- printf("Currently Three Elements per node are supported!\r\n");
-#endif
+ TRACE_M(TF_ELEMENTS,"Currently Three Elements per node are supported!\r\n");
return MAX_NUMB_ELEMENTS;
}
else
@@ -448,11 +534,97 @@ MOBLEUINT8 Appli_BleSetNumberOfElementsCb(void)
*/
MOBLE_RESULT Appli_BleAttentionTimerCb(void)
{
-#ifndef DISABLE_TRACES
- printf("Attention timer callback received \r\n");
+/* avoid printf, if low power feature is supported */
+#if (LOW_POWER_FEATURE == 0)
+ TRACE_M(TF_MISC, " \r\n");
+#endif /* LOW_POWER_FEATURE == 0 */
+ return MOBLE_RESULT_SUCCESS;
+}
+/**
+* @brief Call back function to give Output OOB information
+* @param MOBLEUINT8* output_oob
+* @param MOBLEUINT8 size
+* @retval void
+*/
+void Appli_BleOutputOOBAuthCb(MOBLEUINT8* output_oob, MOBLEUINT8 size)
+{
+#ifdef ENABLE_AUTH_TYPE_OUTPUT_OOB
+ uint32_t ooBData = 0;
+ for (MOBLEUINT8 i = 0; i < size; i++)
+ {
+ ooBData |= (output_oob[i] << 8*i);
+ }
+ OutputOobData = ooBData;
+ TRACE_M(TF_PROVISION,"Output OOB information for provisioner: %ld\n\r", ooBData);
#endif
+}
- return MOBLE_RESULT_SUCCESS;
+#ifdef ENABLE_AUTH_TYPE_OUTPUT_OOB
+/**
+* @brief Process for both output and Input OOB handling
+* @param void
+* @retval void
+*/
+void Appli_OobAuthenticationProcess(void)
+{
+ if(OutputOobBlinkCount < OutputOobData)
+ {
+ OutputOobBlinkCount++;
+ Appli_LedBlink();
+ }
+ else
+ {
+ OutputOobBlinkCount++;
+ Clock_Wait(1000);
+ if(OutputOobBlinkCount > OutputOobData+3)
+ {
+ OutputOobBlinkCount = 0;
+ }
+ }
+}
+#endif
+/**
+* @brief Call back function to provide Input OOB information
+* @param MOBLEUINT8 size
+* @retval MOBLEUINT8*
+*/
+
+MOBLEUINT8* Appli_BleInputOOBAuthCb(MOBLEUINT8 size)
+{
+#if defined (ENABLE_AUTH_TYPE_INPUT_OOB) && (ENABLE_SERIAL_INTERFACE)
+ MOBLEUINT16 inputTimer = 0;
+ TRACE_M(TF_PROVISION,"Input OOB information for provisioner-Size: %d\n\r", size);
+ while(1)
+ {
+ Serial_InterfaceProcess();
+ /* Check if input is completed or timeout */
+ if((inputOOBDataReady != 0x00) | (inputTimer > INPUT_OOB_TIMEOUT))
+ {
+ inputOOBDataReady = 0;
+ break;
+ }
+ Clock_Wait(100);
+ inputTimer++;
+ }
+ return InputOobData;
+#else
+ return NULL;
+#endif
+}
+/**
+* @brief Call back function to provide Input OOB information
+* @param rcvdStringBuff: buffer to store input string
+* @param rcvdStringSize: length of the input string
+* @retval void
+*/
+void Appli_BleSerialInputOOBValue(char *rcvdStringBuff, uint16_t rcvdStringSize)
+{
+#ifdef ENABLE_AUTH_TYPE_INPUT_OOB
+ unsigned long long InputOobDatatemp;
+ sscanf(rcvdStringBuff + 5, "%lld", &InputOobDatatemp);
+ memmove(&InputOobData, &InputOobDatatemp, sizeof(InputOobDatatemp));
+ inputOOBDataReady = 1;
+#endif
}
/**
@@ -493,11 +665,13 @@ void Appli_CheckForUnprovision(void)
if (!interrupted)
{
BLEMesh_Unprovision();
-#ifndef DISABLE_TRACES
- printf("Device is unprovisioned by application \r\n");
-#endif
+ AppliNvm_ClearModelState();
+ TRACE_M(TF_PROVISION,"Device is unprovisioned by application \r\n");
t = Clock_Time();
- while ((Clock_Time() - t) < FLASH_ERASE_TIME);
+ while ((Clock_Time() - t) < FLASH_ERASE_TIME)
+ {
+ BLEMesh_Process();
+ }
while (BSP_PB_GetState(BUTTON_SW1) == BUTTON_PRESSED)
{
@@ -514,18 +688,6 @@ void Appli_CheckForUnprovision(void)
}
/**
-* @brief Application processing
-* This function should be called in main loop
-* @param void
-* @retval void
-*/
-void Appli_Process(void)
-{
- Appli_UpdateButtonState(BSP_PB_GetState(BUTTON_SW1) == BUTTON_PRESSED);
-}
-
-
-/**
* @brief Checks and updates Mac address to generate MAC Address
* @param void
* @retval MOBLEUINT8 sum return the sum calculated mac
@@ -537,7 +699,7 @@ int Appli_CheckBdMacAddr(void)
#ifdef EXTERNAL_MAC_ADDR_MGMT
memcpy(bdaddr, (MOBLEUINT8 *)CFG_ADV_BD_ADDRESS, 7);
- bdaddr[7] = EXTERNAL_MAC_ADDR_MGMT;
+ bdaddr[7] = (EXTERNAL_MAC_ADDR_MGMT | EXTERNAL_MAC_TYPE);
#endif
#ifdef INTERNAL_UNIQUE_NUMBER_MAC
@@ -556,9 +718,13 @@ int Appli_CheckBdMacAddr(void)
result = 1;
}
-#ifdef GENERATE_STATIC_RANDOM_MAC
+#if defined(EXTERNAL_MAC_ADDR_MGMT) && defined(EXTERNAL_MAC_IS_PUBLIC_ADDR)
+ /* Do nothing for modification of 2 MSb */
+#else
bdaddr[5] |= 0xC0; /* 2 Msb bits shall be 11b for Static Random Address */
+#endif
+#ifdef GENERATE_STATIC_RANDOM_MAC
bdaddr[7] = GENERATE_STATIC_RANDOM_MAC;
/* Do nothing for bdaddr, just pass the identification */
result = 1; /* This will overwrite the above for loop result,
@@ -623,18 +789,38 @@ static void Appli_GetMACfromUniqueNumber(void)
#endif
+#if 0
+/**
+* @brief provides the information of the power saving mode
+* @param sleepMode curently unused, to be used in future
+* @retval SleepModes returns the mode of the controller
+*/
+SleepModes App_SleepMode_Check(SleepModes sleepMode)
+{
+ if (buttonState == BS_OFF)
+ {
+ return SLEEPMODE_WAKETIMER;
+ }
+ else
+ {
+ return SLEEPMODE_RUNNING;
+ }
+}
+#endif
+
/**
* @brief callback for unprovision the node by provisioner.
* @param status reserved for future
* @retval void
*/
-void BLEMesh_UnprovisionCallback(MOBLEUINT8 status)
+void BLEMesh_UnprovisionCallback(MOBLEUINT8 reason)
{
ProvisionFlag = 0;
-
-#ifndef DISABLE_TRACES
- printf("Device is unprovisioned by provisioner \n\r");
+ TRACE_M(TF_PROVISION,"Device is unprovisioned by provisioner \n\r");
+#if PB_ADV_SUPPORTED
+ BLEMesh_SetUnprovisionedDevBeaconInterval(100);
#endif
+ AppliNvm_ClearModelState();
}
/**
@@ -645,9 +831,10 @@ void BLEMesh_UnprovisionCallback(MOBLEUINT8 status)
void BLEMesh_ProvisionCallback(void)
{
ProvisionFlag = 1;
-#ifndef DISABLE_TRACES
- printf("Device is provisioned by provisioner \r\n");
+#ifdef ENABLE_AUTH_TYPE_OUTPUT_OOB
+ PrvngInProcess = 0;
#endif
+ TRACE_M(TF_PROVISION,"Device is provisioned by provisioner \r\n");
}
/**
@@ -868,6 +1055,223 @@ void BLEMesh_NeighborRefreshedCallback(const MOBLEUINT8* bdAddr,
}
/**
+* @brief Appli_IntensityControl:Function to increase the intensity of led by
+* Publishing the value.
+* @param void
+*/
+void Appli_IntensityControlPublishing(void)
+{
+ MOBLEUINT8 generic_Level_Buff[3];
+ MOBLE_ADDRESS publishAddress;
+ MOBLEUINT8 elementNumber;
+ MOBLEUINT8 elementIndex;
+
+ /*Select the Element Number for which publication address is required*/
+
+ if (NumberOfElements == 1)
+ {
+ elementNumber = 0x01;
+ }
+
+ else if(NumberOfElements == 2)
+ {
+ elementNumber = 0x02; /*Element 2 is configured as switch*/
+ }
+
+ else if(NumberOfElements == 3)
+ {
+ elementNumber = 0x03; /*Element 3 is configured as switch*/
+ }
+
+ else
+ {
+ elementNumber = 0x01;
+ }
+
+ publishAddress = BLEMesh_GetPublishAddress(elementNumber);
+ elementIndex = elementNumber-1;
+
+ TRACE_M(TF_MISC,"IntensityFlag %d\n\r", IntensityFlag);
+
+ if(IntensityFlag == FALSE)
+ {
+
+ IntensityValue = IntensityValue + (INTENSITY_LEVEL_FULL/5);
+ generic_Level_Buff[0] = (MOBLEUINT8)IntensityValue;
+ generic_Level_Buff[1] = (MOBLEUINT8)(IntensityValue >> 8) ;
+
+ TRACE_M(TF_MISC,"IntensityValue %d\n\r", IntensityValue);
+
+ BLEMesh_SetRemoteData(publishAddress, elementIndex, GENERIC_LEVEL_SET_UNACK ,
+ generic_Level_Buff,3, MOBLE_FALSE, MOBLE_FALSE);
+
+ if(IntensityValue >= INTENSITY_LEVEL_FULL)
+ {
+ IntensityFlag = TRUE;
+ }
+
+ }
+ else
+ {
+
+ IntensityValue = IntensityValue - (INTENSITY_LEVEL_FULL/5);
+ generic_Level_Buff[0] = (MOBLEUINT8)IntensityValue;
+ generic_Level_Buff[1] = (MOBLEUINT8)(IntensityValue >> 8) ;
+
+ TRACE_M(TF_MISC,"IntensityValue %d\n\r", IntensityValue);
+
+ BLEMesh_SetRemoteData(publishAddress, elementIndex, GENERIC_LEVEL_SET_UNACK,
+ generic_Level_Buff, 3, MOBLE_FALSE, MOBLE_FALSE);
+
+ if(IntensityValue <= INTENSITY_LEVEL_ZERO)
+ {
+ IntensityFlag = FALSE;
+ }
+
+ }
+}
+
+/**
+* @brief Low Power mode process
+* If low power feature is supported, device enables low power mode
+* @param void
+* @retval void
+*/
+void Appli_LowPowerProcess(void)
+{
+#if 0
+#if LOW_POWER_FEATURE
+ BluenrgMesh_sleepTime = (MOBLEINT32)BluenrgMesh_GetSleepDuration();
+
+ if (BluenrgMesh_sleepTime > 0)
+ {
+ /* Timer 0 used for low power */
+ HAL_VTimerStart_ms(0, BluenrgMesh_sleepTime);
+
+ /* To start virtual timer */
+ BTLE_StackTick();
+
+ /* save virtual timer current count */
+ SysRefCount = HAL_VTimerGetCurrentTime_sysT32();
+
+ /* wakeup either from io or virtual timer */
+ BlueNRG_Sleep(SLEEPMODE_WAKETIMER, WAKEUP_IO13, WAKEUP_IOx_LOW);
+
+ /* update systick count based on updated virtual timer count */
+ Set_Clock_Time(Clock_Time() +
+ HAL_VTimerDiff_ms_sysT32(HAL_VTimerGetCurrentTime_sysT32(), SysRefCount));
+
+ /* Stop Timer 0 */
+ HAL_VTimer_Stop(0);
+ }
+#endif /* LOW_POWER_FEATURE */
+#endif
+}
+
+/**
+* @brief Application processing
+* This function should be called in main loop
+* @param void
+* @retval void
+*/
+void Appli_Process(void)
+{
+ Appli_UpdateButtonState(BSP_PB_GetState(BUTTON_SW1) == BUTTON_PRESSED);
+
+ Appli_LowPowerProcess();
+
+#ifdef ENABLE_AUTH_TYPE_OUTPUT_OOB
+ if(PrvngInProcess)
+ {
+#if USER_OUTPUT_OOB_APPLI_PROCESS
+ Appli_OobAuthenticationProcess();
+#endif
+ }
+#endif
+#ifdef ENABLE_SAVE_MODEL_STATE_NVM
+ AppliNvm_Process();
+#endif
+
+}
+
+#if PB_ADV_SUPPORTED
+static void UnprovisionedDeviceBeaconApp(void)
+{
+ BLEMesh_SetUnprovisionedDevBeaconInterval(0);
+}
+
+static void UnprovisionedDeviceBeaconTask(void)
+{
+ /**
+ * The code shall be executed in the background as aci command may be sent
+ * The background is the only place where the application can make sure a new aci command
+ * is not sent if there is a pending one
+ */
+ UTIL_SEQ_SetTask( 1<<CFG_TASK_MESH_BEACON_REQ_ID, CFG_SCH_PRIO_0);
+
+ return;
+}
+#endif
+
+#ifdef SAVE_MODEL_STATE_POWER_FAILURE_DETECTION
+/**
+* @brief function to inintiallise the GPIO interrupt fot Power down
+* @param void
+* @retval void
+*/
+static void GPIO_InitNVICPowerOff(void)
+{
+ GPIO_InitTypeDef gpioinitstruct = {0};
+
+ /* Enable the PowerOff GPIO Clock */
+ POWEROFF_GPIO_CLK_ENABLE();
+
+ /* Configure PowerOff pin as input with External interrupt */
+ gpioinitstruct.Pin = POWEROFF_PIN;
+ gpioinitstruct.Pull = GPIO_PULLUP;
+ gpioinitstruct.Mode = GPIO_MODE_IT_FALLING;
+ HAL_GPIO_Init(POWEROFF_GPIO_PORT, &gpioinitstruct);
+
+ /* Enable and set PowerOff EXTI Interrupt to the lowest priority */
+ HAL_NVIC_SetPriority((IRQn_Type)(POWEROFF_EXTI_IRQn), 0x0F, 0x00);
+ HAL_NVIC_EnableIRQ((IRQn_Type)(POWEROFF_EXTI_IRQn));
+}
+#endif
+
+/**
+* @brief Initializes the Application
+* @param void
+* @retval void
+*/
+void Appli_Init(void)
+{
+#ifdef ENABLE_UNPROVISIONING_BY_POWER_ONOFF_CYCLE
+ /* Hardware Factory Restore implementation */
+ AppliNvm_FactorySettingReset();
+#endif
+
+#if PB_ADV_SUPPORTED
+ UTIL_SEQ_RegTask( 1<< CFG_TASK_MESH_BEACON_REQ_ID, UTIL_SEQ_RFU, UnprovisionedDeviceBeaconApp );
+ /**
+ * Create Timer to control unprovisioned device beacons
+ */
+ HW_TS_Create(CFG_TIM_PROC_ID_ISR, &discoverTimer_Id, hw_ts_SingleShot, UnprovisionedDeviceBeaconTask);
+
+ HW_TS_Start(discoverTimer_Id, DISCOVER_TIMER_INTERVAL);
+#endif
+#if ENABLE_SERIAL_INTERFACE
+ Serial_Init();
+#endif
+#ifdef SAVE_MODEL_STATE_POWER_FAILURE_DETECTION
+ GPIO_InitNVICPowerOff();
+#endif
+
+ __HAL_RCC_TIM1_CLK_ENABLE();
+ __HAL_RCC_TIM2_CLK_ENABLE();
+ PWM_Init();
+}
+
+/**
* @}
*/