FIX | 修改配置结构体, 删除不需要的配置

master
yuliang 6 months ago
parent 61effcd877
commit a18ee4d648

@ -386,7 +386,6 @@ extern void common_sys_set(uint8_t flag, void *arg);
extern uint32_t abs_cal(int32_t a, int32_t b);
extern uint32_t abs_cal_u(uint32_t a, uint32_t b);
extern void rtc_time_set(uint32_t utc);
extern void restart_ontime(void);
#endif
/******************* (C) COPYRIGHT LandPower ***** END OF FILE ****************/

@ -55,14 +55,14 @@
#define DEV_VERSION_STR_LEN 32
#define DEV_NAME_LEN 128
#define DEV_RESET_INFO_NUM 10
#define DEV_APN_LEN 16
#define DEV_APN_LEN_LONG 64
#define DEV_APN_LEN 128
#define DEV_CONFIG_SIZE 1024
#define DEV_RECORD_SIZE 512
/* 默认串口密码. */
#define DEV_DEFAULT_PASSWORD "ld.admin"
#define DEV_DEFAULT_PASSWORD "root"
#define DEV_DEFAULT_HOST "landpower"
/* Exported types ------------------------------------------------------------*/
/* 重启类型号. */
@ -169,48 +169,30 @@ typedef struct
/* INIT_DONE_MAGIC. 4byte */
uint32_t magic;
/* 进入串口cli的密码. 16byte */
uint8_t password[DEV_PASSWORD_LEN];
char password[DEV_PASSWORD_LEN];
/* 器件名字. 128byte */
uint8_t host[DEV_NAME_LEN];
/* ADC 校准. 418byte */
char host[DEV_NAME_LEN];
/* ADC 校准. 424byte */
uint16_t ADC_ratio[DAU_PORT_POWER_CNT];
uint32_t ADC_base_elec[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT];
uint16_t ADC_adj[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT];
float ADC_base[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT];
uint8_t ADC_turns[DAU_PORT_POWER_CNT];
/* ADCi 电压校准配置. 4byte */
uint16_t vin;
uint16_t vin_adj;
/* 各种 bool 类型配置, 见 DEV_FLAG_E. 2byte */
uint16_t flag;
/* 8 路传感器 id 配置. 8byte */
uint8_t sensor_id[4];
uint32_t keepalive; //保活间隔 ms
/* 采样间隔配置. 4byte */
uint16_t collect_interval;
/* 各种 bool 类型配置, 见 DEV_FLAG_E. 8byte */
uint32_t flag;
uint32_t keepalive; // 保活间隔单位: ms
/* 采样间隔配置. 8byte */
uint16_t collect_interval; // 单位: min
uint16_t power_threshold;
uint16_t fault_threshold;
/* ADCi 电压校准配置. 2byte */
uint16_t vin;
/* 工作模式配置. 2byte */
uint8_t energy_mode;
uint8_t is_voltage_col;
/* 上传阈值. 8byte */
uint16_t threshold;
uint16_t wave_threshold;
uint16_t wave_adj;
uint8_t main_cable;
uint8_t normal_sleep;
uint16_t defect_threshold;
/* APN 配置. 128byte */
uint8_t APN[DEV_APN_LEN];
uint8_t is_temp_col;
uint8_t is_wave_col;
uint8_t csg_beat_interval;
uint8_t reserve0[1];
uint8_t ADC_turns[DAU_PORT_POWER_CNT];
uint8_t csg_ciphertext[CSG_CIPHERTEXT_LEN];
uint8_t csg_passwd[8];
uint16_t csg_sleep;
uint16_t csg_online;
uint8_t csg_reset_time[4];
uint8_t APN_long[DEV_APN_LEN_LONG];
/* 保证配置区 8K 的保留位. */
uint8_t reserve[316];
uint8_t reserve[300];
/* INIT_DONE_MAGIC. 4byte */
uint32_t magic_bak;
} dev_config_t;
@ -258,14 +240,8 @@ typedef struct
/* 内部flash和spi flash中img的大小. 32byte */
uint32_t fireware_size;
uint32_t spi_fireware_size;
uint8_t update_ip_addr[4];
uint16_t update_port;
uint16_t csg_version;
unsigned char capability_set[DEV_CAPABILITY_LEN];
uint8_t csg_id[8];
uint8_t csg_card[8];
/* 保留空间,以便以后添加成员的时候不用再升级IAP程序. */
uint8_t reserved[196];
uint8_t reserved[236];
/* INIT_DONE_MAGIC. 4byte */
uint32_t magic_bak;
} dev_info_t;
@ -297,15 +273,9 @@ extern void dev_info_type_set(uint8_t id_m, uint8_t id_s);
extern void dev_info_mac_set(uint8_t *mac);
extern void dev_info_id_set(uint32_t id);
extern void dev_info_wireless_server_ip_set(uint8_t *ip);
extern void dev_info_capability_set(uint8_t *data);
extern void dev_info_capability_add(uint8_t cap);
extern void dev_info_capability_del(uint8_t cap);
extern void dev_info_capability_remove(void);
extern void dev_info_fireware_size_set(uint32_t size);
extern void dev_info_update_ip_set(uint8_t *ip, uint16_t port);
extern void dev_info_magic_set(uint32_t magic);
extern HAL_StatusTypeDef dev_info_save(void);
extern void dev_info_print(void);
extern void dev_csg_print(void);
#endif
/******************* (C) COPYRIGHT LandPower ***** END OF FILE ****************/

