#ifndef _OSDP_FILE_H_
#define _OSDP_FILE_H_
#include "osdp_common.h"
#define TO_FILE(pd) (pd)->file
#define OSDP_FILE_TX_STATE_IDLE 0
#define OSDP_FILE_TX_STATE_PENDING 1
#define OSDP_FILE_TX_STATE_ERROR -1
#define OSDP_FILE_TX_STATE_WAIT -2
PACK(struct osdp_cmd_file_xfer {
uint8_t type;
uint32_t size;
uint32_t offset;
uint16_t length;
uint8_t data[];
});
PACK(struct osdp_cmd_file_stat {
uint8_t control;
uint16_t delay;
int16_t status;
uint16_t rx_size;
});
enum file_tx_state_e {
OSDP_FILE_IDLE,
OSDP_FILE_INPROG,
OSDP_FILE_DONE,
OSDP_FILE_KEEP_ALIVE,
};
struct osdp_file {
uint32_t flags;
int file_id;
enum file_tx_state_e state;
int length;
uint32_t size;
uint32_t offset;
int errors;
bool cancel_req;
int64_t tstamp;
uint32_t wait_time_ms;
struct osdp_file_ops ops;
};
int osdp_file_cmd_tx_build(struct osdp_pd *pd, uint8_t *buf, int max_len);
int osdp_file_cmd_tx_decode(struct osdp_pd *pd, uint8_t *buf, int len);
int osdp_file_cmd_stat_decode(struct osdp_pd *pd, uint8_t *buf, int len);
int osdp_file_cmd_stat_build(struct osdp_pd *pd, uint8_t *buf, int max_len);
int osdp_file_tx_command(struct osdp_pd *pd, int file_id, uint32_t flags);
int osdp_file_tx_get_command(struct osdp_pd *pd);
void osdp_file_tx_abort(struct osdp_pd *pd);
#endif