更新 common.h

This commit is contained in:
2025-12-26 14:54:01 +08:00
parent 33ca258855
commit a5a9a3efa6

View File

@@ -3,20 +3,15 @@
#include <stdint.h> #include <stdint.h>
#define TYPE_DATA 0 #define DATA_LEN 512
#define TYPE_ACK 1 #define TYPE_DATA 1
#define TYPE_ACK 2
#define PORT 9000 typedef struct {
#define BUF_SIZE 1024 uint8_t type; // DATA or ACK
#define TIMEOUT_SEC 2 uint8_t seq; // 序号 0 / 1
uint16_t length; // 数据长度
/* 应用层协议数据包 */ char data[DATA_LEN];
#pragma pack(push, 1) } packet_t;
struct packet {
uint8_t seq; // 停等协议序号0 / 1
uint8_t type; // 0=DATA, 1=ACK
char payload[BUF_SIZE - 2];
};
#pragma pack(pop)
#endif #endif