-
Notifications
You must be signed in to change notification settings - Fork 13.3k
/
Copy pathtest_WiFiClient.ino
57 lines (48 loc) · 1.07 KB
/
test_WiFiClient.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <Arduino.h>
#include <BSTest.h>
#include <test_config.h>
#include <ESP8266WiFi.h>
#include <Ticker.h>
extern "C" {
#include "user_interface.h"
}
BS_ENV_DECLARE();
void setup()
{
Serial.begin(115200);
Serial.setDebugOutput(true);
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
WiFi.begin(STA_SSID, STA_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
BS_RUN(Serial);
}
static void stopAll()
{
WiFiClient::stopAll();
}
static void disconnectWiFI()
{
wifi_station_disconnect();
}
/* Some IP address that we can try connecting to, and expect a timeout */
#define UNREACHABLE_IP "192.168.255.255"
TEST_CASE("WiFiClient::stopAll during WiFiClient::connect", "[wificlient]")
{
WiFiClient client;
Ticker t;
t.once_ms(500, &stopAll);
REQUIRE(client.connect(UNREACHABLE_IP, 1024) == 0);
}
TEST_CASE("WiFi disconnect during WiFiClient::connect", "[wificlient]")
{
WiFiClient client;
Ticker t;
t.once_ms(500, &disconnectWiFI);
REQUIRE(client.connect(UNREACHABLE_IP, 1024) == 0);
}
void loop()
{
}