updateNaming
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <FSPersistence.h>
|
||||
#include <HttpEndpoint.h>
|
||||
#include <FanMqttSettingsService.h>
|
||||
#include <MqttPubSub.h>
|
||||
|
||||
#include <OneWire.h>
|
||||
#include <DallasTemperature.h>
|
||||
@@ -33,7 +35,7 @@
|
||||
#define FAN_SETTINGS_ENDPOINT_PATH "/rest/fanState"
|
||||
|
||||
|
||||
class FanSettings {
|
||||
class FanState {
|
||||
public:
|
||||
bool fanStatus;
|
||||
int fanSpeed;
|
||||
@@ -47,7 +49,7 @@ class FanSettings {
|
||||
float sensorInTemp;
|
||||
float sensorOutTemp;
|
||||
|
||||
static void read(FanSettings& settings, JsonObject& root) {
|
||||
static void read(FanState& settings, JsonObject& root) {
|
||||
root["oneWire_gpio"] = settings.OneWireGPIO;
|
||||
root["sensor_in_temp"] = settings.sensorInTemp;
|
||||
root["sensor_out_temp"] = settings.sensorOutTemp;
|
||||
@@ -67,7 +69,7 @@ class FanSettings {
|
||||
String y = root["oneWire_gpio"]; Serial.println(" ** Fan read [oneWire_gpio : " + y + "]");
|
||||
}
|
||||
|
||||
static StateUpdateResult update(JsonObject& root, FanSettings& fanState) {
|
||||
static StateUpdateResult update(JsonObject& root, FanState& fanState) {
|
||||
boolean newFanState = root["fan_status"] | DEFAULT_FAN_STATE;
|
||||
int newFanPwmGPIO = root["fan_pwm_gpio"] | DEFAULT_FAN_PWM_GPIO;
|
||||
int newFanTachGPIO = root["fan_tach_gpio"] | DEFAULT_FAN_TACH_GPIO;
|
||||
@@ -97,13 +99,13 @@ class FanSettings {
|
||||
return StateUpdateResult::UNCHANGED;
|
||||
}
|
||||
|
||||
static void haRead(FanSettings& settings, JsonObject& root) {
|
||||
static void haRead(FanState& settings, JsonObject& root) {
|
||||
root["state"] = settings.fanStatus ? ON_STATE : OFF_STATE;
|
||||
String s = root["state"];
|
||||
Serial.println(" ** Fan haRead [" + s + "]");
|
||||
}
|
||||
|
||||
static StateUpdateResult haUpdate(JsonObject& root, FanSettings& fanState) {
|
||||
static StateUpdateResult haUpdate(JsonObject& root, FanState& fanState) {
|
||||
String state = root["state"];
|
||||
String s = root["state"];
|
||||
Serial.println(" ** Fan haUpdate [" + s + "]");
|
||||
@@ -123,7 +125,7 @@ class FanSettings {
|
||||
}
|
||||
};
|
||||
|
||||
class FanStateService : public StatefulService<FanSettings> {
|
||||
class FanStateService : public StatefulService<FanState> {
|
||||
public:
|
||||
unsigned long lastpoll;
|
||||
float Tin;
|
||||
@@ -133,7 +135,7 @@ class FanStateService : public StatefulService<FanSettings> {
|
||||
unsigned int RPM;
|
||||
|
||||
|
||||
FanStateService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
|
||||
FanStateService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager, AsyncMqttClient* mqttClient, FanMqttSettingsService* fanMQTTSettingsService);
|
||||
void begin();
|
||||
void save();
|
||||
void compute();
|
||||
@@ -141,8 +143,12 @@ class FanStateService : public StatefulService<FanSettings> {
|
||||
int getTachGPIO();
|
||||
|
||||
private:
|
||||
HttpEndpoint<FanSettings> _httpEndpoint;
|
||||
FSPersistence<FanSettings> _fsPersistence;
|
||||
HttpEndpoint<FanState> _httpEndpoint;
|
||||
FSPersistence<FanState> _fsPersistence;
|
||||
|
||||
FanMqttSettingsService* _fanMQTTSettingsService;
|
||||
AsyncMqttClient* _mqttClient;
|
||||
MqttPubSub<FanState> _mqttPubSub;
|
||||
|
||||
void registerConfig();
|
||||
void onConfigUpdated();
|
||||
|
||||
Reference in New Issue
Block a user