Skip to content

Add API to WiFi class to configure wdog feed function #258

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 5 commits into from
Jun 15, 2021
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: 12 additions & 0 deletions libraries/WiFi/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,18 @@ unsigned long arduino::WiFiClass::getTime() {
return 0;
}

void arduino::WiFiClass::setFeedWatchdogFunc(ArduinoPortentaH7WiFiFeedWatchdogFuncPtr func)
{
_feed_watchdog_func = func;
}

void arduino::WiFiClass::feedWatchdog()
{
if (_feed_watchdog_func)
_feed_watchdog_func();
}


#if defined(COMPONENT_4343W)

#include "QSPIFBlockDevice.h"
Expand Down
7 changes: 7 additions & 0 deletions libraries/WiFi/src/WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ extern "C" {
#define DEFAULT_AP_CHANNEL 6
#endif

#define ARDUINO_PORTENTA_H7_WIFI_HAS_FEED_WATCHDOG_FUNC

namespace arduino {

typedef void* (*voidPrtFuncPtr)(void);
typedef void (*ArduinoPortentaH7WiFiFeedWatchdogFuncPtr)(void);

class WiFiClass
{
Expand Down Expand Up @@ -296,6 +299,9 @@ class WiFiClass

NetworkInterface *getNetwork();

void setFeedWatchdogFunc(ArduinoPortentaH7WiFiFeedWatchdogFuncPtr func);
void feedWatchdog();

private:

EMACInterface* _softAP = nullptr;
Expand All @@ -316,6 +322,7 @@ class WiFiClass
bool isVisible(const char* ssid);
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
SocketAddress socketAddressFromIpAddress(arduino::IPAddress ip, uint16_t port);
ArduinoPortentaH7WiFiFeedWatchdogFuncPtr _feed_watchdog_func = 0;
};

}
Expand Down
1 change: 1 addition & 0 deletions libraries/WiFi/src/WiFiHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static FILE* target;

void body_callback(const char* data, uint32_t data_len)
{
WiFi.feedWatchdog();
fwrite(data, 1, data_len, target);
}

Expand Down