le_atServer_interface.h File Reference

#include "legato.h"
#include "le_atClient_interface.h"

Go to the source code of this file.

Macros

#define LE_ATSERVER_COMMAND_MAX_LEN   100
 
#define LE_ATSERVER_COMMAND_MAX_BYTES   101
 
#define LE_ATSERVER_PARAMETER_MAX_LEN   20
 
#define LE_ATSERVER_PARAMETER_MAX_BYTES   21
 
#define LE_ATSERVER_PATH_MAX_LEN   30
 
#define LE_ATSERVER_DEVICE_NAME_MAX_BYTES   31
 
#define LE_ATSERVER_RESPONSE_MAX_LEN   40
 
#define LE_ATSERVER_RESPONSE_MAX_BYTES   41
 

Typedefs

typedef struct le_atServer_Cmd * le_atServer_CmdRef_t
 
typedef struct le_atServer_Device * le_atServer_DeviceRef_t
 
typedef struct le_atServer_CommandHandler * le_atServer_CommandHandlerRef_t
 
typedef void(* le_atServer_CommandHandlerFunc_t) (le_atServer_CmdRef_t commandRef, le_atServer_Type_t type, uint32_t parametersNumber, void *contextPtr)
 

Enumerations

enum  le_atServer_Type_t { LE_ATSERVER_TYPE_ACT = 0, LE_ATSERVER_TYPE_PARA = 1, LE_ATSERVER_TYPE_TEST = 2, LE_ATSERVER_TYPE_READ = 3 }
 
enum  le_atServer_FinalRsp_t { LE_ATSERVER_OK = 0, LE_ATSERVER_ERROR = 1 }
 
enum  le_atServer_AvailableDevice_t { LE_ATSERVER_ALL_DEVICES = 0, LE_ATSERVER_SPECIFIC_DEVICE = 1 }
 

Functions

void le_atServer_ConnectService (void)
 
le_result_t le_atServer_TryConnectService (void)
 
void le_atServer_DisconnectService (void)
 
le_atServer_DeviceRef_t le_atServer_Start (const char *devicePath)
 
le_result_t le_atServer_Stop (le_atServer_DeviceRef_t device)
 
le_atServer_CmdRef_t le_atServer_Create (const char *name)
 
le_result_t le_atServer_Delete (le_atServer_CmdRef_t commandRef)
 
le_result_t le_atServer_SetDevice (le_atServer_CmdRef_t commandRef, le_atServer_AvailableDevice_t availableDevice, le_atServer_DeviceRef_t device)
 
le_atServer_CommandHandlerRef_t le_atServer_AddCommandHandler (le_atServer_CmdRef_t commandRef, le_atServer_CommandHandlerFunc_t handlerPtr, void *contextPtr)
 
void le_atServer_RemoveCommandHandler (le_atServer_CommandHandlerRef_t addHandlerRef)
 
le_result_t le_atServer_GetParameter (le_atServer_CmdRef_t commandRef, uint32_t index, char *parameter, size_t parameterNumElements)
 
le_result_t le_atServer_GetCommandName (le_atServer_CmdRef_t commandRef, char *name, size_t nameNumElements)
 
le_result_t le_atServer_SendIntermediateResponse (le_atServer_CmdRef_t commandRef, const char *intermediateRsp)
 
le_result_t le_atServer_SendFinalResponse (le_atServer_CmdRef_t commandRef, le_atServer_FinalRsp_t final, bool customStringAvailable, const char *finalRsp)
 
le_result_t le_atServer_SendUnsolicitedResponse (const char *unsolRsp, le_atServer_AvailableDevice_t availableDevice, le_atServer_DeviceRef_t device)
 

Detailed Description

Legato AT Commands Server include file.

Macro Definition Documentation

#define LE_ATSERVER_COMMAND_MAX_BYTES   101

Command string maximum length. One extra byte is added for the null character.

#define LE_ATSERVER_COMMAND_MAX_LEN   100

Command string maximum length.

#define LE_ATSERVER_DEVICE_NAME_MAX_BYTES   31

Device name maximum length. One extra byte is added for the null character.

#define LE_ATSERVER_PARAMETER_MAX_BYTES   21

Parameter string maximum length. One extra byte is added for the null character.

#define LE_ATSERVER_PARAMETER_MAX_LEN   20

Parameter string maximum length.

#define LE_ATSERVER_PATH_MAX_LEN   30

Device name maximum length.

#define LE_ATSERVER_RESPONSE_MAX_BYTES   41

AT command response maximum length. One extra byte is added for the null character.

#define LE_ATSERVER_RESPONSE_MAX_LEN   40

AT command response maximum length.

Typedef Documentation

typedef struct le_atServer_Cmd* le_atServer_CmdRef_t

Reference type for an AT command.

typedef void(* le_atServer_CommandHandlerFunc_t) (le_atServer_CmdRef_t commandRef, le_atServer_Type_t type, uint32_t parametersNumber, void *contextPtr)

Handler for the AT command processing.

Note
The argument "parametersNumber" is set only when "type" parameter value is LE_AT_SERVER_TYPE_PARA
Parameters
commandRefReceived AT command reference
typeReceived AT command type
parametersNumberParameters number
contextPtr
typedef struct le_atServer_CommandHandler* le_atServer_CommandHandlerRef_t

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

