m2mb API docs  37.00.006.0
m2mb API sets documentation
m2mb_ati.h File Reference

Header file for m2mb_ati APIs. More...

Go to the source code of this file.

Typedefs

typedef HANDLE M2MB_ATI_HANDLE
 
typedef void(* m2mb_ati_callback) (M2MB_ATI_HANDLE h, M2MB_ATI_EVENTS_E ati_event, UINT16 resp_size, void *resp_struct, void *userdata)
 Transmit and receive operation callback type. More...
 

Enumerations

enum  M2MB_ATI_EVENTS_E {
  M2MB_RX_DATA_EVT = 0x01, M2MB_STATE_IDLE_EVT = 0x02, M2MB_STATE_RUNNING_EVT = 0x04, M2MB_STATE_CMD_MODE_EVT = 0x08,
  M2MB_STATE_ONLINE_MODE_EVT = 0x10
}
 ATI event type. More...
 

Functions

M2MB_RESULT_E m2mb_ati_init (M2MB_ATI_HANDLE *pHandle, INT16 atInstance, m2mb_ati_callback callback, void *userdata)
 m2mb_ati_init initializes a ATI interface for current client. More...
 
M2MB_RESULT_E m2mb_ati_deinit (M2MB_ATI_HANDLE handle)
 m2mb_ati_deinit deinitializes ATI interface for current client. More...
 
M2MB_RESULT_E m2mb_ati_send_cmd (M2MB_ATI_HANDLE handle, void *buf, SIZE_T nbyte)
 m2mb_ati_send_cmd sends a command to an initialized ATI interface. More...
 
SSIZE_T m2mb_ati_rcv_resp (M2MB_ATI_HANDLE handle, void *buf, SIZE_T nbyte)
 m2mb_ati_rcv_resp receives data from an initialized ATI interface. More...
 

Detailed Description

Header file for m2mb_ati APIs.

m2m/m2m_generic/common/m2nb_inc/m2mb_ati.h

m2mb_ati APIs provide actions and events for AT interface.

@notes

Author
Morgan Deidda
Date
09/07/2018

Typedef Documentation

◆ m2mb_ati_callback

typedef void( * m2mb_ati_callback) (M2MB_ATI_HANDLE h, M2MB_ATI_EVENTS_E ati_event, UINT16 resp_size, void *resp_struct, void *userdata)

Transmit and receive operation callback type.

This type defines the callback functions that the client can set in the m2mb_ati_init API.

Enumeration Type Documentation

◆ M2MB_ATI_EVENTS_E

ATI event type.

This type defines the indications which can be passed to the callback.

Enumerator
M2MB_RX_DATA_EVT 

Received data Event

M2MB_STATE_IDLE_EVT 

AT parser entered in IDLE state

M2MB_STATE_RUNNING_EVT 

AT parser entered in RUNNING state

M2MB_STATE_CMD_MODE_EVT 

AT parser entered in COMMAND mode

M2MB_STATE_ONLINE_MODE_EVT 

AT parser entered in ONLINE mode

Function Documentation

◆ m2mb_ati_deinit()

M2MB_RESULT_E m2mb_ati_deinit ( M2MB_ATI_HANDLE  handle)

m2mb_ati_deinit deinitializes ATI interface for current client.

m2mb_ati_deinit deinitialize ATI interface for current client freeing the handle passed as first parameter. Calling the m2mb_ati_deinit is useful after using the ATI interface in order to free memory space and to restore the previous scenario.

Parameters
[in]handlefirst parameter is the handle to the ATI interface, that will be deinitialized by the function.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note

m2mb_ati_deinit(h);

M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_ATI_HANDLE h;
INT16 instanceID = 2;
struct myStruct myUserdata;
retVal = m2mb_ati_init(&h, instanceID, myCallback, (void*)myUserdata);
//... use ATI APIs ...
retVal = m2mb_ati_deinit(h);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_ati_deinit succeeded");

◆ m2mb_ati_init()

M2MB_RESULT_E m2mb_ati_init ( M2MB_ATI_HANDLE *  pHandle,
INT16  atInstance,
m2mb_ati_callback  callback,
void *  userdata 
)

m2mb_ati_init initializes a ATI interface for current client.

m2mb_ati_init initializes a ATI interface for current client returning the handle that must be passed as first parameter for all ATI actions. Every ATI interface is linked to a AT parser instance. Calling the m2mb_ati_init is mandatory before using the ATI interface.

Parameters
[in,out]*pHandlefirst parameter is the handle to the ATI interface, that will be initialized by the function.
[in]atInstancesecond parameter is the index of the AT parser instance that will be reserved to the current ATI interface. If the At instance is already reseved to another ATI interface or to a physical port, an error is returned.
[in]callbackthird parameter is the callback that will be called if an event or a response happens.
[in]userdatafourth parameter is a pointer to generic user data that will be returned as it is in the callback.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note
atInstance MUST be not reserved to a physical port: use atInstance=0 with PORTCFG=8 or atInstance=2 with PORTCFG=13

