@@ -134,19 +134,19 @@ class SDFileTransferProtocol {
134
134
public:
135
135
136
136
static void idle () {
137
- // If a transfer is interrupted and a file is left open, abort it after TIMEOUT ms
137
+ // If a transfer is interrupted and a file is left open, abort it after 'idle_period' ms
138
138
const millis_t ms = millis ();
139
139
if (transfer_active && ELAPSED (ms, idle_timeout)) {
140
- idle_timeout = ms + IDLE_PERIOD ;
140
+ idle_timeout = ms + idle_period ;
141
141
if (ELAPSED (ms, transfer_timeout)) transfer_abort ();
142
142
}
143
143
}
144
144
145
145
static void process (uint8_t packet_type, char *buffer, const uint16_t length) {
146
- transfer_timeout = millis () + TIMEOUT ;
146
+ transfer_timeout = millis () + timeout ;
147
147
switch (static_cast <FileTransfer>(packet_type)) {
148
148
case FileTransfer::QUERY:
149
- SERIAL_ECHO (F (" PFT:version:" ), VERSION_MAJOR , C (' .' ), VERSION_MINOR , C (' .' ), VERSION_PATCH );
149
+ SERIAL_ECHO (F (" PFT:version:" ), version_major , C (' .' ), version_minor , C (' .' ), version_patch );
150
150
#if ENABLED(BINARY_STREAM_COMPRESSION)
151
151
SERIAL_ECHOLN (F (" :compression:heatshrink," ), HEATSHRINK_STATIC_WINDOW_BITS, C (' ,' ), HEATSHRINK_STATIC_LOOKAHEAD_BITS);
152
152
#else
@@ -194,7 +194,7 @@ class SDFileTransferProtocol {
194
194
}
195
195
}
196
196
197
- static const uint16_t VERSION_MAJOR = 0 , VERSION_MINOR = 1 , VERSION_PATCH = 0 , TIMEOUT = 10000 , IDLE_PERIOD = 1000 ;
197
+ static const uint16_t version_major = 0 , version_minor = 1 , version_patch = 0 , timeout = 10000 , idle_period = 1000 ;
198
198
};
199
199
200
200
class BinaryStream {
@@ -209,7 +209,7 @@ class BinaryStream {
209
209
struct Packet { // 10 byte protocol overhead, ascii with checksum and line number has a minimum of 7 increasing with line
210
210
211
211
union Header {
212
- static constexpr uint16_t HEADER_TOKEN = 0xB5AD ;
212
+ static constexpr uint16_t header_token = 0xB5AD ;
213
213
struct [[gnu::packed]] {
214
214
uint16_t token; // packet start token
215
215
uint8_t sync ; // stream sync, resend id and packet loss detection
@@ -245,7 +245,7 @@ class BinaryStream {
245
245
bytes_received = 0 ;
246
246
checksum = 0 ;
247
247
header_checksum = 0 ;
248
- timeout = millis () + PACKET_MAX_WAIT ;
248
+ timeout = millis () + packet_max_wait ;
249
249
buffer = nullptr ;
250
250
}
251
251
} packet{};
@@ -272,14 +272,14 @@ class BinaryStream {
272
272
}
273
273
if (!bs_serial_data_available (card.transfer_port_index )) return false ;
274
274
data = bs_read_serial (card.transfer_port_index );
275
- packet.timeout = millis () + PACKET_MAX_WAIT ;
275
+ packet.timeout = millis () + packet_max_wait ;
276
276
return true ;
277
277
}
278
278
279
279
template <const size_t buffer_size>
280
280
void receive (char (&buffer)[buffer_size]) {
281
281
uint8_t data = 0 ;
282
- millis_t transfer_window = millis () + RX_TIMESLICE ;
282
+ millis_t transfer_window = millis () + rx_timeslice ;
283
283
284
284
#if HAS_MEDIA
285
285
PORT_REDIRECT (SERIAL_PORTMASK (card.transfer_port_index ));
@@ -299,7 +299,7 @@ class BinaryStream {
299
299
case StreamState::PACKET_WAIT:
300
300
if (!stream_read (data)) { idle (); return ; } // no active packet so don't wait
301
301
packet.header .data [1 ] = data;
302
- if (packet.header .token == packet.header .HEADER_TOKEN ) {
302
+ if (packet.header .token == packet.header .header_token ) {
303
303
packet.bytes_received = 2 ;
304
304
stream_state = StreamState::PACKET_HEADER;
305
305
}
@@ -322,7 +322,7 @@ class BinaryStream {
322
322
if (packet.header .checksum == packet.header_checksum ) {
323
323
// The SYNC control packet is a special case in that it doesn't require the stream sync to be correct
324
324
if (static_cast <Protocol>(packet.header .protocol ()) == Protocol::CONTROL && static_cast <ProtocolControl>(packet.header .type ()) == ProtocolControl::SYNC) {
325
- SERIAL_ECHOLN (F (" ss" ), sync , C (' ,' ), buffer_size, C (' ,' ), VERSION_MAJOR , C (' .' ), VERSION_MINOR , C (' .' ), VERSION_PATCH );
325
+ SERIAL_ECHOLN (F (" ss" ), sync , C (' ,' ), buffer_size, C (' ,' ), version_major , C (' .' ), version_minor , C (' .' ), version_patch );
326
326
stream_state = StreamState::PACKET_RESET;
327
327
break ;
328
328
}
@@ -398,7 +398,7 @@ class BinaryStream {
398
398
stream_state = StreamState::PACKET_RESET;
399
399
break ;
400
400
case StreamState::PACKET_RESEND:
401
- if (packet_retries < MAX_RETRIES || MAX_RETRIES == 0 ) {
401
+ if (packet_retries < max_retries || max_retries == 0 ) {
402
402
packet_retries++;
403
403
stream_state = StreamState::PACKET_RESET;
404
404
SERIAL_ECHO_MSG (" Resend request " , packet_retries);
@@ -446,7 +446,7 @@ class BinaryStream {
446
446
SDFileTransferProtocol::idle ();
447
447
}
448
448
449
- static const uint16_t PACKET_MAX_WAIT = 500 , RX_TIMESLICE = 20 , MAX_RETRIES = 0 , VERSION_MAJOR = 0 , VERSION_MINOR = 1 , VERSION_PATCH = 0 ;
449
+ static const uint16_t packet_max_wait = 500 , rx_timeslice = 20 , max_retries = 0 , version_major = 0 , version_minor = 1 , version_patch = 0 ;
450
450
uint8_t packet_retries, sync;
451
451
uint16_t buffer_next_index;
452
452
uint32_t bytes_received;
0 commit comments