修改工作时长为小时,到期的标志显示,网络重连修改,出厂时间

This commit is contained in:
小马_666 2025-06-11 10:38:42 +08:00
parent ea610ac8b9
commit fad648f428
5 changed files with 39 additions and 63 deletions

View File

@ -292,7 +292,7 @@ int main(void)
{ {
// 定义超时时间,单位为毫秒 // 定义超时时间,单位为毫秒
#define TIMEOUT_MS (3 * 60 * 1000) #define TIMEOUT_MS (3 * 60 * 1000)
#define WORK_TIMER_CNT (1000 * 60 * 60 * 24) #define WORK_TIMER_CNT (1000 * 60 * 60)//按照小时算
if (Get_VIN_VoltageInt1000x() > 10000) if (Get_VIN_VoltageInt1000x() > 10000)
{ {

View File

@ -19,7 +19,7 @@
#define SYS_HW_VERSION (0X13U) #define SYS_HW_VERSION (0X13U)
#define SYS_SW_VERSION (0X14U) #define SYS_SW_VERSION (0X16U)
#define SYS_IOT_UPLOAD_CYCLE_MIN (0X003CU) // 高位在后,低位在前 #define SYS_IOT_UPLOAD_CYCLE_MIN (0X003CU) // 高位在后,低位在前
#define SYS_IOT_RETRY (0X03U) #define SYS_IOT_RETRY (0X03U)
#define SYS_TEMP_ALARM_THRESHOLD (0X32U) #define SYS_TEMP_ALARM_THRESHOLD (0X32U)

View File

@ -902,7 +902,7 @@ int BSP_Flash_Init (void)
LOG_D ("Flash_Set_Sever_Data error!"); LOG_D ("Flash_Set_Sever_Data error!");
} }
Flash_SetProductTimeLimit (2025, 2, 10, 13, 50, 20, kFactoryTimeId); Flash_SetProductTimeLimit (2025, 6, 11, 11, 50, 20, kFactoryTimeId);
Set_ExpirationTime (MAX_EXPIRATION_DAYS); Set_ExpirationTime (MAX_EXPIRATION_DAYS);
Flash_Set_Calibration_State(kSysGasCalibStatus); // 标定状态 Flash_Set_Calibration_State(kSysGasCalibStatus); // 标定状态
Flash_Set_Valve_Num(0); Flash_Set_Valve_Num(0);

View File

@ -337,7 +337,8 @@ int _Update_Valve_Data (struct Ml307_Ops *ops)
LOG_D ("valve_num: %d", ops->body->valve_num); LOG_D ("valve_num: %d", ops->body->valve_num);
rt_memcpy (&ops->body->valve_data[0], &valve[0], sizeof (struct valve_t)); rt_memcpy (&ops->body->valve_data[0], &valve[0], sizeof (struct valve_t));
// rt_memset(&valve[0].valve_connct_status, 0, (sizeof(struct valve_t) - 7)); // 清空阀门包数据,等待下次更新,如果没更新说明断开了 // rt_memset(&valve[0].valve_connct_status, 0, (sizeof(struct valve_t) - 7)); // 清空阀门包数据,等待下次更新,如果没更新说明断开了
ops->body->valve_data[0].valve_voltage = dec_to_bcd (ops->body->valve_data[0].valve_voltage); // ops->body->valve_data[0].valve_voltage = dec_to_bcd (ops->body->valve_data[0].valve_voltage);
LOG_D ("阀门电压为:%d", ops->body->valve_data[0].valve_voltage);
} }
return RT_EOK; return RT_EOK;
} }
@ -345,7 +346,6 @@ int _Update_Valve_Data (struct Ml307_Ops *ops)
// 更新函数 // 更新函数
int BSP_Ml307_Update (struct Ml307_Ops *ops, rt_uint8_t device_type, rt_uint8_t event_type) int BSP_Ml307_Update (struct Ml307_Ops *ops, rt_uint8_t device_type, rt_uint8_t event_type)
{ {
ops->body->device_type = device_type; ops->body->device_type = device_type;
ops->body->event_type = event_type; ops->body->event_type = event_type;
ops->body->hw = (rt_uint8_t)Flash_Get_SysCfg (kHwVerId); ops->body->hw = (rt_uint8_t)Flash_Get_SysCfg (kHwVerId);
@ -356,9 +356,8 @@ int BSP_Ml307_Update (struct Ml307_Ops *ops, rt_uint8_t device_type, rt_uint8_t
ops->body->work_duration = work_duration; ops->body->work_duration = work_duration;
ops->body->device_status = device_state_flag; ops->body->device_status = device_state_flag;
ops->body->valve_num = Flash_Get_Valve_Num(); ops->body->valve_num = Flash_Get_Valve_Num();
_Update_Valve_Data (ops);
return RT_EOK; return _Update_Valve_Data (ops);
} }
int Ml307_Send_Data (struct Ml307_Ops *ops, rt_uint8_t data_num, rt_uint8_t cmd, rt_uint8_t device_type, rt_uint8_t event_type) int Ml307_Send_Data (struct Ml307_Ops *ops, rt_uint8_t data_num, rt_uint8_t cmd, rt_uint8_t device_type, rt_uint8_t event_type)
@ -1944,6 +1943,8 @@ static void Ml307_Recv_Thread_Entry (void *parameter)
static void Ml307_Life_Thread_Entry (void *parameter) static void Ml307_Life_Thread_Entry (void *parameter)
{ {
rt_uint8_t i = 0;
struct at_device_ml307 *ml307 = &_dev; struct at_device_ml307 *ml307 = &_dev;
struct at_device *device = at_device_get_by_name (AT_DEVICE_NAMETYPE_NETDEV, ml307->device_name); struct at_device *device = at_device_get_by_name (AT_DEVICE_NAMETYPE_NETDEV, ml307->device_name);
RT_ASSERT (device); RT_ASSERT (device);
@ -2019,38 +2020,6 @@ static void Ml307_Life_Thread_Entry (void *parameter)
result = -RT_ERROR; result = -RT_ERROR;
goto __exit; goto __exit;
} }
if (at_obj_exec_cmd (device->client, resp, "AT+CEREG=1") != RT_EOK)
{
result = -RT_ERROR;
goto __exit;
}
rt_uint8_t i = 0;
/* check the GPRS network is registered */
for (i = 0; i < 10; i++)
{
if (at_obj_exec_cmd (device->client, resp, "AT+CEREG?") == RT_EOK)
{
int link_stat = 0;
if (at_resp_parse_line_args_by_kw (resp, "+CEREG:", "+CEREG: %*d,%d", &link_stat) > 0)
{
if ((link_stat == 1) || (link_stat == 5))
{
LOG_D ("%s device GPRS is registered", device->name);
break;
}
}
}
rt_thread_mdelay (1000);
}
if (i == 10)
{
LOG_E ("%s device GPRS is register failed", device->name);
result = -RT_ERROR;
goto __exit;
}
/* check SIM card */ /* check SIM card */
for (i = 0; i < 60; i++) for (i = 0; i < 60; i++)
{ {
@ -2081,22 +2050,6 @@ static void Ml307_Life_Thread_Entry (void *parameter)
goto __exit; goto __exit;
} }
/* Define PDP Context */ /* Define PDP Context */
for (i = 0; i < 5; i++)
{
if (at_obj_exec_cmd (device->client, resp, "AT+CGDCONT=1,\"IPV4V6\",\"cmnet\"") == RT_EOK)
{
LOG_D ("%s device Define PDP Context Success.", device->name);
break;
}
rt_thread_mdelay (1000);
}
if (i == 5)
{
LOG_E ("%s device Define PDP Context failed.", device->name);
result = -RT_ERROR;
goto __exit;
}
for (i = 0; i < 60; i++) for (i = 0; i < 60; i++)
{ {
if (at_obj_exec_cmd (device->client, resp, "AT+CGACT=1") == RT_EOK) if (at_obj_exec_cmd (device->client, resp, "AT+CGACT=1") == RT_EOK)
@ -2119,6 +2072,28 @@ static void Ml307_Life_Thread_Entry (void *parameter)
result = -RT_ERROR; result = -RT_ERROR;
goto __exit; goto __exit;
} }
for (i = 0; i < 5; i++)
{
if (at_obj_exec_cmd (device->client, resp, "AT+CGDCONT=1,\"IPV4V6\",\"cmnet\"") == RT_EOK)
{
LOG_D ("%s device Define PDP Context Success.", device->name);
break;
}
rt_thread_mdelay (1000);
}
if (i == 5)
{
LOG_E ("%s device Define PDP Context failed.", device->name);
result = -RT_ERROR;
goto __exit;
}
if (at_obj_exec_cmd (device->client, resp, "AT+CEREG=1") != RT_EOK)
{
result = -RT_ERROR;
goto __exit;
}
/* check the GPRS network is registered */ /* check the GPRS network is registered */
for (i = 0; i < 60; i++) for (i = 0; i < 60; i++)
{ {
@ -2143,11 +2118,11 @@ static void Ml307_Life_Thread_Entry (void *parameter)
result = -RT_ERROR; result = -RT_ERROR;
goto __exit; goto __exit;
} }
// if (at_obj_exec_cmd (device->client, resp, "AT+MIPCALL=1,1") != RT_EOK) if (at_obj_exec_cmd (device->client, resp, "AT+MIPCALL=1,1") != RT_EOK)
// { {
// result = -RT_ERROR; result = -RT_ERROR;
// goto __exit; goto __exit;
// } }
#if defined(AT_DEBUG) #if defined(AT_DEBUG)
/* check the GPRS network IP address */ /* check the GPRS network IP address */
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)

