|
@@ -103,8 +103,8 @@ void reset_default(bool is_dis, uint8_t power_status)
|
|
}
|
|
}
|
|
|
|
|
|
// xQueueReset(screen_queue);
|
|
// xQueueReset(screen_queue);
|
|
- set_screen_dis_info_and_send_queue(false, true, false, false,100);
|
|
|
|
- set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
|
|
|
+ set_screen_dis_info_and_send_queue(false, true, false, false, 100);
|
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false, 100);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -155,11 +155,10 @@ void print_systenInfo(void)
|
|
printf("\r\n%s\r\n", InfoBuffer);
|
|
printf("\r\n%s\r\n", InfoBuffer);
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
-void send_update_status(void);
|
|
|
|
-void send_status_duration(void);
|
|
|
|
|
|
+void f_send_update_status(void);
|
|
|
|
+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)
|
|
|
|
|
|
+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)
|
|
{
|
|
{
|
|
screen_dis_info.is_into_sleep = is_into_sleep;
|
|
screen_dis_info.is_into_sleep = is_into_sleep;
|
|
screen_dis_info.is_left = is_left;
|
|
screen_dis_info.is_left = is_left;
|
|
@@ -175,9 +174,9 @@ void terminal_send_data(void)
|
|
{
|
|
{
|
|
// send_rssi();
|
|
// send_rssi();
|
|
// vTaskDelay(100 / portTICK_PERIOD_MS);
|
|
// vTaskDelay(100 / portTICK_PERIOD_MS);
|
|
- send_status_duration();
|
|
|
|
|
|
+ f_send_status_duration();
|
|
// vTaskDelay(50 / portTICK_PERIOD_MS);
|
|
// vTaskDelay(50 / portTICK_PERIOD_MS);
|
|
- send_update_status();
|
|
|
|
|
|
+ f_send_update_status();
|
|
// vTaskDelay(100 / portTICK_PERIOD_MS);
|
|
// vTaskDelay(100 / portTICK_PERIOD_MS);
|
|
}
|
|
}
|
|
void update_last_button_info(uint8_t btn)
|
|
void update_last_button_info(uint8_t btn)
|
|
@@ -226,20 +225,20 @@ void screen_display(void)
|
|
* happened. */
|
|
* happened. */
|
|
if (bits == 3)
|
|
if (bits == 3)
|
|
{
|
|
{
|
|
- // xQueueReset(screen_queue);
|
|
|
|
- set_screen_dis_info_and_send_queue(false, true, false, false,100);
|
|
|
|
- set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
|
|
|
+ // xQueueReset(screen_queue);
|
|
|
|
+ Machine_info.left_current_Quick_refresh_time = 5; // 刷两个屏最好为慢刷
|
|
|
|
+ set_screen_dis_info_and_send_queue(false, true, false, false, 100);
|
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false, 100);
|
|
}
|
|
}
|
|
else if (bits & RIGHT_SCREEN_BIT)
|
|
else if (bits & RIGHT_SCREEN_BIT)
|
|
{
|
|
{
|
|
ESP_LOGE(LOG_TAG, "RIGHT_SCREEN_BIT");
|
|
ESP_LOGE(LOG_TAG, "RIGHT_SCREEN_BIT");
|
|
-
|
|
|
|
- set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false, 100);
|
|
}
|
|
}
|
|
else if (bits & LEFT_SCREEN_BIT)
|
|
else if (bits & LEFT_SCREEN_BIT)
|
|
{
|
|
{
|
|
ESP_LOGE(LOG_TAG, "LEFT_SCREEN_BIT");
|
|
ESP_LOGE(LOG_TAG, "LEFT_SCREEN_BIT");
|
|
- set_screen_dis_info_and_send_queue(true, true, false, false,100);
|
|
|
|
|
|
+ set_screen_dis_info_and_send_queue(true, true, false, false, 100);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -337,7 +336,7 @@ static int time_synchronization_func(const LORA_DATA_T *buf)
|
|
|
|
|
|
getRtcTime(&Machine_info);
|
|
getRtcTime(&Machine_info);
|
|
|
|
|
|
- xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
|
|
|
|
|
|
+ // xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
|
|
// printf("msg h = %02X,msg l = %02X\r\n",buf->data_buf[13],buf->data_buf[14]);
|
|
// printf("msg h = %02X,msg l = %02X\r\n",buf->data_buf[13],buf->data_buf[14]);
|
|
int msg_id = (buf->data_buf[13] >> 8) | buf->data_buf[14]; // 获取当前消息id 用于删除
|
|
int msg_id = (buf->data_buf[13] >> 8) | buf->data_buf[14]; // 获取当前消息id 用于删除
|
|
// printf("msg_id =%X\r\n",msg_id);
|
|
// printf("msg_id =%X\r\n",msg_id);
|
|
@@ -1344,17 +1343,17 @@ static void hardware_gwpair_func(const LORA_DATA_T *buf)
|
|
Machine_info.rssi = set_lora(Machine_info.lora_new_channel, Machine_info.eflagID);
|
|
Machine_info.rssi = set_lora(Machine_info.lora_new_channel, Machine_info.eflagID);
|
|
f_send_version();
|
|
f_send_version();
|
|
f_send_reply_status(0x01); // 回复在线状态
|
|
f_send_reply_status(0x01); // 回复在线状态
|
|
- send_update_status();
|
|
|
|
|
|
+ f_send_update_status();
|
|
// f_send_lora_rssi(Machine_info.rssi);
|
|
// f_send_lora_rssi(Machine_info.rssi);
|
|
- f_send_lora_rssi(100); // 刚配完直接发100
|
|
|
|
|
|
+ // f_send_lora_rssi(100); // 刚配完直接发100
|
|
f_send_battary_vaule(Machine_info.batt_precent);
|
|
f_send_battary_vaule(Machine_info.batt_precent);
|
|
|
|
|
|
-#if 1
|
|
|
|
|
|
+#if 0
|
|
f_send_get_chart_data();
|
|
f_send_get_chart_data();
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if USER_LIGHT_SLEEP_ENABLE || USER_DEEP_SLEEP_ENABLE
|
|
#if USER_LIGHT_SLEEP_ENABLE || USER_DEEP_SLEEP_ENABLE
|
|
- set_screen_dis_info_and_send_queue(false, true, false, true,100);
|
|
|
|
|
|
+ set_screen_dis_info_and_send_queue(false, true, false, true, 100);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// printf("start timer id = %d,%d\r\n",Machine_info.eflagID,Machine_info.eflagID * TIMER_CAN_SEND_TIME);
|
|
// printf("start timer id = %d,%d\r\n",Machine_info.eflagID,Machine_info.eflagID * TIMER_CAN_SEND_TIME);
|
|
@@ -1467,13 +1466,22 @@ static void hardware_ack_delete_msg_id(const LORA_DATA_T *buf)
|
|
|
|
|
|
// int current = countNodes(Send_list); //获取当前节点数据
|
|
// int current = countNodes(Send_list); //获取当前节点数据
|
|
Node *find = findNode(Send_list, msg_id);
|
|
Node *find = findNode(Send_list, msg_id);
|
|
- printf("delete list node bofore = %d\r\n", msg_id);
|
|
|
|
|
|
|
|
if (find != NULL)
|
|
if (find != NULL)
|
|
{
|
|
{
|
|
// printf("delete list node bofore = %d\r\n",msg_id);
|
|
// printf("delete list node bofore = %d\r\n",msg_id);
|
|
// printList(Send_list);
|
|
// printList(Send_list);
|
|
- Send_list = deleteNode(Send_list, msg_id);
|
|
|
|
|
|
+
|
|
|
|
+ for(int i=0;i< LORA_INFO_END;i++)
|
|
|
|
+ {
|
|
|
|
+ if(lora_pool[i].num == msg_id)
|
|
|
|
+ {
|
|
|
|
+ lora_pool[LORA_INFO_VERSION].flag = false;
|
|
|
|
+ Send_list = deleteNode(Send_list, msg_id);
|
|
|
|
+ ESP_LOGE(LOG_TAG,"delete msg_id %d",msg_id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// printf("delete list node msg_id = %d\r\n",msg_id);
|
|
// printf("delete list node msg_id = %d\r\n",msg_id);
|
|
|
|
|
|
// printf("delete list node after = %d\r\n",msg_id);
|
|
// printf("delete list node after = %d\r\n",msg_id);
|
|
@@ -1484,19 +1492,19 @@ static void hardware_ack_delete_msg_id(const LORA_DATA_T *buf)
|
|
ESP_LOGE(LOG_TAG, "delete fail");
|
|
ESP_LOGE(LOG_TAG, "delete fail");
|
|
}
|
|
}
|
|
|
|
|
|
- display_flag = 0;
|
|
|
|
|
|
+ // display_flag = 0;
|
|
}
|
|
}
|
|
|
|
|
|
void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
|
|
void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
|
|
{
|
|
{
|
|
- int cmd = 0; // 当前的命令
|
|
|
|
|
|
+ // int cmd = 0; // 当前的命令
|
|
int msg_id = 0; // 消息的id
|
|
int msg_id = 0; // 消息的id
|
|
// bool is_rsp_ack = false;
|
|
// bool is_rsp_ack = false;
|
|
#if 0
|
|
#if 0
|
|
printf("cmd = %02X\r\n",buf->data_buf[cmd_index]);
|
|
printf("cmd = %02X\r\n",buf->data_buf[cmd_index]);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- cmd = buf->data_buf[cmd_index];
|
|
|
|
|
|
+ // cmd = buf->data_buf[cmd_index];
|
|
|
|
|
|
switch (buf->data_buf[cmd_index])
|
|
switch (buf->data_buf[cmd_index])
|
|
{
|
|
{
|
|
@@ -1615,8 +1623,8 @@ void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
|
|
// 重置快刷
|
|
// 重置快刷
|
|
Machine_info.left_current_Quick_refresh_time = 0;
|
|
Machine_info.left_current_Quick_refresh_time = 0;
|
|
Machine_info.right_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);
|
|
|
|
|
|
+ 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;
|
|
break;
|
|
|
|
|
|
case PROTOCOL_HARDWARE_UNGWPAIRED: // 取消配网
|
|
case PROTOCOL_HARDWARE_UNGWPAIRED: // 取消配网
|
|
@@ -1626,7 +1634,7 @@ void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
|
|
|
|
|
|
case PROTOCOL_RSPONSIBLE_ACK:
|
|
case PROTOCOL_RSPONSIBLE_ACK:
|
|
|
|
|
|
- printf("receive gateway ack delete data in list\r\n");
|
|
|
|
|
|
+ // printf("receive gateway ack delete data in list\r\n");
|
|
hardware_ack_delete_msg_id(buf);
|
|
hardware_ack_delete_msg_id(buf);
|
|
|
|
|
|
break;
|
|
break;
|
|
@@ -2158,68 +2166,68 @@ bool subcontract(YC_DATA_T *data)
|
|
return refresh_flag;
|
|
return refresh_flag;
|
|
}
|
|
}
|
|
|
|
|
|
-// len:有效数据长度,不是总长//
|
|
|
|
-static void protocol_package(char cmd, const uint8_t *info, int len)
|
|
|
|
-{
|
|
|
|
-#define __PACKAGE 15
|
|
|
|
- uint8_t *__str = (uint8_t *)malloc(sizeof(uint8_t) * (__PACKAGE + len) * 2);
|
|
|
|
-
|
|
|
|
- __str[0] = 0x5a;
|
|
|
|
- __str[1] = 0x51;
|
|
|
|
-
|
|
|
|
- __str[2] = 0x00;
|
|
|
|
-
|
|
|
|
- __str[3] = mac_addr[0];
|
|
|
|
- __str[4] = mac_addr[1];
|
|
|
|
- __str[5] = mac_addr[2];
|
|
|
|
- __str[6] = mac_addr[3];
|
|
|
|
- __str[7] = mac_addr[4];
|
|
|
|
- __str[8] = mac_addr[5];
|
|
|
|
-
|
|
|
|
- __str[9] = Machine_info.eflagID;
|
|
|
|
-
|
|
|
|
- __str[10] = cmd;
|
|
|
|
-#if 0
|
|
|
|
- __str[11] = 0x01;//当前只为一包
|
|
|
|
- __str[12] = 0x01;//当前只为一包
|
|
|
|
-#else
|
|
|
|
-
|
|
|
|
- // 随机数
|
|
|
|
- srand((unsigned int)time(NULL));
|
|
|
|
- int time_rand = rand() % 65535 + 1; // 生成1~100的随机数
|
|
|
|
- __str[11] = (time_rand >> 8) & 0xFF;
|
|
|
|
- __str[12] = time_rand & 0xFF;
|
|
|
|
-#endif
|
|
|
|
- // 分包
|
|
|
|
- __str[13] = (len >> 8) & 0xFF;
|
|
|
|
- __str[14] = len & 0xFF;
|
|
|
|
-
|
|
|
|
- memcpy(__str + __PACKAGE, info, len);
|
|
|
|
- int i = 0, sum = 0;
|
|
|
|
- for (i = 0; i < len + __PACKAGE; i++)
|
|
|
|
- {
|
|
|
|
- sum += __str[i];
|
|
|
|
- }
|
|
|
|
- __str[2] = sum & 0xFF;
|
|
|
|
|
|
+// // len:有效数据长度,不是总长//
|
|
|
|
+// static void protocol_package(char cmd, const uint8_t *info, int len)
|
|
|
|
+// {
|
|
|
|
+// #define __PACKAGE 15
|
|
|
|
+// uint8_t *__str = (uint8_t *)malloc(sizeof(uint8_t) * (__PACKAGE + len) * 2);
|
|
|
|
+
|
|
|
|
+// __str[0] = 0x5a;
|
|
|
|
+// __str[1] = 0x51;
|
|
|
|
+
|
|
|
|
+// __str[2] = 0x00;
|
|
|
|
+
|
|
|
|
+// __str[3] = mac_addr[0];
|
|
|
|
+// __str[4] = mac_addr[1];
|
|
|
|
+// __str[5] = mac_addr[2];
|
|
|
|
+// __str[6] = mac_addr[3];
|
|
|
|
+// __str[7] = mac_addr[4];
|
|
|
|
+// __str[8] = mac_addr[5];
|
|
|
|
+
|
|
|
|
+// __str[9] = Machine_info.eflagID;
|
|
|
|
+
|
|
|
|
+// __str[10] = cmd;
|
|
|
|
+// #if 0
|
|
|
|
+// __str[11] = 0x01;//当前只为一包
|
|
|
|
+// __str[12] = 0x01;//当前只为一包
|
|
|
|
+// #else
|
|
|
|
+
|
|
|
|
+// // 随机数
|
|
|
|
+// srand((unsigned int)time(NULL));
|
|
|
|
+// int time_rand = rand() % 65535 + 1; // 生成1~100的随机数
|
|
|
|
+// __str[11] = (time_rand >> 8) & 0xFF;
|
|
|
|
+// __str[12] = time_rand & 0xFF;
|
|
|
|
+// #endif
|
|
|
|
+// // 分包
|
|
|
|
+// __str[13] = (len >> 8) & 0xFF;
|
|
|
|
+// __str[14] = len & 0xFF;
|
|
|
|
+
|
|
|
|
+// memcpy(__str + __PACKAGE, info, len);
|
|
|
|
+// int i = 0, sum = 0;
|
|
|
|
+// for (i = 0; i < len + __PACKAGE; i++)
|
|
|
|
+// {
|
|
|
|
+// sum += __str[i];
|
|
|
|
+// }
|
|
|
|
+// __str[2] = sum & 0xFF;
|
|
|
|
|
|
- printf("crc=%02x ", __str[2]);
|
|
|
|
|
|
+// printf("crc=%02x ", __str[2]);
|
|
|
|
|
|
- printf("-->package:");
|
|
|
|
- for (i = 0; i < len + __PACKAGE; i++)
|
|
|
|
- {
|
|
|
|
- printf("%02x ", __str[i]);
|
|
|
|
- }
|
|
|
|
- printf("\n");
|
|
|
|
|
|
+// printf("-->package:");
|
|
|
|
+// for (i = 0; i < len + __PACKAGE; i++)
|
|
|
|
+// {
|
|
|
|
+// printf("%02x ", __str[i]);
|
|
|
|
+// }
|
|
|
|
+// printf("\n");
|
|
|
|
|
|
- changebintotxt(__str, len + __PACKAGE);
|
|
|
|
|
|
+// changebintotxt(__str, len + __PACKAGE);
|
|
|
|
|
|
-#if 0
|
|
|
|
- Send_list = postInsert(Send_list, time_rand,cmd,(char *)__str,(int)(len+__PACKAGE)*2);//len*2
|
|
|
|
-#else
|
|
|
|
- lora_send_data((char *)__str, len + __PACKAGE);
|
|
|
|
-#endif
|
|
|
|
- free(__str);
|
|
|
|
-}
|
|
|
|
|
|
+// #if 0
|
|
|
|
+// Send_list = postInsert(Send_list, time_rand,cmd,(char *)__str,(int)(len+__PACKAGE)*2);//len*2
|
|
|
|
+// #else
|
|
|
|
+// lora_send_data((char *)__str, len + __PACKAGE);
|
|
|
|
+// #endif
|
|
|
|
+// free(__str);
|
|
|
|
+// }
|
|
|
|
|
|
int txttobin(uint8_t *strlorabuf)
|
|
int txttobin(uint8_t *strlorabuf)
|
|
{
|
|
{
|
|
@@ -2300,6 +2308,10 @@ void changebintotxt(uint8_t *strb, int len)
|
|
******************************/
|
|
******************************/
|
|
void f_send_get_time(void)
|
|
void f_send_get_time(void)
|
|
{
|
|
{
|
|
|
|
+ if (lora_pool[LORA_INFO_GET_TIME].flag == true)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
uint8_t strlorabuf[200];
|
|
uint8_t strlorabuf[200];
|
|
uint8_t strnum[20];
|
|
uint8_t strnum[20];
|
|
|
|
|
|
@@ -2338,10 +2350,16 @@ void f_send_get_time(void)
|
|
len = strlen((char *)strlorabuf);
|
|
len = strlen((char *)strlorabuf);
|
|
|
|
|
|
// lora_send_data((char *)strlorabuf,len);
|
|
// lora_send_data((char *)strlorabuf,len);
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
+ lora_pool[LORA_INFO_GET_TIME].num = Machine_info.msg_id;
|
|
|
|
+ lora_pool[LORA_INFO_GET_TIME].flag = true;
|
|
|
|
+ Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_GET_TIME, (char *)strlorabuf, len); // 插入数据
|
|
}
|
|
}
|
|
void f_send_get_chart_data(void)
|
|
void f_send_get_chart_data(void)
|
|
{
|
|
{
|
|
|
|
+ if (lora_pool[LORA_INFO_GET_CHART].flag == true)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
ESP_LOGW(LOG_TAG, "f_send_get_chart_data");
|
|
ESP_LOGW(LOG_TAG, "f_send_get_chart_data");
|
|
uint8_t strlorabuf[200];
|
|
uint8_t strlorabuf[200];
|
|
|
|
|
|
@@ -2379,11 +2397,16 @@ void f_send_get_chart_data(void)
|
|
len = strlen((char *)strlorabuf);
|
|
len = strlen((char *)strlorabuf);
|
|
|
|
|
|
// lora_send_data((char *)strlorabuf,len);
|
|
// lora_send_data((char *)strlorabuf,len);
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
+ lora_pool[LORA_INFO_GET_CHART].num = Machine_info.msg_id;
|
|
|
|
+ lora_pool[LORA_INFO_GET_CHART].flag = true;
|
|
|
|
+ Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_GET_CHART, (char *)strlorabuf, len); // 插入数据
|
|
}
|
|
}
|
|
void f_send_version(void)
|
|
void f_send_version(void)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ if (lora_pool[LORA_INFO_VERSION].flag == true)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
ESP_LOGW(LOG_TAG, "f_send_version");
|
|
ESP_LOGW(LOG_TAG, "f_send_version");
|
|
uint8_t strlorabuf[200];
|
|
uint8_t strlorabuf[200];
|
|
|
|
|
|
@@ -2423,11 +2446,16 @@ void f_send_version(void)
|
|
strcat((char *)strlorabuf, (char *)Machine_info.cid);
|
|
strcat((char *)strlorabuf, (char *)Machine_info.cid);
|
|
len = strlen((char *)strlorabuf);
|
|
len = strlen((char *)strlorabuf);
|
|
|
|
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
+ lora_pool[LORA_INFO_VERSION].num = Machine_info.msg_id;
|
|
|
|
+ lora_pool[LORA_INFO_VERSION].flag = true;
|
|
|
|
+ Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_VERSION, (char *)strlorabuf, len); // 插入数据
|
|
}
|
|
}
|
|
void f_send_lora_rssi(int rssi)
|
|
void f_send_lora_rssi(int rssi)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ if (lora_pool[LORA_INFO_RSSI].flag == true)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
// ESP_LOGW(LOG_TAG,"f_send_lora_rssi:rssi = %d",rssi);
|
|
// ESP_LOGW(LOG_TAG,"f_send_lora_rssi:rssi = %d",rssi);
|
|
uint8_t strlorabuf[200];
|
|
uint8_t strlorabuf[200];
|
|
|
|
|
|
@@ -2465,12 +2493,17 @@ void f_send_lora_rssi(int rssi)
|
|
strcat((char *)strlorabuf, (char *)Machine_info.cid);
|
|
strcat((char *)strlorabuf, (char *)Machine_info.cid);
|
|
len = strlen((char *)strlorabuf);
|
|
len = strlen((char *)strlorabuf);
|
|
|
|
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
+ lora_pool[LORA_INFO_RSSI].num = Machine_info.msg_id;
|
|
|
|
+ lora_pool[LORA_INFO_RSSI].flag = true;
|
|
|
|
+ Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_RSSI, (char *)strlorabuf, len); // 插入数据
|
|
}
|
|
}
|
|
|
|
|
|
void f_send_battary_vaule(int battry)
|
|
void f_send_battary_vaule(int battry)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ if (lora_pool[LORA_INFO_BATT].flag == true)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
uint8_t strlorabuf[200];
|
|
uint8_t strlorabuf[200];
|
|
|
|
|
|
int crc16 = 0, i = 0, len = 0;
|
|
int crc16 = 0, i = 0, len = 0;
|
|
@@ -2507,12 +2540,18 @@ void f_send_battary_vaule(int battry)
|
|
strcat((char *)strlorabuf, (char *)Machine_info.cid);
|
|
strcat((char *)strlorabuf, (char *)Machine_info.cid);
|
|
len = strlen((char *)strlorabuf);
|
|
len = strlen((char *)strlorabuf);
|
|
|
|
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
+ lora_pool[LORA_INFO_BATT].num = Machine_info.msg_id;
|
|
|
|
+ lora_pool[LORA_INFO_BATT].flag = true;
|
|
|
|
+ Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_BATT, (char *)strlorabuf, len); // 插入数据
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
void f_send_reply_status(int status)
|
|
void f_send_reply_status(int status)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ if (lora_pool[LORA_INFO_BATT].flag == true)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
uint8_t strlorabuf[200];
|
|
uint8_t strlorabuf[200];
|
|
|
|
|
|
int crc16 = 0, i = 0, len = 0;
|
|
int crc16 = 0, i = 0, len = 0;
|
|
@@ -2549,7 +2588,9 @@ void f_send_reply_status(int status)
|
|
strcat((char *)strlorabuf, (char *)Machine_info.cid);
|
|
strcat((char *)strlorabuf, (char *)Machine_info.cid);
|
|
len = strlen((char *)strlorabuf);
|
|
len = strlen((char *)strlorabuf);
|
|
|
|
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
+ lora_pool[LORA_INFO_REPLY].num = Machine_info.msg_id;
|
|
|
|
+ lora_pool[LORA_INFO_REPLY].flag = true;
|
|
|
|
+ Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_REPLY, (char *)strlorabuf, len); // 插入数据
|
|
}
|
|
}
|
|
|
|
|
|
// 唤醒时发送是否可以接收数据命令
|
|
// 唤醒时发送是否可以接收数据命令
|
|
@@ -2618,16 +2659,6 @@ void send_can_I_receive()
|
|
// lora_send_data((char *)strlorabuf,7);
|
|
// lora_send_data((char *)strlorabuf,7);
|
|
// }
|
|
// }
|
|
|
|
|
|
-void send_rssi(void)
|
|
|
|
-{
|
|
|
|
- char rssi = Machine_info.rssi;
|
|
|
|
-#if 0
|
|
|
|
- protocol_package(0x05,&rssi,1);
|
|
|
|
-#else
|
|
|
|
-
|
|
|
|
- f_send_lora_rssi(rssi);
|
|
|
|
-#endif
|
|
|
|
-}
|
|
|
|
// 4bytes、32bit数据大小端转化
|
|
// 4bytes、32bit数据大小端转化
|
|
#define L2B32(Little) (Little = ((Little & 0xff) << 24) | (((Little) & 0xff00) << 8) | (((Little) & 0xff0000) >> 8) | ((Little >> 24) & 0xff))
|
|
#define L2B32(Little) (Little = ((Little & 0xff) << 24) | (((Little) & 0xff00) << 8) | (((Little) & 0xff0000) >> 8) | ((Little >> 24) & 0xff))
|
|
|
|
|
|
@@ -2693,34 +2724,12 @@ uint8_t change_btn(uint8_t btn)
|
|
return btn_tmp;
|
|
return btn_tmp;
|
|
}
|
|
}
|
|
/*发送状态持续的时间 状态持续时长(0x0E)*/
|
|
/*发送状态持续的时间 状态持续时长(0x0E)*/
|
|
-void send_status_duration(void)
|
|
|
|
|
|
+void f_send_status_duration(void)
|
|
{
|
|
{
|
|
-#if 0
|
|
|
|
- uint8_t* dur = (uint8_t*)malloc(sizeof(uint8_t)*(12));
|
|
|
|
-
|
|
|
|
- memcpy(dur,&last_button_info.button_info,1);
|
|
|
|
- memcpy(dur+1,&last_button_info.Year,2);
|
|
|
|
- memcpy(dur+3,&last_button_info.Month,1);
|
|
|
|
- memcpy(dur+4,&last_button_info.Day,1);
|
|
|
|
- memcpy(dur+5,&last_button_info.Hour,1);
|
|
|
|
- memcpy(dur+6,&last_button_info.Minute,1);
|
|
|
|
- memcpy(dur+7,&last_button_info.Second,1);
|
|
|
|
-
|
|
|
|
- uint32_t tmp = last_button_info.time_min;
|
|
|
|
- L2B32(tmp);
|
|
|
|
- memcpy(dur+8,&tmp,4);
|
|
|
|
-
|
|
|
|
- ESP_LOGW(LOG_TAG,"log -->btn = %d [%d-%d-%d]%d:%d:%d <%04ld>",\
|
|
|
|
- last_button_info.button_info, last_button_info.Year,\
|
|
|
|
- last_button_info.Month,last_button_info.Day,\
|
|
|
|
- last_button_info.Hour, last_button_info.Minute,\
|
|
|
|
- last_button_info.Second,last_button_info.time_min);
|
|
|
|
-
|
|
|
|
- protocol_package(0x0E,dur,12);
|
|
|
|
- last_button_info.time_min = 0;
|
|
|
|
- free(dur);
|
|
|
|
-#else
|
|
|
|
-
|
|
|
|
|
|
+ if (lora_pool[LORA_INFO_DUR].flag == true)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
uint8_t strlorabuf[200];
|
|
uint8_t strlorabuf[200];
|
|
|
|
|
|
int crc16 = 0, i = 0, len = 0;
|
|
int crc16 = 0, i = 0, len = 0;
|
|
@@ -2793,27 +2802,28 @@ void send_status_duration(void)
|
|
len = strlen((char *)strlorabuf);
|
|
len = strlen((char *)strlorabuf);
|
|
|
|
|
|
#if 0
|
|
#if 0
|
|
- lora_send_data((char *)strlorabuf,len);
|
|
|
|
|
|
+ lora_send_data((char *)strlorabuf,len);/直接发送
|
|
|
|
|
|
#else
|
|
#else
|
|
-
|
|
|
|
// printList(Send_list);
|
|
// printList(Send_list);
|
|
-
|
|
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
+ lora_pool[LORA_INFO_DUR].flag =true;
|
|
|
|
+ lora_pool[LORA_INFO_DUR].num = Machine_info.msg_id;
|
|
|
|
+ Send_list = postInsert(Send_list, Machine_info.msg_id , LORA_INFO_DUR, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// lora_send_data((char *)strlorabuf,len);
|
|
// lora_send_data((char *)strlorabuf,len);
|
|
|
|
|
|
last_button_info.time_min = 0;
|
|
last_button_info.time_min = 0;
|
|
-
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/*当前最新的状态*/
|
|
/*当前最新的状态*/
|
|
-void send_update_status(void)
|
|
|
|
|
|
+void f_send_update_status(void)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ if (lora_pool[LORA_INFO_STATUS].flag == true)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
#if 0
|
|
#if 0
|
|
uint8_t* update = (uint8_t*)malloc(sizeof(uint8_t)*(12));
|
|
uint8_t* update = (uint8_t*)malloc(sizeof(uint8_t)*(12));
|
|
memset(&new_button_info,0,sizeof(Button_Time_t));
|
|
memset(&new_button_info,0,sizeof(Button_Time_t));
|
|
@@ -2927,7 +2937,9 @@ void send_update_status(void)
|
|
#if 0
|
|
#if 0
|
|
lora_send_data((char *)strlorabuf,len);
|
|
lora_send_data((char *)strlorabuf,len);
|
|
#else
|
|
#else
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
+ lora_pool[LORA_INFO_STATUS].num = Machine_info.msg_id;
|
|
|
|
+ lora_pool[LORA_INFO_STATUS].flag = true;
|
|
|
|
+ Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_STATUS, (char *)strlorabuf, len); // 插入数据
|
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -2936,15 +2948,15 @@ void send_update_status(void)
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
-void send_ACK(char cmd, bool flag)
|
|
|
|
-{
|
|
|
|
- uint8_t ack = 0;
|
|
|
|
- if (flag)
|
|
|
|
- ack = 0x01;
|
|
|
|
- else
|
|
|
|
- ack = 0x00;
|
|
|
|
- protocol_package(cmd, &ack, 1);
|
|
|
|
-}
|
|
|
|
|
|
+// void send_ACK(char cmd, bool flag)
|
|
|
|
+// {
|
|
|
|
+// uint8_t ack = 0;
|
|
|
|
+// if (flag)
|
|
|
|
+// ack = 0x01;
|
|
|
|
+// else
|
|
|
|
+// ack = 0x00;
|
|
|
|
+// protocol_package(cmd, &ack, 1);
|
|
|
|
+// }
|
|
|
|
|
|
void adc1_init(void)
|
|
void adc1_init(void)
|
|
{
|
|
{
|
|
@@ -3551,7 +3563,7 @@ void lora_rev_cmd_send_ack()
|
|
}
|
|
}
|
|
void right_screen_send()
|
|
void right_screen_send()
|
|
{
|
|
{
|
|
- set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false, 100);
|
|
}
|
|
}
|
|
void user_compare(int last, int now) // 这个函数用来比较rssi和 电量变化 刷右屏//
|
|
void user_compare(int last, int now) // 这个函数用来比较rssi和 电量变化 刷右屏//
|
|
{
|
|
{
|
|
@@ -3655,6 +3667,6 @@ void user_compare_power_off(int last, int now) // 这个函数用来比较关机
|
|
if (is_dis)
|
|
if (is_dis)
|
|
{
|
|
{
|
|
|
|
|
|
- set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false, 100);
|
|
}
|
|
}
|
|
}
|
|
}
|