|
|
@ -24,6 +24,9 @@
|
|
|
|
#include "debug.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "ca_cau.h"
|
|
|
|
#include "ca_cau.h"
|
|
|
|
#include "ca_dbg.h"
|
|
|
|
#include "ca_dbg.h"
|
|
|
|
|
|
|
|
#include "ca_param.h"
|
|
|
|
|
|
|
|
#include "ca_network.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
@ -34,7 +37,7 @@
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
csg_t csg;
|
|
|
|
csg_t csg;
|
|
|
|
int csg_reconn_times = 0;
|
|
|
|
int csg_reconn_times = 0;
|
|
|
|
extern cau_collect_flag;
|
|
|
|
extern int cau_collect_flag;
|
|
|
|
//extern int upg_state;
|
|
|
|
//extern int upg_state;
|
|
|
|
//char csg_deliver_path[128] = {0};
|
|
|
|
//char csg_deliver_path[128] = {0};
|
|
|
|
|
|
|
|
|
|
|
@ -376,29 +379,129 @@ int _csg_response_realtime_data(int sendtype)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int _csg_query_device_config()
|
|
|
|
int _csg_get_system_config()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct in_addr addr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strncpy((char *)pparam_config->gateway.DeviceNum, host.name, 15);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inet_pton(AF_INET, device_info.host_ip, &addr);
|
|
|
|
|
|
|
|
memcpy(pparam_config->gateway.LocalIP1, &addr.s_addr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(pparam_config->gateway.ServerIP1, &csg.server.sin_addr.s_addr, 4);
|
|
|
|
|
|
|
|
pparam_config->gateway.ServerIP1_Port = csg.server_port;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char buf[64] = {0};
|
|
|
|
|
|
|
|
sprintf(buf, "V%s", host.version);
|
|
|
|
|
|
|
|
strcpy((char *)pparam_config->gateway.reserved, buf);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_csg_send_packet(Res_ReqSysCfg, (char *)&pparam_config->gateway, sizeof(GateWay_t));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int _csg_set_system_config(char *databuf, int datalen)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (datalen != sizeof(GateWay_t))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
DBG(DBG_M_CA_CSG_ERR, "msg reallen:%d,expect len:%d\n", datalen, sizeof(GateWay_t));
|
|
|
|
|
|
|
|
return _csg_send_packet(Res_SetSysCfg, (char *)&result, sizeof(result));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GateWay_t *pcfg = (GateWay_t *)databuf;
|
|
|
|
|
|
|
|
if (strncmp((char *)pcfg->apn, (char *)pparam_config->gateway.apn,
|
|
|
|
|
|
|
|
sizeof(pparam_config->gateway.apn)) != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_network_change_apn((char *)pcfg->apn);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strncpy(host.name, (char *)pcfg->DeviceNum, 15);
|
|
|
|
|
|
|
|
sysctrl.dev_hex_id = dev_id_2_hex(host.name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(device_info.host_ip, "%d.%d.%d.%d", pcfg->LocalIP1[0],
|
|
|
|
|
|
|
|
pcfg->LocalIP1[1], pcfg->LocalIP1[2], pcfg->LocalIP1[3]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char serverip[16] = {0};
|
|
|
|
|
|
|
|
sprintf(serverip, "%d.%d.%d.%d", pcfg->ServerIP1[0],
|
|
|
|
|
|
|
|
pcfg->ServerIP1[1], pcfg->ServerIP1[2], pcfg->ServerIP1[3]);
|
|
|
|
|
|
|
|
csg.server_ip = inet_addr(serverip);
|
|
|
|
|
|
|
|
LOG("serverip=0x%x", csg.server_ip);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(&pparam_config->gateway, databuf, datalen);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
param_save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vtysh_config_save();
|
|
|
|
|
|
|
|
uint8_t mac[MAC_ADDR_LEN] = {0};
|
|
|
|
|
|
|
|
mac_generate_from_ip(device_info.host_ip, mac);
|
|
|
|
|
|
|
|
memcpy(device_info.mac, mac, MAC_ADDR_LEN);
|
|
|
|
|
|
|
|
vtysh_eth0_save();
|
|
|
|
|
|
|
|
vtysh_device_save();
|
|
|
|
|
|
|
|
reboot_system(LOG_DEBUG, BOOT_REMOTE_IP_CHANGE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int _csg_get_device_config()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_csg_send_packet(Res_ReqDevCfg, (char *)&pparam_config->landHexCfg, sizeof(LandDevCfg_t));
|
|
|
|
_csg_send_packet(Res_ReqDevCfg, (char *)&pparam_config->landHexCfg, sizeof(LandDevCfg_t));
|
|
|
|
LOG("cau1En:%d", pparam_config->landHexCfg.cau1En);
|
|
|
|
|
|
|
|
LOG("cau1level:%d", pparam_config->landHexCfg.cau1level);
|
|
|
|
|
|
|
|
LOG("cau1Space:%d", pparam_config->landHexCfg.cau1Space);
|
|
|
|
|
|
|
|
LOG("cau1Ch1:%d", pparam_config->landHexCfg.cau1Ch1);
|
|
|
|
|
|
|
|
LOG("cau1Ch2:%d", pparam_config->landHexCfg.cau1Ch2);
|
|
|
|
|
|
|
|
LOG("cau1Ch3:%d", pparam_config->landHexCfg.cau1Ch3);
|
|
|
|
|
|
|
|
LOG("cau1Ch4:%d", pparam_config->landHexCfg.cau1Ch4);
|
|
|
|
|
|
|
|
LOG("cau1Ch5:%d", pparam_config->landHexCfg.cau1Ch5);
|
|
|
|
|
|
|
|
LOG("cau1Ch6:%d", pparam_config->landHexCfg.cau1Ch6);
|
|
|
|
|
|
|
|
LOG("cau1Ch7:%d", pparam_config->landHexCfg.cau1Ch7);
|
|
|
|
|
|
|
|
LOG("cau1Ch8:%d", pparam_config->landHexCfg.cau1Ch8);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int _csg_set_device_config()
|
|
|
|
int _csg_set_device_config(char *databuf, int datalen)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (datalen != sizeof(LandDevCfg_t))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
DBG(DBG_M_CA_CSG_ERR, "msg reallen:%d,expect len:%d\n", datalen, sizeof(LandDevCfg_t));
|
|
|
|
|
|
|
|
return _csg_send_packet(Res_SetDevCfg, (char *)&result, sizeof(result));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(&pparam_config->landHexCfg, databuf, sizeof(LandDevCfg_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
param_save();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int _csg_get_cau_cfg()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char buf[1024] = {0};
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
for (i = 0; i < 24; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
memcpy(buf + i * 32, &pparam_config->cauParam[i], 24);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
len = 32 * 24;
|
|
|
|
|
|
|
|
_csg_send_packet(Res_ReqCauCfg, buf, len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int _csg_set_cau_cfg(char *databuf, int datalen)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (datalen != 1024)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DBG(DBG_M_CA_CSG_ERR, "msg reallen:%d,expect len:1024\n", datalen);
|
|
|
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
return _csg_send_packet(Res_SetCauCfg, (char *)&result, sizeof(result));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 24; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
memcpy(&pparam_config->cauParam[i], databuf + i * 32, 24);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
param_save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = 1;
|
|
|
|
|
|
|
|
return _csg_send_packet(Res_SetCauCfg, (char *)&result, sizeof(result));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
int _csg_upload_realtime_data()
|
|
|
|
int _csg_upload_realtime_data()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -453,7 +556,9 @@ int _csg_recv_process(char *buf)
|
|
|
|
//----------------------------
|
|
|
|
//----------------------------
|
|
|
|
char str[128] = {0};
|
|
|
|
char str[128] = {0};
|
|
|
|
time2str(str);
|
|
|
|
time2str(str);
|
|
|
|
DBG(DBG_M_CA_CSG, "%s cmd=0x%x\n", str, head->Type);
|
|
|
|
int dataLen = head->Len - LandPackHeadTailLen;
|
|
|
|
|
|
|
|
char *pdata = buf + sizeof(LandPkHead);
|
|
|
|
|
|
|
|
DBG(DBG_M_CA_CSG, "%s cmd=0x%x len=%d\n", str, head->Type, dataLen);
|
|
|
|
//----------------------------
|
|
|
|
//----------------------------
|
|
|
|
switch (head->Type)
|
|
|
|
switch (head->Type)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -463,11 +568,23 @@ int _csg_recv_process(char *buf)
|
|
|
|
case Cmd_ReqRTD2:
|
|
|
|
case Cmd_ReqRTD2:
|
|
|
|
_csg_response_realtime_data(1);
|
|
|
|
_csg_response_realtime_data(1);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Cmd_ReqSysCfg:
|
|
|
|
|
|
|
|
_csg_get_system_config();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Cmd_SetSysCfg:
|
|
|
|
|
|
|
|
_csg_set_system_config(pdata, dataLen);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case Cmd_ReqDevCfg:
|
|
|
|
case Cmd_ReqDevCfg:
|
|
|
|
_csg_query_device_config();
|
|
|
|
_csg_get_device_config();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case Cmd_SetDevCfg:
|
|
|
|
case Cmd_SetDevCfg:
|
|
|
|
_csg_set_device_config();
|
|
|
|
_csg_set_device_config(pdata, dataLen);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Cmd_ReqCauCfg:
|
|
|
|
|
|
|
|
_csg_get_cau_cfg();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Cmd_SetCauCfg:
|
|
|
|
|
|
|
|
_csg_set_cau_cfg(pdata, dataLen);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|