le_atClient_interface.h File Reference

#include "legato.h"
#include "le_atDefs_interface.h"

Go to the source code of this file.

Typedefs

typedef void(* le_atClient_DisconnectHandler_t) (void *)
 
typedef struct le_atClient_Cmd * le_atClient_CmdRef_t
 
typedef struct le_atClient_Device * le_atClient_DeviceRef_t
 
typedef struct le_atClient_UnsolicitedResponseHandler * le_atClient_UnsolicitedResponseHandlerRef_t
 
typedef void(* le_atClient_UnsolicitedResponseHandlerFunc_t) (const char *LE_NONNULL unsolicitedRsp, void *contextPtr)
 

Functions

void le_atClient_ConnectService (void)
 
le_result_t le_atClient_TryConnectService (void)
 
void le_atClient_SetServerDisconnectHandler (le_atClient_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
void le_atClient_DisconnectService (void)
 
le_atClient_DeviceRef_t le_atClient_Start (int fd)
 
le_result_t le_atClient_Stop (le_atClient_DeviceRef_t device)
 
le_atClient_CmdRef_t le_atClient_Create (void)
 
le_result_t le_atClient_Delete (le_atClient_CmdRef_t cmdRef)
 
le_result_t le_atClient_SetCommand (le_atClient_CmdRef_t cmdRef, const char *LE_NONNULL command)
 
le_result_t le_atClient_SetIntermediateResponse (le_atClient_CmdRef_t cmdRef, const char *LE_NONNULL intermediate)
 
le_result_t le_atClient_SetFinalResponse (le_atClient_CmdRef_t cmdRef, const char *LE_NONNULL response)
 
le_result_t le_atClient_SetText (le_atClient_CmdRef_t cmdRef, const char *LE_NONNULL text)
 
le_result_t le_atClient_SetTimeout (le_atClient_CmdRef_t cmdRef, uint32_t timer)
 
le_result_t le_atClient_SetDevice (le_atClient_CmdRef_t cmdRef, le_atClient_DeviceRef_t devRef)
 
le_result_t le_atClient_Send (le_atClient_CmdRef_t cmdRef)
 
le_result_t le_atClient_GetFirstIntermediateResponse (le_atClient_CmdRef_t cmdRef, char *intermediateRsp, size_t intermediateRspSize)
 
le_result_t le_atClient_GetNextIntermediateResponse (le_atClient_CmdRef_t cmdRef, char *intermediateRsp, size_t intermediateRspSize)
 
le_result_t le_atClient_GetFinalResponse (le_atClient_CmdRef_t cmdRef, char *finalRsp, size_t finalRspSize)
 
le_result_t le_atClient_SetCommandAndSend (le_atClient_CmdRef_t *cmdRefPtr, le_atClient_DeviceRef_t devRef, const char *LE_NONNULL command, const char *LE_NONNULL interResp, const char *LE_NONNULL finalResp, uint32_t timeout)
 
le_atClient_UnsolicitedResponseHandlerRef_t le_atClient_AddUnsolicitedResponseHandler (const char *LE_NONNULL unsolRsp, le_atClient_DeviceRef_t devRef, le_atClient_UnsolicitedResponseHandlerFunc_t handlerPtr, void *contextPtr, uint32_t lineCount)
 
void le_atClient_RemoveUnsolicitedResponseHandler (le_atClient_UnsolicitedResponseHandlerRef_t handlerRef)
 

Detailed Description

Legato AT Commands Client include file.

Typedef Documentation

typedef void(* le_atClient_DisconnectHandler_t) (void *)

Type for handler called when a server disconnects.

typedef void(* le_atClient_UnsolicitedResponseHandlerFunc_t) (const char *LE_NONNULL unsolicitedRsp,void *contextPtr)

Handler for unsolicited response reception.

typedef struct le_atClient_UnsolicitedResponseHandler* le_atClient_UnsolicitedResponseHandlerRef_t

Reference type used by Add/Remove functions for EVENT 'le_atClient_UnsolicitedResponse'

Function Documentation

le_atClient_UnsolicitedResponseHandlerRef_t le_atClient_AddUnsolicitedResponseHandler ( const char *LE_NONNULL  unsolRsp,
le_atClient_DeviceRef_t  devRef,
le_atClient_UnsolicitedResponseHandlerFunc_t  handlerPtr,
void *  contextPtr,
uint32_t  lineCount 
)

Add handler function for EVENT 'le_atClient_UnsolicitedResponse'

This event provides information on a subscribed unsolicited response when this unsolicited response is received.

Parameters
[in]unsolRspPattern to match
[in]devRefDevice to listen
[in]handlerPtrunsolicited handler
[in]contextPtr
[in]lineCountIndicate the number of line of the unsolicited
void le_atClient_ConnectService ( void  )

Connect the current client thread to the service providing this API. Block until the service is available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.

This function is created automatically.

le_atClient_CmdRef_t le_atClient_Create ( void  )

This function must be called to create a new AT command.

Returns
pointer to the new AT Command reference
le_result_t le_atClient_Delete ( le_atClient_CmdRef_t  cmdRef)

This function must be called to delete an AT command reference.

Returns
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
void le_atClient_DisconnectService ( void  )

Disconnect the current client thread from the service providing this API.

Normally, this function doesn't need to be called. After this function is called, there's no longer a connection to the service, and the functions in this API can't be used. For details, see Client-specific Functions.

This function is created automatically.

le_result_t le_atClient_GetFinalResponse ( le_atClient_CmdRef_t  cmdRef,
char *  finalRsp,
size_t  finalRspSize 
)

This function is used to get the final response

Returns
  • LE_FAULT when function failed
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[out]finalRspGet Final Line
[in]finalRspSize
le_result_t le_atClient_GetFirstIntermediateResponse ( le_atClient_CmdRef_t  cmdRef,
char *  intermediateRsp,
size_t  intermediateRspSize 
)

This function is used to get the first intermediate response.

Returns
  • LE_FAULT when function failed
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[out]intermediateRspFirst intermediate result code
[in]intermediateRspSize
le_result_t le_atClient_GetNextIntermediateResponse ( le_atClient_CmdRef_t  cmdRef,
char *  intermediateRsp,
size_t  intermediateRspSize 
)

This function is used to get the next intermediate response.

Returns
  • LE_NOT_FOUND when there are no further results
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[out]intermediateRspGet Next intermediate result code.
[in]intermediateRspSize
void le_atClient_RemoveUnsolicitedResponseHandler ( le_atClient_UnsolicitedResponseHandlerRef_t  handlerRef)

Remove handler function for EVENT 'le_atClient_UnsolicitedResponse'

Parameters
[in]handlerRef
le_result_t le_atClient_Send ( le_atClient_CmdRef_t  cmdRef)

This function must be called to send an AT Command and wait for response.

Returns
  • LE_FAULT when function failed
  • LE_TIMEOUT when a timeout occur
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
le_result_t le_atClient_SetCommand ( le_atClient_CmdRef_t  cmdRef,
const char *LE_NONNULL  command 
)

This function must be called to set the AT command string to be sent.

Returns
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[in]commandSet Command
le_result_t le_atClient_SetCommandAndSend ( le_atClient_CmdRef_t *  cmdRefPtr,
le_atClient_DeviceRef_t  devRef,
const char *LE_NONNULL  command,
const char *LE_NONNULL  interResp,
const char *LE_NONNULL  finalResp,
uint32_t  timeout 
)

This function must be called to automatically set and send an AT Command.

Returns
  • LE_FAULT when function failed
  • LE_TIMEOUT when a timeout occur
  • LE_OK when function succeed
Note
This command creates a command reference when called
In case of an Error the command reference will be deleted and though not usable. Make sure to test the return code and not use the reference in other functions.
If the AT command is invalid, a fatal error occurs, the function won't return.
Parameters
[out]cmdRefPtrCmd reference
[in]devRefDev reference
[in]commandAT Command
[in]interRespExpected intermediate response
[in]finalRespExpected final response
[in]timeoutTimeout value in milliseconds.
le_result_t le_atClient_SetDevice ( le_atClient_CmdRef_t  cmdRef,
le_atClient_DeviceRef_t  devRef 
)

This function must be called to set the device where the AT command will be sent.

Returns
  • LE_FAULT when function failed
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[in]devRefDevice where the AT command has to be sent
le_result_t le_atClient_SetFinalResponse ( le_atClient_CmdRef_t  cmdRef,
const char *LE_NONNULL  response 
)

This function must be called to set the final response(s) of the AT command execution. Several final responses can be specified separated by a '|' character into the string given in parameter.

Returns
  • LE_FAULT when function failed
  • LE_OK when function succeed
Note
If the AT Command reference or set response is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[in]responseSet Response
le_result_t le_atClient_SetIntermediateResponse ( le_atClient_CmdRef_t  cmdRef,
const char *LE_NONNULL  intermediate 
)

This function must be called to set the waiting intermediate responses. Several intermediate responses can be specified separated by a '|' character into the string given in parameter.

Returns
  • LE_FAULT when function failed
  • LE_OK when function succeed
Note
If the AT Command reference or set intermediate response is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[in]intermediateSet Intermediate
void le_atClient_SetServerDisconnectHandler ( le_atClient_DisconnectHandler_t  disconnectHandler,
void *  contextPtr 
)

Set handler called when server disconnection is detected.

When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants to continue without exiting, it should call longjmp() from inside the handler.

le_result_t le_atClient_SetText ( le_atClient_CmdRef_t  cmdRef,
const char *LE_NONNULL  text 
)

This function must be called to set the text when the prompt is expected.

Returns
  • LE_FAULT when function failed
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[in]textThe AT Data to send
le_result_t le_atClient_SetTimeout ( le_atClient_CmdRef_t  cmdRef,
uint32_t  timer 
)

This function must be called to set the timeout of the AT command execution.

Returns
  • LE_OK when function succeed
Note
If the AT Command reference is invalid, a fatal error occurs, the function won't return.
Parameters
[in]cmdRefAT Command
[in]timerThe timeout value in milliseconds.
le_atClient_DeviceRef_t le_atClient_Start ( int  fd)

This function must be called to start a ATClient session on a specified device.

Returns
reference on a device context
Parameters
[in]fdFile descriptor.
le_result_t le_atClient_Stop ( le_atClient_DeviceRef_t  device)

This function must be called to stop the ATClient session on the specified device.

Returns
  • LE_FAULT when function failed
  • LE_OK when function succeed
Parameters
[in]deviceDevice reference
le_result_t le_atClient_TryConnectService ( void  )

Try to connect the current client thread to the service providing this API. Return with an error if the service is not available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.

This function is created automatically.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.