FIX 1.修正南网mqtt和后台可以同时在线,优先检查南网mqtt;2.修正南网协议号为2;

main
wangbo 2 years ago
parent 698b257224
commit 29202eb8ca

@ -34,7 +34,6 @@ typedef enum modelType
typedef struct
{
e_connetType last_connect_type;
e_connetType connetType;
e_pppState net_dev_stat;
pthread_mutex_t m_mutex; // dial mutex
int m_first_inti;
@ -44,7 +43,6 @@ typedef struct
network_ctrl_t network_ctrl;
extern int _network_change_apn(const char *apn);
extern void _network_set_connect_type(e_connetType type);
extern int network_handle_init(void);
#endif
#endif

@ -121,7 +121,8 @@ typedef enum _BOOT_MSG
BOOT_SYSTEM_RESET,
BOOT_DAU_ERR_RESET,
BOOT_PPP_NO_FOUND,
BOOT_PPP_FOUND_LINK_FAIL,
BOOT_PPP_FOUND_CSG_LINK_FAIL,
BOOT_PPP_FOUND_MQTT_LINK_FAIL,
BOOT_TTYUSB_NO_FOUND,
BOOT_MAX,
} BOOT_MSG;

@ -475,6 +475,7 @@ int _csg_set_system_config(char *databuf, int datalen)
LOG("%d %d %d %d", csg.server_ip & 0xff, (csg.server_ip >> 8) & 0xff,
(csg.server_ip >> 16) & 0xff, (csg.server_ip >> 24) & 0xff);
csg.server_port = (uint16_t)pcfg->ServerIP1_Port;
LOG("CommunicationMode=%d\n", pcfg->CommunicationMode);
memcpy(&pparam_config->gateway, databuf, datalen);
@ -741,7 +742,7 @@ void *_csg_manage_handle(void *arg)
|| pparam_config->gateway.ServerIP1[2] == 0
|| pparam_config->gateway.ServerIP1[3] == 0
|| pparam_config->gateway.ServerIP1_Port == 0
|| pparam_config->gateway.CommunicationMode != 1)
/*|| pparam_config->gateway.CommunicationMode != 1*/)
{
sleep(1);
DBG(DBG_M_CA_CSG_ERR, "param error: ServerIP1:%d.%d.%d.%d ServerIP1_Port:%d CommunicationMode:%d\r\n",

@ -159,12 +159,6 @@ int _dbg_pkt_config_set(debug_msg_info_t *msg)
_network_change_apn((char *)pcfg->gateway.apn);
}
if (pparam_config->gateway.radioType != pcfg->gateway.radioType
&& pcfg->gateway.radioType == 1)
{
_network_set_connect_type(CONNET4G);
}
strncpy(host.name, (char *)pcfg->gateway.DeviceNum, 15);
sysctrl.dev_hex_id = dev_id_2_hex(host.name);

@ -39,6 +39,7 @@
/* Private variables ---------------------------------------------------------*/
//mqtt_ctrl_t mqtt_ctrl;
int mqtt_reconn_times = 0;
/* Private function prototypes -----------------------------------------------*/
@ -474,7 +475,7 @@ void *_mqtt_manage_thread(void *args)
heartbeat_time = cur_time;
while (1)
{
if (pparam_config->gateway.CommunicationMode != 5)
if (pparam_config->gateway.CommunicationMode != 2)
{
sleep(1);
DBG(DBG_M_CA_MQTT_ERR, "CommunicationMode %d", pparam_config->gateway.CommunicationMode);
@ -493,7 +494,7 @@ void *_mqtt_manage_thread(void *args)
heartbeat_time = cur_time;
_mqtt_heartbeat_upload();
}
sleep(2);
sleep(1);
}
}

@ -27,6 +27,7 @@
#include "debug.h"
#include "common.h"
extern int csg_reconn_times;
extern int mqtt_reconn_times;
/* Private define ------------------------------------------------------------*/
int _network_chat(int fd, const char *at, const char *expect, int timeout, char **response, bool IsPrintf)
@ -175,11 +176,6 @@ int _network_AT_read_operation(const char *Devname, const char *cmd, \
return 0;
}
void _network_set_connect_type(e_connetType type)
{
network_ctrl.connetType = type;
}
int _network_change_apn(const char *apn)
{
int i=0,num;
@ -260,22 +256,6 @@ void _network_kill_ppp()
system(cmd);
}
void _network_check_change()
{
if (network_ctrl.connetType == network_ctrl.last_connect_type)
{
return ;
}
else
{
if (network_ctrl.connetType == CONNET4G)
{
network_ctrl.net_dev_stat = PPP_OFF;
}
network_ctrl.last_connect_type = network_ctrl.connetType;
}
}
int _network_check_usb_exist(const char* iDevPath)
{
int iReturnCode = 0;
@ -474,9 +454,19 @@ void *_network_manage_thread(void *args)
// found ppp0
ppp_not_found_cnt = 0;
// The connection still fails in the presence of ppp0 and needs to be restarted
if (csg_reconn_times > 10)
if (pparam_config->gateway.CommunicationMode == 2)
{
if (mqtt_reconn_times > 6)
{
reboot_system(LOG_NETWORK, BOOT_PPP_FOUND_MQTT_LINK_FAIL);
}
}
else
{
reboot_system(LOG_NETWORK, BOOT_PPP_FOUND_LINK_FAIL);
if (csg_reconn_times > 10)
{
reboot_system(LOG_NETWORK, BOOT_PPP_FOUND_CSG_LINK_FAIL);
}
}
}
}

@ -606,7 +606,8 @@ boot_msg_t g_bootmsg[] =
{BOOT_SYSTEM_RESET, "System reboot..."},
{BOOT_DAU_ERR_RESET, "DAU communicate ERROR."},
{BOOT_PPP_NO_FOUND, "ppp0 not found."},
{BOOT_PPP_FOUND_LINK_FAIL, "ppp0 found but link failed."},
{BOOT_PPP_FOUND_CSG_LINK_FAIL, "ppp0 found but csg link failed."},
{BOOT_PPP_FOUND_MQTT_LINK_FAIL, "ppp0 found but mqtt link failed."},
{BOOT_TTYUSB_NO_FOUND, "/dev/ttyUSB3 not found."},
{BOOT_MAX, NULL}
};

Loading…
Cancel
Save