|
@@ -214,7 +214,7 @@ void update_last_button_info(uint8_t btn)
|
|
|
void screen_display(void)
|
|
|
{
|
|
|
|
|
|
- font_exit_sleep();
|
|
|
+ // font_exit_sleep();
|
|
|
|
|
|
EventBits_t bits = xEventGroupWaitBits(screen_event,
|
|
|
LEFT_SCREEN_BIT | RIGHT_SCREEN_BIT,
|
|
@@ -1327,15 +1327,12 @@ static void hardware_gwpair_func(const LORA_DATA_T *buf)
|
|
|
|
|
|
Machine_info.paired = 1; // 已配对
|
|
|
|
|
|
-#if 0
|
|
|
- send_pair_ack();
|
|
|
-#else
|
|
|
+
|
|
|
int msg_id = (buf->data_buf[11] << 8) | buf->data_buf[12]; // 获取当前消息id 用于删除
|
|
|
printf("msg_id =%X\r\n", msg_id);
|
|
|
|
|
|
reply_ack_func(PROTOCOL_HARDWARE_GWPAIRED, msg_id, true, NULL); // 回复ack
|
|
|
|
|
|
-#endif
|
|
|
// vTaskDelay(200 / portTICK_PERIOD_MS);
|
|
|
// //修改信道前修改设备ID 及 设备ID
|
|
|
// dymatic_change_device_id(child_num+1);
|
|
@@ -1346,7 +1343,7 @@ static void hardware_gwpair_func(const LORA_DATA_T *buf)
|
|
|
|
|
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
|
|
Machine_info.rssi = set_lora(Machine_info.lora_new_channel, Machine_info.eflagID);
|
|
|
- f_send_get_time();
|
|
|
+ // f_send_get_time();
|
|
|
f_send_version();
|
|
|
f_send_reply_status(0x01); // 回复在线状态
|
|
|
f_send_update_status();
|
|
@@ -1437,15 +1434,12 @@ static void hardware_ungwpair_func(const LORA_DATA_T *buf)
|
|
|
|
|
|
// 取消配网成功 回复 ACK 设置新的信道
|
|
|
|
|
|
-#if 0
|
|
|
- send_pair_ack();
|
|
|
-#else
|
|
|
+
|
|
|
int msg_id = (buf->data_buf[11] << 8) | buf->data_buf[12]; // 获取当前消息id 用于删除
|
|
|
// printf("msg_id =%X\r\n",msg_id);
|
|
|
|
|
|
reply_ack_func(PROTOCOL_HARDWARE_UNGWPAIRED, msg_id, true, NULL); // 回复ack
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
// #include "user_sleep.h"
|
|
|
// #include "esp_sleep.h"
|
|
@@ -1465,6 +1459,7 @@ static void hardware_ungwpair_func(const LORA_DATA_T *buf)
|
|
|
Machine_info.lora_new_channel = LORA_CHANENL;
|
|
|
// dymatic_change_chanel(Machine_info.lora_factory_channel); //切换信道
|
|
|
reset_lora(LORA_CHANENL);
|
|
|
+ Machine_info.paired = 0; // 解除配对
|
|
|
}
|
|
|
/*网关收到终端发送的数据 ACK 终端收到用于删除当前的msgid的数据*/
|
|
|
static void hardware_ack_delete_msg_id(const LORA_DATA_T *buf)
|
|
@@ -2244,7 +2239,6 @@ void f_send_get_time(void)
|
|
|
uint8_t strlorabuf[200];
|
|
|
uint8_t strnum[20];
|
|
|
|
|
|
- static int rssiold = 0;
|
|
|
int crc16 = 0, i = 0, len = 0;
|
|
|
|
|
|
strlorabuf[0] = 0x5A;
|
|
@@ -2261,7 +2255,11 @@ void f_send_get_time(void)
|
|
|
strlorabuf[10] = 0x01; // cmd命令字
|
|
|
|
|
|
Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
-
|
|
|
+ if (Machine_info.msg_id > 1000)
|
|
|
+ {
|
|
|
+ ESP_LOGE(LOG_TAG, "time Machine_info.msg_id>1000");
|
|
|
+ return;
|
|
|
+ }
|
|
|
strlorabuf[11] = ((Machine_info.msg_id) >> 8) & 0XFF; //
|
|
|
strlorabuf[12] = ((Machine_info.msg_id) >> 0) & 0XFF; // 总包数,当前包数
|
|
|
|
|
@@ -2308,7 +2306,12 @@ void f_send_get_chart_data(void)
|
|
|
strlorabuf[9] = Machine_info.eflagID; // 组内编号
|
|
|
strlorabuf[10] = 0x11; // cmd命令字
|
|
|
|
|
|
- Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
+ Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
+ if (Machine_info.msg_id > 1000)
|
|
|
+ {
|
|
|
+ ESP_LOGE(LOG_TAG, "chart Machine_info.msg_id>1000");
|
|
|
+ return;
|
|
|
+ }
|
|
|
strlorabuf[11] = ((Machine_info.msg_id) >> 8) & 0XFF; //
|
|
|
strlorabuf[12] = ((Machine_info.msg_id) >> 0) & 0XFF; // 总包数,当前包数
|
|
|
|
|
@@ -2329,7 +2332,7 @@ void f_send_get_chart_data(void)
|
|
|
// lora_send_data((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); // 插入数据
|
|
|
+ Send_list = postInsert(Send_list, (int)Machine_info.msg_id, LORA_INFO_GET_CHART, (char *)strlorabuf, len); // 插入数据
|
|
|
}
|
|
|
void f_send_version(void)
|
|
|
{
|
|
@@ -2338,7 +2341,7 @@ void f_send_version(void)
|
|
|
ESP_LOGE(LOG_TAG, "%s-->return", __FUNCTION__);
|
|
|
return;
|
|
|
}
|
|
|
- ESP_LOGW(LOG_TAG, "f_send_version");
|
|
|
+ // ESP_LOGW(LOG_TAG, "f_send_version");
|
|
|
uint8_t strlorabuf[200];
|
|
|
|
|
|
int crc16 = 0, i = 0, len = 0;
|
|
@@ -2356,7 +2359,12 @@ void f_send_version(void)
|
|
|
strlorabuf[9] = Machine_info.eflagID; // 组内编号
|
|
|
strlorabuf[10] = 0x91; // cmd命令字
|
|
|
|
|
|
- Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
+ Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
+ if (Machine_info.msg_id > 1000)
|
|
|
+ {
|
|
|
+ ESP_LOGE(LOG_TAG, "version Machine_info.msg_id>1000");
|
|
|
+ return;
|
|
|
+ }
|
|
|
strlorabuf[11] = ((Machine_info.msg_id) >> 8) & 0XFF; //
|
|
|
strlorabuf[12] = ((Machine_info.msg_id) >> 0) & 0XFF; // 总包数,当前包数
|
|
|
|
|
@@ -2379,7 +2387,7 @@ void f_send_version(void)
|
|
|
|
|
|
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); // 插入数据
|
|
|
+ Send_list = postInsert(Send_list, (int)Machine_info.msg_id, LORA_INFO_VERSION, (char *)strlorabuf, len); // 插入数据
|
|
|
}
|
|
|
void f_send_lora_rssi(int rssi)
|
|
|
{
|
|
@@ -2406,7 +2414,12 @@ void f_send_lora_rssi(int rssi)
|
|
|
strlorabuf[9] = Machine_info.eflagID; // 组内编号
|
|
|
strlorabuf[10] = 0x05; // cmd命令字
|
|
|
|
|
|
- Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
+ Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
+ if (Machine_info.msg_id > 1000)
|
|
|
+ {
|
|
|
+ ESP_LOGE(LOG_TAG, "rssi Machine_info.msg_id>1000");
|
|
|
+ return;
|
|
|
+ }
|
|
|
strlorabuf[11] = ((Machine_info.msg_id) >> 8) & 0XFF; //
|
|
|
strlorabuf[12] = ((Machine_info.msg_id) >> 0) & 0XFF; // 总包数,当前包数
|
|
|
|
|
@@ -2427,7 +2440,7 @@ void f_send_lora_rssi(int rssi)
|
|
|
|
|
|
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); // 插入数据
|
|
|
+ Send_list = postInsert(Send_list, (int)Machine_info.msg_id, LORA_INFO_RSSI, (char *)strlorabuf, len); // 插入数据
|
|
|
}
|
|
|
void f_send_test(void)
|
|
|
{
|
|
@@ -2472,7 +2485,7 @@ void f_send_test(void)
|
|
|
len = strlen((char *)strlorabuf);
|
|
|
// send_lora_data(strlorabuf, len);
|
|
|
// lora_send_data((char *)strlorabuf, len);
|
|
|
- Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_BATT, (char *)strlorabuf, len); // 插入数据
|
|
|
+ Send_list = postInsert(Send_list, (int)Machine_info.msg_id, LORA_INFO_BATT, (char *)strlorabuf, len); // 插入数据
|
|
|
}
|
|
|
void f_send_battary_vaule(int battry)
|
|
|
{
|
|
@@ -2498,7 +2511,12 @@ void f_send_battary_vaule(int battry)
|
|
|
strlorabuf[9] = Machine_info.eflagID; // 组内编号
|
|
|
strlorabuf[10] = 0x04; // cmd命令字
|
|
|
|
|
|
- Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
+ Machine_info.msg_id = allocateMsgIdNum(); // 分配ID
|
|
|
+ if (Machine_info.msg_id > 1000)
|
|
|
+ {
|
|
|
+ ESP_LOGE(LOG_TAG, "batt Machine_info.msg_id>1000");
|
|
|
+ return;
|
|
|
+ }
|
|
|
strlorabuf[11] = ((Machine_info.msg_id) >> 8) & 0XFF; //
|
|
|
strlorabuf[12] = ((Machine_info.msg_id) >> 0) & 0XFF; // 总包数,当前包数
|
|
|
|
|
@@ -2519,7 +2537,7 @@ void f_send_battary_vaule(int battry)
|
|
|
|
|
|
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); // 插入数据
|
|
|
+ Send_list = postInsert(Send_list, (int)Machine_info.msg_id, LORA_INFO_BATT, (char *)strlorabuf, len); // 插入数据
|
|
|
}
|
|
|
|
|
|
void f_send_reply_status(int status)
|
|
@@ -2567,7 +2585,7 @@ void f_send_reply_status(int status)
|
|
|
|
|
|
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); // 插入数据
|
|
|
+ Send_list = postInsert(Send_list,(int)Machine_info.msg_id, LORA_INFO_REPLY, (char *)strlorabuf, len); // 插入数据
|
|
|
}
|
|
|
|
|
|
// 唤醒时发送是否可以接收数据命令
|
|
@@ -3030,37 +3048,37 @@ void set_status_heights(void)
|
|
|
// // }
|
|
|
// }
|
|
|
|
|
|
-void lora_timer_callback(void *arg)
|
|
|
-{
|
|
|
- ESP_LOGI(LOG_TAG, " lora_timer_callback");
|
|
|
-
|
|
|
- if (xQueueSend(yc_data_queue, &yc_data, 0) != true)
|
|
|
- {
|
|
|
- ESP_LOGE(LOG_TAG, "yc_data_queue send is fail");
|
|
|
- }
|
|
|
- yc_data.len = 0;
|
|
|
- yc_data.index = 0;
|
|
|
-}
|
|
|
-void timer_init(void)
|
|
|
-{
|
|
|
- // const esp_timer_create_args_t periodic_timer_args = {
|
|
|
- // .callback = &periodic_timer_callback,
|
|
|
- // /* name is optional, but may help identify the timer when debugging */
|
|
|
- // .name = "periodic"
|
|
|
- // };
|
|
|
-
|
|
|
- // ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
|
|
|
- // /* The timer has been created but is not running yet */
|
|
|
-
|
|
|
- // ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, 1*1000*1000));
|
|
|
+// void lora_timer_callback(void *arg)
|
|
|
+// {
|
|
|
+// ESP_LOGI(LOG_TAG, " lora_timer_callback");
|
|
|
|
|
|
- // lora timer
|
|
|
- const esp_timer_create_args_t lora_timer_args = {
|
|
|
- .callback = &lora_timer_callback,
|
|
|
- /* argument specified here will be passed to timer callback function */
|
|
|
- .name = "one-shot"};
|
|
|
- ESP_ERROR_CHECK(esp_timer_create(&lora_timer_args, &lora_timer));
|
|
|
-}
|
|
|
+// if (xQueueSend(yc_data_queue, &yc_data, 0) != true)
|
|
|
+// {
|
|
|
+// ESP_LOGE(LOG_TAG, "yc_data_queue send is fail");
|
|
|
+// }
|
|
|
+// yc_data.len = 0;
|
|
|
+// yc_data.index = 0;
|
|
|
+// }
|
|
|
+// void timer_init(void)
|
|
|
+// {
|
|
|
+// // const esp_timer_create_args_t periodic_timer_args = {
|
|
|
+// // .callback = &periodic_timer_callback,
|
|
|
+// // /* name is optional, but may help identify the timer when debugging */
|
|
|
+// // .name = "periodic"
|
|
|
+// // };
|
|
|
+
|
|
|
+// // ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
|
|
|
+// // /* The timer has been created but is not running yet */
|
|
|
+
|
|
|
+// // ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, 1*1000*1000));
|
|
|
+
|
|
|
+// // lora timer
|
|
|
+// const esp_timer_create_args_t lora_timer_args = {
|
|
|
+// .callback = &lora_timer_callback,
|
|
|
+// /* argument specified here will be passed to timer callback function */
|
|
|
+// .name = "one-shot"};
|
|
|
+// ESP_ERROR_CHECK(esp_timer_create(&lora_timer_args, &lora_timer));
|
|
|
+// }
|
|
|
// void yc_timer_restart(void)
|
|
|
// {
|
|
|
// ESP_LOGI(LOG_TAG,"timer restart");
|
|
@@ -3084,91 +3102,91 @@ void lora_timer_restart(void)
|
|
|
|
|
|
#if 1
|
|
|
|
|
|
-/*********************************************************************************
|
|
|
- * function : analysis_protocol
|
|
|
- * Description : lora 接受数据解析函数
|
|
|
- * Input :
|
|
|
- * Output :
|
|
|
- * Author : 祁鑫 Data : 2023 9.18
|
|
|
- **********************************************************************************/
|
|
|
-void analysis_protocol(char *result, int len)
|
|
|
-{
|
|
|
- int index = 0;
|
|
|
- int length = 0;
|
|
|
-
|
|
|
- int count = len;
|
|
|
+// /*********************************************************************************
|
|
|
+// * function : analysis_protocol
|
|
|
+// * Description : lora 接受数据解析函数
|
|
|
+// * Input :
|
|
|
+// * Output :
|
|
|
+// * Author : 祁鑫 Data : 2023 9.18
|
|
|
+// **********************************************************************************/
|
|
|
+// void analysis_protocol(char *result, int len)
|
|
|
+// {
|
|
|
+// int index = 0;
|
|
|
+// int length = 0;
|
|
|
|
|
|
- int num = 0;
|
|
|
+// int count = len;
|
|
|
|
|
|
- while (count)
|
|
|
- {
|
|
|
-
|
|
|
- if (((result[index + 2]) == 0x5A) && ((result[index + 3]) == 0x51))
|
|
|
- {
|
|
|
- length = ((result[index]) << 8) | ((result[index + 1]));
|
|
|
- num++;
|
|
|
- printf("num =%d,length=%d\r\n", num, length);
|
|
|
+// int num = 0;
|
|
|
|
|
|
-#if 1
|
|
|
- for (int i = 0; i < length; i++)
|
|
|
- {
|
|
|
- printf("%02x", result[index + 2 + i]);
|
|
|
- }
|
|
|
-#endif
|
|
|
- printf("\r\n");
|
|
|
-
|
|
|
- // 匹配mac地址 //计算校验和
|
|
|
- if (
|
|
|
- (Machine_info.mac_addr[0] == (result[index + 5])) &&
|
|
|
- (Machine_info.mac_addr[1] == (result[index + 6])) &&
|
|
|
- (Machine_info.mac_addr[2] == (result[index + 7])) &&
|
|
|
- (Machine_info.mac_addr[3] == (result[index + 8])) &&
|
|
|
- (Machine_info.mac_addr[4] == (result[index + 9])) &&
|
|
|
- (Machine_info.mac_addr[5] == (result[index + 10])))
|
|
|
- {
|
|
|
-
|
|
|
- // mac地址匹配
|
|
|
- printf("mac check ok\r\n");
|
|
|
- // packetparsing((unsigned char *)&result[index+2]); //16进制解析数据
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- printf("mac = %02x%02x%02x%02x%02x%02x\r\n",
|
|
|
- result[index + 5],
|
|
|
- result[index + 6],
|
|
|
- result[index + 7],
|
|
|
- result[index + 8],
|
|
|
- result[index + 9],
|
|
|
- result[index + 10]);
|
|
|
- printf("device mac = %02x%02x%02x%02x%02x%02x\r\n",
|
|
|
- Machine_info.mac_addr[0],
|
|
|
- Machine_info.mac_addr[1],
|
|
|
- Machine_info.mac_addr[2],
|
|
|
- Machine_info.mac_addr[3],
|
|
|
- Machine_info.mac_addr[4],
|
|
|
- Machine_info.mac_addr[5]);
|
|
|
- // mac地址匹配
|
|
|
- printf("mac check fail\r\n");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- {
|
|
|
- index++;
|
|
|
- }
|
|
|
+// while (count)
|
|
|
+// {
|
|
|
|
|
|
- count--;
|
|
|
- }
|
|
|
- // printf("num =%d\r\n",num);
|
|
|
+// if (((result[index + 2]) == 0x5A) && ((result[index + 3]) == 0x51))
|
|
|
+// {
|
|
|
+// length = ((result[index]) << 8) | ((result[index + 1]));
|
|
|
+// num++;
|
|
|
+// printf("num =%d,length=%d\r\n", num, length);
|
|
|
+
|
|
|
+// #if 1
|
|
|
+// for (int i = 0; i < length; i++)
|
|
|
+// {
|
|
|
+// printf("%02x", result[index + 2 + i]);
|
|
|
+// }
|
|
|
+// #endif
|
|
|
+// printf("\r\n");
|
|
|
+
|
|
|
+// // 匹配mac地址 //计算校验和
|
|
|
+// if (
|
|
|
+// (Machine_info.mac_addr[0] == (result[index + 5])) &&
|
|
|
+// (Machine_info.mac_addr[1] == (result[index + 6])) &&
|
|
|
+// (Machine_info.mac_addr[2] == (result[index + 7])) &&
|
|
|
+// (Machine_info.mac_addr[3] == (result[index + 8])) &&
|
|
|
+// (Machine_info.mac_addr[4] == (result[index + 9])) &&
|
|
|
+// (Machine_info.mac_addr[5] == (result[index + 10])))
|
|
|
+// {
|
|
|
+
|
|
|
+// // mac地址匹配
|
|
|
+// printf("mac check ok\r\n");
|
|
|
+// // packetparsing((unsigned char *)&result[index+2]); //16进制解析数据
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// printf("mac = %02x%02x%02x%02x%02x%02x\r\n",
|
|
|
+// result[index + 5],
|
|
|
+// result[index + 6],
|
|
|
+// result[index + 7],
|
|
|
+// result[index + 8],
|
|
|
+// result[index + 9],
|
|
|
+// result[index + 10]);
|
|
|
+// printf("device mac = %02x%02x%02x%02x%02x%02x\r\n",
|
|
|
+// Machine_info.mac_addr[0],
|
|
|
+// Machine_info.mac_addr[1],
|
|
|
+// Machine_info.mac_addr[2],
|
|
|
+// Machine_info.mac_addr[3],
|
|
|
+// Machine_info.mac_addr[4],
|
|
|
+// Machine_info.mac_addr[5]);
|
|
|
+// // mac地址匹配
|
|
|
+// printf("mac check fail\r\n");
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// {
|
|
|
+// index++;
|
|
|
+// }
|
|
|
+
|
|
|
+// count--;
|
|
|
+// }
|
|
|
+// // printf("num =%d\r\n",num);
|
|
|
|
|
|
-#if 0
|
|
|
- if(left_display_refresh == true)
|
|
|
- {
|
|
|
- left_display_refresh = false;
|
|
|
- PIC_display((unsigned char *)dspbuf_left);
|
|
|
- }
|
|
|
- reflashdfpr(dspbuf);
|
|
|
-#endif
|
|
|
-}
|
|
|
+// #if 0
|
|
|
+// if(left_display_refresh == true)
|
|
|
+// {
|
|
|
+// left_display_refresh = false;
|
|
|
+// PIC_display((unsigned char *)dspbuf_left);
|
|
|
+// }
|
|
|
+// reflashdfpr(dspbuf);
|
|
|
+// #endif
|
|
|
+// }
|
|
|
|
|
|
/*********************************************************************************
|
|
|
* function : selectionSort
|