28 0xA1, 0x3C, 0x7F, 0x04, 0xE8, 0x92, 0x5B, 0xD6,
29 0x3A, 0xFF, 0x01, 0x88, 0x4D, 0x62, 0xC0, 0x19,
30 0x77, 0x2E, 0xB3, 0x55, 0x0C, 0xAD, 0xF1, 0x39,
31 0x6B, 0x84, 0xE0, 0x27, 0x93, 0x5A, 0x1D, 0xCC
const uint32_t ACK_TIMEOUT_MS
Maximum milliseconds TX waits for an ACK before retransmitting.
const uint8_t MAX_RETRIES
Retransmission limit per packet; exhausting this triggers suspendSession().
const uint8_t FLAG_FIN
Session close — instructs RX to teardown the current session.
const uint8_t FLAG_DAT
Data frame — DataPacket carrying an encrypted note (index + duration).
const uint8_t FLAG_SYN
Session open — HelloPacket carrying the 12-byte CSPRNG nonce.
const uint8_t AUTH_TAG_SIZE
Full Poly1305 tag length in bytes (computed internally, not fully transmitted).
const uint8_t HELLO_NONCE_SIZE
ChaCha20 IV length in bytes (IETF 96-bit nonce format).
const uint8_t DATA_PAYLOAD_SIZE
Byte size of the encrypted payload in a DataPacket.
const uint8_t TRUNCATED_MAC_SIZE
Bytes of Poly1305 MAC actually placed on the wire (first 8 of 16).
const uint8_t REST_INDEX
Special note index value representing a rest (silence).
const uint8_t MASTER_PSK[32]
256-bit (32-byte) Pre-Shared Master Key for ChaCha20-Poly1305 AEAD.
const uint8_t NACK_BYTE
Negative acknowledgement — MAC mismatch; TX must retransmit.
const uint8_t ACK_BYTE
Positive acknowledgement — MAC verified, note played (or FIN accepted).
const uint8_t SYNC_BYTE_2
Second synchronisation byte (preamble marker).
const uint8_t SYNC_BYTE_1
First synchronisation byte (preamble marker).
const uint16_t BAUD_RATE
UART baud rate in bps (8N1). Chosen for clear bit-width visibility on SimulIDE oscilloscope.
Authenticated data packet (FLAG_DAT) and session-close packet (FLAG_FIN).
uint16_t payload[2]
ChaCha20-encrypted payload: [0] = note_index, [1] = duration_ms.
uint8_t flags
Frame type — FLAG_DAT (0x02) for data; FLAG_FIN (0x04) for teardown. Part of plaintext AAD.
uint16_t seq_num
16-bit packet sequence number (little-endian). Part of plaintext AAD.
uint8_t mac[TRUNCATED_MAC_SIZE]
First 8 bytes of the Poly1305 authentication tag.
Session-open handshake packet (FLAG_SYN).
uint8_t nonce[HELLO_NONCE_SIZE]
96-bit session nonce for ChaChaPoly per-packet IV derivation.
uint8_t flags
Frame type — must equal FLAG_SYN (0x01).