-->
Page 1 of 3

Connect STA to AP

PostPosted: Tue Jul 28, 2015 10:19 am
by noisette
Hello
I see on reference http://arduino.esp8266.com/versions/1.6.5-947-g39819f0/doc/reference.html that it is not possible to use multicast on AP interface so I was trying to connect the STA interface to AP interface but it doesn't seem to work
this is my code :
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "tagada";
const char* password = "azertyuiop";

void setup(void)
  {
  Serial.begin(115200);
  delay(2000);
  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid, password);
  delay(2000);
  wifiConnect();
  }

void loop(void)
  {
  delay(500);
  }

void wifiConnect()
  {
  WiFi.begin(ssid, password);
  // Wait for connection
  while(WiFi.status() != WL_CONNECTED)
    {
    delay(500);
    Serial.println("waiting");
    }
  Serial.println(WiFi.localIP());
  }

the second connexion never happens
i can connect to my acces point with another device
Does somebody know why I can't do that ?
thanks !

Re: Connect STA to AP

PostPosted: Tue Jul 28, 2015 10:26 am
by martinayotte
It is probably only that it requires to be init in STA+AP mode :
Code: Select allWiFi.mode(WIFI_AP_STA);

Re: Connect STA to AP

PostPosted: Tue Jul 28, 2015 11:11 am
by noisette
My mistake but it doesn't resolve the issue :/

new version of my code :
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "tagada";
const char* password = "azertyuiop";

void setup(void)
  {
  Serial.begin(115200);
  delay(2000);
  WiFi.mode(WIFI_AP_STA);
  WiFi.softAP(ssid, password);
  delay(2000);
  wifiConnect();
  }

void loop(void)
  {
  delay(500);
  }

void wifiConnect()
  {
  WiFi.begin(ssid, password);
  // Wait for connection
  while(WiFi.status() != WL_CONNECTED)
    {
    delay(500);
    Serial.println("waiting");
    }
  Serial.println(WiFi.localIP());
  }

Re: Connect STA to AP

PostPosted: Tue Jul 28, 2015 11:15 am
by noisette
also I add a WiFi.printDiag(Serial) in my connexion wait loop
I have this return :
waiting
Mode: STA+AP
PHY mode: N
Channel: 4
AP id: 0
Status: 1
Auto connect: 1
SSID (6): tagada
Passphrase (10): azertyuiop
BSSID set: 0
18:FE:34:F9:73:65
waiting
Mode: STA+AP
PHY mode: N
Channel: 1
AP id: 0
Status: 1
Auto connect: 1
SSID (6): tagada
Passphrase (10): azertyuiop
BSSID set: 0
18:FE:34:F9:73:65
waiting
Mode: STA+AP
PHY mode: N
Channel: 11
AP id: 0
Status: 1
Auto connect: 1
SSID (6): tagada
Passphrase (10): azertyuiop
BSSID set: 0
18:FE:34:F9:73:65


My Channel changes in continue :/ it is strange !