61 lines
2.4 KiB
C
61 lines
2.4 KiB
C
#ifndef AIR780E_H
|
||
#define AIR780E_H
|
||
|
||
#include "main.h"
|
||
#include <stdint.h>
|
||
|
||
/*===== 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 10240
|
||
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);
|
||
|
||
/* GPS 定位运行时可切:EEPROM(偏移173) 存 0/1,空白(0xFF) 用 main.h 的
|
||
* PRODUCT_WITH_GPS 编译宏做默认值。蓝牙命令 GPS 查询,GPS0/GPS1 切换(重启生效) */
|
||
extern uint8_t g_gps_on;
|
||
void gps_load_mode(void);
|
||
void gps_set_mode(uint8_t on);
|
||
#define GPS_MODE_ADDR 173 /* EEPROM GPS 开关字节(172 为产品模式) */ /* 后台切片延时(喂狗+业务轮询), 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);
|
||
int air780e_mqtt_report(const char *header, const char *ota_id, int percent_or_success); /* 返回 0=送达 */
|
||
void air780e_mqtt_result_nowait(const char *header, const char *ota_id, int val); /* 结果上报:发了就走不等OK */
|
||
int air780e_ota_confirm(void); /* 0=通知已送达 1=无挂起 -1=通知未送达(需重试) */
|
||
uint16_t ota_get_version(void);
|
||
void CAT1_printf(const char *fmt, ...);
|
||
|
||
#endif /* AIR780E_H */
|