@ -97,7 +97,6 @@ typedef struct
uint8_t is_temp_col;
uint8_t is_wave_col;
uint8_t APN[DEV_APN_LEN];
uint8_t APN_long[DEV_APN_LEN_LONG];
} debug_config_t;
/* Private macro -------------------------------------------------------------*/
@ -190,9 +189,6 @@ static void _debug_pkt_info_get(void)
/* 封装数据. */
memcpy(data, &dev_info.type_m, sizeof(debug_info_t) - DEV_NAME_LEN);
memcpy(data->name, dev_config.host, DEV_NAME_LEN);
snprintf((char*)data->csg_id, 8, "%s", dev_info.csg_id);
data->csg_version = dev_info.csg_version;
memcpy(data->csg_card, dev_info.csg_card, 6);
/* 计算校验和. */
crc = (uint32_t*)(debug_buf.buf + head->len);
@ -214,9 +210,6 @@ static void _debug_pkt_info_set(void)
/* 保存数据. */
memcpy(&dev_info.type_m, data, 260);
memcpy(dev_config.host, data->name, DEV_NAME_LEN);
snprintf((char*)dev_info.csg_id, 8, "%s", data->csg_id);
dev_info.csg_version = data->csg_version;
memcpy(dev_info.csg_card, data->csg_card, 6);
/* 封装报文头. */
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_REPLY);
@ -481,22 +474,13 @@ static void _debug_pkt_config_get(void)
/* 封装数据. */
data->flag = dev_config.flag;
data->energy_mode = dev_config.energy_mode;
for(i = 0; i < SENSOR_SUM; i++)
{
data->sensor_id[i] = 0;
}
data->collect_interval = dev_config.collect_interval;
data->wave_interval = 12;
data->collect_threshold = dev_config.threshold;
data->wave_threshold = dev_config.wave_threshold;
data->main_cable = dev_config.main_cable;
data->normal_sleep = dev_config.normal_sleep;
memcpy(data->APN, dev_config.APN, DEV_APN_LEN);
memcpy(data->APN_long, dev_config.APN_long, DEV_APN_LEN_LONG);
data->is_voltage_col = dev_config.is_voltage_col;
data->is_temp_col = dev_config.is_temp_col;
data->is_wave_col = dev_config.is_wave_col;
/* 计算校验和. */
crc = (uint32_t*)(debug_buf.buf + head->len);
@ -524,18 +508,8 @@ static void _debug_pkt_config_set(void)
dev_config_flag_assgin(data->flag);
}
dev_config.energy_mode = data->energy_mode;
dev_config.collect_interval = data->collect_interval;
dev_config.keepalive = data->wave_interval * 60000;
dev_config.threshold = data->collect_threshold;
dev_config.wave_threshold = data->wave_threshold;
dev_config.main_cable = data->main_cable;
dev_config.normal_sleep = data->normal_sleep;
memcpy(dev_config.APN, data->APN, DEV_APN_LEN);
memcpy(dev_config.APN_long, data->APN_long, DEV_APN_LEN_LONG);
dev_config.is_voltage_col = data->is_voltage_col;
dev_config.is_temp_col = data->is_temp_col;
dev_config.is_wave_col = data->is_wave_col;
/* 封装报文头. */
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_REPLY);
@ -1090,7 +1064,6 @@ static void _debug_pkt_dev_state_get(void)
data->wl_cnt = wl_ctrl.send_cnt;
data->force_sleep_up = st_data.force_sleep_up;
data->is_bat_charge = HAL_GPIO_ReadPin(BAT_CHECK_GPIO_Port, BAT_CHECK_Pin);
data->wave_adj = dev_config.wave_adj;
data->sys_time = HAL_GetTick() / 1000;
/* 计算校验和. */
@ -1135,12 +1108,8 @@ static void _debug_pkt_wave_col(void)
static void _debug_pkt_wave_cal(void)
{
proto_head_t *head = (proto_head_t*)debug_buf.buf;
uint16_t *data = (uint16_t*)(debug_buf.buf + sizeof(proto_head_t));
uint32_t *crc = NULL;
/* 配置参数. */
dev_config.wave_adj = *data;
/* 封装报文头. */
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
@ -1150,9 +1119,6 @@ static void _debug_pkt_wave_cal(void)
/* 发送报文 */
_debug_pkt_send(head->len + 4, 20);
/* 保存参数. */
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
return;
}
@ -1388,23 +1354,11 @@ static void _debug_pkt_adj_manual(void)
static void _debug_pkt_csg_config_get(void)
{
proto_head_t *head = (proto_head_t*)debug_buf.buf;
debug_csg_config_t *data = (debug_csg_config_t*)(debug_buf.buf + sizeof(proto_head_t));
uint32_t *crc = NULL;
/* 封装报文头. */
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(debug_csg_config_t), DEBUG_CT_PRV_REPLY);
/* 装填数据. */
memcpy(data->passwd, dev_config.csg_passwd, CSG_PASSWD_LEN);
data->passwd[CSG_PASSWD_LEN] = 0;
data->beat_interval = dev_config.csg_beat_interval;
data->collect_interval = dev_config.collect_interval;
data->sleep_time = dev_config.csg_sleep;
data->online_time = HAL_GetTick() / 1000 / 60;
memcpy(data->reset_time, dev_config.csg_reset_time, 3);
memcpy(data->ciphertext, dev_config.csg_ciphertext, CSG_CIPHERTEXT_LEN);
data->ciphertext[CSG_CIPHERTEXT_LEN] = 0;
/* 计算校验和. */
crc = (uint32_t*)(debug_buf.buf + head->len);
*crc = crc32(debug_buf.buf, head->len);
@ -1419,19 +1373,8 @@ static void _debug_pkt_csg_config_get(void)
static void _debug_pkt_csg_config_set(void)
{
proto_head_t *head = (proto_head_t*)debug_buf.buf;
debug_csg_config_t *data = (debug_csg_config_t*)(debug_buf.buf + sizeof(proto_head_t));
uint32_t *crc = NULL;
/* 保存数据. */
memcpy(dev_config.csg_passwd, data->passwd, CSG_PASSWD_LEN);
dev_config.csg_passwd[CSG_PASSWD_LEN] = 0;
dev_config.csg_beat_interval = data->beat_interval;
dev_config.collect_interval = data->collect_interval;
dev_config.csg_sleep = data->sleep_time;
dev_config.csg_online = data->online_time;
memcpy(dev_config.csg_reset_time, data->reset_time, 3);
memcpy(dev_config.csg_ciphertext, data->ciphertext, CSG_CIPHERTEXT_LEN);
/* 封装报文头. */
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
@ -1441,9 +1384,6 @@ static void _debug_pkt_csg_config_set(void)
/* 发送报文 */
_debug_pkt_send(head->len + 4, 20);
/* 保存配置. */
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
return;
}

