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
I'm trying to set up a webpage with fixed IP-adress by using an Arduino Nano (master) and an ESP-01 (as a shield) in Station-, softAP- and combined mode. AT mode 3 = #44 .
Basically: I want to use two servers separated by the IP-adress and port. Is there a solution for in the WiFiEsp.h library?
My code for the webserver in softAP mode:
#include <Arduino.h>
#include <stddef.h>
#include <WiFiEsp.h>
bool AP = HIGH; //permanent aan of uit
char ssidAP[] = "MasterproefMateo"; // your AP network SSID (name)
char passAP[] = "*********"; // your AP network password min 8 karakters
IPAddress IpAP(192, 168, 1, 12); //Gewenst IP-adres van Acces Point
WiFiEspClient client;
WiFiEspServer server(80);
RingBuffer buf(8);
void setup() {
Serial1.begin(115200); //Serial1 programmed as Serial and ESP-01 connected by hardware.serial
WiFi.init(&Serial1);
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
i = LOW; }
if(i && AP){
statusAP = WiFi.beginAP(ssidAP, 11, passAP, ENC_TYPE_WPA2_PSK, true);
WiFi.configAP(IpAP);
IpAP = WiFi.APlocalIP(); //Modified version on .localIP() to force getIpAddressAP
}
if (statusAP == WL_CONNECTED){server.begin();}
}
void loop() {
WriteServer();
}
void WriteServer() {
WiFiEspClient client = server.available(); // listen for incoming clients
if (client) { // if you get a client,
buf.init(); // initialize the circular buffer
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
buf.push(c); // push it to the ring buffer
if (buf.endsWith("\r\n\r\n")) {
WebPage1(client);
break;
}
execute2();
}
}
delay(1);
client.stop();
}
}
My code for the webserver in Station mode: Same code but AP in names changed in WF and AP in commands ( .AP***) deleted.
(Works Fine)
What I would like to do and probably gonna need to write myself in te library:
#include <Arduino.h>
#include <stddef.h>
#include <WiFiEsp.h>
char ssidAP[] = "MasterproefMateo"; // your AP network SSID (name)
char passAP[] = "*********"; // your AP network password min 8 karakters
IPAddress IpAP(192, 168, 1, 12); //Gewenst IP-adres van Acces Point
char ssidWF[] = "MasterproefMateoWF"; // your AP network SSID (name)
char passWF[] = "*********"; // your AP network password min 8 karakters
IPAddress IpAP(192, 168, 1, 21); //Gewenst IP-adres van station
WiFiEspClient client;
WiFiEspServer serverAP(80);
WiFiEspServer serverWF(81);
RingBuffer buf(8);
void setup() {
Serial1.begin(115200); //Serial1 programmed as Serial and ESP-01 connected by hardware.serial
WiFi.init(&Serial1);
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
i = LOW; }
if(i){
statusAP = WiFi.beginAP(ssidAP, 11, passAP, ENC_TYPE_WPA2_PSK, false);
WiFi.configAP(IpAP);
IpAP = WiFi.APlocalIP(); //Modified version on .localIP() to force getIpAddressAP
statusWF = WiFi.begin(ssidWF, passWF, false);
WiFi.config(IpWF_setup);
IpWF = WiFi.localIP();
}
if (statusAP == WL_CONNECTED){serverAP = WiFiEspServer(WiFi.APlocalIP(), 80); serverAP.begin();}
if (statusWF == WL_CONNECTED){serverWF = WiFiEspServer(WiFi.localIP(), 81); serverWF.begin();}
}
void loop() {
WriteServer();
}
void WriteServer() {
WiFiEspClient client = serverAP.available(); // QUESTIONABLE
if (client) { // if you get a client,
buf.init(); // initialize the circular buffer
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
buf.push(c); // push it to the ring buffer
if (buf.endsWith("\r\n\r\n")) {
WebPage1(client);
break;
}
execute2();
}
}
delay(1);
client.stop();
}
WiFiEspClient client = serverWF.available(); // QUESTIONABLE
if (client) { // if you get a client,
buf.init(); // initialize the circular buffer
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
buf.push(c); // push it to the ring buffer
if (buf.endsWith("\r\n\r\n")) {
WebPage1(client);
break;
}
execute2();
}
}
delay(1);
client.stop();
}
}
The text was updated successfully, but these errors were encountered:
I'm trying to set up a webpage with fixed IP-adress by using an Arduino Nano (master) and an ESP-01 (as a shield) in Station-, softAP- and combined mode. AT mode 3 = #44 .
The webpage in station mode as well as the webpage in softAP mode are working fine. But when I lounge my code in combined mode only the webpage on the softAP is reachable. I found my similar question solved for the
ESP8266WiFi.h
library, but it is too late for me to switching from library.https://arduino.stackexchange.com/questions/67269/create-one-server-in-ap-mode-and-another-in-station-mode
Basically: I want to use two servers separated by the IP-adress and port. Is there a solution for in the
WiFiEsp.h
library?My code for the webserver in softAP mode:
My code for the webserver in Station mode:
Same code but AP in names changed in WF and AP in commands ( .AP***) deleted.
(Works Fine)
What I would like to do and probably gonna need to write myself in te library:
The text was updated successfully, but these errors were encountered: