Skip to content

add LwipIntf::stateUpCB() #7391

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

Closed
wants to merge 5 commits into from
Closed
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
25 changes: 25 additions & 0 deletions cores/esp8266/LwipIntf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

#ifndef _LWIPINTF_H
#define _LWIPINTF_H

#include <lwip/netif.h>

#include <functional>

class LwipIntf
{
private:

LwipIntf () { }

protected:

static bool stateChangeSysCB (std::function<void(netif*)>&& cb);

public:

static bool stateUpCB (std::function<void(netif*)>&& cb);

};

#endif // _LWIPINTF_H
44 changes: 44 additions & 0 deletions cores/esp8266/LwipIntfCB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

#include <LwipIntf.h>
#include <Schedule.h>
#include <debug.h>

#define NETIF_STATUS_CB_SIZE 3

static int netifStatusChangeListLength = 0;
std::function<void(netif*)> netifStatusChangeList [NETIF_STATUS_CB_SIZE];

// this function needs to be in a separate file
// (overriding a weak function)
extern "C" void netif_status_changed (struct netif* netif)
{
// override the default empty weak function
for (int i = 0; i < netifStatusChangeListLength; i++)
netifStatusChangeList[i](netif);
}

bool LwipIntf::stateChangeSysCB (std::function<void(netif*)>&& cb)
{
if (netifStatusChangeListLength >= NETIF_STATUS_CB_SIZE)
{
#if defined(DEBUG_ESP_CORE)
DEBUGV("NETIF_STATUS_CB_SIZE is too low\n");
#endif
return false;
}

netifStatusChangeList[netifStatusChangeListLength++] = cb;
return true;
}

bool LwipIntf::stateUpCB (std::function<void(netif*)>&& cb)
{
return stateChangeSysCB([cb](netif* nif)
{
if (netif_is_up(nif))
schedule_function([cb, nif]()
{
cb(nif);
});
});
}
Binary file modified tools/sdk/lib/liblwip2-1460-feat.a
Binary file not shown.
Binary file modified tools/sdk/lib/liblwip2-1460.a
Binary file not shown.
Binary file modified tools/sdk/lib/liblwip2-536-feat.a
Binary file not shown.
Binary file modified tools/sdk/lib/liblwip2-536.a
Binary file not shown.
Binary file modified tools/sdk/lib/liblwip6-1460-feat.a
Binary file not shown.
Binary file modified tools/sdk/lib/liblwip6-536-feat.a
Binary file not shown.
2 changes: 1 addition & 1 deletion tools/sdk/lwip2/builder
8 changes: 6 additions & 2 deletions tools/sdk/lwip2/include/gluedebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@

#define HAS_PHY_CAPTURE 1
#ifdef __cplusplus
extern "C"
extern "C" {
#endif
void (*phy_capture) (int netif_idx, const char* data, size_t len, int out, int success);
extern void (*phy_capture) (int netif_idx, const char* data, size_t len, int out, int success);
#ifdef __cplusplus
}
#endif


/////////////////////////////////////////////////////////////////////////////
#if ARDUINO
Expand Down
2 changes: 1 addition & 1 deletion tools/sdk/lwip2/include/lwip-git-hash.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// generated by makefiles/make-lwip2-hash
#ifndef LWIP_HASH_H
#define LWIP_HASH_H
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50"
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-33-g61b0163"
#endif // LWIP_HASH_H
3 changes: 3 additions & 0 deletions tools/sdk/lwip2/include/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -3619,6 +3619,9 @@ struct netif;
//#define LWIP_ERR_T s8
LWIP_ERR_T lwip_unhandled_packet (struct pbuf* pbuf, struct netif* netif);

// called when STA OR AP is set up or down
void netif_status_changed (struct netif*);

/*
--------------------------------------------------
----------------- TIME-WAIT tweak ----------------
Expand Down