mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
compile on mac osx
This commit is contained in:
12
Makefile
12
Makefile
@@ -23,15 +23,17 @@ LIBRARIES :=
|
|||||||
|
|
||||||
CPPCHECK = cppcheck
|
CPPCHECK = cppcheck
|
||||||
# CHECKFLAGS = -q --force --std=c++17
|
# CHECKFLAGS = -q --force --std=c++17
|
||||||
CHECKFLAGS = -q --force --std=c++11 -pthread
|
CHECKFLAGS = -q --force --std=c++11
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# Languages Standard
|
# Languages Standard
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# C_STANDARD := -std=c17
|
C_STANDARD := -std=c17
|
||||||
# CXX_STANDARD := -std=c++17
|
# CXX_STANDARD := -std=c++17
|
||||||
C_STANDARD := -std=c11
|
CXX_STANDARD := -std=gnu++17
|
||||||
CXX_STANDARD := -std=c++11
|
|
||||||
|
# C_STANDARD := -std=c11
|
||||||
|
# CXX_STANDARD := -std=c++11
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# Defined Symbols
|
# Defined Symbols
|
||||||
@@ -79,7 +81,7 @@ CPPFLAGS += -g3
|
|||||||
CPPFLAGS += -Os
|
CPPFLAGS += -Os
|
||||||
|
|
||||||
CFLAGS += $(CPPFLAGS)
|
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
|
CXXFLAGS += $(CFLAGS) -MMD
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||||
"@typescript-eslint/parser": "^6.0.0",
|
"@typescript-eslint/parser": "^6.0.0",
|
||||||
"cspell": "^6.31.1",
|
"cspell": "^6.31.1",
|
||||||
"eslint": "^8.44.0",
|
"eslint": "^8.45.0",
|
||||||
"eslint-config-airbnb": "^19.0.4",
|
"eslint-config-airbnb": "^19.0.4",
|
||||||
"eslint-config-airbnb-typescript": "^17.1.0",
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
|
|||||||
@@ -1967,7 +1967,7 @@ __metadata:
|
|||||||
alova: ^2.9.2
|
alova: ^2.9.2
|
||||||
async-validator: ^4.2.5
|
async-validator: ^4.2.5
|
||||||
cspell: ^6.31.1
|
cspell: ^6.31.1
|
||||||
eslint: ^8.44.0
|
eslint: ^8.45.0
|
||||||
eslint-config-airbnb: ^19.0.4
|
eslint-config-airbnb: ^19.0.4
|
||||||
eslint-config-airbnb-typescript: ^17.1.0
|
eslint-config-airbnb-typescript: ^17.1.0
|
||||||
eslint-config-prettier: ^8.8.0
|
eslint-config-prettier: ^8.8.0
|
||||||
@@ -3488,9 +3488,9 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"eslint@npm:^8.44.0":
|
"eslint@npm:^8.45.0":
|
||||||
version: 8.44.0
|
version: 8.45.0
|
||||||
resolution: "eslint@npm:8.44.0"
|
resolution: "eslint@npm:8.45.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@eslint-community/eslint-utils": ^4.2.0
|
"@eslint-community/eslint-utils": ^4.2.0
|
||||||
"@eslint-community/regexpp": ^4.4.0
|
"@eslint-community/regexpp": ^4.4.0
|
||||||
@@ -3517,7 +3517,6 @@ __metadata:
|
|||||||
globals: ^13.19.0
|
globals: ^13.19.0
|
||||||
graphemer: ^1.4.0
|
graphemer: ^1.4.0
|
||||||
ignore: ^5.2.0
|
ignore: ^5.2.0
|
||||||
import-fresh: ^3.0.0
|
|
||||||
imurmurhash: ^0.1.4
|
imurmurhash: ^0.1.4
|
||||||
is-glob: ^4.0.0
|
is-glob: ^4.0.0
|
||||||
is-path-inside: ^3.0.3
|
is-path-inside: ^3.0.3
|
||||||
@@ -3529,11 +3528,10 @@ __metadata:
|
|||||||
natural-compare: ^1.4.0
|
natural-compare: ^1.4.0
|
||||||
optionator: ^0.9.3
|
optionator: ^0.9.3
|
||||||
strip-ansi: ^6.0.1
|
strip-ansi: ^6.0.1
|
||||||
strip-json-comments: ^3.1.0
|
|
||||||
text-table: ^0.2.0
|
text-table: ^0.2.0
|
||||||
bin:
|
bin:
|
||||||
eslint: bin/eslint.js
|
eslint: bin/eslint.js
|
||||||
checksum: a31ca4571a67012629936d891141a4a5747d5902fb7f4e10119a5acd632e0976b9ba1b761d8c81cff8a9cc3e796df2c56f86c02535fd977de962a98ce585624a
|
checksum: 2a043b8d3b9a5684e2f66bd446c3dc8522cc7afbb0982d0a5be76ea1f578d0e617598a7b289616a861ab8272b57f6056acb2b264bec6302c9b0921a1cfa66fdb
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -4254,7 +4252,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
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
|
version: 3.3.0
|
||||||
resolution: "import-fresh@npm:3.3.0"
|
resolution: "import-fresh@npm:3.3.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -6406,7 +6404,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
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
|
version: 3.1.1
|
||||||
resolution: "strip-json-comments@npm:3.1.1"
|
resolution: "strip-json-comments@npm:3.1.1"
|
||||||
checksum: 9681a6257b925a7fa0f285851c0e613cc934a50661fa7bb41ca9cbbff89686bb4a0ee366e6ecedc4daafd01e83eee0720111ab294366fe7c185e935475ebcecd
|
checksum: 9681a6257b925a7fa0f285851c0e613cc934a50661fa7bb41ca9cbbff89686bb4a0ee366e6ecedc4daafd01e83eee0720111ab294366fe7c185e935475ebcecd
|
||||||
|
|||||||
@@ -13,80 +13,81 @@ the LICENSE file.
|
|||||||
namespace espMqttClientInternals {
|
namespace espMqttClientInternals {
|
||||||
|
|
||||||
ClientPosix::ClientPosix()
|
ClientPosix::ClientPosix()
|
||||||
: _sockfd(-1)
|
: _sockfd(-1)
|
||||||
, _host() {
|
, _host() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientPosix::~ClientPosix() {
|
ClientPosix::~ClientPosix() {
|
||||||
ClientPosix::stop();
|
ClientPosix::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientPosix::connect(IPAddress ip, uint16_t port) {
|
bool ClientPosix::connect(IPAddress ip, uint16_t port) {
|
||||||
if (connected()) stop();
|
if (connected())
|
||||||
|
stop();
|
||||||
|
|
||||||
_sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
|
_sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (_sockfd < 0) {
|
if (_sockfd < 0) {
|
||||||
emc_log_e("Error %d opening socket", errno);
|
emc_log_e("Error %d opening socket", errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
int flag = 1;
|
int flag = 1;
|
||||||
if (setsockopt(_sockfd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)) < 0) {
|
if (setsockopt(_sockfd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)) < 0) {
|
||||||
emc_log_e("Error %d disabling nagle", errno);
|
emc_log_e("Error %d disabling nagle", errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&_host, 0, sizeof(_host));
|
memset(&_host, 0, sizeof(_host));
|
||||||
_host.sin_family = AF_INET;
|
_host.sin_family = AF_INET;
|
||||||
_host.sin_addr.s_addr = htonl(uint32_t(ip));
|
_host.sin_addr.s_addr = htonl(uint32_t(ip));
|
||||||
_host.sin_port = ::htons(port);
|
_host.sin_port = htons(port);
|
||||||
|
|
||||||
int ret = ::connect(_sockfd, (struct sockaddr *)&_host, sizeof(_host));
|
int ret = ::connect(_sockfd, (struct sockaddr *)&_host, sizeof(_host));
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
emc_log_e("Error connecting: %d - (%d) %s", ret, errno, strerror(errno));
|
emc_log_e("Error connecting: %d - (%d) %s", ret, errno, strerror(errno));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
emc_log_i("Connected");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClientPosix::connect(const char * host, uint16_t port) {
|
||||||
|
// tbi
|
||||||
|
(void)host;
|
||||||
|
(void)port;
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
emc_log_i("Connected");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientPosix::connect(const char* host, uint16_t port) {
|
size_t ClientPosix::write(const uint8_t * buf, size_t size) {
|
||||||
// tbi
|
return ::send(_sockfd, buf, size, 0);
|
||||||
(void) host;
|
|
||||||
(void) port;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ClientPosix::write(const uint8_t* buf, size_t size) {
|
int ClientPosix::read(uint8_t * buf, size_t size) {
|
||||||
return ::send(_sockfd, buf, size, 0);
|
int ret = ::recv(_sockfd, buf, size, MSG_DONTWAIT);
|
||||||
}
|
/*
|
||||||
|
|
||||||
int ClientPosix::read(uint8_t* buf, size_t size) {
|
|
||||||
int ret = ::recv(_sockfd, buf, size, MSG_DONTWAIT);
|
|
||||||
/*
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
emc_log_e("Error reading: %s", strerror(errno));
|
emc_log_e("Error reading: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientPosix::stop() {
|
void ClientPosix::stop() {
|
||||||
if (_sockfd >= 0) {
|
if (_sockfd >= 0) {
|
||||||
::close(_sockfd);
|
::close(_sockfd);
|
||||||
_sockfd = -1;
|
_sockfd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientPosix::connected() {
|
bool ClientPosix::connected() {
|
||||||
return _sockfd >= 0;
|
return _sockfd >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientPosix::disconnected() {
|
bool ClientPosix::disconnected() {
|
||||||
return _sockfd < 0;
|
return _sockfd < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace espMqttClientInternals
|
} // namespace espMqttClientInternals
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -144,12 +144,13 @@ build_flags = ${common.build_flags} -O2
|
|||||||
platform = native
|
platform = native
|
||||||
build_flags =
|
build_flags =
|
||||||
-DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
|
-DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
|
||||||
-DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST
|
-DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST -D__linux__
|
||||||
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.6.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
|
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.6.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
|
||||||
-lpthread
|
-lpthread
|
||||||
-std=gnu++11 -Og -ggdb
|
-std=gnu++17 -Og -ggdb
|
||||||
build_src_flags =
|
build_src_flags =
|
||||||
-Wall -Wextra -Werror -Wswitch-enum -Wno-unused-parameter -Wno-inconsistent-missing-override -Wno-unused-lambda-capture
|
-Wall -Wextra -Werror -Wswitch-enum -Wno-unused-parameter -Wno-inconsistent-missing-override -Wno-unused-lambda-capture
|
||||||
|
-Wno-missing-braces
|
||||||
-I./lib_standalone
|
-I./lib_standalone
|
||||||
-I./lib/ArduinoJson/src
|
-I./lib/ArduinoJson/src
|
||||||
-I./lib/uuid-common/src
|
-I./lib/uuid-common/src
|
||||||
|
|||||||
@@ -210,13 +210,18 @@ void Mqtt::incoming(const char * topic, const char * payload) {
|
|||||||
// received an MQTT message that we subscribed too
|
// received an MQTT message that we subscribed too
|
||||||
// topic is the full path
|
// topic is the full path
|
||||||
// payload is json or a single string and converted to a json with key 'value'
|
// payload is json or a single string and converted to a json with key 'value'
|
||||||
void Mqtt::on_message(const char * topic, const char * payload, size_t len) const {
|
void Mqtt::on_message(const char * topic, const char * message, size_t len) const {
|
||||||
|
// This causes a compile error "error: variable-sized object may not be initialized"
|
||||||
|
// so commenting out and assuming with the new mqtt lib it's always null terminated
|
||||||
|
|
||||||
|
/*
|
||||||
// sometimes the payload is not terminated correctly, so make a copy
|
// sometimes the payload is not terminated correctly, so make a copy
|
||||||
// convert payload to a null-terminated char string
|
// convert payload to a null-terminated char string
|
||||||
char message[len + 2] = {'\0'};
|
char message[len + 2] = {'\0'};
|
||||||
if (payload != nullptr) {
|
if (payload != nullptr) {
|
||||||
strlcpy(message, payload, len + 1);
|
strlcpy(message, payload, len + 1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
if (len) {
|
if (len) {
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ class Mqtt {
|
|||||||
|
|
||||||
static std::vector<MQTTSubFunction> mqtt_subfunctions_; // list of mqtt subscribe callbacks for all devices
|
static std::vector<MQTTSubFunction> mqtt_subfunctions_; // list of mqtt subscribe callbacks for all devices
|
||||||
|
|
||||||
uint32_t last_mqtt_poll_ = 0;
|
// uint32_t last_mqtt_poll_ = 0;
|
||||||
uint32_t last_publish_boiler_ = 0;
|
uint32_t last_publish_boiler_ = 0;
|
||||||
uint32_t last_publish_thermostat_ = 0;
|
uint32_t last_publish_thermostat_ = 0;
|
||||||
uint32_t last_publish_solar_ = 0;
|
uint32_t last_publish_solar_ = 0;
|
||||||
@@ -259,7 +259,7 @@ class Mqtt {
|
|||||||
uint32_t last_publish_other_ = 0;
|
uint32_t last_publish_other_ = 0;
|
||||||
uint32_t last_publish_sensor_ = 0;
|
uint32_t last_publish_sensor_ = 0;
|
||||||
uint32_t last_publish_heartbeat_ = 0;
|
uint32_t last_publish_heartbeat_ = 0;
|
||||||
uint32_t last_publish_queue_ = 0;
|
// uint32_t last_publish_queue_ = 0;
|
||||||
|
|
||||||
static bool connecting_;
|
static bool connecting_;
|
||||||
static bool initialized_;
|
static bool initialized_;
|
||||||
|
|||||||
Reference in New Issue
Block a user