m2mb_ati_init(&h, instanceID, myCallback, myUserdata);

static void ati_callback( M2MB_ATI_HANDLE h, M2MB_ATI_EVENTS_E ati_event, UINT16 resp_size, void *resp_struct, void *userdata )
{
//my code
}
int main()
{
M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_ATI_HANDLE h;
INT16 instanceID = 2;
struct myStruct myUserdata;
retVal = m2mb_ati_init(&h, instanceID, myCallback, (void*)myUserdata);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_ati_init succeeded");
}

◆ m2mb_ati_rcv_resp()

SSIZE_T m2mb_ati_rcv_resp ( M2MB_ATI_HANDLE  handle,
void *  buf,
SIZE_T  nbyte 
)

m2mb_ati_rcv_resp receives data from an initialized ATI interface.

m2mb_ati_rcv_resp reads a message (response or indication) of maximum nbyte Bytes from an previously initialized ATI interface into the destination buffer buf.

Parameters
[in]handlefirst parameter is the handle to the ATI interface, previously initialized by the m2mb_ati_init function.
[in]bufsecond parameter is the destination buffer, previously allocated.
[in]nbytethird parameter is the length of the destination buffer in Bytes.
Returns
returns the number of read Bytes on SUCCESS, -1 on FAILURE.
Note

m2mb_ati_rcv_resp(h, resp_str, max_rsp_len);

M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_ATI_HANDLE h;
INT16 instanceID = 2;
struct myStruct myUserdata;
CHAR resp_str[ATI_RSP_LEN];
SIZE_T max_rsp_len = ATI_RSP_LEN;
SSIZE_T rsp_len;
retVal = m2mb_ati_init(&h, instanceID, myCallback, (void*)myUserdata);
...
rsp_len = m2mb_ati_rcv_resp(atiHandle, resp_str, max_rsp_len);
if ( rsp_len > 0 )
printf( "m2mb_ati_rcv_resp succeeded");

◆ m2mb_ati_send_cmd()

M2MB_RESULT_E m2mb_ati_send_cmd ( M2MB_ATI_HANDLE  handle,
void *  buf,
SIZE_T  nbyte 
)

m2mb_ati_send_cmd sends a command to an initialized ATI interface.

m2mb_ati_send_cmd writes a command of nbyte Bytes from the source buffer buf to a previously initialized ATI interface.

Parameters
[in]handlefirst parameter is the handle to the ATI interface, previously initialized by the m2mb_ati_init function.
[in]bufsecond parameter is the source buffer, previously allocated, containing the command string.
[in]nbytethird parameter is the length of the command string.
Returns
returns M2MB_RESULT_SUCCESS on success, a different value on error.
Note

m2mb_ati_send_cmd(h, cmd_str, cmd_len);

M2MB_RESULT_E retVal = M2MB_RESULT_SUCCESS;
M2MB_ATI_HANDLE h;
INT16 instanceID = 2;
struct myStruct myUserdata;
CHAR cmd_str[ATI_CMD_LEN];
SSIZE_T cmd_len;
retVal = m2mb_ati_init(&h, instanceID, myCallback, (void*)myUserdata);
...
strncpy(cmd_str, "at+cfun?", ATI_CMD_LEN);
cmd_len = strlen(cmd_str);
cmd_str[cmd_len++] = '\r';
retVal = m2mb_ati_send_cmd(h, cmd_str, cmd_len);
if ( retVal == M2MB_RESULT_SUCCESS )
printf( "m2mb_ati_send_cmd succeeded");
m2mb_ati_send_cmd
M2MB_RESULT_E m2mb_ati_send_cmd(M2MB_ATI_HANDLE handle, void *buf, SIZE_T nbyte)
m2mb_ati_send_cmd sends a command to an initialized ATI interface.
m2mb_ati_deinit
M2MB_RESULT_E m2mb_ati_deinit(M2MB_ATI_HANDLE handle)
m2mb_ati_deinit deinitializes ATI interface for current client.
M2MB_ATI_EVENTS_E
M2MB_ATI_EVENTS_E
ATI event type.
Definition: m2mb_ati.h:39
m2mb_ati_rcv_resp
SSIZE_T m2mb_ati_rcv_resp(M2MB_ATI_HANDLE handle, void *buf, SIZE_T nbyte)
m2mb_ati_rcv_resp receives data from an initialized ATI interface.
m2mb_ati_init
M2MB_RESULT_E m2mb_ati_init(M2MB_ATI_HANDLE *pHandle, INT16 atInstance, m2mb_ati_callback callback, void *userdata)
m2mb_ati_init initializes a ATI interface for current client.