Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- Ignore UnlockConnector when handler not set ([#271](https://github.com/matth-x/MicroOcpp/pull/271))
- Reject ChargingProfile if unit not supported ([#271](https://github.com/matth-x/MicroOcpp/pull/271))
- Fix building with debug level warn and error
- Reduce debug output FW size overhead ([#304](https://github.com/matth-x/MicroOcpp/pull/304))
- Fix transaction freeze in offline mode ([#279](https://github.com/matth-x/MicroOcpp/pull/279), [#287](https://github.com/matth-x/MicroOcpp/pull/287))
- Fix compilation error caused by `PRId32` ([#279](https://github.com/matth-x/MicroOcpp/pull/279))
- Don't load FW-mngt. module when no handlers set ([#271](https://github.com/matth-x/MicroOcpp/pull/271))
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ set(MO_SRC
src/MicroOcpp/Operations/InstallCertificate.cpp
src/MicroOcpp/Operations/UnlockConnector.cpp
src/MicroOcpp/Operations/UpdateFirmware.cpp
src/MicroOcpp/Debug.cpp
src/MicroOcpp/Platform.cpp
src/MicroOcpp/Core/SimpleRequestFactory.cpp
src/MicroOcpp/Core/OperationRegistry.cpp
Expand Down
2 changes: 0 additions & 2 deletions src/MicroOcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ bool endTransaction(const char *idTag, const char *reason, unsigned int connecto
res = endTransaction_authorized(idTag, reason, connectorId);
} else {
MO_DBG_INFO("endTransaction: idTag doesn't match");
(void)0;
}
}
return res;
Expand Down Expand Up @@ -977,7 +976,6 @@ void setCertificateStore(std::unique_ptr<MicroOcpp::CertificateStore> certStore)
certService->setCertificateStore(std::move(certStore));
} else {
MO_DBG_ERR("OOM");
(void)0;
}
}
#endif //MO_ENABLE_CERT_MGMT
Expand Down
2 changes: 0 additions & 2 deletions src/MicroOcpp/Core/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ ConfigurationContainer *declareContainer(const char *filename, bool accessible)

if (container->isAccessible() != accessible) {
MO_DBG_ERR("%s: conflicting accessibility declarations (expect %s)", filename, container->isAccessible() ? "accessible" : "inaccessible");
(void)0;
}

return container.get();
Expand All @@ -95,7 +94,6 @@ std::shared_ptr<Configuration> loadConfiguration(TConfig type, const char *key,
}
if (container->isAccessible() != accessible) {
MO_DBG_ERR("conflicting accessibility for %s", key);
(void)0;
}
container->loadStaticKey(*config.get(), key);
return config;
Expand Down
1 change: 0 additions & 1 deletion src/MicroOcpp/Core/ConfigurationContainerFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ class ConfigurationContainerFlash : public ConfigurationContainer {
}
} else {
MO_DBG_ERR("OOM: %s", key);
(void)0;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/MicroOcpp/Core/FilesystemUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ bool FilesystemUtils::remove_if(std::shared_ptr<FilesystemAdapter> filesystem, s

if (ret != 0) {
MO_DBG_ERR("ftw_root: %i", ret);
(void)0;
}

return ret == 0;
Expand Down
2 changes: 0 additions & 2 deletions src/MicroOcpp/Core/FtpMbedTLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ void FtpTransferMbedTLS::send_cmd(const char *cmd, const char *arg, bool disable
MO_DBG_DEBUG("SEND: %s %s",
cmd,
!strncmp((char*) cmd, "PASS", strlen("PASS")) ? "***" : arg ? (char*) arg : "");
(void)0;
}

int ret = -1;
Expand Down Expand Up @@ -647,7 +646,6 @@ void FtpTransferMbedTLS::process_ctrl() {
return;
} else if (!strncmp("200", line, 3)) { //PBSZ -> 0 and PROT -> P accepted
MO_DBG_INFO("PBSZ/PROT success: %s", line);
(void)0;
} else if (!strncmp("221", line, 3)) { // Server Goodbye
MO_DBG_DEBUG("closing ctrl connection");
close_ctrl();
Expand Down
3 changes: 0 additions & 3 deletions src/MicroOcpp/Core/Request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ bool Request::restore(std::unique_ptr<StoredOperationHandler> opStorage, Model *
}
} else {
MO_DBG_ERR("cannot set unique msgID counter");
(void)0;
//skip this step but don't abort restore
}

Expand All @@ -330,10 +329,8 @@ bool Request::restore(std::unique_ptr<StoredOperationHandler> opStorage, Model *

if (success) {
MO_DBG_DEBUG("restored opNr %i: %s", opStore->getOpNr(), operation->getOperationType());
(void)0;
} else {
MO_DBG_ERR("restore opNr %i error", opStore->getOpNr());
(void)0;
}

return success;
Expand Down
2 changes: 0 additions & 2 deletions src/MicroOcpp/Core/RequestQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,8 @@ void RequestQueue::receiveResponse(JsonArray json) {
//didn't find matching Request
if (json[0] == MESSAGE_TYPE_CALLERROR) {
MO_DBG_DEBUG("Received CALLERROR did not abort a pending operation");
(void)0;
} else {
MO_DBG_WARN("Received response doesn't match any pending operation");
(void)0;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/MicroOcpp/Core/RequestQueueStorageStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void VolatileRequestQueue::push_back(std::unique_ptr<Request> op) {

if (queue.size() >= MO_OPERATIONCACHE_MAXSIZE) {
MO_DBG_WARN("unsafe number of cached operations");
(void)0;
}

queue.push_back(std::move(op));
Expand Down
2 changes: 0 additions & 2 deletions src/MicroOcpp/Core/RequestStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ void RequestStore::advanceOpNr(unsigned int oldOpNr) {
if (oldOpNr != (unsigned int) opBeginInt->getInt()) {
if ((oldOpNr + MO_MAX_OPNR - (unsigned int) opBeginInt->getInt()) % MO_MAX_OPNR < 100) {
MO_DBG_ERR("synchronization failure - try to fix");
(void)0;
} else {
MO_DBG_ERR("synchronization failure");
return;
Expand Down Expand Up @@ -187,7 +186,6 @@ void RequestStore::advanceOpNr(unsigned int oldOpNr) {
bool success = filesystem->remove(fn);
if (!success) {
MO_DBG_ERR("error deleting %s", fn);
(void)0;
}
}

Expand Down
54 changes: 54 additions & 0 deletions src/MicroOcpp/Debug.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// matth-x/MicroOcpp
// Copyright Matthias Akstaller 2019 - 2024
// MIT License

#include <string.h>

#include <MicroOcpp/Debug.h>

const char *level_label [] = {
"", //MO_DL_NONE 0x00
"ERROR", //MO_DL_ERROR 0x01
"warning", //MO_DL_WARN 0x02
"info", //MO_DL_INFO 0x03
"debug", //MO_DL_DEBUG 0x04
"verbose" //MO_DL_VERBOSE 0x05
};

#if MO_DBG_FORMAT == MO_DF_MINIMAL
void mo_dbg_print_prefix(int level, const char *fn, int line) {
(void)0;
}

#elif MO_DBG_FORMAT == MO_DF_COMPACT
void mo_dbg_print_prefix(int level, const char *fn, int line) {
size_t l = strlen(fn);
size_t r = l;
while (l > 0 && fn[l-1] != '/' && fn[l-1] != '\\') {
l--;
if (fn[l] == '.') r = l;
}
MO_CONSOLE_PRINTF("%.*s:%i ", (int) (r - l), fn + l, line);
}

#elif MO_DBG_FORMAT == MO_DF_FILE_LINE
void mo_dbg_print_prefix(int level, const char *fn, int line) {
size_t l = strlen(fn);
while (l > 0 && fn[l-1] != '/' && fn[l-1] != '\\') {
l--;
}
MO_CONSOLE_PRINTF("[MO] %s (%s:%i): ", level_label[level], fn + l, line);
}

#elif MO_DBG_FORMAT == MO_DF_FULL
void mo_dbg_print_prefix(int level, const char *fn, int line) {
MO_CONSOLE_PRINTF("[MO] %s (%s:%i): ", level_label[level], fn, line);
}

#else
#error invalid MO_DBG_FORMAT definition
#endif

void mo_dbg_print_suffix() {
MO_CONSOLE_PRINTF("\n");
}
79 changes: 25 additions & 54 deletions src/MicroOcpp/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,81 +32,52 @@
#define MO_DBG_FORMAT MO_DF_FILE_LINE //default
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if MO_DBG_FORMAT == MO_DF_MINIMAL
#define MO_DBG(level, X) \
do { \
MO_CONSOLE_PRINTF X; \
MO_CONSOLE_PRINTF("\n"); \
} while (0);

#elif MO_DBG_FORMAT == MO_DF_COMPACT
#define MO_DBG(level, X) \
do { \
const char *_mo_file = __FILE__; \
size_t _mo_l = sizeof(__FILE__); \
size_t _mo_r = _mo_l; \
while (_mo_l > 0 && _mo_file[_mo_l-1] != '/' && _mo_file[_mo_l-1] != '\\') { \
_mo_l--; \
if (_mo_file[_mo_l] == '.') _mo_r = _mo_l; \
} \
MO_CONSOLE_PRINTF("%.*s:%i ", (int) (_mo_r - _mo_l), _mo_file + _mo_l,__LINE__); \
MO_CONSOLE_PRINTF X; \
MO_CONSOLE_PRINTF("\n"); \
} while (0);

#elif MO_DBG_FORMAT == MO_DF_FILE_LINE
#define MO_DBG(level, X) \
do { \
const char *_mo_file = __FILE__; \
size_t _mo_l = sizeof(__FILE__); \
for (; _mo_l > 0 && _mo_file[_mo_l-1] != '/' && _mo_file[_mo_l-1] != '\\'; _mo_l--); \
MO_CONSOLE_PRINTF("[MO] %s (%s:%i): ",level, _mo_file + _mo_l,__LINE__); \
MO_CONSOLE_PRINTF X; \
MO_CONSOLE_PRINTF("\n"); \
} while (0);

#elif MO_DBG_FORMAT == MO_DF_FULL
#define MO_DBG(level, X) \
do { \
MO_CONSOLE_PRINTF("[MO] %s (%s:%i): ",level, __FILE__,__LINE__); \
MO_CONSOLE_PRINTF X; \
MO_CONSOLE_PRINTF("\n"); \
} while (0);
void mo_dbg_print_prefix(int level, const char *fn, int line);
void mo_dbg_print_suffix();

#else
#error invalid MO_DBG_FORMAT definition
#ifdef __cplusplus
}
#endif

#define MO_DBG(level, X) \
do { \
mo_dbg_print_prefix(level, __FILE__, __LINE__); \
MO_CONSOLE_PRINTF X; \
mo_dbg_print_suffix(); \
} while (0)

#if MO_DBG_LEVEL >= MO_DL_ERROR
#define MO_DBG_ERR(...) MO_DBG("ERROR",(__VA_ARGS__))
#define MO_DBG_ERR(...) MO_DBG(MO_DL_ERROR,(__VA_ARGS__))
#else
#define MO_DBG_ERR(...)
#define MO_DBG_ERR(...) ((void)0)
#endif

#if MO_DBG_LEVEL >= MO_DL_WARN
#define MO_DBG_WARN(...) MO_DBG("warning",(__VA_ARGS__))
#define MO_DBG_WARN(...) MO_DBG(MO_DL_WARN,(__VA_ARGS__))
#else
#define MO_DBG_WARN(...)
#define MO_DBG_WARN(...) ((void)0)
#endif

#if MO_DBG_LEVEL >= MO_DL_INFO
#define MO_DBG_INFO(...) MO_DBG("info",(__VA_ARGS__))
#define MO_DBG_INFO(...) MO_DBG(MO_DL_INFO,(__VA_ARGS__))
#else
#define MO_DBG_INFO(...)
#define MO_DBG_INFO(...) ((void)0)
#endif

#if MO_DBG_LEVEL >= MO_DL_DEBUG
#define MO_DBG_DEBUG(...) MO_DBG("debug",(__VA_ARGS__))
#define MO_DBG_DEBUG(...) MO_DBG(MO_DL_DEBUG,(__VA_ARGS__))
#else
#define MO_DBG_DEBUG(...)
#define MO_DBG_DEBUG(...) ((void)0)
#endif

#if MO_DBG_LEVEL >= MO_DL_VERBOSE
#define MO_DBG_VERBOSE(...) MO_DBG("verbose",(__VA_ARGS__))
#define MO_DBG_VERBOSE(...) MO_DBG(MO_DL_VERBOSE,(__VA_ARGS__))
#else
#define MO_DBG_VERBOSE(...)
#define MO_DBG_VERBOSE(...) ((void)0)
#endif

#ifdef MO_TRAFFIC_OUT
Expand All @@ -124,8 +95,8 @@
} while (0)

#else
#define MO_DBG_TRAFFIC_OUT(...)
#define MO_DBG_TRAFFIC_IN(...)
#define MO_DBG_TRAFFIC_OUT(...) ((void)0)
#define MO_DBG_TRAFFIC_IN(...) ((void)0)
#endif

#endif
1 change: 0 additions & 1 deletion src/MicroOcpp/Model/Boot/BootService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ BootService::BootService(Context& context, std::shared_ptr<FilesystemAdapter> fi

if (!preBootTransactionsBool) {
MO_DBG_ERR("initialization error");
(void)0;
}

//Register message handler for TriggerMessage operation
Expand Down
3 changes: 0 additions & 3 deletions src/MicroOcpp/Model/ConnectorBase/Connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ Connector::Connector(Context& context, int connectorId)
transaction = model.getTransactionStore()->getLatestTransaction(connectorId);
} else {
MO_DBG_ERR("must initialize TxStore before Connector");
(void)0;
}
}

Expand Down Expand Up @@ -398,7 +397,6 @@ void Connector::loop() {

if (!transaction) {
MO_DBG_ERR("could not begin FreeVend Tx");
(void)0;
}
}

Expand Down Expand Up @@ -574,7 +572,6 @@ std::shared_ptr<Transaction> Connector::allocateTransaction() {

if (tx) {
MO_DBG_DEBUG("created silent transaction");
(void)0;
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/MicroOcpp/Model/Metering/MeterStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ TransactionMeterData::TransactionMeterData(unsigned int connectorId, unsigned in

if (!filesystem) {
MO_DBG_DEBUG("volatile mode");
(void)0;
}
}

Expand Down Expand Up @@ -151,7 +150,6 @@ MeterStore::MeterStore(std::shared_ptr<FilesystemAdapter> filesystem) : filesyst

if (!filesystem) {
MO_DBG_DEBUG("volatile mode");
(void)0;
}
}

Expand Down Expand Up @@ -293,7 +291,6 @@ bool MeterStore::remove(unsigned int connectorId, unsigned int txNr) {

if (success) {
MO_DBG_DEBUG("Removed meter values for cId %u, txNr %u", connectorId, txNr);
(void)0;
} else {
MO_DBG_DEBUG("corrupted fs");
}
Expand Down
1 change: 0 additions & 1 deletion src/MicroOcpp/Model/Reservation/Reservation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Reservation::Reservation(Model& model, unsigned int slot) : model(model), slot(s

if (!connectorIdInt || !expiryDateRawString || !idTagString || !reservationIdInt || !parentIdTagString) {
MO_DBG_ERR("initialization failure");
(void)0;
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/MicroOcpp/Model/SmartCharging/SmartChargingService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ void SmartChargingConnector::loop(){
void SmartChargingConnector::setSmartChargingOutput(std::function<void(float,float,int)> limitOutput) {
if (this->limitOutput) {
MO_DBG_WARN("replacing existing SmartChargingOutput");
(void)0;
}
this->limitOutput = limitOutput;
}
Expand Down Expand Up @@ -532,7 +531,6 @@ void SmartChargingService::setSmartChargingOutput(unsigned int connectorId, std:
if (connectorId == 0) {
if (this->limitOutput) {
MO_DBG_WARN("replacing existing SmartChargingOutput");
(void)0;
}
this->limitOutput = limitOutput;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ bool deserializeTransaction(Transaction& tx, JsonObject state) {
MO_DBG_DEBUG("Stop RPC | req: %i, conf: %i", tx.getStopSync().isRequested(), tx.getStopSync().isConfirmed());
if (tx.isSilent()) {
MO_DBG_DEBUG(" | silent Tx");
(void)0;
}

return true;
Expand Down
Loading