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

appli_light_lc.c « app « STM32_WPAN « BLE_MeshLightingLPN « BLE « Applications « P-NUCLEO-WB55.USBDongle « Projects - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a7d123c9190b0d3049b38c31ba73f32636e4f53e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/**
  ******************************************************************************
  * @file    appli_light_lc.c
  * @author  BLE Mesh Team
  * @brief   Application interface for light LC Mesh Models 
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                             www.st.com/SLA0044
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "hal_common.h"
#include "types.h"
#include "appli_generic.h"
#include "appli_light.h"
#include "common.h"
#include "mesh_cfg_usr.h"
#include "appli_light_lc.h"

/** @addtogroup ST_BLE_Mesh
*  @{
*/

/** @addtogroup Application_Mesh_Models
*  @{
*/

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variable ----------------------------------------------------------*/

Appli_LightLC_Set_t Appli_LightLC_set;
Appli_Light_LC_PropertySet_t Appli_LightLC_PropertySet; 

MOBLEUINT16 AmbientLuxLevel;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/**
* @brief  Appli_Light_LCMode_Set: This function is callback for Application
*         when Light LC mode Set message is received
* @param  pLight_LC_Param: Pointer to the parameters received for message
* @param  OptionalValid: Flag to inform about the validity of optional parameters 
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT Appli_LightLC_Mode_Set(Light_LC_Param_t* pLight_LC_Param,
                                                     MOBLEUINT8 OptionalValid)
{
  Appli_LightLC_set.LC_mode = pLight_LC_Param->LC_mode;
  TRACE_M(TF_SERIAL_CTRL,"Mode Set: %d\n\r",
          pLight_LC_Param->LC_mode);
  return MOBLE_RESULT_SUCCESS;
}
  
/**
* @brief  Appli_LightLC_OM_Set: This function is callback for Application
*         when Light LC mode Occupancy Model Set message is received
* @param  pLight_LC_Param: Pointer to the parameters received for message
* @param  OptionalValid: Flag to inform about the validity of optional parameters 
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT Appli_LightLC_OM_Set(Light_LC_Param_t* pLight_LC_Param,
                                                     MOBLEUINT8 OptionalValid)
{
  Appli_LightLC_set.LC_OM = pLight_LC_Param->LC_OM;
  TRACE_M(TF_SERIAL_CTRL,"OM Set: %d\n\r",
          pLight_LC_Param->LC_OM);
  return MOBLE_RESULT_SUCCESS;
}  

/**
* @brief  Appli_LightLC_OnOff_Set: This function is callback for Application
*         when Light LC On Off Set message is received
* @param  pLight_LC_Param: Pointer to the parameters received for message
* @param  OptionalValid: Flag to inform about the validity of optional parameters 
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT Appli_LightLC_OnOff_Set(Light_LC_Param_t* pLight_LC_Param,
                                                     MOBLEUINT8 OptionalValid)
{
  Appli_LightLC_set.Light_OnOffState = pLight_LC_Param->Present_Light_OnOff;
  TRACE_M(TF_SERIAL_CTRL,"OnOff Set: %d\n\r",
          pLight_LC_Param->Present_Light_OnOff);
  return MOBLE_RESULT_SUCCESS;
}  

/**
* @brief Get_AmbientLuxLevelOutput: This function is given to calculate the Ambient 
         Lux level output from the ambient sensor.
* @param void:
* @retval MOBLEUINT16:    
**/
MOBLEUINT16 Appli_LightLC_Get_AmbientLuxLevelOutput(void)
{
  /* Use AmbientLuxLevel global variable to store the value from ambient lux sensor
     and then use this value to copmpare the lux level output from state machine.
   */
  
  return AmbientLuxLevel;
}

/**
* @brief Light_LC_LuxLevelPIRegulator: This function will calculate all the parameter
*        Kid,kpu,kiu,kpd and return the value Light Lightness Linear.           
* @param tableLuxLevel:
* @param ambientLuxLevel:
* @retval MOBLEUINT16:    
**/
MOBLEUINT16 Appli_Light_LC_PIRegulatorOutput(MOBLEUINT16 tableLuxLevel,MOBLEUINT16 ambientLuxLevel)
{
  MOBLEUINT16 luxLevel = 0;
  /* User can write their code for the calculation */
  
  
  return luxLevel;
}

/**
* @brief  Appli_LightLC_Get_ModeStatus: This function is callback for Application
*         to get the application values in middleware used for transition change.
* @param  plcModeState: Pointer to the status message
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT Appli_LightLC_Get_ModeStatus(MOBLEUINT8* plcModeState)
{  
  *(plcModeState) = Appli_LightLC_set.LC_mode;
  TRACE_M(TF_SERIAL_CTRL,"Get Mode Status: %d\n\r",
          Appli_LightLC_set.LC_mode);
  
  return MOBLE_RESULT_SUCCESS;
}  

/**
* @brief  Appli_LightLC_Get_OMModeStatus: This function is callback for Application
*         to get the application values in middleware used for transition change.
* @param  plcOM_ModeState: Pointer to the status message
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT Appli_LightLC_Get_OMModeStatus(MOBLEUINT8* plcOM_ModeState)
{  
  *(plcOM_ModeState) = Appli_LightLC_set.LC_OM;
  TRACE_M(TF_SERIAL_CTRL,"Get OM Mode Status: %d\n\r",
          Appli_LightLC_set.LC_OM);
  
  return MOBLE_RESULT_SUCCESS;
}  

/**
* @brief  Appli_LightLC_Get_OnOffStatus: This function is callback for Application
*         to get the application values in middleware used for transition change.
* @param  plcOnOffState: Pointer to the status message
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT Appli_LightLC_Get_OnOffStatus(MOBLEUINT8* plcOnOffState)
{  
  *(plcOnOffState) = Appli_LightLC_set.Light_OnOffState;
  *(plcOnOffState+1) = Appli_LightLC_set.Light_OnOffState;
  *(plcOnOffState+2) = Appli_LightLC_set.Light_OnOffState;
  TRACE_M(TF_SERIAL_CTRL,"Get On Off Status: %d\n\r",
          Appli_LightLC_set.Light_OnOffState);
  
  return MOBLE_RESULT_SUCCESS;
}  


/**
* @}
*/

/**
* @}
*/

/******************* (C) COPYRIGHT 2017 STMicroelectronics *****END OF FILE****/