// Common types shared across modules #ifndef COMMON_H #define COMMON_H #include #include // 时间段类型 typedef enum { TIME_PERIOD_DAY = 0, TIME_PERIOD_NIGHT = 1, } time_period_type_t; // 设备状态结构体 typedef struct { bool online; char current_mode[20]; bool home_status; bool standby_mode; uint8_t error_code; bool auto_mode; // true=自动模式, false=手动模式 } device_state_t; // 遥测数据结构体 typedef struct { float temperature; float humidity; float light_intensity; uint16_t co2_ppm; uint16_t tvoc_ppb; char curtain_state[10]; char led_state[10]; uint8_t led_power; char fan_state[10]; char buzzer_state[10]; } telemetry_data_t; // 设备消息结构体 typedef struct { char device_id[32]; char device_type[32]; uint64_t timestamp; device_state_t state; telemetry_data_t telemetry; } device_message_t; #ifdef __cplusplus extern "C" { #endif // 时间段与降温模式函数声明 void time_period_set(time_period_type_t period_type, uint8_t start_hour, uint8_t start_minute, uint8_t end_hour, uint8_t end_minute); void cooling_mode_save_to_nvs(void); void cooling_mode_load_from_nvs(void); void time_period_save_to_nvs(void); void time_period_load_from_nvs(void); #ifdef __cplusplus } #endif #endif // COMMON_H