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 @@ -38,6 +38,7 @@
- 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
- Avoid creating conf when operation fails ([#290](https://github.com/matth-x/MicroOcpp/pull/290))

## [1.0.3] - 2024-04-06

Expand Down
18 changes: 9 additions & 9 deletions src/MicroOcpp/Core/Request.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// matth-x/MicroOcpp
// Copyright Matthias Akstaller 2019 - 2023
// Copyright Matthias Akstaller 2019 - 2024
// MIT License

#include <MicroOcpp/Core/Request.h>
Expand Down Expand Up @@ -184,17 +184,17 @@ std::unique_ptr<DynamicJsonDocument> Request::createResponse(){
* Create the OCPP message
*/
std::unique_ptr<DynamicJsonDocument> response = nullptr;
std::unique_ptr<DynamicJsonDocument> payload = operation->createConf();
std::unique_ptr<DynamicJsonDocument> errorDetails = nullptr;

bool operationFailure = operation->getErrorCode() != nullptr;

if (!operationFailure && !payload) {
return nullptr; //confirmation message still pending
}
bool operationFailure = operation->getErrorCode() != nullptr;

if (!operationFailure) {

std::unique_ptr<DynamicJsonDocument> payload = operation->createConf();

if (!payload) {
return nullptr; //confirmation message still pending
}

/*
* Create OCPP-J Remote Procedure Call header
*/
Expand All @@ -213,7 +213,7 @@ std::unique_ptr<DynamicJsonDocument> Request::createResponse(){

const char *errorCode = operation->getErrorCode();
const char *errorDescription = operation->getErrorDescription();
errorDetails = std::unique_ptr<DynamicJsonDocument>(operation->getErrorDetails());
std::unique_ptr<DynamicJsonDocument> errorDetails = std::unique_ptr<DynamicJsonDocument>(operation->getErrorDetails());
if (!errorCode) { //catch corner case when payload is null but errorCode is not set too!
errorCode = "GenericError";
errorDescription = "Could not create payload (createConf() returns Null)";
Expand Down