Files
arduino/src/AgWiFiConnector.h

57 lines
1.2 KiB
C
Raw Normal View History

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"
#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;
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;
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
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);
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);
void reset(void);
int RSSI(void);
String localIpStr(void);
bool hasConfigurated(void);
2024-04-03 21:26:04 +07:00
};
2024-04-03 11:40:46 +07:00
#endif /** _AG_WIFI_CONNECTOR_H_ */