mirror of
https://github.com/markqvist/OpenModem.git
synced 2025-05-02 14:36:20 -04:00
Indentation mess cleanup
This commit is contained in:
parent
c7ff5cc5f1
commit
80459cbbd3
6 changed files with 1077 additions and 1077 deletions
1556
Modem/protocol/mp1.c
1556
Modem/protocol/mp1.c
File diff suppressed because it is too large
Load diff
|
@ -7,23 +7,23 @@
|
|||
// Options
|
||||
#define MP1_ENABLE_TCP_COMPATIBILITY false
|
||||
#if MP1_ENABLE_TCP_COMPATIBILITY
|
||||
#define MP1_ENABLE_COMPRESSION false
|
||||
#define MP1_ENABLE_CSMA true
|
||||
#define MP1_ENABLE_COMPRESSION false
|
||||
#define MP1_ENABLE_CSMA true
|
||||
#else
|
||||
#define MP1_ENABLE_COMPRESSION true
|
||||
#define MP1_ENABLE_CSMA false
|
||||
#define MP1_ENABLE_COMPRESSION true
|
||||
#define MP1_ENABLE_CSMA false
|
||||
#endif
|
||||
|
||||
// Frame sizing & checksum
|
||||
#define MP1_INTERLEAVE_SIZE 12
|
||||
#if MP1_ENABLE_COMPRESSION
|
||||
#define MP1_MAX_FRAME_LENGTH 22 * MP1_INTERLEAVE_SIZE
|
||||
#define MP1_USE_TX_QUEUE false
|
||||
#define MP1_MAX_FRAME_LENGTH 22 * MP1_INTERLEAVE_SIZE
|
||||
#define MP1_USE_TX_QUEUE false
|
||||
#else
|
||||
#define MP1_MAX_FRAME_LENGTH 25 * MP1_INTERLEAVE_SIZE
|
||||
#define MP1_USE_TX_QUEUE true
|
||||
#define MP1_TX_QUEUE_LENGTH 2
|
||||
#define MP1_QUEUE_TX_WAIT 16UL
|
||||
#define MP1_MAX_FRAME_LENGTH 25 * MP1_INTERLEAVE_SIZE
|
||||
#define MP1_USE_TX_QUEUE true
|
||||
#define MP1_TX_QUEUE_LENGTH 2
|
||||
#define MP1_QUEUE_TX_WAIT 16UL
|
||||
#endif
|
||||
#define MP1_HEADER_SIZE 1
|
||||
#define MP1_CHECKSUM_SIZE 1
|
||||
|
@ -34,10 +34,10 @@
|
|||
|
||||
// These two parameters are used for
|
||||
// P-persistent CSMA
|
||||
#define MP1_SETTLE_TIME 100UL // The minimum wait time before even considering sending
|
||||
#define MP1_SLOT_TIME 100UL // The time to wait if deciding not to send
|
||||
#define MP1_P_PERSISTENCE 85UL // The probability (between 0 and 255) for sending
|
||||
#define MP1_TXDELAY 0UL // Delay between turning on the transmitter and sending
|
||||
#define MP1_SETTLE_TIME 100UL // The minimum wait time before even considering sending
|
||||
#define MP1_SLOT_TIME 100UL // The time to wait if deciding not to send
|
||||
#define MP1_P_PERSISTENCE 85UL // The probability (between 0 and 255) for sending
|
||||
#define MP1_TXDELAY 0UL // Delay between turning on the transmitter and sending
|
||||
|
||||
// We need to know some basic HDLC flag bytes
|
||||
#define HDLC_FLAG 0x7E
|
||||
|
@ -48,9 +48,9 @@
|
|||
// to send as padding if we need to pad a
|
||||
// packet. Due to forward error correction,
|
||||
// packets must have an even number of bytes.
|
||||
#define MP1_PADDING 0x55
|
||||
#define MP1_HEADER_PADDED 0x01
|
||||
#define MP1_HEADER_COMPRESSION 0x02
|
||||
#define MP1_PADDING 0x55
|
||||
#define MP1_HEADER_PADDED 0x01
|
||||
#define MP1_HEADER_COMPRESSION 0x02
|
||||
|
||||
// Just a forward declaration that this struct exists
|
||||
struct MP1Packet;
|
||||
|
@ -61,35 +61,35 @@ typedef void (*mp1_callback_t)(struct MP1Packet *packet);
|
|||
|
||||
// Struct for a protocol context
|
||||
typedef struct MP1 {
|
||||
uint8_t buffer[MP1_MAX_FRAME_LENGTH+MP1_INTERLEAVE_SIZE]; // A buffer for incoming packets
|
||||
KFile *modem; // KFile access to the modem
|
||||
size_t packetLength; // Counter for received packet length
|
||||
size_t readLength; // This is the full read length, including parity bytes
|
||||
uint8_t calculatedParity; // Calculated parity for incoming data block
|
||||
mp1_callback_t callback; // The function to call when a packet has been received
|
||||
uint8_t checksum_in; // Rolling checksum for incoming packets
|
||||
uint8_t checksum_out; // Rolling checksum for outgoing packets
|
||||
bool reading; // True when we have seen a HDLC flag
|
||||
bool escape; // We need to know if we are in an escape sequence
|
||||
ticks_t settleTimer; // Timer used for carrier sense settling
|
||||
long correctionsMade; // A counter for how many corrections were made to a packet
|
||||
uint8_t interleaveCounter; // Keeps track of when we have received an entire interleaved block
|
||||
uint8_t interleaveOut[MP1_INTERLEAVE_SIZE]; // A buffer for interleaving bytes before they are sent
|
||||
uint8_t interleaveIn[MP1_INTERLEAVE_SIZE]; // A buffer for storing interleaved bytes before they are deinterleaved
|
||||
uint8_t randomSeed; // A seed for the pseudo-random number generator
|
||||
#if MP1_USE_TX_QUEUE
|
||||
bool queueProcessing; // For sending queued frames without preamble after first one
|
||||
size_t queueLength; // The length of the transmission queue
|
||||
size_t frameLengths[MP1_TX_QUEUE_LENGTH]; // The lengths of the frames in the queue
|
||||
uint8_t frameQueue[MP1_TX_QUEUE_LENGTH] // A buffer for a queued frame
|
||||
[MP1_MAX_DATA_SIZE];
|
||||
#endif
|
||||
uint8_t buffer[MP1_MAX_FRAME_LENGTH+MP1_INTERLEAVE_SIZE]; // A buffer for incoming packets
|
||||
KFile *modem; // KFile access to the modem
|
||||
size_t packetLength; // Counter for received packet length
|
||||
size_t readLength; // This is the full read length, including parity bytes
|
||||
uint8_t calculatedParity; // Calculated parity for incoming data block
|
||||
mp1_callback_t callback; // The function to call when a packet has been received
|
||||
uint8_t checksum_in; // Rolling checksum for incoming packets
|
||||
uint8_t checksum_out; // Rolling checksum for outgoing packets
|
||||
bool reading; // True when we have seen a HDLC flag
|
||||
bool escape; // We need to know if we are in an escape sequence
|
||||
ticks_t settleTimer; // Timer used for carrier sense settling
|
||||
long correctionsMade; // A counter for how many corrections were made to a packet
|
||||
uint8_t interleaveCounter; // Keeps track of when we have received an entire interleaved block
|
||||
uint8_t interleaveOut[MP1_INTERLEAVE_SIZE]; // A buffer for interleaving bytes before they are sent
|
||||
uint8_t interleaveIn[MP1_INTERLEAVE_SIZE]; // A buffer for storing interleaved bytes before they are deinterleaved
|
||||
uint8_t randomSeed; // A seed for the pseudo-random number generator
|
||||
#if MP1_USE_TX_QUEUE
|
||||
bool queueProcessing; // For sending queued frames without preamble after first one
|
||||
size_t queueLength; // The length of the transmission queue
|
||||
size_t frameLengths[MP1_TX_QUEUE_LENGTH]; // The lengths of the frames in the queue
|
||||
uint8_t frameQueue[MP1_TX_QUEUE_LENGTH] // A buffer for a queued frame
|
||||
[MP1_MAX_DATA_SIZE];
|
||||
#endif
|
||||
} MP1;
|
||||
|
||||
// A struct encapsulating a network packet
|
||||
typedef struct MP1Packet {
|
||||
const uint8_t *data; // Pointer to the actual data in the packet
|
||||
size_t dataLength; // The length of the received data
|
||||
const uint8_t *data; // Pointer to the actual data in the packet
|
||||
size_t dataLength; // The length of the received data
|
||||
} MP1Packet;
|
||||
|
||||
// Declarations of functions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue