-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* migrate FTP from matth-x/MicroFtp * fix compilation errors * add extra switch or certs store * fix disable MbedTLS by default * add FTP client to CMakeLists * add FTP client to CMakeLists II
- Loading branch information
Showing
9 changed files
with
1,074 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// matth-x/MicroOcpp | ||
// Copyright Matthias Akstaller 2019 - 2024 | ||
// MIT License | ||
|
||
#ifndef MO_FTP_H | ||
#define MO_FTP_H | ||
|
||
#include <stddef.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct ocpp_ftp_download { | ||
void *user_data; //set this at your choice. MO passes it back to the functions below | ||
|
||
void (*loop)(void *user_data); | ||
} ocpp_ftp_download; | ||
|
||
typedef struct ocpp_ftp_upload { | ||
void *user_data; //set this at your choice. MO passes it back to the functions below | ||
|
||
void (*loop)(void *user_data); | ||
} ocpp_ftp_upload; | ||
|
||
typedef struct ocpp_ftp_client { | ||
void *user_data; //set this at your choice. MO passes it back to the functions below | ||
|
||
void (*loop)(void *user_data); | ||
|
||
ocpp_ftp_download* (*get_file)(void *user_data, | ||
const char *ftp_url, // ftp[s]://[user[:pass]@]host[:port][/directory]/filename | ||
size_t (*file_writer)(void *mo_data, unsigned char *data, size_t len), | ||
void (*on_close)(void *mo_data), | ||
void *mo_data, | ||
const char *ca_cert); // nullptr to disable cert check; will be ignored for non-TLS connections | ||
|
||
void (*get_file_free)(void *user_data, ocpp_ftp_download*); | ||
|
||
ocpp_ftp_upload* (*post_file)(void *user_data, | ||
const char *ftp_url, // ftp[s]://[user[:pass]@]host[:port][/directory]/filename | ||
size_t (*file_reader)(void *mo_data, unsigned char *buf, size_t bufsize), | ||
void (*on_close)(void *mo_data), | ||
void *mo_data, | ||
const char *ca_cert); // nullptr to disable cert check; will be ignored for non-TLS connections | ||
|
||
void (*post_file_free)(void *user_data, ocpp_ftp_upload*); | ||
} ocpp_ftp_client; | ||
|
||
#ifdef __cplusplus | ||
} //extern "C" | ||
|
||
#include <memory> | ||
#include <functional> | ||
|
||
namespace MicroOcpp { | ||
|
||
class FtpDownload { | ||
public: | ||
virtual void loop() = 0; | ||
}; | ||
|
||
class FtpUpload { | ||
public: | ||
virtual void loop() = 0; | ||
}; | ||
|
||
class FtpClient { | ||
public: | ||
|
||
virtual std::unique_ptr<FtpDownload> getFile( | ||
const char *ftp_url, // ftp[s]://[user[:pass]@]host[:port][/directory]/filename | ||
std::function<size_t(unsigned char *data, size_t len)> fileWriter, | ||
std::function<void()> onClose, | ||
const char *ca_cert = nullptr) = 0; // nullptr to disable cert check; will be ignored for non-TLS connections | ||
|
||
virtual std::unique_ptr<FtpUpload> postFile( | ||
const char *ftp_url, // ftp[s]://[user[:pass]@]host[:port][/directory]/filename | ||
std::function<size_t(unsigned char *out, size_t buffsize)> fileReader, //write at most buffsize bytes into out-buffer. Return number of bytes written | ||
std::function<void()> onClose, | ||
const char *ca_cert = nullptr) = 0; // nullptr to disable cert check; will be ignored for non-TLS connections | ||
}; | ||
|
||
} // namespace MicroOcpp | ||
#endif //def __cplusplus | ||
#endif |
Oops, something went wrong.