le_ips_interface.h

Go to the documentation of this file.
1 
2 
3 /*
4  * ====================== WARNING ======================
5  *
6  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
7  * DO NOT MODIFY IN ANY WAY.
8  *
9  * ====================== WARNING ======================
10  */
11 
12 /**
13  * @page c_ips Input Power Supply Monitoring API
14  *
15  * @ref le_ips_interface.h "API Reference"
16  *
17  * <HR>
18  *
19  * The IPS API is used to get monitoring information related to the platform power supply and set
20  * warning and critical thresholds.
21  *
22  * @section le_ips_binding IPC interfaces binding
23  *
24  * All the functions of this API are provided by the @b modemService.
25  *
26  * Here's a code sample binding to modem services:
27  * @verbatim
28  bindings:
29  {
30  clientExe.clientComponent.le_ips -> modemService.le_ips
31  }
32  @endverbatim
33  *
34  * @section le_ips_powerMonitoring Input power supply monitoring
35  *
36  * This functionality allows to retrieve data related to the platform power supply, so that
37  * the application can use the information to diagnose why the modem isn't fully functioning.
38  *
39  * The application can retrieve the following power supply information:
40  * - le_ips_GetInputVoltage() API gives the Platform voltage input.
41  * - le_ips_GetPowerSource() API gives the power source used by the Platform:
42  * - @ref LE_IPS_POWER_SOURCE_EXTERNAL for an external power source
43  * - @ref LE_IPS_POWER_SOURCE_BATTERY for a battery.
44  * - le_ips_GetBatteryLevel() API gives the Platform battery level.
45  *
46  * In case the device is powered by an external battery monitored by an application, this
47  * application can set the battery level with the le_ips_SetBatteryLevel() API. This value will
48  * then be used when the battery level is requested through the le_ips_GetBatteryLevel() API.
49  *
50  * @note The value set by le_ips_SetBatteryLevel() will be reported by le_ips_GetBatteryLevel()
51  * until Legato is restarted.
52  *
53  * @section le_ips_voltageThresholds Platform input voltage thresholds
54  *
55  * @warning When a critical event occurs, some platform may automatically switch off.
56  *
57  * @warning On some platforms, the thresholds parameters are persistent and a platform reboot is
58  * required for thresholds change takes effect.
59  *
60  * Four thresholds are set to decide the state: the @e critical, @e warning, @e normal and
61  * <em>high critical</em> platform input voltage thresholds.
62  *
63  * if the platform input voltage decreases below the:
64  * - "High critical threshold - 1 " but still higher than "Warning threshold",
65  * @c LE_IPS_VOLTAGE_NORMAL event occurs.
66  * - "Warning threshold" but still higher than "Critical threshold",
67  * @c LE_IPS_VOLTAGE_WARNING event occurs.
68  * - "Critical threshold", a @c LE_IPS_VOLTAGE_CRITICAL event occurs.
69  *
70  * if the platform input voltage goes up and it reaches the:
71  * - "Normal threshold", a @c LE_IPS_VOLTAGE_NORMAL event occurs.
72  * - "High critical thresholds", a @c LE_IPS_HI_VOLTAGE_CRITICAL event occurs.
73  *
74  * @note The threshold values range is platform dependent.
75  *
76  * - le_ips_SetVoltageThresholds() API allows the application to set platform input voltage
77  * thresholds.
78  * - le_ips_GetVoltageThresholds() API allows the application to get platform input voltage
79  * thresholds.
80  * - le_ips_AddThresholdEventHandler() API adds a handler to notify when the platform input voltage
81  * threshold is reached.
82  * - le_ips_RemoveThresholdEventHandler() API removes the platform input voltage handler.
83  *
84  * <HR>
85  *
86  * Copyright (C) Sierra Wireless Inc.
87  */
88 /**
89  * @file le_ips_interface.h
90  *
91  * Legato @ref c_ips include file.
92  *
93  * Copyright (C) Sierra Wireless Inc.
94  */
95 
96 #ifndef LE_IPS_INTERFACE_H_INCLUDE_GUARD
97 #define LE_IPS_INTERFACE_H_INCLUDE_GUARD
98 
99 
100 #include "legato.h"
101 
102 // Internal includes for this interface
103 #include "le_ips_common.h"
104 /** @addtogroup le_ips le_ips API Reference
105  * @{
106  * @file le_ips_common.h
107  * @file le_ips_interface.h **/
108 //--------------------------------------------------------------------------------------------------
109 /**
110  * Type for handler called when a server disconnects.
111  */
112 //--------------------------------------------------------------------------------------------------
113 typedef void (*le_ips_DisconnectHandler_t)(void *);
114 
115 //--------------------------------------------------------------------------------------------------
116 /**
117  *
118  * Connect the current client thread to the service providing this API. Block until the service is
119  * available.
120  *
121  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
122  * called before any other functions in this API. Normally, ConnectService is automatically called
123  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
124  *
125  * This function is created automatically.
126  */
127 //--------------------------------------------------------------------------------------------------
129 (
130  void
131 );
132 
133 //--------------------------------------------------------------------------------------------------
134 /**
135  *
136  * Try to connect the current client thread to the service providing this API. Return with an error
137  * if the service is not available.
138  *
139  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
140  * called before any other functions in this API. Normally, ConnectService is automatically called
141  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
142  *
143  * This function is created automatically.
144  *
145  * @return
146  * - LE_OK if the client connected successfully to the service.
147  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
148  * bound.
149  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
150  * - LE_COMM_ERROR if the Service Directory cannot be reached.
151  */
152 //--------------------------------------------------------------------------------------------------
154 (
155  void
156 );
157 
158 //--------------------------------------------------------------------------------------------------
159 /**
160  * Set handler called when server disconnection is detected.
161  *
162  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
163  * to continue without exiting, it should call longjmp() from inside the handler.
164  */
165 //--------------------------------------------------------------------------------------------------
167 (
168  le_ips_DisconnectHandler_t disconnectHandler,
169  void *contextPtr
170 );
171 
172 //--------------------------------------------------------------------------------------------------
173 /**
174  *
175  * Disconnect the current client thread from the service providing this API.
176  *
177  * Normally, this function doesn't need to be called. After this function is called, there's no
178  * longer a connection to the service, and the functions in this API can't be used. For details, see
179  * @ref apiFilesC_client.
180  *
181  * This function is created automatically.
182  */
183 //--------------------------------------------------------------------------------------------------
185 (
186  void
187 );
188 
189 
190 //--------------------------------------------------------------------------------------------------
191 /**
192  * Platform input voltage event type.
193  */
194 //--------------------------------------------------------------------------------------------------
195 
196 
197 //--------------------------------------------------------------------------------------------------
198 /**
199  * Platform power source type.
200  */
201 //--------------------------------------------------------------------------------------------------
202 
203 
204 //--------------------------------------------------------------------------------------------------
205 /**
206  * Handler for Platform input voltage event.
207  */
208 //--------------------------------------------------------------------------------------------------
209 
210 
211 //--------------------------------------------------------------------------------------------------
212 /**
213  * Reference type used by Add/Remove functions for EVENT 'le_ips_ThresholdEvent'
214  */
215 //--------------------------------------------------------------------------------------------------
216 
217 
218 //--------------------------------------------------------------------------------------------------
219 /**
220  * Add handler function for EVENT 'le_ips_ThresholdEvent'
221  *
222  * This event provides information on Threshold reached.
223  *
224  */
225 //--------------------------------------------------------------------------------------------------
227 (
229  ///< [IN]
230  void* contextPtr
231  ///< [IN]
232 );
233 
234 //--------------------------------------------------------------------------------------------------
235 /**
236  * Remove handler function for EVENT 'le_ips_ThresholdEvent'
237  */
238 //--------------------------------------------------------------------------------------------------
240 (
242  ///< [IN]
243 );
244 
245 //--------------------------------------------------------------------------------------------------
246 /**
247  * Get the Platform input voltage in [mV].
248  *
249  * @return
250  * - LE_OK The function succeeded.
251  * - LE_FAULT The function failed to get the value.
252  *
253  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
254  * function will not return.
255  */
256 //--------------------------------------------------------------------------------------------------
258 (
259  uint32_t* inputVoltagePtr
260  ///< [OUT] [OUT] The input voltage in [mV]
261 );
262 
263 //--------------------------------------------------------------------------------------------------
264 /**
265  * Set the Platform warning and critical input voltage thresholds in [mV].
266  * When thresholds input voltage are reached, a input voltage event is triggered.
267  *
268  * @return
269  * - LE_OK The function succeeded.
270  * - LE_BAD_PARAMETER The hiCriticalVolt threshold is equal or lower than the (normalVolt+1)
271  * threshold.
272  * The warningVolt threshold is equal to or higher than the normalVolt
273  * threshold.
274  * The warningVolt threshold is equal to or lower than the criticalVolt
275  * threshold.
276  * - LE_FAULT The function failed to set the thresholds.
277  */
278 //--------------------------------------------------------------------------------------------------
280 (
281  uint16_t criticalVolt,
282  ///< [IN] [IN] The critical input voltage threshold in [mV].
283  uint16_t warningVolt,
284  ///< [IN] [IN] The warning input voltage threshold in [mV].
285  uint16_t normalVolt,
286  ///< [IN] [IN] The normal input voltage threshold in [mV].
287  uint16_t hiCriticalVolt
288  ///< [IN] [IN] The high critical input voltage threshold in [mV].
289 );
290 
291 //--------------------------------------------------------------------------------------------------
292 /**
293  * Get the Platform warning and critical input voltage thresholds in [mV].
294  *
295  * @return
296  * - LE_OK The function succeeded.
297  * - LE_FAULT The function failed to get the thresholds.
298  *
299  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
300  * function will not return.
301  */
302 //--------------------------------------------------------------------------------------------------
304 (
305  uint16_t* criticalVoltPtr,
306  ///< [OUT] [OUT] The critical input voltage threshold in [mV].
307  uint16_t* warningVoltPtr,
308  ///< [OUT] [OUT] The warning input voltage threshold in [mV].
309  uint16_t* normalVoltPtr,
310  ///< [OUT] [OUT] The normal input voltage threshold in [mV].
311  uint16_t* hiCriticalVoltPtr
312  ///< [OUT] [IN] The high critical input voltage threshold in [mV].
313 );
314 
315 //--------------------------------------------------------------------------------------------------
316 /**
317  * Get the Platform power source.
318  *
319  * @return
320  * - LE_OK The function succeeded.
321  * - LE_FAULT The function failed to get the value.
322  *
323  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
324  * function will not return.
325  */
326 //--------------------------------------------------------------------------------------------------
328 (
329  le_ips_PowerSource_t* powerSourcePtr
330  ///< [OUT] [OUT] The power source.
331 );
332 
333 //--------------------------------------------------------------------------------------------------
334 /**
335  * Get the Platform battery level in percent:
336  * - 0: battery is exhausted or platform does not have a battery connected
337  * - 1 to 100: percentage of battery capacity remaining
338  *
339  * @return
340  * - LE_OK The function succeeded.
341  * - LE_FAULT The function failed to get the value.
342  *
343  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
344  * function will not return.
345  */
346 //--------------------------------------------------------------------------------------------------
348 (
349  uint8_t* batteryLevelPtr
350  ///< [OUT] [OUT] The battery level in percent.
351 );
352 
353 //--------------------------------------------------------------------------------------------------
354 /**
355  * Set the Platform battery level in percent.
356  * This is useful when an external battery is used and its level is provided by the application
357  * monitoring it.
358  *
359  * @note The battery level set through this API will be the value reported by
360  * le_ips_GetBatteryLevel() until Legato is restarted.
361  *
362  * @return
363  * - LE_OK The function succeeded.
364  * - LE_BAD_PARAMETER Incorrect battery level provided.
365  */
366 //--------------------------------------------------------------------------------------------------
368 (
369  uint8_t batteryLevel
370  ///< [IN] [IN] The battery level in percent.
371 );
372 
373 /** @} **/
374 
375 #endif // LE_IPS_INTERFACE_H_INCLUDE_GUARD
le_ips_ThresholdEventHandlerRef_t le_ips_AddThresholdEventHandler(le_ips_ThresholdEventHandlerFunc_t handlerPtr, void *contextPtr)
le_result_t le_ips_TryConnectService(void)
le_result_t le_ips_GetInputVoltage(uint32_t *inputVoltagePtr)
le_result_t
Definition: le_basics.h:46
void le_ips_DisconnectService(void)
void(* le_ips_ThresholdEventHandlerFunc_t)(le_ips_ThresholdStatus_t event, void *contextPtr)
Definition: le_ips_common.h:76
void le_ips_ConnectService(void)
void(* le_ips_DisconnectHandler_t)(void *)
Definition: le_ips_interface.h:113
void le_ips_RemoveThresholdEventHandler(le_ips_ThresholdEventHandlerRef_t handlerRef)
le_result_t le_ips_GetVoltageThresholds(uint16_t *criticalVoltPtr, uint16_t *warningVoltPtr, uint16_t *normalVoltPtr, uint16_t *hiCriticalVoltPtr)
LE_FULL_API void le_ips_SetServerDisconnectHandler(le_ips_DisconnectHandler_t disconnectHandler, void *contextPtr)
le_ips_PowerSource_t
Definition: le_ips_common.h:52
#define LE_FULL_API
Definition: le_apiFeatures.h:40
le_result_t le_ips_GetPowerSource(le_ips_PowerSource_t *powerSourcePtr)
le_result_t le_ips_SetBatteryLevel(uint8_t batteryLevel)
le_result_t le_ips_SetVoltageThresholds(uint16_t criticalVolt, uint16_t warningVolt, uint16_t normalVolt, uint16_t hiCriticalVolt)
struct le_ips_ThresholdEventHandler * le_ips_ThresholdEventHandlerRef_t
Definition: le_ips_common.h:67
le_result_t le_ips_GetBatteryLevel(uint8_t *batteryLevelPtr)