WEb access point : number max of client = 1 not possible ???
Posted: 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 ...
An idea ?
Thanks
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);
}
}
}
Thanks