diff --git a/libraries/esp8266/examples/interactive/interactive.ino b/libraries/esp8266/examples/interactive/interactive.ino new file mode 100644 index 0000000000..bf084c9674 --- /dev/null +++ b/libraries/esp8266/examples/interactive/interactive.ino @@ -0,0 +1,91 @@ + +/* + Interactive script meant for debugging only + Run it on serial console and keep this source file opened for the list of commands + Please configure SSID, PSK and IPAddresses below to fit with your network + + Released to public domain +*/ + +#include "ESP8266WiFi.h" +#include "user_interface.h" + +const char SSID[] = "open"; +const char PSK[] = ""; + +IPAddress staticip(192, 168, 1, 123); +IPAddress gateway(192, 168, 1, 254); +IPAddress subnet(255, 255, 255, 0); + +void setup() { + Serial.begin(115200); + Serial.setDebugOutput(true); + + WiFi.mode(WIFI_STA); + WiFi.begin(SSID, PSK); + Serial.println("connecting"); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println(); + Serial.println(WiFi.localIP()); + Serial.print( + "WL_IDLE_STATUS = 0\n" + "WL_NO_SSID_AVAIL = 1\n" + "WL_SCAN_COMPLETED = 2\n" + "WL_CONNECTED = 3\n" + "WL_CONNECT_FAILED = 4\n" + "WL_CONNECTION_LOST = 5\n" + "WL_DISCONNECTED = 6\n" + ); +} + +void WiFiOn() { + wifi_fpm_do_wakeup(); + wifi_fpm_close(); + wifi_set_opmode(STATION_MODE); + wifi_station_connect(); +} + +void WiFiOff() { + wifi_station_disconnect(); + wifi_set_opmode(NULL_MODE); + wifi_set_sleep_type(MODEM_SLEEP_T); + wifi_fpm_open(); + wifi_fpm_do_sleep(0xFFFFFFF); +} + +void loop() { +#define TEST(name, var, varinit, func) \ + static decltype(func) var = (varinit); \ + if ((var) != (func)) { var = (func); Serial.printf("**** %s: ", name); Serial.println(var); } + +#define DO(x...) Serial.println(F( #x )); x; break + + TEST("Free Heap", freeHeap, 0, ESP.getFreeHeap()); + TEST("WiFiStatus", status, WL_IDLE_STATUS, WiFi.status()); + TEST("STA-IP", localIp, (uint32_t)0, WiFi.localIP()); + TEST("AP-IP", apIp, (uint32_t)0, WiFi.softAPIP()); + + switch (Serial.read()) { + case 'F': DO(WiFiOff()); + case 'N': DO(WiFiOn()); + case '1': DO(WiFi.mode(WIFI_AP)); + case '2': DO(WiFi.mode(WIFI_AP_STA)); + case '3': DO(WiFi.mode(WIFI_STA)); + case 'R': DO(if (((GPI >> 16) & 0xf) == 1) ESP.reset() /* else must hard reset */); + case 'd': DO(WiFi.disconnect()); + case 'b': DO(WiFi.begin()); + case 'B': DO(WiFi.begin(SSID, PSK)); + case 'r': DO(WiFi.reconnect()); + case 'c': DO(wifi_station_connect()); + case 'a': DO(WiFi.setAutoReconnect(false)); + case 'A': DO(WiFi.setAutoReconnect(true)); + case 'n': DO(WiFi.setSleepMode(WIFI_NONE_SLEEP)); + case 'l': DO(WiFi.setSleepMode(WIFI_LIGHT_SLEEP)); + case 'm': DO(WiFi.setSleepMode(WIFI_MODEM_SLEEP)); + case 's': DO(WiFi.config(staticip, gateway, subnet)); + case 'D': DO(wifi_station_dhcpc_start()); + } +} diff --git a/tools/sdk/lib/liblwip2.a b/tools/sdk/lib/liblwip2.a index e681bdc398..9bfbf64aae 100644 Binary files a/tools/sdk/lib/liblwip2.a and b/tools/sdk/lib/liblwip2.a differ diff --git a/tools/sdk/lib/liblwip2_1460.a b/tools/sdk/lib/liblwip2_1460.a index 8929c2d009..56588f6dd4 100644 Binary files a/tools/sdk/lib/liblwip2_1460.a and b/tools/sdk/lib/liblwip2_1460.a differ diff --git a/tools/sdk/lwip2/Makefile b/tools/sdk/lwip2/Makefile index 6284486a7c..90d157270e 100644 --- a/tools/sdk/lwip2/Makefile +++ b/tools/sdk/lwip2/Makefile @@ -2,6 +2,16 @@ all install clean: builder/lwip2-src/README make -C builder -f Makefile.arduino $@ +latestmaster: downloadmaster install + +latestupstream: downloadupstream install + +downloadupstream: downloadmaster + cd builder/lwip2-src; git checkout master + +downloadmaster: download + cd builder; git checkout master + download: builder/lwip2-src/README builder/lwip2-src/README: diff --git a/tools/sdk/lwip2/README.md b/tools/sdk/lwip2/README.md index 4063071013..8f17da128b 100644 --- a/tools/sdk/lwip2/README.md +++ b/tools/sdk/lwip2/README.md @@ -1,5 +1,9 @@ ```make install```: download, compile, install lwip2 +```make latestmaster```: download latest lwip2, compile, install + +```make latestupstream```: download latest lwip2 and latest upstream lwIP, compile, install + ```make download```: download lwIP-2 builder ```make clean```: clean builder only @@ -10,4 +14,4 @@ MSS values are in builder/Makefile.arduino MSS values in boards.txt are only informative -current lwip2 submodule repository: https://github.com/d-a-v/esp82xx-nonos-linklayer/tree/arduino-2.4.0 +current lwip2 submodule repository: https://github.com/d-a-v/esp82xx-nonos-linklayer/tree/arduino-2.4.1 diff --git a/tools/sdk/lwip2/builder b/tools/sdk/lwip2/builder index a376280e35..2b827f8429 160000 --- a/tools/sdk/lwip2/builder +++ b/tools/sdk/lwip2/builder @@ -1 +1 @@ -Subproject commit a376280e3567dff7d494d6fe3e54146f6125f5c6 +Subproject commit 2b827f842925b2daf12b67ab1ae498e58174124e diff --git a/tools/sdk/lwip2/include/gluedebug.h b/tools/sdk/lwip2/include/gluedebug.h index 55d0e8d746..0252666524 100644 --- a/tools/sdk/lwip2/include/gluedebug.h +++ b/tools/sdk/lwip2/include/gluedebug.h @@ -2,6 +2,7 @@ #ifndef __GLUE_DEBUG_H #define __GLUE_DEBUG_H +// this file is commonly included by both sides of the glue ///////////////////////////////////////////////////////////////////////////// // user-definable @@ -27,6 +28,15 @@ #define LWIP_DBG_TYPES_ON (LWIP_DBG_ON) #endif +///////////////////////////////////////////////////////////////////////////// +// packet capture callback from esp side +#include + +#ifdef __cplusplus +extern "C" +#endif +void (*phy_capture) (int netif_idx, const char* data, size_t len, int out, int success); + ///////////////////////////////////////////////////////////////////////////// #if UDEBUG && UDEBUGSTORE diff --git a/tools/sdk/lwip2/include/lwip-git-hash.h b/tools/sdk/lwip2/include/lwip-git-hash.h index 2d1392e4e5..19bd78b941 100644 --- a/tools/sdk/lwip2/include/lwip-git-hash.h +++ b/tools/sdk/lwip2/include/lwip-git-hash.h @@ -1,5 +1,5 @@ // generated by makefiles/make-lwip2-hash #ifndef LWIP_HASH_H #define LWIP_HASH_H -#define LWIP_HASH_STR "STABLE-2_0_3_RELEASE/glue:arduino-2.4.1" +#define LWIP_HASH_STR "STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-7-g2b827f8" #endif // LWIP_HASH_H diff --git a/tools/sdk/lwip2/include/lwipopts.h b/tools/sdk/lwip2/include/lwipopts.h index 9d365498d6..1c9d0a9e0f 100644 --- a/tools/sdk/lwip2/include/lwipopts.h +++ b/tools/sdk/lwip2/include/lwipopts.h @@ -2688,9 +2688,11 @@ * Return ERR_OK if packet is accepted, any error code otherwise. * Payload points to ethernet header! */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) -#endif +//#ifdef __DOXYGEN__ +//#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) +//#endif +#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) lwip_unhandled_packet((pbuf), (netif)) + /** * @} */ @@ -3003,4 +3005,12 @@ #include "lwip-git-hash.h" #include // settimeofday() + struct timeval +// allow to handle special packets (user redefinable) +struct pbuf; +struct netif; +#ifndef LWIP_ERR_T +#define LWIP_ERR_T s8 +#endif +LWIP_ERR_T lwip_unhandled_packet (struct pbuf* pbuf, struct netif* netif) __attribute__((weak)); + #endif // MYLWIPOPTS_H