mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
* help in makefile * fix some device tests, http_server is pending * fix webserver test, one test is disabled due to general python2->3 failure * remove debug strings * minimize diff * set reset method back to the default one on generic board * fix vcc range check from datasheet vcc is read as 2.9V here, datasheet says 2.5-3.6, old low limit was 3v * tell python to decode string
59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
#include <Arduino.h>
|
|
#include <ESP8266WiFi.h>
|
|
#include <ESP8266mDNS.h>
|
|
#include <WiFiClient.h>
|
|
#include <BSTest.h>
|
|
|
|
|
|
BS_ENV_DECLARE();
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
BS_RUN(Serial);
|
|
}
|
|
|
|
bool pretest()
|
|
{
|
|
WiFi.persistent(false);
|
|
WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS"));
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
delay(500);
|
|
}
|
|
MDNS.begin("esp8266-wfs-test");
|
|
return true;
|
|
}
|
|
|
|
TEST_CASE("Simple echo server", "[WiFiServer]")
|
|
{
|
|
const uint32_t timeout = 10000;
|
|
const uint16_t port = 5000;
|
|
const int maxRequests = 5;
|
|
const int minRequestLength = 128;
|
|
WiFiServer server(port);
|
|
server.begin();
|
|
auto start = millis();
|
|
|
|
int replyCount = 0;
|
|
while (millis() - start < timeout) {
|
|
MDNS.update();
|
|
WiFiClient client = server.available();
|
|
if (!client) {
|
|
continue;
|
|
}
|
|
String request = client.readStringUntil('\n');
|
|
CHECK(request.length() >= minRequestLength);
|
|
client.print(request);
|
|
client.print('\n');
|
|
if (++replyCount == maxRequests) {
|
|
break;
|
|
}
|
|
}
|
|
CHECK(replyCount == maxRequests);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
}
|
|
|