|
|
@ -58,6 +58,7 @@
|
|
|
|
#define WL_SOFT_INIT_ERR 5 // 软件初始化错误最大次数
|
|
|
|
#define WL_SOFT_INIT_ERR 5 // 软件初始化错误最大次数
|
|
|
|
#define WL_DATA_ERR 3 // 数据发送错误最大次数
|
|
|
|
#define WL_DATA_ERR 3 // 数据发送错误最大次数
|
|
|
|
#define WL_SLEEP_TIME 1800 // 休眠时间
|
|
|
|
#define WL_SLEEP_TIME 1800 // 休眠时间
|
|
|
|
|
|
|
|
#define WL_SLEEP_TIME_4G 21600 // 因为 4G 故障或者连接不上服务器, 直接休眠 6 小时, 这里为了保护 4G 模块不让 4G 模块频繁重启.
|
|
|
|
|
|
|
|
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
|
|
/* 状态机状态. */
|
|
|
|
/* 状态机状态. */
|
|
|
@ -68,6 +69,7 @@ typedef enum
|
|
|
|
WL_STATE_AT_IPR,
|
|
|
|
WL_STATE_AT_IPR,
|
|
|
|
WL_STATE_AT_QICSGP,
|
|
|
|
WL_STATE_AT_QICSGP,
|
|
|
|
WL_STATE_AT_QIACT,
|
|
|
|
WL_STATE_AT_QIACT,
|
|
|
|
|
|
|
|
WL_STATE_AT_QIACT_Q,
|
|
|
|
WL_STATE_AT_CSQ,
|
|
|
|
WL_STATE_AT_CSQ,
|
|
|
|
WL_STATE_AT_QCCID,
|
|
|
|
WL_STATE_AT_QCCID,
|
|
|
|
WL_STATE_AT_QICFGTS,
|
|
|
|
WL_STATE_AT_QICFGTS,
|
|
|
@ -89,6 +91,13 @@ typedef enum
|
|
|
|
WL_STATE_END = 255
|
|
|
|
WL_STATE_END = 255
|
|
|
|
} WL_STATE_E;
|
|
|
|
} WL_STATE_E;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 状态机状态. */
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
WL_SLEEP_POWER = 0,
|
|
|
|
|
|
|
|
WL_SLEEP_DAU
|
|
|
|
|
|
|
|
} WL_SLEEP_E;
|
|
|
|
|
|
|
|
|
|
|
|
/* RS485调试通讯协议器件信息. */
|
|
|
|
/* RS485调试通讯协议器件信息. */
|
|
|
|
typedef struct
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -178,6 +187,13 @@ typedef struct
|
|
|
|
uint32_t utc; // gps 对时时间
|
|
|
|
uint32_t utc; // gps 对时时间
|
|
|
|
} wl_proto_state_t;
|
|
|
|
} wl_proto_state_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint8_t type; // 休眠原因
|
|
|
|
|
|
|
|
uint8_t reserve[3]; // 保留位
|
|
|
|
|
|
|
|
uint32_t data; // 休眠时间
|
|
|
|
|
|
|
|
} wl_proto_sleep_t;
|
|
|
|
|
|
|
|
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
const osThreadAttr_t WL_attributes =
|
|
|
|
const osThreadAttr_t WL_attributes =
|
|
|
@ -188,9 +204,6 @@ const osThreadAttr_t WL_attributes =
|
|
|
|
};
|
|
|
|
};
|
|
|
|
wl_buf_list_t wl_buf_list_rx;
|
|
|
|
wl_buf_list_t wl_buf_list_rx;
|
|
|
|
wl_ctrl_t wl_ctrl;
|
|
|
|
wl_ctrl_t wl_ctrl;
|
|
|
|
static RTC_DateTypeDef wl_date;
|
|
|
|
|
|
|
|
static RTC_TimeTypeDef wl_time;
|
|
|
|
|
|
|
|
static struct tm wl_tm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
static void _wl_4G_send_dev_set(void);
|
|
|
|
static void _wl_4G_send_dev_set(void);
|
|
|
@ -280,6 +293,38 @@ static void _wl_4G_AT_QCCID_process(uint8_t *cmd)
|
|
|
|
wl_ctrl.QCCID[j] = 0;
|
|
|
|
wl_ctrl.QCCID[j] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* AT 命令 QIACT 返回数据处理 "+QIACT: 1,1,1,"10.7.157.1" */
|
|
|
|
|
|
|
|
static int32_t _wl_4G_AT_QIACT_process(uint8_t *cmd)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint8_t i = 0;
|
|
|
|
|
|
|
|
uint8_t idx = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(cmd[i] != ' ')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (0 == cmd[i])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(cmd[i] != 0 && cmd[i] != '\r' && cmd[i] != '\n')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (1 == idx)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return cmd[i] == '1' ? TRUE : FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (',' == cmd[i])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
idx++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* AT 命令回复处理. */
|
|
|
|
/* AT 命令回复处理. */
|
|
|
|
static void _wl_4G_AT_process(uint8_t *cmd)
|
|
|
|
static void _wl_4G_AT_process(uint8_t *cmd)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -302,7 +347,30 @@ static void _wl_4G_AT_process(uint8_t *cmd)
|
|
|
|
HAL_UARTEx_ReceiveToIdle_DMA(wl_ctrl.uart, wl_ctrl.dma_rx_buf, WL_DMA_RX_BUF_LEN);
|
|
|
|
HAL_UARTEx_ReceiveToIdle_DMA(wl_ctrl.uart, wl_ctrl.dma_rx_buf, WL_DMA_RX_BUF_LEN);
|
|
|
|
osDelay(1000);
|
|
|
|
osDelay(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wl_ctrl.state < WL_STATE_AT_QIOPEN)
|
|
|
|
|
|
|
|
|
|
|
|
if (WL_STATE_AT_QIACT_Q == wl_ctrl.state)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (wl_ctrl.state_QIACT)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wl_ctrl.state++;
|
|
|
|
|
|
|
|
wl_ctrl.send_cnt = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wl_ctrl.state = WL_STATE_AT_QIACT;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (WL_STATE_AT_QIACT == wl_ctrl.state)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wl_ctrl.state++;
|
|
|
|
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
|
|
|
|
|
if (wl_ctrl.send_cnt)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wl_ctrl.send_cnt--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (wl_ctrl.state < WL_STATE_AT_QIOPEN)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wl_ctrl.state++;
|
|
|
|
wl_ctrl.state++;
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
@ -323,15 +391,35 @@ static void _wl_4G_AT_process(uint8_t *cmd)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (0 == strncmp((char*)cmd, "+QCCID", 6))
|
|
|
|
else if (0 == strncmp((char*)cmd, "+QCCID", 6))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 获取信号质量. */
|
|
|
|
/* 获卡信息. */
|
|
|
|
_wl_4G_AT_QCCID_process(cmd);
|
|
|
|
_wl_4G_AT_QCCID_process(cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (0 == strncmp((char*)cmd, "+QIACT", 6))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* 获取激活拨号信息. */
|
|
|
|
|
|
|
|
if (_wl_4G_AT_QIACT_process(cmd))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wl_ctrl.state_QIACT = TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (0 == strncmp((char*)cmd, "ERROR", 5))
|
|
|
|
else if (0 == strncmp((char*)cmd, "ERROR", 5))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 命令执行失败. */
|
|
|
|
/* 命令执行失败. */
|
|
|
|
|
|
|
|
if (WL_STATE_AT_QIACT == wl_ctrl.state)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wl_ctrl.state++;
|
|
|
|
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
|
|
|
|
|
if (wl_ctrl.send_cnt)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wl_ctrl.send_cnt--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
wl_ctrl.time_send = HAL_GetTick() + 1000;
|
|
|
|
wl_ctrl.time_send = HAL_GetTick() + 1000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 处理接收到的 AT 指令. */
|
|
|
|
/* 处理接收到的 AT 指令. */
|
|
|
|
void _wl_4G_AT_recv(void)
|
|
|
|
void _wl_4G_AT_recv(void)
|
|
|
@ -889,6 +977,12 @@ static void _wl_4G_recv_sleep(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32_t sleep_time = WL_SLEEP_TIME;
|
|
|
|
uint32_t sleep_time = WL_SLEEP_TIME;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 复位标志位, 不然会一直发送 */
|
|
|
|
|
|
|
|
if (dau_ctrl.is_dau_fault)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dau_ctrl.is_dau_fault = FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_ctrl.state = WL_STATE_END;
|
|
|
|
wl_ctrl.state = WL_STATE_END;
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
|
wl_ctrl.time_send = 0;
|
|
|
|
wl_ctrl.send_cnt = 0;
|
|
|
|
wl_ctrl.send_cnt = 0;
|
|
|
@ -1303,7 +1397,7 @@ static void _wl_4G_send_keepalive(void)
|
|
|
|
_wl_4G_head_init(sizeof(proto_head_t) + sizeof(wl_proto_state_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_ok;
|
|
|
|
data->is_utc_valid = dau_ctrl.is_utc_ok;
|
|
|
|
data->utc = dau_ctrl.utc;
|
|
|
|
data->utc = dau_ctrl.utc + 28800;
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(wl_ctrl.dma_tx_buf + head->len);
|
|
|
|
crc = (uint32_t*)(wl_ctrl.dma_tx_buf + head->len);
|
|
|
@ -1326,13 +1420,21 @@ static void _wl_4G_send_keepalive(void)
|
|
|
|
static void _wl_4G_send_sleep(void)
|
|
|
|
static void _wl_4G_send_sleep(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)wl_ctrl.dma_tx_buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)wl_ctrl.dma_tx_buf;
|
|
|
|
uint32_t *data = (uint32_t*)(wl_ctrl.dma_tx_buf + sizeof(proto_head_t));
|
|
|
|
wl_proto_sleep_t *data = (wl_proto_sleep_t*)(wl_ctrl.dma_tx_buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_wl_4G_head_init(sizeof(proto_head_t) + sizeof(uint32_t), DEBUG_CT_PRV_REPLY, DEBUG_PRV_SLEEP, wl_ctrl.pkt_id);
|
|
|
|
_wl_4G_head_init(sizeof(proto_head_t) + sizeof(wl_proto_sleep_t), DEBUG_CT_PRV_REPLY, DEBUG_PRV_SLEEP, wl_ctrl.pkt_id);
|
|
|
|
|
|
|
|
|
|
|
|
*data = WL_SLEEP_TIME;
|
|
|
|
data->data = WL_SLEEP_TIME;
|
|
|
|
|
|
|
|
if (dau_ctrl.is_dau_fault)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->type = WL_SLEEP_DAU;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->type = WL_SLEEP_POWER;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(wl_ctrl.dma_tx_buf + head->len);
|
|
|
|
crc = (uint32_t*)(wl_ctrl.dma_tx_buf + head->len);
|
|
|
@ -1386,16 +1488,7 @@ static void _wl_4G_send_realdata(void)
|
|
|
|
data->energy_mode = ADC_ctrl.energy_mode;
|
|
|
|
data->energy_mode = ADC_ctrl.energy_mode;
|
|
|
|
data->temperature = ADC_ctrl.ADCi_temp;
|
|
|
|
data->temperature = ADC_ctrl.ADCi_temp;
|
|
|
|
data->CSQ = wl_ctrl.CSQ;
|
|
|
|
data->CSQ = wl_ctrl.CSQ;
|
|
|
|
|
|
|
|
data->utc = dau_ctrl.col_utc;
|
|
|
|
HAL_RTC_GetTime(&hrtc, &wl_time, RTC_FORMAT_BIN);
|
|
|
|
|
|
|
|
HAL_RTC_GetDate(&hrtc, &wl_date, RTC_FORMAT_BIN);
|
|
|
|
|
|
|
|
wl_tm.tm_year = wl_date.Year + 100;
|
|
|
|
|
|
|
|
wl_tm.tm_mon = wl_date.Month - 1;
|
|
|
|
|
|
|
|
wl_tm.tm_mday = wl_date.Date;
|
|
|
|
|
|
|
|
wl_tm.tm_hour = wl_time.Hours;
|
|
|
|
|
|
|
|
wl_tm.tm_min = wl_time.Minutes;
|
|
|
|
|
|
|
|
wl_tm.tm_sec = wl_time.Seconds;
|
|
|
|
|
|
|
|
data->utc = mktime(&wl_tm);
|
|
|
|
|
|
|
|
data->run_time = HAL_GetTick() / 1000;
|
|
|
|
data->run_time = HAL_GetTick() / 1000;
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
@ -1550,7 +1643,7 @@ static void _wl_4G_send_realdata_fault(void)
|
|
|
|
_wl_4G_head_init(sizeof(proto_head_t) + sizeof(wl_proto_realdata_fault_t), DEBUG_CT_PRV_REPLY, DEBUG_PRV_REALDATA_FUALT, wl_ctrl.pkt_id);
|
|
|
|
_wl_4G_head_init(sizeof(proto_head_t) + sizeof(wl_proto_realdata_fault_t), DEBUG_CT_PRV_REPLY, DEBUG_PRV_REALDATA_FUALT, wl_ctrl.pkt_id);
|
|
|
|
|
|
|
|
|
|
|
|
/* 装填数据. */
|
|
|
|
/* 装填数据. */
|
|
|
|
data->utc = dau_ctrl.fault_utc;
|
|
|
|
data->utc = dau_ctrl.fault_utc + 28800;
|
|
|
|
data->ns = dau_ctrl.fault_ns;
|
|
|
|
data->ns = dau_ctrl.fault_ns;
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_PORT_DEFECT_CNT; i++)
|
|
|
|
for(i = 0; i < DAU_PORT_DEFECT_CNT; i++)
|
|
|
@ -1828,7 +1921,8 @@ void _wl_4G_send(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (WL_STATE_SLEEP == wl_ctrl.state)
|
|
|
|
else if (WL_STATE_SLEEP == wl_ctrl.state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ADC_ENERGY_SLEEP == ADC_ctrl.energy_mode)
|
|
|
|
if (ADC_ENERGY_SLEEP == ADC_ctrl.energy_mode
|
|
|
|
|
|
|
|
|| dau_ctrl.is_dau_fault)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_wl_4G_send_sleep();
|
|
|
|
_wl_4G_send_sleep();
|
|
|
|
wl_ctrl.send_cnt++;
|
|
|
|
wl_ctrl.send_cnt++;
|
|
|
@ -1872,6 +1966,11 @@ void _wl_4G_state_chg(void)
|
|
|
|
wl_ctrl.state = WL_STATE_KEEPALIVE;
|
|
|
|
wl_ctrl.state = WL_STATE_KEEPALIVE;
|
|
|
|
wl_ctrl.keepalive = HAL_GetTick() + dev_config.keepalive * 60000;
|
|
|
|
wl_ctrl.keepalive = HAL_GetTick() + dev_config.keepalive * 60000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(dau_ctrl.is_dau_fault)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* DAU 启动失败, 设备休眠 */
|
|
|
|
|
|
|
|
wl_ctrl.state = WL_STATE_SLEEP;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 初始化 4G 模块软件 */
|
|
|
|
/* 初始化 4G 模块软件 */
|
|
|
@ -1926,10 +2025,17 @@ void _wl_4G_init_soft(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((WL_STATE_AT_QIACT == wl_ctrl.state) && is_timeout)
|
|
|
|
else if ((WL_STATE_AT_QIACT == wl_ctrl.state) && is_timeout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 使能场景 */
|
|
|
|
/* 使能场景, 不论返回值是多少, 以查询命令为准 */
|
|
|
|
_wl_4G_init_cmd_send("AT+QIACT=1\r\n", 33000);
|
|
|
|
_wl_4G_init_cmd_send("AT+QIACT=1\r\n", 33000);
|
|
|
|
wl_ctrl.send_cnt++;
|
|
|
|
wl_ctrl.send_cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ((WL_STATE_AT_QIACT_Q == wl_ctrl.state) && is_timeout)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* 查询使能场景是否成功, +QIACT: 1,1,1,"10.7.157.1 */
|
|
|
|
|
|
|
|
osDelay(5000);
|
|
|
|
|
|
|
|
_wl_4G_init_cmd_send("AT+QIACT?\r\n", 1100);
|
|
|
|
|
|
|
|
wl_ctrl.send_cnt++;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if ((WL_STATE_AT_CSQ == wl_ctrl.state) && is_timeout)
|
|
|
|
else if ((WL_STATE_AT_CSQ == wl_ctrl.state) && is_timeout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 读取网络信号质量. */
|
|
|
|
/* 读取网络信号质量. */
|
|
|
@ -1960,7 +2066,7 @@ void _wl_4G_init_soft(void)
|
|
|
|
else if ((WL_STATE_AT_QIOPEN == wl_ctrl.state) && is_timeout)
|
|
|
|
else if ((WL_STATE_AT_QIOPEN == wl_ctrl.state) && is_timeout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 连接远程服务器. */
|
|
|
|
/* 连接远程服务器. */
|
|
|
|
snprintf((char*)wl_ctrl.dma_tx_buf, WL_DMA_TX_BUF_LEN, "AT+QIOPEN=1,0,\"TCP\",\"%d.%d.%d.%d\",%d,19421,2\r\n",
|
|
|
|
snprintf((char*)wl_ctrl.dma_tx_buf, WL_DMA_TX_BUF_LEN, "AT+QIOPEN=1,0,\"TCP\",\"%d.%d.%d.%d\",%d,0,2\r\n",
|
|
|
|
dev_info.server_ip[0], dev_info.server_ip[1], dev_info.server_ip[2],
|
|
|
|
dev_info.server_ip[0], dev_info.server_ip[1], dev_info.server_ip[2],
|
|
|
|
dev_info.server_ip[3], dev_info.server_port);
|
|
|
|
dev_info.server_ip[3], dev_info.server_port);
|
|
|
|
//_wl_4G_init_cmd_send("AT+QIOPEN=1,0,\"TCP\",\"111.47.21.142\",8809,19421,2\r\n", 10000);
|
|
|
|
//_wl_4G_init_cmd_send("AT+QIOPEN=1,0,\"TCP\",\"111.47.21.142\",8809,19421,2\r\n", 10000);
|
|
|
@ -2002,12 +2108,6 @@ static void _wl_4G_hw_close(uint32_t sleep_time)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HAL_GPIO_WritePin(POWER_4G_GPIO_Port, POWER_4G_Pin, GPIO_PIN_RESET);
|
|
|
|
HAL_GPIO_WritePin(POWER_4G_GPIO_Port, POWER_4G_Pin, GPIO_PIN_RESET);
|
|
|
|
|
|
|
|
|
|
|
|
if (ADC_ctrl.energy_mode != ADC_ENERGY_NORMAL
|
|
|
|
|
|
|
|
&& sleep_time < WL_SLEEP_TIME)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sleep_time = WL_SLEEP_TIME;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flash_log_write(FLASH_LOG_TYPE_WARNING, "Server is disconnect system sleep %ds!\r\n", sleep_time);
|
|
|
|
flash_log_write(FLASH_LOG_TYPE_WARNING, "Server is disconnect system sleep %ds!\r\n", sleep_time);
|
|
|
|
common_sys_set(COM_SYS_SHUTDOWN, (void*)&sleep_time);
|
|
|
|
common_sys_set(COM_SYS_SHUTDOWN, (void*)&sleep_time);
|
|
|
|
|
|
|
|
|
|
|
@ -2027,14 +2127,16 @@ static void _wl_4G_hw_restart(void)
|
|
|
|
HAL_UART_Abort(wl_ctrl.uart);
|
|
|
|
HAL_UART_Abort(wl_ctrl.uart);
|
|
|
|
HAL_UART_DeInit(wl_ctrl.uart);
|
|
|
|
HAL_UART_DeInit(wl_ctrl.uart);
|
|
|
|
|
|
|
|
|
|
|
|
if (wl_ctrl.err_cnt > 3)
|
|
|
|
if (wl_ctrl.err_cnt >= 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_wl_4G_hw_close(dev_config.collect_interval * 60);
|
|
|
|
/* 不建议频繁重启 4G 模块, 如果连接出现问题直接休眠 6 小时 */
|
|
|
|
|
|
|
|
_wl_4G_hw_close(WL_SLEEP_TIME_4G);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 初始化软硬件 */
|
|
|
|
/* 初始化软硬件 */
|
|
|
|
osDelay(10000);
|
|
|
|
osDelay(10000);
|
|
|
|
wl_ctrl.state = 0;
|
|
|
|
wl_ctrl.state = 0;
|
|
|
|
|
|
|
|
wl_ctrl.state_QIACT = 0;
|
|
|
|
wl_ctrl.send_cnt = 0;
|
|
|
|
wl_ctrl.send_cnt = 0;
|
|
|
|
wl_ctrl.mul_idx = 0;
|
|
|
|
wl_ctrl.mul_idx = 0;
|
|
|
|
wl_ctrl.cmd_buf_index = 0;
|
|
|
|
wl_ctrl.cmd_buf_index = 0;
|
|
|
@ -2089,6 +2191,7 @@ static void _wl_4G_start(void *argument)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
osDelay(200);
|
|
|
|
osDelay(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
osDelay(3000);
|
|
|
|
|
|
|
|
|
|
|
|
/* 初始化 4G 模块硬件 */
|
|
|
|
/* 初始化 4G 模块硬件 */
|
|
|
|
MX_USART3_UART_Init();
|
|
|
|
MX_USART3_UART_Init();
|
|
|
|