forked from Akcelerometry_drgania_WMT/PI_mikrokontroler
Dodanie folderów include i src
This commit is contained in:
92
include/Network.h
Normal file
92
include/Network.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#ifndef NETWORK_H
|
||||
#define NETWORK_H
|
||||
|
||||
#include "esp_log.h"
|
||||
#include <Arduino.h>
|
||||
#include <Config.h>
|
||||
|
||||
#ifdef ESP32
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
#include <ESPmDNS.h>
|
||||
#elif defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#endif
|
||||
|
||||
#include <DNSServer.h> // Dodano dla Captive Portal
|
||||
//#include <Pinout.h>
|
||||
//#include <IPAddress.h>
|
||||
//#include <WiFiUdp.h>
|
||||
|
||||
//#include <WiFiClientSecureBearSSL.h>
|
||||
|
||||
// OTA
|
||||
#include <HTTPUpdate.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <functional>
|
||||
// OTA
|
||||
|
||||
#include "Display.h" // Dodano dla obsługi komunikatów na LCD
|
||||
|
||||
extern Config config; // Deklaracja zewnętrznej struktury config
|
||||
extern ConfigManager configManager; // Deklaracja zewnętrznego managera (to naprawi błąd)
|
||||
|
||||
class WiFiManager {
|
||||
public:
|
||||
WiFiManager();
|
||||
void begin();
|
||||
void connectToWiFi();
|
||||
void setupAccessPoint(const char *newSSID, const char *newPassword);
|
||||
void checkWiFiConnection();
|
||||
void updateLED();
|
||||
void setupMDNS();
|
||||
void ReadConnection();
|
||||
bool isConnected(); // Zwraca stan połączenia
|
||||
bool convertCharToIPAddress(const char *str, IPAddress& ip);
|
||||
void ledBlink(); // Z innego projektu - niepotrzebne, bo nie ma LED WiFi...
|
||||
bool isWiFiOK(); // True, gdy WiFi połączone i false, gdy brak połączenia
|
||||
int rssiToPercent(int rssi); // rssi na procenty
|
||||
int8_t getRSSI();
|
||||
|
||||
/**
|
||||
* NOWA METODA: Portal konfiguracyjny (Captive Portal)
|
||||
* Uruchamiany automatycznie przy braku połączenia.
|
||||
*/
|
||||
void startConfigPortal(Display &display);
|
||||
|
||||
/**
|
||||
* Aktualizacja systemu przez internet z adresu config.updateUrl.
|
||||
* @param allowInsecureTLS true => dla https wyłącz weryfikację certyfikatu.
|
||||
* @param progressCb callback progress (opcjonalnie) (bytes, total).
|
||||
* @return true, jeśli update zakończony sukcesem (urządzenie się zrestartuje).
|
||||
*/
|
||||
bool performOTAUpdate(bool allowInsecureTLS = true, std::function<void(int,int)> progressCb = nullptr);
|
||||
|
||||
int8_t rssi = 0;
|
||||
bool useDHCP = true;
|
||||
IPAddress local_IP;
|
||||
IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
IPAddress dns;
|
||||
String ssidAP = "ACCEL666";
|
||||
String passwordAP = "12345678";
|
||||
|
||||
private:
|
||||
bool isAccessPoint = false;
|
||||
|
||||
// Obiekty serwerów dla Portalu (ESP32/ESP8266)
|
||||
#ifdef ESP32
|
||||
WebServer server{80};
|
||||
#elif defined(ESP8266)
|
||||
ESP8266WebServer server{80};
|
||||
#endif
|
||||
DNSServer dnsServer;
|
||||
void handleRoot();
|
||||
void handleSave();
|
||||
};
|
||||
|
||||
extern WiFiManager wifi;
|
||||
|
||||
#endif // WIFIMANAGER_H
|
||||
Reference in New Issue
Block a user