mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 16:59:50 +03:00
more EMS+ RC3000 handling
This commit is contained in:
52
src/ems.cpp
52
src/ems.cpp
@@ -10,7 +10,7 @@
|
|||||||
#include "ems_devices.h"
|
#include "ems_devices.h"
|
||||||
#include "emsuart.h"
|
#include "emsuart.h"
|
||||||
#include <CircularBuffer.h> // https://github.com/rlogiacco/CircularBuffer
|
#include <CircularBuffer.h> // https://github.com/rlogiacco/CircularBuffer
|
||||||
#include <MyESP.h>
|
#include "MyESP.h"
|
||||||
|
|
||||||
#ifdef TESTS
|
#ifdef TESTS
|
||||||
#include "test_data.h"
|
#include "test_data.h"
|
||||||
@@ -803,7 +803,8 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
|
|||||||
return; // ignore the whole telegram Rx Telegram while in DETECT mode
|
return; // ignore the whole telegram Rx Telegram while in DETECT mode
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It may happen that we where interrupted (for instance by WIFI activity) and the
|
/*
|
||||||
|
* It may happen that we where interrupted (for instance by WIFI activity) and the
|
||||||
* buffer isn't valid anymore, so we must not answer at all...
|
* buffer isn't valid anymore, so we must not answer at all...
|
||||||
*/
|
*/
|
||||||
if (EMS_Sys_Status.emsRxStatus != EMS_RX_STATUS_IDLE) {
|
if (EMS_Sys_Status.emsRxStatus != EMS_RX_STATUS_IDLE) {
|
||||||
@@ -825,7 +826,6 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
|
|||||||
|
|
||||||
// check first for a Poll for us
|
// check first for a Poll for us
|
||||||
if ((value ^ 0x80 ^ EMS_Sys_Status.emsIDMask) == EMS_ID_ME) {
|
if ((value ^ 0x80 ^ EMS_Sys_Status.emsIDMask) == EMS_ID_ME) {
|
||||||
EMS_Sys_Status.emsTxCapable = true;
|
|
||||||
uint32_t timenow_microsecs = micros();
|
uint32_t timenow_microsecs = micros();
|
||||||
EMS_Sys_Status.emsPollFrequency = (timenow_microsecs - _last_emsPollFrequency);
|
EMS_Sys_Status.emsPollFrequency = (timenow_microsecs - _last_emsPollFrequency);
|
||||||
_last_emsPollFrequency = timenow_microsecs;
|
_last_emsPollFrequency = timenow_microsecs;
|
||||||
@@ -1100,7 +1100,7 @@ void _removeTxQueue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deciphers the telegram packet, which has already been checked for valid CRC and has a complete header (min of 5 bytes)
|
* deciphers the telegram packet, which has already been checked for valid CRC and has a complete header
|
||||||
* length is only data bytes, excluding the BRK
|
* length is only data bytes, excluding the BRK
|
||||||
* We only remove from the Tx queue if the read or write was successful
|
* We only remove from the Tx queue if the read or write was successful
|
||||||
*/
|
*/
|
||||||
@@ -1132,7 +1132,7 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// first double check we actually have something in the queue
|
// first double check we actually have something in the Tx queue that we're waiting upon
|
||||||
if (EMS_TxQueue.isEmpty()) {
|
if (EMS_TxQueue.isEmpty()) {
|
||||||
_ems_processTelegram(EMS_RxTelegram);
|
_ems_processTelegram(EMS_RxTelegram);
|
||||||
return;
|
return;
|
||||||
@@ -1142,7 +1142,7 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
_EMS_TxTelegram EMS_TxTelegram = EMS_TxQueue.first();
|
_EMS_TxTelegram EMS_TxTelegram = EMS_TxQueue.first();
|
||||||
|
|
||||||
// check action
|
// check action
|
||||||
// if READ, match the current inbound telegram to what we sent
|
// if READ, match the current inbound telegram to what we just sent
|
||||||
// if WRITE, should not happen
|
// if WRITE, should not happen
|
||||||
// if VALIDATE, check the contents
|
// if VALIDATE, check the contents
|
||||||
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_READ) {
|
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_READ) {
|
||||||
@@ -1151,10 +1151,10 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
// all checks out, read was successful, remove tx from queue and continue to process telegram
|
// all checks out, read was successful, remove tx from queue and continue to process telegram
|
||||||
_removeTxQueue();
|
_removeTxQueue();
|
||||||
EMS_Sys_Status.emsRxPgks++; // increment Rx happy counter
|
EMS_Sys_Status.emsRxPgks++; // increment Rx happy counter
|
||||||
|
EMS_Sys_Status.emsTxCapable = true; // we're able to transmit a telegram on the Tx
|
||||||
ems_setEmsRefreshed(EMS_TxTelegram.forceRefresh); // does mqtt need refreshing?
|
ems_setEmsRefreshed(EMS_TxTelegram.forceRefresh); // does mqtt need refreshing?
|
||||||
} else {
|
} else {
|
||||||
// read not OK, we didn't get back a telegram we expected
|
// read not OK, we didn't get back a telegram we expected.
|
||||||
|
|
||||||
// first see if we got a response back from the sender saying its an unknown command
|
// first see if we got a response back from the sender saying its an unknown command
|
||||||
if (EMS_RxTelegram->data_length == 0) {
|
if (EMS_RxTelegram->data_length == 0) {
|
||||||
_removeTxQueue();
|
_removeTxQueue();
|
||||||
@@ -1420,16 +1420,14 @@ void _process_RCPLUSStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
EMS_Thermostat.mode = _bitRead(EMS_OFFSET_RCPLUSStatusMessage_mode, 0); // bit 1, mode (auto=1 or manual=0)
|
EMS_Thermostat.mode = _bitRead(EMS_OFFSET_RCPLUSStatusMessage_mode, 0); // bit 1, mode (auto=1 or manual=0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// actual set point
|
// current target temp
|
||||||
// e.g. Thermostat -> all, telegram: 10 00 FF 07 01 A5 32
|
if (EMS_RxTelegram->offset == EMS_OFFSET_RCPLUSStatusMessage_setpoint) {
|
||||||
if (EMS_RxTelegram->offset == 7) {
|
EMS_Thermostat.setpoint_roomTemp = _toByte(0); // value is * 2
|
||||||
// to add...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// next set point
|
// current setpoint temp, e.g. Thermostat -> all, telegram: 10 00 FF 06 01 A5 22
|
||||||
// e.g. Thermostat -> all, telegram: 18 00 FF 06 01 A5 22
|
|
||||||
if (EMS_RxTelegram->offset == 6) {
|
if (EMS_RxTelegram->offset == 6) {
|
||||||
// to add...
|
EMS_Thermostat.setpoint_roomTemp = _toByte(0); // value is * 2
|
||||||
}
|
}
|
||||||
|
|
||||||
// thermostat mode auto/manual, examples:
|
// thermostat mode auto/manual, examples:
|
||||||
@@ -1438,6 +1436,8 @@ void _process_RCPLUSStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
if (EMS_RxTelegram->offset == EMS_OFFSET_RCPLUSStatusMessage_mode) {
|
if (EMS_RxTelegram->offset == EMS_OFFSET_RCPLUSStatusMessage_mode) {
|
||||||
EMS_Thermostat.mode = _bitRead(0, 0); // bit 0
|
EMS_Thermostat.mode = _bitRead(0, 0); // bit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1468,15 +1468,11 @@ void _process_RCPLUSSetMessage(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EMS_RxTelegram->offset == 0) {
|
// check for single values
|
||||||
EMS_Thermostat.mode = _toByte(EMS_OFFSET_RCPLUSSet_mode);
|
// but ignore values of 0xFF, e.g. 10 00 FF 08 01 B9 FF
|
||||||
EMS_Thermostat.daytemp = _toByte(EMS_OFFSET_RCPLUSSet_temp_comfort2); // is * 2
|
if ((EMS_RxTelegram->data_length == 1) && (_toByte(0) != 0xFF)) {
|
||||||
EMS_Thermostat.nighttemp = _toByte(EMS_OFFSET_RCPLUSSet_temp_eco); // is * 2
|
|
||||||
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EMS_RxTelegram->data_length == 1) {
|
|
||||||
// check for setpoint temps, e.g. Thermostat -> all, type 0x01B9, telegram: 10 00 FF 08 01 B9 26 (CRC=1A) #data=1
|
// check for setpoint temps, e.g. Thermostat -> all, type 0x01B9, telegram: 10 00 FF 08 01 B9 26 (CRC=1A) #data=1
|
||||||
|
|
||||||
if ((EMS_RxTelegram->offset == EMS_OFFSET_RCPLUSSet_temp_setpoint) || (EMS_RxTelegram->offset == EMS_OFFSET_RCPLUSSet_manual_setpoint)) {
|
if ((EMS_RxTelegram->offset == EMS_OFFSET_RCPLUSSet_temp_setpoint) || (EMS_RxTelegram->offset == EMS_OFFSET_RCPLUSSet_manual_setpoint)) {
|
||||||
EMS_Thermostat.setpoint_roomTemp = _toByte(0); // value is * 2
|
EMS_Thermostat.setpoint_roomTemp = _toByte(0); // value is * 2
|
||||||
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
||||||
@@ -1486,6 +1482,16 @@ void _process_RCPLUSSetMessage(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
EMS_Thermostat.mode = (_toByte(0) == 0xFF); // Auto = xFF, Manual = x00 (auto=1 or manual=0)
|
EMS_Thermostat.mode = (_toByte(0) == 0xFF); // Auto = xFF, Manual = x00 (auto=1 or manual=0)
|
||||||
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return; // quit
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for long broadcasts
|
||||||
|
if (EMS_RxTelegram->offset == 0) {
|
||||||
|
EMS_Thermostat.mode = _toByte(EMS_OFFSET_RCPLUSSet_mode);
|
||||||
|
EMS_Thermostat.daytemp = _toByte(EMS_OFFSET_RCPLUSSet_temp_comfort2); // is * 2
|
||||||
|
EMS_Thermostat.nighttemp = _toByte(EMS_OFFSET_RCPLUSSet_temp_eco); // is * 2
|
||||||
|
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
* ° for Rx, we use GPIO14
|
* ° for Rx, we use GPIO14
|
||||||
* ° for Tx, we use GPIO12
|
* ° for Tx, we use GPIO12
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#ifdef LOGICANALYZER
|
#ifdef LOGICANALYZER
|
||||||
#define RX_MARK_PIN 14
|
#define RX_MARK_PIN 14
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ static const char * TEST_DATA[] = {
|
|||||||
"08 0B 19 00 00 F7 80 00 80 00 00 00 00 00 03 58 97 0C 7B 1F 00 00 00 06 C4 DF 02 64 48 80 00", // test 48 - outdoor temp check
|
"08 0B 19 00 00 F7 80 00 80 00 00 00 00 00 03 58 97 0C 7B 1F 00 00 00 06 C4 DF 02 64 48 80 00", // test 48 - outdoor temp check
|
||||||
"88 00 19 00 00 DC 80 00 80 00 FF FF 00 00 00 21 9A 06 E1 7C 00 00 00 06 C2 13 00 1E 90 80 00", // test 49 - check max length
|
"88 00 19 00 00 DC 80 00 80 00 FF FF 00 00 00 21 9A 06 E1 7C 00 00 00 06 C2 13 00 1E 90 80 00", // test 49 - check max length
|
||||||
"30 00 FF 00 02 8E 00 00 41 82 00 00 28 36 00 00 82 21", // test 50 - SM100
|
"30 00 FF 00 02 8E 00 00 41 82 00 00 28 36 00 00 82 21", // test 50 - SM100
|
||||||
"10 00 FF 08 01 B9 26" // test 51 - EMS+ 0x1B9 set temp
|
"10 00 FF 08 01 B9 26", // test 51 - EMS+ 0x1B9 set temp
|
||||||
|
"10 00 F7 00 FF 01 B9 21 E9" // test 52 - EMS+ 0x1B9 F7 test
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user