WEb access point : number max of client = 1 not possible ???

borgias511
Posts: 3
Joined: Mon Mar 04, 2019 10:10 am

WEb access point : number max of client = 1 not possible ???

Postby borgias511 » Mon Mar 04, 2019 10:27 am

Hi,

Sorry for my english.

I play a game and I want only one client to be connected at the same time at my web point acess

i put int max_connection =1;

but I can connect 2 client anyway ...

Code: Select all

#include "SPIFFS.h"
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif
#include <ESPmDNS.h>
 
// Set SSID nom réseau
const char* ssid= "toto";
// Set password
const char* password = "tata";

// Set Access Point IP
IPAddress   apIP(10, 10, 10, 1);
int max_connection =1; // nb client max

#define PIN 25 // pin connecté
#define NUMPIXELS 20 // Nb de Led
// Variables to store the most recent color sent to us by the client (i.e a web browser)
int red = 255;
int green = 255;
int blue = 255;

// Variables to store the current color of the pixels (we will compare with above to see if we need to update the color)
int currentRed = red;
int currentGreen = green;
int currentBlue = blue;

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 10; // delay for half a second   
 
AsyncWebServer server(80);
 
void setup(){
  Serial.begin(115200);
  pixels.begin(); // This initializes the NeoPixel library.
 
  if(!SPIFFS.begin()){
        Serial.println("Erreur de récupération des fichiers sur SPIFFS");
        return;
  }
  
 // Set Access Point configuration
    WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));   // ss réseau FF FF FF 00
    WiFi.softAP(ssid,password, max_connection);
 
  server.on("/html", HTTP_GET, [](AsyncWebServerRequest *request){ // Page de menu par défaut
    request->send(SPIFFS, "/vib.html", "text/html");
  });


  server.on("/UN", HTTP_GET, [](AsyncWebServerRequest *request){ // page UN
    request->send(SPIFFS, "/vib.html", "text/html");
      currentRed = 100;
      currentGreen = 255;
      currentBlue = 120;
  });
 
 
AdvertiseServices("toto");
  server.begin(); 
}
 
void loop(){
 
    turquoise (0,currentRed,currentGreen,currentBlue,delayval );
    retour(NUMPIXELS,0,0,0);
     }


void AdvertiseServices(const char *MyName)
{
  if (MDNS.begin(MyName))
  {
    Serial.println(F("mDNS responder started"));
    Serial.print(F("I am: "));
    Serial.println(MyName);
 
    // Add service to MDNS-SD
    MDNS.addService("n8i-mlp", "tcp", 23);
  }
  else
  {
    while (1) 
    {
      Serial.println(F("Error setting up MDNS responder"));
      delay(1000);
    }
  }
}
An idea ?

Thanks

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Re: WEb access point : number max of client = 1 not possible ???

Postby GeorgeFlorian1 » Mon Mar 04, 2019 11:58 am

borgias511 wrote: Hi,

Sorry for my english.

I play a game and I want only one client to be connected at the same time at my web point acess

i put int max_connection =1;

but I can connect 2 client anyway ...

Code: Select all

#include "SPIFFS.h"
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif
#include <ESPmDNS.h>
 
// Set SSID nom réseau
const char* ssid= "toto";
// Set password
const char* password = "tata";

// Set Access Point IP
IPAddress   apIP(10, 10, 10, 1);
int max_connection =1; // nb client max

#define PIN 25 // pin connecté
#define NUMPIXELS 20 // Nb de Led
// Variables to store the most recent color sent to us by the client (i.e a web browser)
int red = 255;
int green = 255;
int blue = 255;

// Variables to store the current color of the pixels (we will compare with above to see if we need to update the color)
int currentRed = red;
int currentGreen = green;
int currentBlue = blue;

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 10; // delay for half a second   
 
AsyncWebServer server(80);
 
void setup(){
  Serial.begin(115200);
  pixels.begin(); // This initializes the NeoPixel library.
 
  if(!SPIFFS.begin()){
        Serial.println("Erreur de récupération des fichiers sur SPIFFS");
        return;
  }
  
 // Set Access Point configuration
    WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));   // ss réseau FF FF FF 00
    WiFi.softAP(ssid,password, max_connection);
 
  server.on("/html", HTTP_GET, [](AsyncWebServerRequest *request){ // Page de menu par défaut
    request->send(SPIFFS, "/vib.html", "text/html");
  });


  server.on("/UN", HTTP_GET, [](AsyncWebServerRequest *request){ // page UN
    request->send(SPIFFS, "/vib.html", "text/html");
      currentRed = 100;
      currentGreen = 255;
      currentBlue = 120;
  });
 
 
AdvertiseServices("toto");
  server.begin(); 
}
 
void loop(){
 
    turquoise (0,currentRed,currentGreen,currentBlue,delayval );
    retour(NUMPIXELS,0,0,0);
     }


void AdvertiseServices(const char *MyName)
{
  if (MDNS.begin(MyName))
  {
    Serial.println(F("mDNS responder started"));
    Serial.print(F("I am: "));
    Serial.println(MyName);
 
    // Add service to MDNS-SD
    MDNS.addService("n8i-mlp", "tcp", 23);
  }
  else
  {
    while (1) 
    {
      Serial.println(F("Error setting up MDNS responder"));
      delay(1000);
    }
  }
}
An idea ?

Thanks

Hello !

I think that your problem is that you didn't overwrite the WiFi.softAP as you should have.

Here is the sofAP signature:

Code: Select all

bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden, int max_connection)
As you can see:
  • The first argument specifies the SSID: const char* ssid
  • The second argument specifies the password: const char* passphrase . Default is NULL
  • The third one specifies the channel: int channel . Default is 1
  • The fourth one specifies if the SSID will be hidden or not: int ssid_hidden . Default is 0 , meaning not hidden.
  • The fifth one specifies the maximum number of simultaneous connections: int max_connection . Default is 4
I think you should've written:

Code: Select all

WiFi.softAP(ssid, password, 1, 0, max_connection);
Try this and tell me if it worked.
Have a nice day.

Additional information:

Code: Select all

/**
 * Set up an access point
 * @param ssid              Pointer to the SSID (max 63 char).
 * @param passphrase        (for WPA2 min 8 char, for open use NULL)
 * @param channel           WiFi channel number, 1 - 13.
 * @param ssid_hidden       Network cloaking (0 = broadcast SSID, 1 = hide SSID)
 * @param max_connection    Max simultaneous connected clients, 1 - 4.
*/

borgias511
Posts: 3
Joined: Mon Mar 04, 2019 10:10 am

Re: WEb access point : number max of client = 1 not possible ???

Postby borgias511 » Tue Mar 05, 2019 11:09 pm

Yes ! perfect ! realy Thanks.

i have one another problem
viewtopic.php?f=19&t=9513
May be you have an idea

Who is online

Users browsing this forum: No registered users and 64 guests