# CoAP to HTTP gateway translation

Use Python 3.9 or newer. In this folder:

```bash
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python main.py
python main.py --step 4
```

Each `--step` reruns the complete short scenario from a fresh local state and prints only the selected step. Steps 1–2 GET a fictional reading over CoAP and POST a mapped record to the standard-library HTTP server. Step 3 sends a malformed CoAP value and rejects it. Step 4 closes the HTTP listener and queues one validated event in a two-entry queue; a full queue raises an error rather than accepting more work. Steps 5–6 restart the listener and replay the event twice with one idempotency key. The programs use 127.0.0.1 CoAP port 17682 and HTTP port 17683; stop another service using these ports. No radio, cloud endpoint, authentication, or production durability is claimed. The in-memory queue and receipt table disappear when the program exits.

After the full run, choose a failure question to investigate: compare the malformed reading with the validation rule in step 3, or compare the outage queue and duplicate replay in steps 4–6. aiocoap supplies the CoAP endpoint, while Python's standard-library HTTP server supplies an independent destination and records the received request bytes.
