SH2SC-EDT
Self-Healing Hardware and Software Complex for Encrypted Data Transmission
Loading...
Searching...
No Matches
receiver.h
Go to the documentation of this file.
1
13#pragma once
14
15#include <Arduino.h>
16#include "protocol.h"
17#include "csprng.h"
18#include <ChaChaPoly.h>
19
24const uint8_t RX_BUZZER_PIN = 9;
25const uint8_t ENTROPY_RING_OSC_PIN = 2;
26const uint8_t RX_LCD_ADDR = 0x3E;
27const uint8_t RX_LCD_COLS = 16;
28const uint8_t RX_LCD_ROWS = 2;
// end group rx_hw_pins
30
36const uint8_t NOTE_DICT_SIZE = 21;
37
65
70void rx_setup();
71
81void rx_loop();
82
91void processReceivedByte(uint8_t inByte);
92
101void processHelloBody();
102
121void authenticateAndPlay(const DataPacket* pkt);
122
134void processFinPacket(const DataPacket* pkt);
135
144
155void startNote(uint16_t frequencyHz, uint16_t durationMs);
156
162void stopNote();
163
174void updateRxDisplay(RxState state, uint16_t seqNum, bool macOk);
175
193void generateEntropyPool(uint8_t* outputSeed);
ChaCha20-based CSPRNG for SH2SC-EDT — Transmitter Node A (ATmega328P).
Shared C2P-ARQ protocol definitions for SH2SC-EDT (Transmitter Node A).
static uint16_t seqNum
Packet sequence number (0–65535, wraps).
const uint8_t RX_BUZZER_PIN
PWM-capable pin connected to the piezo buzzer.
Definition receiver.h:24
const uint8_t RX_LCD_ADDR
I2C address of the Aip31068 16x2 LCD display.
Definition receiver.h:26
const uint8_t ENTROPY_RING_OSC_PIN
Hardware ring oscillator entropy source (INT0).
Definition receiver.h:25
const uint8_t RX_LCD_ROWS
Number of rows on the RX LCD.
Definition receiver.h:28
const uint8_t RX_LCD_COLS
Number of columns on the RX LCD.
Definition receiver.h:27
void authenticateAndPlay(const DataPacket *pkt)
Authenticate and decrypt a DataPacket (FLAG_DAT); play the note on MAC success.
void processFinPacket(const DataPacket *pkt)
Authenticate a FLAG_FIN teardown packet and close the session on MAC success.
void resetParser()
Reset the byte-parser FSM to WAITING_SYNC_1 and drain the UART RX FIFO.
void rx_loop()
Execute one non-blocking C2P-ARQ FSM tick for the Receiver node.
void processReceivedByte(uint8_t inByte)
Consume one incoming UART byte and advance the frame-assembly FSM.
void startNote(uint16_t frequencyHz, uint16_t durationMs)
Start a non-blocking note playback on the piezo buzzer.
void processHelloBody()
Handle a fully buffered HelloPacket (FLAG_SYN) from the Transmitter.
void generateEntropyPool(uint8_t *outputSeed)
Harvest 256 bits of hardware entropy and write them to outputSeed (RX variant).
void stopNote()
Stop the currently playing note by calling noTone().
const uint8_t NOTE_DICT_SIZE
Size of the universal note frequency dictionary on RX.
Definition receiver.h:36
void updateRxDisplay(RxState state, uint16_t seqNum, bool macOk)
Refresh the RX LCD with the current FSM state and last packet result.
RxState
Byte-level parser Finite State Machine states for the C2P-ARQ Receiver (Node B).
Definition receiver.h:55
@ WAITING_SYNC_2
SYNC_BYTE_1 confirmed — waiting for SYNC_BYTE_2 (0x55).
@ GOT_DATA
Full DataPacket buffered; authenticateAndPlay() will be called by rx_loop().
@ READING_DATA
Accumulating the 14-byte body (seq_num + payload + mac) of a DataPacket.
@ READING_HELLO
Accumulating the 12-byte nonce body of a HelloPacket into the RX buffer.
@ WAITING_FOR_TYPE
Sync preamble complete — waiting for the frame flags byte.
@ GOT_HELLO
Full HelloPacket buffered; processHelloBody() will be called by rx_loop().
@ EXECUTING_ACTION
MAC verified; note is sounding — non-blocking timer wait for note end.
@ WAITING_SYNC_1
Initial/reset state — scanning the UART stream for SYNC_BYTE_1 (0xAA).
void rx_setup()
Initialise RX hardware and seed the CSPRNG. Called once from setup().
Authenticated data packet (FLAG_DAT) and session-close packet (FLAG_FIN).
Definition protocol.h:122