View Source Jeff.Command.FileTransfer (jeff v0.5.2)
File Transfer Command Settings
OSDP v2.2 Specification Reference: 6.26
Link to this section Summary
Functions
Adjust file transfer command set based on the FTSTAT reply
Create set of FileTransfer commands to run
Link to this section Types
@type param() :: {:type, 1..255} | {:total_size, pos_integer()} | {:offset, pos_integer()} | {:fragment_size, pos_integer()} | {:data, binary()}
@type t() :: %Jeff.Command.FileTransfer{ data: binary(), fragment_size: pos_integer(), offset: pos_integer(), total_size: pos_integer(), type: 1..255 }
Link to this section Functions
@spec adjust_from_reply(Jeff.Reply.t(), [t()]) :: {:cont, [t()], pos_integer()} | {:halt, Jeff.Reply.FileTransferStatus.t() | Jeff.Reply.ErrorCode.t()}
Adjust file transfer command set based on the FTSTAT reply
Mostly used internally to potentially adjust the remaining command set based on the FTSTAT reply from the previous command. In some cases the next set of commands may need to be adjusted or prevented and this provides the functional core to make that decision
@spec command_set(binary(), pos_integer()) :: [t()]
Create set of FileTransfer commands to run
FileTransfers may require multiple command/reply pairs in order to transmit
all the data to the PD. This function helps chunk the data according to the
max byte length allowed by the PD. In most cases, you would run
Jeff.capabilities/2 before this check for the Receive Buffer size reported
by the PD and use that as the max value.
The first message will always be 128 bytes of data if the max value is larger
You can then cycle through sending these commands and check the returned
FTSTAT reply (%Jeff.Reply.FileTransferStatus{}) with adjust_from_reply/2 to
adjust the command set as needed
@spec encode(params()) :: <<_::64>>