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 //--------------------------------------------------------------------------------------------------
105 /**
106  * Type for handler called when a server disconnects.
107  */
108 //--------------------------------------------------------------------------------------------------
109 typedef void (*le_ips_DisconnectHandler_t)(void *);
110 
111 //--------------------------------------------------------------------------------------------------
112 /**
113  *
114  * Connect the current client thread to the service providing this API. Block until the service is
115  * available.
116  *
117  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
118  * called before any other functions in this API. Normally, ConnectService is automatically called
119  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
120  *
121  * This function is created automatically.
122  */
123 //--------------------------------------------------------------------------------------------------
125 (
126  void
127 );
128 
129 //--------------------------------------------------------------------------------------------------
130 /**
131  *
132  * Try to connect the current client thread to the service providing this API. Return with an error
133  * if the service is not available.
134  *
135  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
136  * called before any other functions in this API. Normally, ConnectService is automatically called
137  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
138  *
139  * This function is created automatically.
140  *
141  * @return
142  * - LE_OK if the client connected successfully to the service.
143  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
144  * bound.
145  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
146  * - LE_COMM_ERROR if the Service Directory cannot be reached.
147  */
148 //--------------------------------------------------------------------------------------------------
150 (
151  void
152 );
153 
154 //--------------------------------------------------------------------------------------------------
155 /**
156  * Set handler called when server disconnection is detected.
157  *
158  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
159  * to continue without exiting, it should call longjmp() from inside the handler.
160  */
161 //--------------------------------------------------------------------------------------------------
163 (
164  le_ips_DisconnectHandler_t disconnectHandler,
165  void *contextPtr
166 );
167 
168 //--------------------------------------------------------------------------------------------------
169 /**
170  *
171  * Disconnect the current client thread from the service providing this API.
172  *
173  * Normally, this function doesn't need to be called. After this function is called, there's no
174  * longer a connection to the service, and the functions in this API can't be used. For details, see
175  * @ref apiFilesC_client.
176  *
177  * This function is created automatically.
178  */
179 //--------------------------------------------------------------------------------------------------
181 (
182  void
183 );
184 
185 
186 //--------------------------------------------------------------------------------------------------
187 /**
188  * Platform input voltage event type.
189  */
190 //--------------------------------------------------------------------------------------------------
191 
192 
193 //--------------------------------------------------------------------------------------------------
194 /**
195  * Platform power source type.
196  */
197 //--------------------------------------------------------------------------------------------------
198 
199 
200 //--------------------------------------------------------------------------------------------------
201 /**
202  * Handler for Platform input voltage event.
203  */
204 //--------------------------------------------------------------------------------------------------
205 
206 
207 //--------------------------------------------------------------------------------------------------
208 /**
209  * Reference type used by Add/Remove functions for EVENT 'le_ips_ThresholdEvent'
210  */
211 //--------------------------------------------------------------------------------------------------
212 
213 
214 //--------------------------------------------------------------------------------------------------
215 /**
216  * Add handler function for EVENT 'le_ips_ThresholdEvent'
217  *
218  * This event provides information on Threshold reached.
219  *
220  */
221 //--------------------------------------------------------------------------------------------------
222 le_ips_ThresholdEventHandlerRef_t le_ips_AddThresholdEventHandler
223 (
224  le_ips_ThresholdEventHandlerFunc_t handlerPtr,
225  ///< [IN]
226  void* contextPtr
227  ///< [IN]
228 );
229 
230 //--------------------------------------------------------------------------------------------------
231 /**
232  * Remove handler function for EVENT 'le_ips_ThresholdEvent'
233  */
234 //--------------------------------------------------------------------------------------------------
236 (
237  le_ips_ThresholdEventHandlerRef_t handlerRef
238  ///< [IN]
239 );
240 
241 //--------------------------------------------------------------------------------------------------
242 /**
243  * Get the Platform input voltage in [mV].
244  *
245  * @return
246  * - LE_OK The function succeeded.
247  * - LE_FAULT The function failed to get the value.
248  *
249  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
250  * function will not return.
251  */
252 //--------------------------------------------------------------------------------------------------
254 (
255  uint32_t* inputVoltagePtr
256  ///< [OUT] [OUT] The input voltage in [mV]
257 );
258 
259 //--------------------------------------------------------------------------------------------------
260 /**
261  * Set the Platform warning and critical input voltage thresholds in [mV].
262  * When thresholds input voltage are reached, a input voltage event is triggered.
263  *
264  * @return
265  * - LE_OK The function succeeded.
266  * - LE_BAD_PARAMETER The hiCriticalVolt threshold is equal or lower than the (normalVolt+1)
267  * threshold.
268  * The warningVolt threshold is equal to or higher than the normalVolt
269  * threshold.
270  * The warningVolt threshold is equal to or lower than the criticalVolt
271  * threshold.
272  * - LE_FAULT The function failed to set the thresholds.
273  */
274 //--------------------------------------------------------------------------------------------------
276 (
277  uint16_t criticalVolt,
278  ///< [IN] [IN] The critical input voltage threshold in [mV].
279  uint16_t warningVolt,
280  ///< [IN] [IN] The warning input voltage threshold in [mV].
281  uint16_t normalVolt,
282  ///< [IN] [IN] The normal input voltage threshold in [mV].
283  uint16_t hiCriticalVolt
284  ///< [IN] [IN] The high critical input voltage threshold in [mV].
285 );
286 
287 //--------------------------------------------------------------------------------------------------
288 /**
289  * Get the Platform warning and critical input voltage thresholds in [mV].
290  *
291  * @return
292  * - LE_OK The function succeeded.
293  * - LE_FAULT The function failed to get the thresholds.
294  *
295  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
296  * function will not return.
297  */
298 //--------------------------------------------------------------------------------------------------
300 (
301  uint16_t* criticalVoltPtr,
302  ///< [OUT] [OUT] The critical input voltage threshold in [mV].
303  uint16_t* warningVoltPtr,
304  ///< [OUT] [OUT] The warning input voltage threshold in [mV].
305  uint16_t* normalVoltPtr,
306  ///< [OUT] [OUT] The normal input voltage threshold in [mV].
307  uint16_t* hiCriticalVoltPtr
308  ///< [OUT] [IN] The high critical input voltage threshold in [mV].
309 );
310 
311 //--------------------------------------------------------------------------------------------------
312 /**
313  * Get the Platform power source.
314  *
315  * @return
316  * - LE_OK The function succeeded.
317  * - LE_FAULT The function failed to get the value.
318  *
319  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
320  * function will not return.
321  */
322 //--------------------------------------------------------------------------------------------------
324 (
325  le_ips_PowerSource_t* powerSourcePtr
326  ///< [OUT] [OUT] The power source.
327 );
328 
329 //--------------------------------------------------------------------------------------------------
330 /**
331  * Get the Platform battery level in percent:
332  * - 0: battery is exhausted or platform does not have a battery connected
333  * - 1 to 100: percentage of battery capacity remaining
334  *
335  * @return
336  * - LE_OK The function succeeded.
337  * - LE_FAULT The function failed to get the value.
338  *
339  * @note If the caller is passing a bad pointer into this function, it is a fatal error, the
340  * function will not return.
341  */
342 //--------------------------------------------------------------------------------------------------
344 (
345  uint8_t* batteryLevelPtr
346  ///< [OUT] [OUT] The battery level in percent.
347 );
348 
349 //--------------------------------------------------------------------------------------------------
350 /**
351  * Set the Platform battery level in percent.
352  * This is useful when an external battery is used and its level is provided by the application
353  * monitoring it.
354  *
355  * @note The battery level set through this API will be the value reported by
356  * le_ips_GetBatteryLevel() until Legato is restarted.
357  *
358  * @return
359  * - LE_OK The function succeeded.
360  * - LE_BAD_PARAMETER Incorrect battery level provided.
361  */
362 //--------------------------------------------------------------------------------------------------
364 (
365  uint8_t batteryLevel
366  ///< [IN] [IN] The battery level in percent.
367 );
368 
369 #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_GetInputVoltage(uint32_t *inputVoltagePtr)
void le_ips_ConnectService(void)
le_result_t le_ips_GetPowerSource(le_ips_PowerSource_t *powerSourcePtr)
void le_ips_RemoveThresholdEventHandler(le_ips_ThresholdEventHandlerRef_t handlerRef)
le_result_t
Definition: le_basics.h:45
le_result_t le_ips_GetBatteryLevel(uint8_t *batteryLevelPtr)
void(* le_ips_DisconnectHandler_t)(void *)
Definition: le_ips_interface.h:109
LE_FULL_API void le_ips_SetServerDisconnectHandler(le_ips_DisconnectHandler_t disconnectHandler, void *contextPtr)
void le_ips_DisconnectService(void)
le_result_t le_ips_TryConnectService(void)
#define LE_FULL_API
Definition: le_apiFeatures.h:40
le_result_t le_ips_SetVoltageThresholds(uint16_t criticalVolt, uint16_t warningVolt, uint16_t normalVolt, uint16_t hiCriticalVolt)
le_result_t le_ips_SetBatteryLevel(uint8_t batteryLevel)
le_result_t le_ips_GetVoltageThresholds(uint16_t *criticalVoltPtr, uint16_t *warningVoltPtr, uint16_t *normalVoltPtr, uint16_t *hiCriticalVoltPtr)