2024-05-31

This commit is contained in:
2584532475@qq.com 2024-04-08 20:38:35 +08:00
parent f8591b8b99
commit 4a963bd78c
27 changed files with 2956 additions and 229 deletions

View File

@ -12,6 +12,7 @@
#include <string.h>
#include <stdlib.h>
#include "mqtt-board.h"
#include "relay-board.h"
#include "data.h"
uint32_t os_timer_count = 1;
@ -38,7 +39,7 @@ static rt_timer_t locktimer;
static void locktimerouter (void* parameter)
{
// todo 关闭定时器
HAL_GPIO_WritePin (LOCK_GPIO_Port, LOCK_Pin, GPIO_PIN_RESET);
MX_Relay_Push(RELAYDoor,RELAY_DISC);
}
static void thread_entry (void *parameter)
@ -68,6 +69,7 @@ static void thread_entry (void *parameter)
//gCommEvents = rt_event_create ("gCommEvents", RT_IPC_FLAG_FIFO) ;
locktimer = rt_timer_create ("locktimer", locktimerouter, RT_NULL, 1000, RT_TIMER_FLAG_ONE_SHOT); // 异常检测定时器
RtcThreadStart ();
SluiceThreadStart(); // 闸门控制线程
U4851ThreadStart(); // 4851采集线程
U4852ThreadStart(); // 4852采集线程
@ -89,7 +91,7 @@ static void thread_entry (void *parameter)
if (RT_EOK == rt_event_recv (gCtrlEvents, EVENT_CTRL_SET_UNLOCK, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 2000, RT_NULL)) // 数据接受失败,上报异常状态
{
// todo: 打开继电器,开启定时器
HAL_GPIO_WritePin (LOCK_GPIO_Port, LOCK_Pin, GPIO_PIN_SET);
MX_Relay_Push(RELAYDoor,RELAY_CONN);
rt_timer_start (locktimer);
}
}

View File

@ -64,10 +64,14 @@
#define CFG_THREAD_PRIORITY 13 // 优先级
#define CFG_THREAD_TIMESLICE 5
// UIÏß³Ì
// 升级
#define UPGRADE_THREAD_PRIORITY 12 // 优先级
#define UPGRADE_THREAD_TIMESLICE 5
// RTC
#define RTC_THREAD_PRIORITY 11 // 优先级
#define RTC_THREAD_TIMESLICE 5
int ThreadNewOsApp (void);
void SluiceThreadStart (void);
@ -84,6 +88,7 @@ void CAT1ThreadStart (void);
void ZS001ThreadStart (void);
void MJEth1ThreadStart (void);
void UpgradeThreadStart (void);
void RtcThreadStart (void);
#define EVENT_CTRL_SET_OPT_SLU (1U<< 0) // 发送开度控制到提闸线程
#define EVENT_CTRL_SET_STP_SLU (1U<< 1) // 发送停止控制到提闸线程
@ -118,6 +123,7 @@ void UpgradeThreadStart (void);
#define EVENT_TRIG_COMM_RX (1U << 6) // MQTT 接受到数据
#define EVENT_TRIG_COMM_RST (1U << 7) // MQTT 发送数据
#define EVENT_TRIG_UPGRADE_RX (1U << 8) // MQTT 接受到数据
#define EVENT_TRIG_NETMODE_TX2 (1U << 9) // 通过网络模块向通道2发送数据
#define MAIL_COMM_HEART 0
@ -127,6 +133,7 @@ void UpgradeThreadStart (void);
#define MAIL_COMM_UPACK 4 // 提闸的ACK
#define MAIL_COMM_SLACK 5 // 其他的ACK
#define MAIL_COMM_READPARA 6 // 读取参数
#define MAIL_COMM_ACK 7 // 读取参数
#define MAIL_SLUICE_OPT 0
#define MAIL_SLUICE_STP 1
@ -134,10 +141,10 @@ void UpgradeThreadStart (void);
#define MAIL_SLUICE_SDW 3
#define MAIL_CT_OPT 0
#define MAIL_CT_SUP 1
#define MAIL_CT_SDW 2
#define MAIL_CT_STP 3
#define MAIL_CT_OPT 0 // 执行
#define MAIL_CT_SUP 1 // 上升
#define MAIL_CT_SDW 2 // 下降
#define MAIL_CT_STP 3 // 停止
#define MAIL_VIEW_LOGIN 1 // 登录成功 需要跳转页面
#define MAIL_VIEW_FLUSH 2 // 刷新界面显示

View File

