xerbot 0.1.1 : xb.commandes("led,seuil") déclare les sorties (state.cmds) ; test 9/9

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R75H65SynGwRG5vBSoYeZ1
This commit is contained in:
cloudion
2026-11-04 19:50:41 +00:00
parent 5452df71a7
commit a361215dcf
7 changed files with 25 additions and 7 deletions

View File

@@ -53,10 +53,11 @@ typedef void (*XerbotSortie)(const char* ligne, void* ctx);
class Xerbot {
public:
Xerbot(const char* dev, const char* type = "capteur") : _dev(dev), _type(type) {}
void begin(Stream& s) { _s = &s; etat().add("online", true).envoyer(); }
void begin(Stream& s) { _s = &s; etatComplet().envoyer(); }
void sortie(XerbotSortie f, void* ctx) { _sortie = f; _ctx = ctx; }
void onCommande(void (*cb)(Xerbot&, const XerbotCommande&)) { _cb = cb; }
void battement(unsigned long ms) { _bat = ms; } // l'état toutes les ms (10 s par défaut ; 0 = jamais)
void commandes(const char* csv); // ses SORTIES : « led,seuil » → state.cmds (le labo les montre en boutons)
void loop();
void recevoir(const char* ligne); // une ligne reçue par n'importe quel transport
XerbotMsg telemetrie() { return XerbotMsg(this, "telemetry"); }
@@ -76,4 +77,6 @@ class Xerbot {
Stream* _s = nullptr; XerbotSortie _sortie = nullptr; void* _ctx = nullptr;
void (*_cb)(Xerbot&, const XerbotCommande&) = nullptr;
char _l[XERBOT_LIGNE]; size_t _ln = 0; unsigned long _bat = 10000, _dernier = 0;
char _cmds[96] = {0};
XerbotMsg etatComplet();
};