@ -112,7 +112,6 @@ extern uint8_t yl_test;
static BaseType_t _cli_adc_auto(const char *string);
static BaseType_t _cli_dbg_mode(const char *string);
static BaseType_t _cli_default(const char *string);
static BaseType_t _cli_eny_mode(const char *string);
static BaseType_t _cli_host(const char *string);
static BaseType_t _cli_id(const char *string);
static BaseType_t _cli_password(const char *string);
@ -139,7 +138,6 @@ static const CLI_Command_Definition_t cmd_debug = {"debug", _cli_debug, 2};
static const CLI_Command_Definition_t cmd_adc_auto = {"adc-auto", _cli_adc_auto, 1};
static const CLI_Command_Definition_t cmd_dbg_mode = {"dbg-mode", _cli_dbg_mode, 1};
static const CLI_Command_Definition_t cmd_default = {"default", _cli_default, 1};
static const CLI_Command_Definition_t cmd_eny_mode = {"eny-mode", _cli_eny_mode, 1};
static const CLI_Command_Definition_t cmd_host = {"host", _cli_host, 1};
static const CLI_Command_Definition_t cmd_id = {"id", _cli_id, 1};
static const CLI_Command_Definition_t cmd_pw = {"passwd", _cli_password, 1};
@ -356,49 +354,6 @@ static BaseType_t _cli_default(const char *string)
return pdFALSE;
}
/* 配置电源工作模式. */
static BaseType_t _cli_eny_mode(const char *string)
{
const char *param = NULL;
uint8_t param_len = 0;
param = FreeRTOS_CLIGetParameter(string, 1, (BaseType_t *)&param_len);
if (NULL == param)
{
vty_print(cli_param_erro);
return pdFALSE;
}
switch(param[0])
{
/* 智能模式. */
case 'a':
dev_config.energy_mode = ADC_ENERGY_AUTO;
break;
/* 正常模式. */
case 'n':
dev_config.energy_mode = ADC_ENERGY_NORMAL;
break;
/* 节能模式. */
case 's':
dev_config.energy_mode = ADC_ENERGY_SLEEP;
break;
/* 帮助信息. */
case 'h':
vty_print("eny-mode <mode>\r\n <mode>: auto | normal | sleep\r\n Entry energy mode.\r\n");
return pdFALSE;
default:
vty_print(cli_param_erro);
return pdFALSE;
}
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
vty_print(cli_rv_ok);
return pdFALSE;
}
/* 设置主机名. */
static BaseType_t _cli_host(const char *string)
{
@ -556,10 +511,6 @@ static BaseType_t _cli_show(const char *string)
{
ADC_show();
}
else if(0 == strncmp(param, "csg", param_len))
{
dev_csg_print();
}
else if(0 == strncmp(param, "data", param_len))
{
fd_show(20);
@ -581,18 +532,13 @@ static BaseType_t _cli_show(const char *string)
vty_print("Debug mode: %s\r\n", IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_CLI) ? "CLI" : "PC");
vty_print("Work mode: %s\r\n", IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_ADJ) ? "ADJ" : "NORMAL");
vty_print("Work mode: %s\r\n", IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_FACTORY) ? "FACTORY" : "NORMAL");
vty_print("Normal sleep: %d\r\n", dev_config.normal_sleep);
vty_print("Force sleep up: %d\r\n", st_data.force_sleep_up);
vty_print("BAT charge: %d\r\n", HAL_GPIO_ReadPin(BAT_CHECK_GPIO_Port, BAT_CHECK_Pin));
vty_print("Collect interval: %dmin\r\n", dev_config.collect_interval);
vty_print("Collect threshold: %dA\r\n", dev_config.threshold);
vty_print("Defect threshold: %dmV\r\n", dev_config.wave_threshold);
vty_print("Power threshold: %dmV\r\n", dev_config.power_threshold);
vty_print("Defect threshold: %dmV\r\n", dev_config.defect_threshold);
vty_print("Fault threshold: %dA\r\n", dev_config.fault_threshold);
vty_print("Keepalive: %dms\r\n", dev_config.keepalive);
vty_print("Mian cable: %d\r\n", dev_config.main_cable);
vty_print("Voltage col: %d\r\n", dev_config.is_voltage_col);
vty_print("Temp col: %d\r\n", dev_config.is_temp_col);
vty_print("Wave col: %d\r\n", dev_config.is_wave_col);
}
else if(0 == strncmp(param, "state", param_len))
{
@ -841,7 +787,6 @@ static void _cli_start(void)
FreeRTOS_CLIRegisterCommand(&cmd_adc_auto, CLI_NODE_CONFIG);
FreeRTOS_CLIRegisterCommand(&cmd_dbg_mode, CLI_NODE_CONFIG);
FreeRTOS_CLIRegisterCommand(&cmd_default, CLI_NODE_CONFIG);
FreeRTOS_CLIRegisterCommand(&cmd_eny_mode, CLI_NODE_CONFIG);
FreeRTOS_CLIRegisterCommand(&cmd_host, CLI_NODE_CONFIG);
FreeRTOS_CLIRegisterCommand(&cmd_id, CLI_NODE_CONFIG);
FreeRTOS_CLIRegisterCommand(&cmd_pw, CLI_NODE_CONFIG);
@ -898,16 +843,15 @@ void cli_start(void const * argument)
dev_config_init();
dev_config_flag_set(DEV_FLAG_CLI);
//dev_config_flag_unset(DEV_FLAG_CLI);
dev_config.keepalive = 60000;
flash_log_init();
st_init();
/* 公共监控任务初始化. */
common_sys_init();
/* 默认开启的 debug. */
dbg_cmd_hander(DBG_CMD_ON, DBG_M_DAU);
dbg_cmd_hander(DBG_CMD_ON, DBG_M_DAU_TXRX);
//dbg_cmd_hander(DBG_CMD_ON, DBG_M_DAU_TXRX);
//dbg_cmd_hander(DBG_CMD_ON, DBG_M_GPS);
//dbg_cmd_hander(DBG_CMD_ON, DBG_M_4G);
dbg_cmd_hander(DBG_CMD_ON, DBG_M_4G);
/* 初始化 ADC 采样任务. */
ADC_init();
/* 初始化 DAU 任务. */
@ -916,7 +860,7 @@ void cli_start(void const * argument)
if (!IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_ADJ)
&& !IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_FACTORY))
{
//wl_init();
wl_init();
}
/* 在这个标志置位前vty_print是原地循环等待,置位后变为任务调度. */

