|
|
@ -97,7 +97,6 @@ typedef struct
|
|
|
|
uint8_t is_temp_col;
|
|
|
|
uint8_t is_temp_col;
|
|
|
|
uint8_t is_wave_col;
|
|
|
|
uint8_t is_wave_col;
|
|
|
|
uint8_t APN[DEV_APN_LEN];
|
|
|
|
uint8_t APN[DEV_APN_LEN];
|
|
|
|
uint8_t APN_long[DEV_APN_LEN_LONG];
|
|
|
|
|
|
|
|
} debug_config_t;
|
|
|
|
} debug_config_t;
|
|
|
|
|
|
|
|
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
/* 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, &dev_info.type_m, sizeof(debug_info_t) - DEV_NAME_LEN);
|
|
|
|
memcpy(data->name, dev_config.host, 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);
|
|
|
|
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_info.type_m, data, 260);
|
|
|
|
memcpy(dev_config.host, data->name, DEV_NAME_LEN);
|
|
|
|
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);
|
|
|
|
_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->flag = dev_config.flag;
|
|
|
|
data->energy_mode = dev_config.energy_mode;
|
|
|
|
|
|
|
|
for(i = 0; i < SENSOR_SUM; i++)
|
|
|
|
for(i = 0; i < SENSOR_SUM; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data->sensor_id[i] = 0;
|
|
|
|
data->sensor_id[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data->collect_interval = dev_config.collect_interval;
|
|
|
|
data->collect_interval = dev_config.collect_interval;
|
|
|
|
data->wave_interval = 12;
|
|
|
|
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, 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);
|
|
|
|
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_flag_assgin(data->flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dev_config.energy_mode = data->energy_mode;
|
|
|
|
|
|
|
|
dev_config.collect_interval = data->collect_interval;
|
|
|
|
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, 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);
|
|
|
|
_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->wl_cnt = wl_ctrl.send_cnt;
|
|
|
|
data->force_sleep_up = st_data.force_sleep_up;
|
|
|
|
data->force_sleep_up = st_data.force_sleep_up;
|
|
|
|
data->is_bat_charge = HAL_GPIO_ReadPin(BAT_CHECK_GPIO_Port, BAT_CHECK_Pin);
|
|
|
|
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;
|
|
|
|
data->sys_time = HAL_GetTick() / 1000;
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
@ -1135,12 +1108,8 @@ static void _debug_pkt_wave_col(void)
|
|
|
|
static void _debug_pkt_wave_cal(void)
|
|
|
|
static void _debug_pkt_wave_cal(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
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;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* 配置参数. */
|
|
|
|
|
|
|
|
dev_config.wave_adj = *data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_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);
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
/* 保存参数. */
|
|
|
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1388,23 +1354,11 @@ static void _debug_pkt_adj_manual(void)
|
|
|
|
static void _debug_pkt_csg_config_get(void)
|
|
|
|
static void _debug_pkt_csg_config_get(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
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;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(debug_csg_config_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_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 = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
*crc = crc32(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)
|
|
|
|
static void _debug_pkt_csg_config_set(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
_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);
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
/* 保存配置. */
|
|
|
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|