#ifndef AIR780E_H #define AIR780E_H #include "main.h" #include /*===== 4G 模组引脚定义 (Air780E 复位控制, 低电平有效) =====*/ #define CAT_RST_PIN GPIO_PIN_4 #define CAT_RST_PORT GPIOA #define CAT_RST_LOW() HAL_GPIO_WritePin(CAT_RST_PORT, CAT_RST_PIN, GPIO_PIN_RESET) #define CAT_RST_HIGH() HAL_GPIO_WritePin(CAT_RST_PORT, CAT_RST_PIN, GPIO_PIN_SET) #define CAT_RST_LOW_MS 4000 /* 拉低 4s 硬件复位 */ /*===== MQTT 服务器配置 =====*/ typedef struct { char ClientID[20]; char Username[20]; char Passward[20]; char ServerIP[20]; uint16_t ServerPort; char Topic[20]; } MqttConfig; /* 默认 MQTT 参数已迁移到 main.h 的 MQTT_xxx 宏,避免多处维护不一致 */ /*===== U2_CopyBuff =====*/ #define U2_COPY_SIZE 20480 extern uint8_t U2_CopyBuff[U2_COPY_SIZE]; extern volatile uint16_t U2_CopyIndex; extern volatile uint8_t U2_CopyFlag; /*===== 运行状态标志 (供 main.c 判断 OTA 业务健康) =====*/ extern volatile uint8_t g_air780e_mqtt_ready; extern volatile uint8_t g_air780e_first_publish_ok; /*===== API =====*/ uint8_t catSendCmd(const char *cmd, const char *expect, uint8_t retry, uint8_t timeout); int air780e_send_at(const char *cmd, const char *expect, int timeout_ms); void bg_delay(uint32_t ms); /* 后台切片延时(喂狗+业务轮询), WiFi 后端 AT 等待同样复用 */ int Verify_Firmware_External(uint32_t ext_addr, uint32_t size); /* 外部Flash固件头校验, WiFi OTA 复用 */ uint16_t crc16_modbus_update(uint16_t crc, uint8_t data); /* MODBUS CRC16 累加, WiFi OTA 复用 */ void air780e_init(void); void air780e_process(void); void air780e_trigger_ota(const char *host, int port, const char *path, const char *ota_id, uint16_t new_ver, uint16_t crc16); void air780e_mqtt_report(const char *header, const char *ota_id, int percent_or_success); void air780e_ota_confirm(void); uint16_t ota_get_version(void); void CAT1_printf(const char *fmt, ...); #endif /* AIR780E_H */