15#ifndef PHYPHOX_BLE_CORE_TRANSFER_H
16#define PHYPHOX_BLE_CORE_TRANSFER_H
28 virtual uint32_t
size()
const = 0;
29 virtual uint32_t
crc()
const = 0;
30 virtual uint32_t
read(uint32_t offset, uint8_t* out, uint32_t n)
const = 0;
35 void set(
const uint8_t* bytes, uint32_t len);
36 uint32_t
size()
const override {
return len_; }
37 uint32_t
crc()
const override {
return crc_; }
38 uint32_t
read(uint32_t offset, uint8_t* out, uint32_t n)
const override;
40 const uint8_t* bytes_ =
nullptr;
52 void holdUntil(uint32_t untilMs) { retryAt_ = untilMs; }
70 uint16_t
retries()
const {
return retries_; }
77 uint16_t lastLen_ = 0;
78 uint16_t packets_ = 0;
79 uint16_t retries_ = 0;
80 uint32_t retryAt_ = 0;
81 uint32_t lastProgress_ = 0;
82 bool pending_ =
false;
#define PHYPHOX_BLE_DEFAULT_MTU
Default MTU payload (ATT_MTU 23 โ 3). setMTU() raises it where the transport can negotiate.
Definition Config.h:52
uint32_t size() const override
Definition Transfer.h:36
uint32_t crc() const override
Definition Transfer.h:37
uint32_t read(uint32_t offset, uint8_t *out, uint32_t n) const override
void set(const uint8_t *bytes, uint32_t len)
Anything that can serve document bytes by offset: the Serializer for generated experiments,...
Definition Transfer.h:25
virtual uint32_t size() const =0
virtual uint32_t read(uint32_t offset, uint8_t *out, uint32_t n) const =0
virtual ~ByteSource()
Definition Transfer.h:27
virtual uint32_t crc() const =0
void reset()
back to idle after the bookkeeping
Definition Transfer.h:54
uint16_t retries() const
Definition Transfer.h:70
uint16_t nextPacket(uint8_t *out, uint32_t nowMs)
Fill out with the packet to send now (header first, then body).
void abort()
Definition Transfer.h:53
uint32_t lastProgressMs() const
Milliseconds of the last accepted packet (or of begin()); the Server's stall watchdog.
Definition Transfer.h:67
uint32_t bytesSent() const
Definition Transfer.h:65
State state() const
Definition Transfer.h:56
void begin(const ByteSource &source, uint16_t payload)
Start a transfer of source with payload bytes per packet (MTU โ 3).
void accepted()
The transport's verdict on the packet last returned by nextPacket().
void holdUntil(uint32_t untilMs)
Do not send before untilMs (the start delay).
Definition Transfer.h:52
State
Definition Transfer.h:47
@ HEADER
Definition Transfer.h:47
@ BODY
Definition Transfer.h:47
@ ABORTED
Definition Transfer.h:47
@ DONE
Definition Transfer.h:47
@ IDLE
Definition Transfer.h:47
bool active() const
Definition Transfer.h:55
uint16_t packetsSent() const
Definition Transfer.h:69
void noteProgress(uint32_t nowMs)
Definition Transfer.h:68
void refused(uint32_t nowMs)
Definition ChannelStore.h:11