stub to remove #ifndef EMSESP_STANDALONE

This commit is contained in:
MichaelDvP
2025-12-08 12:42:11 +01:00
parent a365dc7519
commit 515b75160c
13 changed files with 38 additions and 118 deletions

View File

@@ -19,6 +19,8 @@
#include "esp32-psram/RingBufferStream.h" // Stream-based ring buffer
#include "esp32-psram/TypedRingBuffer.h" // Typed ring buffer for structured data
#define stringPSRAM std::basic_string<char, std::char_traits<char>, AllocatorPSRAM<char>>
#ifndef ESP32_PSRAM_NO_NAMESPACE
using namespace esp32_psram;
#endif

View File

@@ -0,0 +1,4 @@
#pragma once
#define stringPSRAM std::string
#define AllocatorPSRAM std::allocator

View File

@@ -130,7 +130,7 @@ void AnalogSensor::reload(bool get_nvs) {
for (const auto & sensor : settings.analogCustomizations) { // search customlist
if (sensor_.gpio() == sensor.gpio) {
// for output sensors set value to new start-value
if (sensor.type >= AnalogType::DIGITAL_OUT && sensor.type <= AnalogType::PWM_2
if (((sensor.type >= AnalogType::DIGITAL_OUT && sensor.type <= AnalogType::PWM_2) || sensor.type >= AnalogType::RGB)
&& (sensor_.type() != sensor.type || sensor_.offset() != sensor.offset || sensor_.factor() != sensor.factor)) {
sensor_.set_value(sensor.offset);
}
@@ -164,12 +164,11 @@ void AnalogSensor::reload(bool get_nvs) {
}
if (!found) {
// it's new, we assume it's valid
AnalogType type = static_cast<AnalogType>(sensor.type);
sensors_.emplace_back(sensor.gpio, sensor.name, sensor.offset, sensor.factor, sensor.uom, type, sensor.is_system);
sensors_.emplace_back(sensor.gpio, sensor.name, sensor.offset, sensor.factor, sensor.uom, sensor.type, sensor.is_system);
sensors_.back().ha_registered = false; // this will trigger recreate of the HA config
if (sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT
|| (sensor.type >= AnalogType::CNT_0 && sensor.type <= AnalogType::CNT_2)) {
if (sensor.type == AnalogType::COUNTER || (sensor.type >= AnalogType::DIGITAL_OUT && sensor.type <= AnalogType::PWM_2)
|| sensor.type == AnalogType::RGB || (sensor.type >= AnalogType::CNT_0 && sensor.type <= AnalogType::CNT_2)) {
sensors_.back().set_value(sensor.offset);
} else {
sensors_.back().set_value(0); // reset value only for new sensors
@@ -374,10 +373,10 @@ void AnalogSensor::measure() {
uint16_t a = analogReadMilliVolts(sensor.gpio()); // e.g. ADC1_CHANNEL_0_GPIO_NUM
if (!sensor.analog_) { // init first time
sensor.analog_ = a;
sensor.sum_ = a * 512;
sensor.sum_ = a * 128;
} else { // simple moving average filter
sensor.sum_ = (sensor.sum_ * 511) / 512 + a;
sensor.analog_ = sensor.sum_ / 512;
sensor.sum_ = (sensor.sum_ * 127) / 128 + a;
sensor.analog_ = sensor.sum_ / 128;
}
// detect change with little hysteresis on raw mV value
@@ -877,7 +876,8 @@ void AnalogSensor::get_value_json(JsonObject output, const Sensor & sensor) {
output["value"] = sensor.value();
output["readable"] = true;
output["writeable"] = sensor.type() == AnalogType::COUNTER || sensor.type() == AnalogType::RGB || sensor.type() == AnalogType::PULSE
|| (sensor.type() >= AnalogType::DIGITAL_OUT && sensor.type() <= AnalogType::PWM_2)|| (sensor.type() >= AnalogType::CNT_0 && sensor.type() <= AnalogType::CNT_2);
|| (sensor.type() >= AnalogType::DIGITAL_OUT && sensor.type() <= AnalogType::PWM_2)
|| (sensor.type() >= AnalogType::CNT_0 && sensor.type() <= AnalogType::CNT_2);
output["visible"] = true;
output["is_system"] = sensor.is_system();
if (sensor.type() == AnalogType::COUNTER || (sensor.type() >= AnalogType::CNT_0 && sensor.type() <= AnalogType::CNT_2)) {

View File

@@ -25,9 +25,7 @@
#include <uuid/log.h>
#ifndef EMSESP_STANDALONE
#include <esp32-psram.h>
#endif
namespace emsesp {
@@ -150,11 +148,7 @@ class AnalogSensor {
bool updated_values();
// return back reference to the sensor list, used by other classes
#ifndef EMSESP_STANDALONE
std::vector<Sensor, AllocatorPSRAM<Sensor>> sensors() const {
#else
std::vector<Sensor> sensors() const {
#endif
return sensors_;
}
@@ -205,11 +199,7 @@ class AnalogSensor {
void addSensorJson(JsonObject output, const Sensor & sensor);
void get_value_json(JsonObject output, const Sensor & sensor);
#ifndef EMSESP_STANDALONE
std::vector<Sensor, AllocatorPSRAM<Sensor>> sensors_; // our list of sensors
#else
std::vector<Sensor> sensors_; // our list of sensors
#endif
static std::vector<uint8_t> exclude_types_;
bool analog_enabled_;

View File

@@ -25,9 +25,7 @@
#include "helpers.h"
#include "emsdevicevalue.h"
#ifndef EMSESP_STANDALONE
#include <esp32-psram.h>
#endif
#include <unordered_map>
namespace emsesp {
@@ -552,21 +550,12 @@ class EMSdevice {
}
};
#ifndef EMSESP_STANDALONE
std::vector<uint16_t, AllocatorPSRAM<uint16_t>> handlers_ignored_, handlers_broadcasted_, handlers_config_;
#else
std::vector<uint16_t> handlers_ignored_, handlers_broadcasted_, handlers_config_;
#endif
#if defined(EMSESP_STANDALONE) || defined(EMSESP_TEST)
public: // so we can call it from WebCustomizationService::load_test_data() and EMSESP::dump_all_entities()
#endif
#ifndef EMSESP_STANDALONE
std::vector<TelegramFunction, AllocatorPSRAM<TelegramFunction>> telegram_functions_; // each EMS device has its own set of registered telegram types
std::vector<DeviceValue, AllocatorPSRAM<DeviceValue>> devicevalues_; // all the device values
#else
std::vector<TelegramFunction> telegram_functions_; // each EMS device has its own set of registered telegram types
std::vector<DeviceValue> devicevalues_; // all the device values
#endif
};
} // namespace emsesp

View File

@@ -72,9 +72,7 @@
#include "command.h"
#include "../emsesp_version.h"
#ifndef EMSESP_STANDALONE
#include <esp32-psram.h>
#endif
// Load external modules
class Module {}; // forward declaration
@@ -223,11 +221,7 @@ class EMSESP {
static void scan_devices();
static void clear_all_devices();
#ifndef EMSESP_STANDALONE
static std::vector<std::unique_ptr<EMSdevice>, AllocatorPSRAM<std::unique_ptr<EMSdevice>>> emsdevices;
#else
static std::vector<std::unique_ptr<EMSdevice>> emsdevices;
#endif
// services
static Mqtt mqtt_;
static Modbus * modbus_;
@@ -272,11 +266,8 @@ class EMSESP {
const char * default_name;
uint8_t flags;
};
#ifndef EMSESP_STANDALONE
static std::vector<Device_record, AllocatorPSRAM<Device_record>> device_library_;
#else
static std::vector<Device_record> device_library_;
#endif
static uint16_t watch_id_;
static uint8_t watch_;
static uint16_t read_id_;

View File

@@ -31,9 +31,9 @@
#include <esp_wifi.h>
#include <ETH.h>
#include <uuid/syslog.h>
#include <esp32-psram.h>
#endif
#include <esp32-psram.h>
#include <uuid/log.h>
#include <PButton.h>
@@ -395,17 +395,11 @@ class System {
void led_monitor();
void system_check();
#ifndef EMSESP_STANDALONE
static std::vector<uint8_t, AllocatorPSRAM<uint8_t>> string_range_to_vector(const std::string & range);
static std::vector<uint8_t, AllocatorPSRAM<uint8_t>> valid_system_gpios_; // list of valid GPIOs for the ESP32 board that can be used
static std::vector<uint8_t, AllocatorPSRAM<uint8_t>> used_gpios_; // list of GPIOs used by the application
#else
static std::vector<uint8_t> string_range_to_vector(const std::string & range);
static std::vector<uint8_t> valid_system_gpios_; // list of valid GPIOs for the ESP32 board that can be used
static std::vector<uint8_t> used_gpios_; // list of GPIOs used by the application
#endif
int8_t wifi_quality(int8_t dBm);
uint8_t healthcheck_ = HEALTHCHECK_NO_NETWORK | HEALTHCHECK_NO_BUS; // start with all flags set, no wifi and no ems bus connection

View File

@@ -31,9 +31,7 @@
#endif
#include "helpers.h"
#ifndef EMSESP_STANDALONE
#include <esp32-psram.h>
#endif
#define MAX_RX_TELEGRAMS 100 // size of Rx queue
#define MAX_TX_TELEGRAMS 160 // size of Tx queue
@@ -290,11 +288,7 @@ class RxService : public EMSbus {
}
};
#ifndef EMSESP_STANDALONE
std::deque<QueuedRxTelegram, AllocatorPSRAM<QueuedRxTelegram>> queue() const {
#else
std::deque<QueuedRxTelegram> queue() const {
#endif
return rx_telegrams_;
}
@@ -305,11 +299,8 @@ class RxService : public EMSbus {
uint32_t telegram_count_ = 0; // # Rx received
uint32_t telegram_error_count_ = 0; // # Rx CRC errors
std::shared_ptr<const Telegram> rx_telegram; // the incoming Rx telegram
#ifndef EMSESP_STANDALONE
std::deque<QueuedRxTelegram, AllocatorPSRAM<QueuedRxTelegram>> rx_telegrams_; // the Rx Queue
#else
std::deque<QueuedRxTelegram> rx_telegrams_; // the Rx Queue
#endif
};
class TxService : public EMSbus {
@@ -430,11 +421,7 @@ class TxService : public EMSbus {
}
};
#ifndef EMSESP_STANDALONE
std::deque<QueuedTxTelegram, AllocatorPSRAM<QueuedTxTelegram>> queue() const {
#else
std::deque<QueuedTxTelegram> queue() const {
#endif
return tx_telegrams_;
}
@@ -446,11 +433,7 @@ class TxService : public EMSbus {
static constexpr uint32_t POST_SEND_DELAY = 2000;
private:
#ifndef EMSESP_STANDALONE
std::deque<QueuedTxTelegram, AllocatorPSRAM<QueuedTxTelegram>> tx_telegrams_; // the Tx queue
#else
std::deque<QueuedTxTelegram> tx_telegrams_; // the Tx queue
#endif
uint32_t telegram_read_count_ = 0; // # Tx successful reads
uint32_t telegram_write_count_ = 0; // # Tx successful writes

View File

@@ -27,9 +27,10 @@
#include <uuid/log.h>
#include <esp32-psram.h>
#ifndef EMSESP_STANDALONE
#include <OneWire.h>
#include <esp32-psram.h>
#endif
namespace emsesp {

View File

@@ -16,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../core/telegram.h"
#ifndef EMSESP_STANDALONE
#include <esp32-psram.h>
#endif
#ifndef WebCustomEntityService_h
#define WebCustomEntityService_h
@@ -48,11 +46,7 @@ class CustomEntityItem {
class WebCustomEntity {
public:
#ifndef EMSESP_STANDALONE
std::list<CustomEntityItem, AllocatorPSRAM<CustomEntityItem>> customEntityItems;
#else
std::list<CustomEntityItem> customEntityItems;
#endif
static void read(WebCustomEntity & webEntity, JsonObject root);
static StateUpdateResult update(JsonObject root, WebCustomEntity & webEntity);
@@ -89,11 +83,8 @@ class WebCustomEntityService : public StatefulService<WebCustomEntity> {
void getEntities(AsyncWebServerRequest * request);
#ifndef EMSESP_STANDALONE
std::list<CustomEntityItem, AllocatorPSRAM<CustomEntityItem>> * customEntityItems_; // pointer to the list of entity items
#else
std::list<CustomEntityItem> * customEntityItems_; // pointer to the list of entity items
#endif
bool ha_registered_ = false;
};

View File

@@ -18,9 +18,7 @@
#ifndef WebCustomizationService_h
#define WebCustomizationService_h
#ifndef EMSESP_STANDALONE
#include <esp32-psram.h>
#endif
#define EMSESP_CUSTOMIZATION_FILE "/config/emsespCustomization.json"
@@ -73,15 +71,10 @@ class EntityCustomization {
class WebCustomization {
public:
#ifndef EMSESP_STANDALONE
std::list<SensorCustomization, AllocatorPSRAM<SensorCustomization>> sensorCustomizations; // for sensor names and offsets
std::list<AnalogCustomization, AllocatorPSRAM<AnalogCustomization>> analogCustomizations; // for analog sensors
std::list<EntityCustomization, AllocatorPSRAM<EntityCustomization>> entityCustomizations; // for a list of entities that have a special mask set
#else
std::list<SensorCustomization> sensorCustomizations; // for sensor names and offsets
std::list<AnalogCustomization> analogCustomizations; // for analog sensors
std::list<EntityCustomization> entityCustomizations; // for a list of entities that have a special mask set
#endif
static void read(WebCustomization & customizations, JsonObject root);
static StateUpdateResult update(JsonObject root, WebCustomization & customizations);

View File

@@ -21,10 +21,7 @@
#define EMSESP_EVENT_SOURCE_LOG_PATH "/es/log"
#define EMSESP_LOG_SETTINGS_PATH "/rest/logSettings"
#ifndef EMSESP_STANDALONE
#include <esp32-psram.h>
using stringPSRAM = std::basic_string<char, std::char_traits<char>, AllocatorPSRAM<char>>;
#endif
using ::uuid::console::Shell;
@@ -59,11 +56,7 @@ class WebLogService : public uuid::log::Handler {
uint64_t uptime_;
uuid::log::Level level_;
const char * name_;
#ifndef EMSESP_STANDALONE
stringPSRAM text_;
#else
std::string text_;
#endif
};
void transmit(const QueuedLogMessage & message);
@@ -71,11 +64,7 @@ class WebLogService : public uuid::log::Handler {
char * messagetime(char * out, const uint64_t t, const size_t bufsize);
#ifndef EMSESP_STANDALONE
std::deque<QueuedLogMessage, AllocatorPSRAM<QueuedLogMessage>> log_messages_; // Queued log messages, in the order they were received
#else
std::deque<QueuedLogMessage> log_messages_; // Queued log messages, in the order they were received
#endif
size_t maximum_log_messages_ = MAX_LOG_MESSAGES; // Maximum number of log messages to buffer before they are output
size_t limit_log_messages_ = 1; // dynamic limit
unsigned long log_message_id_ = 0; // The next identifier to use for queued log messages

View File

@@ -16,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EMSESP_STANDALONE
#include <esp32-psram.h>
#endif
#ifndef WebSchedulerService_h
#define WebSchedulerService_h
@@ -113,13 +111,8 @@ class WebSchedulerService : public StatefulService<WebScheduler> {
FSPersistence<WebScheduler> _fsPersistence;
bool ha_registered_ = false;
#ifndef EMSESP_STANDALONE
std::list<ScheduleItem, AllocatorPSRAM<ScheduleItem>> * scheduleItems_; // pointer to the list of schedule events
std::list<ScheduleItem *, AllocatorPSRAM<ScheduleItem *>> cmd_changed_; // pointer to commands in list that are triggert by change
#else
std::list<ScheduleItem> * scheduleItems_; // pointer to the list of schedule events
std::list<ScheduleItem *> cmd_changed_; // pointer to commands in list that are triggert by change
#endif
};
} // namespace emsesp