| /* |
| TCP/IP AT header. |
| */ |
| /****************************************************************************** |
| |
| EDIT HISTORY FOR FILE |
| |
| WHEN WHO WHAT,WHERE,WHY |
| -------- -------- ------------------------------------------------------- |
| 2023/9/24 lb Initial version |
| |
| ******************************************************************************/ |
| #ifndef _MBTK_TCPIP_H |
| #define _MBTK_TCPIP_H |
| #include "mbtk_type.h" |
| |
| #define MBTK_TCPIP_LINK_MAX 4 |
| |
| typedef void (*mbtk_tcpip_read_callback_func)(int link_id, const char* data, int data_len); |
| |
| typedef enum { |
| MBTK_TCPIP_ERR_SUCCESS, |
| |
| MBTK_TCPIP_ERR_UNKNOWN |
| } mbtk_tcpip_err_enum; |
| |
| typedef enum { |
| MBTK_PROT_TYPE_TCP, |
| MBTK_PROT_TYPE_UDP |
| } mbtk_tcpip_prot_type_enum; |
| |
| typedef enum { |
| MBTK_TCPIP_TYPE_CLIENT, |
| MBTK_TCPIP_TYPE_SERVER |
| } mbtk_tcpip_type_enum; |
| |
| typedef struct { |
| int link_id; |
| char ser_addr[256]; |
| int ser_port; |
| mbtk_tcpip_prot_type_enum prot_type; |
| int local_port; |
| bool ack_support; |
| bool ssl_support; |
| bool ignore_cert; |
| uint32 heartbeat_time; |
| uint32 delay_time; |
| |
| mbtk_tcpip_read_callback_func read_cb; |
| } mbtk_tcpip_info_t; |
| |
| mbtk_tcpip_err_enum mbtk_tcpip_net_open(); |
| mbtk_tcpip_err_enum mbtk_tcpip_net_close(); |
| mbtk_tcpip_err_enum mbtk_tcpip_sock_open(const mbtk_tcpip_info_t *tcpip_info); |
| mbtk_tcpip_err_enum mbtk_tcpip_sock_close(int link_id); |
| |
| int mbtk_tcpip_send(int link_id, const char* data, int data_len, const char* ser_addr, int ser_port); |
| int mbtk_tcpip_read(int link_id, char* buff, int buff_size); |
| |
| /* |
| * Get the data traffic of the specified link. |
| */ |
| int mbtk_tcpip_data_traffic_get(int link_id); |
| |
| /* |
| * Reset the data traffic of the specified link. |
| */ |
| mbtk_tcpip_err_enum mbtk_tcpip_data_traffic_reset(int link_id); |
| |
| /* |
| * Return 0 if disconnected, other for connected. |
| */ |
| int mbtk_tcpip_link_state_get(int link_id); |
| |
| |
| #endif /* _MBTK_TCPIP_H */ |