V2.0.4
This commit is contained in:
@ -424,16 +424,19 @@ void Update_firmware(Stream &updateSource, size_t updateSize)
|
||||
size_t http_download(String url)
|
||||
{
|
||||
// String url="/gaoguangpu/firmware/esp32/firmware_"+version+".bin";
|
||||
write_log(log_path,"start http_download",10);
|
||||
int err = http->get(url.c_str());
|
||||
if (err != 0)
|
||||
{
|
||||
//Serial.println(F("Date failed to connect"));
|
||||
write_log(log_path,"Date failed to connect",10);
|
||||
vTaskDelay(10000);
|
||||
return 0;
|
||||
}
|
||||
int status = http->responseStatusCode();
|
||||
if (!status)
|
||||
{
|
||||
write_log(log_path,"http->responseStatusCode false",10);
|
||||
vTaskDelay(10000);
|
||||
return 0;
|
||||
}
|
||||
@ -477,7 +480,7 @@ size_t http_download(String url)
|
||||
file.close();
|
||||
|
||||
http->stop();
|
||||
|
||||
write_log(log_path,"download finish",10);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -505,6 +508,7 @@ bool check_file_ota(String MD5)
|
||||
else
|
||||
{
|
||||
//Serial.println("md5 error");
|
||||
write_log(log_path,"md5 error",10);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -519,8 +523,10 @@ void http_OTA(String url,String MD5)
|
||||
vTaskDelay(1);
|
||||
}
|
||||
|
||||
write_log(log_path,"wait mqtt stop",10);
|
||||
xEventGroupSetBits(http_event_group, mqtt_stop_bit);
|
||||
xEventGroupWaitBits(http_event_group, Http_start_bit,pdTRUE, pdFALSE,portMAX_DELAY);
|
||||
write_log(log_path,"start http_OTA",10);
|
||||
uint32_t count = http_download(url);
|
||||
if(count != 0) check_file_ota(MD5);
|
||||
|
||||
|
||||
46
src/main.cpp
46
src/main.cpp
@ -213,6 +213,18 @@ void setup()
|
||||
|
||||
// 初始化DS18b20
|
||||
uint8_t temp_number = DS18b20_init();
|
||||
// while(1)
|
||||
// {
|
||||
// ////排序时使用
|
||||
// float temp[8];
|
||||
// getall_temp(temp);
|
||||
|
||||
// for(int i = 0;i<8;i++)
|
||||
// {
|
||||
// Serial.printf("temp[%d]: %f\n",i + 1,temp[i]);
|
||||
// }
|
||||
// vTaskDelay(500);
|
||||
// }
|
||||
|
||||
//ADC电压采集初始化
|
||||
// adc_init();
|
||||
@ -234,7 +246,7 @@ void setup()
|
||||
write_log(log_path," ",20);
|
||||
write_log(log_path,"===============================================================",20);
|
||||
write_log(log_path,time,20);
|
||||
write_log(log_path,"system start",20);
|
||||
write_log(log_path,"system start !",20);
|
||||
|
||||
|
||||
|
||||
@ -263,7 +275,7 @@ void setup()
|
||||
// is11Sensor->guangpu_bochang.a2 = 0.000000000;
|
||||
|
||||
sys_info_init();
|
||||
|
||||
sys_sd_doc["firmware"] = "V2.0.4";
|
||||
// dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
|
||||
// dingbiao_init("/dingbiao/dingbiao_up_offset.bin");
|
||||
// dingbiao_init("/dingbiao/dingbiao_down_gain.bin");
|
||||
@ -309,6 +321,13 @@ void setup()
|
||||
is11Sensor->guangpu_bochang.b1 = is11Sensor->SensorInfo.a2;
|
||||
is11Sensor->guangpu_bochang.b2 = is11Sensor->SensorInfo.a3;
|
||||
is11Sensor->guangpu_bochang.b3 = is11Sensor->SensorInfo.a4;
|
||||
|
||||
sys_sd_doc["bochangxishu"]["a0"] = is11Sensor->guangpu_bochang.a0;
|
||||
sys_sd_doc["bochangxishu"]["a1"] = is11Sensor->guangpu_bochang.a1;
|
||||
sys_sd_doc["bochangxishu"]["a2"] = is11Sensor->guangpu_bochang.a2;
|
||||
sys_sd_doc["bochangxishu"]["a3"] = is11Sensor->guangpu_bochang.a3;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -328,7 +347,7 @@ void setup()
|
||||
|
||||
|
||||
xTaskCreatePinnedToCore(task_4G_mode, "task_4G_mode",1024*23,NULL, 1,&A4G_Handler, 1);
|
||||
xTaskCreatePinnedToCore(OTA_task , "OTA_task",1024*10 ,NULL, 1,&OTA_Handler, 1);
|
||||
xTaskCreatePinnedToCore(OTA_task , "OTA_task",1024*4 ,NULL, 1,&OTA_Handler, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -780,7 +799,8 @@ void task_4G_mode(void *pvParameters)
|
||||
write_log(log_path,"task 4G mode",10);
|
||||
while (1)
|
||||
{
|
||||
Serial.println("task_4G_mode 11");
|
||||
// Serial.println("task_4G_mode 11");
|
||||
write_log(log_path,"task_4G_mode 11",10);
|
||||
// vTaskDelay(1000 * 10);
|
||||
bool warn_sta = false;
|
||||
float temperature[8];
|
||||
@ -968,12 +988,22 @@ void task_4G_mode(void *pvParameters)
|
||||
|
||||
void OTA_task(void *pvParameters)
|
||||
{
|
||||
vTaskDelay(10);
|
||||
write_log(log_path,"ota task start",10);
|
||||
while (1)
|
||||
{
|
||||
xEventGroupWaitBits(Main_EventGroup, OTA_BIT, pdTRUE, pdFALSE, portMAX_DELAY);
|
||||
vTaskDelay(100);
|
||||
vTaskSuspend(Task0_Handler);
|
||||
vTaskSuspend(Task1_Handler);
|
||||
|
||||
vTaskSuspend(A4G_Handler);
|
||||
|
||||
String url = sys_sd_doc["version_url"];
|
||||
String MD5 = sys_sd_doc["MD5"];
|
||||
write_log(log_path,"ota start",10);
|
||||
write_log(log_path,"ota url: " + url,10);
|
||||
write_log(log_path,"ota MD5: " + MD5,10);
|
||||
http_OTA(url, MD5);
|
||||
}
|
||||
}
|
||||
@ -995,10 +1025,10 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
||||
// write_log(log_path,"ret: " + String(ret),10);
|
||||
|
||||
// Serial.println("read_buf: " + String(read_buf,data_length));
|
||||
for (int i = 0; i < data_length; i++)
|
||||
{
|
||||
Serial.printf("%02X ",read_buf[i]);
|
||||
}
|
||||
// for (int i = 0; i < data_length; i++)
|
||||
// {
|
||||
// Serial.printf("%02X ",read_buf[i]);
|
||||
// }
|
||||
|
||||
|
||||
if (ret > 0)
|
||||
|
||||
Reference in New Issue
Block a user