Skip to content

Ping: Expose timeout to interfaces #1038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions libraries/SocketWrapper/src/SocketHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ arduino::IPAddress arduino::MbedSocketClass::dnsIP(int n) {
return ipAddressFromSocketAddress(ip);
}

int arduino::MbedSocketClass::ping(const char *hostname, uint8_t ttl)
int arduino::MbedSocketClass::ping(const char *hostname, uint8_t ttl, uint32_t timeout)
{
SocketAddress socketAddress;
gethostbyname(getNetwork(),hostname, &socketAddress);
return ping(socketAddress, ttl);
return ping(socketAddress, ttl, timeout);
}

int arduino::MbedSocketClass::ping(const String &hostname, uint8_t ttl)
int arduino::MbedSocketClass::ping(const String &hostname, uint8_t ttl, uint32_t timeout)
{
return ping(hostname.c_str(), ttl);
return ping(hostname.c_str(), ttl, timeout);
}

int arduino::MbedSocketClass::ping(IPAddress host, uint8_t ttl)
int arduino::MbedSocketClass::ping(IPAddress host, uint8_t ttl, uint32_t timeout)
{
SocketAddress socketAddress = socketAddressFromIpAddress(host, 0);
return ping(socketAddress, ttl);
return ping(socketAddress, ttl, timeout);
}

void arduino::MbedSocketClass::config(arduino::IPAddress local_ip) {
Expand Down
8 changes: 4 additions & 4 deletions libraries/SocketWrapper/src/SocketHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ class MbedSocketClass {
*
* return: RTT in milliseconds or -1 on error
*/
int ping(const char* hostname, uint8_t ttl = 255);
int ping(const String &hostname, uint8_t ttl = 255);
int ping(IPAddress host, uint8_t ttl = 255);
int ping(const char* hostname, uint8_t ttl = 255, uint32_t timeout = 5000);
int ping(const String &hostname, uint8_t ttl = 255, uint32_t timeout = 5000);
int ping(IPAddress host, uint8_t ttl = 255, uint32_t timeout = 5000);

/*
* Download a file from an HTTP endpoint and save it in the provided `target` location on the fs
Expand Down Expand Up @@ -185,7 +185,7 @@ class MbedSocketClass {

void body_callback(const char* data, uint32_t data_len);

int ping(SocketAddress &socketAddress, uint8_t ttl, uint32_t timeout = 5000);
int ping(SocketAddress &socketAddress, uint8_t ttl, uint32_t timeout);
static arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
static SocketAddress socketAddressFromIpAddress(arduino::IPAddress ip, uint16_t port);
static nsapi_error_t gethostbyname(NetworkInterface* interface, const char* aHostname, SocketAddress* socketAddress);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy