TCP Client Driver

The TCP Client driver is used for allowing a project to connect to a TCP server and send and receive data packets.

Data Structures

ATMO_TCP_CLIENT_Config_t

Member Name Type
unused uint8_t

Type Definitions

Name Definition Description
ATMO_TCP_CLIENT_DriverInstance_t typedef struct ATMO_TCP_CLIENT_DriverInstance_t ATMO_TCP_CLIENT_DriverInstance_t  

Enumerations

enum ATMO_TCP_CLIENT_Status_t

Name Value
ATMO_TCP_CLIENT_Status_Success 0x00u
ATMO_TCP_CLIENT_Status_Fail 0x01u
ATMO_TCP_CLIENT_Status_Initialized 0x02u
ATMO_TCP_CLIENT_Status_Invalid 0x03u
ATMO_TCP_CLIENT_Status_NotSupported 0x04u
ATMO_TCP_CLIENT_Status_Unspecified 0x05u

enum ATMO_TCP_CLIENT_ConnectionStatus_t

Name Value Description
ATMO_TCP_CLIENT_Connected   Connected to server
ATMO_TCP_CLIENT_Disconnected   Disconnected from server
ATMO_TCP_CLIENT_Error   Internal error.

Functions

ATMO_Status_t ATMO_TCP_CLIENT_AddDriverInstance(const ATMO_TCP_CLIENT_DriverInstance_t *driverInstance, ATMO_DriverInstanceData_t *driverInstanceData, ATMO_DriverInstanceHandle_t *instanceNumber)

Add an instance of a driver for TCP_CLIENT into the TCP_CLIENT driver handler.

Parameter Direction Type
instanceNumber N/A ATMO_DriverInstanceHandle_t *
driverInstanceData N/A ATMO_DriverInstanceData_t *
driverInstance N/A const ATMO_TCP_CLIENT_DriverInstance_t *
Return Type
ATMO_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_Init(ATMO_DriverInstanceHandle_t instance)

Initialize the TCP_CLIENT driver.

Parameter Direction Type
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_DeInit(ATMO_DriverInstanceHandle_t instance)

De-initialize the TCP_CLIENT driver.

Parameter Direction Type
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_SetConfiguration(ATMO_DriverInstanceHandle_t instance, const ATMO_TCP_CLIENT_Config_t *config)

Set the TCP_CLIENT configuration.

Parameter Direction Type
config in const ATMO_TCP_CLIENT_Config_t *
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_Connect(ATMO_DriverInstanceHandle_t instance, const char *host, unsigned int port, bool useSSL)

Connect to a TCP endpoint.

Parameter Direction Type
useSSL in bool
port in unsigned int
host in const char *
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_Disconnect(ATMO_DriverInstanceHandle_t instance)

Disconnect from the TCP endpoint.

Parameter Direction Type
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_GetConnectionStatus(ATMO_DriverInstanceHandle_t instance, ATMO_TCP_CLIENT_ConnectionStatus_t *status)

Get the current connection status.

Parameter Direction Type
status N/A ATMO_TCP_CLIENT_ConnectionStatus_t *
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_WriteBytes(ATMO_DriverInstanceHandle_t instance, uint8_t *data, unsigned int dataLen)

Send data to a TCP endpoint.

Parameter Direction Type
dataLen in unsigned int
data in uint8_t *
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_SetReceiveCallback(ATMO_DriverInstanceHandle_t instance, ATMO_Callback_t cb)

Set the receive callback function. There will be no data transferred. Use ATMO_TCP_CLIENT_ReadBytes to read the data.

Parameter Direction Type
cb in ATMO_Callback_t
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t

ATMO_TCP_CLIENT_Status_t ATMO_TCP_CLIENT_GetNumAvailableBytes(ATMO_DriverInstanceHandle_t instance, uint32_t *numBytes, uint8_t **bytePtr)

Get the number of available bytes waiting to be processed. This is intended to be called from the callback set in ATMO_TCP_CLIENT_SetReceiveCallback.

Parameter Direction Type
bytePtr N/A uint8_t **
numBytes N/A uint32_t *
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_CLIENT_Status_t