P2P: ESP in AP mode and ESP in STA mode not working
Posted: Fri Jul 17, 2015 2:33 pm
Hello,
I have two ESPs. One is setup in AP mode the other in STA mode.
The problem I have is that the STA will not connect to the network that the AP sets up.
The STA will connect within 1 sec to my Home Wifi.
And I can connect to the AP with my phone/laptop.
Here's the code:
Server side
Client side
I have two ESPs. One is setup in AP mode the other in STA mode.
The problem I have is that the STA will not connect to the network that the AP sets up.
The STA will connect within 1 sec to my Home Wifi.
And I can connect to the AP with my phone/laptop.
Here's the code:
Server side
Code: Select all
#include <ESP8266WiFi.h>
#define LED_PIN 5
const char *ssid = "ESPap";
const char *passwd = "1234567890";
void setup()
{
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
SetupWiFi();
digitalWrite(LED_PIN, LOW);
}
void loop()
{
}
void SetupWiFi()
{
WiFi.mode(WIFI_AP);
WiFi.softAP(ssid, passwd);
}
Client side
Code: Select all
#include <ESP8266WiFi.h>
#define LED_PIN 5
const char *ssid = "ESPap";
const char *passwd = "1234567890";
byte LedState;
void setup()
{
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
ConnectWiFi();
digitalWrite(LED_PIN, LOW);
}
void loop()
{
}
void ConnectWiFi()
{
LedState = HIGH;
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, passwd);
while (WiFi.status() != WL_CONNECTED) {
LedState = (LedState == HIGH) ? LOW : HIGH;
digitalWrite(LED_PIN, LedState);
delay(100);
}
}