mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 17:29:50 +03:00
refactor commands to its own class, implement rest API #506
This commit is contained in:
@@ -31,6 +31,12 @@ class DummySettings {
|
||||
String jwtSecret = "ems-esp";
|
||||
String ssid = "ems-esp";
|
||||
String password = "ems-esp";
|
||||
String localIP;
|
||||
String gatewayIP;
|
||||
String subnetMask;
|
||||
String staticIPConfig;
|
||||
String dnsIP1;
|
||||
String dnsIP2;
|
||||
uint16_t publish_time_boiler;
|
||||
uint16_t publish_time_thermostat;
|
||||
uint16_t publish_time_solar;
|
||||
@@ -105,4 +111,11 @@ class EMSESPSettingsService {
|
||||
private:
|
||||
};
|
||||
|
||||
class JsonUtils {
|
||||
public:
|
||||
static void writeIP(JsonObject & root, const String & key, const String & ip) {
|
||||
root[key] = ip;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,39 @@ class AsyncWebServerRequest;
|
||||
class AsyncWebServerResponse;
|
||||
class AsyncJsonResponse;
|
||||
|
||||
class AsyncWebParameter {
|
||||
private:
|
||||
String _name;
|
||||
String _value;
|
||||
size_t _size;
|
||||
bool _isForm;
|
||||
bool _isFile;
|
||||
|
||||
public:
|
||||
AsyncWebParameter(const String & name, const String & value, bool form = false, bool file = false, size_t size = 0)
|
||||
: _name(name)
|
||||
, _value(value)
|
||||
, _size(size)
|
||||
, _isForm(form)
|
||||
, _isFile(file) {
|
||||
}
|
||||
const String & name() const {
|
||||
return _name;
|
||||
}
|
||||
const String & value() const {
|
||||
return _value;
|
||||
}
|
||||
size_t size() const {
|
||||
return _size;
|
||||
}
|
||||
bool isPost() const {
|
||||
return _isForm;
|
||||
}
|
||||
bool isFile() const {
|
||||
return _isFile;
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
HTTP_GET = 0b00000001,
|
||||
HTTP_POST = 0b00000010,
|
||||
@@ -54,9 +87,41 @@ class AsyncWebServerRequest {
|
||||
void send(AsyncWebServerResponse * response){};
|
||||
void send(AsyncJsonResponse * response){};
|
||||
void send(int code, const String & contentType = String(), const String & content = String()){};
|
||||
void send(int code, const String & contentType, const __FlashStringHelper *){};
|
||||
|
||||
bool hasParam(const String & name, bool post, bool file) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasParam(const char * name, bool post, bool file) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasParam(const __FlashStringHelper * data) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasParam(const __FlashStringHelper * data, bool post, bool file) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
AsyncWebParameter * getParam(const String & name, bool post, bool file) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AsyncWebParameter * getParam(const __FlashStringHelper * data, bool post, bool file) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AsyncWebParameter * getParam(const __FlashStringHelper * data) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AsyncWebParameter * getParam(size_t num) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AsyncWebServerResponse * beginResponse(int code, const String & contentType = String(), const String & content = String()) {
|
||||
// AsyncWebServerResponse *a = new AsyncWebServerResponse()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,14 +33,13 @@ class String {
|
||||
return lhs;
|
||||
}
|
||||
|
||||
///
|
||||
bool isEmpty() {
|
||||
return _str.empty();
|
||||
}
|
||||
|
||||
// long toInt() const {
|
||||
// return std::stol(_str);
|
||||
// }
|
||||
long toInt() const {
|
||||
return std::stol(_str);
|
||||
}
|
||||
|
||||
bool equals(const char * s) {
|
||||
return _str == s;
|
||||
|
||||
Reference in New Issue
Block a user