mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
compiling with EMSESP_DEBUG only sends to DEBUG log
This commit is contained in:
@@ -60,7 +60,7 @@ bool Shell::running() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Shell::start() {
|
void Shell::start() {
|
||||||
#ifdef EMSESP_DEBUG
|
#if defined(EMSESP_DEBUG)
|
||||||
uuid::log::Logger::register_handler(this, uuid::log::Level::DEBUG); // added for EMS-ESP
|
uuid::log::Logger::register_handler(this, uuid::log::Level::DEBUG); // added for EMS-ESP
|
||||||
#else
|
#else
|
||||||
uuid::log::Logger::register_handler(this, uuid::log::Level::INFO);
|
uuid::log::Logger::register_handler(this, uuid::log::Level::INFO);
|
||||||
|
|||||||
@@ -395,9 +395,7 @@ void AnalogSensor::remove_ha_topic(const uint8_t gpio) const {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMSESP_DEBUG
|
|
||||||
LOG_DEBUG("Removing HA config for analog sensor GPIO %02d", gpio);
|
LOG_DEBUG("Removing HA config for analog sensor GPIO %02d", gpio);
|
||||||
#endif
|
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf(topic, sizeof(topic), "sensor/%s/analogsensor_%02d/config", Mqtt::basename().c_str(), gpio);
|
snprintf(topic, sizeof(topic), "sensor/%s/analogsensor_%02d/config", Mqtt::basename().c_str(), gpio);
|
||||||
@@ -701,7 +699,7 @@ bool AnalogSensor::command_commands(const char * value, const int8_t id, JsonObj
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hard coded tests
|
// hard coded tests
|
||||||
#ifdef EMSESP_DEBUG
|
#if defined(EMSESP_DEBUG)
|
||||||
void AnalogSensor::test() {
|
void AnalogSensor::test() {
|
||||||
sensors_.emplace_back(36, "test12", 0, 0.1, 17, AnalogType::ADC);
|
sensors_.emplace_back(36, "test12", 0, 0.1, 17, AnalogType::ADC);
|
||||||
sensors_.back().set_value(12.4);
|
sensors_.back().set_value(12.4);
|
||||||
|
|||||||
@@ -52,10 +52,12 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
#ifdef EMSESP_DEBUG
|
#ifdef EMSESP_DEBUG
|
||||||
Serial.print("[DEBUG] processing path: ");
|
Serial.print("Processing path: ");
|
||||||
Serial.println(p.path().c_str()); // dump paths, for debugging
|
Serial.println(p.path().c_str()); // dump paths, for debugging
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
// re-calculate new path
|
// re-calculate new path
|
||||||
// if there is only a path (URL) and no body then error!
|
// if there is only a path (URL) and no body then error!
|
||||||
@@ -273,9 +275,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
|||||||
// except for system commands as this is a special device without any queryable entities (device values)
|
// except for system commands as this is a special device without any queryable entities (device values)
|
||||||
if ((device_type > EMSdevice::DeviceType::SYSTEM) && (!value || !strlen(value))) {
|
if ((device_type > EMSdevice::DeviceType::SYSTEM) && (!value || !strlen(value))) {
|
||||||
if (!cf || !cf->cmdfunction_json_) {
|
if (!cf || !cf->cmdfunction_json_) {
|
||||||
#if defined(EMSESP_DEBUG)
|
LOG_DEBUG("Calling %s command '%s' to retrieve attributes", dname, cmd);
|
||||||
LOG_DEBUG("[DEBUG] Calling %s command '%s' to retrieve attributes", dname, cmd);
|
|
||||||
#endif
|
|
||||||
return EMSESP::get_device_value_info(output, cmd, id, device_type) ? CommandRet::OK : CommandRet::ERROR; // entity = cmd
|
return EMSESP::get_device_value_info(output, cmd, id, device_type) ? CommandRet::OK : CommandRet::ERROR; // entity = cmd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,12 @@
|
|||||||
#include <uuid/log.h>
|
#include <uuid/log.h>
|
||||||
|
|
||||||
using uuid::log::Level;
|
using uuid::log::Level;
|
||||||
|
#if defined(EMSESP_DEBUG)
|
||||||
#define LOG_DEBUG(...) logger_.debug(__VA_ARGS__)
|
#define LOG_DEBUG(...) logger_.debug(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define LOG_DEBUG(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LOG_INFO(...) logger_.info(__VA_ARGS__)
|
#define LOG_INFO(...) logger_.info(__VA_ARGS__)
|
||||||
#define LOG_TRACE(...) logger_.trace(__VA_ARGS__)
|
#define LOG_TRACE(...) logger_.trace(__VA_ARGS__)
|
||||||
#define LOG_NOTICE(...) logger_.notice(__VA_ARGS__)
|
#define LOG_NOTICE(...) logger_.notice(__VA_ARGS__)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void DallasSensor::loop() {
|
|||||||
if (state_ == State::IDLE) {
|
if (state_ == State::IDLE) {
|
||||||
if (time_now - last_activity_ >= READ_INTERVAL_MS) {
|
if (time_now - last_activity_ >= READ_INTERVAL_MS) {
|
||||||
#ifdef EMSESP_DEBUG_SENSOR
|
#ifdef EMSESP_DEBUG_SENSOR
|
||||||
LOG_DEBUG("[DEBUG] Read sensor temperature");
|
LOG_DEBUG("Read sensor temperature");
|
||||||
#endif
|
#endif
|
||||||
if (bus_.reset() || parasite_) {
|
if (bus_.reset() || parasite_) {
|
||||||
YIELD;
|
YIELD;
|
||||||
@@ -456,9 +456,7 @@ void DallasSensor::remove_ha_topic(const std::string & id) {
|
|||||||
if (!Mqtt::ha_enabled()) {
|
if (!Mqtt::ha_enabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef EMSESP_DEBUG
|
|
||||||
LOG_DEBUG("Removing HA config for temperature sensor ID %s", id.c_str());
|
LOG_DEBUG("Removing HA config for temperature sensor ID %s", id.c_str());
|
||||||
#endif
|
|
||||||
// use '_' as HA doesn't like '-' in the topic name
|
// use '_' as HA doesn't like '-' in the topic name
|
||||||
std::string sensorid = id;
|
std::string sensorid = id;
|
||||||
std::replace(sensorid.begin(), sensorid.end(), '-', '_');
|
std::replace(sensorid.begin(), sensorid.end(), '-', '_');
|
||||||
@@ -600,9 +598,7 @@ bool DallasSensor::Sensor::apply_customization() {
|
|||||||
auto sensors = settings.sensorCustomizations;
|
auto sensors = settings.sensorCustomizations;
|
||||||
if (!sensors.empty()) {
|
if (!sensors.empty()) {
|
||||||
for (const auto & sensor : sensors) {
|
for (const auto & sensor : sensors) {
|
||||||
#if defined(EMSESP_DEBUG)
|
|
||||||
LOG_DEBUG("Loading customization for dallas sensor %s", sensor.id.c_str());
|
LOG_DEBUG("Loading customization for dallas sensor %s", sensor.id.c_str());
|
||||||
#endif
|
|
||||||
if (id_ == sensor.id) {
|
if (id_ == sensor.id) {
|
||||||
set_name(sensor.name);
|
set_name(sensor.name);
|
||||||
set_offset(sensor.offset);
|
set_offset(sensor.offset);
|
||||||
@@ -617,7 +613,7 @@ bool DallasSensor::Sensor::apply_customization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hard coded tests
|
// hard coded tests
|
||||||
#ifdef EMSESP_DEBUG
|
#if defined(EMSESP_DEBUG)
|
||||||
void DallasSensor::test() {
|
void DallasSensor::test() {
|
||||||
// add 2 dallas sensors
|
// add 2 dallas sensors
|
||||||
uint8_t addr[ADDR_LEN] = {1, 2, 3, 4, 5, 6, 7, 8};
|
uint8_t addr[ADDR_LEN] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||||
|
|||||||
@@ -216,9 +216,7 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(const ui
|
|||||||
return heating_circuit;
|
return heating_circuit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(EMSESP_DEBUG)
|
|
||||||
LOG_DEBUG("Heating circuit not fond on device 0x%02X", device_id());
|
LOG_DEBUG("Heating circuit not fond on device 0x%02X", device_id());
|
||||||
#endif
|
|
||||||
return nullptr; // not found
|
return nullptr; // not found
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3299,9 +3297,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
|||||||
write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid);
|
write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#if defined(EMSESP_DEBUG)
|
|
||||||
LOG_DEBUG("temperature mode %d not found", mode);
|
LOG_DEBUG("temperature mode %d not found", mode);
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,7 +283,9 @@ const std::string EMSdevice::to_string_short() {
|
|||||||
|
|
||||||
// for each telegram that has the fetch value set (true) do a read request
|
// for each telegram that has the fetch value set (true) do a read request
|
||||||
void EMSdevice::fetch_values() {
|
void EMSdevice::fetch_values() {
|
||||||
|
#if defined(EMSESP_DEBUG)
|
||||||
EMSESP::logger().debug("Fetching values for deviceID 0x%02X", device_id());
|
EMSESP::logger().debug("Fetching values for deviceID 0x%02X", device_id());
|
||||||
|
#endif
|
||||||
|
|
||||||
for (const auto & tf : telegram_functions_) {
|
for (const auto & tf : telegram_functions_) {
|
||||||
if (tf.fetch_) {
|
if (tf.fetch_) {
|
||||||
@@ -294,7 +296,9 @@ void EMSdevice::fetch_values() {
|
|||||||
|
|
||||||
// toggle on/off automatic fetch for a telegramID
|
// toggle on/off automatic fetch for a telegramID
|
||||||
void EMSdevice::toggle_fetch(uint16_t telegram_id, bool toggle) {
|
void EMSdevice::toggle_fetch(uint16_t telegram_id, bool toggle) {
|
||||||
|
#if defined(EMSESP_DEBUG)
|
||||||
EMSESP::logger().debug("Toggling fetch for deviceID 0x%02X, telegramID 0x%02X to %d", device_id(), telegram_id, toggle);
|
EMSESP::logger().debug("Toggling fetch for deviceID 0x%02X, telegramID 0x%02X to %d", device_id(), telegram_id, toggle);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (auto & tf : telegram_functions_) {
|
for (auto & tf : telegram_functions_) {
|
||||||
if (tf.telegram_type_id_ == telegram_id) {
|
if (tf.telegram_type_id_ == telegram_id) {
|
||||||
@@ -1480,7 +1484,7 @@ bool EMSdevice::get_value_info(JsonObject & output, const char * cmd, const int8
|
|||||||
// if we're filtering on an attribute, go find it
|
// if we're filtering on an attribute, go find it
|
||||||
if (attribute_s) {
|
if (attribute_s) {
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
EMSESP::logger().debug("[DEBUG] Attribute '%s'", attribute_s);
|
EMSESP::logger().debug("Attribute '%s'", attribute_s);
|
||||||
#endif
|
#endif
|
||||||
if (json.containsKey(attribute_s)) {
|
if (json.containsKey(attribute_s)) {
|
||||||
JsonVariant data = json[attribute_s];
|
JsonVariant data = json[attribute_s];
|
||||||
@@ -1765,7 +1769,9 @@ bool EMSdevice::handle_telegram(std::shared_ptr<const Telegram> telegram) {
|
|||||||
// if the data block is empty and we have not received data before, assume that this telegram
|
// if the data block is empty and we have not received data before, assume that this telegram
|
||||||
// is not recognized by the bus master. So remove it from the automatic fetch list
|
// is not recognized by the bus master. So remove it from the automatic fetch list
|
||||||
if (telegram->message_length == 0 && telegram->offset == 0 && !tf.received_) {
|
if (telegram->message_length == 0 && telegram->offset == 0 && !tf.received_) {
|
||||||
|
#if defined(EMSESP_DEBUG)
|
||||||
EMSESP::logger().debug("This telegram (%s) is not recognized by the EMS bus", tf.telegram_type_name_);
|
EMSESP::logger().debug("This telegram (%s) is not recognized by the EMS bus", tf.telegram_type_name_);
|
||||||
|
#endif
|
||||||
tf.fetch_ = false;
|
tf.fetch_ = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1430,7 +1430,7 @@ void EMSESP::start() {
|
|||||||
File root = LittleFS.open("/config");
|
File root = LittleFS.open("/config");
|
||||||
bool factory_settings = !root;
|
bool factory_settings = !root;
|
||||||
if (!root) {
|
if (!root) {
|
||||||
#ifdef EMSESP_DEBUG
|
#if defined(EMSESP_DEBUG)
|
||||||
Serial.println("No config found, assuming factory settings");
|
Serial.println("No config found, assuming factory settings");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1442,7 @@ void EMSESP::start() {
|
|||||||
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
|
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
|
||||||
webLogService.begin(); // start web log service. now we can start capturing logs to the web log
|
webLogService.begin(); // start web log service. now we can start capturing logs to the web log
|
||||||
|
|
||||||
#ifdef EMSESP_DEBUG
|
#if defined(EMSESP_DEBUG)
|
||||||
LOG_NOTICE("System is running in Debug mode");
|
LOG_NOTICE("System is running in Debug mode");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
27
src/mqtt.cpp
27
src/mqtt.cpp
@@ -372,7 +372,7 @@ void Mqtt::on_publish(uint16_t packetId) const {
|
|||||||
// find the MQTT message in the queue and remove it
|
// find the MQTT message in the queue and remove it
|
||||||
if (mqtt_messages_.empty()) {
|
if (mqtt_messages_.empty()) {
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
LOG_DEBUG("[DEBUG] No message stored for ACK pid %d", packetId);
|
LOG_DEBUG("No message stored for ACK pid %d", packetId);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -382,7 +382,7 @@ void Mqtt::on_publish(uint16_t packetId) const {
|
|||||||
// if the last published failed, don't bother checking it. wait for the next retry
|
// if the last published failed, don't bother checking it. wait for the next retry
|
||||||
if (mqtt_message.packet_id_ == 0) {
|
if (mqtt_message.packet_id_ == 0) {
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
LOG_DEBUG("[DEBUG] ACK for failed message pid 0");
|
LOG_DEBUG("ACK for failed message pid 0");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -393,7 +393,7 @@ void Mqtt::on_publish(uint16_t packetId) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
LOG_DEBUG("[DEBUG] ACK pid %d", packetId);
|
LOG_DEBUG("ACK pid %d", packetId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mqtt_messages_.pop_front(); // always remove from queue, regardless if there was a successful ACK
|
mqtt_messages_.pop_front(); // always remove from queue, regardless if there was a successful ACK
|
||||||
@@ -685,12 +685,12 @@ std::shared_ptr<const MqttMessage> Mqtt::queue_message(const uint8_t operation,
|
|||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
if (operation == Operation::PUBLISH) {
|
if (operation == Operation::PUBLISH) {
|
||||||
if (message->payload.empty()) {
|
if (message->payload.empty()) {
|
||||||
LOG_INFO("[DEBUG] Adding to queue: (publish) topic='%s' empty payload", message->topic.c_str());
|
LOG_INFO("Adding to queue: (publish) topic='%s' empty payload", message->topic.c_str());
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("[DEBUG] Adding to queue: (publish) topic='%s' payload=%s", message->topic.c_str(), message->payload.c_str());
|
LOG_INFO("Adding to queue: (publish) topic='%s' payload=%s", message->topic.c_str(), message->payload.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("[DEBUG] Adding to queue: (subscribe) topic='%s'", message->topic.c_str());
|
LOG_INFO("Adding to queue: (subscribe) topic='%s'", message->topic.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -773,7 +773,7 @@ void Mqtt::publish_ha(const char * topic) {
|
|||||||
|
|
||||||
std::string fulltopic = Mqtt::discovery_prefix() + topic;
|
std::string fulltopic = Mqtt::discovery_prefix() + topic;
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
LOG_DEBUG("[DEBUG] Publishing empty HA topic=%s", fulltopic.c_str());
|
LOG_DEBUG("Publishing empty HA topic=%s", fulltopic.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
queue_publish_message(fulltopic, "", true); // publish with retain to remove from broker
|
queue_publish_message(fulltopic, "", true); // publish with retain to remove from broker
|
||||||
@@ -793,7 +793,7 @@ void Mqtt::publish_ha(const char * topic, const JsonObject & payload) {
|
|||||||
#if defined(EMSESP_STANDALONE)
|
#if defined(EMSESP_STANDALONE)
|
||||||
LOG_DEBUG("Publishing HA topic=%s, payload=%s", fulltopic.c_str(), payload_text.c_str());
|
LOG_DEBUG("Publishing HA topic=%s, payload=%s", fulltopic.c_str(), payload_text.c_str());
|
||||||
#elif defined(EMSESP_DEBUG)
|
#elif defined(EMSESP_DEBUG)
|
||||||
LOG_DEBUG("[debug] Publishing HA topic=%s, payload=%s", fulltopic.c_str(), payload_text.c_str());
|
LOG_DEBUG("Publishing HA topic=%s, payload=%s", fulltopic.c_str(), payload_text.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// queue messages if the MQTT connection is not yet established. to ensure we don't miss messages
|
// queue messages if the MQTT connection is not yet established. to ensure we don't miss messages
|
||||||
@@ -823,7 +823,7 @@ void Mqtt::process_queue() {
|
|||||||
// it will have a real packet ID
|
// it will have a real packet ID
|
||||||
if (mqtt_message.packet_id_ > 0) {
|
if (mqtt_message.packet_id_ > 0) {
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
LOG_DEBUG("[DEBUG] Waiting for QOS-ACK");
|
LOG_DEBUG("Waiting for QOS-ACK");
|
||||||
#endif
|
#endif
|
||||||
// if we don't get the ack within 10 minutes, republish with new packet_id
|
// if we don't get the ack within 10 minutes, republish with new packet_id
|
||||||
if (uuid::get_uptime_sec() - last_publish_queue_ < 600) {
|
if (uuid::get_uptime_sec() - last_publish_queue_ < 600) {
|
||||||
@@ -870,6 +870,7 @@ void Mqtt::process_queue() {
|
|||||||
uint16_t packet_id = mqttClient_->publish(topic, mqtt_qos_, message->retain, message->payload.c_str(), message->payload.size(), false, mqtt_message.id_);
|
uint16_t packet_id = mqttClient_->publish(topic, mqtt_qos_, message->retain, message->payload.c_str(), message->payload.size(), false, mqtt_message.id_);
|
||||||
lasttopic_ = topic;
|
lasttopic_ = topic;
|
||||||
lastpayload_ = message->payload;
|
lastpayload_ = message->payload;
|
||||||
|
|
||||||
LOG_DEBUG("Publishing topic %s (#%02d, retain=%d, retry=%d, size=%d, pid=%d)",
|
LOG_DEBUG("Publishing topic %s (#%02d, retain=%d, retry=%d, size=%d, pid=%d)",
|
||||||
topic,
|
topic,
|
||||||
mqtt_message.id_,
|
mqtt_message.id_,
|
||||||
@@ -877,11 +878,11 @@ void Mqtt::process_queue() {
|
|||||||
mqtt_message.retry_count_ + 1,
|
mqtt_message.retry_count_ + 1,
|
||||||
message->payload.size(),
|
message->payload.size(),
|
||||||
packet_id);
|
packet_id);
|
||||||
#if defined(EMSESP_DEBUG)
|
|
||||||
if (!message->payload.empty()) {
|
if (!message->payload.empty()) {
|
||||||
LOG_DEBUG("Payload:%s", message->payload.c_str()); // extra message for #784
|
LOG_DEBUG("Payload:%s", message->payload.c_str()); // extra message for #784
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (packet_id == 0) {
|
if (packet_id == 0) {
|
||||||
// it failed. if we retried n times, give up. remove from queue
|
// it failed. if we retried n times, give up. remove from queue
|
||||||
if (mqtt_message.retry_count_ == (MQTT_PUBLISH_MAX_RETRY - 1)) {
|
if (mqtt_message.retry_count_ == (MQTT_PUBLISH_MAX_RETRY - 1)) {
|
||||||
@@ -901,9 +902,7 @@ void Mqtt::process_queue() {
|
|||||||
// but add the packet_id so we can check it later
|
// but add the packet_id so we can check it later
|
||||||
if (mqtt_qos_ != 0) {
|
if (mqtt_qos_ != 0) {
|
||||||
mqtt_messages_.front().packet_id_ = packet_id;
|
mqtt_messages_.front().packet_id_ = packet_id;
|
||||||
#if defined(EMSESP_DEBUG)
|
LOG_DEBUG("Setting packetID for ACK to %d", packet_id);
|
||||||
LOG_DEBUG("[DEBUG] Setting packetID for ACK to %d", packet_id);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,9 +211,7 @@ void RxService::add(uint8_t * data, uint8_t length) {
|
|||||||
LOG_TRACE("Rx: %s", Helpers::data_to_hex(data, length).c_str());
|
LOG_TRACE("Rx: %s", Helpers::data_to_hex(data, length).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMSESP_DEBUG
|
LOG_DEBUG("New Rx telegram, message length %d", message_length);
|
||||||
LOG_DEBUG("[DEBUG] New Rx telegram, message length %d", message_length);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// if we don't have a type_id exit,
|
// if we don't have a type_id exit,
|
||||||
// do not exit on empty message, it is checked for toggle fetch
|
// do not exit on empty message, it is checked for toggle fetch
|
||||||
@@ -443,9 +441,7 @@ void TxService::add(const uint8_t operation,
|
|||||||
const bool front) {
|
const bool front) {
|
||||||
auto telegram = std::make_shared<Telegram>(operation, ems_bus_id(), dest, type_id, offset, message_data, message_length);
|
auto telegram = std::make_shared<Telegram>(operation, ems_bus_id(), dest, type_id, offset, message_data, message_length);
|
||||||
|
|
||||||
#ifdef EMSESP_DEBUG
|
LOG_DEBUG("New Tx [#%d] telegram, length %d", tx_telegram_id_, message_length);
|
||||||
LOG_DEBUG("[DEBUG] New Tx [#%d] telegram, length %d", tx_telegram_id_, message_length);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// if the queue is full, make room by removing the last one
|
// if the queue is full, make room by removing the last one
|
||||||
if (tx_telegrams_.size() >= MAX_TX_TELEGRAMS) {
|
if (tx_telegrams_.size() >= MAX_TX_TELEGRAMS) {
|
||||||
@@ -507,9 +503,7 @@ void TxService::add(uint8_t operation, const uint8_t * data, const uint8_t lengt
|
|||||||
|
|
||||||
// if we don't have a type_id or empty data block, exit
|
// if we don't have a type_id or empty data block, exit
|
||||||
if ((type_id == 0) || (message_length == 0)) {
|
if ((type_id == 0) || (message_length == 0)) {
|
||||||
#ifdef EMSESP_DEBUG
|
LOG_DEBUG("Tx telegram type %d failed, length %d", type_id, message_length);
|
||||||
LOG_DEBUG("[DEBUG] Tx telegram type %d failed, length %d", type_id, message_length);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,9 +531,7 @@ void TxService::add(uint8_t operation, const uint8_t * data, const uint8_t lengt
|
|||||||
tx_telegrams_.pop_front();
|
tx_telegrams_.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMSESP_DEBUG
|
LOG_DEBUG("New Tx [#%d] telegram, length %d", tx_telegram_id_, message_length);
|
||||||
LOG_DEBUG("[DEBUG] New Tx [#%d] telegram, length %d", tx_telegram_id_, message_length);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (front) {
|
if (front) {
|
||||||
// tx_telegrams_.push_front(qtxt); // add to front of queue
|
// tx_telegrams_.push_front(qtxt); // add to front of queue
|
||||||
@@ -639,13 +631,11 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMSESP_DEBUG
|
LOG_DEBUG("Last Tx %s operation failed. Retry #%d. sent message: %s, received: %s",
|
||||||
LOG_DEBUG("[DEBUG] Last Tx %s operation failed. Retry #%d. sent message: %s, received: %s",
|
|
||||||
(operation == Telegram::Operation::TX_WRITE) ? ("Write") : ("Read"),
|
(operation == Telegram::Operation::TX_WRITE) ? ("Write") : ("Read"),
|
||||||
retry_count_,
|
retry_count_,
|
||||||
telegram_last_->to_string().c_str(),
|
telegram_last_->to_string().c_str(),
|
||||||
Helpers::data_to_hex(data, length - 1).c_str());
|
Helpers::data_to_hex(data, length - 1).c_str());
|
||||||
#endif
|
|
||||||
|
|
||||||
// add to the top of the queue
|
// add to the top of the queue
|
||||||
if (tx_telegrams_.size() >= MAX_TX_TELEGRAMS) {
|
if (tx_telegrams_.size() >= MAX_TX_TELEGRAMS) {
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
|
|||||||
emsesp::EMSESP::logger().err(error);
|
emsesp::EMSESP::logger().err(error);
|
||||||
api_fails_++;
|
api_fails_++;
|
||||||
} else {
|
} else {
|
||||||
// emsesp::EMSESP::logger().debug("API command called successfully");
|
|
||||||
// if there was no json output from the call, default to the output message 'OK'.
|
// if there was no json output from the call, default to the output message 'OK'.
|
||||||
if (!output.size()) {
|
if (!output.size()) {
|
||||||
output["message"] = "OK";
|
output["message"] = "OK";
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ void WebDataService::device_data(AsyncWebServerRequest * request, JsonVariant &
|
|||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
size_t length = response->setLength();
|
size_t length = response->setLength();
|
||||||
EMSESP::logger().debug("[DEBUG] Dashboard buffer used: %d", length);
|
EMSESP::logger().debug("Dashboard buffer used: %d", length);
|
||||||
#else
|
#else
|
||||||
response->setLength();
|
response->setLength();
|
||||||
#endif
|
#endif
|
||||||
@@ -245,7 +245,9 @@ void WebDataService::write_value(AsyncWebServerRequest * request, JsonVariant &
|
|||||||
if (return_code != CommandRet::OK) {
|
if (return_code != CommandRet::OK) {
|
||||||
EMSESP::logger().err("Write command failed %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str());
|
EMSESP::logger().err("Write command failed %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str());
|
||||||
} else {
|
} else {
|
||||||
|
#if defined(EMSESP_DEBUG)
|
||||||
EMSESP::logger().debug("Write command successful");
|
EMSESP::logger().debug("Write command successful");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
response->setCode((return_code == CommandRet::OK) ? 200 : 204);
|
response->setCode((return_code == CommandRet::OK) ? 200 : 204);
|
||||||
|
|||||||
Reference in New Issue
Block a user