forked from esp8266/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test_ping fix test_millis_mm
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <Arduino.h> | ||
#include <BSTest.h> | ||
#include <ESP8266WiFi.h> | ||
|
||
#include <ping.h> | ||
|
||
BS_ENV_DECLARE(); | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.setDebugOutput(true); | ||
WiFi.persistent(false); | ||
WiFi.mode(WIFI_STA); | ||
WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); | ||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(500); | ||
} | ||
BS_RUN(Serial); | ||
} | ||
|
||
static struct ping_option po; | ||
static const uint32_t PING_COUNT = 5; | ||
static volatile uint32_t recv_count; | ||
static volatile uint32_t done_count; | ||
|
||
static void ping_recv(void* options, void* resp) | ||
{ | ||
(void)options; | ||
(void)resp; | ||
++recv_count; | ||
} | ||
|
||
static void ping_done(void* options, void* resp) | ||
{ | ||
(void)options; | ||
(void)resp; | ||
done_count = ((struct ping_resp*)resp)->total_count; | ||
} | ||
|
||
TEST_CASE("pings sent/answered", "[lwip]") | ||
{ | ||
IPAddress address; | ||
if (WiFi.hostByName(getenv("SERVER_IP"), address)) | ||
{ | ||
po.ip = address; | ||
po.count = PING_COUNT; | ||
po.coarse_time = 1; | ||
po.sent_function = &ping_done; | ||
po.recv_function = &ping_recv; | ||
ping_start(&po); | ||
delay((PING_COUNT+2)*1000); | ||
} | ||
REQUIRE(recv_count == PING_COUNT); | ||
REQUIRE(done_count == PING_COUNT); | ||
} | ||
|
||
void loop() | ||
{ | ||
} |