mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-21 15:47:06 +01:00
Core 2.6.0+ fixes (#1852)
* Core 2.6.0+ fixes * fix env -> config, run travis04 job * don't duplicate free heap in frag data, use single stats struct * fix dtostrf warnings, bump buffer sizes * ...and even less words for fragmentation stat
This commit is contained in:
@@ -635,7 +635,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef API_BUFFER_SIZE
|
||||
#define API_BUFFER_SIZE 15 // Size of the buffer for HTTP GET API responses
|
||||
#define API_BUFFER_SIZE 64 // Size of the buffer for HTTP GET API responses
|
||||
#endif
|
||||
|
||||
#ifndef API_REAL_TIME_VALUES
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace EspClass_has_getHeapStats {
|
||||
template <typename T>
|
||||
struct detector : public _detector {
|
||||
using result = decltype(
|
||||
std::declval<detector>().detect<T>(0));
|
||||
std::declval<detector>().template detect<T>(0));
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -96,13 +96,10 @@ void infoMemory(const char* name, const heap_stats_t& stats) {
|
||||
|
||||
void infoHeapStats(const char* name, const heap_stats_t& stats) {
|
||||
DEBUG_MSG_P(
|
||||
PSTR("[MAIN] %-6s: %5u bytes available | %5u bytes lost (%2u%%) | %5u bytes free (%2u%%)\n"),
|
||||
PSTR("[MAIN] %-6s: %5u contiguous bytes available (%u%% fragmentation)\n"),
|
||||
name,
|
||||
stats.available,
|
||||
(stats.available - stats.usable),
|
||||
stats.frag_pct,
|
||||
stats.usable,
|
||||
(100 - stats.frag_pct)
|
||||
stats.frag_pct
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -814,11 +814,11 @@ void relaySetupAPI() {
|
||||
snprintf_P(key, sizeof(key), PSTR("%s/%d"), MQTT_TOPIC_PULSE, relayID);
|
||||
apiRegister(key,
|
||||
[relayID](char * buffer, size_t len) {
|
||||
dtostrf((double) _relays[relayID].pulse_ms / 1000, 1-len, 3, buffer);
|
||||
dtostrf((double) _relays[relayID].pulse_ms / 1000, 1, 3, buffer);
|
||||
},
|
||||
[relayID](const char * payload) {
|
||||
|
||||
unsigned long pulse = 1000 * String(payload).toFloat();
|
||||
unsigned long pulse = 1000 * atof(payload);
|
||||
if (0 == pulse) return;
|
||||
|
||||
if (RELAY_PULSE_NONE != _relays[relayID].pulse) {
|
||||
@@ -963,7 +963,7 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long pulse = 1000 * String(payload).toFloat();
|
||||
unsigned long pulse = 1000 * atof(payload);
|
||||
if (0 == pulse) return;
|
||||
|
||||
if (RELAY_PULSE_NONE != _relays[id].pulse) {
|
||||
|
||||
@@ -209,7 +209,7 @@ void _sensorWebSocketMagnitudesConfig(JsonObject& root) {
|
||||
|
||||
void _sensorWebSocketSendData(JsonObject& root) {
|
||||
|
||||
char buffer[10];
|
||||
char buffer[64];
|
||||
|
||||
JsonObject& magnitudes = root.createNestedObject("magnitudes");
|
||||
uint8_t size = 0;
|
||||
@@ -223,7 +223,7 @@ void _sensorWebSocketSendData(JsonObject& root) {
|
||||
++size;
|
||||
|
||||
double value_show = _magnitudeProcess(magnitude.type, magnitude.decimals, magnitude.last);
|
||||
dtostrf(value_show, 1-sizeof(buffer), magnitude.decimals, buffer);
|
||||
dtostrf(value_show, 1, magnitude.decimals, buffer);
|
||||
|
||||
value.add(buffer);
|
||||
error.add(magnitude.sensor->error());
|
||||
@@ -337,7 +337,7 @@ void _sensorAPISetup() {
|
||||
apiRegister(topic.c_str(), [magnitude_id](char * buffer, size_t len) {
|
||||
sensor_magnitude_t magnitude = _magnitudes[magnitude_id];
|
||||
double value = _sensor_realtime ? magnitude.last : magnitude.reported;
|
||||
dtostrf(value, 1-len, magnitude.decimals, buffer);
|
||||
dtostrf(value, 1, magnitude.decimals, buffer);
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1480,8 +1480,11 @@ void _sensorReport(unsigned char index, double value) {
|
||||
sensor_magnitude_t magnitude = _magnitudes[index];
|
||||
unsigned char decimals = magnitude.decimals;
|
||||
|
||||
char buffer[10];
|
||||
dtostrf(value, 1-sizeof(buffer), decimals, buffer);
|
||||
// XXX: ensure that the received 'value' will fit here
|
||||
// dtostrf 2nd arg only controls leading zeroes and the
|
||||
// 3rd is only for the part after the dot
|
||||
char buffer[64];
|
||||
dtostrf(value, 1, decimals, buffer);
|
||||
|
||||
#if BROKER_SUPPORT
|
||||
brokerPublish(BROKER_MSG_TYPE_SENSOR ,magnitudeTopic(magnitude.type).c_str(), magnitude.local, buffer);
|
||||
@@ -1748,7 +1751,7 @@ void sensorLoop() {
|
||||
#if SENSOR_DEBUG
|
||||
{
|
||||
char buffer[64];
|
||||
dtostrf(value_show, 1-sizeof(buffer), magnitude.decimals, buffer);
|
||||
dtostrf(value_show, 1, magnitude.decimals, buffer);
|
||||
DEBUG_MSG_P(PSTR("[SENSOR] %s - %s: %s%s\n"),
|
||||
magnitude.sensor->slot(magnitude.local).c_str(),
|
||||
magnitudeTopic(magnitude.type).c_str(),
|
||||
|
||||
@@ -138,8 +138,8 @@ double value(unsigned char index) {
|
||||
double value = _events * 60000;
|
||||
value = value / (_lastreport_cpm-_period_begin);
|
||||
#if SENSOR_DEBUG
|
||||
char data[128]; char buffer[10];
|
||||
dtostrf(value, 1-sizeof(buffer), 4, buffer);
|
||||
char data[128]; char buffer[32];
|
||||
dtostrf(value, 1, 4, buffer);
|
||||
snprintf(data, sizeof(data), "Ticks: %u | Interval: %u | CPM: %s", _ticks, (_lastreport_cpm-_period_begin), buffer);
|
||||
DEBUG_MSG("[GEIGER] %s\n", data);
|
||||
#endif
|
||||
@@ -154,8 +154,8 @@ double value(unsigned char index) {
|
||||
double value = _ticks * 60000 / _cpm2sievert;
|
||||
value = value / (_lastreport_sv-_period_begin);
|
||||
#if SENSOR_DEBUG
|
||||
char data[128]; char buffer[10];
|
||||
dtostrf(value, 1-sizeof(buffer), 4, buffer);
|
||||
char data[128]; char buffer[32];
|
||||
dtostrf(value, 1, 4, buffer);
|
||||
snprintf(data, sizeof(data), "Ticks: %u | Interval: %u | µSievert: %s", _ticks, (_lastreport_sv-_period_begin), buffer);
|
||||
DEBUG_MSG("[GEIGER] %s\n", data);
|
||||
#endif
|
||||
|
||||
@@ -142,13 +142,13 @@ void updateOperationMode() {
|
||||
//------------------------------------------------------------------------------
|
||||
void updateRemoteTemp(bool remote_temp_actual) {
|
||||
#if WEB_SUPPORT
|
||||
char tmp_str[6];
|
||||
char tmp_str[16];
|
||||
if (remote_temp_actual) {
|
||||
dtostrf(_remote_temp.temp, 1-sizeof(tmp_str), 1, tmp_str);
|
||||
dtostrf(_remote_temp.temp, 1, 1, tmp_str);
|
||||
} else {
|
||||
strcpy(tmp_str, "\"?\"");
|
||||
}
|
||||
char buffer[100];
|
||||
char buffer[128];
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("{\"thermostatVisible\": 1, \"remoteTmp\": %s}"), tmp_str);
|
||||
wsSend(buffer);
|
||||
#endif
|
||||
@@ -387,8 +387,8 @@ void setThermostatState(bool state) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void debugPrintSwitch(bool state, double temp) {
|
||||
char tmp_str[6];
|
||||
dtostrf(temp, 1-sizeof(tmp_str), 1, tmp_str);
|
||||
char tmp_str[16];
|
||||
dtostrf(temp, 1, 1, tmp_str);
|
||||
DEBUG_MSG_P(PSTR("[THERMOSTAT] switch %s, temp: %s, min: %d, max: %d, mode: %s, relay: %s, last switch %d\n"),
|
||||
state ? "ON" : "OFF", tmp_str, _temp_range.min, _temp_range.max, _thermostat_mode_cooler ? "COOLER" : "HEATER", relayStatus(THERMOSTAT_RELAY) ? "ON" : "OFF", millis() - _thermostat.last_switch);
|
||||
}
|
||||
@@ -486,8 +486,8 @@ double getLocalTemperature() {
|
||||
for (byte i=0; i<magnitudeCount(); i++) {
|
||||
if (magnitudeType(i) == MAGNITUDE_TEMPERATURE) {
|
||||
double temp = magnitudeValue(i);
|
||||
char tmp_str[6];
|
||||
dtostrf(temp, 1-sizeof(tmp_str), 1, tmp_str);
|
||||
char tmp_str[16];
|
||||
dtostrf(temp, 1, 1, tmp_str);
|
||||
DEBUG_MSG_P(PSTR("[THERMOSTAT] getLocalTemperature temp: %s\n"), tmp_str);
|
||||
return temp > -0.1 && temp < 0.1 ? DBL_MIN : temp;
|
||||
}
|
||||
@@ -502,8 +502,8 @@ double getLocalHumidity() {
|
||||
for (byte i=0; i<magnitudeCount(); i++) {
|
||||
if (magnitudeType(i) == MAGNITUDE_HUMIDITY) {
|
||||
double hum = magnitudeValue(i);
|
||||
char tmp_str[4];
|
||||
dtostrf(hum, 1-sizeof(tmp_str), 0, tmp_str);
|
||||
char tmp_str[16];
|
||||
dtostrf(hum, 1, 0, tmp_str);
|
||||
DEBUG_MSG_P(PSTR("[THERMOSTAT] getLocalHumidity hum: %s\%\n"), tmp_str);
|
||||
return hum > -0.1 && hum < 0.1 ? DBL_MIN : hum;
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ void _tspkPost() {
|
||||
|
||||
#endif // THINGSPEAK_USE_ASYNC
|
||||
|
||||
void _tspkEnqueue(unsigned char index, char * payload) {
|
||||
void _tspkEnqueue(unsigned char index, const char * payload) {
|
||||
DEBUG_MSG_P(PSTR("[THINGSPEAK] Enqueuing field #%u with value %s\n"), index, payload);
|
||||
--index;
|
||||
if (_tspk_queue[index] != NULL) free(_tspk_queue[index]);
|
||||
@@ -361,7 +361,7 @@ bool tspkEnqueueRelay(unsigned char index, char * payload) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool tspkEnqueueMeasurement(unsigned char index, char * payload) {
|
||||
bool tspkEnqueueMeasurement(unsigned char index, const char * payload) {
|
||||
if (!_tspk_enabled) return true;
|
||||
unsigned char id = getSetting("tspkMagnitude", index, 0).toInt();
|
||||
if (id > 0) {
|
||||
|
||||
@@ -284,9 +284,9 @@ void heartbeat() {
|
||||
}
|
||||
|
||||
if (hb_cfg & Heartbeat::Remote_temp) {
|
||||
char remote_temp[6];
|
||||
dtostrf(_remote_temp.temp, 1-sizeof(remote_temp), 1, remote_temp);
|
||||
mqttSend(MQTT_TOPIC_REMOTE_TEMP, String(remote_temp).c_str());
|
||||
char remote_temp[16];
|
||||
dtostrf(_remote_temp.temp, 1, 1, remote_temp);
|
||||
mqttSend(MQTT_TOPIC_REMOTE_TEMP, remote_temp);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import sys
|
||||
|
||||
TRAVIS = os.environ.get("TRAVIS")
|
||||
PIO_PLATFORM = env.PioPlatform()
|
||||
CONFIG = env.GetProjectConfig()
|
||||
|
||||
|
||||
class ExtraScriptError(Exception):
|
||||
@@ -50,12 +51,11 @@ def library_manager_libdeps(lib_deps, storage=None):
|
||||
|
||||
|
||||
def get_shared_libdeps_dir(section, name):
|
||||
cfg = env.GetProjectConfig()
|
||||
|
||||
if not cfg.has_option(section, name):
|
||||
if not CONFIG.has_option(section, name):
|
||||
raise ExtraScriptError("{}.{} is required to be set".format(section, name))
|
||||
|
||||
opt = cfg.get(section, name)
|
||||
opt = CONFIG.get(section, name)
|
||||
|
||||
if not opt in env.GetProjectOption("lib_extra_dirs"):
|
||||
raise ExtraScriptError(
|
||||
@@ -73,10 +73,10 @@ def ensure_platform_updated():
|
||||
except Exception:
|
||||
print("Warning: no connection, cannot check for outdated packages", file=sys.stderr)
|
||||
|
||||
|
||||
# latest toolchain is still optional with PIO (TODO: recheck after 2.6.0!)
|
||||
ensure_platform_updated()
|
||||
|
||||
# also updates arduino core git to the latest master commit
|
||||
if TRAVIS and (env.GetProjectOption("platform") == CONFIG.get("common", "arduino_core_git")):
|
||||
ensure_platform_updated()
|
||||
|
||||
# to speed-up build process, install libraries in either global or local shared storage
|
||||
if os.environ.get("ESPURNA_PIO_SHARED_LIBRARIES"):
|
||||
|
||||
@@ -65,7 +65,7 @@ board_1m = esp01_1m
|
||||
board_2m = esp_wroom_02
|
||||
board_4m = esp12e
|
||||
|
||||
build_flags = -g -w -DMQTT_MAX_PACKET_SIZE=400 -DNO_GLOBAL_EEPROM ${sysenv.ESPURNA_FLAGS} -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
|
||||
build_flags = -g -w -DMQTT_MAX_PACKET_SIZE=400 -DNO_GLOBAL_EEPROM ${sysenv.ESPURNA_FLAGS} -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
||||
build_flags_512k = ${common.build_flags} -Wl,-Teagle.flash.512k0m1s.ld
|
||||
build_flags_1m0m = ${common.build_flags} -Wl,-Teagle.flash.1m0m1s.ld
|
||||
build_flags_2m1m = ${common.build_flags} -Wl,-Teagle.flash.2m1m4s.ld
|
||||
@@ -210,6 +210,11 @@ platform = ${common.platform_latest}
|
||||
board = ${common.board_4m}
|
||||
build_flags = ${common.build_flags_4m1m} -DTRAVIS03 -DNOWSAUTH -DASYNC_TCP_SSL_ENABLED=1
|
||||
|
||||
[env:travis04]
|
||||
platform = ${common.arduino_core_git}
|
||||
board = ${common.board_4m}
|
||||
build_flags = ${common.build_flags_4m1m} -DTRAVIS03 -DNOWSAUTH
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# DEVELOPMENT BOARDS
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user