1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00
esp8266/libraries/ESP8266WiFi/src/ESP8266WiFiGratuitous.cpp
david gauchard af1bc71a9e
remove lwip-v1.4 specific code (#7436)
* remove lwip-v1.4 specific code

* ditto

* ditto

* fix ip4_addr definition

* CI: change debug builds to use IPv6, remove regular IPv6 builds

* ditto

* split pio CI in four (because they last twice the time of the other builds)

* remove option from pio

* remove lwIP-1.4 from doc

* restore pio CI splitting

* fix CI debug6 script

* ditto
2020-07-09 09:59:49 -07:00

83 lines
2.2 KiB
C++

/*
ESP8266WiFiGratuitous.cpp - esp8266 Wifi support
copyright esp8266/arduino
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern "C"
{
#include "lwip/etharp.h" // gratuitous arp
} // extern "C"
#include <Schedule.h>
#include "ESP8266WiFiGratuitous.h"
namespace experimental
{
ETSTimer* ESP8266WiFiGratuitous::_timer = nullptr;
void ESP8266WiFiGratuitous::stationKeepAliveNow ()
{
for (netif* interface = netif_list; interface != nullptr; interface = interface->next)
if (
(interface->flags & NETIF_FLAG_LINK_UP)
&& (interface->flags & NETIF_FLAG_UP)
&& interface->num == STATION_IF
&& (!ip4_addr_isany_val(*netif_ip4_addr(interface))))
{
etharp_gratuitous(interface);
break;
}
}
void ESP8266WiFiGratuitous::scheduleItForNextYieldOnce (void*)
{
schedule_recurrent_function_us([]()
{
ESP8266WiFiGratuitous::stationKeepAliveNow();
return false;
}, 0);
}
bool ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs (uint32_t ms)
{
if (_timer)
{
os_timer_disarm(_timer);
free(_timer);
_timer = nullptr;
}
if (ms)
{
// send one now
stationKeepAliveNow();
_timer = (ETSTimer*)malloc(sizeof(ETSTimer));
if (_timer == nullptr)
return false;
os_timer_setfn(_timer, ESP8266WiFiGratuitous::scheduleItForNextYieldOnce, nullptr);
os_timer_arm(_timer, ms, true);
}
return true;
}
}; // experimental::