Skip to content

Commit 03256c2

Browse files
committed
reworked project organization
1 parent 3c61a70 commit 03256c2

73 files changed

Lines changed: 1200 additions & 289 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 matth-x
3+
Copyright (c) 2019 - 2021 matth-x
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

library.json

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
11
{
2-
"name": "ESP8266-OCPP",
2+
"name": "ArduinoOcpp",
33
"version": "0.0.1",
4-
"keywords": "OCPP, 1.6, OCPP 1.6, Smart Energy, Smart Charging, client",
5-
"description": "OCPP 1.6 Smart Charging client for ESP8266",
4+
"description": "OCPP 1.6 Client for the ESP8266 (ESP32 and more coming soon)",
5+
"keywords": "OCPP, 1.6, OCPP 1.6, Smart Energy, Smart Charging, client, ESP8266, Arduino",
66
"repository":
77
{
88
"type": "git",
9-
"url": "https://github.com/matth-x/ESP8266-OCPP/"
9+
"url": "https://github.com/matth-x/ArduinoOcpp/"
10+
},
11+
"authors":
12+
[
13+
{
14+
"name": "Matthias Akstaller",
15+
"url": "https://www.arduino-ocpp.com",
16+
"maintainer": true
17+
}
18+
],
19+
"license": "MIT",
20+
"homepage": "https://www.arduino-ocpp.com",
21+
"dependencies": {
22+
"ArduinoJson": "6.17.2",
23+
"WebSockets": "2.2.0",
24+
"ivanseidel/LinkedList": "0.0.0-alpha+sha.dac3874d28",
25+
"Time": "1.6"
1026
},
1127
"frameworks": "arduino",
12-
"platforms": "esspressif8266"
13-
}
28+
"platforms": "espressif8266",
29+
30+
"export": {
31+
"include":
32+
[
33+
"src/*",
34+
"examples/*",
35+
"platformio.ini",
36+
"library.json",
37+
"LICENSE"
38+
],
39+
"exclude":
40+
[
41+
"src/OneConnector*",
42+
"src/Simulated_HW*",
43+
"src/OcppServer*"
44+
]
45+
}
46+
}

library.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name=ESP8266-OCPP
1+
name=ArduinoOcpp
22
version=0.0.1
3-
author=matth-x
4-
maintainer=matth-x
5-
sentence=OCPP Smart Charging client for ESP8266
3+
author=Matthias Akstaller
4+
maintainer=Matthias Akstaller
5+
sentence=OCPP 1.6 Client for the ESP8266 (ESP32 and more coming soon)
66
paragraph=
77
category=Communication
8-
url=https://github.com/invalid
9-
architectures=*
8+
url=https://github.com/matth-x/ArduinoOcpp/
9+
architectures=espressif8266

platformio.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ lib_deps =
2626

2727
; Serial Monitor options
2828
monitor_speed = 115200
29+
30+
;

src/ArduinoOcpp.cpp

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
#if USE_FACADE
1010

11-
#include "OcppEngine.h"
12-
#include "MeteringService.h"
13-
#include "SmartChargingService.h"
14-
#include "ChargePointStatusService.h"
15-
#include "SimpleOcppOperationFactory.h"
16-
#include "Configuration.h"
17-
18-
#include "Authorize.h"
19-
#include "BootNotification.h"
20-
#include "StartTransaction.h"
21-
#include "StopTransaction.h"
22-
#include "OcppOperationTimeout.h"
11+
#include <ArduinoOcpp/Core/OcppEngine.h>
12+
#include <ArduinoOcpp/Tasks/Metering/MeteringService.h>
13+
#include <ArduinoOcpp/Tasks/SmartCharging/SmartChargingService.h>
14+
#include <ArduinoOcpp/Tasks/ChargePointStatus/ChargePointStatusService.h>
15+
#include <ArduinoOcpp/SimpleOcppOperationFactory.h>
16+
#include <ArduinoOcpp/Core/Configuration.h>
17+
18+
#include <ArduinoOcpp/MessagesV16/Authorize.h>
19+
#include <ArduinoOcpp/MessagesV16/BootNotification.h>
20+
#include <ArduinoOcpp/MessagesV16/StartTransaction.h>
21+
#include <ArduinoOcpp/MessagesV16/StopTransaction.h>
22+
#include <ArduinoOcpp/Core/OcppOperationTimeout.h>
2323

2424
namespace ArduinoOcpp {
2525
namespace Facade {
@@ -40,6 +40,7 @@ OnLimitChange onLimitChange;
4040
#define OCPP_ID_OF_CP 0
4141
boolean OCPP_initialized = false;
4242

43+
#if 0 //moved to OcppConnection
4344
/*
4445
Called by Websocket library on incoming message on the internet link
4546
*/
@@ -82,10 +83,14 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
8283
}
8384
}
8485

86+
#endif //moved to OcppConnection
87+
8588
} //end namespace ArduinoOcpp::Facade
8689
} //end namespace ArduinoOcpp
8790

91+
using namespace ArduinoOcpp;
8892
using namespace ArduinoOcpp::Facade;
93+
using namespace ArduinoOcpp::Ocpp16;
8994