File diff suppressed because it is too large Load Diff

@ -335,7 +335,7 @@ int32_t _dau_update(void)
uint16_t cnt = 0;
uint16_t page_cnt = 0;
//uint32_t app_len = wl_ctrl.app_len;
uint32_t app_len = 2097378;
uint32_t app_len = 476549;
uint32_t len = 0;
uint32_t addr = TFTP_APP_ADDRESS;
int32_t rv = HAL_ERROR;
@ -348,6 +348,7 @@ int32_t _dau_update(void)
{
/* 组装数据报文, 报文头是大端模式 DAU_REG_ADDR_GSUDR */
len = app_len < 1024 ? app_len : 1024;
vty_print("#D%d %d\r\n", page_cnt, len);
if (0 == len)
{
/* 无数据, 直接结束 */
@ -372,23 +373,26 @@ int32_t _dau_update(void)
cnt = 0;
while(1)
{
osDelay(500);
osDelay(200);
cnt++;
if (cnt > 3)
{
DBG(DBG_M_DAU, "DAU update timeout\r\n");
return HAL_TIMEOUT;
}
/* 读取 spi flash 状态 DAU_REG_ADDR_GSR */
E_RETURN(_dau_reg_read_global_state());
/* 0 - 空闲, 1 - 忙 */
if (!((dau_ctrl.reg_global.GSR & DAU_GSR_FLASH_Msk) >> DAU_GSR_FLASH_Pos))
/* 0 - 忙, 1 - 空闲 */
if ((dau_ctrl.reg_global.GSR & DAU_GSR_FLASH_Msk) >> DAU_GSR_FLASH_Pos)
{
break;
}
}
common_watchdog_set(COM_WDG_DAU);
/* 结束直接返回 */
if (len < 1024)
@ -401,10 +405,6 @@ int32_t _dau_update(void)
page_cnt++;
addr += 1024;
}
/* 向 DAU_REG_ADDR_GFWSR 写 0, 回复标志 */
*reg = 0;
E_RETURN(_dau_reg_write(DAU_REG_ADDR_GFWSR, sizeof(uint16_t)));
return HAL_OK;
}
@ -559,7 +559,7 @@ int32_t _dau_wave_col_defect(void)
for(i = 0; i < DAU_PORT_DEFECT_CNT; i++)
{
dau_ctrl.reg_defect_max[i] = dau_ctrl.reg_port_state.MAX[i];
if (dau_ctrl.reg_port_state.MAX[i] > dev_config.wave_threshold)
if (dau_ctrl.reg_port_state.MAX[i] > dev_config.defect_threshold)
{
is_exceed = TRUE;
}
@ -823,7 +823,7 @@ void _dau_power_calculate(DAU_SOURCE_E source)
for(ch = 0; ch < DAU_PORT_GROUND_CNT; ch++)
{
/* 判断工频录波上传阈值 */
if (abs_cal_u(power[ch], fd_data.elec[ch]) >= (uint32_t)dev_config.threshold * 1000)
if (abs_cal_u(power[ch], fd_data.elec[ch]) >= (uint32_t)dev_config.power_threshold * 1000)
{
MONITOR_BITMAP_SET(dau_ctrl.col_flag, DAU_COL_FLAG_REG_POWER);
break;
@ -1069,21 +1069,7 @@ static void _dau_start(void *argument)
//_dau_wave_col_trigger_by_fault();
/* 循环工频缺陷电流采集 */
_dau_wave_col_trigger_by_reg();
if (1 == _dau_spi_rw)
{
_dau_spi_rw = 0;
_dau_reg_read(_dau_spi_addr, _dau_spi_len << 1);
}
else if(2 == _dau_spi_rw)
{
uint16_t *data = (uint16_t*)&dau_ctrl.buf_dau_tx[2];
*data = _dau_spi_len;
_dau_spi_rw = 0;
_dau_reg_write(_dau_spi_addr, 2);
}
common_watchdog_set(COM_WDG_DAU);
//_dau_wave_col_trigger_by_reg();
#if 0
addr = dau_ctrl.addr_reg;
@ -1113,7 +1099,7 @@ static void _dau_start(void *argument)
vty_print("\r\n");
}
#endif
#if 1
#if 0
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
{
vty_print("POWER %d\r\n", i);
@ -1143,9 +1129,20 @@ static void _dau_start(void *argument)
while(1)
{
osDelay(5000);
osDelay(500);
common_watchdog_set(COM_WDG_DAU);
//vty_print("sleep\r\n");
if (1 == _dau_spi_rw)
{
_dau_spi_rw = 0;
_dau_reg_read(_dau_spi_addr, _dau_spi_len << 1);
}
else if(2 == _dau_spi_rw)
{
uint16_t *data = (uint16_t*)&dau_ctrl.buf_dau_tx[2];
*data = _dau_spi_len;
_dau_spi_rw = 0;
_dau_reg_write(_dau_spi_addr, 2);
}
}
}
}

@ -48,7 +48,6 @@
/* Private define ------------------------------------------------------------*/
#define DEV_FLASH_REPETITION 3 // 多次读取 flash 失败才认为失败.
#define DEV_VIN_ADJ_DEFAULT 5000
#define DEV_WARE_ADJ_DEFAULT 7296
/* Private macro -------------------------------------------------------------*/
#define DEV_IS_VERSION_CHG (strncmp((char*)dev_info.img_compile_time, COMPILE_TIME, DEV_COMPILE_TIME_LEN - 1) != 0)
@ -132,12 +131,13 @@ static HAL_StatusTypeDef _dev_config_default_set(void)
uint8_t i = 0;
memset(&dev_config, 0, sizeof(dev_config_t));
dev_config.magic = INIT_DONE_MAGIC;
dev_config.magic_bak = INIT_DONE_MAGIC;
/* 默认密码初始化. */
snprintf((char*)dev_config.password, DEV_PASSWORD_LEN, "%s", DEV_DEFAULT_PASSWORD);
snprintf(dev_config.password, DEV_PASSWORD_LEN, "%s", DEV_DEFAULT_PASSWORD);
snprintf(dev_config.host, DEV_NAME_LEN, "%s", DEV_DEFAULT_HOST);
/* 默认工频校准系数 */
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
{
if (i < 4)
@ -182,21 +182,14 @@ static HAL_StatusTypeDef _dev_config_default_set(void)
}
}
dev_config.vin_adj = DEV_VIN_ADJ_DEFAULT;
dev_config.vin = DEV_VIN_ADJ_DEFAULT;
dev_config.collect_interval = 10;
dev_config.vin_adj = DEV_VIN_ADJ_DEFAULT;
dev_config.keepalive = 300000;
dev_config.wave_adj = DEV_WARE_ADJ_DEFAULT;
dev_config.main_cable = 5;
dev_config.collect_interval = 10;
snprintf((char*)dev_config.APN, DEV_APN_LEN, "CMIOT");
snprintf((char*)dev_config.APN_long, DEV_APN_LEN_LONG, "CMIOT");
dev_config.csg_beat_interval = 1;
for(i = 0; i < CSG_CIPHERTEXT_LEN; i++)
{
dev_config.csg_ciphertext[i] = i + 0x31;
}
snprintf((char*)dev_config.csg_passwd, 8, "1234");
dev_config.magic_bak = INIT_DONE_MAGIC;
rv |= _dev_config_save(CONFIG_ADDRESS);
rv |= _dev_config_save(CONFIG_ADDRESS_BAK);
@ -717,52 +710,6 @@ void dev_info_wireless_server_ip_set(uint8_t *ip)
_dev_config_mutex_unlock();
}
/* 设置整个能力集. */
void dev_info_capability_set(uint8_t *data)
{
_dev_config_mutex_lock();
memcpy(dev_info.capability_set, data, DEV_CAPABILITY_LEN);
_dev_config_mutex_unlock();
}
/* 设置单个能力. */
void dev_info_capability_add(uint8_t cap)
{
if (cap >= DEV_CAPABILITY_BIT_LEN)
return;
_dev_config_mutex_lock();
bit_list_set(dev_info.capability_set, cap);
_dev_config_mutex_unlock();
}
/* 删除单个能力. */
void dev_info_capability_del(uint8_t cap)
{
if (cap >= DEV_CAPABILITY_BIT_LEN)
return;
_dev_config_mutex_lock();
bit_list_clr(dev_info.capability_set, cap);
_dev_config_mutex_unlock();
}
/* 删除整个能力. */
void dev_info_capability_remove(void)
{
_dev_config_mutex_lock();
memset(dev_info.capability_set, 0, DEV_CAPABILITY_LEN);
_dev_config_mutex_unlock();
}
/* 设置固件大小. */
void dev_info_fireware_size_set(uint32_t size)
{
@ -773,17 +720,6 @@ void dev_info_fireware_size_set(uint32_t size)
_dev_config_mutex_unlock();
}
/* 记录升级 ip 和端口, 用于回复升级结果报文. */
void dev_info_update_ip_set(uint8_t *ip, uint16_t port)
{
_dev_config_mutex_lock();
memcpy(dev_info.update_ip_addr, ip, 4);
dev_info.update_port = port;
_dev_config_mutex_unlock();
}
/* 设置设备信息标志头 */
void dev_info_magic_set(uint32_t magic)
{
@ -809,9 +745,6 @@ HAL_StatusTypeDef dev_info_save(void)
/* 打印info信息. */
void dev_info_print(void)
{
int8_t i = 0;
uint8_t *addr = (uint8_t*)(&dev_info.update_ip_addr);
vty_print("\r\nWelcome To Intelligent Monitor Application, By WTOE Embed Application Team.\r\n");
vty_print("Copyright(c) 2019 WTOE. All rights reserved.\r\n");
vty_print("Boot version %s, compile time is %s.\r\n", dev_info.boot_version, dev_info.boot_compile_time);
@ -825,29 +758,7 @@ void dev_info_print(void)
vty_print("Gw: %d.%d.%d.%d\r\n", dev_info.ip_gw[0], dev_info.ip_gw[1], dev_info.ip_gw[2], dev_info.ip_gw[3]);
vty_print("Server: %d.%d.%d.%d\r\n", dev_info.server_ip[0], dev_info.server_ip[1], dev_info.server_ip[2], dev_info.server_ip[3]);
vty_print("Wireless server: %d.%d.%d.%d\r\n", dev_info.wireless_server_ip[0], dev_info.wireless_server_ip[1], dev_info.wireless_server_ip[2], dev_info.wireless_server_ip[3]);
vty_print("Update: %d.%d.%d.%d:%d\r\n", addr[0], addr[1], addr[2], addr[3], dev_info.update_port);
vty_print("Capability: ");
for(i = DEV_CAPABILITY_LEN - 1; i >= 0; i--)
vty_print("%02x ", dev_info.capability_set[i]);
vty_print("\r\n\nFireware size: %d | Spi fireware size: %d\r\n", dev_info.fireware_size, dev_info.spi_fireware_size);
vty_print("Config size: %d | Record size: %d | Info size: %d\r\n\n", sizeof(dev_config_t), sizeof(dev_record_t), sizeof(dev_info_t));
}
/* 打印info信息. */
void dev_csg_print(void)
{
uint8_t temp[CSG_CIPHERTEXT_LEN + 1] = {0};
vty_print("Id: %s\r\n", dev_info.csg_id);
vty_print("Card: %01x%02x%02x%02x%02x%02x\r\n", dev_info.csg_card[0], dev_info.csg_card[1], dev_info.csg_card[2],
dev_info.csg_card[3], dev_info.csg_card[4], dev_info.csg_card[5]);
vty_print("Version: %04x\r\n", dev_info.csg_version);
vty_print("Passwd: %s\r\n", dev_config.csg_passwd);
vty_print("Beat interval: %dm\r\n", dev_config.csg_beat_interval);
vty_print("Restart ontime: %d %d:%d\r\n", dev_config.csg_reset_time[0], dev_config.csg_reset_time[1], dev_config.csg_reset_time[2]);
memcpy(temp, dev_config.csg_ciphertext, CSG_CIPHERTEXT_LEN);
vty_print("Ciphertext: %s\r\n\n", temp);
vty_print("\r\nFireware size: %d | Spi fireware size: %d\r\n", dev_info.fireware_size, dev_info.spi_fireware_size);
}
/******************* (C) COPYRIGHT LandPower ***** END OF FILE ****************/

@ -431,16 +431,16 @@ static void _wl_4G_recv_contect(uint8_t *cmd, uint32_t len)
dev_config_collect_interval_set(cfg->interval);
}
if (cfg->threshold_power != dev_config.threshold)
if (cfg->threshold_power != dev_config.power_threshold)
{
is_cfg_save = TRUE;
dev_config.threshold = cfg->threshold_power;
dev_config.power_threshold = cfg->threshold_power;
}
if (cfg->threshold_defect != dev_config.wave_threshold)
if (cfg->threshold_defect != dev_config.defect_threshold)
{
is_cfg_save = TRUE;
dev_config.wave_threshold = cfg->threshold_defect;
dev_config.defect_threshold = cfg->threshold_defect;
}
if (cfg->threshold_fault != dev_config.fault_threshold)
@ -561,16 +561,16 @@ static void _wl_4G_recv_cfg_set(uint8_t *cmd, uint32_t len)
dev_config.collect_interval = cfg->interval;
}
if (cfg->threshold_power != dev_config.threshold)
if (cfg->threshold_power != dev_config.power_threshold)
{
is_cfg_save = TRUE;
dev_config.threshold = cfg->threshold_power;
dev_config.power_threshold = cfg->threshold_power;
}
if (cfg->threshold_defect != dev_config.wave_threshold)
if (cfg->threshold_defect != dev_config.defect_threshold)
{
is_cfg_save = TRUE;
dev_config.wave_threshold = cfg->threshold_defect;
dev_config.defect_threshold = cfg->threshold_defect;
}
if (cfg->threshold_fault != dev_config.fault_threshold)
@ -1813,7 +1813,7 @@ void _wl_4G_init_soft(void)
else if ((WL_STATE_AT_QICSGP == wl_ctrl.state) && is_timeout)
{
/* 创建场景. */
snprintf((char*)wl_ctrl.dma_tx_buf, WL_DMA_TX_BUF_LEN, "AT+QICSGP=1,1,\"%s\",\"\",\"\",1\r\n", dev_config.APN_long);
snprintf((char*)wl_ctrl.dma_tx_buf, WL_DMA_TX_BUF_LEN, "AT+QICSGP=1,1,\"%s\",\"\",\"\",1\r\n", dev_config.APN);
_wl_4G_init_cmd_send(wl_ctrl.dma_tx_buf, 1100);
wl_ctrl.send_cnt++;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -42,14 +42,13 @@
/* Define --------------------------------------------------------------------*/
#define VERSION_MAJOR 1
#define VERSION_MINOR 10
#define VERSION_MINOR 1
#define COMPILE_TIME (__DATE__" "__TIME__)
#define NAME_LEN 32
#define DEV_COMPILE_TIME_LEN 32
#define DEV_VERSION_STR_LEN 32
#define NUM_LEN 11
#define DEV_CAPABILITY_LEN 16
#define DEV_RESET_INFO_NUM 10
/* 以下宏保证dev_info_t结构体大小是4096byte,正好占用1个扇区大小. */
@ -197,14 +196,8 @@ typedef struct
/* 内部flash和spi flash中img的大小. 32byte */
uint32_t fireware_size;
uint32_t spi_fireware_size;
uint8_t update_ip_addr[4];
uint16_t update_port;
uint16_t csg_version;
unsigned char capability_set[DEV_CAPABILITY_LEN];
uint8_t csg_id[8];
uint8_t csg_card[8];
/* 保留空间,以便以后添加成员的时候不用再升级IAP程序. */
uint8_t reserved[196];
uint8_t reserved[236];
/* INIT_DONE_MAGIC. 4byte */
uint32_t magic_bak;
} dev_info_t;

