一次多个 HTTP GET ESP8266
multiple HTTP GET in one go ESP8266
我不知道如何一次性发送数据。这是一些代码。
好吧,我问的原因是同时发送它会延迟一点。
我确实看到有人发布了一段代码的其他主题,但那没有用。
void handleRoot()
{
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void handleFORESTTEMPERATURE() {
String ForrestTemperatureDev = String(ForestTemperature, 1);
server.send(200, "text/plane", ForestTemperatureDev); //Send ADC value only to client ajax request
}
void handleFORESTPRESSURE() {
String ForrestPressureDev = String(ForestPressure);
server.send(200, "text/plane", ForrestPressureDev); //Send ADC value only to client ajax request
}
void handleFORESTHUMIDITY() {
String ForrestHumidityDev = String(ForestHumidity);
server.send(200, "text/plane", ForestHumidityDev); //Send ADC value only to client ajax request
}
server.on("/readFORESTPRESSURE", handleFORESTPRESSURE);
server.on("/readFORESTTEMPERATURE", handleFORESTTEMPERATURE);
server.on("/readFORESTHUMIDITY", handleFORESTHUMIDITY);
server.on("/readFORESTWEATHERSTATUS", handleFORESTWEATHERSTATUS);
当请求 \readALL
时,这样的事情会发送所有三个值,并用 ;
分隔。这三个值可以在接收应用程序的 ;
上拆分。使用 JSON 会稍微多一些工作。
注意 1:未经测试,我只是输入,但您明白了。
注2:是text/plain
,不是text/plane
。
void handleRoot() {
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void handleFORESTTEMPERATURE() {
String ForrestTemperatureDev = String(ForestTemperature, 1);
server.send(200, "text/plain", ForestTemperatureDev); //Send ADC value only to client ajax request
}
void handleFORESTPRESSURE() {
String ForrestPressureDev = String(ForestPressure);
server.send(200, "text/plain", ForrestPressureDev); //Send ADC value only to client ajax request
}
void handleFORESTHUMIDITY() {
String ForrestHumidityDev = String(ForestHumidity);
server.send(200, "text/plain", ForestHumidityDev); //Send ADC value only to client ajax request
}
void handleALL() {
String AllDev = String(ForestTemperature, 1) + ";" + String(ForestPressure) + ";" + String(ForestHumidity);
server.send(200, "text/plain", AllDev); //Send ADC values only to client ajax request
}
server.on("/readFORESTPRESSURE", handleFORESTPRESSURE);
server.on("/readFORESTTEMPERATURE", handleFORESTTEMPERATURE);
server.on("/readFORESTHUMIDITY", handleFORESTHUMIDITY);
server.on("/readFORESTWEATHERSTATUS", handleFORESTWEATHERSTATUS);
server.on("/readALL", handleALL);
我不知道如何一次性发送数据。这是一些代码。 好吧,我问的原因是同时发送它会延迟一点。
我确实看到有人发布了一段代码的其他主题,但那没有用。
void handleRoot()
{
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void handleFORESTTEMPERATURE() {
String ForrestTemperatureDev = String(ForestTemperature, 1);
server.send(200, "text/plane", ForestTemperatureDev); //Send ADC value only to client ajax request
}
void handleFORESTPRESSURE() {
String ForrestPressureDev = String(ForestPressure);
server.send(200, "text/plane", ForrestPressureDev); //Send ADC value only to client ajax request
}
void handleFORESTHUMIDITY() {
String ForrestHumidityDev = String(ForestHumidity);
server.send(200, "text/plane", ForestHumidityDev); //Send ADC value only to client ajax request
}
server.on("/readFORESTPRESSURE", handleFORESTPRESSURE);
server.on("/readFORESTTEMPERATURE", handleFORESTTEMPERATURE);
server.on("/readFORESTHUMIDITY", handleFORESTHUMIDITY);
server.on("/readFORESTWEATHERSTATUS", handleFORESTWEATHERSTATUS);
当请求 \readALL
时,这样的事情会发送所有三个值,并用 ;
分隔。这三个值可以在接收应用程序的 ;
上拆分。使用 JSON 会稍微多一些工作。
注意 1:未经测试,我只是输入,但您明白了。
注2:是text/plain
,不是text/plane
。
void handleRoot() {
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void handleFORESTTEMPERATURE() {
String ForrestTemperatureDev = String(ForestTemperature, 1);
server.send(200, "text/plain", ForestTemperatureDev); //Send ADC value only to client ajax request
}
void handleFORESTPRESSURE() {
String ForrestPressureDev = String(ForestPressure);
server.send(200, "text/plain", ForrestPressureDev); //Send ADC value only to client ajax request
}
void handleFORESTHUMIDITY() {
String ForrestHumidityDev = String(ForestHumidity);
server.send(200, "text/plain", ForestHumidityDev); //Send ADC value only to client ajax request
}
void handleALL() {
String AllDev = String(ForestTemperature, 1) + ";" + String(ForestPressure) + ";" + String(ForestHumidity);
server.send(200, "text/plain", AllDev); //Send ADC values only to client ajax request
}
server.on("/readFORESTPRESSURE", handleFORESTPRESSURE);
server.on("/readFORESTTEMPERATURE", handleFORESTTEMPERATURE);
server.on("/readFORESTHUMIDITY", handleFORESTHUMIDITY);
server.on("/readFORESTWEATHERSTATUS", handleFORESTWEATHERSTATUS);
server.on("/readALL", handleALL);