mirror of
https://github.com/deunix-educ/voice-assistant.git
synced 2026-10-13 00:11:57 +02:00
Assistant vocal local ESP32 : étapes 1 à 15, et 15b écrite
État du projet au premier commit : - firmware ESP32 : micro I2S, lecture anti-gigue, MQTT (état retenu, testament), mains libres, domotique de démonstration, chien de garde, présence du serveur ; - serveur Python : sessions, VAD, faster-whisper, pyannote, identification, droits par profil, domotique, mot de réveil, Piper ; - broker Mosquitto : configuration, comptes et ACL (non activés en développement) ; - étape 15b écrite, en attente d'essai : agent MQTT pour machines Linux. Étapes 1 à 15 validées. 203 tests, pyright sans erreur. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#include "DemoDevices.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
DemoDevices::DemoDevices(int lightPin) : _lightPin(lightPin) {}
|
||||
|
||||
void DemoDevices::begin() {
|
||||
pinMode(_lightPin, OUTPUT);
|
||||
digitalWrite(_lightPin, LOW);
|
||||
}
|
||||
|
||||
bool DemoDevices::apply(const char* device, const char* action) {
|
||||
const bool on = strcmp(action, "on") == 0;
|
||||
const bool off = strcmp(action, "off") == 0;
|
||||
const bool open = strcmp(action, "open") == 0;
|
||||
const bool close = strcmp(action, "close") == 0;
|
||||
|
||||
if (strcmp(device, "light") == 0 && (on || off)) {
|
||||
_lightOn = on;
|
||||
digitalWrite(_lightPin, on ? HIGH : LOW);
|
||||
return true;
|
||||
}
|
||||
if (strcmp(device, "shutter") == 0 && (open || close)) {
|
||||
_shutterOpen = open; // simulé : un moteur de volet se piloterait ici
|
||||
return true;
|
||||
}
|
||||
if (strcmp(device, "door") == 0 && (open || close)) {
|
||||
_doorOpen = open; // simulé : jamais de gâche réelle commandée à la voix (voir README)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* DemoDevices::state(const char* device) const {
|
||||
if (strcmp(device, "light") == 0) {
|
||||
return _lightOn ? "on" : "off";
|
||||
}
|
||||
if (strcmp(device, "shutter") == 0) {
|
||||
return _shutterOpen ? "open" : "closed";
|
||||
}
|
||||
if (strcmp(device, "door") == 0) {
|
||||
return _doorOpen ? "open" : "closed";
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
Reference in New Issue
Block a user