balcony_weather_station/tcp_client.h

45 lines
1.4 KiB
C

#ifndef TCP_CLIENT_H
#define TCP_CLIENT_H
#include <stdbool.h>
#include "lwip/ip_addr.h"
/**
* TCP Client Configuration
*/
typedef struct {
char server_ip[16]; // Server IP address as string (e.g., "192.168.1.100")
uint16_t server_port; // Server port number
uint32_t timeout_ms; // Connection timeout in milliseconds
bool initialized; // Internal state flag
void *internal_state; // Internal state pointer (opaque)
} tcp_client_config;
/**
* Initialize the TCP client configuration
*
* @param config Pointer to the configuration structure
* @param server_ip Server IP address as a string (e.g., "192.168.1.100")
* @param server_port Server port number
* @param timeout_ms Connection timeout in milliseconds
* @return true on success, false on failure
*/
bool tcp_client_init(tcp_client_config *config, const char *server_ip, uint16_t server_port, uint32_t timeout_ms);
/**
* Send a message to the TCP server
*
* @param config Pointer to the configuration structure
* @param message Null-terminated string message to send
* @return true on success, false on failure
*/
bool tcp_client_send_message(tcp_client_config *config, const char *message);
/**
* Close and cleanup the TCP client
*
* @param config Pointer to the configuration structure
*/
void tcp_client_cleanup(tcp_client_config *config);
#endif // TCP_CLIENT_H