Bonjour Dominique,
voici le code plus simple (meme si il reste tout de meme compliqué)
Il suffit de modifier les ligne 5, 6, 7 .
voici le code;
#if LWIP_FEATURES && !LWIP_IPV6
#define HAVE_NETDUMP 0
#ifndef STASSID
#define STASSID "SSID" //preciser ici le nom de votre wifi parent
#define STAPSK "PASS" //preciser ici le mot de pass de votre wifi
#define REPETEUR "Nouveau nom" //preciser ici le nom du wifi visible (le nom du répéteur)
#endif
#include <ESP8266WiFi.h>
#include <lwip/napt.h>
#include <lwip/dns.h>
#include <dhcpserver.h>
#define NAPT 1000
#define NAPT_PORT 10
#if HAVE_NETDUMP
#include <NetDump.h>
void dump(int netif_idx, const char* data, size_t len, int out, int success) {
(void)success;
Serial.print(out ? F("out ") : F(" in "));
Serial.printf("%d ", netif_idx);
// optional filter example: if (netDump_is_ARP(data))
{
netDump(Serial, data, len);
//netDumpHex(Serial, data, len);
}
}
#endif
void setup() {
pinMode(16, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
Serial.begin(115200);
Serial.printf("
NAPT Range extender
");
Serial.printf("Heap on start: %d
", ESP.getFreeHeap());
#if HAVE_NETDUMP
phy_capture = dump;
#endif
// first, connect to STA so we can get a proper local DNS server
WiFi.mode(WIFI_STA);
WiFi.begin(STASSID, STAPSK);
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
digitalWrite(4, HIGH);
delay(250);
digitalWrite(4, LOW);
delay(250);
}
Serial.printf("
STA: %s (dns: %s / %s)
",
WiFi.localIP().toString().c_str(),
WiFi.dnsIP(0).toString().c_str(),
WiFi.dnsIP(1).toString().c_str());
// give DNS servers to AP side
dhcps_set_dns(0, WiFi.dnsIP(0));
dhcps_set_dns(1, WiFi.dnsIP(1));
WiFi.softAPConfig( // enable AP, with android-compatible google domain
IPAddress(172, 217, 28, 254),
IPAddress(172, 217, 28, 254),
IPAddress(255, 255, 255, 0));
WiFi.softAP(REPETEUR, STAPSK);
Serial.printf("AP: %s
", WiFi.softAPIP().toString().c_str());
Serial.printf("Heap before: %d
", ESP.getFreeHeap());
err_t ret = ip_napt_init(NAPT, NAPT_PORT);
Serial.printf("ip_napt_init(%d,%d): ret=%d (OK=%d)
", NAPT, NAPT_PORT, (int)ret, (int)ERR_OK);
if (ret == ERR_OK) {
ret = ip_napt_enable_no(SOFTAP_IF, 1);
Serial.printf("ip_napt_enable_no(SOFTAP_IF): ret=%d (OK=%d)
", (int)ret, (int)ERR_OK);
if (ret == ERR_OK) {
}
}
Serial.printf("Heap after napt init: %d
", ESP.getFreeHeap());
if (ret != ERR_OK) {
Serial.printf("NAPT initialization failed
");
}
}
#else
void setup() {
Serial.begin(115200);
Serial.printf("
NAPT not supported in this configuration
");
}
#endif
void loop() {
}