36 lines
878 B
C
36 lines
878 B
C
/*
|
||
* tcp_server.h
|
||
*
|
||
* Created on: 2026-03-03
|
||
* Author: RT-Thread
|
||
*
|
||
* 功能: TCP服务器模块
|
||
* 依赖: lwIP网络栈、SHT40传感器
|
||
* 跨平台适配: 基于RT-Thread Nano,使用标准lwIP API
|
||
*/
|
||
|
||
#ifndef TCP_SERVER_H
|
||
#define TCP_SERVER_H
|
||
|
||
#include "lwip/sockets.h"
|
||
|
||
/* TCP Server Configuration */
|
||
#define TCP_SERVER_PORT 5588
|
||
#define TCP_SERVER_MAX_CLIENTS 2
|
||
#define TCP_SERVER_HEARTBEAT_INTERVAL 500 // 心跳间隔 500ms
|
||
#define TCP_SERVER_RECEIVE_TIMEOUT 5000 // 接收超时 5 秒
|
||
|
||
/* 客户端连接结构 */
|
||
typedef struct {
|
||
int sock; /* 客户端socket */
|
||
struct sockaddr_in addr; /* 客户端地址 */
|
||
int connected; /* 连接状态 */
|
||
} client_conn_t;
|
||
|
||
/* 全局标志 */
|
||
extern volatile int data_upload_success;
|
||
|
||
/* 函数声明 */
|
||
void tcp_server_entry(void *parameter);
|
||
|
||
#endif /* TCP_SERVER_H */ |