@@ -32,7 +32,7 @@ extern "C" {
3232// call mo_setup() to finalize the setup
3333bool mo_initialize ();
3434
35- // End the lifecycle of MO and free all resources
35+ // End the lifecycle of MO and free all resources. Can be called any time
3636void mo_deinitialize ();
3737
3838// Returns if library is initialized
@@ -42,7 +42,8 @@ bool mo_isInitialized();
4242MO_Context *mo_getApiContext ();
4343
4444#if MO_USE_FILEAPI != MO_CUSTOM_FS
45- // Set if MO can use the filesystem and if it needs to mount it. See "FilesystemAdapter.h" for all options
45+ // Set if MO can use the filesystem and if it needs to mount it. See "FilesystemAdapter.h" for all
46+ // options. Can only set before `mo_setup()`.
4647void mo_setFilesystemConfig (MO_FilesystemOpt opt);
4748void mo_setFilesystemConfig2 (MO_Context *ctx, MO_FilesystemOpt opt, const char *pathPrefix);
4849#endif // #if MO_USE_FILEAPI != MO_CUSTOM_FS
@@ -58,6 +59,8 @@ void mo_setFilesystem2(MO_Context *ctx, MO_FilesystemAdapter *filesystem);
5859 * If the connections fails, please refer to
5960 * https://github.com/matth-x/MicroOcpp/issues/36#issuecomment-989716573 for recommendations on
6061 * how to track down the issue with the connection.
62+ *
63+ * Can only set before `mo_setup()`.
6164 */
6265bool mo_setWebsocketUrl (
6366 const char *backendUrl, // e.g. "wss://example.com:8443/steve/websocket/CentralSystemService". Must be defined
@@ -96,6 +99,8 @@ bool mo_setWebsocketUrl(
9699 *
97100 * Note: MO v2 does not reset the `Context` pointer in the C++ `Connection` anymore during
98101 * `mo_deinitialize()`. It's recommended to check `ctx` in `MO_Connection`, or `mo_getContext()`.
102+ *
103+ * Can only set before `mo_setup()`.
99104 */
100105void mo_setConnection (MO_Connection *connection);
101106void mo_setConnection2 (MO_Context *ctx, MO_Connection *connection);
@@ -124,12 +129,12 @@ void mo_useMockServer();
124129#endif // MO_ENABLE_MOCK_SERVER
125130
126131// Set the OCPP version `MO_OCPP_V16` or `MO_OCPP_V201`. Works only if build flags `MO_ENABLE_V16` or
127- // `MO_ENABLE_V201` are set to 1
132+ // `MO_ENABLE_V201` are set to 1. Can only set before `mo_setup()`.
128133void mo_setOcppVersion (int ocppVersion);
129134void mo_setOcppVersion2 (MO_Context *ctx, int ocppVersion);
130135
131136// Set BootNotification fields (for more options, use `mo_setBootNotificationData2()`). For a description of
132- // the fields, refer to OCPP 1.6 or 2.0.1 specification
137+ // the fields, refer to OCPP 1.6 or 2.0.1 specification. Can only set before `mo_setup()`.
133138bool mo_setBootNotificationData (
134139 const char *chargePointModel, // model name of this charger, e.g. "Demo Charger"
135140 const char *chargePointVendor); // brand name, e.g. "My Company Ltd."
@@ -161,7 +166,7 @@ bool mo_setBootNotificationData2(MO_Context *ctx, MO_BootNotificationData bnData
161166 * });
162167 * ```
163168 *
164- * Configure the library with Inputs and Outputs after mo_initialize() and before mo_setup().
169+ * Configure the library with Inputs and Outputs after mo_initialize() and before ` mo_setup()` .
165170 */
166171
167172void mo_setConnectorPluggedInput (bool (*connectorPlugged)()); // Input about if an EV is plugged to this EVSE
@@ -219,6 +224,8 @@ void mo_loop();
219224 *
220225 * Returns true if it was possible to create the transaction process. Returns
221226 * false if either another transaction process is still active or you need to try it again later.
227+ *
228+ * Transaction management functions can only be called after `mo_setup()`.
222229 *
223230 * OCPP 2.0.1:
224231 * Authorize a transaction. Like the OCPP 1.6 behavior, this should be called when the user swipes the
@@ -437,7 +444,8 @@ void mo_setOnUnlockConnector2(MO_Context *ctx, unsigned int evseId, MO_UnlockCon
437444
438445
439446/*
440- * Access further information about the internal state of the library
447+ * Access further information about the internal state of the library. Can only be called
448+ * after `mo_setup()`.
441449 */
442450
443451bool mo_isOperative (); // if the charge point is operative (see OCPP1.6 Edit2, p. 45) and ready for transactions
@@ -490,7 +498,7 @@ void mo_v201_setOnResetExecute2(MO_Context *ctx, unsigned int evseId, bool (*onR
490498#endif // MO_ENABLE_V201
491499
492500/*
493- * Further platform configurations (Advanced)
501+ * Further platform configurations (Advanced). Can only set before `mo_setup()`.
494502 */
495503
496504// Set custom debug function
@@ -551,7 +559,7 @@ void mo_setDiagnosticsFtpServerCert(MO_Context *ctx, const char *cert); //zero-c
551559#endif // MO_ENABLE_MBEDTLS
552560
553561/*
554- * Transaction management (Advanced)
562+ * Transaction management (Advanced). Can only be called after `mo_setup()`.
555563 */
556564
557565bool mo_isTransactionAuthorized ();
@@ -625,18 +633,19 @@ bool mo_getConfigurationString(const char *key, const char **valueOut); //need t
625633// Add new Variable or Config. If running OCPP 2.0.1, `key16` can be NULL. If running OCPP 1.6,
626634// `component201` and `name201` can be NULL. `component201`, `name201` and `key16` are zero-copy,
627635// i.e. must outlive the MO lifecycle. Add before `mo_setup()`. At first boot, MO uses `factoryDefault`.
628- // At subsequent boots, it loads the values from flash during `mo_setup()`
636+ // At subsequent boots, it loads the values from flash during `mo_setup()`. Call before `mo_setup()`.
629637bool mo_declareVarConfigInt (MO_Context *ctx, const char *component201, const char *name201, const char *key16, int factoryDefault, MO_Mutability mutability, bool persistent, bool rebootRequired);
630638bool mo_declareVarConfigBool (MO_Context *ctx, const char *component201, const char *name201, const char *key16, bool factoryDefault, MO_Mutability mutability, bool persistent, bool rebootRequired);
631639bool mo_declareVarConfigString (MO_Context *ctx, const char *component201, const char *name201, const char *key16, const char *factoryDefault, MO_Mutability mutability, bool persistent, bool rebootRequired);
632640
633- // Set Variable or Config value. Set after `mo_setup()`. If running OCPP 2.0.1, `key16` can be NULL
641+ // Set Variable or Config value. Set after `mo_setup()`. If running OCPP 2.0.1, `key16` can be NULL.
642+ // Call after `mo_setup()`.
634643bool mo_setVarConfigInt (MO_Context *ctx, const char *component201, const char *name201, const char *key16, int value);
635644bool mo_setVarConfigBool (MO_Context *ctx, const char *component201, const char *name201, const char *key16, bool value);
636645bool mo_setVarConfigString (MO_Context *ctx, const char *component201, const char *name201, const char *key16, const char *value);
637646
638647// Get Config value. MO writes the value into `valueOut`. Call after `mo_setup()`. If running
639- // OCPP 2.0.1, `key16` can be NULL
648+ // OCPP 2.0.1, `key16` can be NULL. Call after `mo_setup()`.
640649bool mo_getVarConfigInt (MO_Context *ctx, const char *component201, const char *name201, const char *key16, int *valueOut);
641650bool mo_getVarConfigBool (MO_Context *ctx, const char *component201, const char *name201, const char *key16, bool *valueOut);
642651bool mo_getVarConfigString (MO_Context *ctx, const char *component201, const char *name201, const char *key16, const char **valueOut); // need to copy `valueOut` into own buffer. `valueOut` may be invalidated after call
@@ -681,27 +690,28 @@ bool mo_setup2(MO_Context *ctx);
681690void mo_deinitialize2 (MO_Context *ctx);
682691void mo_loop2 (MO_Context *ctx);
683692
684- // Send operation manually and bypass MO business logic
693+ // Send operation manually and bypass MO business logic. Call after `mo_setup()`.
685694bool mo_sendRequest (MO_Context *ctx,
686695 const char *operationType, // zero-copy, i.e. must outlive MO
687696 const char *payloadJson, // copied, i.e. can be invalidated
688697 void (*onResponse)(const char *payloadJson, void *userData),
689698 void (*onAbort)(void *userData),
690699 void *userData);
691700
692- // Set custom operation handler for incoming reqeusts and bypass MO business logic
701+ // Set custom operation handler for incoming reqeusts and bypass MO business logic. Call before
702+ // `mo_setup()`.
693703bool mo_setRequestHandler (MO_Context *ctx, const char *operationType,
694704 void (*onRequest)(const char *operationType, const char *payloadJson, void **userStatus, void *userData),
695705 int (*writeResponse)(const char *operationType, char *buf, size_t size, void *userStatus, void *userData),
696706 void (*finally)(const char *operationType, void *userStatus, void *userData),
697707 void *userData);
698708
699- // Sniff incoming requests without control over the response
709+ // Sniff incoming requests without control over the response. Call before `mo_setup()`.
700710bool mo_setOnReceiveRequest (MO_Context *ctx, const char *operationType,
701711 void (*onRequest)(const char *operationType, const char *payloadJson, void *userData),
702712 void *userData);
703713
704- // Sniff outgoing responses generated by MO
714+ // Sniff outgoing responses generated by MO. Call before `mo_setup()`.
705715bool mo_setOnSendConf (MO_Context *ctx, const char *operationType,
706716 void (*onSendConf)(const char *operationType, const char *payloadJson, void *userData),
707717 void *userData);
0 commit comments