Merge branch 'mbw' of https://gitee.com/SXDT-Embedded/ble_-tyq_-bjq_-ch32-v303 into mbw
This commit is contained in:
commit
224f2834b6
|
@ -43,9 +43,13 @@ TsSysControl SysControl;
|
||||||
struct rt_timer work_cnt_timer;
|
struct rt_timer work_cnt_timer;
|
||||||
struct rt_timer preheat_timer; // 传统模式需要进行预热,
|
struct rt_timer preheat_timer; // 传统模式需要进行预热,
|
||||||
|
|
||||||
|
uint8_t preheat_flag = 0; // 预热时间是否结束标志
|
||||||
|
|
||||||
|
uint8_t Calibration_flag = 0;//查看是否在标定检测状态
|
||||||
void Send_Laser_Alarm_Event(AlarmEvent event_type);
|
void Send_Laser_Alarm_Event(AlarmEvent event_type);
|
||||||
|
|
||||||
TeCalibrationStatus g_Calibration_status = kNotCalibrated;
|
TeCalibrationStatus g_Calibration_status = kNotCalibrated;
|
||||||
|
|
||||||
static void Set_Event(AlarmEvent event_type)
|
static void Set_Event(AlarmEvent event_type)
|
||||||
{
|
{
|
||||||
if (event_type < kMaxEventcnt)
|
if (event_type < kMaxEventcnt)
|
||||||
|
@ -143,63 +147,113 @@ void Work_Cnt_Timer_Callback(void *parameter)
|
||||||
|
|
||||||
void Preheat_Timer_Callback(void *parameter)
|
void Preheat_Timer_Callback(void *parameter)
|
||||||
{
|
{
|
||||||
BEEP_PREAT_OK;
|
|
||||||
LED_STOP(r);
|
LED_STOP(r);
|
||||||
LED_STOP(g);
|
LED_STOP(g);
|
||||||
LED_STOP(y);
|
LED_STOP(y);
|
||||||
LOG_D("预热完成");
|
LOG_D("预热完成");
|
||||||
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
preheat_flag = 1;
|
||||||
|
if (g_Calibration_status == kSysGasCalibStatus)
|
||||||
|
{
|
||||||
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Send_Laser_Alarm_Event(kCalibrationEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int APP_Calibration_Handle(void)
|
int APP_Calibration_Handle(void)
|
||||||
{
|
{
|
||||||
// 定义超时时间,单位为毫秒
|
uint8_t i = 0;
|
||||||
#define TIMEOUT_MS (3 * 60 * 1000)
|
uint16_t gas_buf[10] = {0};
|
||||||
|
uint32_t gas_calibration_voltage = 0;
|
||||||
|
|
||||||
LED_STOP(g);
|
// if (Get_Gas_VoltageAdcInt1000x() > 400 && Get_Gas_VoltageAdcInt1000x() < 900)
|
||||||
LED_STOP(y);
|
// {
|
||||||
LED_ON(r);
|
// LED_OFF(r);
|
||||||
LED_START(r);
|
// LED_OFF(g);
|
||||||
|
// LED_ON(y);
|
||||||
uint32_t ticks = 0, gas_calibration_voltage;
|
// LOG_D("传感器故障");
|
||||||
LOG_D("标定开始");
|
// return 0;
|
||||||
|
// }
|
||||||
|
if (Get_Gas_VoltageAdcInt1000x() > (MQ_VOLTAGE_ALARM_DEFAULT - 1500) && Get_Gas_VoltageAdcInt1000x() < (MQ_VOLTAGE_ALARM_DEFAULT + 1000))
|
||||||
|
{
|
||||||
|
LOG_D("标定开始");
|
||||||
|
LED_OFF(g);
|
||||||
|
LED_OFF(y);
|
||||||
|
LED_OFF(r);
|
||||||
|
LED_CTRL(y, "200,200", -1);
|
||||||
|
LED_START(y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_Calibration_status = kNotCalibrated;
|
||||||
|
LOG_D("没有气体,请重新上电标定");
|
||||||
|
Send_Laser_Alarm_Event(kNotCalibratedEvent);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Calibration_flag = 1;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
gas_calibration_voltage = Get_Gas_VoltageAdcInt1000x();
|
for (i = 0; i < 10; i++)
|
||||||
LOG_D("ticks[%d] gas_calibration_voltage = %d", ticks++, gas_calibration_voltage);
|
|
||||||
|
|
||||||
if (ticks > (TIMEOUT_MS / 1000))
|
|
||||||
{
|
{
|
||||||
ticks = 0; // 加这个的原因是,如果刚开始没标定,但是时间到了,此时刚通气开始标定,可能直接就读到值了,所以加这个判断
|
gas_buf[i] = Get_Gas_VoltageAdcInt1000x();
|
||||||
if (gas_calibration_voltage > (MQ_VOLTAGE_ALARM_DEFAULT - 1500) && gas_calibration_voltage < (MQ_VOLTAGE_ALARM_DEFAULT + 1000))
|
if (gas_buf[i] == 0)
|
||||||
{
|
{
|
||||||
uint8_t calibration_buf[2] = {0};
|
return 0;
|
||||||
calibration_buf[0] = gas_calibration_voltage & 0xFF; // 低字节
|
|
||||||
calibration_buf[1] = (gas_calibration_voltage >> 8) & 0xFF; // 高字节
|
|
||||||
LOG_D("calibration_buf[0] = %X calibration_buf[1] = %X", calibration_buf[0], calibration_buf[1]);
|
|
||||||
Flash_Sys_Cfg(kAlarmLValueId, calibration_buf, 2);
|
|
||||||
LOG_D("标定完成");
|
|
||||||
// 标定完成打开绿灯常亮,蜂鸣器叫一下
|
|
||||||
BEEP_CALIBRATION_OK;
|
|
||||||
LED_STOP(g);
|
|
||||||
LED_ON(g);
|
|
||||||
Flash_Set_Calibration_State(kSysGasCalibStatus);
|
|
||||||
g_Calibration_status = kSysGasCalibStatus;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
gas_calibration_voltage |= gas_buf[i];
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
}
|
}
|
||||||
if (g_Calibration_status == kSysGasCalibStatus)
|
if (i == 10)
|
||||||
{
|
{
|
||||||
return RT_EOK;
|
gas_calibration_voltage = (uint16_t)gas_calibration_voltage / 10;
|
||||||
|
uint8_t calibration_buf[2] = {0};
|
||||||
|
calibration_buf[0] = gas_calibration_voltage & 0xFF; // 低字节
|
||||||
|
calibration_buf[1] = (gas_calibration_voltage >> 8) & 0xFF; // 高字节
|
||||||
|
LOG_D("calibration_buf[0] = %X calibration_buf[1] = %X", calibration_buf[0], calibration_buf[1]);
|
||||||
|
Flash_Sys_Cfg(kAlarmLValueId, calibration_buf, 2);
|
||||||
|
LOG_D("标定完成");
|
||||||
|
Calibration_flag = 0;
|
||||||
|
Flash_Set_Calibration_State(kSysGasCalibStatus);
|
||||||
|
g_Calibration_status = kSysGasCalibStatus;
|
||||||
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_E("标定错误");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
rt_thread_mdelay(1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 已经标定了
|
int main(void)
|
||||||
void APP_Handle(void)
|
|
||||||
{
|
{
|
||||||
|
// 定义超时时间,单位为毫秒
|
||||||
|
#define TIMEOUT_MS (3 * 60 * 1000)
|
||||||
#define WORK_TIMER_CNT (1000 * 60 * 60)
|
#define WORK_TIMER_CNT (1000 * 60 * 60)
|
||||||
|
|
||||||
|
if (Get_VIN_VoltageInt1000x() > 10000)
|
||||||
|
{
|
||||||
|
SYS_EventInit();
|
||||||
|
BSP_SYS_Init();
|
||||||
|
work_duration = Flash_Get_WorkDuration();
|
||||||
|
LOG_D("工作时长:%d", work_duration);
|
||||||
|
// 读取历史记录总数
|
||||||
|
g_Calibration_status = Flash_Get_Calibration_State();
|
||||||
|
rt_thread_mdelay(10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_D("欠压复位\r\n");
|
||||||
|
RCC_ClearFlag();
|
||||||
|
NVIC_SystemReset(); // 直接重启系统
|
||||||
|
}
|
||||||
|
BSP_VIN_Detection_Init();
|
||||||
|
|
||||||
|
|
||||||
rt_err_t result = RT_EINVAL;
|
rt_err_t result = RT_EINVAL;
|
||||||
rt_uint32_t received_event;
|
rt_uint32_t received_event;
|
||||||
|
|
||||||
|
@ -237,6 +291,7 @@ void APP_Handle(void)
|
||||||
Send_Laser_Alarm_Event(kPreheatingEvent); // 这一句的作用是设备不是掉电重启的情况,直接进入预热模式
|
Send_Laser_Alarm_Event(kPreheatingEvent); // 这一句的作用是设备不是掉电重启的情况,直接进入预热模式
|
||||||
}
|
}
|
||||||
RCC_ClearFlag();
|
RCC_ClearFlag();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
result = rt_event_recv(&alarm_event,
|
result = rt_event_recv(&alarm_event,
|
||||||
|
@ -250,7 +305,9 @@ void APP_Handle(void)
|
||||||
Get_Sys_Event_Flag(kSelfCheckEvent) | // 自检
|
Get_Sys_Event_Flag(kSelfCheckEvent) | // 自检
|
||||||
Get_Sys_Event_Flag(kFaultEvent) | // 故障模式
|
Get_Sys_Event_Flag(kFaultEvent) | // 故障模式
|
||||||
Get_Sys_Event_Flag(kFaultRcyEvent) | // 故障恢复
|
Get_Sys_Event_Flag(kFaultRcyEvent) | // 故障恢复
|
||||||
Get_Sys_Event_Flag(KMuteEvent), // 消音
|
Get_Sys_Event_Flag(KMuteEvent) | // 消音
|
||||||
|
Get_Sys_Event_Flag(kCalibrationEvent) | // 标定
|
||||||
|
Get_Sys_Event_Flag(kNotCalibratedEvent), // 标定
|
||||||
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
||||||
RT_WAITING_FOREVER, &received_event);
|
RT_WAITING_FOREVER, &received_event);
|
||||||
if (result == RT_EOK)
|
if (result == RT_EOK)
|
||||||
|
@ -272,8 +329,38 @@ void APP_Handle(void)
|
||||||
|
|
||||||
SysControl.last_status = SysControl.status;
|
SysControl.last_status = SysControl.status;
|
||||||
SysControl.status = kPreheatingEvent;
|
SysControl.status = kPreheatingEvent;
|
||||||
LED_G_PREAT;
|
|
||||||
rt_timer_start(&preheat_timer);
|
if (SysControl.last_status != kSelfCheckEvent)
|
||||||
|
{
|
||||||
|
LED_G_PREAT;
|
||||||
|
rt_timer_start(&preheat_timer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LED_STOP(r);
|
||||||
|
LED_STOP(g);
|
||||||
|
LED_STOP(y);
|
||||||
|
LED_CTRL(g, "100,100", -1);
|
||||||
|
LED_START(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kCalibrationEvent)) // 标定状态
|
||||||
|
{
|
||||||
|
LOG_D("标定检测");
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kCalibrationEvent;
|
||||||
|
APP_Calibration_Handle();
|
||||||
|
}
|
||||||
|
else if (received_event & Get_Sys_Event_Flag(kNotCalibratedEvent)) // 未标定状态
|
||||||
|
{
|
||||||
|
LOG_D("未标定模式");
|
||||||
|
|
||||||
|
SysControl.last_status = SysControl.status;
|
||||||
|
SysControl.status = kNotCalibratedEvent;
|
||||||
|
LED_STOP(r);
|
||||||
|
LED_STOP(g);
|
||||||
|
LED_STOP(y);
|
||||||
|
LED_ON(r);
|
||||||
}
|
}
|
||||||
else if (received_event & Get_Sys_Event_Flag(kNormalDetectionEvents)) // 正常检测
|
else if (received_event & Get_Sys_Event_Flag(kNormalDetectionEvents)) // 正常检测
|
||||||
{
|
{
|
||||||
|
@ -472,7 +559,36 @@ void APP_Handle(void)
|
||||||
LED_STOP(r);
|
LED_STOP(r);
|
||||||
LED_STOP(g);
|
LED_STOP(g);
|
||||||
LED_STOP(y);
|
LED_STOP(y);
|
||||||
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
|
||||||
|
if (g_Calibration_status == kSysGasCalibStatus)
|
||||||
|
{
|
||||||
|
if (SysControl.last_status == kPreheatingEvent)
|
||||||
|
{
|
||||||
|
if (preheat_flag)
|
||||||
|
{
|
||||||
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Send_Laser_Alarm_Event(kPreheatingEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (preheat_flag)
|
||||||
|
{
|
||||||
|
Send_Laser_Alarm_Event(kNotCalibratedEvent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Send_Laser_Alarm_Event(kPreheatingEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (received_event & Get_Sys_Event_Flag(kSensorFailureEvent)) // 失效
|
else if (received_event & Get_Sys_Event_Flag(kSensorFailureEvent)) // 失效
|
||||||
{
|
{
|
||||||
|
@ -485,8 +601,8 @@ void APP_Handle(void)
|
||||||
{
|
{
|
||||||
Flash_Write_Record(kRecordSensoEndOfLife);
|
Flash_Write_Record(kRecordSensoEndOfLife);
|
||||||
}
|
}
|
||||||
Ml307_Send_Event(kMl307DeviceFailureEvent);//发送一个失效事件
|
Ml307_Send_Event(kMl307DeviceFailureEvent); // 发送一个失效事件
|
||||||
Send_Laser_Alarm_Event(kNormalDetectionEvents);///再返回正常模式继续检测
|
Send_Laser_Alarm_Event(kNormalDetectionEvents); /// 再返回正常模式继续检测
|
||||||
// LED_Y_END_OF_LIFE;
|
// LED_Y_END_OF_LIFE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,46 +610,6 @@ void APP_Handle(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
if (Get_VIN_VoltageInt1000x() > 10000)
|
|
||||||
{
|
|
||||||
SYS_EventInit();
|
|
||||||
BSP_SYS_Init();
|
|
||||||
work_duration = Flash_Get_WorkDuration();
|
|
||||||
LOG_D("工作时长:%d", work_duration);
|
|
||||||
// 读取历史记录总数
|
|
||||||
g_Calibration_status = Flash_Get_Calibration_State();
|
|
||||||
rt_thread_mdelay(10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_D("欠压复位\r\n");
|
|
||||||
RCC_ClearFlag();
|
|
||||||
NVIC_SystemReset(); // 直接重启系统
|
|
||||||
}
|
|
||||||
BSP_VIN_Detection_Init();
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
switch (g_Calibration_status)
|
|
||||||
{
|
|
||||||
case kNotCalibrated: // 没标定
|
|
||||||
{
|
|
||||||
APP_Calibration_Handle();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case kSysGasCalibStatus:
|
|
||||||
{
|
|
||||||
APP_Handle();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rt_thread_mdelay(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TEST_ENABLE
|
#ifdef TEST_ENABLE
|
||||||
static void SYS_Set_RtcProductTime(int argc, char **argv)
|
static void SYS_Set_RtcProductTime(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -560,6 +636,7 @@ static void SYS_Set_RtcProductTime(int argc, char **argv)
|
||||||
LOG_E("SYS_Set_RtcProductTime --use _cmd_ [2000 + y] [m] [d] [h] [m] [s]");
|
LOG_E("SYS_Set_RtcProductTime --use _cmd_ [2000 + y] [m] [d] [h] [m] [s]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MSH_CMD_EXPORT(SYS_Set_RtcProductTime, "SYS_Set_RtcProductTime");
|
MSH_CMD_EXPORT(SYS_Set_RtcProductTime, "SYS_Set_RtcProductTime");
|
||||||
|
|
||||||
// 测试系统标定值修改
|
// 测试系统标定值修改
|
||||||
|
@ -575,12 +652,14 @@ static void TEST_SYS_Calibartion(int argc, char **argv)
|
||||||
Flash_Set_Calibration_State(kSysGasCalibStatus);
|
Flash_Set_Calibration_State(kSysGasCalibStatus);
|
||||||
LOG_D("标定值修改为 = %d", Flash_Get_SysCfg(kAlarmLValueId));
|
LOG_D("标定值修改为 = %d", Flash_Get_SysCfg(kAlarmLValueId));
|
||||||
g_Calibration_status = kSysGasCalibStatus;
|
g_Calibration_status = kSysGasCalibStatus;
|
||||||
|
Send_Laser_Alarm_Event(kNormalDetectionEvents); /// 再返回正常模式继续检测
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_E("TEST_SYS_Calibartion 0~4095");
|
LOG_E("TEST_SYS_Calibartion 0~4095");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MSH_CMD_EXPORT(TEST_SYS_Calibartion, "修改系统标定值");
|
MSH_CMD_EXPORT(TEST_SYS_Calibartion, "修改系统标定值");
|
||||||
|
|
||||||
static void SYS_SW_Version(void)
|
static void SYS_SW_Version(void)
|
||||||
|
|
|
@ -64,6 +64,8 @@ typedef enum
|
||||||
kSelfCheckEvent,
|
kSelfCheckEvent,
|
||||||
KMuteEvent,
|
KMuteEvent,
|
||||||
kAlarmExceptionEvent, // 浓度异常报警
|
kAlarmExceptionEvent, // 浓度异常报警
|
||||||
|
kCalibrationEvent, //标定阶段
|
||||||
|
kNotCalibratedEvent, //未标定状态
|
||||||
kMaxEventcnt,
|
kMaxEventcnt,
|
||||||
} AlarmEvent;
|
} AlarmEvent;
|
||||||
|
|
||||||
|
|
|
@ -38,15 +38,19 @@ extern agile_led_t *led_y;
|
||||||
LED_STOP(r);\
|
LED_STOP(r);\
|
||||||
LED_STOP(g);\
|
LED_STOP(g);\
|
||||||
LED_STOP(y);\
|
LED_STOP(y);\
|
||||||
LED_CTRL(g, "500,2500", -1);\
|
LED_CTRL(g, "500,2500", 1);\
|
||||||
LED_START(g);\
|
LED_START(g);\
|
||||||
rt_thread_mdelay(1000);\
|
rt_thread_mdelay(1000);\
|
||||||
LED_CTRL(y, "500,2500", -1);\
|
LED_CTRL(y, "500,2500", 1);\
|
||||||
LED_START(y);\
|
LED_START(y);\
|
||||||
rt_thread_mdelay(1000);\
|
rt_thread_mdelay(1000);\
|
||||||
LED_CTRL(r, "500,2500", -1);\
|
LED_CTRL(r, "500,2500", 1);\
|
||||||
LED_START(r);\
|
LED_START(r);\
|
||||||
rt_thread_mdelay(1000);\
|
rt_thread_mdelay(1000);\
|
||||||
|
BEEP_CTRL("500,500", 1); \
|
||||||
|
BEEP_START; \
|
||||||
|
LED_CTRL(g, "100,100", -1);\
|
||||||
|
LED_START(g);\
|
||||||
} while (0U)
|
} while (0U)
|
||||||
|
|
||||||
#define LED_G_NORMAL \
|
#define LED_G_NORMAL \
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/***
|
/***
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-11-30 16:46:31
|
* @Date: 2024-11-30 16:46:31
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-02-21 15:32:14
|
* @LastEditTime: 2025-02-21 15:32:14
|
||||||
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\inc\bsp_mq.h
|
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\inc\bsp_mq.h
|
||||||
* @Description:
|
* @Description:
|
||||||
* @
|
* @
|
||||||
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* @Author : stark1898y 1658608470@qq.com
|
* @Author : stark1898y 1658608470@qq.com
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
// MQ采样间隔
|
// MQ采样间隔
|
||||||
#define MQ_SAMPLING_INTERVAL_MS (100U)
|
#define MQ_SAMPLING_INTERVAL_MS (100U)
|
||||||
|
|
||||||
#define SENSOR_SAMPLING_TIMS (10U)
|
#define SENSOR_SAMPLING_TIMS (4U)
|
||||||
|
|
||||||
// MQ采样时间窗口
|
// MQ采样时间窗口
|
||||||
#define MQ_SAMPLING_S (uint8_t)(3U)
|
#define MQ_SAMPLING_S (uint8_t)(3U)
|
||||||
|
|
|
@ -186,7 +186,7 @@ static void urc_tcp_connect_state(struct at_client *client, const char *data, rt
|
||||||
|
|
||||||
if (sscanf(data, "+MIPOPEN:%d,%d", &id, &err_code) == 2)
|
if (sscanf(data, "+MIPOPEN:%d,%d", &id, &err_code) == 2)
|
||||||
{
|
{
|
||||||
socket_id = id;
|
socket_id = id;
|
||||||
{
|
{
|
||||||
switch (err_code)
|
switch (err_code)
|
||||||
{
|
{
|
||||||
|
@ -954,6 +954,8 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
result = -RT_ERROR;
|
result = -RT_ERROR;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
// LOG_D("*(rt_uint16_t *)FLASH_IOT_IMEI_ADDR = %#X", *(rt_uint16_t *)FLASH_IOT_IMEI_ADDR);
|
||||||
|
if ((*(rt_uint16_t *)FLASH_IOT_IMEI_ADDR == 0xE339) || (*(uint16_t *)FLASH_IOT_IMEI_ADDR == 0x39E3))
|
||||||
{
|
{
|
||||||
#define ML307_NETDEV_HWADDR_LEN 8
|
#define ML307_NETDEV_HWADDR_LEN 8
|
||||||
#define ML307_IMEI_LEN 15
|
#define ML307_IMEI_LEN 15
|
||||||
|
@ -976,6 +978,12 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
rt_memcpy(ml307.imei, imei, ML307_IMEI_LEN);
|
rt_memcpy(ml307.imei, imei, ML307_IMEI_LEN);
|
||||||
Flash_Sys_Cfg(kIotImeiId, ml307.imei, ML307_IMEI_LEN);
|
Flash_Sys_Cfg(kIotImeiId, ml307.imei, ML307_IMEI_LEN);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_memset((char *)ml307.imei, 0, ML307_IMEI_LEN);
|
||||||
|
Get_IotImei((char *)&ml307.imei[0], ML307_IMEI_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
/* check SIM card */
|
/* check SIM card */
|
||||||
for (i = 0; i < CPIN_RETRY; i++)
|
for (i = 0; i < CPIN_RETRY; i++)
|
||||||
{
|
{
|
||||||
|
@ -1019,6 +1027,8 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
rt_thread_mdelay(1000);
|
rt_thread_mdelay(1000);
|
||||||
}
|
}
|
||||||
/* set network interface device hardware iccid */
|
/* set network interface device hardware iccid */
|
||||||
|
// LOG_D("*(rt_uint16_t *)FLASH_IOT_ICCID_ADDR = %#X", *(rt_uint16_t *)FLASH_IOT_ICCID_ADDR);
|
||||||
|
if ((*(rt_uint16_t *)FLASH_IOT_ICCID_ADDR == 0xE339) || (*(uint16_t *)FLASH_IOT_ICCID_ADDR == 0x39E3))
|
||||||
{
|
{
|
||||||
|
|
||||||
#define ML307_ICCID_LEN 20
|
#define ML307_ICCID_LEN 20
|
||||||
|
@ -1043,8 +1053,14 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
rt_memcpy(ml307.iccid, iccid, ML307_ICCID_LEN);
|
rt_memcpy(ml307.iccid, iccid, ML307_ICCID_LEN);
|
||||||
Flash_Sys_Cfg(kIotIccidId, ml307.iccid, ML307_ICCID_LEN);
|
Flash_Sys_Cfg(kIotIccidId, ml307.iccid, ML307_ICCID_LEN);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_memset((char *)ml307.iccid, 0, ML307_ICCID_LEN);
|
||||||
|
Get_IotIccid((char *)&ml307.iccid[0], ML307_ICCID_LEN);
|
||||||
|
}
|
||||||
|
// LOG_D("*(rt_uint16_t *)FLASH_IOT_IMSI_ADDR = %#X", *(rt_uint16_t *)FLASH_IOT_IMSI_ADDR);
|
||||||
/* set network interface device hardware imsi */
|
/* set network interface device hardware imsi */
|
||||||
|
if ((*(rt_uint16_t *)FLASH_IOT_IMSI_ADDR == 0xE339) || (*(uint16_t *)FLASH_IOT_IMSI_ADDR == 0x39E3))
|
||||||
{
|
{
|
||||||
|
|
||||||
#define ML307_IMSI_LEN 15
|
#define ML307_IMSI_LEN 15
|
||||||
|
@ -1069,6 +1085,11 @@ static void ml307_init_thread_entry(void *parameter)
|
||||||
rt_memcpy(ml307.imsi, imsi, ML307_IMSI_LEN);
|
rt_memcpy(ml307.imsi, imsi, ML307_IMSI_LEN);
|
||||||
Flash_Sys_Cfg(kIotImsiId, ml307.imsi, ML307_IMSI_LEN);
|
Flash_Sys_Cfg(kIotImsiId, ml307.imsi, ML307_IMSI_LEN);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_memset((char *)ml307.imsi, 0, ML307_IMSI_LEN);
|
||||||
|
Get_IotImsi((char *)&ml307.imsi[0], ML307_IMSI_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
/* check the GPRS network is registered */
|
/* check the GPRS network is registered */
|
||||||
for (i = 0; i < CEREG_RETRY; i++)
|
for (i = 0; i < CEREG_RETRY; i++)
|
||||||
|
@ -1094,43 +1115,43 @@ static void ml307_init_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)
|
||||||
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCALL=0") != RT_EOK)
|
// if (at_obj_exec_cmd(device->client, resp, "AT+MIPCALL=0") != 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 < IPADDR_RETRY; i++)
|
for (i = 0; i < IPADDR_RETRY; i++)
|
||||||
// {
|
{
|
||||||
// if (at_obj_exec_cmd(client, resp, "AT+MIPCALL?") == RT_EOK)
|
if (at_obj_exec_cmd(client, resp, "AT+MIPCALL?") == RT_EOK)
|
||||||
// {
|
{
|
||||||
// #define IP_ADDR_SIZE_MAX 16
|
#define IP_ADDR_SIZE_MAX 16
|
||||||
// char ipaddr_str[8 * IP_ADDR_SIZE_MAX] = {0};
|
char ipaddr_str[8 * IP_ADDR_SIZE_MAX] = {0};
|
||||||
// char ipaddr_v4[IP_ADDR_SIZE_MAX] = {0};
|
char ipaddr_v4[IP_ADDR_SIZE_MAX] = {0};
|
||||||
// char ipaddr_v6[4 * IP_ADDR_SIZE_MAX] = {0};
|
char ipaddr_v6[4 * IP_ADDR_SIZE_MAX] = {0};
|
||||||
|
|
||||||
// /* parse response data "+CGPADDR: 1,<IP_address>" */
|
/* parse response data "+CGPADDR: 1,<IP_address>" */
|
||||||
// if (at_resp_parse_line_args_by_kw(resp, "+MIPCALL:", "+MIPCALL: %*d,%*d,%s", ipaddr_str) > 0)
|
if (at_resp_parse_line_args_by_kw(resp, "+MIPCALL:", "+MIPCALL: %*d,%*d,%s", ipaddr_str) > 0)
|
||||||
// {
|
{
|
||||||
// const char *ipaddr_v4_str = strstr(ipaddr_str, "\"");
|
const char *ipaddr_v4_str = strstr(ipaddr_str, "\"");
|
||||||
// sscanf(ipaddr_v4_str, "\"%[^\"]", ipaddr_v4);
|
sscanf(ipaddr_v4_str, "\"%[^\"]", ipaddr_v4);
|
||||||
// const char *ipaddr_v6_str = strstr(ipaddr_str, "\",\"");
|
const char *ipaddr_v6_str = strstr(ipaddr_str, "\",\"");
|
||||||
// sscanf(ipaddr_v6_str, "\",\"%[^\"]", ipaddr_v6);
|
sscanf(ipaddr_v6_str, "\",\"%[^\"]", ipaddr_v6);
|
||||||
|
|
||||||
// LOG_D("%s device IP address: %s - %s", device->name, ipaddr_v4, ipaddr_v6);
|
LOG_D("%s device IP address: %s - %s", device->name, ipaddr_v4, ipaddr_v6);
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// rt_thread_mdelay(1000);
|
rt_thread_mdelay(1000);
|
||||||
// }
|
}
|
||||||
// if (i == IPADDR_RETRY)
|
if (i == IPADDR_RETRY)
|
||||||
// {
|
{
|
||||||
// LOG_E("%s device GPRS is get IP address failed", device->name);
|
LOG_E("%s device GPRS is get IP address failed", device->name);
|
||||||
// result = -RT_ERROR;
|
result = -RT_ERROR;
|
||||||
// goto __exit;
|
goto __exit;
|
||||||
// }
|
}
|
||||||
#endif
|
#endif
|
||||||
Time_Calibration(device);
|
Time_Calibration(device);
|
||||||
/* initialize successfully */
|
/* initialize successfully */
|
||||||
|
|
|
@ -55,7 +55,7 @@ static void _CommonBtnEvtCb (void *arg)
|
||||||
|
|
||||||
if (flex_button_event_read (&user_button[USER_BUTTON_1]) == FLEX_BTN_PRESS_DOUBLE_CLICK)
|
if (flex_button_event_read (&user_button[USER_BUTTON_1]) == FLEX_BTN_PRESS_DOUBLE_CLICK)
|
||||||
{
|
{
|
||||||
if (SysControl.status > kPreheatingEvent)
|
if(SysControl.status != kCalibrationEvent)
|
||||||
{
|
{
|
||||||
Send_Laser_Alarm_Event (kSelfCheckEvent);
|
Send_Laser_Alarm_Event (kSelfCheckEvent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,13 +150,16 @@ static rt_size_t Flash_Read(rt_uint32_t addr, rt_uint8_t *buf, rt_size_t len)
|
||||||
return read_len;
|
return read_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Get_IotImei(char *buf, rt_size_t len)
|
int Get_IotImei (char *buf, rt_size_t len)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0x39))
|
if ((*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_IMEI_ADDR != 0x39))
|
||||||
{
|
{
|
||||||
rt_memcpy(buf, (char *)FLASH_IOT_IMEI_ADDR, len);
|
char imei_buf[FLASH_IOT_IMEI_LEN + 1]={0};
|
||||||
|
Flash_Read(FLASH_IOT_IMEI_ADDR, (rt_uint8_t *)&imei_buf[0], len);
|
||||||
LOG_D("IMEI: %s", buf);
|
imei_buf[len] = '\0';
|
||||||
|
LOG_D ("read imei: %s", imei_buf);
|
||||||
|
rt_memcpy(buf, imei_buf, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -166,18 +169,21 @@ int Get_IotImei(char *buf, rt_size_t len)
|
||||||
{
|
{
|
||||||
buf[i] = '0';
|
buf[i] = '0';
|
||||||
}
|
}
|
||||||
LOG_D("IMSI: %s", buf);
|
LOG_D ("IOT IMSI: %s", buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Get_IotImsi(char *buf, rt_size_t len)
|
int Get_IotImsi (char *buf, rt_size_t len)
|
||||||
{
|
{
|
||||||
if ((*(rt_uint8_t *)FLASH_IOT_IMSI_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_IMSI_ADDR != 0x39))
|
if ((*(rt_uint8_t *)FLASH_IOT_IMSI_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_IMSI_ADDR != 0x39))
|
||||||
{
|
{
|
||||||
rt_memcpy(buf, (char *)FLASH_IOT_IMSI_ADDR, len);
|
char imsi_buf[FLASH_IOT_IMSI_LEN]={0};
|
||||||
|
Flash_Read(FLASH_IOT_IMSI_ADDR, (rt_uint8_t *)imsi_buf, len);
|
||||||
|
imsi_buf[len] = '\0';
|
||||||
|
LOG_D ("read imsi: %s", imsi_buf);
|
||||||
|
rt_memcpy(buf, imsi_buf, len);
|
||||||
|
|
||||||
LOG_D("IMSI: %s", buf);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -187,18 +193,20 @@ int Get_IotImsi(char *buf, rt_size_t len)
|
||||||
{
|
{
|
||||||
buf[i] = '0';
|
buf[i] = '0';
|
||||||
}
|
}
|
||||||
LOG_D("IMSI: %s", buf);
|
LOG_D ("IOT IMSI: %s", buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Get_IotIccid(char *buf, rt_size_t len)
|
int Get_IotIccid (char *buf, rt_size_t len)
|
||||||
{
|
{
|
||||||
if ((*(rt_uint8_t *)FLASH_IOT_ICCID_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_ICCID_ADDR != 0x39))
|
if ((*(rt_uint8_t *)FLASH_IOT_ICCID_ADDR != 0xE3) && (*(rt_uint8_t *)FLASH_IOT_ICCID_ADDR != 0x39))
|
||||||
{
|
{
|
||||||
rt_memcpy(buf, (char *)FLASH_IOT_ICCID_ADDR, len);
|
char iccid_buf[FLASH_IOT_ICCID_LEN]={0};
|
||||||
|
Flash_Read(FLASH_IOT_ICCID_ADDR, (rt_uint8_t *)iccid_buf, len);
|
||||||
LOG_D("ICCID: %s", buf);
|
iccid_buf[len] = '\0';
|
||||||
|
LOG_D ("read iccid: %s", iccid_buf);
|
||||||
|
rt_memcpy(buf, iccid_buf, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -208,11 +216,12 @@ int Get_IotIccid(char *buf, rt_size_t len)
|
||||||
{
|
{
|
||||||
buf[i] = '0';
|
buf[i] = '0';
|
||||||
}
|
}
|
||||||
LOG_D("ICCID: %s", buf);
|
LOG_D ("IOT ICCID: %s", buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description:
|
* @description:
|
||||||
* @param {uint32_t} addr
|
* @param {uint32_t} addr
|
||||||
|
@ -895,7 +904,7 @@ int BSP_Flash_Init (void)
|
||||||
|
|
||||||
Flash_SetProductTimeLimit (2025, 2, 10, 13, 50, 20, kFactoryTimeId);
|
Flash_SetProductTimeLimit (2025, 2, 10, 13, 50, 20, kFactoryTimeId);
|
||||||
Set_ExpirationTime (MAX_EXPIRATION_DAYS);
|
Set_ExpirationTime (MAX_EXPIRATION_DAYS);
|
||||||
Flash_Set_Calibration_State(kSysGasCalibStatus); // 标定状态
|
Flash_Set_Calibration_State(kNotCalibrated); // 标定状态
|
||||||
Flash_Set_Valve_Num(0);
|
Flash_Set_Valve_Num(0);
|
||||||
sci.hw_ver = SYS_HW_VERSION;
|
sci.hw_ver = SYS_HW_VERSION;
|
||||||
sci.sw_ver = SYS_SW_VERSION;
|
sci.sw_ver = SYS_SW_VERSION;
|
||||||
|
|
|
@ -814,6 +814,7 @@ int Ml307_Send_Device_Failure(struct at_device *device, void *param)
|
||||||
}
|
}
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*这个【4、优先级最低当同时触发后,相同服务直接合并】暂时还没想好怎么做,
|
/*这个【4、优先级最低当同时触发后,相同服务直接合并】暂时还没想好怎么做,
|
||||||
思路感觉就是得重新开一个线程,然后再开一个任务队列,将所有的事件,发送到任务队列
|
思路感觉就是得重新开一个线程,然后再开一个任务队列,将所有的事件,发送到任务队列
|
||||||
在线程中,对任务队列进行查看并处理,看目前都有哪些事件,是处于那个优先级得,如果是最低优先级,就只发送一帧数据就行了,
|
在线程中,对任务队列进行查看并处理,看目前都有哪些事件,是处于那个优先级得,如果是最低优先级,就只发送一帧数据就行了,
|
||||||
|
@ -943,13 +944,8 @@ int Ml307_Process_Events(Ml307Event ml307_recv_event, struct at_device *device,
|
||||||
if (ret != RT_EOK)
|
if (ret != RT_EOK)
|
||||||
{
|
{
|
||||||
ml307_connect_sever_flag = 0;
|
ml307_connect_sever_flag = 0;
|
||||||
ml307_conncet_tcp_flag = 0;
|
rt_sem_release(ml307_disconnect_sem);
|
||||||
if (!ml307_disconnect_retry_flag)
|
LOG_D("与服务区断开连接,等待连接中......\n");
|
||||||
{
|
|
||||||
LOG_D("断网,启动重连\n");
|
|
||||||
rt_sem_release(ml307_disconnect_sem);
|
|
||||||
}
|
|
||||||
LOG_D("断网,等待连接中......\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1967,19 +1963,43 @@ 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;
|
||||||
// }
|
}
|
||||||
// int link_stat = 0;
|
#if defined(AT_DEBUG)
|
||||||
// if (at_resp_parse_line_args_by_kw(resp, "+MIPCALL:", "+MIPCALL: %d,%*d,%*s", &link_stat) > 0)
|
/* check the GPRS network IP address */
|
||||||
// {
|
for (i = 0; i < 10; i++)
|
||||||
// if (link_stat == 1)
|
{
|
||||||
// {
|
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCALL?") == RT_EOK)
|
||||||
// result = RT_EOK;
|
{
|
||||||
// }
|
#define IP_ADDR_SIZE_MAX 16
|
||||||
// }
|
char ipaddr_str[8 * IP_ADDR_SIZE_MAX] = {0};
|
||||||
|
char ipaddr_v4[IP_ADDR_SIZE_MAX] = {0};
|
||||||
|
char ipaddr_v6[4 * IP_ADDR_SIZE_MAX] = {0};
|
||||||
|
|
||||||
|
/* parse response data "+CGPADDR: 1,<IP_address>" */
|
||||||
|
if (at_resp_parse_line_args_by_kw(resp, "+MIPCALL:", "+MIPCALL: %*d,%*d,%s", ipaddr_str) > 0)
|
||||||
|
{
|
||||||
|
const char *ipaddr_v4_str = rt_strstr(ipaddr_str, "\"");
|
||||||
|
sscanf(ipaddr_v4_str, "\"%[^\"]", ipaddr_v4);
|
||||||
|
const char *ipaddr_v6_str = rt_strstr(ipaddr_str, "\",\"");
|
||||||
|
sscanf(ipaddr_v6_str, "\",\"%[^\"]", ipaddr_v6);
|
||||||
|
|
||||||
|
LOG_D("%s device IP address: %s - %s", device->name, ipaddr_v4, ipaddr_v6);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rt_thread_mdelay(2000);
|
||||||
|
}
|
||||||
|
if (i == 10)
|
||||||
|
{
|
||||||
|
LOG_E("%s device GPRS is get IP address failed", device->name);
|
||||||
|
result = -RT_ERROR;
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (device->class->device_ops->control(device, AT_DEVICE_CTRL_NET_CONN, RT_NULL) == RT_EOK)
|
if (device->class->device_ops->control(device, AT_DEVICE_CTRL_NET_CONN, RT_NULL) == RT_EOK)
|
||||||
{
|
{
|
||||||
LOG_D("重连网络成功\n");
|
LOG_D("重连网络成功\n");
|
||||||
|
@ -2012,6 +2032,7 @@ static void Ml307_Life_Thread_Entry(void *parameter)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ml307_disconnect_retry_flag = 0;
|
ml307_disconnect_retry_flag = 0;
|
||||||
|
Ml307_Send_Event(kMl307HeartbeatEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2146,6 +2167,7 @@ int BSP_Ml307_Thread_Init(void)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INIT_APP_EXPORT(BSP_Ml307_Thread_Init);
|
// INIT_APP_EXPORT(BSP_Ml307_Thread_Init);
|
||||||
|
|
||||||
int ml307_device_register(void)
|
int ml307_device_register(void)
|
||||||
|
@ -2158,6 +2180,7 @@ int ml307_device_register(void)
|
||||||
AT_DEVICE_CLASS_ML307,
|
AT_DEVICE_CLASS_ML307,
|
||||||
(void *)ml307);
|
(void *)ml307);
|
||||||
}
|
}
|
||||||
|
|
||||||
// INIT_DEVICE_EXPORT(ml307_device_register);
|
// INIT_DEVICE_EXPORT(ml307_device_register);
|
||||||
|
|
||||||
#endif // IOT_MODULE_SWITCH
|
#endif // IOT_MODULE_SWITCH
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ static void Sensor_HandleAlarm(uint8_t count, uint8_t threshold)
|
||||||
alarm_flag = 1;
|
alarm_flag = 1;
|
||||||
Sensor_device.detection_flag = kSensorAlarm;
|
Sensor_device.detection_flag = kSensorAlarm;
|
||||||
Send_Laser_Alarm_Event(kAlarmEvent);
|
Send_Laser_Alarm_Event(kAlarmEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (alarm_flag == 1 && count == 0)
|
else if (alarm_flag == 1 && count == 0)
|
||||||
{
|
{
|
||||||
|
@ -180,6 +180,7 @@ static void Sensor_detection_thread_entry(void *param)
|
||||||
if(calibration_flag == 1)
|
if(calibration_flag == 1)
|
||||||
break;
|
break;
|
||||||
rt_thread_mdelay(1000);
|
rt_thread_mdelay(1000);
|
||||||
|
Get_Gas_VoltageAdcInt1000x();
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_uint16_t alarm_value = Flash_Get_SysCfg(kAlarmLValueId); // 获取系统报警阈值;
|
rt_uint16_t alarm_value = Flash_Get_SysCfg(kAlarmLValueId); // 获取系统报警阈值;
|
||||||
|
|
Loading…
Reference in New Issue