You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So here is my code, Its the simple_server example from ESPAsyncWebServer.h and encryption example from PracticalCrypto.h combined.
The webserver works fine and I can see the / page, but the moment I open the /get page, where the code for encryption exmple is, ESP8266 crashes. I tried removing while (1) yield(); but the problem is persistent.
Is PracticalCrypto too much for ESP8266? So why is this happening?
#include<Arduino.h>#ifdefESP32#include<WiFi.h>#include<AsyncTCP.h># elif defined(ESP8266)
#include<ESP8266WiFi.h>#include<ESPAsyncTCP.h>#endif#include<ESPAsyncWebServer.h>#include<Arduino.h>#include<PracticalCrypto.h>PracticalCryptocrypto;
AsyncWebServerserver(80);
constchar*ssid="123456789";
constchar*password="123456789";
constchar*PARAM_MESSAGE="message";
voidnotFound(AsyncWebServerRequest*request)
{
request->send(404, "text/plain", "Not found");
}
voidsetup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() !=WL_CONNECTED)
{
Serial.printf("WiFi Failed!\n");
return;
}
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
server.on("/", HTTP_GET, [](AsyncWebServerRequest*request)
{
request->send(200, "text/plain", "Hello, world");
});
// Send a GET request to<IP>/get?message=<message>server.on("/get", HTTP_GET, [](AsyncWebServerRequest*request)
{
Stringmessage;
if (request->hasParam(PARAM_MESSAGE))
{
message=request->getParam(PARAM_MESSAGE)->value();
}
else
{
message="No message sent";
}
Stringkey=crypto.generateKey();
crypto.setKey(key);
// let's make sure the key was set.// if the key is empty, it's likely your key doesn't have the right lengthkey=crypto.getKey();
Serial.printf("\nEncryption key: %s\n", key.c_str());
Stringplaintext="hello world!";
Serial.printf("Plaintext: '%s'\n", plaintext.c_str());
Stringciphertext=crypto.encrypt(plaintext);
if (ciphertext.length() ==0)
{
Serial.printf("Encryption failed (status %d)\n", crypto.lastStatus());
while (1) yield();
}
Serial.printf("Ciphertext: '%s'\n", ciphertext.c_str());
request->send(200, "text/plain", "Hello, GET: "+message);
});
// Send a POST request to<IP>/post with a form field message set to < message>server.on("/post", HTTP_POST, [](AsyncWebServerRequest*request)
{
Stringmessage;
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();
}
voidloop() {}
So here is my code, Its the simple_server example from
ESPAsyncWebServer.h
and encryption example fromPracticalCrypto.h
combined.The webserver works fine and I can see the
/
page, but the moment I open the/get
page, where the code for encryption exmple is, ESP8266 crashes. I tried removingwhile (1) yield();
but the problem is persistent.Is PracticalCrypto too much for ESP8266? So why is this happening?
Here last prints before crash
The text was updated successfully, but these errors were encountered: