Skip to content

Commit

Permalink
new default_state flag
Browse files Browse the repository at this point in the history
  • Loading branch information
KipK committed May 2, 2023
1 parent f6da475 commit 2c43911
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ ConfigOpt *opts[] =
new ConfigOptVirtualBool(flagsOpt, CONFIG_FACTORY_WRITE_LOCK, CONFIG_FACTORY_WRITE_LOCK, "factory_write_lock", "fwl"),
new ConfigOptVirtualBool(flagsOpt, CONFIG_THREEPHASE, CONFIG_THREEPHASE, "is_threephase", "itp"),
new ConfigOptVirtualBool(flagsOpt, CONFIG_WIZARD, CONFIG_WIZARD, "wizard_passed", "wzp"),
new ConfigOptVirtualBool(flagsOpt, CONFIG_DEFAULT_STATE, CONFIG_DEFAULT_STATE, "default_state", "dfs"),
new ConfigOptVirtualMqttProtocol(flagsOpt, "mqtt_protocol", "mprt"),
new ConfigOptVirtualChargeMode(flagsOpt, "charge_mode", "chmd")
};
Expand Down
7 changes: 7 additions & 0 deletions src/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include "evse_state.h"

#ifndef ENABLE_CONFIG_V1_IMPORT
#define ENABLE_CONFIG_V1_IMPORT 1
Expand Down Expand Up @@ -119,6 +120,7 @@ extern uint32_t flags;
#define CONFIG_OCPP_OFFLINE_AUTH (1 << 23)
#define CONFIG_THREEPHASE (1 << 24)
#define CONFIG_WIZARD (1 << 25)
#define CONFIG_DEFAULT_STATE (1 << 26)

inline bool config_emoncms_enabled() {
return CONFIG_SERVICE_EMONCMS == (flags & CONFIG_SERVICE_EMONCMS);
Expand Down Expand Up @@ -205,6 +207,11 @@ inline bool config_wizard_passed()
return CONFIG_WIZARD == (flags & CONFIG_WIZARD);
}

inline EvseState config_default_state()
{
return CONFIG_DEFAULT_STATE == (flags & CONFIG_DEFAULT_STATE) ? EvseState::Active : EvseState::Disabled;
}

// Ohm Connect Settings
extern String ohm;

Expand Down
4 changes: 2 additions & 2 deletions src/evse_man.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ bool EvseManager::evaluateClaims(EvseProperties &properties)
{
// Clear the target state and set to active by default
properties.clear();
properties.setState(EvseState::Active);
properties.setState(config_default_state());

bool foundClaim = false;

Expand Down Expand Up @@ -456,7 +456,7 @@ bool EvseManager::release(EvseClient client)
event["claims_version"] = ++_version;
if (client == EvseClient_OpenEVSE_Manual) {
event["override_version"] = manual.setVersion(manual.getVersion() + 1);

}
event_send(event);
return true;
Expand Down

0 comments on commit 2c43911

Please sign in to comment.