3 bool isNetConnected = false;
7 const char* apMsg1 PROGMEM = "Активирована точка доступа ";
8 const char* apMsg2 PROGMEM = ", пароль ";
9 const char* apMsg3 PROGMEM = ", IP-адрес ";
11 void setupNet(bool AP) {
12 SSID = cfg.getCharValue(F("sta_ssid"));
13 PSK = cfg.getCharValue(F("sta_psk"));
14 if (SSID && SSID[0] && !AP) {
18 Serial.println(F("STA mode active"));
20 SSID = cfg.getCharValue(F("ap_ssid"));
21 PSK = cfg.getCharValue(F("ap_psk"));
22 if (!SSID || !SSID[0]) {
26 WiFi.softAP(SSID,PSK);
27 Serial.println(F("AP mode active"));
29 String IP = WiFi.softAPIP().toString();
31 strcpy_P(buf, apMsg1);
34 strcat_P(buf, apMsg2);
37 strcat_P(buf, apMsg3);
38 strcat(buf, IP.c_str());
45 if (WiFi.status() == WL_CONNECTED && !isNetConnected) {
46 isNetConnected = true;
47 Serial.print(F("Device connected to SSID ")); Serial.println(SSID);
48 message(F("Соединение установлено"));
49 } else if (WiFi.status() != WL_CONNECTED && isNetConnected) {
50 isNetConnected = false;
51 Serial.println(F("Network connection lost"));
52 message(F("Сеть потеряна"));