typedef struct le_atServer_Device* le_atServer_DeviceRef_t

Reference type for a AT command device.

Enumeration Type Documentation

Device availabality.

Enumerator
LE_ATSERVER_ALL_DEVICES 

action will be done on all bound devices

LE_ATSERVER_SPECIFIC_DEVICE 

action will be done on a specified device

Final response.

Enumerator
LE_ATSERVER_OK 

AT command successfully treated, "\r\nOK\r\n" is sent if no custom response is set

LE_ATSERVER_ERROR 

error in AT command treatement, "\r\nERROR\r\n" is sent if no custom response is set

Received AT command type.

Enumerator
LE_ATSERVER_TYPE_ACT 

Action AT command (e.g. 'AT+CMD')

LE_ATSERVER_TYPE_PARA 

AT command received with parameters (e.g. 'AT+CMD=x,y')

LE_ATSERVER_TYPE_TEST 

Test AT command (e.g. 'AT+CMD=?')

LE_ATSERVER_TYPE_READ 

Read AT command (e.g. 'AT+CMD?')

Function Documentation

le_atServer_CommandHandlerRef_t le_atServer_AddCommandHandler ( le_atServer_CmdRef_t  commandRef,
le_atServer_CommandHandlerFunc_t  handlerPtr,
void *  contextPtr 
)

Add handler function for EVENT 'le_atServer_Command'

This event provides information when the AT command is detected.

Parameters
[in]commandRefAT command reference
[in]handlerPtr
[in]contextPtr
void le_atServer_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_atServer_CmdRef_t le_atServer_Create ( const char *  name)

This function created an AT command and register it into the AT parser.

Returns
  • Reference to the AT command.
  • NULL if an error occurs.
Parameters
[in]nameAT command name string
le_result_t le_atServer_Delete ( le_atServer_CmdRef_t  commandRef)

This function deletes an AT command (i.e. unregister from the AT parser).

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed to delete the command.
Parameters
[in]commandRefAT command reference
void le_atServer_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_atServer_GetCommandName ( le_atServer_CmdRef_t  commandRef,
char *  name,
size_t  nameNumElements 
)

This function can be used to get the AT command string.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed to get the AT command string.
Parameters
[in]commandRefAT command reference
[out]nameAT command string
[in]nameNumElements
le_result_t le_atServer_GetParameter ( le_atServer_CmdRef_t  commandRef,
uint32_t  index,
char *  parameter,
size_t  parameterNumElements 
)

This function can be used to get the parameters of a received AT command.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed to get the requested parameter.
Parameters
[in]commandRefAT command reference
[in]indexagument index
[out]parameterparameter value
[in]parameterNumElements
void le_atServer_RemoveCommandHandler ( le_atServer_CommandHandlerRef_t  addHandlerRef)

Remove handler function for EVENT 'le_atServer_Command'

Parameters
[in]addHandlerRef
le_result_t le_atServer_SendFinalResponse ( le_atServer_CmdRef_t  commandRef,
le_atServer_FinalRsp_t  final,
bool  customStringAvailable,
const char *  finalRsp 
)

This function can be used to send the final response.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed to send the final response.
Parameters
[in]commandRefAT command reference
[in]finalFinal response to be sent
[in]customStringAvailableCustom finalRsp string has to be sent instead of the default one.
[in]finalRspcustom final response string
le_result_t le_atServer_SendIntermediateResponse ( le_atServer_CmdRef_t  commandRef,
const char *  intermediateRsp 
)

This function can be used to send an intermediate response.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed to send the intermediate response.
Parameters
[in]commandRefAT command reference
[in]intermediateRspIntermediate response to be sent
le_result_t le_atServer_SendUnsolicitedResponse ( const char *  unsolRsp,
le_atServer_AvailableDevice_t  availableDevice,
le_atServer_DeviceRef_t  device 
)

This function can be used to send the unsolicited response.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed to send the unsolicited response.
Parameters
[in]unsolRspUnsolicited response to be sent
[in]availableDevicedevice to send the unsolicited response
[in]devicedevice reference where the unsolicited response has to be sent
le_result_t le_atServer_SetDevice ( le_atServer_CmdRef_t  commandRef,
le_atServer_AvailableDevice_t  availableDevice,
le_atServer_DeviceRef_t  device 
)

This function sets the device(s) where the specified AT command is available.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed to set the device.
Note
If the AT command is available for all devices (i.e. availableDevice argument is set to LE_ATSERVER_ALL_DEVICES), the "device" argument is unused.
Parameters
[in]commandRefAT command reference
[in]availableDevicedevice available for the AT command
[in]devicedevice reference where the AT command is available
le_atServer_DeviceRef_t le_atServer_Start ( const char *  devicePath)

This function starts an AT server session on the requested device.

Returns
  • Reference to the requested device.
  • NULL if the device is not available.
Parameters
[in]devicePathdevice path which has to be used for the AT parser
le_result_t le_atServer_Stop ( le_atServer_DeviceRef_t  device)

This function stops the AT server session on the requested device.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed to stop the AT server session.
Parameters
[in]devicedevice to be unbound
le_result_t le_atServer_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.