
#ifndef ETHERCAT_SLAVE_FOE_H
#define ETHERCAT_SLAVE_FOE_H

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

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    FOE_ERR_NotDefined        = 0x8000,
    FOE_ERR_NotFound          = 0x8001,
    FOE_ERR_AccessDenied      = 0x8002,
    FOE_ERR_DiskFull          = 0x8003,
    FOE_ERR_Illegal           = 0x8004,
    FOE_ERR_PacketNumberWrong = 0x8005,
    FOE_ERR_AlreadyExists     = 0x8006,
    FOE_ERR_NoUser            = 0x8007,
    FOE_ERR_BootstrapOnly     = 0x8008,
    FOE_ERR_NotBootstrap      = 0x8009,
    FOE_ERR_NoRights          = 0x800A,
    FOE_ERR_ProgramError      = 0x800B
} foe_error_code_t;

typedef void (*foe_busy_callback_t)(uint16_t slave, uint16_t done, uint16_t entire,
                                           const char* text, int retry_idx);

#ifndef DYNAMIC_LOAD

BOOL     dx_foe_read(uint16_t master_index, uint16_t slave, const char* filename,
                  uint32_t password, char** file_data, int* file_size, int timeout);
BOOL     dx_foe_write(uint16_t master_index, uint16_t slave, const char* filename,
                   uint32_t password, const char* file_data, int file_size, int timeout);

BOOL     dx_foe_read_ex(uint16_t master_index, uint16_t slave, const char* filename,
                    uint32_t password, char** file_data, int* file_size,
                    int timeout, ec_foe_options_t* options);
BOOL     dx_foe_write_ex(uint16_t master_index, uint16_t slave, const char* filename,
                     uint32_t password, const char* file_data, int file_size,
                     int timeout, ec_foe_options_t* options);
BOOL     dx_foe_set_progress_hook(uint16_t master_index, foe_progress_callback_t callback);
BOOL     dx_foe_clear_progress_hook(uint16_t master_index);

#endif

int     foe_get_default_timeout_ms(void);
void    foe_set_default_timeout_ms(int timeout_ms);

int     foe_get_default_timeout_us(void);
void    foe_set_default_timeout_us(int timeout_us);

uint32_t foe_get_default_password(void);
void     foe_set_default_password(uint32_t password);

#ifdef __cplusplus
}
#endif

#endif
