提交
This commit is contained in:
@ -6,15 +6,15 @@ String myHttpServer::getnetData()
|
||||
{
|
||||
if (!isinit)
|
||||
{
|
||||
return "fail";
|
||||
return "1989-03-27 00:00:01";
|
||||
}
|
||||
|
||||
//http->beginRequest();
|
||||
int timetryget = 0;
|
||||
labelloop:
|
||||
write_log(log_path,100,"http->get11111");
|
||||
// write_log(log_path,100,"http->get11111");
|
||||
|
||||
int err = http1->get("/weather/php/Date.php");
|
||||
int err = http1->get(Http_Date_Path);
|
||||
if (err != 0)
|
||||
{
|
||||
// SerialMon.println(F("Date failed to connect"));
|
||||
@ -23,55 +23,57 @@ String myHttpServer::getnetData()
|
||||
write_log(log_path,100,"Date failed to connect"+String(err));
|
||||
vTaskDelay(10000);
|
||||
|
||||
esp_restart();
|
||||
return "";
|
||||
|
||||
return "1989-03-27 00:00:01";
|
||||
esp_restart();
|
||||
}
|
||||
write_log(log_path,100,"http->responseStatusCode222");
|
||||
// write_log(log_path,100,"http->responseStatusCode222");
|
||||
int status = http1->responseStatusCode();
|
||||
if (!status)
|
||||
{
|
||||
vTaskDelay(10000);
|
||||
|
||||
return "";
|
||||
return "1989-03-27 00:00:01";
|
||||
}
|
||||
|
||||
// SerialMon.println(F("Response Headers:"));
|
||||
write_log(log_path,100,"http->headerAvailable333");
|
||||
// write_log(log_path,100,"http->headerAvailable333");
|
||||
int times_try = 0;
|
||||
while (http1->headerAvailable())
|
||||
{
|
||||
|
||||
if(times_try > 50)
|
||||
{
|
||||
write_log(log_path,100,"http->headerAvailable failed ...");
|
||||
// write_log(log_path,100,"http->headerAvailable failed ...");
|
||||
http1->stop();
|
||||
if (timetryget++ > 5)
|
||||
{
|
||||
write_log(log_path,100,"http->headerAvailable failed than 5 times ... return error");
|
||||
return "error";
|
||||
// write_log(log_path,100,"http->headerAvailable failed than 5 times ... return error");
|
||||
return "1989-03-27 00:00:01";
|
||||
}
|
||||
|
||||
|
||||
goto labelloop;
|
||||
}
|
||||
write_log(log_path,100,"http->readHeaderName");
|
||||
// write_log(log_path,100,"http->readHeaderName");
|
||||
String headerName = http1->readHeaderName();
|
||||
write_log(log_path,100,"http->readHeaderValue");
|
||||
// write_log(log_path,100,"http->readHeaderValue");
|
||||
String headerValue = http1->readHeaderValue();
|
||||
write_log(log_path,100,String(times_try)+"http->headerName "+headerName);
|
||||
write_log(log_path,100,String(times_try)+"http->headerValue "+headerValue);
|
||||
// write_log(log_path,100,String(times_try)+"http->headerName "+headerName);
|
||||
// write_log(log_path,100,String(times_try)+"http->headerValue "+headerValue);
|
||||
// SerialMon.println("Date: " + headerName + " : " + headerValue);
|
||||
vTaskDelay(100);
|
||||
times_try++;
|
||||
}
|
||||
write_log(log_path,100,"http->isResponseChunked4444");
|
||||
// write_log(log_path,100,"http->isResponseChunked4444");
|
||||
if (http1->isResponseChunked())
|
||||
{
|
||||
// SerialMon.println(F("Date The response is chunked"));
|
||||
}
|
||||
write_log(log_path,100,"http->responseBody555");
|
||||
|
||||
String body = http1->responseBody();
|
||||
http1->stop();
|
||||
write_log(log_path,100,body);
|
||||
return body;
|
||||
}
|
||||
|
||||
@ -81,7 +83,7 @@ bool myHttpServer::UpdateData(String path, char *str, size_t lenth, String Conte
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Serial.println("start put data to "+path);
|
||||
http1->beginRequest();
|
||||
http1->post(path);
|
||||
if (Contenttype != "")
|
||||
@ -211,21 +213,21 @@ void myHttpServer::ReuploadData(String path, String webpath, String content )
|
||||
|
||||
void Reuploaddata1(void *) //重新上传数据
|
||||
{
|
||||
myhttpserver->ReuploadData("/down", "/weather/php/SpectralDataUp.php");
|
||||
myhttpserver->ReuploadData("/up", "/weather/php/SpectralDataUp.php");
|
||||
myhttpserver->ReuploadData("/other", "/weather/php/WindsensorUp.php", "application/json");
|
||||
myhttpserver->ReuploadData("/down", Http_Sepctral_Path);
|
||||
myhttpserver->ReuploadData("/up", Http_Sepctral_Path);
|
||||
myhttpserver->ReuploadData("/other", Http_Wind_Path, "application/json");
|
||||
}
|
||||
void Reuploaddata2() //重新上传数据
|
||||
{
|
||||
myhttpserver->ReuploadData("/down", "/weather/php/SpectralDataUp.php");
|
||||
myhttpserver->ReuploadData("/up", "/weather/php/SpectralDataUp.php");
|
||||
myhttpserver->ReuploadData("/other", "/weather/php/WindsensorUp.php", "application/json");
|
||||
myhttpserver->ReuploadData("/down", Http_Sepctral_Path);
|
||||
myhttpserver->ReuploadData("/up", Http_Sepctral_Path);
|
||||
myhttpserver->ReuploadData("/other", Http_Wind_Path, "application/json");
|
||||
}
|
||||
|
||||
void myHttpServer::setup1(Client &client,char * serveradd)
|
||||
{
|
||||
|
||||
http1 = new HttpClient(client, serveradd,80);
|
||||
http1 = new HttpClient(client, serveradd,800);
|
||||
|
||||
isinit = true;
|
||||
log_path = "/httplog.txt";
|
||||
|
||||
@ -7,6 +7,17 @@
|
||||
#include "log.h"
|
||||
void Reuploaddata1(void *);
|
||||
void Reuploaddata2() ;
|
||||
static String Http_Sepctral_Path="/DDY/weather/php/SpectralDataUp.php";
|
||||
|
||||
static String Http_Wind_Path="/DDY/weather/php/WindsensorUp.php";
|
||||
static String Http_Log_Path="/weather/php/log.php";
|
||||
static String Http_Sensorinfo_UP_Path="/weather/php/SensorInfoUp.php";
|
||||
static String Http_Station_GPS_INfo_Path="/weather/php/StationGPSinfo.php";
|
||||
static String Http_Date_Path="/weather/php/Date.php";
|
||||
static String Http_Up_Version_Path="/weather/php/upVserion.php";
|
||||
static String Http_Get_Version_Path="/weather/php/GetVserion.php";
|
||||
static String Http_Get_MD5_Value_Path="/weather/php/GetMD5Value.php";
|
||||
static String Http_Firmware_Base_Path="/weather/firmware/esp32/firmware_";
|
||||
class myHttpServer
|
||||
{
|
||||
public:
|
||||
|
||||
@ -165,6 +165,7 @@ void SensorOptoSky::GetOneDate(int msc) {
|
||||
IS1Sensor.SendComment(SYNCHRONIZATION_GET_DATA,shutter,2);
|
||||
IS1Sensor.GetReturn(SYNCHRONIZATION_GET_DATA, lenthretrunl,msc);
|
||||
memcpy(DATABUFF, IS1Sensor.result + 1, SensorInfo.BandNum * 2);
|
||||
//memcpy(DATABUFF, IS1Sensor.result , SensorInfo.BandNum * 2);
|
||||
shortLittletoBiG(DATABUFF, SensorInfo.BandNum);
|
||||
}
|
||||
|
||||
|
||||
40
src/main.cpp
40
src/main.cpp
@ -90,7 +90,7 @@ void printbytcp(String str)
|
||||
int lennn=str.length();
|
||||
char *temp = new char[lennn];
|
||||
memcpy(temp, str.c_str(), str.length());
|
||||
bool flagsucc = httpserver->UpdateData("/weather/php/log.php", temp, lennn);
|
||||
bool flagsucc = httpserver->UpdateData(Http_Log_Path, temp, lennn);
|
||||
vTaskDelay(3000);
|
||||
delete[] temp;
|
||||
|
||||
@ -157,10 +157,11 @@ String get_GPS(void)
|
||||
// {
|
||||
// return gsmmanger->modem->getNetworkTime;
|
||||
// }
|
||||
#include "esp_task_wdt.h"
|
||||
void setup()
|
||||
{
|
||||
|
||||
|
||||
esp_task_wdt_init(20, true);
|
||||
Serial.begin(115200);
|
||||
Serial.println("start");
|
||||
//return;
|
||||
@ -206,7 +207,8 @@ void setup()
|
||||
{
|
||||
Serial.println("start httpserver");
|
||||
|
||||
httpserver->setup1(*gsmmanger->client, "82.156.1.111");
|
||||
// httpserver->setup1(*gsmmanger->client, "82.156.1.111");
|
||||
httpserver->setup1(*gsmmanger->client, "iot.iris-rs.cn");
|
||||
// httpserver->http1=new HttpClient(*gsmmanger->client, "82.156.1.111");
|
||||
|
||||
|
||||
@ -282,7 +284,7 @@ void setup()
|
||||
String Upheader = StationID + "##" + SensorID + "##" + String(IS1Sensor.SensorInfo.BandNum) + "##"
|
||||
+ String(IS1Sensor.SensorInfo.a1,9) + ":" + String(IS1Sensor.SensorInfo.a2,9) + ":" + String(IS1Sensor.SensorInfo.a3,9) + ":" + String(IS1Sensor.SensorInfo.a4,9)+"##"+ProgrameUper->CurrentVersion;
|
||||
Serial.println(Upheader);
|
||||
httpserver->UpdateData("/weather/php/SensorInfoUp.php", (char *)Upheader.c_str(), Upheader.length());
|
||||
httpserver->UpdateData(Http_Sensorinfo_UP_Path, (char *)Upheader.c_str(), Upheader.length());
|
||||
write_log(log_path,10,"IS1 Init ....");
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -303,8 +305,8 @@ void loop()
|
||||
/////////////////NOW/////////////////////
|
||||
// String tem = fenge(Date," ",0);
|
||||
// log_path = "/log/"+tem+".txt";
|
||||
write_log(log_path,10,"");
|
||||
write_log(log_path,10,Date);
|
||||
//write_log(log_path,10,"");
|
||||
//write_log(log_path,10,Date);
|
||||
|
||||
String yuliang = String(myslave.getYuliang());
|
||||
delay(1010);
|
||||
@ -371,7 +373,7 @@ void loop()
|
||||
int lennn = gpsbac.length();
|
||||
char *temp = new char[lennn];
|
||||
memcpy(temp, gpsbac.c_str(), gpsbac.length());
|
||||
bool flagsucc = httpserver->UpdateData("/weather/php/StationGPSinfo.php", temp, lennn);
|
||||
bool flagsucc = httpserver->UpdateData(Http_Station_GPS_INfo_Path, temp, lennn);
|
||||
|
||||
if (!flagsucc)
|
||||
{
|
||||
@ -440,8 +442,21 @@ void loop()
|
||||
{
|
||||
//temp[Upheader.length()+i]=str[i];
|
||||
}
|
||||
Serial.println("lenth of up data is "+String(lennn));
|
||||
memcpy(temp + Upheader.length(), IS1Sensor.UpData,IS1Sensor.SensorInfo.BandNum * 2);
|
||||
bool flagsucc = httpserver->UpdateData("/weather/php/SpectralDataUp.php", temp, lennn);
|
||||
bool flagsucc = httpserver->UpdateData(Http_Sepctral_Path, temp, lennn);
|
||||
//输出前100个字节 字符
|
||||
|
||||
Serial.println("temp is :");
|
||||
Serial.write(temp, 100);
|
||||
|
||||
for (int i = 0; i < 100 && i < lennn; i++)
|
||||
{
|
||||
Serial.print(temp[i], HEX);
|
||||
Serial.print(" ");
|
||||
}
|
||||
|
||||
|
||||
vTaskDelay(3000);
|
||||
if (!flagsucc)
|
||||
{
|
||||
@ -470,9 +485,14 @@ void loop()
|
||||
{
|
||||
// temp[Downheader.length()+i]=str[i];
|
||||
}
|
||||
Serial.println("lenth of down data is "+String(lennn));
|
||||
memcpy(temp + Downheader.length(), IS1Sensor.DownData,IS1Sensor.SensorInfo.BandNum * 2);
|
||||
flagsucc = httpserver->UpdateData("/weather/php/SpectralDataUp.php", temp, lennn);
|
||||
flagsucc = httpserver->UpdateData(Http_Sepctral_Path, temp, lennn);
|
||||
vTaskDelay(3000);
|
||||
//输出前100个
|
||||
Serial.println("temp is :");
|
||||
Serial.write(temp, 100);
|
||||
|
||||
|
||||
if (!flagsucc)
|
||||
{
|
||||
@ -491,7 +511,7 @@ void loop()
|
||||
temp = new char[lennn];
|
||||
memcpy(temp, senderID.c_str(), senderID.length());
|
||||
memcpy(temp + senderID.length(), windret + 3, 12);
|
||||
flagsucc = httpserver->UpdateData("/weather/php/WindsensorUp.php", temp, lennn, "application/json");
|
||||
flagsucc = httpserver->UpdateData(Http_Wind_Path, temp, lennn, "application/json");
|
||||
vTaskDelay(3000);
|
||||
if (!flagsucc)
|
||||
{
|
||||
|
||||
@ -88,7 +88,7 @@ bool OptoSky::GetReturn(byte id,int &lenth,int timewaitbefor)
|
||||
|
||||
return false;//<2F>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>0<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>0<EFBFBD>8<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>5<EFBFBD>3<EFBFBD>1<EFBFBD>2<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7<EFBFBD>1<EFBFBD>7
|
||||
}
|
||||
memcpy(datatoget,datatoget+5,lenth-1);
|
||||
memcpy(datatoget,datatoget+5,lenth-5);
|
||||
lenth=lenth-6;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "updatebyme.h"
|
||||
#include "SDmanger.h"
|
||||
#include "Myhttpserver.h"
|
||||
void UpDateClassByme::performUpdate(Stream &updateSource, size_t updateSize)
|
||||
{
|
||||
if (Update.begin(updateSize))
|
||||
@ -41,7 +42,7 @@ void UpDateClassByme::performUpdate(Stream &updateSource, size_t updateSize)
|
||||
|
||||
size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
{
|
||||
String url="/weather/firmware/esp32/firmware_"+version+".bin";
|
||||
String url=Http_Firmware_Base_Path+version+".bin";
|
||||
int err = http->get(url.c_str());
|
||||
if (err != 0)
|
||||
{
|
||||
@ -114,13 +115,13 @@ void UpDateClassByme::initme(String Version)
|
||||
}
|
||||
void UpDateClassByme::updateversion()
|
||||
{
|
||||
String Targetversion=GetValueFromNet("/weather/php/upVserion.php",StationID+":"+CurrentVersion);
|
||||
String Targetversion=GetValueFromNet(Http_Up_Version_Path,StationID+":"+CurrentVersion);
|
||||
}
|
||||
bool UpDateClassByme::CheckAndUpdate()
|
||||
{
|
||||
|
||||
|
||||
String Targetversion=GetValueFromNet("/weather/php/GetVserion.php",StationID);
|
||||
String Targetversion=GetValueFromNet(Http_Get_Version_Path,StationID);
|
||||
if ( Targetversion=="0"||Targetversion==CurrentVersion||Targetversion=="")
|
||||
{
|
||||
return true;
|
||||
@ -136,7 +137,7 @@ bool UpDateClassByme::CheckAndUpdate()
|
||||
}
|
||||
Serial.println("count download is:"+String(countdownload1));
|
||||
|
||||
String MD5=GetValueFromNet("/weather/php/GetMD5Value.php",Targetversion);
|
||||
String MD5=GetValueFromNet(Http_Get_MD5_Value_Path,Targetversion);
|
||||
|
||||
if (MD5=="0")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user