This is the one working as a station altough both esp are configured as AP and STA because i´ll need them to change roles later. This esp connects with succes and it prints a confirmation in the serial monitor.
//ENTREGA MENSAJE(07)
#include <ESP8266WiFi.h>
char bandera;
WiFiServer Nserver(9001);
WiFiClient Nclient;
void setup() {
Serial.begin(115200);
WiFi.disconnect();
WiFi.mode(WIFI_AP_STA); //access point y estación
WiFi.softAP("modulo_01"); //nombre del AP
Nserver.begin();
WiFi.begin("modulo_07","",9001);
}
void loop() {
while(WiFi.status() != WL_CONNECTED){ //see if it connected
Serial.println("no connected");
delay(1000);
}
while(WiFi.status() == WL_CONNECTED){
Serial.println("connected");
Nclient.println('1');
Serial.println("bandera send :1");
delay(1000);
}
}
And this is the one working as an AP, it never seem to detect the client when it connects and keeps printing in the monitor "no client"
//RECIBE MENSAJE(01)
#include <ESP8266WiFi.h>
char bandera;
WiFiServer Nserver(9001);
WiFiClient Nclient;
void setup() {
Serial.begin(115200);
WiFi.disconnect();
WiFi.mode(WIFI_AP_STA); //access point y estación
WiFi.softAP("modulo_07"); //nombre del AP
Nserver.begin();
}
void loop() {
if(Nclient){
WiFiClient Nclient = Nserver.available();
Serial.println("client connected");
if(Nclient.available()){
bandera = Nclient.read();
Serial.println(bandera);
Serial.println("bandera received : 1");
}
}
else{
Serial.println("no client");
delay(500);
}
}