@ -3,94 +3,116 @@
const StrIndex_t cDownDataType[] =
/******************************************
*
******************************************/
volatile const char _makeData[] = __DATE__; //12字节编译日期
volatile const char _makeTime[] = __TIME__; //9字节
volatile const char cBootv[] = "Ver3.0.0"; //获取时添加上面两个时间信息最大长度64字节
char _versionTemp[64];
const StrIndex_t cDownDataType[] =
{
{"run",DownRun} ,
{"stop",DownStop} ,
{"open",DownOpen} ,
{"close",DownClose} ,
{"reg_ans",DownRegistAns} ,
{"heart_ans",DownHeartAns},
{"update",DownUpdate},
{"reboot",DownReboot},
{"config",DownConfig},
{"read",DownRead}
{"run", DownRun},
{"stop", DownStop},
{"open", DownOpen},
{"close", DownClose},
{"reg_ans", DownRegistAns},
{"heart_ans", DownHeartAns},
{"update", DownUpdate},
{"reboot", DownReboot},
{"config", DownConfig},
{"read", DownRead},
{"fact", DownFact}
};
const StrIndex_t cSiteType[] =
const StrIndex_t cSiteType[] =
{
{"sluice",SiteSluice} ,
{"flow",SiteFlow} ,
{"press",SiteSee} ,
{"auto",SiteColl} ,
{"trans",SiteServer} ,
{"level",SiteLevel}
{"sluice", SiteSluice},
{"flow", SiteFlow},
{"press", SiteSee},
{"auto", SiteColl}, // 自动化采集站
{"trans", SiteServer},
{"level", SiteLevel},
{"skew", SiteSkew} //测斜仪
};
const StrIndex_t cMotorType[] =
const StrIndex_t cMotorType[] =
{
{"mg1000",MT_MG_1000} ,
{"qh100",MT_QH_V100} ,
{"qh200",MT_QH_V200} ,
{"zs100",MT_ZS_V100} ,
{"dy100",MT_DY_V100} ,
{"kg100",MT_KG_V100}
{"mg1000", MT_MG_1000},
{"qh100", MT_QH_V100},
{"qh200", MT_QH_V200},
{"zs100", MT_ZS_V100},
{"jz200", MT_JZ_V200}, // 金志 4-20 ma
{"dy100", MT_DY_V100}, // 大禹锥型阀
{"kg100", MT_KG_V100}, // 开关量模块
{"kr100", MT_KR_V100}, // 闸位计
{"asca3", MT_ASC_A3}, // A3 驱动器
{"ascws", MT_ASC_WS}, // A3 驱动器
};
const StrIndex_t c4851Type[] =
const StrIndex_t c4851Type[] =
{
{"mg1000",ST_MG_1000} ,
{"qh100",ST_QH_V100} ,
{"qh200",ST_QH_V200} ,
{"dy100",ST_DY_V100} ,
{"kg100",ST_KG_V100} ,
{"mg1000", ST_MG_1000},
{"qh100", ST_QH_V100},
{"qh200", ST_QH_V200},
{"zs100", ST_ZS_V100}, // 中盛4-20ma
{"dy100", ST_DY_V100},
{"kg100", ST_KG_V100},
{"at100", ST_AT_V100},
{"kr100", ST_KR_V100},
};
const StrIndex_t cU485Type[] =
const StrIndex_t cU485Type[] =
{
{"modbus",0}
{"modbus", 0}
};
const StrIndex_t c4852Type[] =
// 485 2 通道
const StrIndex_t c4852Type[] =
{
{"rds600",ST_RDS_600} ,
{"tds300",ST_TDS_300} ,
{"ht100",ST_HT_V100} ,
{"zkjszk",ST_ZK_JSZK},
{"djx100",ST_DJX_100},
{"rds300",ST_RDS_300}
{"rds600", ST_RDS_600},
{"tds300", ST_TDS_300},
{"ht100", ST_HT_V100},
{"zkjszk", ST_ZK_JSZK},
{"djx100", ST_DJX_100},
{"rds300", ST_RDS_300},
{"mi600", ST_MI_600} // 测斜仪
};
const ParShallInfo_t ParShallTale[] =
const ParShallInfo_t ParShallTale[] =
{
{.w = 0,.c = 0,.m = 0},
{.w = 0.152, .c = 0.381, .m = 1.58 ,.minLeve = 0.03, .maxLeve = 0.45, .minFlow = 1.5/1000, .maxFlow = 100/1000},
{.w = 0.25, .c = 0.561, .m = 1.513 ,.minLeve = 0.03, .maxLeve = 0.60, .minFlow = 3.0/1000, .maxFlow = 250/1000},
{.w = 0.30, .c = 0.679, .m = 1.521 ,.minLeve = 0.03, .maxLeve = 0.75, .minFlow = 3.5/1000, .maxFlow = 400/1000},
{.w = 0.45, .c = 1.038, .m = 1.537 ,.minLeve = 0.03, .maxLeve = 0.75, .minFlow = 4.5/1000, .maxFlow = 630/1000},
{.w = 0.60, .c = 1.403, .m = 1.548 ,.minLeve = 0.05, .maxLeve = 0.75, .minFlow = 12.5/1000, .maxFlow = 850/1000},
{.w = 0.75, .c = 1.772, .m = 1.557 ,.minLeve = 0.06, .maxLeve = 0.75, .minFlow = 25.0/1000, .maxFlow = 1100/1000},
{.w = 0.90, .c = 2.147, .m = 1.565 ,.minLeve = 0.06, .maxLeve = 0.75, .minFlow = 30.0/1000, .maxFlow = 1250/1000},
{.w = 1.00, .c = 2.397, .m = 1.569 ,.minLeve = 0.06, .maxLeve = 0.80, .minFlow = 30.0/1000, .maxFlow = 1500/1000},
{.w = 1.20, .c = 2.904, .m = 1.577 ,.minLeve = 0.06, .maxLeve = 0.80, .minFlow = 35.0/1000, .maxFlow = 2000/1000},
{.w = 1.50, .c = 3.668, .m = 1.586 ,.minLeve = 0.06, .maxLeve = 0.80, .minFlow = 45.0/1000, .maxFlow = 2500/1000},
{.w = 1.80, .c = 4.440, .m = 1.593 ,.minLeve = 0.08, .maxLeve = 0.80, .minFlow = 80.0/1000, .maxFlow = 3000/1000},
{.w = 2.10, .c = 5.222, .m = 1.599 ,.minLeve = 0.08, .maxLeve = 0.80, .minFlow = 95.0/1000, .maxFlow = 3600/1000},
{.w = 2.40, .c = 6.004, .m = 1.605 ,.minLeve = 0.08, .maxLeve = 0.80, .minFlow = 100.0/1000, .maxFlow = 4000/1000},
{.w = 3.05, .c = 7.463, .m = 1.6 ,.minLeve = 0.09, .maxLeve = 1.07, .minFlow = 0.16, .maxFlow = 8.28},
{.w = 3.66, .c = 8.859, .m = 1.6 ,.minLeve = 0.09, .maxLeve = 1.37, .minFlow = 0.19, .maxFlow = 14.68},
{.w = 4.57, .c = 10.96, .m = 1.6 ,.minLeve = 0.09, .maxLeve = 1.67, .minFlow = 0.23, .maxFlow = 25.04},
{.w = 6.10, .c = 14.45, .m = 1.6 ,.minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.31, .maxFlow = 37.97},
{.w = 7.62, .c = 17.94, .m = 1.6 ,.minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.38, .maxFlow = 47.16},
{.w = 9.14, .c = 21.44, .m = 1.6 ,.minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.46, .maxFlow = 56.33},
{.w = 12.19, .c = 28.43, .m = 1.6 ,.minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.60, .maxFlow = 74.70},
{.w = 15.24, .c = 35.41, .m = 1.6 ,.minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.75, .maxFlow = 93.04},
{.w = 0, .c = 0, .m = 0},
{.w = 0.152, .c = 0.381, .m = 1.58 , .minLeve = 0.03, .maxLeve = 0.45, .minFlow = 1.5 / 1000, .maxFlow = 100 / 1000},
{.w = 0.25, .c = 0.561, .m = 1.513 , .minLeve = 0.03, .maxLeve = 0.60, .minFlow = 3.0 / 1000, .maxFlow = 250 / 1000},
{.w = 0.30, .c = 0.679, .m = 1.521 , .minLeve = 0.03, .maxLeve = 0.75, .minFlow = 3.5 / 1000, .maxFlow = 400 / 1000},
{.w = 0.45, .c = 1.038, .m = 1.537 , .minLeve = 0.03, .maxLeve = 0.75, .minFlow = 4.5 / 1000, .maxFlow = 630 / 1000},
{.w = 0.60, .c = 1.403, .m = 1.548 , .minLeve = 0.05, .maxLeve = 0.75, .minFlow = 12.5 / 1000, .maxFlow = 850 / 1000},
{.w = 0.75, .c = 1.772, .m = 1.557 , .minLeve = 0.06, .maxLeve = 0.75, .minFlow = 25.0 / 1000, .maxFlow = 1100 / 1000},
{.w = 0.90, .c = 2.147, .m = 1.565 , .minLeve = 0.06, .maxLeve = 0.75, .minFlow = 30.0 / 1000, .maxFlow = 1250 / 1000},
{.w = 1.00, .c = 2.397, .m = 1.569 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 30.0 / 1000, .maxFlow = 1500 / 1000},
{.w = 1.20, .c = 2.904, .m = 1.577 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 35.0 / 1000, .maxFlow = 2000 / 1000},
{.w = 1.50, .c = 3.668, .m = 1.586 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 45.0 / 1000, .maxFlow = 2500 / 1000},
{.w = 1.80, .c = 4.440, .m = 1.593 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 80.0 / 1000, .maxFlow = 3000 / 1000},
{.w = 2.10, .c = 5.222, .m = 1.599 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 95.0 / 1000, .maxFlow = 3600 / 1000},
{.w = 2.40, .c = 6.004, .m = 1.605 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 100.0 / 1000, .maxFlow = 4000 / 1000},
{.w = 3.05, .c = 7.463, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.07, .minFlow = 0.16, .maxFlow = 8.28},
{.w = 3.66, .c = 8.859, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.37, .minFlow = 0.19, .maxFlow = 14.68},
{.w = 4.57, .c = 10.96, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.67, .minFlow = 0.23, .maxFlow = 25.04},
{.w = 6.10, .c = 14.45, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.31, .maxFlow = 37.97},
{.w = 7.62, .c = 17.94, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.38, .maxFlow = 47.16},
{.w = 9.14, .c = 21.44, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.46, .maxFlow = 56.33},
{.w = 12.19, .c = 28.43, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.60, .maxFlow = 74.70},
{.w = 15.24, .c = 35.41, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.75, .maxFlow = 93.04},
} ;
@ -98,7 +120,14 @@ const ParShallInfo_t ParShallTale[] =
SluiceData_t SluiceData[SLUICE_COUTN];
WaterData_t WaterData[WATER_COUTN];
InclinometerData_t IncData[6]; // 测斜仪数据
SysData_t SysData;
SOFTRTC_t g_SoftRtc =
{
23, 10, 1, 0, 0, 0
};
uint32_t g_ifconfig = 0;
uint32_t g_ifupdate = 0;
@ -106,9 +135,9 @@ uint32_t g_ifupdate = 0;
int cMotorGetType (char * str)
{
for (int i =0;i < sizeof(cMotorType)/sizeof(StrIndex_t);i++)
for (int i = 0; i < sizeof (cMotorType) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp(str,cMotorType[i].str,rt_strlen(str)) == 0)
if (rt_memcmp (str, cMotorType[i].str, rt_strlen (str)) == 0)
{
return cMotorType[i].index;
}
@ -117,13 +146,13 @@ int cMotorGetType (char * str)
}
int c4851GetType(char * str)
int c4851GetType (char * str)
{
rt_kprintf("485 option count:%d\r\n",sizeof(c4851Type)/sizeof(StrIndex_t)) ;
for (int i =0;i < sizeof(c4851Type)/sizeof(StrIndex_t);i++)
rt_kprintf ("485 option count:%d\r\n", sizeof (c4851Type) / sizeof (StrIndex_t)) ;
for (int i = 0; i < sizeof (c4851Type) / sizeof (StrIndex_t); i++)
{
rt_kprintf("%s,%s\r\n",str,c4851Type[i].str) ;
if (rt_memcmp(str,c4851Type[i].str,rt_strlen(str)) == 0)
rt_kprintf ("%s,%s\r\n", str, c4851Type[i].str) ;
if (rt_memcmp (str, c4851Type[i].str, rt_strlen (str)) == 0)
{
return c4851Type[i].index;
}
@ -131,11 +160,11 @@ int c4851GetType(char * str)
return -1;
}
int c4852GetType(char * str)
int c4852GetType (char * str)
{
for (int i =0;i < sizeof(c4852Type)/sizeof(StrIndex_t);i++)
for (int i = 0; i < sizeof (c4852Type) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp(str,c4852Type[i].str,rt_strlen(str)) == 0)
if (rt_memcmp (str, c4852Type[i].str, rt_strlen (str)) == 0)
{
return c4852Type[i].index;
}
@ -144,11 +173,11 @@ int c4852GetType(char * str)
}
int cU485GetType(char *str)
int cU485GetType (char *str)
{
for (int i =0;i < sizeof(cU485Type)/sizeof(StrIndex_t);i++)
for (int i = 0; i < sizeof (cU485Type) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp(str,cU485Type[i].str,rt_strlen(str)) == 0)
if (rt_memcmp (str, cU485Type[i].str, rt_strlen (str)) == 0)
{
return cU485Type[i].index;
}
@ -157,11 +186,11 @@ int cU485GetType(char *str)
}
int cDownType2Index(char * str)
int cDownType2Index (char * str)
{
for (int i =0;i < sizeof(cDownDataType)/sizeof(StrIndex_t);i++)
for (int i = 0; i < sizeof (cDownDataType) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp(str,cDownDataType[i].str,rt_strlen(str)) == 0)
if (rt_memcmp (str, cDownDataType[i].str, rt_strlen (str)) == 0)
{
return cDownDataType[i].index;
}
@ -171,11 +200,11 @@ int cDownType2Index(char * str)
int cSiteType2Index(char * str)
int cSiteType2Index (char * str)
{
for (int i =0;i < sizeof(cSiteType)/sizeof(StrIndex_t);i++)
for (int i = 0; i < sizeof (cSiteType) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp(str,cSiteType[i].str,rt_strlen(str)) == 0)
if (rt_memcmp (str, cSiteType[i].str, rt_strlen (str)) == 0)
{
return cSiteType[i].index;
}
@ -186,6 +215,17 @@ int cSiteType2Index(char * str)
/**********************************************
boot版本信息
**********************************************/
void *GetVersion (void)
{
int i = rt_sprintf (_versionTemp, "%s-%s %s", cBootv, _makeData, _makeTime);
_versionTemp[i] = 0;
return (void*) _versionTemp;
}

View File

@ -3,13 +3,20 @@
#include <stdint.h>
#define SLUICE_COUTN 1// 当前处理几口闸
#define WATER_COUTN 6// 当前接入n个流量计
#define SUBTOPIC_COUNT 1 // 订阅topic 数量
#define SLUCIE_EXEC_COUNT 20// 闸门异常时间
#define VERSION "V2.0.1"
#define VERSION "KRH-1.0.16"
// #define AI_AOVERSION "KRH-1.0.16"
//AIAO
@ -20,7 +27,7 @@ typedef struct StrIndex_t
{
char str[10];
int index;
}StrIndex_t;
} StrIndex_t;
// 巴歇尔槽流量计
@ -33,7 +40,7 @@ typedef struct ParShallInfo_t
double maxLeve;
double minFlow;
double maxFlow;
}ParShallInfo_t;
} ParShallInfo_t;
@ -41,13 +48,13 @@ typedef struct LeveInfo_t
{
uint16_t Y[100]; // 水位
uint16_t Key[100]; // 流量
}LeveInfo_t;
} LeveInfo_t;
// 水位流量关系表数据
typedef struct WaterLeveInfo_t
{
uint16_t X[100]; // 单位 mm
LeveInfo_t Key[100];
}WaterLeveInfo_t;
} WaterLeveInfo_t;
@ -78,18 +85,37 @@ typedef struct SysData_t
int fileSize; // 文件大小
} SysData_t;
typedef struct SOFTRTC_t
{
uint8_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minutes;
uint8_t second;
} SOFTRTC_t;
// 水量参数
typedef struct InclinometerData_t
{
uint8_t dir; // 方向
uint32_t data;// 数据
} InclinometerData_t;
// 测斜数据
typedef struct WaterData_t
{
int64_t ttWater; // 累计流量 单位 m3
int32_t thisFlow; // 瞬时流量 单位 m3
int32_t thisLevel; // 水位
int32_t thisSpeed; // 流速
int64_t ttWater; // 累计流量 单位 m3
int32_t thisFlow; // 瞬时流量 单位 m3
int32_t thisLevel; // 水位
int32_t thisSpeed; // 流速
int32_t thisPress; // 压力
int32_t thisTemp; // 温度
int retry ; // 重试次数
} WaterData_t;
@ -98,7 +124,7 @@ typedef enum Ctrl_Mode_t
{
CTRL_FOPEN = 0,
CTRL_ZOPEN = 1
}Ctrl_Mode_t;
} Ctrl_Mode_t;
typedef enum MotorType_t
@ -106,11 +132,13 @@ typedef enum MotorType_t
MT_MG_1000, // 米格1000
MT_QH_V100, // 强华 1.0 版本
MT_QH_V200, // 强华 2.0 版本
MT_ZS_V100, // 中盛 4-20 ma
MT_ZS_V100, // 中盛 4-20 ma
MT_JZ_V200, // 金志 4-20 ma
MT_DY_V100, // 大禹锥型阀
MT_KG_V100, // 开关量模块
MT_KR_V100, // 徐州正天闸位计
MT_ASC_A3, // A3驱动器
MT_ASC_WS, // 金昌无刷电机
} MotorType_t;
typedef enum S4851Type_t
@ -118,6 +146,7 @@ typedef enum S4851Type_t
ST_MG_1000, // 米格1000
ST_QH_V100, // 强华 1.0 版本
ST_QH_V200, // 强华 2.0 版本
ST_ZS_V100, // 中盛4-20ma
ST_AT_V100, // 奥图编码器
ST_DY_V100, // 大禹锥形阀
ST_KG_V100, // 开关量模块
@ -129,9 +158,10 @@ typedef enum S4852Type_t
ST_RDS_600, // rds600 雷达流速一体机
ST_TDS_300, // tds300 超声波流量计
ST_HT_V100, // 华天液位计
ST_ZK_JSZK, // 精水中科多普勒
ST_ZK_JSZK, // 精水中科多普勒
ST_DJX_100, // 丁家峡闸门 读取开度
ST_RDS_300, // 雷达流量计
ST_MI_600, // 鹦鸽嘴测斜仪
} S4852Type_t;
@ -140,7 +170,7 @@ typedef enum SOFTFLOWType_t
NONE,
WATER,
PARSHALL//
}SOFTFLOWType_t;
} SOFTFLOWType_t;
@ -151,8 +181,9 @@ typedef enum SiteType_t
SiteSee, // 渗流渗压站
SiteColl, // 采集站
SiteServer, // 串口服务器
SiteLevel // 水位站
}SiteType_t;
SiteLevel, // 水位站
SiteSkew // 测斜仪
} SiteType_t;
typedef enum DownDataType_t
@ -167,7 +198,8 @@ typedef enum DownDataType_t
DownReboot = 7, // 重启
DownConfig = 8, // 修改参数
DownRead = 9, // 读取参数
}DownDataType_t;
DownFact = 10, // 读取参数
} DownDataType_t;
@ -178,36 +210,40 @@ typedef struct TypeIndexMail_t
{
uint16_t Type;
uint16_t index;
}TypeIndexMail_t;
} TypeIndexMail_t;
extern SluiceData_t SluiceData[SLUICE_COUTN];
extern WaterData_t WaterData[WATER_COUTN];
extern InclinometerData_t IncData[6];
extern SysData_t SysData;
extern const WaterLeveInfo_t LeveInfo;
extern const ParShallInfo_t ParShallTale[];
extern SOFTRTC_t g_SoftRtc;
int cMotorGetType (char * str);
int c4851GetType(char * str);
int c4851GetType (char * str);
int c4852GetType(char * str);
int c4852GetType (char * str);
int cU485GetType(char *str);
int cU485GetType (char *str);
// 读取控制模式
int cCtrlGetType(char * str);
int cCtrlGetType (char * str);
int cDownType2Index(char * str);
int cDownType2Index (char * str);
int cSiteType2Index(char * str);
int cSiteType2Index (char * str);
void *GetVersion (void);
#endif

