mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
Merge remote-tracking branch 'letscontrolit/mega' into bugfix/simplify_serial_fallback
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 121 KiB |
@@ -39,6 +39,8 @@ Sensor
|
|||||||
|
|
||||||
* **Receiver buffer size**: For receiving and decoding the data from the sensor, a buffer is needed. For more complex protocols, like often used for Air Conditioner remote controls, a larger buffer may be needed. By default this buffer is dimensioned at 300 bytes (will be rounded up to the next even number when stored), and needs to be enlarged if a message of this intent is shown in the log at INFO level (Either Web or serial log).
|
* **Receiver buffer size**: For receiving and decoding the data from the sensor, a buffer is needed. For more complex protocols, like often used for Air Conditioner remote controls, a larger buffer may be needed. By default this buffer is dimensioned at 300 bytes (will be rounded up to the next even number when stored), and needs to be enlarged if a message of this intent is shown in the log at INFO level (Either Web or serial log).
|
||||||
|
|
||||||
|
* **Event on boffer overflow**: When enabled, will generate an event ``<TaskName>#Overflow=<raw_buffer_length>`` when the buffer overflows, so this can be used as a way to handle this exception, f.e. by lighting up a LED or activating a buzzer. The received data won't be processed further, and discarded, when this error occurs.
|
||||||
|
|
||||||
Content
|
Content
|
||||||
^^^^^^^
|
^^^^^^^
|
||||||
|
|
||||||
@@ -71,10 +73,7 @@ Code - command map
|
|||||||
|
|
||||||
.. note:: Using compile-time options, the **Code - command map** and related options can be disabled.
|
.. note:: Using compile-time options, the **Code - command map** and related options can be disabled.
|
||||||
|
|
||||||
Data acquisition
|
.. include:: DataAcquisition.repl
|
||||||
~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
This group of settings, **Single event with all values** settings are standard available configuration items.
|
|
||||||
|
|
||||||
Values
|
Values
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|||||||
@@ -20,15 +20,6 @@ enum class ESPEasySerialPort : uint8_t {
|
|||||||
#if USABLE_SOC_UART_NUM > 2
|
#if USABLE_SOC_UART_NUM > 2
|
||||||
serial2 = 5,
|
serial2 = 5,
|
||||||
#endif // if USABLE_SOC_UART_NUM > 2
|
#endif // if USABLE_SOC_UART_NUM > 2
|
||||||
#if USABLE_SOC_UART_NUM > 3
|
|
||||||
serial3 = 10,
|
|
||||||
#endif
|
|
||||||
#if USABLE_SOC_UART_NUM > 4
|
|
||||||
serial4 = 11,
|
|
||||||
#endif
|
|
||||||
#if USABLE_SOC_UART_NUM > 5
|
|
||||||
serial5 = 12,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if USES_SW_SERIAL
|
#if USES_SW_SERIAL
|
||||||
software = 6,
|
software = 6,
|
||||||
@@ -41,8 +32,17 @@ enum class ESPEasySerialPort : uint8_t {
|
|||||||
usb_cdc_0 = 8,
|
usb_cdc_0 = 8,
|
||||||
// usb_cdc_1 = 9, // TD-er: Disable 2nd USB CDC port as it doesn't seem to work well
|
// usb_cdc_1 = 9, // TD-er: Disable 2nd USB CDC port as it doesn't seem to work well
|
||||||
#endif // if USES_USBCDC
|
#endif // if USES_USBCDC
|
||||||
|
#if USABLE_SOC_UART_NUM > 3
|
||||||
|
serial3 = 10,
|
||||||
|
#endif
|
||||||
|
#if USABLE_SOC_UART_NUM > 4
|
||||||
|
serial4 = 11,
|
||||||
|
#endif
|
||||||
|
#if USABLE_SOC_UART_NUM > 5
|
||||||
|
serial5 = 12,
|
||||||
|
#endif
|
||||||
|
|
||||||
MAX_SERIAL_TYPE
|
MAX_SERIAL_TYPE // Keep enum values in numerical order so MAX_SERIAL_TYPE has a useable value
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+24
-8
@@ -23,6 +23,10 @@
|
|||||||
// IRSENDAC,'{"protocol":"COOLIX","power":"on","mode":"dry","fanspeed":"auto","temp":22,"swingv":"max","swingh":"off"}'
|
// IRSENDAC,'{"protocol":"COOLIX","power":"on","mode":"dry","fanspeed":"auto","temp":22,"swingv":"max","swingh":"off"}'
|
||||||
|
|
||||||
/** Changelog:
|
/** Changelog:
|
||||||
|
* 2026-06-22 tonhuisman: Add Event on buffer overflow option, guarded with P016_EVENT_ON_ERROR (enabled by default) Event includes the raw
|
||||||
|
* command length (for what it's worth)
|
||||||
|
* Deprecate History section in favor of Changelog
|
||||||
|
* 2025-01-12 tonhuisman: Add support for MQTT AutoDiscovery (not supported for IR receive)
|
||||||
* 2024-01-26 uwekaditz: Decode type UNKNOWN was not added to the web settings
|
* 2024-01-26 uwekaditz: Decode type UNKNOWN was not added to the web settings
|
||||||
* Decode types UNKNOWN and UNUSED were mixed up
|
* Decode types UNKNOWN and UNUSED were mixed up
|
||||||
* Workaround for decode type UNKNOWN is not necessary
|
* Workaround for decode type UNKNOWN is not necessary
|
||||||
@@ -69,9 +73,7 @@
|
|||||||
# define P016_SEND_IR_TO_CONTROLLER false
|
# define P016_SEND_IR_TO_CONTROLLER false
|
||||||
# endif // ifndef P016_SEND_IR_TO_CONTROLLER
|
# endif // ifndef P016_SEND_IR_TO_CONTROLLER
|
||||||
|
|
||||||
// History
|
// History (deprecated, use Changelog, above)
|
||||||
// @tonhuisman: 2025-01-12
|
|
||||||
// ADD: support for MQTT AutoDiscovery (not supported for IR receive)
|
|
||||||
// @uwekaditz: 2024-01-23
|
// @uwekaditz: 2024-01-23
|
||||||
// CHG: Use the new property addToQueue in ExecuteCommand_all() due to the lack of resources
|
// CHG: Use the new property addToQueue in ExecuteCommand_all() due to the lack of resources
|
||||||
// NEW: Heap and memory can be reported (P016_CHECK_HEAP)
|
// NEW: Heap and memory can be reported (P016_CHECK_HEAP)
|
||||||
@@ -183,6 +185,7 @@ boolean displayRawToReadableB32Hex(String& outputStr, decode_results results);
|
|||||||
# endif // ifdef P016_P035_USE_RAW_RAW2
|
# endif // ifdef P016_P035_USE_RAW_RAW2
|
||||||
|
|
||||||
# ifdef PLUGIN_016_DEBUG
|
# ifdef PLUGIN_016_DEBUG
|
||||||
|
|
||||||
void P016_infoLogMemory(const __FlashStringHelper *text) {
|
void P016_infoLogMemory(const __FlashStringHelper *text) {
|
||||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||||
addLogMove(LOG_LEVEL_INFO, strformat(
|
addLogMove(LOG_LEVEL_INFO, strformat(
|
||||||
@@ -202,8 +205,8 @@ boolean Plugin_016(uint8_t function, struct EventStruct *event, String& string)
|
|||||||
case PLUGIN_DEVICE_ADD:
|
case PLUGIN_DEVICE_ADD:
|
||||||
{
|
{
|
||||||
auto& dev = Device[++deviceCount];
|
auto& dev = Device[++deviceCount];
|
||||||
dev.Number = PLUGIN_ID_016;
|
dev.Number = PLUGIN_ID_016;
|
||||||
dev.Type = DEVICE_TYPE_SINGLE;
|
dev.Type = DEVICE_TYPE_SINGLE;
|
||||||
# if P016_SEND_IR_TO_CONTROLLER
|
# if P016_SEND_IR_TO_CONTROLLER
|
||||||
dev.VType = Sensor_VType::SENSOR_TYPE_STRING;
|
dev.VType = Sensor_VType::SENSOR_TYPE_STRING;
|
||||||
# else // if P016_SEND_IR_TO_CONTROLLER
|
# else // if P016_SEND_IR_TO_CONTROLLER
|
||||||
@@ -357,6 +360,9 @@ boolean Plugin_016(uint8_t function, struct EventStruct *event, String& string)
|
|||||||
addUnit(unit);
|
addUnit(unit);
|
||||||
addFormNote(F("Increase buffer size if IR commands are received incomplete."));
|
addFormNote(F("Increase buffer size if IR commands are received incomplete."));
|
||||||
|
|
||||||
|
# if P016_EVENT_ON_ERROR
|
||||||
|
addFormCheckBox(F("Event on buffer overflow"), F("pErrEvt"), bitRead(PCONFIG_LONG(0), P016_EventOnError));
|
||||||
|
# endif
|
||||||
|
|
||||||
addFormSubHeader(F("Content"));
|
addFormSubHeader(F("Content"));
|
||||||
|
|
||||||
@@ -441,7 +447,7 @@ boolean Plugin_016(uint8_t function, struct EventStruct *event, String& string)
|
|||||||
FormSelectorOptions selector(protocolCount, &decodeTypes[0], &decodeTypeOptions[0]);
|
FormSelectorOptions selector(protocolCount, &decodeTypes[0], &decodeTypeOptions[0]);
|
||||||
selector.clearClassName();
|
selector.clearClassName();
|
||||||
selector.addSelector(
|
selector.addSelector(
|
||||||
getPluginCustomArgName(rowCnt + 0),
|
getPluginCustomArgName(rowCnt + 0),
|
||||||
static_cast<int>(line.CodeDecodeType));
|
static_cast<int>(line.CodeDecodeType));
|
||||||
}
|
}
|
||||||
html_TD();
|
html_TD();
|
||||||
@@ -460,7 +466,7 @@ boolean Plugin_016(uint8_t function, struct EventStruct *event, String& string)
|
|||||||
selector.clearClassName();
|
selector.clearClassName();
|
||||||
|
|
||||||
selector.addSelector(
|
selector.addSelector(
|
||||||
getPluginCustomArgName(rowCnt + 3),
|
getPluginCustomArgName(rowCnt + 3),
|
||||||
static_cast<int>(line.AlternativeCodeDecodeType));
|
static_cast<int>(line.AlternativeCodeDecodeType));
|
||||||
}
|
}
|
||||||
html_TD();
|
html_TD();
|
||||||
@@ -521,6 +527,9 @@ boolean Plugin_016(uint8_t function, struct EventStruct *event, String& string)
|
|||||||
bitWrite(lSettings, P016_BitExecuteCmd, isFormItemChecked(F("pExecuteCmd")));
|
bitWrite(lSettings, P016_BitExecuteCmd, isFormItemChecked(F("pExecuteCmd")));
|
||||||
# endif // if P016_FEATURE_COMMAND_HANDLING
|
# endif // if P016_FEATURE_COMMAND_HANDLING
|
||||||
bitWrite(lSettings, P016_BitAcceptUnknownType, isFormItemChecked(F("pAcceptUnknownType")));
|
bitWrite(lSettings, P016_BitAcceptUnknownType, isFormItemChecked(F("pAcceptUnknownType")));
|
||||||
|
# if P016_EVENT_ON_ERROR
|
||||||
|
bitWrite(lSettings, P016_EventOnError, isFormItemChecked(F("pErrEvt")));
|
||||||
|
# endif
|
||||||
|
|
||||||
bEnableIRcodeAdding = true;
|
bEnableIRcodeAdding = true;
|
||||||
PCONFIG_LONG(0) = lSettings;
|
PCONFIG_LONG(0) = lSettings;
|
||||||
@@ -644,8 +653,15 @@ boolean Plugin_016(uint8_t function, struct EventStruct *event, String& string)
|
|||||||
|
|
||||||
if (results.overflow)
|
if (results.overflow)
|
||||||
{
|
{
|
||||||
addLog(LOG_LEVEL_ERROR, F("IR: WARNING, IR code is too big for buffer. Try pressing the transmiter button only momenteraly"));
|
addLog(LOG_LEVEL_ERROR, F("IR: WARNING, IR code is too big for buffer. Try pressing the transmitter button only momentarily"));
|
||||||
success = false;
|
success = false;
|
||||||
|
|
||||||
|
# if P016_EVENT_ON_ERROR
|
||||||
|
|
||||||
|
if (bitRead(PCONFIG_LONG(0), P016_EventOnError)) {
|
||||||
|
eventQueue.add(event->TaskIndex, F("Overflow"), results.rawlen);
|
||||||
|
}
|
||||||
|
# endif // if P016_EVENT_ON_ERROR
|
||||||
break; // Do not continue and risk hanging the ESP
|
break; // Do not continue and risk hanging the ESP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
/************
|
/************
|
||||||
* Changelog:
|
* Changelog:
|
||||||
|
* 2026-07-11 tonhuisman: Send also Derived values when sending the event with received data, when enabled and available
|
||||||
* 2025-03-26 tonhuisman: Add optional receiving (relaying) of UDP data to Serial. Uses the same port as configured for the (default) TCP
|
* 2025-03-26 tonhuisman: Add optional receiving (relaying) of UDP data to Serial. Uses the same port as configured for the (default) TCP
|
||||||
* connection. Available on ESP32 only.
|
* connection. Available on ESP32 only.
|
||||||
* Can be enabled for ESP8266 in a Custom build by adding #define P020_USE_PROTOCOL 1
|
* Can be enabled for ESP8266 in a Custom build by adding #define P020_USE_PROTOCOL 1
|
||||||
|
|||||||
@@ -115,13 +115,13 @@ void C018_ConfigStruct::webform_load(C018_data_struct *C018_data) {
|
|||||||
|
|
||||||
addTableSeparator(F("Serial Port Configuration"), 2, 3);
|
addTableSeparator(F("Serial Port Configuration"), 2, 3);
|
||||||
|
|
||||||
serialHelper_webformLoad(port, rxpin, txpin, true);
|
serialHelper_webformLoad(port, rxpin, txpin);
|
||||||
|
|
||||||
// Show serial port selection
|
// Show serial port selection
|
||||||
addFormPinSelect(PinSelectPurpose::Generic_input, formatGpioName_serialRX(false), F("taskdevicepin1"), rxpin);
|
addFormPinSelect(PinSelectPurpose::Generic_input, formatGpioName_serialRX(false), F("taskdevicepin1"), rxpin);
|
||||||
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_serialTX(false), F("taskdevicepin2"), txpin);
|
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_serialTX(false), F("taskdevicepin2"), txpin);
|
||||||
|
|
||||||
html_add_script(F("document.getElementById('serPort').onchange();"), false);
|
html_add_script(F("elId('serPort').onchange();"), false);
|
||||||
|
|
||||||
addFormNumericBox(F("Baudrate"), F(C018_BAUDRATE_LABEL), baudrate, 2400, 115200);
|
addFormNumericBox(F("Baudrate"), F(C018_BAUDRATE_LABEL), baudrate, 2400, 115200);
|
||||||
addUnit(F("baud"));
|
addUnit(F("baud"));
|
||||||
|
|||||||
@@ -121,13 +121,13 @@ void C023_ConfigStruct::webform_load(C023_data_struct *C023_data) {
|
|||||||
|
|
||||||
addTableSeparator(F("Serial Port Configuration"), 2, 3);
|
addTableSeparator(F("Serial Port Configuration"), 2, 3);
|
||||||
|
|
||||||
serialHelper_webformLoad(port, rxpin, txpin, true);
|
serialHelper_webformLoad(port, rxpin, txpin);
|
||||||
|
|
||||||
// Show serial port selection
|
// Show serial port selection
|
||||||
addFormPinSelect(PinSelectPurpose::Generic_input, formatGpioName_serialRX(false), F("taskdevicepin1"), rxpin);
|
addFormPinSelect(PinSelectPurpose::Generic_input, formatGpioName_serialRX(false), F("taskdevicepin1"), rxpin);
|
||||||
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_serialTX(false), F("taskdevicepin2"), txpin);
|
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_serialTX(false), F("taskdevicepin2"), txpin);
|
||||||
|
|
||||||
html_add_script(F("document.getElementById('serPort').onchange();"), false);
|
html_add_script(F("elId('serPort').onchange();"), false);
|
||||||
|
|
||||||
addFormNumericBox(F("Baudrate"), F(C023_BAUDRATE_LABEL), baudrate, 2400, 115200);
|
addFormNumericBox(F("Baudrate"), F(C023_BAUDRATE_LABEL), baudrate, 2400, 115200);
|
||||||
addUnit(F("baud"));
|
addUnit(F("baud"));
|
||||||
|
|||||||
@@ -120,14 +120,17 @@ String serialHelper_getSerialTypeLabel(struct EventStruct *event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_SC16IS752_Serial
|
#ifndef DISABLE_SC16IS752_Serial
|
||||||
void serialHelper_addI2CuartSelectors(int address, int channel) {
|
void serialHelper_addI2CuartSelectors(int address, int channel, String id, String uid) {
|
||||||
# define SC16IS752_I2C_ADDRESSES 16
|
# define SC16IS752_I2C_ADDRESSES 16
|
||||||
# define SC16IS752_I2C_BASE_ADDR (0x90 >> 1)
|
# define SC16IS752_I2C_BASE_ADDR (0x90 >> 1)
|
||||||
# define SC16IS752_CHANNELS 2
|
# define SC16IS752_CHANNELS 2
|
||||||
# define SC16IS752_CHANNEL_A 0x00
|
# define SC16IS752_CHANNEL_A 0x00
|
||||||
# define SC16IS752_CHANNEL_B 0x01
|
# define SC16IS752_CHANNEL_B 0x01
|
||||||
{
|
{
|
||||||
String id = F("i2cuart_addr");
|
if (id.isEmpty()) {
|
||||||
|
id = F("i2cuart_addr");
|
||||||
|
}
|
||||||
|
|
||||||
addRowLabel_tr_id(F("I2C Address"), id);
|
addRowLabel_tr_id(F("I2C Address"), id);
|
||||||
do_addSelector_Head(id, F(""), EMPTY_STRING, false);
|
do_addSelector_Head(id, F(""), EMPTY_STRING, false);
|
||||||
|
|
||||||
@@ -163,28 +166,53 @@ void serialHelper_addI2CuartSelectors(int address, int channel) {
|
|||||||
SC16IS752_CHANNEL_B,
|
SC16IS752_CHANNEL_B,
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
if (uid.isEmpty()) {
|
||||||
|
uid = F("i2cuart_ch");
|
||||||
|
}
|
||||||
|
|
||||||
const FormSelectorOptions selector(NR_ELEMENTS(chOptions), chOptions);
|
const FormSelectorOptions selector(NR_ELEMENTS(chOptions), chOptions);
|
||||||
selector.addFormSelector(F("Channel"), F("i2cuart_ch"), channel);
|
selector.addFormSelector(F("Channel"), uid, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ifndef DISABLE_SC16IS752_Serial
|
#endif // ifndef DISABLE_SC16IS752_Serial
|
||||||
|
|
||||||
void serialHelper_webformLoad(struct EventStruct *event) {
|
void serialHelper_webformLoad(struct EventStruct *event) {
|
||||||
serialHelper_webformLoad(event, true);
|
serialHelper_webformLoad(event, INCLUDE_DEFAULT_SERIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// These helper functions were made to create a generic interface to setup serial port config.
|
// These helper functions were made to create a generic interface to setup serial port config.
|
||||||
// See issue #2343 and Pull request https://github.com/letscontrolit/ESPEasy/pull/2352
|
// See issue #2343 and Pull request https://github.com/letscontrolit/ESPEasy/pull/2352
|
||||||
// For now P020 and P044 have been reverted to make them work again.
|
// For now P020 and P044 have been reverted to make them work again.
|
||||||
void serialHelper_webformLoad(struct EventStruct *event, bool allowSoftwareSerial) {
|
void serialHelper_webformLoad(struct EventStruct *event, uint8_t allowedSerial) {
|
||||||
serialHelper_webformLoad(static_cast<ESPEasySerialPort>(CONFIG_PORT),
|
serialHelper_webformLoad(static_cast<ESPEasySerialPort>(CONFIG_PORT),
|
||||||
serialHelper_getRxPin(event),
|
serialHelper_getRxPin(event),
|
||||||
serialHelper_getTxPin(event),
|
serialHelper_getTxPin(event),
|
||||||
allowSoftwareSerial);
|
allowedSerial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef, bool allowSoftwareSerial) {
|
void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef, uint8_t allowedSerial) {
|
||||||
|
serialHelper_webformLoad(port,
|
||||||
|
rxPinDef,
|
||||||
|
txPinDef,
|
||||||
|
allowedSerial,
|
||||||
|
F("Serial Port"),
|
||||||
|
F("serPort"),
|
||||||
|
EMPTY_STRING,
|
||||||
|
EMPTY_STRING,
|
||||||
|
EMPTY_STRING,
|
||||||
|
EMPTY_STRING);
|
||||||
|
}
|
||||||
|
void serialHelper_webformLoad(ESPEasySerialPort port,
|
||||||
|
int rxPinDef,
|
||||||
|
int txPinDef,
|
||||||
|
uint8_t allowedSerial,
|
||||||
|
String label,
|
||||||
|
String id,
|
||||||
|
String pin1Var,
|
||||||
|
String pin2Var,
|
||||||
|
String i2c1Var,
|
||||||
|
String i2c2Var) {
|
||||||
// Field for I2C addr & RX are shared
|
// Field for I2C addr & RX are shared
|
||||||
// Field for channel and TX are shared
|
// Field for channel and TX are shared
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
@@ -194,11 +222,19 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef
|
|||||||
// 'none';document.getElementById('tr_taskdevicepin1').style.display = style;document.getElementById('tr_taskdevicepin2').style.display =
|
// 'none';document.getElementById('tr_taskdevicepin1').style.display = style;document.getElementById('tr_taskdevicepin2').style.display =
|
||||||
// style;document.getElementById('tr_i2cuart_addr').style.display = i2cstyle;document.getElementById('tr_i2cuart_ch').style.display =
|
// style;document.getElementById('tr_i2cuart_addr').style.display = i2cstyle;document.getElementById('tr_i2cuart_ch').style.display =
|
||||||
// i2cstyle;}"),
|
// i2cstyle;}"),
|
||||||
html_add_script(F("function serialPortChanged(e){var t=6==e.value?'':'none',l=1==e.value?'':'none';"
|
html_add_script(F("function elId(e){return document.getElementById(e)}\n"
|
||||||
"document.getElementById('tr_taskdevicepin1').style.display=t,"
|
"function serialPortChanged(e,p1=\"taskdevicepin1\",p2=\"taskdevicepin2\",ia=\"i2cuart_addr\",ic=\"i2cuart_ch\")"
|
||||||
"document.getElementById('tr_taskdevicepin2').style.display=t,"
|
"{var t=6==e.value?'':'none'"
|
||||||
"document.getElementById('tr_i2cuart_addr').style.display=l,"
|
#if USES_I2C_SC16IS752
|
||||||
"document.getElementById('tr_i2cuart_ch').style.display=l}"),
|
",l=1==e.value?'':'none';"
|
||||||
|
#endif // if USES_I2C_SC16IS752
|
||||||
|
"elId('tr_'+p1).style.display=t,"
|
||||||
|
"elId('tr_'+p2).style.display=t,"
|
||||||
|
#if USES_I2C_SC16IS752
|
||||||
|
"elId('tr_'+ia).style.display=l,"
|
||||||
|
"elId('tr_'+ic).style.display=l}"
|
||||||
|
#endif // if USES_I2C_SC16IS752
|
||||||
|
),
|
||||||
false);
|
false);
|
||||||
#endif // ifdef ESP8266
|
#endif // ifdef ESP8266
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
@@ -208,47 +244,53 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef
|
|||||||
// elem.value == 1 ? '' : 'none';document.getElementById('tr_taskdevicepin1').style.display =
|
// elem.value == 1 ? '' : 'none';document.getElementById('tr_taskdevicepin1').style.display =
|
||||||
// style;document.getElementById('tr_taskdevicepin2').style.display = style;document.getElementById('tr_i2cuart_addr').style.display =
|
// style;document.getElementById('tr_taskdevicepin2').style.display = style;document.getElementById('tr_i2cuart_addr').style.display =
|
||||||
// i2cstyle;document.getElementById('tr_i2cuart_ch').style.display = i2cstyle;}"),
|
// i2cstyle;document.getElementById('tr_i2cuart_ch').style.display = i2cstyle;}"),
|
||||||
html_add_script(F("function serialPortChanged(elem) {"
|
html_add_script(F("function elId(e){return document.getElementById(e)}\n"
|
||||||
" var style = 'none';"
|
"function serialPortChanged(elem,p1=\"taskdevicepin1\",p2=\"taskdevicepin2\",ia=\"i2cuart_addr\",ic=\"i2cuart_ch\") {"
|
||||||
" var i2cstyle = elem.value == 1 ? '' : 'none';"
|
"var v=elem.value;"
|
||||||
" if (elem.value == 2) {"
|
"var st='none';"
|
||||||
//" document.querySelector('#taskdevicepin1').value =" STRINGIFY(SOC_RX0) ";"
|
#if USES_I2C_SC16IS752
|
||||||
//" document.querySelector('#taskdevicepin2').value =" STRINGIFY(SOC_TX0) ";"
|
"var i2cst=v==1?'':'none';"
|
||||||
" style = '';"
|
#endif // if USES_I2C_SC16IS752
|
||||||
# if USABLE_SOC_UART_NUM > 1
|
"if (v==2) {"
|
||||||
" } else if (elem.value == 4) {"
|
// "document.querySelector('#'+p1).value =" STRINGIFY(SOC_RX0) ";"
|
||||||
//" document.querySelector('#taskdevicepin1').value =" STRINGIFY(SOC_RX1) ";"
|
// "document.querySelector('#'+p2).value =" STRINGIFY(SOC_TX0) ";"
|
||||||
//" document.querySelector('#taskdevicepin2').value =" STRINGIFY(SOC_TX1) ";"
|
"st='';"
|
||||||
" style = '';"
|
# if USABLE_SOC_UART_NUM > 1
|
||||||
#endif
|
"} else if (v==4) {"
|
||||||
# if USABLE_SOC_UART_NUM > 2
|
// "document.querySelector('#'+p1).value =" STRINGIFY(SOC_RX1) ";"
|
||||||
" } else if (elem.value == 5) {"
|
// "document.querySelector('#'+p2).value =" STRINGIFY(SOC_TX1) ";"
|
||||||
//" document.querySelector('#taskdevicepin1').value =" STRINGIFY(SOC_RX2) ";"
|
"st='';"
|
||||||
//" document.querySelector('#taskdevicepin2').value =" STRINGIFY(SOC_TX2) ";"
|
#endif
|
||||||
" style = '';"
|
# if USABLE_SOC_UART_NUM > 2
|
||||||
#endif
|
"} else if (v==5) {"
|
||||||
# if USABLE_SOC_UART_NUM > 3
|
//"document.querySelector('#'+p1).value =" STRINGIFY(SOC_RX2) ";"
|
||||||
" } else if (elem.value == 10) {"
|
//"document.querySelector('#'+p2).value =" STRINGIFY(SOC_TX2) ";"
|
||||||
" style = '';"
|
"st='';"
|
||||||
#endif
|
#endif
|
||||||
# if USABLE_SOC_UART_NUM > 4
|
# if USABLE_SOC_UART_NUM > 3
|
||||||
" } else if (elem.value == 11) {"
|
"} else if (v==10) {"
|
||||||
" style = '';"
|
"st='';"
|
||||||
#endif
|
#endif
|
||||||
# if USABLE_SOC_UART_NUM > 5
|
# if USABLE_SOC_UART_NUM > 4
|
||||||
" } else if (elem.value == 12) {"
|
"} else if (v==11) {"
|
||||||
" style = '';"
|
"st='';"
|
||||||
#endif
|
#endif
|
||||||
#if USES_SW_SERIAL
|
# if USABLE_SOC_UART_NUM > 5
|
||||||
" } else if (elem.value == 6) {"
|
"} else if (v==12) {"
|
||||||
" style = '';"
|
"st='';"
|
||||||
#endif
|
#endif
|
||||||
" }"
|
#if USES_SW_SERIAL
|
||||||
" document.getElementById('tr_taskdevicepin1').style.display = style;"
|
" } else if (v==6) {"
|
||||||
" document.getElementById('tr_taskdevicepin2').style.display = style;"
|
"st='';"
|
||||||
" document.getElementById('tr_i2cuart_addr').style.display = i2cstyle;"
|
#endif
|
||||||
" document.getElementById('tr_i2cuart_ch').style.display = i2cstyle;"
|
"}"
|
||||||
"}"),
|
"elId('tr_'+p1).style.display=st;"
|
||||||
|
"elId('tr_'+p2).style.display=st;"
|
||||||
|
#if USES_I2C_SC16IS752
|
||||||
|
"elId('tr_'+ia).style.display=i2cst;"
|
||||||
|
"elId('tr_'+ic).style.display=i2cst;"
|
||||||
|
#endif // if USES_I2C_SC16IS752
|
||||||
|
"}"),
|
||||||
true);
|
true);
|
||||||
#endif // ifdef ESP32
|
#endif // ifdef ESP32
|
||||||
|
|
||||||
@@ -296,7 +338,7 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef
|
|||||||
constexpr int NR_ESPEASY_SERIAL_TYPES = NR_ELEMENTS(ids);
|
constexpr int NR_ESPEASY_SERIAL_TYPES = NR_ELEMENTS(ids);
|
||||||
String options[NR_ESPEASY_SERIAL_TYPES];
|
String options[NR_ESPEASY_SERIAL_TYPES];
|
||||||
|
|
||||||
// String attr[NR_ESPEASY_SERIAL_TYPES];
|
String attr[NR_ESPEASY_SERIAL_TYPES];
|
||||||
|
|
||||||
for (int i = 0; (i < NR_ESPEASY_SERIAL_TYPES); ++i) {
|
for (int i = 0; (i < NR_ESPEASY_SERIAL_TYPES); ++i) {
|
||||||
ESPEasySerialPort serType = static_cast<ESPEasySerialPort>(ids[i]);
|
ESPEasySerialPort serType = static_cast<ESPEasySerialPort>(ids[i]);
|
||||||
@@ -324,16 +366,47 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
options[i] = option;
|
options[i] = option;
|
||||||
|
if (!(allowedSerial & INCLUDE_HW_SERIAL) && isHWserial(serType)) {
|
||||||
|
attr[i] = F("disabled");
|
||||||
|
}
|
||||||
|
if (!(allowedSerial & INCLUDE_SW_SERIAL) && (serType == ESPEasySerialPort::software)) {
|
||||||
|
attr[i] = F("disabled");
|
||||||
|
}
|
||||||
|
#if USES_I2C_SC16IS752
|
||||||
|
if (!(allowedSerial & INCLUDE_I2C_SERIAL) && (serType == ESPEasySerialPort::sc16is752)) {
|
||||||
|
attr[i] = F("disabled");
|
||||||
|
}
|
||||||
|
#endif // if USES_I2C_SC16IS752
|
||||||
|
#if USES_HWCDC || USES_USBCDC
|
||||||
|
if (!(allowedSerial & INCLUDE_CDC_SERIAL)
|
||||||
|
#if USES_HWCDC
|
||||||
|
&& (serType == ESPEasySerialPort::usb_hw_cdc)
|
||||||
|
#endif // if USES_HWCDC
|
||||||
|
#if USES_USBCDC
|
||||||
|
&& (serType == ESPEasySerialPort::usb_cdc_0)
|
||||||
|
#endif // if USES_USBCDC
|
||||||
|
) {
|
||||||
|
attr[i] = F("disabled");
|
||||||
|
}
|
||||||
|
#endif // if USES_HWCDC || USES_USBCDC
|
||||||
}
|
}
|
||||||
FormSelectorOptions selector(NR_ESPEASY_SERIAL_TYPES, options, ids);
|
FormSelectorOptions selector(NR_ESPEASY_SERIAL_TYPES, options, ids, attr);
|
||||||
|
|
||||||
// Script to toggle GPIO visibility when changing selection.
|
// Script to toggle GPIO visibility when changing selection.
|
||||||
selector.onChangeCall = F("serialPortChanged(this)");
|
if (pin1Var.isEmpty() && pin2Var.isEmpty() && i2c1Var.isEmpty() && i2c2Var.isEmpty()) {
|
||||||
|
selector.onChangeCall = F("serialPortChanged(this)");
|
||||||
|
} else {
|
||||||
|
selector.onChangeCall = strformat(F("serialPortChanged(this,\"%s\",\"%s\",\"%s\",\"%s\")"),
|
||||||
|
pin1Var.c_str(), pin2Var.c_str(), i2c1Var.c_str(), i2c2Var.c_str());
|
||||||
|
}
|
||||||
selector.addFormSelector(
|
selector.addFormSelector(
|
||||||
F("Serial Port"), F("serPort"),
|
label, id,
|
||||||
static_cast<int>(ESPeasySerialType::getSerialType(port, rxPinDef, txPinDef)));
|
// static_cast<int>(ESPeasySerialType::getSerialType(port, rxPinDef, txPinDef)));
|
||||||
|
static_cast<int>(port));
|
||||||
#if USES_I2C_SC16IS752
|
#if USES_I2C_SC16IS752
|
||||||
serialHelper_addI2CuartSelectors(rxPinDef, txPinDef);
|
if (allowedSerial & INCLUDE_I2C_SERIAL) {
|
||||||
|
serialHelper_addI2CuartSelectors(rxPinDef, txPinDef, i2c1Var, i2c2Var);
|
||||||
|
}
|
||||||
#endif // ifndef DISABLE_SC16IS752_Serial
|
#endif // ifndef DISABLE_SC16IS752_Serial
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
|||||||
@@ -8,6 +8,13 @@
|
|||||||
|
|
||||||
#include <ESPeasySerial.h>
|
#include <ESPeasySerial.h>
|
||||||
|
|
||||||
|
constexpr uint8_t INCLUDE_SW_SERIAL = (1 << 0);
|
||||||
|
constexpr uint8_t INCLUDE_HW_SERIAL = (1 << 1); // Ignored for now, always enabled
|
||||||
|
constexpr uint8_t INCLUDE_I2C_SERIAL = (1 << 2);
|
||||||
|
constexpr uint8_t INCLUDE_CDC_SERIAL = (1 << 3);
|
||||||
|
constexpr uint8_t INCLUDE_ALL_SERIAL = (INCLUDE_SW_SERIAL | INCLUDE_HW_SERIAL | INCLUDE_I2C_SERIAL | INCLUDE_CDC_SERIAL);
|
||||||
|
constexpr uint8_t INCLUDE_DEFAULT_SERIAL = INCLUDE_ALL_SERIAL;
|
||||||
|
constexpr uint8_t INCLUDE_NOT_CDC_SERIAL = (INCLUDE_SW_SERIAL | INCLUDE_HW_SERIAL | INCLUDE_I2C_SERIAL);
|
||||||
|
|
||||||
struct ESPeasySerialType;
|
struct ESPeasySerialType;
|
||||||
|
|
||||||
@@ -41,8 +48,10 @@ ESPEasySerialPort serialHelper_getSerialType(struct EventStruct *event);
|
|||||||
String serialHelper_getSerialTypeLabel(struct EventStruct *event);
|
String serialHelper_getSerialTypeLabel(struct EventStruct *event);
|
||||||
|
|
||||||
#ifndef DISABLE_SC16IS752_Serial
|
#ifndef DISABLE_SC16IS752_Serial
|
||||||
void serialHelper_addI2CuartSelectors(int address,
|
void serialHelper_addI2CuartSelectors(int address,
|
||||||
int channel);
|
int channel,
|
||||||
|
String id = "",
|
||||||
|
String uid = "");
|
||||||
#endif // ifndef DISABLE_SC16IS752_Serial
|
#endif // ifndef DISABLE_SC16IS752_Serial
|
||||||
|
|
||||||
void serialHelper_webformLoad(struct EventStruct *event);
|
void serialHelper_webformLoad(struct EventStruct *event);
|
||||||
@@ -51,12 +60,23 @@ void serialHelper_webformLoad(struct EventStruct *event);
|
|||||||
// See issue #2343 and Pull request https://github.com/letscontrolit/ESPEasy/pull/2352
|
// See issue #2343 and Pull request https://github.com/letscontrolit/ESPEasy/pull/2352
|
||||||
// For now P020 and P044 have been reverted to make them work again.
|
// For now P020 and P044 have been reverted to make them work again.
|
||||||
void serialHelper_webformLoad(struct EventStruct *event,
|
void serialHelper_webformLoad(struct EventStruct *event,
|
||||||
bool allowSoftwareSerial);
|
uint8_t allowedSerial);
|
||||||
|
|
||||||
void serialHelper_webformLoad(ESPEasySerialPort port,
|
void serialHelper_webformLoad(ESPEasySerialPort port,
|
||||||
int rxPinDef,
|
int rxPinDef,
|
||||||
int txPinDef,
|
int txPinDef,
|
||||||
bool allowSoftwareSerial);
|
uint8_t allowedSerial = INCLUDE_DEFAULT_SERIAL);
|
||||||
|
|
||||||
|
void serialHelper_webformLoad(ESPEasySerialPort port,
|
||||||
|
int rxPinDef,
|
||||||
|
int txPinDef,
|
||||||
|
uint8_t allowedSerial,
|
||||||
|
String label,
|
||||||
|
String id,
|
||||||
|
String pin1Var,
|
||||||
|
String pin2Var,
|
||||||
|
String i2c1Var,
|
||||||
|
String i2c2Var);
|
||||||
|
|
||||||
void serialHelper_webformSave(uint8_t& port,
|
void serialHelper_webformSave(uint8_t& port,
|
||||||
int8_t & rxPin,
|
int8_t & rxPin,
|
||||||
|
|||||||
@@ -19,10 +19,15 @@
|
|||||||
# endif // if defined(P016_CHECK_HEAP)
|
# endif // if defined(P016_CHECK_HEAP)
|
||||||
# endif // if defined(LIMIT_BUILD_SIZE)
|
# endif // if defined(LIMIT_BUILD_SIZE)
|
||||||
|
|
||||||
|
# ifndef P016_EVENT_ON_ERROR
|
||||||
|
# define P016_EVENT_ON_ERROR 1
|
||||||
|
# endif // ifndef P016_EVENT_ON_ERROR
|
||||||
|
|
||||||
// bit definition in PCONFIG_LONG(0)
|
// bit definition in PCONFIG_LONG(0)
|
||||||
# define P016_BitAddNewCode 0 // Add automatically new code into Code of the command structure
|
# define P016_BitAddNewCode 0 // Add automatically new code into Code of the command structure
|
||||||
# define P016_BitExecuteCmd 1 // Execute command if received code matches Code or AlternativeCode of the command structure
|
# define P016_BitExecuteCmd 1 // Execute command if received code matches Code or AlternativeCode of the command structure
|
||||||
# define P016_BitAcceptUnknownType 2 // Accept unknown DecodeType as valid IR code (UNKNOWH is only the result of DECODE_HASH)
|
# define P016_BitAcceptUnknownType 2 // Accept unknown DecodeType as valid IR code (UNKNOWH is only the result of DECODE_HASH)
|
||||||
|
# define P016_EventOnError 3 // Generate <taskName>#Overflow event on buffer overflow
|
||||||
|
|
||||||
# define P16_Nlines 10 // The number of different lines which can be displayed - each line is 64 chars max
|
# define P16_Nlines 10 // The number of different lines which can be displayed - each line is 64 chars max
|
||||||
# define P16_Nchars 64 // max chars per command line
|
# define P16_Nchars 64 // max chars per command line
|
||||||
@@ -57,6 +62,7 @@ typedef struct {
|
|||||||
char Command[P16_Nchars] = { 0 };
|
char Command[P16_Nchars] = { 0 };
|
||||||
uint32_t Code = 0; // received code (can be added automatically)
|
uint32_t Code = 0; // received code (can be added automatically)
|
||||||
uint32_t AlternativeCode = 0; // alternative code fpr the same command
|
uint32_t AlternativeCode = 0; // alternative code fpr the same command
|
||||||
|
|
||||||
} tCommandLinesV1;
|
} tCommandLinesV1;
|
||||||
# endif // ifdef P16_SETTINGS_V1
|
# endif // ifdef P16_SETTINGS_V1
|
||||||
|
|
||||||
@@ -75,7 +81,9 @@ struct tCommandLinesV2 {
|
|||||||
decode_type_t AlternativeCodeDecodeType = decode_type_t::UNUSED;
|
decode_type_t AlternativeCodeDecodeType = decode_type_t::UNUSED;
|
||||||
uint16_t CodeFlags = 0;
|
uint16_t CodeFlags = 0;
|
||||||
uint16_t AlternativeCodeFlags = 0;
|
uint16_t AlternativeCodeFlags = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# endif // if P016_FEATURE_COMMAND_HANDLING
|
# endif // if P016_FEATURE_COMMAND_HANDLING
|
||||||
|
|
||||||
struct P016_data_struct : public PluginTaskData_base {
|
struct P016_data_struct : public PluginTaskData_base {
|
||||||
@@ -132,6 +140,7 @@ private:
|
|||||||
# ifdef P016_CHECK_HEAP
|
# ifdef P016_CHECK_HEAP
|
||||||
void CheckHeap(String dbgtxt);
|
void CheckHeap(String dbgtxt);
|
||||||
# endif // ifdef P016_CHECK_HEAP
|
# endif // ifdef P016_CHECK_HEAP
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ifdef USES_P016
|
#endif // ifdef USES_P016
|
||||||
|
|||||||
@@ -297,7 +297,8 @@ void P020_Task::handleSerialIn(struct EventStruct *event) {
|
|||||||
bool done = false;
|
bool done = false;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
if (ser2netSerial->available()) {
|
if (ser2netSerial->available()) {
|
||||||
if ((serial_processing != P020_Events::P1WiFiGateway) // P1 handling without this check
|
if ((serial_processing != P020_Events::P1WiFiGateway) // P1 handling without this check
|
||||||
&& (serial_buffer.length() > static_cast<size_t>(P020_RX_BUFFER))) {
|
&& (serial_buffer.length() > static_cast<size_t>(P020_RX_BUFFER))) {
|
||||||
@@ -357,7 +358,7 @@ void P020_Task::handleSerialIn(struct EventStruct *event) {
|
|||||||
|
|
||||||
blinkLED();
|
blinkLED();
|
||||||
|
|
||||||
rulesEngine(serial_buffer);
|
rulesEngine(serial_buffer, event);
|
||||||
ser2netClient.PR_9453_FLUSH_TO_CLEAR();
|
ser2netClient.PR_9453_FLUSH_TO_CLEAR();
|
||||||
clearBuffer();
|
clearBuffer();
|
||||||
# ifndef BUILD_NO_DEBUG
|
# ifndef BUILD_NO_DEBUG
|
||||||
@@ -375,14 +376,16 @@ void P020_Task::discardSerialIn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We can also use the rules engine for local control!
|
// We can also use the rules engine for local control!
|
||||||
void P020_Task::rulesEngine(const String& message) {
|
void P020_Task::rulesEngine(const String& message, struct EventStruct *event) {
|
||||||
if (!Settings.UseRules || message.isEmpty() || (P020_Events::None == serial_processing)) { return; }
|
if (!Settings.UseRules || message.isEmpty() || (P020_Events::None == serial_processing)) { return; }
|
||||||
int NewLinePos = 0;
|
int NewLinePos = 0;
|
||||||
uint16_t StartPos = 0;
|
uint16_t StartPos = 0;
|
||||||
|
bool eventSent = false;
|
||||||
|
|
||||||
NewLinePos = handleMultiLine ? message.indexOf('\n', StartPos) : message.length();
|
NewLinePos = handleMultiLine ? message.indexOf('\n', StartPos) : message.length();
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
if (NewLinePos < 0) {
|
if (NewLinePos < 0) {
|
||||||
NewLinePos = message.length();
|
NewLinePos = message.length();
|
||||||
}
|
}
|
||||||
@@ -394,11 +397,14 @@ void P020_Task::rulesEngine(const String& message) {
|
|||||||
NewLinePos--;
|
NewLinePos--;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (serial_processing) {
|
switch (serial_processing)
|
||||||
case P020_Events::None: { break; }
|
{
|
||||||
case P020_Events::Generic: { // Generic
|
case P020_Events::None:
|
||||||
|
break;
|
||||||
|
case P020_Events::Generic: // Generic
|
||||||
|
{
|
||||||
if (NewLinePos > StartPos) {
|
if (NewLinePos > StartPos) {
|
||||||
eventString = '!'; // F("!Serial");
|
eventString = '!'; // F("!Serial");
|
||||||
|
|
||||||
if (_serialId) {
|
if (_serialId) {
|
||||||
eventString += ESPEasySerialPort_toString(_port, true);
|
eventString += ESPEasySerialPort_toString(_port, true);
|
||||||
@@ -421,8 +427,9 @@ void P020_Task::rulesEngine(const String& message) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case P020_Events::RFLink: { // RFLink
|
case P020_Events::RFLink: // RFLink
|
||||||
StartPos += 6; // RFLink, strip 20;xx; from incoming message
|
{
|
||||||
|
StartPos += 6; // RFLink, strip 20;xx; from incoming message
|
||||||
|
|
||||||
if (((NewLinePos - StartPos) >= 8) &&
|
if (((NewLinePos - StartPos) >= 8) &&
|
||||||
message.substring(StartPos, StartPos + 8)
|
message.substring(StartPos, StartPos + 8)
|
||||||
@@ -442,6 +449,7 @@ void P020_Task::rulesEngine(const String& message) {
|
|||||||
eventString += message.substring(StartPos, NewLinePos);
|
eventString += message.substring(StartPos, NewLinePos);
|
||||||
}
|
}
|
||||||
eventQueue.addMove(std::move(eventString));
|
eventQueue.addMove(std::move(eventString));
|
||||||
|
eventSent = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case P020_Events::P1WiFiGateway: // P1 WiFi Gateway
|
case P020_Events::P1WiFiGateway: // P1 WiFi Gateway
|
||||||
@@ -466,6 +474,7 @@ void P020_Task::rulesEngine(const String& message) {
|
|||||||
|
|
||||||
if (!eventString.isEmpty()) {
|
if (!eventString.isEmpty()) {
|
||||||
eventQueue.add(eventString);
|
eventQueue.add(eventString);
|
||||||
|
eventSent = true;
|
||||||
}
|
}
|
||||||
NewLinePos = message.indexOf('\n', StartPos);
|
NewLinePos = message.indexOf('\n', StartPos);
|
||||||
|
|
||||||
@@ -473,6 +482,13 @@ void P020_Task::rulesEngine(const String& message) {
|
|||||||
NewLinePos = message.length();
|
NewLinePos = message.length();
|
||||||
}
|
}
|
||||||
} while (handleMultiLine && NewLinePos > StartPos);
|
} while (handleMultiLine && NewLinePos > StartPos);
|
||||||
|
|
||||||
|
# if FEATURE_STRING_VARIABLES
|
||||||
|
|
||||||
|
if (eventSent) {
|
||||||
|
sendData(event); // Send derived values
|
||||||
|
}
|
||||||
|
# endif // if FEATURE_STRING_VARIABLES
|
||||||
}
|
}
|
||||||
|
|
||||||
bool P020_Task::isInit() const {
|
bool P020_Task::isInit() const {
|
||||||
@@ -483,10 +499,7 @@ bool P020_Task::isInit() const {
|
|||||||
) && nullptr != ser2netSerial;
|
) && nullptr != ser2netSerial;
|
||||||
}
|
}
|
||||||
|
|
||||||
void P020_Task::sendConnectedEvent(bool connected)
|
void P020_Task::sendConnectedEvent(bool connected) { eventQueue.add(_taskIndex, F("Client"), (connected ? 1 : 0)); }
|
||||||
{
|
|
||||||
eventQueue.add(_taskIndex, F("Client"), (connected ? 1 : 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
void P020_Task::blinkLED() {
|
void P020_Task::blinkLED() {
|
||||||
if (_ledEnabled) {
|
if (_ledEnabled) {
|
||||||
@@ -605,7 +618,8 @@ bool P020_Task::handleP1Char(char ch) {
|
|||||||
bool done = false;
|
bool done = false;
|
||||||
bool invalid = false;
|
bool invalid = false;
|
||||||
|
|
||||||
switch (_state) {
|
switch (_state)
|
||||||
|
{
|
||||||
case ParserState::WAITING:
|
case ParserState::WAITING:
|
||||||
|
|
||||||
if (ch == P020_DATAGRAM_START_CHAR) {
|
if (ch == P020_DATAGRAM_START_CHAR) {
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ enum class P020_Events : uint8_t {
|
|||||||
Generic = 1u,
|
Generic = 1u,
|
||||||
RFLink = 2u,
|
RFLink = 2u,
|
||||||
P1WiFiGateway = 3u,
|
P1WiFiGateway = 3u,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# if P020_USE_PROTOCOL
|
# if P020_USE_PROTOCOL
|
||||||
@@ -86,7 +87,9 @@ enum class P020_Protocol_e : uint8_t {
|
|||||||
TCP = 0u,
|
TCP = 0u,
|
||||||
UDP = 1u,
|
UDP = 1u,
|
||||||
TCP_UDP = 2u,
|
TCP_UDP = 2u,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# endif // if P020_USE_PROTOCOL
|
# endif // if P020_USE_PROTOCOL
|
||||||
|
|
||||||
struct P020_Task : public PluginTaskData_base {
|
struct P020_Task : public PluginTaskData_base {
|
||||||
@@ -94,6 +97,7 @@ struct P020_Task : public PluginTaskData_base {
|
|||||||
WAITING,
|
WAITING,
|
||||||
READING,
|
READING,
|
||||||
CHECKSUM
|
CHECKSUM
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
P020_Task(struct EventStruct *event);
|
P020_Task(struct EventStruct *event);
|
||||||
@@ -120,7 +124,8 @@ struct P020_Task : public PluginTaskData_base {
|
|||||||
void handleSerialIn(struct EventStruct *event);
|
void handleSerialIn(struct EventStruct *event);
|
||||||
void handleClientIn(struct EventStruct *event);
|
void handleClientIn(struct EventStruct *event);
|
||||||
void discardSerialIn();
|
void discardSerialIn();
|
||||||
void rulesEngine(const String& message);
|
void rulesEngine(const String & message,
|
||||||
|
struct EventStruct *event);
|
||||||
|
|
||||||
bool isInit() const;
|
bool isInit() const;
|
||||||
|
|
||||||
@@ -187,6 +192,7 @@ struct P020_Task : public PluginTaskData_base {
|
|||||||
bool _eventAsHex = false;
|
bool _eventAsHex = false;
|
||||||
|
|
||||||
ESPEasySerialPort _port;
|
ESPEasySerialPort _port;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ifdef USES_P020
|
#endif // ifdef USES_P020
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ P129_data_struct::P129_data_struct(int8_t dataPin,
|
|||||||
uint8_t chipCount)
|
uint8_t chipCount)
|
||||||
: _dataPin(dataPin), _clockPin(clockPin), _enablePin(enablePin), _loadPin(loadPin), _chipCount(chipCount) {}
|
: _dataPin(dataPin), _clockPin(clockPin), _enablePin(enablePin), _loadPin(loadPin), _chipCount(chipCount) {}
|
||||||
|
|
||||||
|
|
||||||
bool P129_data_struct::plugin_init(struct EventStruct *event) {
|
bool P129_data_struct::plugin_init(struct EventStruct *event) {
|
||||||
if (isInitialized()) {
|
if (isInitialized()) {
|
||||||
for (uint8_t i = 0; i < P129_MAX_CHIP_COUNT; ++i) { // Clear entire buffer
|
for (uint8_t i = 0; i < P129_MAX_CHIP_COUNT; ++i) { // Clear entire buffer
|
||||||
@@ -29,6 +28,7 @@ bool P129_data_struct::plugin_init(struct EventStruct *event) {
|
|||||||
|
|
||||||
if (validGpio(_enablePin)) { DIRECT_pinWrite(_enablePin, HIGH); }
|
if (validGpio(_enablePin)) { DIRECT_pinWrite(_enablePin, HIGH); }
|
||||||
|
|
||||||
|
plugin_read(event); // Prime data
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -74,6 +74,7 @@ enum class p129_subcommands_e {
|
|||||||
setchipcount,
|
setchipcount,
|
||||||
samplefrequency,
|
samplefrequency,
|
||||||
eventperpin
|
eventperpin
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool P129_data_struct::plugin_write(struct EventStruct *event,
|
bool P129_data_struct::plugin_write(struct EventStruct *event,
|
||||||
@@ -91,7 +92,8 @@ bool P129_data_struct::plugin_write(struct EventStruct *event,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (static_cast<p129_subcommands_e>(command_i)) {
|
switch (static_cast<p129_subcommands_e>(command_i))
|
||||||
|
{
|
||||||
case p129_subcommands_e::pinevent:
|
case p129_subcommands_e::pinevent:
|
||||||
{ // ShiftIn,pinevent,<pin>,<0|1>
|
{ // ShiftIn,pinevent,<pin>,<0|1>
|
||||||
const uint8_t pin = event->Par2 - 1;
|
const uint8_t pin = event->Par2 - 1;
|
||||||
|
|||||||
@@ -253,8 +253,7 @@ void handle_advanced() {
|
|||||||
serialHelper_webformLoad(
|
serialHelper_webformLoad(
|
||||||
static_cast<ESPEasySerialPort>(Settings.console_serial_port),
|
static_cast<ESPEasySerialPort>(Settings.console_serial_port),
|
||||||
Settings.console_serial_rxpin,
|
Settings.console_serial_rxpin,
|
||||||
Settings.console_serial_txpin,
|
Settings.console_serial_txpin);
|
||||||
true);
|
|
||||||
|
|
||||||
// Show serial port selection
|
// Show serial port selection
|
||||||
addFormPinSelect(
|
addFormPinSelect(
|
||||||
@@ -268,7 +267,7 @@ void handle_advanced() {
|
|||||||
F("taskdevicepin2"),
|
F("taskdevicepin2"),
|
||||||
Settings.console_serial_txpin);
|
Settings.console_serial_txpin);
|
||||||
|
|
||||||
html_add_script(F("document.getElementById('serPort').onchange();"), false);
|
html_add_script(F("elId('serPort').onchange();"), false);
|
||||||
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
|
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
|
||||||
addFormCheckBox(LabelType::CONSOLE_FALLBACK_TO_SERIAL0);
|
addFormCheckBox(LabelType::CONSOLE_FALLBACK_TO_SERIAL0);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user