Skip to content

Commit

Permalink
Merge pull request #1227 from proddy/dev2
Browse files Browse the repository at this point in the history
standalone compiling and some formatting
  • Loading branch information
proddy authored Jul 19, 2023
2 parents 981cdae + d84a555 commit ad6be2d
Show file tree
Hide file tree
Showing 34 changed files with 69 additions and 72 deletions.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ LIBRARIES :=

CPPCHECK = cppcheck
# CHECKFLAGS = -q --force --std=c++17
CHECKFLAGS = -q --force --std=c++11 -pthread
CHECKFLAGS = -q --force --std=c++11

#----------------------------------------------------------------------
# Languages Standard
#----------------------------------------------------------------------
# C_STANDARD := -std=c17
C_STANDARD := -std=c17
# CXX_STANDARD := -std=c++17
C_STANDARD := -std=c11
CXX_STANDARD := -std=c++11
CXX_STANDARD := -std=gnu++11

# C_STANDARD := -std=c11
# CXX_STANDARD := -std=c++11

#----------------------------------------------------------------------
# Defined Symbols
Expand Down Expand Up @@ -79,7 +81,7 @@ CPPFLAGS += -g3
CPPFLAGS += -Os

CFLAGS += $(CPPFLAGS)
CFLAGS += -Wall -Wextra -Werror -Wswitch-enum -Wno-unused-parameter
CFLAGS += -Wall -Wextra -Werror -Wswitch-enum -Wno-unused-parameter -Wno-inconsistent-missing-override -Wno-missing-braces -Wno-unused-lambda-capture

CXXFLAGS += $(CFLAGS) -MMD

Expand Down
2 changes: 1 addition & 1 deletion interface/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"cspell": "^6.31.1",
"eslint": "^8.44.0",
"eslint": "^8.45.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^8.8.0",
Expand Down
16 changes: 7 additions & 9 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ __metadata:
alova: ^2.9.2
async-validator: ^4.2.5
cspell: ^6.31.1
eslint: ^8.44.0
eslint: ^8.45.0
eslint-config-airbnb: ^19.0.4
eslint-config-airbnb-typescript: ^17.1.0
eslint-config-prettier: ^8.8.0
Expand Down Expand Up @@ -3488,9 +3488,9 @@ __metadata:
languageName: node
linkType: hard

"eslint@npm:^8.44.0":
version: 8.44.0
resolution: "eslint@npm:8.44.0"
"eslint@npm:^8.45.0":
version: 8.45.0
resolution: "eslint@npm:8.45.0"
dependencies:
"@eslint-community/eslint-utils": ^4.2.0
"@eslint-community/regexpp": ^4.4.0
Expand All @@ -3517,7 +3517,6 @@ __metadata:
globals: ^13.19.0
graphemer: ^1.4.0
ignore: ^5.2.0
import-fresh: ^3.0.0
imurmurhash: ^0.1.4
is-glob: ^4.0.0
is-path-inside: ^3.0.3
Expand All @@ -3529,11 +3528,10 @@ __metadata:
natural-compare: ^1.4.0
optionator: ^0.9.3
strip-ansi: ^6.0.1
strip-json-comments: ^3.1.0
text-table: ^0.2.0
bin:
eslint: bin/eslint.js
checksum: a31ca4571a67012629936d891141a4a5747d5902fb7f4e10119a5acd632e0976b9ba1b761d8c81cff8a9cc3e796df2c56f86c02535fd977de962a98ce585624a
checksum: 2a043b8d3b9a5684e2f66bd446c3dc8522cc7afbb0982d0a5be76ea1f578d0e617598a7b289616a861ab8272b57f6056acb2b264bec6302c9b0921a1cfa66fdb
languageName: node
linkType: hard

Expand Down Expand Up @@ -4254,7 +4252,7 @@ __metadata:
languageName: node
linkType: hard

"import-fresh@npm:^3.0.0, import-fresh@npm:^3.2.1, import-fresh@npm:^3.3.0":
"import-fresh@npm:^3.2.1, import-fresh@npm:^3.3.0":
version: 3.3.0
resolution: "import-fresh@npm:3.3.0"
dependencies:
Expand Down Expand Up @@ -6406,7 +6404,7 @@ __metadata:
languageName: node
linkType: hard

