le_port_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_port Port Service
14  *
15  * @ref le_port_interface.h "API Reference"
16  *
17  * This service manages a list of serial links (physical or emulated). It also manages the
18  * link modes (AT command and data mode).
19  *
20  * @section le_port_binding IPC interfaces binding
21  *
22  * All the functions of this API are provided by the @b portService.
23  *
24  * Here's a code sample binding to the port service:
25  * @verbatim
26  bindings:
27  {
28  portTest.portTestComp.le_port -> portService.le_port
29  }
30  @endverbatim
31  *
32  * @section port_request Request Device
33  *
34  * le_port_Request() must be called to open a configured device. If the device was not opened, it
35  * opens the device.
36  *
37  * @section port_SwitchMode Switch Mode
38  *
39  * le_port_SetDataMode() must be called to switch the device into data mode.
40  * le_port_SetCommandMode() must be called to switch the device into command mode.
41  *
42  * @section port_Release Release Device
43  *
44  * le_port_Release() must be called to release the device.
45  *
46  * @section port_config Configuration
47  *
48  * @todo Configuration documentation to be written.
49  *
50  * @section port_GetPortReference Get Port Reference
51  *
52  * le_port_GetPortReference() must be called to get the port object reference regarding to a given
53  * reference coming from the AT server.
54  *
55  * @todo The port service is not implemented yet.
56  *
57  * <HR>
58  *
59  * Copyright (C) Sierra Wireless Inc.
60  */
61 /**
62  * @file le_port_interface.h
63  *
64  * Legato @ref c_port include file.
65  *
66  * Copyright (C) Sierra Wireless Inc.
67  */
68 /**
69  * Include le_atServer.api for atServer type definitions.
70  */
71 
72 #ifndef LE_PORT_INTERFACE_H_INCLUDE_GUARD
73 #define LE_PORT_INTERFACE_H_INCLUDE_GUARD
74 
75 
76 #include "legato.h"
77 
78 // Interface specific includes
79 #include "le_atServer_interface.h"
80 
81 
82 //--------------------------------------------------------------------------------------------------
83 /**
84  * Type for handler called when a server disconnects.
85  */
86 //--------------------------------------------------------------------------------------------------
87 typedef void (*le_port_DisconnectHandler_t)(void *);
88 
89 //--------------------------------------------------------------------------------------------------
90 /**
91  *
92  * Connect the current client thread to the service providing this API. Block until the service is
93  * available.
94  *
95  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
96  * called before any other functions in this API. Normally, ConnectService is automatically called
97  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
98  *
99  * This function is created automatically.
100  */
101 //--------------------------------------------------------------------------------------------------
103 (
104  void
105 );
106 
107 //--------------------------------------------------------------------------------------------------
108 /**
109  *
110  * Try to connect the current client thread to the service providing this API. Return with an error
111  * if the service is not available.
112  *
113  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
114  * called before any other functions in this API. Normally, ConnectService is automatically called
115  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
116  *
117  * This function is created automatically.
118  *
119  * @return
120  * - LE_OK if the client connected successfully to the service.
121  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
122  * bound.
123  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
124  * - LE_COMM_ERROR if the Service Directory cannot be reached.
125  */
126 //--------------------------------------------------------------------------------------------------
128 (
129  void
130 );
131 
132 //--------------------------------------------------------------------------------------------------
133 /**
134  * Set handler called when server disconnection is detected.
135  *
136  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
137  * to continue without exiting, it should call longjmp() from inside the handler.
138  */
139 //--------------------------------------------------------------------------------------------------
141 (
142  le_port_DisconnectHandler_t disconnectHandler,
143  void *contextPtr
144 );
145 
146 //--------------------------------------------------------------------------------------------------
147 /**
148  *
149  * Disconnect the current client thread from the service providing this API.
150  *
151  * Normally, this function doesn't need to be called. After this function is called, there's no
152  * longer a connection to the service, and the functions in this API can't be used. For details, see
153  * @ref apiFilesC_client.
154  *
155  * This function is created automatically.
156  */
157 //--------------------------------------------------------------------------------------------------
159 (
160  void
161 );
162 
163 
164 //--------------------------------------------------------------------------------------------------
165 /**
166  * Maximum length of the device name.
167  */
168 //--------------------------------------------------------------------------------------------------
169 #define LE_PORT_MAX_LEN_DEVICE_NAME 50
170 
171 //--------------------------------------------------------------------------------------------------
172 /**
173  * Reference type for referring to the device.
174  */
175 //--------------------------------------------------------------------------------------------------
176 typedef struct le_port_Device* le_port_DeviceRef_t;
177 
178 
179 //--------------------------------------------------------------------------------------------------
180 /**
181  * This function requests to open a configured device. If the device was not opened, it opens
182  * the device.
183  *
184  * @return
185  * - Reference to the device.
186  * - NULL if the device is not available.
187  */
188 //--------------------------------------------------------------------------------------------------
190 (
191  const char* LE_NONNULL deviceName
192  ///< [IN] Device name to be requested.
193 );
194 
195 //--------------------------------------------------------------------------------------------------
196 /**
197  * This function switches the device into data mode.
198  *
199  * @return
200  * - LE_OK Function succeeded.
201  * - LE_FAULT Function failed.
202  * - LE_BAD_PARAMETER Invalid parameter.
203  * - LE_UNAVAILABLE JSON parsing is not completed.
204  * - LE_DUPLICATE Device already opened in data mode.
205  */
206 //--------------------------------------------------------------------------------------------------
208 (
209  le_port_DeviceRef_t devRef,
210  ///< [IN] Device reference.
211  int* fdPtr
212  ///< [OUT] File descriptor of the device.
213 );
214 
215 //--------------------------------------------------------------------------------------------------
216 /**
217  * This function switches the device into AT command mode and returns AT server device reference.
218  *
219  * @return
220  * - LE_OK Function succeeded.
221  * - LE_FAULT Function failed.
222  * - LE_BAD_PARAMETER Invalid parameter.
223  */
224 //--------------------------------------------------------------------------------------------------
226 (
227  le_port_DeviceRef_t devRef,
228  ///< [IN] Device reference.
229  le_atServer_DeviceRef_t* atServerDevRefPtr
230  ///< [OUT] AT server device reference.
231 );
232 
233 //--------------------------------------------------------------------------------------------------
234 /**
235  * This function closes the device and releases the resources.
236  *
237  * @return
238  * - LE_OK Function succeeded.
239  * - LE_FAULT Function failed.
240  * - LE_BAD_PARAMETER Invalid parameter.
241  * - LE_UNAVAILABLE JSON parsing is not completed.
242  */
243 //--------------------------------------------------------------------------------------------------
245 (
246  le_port_DeviceRef_t devRef
247  ///< [IN] Device reference.
248 );
249 
250 //--------------------------------------------------------------------------------------------------
251 /**
252  * This function gets the device reference regarding to a given reference coming from the AT server.
253  *
254  * @return
255  * - LE_OK Function succeeded.
256  * - LE_FAULT Function failed.
257  * - LE_BAD_PARAMETER Invalid parameter.
258  */
259 //--------------------------------------------------------------------------------------------------
261 (
262  le_atServer_DeviceRef_t atServerDevRef,
263  ///< [IN] Device reference from AT server.
264  le_port_DeviceRef_t* devRefPtr
265  ///< [OUT] Device reference from port service.
266 );
267 
268 #endif // LE_PORT_INTERFACE_H_INCLUDE_GUARD
le_result_t
Definition: le_basics.h:35
void le_port_DisconnectService(void)
le_result_t le_port_TryConnectService(void)
struct le_atServer_Device * le_atServer_DeviceRef_t
Definition: le_atServer_interface.h:411
le_result_t le_port_Release(le_port_DeviceRef_t devRef)
le_port_DeviceRef_t le_port_Request(const char *LE_NONNULL deviceName)
struct le_port_Device * le_port_DeviceRef_t
Definition: le_port_interface.h:176
void le_port_ConnectService(void)
void le_port_SetServerDisconnectHandler(le_port_DisconnectHandler_t disconnectHandler, void *contextPtr)
le_result_t le_port_SetDataMode(le_port_DeviceRef_t devRef, int *fdPtr)
void(* le_port_DisconnectHandler_t)(void *)
Definition: le_port_interface.h:87
le_result_t le_port_SetCommandMode(le_port_DeviceRef_t devRef, le_atServer_DeviceRef_t *atServerDevRefPtr)
le_result_t le_port_GetPortReference(le_atServer_DeviceRef_t atServerDevRef, le_port_DeviceRef_t *devRefPtr)