View File

@ -47,7 +47,7 @@ uint16_t Get_Gas_VoltageInt1000x(void)
uint16_t Get_Gas_VoltageAdcInt1000x(void) uint16_t Get_Gas_VoltageAdcInt1000x(void)
{ {
rt_uint16_t voltage_adc = (Get_ADC_Average(kGasAdc) * 3.3 / 4096) * 1000; rt_uint16_t voltage_adc = (Get_ADC_Average(kGasAdc) * 3.3 / 4096) * 1000;
LOG_D("Get_Gas_VoltageAdcInt1000x = %04d", voltage_adc); // LOG_D("Get_Gas_VoltageAdcInt1000x = %04d", voltage_adc);
return voltage_adc; return voltage_adc;
} }
@ -151,11 +151,12 @@ uint8_t IS_EndOfLife(void)
ntp_flag = 0; ntp_flag = 0;
RTC_GetTime(); RTC_GetTime();
if ((RtcDateTime.year >= 2030) && (work_duration >= 43800)) // 5年后到期 if ((RtcDateTime.year >= 2031) && (work_duration >= 43800)) // 5年后到期
{ {
if (RTC_GetCounter() >= Sensor_device.expiration_seconds) if (RTC_GetCounter() >= Sensor_device.expiration_seconds)
{ {
Sensor_device.end_of_life = 1; Sensor_device.end_of_life = 1;
device_state_flag = 1;
} }
else else
{ {