diff --git a/src/_P054_DMX512.ino b/src/_P054_DMX512.ino index 7c42c4ec84..94d417e81a 100644 --- a/src/_P054_DMX512.ino +++ b/src/_P054_DMX512.ino @@ -90,9 +90,10 @@ boolean Plugin_054(uint8_t function, struct EventStruct *event, String& string) case PLUGIN_DEVICE_ADD: { auto& dev = Device[++deviceCount]; - dev.Number = PLUGIN_ID_054; - dev.Type = DEVICE_TYPE_SERIAL; - dev.VType = Sensor_VType::SENSOR_TYPE_NONE; + dev.Number = PLUGIN_ID_054; + dev.Type = DEVICE_TYPE_SERIAL; + dev.VType = Sensor_VType::SENSOR_TYPE_NONE; + dev.SerialPortsAllowed = INCLUDE_HW_SERIAL | INCLUDE_SW_SERIAL; break; } @@ -133,19 +134,6 @@ boolean Plugin_054(uint8_t function, struct EventStruct *event, String& string) break; } - case PLUGIN_WEBFORM_SHOW_SERIAL_PARAMS: - { - addFormNote(F("An on-chip ESP Serial port" - # if USES_USBCDC - " (not USB CDC)" - # endif // if USES_USBCDC - # if USES_HWCDC - " (not USB HWCDC)" - # endif // if USES_HWCDC - " must be selected!")); - break; - } - case PLUGIN_GET_DEVICEGPIONAMES: { serialHelper_getGpioNames(event, true); diff --git a/src/_P065_DRF0299_MP3.ino b/src/_P065_DRF0299_MP3.ino index ec0a70f255..524a1ef1f4 100644 --- a/src/_P065_DRF0299_MP3.ino +++ b/src/_P065_DRF0299_MP3.ino @@ -53,7 +53,6 @@ ESPeasySerial *P065_easySerial = nullptr; uint8_t P065_initialVolumeSet = P065_VOLUME_DELAY; - boolean Plugin_065(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -63,9 +62,10 @@ boolean Plugin_065(uint8_t function, struct EventStruct *event, String& string) case PLUGIN_DEVICE_ADD: { auto& dev = Device[++deviceCount]; - dev.Number = PLUGIN_ID_065; - dev.Type = DEVICE_TYPE_SERIAL; - dev.VType = Sensor_VType::SENSOR_TYPE_NONE; + dev.Number = PLUGIN_ID_065; + dev.Type = DEVICE_TYPE_SERIAL; + dev.VType = Sensor_VType::SENSOR_TYPE_NONE; + dev.SerialPortsAllowed = INCLUDE_NOT_CDC_SERIAL; break; } @@ -274,10 +274,7 @@ void Plugin_065_SetMode(int8_t mode) Plugin_065_SendCmd(0x08, mode); } -void Plugin_065_SetRepeat(int8_t repeat) -{ - Plugin_065_SendCmd(0x11, (repeat <= 0) ? 0 : 1); -} +void Plugin_065_SetRepeat(int8_t repeat) { Plugin_065_SendCmd(0x11, (repeat <= 0) ? 0 : 1); } void Plugin_065_SendCmd(uint8_t cmd, int16_t data) { diff --git a/src/_P077_CSE7766.ino b/src/_P077_CSE7766.ino index 4d79ba1269..a366a5c79f 100644 --- a/src/_P077_CSE7766.ino +++ b/src/_P077_CSE7766.ino @@ -44,18 +44,19 @@ boolean Plugin_077(uint8_t function, struct EventStruct *event, String& string) switch (function) { case PLUGIN_DEVICE_ADD: { auto& dev = Device[++deviceCount]; - dev.Number = PLUGIN_ID_077; - dev.Type = DEVICE_TYPE_SERIAL; - dev.VType = Sensor_VType::SENSOR_TYPE_QUAD; - dev.FormulaOption = true; - dev.ValueCount = 4; - dev.OutputDataType = Output_Data_type_t::Simple; - dev.SendDataOption = true; - dev.TimerOption = true; - dev.TimerOptional = true; - dev.PluginStats = true; - dev.TaskLogsOwnPeaks = true; - dev.MqttStateClass = true; + dev.Number = PLUGIN_ID_077; + dev.Type = DEVICE_TYPE_SERIAL; + dev.VType = Sensor_VType::SENSOR_TYPE_QUAD; + dev.FormulaOption = true; + dev.ValueCount = 4; + dev.OutputDataType = Output_Data_type_t::Simple; + dev.SendDataOption = true; + dev.TimerOption = true; + dev.TimerOptional = true; + dev.PluginStats = true; + dev.TaskLogsOwnPeaks = true; + dev.MqttStateClass = true; + dev.SerialPortsAllowed = INCLUDE_HW_SERIAL; break; } diff --git a/src/_P159_LD2410.ino b/src/_P159_LD2410.ino index 1611509984..4e5f0e32d9 100644 --- a/src/_P159_LD2410.ino +++ b/src/_P159_LD2410.ino @@ -92,6 +92,7 @@ boolean Plugin_159(uint8_t function, struct EventStruct *event, String& string) dev.PluginStats = true; dev.ExitTaskBeforeSave = false; // Enable calling PLUGIN_WEBFORM_SAVE on the instantiated object dev.CustomVTypeVar = true; + dev.SerialPortsAllowed = INCLUDE_NOT_CDC_SERIAL; break; } diff --git a/src/src/DataStructs/DeviceStruct.cpp b/src/src/DataStructs/DeviceStruct.cpp index 43069f3e8c..698cd17536 100644 --- a/src/src/DataStructs/DeviceStruct.cpp +++ b/src/src/DataStructs/DeviceStruct.cpp @@ -30,7 +30,8 @@ DeviceStruct::DeviceStruct() : OutputDataType(Output_Data_type_t::Default), Pin1Direction(static_cast(gpio_direction::gpio_direction_MAX)), Pin2Direction(static_cast(gpio_direction::gpio_direction_MAX)), - Pin3Direction(static_cast(gpio_direction::gpio_direction_MAX)) + Pin3Direction(static_cast(gpio_direction::gpio_direction_MAX)), + SerialPortsAllowed(INCLUDE_DEFAULT_SERIAL) { // Only initialize union members in the constructor body // TODO: Rename this so it can be default initialized to 'false' diff --git a/src/src/DataStructs/DeviceStruct.h b/src/src/DataStructs/DeviceStruct.h index 7433096f57..f38b8aa04a 100644 --- a/src/src/DataStructs/DeviceStruct.h +++ b/src/src/DataStructs/DeviceStruct.h @@ -11,6 +11,7 @@ #include "../DataTypes/SensorVType.h" #include "../Helpers/StringGenerator_GPIO.h" +#include "../Helpers/_Plugin_Helper_serial.h" #define DEVICE_TYPE_SINGLE 1 // connected through 1 datapin @@ -154,7 +155,7 @@ struct DeviceStruct uint8_t PinDirection_unused : GPIO_DIRECTION_NR_BITS; }; }; - uint8_t Unused{}; // Padding to 12 bytes struct size + uint8_t SerialPortsAllowed = INCLUDE_DEFAULT_SERIAL; // The bitmap for the allowed serial port types, uses global default }; diff --git a/src/src/WebServer/DevicesPage.cpp b/src/src/WebServer/DevicesPage.cpp index d1386ae5dc..d4e3fa4d99 100644 --- a/src/src/WebServer/DevicesPage.cpp +++ b/src/src/WebServer/DevicesPage.cpp @@ -1229,7 +1229,7 @@ void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page) ) { if (device.isSerial()) { # ifdef PLUGIN_USES_SERIAL - devicePage_show_serial_config(taskIndex); + devicePage_show_serial_config(taskIndex, DeviceIndex); # else // ifdef PLUGIN_USES_SERIAL addHtml(F("PLUGIN_USES_SERIAL not defined")); # endif // ifdef PLUGIN_USES_SERIAL @@ -1424,7 +1424,7 @@ void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex # ifdef PLUGIN_USES_SERIAL -void devicePage_show_serial_config(taskIndex_t taskIndex) +void devicePage_show_serial_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex) { struct EventStruct TempEvent(taskIndex); @@ -1432,7 +1432,7 @@ void devicePage_show_serial_config(taskIndex_t taskIndex) PluginCall(PLUGIN_WEBFORM_PRE_SERIAL_PARAMS, &TempEvent, webformLoadString); - serialHelper_webformLoad(&TempEvent); + serialHelper_webformLoad(&TempEvent, Device[DeviceIndex].SerialPortsAllowed); PluginCall(PLUGIN_WEBFORM_SHOW_SERIAL_PARAMS, &TempEvent, webformLoadString); } diff --git a/src/src/WebServer/DevicesPage.h b/src/src/WebServer/DevicesPage.h index 9ccfe1cf15..ee2f453726 100644 --- a/src/src/WebServer/DevicesPage.h +++ b/src/src/WebServer/DevicesPage.h @@ -58,7 +58,7 @@ void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page); void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex); #ifdef PLUGIN_USES_SERIAL -void devicePage_show_serial_config(taskIndex_t taskIndex); +void devicePage_show_serial_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex); #endif #if FEATURE_SPI