"strip-json-comments@npm:^3.1.0, strip-json-comments@npm:^3.1.1":
"strip-json-comments@npm:^3.1.1":
version: 3.1.1
resolution: "strip-json-comments@npm:3.1.1"
checksum: 9681a6257b925a7fa0f285851c0e613cc934a50661fa7bb41ca9cbbff89686bb4a0ee366e6ecedc4daafd01e83eee0720111ab294366fe7c185e935475ebcecd
Expand Down
2 changes: 1 addition & 1 deletion lib/PButton/PButon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool PButton::init(uint8_t pin, bool pullMode) {

#if defined(ESP32)
pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT_PULLDOWN);
#else // esp8266 and standalone
#else // esp8266 and standalone
pinMode(pin_, pullMode ? INPUT_PULLUP : INPUT);
#endif
enabled_ = (digitalRead(pin_) == pullMode); // see if a button is connected
Expand Down
16 changes: 8 additions & 8 deletions lib/PButton/PButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ class PButton {
bool pullMode_;
bool enabled_;

bool state_; // Value read from button
bool lastState_; // Last value of button state
bool dblClickWaiting_; // whether we're waiting for a double click (down)
bool dblClickOnNextUp_; // whether to register a double click on next release, or whether to wait and click
bool singleClickOK_; // whether it's OK to do a single click
bool state_; // Value read from button
bool lastState_; // Last value of button state
bool dblClickWaiting_; // whether we're waiting for a double click (down)
bool dblClickOnNextUp_; // whether to register a double click on next release, or whether to wait and click
bool singleClickOK_; // whether it's OK to do a single click

uint32_t downTime_; // time the button was pressed down
uint32_t upTime_; // time the button was released
uint32_t downTime_; // time the button was pressed down
uint32_t upTime_; // time the button was released

bool ignoreUP_; // whether to ignore the button release because the click+hold was triggered
bool waitForUP_; // when held, whether to wait for the up event
bool longPressHappened_; // whether or not the hold event happened already
bool vLongPressHappened_; // whether or not the long hold event happened already

bool buttonBusy_; // false if idle
bool buttonBusy_; // false if idle

buttonEventHandler cb_onClick, cb_onDblClick, cb_onLongPress, cb_onVLongPress;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/espMqttClient/src/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const char * MqttClient::getClientId() const {
}

void MqttClient::loop() {
switch (_state) {
switch ((State)_state) { // modified by proddy for EMS-ESP compiling standalone
case State::disconnected:
#if defined(ARDUINO_ARCH_ESP32)
if (_useInternalTask == espMqttClientTypes::UseInternalTask::YES) {
Expand Down
3 changes: 1 addition & 2 deletions lib/espMqttClient/src/MqttClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ class MqttClient {
#elif defined(ARDUINO_ARCH_ESP8266) && EMC_ESP8266_MULTITHREADING
std::atomic<bool> _xSemaphore = false;
#elif defined(__linux__)
// added mutable to compile EMS-ESP standalone
mutable std::mutex mtx;
mutable std::mutex mtx; // modified by proddy for EMS-ESP compiling standalone
#endif

uint8_t _rxBuffer[EMC_RX_BUFFER_SIZE];
Expand Down
2 changes: 1 addition & 1 deletion lib/espMqttClient/src/Transport/ClientPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool ClientPosix::connect(IPAddress ip, uint16_t port) {
memset(&_host, 0, sizeof(_host));
_host.sin_family = AF_INET;
_host.sin_addr.s_addr = htonl(uint32_t(ip));
_host.sin_port = ::htons(port);
_host.sin_port = htons(port); // modified by proddy for EMS-ESP compiling standalone

int ret = ::connect(_sockfd, (struct sockaddr *)&_host, sizeof(_host));

Expand Down
2 changes: 1 addition & 1 deletion lib/framework/APSettingsService.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <APSettingsService.h>

#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

APSettingsService::APSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager)
: _httpEndpoint(APSettings::read, APSettings::update, this, server, AP_SETTINGS_SERVICE_PATH, securityManager)
Expand Down
5 changes: 1 addition & 4 deletions lib/framework/FactoryResetService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ void FactoryResetService::handleRequest(AsyncWebServerRequest * request) {
* Delete function assumes that all files are stored flat, within the config directory.
*/
void FactoryResetService::factoryReset() {
/*
* Based on LittleFS. Modified by proddy
* Could be replaced with fs.rmdir(FS_CONFIG_DIRECTORY) in IDF 4.2
*/
// TODO Could be replaced with fs.rmdir(FS_CONFIG_DIRECTORY) in IDF 4.2
File root = fs->open(FS_CONFIG_DIRECTORY);
File file;
while (file = root.openNextFile()) {
Expand Down
4 changes: 2 additions & 2 deletions lib/framework/FeaturesService.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <FeaturesService.h>
#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

using namespace std::placeholders; // for `_1` etc
using namespace std::placeholders; // for `_1` etc

FeaturesService::FeaturesService(AsyncWebServer * server) {
server->on(FEATURES_SERVICE_PATH, HTTP_GET, std::bind(&FeaturesService::features, this, _1));
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/HttpEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class HttpPostEndpoint {
response->setLength();

if (outcome == StateUpdateResult::CHANGED_RESTART) {
response->setCode(205); // added by proddy, reboot required
response->setCode(205); // reboot required
}
request->send(response);
}
Expand Down
6 changes: 2 additions & 4 deletions lib/framework/MqttSettingsService.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <MqttSettingsService.h>

#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

using namespace std::placeholders; // for `_1` etc
using namespace std::placeholders; // for `_1` etc

/**
* Retains a copy of the cstr provided in the pointer provided using dynamic allocation.
Expand Down Expand Up @@ -144,7 +144,6 @@ void MqttSettingsService::onConfigUpdated() {
_reconfigureMqtt = true;
_disconnectedAt = 0;

// added by proddy
startClient();
emsesp::EMSESP::mqtt_.start(); // reload EMS-ESP MQTT settings
}
Expand Down Expand Up @@ -231,7 +230,6 @@ void MqttSettings::read(MqttSettings & settings, JsonObject & root) {
root["clean_session"] = settings.cleanSession;
root["entity_format"] = settings.entity_format;

// added by proddy for EMS-ESP
root["publish_time_boiler"] = settings.publish_time_boiler;
root["publish_time_thermostat"] = settings.publish_time_thermostat;
root["publish_time_solar"] = settings.publish_time_solar;
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/MqttSettingsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MqttSettings {
uint16_t keepAlive;
bool cleanSession;

// proddy EMS-ESP specific
// EMS-ESP specific
String base;
uint16_t publish_time_boiler;
uint16_t publish_time_thermostat;
Expand Down
8 changes: 4 additions & 4 deletions lib/framework/MqttStatus.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <MqttStatus.h>

#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

using namespace std::placeholders; // for `_1` etc

Expand All @@ -20,9 +20,9 @@ void MqttStatus::mqttStatus(AsyncWebServerRequest * request) {
root["client_id"] = _mqttSettingsService->getClientId();
root["disconnect_reason"] = (uint8_t)_mqttSettingsService->getDisconnectReason();

root["mqtt_queued"] = emsesp::Mqtt::publish_queued(); // mdvp added
root["mqtt_fails"] = emsesp::Mqtt::publish_fails(); // proddy added
root["connect_count"] = emsesp::Mqtt::connect_count(); // mdvp added
root["mqtt_queued"] = emsesp::Mqtt::publish_queued();
root["mqtt_fails"] = emsesp::Mqtt::publish_fails();
root["connect_count"] = emsesp::Mqtt::connect_count();

response->setLength();
request->send(response);
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/NTPSettingsService.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <NTPSettingsService.h>
#include <esp_sntp.h>

#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

using namespace std::placeholders; // for `_1` etc

Expand Down
2 changes: 1 addition & 1 deletion lib/framework/NTPStatus.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <NTPStatus.h>
#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

using namespace std::placeholders; // for `_1` etc

Expand Down
2 changes: 1 addition & 1 deletion lib/framework/NetworkSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void NetworkSettingsService::manageSTA() {
esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_STA, WIFI_BW_HT40);
}
if (networkSettings.nosleep) {
WiFi.setSleep(false); // turn off sleep - WIFI_PS_NONE
WiFi.setSleep(false); // turn off sleep - WIFI_PS_NONE
}
WiFi.begin(_state.ssid.c_str(), _state.password.c_str()); // attempt to connect to the network
esp_wifi_set_max_tx_power(networkSettings.tx_power * 4); // set power after wifi is startet for C3
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/NetworkStatus.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <NetworkStatus.h>

#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

using namespace std::placeholders; // for `_1` etc

Expand Down
2 changes: 1 addition & 1 deletion lib/framework/OTASettingsService.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <OTASettingsService.h>

#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

using namespace std::placeholders; // for `_1` etc

Expand Down
2 changes: 1 addition & 1 deletion lib/framework/SecuritySettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#if FT_ENABLED(FT_SECURITY)

#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs)
: _httpEndpoint(SecuritySettings::read, SecuritySettings::update, this, server, SECURITY_SETTINGS_PATH, this)
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/StatefulService.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

enum class StateUpdateResult {
CHANGED = 0, // The update changed the state and propagation should take place if required
CHANGED_RESTART, // a restart of the device is needed - added by proddy
CHANGED_RESTART, // a restart of the device is needed
UNCHANGED, // The state was unchanged, propagation should not take place
ERROR // There was a problem updating the state, propagation should not take place
};
Expand Down
4 changes: 2 additions & 2 deletions lib/framework/SystemStatus.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <SystemStatus.h>
#include <esp_ota_ops.h>

#include "../../src/emsesp_stub.hpp" // proddy added
#include "../../src/emsesp_stub.hpp"

using namespace std::placeholders; // for `_1` etc

Expand Down Expand Up @@ -39,7 +39,7 @@ void SystemStatus::systemStatus(AsyncWebServerRequest * request) {
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
if (partition != NULL) { // factory partition found
root["has_loader"] = true;
} else { // check for not empty, smaller OTA partition
} else { // check for not empty, smaller OTA partition
partition = esp_ota_get_next_update_partition(NULL);
if (partition) {
uint64_t buffer;
Expand Down
1 change: 0 additions & 1 deletion lib/uuid-common/src/get_uptime_ms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace uuid {

// added by proddy for EMS-ESP
static uint64_t now_millis = 0;

// returns system uptime in seconds
Expand Down
2 changes: 1 addition & 1 deletion lib/uuid-common/src/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace uuid {

void loop() {
set_uptime(); // added by proddy
set_uptime();
}

} // namespace uuid
4 changes: 2 additions & 2 deletions lib/uuid-common/src/uuid/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void loop();
*/
uint64_t get_uptime_ms();

uint32_t get_uptime(); // added by proddy for EMS-ESP
uint32_t get_uptime_sec(); // added by proddy for EMS-ESP
uint32_t get_uptime();
uint32_t get_uptime_sec();

void set_uptime();

Expand Down
2 changes: 0 additions & 2 deletions lib/uuid-console/src/shell_prompt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ void Shell::display_prompt() {
std::string context = context_text();

print(prompt_prefix());
// colors added by proddy
if (!hostname.empty()) {
print(COLOR_BRIGHT_GREEN);
print(COLOR_BOLD_ON);
Expand All @@ -78,7 +77,6 @@ void Shell::display_prompt() {
print(COLOR_BOLD_ON);
print(context);
print(COLOR_RESET);
// print(' ');
}
print(prompt_suffix());
print(' ');
Expand Down
2 changes: 1 addition & 1 deletion lib/uuid-syslog/src/syslog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ bool SyslogService::can_transmit() {
#endif

if (!emsesp::EMSESP::system_.network_connected()) {
return false; // added by proddy. Check Ethernet
return false;
}

const uint64_t now = uuid::get_uptime_ms();
Expand Down
Loading

0 comments on commit ad6be2d

Please sign in to comment.