@ -388,7 +388,7 @@ static HAL_StatusTypeDef _dev_info_default_set(void)
dev_info.magic = INIT_DONE_MAGIC;
dev_info.magic_bak = INIT_DONE_MAGIC;
dev_info.type_m = 0x1;
dev_info.type_m = 0x2;
dev_info.type_s = 0x1;
dev_info.mac[0] = 0x00; dev_info.mac[1] = 0x19; dev_info.mac[2] = 0x20;
dev_info.mac[3] = 0x22; dev_info.mac[4] = 0x11; dev_info.mac[5] = 0x01;
@ -399,16 +399,14 @@ static HAL_StatusTypeDef _dev_info_default_set(void)
dev_info.ip_mask[0] = 255;
dev_info.ip_gw[0] = 10; dev_info.ip_gw[3] = 1;
dev_info.server_ip[0] = 10; dev_info.server_ip[3] = 1;
dev_info.wireless_server_ip[0] = 111;dev_info.wireless_server_ip[1] = 47;
dev_info.server_port = 17777;
dev_info.wireless_server_ip[0] = 111;dev_info.wireless_server_ip[1] = 47;
dev_info.wireless_server_ip[2] = 21;dev_info.wireless_server_ip[3] = 141;
dev_info.wireless_server_port = 9456;
snprintf((char*)dev_info.boot_version, DEV_VERSION_STR_LEN, "V%d.%d.%d.%d", dev_info.type_m, dev_info.type_s,
VERSION_MAJOR, VERSION_MINOR);
strncpy((char*)dev_info.boot_compile_time, COMPILE_TIME, DEV_COMPILE_TIME_LEN - 1);
dev_info.csg_version = 0x0300;
snprintf((char*)dev_info.csg_id, 8, "LD5678");
rv = dev_info_save();

Loading…
Cancel
Save