View File

@ -1,39 +1,40 @@
#include "main.h"
#include "di-board.h"
int DiReadChann (int chann)
DIState_t MX_Din_Pull (int chann)
{
int ret = -1;
DIState_t ret;
switch (chann)
{
case 1:
{
ret = HAL_GPIO_ReadPin (DI1_GPIO_Port, DI1_Pin);
ret = (DIState_t) HAL_GPIO_ReadPin (DI1_GPIO_Port, DI1_Pin);
break;
}
case 2:
{
ret = HAL_GPIO_ReadPin (DI2_GPIO_Port, DI2_Pin);
ret = (DIState_t) HAL_GPIO_ReadPin (DI2_GPIO_Port, DI2_Pin);
break;
}
case 3:
{
ret = HAL_GPIO_ReadPin (DI3_GPIO_Port, DI4_Pin);
ret = (DIState_t) HAL_GPIO_ReadPin (DI3_GPIO_Port, DI3_Pin);
break;
}
case 4:
{
ret = HAL_GPIO_ReadPin (DI4_GPIO_Port, DI4_Pin);
ret = (DIState_t) HAL_GPIO_ReadPin (DI4_GPIO_Port, DI4_Pin);
break;
}
case 5:
{
ret = HAL_GPIO_ReadPin (DI5_GPIO_Port, DI5_Pin);
ret = (DIState_t) HAL_GPIO_ReadPin (DI5_GPIO_Port, DI5_Pin);
break;
}
case 6:
{
ret = HAL_GPIO_ReadPin (DI6_GPIO_Port, DI6_Pin);
ret = (DIState_t) HAL_GPIO_ReadPin (DI6_GPIO_Port, DI6_Pin);
break;
}
}

View File

@ -1,8 +1,14 @@
#ifndef _DI_BOARD_H
#define _DI_BOARD_H
typedef enum DIState_t
{
DI_HIGH = 1,
DI_LOW = 0
} DIState_t;
void DiInit (void);
int DiReadChann (int chann);
DIState_t MX_Din_Pull (int chann);
#endif

View File

@ -3,7 +3,7 @@
void MX_Dout_Push(int index,int pwm)
void MX_Dout_Push (int index, int pwm)
{
MX_TIM_SetDuty(index,pwm);
MX_TIM_SetDuty (index, pwm);
}

View File

@ -1,6 +1,6 @@
#ifndef _DO_BOARD_HH
#define _DO_BOARD_HH
void MX_Dout_Push(int index, int pwm);
void MX_Dout_Push (int index, int pwm);
#endif
#endif

View File

@ -165,7 +165,7 @@ static CommRet_T cat1_sendcmd_and_responce (int time, char * tx, int size, char
{
if (RT_EOK == rt_event_recv (gUartEvents, EVENT_UART_GSM_RX, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, RT_NULL))
{
// rt_kprintf ("[%.*s]", g_GSMDrv.rx_size, g_GSMDrv.rx_buffer) ;
//rt_kprintf ("[%.*s]", g_GSMDrv.rx_size, g_GSMDrv.rx_buffer) ;
if (NULL != rt_strstr ( (char *) g_GSMDrv.rx_buffer, ack))
{
if (call != NULL)
@ -278,6 +278,26 @@ CAT1RST:
rt_kprintf ("NET:+CME:ERROR QIRD\r\n");
goto CAT1RST;
}
// // 通过通道2上报数据
// if (RT_EOK == rt_event_recv (gTrigEvents, EVENT_TRIG_NETMODE_TX2, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, RT_NULL)) // 需要发送数据
// {
// if (g_cat1Drv.txbuff != NULL)
// {
// rt_sprintf (at_cmd, "AT+QISEND=0,%d\r\n", g_cat1Drv.tx_size);
// rt_thread_mdelay (10);
// if (cat1_sendcmd_and_responce (1000, at_cmd, strlen (at_cmd), ">", NULL) != RetSucc)
// {
// rt_kprintf ("NET:+CME:ERROR QISEND\r\n");
// goto CAT1RST;
// }
// if (cat1_sendcmd_and_responce (3000, g_cat1Drv.txbuff, g_cat1Drv.tx_size, "SEND OK", NULL) != RetSucc)
// {
// rt_kprintf ("NET:+CME:ERROR QPUSH\r\n");
// goto CAT1RST;
// }
// }
// }
}
rt_thread_mdelay (3000);
}
@ -292,6 +312,14 @@ void cat1_service_tx (char * buff, int size)
rt_event_send (gTrigEvents, EVENT_TRIG_NETMODE_TX1) ;
}
// 通过网络通道2发送数据
void cat1_service2_tx (char * buff, int size)
{
rt_memcpy (g_cat1Drv.txbuff, buff, size);
g_cat1Drv.tx_size = size;
rt_event_send (gTrigEvents, EVENT_TRIG_NETMODE_TX2) ;
}
void CAT1ThreadStart (void)
{

View File

@ -26,15 +26,15 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
cJSON_AddItemToObject (root, "site_type", cJSON_CreateString (p)); // 表示流量计
cJSON_AddItemToObject (root, "pver", cJSON_CreateString (PROTO_VER)); // 表示流量计
cJSON_AddItemToObject (root, "iccid", cJSON_CreateString (SysData.iccid)); // 表示流量计
cJSON_AddItemToObject (root, "ver", cJSON_CreateString (VERSION)); // ±íʾÁ÷Á¿¼Æ
cJSON_AddItemToObject (root, "ver", cJSON_CreateString (GetVersion())); // 表示流量计
cJSON_AddItemToObject (root, "vol", cJSON_CreateNumber (12.3)); // 表示电池电压
cJSON_AddItemToObject (root, "temp", cJSON_CreateNumber (32.5)); // 表示流量计
p = ef_get_env ("net_drv");
cJSON_AddItemToObject (root, "netdrv", cJSON_CreateString (p)); // 表示流量计
p = ef_get_env ("iap_app_filename");
//uint32_t max_open = atoi (p);
cJSON_AddItemToObject (root, "filename", cJSON_CreateString (p)); // 表示电池电压
cJSON_AddItemToObject (root, "chancnt", cJSON_CreateNumber (1)); // ±íʾµç³Øµçѹ
p = ef_get_env ("chancnt");
cJSON_AddItemToObject (root, "chancnt", cJSON_CreateString (p)); // 表示电池电压
//cJSON_AddItemToObject (root, "chancnt", cJSON_CreateNumber (1)); // 表示电池电压
// 瞬时流速
for (int i = 0; i < 6; i++)
@ -63,7 +63,7 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
// 当前水位
for (int i = 0; i < 6; i++)
{
dbl[i] = WaterData[i].thisLevel;
dbl[i] = (double)WaterData[i].thisLevel/100;
}
cJSON * ArrNumLeve = cJSON_CreateDoubleArray (dbl, 6);
cJSON_AddItemToObject (root, "thisLeve", ArrNumLeve);
@ -82,6 +82,22 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
}
cJSON * ArrNumTemp = cJSON_CreateDoubleArray (dbl, 6);
cJSON_AddItemToObject (root, "thistemp", ArrNumTemp);
// 当前测斜方向
for (int i = 0; i < 6; i++)
{
dbl[i] = IncData[i].dir;
}
cJSON * ArrNumIncDir = cJSON_CreateDoubleArray (dbl, 6);
cJSON_AddItemToObject (root, "thisincdir", ArrNumIncDir);
// 当前测斜数据
for (int i = 0; i < 6; i++)
{
dbl[i] = IncData[i].data;
}
cJSON * ArrNumIncData = cJSON_CreateDoubleArray (dbl, 6);
cJSON_AddItemToObject (root, "thisincdata", ArrNumIncData);
//---------------------------------------------以下不准修改
result = cJSON_PrintUnformatted (root);

View File

@ -7,9 +7,13 @@
#include <stdlib.h>
#include "data.h"
#include "os-app.h"
#include "main.h"
char config_list[16][32] = {NULL};
int config_list_size = 0;
// 用于远程出厂设置时保留配置
char backdevice_id[12] = {0};
char backnetdrv[12] = {0};
@ -66,6 +70,7 @@ void JsonUnPacket (int index, char *buff)
UpgradeThreadStart();
break;
case DownReboot :
HAL_NVIC_SystemReset();
break;
case DownConfig: // 设置参数
// 读取参数列表
@ -80,6 +85,9 @@ void JsonUnPacket (int index, char *buff)
ef_set_env (key, value);
}
}
mail.Type = MAIL_COMM_ACK;
mail.index = index + 1; // 0通道用来升级的通道
rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
break;
case DownRead: // 读取参数
list = cJSON_GetObjectItem (root, "list");
@ -94,6 +102,18 @@ void JsonUnPacket (int index, char *buff)
rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
// 读取参数列表
break;
case DownFact:
p = ef_get_env("device_id");
rt_sprintf(backdevice_id,"%s",p);
p = ef_get_env("net_drv") ;
rt_sprintf(backnetdrv,"%s",p);
ef_env_set_default();
ef_set_env("device_id",backdevice_id) ;
ef_set_env("net_drv",backnetdrv) ;
mail.Type = MAIL_COMM_ACK;
mail.index = index + 1; // 0通道用来升级的通道
rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
break;
default:
break;
}

