Adding range choice for setRandomPort()

This commit is contained in:
Luigi Gubello 2020-08-31 15:31:55 +02:00
parent a8bdae7ca4
commit 9e4323bcef
2 changed files with 3 additions and 3 deletions

View File

@ -204,7 +204,7 @@ void NTPClient::sendNTPPacket() {
this->_udp->endPacket(); this->_udp->endPacket();
} }
void NTPClient::setRandomPort() { void NTPClient::setRandomPort(long minValue, long maxValue) {
randomSeed(analogRead(0)); randomSeed(analogRead(0));
this->_port = random(1, 65534); this->_port = random(minValue, maxValue);
} }

View File

@ -47,7 +47,7 @@ class NTPClient {
/** /**
* Set random local port * Set random local port
*/ */
void setRandomPort(); void setRandomPort(long minValue, long maxValue);
/** /**
* Starts the underlying UDP client with the default local port * Starts the underlying UDP client with the default local port