v2.0.2
This commit is contained in:
106
src/main.cpp
106
src/main.cpp
@ -157,8 +157,8 @@ bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype = ""
|
||||
|
||||
void setup()
|
||||
{
|
||||
sun_latitude = 39.5;
|
||||
sun_longitude = 117.6;
|
||||
sun_latitude = 39.0864;
|
||||
sun_longitude = 117.113055;
|
||||
// Serial2.begin(115200, SERIAL_8N1, SIMUART_RX, SIMUART_TX);
|
||||
//关闭光谱仪
|
||||
pinMode(36,OUTPUT);
|
||||
@ -169,12 +169,8 @@ void setup()
|
||||
vTaskDelay(1000);
|
||||
|
||||
Serial0.begin(115200);
|
||||
Serial.begin(115200);
|
||||
|
||||
// while (1)
|
||||
// {
|
||||
// Serial0.println("66666666666666666666666");
|
||||
// vTaskDelay(1000);
|
||||
// }
|
||||
|
||||
log_init();
|
||||
|
||||
@ -280,6 +276,19 @@ void setup()
|
||||
if(sys_sd_doc["status_4g"] == "open_4g")
|
||||
{
|
||||
gsmm_mqtt_init(STRSensorInfos_structure.serialnumber);
|
||||
// while (1)
|
||||
// {
|
||||
|
||||
// ////获取GPS
|
||||
// write_log(log_path,"test gps",10);
|
||||
// gps_struct gps_structure;
|
||||
// String gpsbac = get_GPS(&gps_structure);
|
||||
// write_log(log_path,gpsbac,10);
|
||||
// Serial.printf("time: %d-%d-%d %d:%d:%d\n",gps_structure.year,gps_structure.month,gps_structure.day,gps_structure.hour,gps_structure.minute,gps_structure.second);
|
||||
// Serial.printf("latitude: %d ,longitude : %d\n",gps_structure.latitude,gps_structure.longitude);
|
||||
|
||||
// vTaskDelay(1000);
|
||||
// }
|
||||
|
||||
xTaskCreatePinnedToCore(task_4G_mode, "task_4G_mode",1024*(20),NULL, 1,NULL, 1);
|
||||
xTaskCreatePinnedToCore(OTA_task, "OTA_task",1024*(10),NULL, 1,NULL, 1);
|
||||
@ -347,8 +356,9 @@ void Task0(void *pvParameters)
|
||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
{
|
||||
caiji_state = 2;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
is11Sensor->TakeOneJob();
|
||||
if (atuo_return == 1)
|
||||
{
|
||||
@ -360,8 +370,9 @@ void Task0(void *pvParameters)
|
||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
{
|
||||
caiji_state = 2;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
is11Sensor->TakeOneJob();
|
||||
if (atuo_return == 1)
|
||||
{
|
||||
@ -378,8 +389,9 @@ void Task0(void *pvParameters)
|
||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
{
|
||||
caiji_state = 2;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
is11Sensor->advanced_mode(advanced_direction,advanced_shutter_time,advanced_collect_times,advanced_remove_dark);
|
||||
uint_work_task0 = 100;
|
||||
break;
|
||||
@ -388,8 +400,9 @@ void Task0(void *pvParameters)
|
||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
{
|
||||
caiji_state = 2;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
is11Sensor->opt(advanced_direction);
|
||||
uint_work_task0 = 100;
|
||||
break;
|
||||
@ -398,8 +411,9 @@ void Task0(void *pvParameters)
|
||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
{
|
||||
caiji_state = 2;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
|
||||
is11Sensor->calculation(calculation_bochang1,calculation_bochang2);
|
||||
uint_work_task0 = 100;
|
||||
@ -536,7 +550,7 @@ void Task1(void *pvParameters)
|
||||
String path_b = "/gaugpu_data";
|
||||
for(int i=24;i<255 ;i++)
|
||||
{
|
||||
for (uint8_t j = 1; j < 13; i++)
|
||||
for (uint8_t j = 1; j < 13; j++)
|
||||
{
|
||||
String path_a = path_b + "/" +String(i)+ "/" +String(j);
|
||||
if(SD_MMC.exists(path_a))
|
||||
@ -641,8 +655,9 @@ void Task1(void *pvParameters)
|
||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
{
|
||||
caiji_mode = 0;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
}
|
||||
}
|
||||
vTaskDelay(1000 * 1);
|
||||
@ -721,7 +736,7 @@ void Task1(void *pvParameters)
|
||||
if(count == 10)
|
||||
{
|
||||
write_log(log_path,"temperature " + String(n) +":" + String(temperature[n]),20);
|
||||
count == 0;
|
||||
count = 0;
|
||||
}else
|
||||
write_log(log_path,"temperature " + String(n) +":" + String(temperature[n]),10);
|
||||
}
|
||||
@ -871,6 +886,7 @@ void task_4G_mode(void *pvParameters)
|
||||
doc_4G["temperature 7 : "] = temperature[7];
|
||||
break;
|
||||
}
|
||||
Serial.println("uptodate temperature " + String(n) +":" + String(temperature[n]));
|
||||
}
|
||||
if(warn_sta)
|
||||
{
|
||||
@ -913,6 +929,37 @@ void task_4G_mode(void *pvParameters)
|
||||
now.second = second;
|
||||
rtc.setDateTime(&now);
|
||||
}
|
||||
|
||||
////获取GPS
|
||||
gps_struct gps_structure;
|
||||
String gpsbac = get_GPS(&gps_structure);
|
||||
if(gpsbac == "-1") write_log(log_path,"no gps",10);
|
||||
else if(gpsbac != "-1")
|
||||
{
|
||||
|
||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
{
|
||||
sun_latitude = gps_structure.latitude;
|
||||
sun_longitude = gps_structure.longitude;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
|
||||
Serial.println("gps_structure.latitude " + String(gps_structure.latitude));
|
||||
Serial.println("gps_structure.longitude " + String(gps_structure.longitude));
|
||||
|
||||
// gps_structure.year = gps_structure.year - 2000;
|
||||
// if(now.year != gps_structure.year || now.month != gps_structure.month || now.day != gps_structure.day || now.hour != gps_structure.hour || (fabs(now.minute - net_structure.minute)>5 ))
|
||||
// {
|
||||
// now.year = gps_structure.year;
|
||||
// now.month = gps_structure.month;
|
||||
// now.day = gps_structure.day;
|
||||
// now.hour = gps_structure.hour;
|
||||
// now.minute = gps_structure.minute;
|
||||
// now.second = gps_structure.second;
|
||||
// // rtc.setDateTime(&now);
|
||||
// }
|
||||
// last_day = now.day;
|
||||
}
|
||||
}
|
||||
|
||||
float now_time = now.hour + now.minute/100;
|
||||
@ -955,6 +1002,9 @@ void task_4G_mode(void *pvParameters)
|
||||
vTaskDelay(10);
|
||||
UpdateData("/HyperspectralV2/DataUpload.php",data , sizeof(http_head) + sizeof(IS11_datastruct_fanshelv),HTTP_METHOD_POST);
|
||||
}
|
||||
Serial.println("http_head.lat " + String(http_head.lat));
|
||||
Serial.println("http_head.lon " + String(http_head.lon));
|
||||
|
||||
vTaskDelay(1000 * time_interval);
|
||||
}
|
||||
vTaskDelay(10);
|
||||
@ -1082,8 +1132,9 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
||||
if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
{
|
||||
caiji_mode = 1;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
uint8_t a = 0x01;
|
||||
send_lenth = IRIS_Protocol_Pack(0X62,1,&a,send_buff);
|
||||
|
||||
@ -1171,8 +1222,9 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
||||
calculation_bochang2 = b;
|
||||
|
||||
caiji_mode = 6;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
|
||||
// uint8_t dd = 0x01;
|
||||
is11Sensor->calculation_value = 0;
|
||||
@ -1208,6 +1260,7 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
||||
if(port_type == 1) wb485Serial.write(send_buff,send_lenth);
|
||||
else if(port_type == 2) mqtt_write(send_buff,send_lenth);
|
||||
|
||||
sys_sd_doc["GPS_mode"]== "manual";
|
||||
sys_sd_doc["latitude"] = sun_latitude;
|
||||
sys_sd_doc["longitude"] = sun_longitude;
|
||||
String send_str = "";
|
||||
@ -2444,8 +2497,9 @@ void json_command(uint8_t port_type)
|
||||
file.close();
|
||||
save = false;
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2544,12 +2598,16 @@ void sys_info_init()
|
||||
write_log(log_path,"servo_offset_angle_down" + String(a),10);
|
||||
servo_offset(a,0);
|
||||
|
||||
sys_sd_doc["latitude"] = doc["latitude"];
|
||||
sys_sd_doc["longitude"] = doc["longitude"];
|
||||
sun_latitude = doc["latitude"];
|
||||
sun_longitude = doc["longitude"];
|
||||
write_log(log_path,"latitude" + String(sun_latitude),10);
|
||||
write_log(log_path,"longitude" + String(sun_longitude),10);
|
||||
if(doc["GPS_mode"]== "manual")
|
||||
{
|
||||
sys_sd_doc["latitude"] = doc["latitude"];
|
||||
sys_sd_doc["longitude"] = doc["longitude"];
|
||||
sun_latitude = doc["latitude"];
|
||||
sun_longitude = doc["longitude"];
|
||||
write_log(log_path,"latitude" + String(sun_latitude),10);
|
||||
write_log(log_path,"longitude" + String(sun_longitude),10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
sys_sd_doc["bochangxishu"]["a0"] = STRSensorInfos_structure.a1;
|
||||
|
||||
Reference in New Issue
Block a user