6 #include <satcat5/eth_dispatch.h>
8 #include <satcat5/net_aeroftp.h>
9 #include <satcat5/udp_dispatch.h>
31 using satcat5::util::div_ceil;
32 using satcat5::util::max_unsigned;
33 using satcat5::util::min_unsigned;
35 static constexpr
unsigned BLOCK_BYTES = 1024;
37 static constexpr
unsigned bytes2words(
unsigned bytes)
38 {
return div_ceil(bytes, 4u); }
39 static constexpr
unsigned bytes2blocks(
unsigned bytes)
40 {
return div_ceil(bytes, BLOCK_BYTES); }
76 if (
busy())
return false;
85 if (src_blocks != aux_blocks)
return false;
124 unsigned next_words = bytes2words(next_bytes);
133 wr->write_u32(next_words);
136 u8 temp[BLOCK_BYTES];
141 unsigned pad = 4*next_words - next_bytes;
154 Log(satcat5::log::INFO,
"AeroFTP: Transmission complete, ID")
Inheritable container for a eth::Address.
Implement AeroFTP protocol over Ethernet.
AeroFtpClient(satcat5::eth::Dispatch *eth)
Constructor links to the Ethernet interface.
Implemention of "net::Dispatch" for Ethernet frames.
Abstract API for reading byte-streams and packets.
u8 read_u8()
One of many functions for reading integer/floating point values, see details.
virtual bool read_bytes(unsigned nbytes, void *dst)
Read 0 or more bytes into a buffer.
virtual void read_finalize()
Consume any remaining bytes in this frame, if applicable.
virtual bool read_consume(unsigned nbytes)
Read and discard 0 or more bytes.
virtual unsigned get_read_ready() const =0
How many bytes can be read without blocking?
Abstract API for writing byte-streams and packets.
virtual void write_bytes(unsigned nbytes, const void *src)
Write 0 or more bytes from a buffer.
void write_u8(u8 data)
One of many functions for writing integer/floating point values, see details.
virtual bool write_finalize()
Mark end of frame and release temporary working data.
The Log class creates and formats one log message.
Log & write10(s32 val)
Print integer as a decimal value with no leading zeros.
Log & write(const char *str)
Formatting methods for various data types.
Defines a generic API for sending data to a specific destination, such as a MAC address,...
virtual satcat5::io::Writeable * open_write(unsigned len)=0
Open a new frame to the designated address and type.
virtual void close()=0
Close any open connections and revert to idle.
AeroCube File Transfer Protocol (AeroFTP) transmitter.
u32 m_file_len
Length (bytes)
bool done() const
Is the current transfer completed?
u32 m_file_pos
Current read index (bytes)
satcat5::io::Readable * m_src
Source for file data.
bool send(u32 file_id, satcat5::io::Readable *src, satcat5::io::Readable *aux=0)
Begin transmission of the designated file.
void timer_event() override
Callback for timer events.
void skip_ahead()
Skip to next requested block.
void throttle(unsigned msec_per_pkt)
Set throttle (one packet every N msec).
satcat5::io::Readable * m_aux
Source for retransmit control.
void close()
Close connection and abort transfer in progress.
void end_of_file()
End-of-file cleanup.
unsigned m_throttle
Delay per packet (msec)
u32 m_file_id
ID for this file.
u32 m_bytes_sent
Count transmission length.
bool busy() const
Is there already a transfer in progress?
void timer_stop()
Stop all future notifications.
void timer_once(unsigned msec)
Configure a one-time notification after X milliseconds.
Inheritable container for a udp::Address.
Implement AeroFTP protocol over UDP.
AeroFtpClient(satcat5::udp::Dispatch *udp)
Constructor links to the UDP stack.
Dispatcher sorts incoming UDP messages by port index.
Diagnostic logging to UART and/or Ethernet ports.
Miscellaneous mathematical utility functions.