|
@@ -423,7 +423,7 @@ void setSystemTime(struct tm *timeinfo) {
|
|
|
// 函数定义:判断数组中是否有大于 100 的元素
|
|
// 函数定义:判断数组中是否有大于 100 的元素
|
|
|
int hasElementGreaterThan400(uint16_t arr[], int size) {
|
|
int hasElementGreaterThan400(uint16_t arr[], int size) {
|
|
|
for (int i = 0; i < size; i++) {
|
|
for (int i = 0; i < size; i++) {
|
|
|
- if (arr[i] < 400) {
|
|
|
|
|
|
|
+ if (arr[i] < LAMP_CURRENT) {
|
|
|
return 1; // 找到大于 100 的元素,返回 1
|
|
return 1; // 找到大于 100 的元素,返回 1
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -432,7 +432,7 @@ int hasElementGreaterThan400(uint16_t arr[], int size) {
|
|
|
|
|
|
|
|
int hasElementGreater_lessThan400(uint16_t arr[], int size) {
|
|
int hasElementGreater_lessThan400(uint16_t arr[], int size) {
|
|
|
for (int i = 0; i < size; i++) {
|
|
for (int i = 0; i < size; i++) {
|
|
|
- if (arr[i] > 400) {
|
|
|
|
|
|
|
+ if (arr[i] > LAMP_CURRENT) {
|
|
|
return 1; // 找到大于 100 的元素,返回 1
|
|
return 1; // 找到大于 100 的元素,返回 1
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -515,14 +515,14 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
record_current = 0;
|
|
record_current = 0;
|
|
|
if(hasElementGreaterThan400(current_arry, 10)==0) //连续10条电流值大于400,灯管状态正常
|
|
if(hasElementGreaterThan400(current_arry, 10)==0) //连续10条电流值大于400,灯管状态正常
|
|
|
{
|
|
{
|
|
|
- device_status.lamp_status = 0;
|
|
|
|
|
|
|
+ device_status.lamp = 0;
|
|
|
lamp_sta_cnt = 0;
|
|
lamp_sta_cnt = 0;
|
|
|
}
|
|
}
|
|
|
if(hasElementGreater_lessThan400(current_arry,10)==0) //连续10条电流值小于400,灯管状态异常
|
|
if(hasElementGreater_lessThan400(current_arry,10)==0) //连续10条电流值小于400,灯管状态异常
|
|
|
{
|
|
{
|
|
|
lamp_sta_cnt++;
|
|
lamp_sta_cnt++;
|
|
|
}
|
|
}
|
|
|
- if(lamp_sta_cnt>=3) device_status.lamp_status = 1;
|
|
|
|
|
|
|
+ if(lamp_sta_cnt>=3) device_status.lamp = 1;
|
|
|
memset(current_arry,0,sizeof(current_arry));
|
|
memset(current_arry,0,sizeof(current_arry));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -970,7 +970,7 @@ char * makeJson()
|
|
|
rt_sprintf(device_status.gps, "0");
|
|
rt_sprintf(device_status.gps, "0");
|
|
|
|
|
|
|
|
if(device_status.work_status==0) {
|
|
if(device_status.work_status==0) {
|
|
|
- device_status.lamp_status = 0;
|
|
|
|
|
|
|
+ device_status.lamp = 0;
|
|
|
}
|
|
}
|
|
|
if(atoi(device_status.power)>5000)
|
|
if(atoi(device_status.power)>5000)
|
|
|
rt_sprintf(device_status.power,"0.01");
|
|
rt_sprintf(device_status.power,"0.01");
|
|
@@ -1112,7 +1112,7 @@ char * makeJson()
|
|
|
rt_sprintf(utos, "%d",device_status.bat_status);
|
|
rt_sprintf(utos, "%d",device_status.bat_status);
|
|
|
cJSON_AddStringToObject(pSubJson,"batStatus",utos);
|
|
cJSON_AddStringToObject(pSubJson,"batStatus",utos);
|
|
|
//灯管状态
|
|
//灯管状态
|
|
|
- rt_sprintf(utos, "%d",device_status.lamp_status);
|
|
|
|
|
|
|
+ rt_sprintf(utos, "%d",device_status.lamp);
|
|
|
cJSON_AddStringToObject(pSubJson,"lamp",utos);
|
|
cJSON_AddStringToObject(pSubJson,"lamp",utos);
|
|
|
//上仓门状态 1-打开,0-关闭-(通道) 打开为落虫,关闭为排水
|
|
//上仓门状态 1-打开,0-关闭-(通道) 打开为落虫,关闭为排水
|
|
|
rt_sprintf(utos, "%d",device_status.up_status);
|
|
rt_sprintf(utos, "%d",device_status.up_status);
|
|
@@ -1531,7 +1531,7 @@ int parseDtu(char *json_string)
|
|
|
{
|
|
{
|
|
|
if(strstr(item_cmd->valuestring,"takephoto")!=RT_NULL)
|
|
if(strstr(item_cmd->valuestring,"takephoto")!=RT_NULL)
|
|
|
{
|
|
{
|
|
|
- #if 0
|
|
|
|
|
|
|
+ #if MATCH_DEVICE == 1
|
|
|
ctr_led(ON);
|
|
ctr_led(ON);
|
|
|
//发送拍照指令
|
|
//发送拍照指令
|
|
|
char *takephotojson = makeJson_takephoto();
|
|
char *takephotojson = makeJson_takephoto();
|
|
@@ -1642,7 +1642,6 @@ int parseDtu(char *json_string)
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
device_status.selfcheck_ws = 2;
|
|
device_status.selfcheck_ws = 2;
|
|
|
}
|
|
}
|
|
|
LOG_I("收到自检指令:%d",device_status.selfcheck_ws);
|
|
LOG_I("收到自检指令:%d",device_status.selfcheck_ws);
|