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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Change `MicroOcpp::ChargePointStatus` into C-style enum ([#309](https://github.com/matth-x/MicroOcpp/pull/309))
- Connector lock disabled by default per `MO_ENABLE_CONNECTOR_LOCK` ([#312](https://github.com/matth-x/MicroOcpp/pull/312))
- Relaxed temporal order of non-tx-related operations ([#345](https://github.com/matth-x/MicroOcpp/pull/345))
- Use pseudo-GUIDs as messageId ([#345](https://github.com/matth-x/MicroOcpp/pull/345))

### Added

Expand All @@ -16,10 +18,13 @@
- Build flag `MO_REPORT_NOERROR` to report error recovery ([#331](https://github.com/matth-x/MicroOcpp/pull/331))
- Support for `parentIdTag` ([#344](https://github.com/matth-x/MicroOcpp/pull/344))
- Input validation for unsigned int Configs ([#344](https://github.com/matth-x/MicroOcpp/pull/344))
- Support for TransactionMessageAttempts/-RetryInterval ([#345](https://github.com/matth-x/MicroOcpp/pull/345))

### Removed

- ESP32 built-in HTTP OTA ([#313](https://github.com/matth-x/MicroOcpp/pull/313))
- Operation store (files op-*.jsn and opstore.jsn) ([#345](https://github.com/matth-x/MicroOcpp/pull/345))
- Explicit tracking of txNr (file txstore.jsn) ([#345](https://github.com/matth-x/MicroOcpp/pull/345))

### Fixed

Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ set(MO_SRC
src/MicroOcpp/Core/Request.cpp
src/MicroOcpp/Core/Connection.cpp
src/MicroOcpp/Core/Time.cpp
src/MicroOcpp/Core/RequestQueueStorageStrategy.cpp
src/MicroOcpp/Core/RequestStore.cpp
src/MicroOcpp/Operations/Authorize.cpp
src/MicroOcpp/Operations/BootNotification.cpp
src/MicroOcpp/Operations/CancelReservation.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/MicroOcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void mocpp_initialize(Connection& connection, const char *bootNotificationCreden
new ConnectorsCommon(*context, MO_NUMCONNECTORS, filesystem)));
std::vector<std::unique_ptr<Connector>> connectors;
for (unsigned int connectorId = 0; connectorId < MO_NUMCONNECTORS; connectorId++) {
connectors.emplace_back(new Connector(*context, connectorId));
connectors.emplace_back(new Connector(*context, filesystem, connectorId));
}
model.setConnectors(std::move(connectors));
model.setHeartbeatService(std::unique_ptr<HeartbeatService>(
Expand Down
39 changes: 10 additions & 29 deletions src/MicroOcpp/Core/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
using namespace MicroOcpp;

Context::Context(Connection& connection, std::shared_ptr<FilesystemAdapter> filesystem, uint16_t bootNr, ProtocolVersion version)
: connection(connection), model{version, bootNr}, reqQueue{operationRegistry, &model, filesystem} {
: connection(connection), model{version, bootNr}, reqQueue{connection, operationRegistry} {

preBootQueue = std::unique_ptr<RequestQueue>(new RequestQueue(operationRegistry, &model, nullptr)); //pre boot queue doesn't need persistency
preBootQueue->setConnection(connection);
}

Context::~Context() {
Expand All @@ -24,37 +22,16 @@ Context::~Context() {

void Context::loop() {
connection.loop();

if (preBootQueue) {
preBootQueue->loop(connection);
} else {
reqQueue.loop(connection);
}

reqQueue.loop();
model.loop();
}

void Context::activatePostBootCommunication() {
//switch from pre boot connection to normal connetion
reqQueue.setConnection(connection);
preBootQueue.reset();
}

void Context::initiateRequest(std::unique_ptr<Request> op) {
if (op) {
reqQueue.sendRequest(std::move(op));
}
}

void Context::initiatePreBootOperation(std::unique_ptr<Request> op) {
if (op) {
if (preBootQueue) {
preBootQueue->sendRequest(std::move(op));
} else {
//not in pre boot mode anymore - initiate normally
initiateRequest(std::move(op));
}
if (!op) {
MO_DBG_ERR("invalid arg");
return;
}
reqQueue.sendRequest(std::move(op));
}

Model& Context::getModel() {
Expand All @@ -73,6 +50,10 @@ Connection& Context::getConnection() {
return connection;
}

RequestQueue& Context::getRequestQueue() {
return reqQueue;
}

void Context::setFtpClient(std::unique_ptr<FtpClient> ftpClient) {
this->ftpClient = std::move(ftpClient);
}
Expand Down
9 changes: 2 additions & 7 deletions src/MicroOcpp/Core/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class Context {
Model model;
RequestQueue reqQueue;

std::unique_ptr<RequestQueue> preBootQueue;

std::unique_ptr<FtpClient> ftpClient;

public:
Expand All @@ -35,12 +33,7 @@ class Context {

void loop();

void activatePostBootCommunication();

void initiateRequest(std::unique_ptr<Request> op);

//for BootNotification and TriggerMessage: initiate operations before the first BootNotification was accepted (pre-boot mode)
void initiatePreBootOperation(std::unique_ptr<Request> op);

Model& getModel();

Expand All @@ -50,6 +43,8 @@ class Context {

Connection& getConnection();

RequestQueue& getRequestQueue();

void setFtpClient(std::unique_ptr<FtpClient> ftpClient);
FtpClient *getFtpClient();
};
Expand Down
8 changes: 0 additions & 8 deletions src/MicroOcpp/Core/Operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ const char* Operation::getOperationType(){
return "CustomOperation";
}

void Operation::initiate(StoredOperationHandler *rpcData) {
//called after initiateRequest(anyMsg)
}

bool Operation::restore(StoredOperationHandler *rpcData) {
return false;
}

std::unique_ptr<DynamicJsonDocument> Operation::createReq() {
MO_DBG_ERR("Unsupported operation: createReq() is not implemented");
return createEmptyDocument();
Expand Down
8 changes: 1 addition & 7 deletions src/MicroOcpp/Core/Operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
#ifndef MO_OPERATION_H
#define MO_OPERATION_H

#include <ArduinoJson.h>
#include <memory>

#include <MicroOcpp/Core/RequestStore.h>
#include <ArduinoJson.h>

namespace MicroOcpp {

Expand All @@ -35,10 +33,6 @@ class Operation {

virtual const char* getOperationType();

virtual void initiate(StoredOperationHandler *rpcData);

virtual bool restore(StoredOperationHandler *rpcData);

/**
* Create the payload for the respective OCPP message
*
Expand Down
Loading