Skip to content

Commit e879c0e

Browse files
authored
prepare v1.1.0 release (#306)
* increase dbg msg buf size, clean up * more concise build flag MO_ENABLE_RESERVATION * update docs * advance version to v1.1.0 * fix compiler warnings * clean CMakeLists.txt * update release date * update example, fix compilation error * update dependencies
1 parent 53465b4 commit e879c0e

30 files changed

+131
-113
lines changed

.github/workflows/esp-idf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: actions/checkout@v3
3838
with:
3939
repository: matth-x/MicroOcppMongoose
40-
ref: 92ebea9fe8554999b4d34c6a03fa12c0d9faec48
40+
ref: v1.1.0
4141
path: examples/ESP-IDF/components/MicroOcppMongoose
4242
- name: Checkout ArduinoJson
4343
uses: actions/checkout@v3

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## [Unreleased]
3+
## [1.1.0] - 2024-05-21
44

55
### Changed
66

@@ -14,7 +14,7 @@
1414

1515
- File index ([#270](https://github.com/matth-x/MicroOcpp/pull/270))
1616
- Config `Cst_TxStartOnPowerPathClosed` to put back TxStartPoint ([#271](https://github.com/matth-x/MicroOcpp/pull/271))
17-
- Build flag `MO_ENABLE_V16_RESERVATION=0` disables Reservation module ([#302](https://github.com/matth-x/MicroOcpp/pull/302))
17+
- Build flag `MO_ENABLE_RESERVATION=0` disables Reservation module ([#302](https://github.com/matth-x/MicroOcpp/pull/302))
1818
- Build flag `MO_ENABLE_LOCAL_AUTH=0` disables LocalAuthList module ([#303](https://github.com/matth-x/MicroOcpp/pull/303))
1919
- Function `bool isConnected()` in `Connection` interface ([#282](https://github.com/matth-x/MicroOcpp/pull/282))
2020
- Build flags for customizing memory limits of SmartCharging ([#260](https://github.com/matth-x/MicroOcpp/pull/260))

CMakeLists.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,18 @@ set(MO_SRC
106106
if(ESP_PLATFORM)
107107

108108
idf_component_register(SRCS ${MO_SRC}
109-
INCLUDE_DIRS "./src" "../ArduinoJson/src"
110-
PRIV_REQUIRES spiffs)
109+
INCLUDE_DIRS "./src" "../ArduinoJson/src"
110+
PRIV_REQUIRES spiffs
111+
)
111112

112113
target_compile_options(${COMPONENT_TARGET} PUBLIC
113114
-DMO_PLATFORM=MO_PLATFORM_ESPIDF
114-
-DMO_CUSTOM_RESET
115-
)
115+
)
116116

117117
return()
118118
endif()
119119

120-
project(MicroOcpp
121-
VERSION 0.2.0)
120+
project(MicroOcpp VERSION 1.1.0)
122121

123122
add_library(MicroOcpp ${MO_SRC})
124123

@@ -129,7 +128,6 @@ target_include_directories(MicroOcpp PUBLIC
129128

130129
target_compile_definitions(MicroOcpp PUBLIC
131130
MO_PLATFORM=MO_PLATFORM_UNIX
132-
MO_CUSTOM_RESET
133131
)
134132

135133
# Unit tests
@@ -181,7 +179,6 @@ target_compile_definitions(mo_unit_tests PUBLIC
181179
MO_PLATFORM=MO_PLATFORM_UNIX
182180
MO_NUMCONNECTORS=3
183181
MO_CUSTOM_TIMER
184-
MO_CUSTOM_RESET
185182
MO_DBG_LEVEL=MO_DL_DEBUG
186183
MO_TRAFFIC_OUT
187184
MO_FILENAME_PREFIX="./mo_store/"

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ OCPP 1.6 client for microcontrollers. Portable C/C++. Compatible with Espressif,
1414

1515
Reference usage: [OpenEVSE](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/blob/master/src/ocpp.cpp) | Technical introduction: [Docs](https://matth-x.github.io/MicroOcpp/intro-tech) | Website: [www.micro-ocpp.com](https://www.micro-ocpp.com)
1616

17-
**Updated branches (2024-03-24):** the default branch was renamed from master into main. The develop branch hasn't been used anymore, so it is deleted. This better represents how branches are used in MicroOcpp: active development takes place on main (plus the feature and fixing branches) and the releases are stable versions of this library. To get a release version, checkout a tag, e.g. *v1.0.3*, or download it from GitHub / PlatformIO.
18-
1917
## Tester / Demo App
2018

2119
*Main repository: [MicroOcppSimulator](https://github.com/matth-x/MicroOcppSimulator)*
@@ -71,7 +69,7 @@ If using the built-in certificate store (to enable, set build flag `MO_ENABLE_MB
7169

7270
- [Mbed-TLS/mbedtls](https://github.com/Mbed-TLS/mbedtls) (version `2.28.1`)
7371

74-
In case you use PlatformIO, you can copy all dependencies from `platformio.ini` into your own configuration file. Alternatively, you can install the full library with dependencies by adding `matth-x/MicroOcpp@1.0.3` in the PIO library manager.
72+
In case you use PlatformIO, you can copy all dependencies from `platformio.ini` into your own configuration file. Alternatively, you can install the full library with dependencies by adding `matth-x/MicroOcpp@1.1.0` in the PIO library manager.
7573

7674
## OCPP 2.0.1 and ISO 15118
7775

docs/migration.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
# Migrating to v1.0
1+
# Migrating to v1.1
2+
3+
As a new minor version, all features should work the same as in v1.0 and existing integrations are mostly backwards compatible. However, some fixes / cleanup steps in MicroOcpp require syntactic changes or special consideration when upgrading from v1.0 to v1.1. The known pitfalls are as follows:
4+
5+
- The default branch has been renamed from `master` into `main`
6+
- Need to include extra headers: the transitive includes have been cleaned a bit. Probably it's necessary to add more includes next to `#include <MicroOcpp.h>`. E.g.<br/>`#include <MicroOcpp/Model/Diagnostics/DiagnosticsService.h>`<br/>`#include <MicroOcpp/Model/FirmwareManagement/FirmwareService.h>`
7+
- `ocppPermitsCharge()` does not consider failures reported by the charger anymore. Before v1.1 it was possible to report failures to MicroOcpp using ErrorCodeInputs and then to rely on `ocppPermitsCharge()` becoming false when a failure occurs. For backwards compatibility, complement any occurence to `ocppPermitsCharge() && !isFaulted()`
8+
- `setEnergyMeterInput` changed the expected return type of the callback function from `float` to `int` (see [#301](https://github.com/matth-x/MicroOcpp/pull/301))
9+
- The return type of the UnlockConnector handler also changed from `PollResult<bool>` to enum `UnlockConnectorResult` (see [#271](https://github.com/matth-x/MicroOcpp/pull/271))
10+
11+
If upgrading MicroOcppMongoose at the same time, then the following changes are very important to consider:
12+
13+
- Certificates are no longer copied into heap memory, but the MO-Mongoose class takes the passed certificate pointer as a zero-copy parameter. The string behind the passed pointer must outlive the MO-Mongoose class (see [#10](https://github.com/matth-x/MicroOcppMongoose/pull/10))
14+
- WebSocket authorization keys are no longer stored as c-strings, but as `unsigned char` buffers. For backwards compatibility, a null-byte is still appended and the buffer can be accessed as c-string, but this should be tested in existing deployments. Furtermore, MicroOcpp only accepts hex-encoded keys coming via ChangeConfiguration which is mandated by the standard. This also may break existing deployments (see [#4](https://github.com/matth-x/MicroOcppMongoose/pull/4)).
15+
16+
If accessing the MicroOcpp modules directly (i.e. not over `MicroOcpp.h` or `MicroOcpp_c.h`) then there are likely some more modifications to be done. See the history of pull requests where each change to the code is documented. However, if the existing integration compiles under the new MO version, then there shouldn't be too many unexpected incompatibilities.
17+
18+
## Migrating to v1.0
219

320
The API has been continously improved to best suit the common use cases for MicroOcpp. Moreover, the project has been given a new name to prevent confusion with the relation to the Arduino platform and to reflect the project goals properly. With the new project name, the API has been frozen for the v1.0 release.
421

5-
## Adopting the new project name in existing projects
22+
### Adopting the new project name in existing projects
623

724
Find and replace the keywords in the following.
825

@@ -30,7 +47,7 @@ If using the C-facade, change this as the final step:
3047

3148
- `ao_` to `ocpp_`
3249

33-
## Further API changes to consider
50+
### Further API changes to consider
3451

3552
In addition to the new project name, the API has also been reworked for more consistency. After renaming the existing project as described above, also take a look at the [changelogs](https://github.com/matth-x/MicroOcpp/blob/1.0.x/CHANGELOG.md) (see Section Changed for v1.0.0).
3653

examples/ESP-TLS/main.cpp

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,18 @@ ESP8266WiFiMulti WiFiMulti;
1414
#endif
1515

1616
#include <MicroOcpp.h>
17-
#include <MicroOcpp/Core/Connection.h> //need for setting TLS credentials
1817

19-
#define STASSID "YOUR_WIFI_SSID"
20-
#define STAPSK "YOUR_WIFI_PW"
18+
#define STASSID "YOUR_WIFI_SSID"
19+
#define STAPSK "YOUR_WIFI_PW"
2120

22-
#define OCPP_HOST "echo.websocket.events"
23-
#define OCPP_PORT 443
24-
#define OCPP_URL "wss://echo.websocket.events/"
21+
#define OCPP_BACKEND_URL "wss://echo.websocket.events"
22+
#define OCPP_CHARGE_BOX_ID ""
23+
#define OCPP_AUTH_KEY "SecureAuthKey" // OCPP Security Profile 2: TLS with Basic Authentication
2524

2625
/*
27-
* OCPP Security Profile 2: TLS with Basic Authentication
28-
*
29-
* Example credentials from the OCPP-JSON document (p. 16)
26+
* ISRG ROOT X1
3027
*/
31-
#define OCPP_AUTH_ID "AL1000"
32-
#define OCPP_AUTH_KEY "0001020304050607FFFFFFFFFFFFFFFFFFFFFFFF"
33-
34-
const char ENDPOINT_CA_CERT[] PROGMEM = R"EOF(
35-
-----BEGIN CERTIFICATE-----
28+
const char ca_cert[] PROGMEM = R"EOF(-----BEGIN CERTIFICATE-----
3629
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
3730
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
3831
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
@@ -65,9 +58,6 @@ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
6558
-----END CERTIFICATE-----
6659
)EOF";
6760

68-
WebSocketsClient wsockSecure {};
69-
MicroOcpp::EspWiFi::WSClient osockSecure {&wsockSecure};
70-
7161
void setup() {
7262

7363
/*
@@ -76,7 +66,7 @@ void setup() {
7666

7767
Serial.begin(115200);
7868

79-
Serial.print(F("[main] Wait for WiFi "));
69+
Serial.print(F("[main] Wait for WiFi: "));
8070

8171
#if defined(ESP8266)
8272
WiFiMulti.addAP(STASSID, STAPSK);
@@ -87,12 +77,14 @@ void setup() {
8777
#elif defined(ESP32)
8878
WiFi.begin(STASSID, STAPSK);
8979
while (!WiFi.isConnected()) {
90-
delay(1000);
9180
Serial.print('.');
81+
delay(1000);
9282
}
83+
#else
84+
#error only ESP32 or ESP8266 supported at the moment
9385
#endif
9486

95-
Serial.print(F(" connected\n"));
87+
Serial.println(F(" connected!"));
9688

9789
/*
9890
* Set system time (required for Certificate validation)
@@ -108,23 +100,22 @@ void setup() {
108100
Serial.printf(" finished. Unix timestamp is %lu\n", now);
109101

110102
/*
111-
* Connect to OCPP Central System (using OCPP Security Profile 2: TLS with Basic Authentication )
103+
* Initialize the OCPP library (using OCPP Security Profile 2: TLS with Basic Authentication)
112104
*/
113-
wsockSecure.beginSslWithCA(OCPP_HOST,
114-
OCPP_PORT,
115-
OCPP_URL,
116-
ENDPOINT_CA_CERT, "ocpp1.6");
117-
wsockSecure.setReconnectInterval(5000);
118-
wsockSecure.enableHeartbeat(15000, 3000, 2);
119-
wsockSecure.setAuthorization(OCPP_AUTH_ID, OCPP_AUTH_KEY); // => Authorization: Basic QUwxMDAwOgABAgMEBQYH////////////////
120-
121-
mocpp_initialize(osockSecure, ChargerCredentials("My Charging Station", "My company name"));
105+
mocpp_initialize(
106+
OCPP_BACKEND_URL,
107+
OCPP_CHARGE_BOX_ID,
108+
"My Charging Station",
109+
"My company name",
110+
MicroOcpp::FilesystemOpt::Use_Mount_FormatOnFail,
111+
OCPP_AUTH_KEY,
112+
ca_cert);
122113

123114
/*
124115
* ... see MicroOcpp.h for how to integrate the EVSE hardware.
125116
*
126117
* This example only showcases the TLS connection. For examples about the HW integration,
127-
* please see the other examples
118+
* see the other examples
128119
*/
129120
}
130121

library.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MicroOcpp",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "OCPP 1.6 Client for microcontrollers",
55
"keywords": "OCPP, 1.6, OCPP 1.6, Smart Energy, Smart Charging, client, ESP8266, ESP32, Arduino, esp-idf, EVSE, Charge Point",
66
"repository":
@@ -36,17 +36,18 @@
3636
"export": {
3737
"include":
3838
[
39-
"src/*",
39+
"docs/*",
4040
"examples/*",
41-
"platformio.ini",
41+
"src/*",
42+
"CHANGELOG.md",
43+
"CMakeLists.txt",
4244
"library.json",
4345
"library.properties",
44-
"README.md",
45-
"CMakeLists.txt",
46-
"docs/*",
4746
"LICENSE",
4847
"mkdocs.yml",
49-
"CHANGELOG.md"
48+
"platformio.ini",
49+
"README.md",
50+
"SConscript.py"
5051
]
5152
},
5253

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=MicroOcpp
2-
version=1.0.0
2+
version=1.1.0
33
author=Matthias Akstaller
44
maintainer=Matthias Akstaller
55
sentence=OCPP 1.6 Client for microcontrollers

src/MicroOcpp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void mocpp_initialize(Connection& connection, const char *bootNotificationCreden
293293
new AuthorizationService(*context, filesystem)));
294294
#endif //MO_ENABLE_LOCAL_AUTH
295295

296-
#if MO_ENABLE_V16_RESERVATION
296+
#if MO_ENABLE_RESERVATION
297297
model.setReservationService(std::unique_ptr<ReservationService>(
298298
new ReservationService(*context, MO_NUMCONNECTORS)));
299299
#endif
@@ -583,8 +583,8 @@ void setEnergyMeterInput(std::function<int()> energyInput, unsigned int connecto
583583
SampledValueProperties meterProperties;
584584
meterProperties.setMeasurand("Energy.Active.Import.Register");
585585
meterProperties.setUnit("Wh");
586-
auto mvs = std::unique_ptr<SampledValueSamplerConcrete<int, SampledValueDeSerializer<int>>>(
587-
new SampledValueSamplerConcrete<int, SampledValueDeSerializer<int>>(
586+
auto mvs = std::unique_ptr<SampledValueSamplerConcrete<int32_t, SampledValueDeSerializer<int32_t>>>(
587+
new SampledValueSamplerConcrete<int32_t, SampledValueDeSerializer<int32_t>>(
588588
meterProperties,
589589
[energyInput] (ReadingContext) {return energyInput();}
590590
));

src/MicroOcpp/Core/ConfigurationKeyValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ std::unique_ptr<Configuration> makeConfiguration(TConfig type, const char *key)
243243
}
244244
res->setKey(key);
245245
return res;
246-
};
246+
}
247247

248248
bool deserializeTConfig(const char *serialized, TConfig& out) {
249249
if (!strcmp(serialized, "int")) {

src/MicroOcpp/Core/FtpMbedTLS.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void mo_mbedtls_log(void *user, int level, const char *file, int line, const cha
162162
*/
163163

164164
FtpTransferMbedTLS::FtpTransferMbedTLS(bool tls_only, const char *client_cert, const char *client_key)
165-
: isSecure(tls_only), client_cert(client_cert), client_key(client_key) {
165+
: client_cert(client_cert), client_key(client_key), isSecure(tls_only) {
166166
mbedtls_net_init(&ctrl_fd);
167167
mbedtls_ssl_init(&ctrl_ssl);
168168
mbedtls_net_init(&data_fd);
@@ -369,7 +369,8 @@ void FtpTransferMbedTLS::close_data() {
369369

370370
int FtpTransferMbedTLS::handshake_tls() {
371371

372-
while (auto ret = mbedtls_ssl_handshake(&ctrl_ssl) != 0) {
372+
int ret;
373+
while ((ret = mbedtls_ssl_handshake(&ctrl_ssl)) != 0) {
373374
if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret != 1) {
374375
char buf [1024];
375376
mbedtls_strerror(ret, (char *) buf, 1024);
@@ -381,7 +382,7 @@ int FtpTransferMbedTLS::handshake_tls() {
381382
if (ca_cert) {
382383
//certificate validation enabled
383384

384-
if (auto ret = mbedtls_ssl_get_verify_result(&ctrl_ssl) != 0) {
385+
if ((ret = mbedtls_ssl_get_verify_result(&ctrl_ssl)) != 0) {
385386
char vrfy_buf[512];
386387
mbedtls_x509_crt_verify_info(vrfy_buf, sizeof(vrfy_buf), " > ", ret);
387388
MO_DBG_ERR("mbedtls_ssl_get_verify_result: %i, %s", ret, vrfy_buf);
@@ -403,7 +404,7 @@ void FtpTransferMbedTLS::send_cmd(const char *cmd, const char *arg, bool disable
403404
cmd, //cmd mandatory (e.g. "USER")
404405
arg ? " " : "", //line spacing if arg is provided
405406
arg ? arg : ""); //arg optional (e.g. "anonymous")
406-
if (len < 0 || len >= MSG_SIZE) {
407+
if (len < 0 || (size_t)len >= MSG_SIZE) {
407408
MO_DBG_ERR("could not write cmd, send QUIT instead");
408409
len = sprintf((char*) msg, "QUIT\r\n");
409410
} else {
@@ -883,7 +884,7 @@ bool FtpTransferMbedTLS::read_url_data(const char *data_url_raw) {
883884
}
884885

885886
FtpClientMbedTLS::FtpClientMbedTLS(bool tls_only, const char *client_cert, const char *client_key)
886-
: tls_only(tls_only), client_cert(client_cert), client_key(client_key) {
887+
: client_cert(client_cert), client_key(client_key), tls_only(tls_only) {
887888

888889
}
889890

src/MicroOcpp/Core/Time.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Timestamp &Timestamp::operator+=(int secs) {
190190
}
191191

192192
return *this;
193-
};
193+
}
194194

195195
Timestamp &Timestamp::addMilliseconds(int val) {
196196

src/MicroOcpp/Model/Authorization/IdToken.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ const char *IdToken::get() const {
7070
const char *IdToken::getTypeCstr() const {
7171
const char *res = nullptr;
7272
switch (type) {
73+
case Type::UNDEFINED:
74+
MO_DBG_ERR("internal error");
75+
break;
7376
case Type::Central:
7477
res = "Central";
7578
break;
@@ -96,9 +99,6 @@ const char *IdToken::getTypeCstr() const {
9699
break;
97100
}
98101

99-
if (!res) {
100-
MO_DBG_ERR("internal error");
101-
}
102102
return res ? res : "";
103103
}
104104

src/MicroOcpp/Model/Certificates/CertificateMbedTLS.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class CertificateStoreMbedTLS : public CertificateStore {
178178

179179
if (!success) {
180180
MO_DBG_ERR("could not read cert: %s", fn);
181-
(void)0;
182181
}
183182

184183
delete[] buf;

0 commit comments

Comments
 (0)