@@ -111,6 +111,20 @@ void mo_setFilesystemConfig2(MO_Context *ctx, MO_FilesystemOpt opt, const char *
111111}
112112#endif // MO_USE_FILEAPI != MO_CUSTOM_FS
113113
114+ void mo_setFilesystem (MO_FilesystemAdapter *filesystem) {
115+ return mo_setFilesystem2 (mo_getApiContext (), filesystem);
116+ }
117+
118+ void mo_setFilesystem2 (MO_Context *ctx, MO_FilesystemAdapter *filesystem) {
119+ if (!ctx) {
120+ MO_DBG_ERR (" OCPP uninitialized" ); // need to call mocpp_initialize before
121+ return ;
122+ }
123+ auto context = mo_getContext2 (ctx);
124+
125+ context->setFilesystem (filesystem);
126+ }
127+
114128#if MO_WS_USE == MO_WS_ARDUINO
115129// Setup MO with links2004/WebSockets library
116130bool mo_setWebsocketUrl (const char *backendUrl, const char *chargeBoxId, const char *authorizationKey, const char *CA_cert) {
@@ -136,13 +150,12 @@ bool mo_setWebsocketUrl(const char *backendUrl, const char *chargeBoxId, const c
136150}
137151#endif
138152
139- #if __cplusplus
140153// Set a WebSocket Client
141- void mo_setConnection (MicroOcpp::Connection *connection) {
154+ void mo_setConnection (MO_Connection *connection) {
142155 mo_setConnection2 (mo_getApiContext (), connection);
143156}
144157
145- void mo_setConnection2 (MO_Context *ctx, MicroOcpp::Connection *connection) {
158+ void mo_setConnection2 (MO_Context *ctx, MO_Connection *connection) {
146159 if (!ctx) {
147160 MO_DBG_ERR (" OCPP uninitialized" ); // need to call mocpp_initialize before
148161 return ;
@@ -151,7 +164,17 @@ void mo_setConnection2(MO_Context *ctx, MicroOcpp::Connection *connection) {
151164
152165 context->setConnection (connection);
153166}
154- #endif
167+
168+ #if MO_ENABLE_MOCK_SERVER
169+ void mo_useMockServer () {
170+ if (!g_context) {
171+ MO_DBG_ERR (" OCPP uninitialized" ); // need to call mocpp_initialize before
172+ return ;
173+ }
174+ auto context = g_context;
175+ context->useMockServer ();
176+ }
177+ #endif // MO_ENABLE_MOCK_SERVER
155178
156179// Set the OCPP version
157180void mo_setOcppVersion (int ocppVersion) {
@@ -185,17 +208,6 @@ bool mo_setBootNotificationData2(MO_Context *ctx, MO_BootNotificationData bnData
185208 }
186209 auto context = mo_getContext2 (ctx);
187210
188- #if MO_ENABLE_V16
189- if (context->getOcppVersion () == MO_OCPP_V16 ) {
190-
191- }
192- #endif
193- #if MO_ENABLE_V201
194- if (context->getOcppVersion () == MO_OCPP_V201 ) {
195-
196- }
197- #endif
198-
199211 MicroOcpp::BootService *bootService = context->getModelCommon ().getBootService ();
200212 if (!bootService) {
201213 MO_DBG_ERR (" OOM" );
@@ -1550,7 +1562,12 @@ bool mo_isConnected2(MO_Context *ctx) {
15501562 auto context = mo_getContext2 (ctx);
15511563
15521564 if (auto connection = context->getConnection ()) {
1553- return connection->isConnected ();
1565+ if (connection->isConnected ) {
1566+ return connection->isConnected (connection);
1567+ } else {
1568+ // MO_Connection driver does not implement `isConnected()`. Default to true
1569+ return true ;
1570+ }
15541571 } else {
15551572 MO_DBG_ERR (" WebSocket not set up" );
15561573 return false ;
@@ -1618,7 +1635,7 @@ int32_t mo_getUptime() {
16181635int32_t mo_getUptime2 (MO_Context *ctx) {
16191636 if (!ctx) {
16201637 MO_DBG_ERR (" OCPP uninitialized" ); // need to call mocpp_initialize before
1621- return false ;
1638+ return 0 ;
16221639 }
16231640 auto context = mo_getContext2 (ctx);
16241641
@@ -1710,8 +1727,9 @@ void mo_v16_setOnResetNotify2(MO_Context *ctx, bool (*onResetNotify2)(bool, void
17101727
17111728void mo_v16_setOnResetExecute (void (*onResetExecute)(bool )) {
17121729 mo_v16_setOnResetExecute2 (mo_getApiContext (), [] (bool isHard, void *userData) {
1713- auto onResetExecute = reinterpret_cast <bool (*)(bool )>(userData);
1714- return onResetExecute (isHard);
1730+ auto onResetExecute = reinterpret_cast <void (*)(bool )>(userData);
1731+ onResetExecute (isHard);
1732+ return true ;
17151733 }, reinterpret_cast <void *>(onResetExecute));
17161734}
17171735void mo_v16_setOnResetExecute2 (MO_Context *ctx, bool (*onResetExecute2)(bool , void *), void *userData) {
@@ -1733,7 +1751,7 @@ void mo_v16_setOnResetExecute2(MO_Context *ctx, bool (*onResetExecute2)(bool, vo
17331751 #endif
17341752 #if MO_ENABLE_V201
17351753 if (context->getOcppVersion () == MO_OCPP_V201 ) {
1736- MO_DBG_ERR (" mo_v16_setOnResetNotify not supported with OCPP 2.0.1" );
1754+ MO_DBG_ERR (" mo_v16_setOnResetExecute not supported with OCPP 2.0.1" );
17371755 }
17381756 #endif
17391757}
@@ -2906,9 +2924,11 @@ bool mo_sendRequest(MO_Context *ctx, const char *operationType,
29062924 goto fail;
29072925 }
29082926
2909- request->setOnAbort ([onAbort, userData] () {
2910- onAbort (userData);
2911- });
2927+ if (onAbort) {
2928+ request->setOnAbort ([onAbort, userData] () {
2929+ onAbort (userData);
2930+ });
2931+ }
29122932
29132933 request->setTimeout (20 );
29142934
0 commit comments