View File

@ -172,6 +172,7 @@ int PacketSluiceUp (int k, char * tx_data)
tx_data[tx_size++] = 0x01;
// // Õ¢ÃÅ¿ª¶È
intk.data = SluiceData[k].gopen * 10;
rt_kprintf("gopen:%d\r\n");
tx_data[tx_size++] = intk.byte[3];
tx_data[tx_size++] = intk.byte[2];
tx_data[tx_size++] = intk.byte[1];

View File

@ -1,54 +1,43 @@
#include "relay-board.h"
#include "main.h"
RelayInfo_t RelayInfo =
void MX_Relay_Push (RelayIndex_t index, RelayState_t ste)
{
{GPIOB, GPIO_PIN_8, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, NULL}, //PB5
{GPIOB, GPIO_PIN_9, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, NULL}, //PB5
};
/********************************************
UartInfoInit
NULL
********************************************/
void RelayInfoInit (void)
{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = RelayInfo.Relay1.mode;
GPIO_InitStruct.Pull = RelayInfo.Relay1.Pull;
GPIO_InitStruct.Speed = RelayInfo.Relay1.Speed;
GPIO_InitStruct.Pin = RelayInfo.Relay1.pin;
HAL_GPIO_Init (RelayInfo.Relay1.GPIOx, &GPIO_InitStruct);
HAL_GPIO_WritePin (RelayInfo.Relay1.GPIOx, RelayInfo.Relay1.pin, GPIO_PIN_RESET);
GPIO_InitStruct.Mode = RelayInfo.Relay2.mode;
GPIO_InitStruct.Pull = RelayInfo.Relay2.Pull;
GPIO_InitStruct.Speed = RelayInfo.Relay2.Speed;
GPIO_InitStruct.Pin = RelayInfo.Relay2.pin;
HAL_GPIO_Init (RelayInfo.Relay2.GPIOx, &GPIO_InitStruct);
HAL_GPIO_WritePin (RelayInfo.Relay2.GPIOx, RelayInfo.Relay2.pin, GPIO_PIN_RESET);
}
void RelayOpenDoor (void)
{
HAL_GPIO_WritePin (RelayInfo.Relay1.GPIOx, RelayInfo.Relay1.pin, GPIO_PIN_SET);
}
void RelayCloseDoor (void)
{
HAL_GPIO_WritePin (RelayInfo.Relay1.GPIOx, RelayInfo.Relay1.pin, GPIO_PIN_RESET);
}
void RelayOpenK2 (void)
{
HAL_GPIO_WritePin (RelayInfo.Relay2.GPIOx, RelayInfo.Relay2.pin, GPIO_PIN_SET);
}
void RelayCloseK2 (void)
{
HAL_GPIO_WritePin (RelayInfo.Relay2.GPIOx, RelayInfo.Relay2.pin, GPIO_PIN_RESET);
if (ste == RELAY_CONN)
{
switch (index)
{
case RELAY1:
HAL_GPIO_WritePin (RELAY1_GPIO_Port, RELAY1_Pin, GPIO_PIN_SET);
break;
case RELAY2:
HAL_GPIO_WritePin (RELAY2_GPIO_Port, RELAY2_Pin, GPIO_PIN_SET);
break;
case RELAYDoor:
HAL_GPIO_WritePin (LOCK_GPIO_Port, LOCK_Pin, GPIO_PIN_SET);
break;
default:
break;
}
}
else
{
switch (index)
{
case RELAY1:
HAL_GPIO_WritePin (RELAY1_GPIO_Port, RELAY1_Pin, GPIO_PIN_RESET);
break;
case RELAY2:
HAL_GPIO_WritePin (RELAY2_GPIO_Port, RELAY2_Pin, GPIO_PIN_RESET);
break;
case RELAYDoor:
HAL_GPIO_WritePin (LOCK_GPIO_Port, LOCK_Pin, GPIO_PIN_RESET);
break;
default:
break;
}
}
}

