esp8266 / esp8266/Arduino

When using lwIP_enc28j60 the Wifi doesn't work

Aperta
#8,697 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C++
Stelle
16.7k
Fork
13.1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

#### Platform

- Hardware: ESP8266
- framework-arduinoespressif8266 3.30002.0 (3.0.2)
- Core Version: Espressif 8266 (4.0.1)
- Development Env: Platformio
- Operating System: Windows10

### Settings in IDE

- Module: WEMOS D1 R1
- lwip Variant: lwIP_enc28j60 @ 1
- Upload Using: SERIAL 115200

### Problem Description

Hi everyone.

There's a chance that this is a stupid post but I didn't know where else to place this question, and since this is the official repository for
lwIP_enc28j60, here it goes.

I'm migrating an working firmware from ArduinoIDE to PlatformIO. During the change I found out that UIPEthernet was replaced by a native lwip lib for ENC28j60. That's great! I tried and it works very nicely.

PROBLEM: I can't find a way to make WiFi work when ethernet is initialized. I can run the ENC library and use the asyncWebServer very nicely. The whole thing also works well with WiFi, even with SoftAP. The problem is that after calling

`eth.begin(ethMac)`

Wifi do not work properly anymore. Not even ping works once eth is started. The ETH interface keeps working properly, it's only WiFi that breaks.

The calls:

```
WiFi.softAP()
WiFi.begin()
WiFi.WiFi.softAPIP()
```
and
```
WiFi.localIP()
```
all return true, but there's no connection (on SoftAP the network doesn't show up).

Any light from you Network Mages will be super appreciated and if this is not the place, please let me know so I can remove the issue.

The test code:
```cpp
#define _AWS_ETHERNET_LOGLEVEL_ 1
#define USING_W5500 false
#define USING_W5100 false
#define USING_ENC28J60 true

#include

//#define CSPIN 15 // D8
#define CSPIN 4 // D2

#include
#include
#define SHIELD_TYPE "ESP8266_ENC28J60 Ethernet"

ENC28J60lwIP eth(CSPIN);

//#include // WiFiClient (-> TCPClient)
//using TCPClient = WiFiClient;

#define USING_DHCP false

#include

#include "Configuration.h"

AsyncWebServer* server_;

Configuration config_;

const char* PARAM_MESSAGE = "message";

void initEthernet()
{
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV4);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);

IPAddress ip(config_.commIp[0], config_.commIp[1], config_.commIp[2], config_.commIp[3]);
IPAddress gateway(config_.commGateway[0], config_.commGateway[1], config_.commGateway[2], config_.commGateway[3]);
IPAddress netmask(config_.commNetmask[0], config_.commNetmask[1], config_.commNetmask[2], config_.commNetmask[3]);

eth.config(ip, gateway, netmask, gateway);

eth.setDefault();

if (!eth.begin(config_.ethMac)) // THIS CALL BREAKS THE WIFI
{
Serial.println("No Ethernet hardware ... Stop here");

while (true)
{
delay(1000);
}
}
else
{
Serial.print("Connecting. ");

while (!eth.connected())
{
Serial.print(".");
delay(1000);
}
}

Serial.print("Ethernet OK ");

Serial.println(eth.status());
}

void initWifi()
{
IPAddress ip(config_.commIp[0], config_.commIp[1], config_.commIp[2], config_.commIp[3]);
IPAddress gateway(config_.commGateway[0], config_.commGateway[1], config_.commGateway[2], config_.commGateway[3]);
IPAddress netmask(config_.commNetmask[0], config_.commNetmask[1], config_.commNetmask[2], config_.commNetmask[3]);

Serial.print("Setting soft-AP configuration ... ");
Serial.println(WiFi.softAPConfig(ip, gateway, netmask) ? "Ready" : "Failed!");

Serial.print("Setting soft-AP ... ");
Serial.println(WiFi.softAP(config_.myUnitId) ? "Ready" : "Failed!");

Serial.print("Soft-AP IP address = ");
Serial.println(WiFi.softAPIP());

//WiFi.softAPConfig(ip, gateway, netmask);
//WiFi.softAP(config_.myUnitId, "", 7, false, 2);
//WiFi.mode(WIFI_SOFT_AP);
//WiFi.begin();

Serial.print("Soft-AP IP name '");
Serial.print(config_.myUnitId);
Serial.print("' on ");
Serial.println(WiFi.softAPIP());

//Serial.print("Setting Wifi configuration ... ");
//Serial.println(WiFi.begin("A1-5B071F", "HX35YTZF96") ? "Ready" : "Failed!");

/*while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");*/
}

void onCondig(AsyncWebServerRequest *request)
{
request->send(200, "text/plain", "Hello form the config thingy");
}

void notFound(AsyncWebServerRequest *request)
{
request->send(404, "text/plain", "Not found");
}

void setup()
{
Serial.begin(115200);
while (!Serial && millis() < 5000);

config_.init();

delay(200);

Serial.print("\nStart Async_AdvancedWebServer on ");
Serial.print(BOARD_NAME);
Serial.print(" with "); Serial.println(SHIELD_TYPE);
Serial.println(ASYNC_WEBSERVER_ETHERNET_VERSION);

initEthernet();

initWifi();

server_ = new AsyncWebServer(config_.commServerPort);

server_->on("/", HTTP_GET, [](AsyncWebServerRequest * request)
{
request->send(200, "text/plain", "Hello, world from " SHIELD_TYPE);
});

server_->on("/config", HTTP_GET, onCondig);

// Send a GET request to /get?message=
server_->on("/get", HTTP_GET, [] (AsyncWebServerRequest * request)
{
String message;

if (request->hasParam(PARAM_MESSAGE))
{
message = request->getParam(PARAM_MESSAGE)->value();
}
else
{
message = "No message sent";
}

request->send(200, "text/plain", "Hello, GET: " + message);
});

// Send a POST request to /post with a form field message set to
server_->on("/post", HTTP_POST, [](AsyncWebServerRequest * request)
{
String message;

if (request->hasParam(PARAM_MESSAGE, true))
{
message = request->getParam(PARAM_MESSAGE, true)->value();
}
else
{
message = "No message sent";
}

request->send(200, "text/plain", "Hello, POST: " + message);
});

server_->onNotFound(notFound);

server_->begin();

Serial.print("Server started ");
Serial.print(WiFi.localIP());
Serial.print(" port ");
Serial.println(config_.commServerPort, DEC);
}

void loop()
{

}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia dallo sketch fornito, in particolare da initEthernet(), dalla chiamata eth.begin(config_.ethMac) e da initWifi() su un ESP8266 con un ENC28J60. Riproduci il malfunzionamento con le impostazioni PlatformIO e WEMOS D1 R1 fornite, quindi traccia lo stato di WiFi dopo l’inizializzazione di Ethernet. Il lavoro è completato quando sia Ethernet sia WiFi o SoftAP rimangono utilizzabili e la causa e un test di regressione mirato sono documentati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp
Ambito
embedded-iot, networking
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.