Illustre les modules 7 à 9 (6 figures)

M7 : modes Wi-Fi, requête HTTP. M8 : échanges navigateur/serveur, HTTP vs WebSocket. M9 : modèle GATT, session BLE. Diagrammes de séquence plus lisibles (étiquettes sur fond blanc, boîtes à la largeur du nom). Gabarit : figures pleine largeur par défaut.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Artemia
2026-10-18 15:20:12 +02:00
co-authored by Claude Opus 5.5
parent 372c5a3e1e
commit f4a80f4d5b
20 changed files with 13937 additions and 12 deletions
+54
View File
@@ -0,0 +1,54 @@
"""Module 7 — Wi-Fi : station, point d'accès et client HTTP."""
from outils import boite, fleche, sequence, toile
from style import BLEU, ENCRE, GRIS, ORANGE, VERT, Figure
def modes_wifi():
fig, ax = toile(16, 6.4)
panneaux = [(2.7, "WIFI_STA\nstation"), (8.0, "WIFI_AP\npoint d'accès"), (13.3, "WIFI_AP_STA\nles deux")]
for x, titre in panneaux:
boite(ax, x, 3.1, 5.0, 5.6, couleur=GRIS, fond="#fafafa")
ax.text(x, 5.4, titre, ha="center", va="center", fontsize=8.5, fontweight="bold", color=ENCRE)
# STA
box = boite(ax, 2.7, 3.9, 2.2, 0.8, "Box / routeur", couleur=GRIS, taille=8)
esp = boite(ax, 1.5, 2.0, 2.0, 0.8, "ESP32-S3", couleur=BLEU, taille=8, gras=True)
tel = boite(ax, 3.9, 2.0, 1.8, 0.8, "PC / mobile", couleur=GRIS, taille=8)
fleche(ax, esp["h"], (2.3, box["b"][1]), double=True, couleur=BLEU)
fleche(ax, tel["h"], (3.1, box["b"][1]), double=True, couleur=GRIS)
ax.text(2.7, 4.5, "↑ Internet", ha="center", fontsize=7.5, color=GRIS)
ax.text(2.7, 0.7, "IP donnée par la box\nWiFi.localIP()", ha="center", fontsize=7.2, color=BLEU)
# AP
esp2 = boite(ax, 8.0, 3.9, 2.2, 0.9, "ESP32-S3\n192.168.4.1", couleur=BLEU, taille=8, gras=True)
for dx in (-1.3, 1.3):
t = boite(ax, 8.0 + dx, 2.0, 1.8, 0.8, "mobile", couleur=GRIS, taille=8)
fleche(ax, t["h"], (8.0 + dx * 0.4, esp2["b"][1]), double=True, couleur=ORANGE)
ax.text(8.0, 0.7, "réseau « ESP32-Formation »\nsans box ni Internet", ha="center", fontsize=7.2, color=ORANGE)
# AP_STA
box3 = boite(ax, 13.3, 4.3, 2.2, 0.7, "Box / routeur", couleur=GRIS, taille=8)
esp3 = boite(ax, 13.3, 2.95, 2.2, 0.8, "ESP32-S3", couleur=BLEU, taille=8, gras=True)
t3 = boite(ax, 13.3, 1.5, 1.8, 0.7, "mobile", couleur=GRIS, taille=8)
fleche(ax, esp3["h"], box3["b"], "client", double=True, couleur=BLEU, taille=7)
fleche(ax, t3["h"], esp3["b"], "point d'accès", double=True, couleur=ORANGE, taille=7)
ax.text(13.3, 0.7, "ex. portail de configuration", ha="center", fontsize=7.2, color=GRIS)
return fig
def requete_http():
acteurs = ["ESP32-S3", "Box Wi-Fi", "api.open-meteo.com"]
messages = [
("ESP32-S3", "Box Wi-Fi", "WiFi.begin(ssid, motDePasse)"),
("Box Wi-Fi", "ESP32-S3", "connecté : adresse IP attribuée", True),
("ESP32-S3", "api.open-meteo.com", "http.GET() → GET /v1/forecast?latitude=…"),
("api.open-meteo.com", "ESP32-S3", "200 OK + {\"current_weather\": {\"temperature\": 14.2, …}}", True),
("ESP32-S3", "ESP32-S3", "deserializeJson() puis affichage OLED"),
("ESP32-S3", "ESP32-S3", "http.end()"),
]
fig, ax = sequence(acteurs, messages, largeur_cm=16, pas_cm=0.95,
couleurs={"Box Wi-Fi": GRIS, "api.open-meteo.com": VERT})
return fig
FIGURES = [
Figure("m07-modes-wifi", modes_wifi),
Figure("m07-requete-http", requete_http),
]