2024-04-03 11:40:46 +07:00
|
|
|
#ifndef _AG_WIFI_CONNECTOR_H_
|
|
|
|
#define _AG_WIFI_CONNECTOR_H_
|
|
|
|
|
|
|
|
#include "AgOledDisplay.h"
|
2024-04-03 21:26:04 +07:00
|
|
|
#include "AgStateMachine.h"
|
2024-04-04 10:36:59 +07:00
|
|
|
#include "AirGradient.h"
|
2024-04-11 06:33:56 +07:00
|
|
|
#include "AgConfigure.h"
|
2024-04-03 21:26:04 +07:00
|
|
|
#include "Main/PrintLog.h"
|
2024-04-03 11:40:46 +07:00
|
|
|
|
2024-04-03 21:26:04 +07:00
|
|
|
#include <Arduino.h>
|
|
|
|
|
2024-04-07 16:39:01 +07:00
|
|
|
class WifiConnector : public PrintLog {
|
2024-04-03 11:40:46 +07:00
|
|
|
private:
|
2024-04-04 10:36:59 +07:00
|
|
|
AirGradient *ag;
|
2024-04-07 16:39:01 +07:00
|
|
|
#ifdef ESP32
|
|
|
|
OledDisplay &disp;
|
|
|
|
StateMachine &sm;
|
2024-04-11 06:33:56 +07:00
|
|
|
Configuration &config;
|
2024-04-07 16:39:01 +07:00
|
|
|
#else
|
|
|
|
void displayShowText(String ln1, String ln2, String ln3);
|
|
|
|
#endif
|
2024-04-03 21:26:04 +07:00
|
|
|
String ssid;
|
|
|
|
void *wifi = NULL;
|
2024-04-04 10:36:59 +07:00
|
|
|
bool hasConfig;
|
|
|
|
uint32_t lastRetry;
|
2024-04-22 14:24:01 +07:00
|
|
|
bool hasPortalConfig = false;
|
2024-04-03 21:26:04 +07:00
|
|
|
|
|
|
|
bool wifiClientConnected(void);
|
2024-04-04 10:36:59 +07:00
|
|
|
|
2024-04-03 11:40:46 +07:00
|
|
|
public:
|
2024-04-04 10:36:59 +07:00
|
|
|
void setAirGradient(AirGradient *ag);
|
2024-04-07 16:39:01 +07:00
|
|
|
#ifdef ESP32
|
2024-04-11 06:33:56 +07:00
|
|
|
WifiConnector(OledDisplay &disp, Stream &log, StateMachine &sm, Configuration& config);
|
2024-04-07 16:39:01 +07:00
|
|
|
#else
|
|
|
|
WifiConnector(Stream &log);
|
|
|
|
#endif
|
|
|
|
~WifiConnector();
|
|
|
|
|
2024-04-04 10:36:59 +07:00
|
|
|
bool connect(void);
|
2024-04-04 18:35:15 +07:00
|
|
|
void disconnect(void);
|
2024-04-04 10:36:59 +07:00
|
|
|
void handle(void);
|
2024-04-07 16:39:01 +07:00
|
|
|
#ifdef ESP32
|
2024-04-03 21:26:04 +07:00
|
|
|
void _wifiApCallback(void);
|
|
|
|
void _wifiSaveConfig(void);
|
|
|
|
void _wifiSaveParamCallback(void);
|
|
|
|
bool _wifiConfigPortalActive(void);
|
2024-04-07 16:39:01 +07:00
|
|
|
#endif
|
2024-04-03 21:26:04 +07:00
|
|
|
void _wifiProcess();
|
2024-04-04 10:36:59 +07:00
|
|
|
bool isConnected(void);
|
2024-04-04 18:35:15 +07:00
|
|
|
void reset(void);
|
|
|
|
int RSSI(void);
|
|
|
|
String localIpStr(void);
|
2024-05-13 15:07:10 +07:00
|
|
|
bool hasConfigurated(void);
|
2024-04-03 21:26:04 +07:00
|
|
|
};
|
2024-04-03 11:40:46 +07:00
|
|
|
|
|
|
|
#endif /** _AG_WIFI_CONNECTOR_H_ */
|