|
|
|
@ -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 ****************/
|
|
|
|
|