void Otax::decideWhatToDo() { #ifdef DEBUG_OTAX Serial.print("OTAX RX "); Serial.println(data, HEX); #endif state = OTAX_UNKNOWN; switch (data) { case 0xDB2: // remote set on NORMAL mode sent cmd "ON" case 0xDB4: // remote set on NORMAL mode sent cmd "OFF" case 0xDB6: // remote manual end-of-msg profile=OTAX_NOPROXY; // on a passé la télécommande en mode manuel, on ne fait plus rien break; // on s'arrete de transmettre (relayer/modifier) à la chaudière case 0xCB2: profile=OTAX_PROXY; rx=OTAX_RXON; break; // remote set on PC mode sent cmd "ON" case 0xCB4: profile=OTAX_PROXY; rx=OTAX_RXOFF; break; // remote set on PC mode sent cmd "OFF" case 0xCB6: profile=OTAX_PROXY; break; // remote PC end-of-msg // si on recoit CB2,CB4,CB6: la télécommande est en position "PC" } if ((profile == OTAX_PROXY) && (lastTXtime + 60000 < millis()) && (lastRXtime + 10000 < millis())) { // si on a envoyé il y a plus de 60s et reçu depuis plus de 10s if (( (rx == OTAX_RXON)&&(force==OTAX_DONTFORCE)) || (force==OTAX_FORCEON)) { // ici on peut ajouter || temp < tempdemandee (ajouter une tolerance à la montée/descente) Serial.println("TXch ON"); sendOn(); } else if (( (rx == OTAX_RXOFF)&&(force==OTAX_DONTFORCE)) || (force==OTAX_FORCEOFF)) { // ici on peut ajouter || temp > tempdemandee (ajouter une tolerance à la montée/descente) Serial.println("TXch OFF"); sendOff(); } lastTXtime = millis(); } }
/* Send the corresponding wave signal based on the plug code and the action. */ void sendSequence(unsigned short plug_code, int action) { /* Start the sequence Send House code + Switch code + ON/OFF code + Sync code */ // Validate plug code is different than zero. if (plug_code) { printf("%hx\n", plug_code); unsigned short idx = 0x0400; // Check every bit of the code and send the correspondent signal. // At the end, send the desired action, followed with the // synchronization sequence. do { idx = idx>>1; if(plug_code & idx) { sendHigh(); } else { sendLow(); } } while(!(idx & 0x0001)); if(action == TYPE_SWITCH_ON) { sendOn(); } else { sendOff(); } sendSync(); } }