class Transport
Defined at line 38 of file ../../src/firmware/lib/fastboot/include/lib/fastboot/fastboot_base.h
Communication between the fastboot host and device is in the unit of
"packet". Each fastboot command and response message (INFO, OKAY, FAIL,
DATA) is a single packet. In the DATA phase, the data to download or upload
is sent via one or more packets.
Fastboot USB and TCP use different mechanisms in delivering a "packet".
For USB transport, each USB request is a single packet. Communication
is usually driven by callback/interrupt. For TCP stream, packets are
organized as length-prefixed bytes sequence, i.e.:
<length
>
<payload
>
<length
>
<payload
>...
Fastboot TCP additionally has a handshake phase at the start of a TCP
session, where both sides expect and exchange a 4-byte message
"FB<2-digit version number>" i.e. "FB01", before starting the bytes
stream.
To simplify the design for this device-side library, we draw the boundary
at only providing class/APIs to process a single fastboot packet at a time.
Users are responsible for handling transport level details, including
extracting/passing packet and providing method for sending packets. This is
done by implementing the `class Transport` abstract class below, and
passing to the API `Fastboot::ProcessPacket(...)`;
Public Methods
zx::result<size_t> ReceivePacket (void * dst, size_t capacity)
Fetch a packet in to a given buffer of a given capacity.
Implementation should check against the given capacity. It should block
until the entire packet is read into the given buffer.
zx::result<size_t> ReceivePacket (void * dst, size_t capacity)
Fetch a packet in to a given buffer of a given capacity.
Implementation should check against the given capacity. It should block
until the entire packet is read into the given buffer.
size_t PeekPacketSize ()
Peek the size of the next packet.
zx::result<> Send (std::string_view packet)
Send a packet over the transport.
Note: Once the method returns, implementation should not assume the
memory backing `packet` is still valid. In the case of `fastboot reboot`
The system might event start power cycle shortly after the method returns.
Thus implementation should block at least until the packet is sent out to the
transport.
zx::result<> Send (std::string_view packet)
Send a packet over the transport.
Note: Once the method returns, implementation should not assume the
memory backing `packet` is still valid. In the case of `fastboot reboot`
The system might event start power cycle shortly after the method returns.
Thus implementation should block at least until the packet is sent out to the
transport.
void ~Transport ()
Defined at line 40 of file ../../src/firmware/lib/fastboot/include/lib/fastboot/fastboot_base.h