|
|
|
@ -69,6 +69,7 @@ typedef enum
|
|
|
|
|
{
|
|
|
|
|
WL_STATE_SOFT = 0,
|
|
|
|
|
WL_STATE_AT_ATE,
|
|
|
|
|
WL_STATE_AT_IPR,
|
|
|
|
|
WL_STATE_AT_QICSGP,
|
|
|
|
|
WL_STATE_AT_QIACT,
|
|
|
|
|
WL_STATE_AT_CSQ,
|
|
|
|
@ -84,6 +85,7 @@ typedef enum
|
|
|
|
|
WL_STATE_REALDATA_FAULT,
|
|
|
|
|
WL_STATE_POWER_FAULT,
|
|
|
|
|
WL_STATE_FAULT,
|
|
|
|
|
WL_STATE_UPDATE,
|
|
|
|
|
WL_STATE_KEEPALIVE,
|
|
|
|
|
WL_STATE_END = 255
|
|
|
|
|
} WL_STATE_E;
|
|
|
|
@ -138,6 +140,7 @@ typedef struct
|
|
|
|
|
uint32_t utc; // 故障时间
|
|
|
|
|
uint32_t ns; // 故障时间纳秒
|
|
|
|
|
uint16_t fault_trig[DAU_PORT_FAULT_MAX];// 故障电流触发值 A
|
|
|
|
|
uint32_t elec[DAU_PORT_POWER_CNT]; // 工频电流有效值 mA
|
|
|
|
|
} wl_proto_realdata_fault_t;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
@ -155,7 +158,6 @@ typedef struct
|
|
|
|
|
uint32_t utc; // gps 对时时间
|
|
|
|
|
} wl_proto_state_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
|
const osThreadAttr_t WL_attributes =
|
|
|
|
@ -176,6 +178,7 @@ static void _wl_4G_send_update(void);
|
|
|
|
|
static void _wl_4G_send_cfg_set(void);
|
|
|
|
|
static void _wl_4G_send_update_rt(void);
|
|
|
|
|
static void _wl_4G_send_time(void);
|
|
|
|
|
static void _wl_4G_send_wave_force(void);
|
|
|
|
|
|
|
|
|
|
/* Internal functions --------------------------------------------------------*/
|
|
|
|
|
/* 4G 模块发送数据. */
|
|
|
|
@ -185,7 +188,7 @@ static int32_t _wl_4G_transmit(uint8_t *data, uint16_t len)
|
|
|
|
|
|
|
|
|
|
if (wl_ctrl.state < WL_STATE_CONTACT)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_4G, "Send: %s\r\n", data);
|
|
|
|
|
DBG(DBG_M_4G, "Send: %s", data);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -269,6 +272,15 @@ static void _wl_4G_AT_process(uint8_t *cmd)
|
|
|
|
|
else if (0 == strncmp((char*)cmd, "OK", 2))
|
|
|
|
|
{
|
|
|
|
|
/* 命令执行成功. */
|
|
|
|
|
if (WL_STATE_AT_IPR == wl_ctrl.state)
|
|
|
|
|
{
|
|
|
|
|
HAL_UART_Abort(wl_ctrl.uart);
|
|
|
|
|
HAL_UART_DeInit(wl_ctrl.uart);
|
|
|
|
|
memset(&wl_buf_list_rx, 0, sizeof(wl_buf_list_t));
|
|
|
|
|
MX_USART3_UART_Init_WL();
|
|
|
|
|
HAL_UARTEx_ReceiveToIdle_DMA(wl_ctrl.uart, wl_ctrl.dma_rx_buf, WL_DMA_RX_BUF_LEN);
|
|
|
|
|
osDelay(1000);
|
|
|
|
|
}
|
|
|
|
|
if (wl_ctrl.state < WL_STATE_AT_QIOPEN)
|
|
|
|
|
{
|
|
|
|
|
wl_ctrl.state++;
|
|
|
|
@ -396,7 +408,7 @@ static int32_t _wl_4G_pkt_check(uint8_t *cmd, uint32_t len)
|
|
|
|
|
|
|
|
|
|
/* pkt_id 验证 */
|
|
|
|
|
if (head->pkt_id != wl_ctrl.pkt_id
|
|
|
|
|
|| head->pkt_id >= 0x8000)
|
|
|
|
|
&& head->pkt_id < 0x8000)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_4G, "@4: %d %d\r\n", head->pkt_id, wl_ctrl.pkt_id);
|
|
|
|
|
return HAL_ERROR;
|
|
|
|
@ -429,6 +441,12 @@ static void _wl_4G_recv_contect(uint8_t *cmd, uint32_t len)
|
|
|
|
|
dev_config.wave_threshold = cfg->threshold_defect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cfg->threshold_fault != dev_config.fault_threshold)
|
|
|
|
|
{
|
|
|
|
|
is_cfg_save = TRUE;
|
|
|
|
|
dev_config.fault_threshold = cfg->threshold_fault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_cfg_save)
|
|
|
|
|
{
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
@ -469,6 +487,8 @@ static void _wl_4G_recv_update(uint8_t *cmd, uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
/* 开始时置升级结果为错误. */
|
|
|
|
|
wl_ctrl.update_rt = HAL_ERROR;
|
|
|
|
|
wl_ctrl.state = WL_STATE_UPDATE;
|
|
|
|
|
wl_ctrl.time_update = HAL_GetTick();
|
|
|
|
|
|
|
|
|
|
while(addr != TFTP_APP_ADDRESS_END)
|
|
|
|
|
{
|
|
|
|
@ -521,6 +541,7 @@ static void _wl_4G_recv_update(uint8_t *cmd, uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
wl_ctrl.mul_idx = 0;
|
|
|
|
|
wl_ctrl.update_len = 0;
|
|
|
|
|
wl_ctrl.state = WL_STATE_END;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -549,6 +570,12 @@ static void _wl_4G_recv_cfg_set(uint8_t *cmd, uint32_t len)
|
|
|
|
|
dev_config.wave_threshold = cfg->threshold_defect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cfg->threshold_fault != dev_config.fault_threshold)
|
|
|
|
|
{
|
|
|
|
|
is_cfg_save = TRUE;
|
|
|
|
|
dev_config.fault_threshold = cfg->threshold_fault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_cfg_save)
|
|
|
|
|
{
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
@ -562,13 +589,13 @@ static void _wl_4G_recv_cfg_set(uint8_t *cmd, uint32_t len)
|
|
|
|
|
static void _wl_4G_recv_update_rt(uint8_t *cmd, uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
proto_head_t *head = (proto_head_t*)cmd;
|
|
|
|
|
uint32_t reset_delay = 2;
|
|
|
|
|
uint32_t reset_delay = 2;
|
|
|
|
|
|
|
|
|
|
wl_ctrl.pkt_id_recv = head->pkt_id;
|
|
|
|
|
_wl_4G_send_update_rt();
|
|
|
|
|
|
|
|
|
|
if (HAL_OK == wl_ctrl.update_rt)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
/* 延迟 2s 等待串口回复报文发送完成. */
|
|
|
|
|
flash_log_write(FLASH_LOG_TYPE_INFO, "Update APP system sleep 0s!\r\n");
|
|
|
|
|
common_sys_set(COM_SYS_RESET, (void*)&reset_delay);
|
|
|
|
@ -668,6 +695,7 @@ static void _wl_4G_recv_defect(uint8_t *cmd, uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
dau_ctrl.addr_reg = WARE_REG_ADDRESS;
|
|
|
|
|
}
|
|
|
|
|
st_data.addr_reg = dau_ctrl.addr_reg;
|
|
|
|
|
|
|
|
|
|
MONITOR_BITMAP_SET(dau_ctrl.col_flag, DAU_COL_FLAG_REG_CMP);
|
|
|
|
|
wl_ctrl.state = WL_STATE_END;
|
|
|
|
@ -729,6 +757,7 @@ static void _wl_4G_recv_fault(uint8_t *cmd, uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
dau_ctrl.addr_fault = WARE_FAULT_ADDRESS;
|
|
|
|
|
}
|
|
|
|
|
st_data.addr_fault = dau_ctrl.addr_fault;
|
|
|
|
|
|
|
|
|
|
MONITOR_BITMAP_SET(dau_ctrl.col_flag, DAU_COL_FLAG_FAULT_CMP);
|
|
|
|
|
wl_ctrl.state = WL_STATE_END;
|
|
|
|
@ -745,6 +774,16 @@ static void _wl_4G_recv_fault(uint8_t *cmd, uint32_t len)
|
|
|
|
|
_wl_4G_pkt_id_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 强制录波 */
|
|
|
|
|
static void _wl_4G_recv_wave_force(uint8_t *cmd, uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
proto_head_t *head = (proto_head_t*)cmd;
|
|
|
|
|
|
|
|
|
|
wl_ctrl.pkt_id_recv = head->pkt_id;
|
|
|
|
|
MONITOR_BITMAP_SET(dau_ctrl.col_flag, DAU_COL_FLAG_WAVE_FORCE);
|
|
|
|
|
_wl_4G_send_wave_force();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 数据回复处理. */
|
|
|
|
|
static void _wl_4G_data_process(uint8_t *cmd, uint32_t len)
|
|
|
|
|
{
|
|
|
|
@ -810,6 +849,9 @@ static void _wl_4G_data_process(uint8_t *cmd, uint32_t len)
|
|
|
|
|
case DEBUG_PRV_FAULT:
|
|
|
|
|
_wl_4G_recv_fault(cmd, len);
|
|
|
|
|
break;
|
|
|
|
|
case DEBUG_PRV_WAVE_COL:
|
|
|
|
|
_wl_4G_recv_wave_force(cmd, len);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -846,10 +888,8 @@ void _wl_4G_data_recv(void)
|
|
|
|
|
buf_l->current = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 如果收包大于协议报文长度或者大于 buf 长度, 认为报文错误. */
|
|
|
|
|
len_pkt = head->len + WL_CRC32_LEN;
|
|
|
|
|
if (wl_ctrl.cmd_buf_index + len > WL_CMD_BUF_LEN
|
|
|
|
|
|| (wl_ctrl.cmd_buf_index >= 2 && (len_pkt > WL_DMA_RX_BUF_LEN)))
|
|
|
|
|
/* 如果收包大于协议报文长度, 认为报文错误. */
|
|
|
|
|
if (wl_ctrl.cmd_buf_index + len > WL_CMD_BUF_LEN)
|
|
|
|
|
{
|
|
|
|
|
wl_ctrl.cmd_buf_index = 0;
|
|
|
|
|
continue;
|
|
|
|
@ -858,6 +898,15 @@ void _wl_4G_data_recv(void)
|
|
|
|
|
/* 将 buf 中的数据解析成命令. */
|
|
|
|
|
memcpy(&wl_ctrl.cmd_buf[wl_ctrl.cmd_buf_index], buf, len);
|
|
|
|
|
wl_ctrl.cmd_buf_index += len;
|
|
|
|
|
len_pkt = head->len + WL_CRC32_LEN;
|
|
|
|
|
|
|
|
|
|
/* 如果收包大于 buf 长度, 认为报文错误. */
|
|
|
|
|
if (wl_ctrl.cmd_buf_index >= 2
|
|
|
|
|
&& len_pkt > WL_DMA_RX_BUF_LEN)
|
|
|
|
|
{
|
|
|
|
|
wl_ctrl.cmd_buf_index = 0;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 报文头长度都不够, 不进行处理 */
|
|
|
|
|
if (wl_ctrl.cmd_buf_index < 2)
|
|
|
|
@ -926,7 +975,7 @@ static void _wl_4G_head_init(uint16_t len, uint8_t cmdType, uint8_t cmd, uint16_
|
|
|
|
|
head->pkt_id = pkt_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 初始化报文头. */
|
|
|
|
|
/* 初始化报文头, 后台出动发送的报文. */
|
|
|
|
|
static void _wl_4G_head_init_recv(uint16_t len, uint8_t cmdType, uint8_t cmd, uint16_t pkt_id)
|
|
|
|
|
{
|
|
|
|
|
proto_head_t *head = (proto_head_t*)wl_ctrl.dma_tx_buf_recv;
|
|
|
|
@ -1037,9 +1086,8 @@ static void _wl_4G_send_update_rt(void)
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
_wl_4G_head_init_recv(sizeof(proto_head_t), DEBUG_CT_REPLY, DEBUG_C_UPDATE_APP_RT, wl_ctrl.pkt_id_recv);
|
|
|
|
|
_wl_4G_head_init_recv(sizeof(proto_head_t) + sizeof(int32_t), DEBUG_CT_REPLY, DEBUG_C_UPDATE_APP_RT, wl_ctrl.pkt_id_recv);
|
|
|
|
|
|
|
|
|
|
head->len = sizeof(proto_head_t) + sizeof(int32_t);
|
|
|
|
|
*rt = wl_ctrl.update_rt;
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
@ -1054,10 +1102,14 @@ static void _wl_4G_send_update_rt(void)
|
|
|
|
|
static void _wl_4G_send_keepalive(void)
|
|
|
|
|
{
|
|
|
|
|
proto_head_t *head = (proto_head_t*)wl_ctrl.dma_tx_buf;
|
|
|
|
|
wl_proto_state_t *data = (wl_proto_state_t*)(wl_ctrl.dma_tx_buf + sizeof(proto_head_t));
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
_wl_4G_head_init(sizeof(proto_head_t), DEBUG_CT_REPLY, DEBUG_C_KEEPALIVE, wl_ctrl.pkt_id);
|
|
|
|
|
_wl_4G_head_init(sizeof(proto_head_t) + sizeof(wl_proto_state_t), DEBUG_CT_REPLY, DEBUG_C_KEEPALIVE, wl_ctrl.pkt_id);
|
|
|
|
|
|
|
|
|
|
data->is_utc_valid = dau_ctrl.is_utc_valid;
|
|
|
|
|
data->utc = dau_ctrl.utc;
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
crc = (uint32_t*)(wl_ctrl.dma_tx_buf + head->len);
|
|
|
|
@ -1121,7 +1173,7 @@ static void _wl_4G_send_realdata(void)
|
|
|
|
|
wl_tm.tm_min = wl_time.Minutes;
|
|
|
|
|
wl_tm.tm_sec = wl_time.Seconds;
|
|
|
|
|
temp = mktime(&wl_tm);
|
|
|
|
|
vty_print("tm %d %d\r\n", temp, time(NULL));
|
|
|
|
|
vty_print("tm %d\r\n", temp);
|
|
|
|
|
data->utc = temp;
|
|
|
|
|
data->run_time = HAL_GetTick() / 1000;
|
|
|
|
|
|
|
|
|
@ -1187,7 +1239,7 @@ static void _wl_4G_send_power(void)
|
|
|
|
|
|
|
|
|
|
if (m_head->len > 0)
|
|
|
|
|
{
|
|
|
|
|
memcpy(data, (&dau_ctrl.reg_power[0][0]) + m_head->index * DEBUG_DATA_SIZE, m_head->len);
|
|
|
|
|
memcpy(data, (char*)(&dau_ctrl.reg_power[0][0]) + m_head->index * DEBUG_DATA_SIZE, m_head->len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
@ -1284,6 +1336,11 @@ static void _wl_4G_send_realdata_fault(void)
|
|
|
|
|
data->fault_trig[i] = dau_ctrl.fault_trig[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
|
{
|
|
|
|
|
data->elec[i] = dau_ctrl.fault_elec[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
crc = (uint32_t*)(wl_ctrl.dma_tx_buf + head->len);
|
|
|
|
|
*crc = crc32(wl_ctrl.dma_tx_buf, head->len);
|
|
|
|
@ -1333,7 +1390,7 @@ static void _wl_4G_send_power_fault(void)
|
|
|
|
|
|
|
|
|
|
if (m_head->len > 0)
|
|
|
|
|
{
|
|
|
|
|
memcpy(data, (&dau_ctrl.fault_power[0][0]) + m_head->index * DEBUG_DATA_SIZE, m_head->len);
|
|
|
|
|
memcpy(data, (char*)(&dau_ctrl.fault_power[0][0]) + m_head->index * DEBUG_DATA_SIZE, m_head->len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
@ -1410,6 +1467,23 @@ static void _wl_4G_send_fault(void)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 强制录波报文回复 */
|
|
|
|
|
static void _wl_4G_send_wave_force(void)
|
|
|
|
|
{
|
|
|
|
|
proto_head_t *head = (proto_head_t*)wl_ctrl.dma_tx_buf_recv;
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
_wl_4G_head_init_recv(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY, DEBUG_PRV_WAVE_COL, wl_ctrl.pkt_id_recv);
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
crc = (uint32_t*)(wl_ctrl.dma_tx_buf_recv + head->len);
|
|
|
|
|
*crc = crc32(wl_ctrl.dma_tx_buf_recv, head->len);
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
|
_wl_4G_transmit(wl_ctrl.dma_tx_buf_recv, head->len + 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 数据发送 */
|
|
|
|
|
void _wl_4G_send(void)
|
|
|
|
|
{
|
|
|
|
@ -1488,7 +1562,7 @@ void _wl_4G_state_chg(void)
|
|
|
|
|
else if(wl_ctrl.keepalive < HAL_GetTick())
|
|
|
|
|
{
|
|
|
|
|
wl_ctrl.state = WL_STATE_KEEPALIVE;
|
|
|
|
|
wl_ctrl.keepalive += dev_config.keepalive;
|
|
|
|
|
wl_ctrl.keepalive = dev_config.keepalive + HAL_GetTick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1528,6 +1602,12 @@ void _wl_4G_init_soft(void)
|
|
|
|
|
_wl_4G_init_cmd_send("ATE0\r\n", 1100);
|
|
|
|
|
wl_ctrl.send_cnt++;
|
|
|
|
|
}
|
|
|
|
|
else if ((WL_STATE_AT_IPR == wl_ctrl.state) && is_timeout)
|
|
|
|
|
{
|
|
|
|
|
/* 修改波特率. */
|
|
|
|
|
_wl_4G_init_cmd_send("AT+IPR=230400\r\n", 1100);
|
|
|
|
|
wl_ctrl.send_cnt++;
|
|
|
|
|
}
|
|
|
|
|
else if ((WL_STATE_AT_QICSGP == wl_ctrl.state) && is_timeout)
|
|
|
|
|
{
|
|
|
|
|
/* 创建场景. */
|
|
|
|
@ -1585,6 +1665,13 @@ void _wl_4G_init_soft(void)
|
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
|
|
wl_ctrl.send_cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (wl_ctrl.state > WL_STATE_AT_COMP)
|
|
|
|
|
{
|
|
|
|
|
vty_print("#W4 %d\r\n", wl_ctrl.state);
|
|
|
|
|
wl_ctrl.state = WL_STATE_AT_ATE;
|
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
|
|
wl_ctrl.send_cnt = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 初始化 4G 模块硬件 */
|
|
|
|
@ -1606,12 +1693,13 @@ static void _wl_4G_hw_restart(void)
|
|
|
|
|
DBG(DBG_M_4G, "4G restart(%d)\r\n", wl_ctrl.err_cnt);
|
|
|
|
|
|
|
|
|
|
/* 初始化 4G 模块硬件. */
|
|
|
|
|
HAL_GPIO_WritePin(POWER_4G_GPIO_Port, POWER_4G_Pin, GPIO_PIN_RESET);
|
|
|
|
|
HAL_UART_Abort(wl_ctrl.uart);
|
|
|
|
|
HAL_UART_DeInit(wl_ctrl.uart);
|
|
|
|
|
memset(&wl_buf_list_rx, 0, sizeof(wl_buf_list_t));
|
|
|
|
|
HAL_GPIO_WritePin(POWER_4G_GPIO_Port, POWER_4G_Pin, GPIO_PIN_RESET);
|
|
|
|
|
_wl_4G_hw_init();
|
|
|
|
|
MX_USART3_UART_Init();
|
|
|
|
|
HAL_UARTEx_ReceiveToIdle_DMA(wl_ctrl.uart, wl_ctrl.dma_rx_buf, WL_DMA_RX_BUF_LEN);
|
|
|
|
|
|
|
|
|
|
osDelay(10000);
|
|
|
|
|
/* 20s 内要收到 4G 模块发出的 RDY. */
|
|
|
|
|
wl_ctrl.state = 0;
|
|
|
|
|
wl_ctrl.send_cnt = 0;
|
|
|
|
@ -1619,6 +1707,7 @@ static void _wl_4G_hw_restart(void)
|
|
|
|
|
wl_ctrl.cmd_buf_index = 0;
|
|
|
|
|
wl_ctrl.time_send = HAL_GetTick() + 20000;
|
|
|
|
|
wl_ctrl.err_cnt++;
|
|
|
|
|
_wl_4G_hw_init();
|
|
|
|
|
|
|
|
|
|
/* 4G 掉线后不能阻止波形采集, 掉线后默认上传完成 */
|
|
|
|
|
if (!MONITOR_BITMAP_SET(dau_ctrl.col_flag, DAU_COL_FLAG_REG_CMP))
|
|
|
|
@ -1632,6 +1721,7 @@ static void _wl_4G_hw_restart(void)
|
|
|
|
|
st_data.addr_reg = dau_ctrl.addr_reg;
|
|
|
|
|
MONITOR_BITMAP_SET(dau_ctrl.col_flag, DAU_COL_FLAG_REG_CMP);
|
|
|
|
|
}
|
|
|
|
|
#if 0
|
|
|
|
|
if (!MONITOR_BITMAP_SET(dau_ctrl.col_flag, DAU_COL_FLAG_FAULT_CMP))
|
|
|
|
|
{
|
|
|
|
|
/* 更新 flash 地址 */
|
|
|
|
@ -1643,6 +1733,7 @@ static void _wl_4G_hw_restart(void)
|
|
|
|
|
st_data.addr_fault = dau_ctrl.addr_fault;
|
|
|
|
|
MONITOR_BITMAP_SET(dau_ctrl.col_flag, DAU_COL_FLAG_FAULT_CMP);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 无线模块主任务循环. */
|
|
|
|
@ -1661,6 +1752,7 @@ static void _wl_4G_start(void *argument)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 初始化 4G 模块硬件. */
|
|
|
|
|
MX_USART3_UART_Init();
|
|
|
|
|
_wl_4G_hw_init();
|
|
|
|
|
|
|
|
|
|
/* 开启串口空闲中断收包. */
|
|
|
|
@ -1685,7 +1777,15 @@ static void _wl_4G_start(void *argument)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (WL_STATE_END == wl_ctrl.state)
|
|
|
|
|
if (WL_STATE_UPDATE == wl_ctrl.state
|
|
|
|
|
&& wl_ctrl.time_update + 10000 < HAL_GetTick())
|
|
|
|
|
{
|
|
|
|
|
/* 升级超时处理 10s */
|
|
|
|
|
wl_ctrl.mul_idx = 0;
|
|
|
|
|
wl_ctrl.update_len = 0;
|
|
|
|
|
wl_ctrl.state = WL_STATE_END;
|
|
|
|
|
}
|
|
|
|
|
else if (WL_STATE_END == wl_ctrl.state)
|
|
|
|
|
{
|
|
|
|
|
/* 计算状态机 */
|
|
|
|
|
_wl_4G_state_chg();
|
|
|
|
@ -1716,7 +1816,6 @@ static void _wl_4G_start(void *argument)
|
|
|
|
|
void wl_init(void)
|
|
|
|
|
{
|
|
|
|
|
wl_ctrl.uart = &huart3;
|
|
|
|
|
wl_ctrl.keepalive += dev_config.keepalive;
|
|
|
|
|
wl_ctrl.handle = osThreadNew(_wl_4G_start, NULL, &WL_attributes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|