View File

@ -1,25 +1,23 @@
#ifndef _RELAY_BOARD_H
#define _RELAY_BOARD_H
#include "stm32l0xx_hal.h"
#include "stgpio.h"
typedef struct RelayInfo_t
typedef enum RelayState_t
{
// GpioInfo_t Tx;
// GpioInfo_t Rx;
GpioInfo_t Relay1; // 用于控制485的收发
GpioInfo_t Relay2; // 用于控制485的收发
} RelayInfo_t;
void RelayInfoInit (void);
void RelayOpenDoor (void);
void RelayCloseDoor (void);
void RelayOpenK2 (void);
void RelayCloseK2 (void);
RELAY_CONN = 1,
RELAY_DISC = 0
} RelayState_t;
typedef enum RelayIndex_t
{
RELAY1 = 0,
RELAY2 = 1,
RELAYDoor = 2
} RelayIndex_t;
void MX_Relay_Push (RelayIndex_t index, RelayState_t ste);
#endif

View File

@ -179,6 +179,8 @@ INIT:
break;
case SiteFlow:
case SiteSee:
case SiteLevel:
case SiteSkew:
gMqttDrv.tx_size = Json5MinFlowDataPacket ( (uint8_t *) gMqttDrv.txbuff);
break;
case SiteColl:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,609 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2012-10-27 heyuanjie87 first version.
* 2013-05-17 aozima initial alarm event & mutex in system init.
*/
#include <rtthread.h>
#include <rtdevice.h>
#define RT_RTC_YEARS_MAX 137
#define RT_ALARM_DELAY 2
#define RT_ALARM_STATE_INITED 0x02
#define RT_ALARM_STATE_START 0x01
#define RT_ALARM_STATE_STOP 0x00
#if (defined(RT_USING_RTC) && defined(RT_USING_ALARM))
static struct rt_alarm_container _container;
rt_inline rt_uint32_t alarm_mkdaysec(struct tm *time)
{
rt_uint32_t sec;
sec = time->tm_sec;
sec += time->tm_min * 60;
sec += time->tm_hour * 3600;
return (sec);
}
static rt_err_t alarm_set(struct rt_alarm *alarm)
{
rt_device_t device;
struct rt_rtc_wkalarm wkalarm;
rt_err_t ret;
device = rt_device_find("rtc");
if (device == RT_NULL)
{
return (RT_ERROR);
}
if (alarm->flag & RT_ALARM_STATE_START)
wkalarm.enable = RT_TRUE;
else
wkalarm.enable = RT_FALSE;
wkalarm.tm_sec = alarm->wktime.tm_sec;
wkalarm.tm_min = alarm->wktime.tm_min;
wkalarm.tm_hour = alarm->wktime.tm_hour;
ret = rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_ALARM, &wkalarm);
if ((ret == RT_EOK) && wkalarm.enable)
{
ret = rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_ALARM, &wkalarm);
if (ret == RT_EOK)
{
/*
some RTC device like RX8025,it's alarms precision is 1 minute.
in this case,low level RTC driver should set wkalarm->tm_sec to 0.
*/
alarm->wktime.tm_sec = wkalarm.tm_sec;
alarm->wktime.tm_min = wkalarm.tm_min;
alarm->wktime.tm_hour = wkalarm.tm_hour;
}
}
return (ret);
}
static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
{
rt_uint32_t sec_alarm, sec_now;
rt_bool_t wakeup = RT_FALSE;
time_t timestamp;
sec_alarm = alarm_mkdaysec(&alarm->wktime);
sec_now = alarm_mkdaysec(now);
if (alarm->flag & RT_ALARM_STATE_START)
{
switch (alarm->flag & 0xFF00)
{
case RT_ALARM_ONESHOT:
{
sec_alarm = mktime(&alarm->wktime);
sec_now = mktime(now);
if (((sec_now - sec_alarm) <= RT_ALARM_DELAY) && (sec_now >= sec_alarm))
{
/* stop alarm */
alarm->flag &= ~RT_ALARM_STATE_START;
alarm_set(alarm);
wakeup = RT_TRUE;
}
}
break;
case RT_ALARM_DAILY:
{
if (((sec_now - sec_alarm) <= RT_ALARM_DELAY) && (sec_now >= sec_alarm))
wakeup = RT_TRUE;
}
break;
case RT_ALARM_WEEKLY:
{
/* alarm at wday */
sec_alarm += alarm->wktime.tm_wday * 24 * 3600;
sec_now += now->tm_wday * 24 * 3600;
if (((sec_now - sec_alarm) <= RT_ALARM_DELAY) && (sec_now >= sec_alarm))
wakeup = RT_TRUE;
}
break;
case RT_ALARM_MONTHLY:
{
/* monthly someday generate alarm signals */
if (alarm->wktime.tm_mday == now->tm_mday)
{
if ((sec_now - sec_alarm) <= RT_ALARM_DELAY)
wakeup = RT_TRUE;
}
}
break;
case RT_ALARM_YAERLY:
{
if ((alarm->wktime.tm_mday == now->tm_mday) && \
(alarm->wktime.tm_mon == now->tm_mon))
{
if ((sec_now - sec_alarm) <= RT_ALARM_DELAY)
wakeup = RT_TRUE;
}
}
break;
}
if ((wakeup == RT_TRUE) && (alarm->callback != RT_NULL))
{
timestamp = time(RT_NULL);
alarm->callback(alarm, timestamp);
}
}
}
static void alarm_update(rt_uint32_t event)
{
struct rt_alarm *alm_prev = RT_NULL, *alm_next = RT_NULL;
struct rt_alarm *alarm;
rt_int32_t sec_now, sec_alarm, sec_tmp;
rt_int32_t sec_next = 24 * 3600, sec_prev = 0;
time_t timestamp;
struct tm now;
rt_list_t *next;
rt_mutex_take(&_container.mutex, RT_WAITING_FOREVER);
if (!rt_list_isempty(&_container.head))
{
/* get time of now */
timestamp = time(RT_NULL);
localtime_r(&timestamp, &now);
for (next = _container.head.next; next != &_container.head; next = next->next)
{
alarm = rt_list_entry(next, struct rt_alarm, list);
/* check the overtime alarm */
alarm_wakeup(alarm, &now);
}
timestamp = time(RT_NULL);
localtime_r(&timestamp, &now);
sec_now = alarm_mkdaysec(&now);
for (next = _container.head.next; next != &_container.head; next = next->next)
{
alarm = rt_list_entry(next, struct rt_alarm, list);
/* calculate seconds from 00:00:00 */
sec_alarm = alarm_mkdaysec(&alarm->wktime);
if ((alarm->flag & RT_ALARM_STATE_START) && (alarm != _container.current))
{
sec_tmp = sec_alarm - sec_now;
if (sec_tmp > 0)
{
/* find alarm after now(now to 23:59:59) and the most recent */
if (sec_tmp < sec_next)
{
sec_next = sec_tmp;
alm_next = alarm;
}
}
else
{
/* find alarm before now(00:00:00 to now) and furthest from now */
if (sec_tmp < sec_prev)
{
sec_prev = sec_tmp;
alm_prev = alarm;
}
}
}
}
/* enable the alarm after now first */
if (sec_next < 24 * 3600)
{
if (alarm_set(alm_next) == RT_EOK)
_container.current = alm_next;
}
else if (sec_prev < 0)
{
/* enable the alarm before now */
if (alarm_set(alm_prev) == RT_EOK)
_container.current = alm_prev;
}
}
rt_mutex_release(&_container.mutex);
}
static rt_uint32_t days_of_year_month(int tm_year, int tm_mon)
{
rt_uint32_t ret, year;
year = tm_year + 1900;
if (tm_mon == 1)
{
ret = 28 + ((!(year % 4) && (year % 100)) || !(year % 400));
}
else if (((tm_mon <= 6) && (tm_mon % 2 == 0)) || ((tm_mon > 6) && (tm_mon % 2 == 1)))
{
ret = 31;
}
else
{
ret = 30;
}
return (ret);
}
static rt_bool_t is_valid_date(struct tm *date)
{
if ((date->tm_year < 0) || (date->tm_year > RT_RTC_YEARS_MAX))
{
return (RT_FALSE);
}
if ((date->tm_mon < 0) || (date->tm_mon > 11))
{
return (RT_FALSE);
}
if ((date->tm_mday < 1) || \
(date->tm_mday > days_of_year_month(date->tm_year, date->tm_mon)))
{
return (RT_FALSE);
}
return (RT_TRUE);
}
static rt_err_t alarm_setup(rt_alarm_t alarm, struct tm *wktime)
{
rt_err_t ret = RT_ERROR;
time_t timestamp;
struct tm *setup, now;
setup = &alarm->wktime;
*setup = *wktime;
timestamp = time(RT_NULL);
localtime_r(&timestamp, &now);
/* if these are a "don't care" value,we set them to now*/
if ((setup->tm_sec > 59) || (setup->tm_sec < 0))
setup->tm_sec = now.tm_sec;
if ((setup->tm_min > 59) || (setup->tm_min < 0))
setup->tm_min = now.tm_min;
if ((setup->tm_hour > 23) || (setup->tm_hour < 0))
setup->tm_hour = now.tm_hour;
switch (alarm->flag & 0xFF00)
{
case RT_ALARM_DAILY:
{
/* do nothing but needed */
}
break;
case RT_ALARM_ONESHOT:
{
/* if these are "don't care" value we set them to now */
if (setup->tm_year == RT_ALARM_TM_NOW)
setup->tm_year = now.tm_year;
if (setup->tm_mon == RT_ALARM_TM_NOW)
setup->tm_mon = now.tm_mon;
if (setup->tm_mday == RT_ALARM_TM_NOW)
setup->tm_mday = now.tm_mday;
/* make sure the setup is valid */
if (!is_valid_date(setup))
goto _exit;
}
break;
case RT_ALARM_WEEKLY:
{
/* if tm_wday is a "don't care" value we set it to now */
if ((setup->tm_wday < 0) || (setup->tm_wday > 6))
setup->tm_wday = now.tm_wday;
}
break;
case RT_ALARM_MONTHLY:
{
/* if tm_mday is a "don't care" value we set it to now */
if ((setup->tm_mday < 1) || (setup->tm_mday > 31))
setup->tm_mday = now.tm_mday;
}
break;
case RT_ALARM_YAERLY:
{
/* if tm_mon is a "don't care" value we set it to now */
if ((setup->tm_mon < 0) || (setup->tm_mon > 11))
setup->tm_mon = now.tm_mon;
if (setup->tm_mon == 1)
{
/* tm_mon is February */
/* tm_mday should be 1~29.otherwise,it's a "don't care" value */
if ((setup->tm_mday < 1) || (setup->tm_mday > 29))
setup->tm_mday = now.tm_mday;
}
else if (((setup->tm_mon <= 6) && (setup->tm_mon % 2 == 0)) || \
((setup->tm_mon > 6) && (setup->tm_mon % 2 == 1)))
{
/* Jan,Mar,May,Jul,Aug,Oct,Dec */
/* tm_mday should be 1~31.otherwise,it's a "don't care" value */
if ((setup->tm_mday < 1) || (setup->tm_mday > 31))
setup->tm_mday = now.tm_mday;
}
else
{
/* tm_mday should be 1~30.otherwise,it's a "don't care" value */
if ((setup->tm_mday < 1) || (setup->tm_mday > 30))
setup->tm_mday = now.tm_mday;
}
}
break;
default:
{
goto _exit;
}
}
if ((setup->tm_hour == 23) && (setup->tm_min == 59) && (setup->tm_sec == 59))
{
/*
for insurance purposes, we will generate an alarm
signal two seconds ahead of.
*/
setup->tm_sec = 60 - RT_ALARM_DELAY;
}
/* set initialized state */
alarm->flag |= RT_ALARM_STATE_INITED;
ret = RT_EOK;
_exit:
return (ret);
}
/** \brief send a rtc alarm event
*
* \param dev pointer to RTC device(currently unused,you can ignore it)
* \param event RTC event(currently unused)
* \return none
*/
void rt_alarm_update(rt_device_t dev, rt_uint32_t event)
{
rt_event_send(&_container.event, 1);
}
/** \brief modify the alarm setup
*
* \param alarm pointer to alarm
* \param cmd control command
* \param arg argument
*/
rt_err_t rt_alarm_control(rt_alarm_t alarm, int cmd, void *arg)
{
rt_err_t ret = RT_ERROR;
RT_ASSERT(alarm != RT_NULL);
rt_mutex_take(&_container.mutex, RT_WAITING_FOREVER);
switch (cmd)
{
case RT_ALARM_CTRL_MODIFY:
{
struct rt_alarm_setup *setup;
RT_ASSERT(arg != RT_NULL);
setup = arg;
rt_alarm_stop(alarm);
alarm->flag = setup->flag & 0xFF00;
alarm->wktime = setup->wktime;
ret = alarm_setup(alarm, &alarm->wktime);
}
break;
}
rt_mutex_release(&_container.mutex);
return (ret);
}
/** \brief start an alarm
*
* \param alarm pointer to alarm
* \return RT_EOK
*/
rt_err_t rt_alarm_start(rt_alarm_t alarm)
{
rt_int32_t sec_now, sec_old, sec_new;
rt_err_t ret = RT_ERROR;
time_t timestamp;
struct tm now;
if (alarm == RT_NULL)
return (ret);
rt_mutex_take(&_container.mutex, RT_WAITING_FOREVER);
if (!(alarm->flag & RT_ALARM_STATE_INITED))
{
if (alarm_setup(alarm, &alarm->wktime) != RT_EOK)
goto _exit;
}
if ((alarm->flag & 0x01) == RT_ALARM_STATE_STOP)
{
timestamp = time(RT_NULL);
localtime_r(&timestamp, &now);
alarm->flag |= RT_ALARM_STATE_START;
/* set alarm */
if (_container.current == RT_NULL)
{
ret = alarm_set(alarm);
}
else
{
sec_now = alarm_mkdaysec(&now);
sec_old = alarm_mkdaysec(&_container.current->wktime);
sec_new = alarm_mkdaysec(&alarm->wktime);
if ((sec_new < sec_old) && (sec_new > sec_now))
{
ret = alarm_set(alarm);
}
else if ((sec_new > sec_now) && (sec_old < sec_now))
{
ret = alarm_set(alarm);
}
else if ((sec_new < sec_old) && (sec_old < sec_now))
{
ret = alarm_set(alarm);
}
else
{
ret = RT_EOK;
goto _exit;
}
}
if (ret == RT_EOK)
{
_container.current = alarm;
}
}
_exit:
rt_mutex_release(&_container.mutex);
return (ret);
}
/** \brief stop an alarm
*
* \param alarm pointer to alarm
* \return RT_EOK
*/
rt_err_t rt_alarm_stop(rt_alarm_t alarm)
{
rt_err_t ret = RT_ERROR;
if (alarm == RT_NULL)
return (ret);
rt_mutex_take(&_container.mutex, RT_WAITING_FOREVER);
if (!(alarm->flag & RT_ALARM_STATE_START))
goto _exit;
/* stop alarm */
alarm->flag &= ~RT_ALARM_STATE_START;
if (_container.current == alarm)
{
ret = alarm_set(alarm);
_container.current = RT_NULL;
}
if (ret == RT_EOK)
alarm_update(0);
_exit:
rt_mutex_release(&_container.mutex);
return (ret);
}
/** \brief delete an alarm
*
* \param alarm pointer to alarm
* \return RT_EOK
*/
rt_err_t rt_alarm_delete(rt_alarm_t alarm)
{
rt_err_t ret = RT_ERROR;
if (alarm == RT_NULL)
return (ret);
rt_mutex_take(&_container.mutex, RT_WAITING_FOREVER);
/* stop the alarm */
alarm->flag &= ~RT_ALARM_STATE_START;
if (_container.current == alarm)
{
ret = alarm_set(alarm);
_container.current = RT_NULL;
/* set new alarm if necessary */
alarm_update(0);
}
rt_list_remove(&alarm->list);
rt_free(alarm);
rt_mutex_release(&_container.mutex);
return (ret);
}
/** \brief create an alarm
*
* \param flag set alarm mode e.g: RT_ALARM_DAILY
* \param setup pointer to setup infomation
*/
rt_alarm_t rt_alarm_create(rt_alarm_callback_t callback, struct rt_alarm_setup *setup)
{
struct rt_alarm *alarm;
if (setup == RT_NULL)
return (RT_NULL);
alarm = rt_malloc(sizeof(struct rt_alarm));
if (alarm == RT_NULL)
return (RT_NULL);
rt_list_init(&alarm->list);
alarm->wktime = setup->wktime;
alarm->flag = setup->flag & 0xFF00;
alarm->callback = callback;
rt_mutex_take(&_container.mutex, RT_WAITING_FOREVER);
rt_list_insert_after(&_container.head, &alarm->list);
rt_mutex_release(&_container.mutex);
return (alarm);
}
/** \brief rtc alarm service thread entry
*
*/
static void rt_alarmsvc_thread_init(void *param)
{
rt_uint32_t recv;
_container.current = RT_NULL;
while (1)
{
if (rt_event_recv(&_container.event, 0xFFFF,
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
RT_WAITING_FOREVER, &recv) == RT_EOK)
{
alarm_update(recv);
}
}
}
/** \brief initialize alarm service system
*
* \param none
* \return none
*/
void rt_alarm_system_init(void)
{
rt_thread_t tid;
rt_list_init(&_container.head);
rt_event_init(&_container.event, "alarmsvc", RT_IPC_FLAG_FIFO);
rt_mutex_init(&_container.mutex, "alarmsvc", RT_IPC_FLAG_FIFO);
tid = rt_thread_create("alarmsvc",
rt_alarmsvc_thread_init, RT_NULL,
512, 8, 1);
if (tid != RT_NULL)
rt_thread_startup(tid);
}
#endif

