TCP Server Driver

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

Data Structures

ATMO_TCP_SERVER_Config_t

Member Name Type
port uint16_t

Type Definitions

Name Definition Description
ATMO_TCP_SERVER_DriverInstance_t typedef struct ATMO_TCP_SERVER_DriverInstance_t ATMO_TCP_SERVER_DriverInstance_t  

Enumerations

enum ATMO_TCP_SERVER_Status_t

Name Value
ATMO_TCP_SERVER_Status_Success 0x00u
ATMO_TCP_SERVER_Status_Fail 0x01u
ATMO_TCP_SERVER_Status_Initialized 0x02u
ATMO_TCP_SERVER_Status_Invalid 0x03u
ATMO_TCP_SERVER_Status_NotSupported 0x04u
ATMO_TCP_SERVER_Status_Unspecified 0x05u

enum ATMO_TCP_SERVER_Event_t

Name Value
ATMO_TCP_SERVER_ClientConnected 0
ATMO_TCP_SERVER_ClientDisconnected  
ATMO_TCP_SERVER_DataAvailable  
ATMO_TCP_SERVER_DataSent  
ATMO_TCP_SERVER_RuntimeError  
ATMO_TCP_SERVER_NumEvents  

Functions

ATMO_Status_t ATMO_TCP_SERVER_AddDriverInstance(const ATMO_TCP_SERVER_DriverInstance_t *driverInstance, ATMO_DriverInstanceData_t *driverInstanceData, ATMO_DriverInstanceHandle_t *instanceNumber)

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

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

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_Init(ATMO_DriverInstanceHandle_t instance)

Initialize the TCP_SERVER driver.

Parameter Direction Type
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_DeInit(ATMO_DriverInstanceHandle_t instance)

De-initialize the TCP_SERVER driver.

Parameter Direction Type
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_SetConfiguration(ATMO_DriverInstanceHandle_t instance, const ATMO_TCP_SERVER_Config_t *config)

Set the TCP server configuration.

Parameter Direction Type
config N/A const ATMO_TCP_SERVER_Config_t *
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_Start(ATMO_DriverInstanceHandle_t instance)

Start the TCP server. The underlying implementation may work differently depending on the platform. Some may run on threads, some may be polled in the main loop.

Parameter Direction Type
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_Stop(ATMO_DriverInstanceHandle_t instance)

Stop the TCP server. This is intended to be called when registering a device is complete.

Parameter Direction Type
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_RegisterEventCallback(ATMO_DriverInstanceHandle_t instance, ATMO_TCP_SERVER_Event_t event, ATMO_Callback_t cb)

Register to receive an event callback.

Parameter Direction Type
cb N/A ATMO_Callback_t
event N/A ATMO_TCP_SERVER_Event_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_GetNumAvailableBytes(ATMO_DriverInstanceHandle_t instance, uint32_t connectionId, uint32_t *availableBytes)

How many bytes are available waiting to be read.

Parameter Direction Type
availableBytes N/A uint32_t *
connectionId N/A uint32_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_ReadBytes(ATMO_DriverInstanceHandle_t instance, uint32_t connectionId, uint8_t *buffer, uint32_t numBytes)

Read bytes from the server’s internal buffer.

Parameter Direction Type
numBytes N/A uint32_t
buffer N/A uint8_t *
connectionId N/A uint32_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_WriteBytes(ATMO_DriverInstanceHandle_t instance, uint32_t connectionId, uint8_t *buffer, uint32_t numBytes)

Write bytes and send to the client.

Parameter Direction Type
numBytes N/A uint32_t
buffer N/A uint8_t *
connectionId N/A uint32_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t

ATMO_TCP_SERVER_Status_t ATMO_TCP_SERVER_CloseConnection(ATMO_DriverInstanceHandle_t instance, uint32_t connectionId)

Close a TCP client connection.

Parameter Direction Type
connectionId N/A uint32_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_TCP_SERVER_Status_t