#ifndef LBOOT_MB_SHARED_H
#define LBOOT_MB_SHARED_H

#include "lboot.h"
#include "modbus.h"

int lboot_mb_set_tout(int tout);
int lboot_mb_set_sign_tout(int tout);
int lboot_mb_set_max_retry_cnt(int cnt);
int lboot_mb_set_interframe_delay(int delay);


const char *lboot_mb_get_err_str(int err);

int lboot_mb_open(modbus_t *mb, int slave, int open_err);

void lboot_mb_set_resp_tout(unsigned response_tout);
void lboot_mb_restore_resp_tout(void);
int lboot_mb_read_dev_info(t_lboot_devinfo *info);

int lboot_mb_get_devmode(uint8_t *mode);
int lboot_mb_get_bootloader_version(uint16_t *ver);
int lboot_mb_get_dev_flags(uint32_t *flags);
int lboot_mb_get_features(uint32_t *flags);
int lboot_mb_start_write(t_lboot_startwr_info wr_info);
int lboot_mb_write(const uint8_t *buf, uint32_t size);
int lboot_mb_write_sign(const uint8_t *sign, uint32_t size);
int lboot_mb_speccmd(const t_lboot_speccmd_info *cmd_info, uint32_t size);
int lboot_mb_close(void);

#endif // LBOOT_MB_SHARED_H
