mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
@@ -12,6 +12,10 @@ export function restart(): AxiosPromise<void> {
|
||||
return AXIOS.post('/restart');
|
||||
}
|
||||
|
||||
export function partition(): AxiosPromise<void> {
|
||||
return AXIOS.post('/partition');
|
||||
}
|
||||
|
||||
export function factoryReset(): AxiosPromise<void> {
|
||||
return AXIOS.post('/factoryReset');
|
||||
}
|
||||
|
||||
@@ -87,7 +87,19 @@ const SystemStatusForm: FC = () => {
|
||||
setProcessing(true);
|
||||
try {
|
||||
await SystemApi.restart();
|
||||
enqueueSnackbar(LL.APPLICATION_RESTARTING(), { variant: 'info' });
|
||||
setRestarting(true);
|
||||
} catch (error) {
|
||||
enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_LOADING()), { variant: 'error' });
|
||||
} finally {
|
||||
setConfirmRestart(false);
|
||||
setProcessing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const partition = async () => {
|
||||
setProcessing(true);
|
||||
try {
|
||||
await SystemApi.partition();
|
||||
setRestarting(true);
|
||||
} catch (error) {
|
||||
enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_LOADING()), { variant: 'error' });
|
||||
@@ -121,6 +133,17 @@ const SystemStatusForm: FC = () => {
|
||||
>
|
||||
{LL.RESTART()}
|
||||
</Button>
|
||||
{data?.has_loader && (
|
||||
<Button
|
||||
startIcon={<PowerSettingsNewIcon />}
|
||||
variant="outlined"
|
||||
onClick={partition}
|
||||
disabled={processing}
|
||||
color="primary"
|
||||
>
|
||||
EMS-ESP-Loader
|
||||
</Button>
|
||||
)}
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -25,6 +25,7 @@ import * as EMSESP from './api';
|
||||
import { Settings, BOARD_PROFILES } from './types';
|
||||
|
||||
import { useI18nContext } from '../i18n/i18n-react';
|
||||
import RestartMonitor from '../framework/system/RestartMonitor';
|
||||
|
||||
export function boardProfileSelectItems() {
|
||||
return Object.keys(BOARD_PROFILES).map((code) => (
|
||||
@@ -39,6 +40,7 @@ const SettingsApplication: FC = () => {
|
||||
read: EMSESP.readSettings,
|
||||
update: EMSESP.writeSettings
|
||||
});
|
||||
const [restarting, setRestarting] = useState<boolean>();
|
||||
|
||||
const { LL } = useI18nContext();
|
||||
|
||||
@@ -106,7 +108,7 @@ const SettingsApplication: FC = () => {
|
||||
validateAndSubmit();
|
||||
try {
|
||||
await EMSESP.restart();
|
||||
enqueueSnackbar(LL.APPLICATION_RESTARTING(), { variant: 'info' });
|
||||
setRestarting(true);
|
||||
} catch (error) {
|
||||
enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_UPDATING()), { variant: 'error' });
|
||||
}
|
||||
@@ -617,7 +619,7 @@ const SettingsApplication: FC = () => {
|
||||
|
||||
return (
|
||||
<SectionContent title={LL.APPLICATION_SETTINGS()} titleGutter>
|
||||
{content()}
|
||||
{restarting ? <RestartMonitor /> : content()}
|
||||
</SectionContent>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface SystemStatus {
|
||||
free_mem: number;
|
||||
psram_size?: number;
|
||||
free_psram?: number;
|
||||
has_loader: boolean;
|
||||
}
|
||||
|
||||
export interface OTASettings {
|
||||
|
||||
@@ -1,12 +1,27 @@
|
||||
#include <RestartService.h>
|
||||
#include <esp_ota_ops.h>
|
||||
|
||||
using namespace std::placeholders; // for `_1` etc
|
||||
|
||||
RestartService::RestartService(AsyncWebServer * server, SecurityManager * securityManager) {
|
||||
server->on(RESTART_SERVICE_PATH, HTTP_POST, securityManager->wrapRequest(std::bind(&RestartService::restart, this, _1), AuthenticationPredicates::IS_ADMIN));
|
||||
server->on(PARTITION_SERVICE_PATH,
|
||||
HTTP_POST,
|
||||
securityManager->wrapRequest(std::bind(&RestartService::partition, this, _1), AuthenticationPredicates::IS_ADMIN));
|
||||
}
|
||||
|
||||
void RestartService::restart(AsyncWebServerRequest * request) {
|
||||
request->onDisconnect(RestartService::restartNow);
|
||||
request->send(200);
|
||||
}
|
||||
|
||||
void RestartService::partition(AsyncWebServerRequest * request) {
|
||||
const esp_partition_t * factory_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
|
||||
if (!factory_partition) {
|
||||
request->send(400); // bad request
|
||||
return;
|
||||
}
|
||||
esp_ota_set_boot_partition(factory_partition);
|
||||
request->onDisconnect(RestartService::restartNow);
|
||||
request->send(200);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <SecurityManager.h>
|
||||
|
||||
#define RESTART_SERVICE_PATH "/rest/restart"
|
||||
#define PARTITION_SERVICE_PATH "/rest/partition"
|
||||
|
||||
class RestartService {
|
||||
public:
|
||||
@@ -21,6 +22,7 @@ class RestartService {
|
||||
|
||||
private:
|
||||
void restart(AsyncWebServerRequest * request);
|
||||
void partition(AsyncWebServerRequest * request);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
// Boilers - 0x08
|
||||
{ 64, DeviceType::BOILER, "BK13/BK15/Smartline/GB1x2", DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||
{ 72, DeviceType::BOILER, "GB125/MC10", DeviceFlags::EMS_DEVICE_FLAG_EMS},
|
||||
{ 72, DeviceType::BOILER, "GB125/GB135/MC10", DeviceFlags::EMS_DEVICE_FLAG_EMS},
|
||||
{ 81, DeviceType::BOILER, "Cascade CM10", DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||
{ 84, DeviceType::BOILER, "Logamax Plus GB022", DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||
{ 95, DeviceType::BOILER, "Condens 2500/Logamax/Logomatic/Cerapur Top/Greenstar/Generic HT3", DeviceFlags::EMS_DEVICE_FLAG_HT3},
|
||||
|
||||
@@ -274,6 +274,10 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
|
||||
DeviceValueTAG::TAG_DEVICE_DATA, &burnMaxPower_, DeviceValueType::UINT, FL_(burnMaxPower), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_max_power), 0, 254);
|
||||
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &boilHystOn_, DeviceValueType::INT, FL_(boilHystOn), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_hyst_on));
|
||||
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &boilHystOff_, DeviceValueType::INT, FL_(boilHystOff), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_hyst_off));
|
||||
register_device_value(
|
||||
DeviceValueTAG::TAG_DEVICE_DATA, &boil2HystOn_, DeviceValueType::INT, FL_(boil2HystOn), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_hyst2_on), -20, 0);
|
||||
register_device_value(
|
||||
DeviceValueTAG::TAG_DEVICE_DATA, &boil2HystOff_, DeviceValueType::INT, FL_(boil2HystOff), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_hyst2_off), 0, 20);
|
||||
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &setFlowTemp_, DeviceValueType::UINT, FL_(setFlowTemp), DeviceValueUOM::DEGREES);
|
||||
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &setBurnPow_, DeviceValueType::UINT, FL_(setBurnPow), DeviceValueUOM::PERCENT);
|
||||
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &curBurnPow_, DeviceValueType::UINT, FL_(curBurnPow), DeviceValueUOM::PERCENT);
|
||||
@@ -829,6 +833,8 @@ void Boiler::process_UBAParameters(std::shared_ptr<const Telegram> telegram) {
|
||||
has_update(telegram, pumpDelay_, 8);
|
||||
has_update(telegram, pumpModMax_, 9);
|
||||
has_update(telegram, pumpModMin_, 10);
|
||||
has_update(telegram, boil2HystOff_, 12);
|
||||
has_update(telegram, boil2HystOn_, 13);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1981,7 +1987,7 @@ bool Boiler::set_hyst_on(const char * value, const int8_t id) {
|
||||
if (is_fetch(EMS_TYPE_UBAParametersPlus)) {
|
||||
write_command(EMS_TYPE_UBAParametersPlus, 9, v, EMS_TYPE_UBAParametersPlus);
|
||||
} else {
|
||||
write_command(EMS_TYPE_UBAParameters, 5, v, EMS_TYPE_UBAParameters);
|
||||
write_command(EMS_TYPE_UBAParameters, id == 2 ? 13 : 5, v, EMS_TYPE_UBAParameters);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1997,7 +2003,7 @@ bool Boiler::set_hyst_off(const char * value, const int8_t id) {
|
||||
if (is_fetch(EMS_TYPE_UBAParametersPlus)) {
|
||||
write_command(EMS_TYPE_UBAParametersPlus, 8, v, EMS_TYPE_UBAParametersPlus);
|
||||
} else {
|
||||
write_command(EMS_TYPE_UBAParameters, 4, v, EMS_TYPE_UBAParameters);
|
||||
write_command(EMS_TYPE_UBAParameters, id == 2 ? 12 : 4, v, EMS_TYPE_UBAParameters);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -124,6 +124,8 @@ class Boiler : public EMSdevice {
|
||||
uint8_t burnMaxPower_;
|
||||
int8_t boilHystOn_;
|
||||
int8_t boilHystOff_;
|
||||
int8_t boil2HystOn_;
|
||||
int8_t boil2HystOff_;
|
||||
uint8_t setFlowTemp_; // boiler setpoint temp
|
||||
uint8_t curBurnPow_; // Burner current power %
|
||||
uint8_t setBurnPow_; // max output power in %
|
||||
@@ -319,6 +321,12 @@ class Boiler : public EMSdevice {
|
||||
bool set_max_pump(const char * value, const int8_t id);
|
||||
bool set_hyst_on(const char * value, const int8_t id);
|
||||
bool set_hyst_off(const char * value, const int8_t id);
|
||||
bool set_hyst2_on(const char * value, const int8_t id) {
|
||||
return set_hyst_on(value, 2);
|
||||
}
|
||||
bool set_hyst2_off(const char * value, const int8_t id) {
|
||||
return set_hyst_off(value, 2);
|
||||
}
|
||||
bool set_burn_period(const char * value, const int8_t id);
|
||||
bool set_pump_delay(const char * value, const int8_t id);
|
||||
bool set_reset(const char * value, const int8_t id);
|
||||
|
||||
@@ -847,7 +847,8 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
// handle unknown broadcasted telegrams
|
||||
if (!found && telegram->dest == 0) {
|
||||
LOG_DEBUG("No telegram type handler found for ID 0x%02X (src 0x%02X)", telegram->type_id, telegram->src);
|
||||
if (watch() == WATCH_UNKNOWN) {
|
||||
LOG_NOTICE("%s", pretty_telegram(telegram).c_str());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1306,18 +1306,7 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
|
||||
(int8_t)EMSESP::system_.eth_phy_addr_,
|
||||
(int8_t)EMSESP::system_.eth_clock_mode_};
|
||||
} else {
|
||||
// unknown, use defaults and return false
|
||||
data = {
|
||||
EMSESP_DEFAULT_LED_GPIO,
|
||||
EMSESP_DEFAULT_DALLAS_GPIO,
|
||||
EMSESP_DEFAULT_RX_GPIO,
|
||||
EMSESP_DEFAULT_TX_GPIO,
|
||||
EMSESP_DEFAULT_PBUTTON_GPIO,
|
||||
EMSESP_DEFAULT_PHY_TYPE,
|
||||
-1, // power
|
||||
0, // phy_addr,
|
||||
0 // clock_mode
|
||||
};
|
||||
// unknown, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,14 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)
|
||||
settings.board_profile = root["board_profile"] | EMSESP_DEFAULT_BOARD_PROFILE;
|
||||
#endif
|
||||
if (!System::load_board_profile(data, settings.board_profile.c_str())) {
|
||||
settings.board_profile = "CUSTOM";
|
||||
// unknown, check for ethernet, use default E32/S32
|
||||
if (ETH.begin(1, 16, 23, 18, ETH_PHY_LAN8720)) {
|
||||
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0}; // BBQKees Gateway E32
|
||||
settings.board_profile = "E32";
|
||||
} else {
|
||||
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // BBQKees Gateway S32
|
||||
settings.board_profile = "S32";
|
||||
}
|
||||
EMSESP::logger().info("No board profile found. Re-setting to %s", settings.board_profile.c_str());
|
||||
} else {
|
||||
EMSESP::logger().info("Loading board profile %s", settings.board_profile.c_str());
|
||||
|
||||
Reference in New Issue
Block a user