View File

@ -0,0 +1,254 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2012-01-29 aozima first version.
* 2012-04-12 aozima optimization: find rtc device only first.
* 2012-04-16 aozima add scheduler lock for set_date and set_time.
* 2018-02-16 armink add auto sync time by NTP
*/
#include <time.h>
#include <string.h>
#include <rtthread.h>
#ifdef RT_USING_RTC
/* Using NTP auto sync RTC time */
#ifdef RTC_SYNC_USING_NTP
/* NTP first sync delay time for network connect, unit: second */
#ifndef RTC_NTP_FIRST_SYNC_DELAY
#define RTC_NTP_FIRST_SYNC_DELAY (30)
#endif
/* NTP sync period, unit: second */
#ifndef RTC_NTP_SYNC_PERIOD
#define RTC_NTP_SYNC_PERIOD (1L*60L*60L)
#endif
#endif /* RTC_SYNC_USING_NTP */
/**
* Set system date(time not modify).
*
* @param rt_uint32_t year e.g: 2012.
* @param rt_uint32_t month e.g: 12 (1~12).
* @param rt_uint32_t day e.g: 31.
*
* @return rt_err_t if set success, return RT_EOK.
*
*/
rt_err_t set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
{
time_t now;
struct tm *p_tm;
struct tm tm_new;
rt_device_t device;
rt_err_t ret = -RT_ERROR;
/* get current time */
now = time(RT_NULL);
/* lock scheduler. */
rt_enter_critical();
/* converts calendar time time into local time. */
p_tm = localtime(&now);
/* copy the statically located variable */
memcpy(&tm_new, p_tm, sizeof(struct tm));
/* unlock scheduler. */
rt_exit_critical();
/* update date. */
tm_new.tm_year = year - 1900;
tm_new.tm_mon = month - 1; /* tm_mon: 0~11 */
tm_new.tm_mday = day;
/* converts the local time in time to calendar time. */
now = mktime(&tm_new);
device = rt_device_find("rtc");
if (device == RT_NULL)
{
return -RT_ERROR;
}
/* update to RTC device. */
ret = rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now);
return ret;
}
/**
* Set system time(date not modify).
*
* @param rt_uint32_t hour e.g: 0~23.
* @param rt_uint32_t minute e.g: 0~59.
* @param rt_uint32_t second e.g: 0~59.
*
* @return rt_err_t if set success, return RT_EOK.
*
*/
rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
{
time_t now;
struct tm *p_tm;
struct tm tm_new;
rt_device_t device;
rt_err_t ret = -RT_ERROR;
/* get current time */
now = time(RT_NULL);
/* lock scheduler. */
rt_enter_critical();
/* converts calendar time time into local time. */
p_tm = localtime(&now);
/* copy the statically located variable */
memcpy(&tm_new, p_tm, sizeof(struct tm));
/* unlock scheduler. */
rt_exit_critical();
/* update time. */
tm_new.tm_hour = hour;
tm_new.tm_min = minute;
tm_new.tm_sec = second;
/* converts the local time in time to calendar time. */
now = mktime(&tm_new);
device = rt_device_find("rtc");
if (device == RT_NULL)
{
return -RT_ERROR;
}
/* update to RTC device. */
ret = rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now);
return ret;
}
#ifdef RTC_SYNC_USING_NTP
static void ntp_sync_thread_enrty(void *param)
{
extern time_t ntp_sync_to_rtc(const char *host_name);
/* first sync delay for network connect */
rt_thread_delay(RTC_NTP_FIRST_SYNC_DELAY * RT_TICK_PER_SECOND);
while (1)
{
ntp_sync_to_rtc(NULL);
rt_thread_delay(RTC_NTP_SYNC_PERIOD * RT_TICK_PER_SECOND);
}
}
int rt_rtc_ntp_sync_init(void)
{
static rt_bool_t init_ok = RT_FALSE;
rt_thread_t thread;
if (init_ok)
{
return 0;
}
thread = rt_thread_create("ntp_sync", ntp_sync_thread_enrty, RT_NULL, 1536, 26, 2);
if (thread)
{
rt_thread_startup(thread);
}
else
{
return -RT_ENOMEM;
}
init_ok = RT_TRUE;
return RT_EOK;
}
INIT_COMPONENT_EXPORT(rt_rtc_ntp_sync_init);
#endif /* RTC_SYNC_USING_NTP */
#ifdef RT_USING_FINSH
#include <finsh.h>
#include <rtdevice.h>
void list_date(void)
{
time_t now;
now = time(RT_NULL);
rt_kprintf("%s\n", ctime(&now));
}
FINSH_FUNCTION_EXPORT(list_date, show date and time.)
FINSH_FUNCTION_EXPORT(set_date, set date. e.g: set_date(2010,2,28))
FINSH_FUNCTION_EXPORT(set_time, set time. e.g: set_time(23,59,59))
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
static void date(uint8_t argc, char **argv)
{
if (argc == 1)
{
time_t now;
/* output current time */
now = time(RT_NULL);
rt_kprintf("%s", ctime(&now));
}
else if (argc >= 7)
{
/* set time and date */
uint16_t year;
uint8_t month, day, hour, min, sec;
year = atoi(argv[1]);
month = atoi(argv[2]);
day = atoi(argv[3]);
hour = atoi(argv[4]);
min = atoi(argv[5]);
sec = atoi(argv[6]);
if (year > 2099 || year < 2000)
{
rt_kprintf("year is out of range [2000-2099]\n");
return;
}
if (month == 0 || month > 12)
{
rt_kprintf("month is out of range [1-12]\n");
return;
}
if (day == 0 || day > 31)
{
rt_kprintf("day is out of range [1-31]\n");
return;
}
if (hour > 23)
{
rt_kprintf("hour is out of range [0-23]\n");
return;
}
if (min > 59)
{
rt_kprintf("minute is out of range [0-59]\n");
return;
}
if (sec > 59)
{
rt_kprintf("second is out of range [0-59]\n");
return;
}
set_time(hour, min, sec);
set_date(year, month, day);
}
else
{
rt_kprintf("please input: date [year month day hour min sec] or date\n");
rt_kprintf("e.g: date 2018 01 01 23 59 59 or date\n");
}
}
MSH_CMD_EXPORT(date, get date and time or set [year month day hour min sec]);
#endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */
#endif /* RT_USING_FINSH */
#endif /* RT_USING_RTC */

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2012-10-10 aozima first version.
*/
#ifndef __RTC_H__
#define __RTC_H__
rt_err_t set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day);
rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second);
int rt_soft_rtc_init(void);
int rt_rtc_ntp_sync_init(void);
#endif /* __RTC_H__ */

