|
@@ -21,7 +21,7 @@
|
|
|
#include "SPIFFS.h"
|
|
|
// #include "user_config.h"
|
|
|
|
|
|
-Screen_dis_t screen_dis_info;
|
|
|
+RTC_NOINIT_ATTR Screen_dis_t screen_dis_info;
|
|
|
// 声明一个TimerHandle_t类型的变量,用于存储定时器句柄
|
|
|
|
|
|
extern EventGroupHandle_t screen_event;
|
|
@@ -160,6 +160,7 @@ void f_send_status_duration(void);
|
|
|
|
|
|
void set_screen_dis_info_and_send_queue(bool is_into_sleep, bool is_left, bool is_change_power, bool is_dont_dis, int ms)
|
|
|
{
|
|
|
+ ESP_LOGE(LOG_TAG, "%d %d %d %d %d ",is_into_sleep,is_left,is_change_power,is_dont_dis,ms);
|
|
|
screen_dis_info.is_into_sleep = is_into_sleep;
|
|
|
screen_dis_info.is_left = is_left;
|
|
|
screen_dis_info.is_change_power = is_change_power;
|
|
@@ -226,7 +227,7 @@ void screen_display(void)
|
|
|
if (bits == 3)
|
|
|
{
|
|
|
// xQueueReset(screen_queue);
|
|
|
- Machine_info.left_current_Quick_refresh_time = 5; // 刷两个屏最好为慢刷
|
|
|
+ Machine_info.left_current_Quick_refresh_time = 4; // 刷两个屏最好不同时慢刷
|
|
|
set_screen_dis_info_and_send_queue(false, true, false, false, 100);
|
|
|
set_screen_dis_info_and_send_queue(true, false, false, false, 100);
|
|
|
}
|
|
@@ -414,8 +415,8 @@ static int terminal_number_func(const LORA_DATA_T *buf)
|
|
|
// printf("%02x ",Machine_info.terminal_number[i]);
|
|
|
// }
|
|
|
|
|
|
- printf("setting num %s", Machine_info.terminal_number);
|
|
|
- printf("\n");
|
|
|
+ // printf("setting num %s", Machine_info.terminal_number);
|
|
|
+ // printf("\n");
|
|
|
|
|
|
// display_flag = RIGHT_FLAG;
|
|
|
xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
|
|
@@ -617,7 +618,7 @@ static int production_punch_func(const LORA_DATA_T *buf)
|
|
|
Machine_info.checkIn_set[terminal_info.production_punch[0]].checkIn_close = false; // 开启该类型打卡
|
|
|
}
|
|
|
|
|
|
- ESP_LOGW(LOG_TAG, "打卡设置: 类型[%d] %s", terminal_info.production_punch[0], terminal_info.production_punch[1] ? "开启" : "关闭");
|
|
|
+ ESP_LOGD(LOG_TAG, "打卡设置: 类型[%d] %s", terminal_info.production_punch[0], terminal_info.production_punch[1] ? "开启" : "关闭");
|
|
|
|
|
|
if (len > 2) // 数据长度大于2 ,说明设置了别名
|
|
|
{
|
|
@@ -647,7 +648,7 @@ static int personnel_check_in_func(const LORA_DATA_T *buf)
|
|
|
xEventGroupSetBits(screen_event, LEFT_SCREEN_BIT);
|
|
|
ESP_LOG_BUFFER_HEX(LOG_TAG, terminal_info.personnel_check_in, len);
|
|
|
int ID_crc = crc8(&terminal_info.personnel_check_in[2], len - 2, 0x5a, 0x51); // lora_crc8( , ,0x5a,0x51);暂定对人员id求crc
|
|
|
- ESP_LOGW(LOG_TAG, "打卡类型[%d] %s ,ID_crc = %d", terminal_info.personnel_check_in[0], Machine_info.checkIn_set[terminal_info.personnel_check_in[0]].checkIn_close ? "关闭" : "开启", ID_crc);
|
|
|
+ ESP_LOGD(LOG_TAG, "打卡类型[%d] %s ,ID_crc = %d", terminal_info.personnel_check_in[0], Machine_info.checkIn_set[terminal_info.personnel_check_in[0]].checkIn_close ? "关闭" : "开启", ID_crc);
|
|
|
if (!(Machine_info.checkIn_set[terminal_info.personnel_check_in[0]].checkIn_close)) // 开启打卡
|
|
|
{
|
|
|
if (terminal_info.personnel_check_in[1] == 0x00) // 打卡签入
|
|
@@ -1118,7 +1119,7 @@ int reply_ack_func(int cmd, int msg_id, bool is_send, uint8_t *result)
|
|
|
|
|
|
if (is_send)
|
|
|
{
|
|
|
-
|
|
|
+ ESP_LOG_BUFFER_HEX("send ack to gateway", strlorabuf, 15);
|
|
|
lora_send_data((char *)strlorabuf, 15);
|
|
|
uart_wait_tx_idle_polling(UART_NUM_1);
|
|
|
}
|
|
@@ -1352,10 +1353,12 @@ static void hardware_gwpair_func(const LORA_DATA_T *buf)
|
|
|
f_send_get_chart_data();
|
|
|
#endif
|
|
|
|
|
|
-#if USER_LIGHT_SLEEP_ENABLE || USER_DEEP_SLEEP_ENABLE
|
|
|
- set_screen_dis_info_and_send_queue(false, true, false, true, 100);
|
|
|
-#endif
|
|
|
-
|
|
|
+ // xQueueReset(screen_queue);
|
|
|
+ // 重置快刷
|
|
|
+ Machine_info.left_current_Quick_refresh_time = 0;
|
|
|
+ Machine_info.right_current_Quick_refresh_time = 0;
|
|
|
+ set_screen_dis_info_and_send_queue(false, true, false, false, 100);
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false, 100);
|
|
|
// printf("start timer id = %d,%d\r\n",Machine_info.eflagID,Machine_info.eflagID * TIMER_CAN_SEND_TIME);
|
|
|
// Already_send_timer_start(Machine_info.eflagID * TIMER_CAN_SEND_TIME);
|
|
|
}
|
|
@@ -1468,7 +1471,7 @@ static void hardware_ack_delete_msg_id(const LORA_DATA_T *buf)
|
|
|
|
|
|
if (find != NULL)
|
|
|
{
|
|
|
- ESP_LOGE(LOG_TAG, "find %d", msg_id);
|
|
|
+ ESP_LOGE(LOG_TAG, "find msg_id : %d", msg_id);
|
|
|
// printList(Send_list);
|
|
|
|
|
|
for (int i = 0; i < LORA_INFO_END; i++)
|
|
@@ -1619,12 +1622,7 @@ void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
|
|
|
hardware_gwpair_func(buf);
|
|
|
// Paint_leftScreen_main_quick(&Machine_info);
|
|
|
// Paint_rightScreen_main_quick(&Machine_info);
|
|
|
- // xQueueReset(screen_queue);
|
|
|
- // 重置快刷
|
|
|
- Machine_info.left_current_Quick_refresh_time = 0;
|
|
|
- Machine_info.right_current_Quick_refresh_time = 0;
|
|
|
- set_screen_dis_info_and_send_queue(false, true, false, false, 100);
|
|
|
- set_screen_dis_info_and_send_queue(false, false, false, false, 100);
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case PROTOCOL_HARDWARE_UNGWPAIRED: // 取消配网
|
|
@@ -1958,7 +1956,6 @@ bool subcontract(YC_DATA_T *data)
|
|
|
USE_DATA_T use_data;
|
|
|
|
|
|
bool refresh_flag = false;
|
|
|
-#if 1
|
|
|
|
|
|
u8 targetSequence[] = {0x5A, 0x51};
|
|
|
int sequenceSize = sizeof(targetSequence);
|
|
@@ -1966,13 +1963,6 @@ bool subcontract(YC_DATA_T *data)
|
|
|
int *positions = NULL;
|
|
|
int result = findByteSequence(buf, all_len, targetSequence, sequenceSize, &positions);
|
|
|
|
|
|
- if (result > 1)
|
|
|
- {
|
|
|
- int data_len = 0;
|
|
|
- data_len = (buf[0] << 8) | (buf[1]);
|
|
|
- printf("cmd 5A 51 find times %d,all data len = %d\r\n", result, data_len);
|
|
|
- }
|
|
|
-
|
|
|
if (result == 1)
|
|
|
{
|
|
|
printf("cmd 5A 51 find times %d,data len = %d\r\n", result, data->len);
|
|
@@ -2016,33 +2006,32 @@ bool subcontract(YC_DATA_T *data)
|
|
|
// 多条指令处理逻辑
|
|
|
|
|
|
bool is = mac_is_true(&buf[positions[index] + 3]);
|
|
|
- if (is)
|
|
|
+ if (is) // 验证为本机,处理数据 回复ack
|
|
|
{
|
|
|
use_data.data_len = (((buf[positions[index] - 2]) << 8) | ((buf[positions[index] - 1]))) + 2;
|
|
|
memcpy(use_data.data_buf, data->data + (positions[index] - 2), use_data.data_len);
|
|
|
// print_yc_data(&use_data);
|
|
|
business_logic_func(&use_data, USE_CMD_LEN_INDEX, rsp_msgid);
|
|
|
refresh_flag = true;
|
|
|
+
|
|
|
+ reply_ack_func(0x00, rsp_msgid, true, NULL); // 回复ack
|
|
|
+ spiffs_write(&Machine_info);
|
|
|
+ ESP_LOGE(LOG_TAG, "1times cmd = %02X msg = %X start reply ack\r\n", 0x00, rsp_msgid);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("mac is fail not deal\r\n");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // if(is_rsp_ack)
|
|
|
- {
|
|
|
- reply_ack_func(0x00, rsp_msgid, true, NULL); // 回复ack
|
|
|
- spiffs_write(&Machine_info);
|
|
|
- ESP_LOGE(LOG_TAG, "1times cmd = %02X msg = %X start reply ack\r\n", 0x00, rsp_msgid);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (result > 1)
|
|
|
{
|
|
|
-
|
|
|
+ int data_len = 0;
|
|
|
+ data_len = (buf[0] << 8) | (buf[1]);
|
|
|
+ printf("cmd 5A 51 find times %d,all data len = %d\r\n", result, data_len);
|
|
|
printf("not single cmd len =%d\r\n", use_data.data_len);
|
|
|
|
|
|
rsp_msgid = (buf[13] << 8) | buf[14]; // 获取当前消息id 用于删除;
|
|
@@ -2072,97 +2061,18 @@ bool subcontract(YC_DATA_T *data)
|
|
|
// print_yc_data(&use_data);
|
|
|
business_logic_func(&use_data, USE_CMD_LEN_INDEX, rsp_msgid);
|
|
|
refresh_flag = true;
|
|
|
+
|
|
|
+ reply_ack_func(0x00, rsp_msgid, true, NULL); // 回复ack
|
|
|
+ spiffs_write(&Machine_info);
|
|
|
+ ESP_LOGE(LOG_TAG, "cmd = %02X msg = %X start reply ack\r\n", 0x00, rsp_msgid);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("mac is fail not deal\r\n");
|
|
|
}
|
|
|
}
|
|
|
- // if(is_rsp_ack)
|
|
|
- {
|
|
|
- reply_ack_func(0x00, rsp_msgid, true, NULL); // 回复ack
|
|
|
- spiffs_write(&Machine_info);
|
|
|
- ESP_LOGE(LOG_TAG, "cmd = %02X msg = %X start reply ack\r\n", 0x00, rsp_msgid);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-#if 0
|
|
|
- u8 targetSequence1[] = {0x55, 0x51};
|
|
|
- int sequenceSize1 = sizeof(targetSequence);
|
|
|
-
|
|
|
- int* positions1 = NULL;
|
|
|
- result = findByteSequence(buf, all_len, targetSequence1, sequenceSize1, &positions1);
|
|
|
-
|
|
|
- if(result!=0)
|
|
|
- {
|
|
|
- printf("ack 55 51 find time %d\r\n", result);
|
|
|
}
|
|
|
-
|
|
|
- for(int index = 0;index<result;index++)
|
|
|
- {
|
|
|
- //use_data.data_len =(((buf[positions[index] - 2])<<8) | ((buf[positions[index] - 1])))+2;
|
|
|
- //memcpy(use_data.data_buf,data->data + (positions[index] -2) ,use_data.data_len);
|
|
|
- //print_yc_data(&use_data);
|
|
|
- use_data.data_len = all_len;
|
|
|
- memcpy(use_data.data_buf,data->data + (positions1[index]) ,use_data.data_len);
|
|
|
- business_ack_func(&use_data);
|
|
|
- //refresh_flag =true;
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
- // #if 1
|
|
|
-
|
|
|
- // for (int i = 0; i < all_len; i++)
|
|
|
- // {
|
|
|
- // printf("%02x",buf[i]);
|
|
|
- // }
|
|
|
-
|
|
|
- // #endif
|
|
|
-
|
|
|
free(positions);
|
|
|
-
|
|
|
-// free(positions1);
|
|
|
-#if 0
|
|
|
- printf("index:");
|
|
|
- if (result > 0) {
|
|
|
- //printf("出现的位置索引:");
|
|
|
- for (int i = 0; i < result; i++) {
|
|
|
- printf("%d,", positions[i]);
|
|
|
- }
|
|
|
- printf("\n");
|
|
|
-
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
-#else
|
|
|
- while (all_len > 0)
|
|
|
- {
|
|
|
- // ESP_LOGW(LOG_TAG,"-->[%d]",all_len);
|
|
|
- // for(int i=0;i<all_len;i++)
|
|
|
- // {
|
|
|
- // printf("%02x ",data->data[i]);
|
|
|
- // }
|
|
|
- // printf("\n");
|
|
|
- if (((buf[index + 2]) == 0x5A) && ((buf[index + 3]) == 0x51))
|
|
|
- {
|
|
|
- use_data.data_len = (((buf[index]) << 8) | ((buf[index + 1]))) + 2;
|
|
|
- memcpy(use_data.data_buf, data->data + index, use_data.data_len);
|
|
|
- all_len -= (use_data.data_len);
|
|
|
- index += (use_data.data_len);
|
|
|
- // print_yc_data(&use_data);
|
|
|
- business_logic_func(&use_data);
|
|
|
- refresh_flag = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- all_len--;
|
|
|
- index++;
|
|
|
- // ESP_LOGE(LOG_TAG,"err:data");
|
|
|
- // break;
|
|
|
- }
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
return refresh_flag;
|
|
|
}
|
|
|
|
|
@@ -2841,7 +2751,7 @@ void f_send_status_duration(void)
|
|
|
for (i = 3; i < 27; i++)
|
|
|
crc16 = crc16 + strlorabuf[i];
|
|
|
strlorabuf[2] = crc16 & 0xff;
|
|
|
- // ESP_LOGE(LOG_TAG,"{cmd:0e}send_status_duration btn -->[%d] -->Duration_time = %ld -->time :%d %d %d %d %d %d %d",strlorabuf[15],Machine_info.Duration_time,strlorabuf[16],strlorabuf[17],strlorabuf[18],strlorabuf[19],strlorabuf[20],strlorabuf[21],strlorabuf[22]);
|
|
|
+ ESP_LOGE(LOG_TAG,"{cmd:0e}send_status_duration btn -->[%d] -->Duration_time = %ld -->time :%d %d %d %d %d %d %d",strlorabuf[15],Machine_info.Duration_time,strlorabuf[16],strlorabuf[17],strlorabuf[18],strlorabuf[19],strlorabuf[20],strlorabuf[21],strlorabuf[22]);
|
|
|
|
|
|
changebintotxt(strlorabuf, 27);
|
|
|
|
|
@@ -2873,30 +2783,6 @@ void f_send_update_status(void)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
-#if 0
|
|
|
- uint8_t* update = (uint8_t*)malloc(sizeof(uint8_t)*(12));
|
|
|
- memset(&new_button_info,0,sizeof(Button_Time_t));
|
|
|
- new_button_info.Year = Machine_info.year;
|
|
|
- new_button_info.Month = Machine_info.month;
|
|
|
- new_button_info.Day = Machine_info.day;
|
|
|
- new_button_info.Hour = Machine_info.hour;
|
|
|
- new_button_info.Minute = Machine_info.min;
|
|
|
- new_button_info.Second = Machine_info.sec;
|
|
|
- new_button_info.time_min = 0;
|
|
|
-
|
|
|
-
|
|
|
- memcpy(update,&last_button_info.button_info,1);
|
|
|
- memcpy(update+1,&new_button_info.Year,2);
|
|
|
- memcpy(update+3,&new_button_info.Month,1);
|
|
|
- memcpy(update+4,&new_button_info.Day,1);
|
|
|
- memcpy(update+5,&new_button_info.Hour,1);
|
|
|
- memcpy(update+6,&new_button_info.Minute,1);
|
|
|
- memcpy(update+7,&new_button_info.Second,1);
|
|
|
- memcpy(update+8,&new_button_info.time_min,4);
|
|
|
-
|
|
|
- protocol_package(0x0F,update,12);
|
|
|
- free(update);
|
|
|
-#else
|
|
|
|
|
|
// memset(&Machine_info.current_button,0,sizeof(Button_Time_t));
|
|
|
|
|
@@ -2969,7 +2855,7 @@ void f_send_update_status(void)
|
|
|
strlorabuf[25] = (Machine_info.current_button.time_min >> 8) & 0xff;
|
|
|
strlorabuf[26] = Machine_info.current_button.time_min & 0xff;
|
|
|
strlorabuf[27] = 0;
|
|
|
- // ESP_LOGE(LOG_TAG,"@@send_update_status -->btn = [%d] -->time :%d %d %d %d %d %d %d",strlorabuf[15],strlorabuf[16],strlorabuf[17],strlorabuf[18],strlorabuf[19],strlorabuf[20],strlorabuf[21],strlorabuf[22]);
|
|
|
+ ESP_LOGE(LOG_TAG,"@@send_update_status -->btn = [%d] -->time :%d %d %d %d %d %d %d",strlorabuf[15],strlorabuf[16],strlorabuf[17],strlorabuf[18],strlorabuf[19],strlorabuf[20],strlorabuf[21],strlorabuf[22]);
|
|
|
|
|
|
crc16 = strlorabuf[0] + strlorabuf[1];
|
|
|
for (i = 3; i < 27; i++)
|
|
@@ -2993,8 +2879,6 @@ void f_send_update_status(void)
|
|
|
#endif
|
|
|
|
|
|
Machine_info.last_button.time_min = 0;
|
|
|
-
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
// void send_ACK(char cmd, bool flag)
|