9095
void OCPP_initialize(String CS_hostname, uint16_t CS_port, String CS_url) {
9196
if (OCPP_initialized) {
@@ -99,7 +104,7 @@ void OCPP_initialize(String CS_hostname, uint16_t CS_port, String CS_url) {
99104
webSocket.begin(CS_hostname, CS_port, CS_url, "ocpp1.6");
100105

101106
// event handler
102-
webSocket.onEvent(webSocketEvent);
107+
//webSocket.onEvent(webSocketEvent); //will be set in ocppEngine_initialize()
103108

104109
// use HTTP Basic Authorization this is optional remove if not needed
105110
// webSocket.setAuthorization("user", "Password");
@@ -198,7 +203,7 @@ void setOnResetSendConf(void listener(JsonObject payload)) {
198203
}
199204

200205
void authorize(String &idTag, OnReceiveConfListener onConf, OnAbortListener onAbort, OnTimeoutListener onTimeout, OnReceiveErrorListener onError) {
201-
OcppOperation *authorize = makeOcppOperation(&webSocket,
206+
OcppOperation *authorize = makeOcppOperation(
202207
new Authorize(idTag));
203208
initiateOcppOperation(authorize);
204209
if (onConf)
@@ -213,7 +218,7 @@ void authorize(String &idTag, OnReceiveConfListener onConf, OnAbortListener onAb
213218
}
214219

215220
void bootNotification(String chargePointModel, String chargePointVendor, OnReceiveConfListener onConf, OnAbortListener onAbort, OnTimeoutListener onTimeout, OnReceiveErrorListener onError) {
216-
OcppOperation *bootNotification = makeOcppOperation(&webSocket,
221+
OcppOperation *bootNotification = makeOcppOperation(
217222
new BootNotification(chargePointModel, chargePointVendor));
218223
initiateOcppOperation(bootNotification);
219224
if (onConf)
@@ -228,15 +233,15 @@ void bootNotification(String chargePointModel, String chargePointVendor, OnRecei
228233
}
229234

230235
void bootNotification(String &chargePointModel, String &chargePointVendor, String &chargePointSerialNumber, OnReceiveConfListener onConf) {
231-
OcppOperation *bootNotification = makeOcppOperation(&webSocket,
236+
OcppOperation *bootNotification = makeOcppOperation(
232237
new BootNotification(chargePointModel, chargePointVendor, chargePointSerialNumber));
233238
initiateOcppOperation(bootNotification);
234239
bootNotification->setOnReceiveConfListener(onConf);
235240
bootNotification->setTimeout(new SuppressedTimeout());
236241
}
237242

238243
void startTransaction(OnReceiveConfListener onConf, OnAbortListener onAbort, OnTimeoutListener onTimeout, OnReceiveErrorListener onError) {
239-
OcppOperation *startTransaction = makeOcppOperation(&webSocket,
244+
OcppOperation *startTransaction = makeOcppOperation(
240245
new StartTransaction(OCPP_ID_OF_CONNECTOR));
241246
initiateOcppOperation(startTransaction);
242247
if (onConf)
@@ -251,15 +256,15 @@ void startTransaction(OnReceiveConfListener onConf, OnAbortListener onAbort, OnT
251256
}
252257

253258
void startTransaction(String &idTag, OnReceiveConfListener onConf) {
254-
OcppOperation *startTransaction = makeOcppOperation(&webSocket,
259+
OcppOperation *startTransaction = makeOcppOperation(
255260
new StartTransaction(OCPP_ID_OF_CONNECTOR, idTag));
256261
initiateOcppOperation(startTransaction);
257262
startTransaction->setOnReceiveConfListener(onConf);
258263
startTransaction->setTimeout(new FixedTimeout(20000));
259264
}
260265

261266
void stopTransaction(OnReceiveConfListener onConf, OnAbortListener onAbort, OnTimeoutListener onTimeout, OnReceiveErrorListener onError) {
262-
OcppOperation *stopTransaction = makeOcppOperation(&webSocket,
267+
OcppOperation *stopTransaction = makeOcppOperation(
263268
new StopTransaction(OCPP_ID_OF_CONNECTOR));
264269
initiateOcppOperation(stopTransaction);
265270
if (onConf)

src/ArduinoOcpp.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
#ifndef ARDUINOOCPP_H
66
#define ARDUINOOCPP_H
77

8-
#include "OcppOperation.h"
8+
#include <ArduinoOcpp/Core/OcppOperation.h>
99

1010
#include "Variants.h"
1111

12+
using ArduinoOcpp::OnReceiveConfListener;
13+
using ArduinoOcpp::OnReceiveReqListener;
14+
using ArduinoOcpp::OnSendConfListener;
15+
using ArduinoOcpp::OnAbortListener;
16+
using ArduinoOcpp::OnTimeoutListener;
17+
using ArduinoOcpp::OnReceiveErrorListener;
18+
1219
#if USE_FACADE
1320

1421
void OCPP_initialize(String CS_hostname, uint16_t CS_port, String CS_url);
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Copyright Matthias Akstaller 2019 - 2021
33
// MIT License
44

5-
#include "Configuration.h"
5+
#include <ArduinoOcpp/Core/Configuration.h>
66

7-
#include "Variants.h"
7+
#include <Variants.h>
88

99
#include <string.h>
1010
#include <LinkedList.h>
@@ -22,6 +22,8 @@
2222

2323
#define DEV_CONF true
2424

25+
namespace ArduinoOcpp {
26+
2527
AbstractConfiguration::AbstractConfiguration() {
2628

2729
}
@@ -942,3 +944,5 @@ bool configuration_save() {
942944

943945
return true;
944946
}
947+
948+
} //end namespace ArduinoOcpp
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <LinkedList.h>
1010
#include <memory>
1111

12+
namespace ArduinoOcpp {
13+
1214
class AbstractConfiguration {
1315
private:
1416
char *key = NULL;
@@ -117,4 +119,5 @@ std::shared_ptr<LinkedList<std::shared_ptr<AbstractConfiguration>>> getAllConfig
117119
bool configuration_init();
118120
bool configuration_save();
119121

122+
} //end namespace ArduinoOcpp
120123
#endif

0 commit comments

Comments
 (0)