View File

@ -0,0 +1,109 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-01-30 armink the first version
*/
#include <time.h>
#include <string.h>
#include <rtthread.h>
#include <drivers/rtc.h>
#ifdef RT_USING_SOFT_RTC
/* 2018-01-30 14:44:50 = RTC_TIME_INIT(2018, 1, 30, 14, 44, 50) */
#define RTC_TIME_INIT(year, month, day, hour, minute, second) \
{.tm_year = year - 1900, .tm_mon = month - 1, .tm_mday = day, .tm_hour = hour, .tm_min = minute, .tm_sec = second}
#ifndef SOFT_RTC_TIME_DEFAULT
#define SOFT_RTC_TIME_DEFAULT RTC_TIME_INIT(2018, 1, 1, 0, 0 ,0)
#endif
static struct rt_device soft_rtc_dev;
static rt_tick_t init_tick;
static time_t init_time;
static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args)
{
time_t *time;
struct tm time_temp;
RT_ASSERT(dev != RT_NULL);
memset(&time_temp, 0, sizeof(struct tm));
switch (cmd)
{
case RT_DEVICE_CTRL_RTC_GET_TIME:
time = (time_t *) args;
*time = init_time + (rt_tick_get() - init_tick) / RT_TICK_PER_SECOND;
break;
case RT_DEVICE_CTRL_RTC_SET_TIME:
{
time = (time_t *) args;
init_time = *time - (rt_tick_get() - init_tick) / RT_TICK_PER_SECOND;
break;
}
}
return RT_EOK;
}
#ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops soft_rtc_ops =
{
RT_NULL,
RT_NULL,
RT_NULL,
RT_NULL,
RT_NULL,
soft_rtc_control
};
#endif
int rt_soft_rtc_init(void)
{
static rt_bool_t init_ok = RT_FALSE;
struct tm time_new = SOFT_RTC_TIME_DEFAULT;
if (init_ok)
{
return 0;
}
/* make sure only one 'rtc' device */
RT_ASSERT(!rt_device_find("rtc"));
init_tick = rt_tick_get();
init_time = mktime(&time_new);
soft_rtc_dev.type = RT_Device_Class_RTC;
/* register rtc device */
#ifdef RT_USING_DEVICE_OPS
soft_rtc_dev.ops = &soft_rtc_ops;
#else
soft_rtc_dev.init = RT_NULL;
soft_rtc_dev.open = RT_NULL;
soft_rtc_dev.close = RT_NULL;
soft_rtc_dev.read = RT_NULL;
soft_rtc_dev.write = RT_NULL;
soft_rtc_dev.control = soft_rtc_control;
#endif
/* no private */
soft_rtc_dev.user_data = RT_NULL;
rt_device_register(&soft_rtc_dev, "rtc", RT_DEVICE_FLAG_RDWR);
init_ok = RT_TRUE;
return 0;
}
INIT_DEVICE_EXPORT(rt_soft_rtc_init);
#endif /* RT_USING_SOFT_RTC */

