Skip to content

Commit

Permalink
New method: Net::isNewIP()
Browse files Browse the repository at this point in the history
  • Loading branch information
ThBreuer committed Jun 25, 2024
1 parent 904349f commit f2ecd1d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Src/Hardware/Common/Net/Net.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Net
*/
Net( Timer &timer )
{
isIPvalidFlag = false;
timeoutTics = 1E6 / Net::Task::ticsPerSecond / timer.getCycleTime();
timer.add( &handler );
}
Expand Down Expand Up @@ -124,11 +125,29 @@ class Net

public:
//---------------------------------------------------------------
/*! Returns own IPv4 addrss
/*! Returns own IPv4 address
\return address of zeroAddr if address is unkown/not defined
*/
virtual NetAddr<4> &getIP( void ) = 0;

//---------------------------------------------------------------
/*! Checks, if own IP becomes valid
\return Flag
*/
bool isNewIP( void )
{
if( isIPvalidFlag )
{
return( false ); // valid, but not new
}
else
{
isIPvalidFlag = !(getIP() == zeroAddr);
}
return( isIPvalidFlag );
}


protected:
//---------------------------------------------------------------
virtual void process( void ) = 0;
Expand All @@ -140,6 +159,7 @@ class Net
private:
//---------------------------------------------------------------
WORD timeoutTics;
bool isIPvalidFlag = false;

}; //class Net

Expand Down

0 comments on commit f2ecd1d

Please sign in to comment.