1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

device test updates (#5455)

add test_ping
fix test_millis_mm
This commit is contained in:
liebman 2018-12-08 16:22:29 -08:00 committed by Develo
parent 4d15590096
commit 0550ccd46b
2 changed files with 60 additions and 1 deletions

View File

@ -14,7 +14,6 @@
extern "C" { // SDK functions for Arduino IDE access extern "C" { // SDK functions for Arduino IDE access
#include "osapi.h" #include "osapi.h"
#include "user_interface.h" #include "user_interface.h"
#include "espconn.h"
} //end, 'extern C' } //end, 'extern C'
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -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()
{
}