@ -1 +1 @@
Subproject commit 38d2e6b239cf12f35cc10a3b03de211c06d34aad
Subproject commit 2c9ad35632dd794514b6f54860f2b2c8d4605cb2

View File

@ -21,6 +21,15 @@ uint32_t Bytes2Int (char * data)
return I.data;
}
int16_t Bytes2Int16 (char * data)
{
Int16Tobyte int16_byte;
int16_byte.byte[0] = data[1];
int16_byte.byte[1] = data[0];
return int16_byte.value;
}
// -----------------------------------------------------------------
// 函数功能: hex字符串转byte数组

View File

@ -15,6 +15,11 @@ typedef union
} Float;
typedef union{
int16_t value;
char byte[2];
}Int16Tobyte;
float Bytes2Float (char * data);
uint32_t Bytes2Int (char * data);
int hexstr_to_hexbyte (char *src, char *obj, uint16_t length);
@ -23,6 +28,8 @@ uint32_t byte_to_Inverse(char * data);
// 754 תfloat
float float_to_iee754 (float ff1,char * data);
int16_t Bytes2Int16 (char * data);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,88 @@
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef cJSON_Utils__h
#define cJSON_Utils__h
#ifdef __cplusplus
extern "C"
{
#endif
#include "cJSON.h"
/* Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec. */
CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointer(cJSON * const object, const char *pointer);
CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointerCaseSensitive(cJSON * const object, const char *pointer);
/* Implement RFC6902 (https://tools.ietf.org/html/rfc6902) JSON Patch spec. */
/* NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key */
CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatches(cJSON * const from, cJSON * const to);
CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatchesCaseSensitive(cJSON * const from, cJSON * const to);
/* Utility for generating patch array entries. */
CJSON_PUBLIC(void) cJSONUtils_AddPatchToArray(cJSON * const array, const char * const operation, const char * const path, const cJSON * const value);
/* Returns 0 for success. */
CJSON_PUBLIC(int) cJSONUtils_ApplyPatches(cJSON * const object, const cJSON * const patches);
CJSON_PUBLIC(int) cJSONUtils_ApplyPatchesCaseSensitive(cJSON * const object, const cJSON * const patches);
/*
// Note that ApplyPatches is NOT atomic on failure. To implement an atomic ApplyPatches, use:
//int cJSONUtils_AtomicApplyPatches(cJSON **object, cJSON *patches)
//{
// cJSON *modme = cJSON_Duplicate(*object, 1);
// int error = cJSONUtils_ApplyPatches(modme, patches);
// if (!error)
// {
// cJSON_Delete(*object);
// *object = modme;
// }
// else
// {
// cJSON_Delete(modme);
// }
//
// return error;
//}
// Code not added to library since this strategy is a LOT slower.
*/
/* Implement RFC7386 (https://tools.ietf.org/html/rfc7396) JSON Merge Patch spec. */
/* target will be modified by patch. return value is new ptr for target. */
CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatch(cJSON *target, const cJSON * const patch);
CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatchCaseSensitive(cJSON *target, const cJSON * const patch);
/* generates a patch to move from -> to */
/* NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key */
CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatch(cJSON * const from, cJSON * const to);
CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatchCaseSensitive(cJSON * const from, cJSON * const to);
/* Given a root object and a target object, construct a pointer from one to the other. */
CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON * const object, const cJSON * const target);
/* Sorts the members of the object into alphabetical order. */
CJSON_PUBLIC(void) cJSONUtils_SortObject(cJSON * const object);
CJSON_PUBLIC(void) cJSONUtils_SortObjectCaseSensitive(cJSON * const object);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -34,12 +34,12 @@
#ifdef EF_USING_ENV
/* Auto update ENV to latest default when current ENV version number is changed. */
/* #define EF_ENV_AUTO_UPDATE */
#define EF_ENV_AUTO_UPDATE
/**
* ENV version number defined by user.
* Please change it when your firmware add a new ENV to default_env_set.
*/
#define EF_ENV_VER_NUM 0 /* @note you must define it for a value, such as 0 */
#define EF_ENV_VER_NUM 3 /* @note you must define it for a value, such as 0 */
/* MCU Endian Configuration, default is Little Endian Order. */
/* #define EF_BIG_ENDIAN */

View File

@ -43,7 +43,7 @@ static const ef_env default_env_set[] = {
{"boot_times", "0"},
{"jump_boot_time", "10"}, // BOOT 等待时间 10s
// 基础参数设置
{"device_id", "0000000003"},
{"device_id", "7322070012"},
{"app_id", "220000"}, // 业务ID
{"user_pass", "123456"},
{"sys_pass", "898909"},
@ -51,7 +51,7 @@ static const ef_env default_env_set[] = {
{"mqtt_pass", "admin"},
{"mqtt_addr", "mqtt.zyjzjs.cn"},
{"mqtt_port", "1883"},
{"mqtt_topic", "sluice"}, //订阅topic
{"mqtt_topic", "syksk"}, //订阅topic
{"net_drv", "dtu"}, // mqtt dtu ec200 eth
{"eth2_chann", "0"}, //以太网通道2 支持modbus
@ -82,9 +82,9 @@ static const ef_env default_env_set[] = {
{"pwm4", "0"}, // PWM4功能
// 闸门参数设置
{"max_open", "1400"}, // 最大开度
{"max_ecode", "31241"}, // 编码器最大编码
{"min_ecode", "32828"}, // 编码器最小编码
{"max_open", "1600"}, // 最大开度
{"max_ecode", "25712"}, // 编码器最大编码
{"min_ecode", "31770"}, // 编码器最小编码
{"exec_time", "50"}, // 异常检测时间 单位100ms 50 就是 5s
// 闸门参数设置
@ -98,7 +98,11 @@ static const ef_env default_env_set[] = {
{"site_type", "sluice"}, // 0,闸门站1流量站2渗流渗压站3自动化采集站4串口服务器
{"level","[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]"},
{"flow", "[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]"},
{"wsid","[128,2,3,4,5,6]"},
{"wsid","[1,2,3,4,5,6]"},
{"sl427ip","116.176.77.72"},
{"sl427port","6200"},
{"sl427code","0000000002"},
// 水位流量关系表 配置10 个点