# MicroOcppMongoose **Repository Path**: sunbiao0998/MicroOcppMongoose ## Basic Information - **Project Name**: MicroOcppMongoose - **Description**: Mongoose WebSocket Adapter for ArduinoOcpp - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-12-27 - **Last Updated**: 2023-12-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MicroOcppMongoose Mongoose WebSocket adapter for MicroOcpp **Formerly ArduinoOcppMongoose**: *see the statement on the former ArduinoOcpp [project site](https://github.com/matth-x/MicroOcpp)* ## Dependencies The following projects must be available on the include path: - [Mongoose Embedded Networking Library v6.14 / v7.8](https://github.com/cesanta/mongoose/tree/76e6b23a4f0261dd534d33632f42ea1bba99dc85): The MicroOcppMongoose adapter works with the amalgamated files `mongoose.h` and `mongoose.c`. You may need to copy them from the Mongoose-repository into the `src` folder of your project. To use the backwards-compatibility mode with v6.14, set the build flag `MO_MG_VERSION_614`. - [ArduinoJson v6.19.1](https://github.com/bblanchon/ArduinoJson/tree/079ccadbee4100ad0b2d06f11de8c412b95853c1) - [MicroOcpp](https://github.com/matth-x/MicroOcpp) The setup is done if the following include statements work: ```cpp #include "mongoose.h" #include #include ``` The last dependency is [base64-converter by Densaugeo](https://github.com/Densaugeo/base64_arduino), but it is already included in this repository. Thanks to [Densaugeo](https://github.com/Densaugeo) for providing it! ## Additional FTP(s) Client This library also contains an experimental FTP client based on Mongoose. Its intended use is to download firmware binaries and to upload hardware diagnostics information as part of the OCPP UpdateFirmware / GetDiagnostics operations. Currently, the compatibility with the following FTP servers has been tested: | Server | FTP | FTPS | | --- | --- | --- | | [vsftp](https://security.appspot.com/vsftpd.html) | ✔️ | ✔️ | | [Pure-FTPd](https://www.pureftpd.org/project/pure-ftpd/) | ✔️ | | | [Rebex](https://www.rebex.net/) | ✔️ | ✔️ | The following code snippet shows how to use the FTP client: ```cpp struct mg_mgr mgr; //initialize mgr MicroOcpp::MongooseFtpClient ftp {&mgr}; if (/* test FTP download */) { ftp.getFile("ftps://ftpuser:secret123@ftp.example.com/dir/firmware.bin", [] (unsigned char *data, size_t len) -> size_t { //write firmware data on flash return len; }, [] () { //finalize OTA update }); } else if (/* test FTP upload */) { ftp.postFile("ftps://ftpuser:secret123@ftp.example.com/dir/diagnostics.log", [] (unsigned char *data, size_t len) -> size_t { //write diagnostics text to `data` having length `len` return /* written */; //return number of bytes actually written to data (if 0, upload will be finished) }, [] () { //connection close callback }); } for (;;) { mg_mgr_poll(&mgr, 100); ftp.loop(); //only necessary for Mongoose v6 } ``` ## License This project is licensed under the GPL as it uses the [Mongoose Embedded Networking Library](https://github.com/cesanta/mongoose). If you have a proprietary license of Mongoose, then the [MIT License](https://github.com/matth-x/MicroOcpp/blob/master/LICENSE) applies.