
#ifndef ETHERCAT_SLAVE_FOE_ADVANCED_H
#define ETHERCAT_SLAVE_FOE_ADVANCED_H

#include "../ethercat.h"
#include "../ethercat_types.h"
#include "foe.h"
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

int foe_download(dll_t* dll, uint16_t master, uint16_t slave,
                       const char* filename, uint32_t password,
                       uint8_t* out_buf, uint32_t out_buf_size, uint32_t* out_size,
                       int32_t timeout_us);

int foe_download_ex(dll_t* dll, uint16_t master, uint16_t slave,
                          const char* filename, uint32_t password,
                          uint8_t* out_buf, uint32_t out_buf_size, uint32_t* out_size,
                          int32_t timeout_us, int enable_crc);

int foe_upload(dll_t* dll, uint16_t master, uint16_t slave,
                     const char* filename, uint32_t password,
                     const uint8_t* data, uint32_t data_size,
                     int32_t timeout_us);

int foe_upload_ex(dll_t* dll, uint16_t master, uint16_t slave,
                        const char* filename, uint32_t password,
                        const uint8_t* data, uint32_t data_size,
                        int32_t timeout_us, int enable_crc);

typedef void (*foe_progress_fn)(uint16_t slave, int packet_number, int data_size);

int foe_set_progress_hook(dll_t* dll, uint16_t master, uint16_t slave,
                                foe_progress_fn callback);

int foe_clear_progress_hook(dll_t* dll, uint16_t master, uint16_t slave);

int foe_request_cancel(dll_t* dll, uint16_t master, uint16_t slave);

int foe_clear_cancel(dll_t* dll, uint16_t master, uint16_t slave);

int foe_set_busy_hook(dll_t* dll, uint16_t master,
                             foe_busy_callback_t callback);

foe_error_code_t foe_map_dll_error(int dll_error_code);

const char* foe_get_error_description(foe_error_code_t code);

void foe_register_protocol(dll_t* dll);

#ifdef __cplusplus
}
#endif

#endif
