Description
Basic Infos
- [*] This issue complies with the issue POLICY doc.
- [*] I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- [*] I have searched the issue tracker for a similar issue.
- [*] If there is a stack dump, I have decoded it.
- [*] I have filled out all fields below.
Platform
- Hardware: [ESP-12|
- Core Version: [latest git hash or date]
SDK:3.0.0-dev(c0f7b44)
Core:2.5.2=20502000
lwIP:STABLE-2_1_2_RELEASE
glue:1.1-7-g82abda3
BearSSL:a143020
Also with
SDK:2.2.1(cfd48f3)
Core:2.5.2=20502000
lwIP:STABLE-2_1_2_RELEASE
glue:1.1-7-g82abda3
BearSSL:a143020
Also with
SDK:2.2.2-dev(c0eb301)
Core:2.5.2=20502000
lwIP:STABLE-2_1_2_RELEASE
glue:1.1-7-g82abda3
BearSSL:a143020
- Development Env: [Arduino IDE]
- Operating System: [Windows]
Settings in IDE
- Module: [Generic ESP8266 Module]
- Flash Mode: [qio]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [none]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [256000|other] (serial upload only)
Problem Description
I load the Hellomesh.INO example. Do a manual reset. It gets through setup. Gets into loop. It enters the scan routine. It never makes it to timeOfLastScan = millis(); It never get through loop() even once.
I added Serial.print statements in the code to see how far it gets.
EDIT:
- lwip Variant: [v2 Lower Memory] seems to be the problem. v1.4 Higher Bandwidth seems to work. I have been able to run three units without a crash. Message are being transferred.
MCVE Sketch
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMesh.h>
#include <TypeConversionFunctions.h>
#include <assert.h>
/**
NOTE: Although we could define the strings below as normal String variables,
here we are using PROGMEM combined with the FPSTR() macro (and also just the F() macro further down in the file).
The reason is that this approach will place the strings in flash memory which will help save RAM during program execution.
Reading strings from flash will be slower than reading them from RAM,
but this will be a negligible difference when printing them to Serial.
More on F(), FPSTR() and PROGMEM:
https://github.com/esp8266/Arduino/issues/1143
https://arduino-esp8266.readthedocs.io/en/latest/PROGMEM.html
*/
const char exampleMeshName[] PROGMEM = "MeshNode_";
const char exampleWiFiPassword[] PROGMEM = "ChangeThisWiFiPassword_TODO";
//#define IPport 22
//#define IPport 20
//#define IPport 4
#define IPport 17
const int LED15 = 15;
const int LED13 = 13;
const int LED14 = 14;
const int LED12 = 12;
unsigned int requestNumber = 0;
unsigned int responseNumber = 0;
String manageRequest(const String &request, ESP8266WiFiMesh &meshInstance);
transmission_status_t manageResponse(const String &response, ESP8266WiFiMesh &meshInstance);
void networkFilter(int numberOfNetworks, ESP8266WiFiMesh &meshInstance);
/* Create the mesh node object */
ESP8266WiFiMesh meshNode = ESP8266WiFiMesh(manageRequest, manageResponse, networkFilter, FPSTR(exampleWiFiPassword), FPSTR(exampleMeshName), "", true);
/**
Callback for when other nodes send you a request
@param request The request string received from another node in the mesh
@param meshInstance The ESP8266WiFiMesh instance that called the function.
@returns The string to send back to the other node
*/
String manageRequest(const String &request, ESP8266WiFiMesh &meshInstance) {
// We do not store strings in flash (via F()) in this function.
// The reason is that the other node will be waiting for our response,
// so keeping the strings in RAM will give a (small) improvement in response time.
// Of course, it is advised to adjust this approach based on RAM requirements.
/* Print out received message */
Serial.print("Request received: ");
Serial.println(request);
/* return a string to send back */
return ("Hello world response #" + String(responseNumber++) + " from " + meshInstance.getMeshName() + meshInstance.getNodeID() + ".");
}
/**
Callback for when you get a response from other nodes
@param response The response string received from another node in the mesh
@param meshInstance The ESP8266WiFiMesh instance that called the function.
@returns The status code resulting from the response, as an int
*/
transmission_status_t manageResponse(const String &response, ESP8266WiFiMesh &meshInstance) {
transmission_status_t statusCode = TS_TRANSMISSION_COMPLETE;
/* Print out received message */
Serial.print(F("Request sent: "));
Serial.println(meshInstance.getMessage());
Serial.print(F("Response received: "));
Serial.println(response);
// Our last request got a response, so time to create a new request.
meshInstance.setMessage(String(F("Hello world request #")) + String(++requestNumber) + String(F(" from "))
+ meshInstance.getMeshName() + meshInstance.getNodeID() + String(F(".")));
// (void)meshInstance; // This is useful to remove a "unused parameter" compiler warning. Does nothing else.
return statusCode;
}
/**
Callback used to decide which networks to connect to once a WiFi scan has been completed.
@param numberOfNetworks The number of networks found in the WiFi scan.
@param meshInstance The ESP8266WiFiMesh instance that called the function.
*/
void networkFilter(int numberOfNetworks, ESP8266WiFiMesh &meshInstance) {
for (int networkIndex = 0; networkIndex < numberOfNetworks; ++networkIndex) {
String currentSSID = WiFi.SSID(networkIndex);
int meshNameIndex = currentSSID.indexOf(meshInstance.getMeshName());
/* Connect to any _suitable_ APs which contain meshInstance.getMeshName() */
if (meshNameIndex >= 0) {
uint64_t targetNodeID = stringToUint64(currentSSID.substring(meshNameIndex + meshInstance.getMeshName().length()));
if (targetNodeID < stringToUint64(meshInstance.getNodeID())) {
ESP8266WiFiMesh::connectionQueue.push_back(NetworkInfo(networkIndex));
}
}
}
}
void setup() {
pinMode(LED15, OUTPUT);
pinMode(LED13, OUTPUT);
pinMode(LED14, OUTPUT);
pinMode(LED12, OUTPUT);
digitalWrite(LED12, 1);
digitalWrite(LED13, 1);
digitalWrite(LED14, 1);
// Prevents the flash memory from being worn out, see: https://github.com/esp8266/Arduino/issues/1054 .
// This will however delay node WiFi start-up by about 700 ms. The delay is 900 ms if we otherwise would have stored the WiFi network we want to connect to.
WiFi.persistent(false);
Serial.begin(115200);
delay(50); // Wait for Serial.
//yield(); // Use this if you don't want to wait for Serial.
// The WiFi.disconnect() ensures that the WiFi is working correctly. If this is not done before receiving WiFi connections,
// those WiFi connections will take a long time to make or sometimes will not work at all.
WiFi.disconnect();
Serial.println();
Serial.println();
Serial.println(F("Note that this library can use static IP:s for the nodes to speed up connection times.\n"
"Use the setStaticIP method as shown in this example to enable this.\n"
"Ensure that nodes connecting to the same AP have distinct static IP:s.\n"
"Also, remember to change the default mesh network password!\n\n"));
Serial.println(F("Setting up mesh node..."));
/* Initialise the mesh node */
meshNode.begin();
meshNode.activateAP(); // Each AP requires a separate server port.
meshNode.setStaticIP(IPAddress(192, 168, 4, IPport)); // Activate static IP mode to speed up connection times.
Serial.print("++++ end of setup "); Serial.println(millis());
}
int32_t LED15millis = 0;
int32_t timeOfLastScan = -10000;
void loop() {
if ((millis() - LED15millis) > 250) {
LED15millis = millis();
digitalWrite(LED15, !digitalRead(LED15));
Serial.print("++++ led 15 "); Serial.println(millis());
}
if (millis() - timeOfLastScan > 3000 // Give other nodes some time to connect between data transfers.
|| (WiFi.status() != WL_CONNECTED && millis() - timeOfLastScan > 2000)) { // Scan for networks with two second intervals when not already connected.
Serial.print("++++ in scan "); Serial.println(millis());
String request = String(F("Hello world request #")) + String(requestNumber) + String(F(" from ")) + meshNode.getMeshName() + meshNode.getNodeID() + String(F("."));
Serial.print("++++ in scan after String request "); Serial.println(millis());
meshNode.attemptTransmission(request, false);
Serial.print("++++ in scan defore timeOfLastScan= "); Serial.println(millis());
timeOfLastScan = millis();
Serial.print("++++ in scan after timeOfLastScan= "); Serial.println(millis());
digitalWrite(LED13, !digitalRead(LED13));
digitalWrite(LED14, 0);
// One way to check how attemptTransmission worked out
if (ESP8266WiFiMesh::latestTransmissionSuccessful()) {
Serial.println(F("Transmission successful."));
}
// Another way to check how attemptTransmission worked out
if (ESP8266WiFiMesh::latestTransmissionOutcomes.empty()) {
Serial.println(F("No mesh AP found."));
} else {
Serial.print("++++ in latestTransmissionOutcomes check "); Serial.println(millis());
for (TransmissionResult &transmissionResult : ESP8266WiFiMesh::latestTransmissionOutcomes) {
if (transmissionResult.transmissionStatus == TS_TRANSMISSION_FAILED) {
Serial.println(String(F("Transmission failed to mesh AP ")) + transmissionResult.SSID);
} else if (transmissionResult.transmissionStatus == TS_CONNECTION_FAILED) {
Serial.println(String(F("Connection failed to mesh AP ")) + transmissionResult.SSID);
} else if (transmissionResult.transmissionStatus == TS_TRANSMISSION_COMPLETE) {
// No need to do anything, transmission was successful.
} else {
Serial.println(String(F("Invalid transmission status for ")) + transmissionResult.SSID + String(F("!")));
assert(F("Invalid transmission status returned from responseHandler!") && false);
}
}
}
Serial.println("end of scan "); Serial.println(millis());
} else {
// Accept any incoming connections
meshNode.acceptRequest();
digitalWrite(LED14, 1);
Serial.print("++++ acceptRequest() "); Serial.println(millis());
}
delay(10);
Serial.print("++++ end of loop "); Serial.println(millis());
}
Debug Messages
SDK:3.0.0-dev(c0f7b44)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
Note that this library can use static IP:s for the nodes to speed up connection times.
Use the setStaticIP method as shown in this example to enable this.
Ensure that nodes connecting to the same AP have distinct static IP:s.
Also, remember to change the default mesh network password!
Setting up mesh node...
bcn 0
del if1
usl
mode : sta(18:fe:34:f1:fe:f6)
add if0
lwIP version is at least 2.0.3. Static ip optimizations enabled.
mode : sta(18:fe:34:f1:fe:f6) + softAP(1a:fe:34:f1:fe:f6)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
bcn 0
del if1
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
ip:192.168.4.17,mask:255.255.255.0,gw:192.168.4.1
++++ end of setup 1028
++++ led 15 1028
++++ in scan 1028
++++ in scan after String request 1030
bcn 0
del if1
mode : sta(18:fe:34:f1:fe:f6)
:ref 1
:ctmo
:abort
:ur 1
:del
Server unavailable
mode : sta(18:fe:34:f1:fe:f6) + softAP(1a:fe:34:f1:fe:f6)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
Fatal exception 28(LoadProhibitedCause):
epc1=0x40208140, epc2=0x00000000, epc3=0x00000000, excvaddr=0x001cc842, depc=0x00000000
Exception (28):
epc1=0x40208140 epc2=0x00000000 epc3=0x00000000 excvaddr=0x001cc842 depc=0x00000000
stack>>>
ctx: cont
sp: 3ffffcd0 end: 3fffffc0 offset: 01a0
3ffffe70: 3ffee5dc ffffffff 3ffffe90 402044bc
3ffffe80: 3ffee5dc 3ffee61c 3ffee4dc 40203f6c
3ffffe90: 00000000 3ffe0000 001cc842 00000000
3ffffea0: 00ff01bc 001cc842 3ffffe90 001cc842
3ffffeb0: 3ffe874a 00000000 3ffe8749 402068e6
3ffffec0: 00000000 4bc6a7f0 9916872b 3fffff60
3ffffed0: 3ffe84dc 00000004 3ffee6a0 402049ac
3ffffee0: 00000009 3ffee4dc 401001c0 40204cc5
3ffffef0: 00000000 00000000 3fff0184 00000000
3fffff00: 3ffe84dc 3ffee4dc 3ffee6a0 40204d50
3fffff10: 3ffe84dc 3ffee4dc 3ffee6a0 3fffff60
3fffff20: 3ffe84dc 3ffee4dc 3ffee6a0 402015cd
3fffff30: 00000000 00000000 fffee6a0 00000000
3fffff40: 00000000 fffee4dc 00000000 00000000
3fffff50: fffe005f 00000000 00000000 fffee7bc
3fffff60: 00000000 00000000 fffee6a0 00000000
3fffff70: 00000000 ff04a8c0 00000000 00000000
3fffff80: ffffdad0 3fff022c 002c002f ff2012c6
3fffff90: 402084a0 1104a8c0 feefeffe 3ffee7bc
3fffffa0: 3fffdad0 00000000 3ffee78c 40205b2c
3fffffb0: feefeffe feefeffe 3ffe850c 401005b9
<<<stack<<<
ets Jan 8 2013,rst cause:1, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
SDK:3.0.0-dev(c0f7b44)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
Note that this library can use static IP:s for the nodes to speed up connection times.
Use the setStaticIP method as shown in this example to enable this.
Ensure that nodes connecting to the same AP have distinct static IP:s.
Also, remember to change the default mesh network password!
Setting up mesh node...
bcn 0
del if1
usl
mode : sta(18:fe:34:f1:fe:f6)
add if0
lwIP version is at least 2.0.3. Static ip optimizations enabled.
mode : sta(18:fe:34:f1:fe:f6) + softAP(1a:fe:34:f1:fe:f6)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
bcn 0
del if1
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
ip:192.168.4.17,mask:255.255.255.0,gw:192.168.4.1
++++ end of setup 1029
++++ led 15
1030
++++ in scan 1030
++++ in scan after String request 1031
bcn 0
del if1
mode : sta(18:fe:34:f1:fe:f6)
:ref 1
This is where it waits for a few seconds, before it continues and then dies.
Debug Messages
****************************** STACK DUMP ******************************
Decoding 11 results
0x402044bc: TransmissionResult::TransmissionResult(NetworkInfo const&, transmission_status_t) at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFiMesh\src/TransmissionResult.cpp line 42
0x40203f6c: ESP8266WiFiMesh::attemptTransmission(String const&, bool, bool, bool, bool) at c:\users\rudy\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/stl_vector.h line 922
: (inlined by) ESP8266WiFiMesh::attemptTransmission(String const&, bool, bool, bool, bool) at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFiMesh\src/ESP8266WiFiMesh.cpp line 529
0x402068e6: uart_write at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/uart.cpp line 498
0x402049ac: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x401001c0: millis at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/core_esp8266_wiring.cpp line 186
0x40204cc5: Print::write(char const*) at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/Print.h line 60
0x40204d50: Print::println() at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/Print.cpp line 178
0x402015cd: loop at C:\Users\Rudy\AppData\Local\Temp\arduino_modified_sketch_801160/HelloMesh.ino line 163
0x402084a0: WiFiServer::write(unsigned char const*, unsigned int) at ?? line ?
0x40205b2c: loop_wrapper() at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/core_esp8266_main.cpp line 125
0x401005b9: cont_wrapper at C:\Users\Rudy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/cont.S line 81