[Cleanup] Remove MCP/PCF related code when plugins not included

This commit is contained in:
TD-er
2022-08-20 13:25:16 +02:00
parent 42b0d83d4e
commit 91abe4bb65
13 changed files with 96 additions and 124 deletions
+3 -12
View File
@@ -276,20 +276,11 @@ extends = esp82xx_1M_OTA
board = esp8266_1M128k_OTA
build_flags = ${esp82xx_1M_OTA.build_flags}
lib_ignore = ${esp82xx_1M.lib_ignore}
NewPing
PZEM-004T-v30
SerialSensors
HLW8012
AS_BH1750
AM2320
Itho
ccronexpr
ArduinoOTA
ESP8266mDNS
WakeOnLan
Blynk
Servo(esp8266)
SC16IS752
; Adding the libs below to the lib_ignore will even increase build size
; Adafruit TCS34725
; RN2xx3 Arduino Library
+14 -53
View File
@@ -212,73 +212,34 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string)
float P026_get_value(int type)
{
float value = 0;
switch (type)
{
case 0:
{
value = getUptimeMinutes();
break;
}
case 1:
{
value = FreeMem();
break;
}
case 2:
{
value = WiFi.RSSI();
break;
}
case 0: return getUptimeMinutes();
case 1: return FreeMem();
case 2: return WiFi.RSSI();
case 3:
{
# if FEATURE_ADC_VCC
value = vcc;
return vcc;
# else // if FEATURE_ADC_VCC
value = -1.0f;
return -1.0f;
# endif // if FEATURE_ADC_VCC
break;
}
case 4:
{
value = getCPUload();
break;
}
case 4: return getCPUload();
case 5:
case 6:
case 7:
case 8:
{
value = NetworkLocalIP()[type - 5];
break;
}
case 9:
{
value = timePassedSince(lastWeb) / 1000.0f; // respond in seconds
break;
}
case 10:
{
value = getCurrentFreeStack();
break;
}
case 12:
{
value = WiFiEventData.wifi_TX_pwr;
break;
}
return NetworkLocalIP()[type - 5];
case 9: return timePassedSince(lastWeb) / 1000.0f; // respond in seconds
case 10: return getCurrentFreeStack();
case 12: return WiFiEventData.wifi_TX_pwr;
case 13:
{
#ifdef USE_SECOND_HEAP
value = FreeMem2ndHeap();
#endif
return FreeMem2ndHeap();
#else
break;
}
#endif
}
return value;
return 0.0f;
}
#endif // USES_P026
+48 -32
View File
@@ -204,7 +204,6 @@ const __FlashStringHelper * Command_GPIO_LongPulse_Ms(struct EventStruct *event,
const __FlashStringHelper * Command_GPIO_Status(struct EventStruct *event, const char *Line)
{
bool success = true;
bool sendStatusFlag;
uint8_t pluginID = 0;
@@ -214,31 +213,31 @@ const __FlashStringHelper * Command_GPIO_Status(struct EventStruct *event, const
pluginID = PLUGIN_GPIO;
sendStatusFlag = true;
break;
case 'm': // mcp
#ifdef USES_P009
case 'm': // mcp
pluginID = PLUGIN_MCP;
sendStatusFlag = GPIO_MCP_Read(event->Par2) == -1;
#endif
break;
case 'p': // pcf
#endif
#ifdef USES_P019
case 'p': // pcf
pluginID = PLUGIN_PCF;
sendStatusFlag = GPIO_PCF_Read(event->Par2) == -1;
#endif
break;
#endif
default:
success = false;
addLog(LOG_LEVEL_ERROR, F("Plugin not included in build"));
return return_command_failed();
}
if (success && checkValidPortRange(pluginID, event->Par2))
if (!checkValidPortRange(pluginID, event->Par2))
{
const uint32_t key = createKey(pluginID, event->Par2); // WARNING: 'status' uses Par2 instead of Par1
String dummy;
SendStatusOnlyIfNeeded(event, sendStatusFlag, key, dummy, 0);
return return_command_success();
} else {
return return_command_failed();
}
const uint32_t key = createKey(pluginID, event->Par2); // WARNING: 'status' uses Par2 instead of Par1
String dummy;
SendStatusOnlyIfNeeded(event, sendStatusFlag, key, dummy, 0);
return return_command_success();
}
const __FlashStringHelper * Command_GPIO_PWM(struct EventStruct *event, const char *Line)
@@ -465,16 +464,21 @@ const __FlashStringHelper * Command_GPIO(struct EventStruct *event, const char *
setInternalGPIOPullupMode(event->Par1);
state = GPIO_Read_Switch_State(event->Par1, PIN_MODE_INPUT_PULLUP);
break;
case PLUGIN_MCP:
#ifdef USES_P009
case PLUGIN_MCP:
setMCPInputAndPullupMode(event->Par1, true);
GPIO_Read(PLUGIN_MCP, event->Par1, state);
#endif
break;
#endif
#ifdef USES_P019
case PLUGIN_PCF:
// PCF8574 specific: only can read 0/low state, so we must send 1
state = 1;
break;
#endif
default:
addLog(LOG_LEVEL_ERROR, F("Plugin not included in build"));
return return_command_failed();
}
} else { // OUTPUT
mode = PIN_MODE_OUTPUT;
@@ -584,8 +588,6 @@ void createAndSetPortStatus_Mode_State(uint32_t key, uint8_t newMode, int8_t new
bool getPluginIDAndPrefix(char selection, pluginID_t& pluginID, String& logPrefix)
{
bool success = true;
switch (tolower(selection))
{
case 'g': // gpio
@@ -593,19 +595,23 @@ bool getPluginIDAndPrefix(char selection, pluginID_t& pluginID, String& logPrefi
pluginID = PLUGIN_GPIO;
logPrefix = F("GPIO");
break;
#ifdef USES_P009
case 'm': // mcp & mcplongpulse
pluginID = PLUGIN_MCP;
logPrefix = F("MCP");
break;
#endif
#ifdef USES_P019
case 'p': // pcf & pcflongpulse
pluginID = PLUGIN_PCF;
logPrefix = F("PCF");
break;
#endif
default:
logPrefix = F("PluginID out of range. Error");
success = false;
logPrefix = F("Plugin not included in build");
return false;
}
return success;
return true;
}
struct range_pattern_helper_data {
@@ -1051,17 +1057,20 @@ bool gpio_mode_range_helper(uint8_t pin, uint8_t pinMode, struct EventStruct *ev
case PLUGIN_GPIO:
/* setSuccess = */ setGPIOMode(pin, mode);
break;
#ifdef USES_P019
case PLUGIN_PCF:
// set pin = 1 when INPUT
#ifdef USES_P019
/* setSuccess = */ setPCFMode(pin, mode);
#endif
break;
case PLUGIN_MCP:
#endif
#ifdef USES_P009
case PLUGIN_MCP:
/* setSuccess = */ setMCPMode(pin, mode);
#endif
break;
#endif
default:
addLog(LOG_LEVEL_ERROR, F("Plugin not included in build"));
return false;
}
const uint32_t key = createKey(pluginID, pin);
@@ -1122,21 +1131,24 @@ bool getGPIOPinStateValues(String& str) {
success = true;
break;
case 'm':
#ifdef USES_P009
case 'm':
str = GPIO_MCP_Read(par1);
logPrefix = F("MCP");
success = true;
#endif
break;
#endif
case 'p':
#ifdef USES_P019
case 'p':
str = GPIO_PCF_Read(par1);
logPrefix = F("PCF");
success = true;
#endif
break;
#endif
default:
addLog(LOG_LEVEL_ERROR, F("Plugin not included in build"));
return false;
}
}
@@ -1162,27 +1174,31 @@ bool getGPIOPinStateValues(String& str) {
if (successPar) {
switch (device[0]) {
case 'm':
#ifdef USES_P009
case 'm':
{
uint16_t tempValue = 0;
logPrefix = F("MCP");
success = mcpgpio_plugin_range_helper(par1, par2, tempValue);
str = String(tempValue);
break;
}
#endif
break;
case 'p':
#ifdef USES_P019
case 'p':
{
uint16_t tempValue = 0;
logPrefix = F("PCF");
success = pcfgpio_plugin_range_helper(par1, par2, tempValue);
str = String(tempValue);
}
#endif
break;
}
#endif
default:
addLog(LOG_LEVEL_ERROR, F("PLUGIN PINSTATE. Plugin not included in build"));
return false;
}
if (success) {
-1
View File
@@ -1768,7 +1768,6 @@ To create/register a plugin, you have to :
#endif
*/
#if defined(USES_C018)
#define FEATURE_PACKED_RAW_DATA 1
#endif
+15 -13
View File
@@ -212,14 +212,14 @@ bool MQTTConnect(controllerIndex_t controller_idx)
MQTTclient.setCallback(incoming_mqtt_callback);
// MQTT needs a unique clientname to subscribe to broker
String clientid = getMQTTclientID(ControllerSettings);
const String clientid = getMQTTclientID(ControllerSettings);
String LWTTopic = getLWT_topic(ControllerSettings);
String LWTMessageDisconnect = getLWT_messageDisconnect(ControllerSettings);
bool MQTTresult = false;
uint8_t willQos = 0;
bool willRetain = ControllerSettings.mqtt_willRetain() && ControllerSettings.mqtt_sendLWT();
bool cleanSession = ControllerSettings.mqtt_cleanSession(); // As suggested here:
const String LWTTopic = getLWT_topic(ControllerSettings);
const String LWTMessageDisconnect = getLWT_messageDisconnect(ControllerSettings);
bool MQTTresult = false;
const uint8_t willQos = 0;
const bool willRetain = ControllerSettings.mqtt_willRetain() && ControllerSettings.mqtt_sendLWT();
const bool cleanSession = ControllerSettings.mqtt_cleanSession(); // As suggested here:
if (MQTTclient_should_reconnect) {
addLog(LOG_LEVEL_ERROR, F("MQTT : Intentional reconnect"));
@@ -247,10 +247,7 @@ bool MQTTConnect(controllerIndex_t controller_idx)
}
delay(0);
uint8_t controller_number = Settings.Protocol[controller_idx];
count_connection_results(MQTTresult, F("MQTT : Broker "), controller_number);
count_connection_results(MQTTresult, F("MQTT : Broker "), Settings.Protocol[controller_idx]);
if (!MQTTresult) {
MQTTclient.disconnect();
@@ -259,8 +256,8 @@ bool MQTTConnect(controllerIndex_t controller_idx)
return false;
}
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
String log = F("MQTT : Connected to broker with client ID: ");
String log;
log += F("MQTT : Connected to broker with client ID: ");
log += clientid;
addLogMove(LOG_LEVEL_INFO, log);
}
@@ -460,6 +457,11 @@ bool SourceNeedsStatusUpdate(EventValueSource::Enum eventSource)
return false;
}
void SendStatus(struct EventStruct *event, const __FlashStringHelper * status)
{
SendStatus(event, String(status));
}
void SendStatus(struct EventStruct *event, const String& status)
{
if (status.isEmpty()) { return; }
+1
View File
@@ -54,6 +54,7 @@ void SendStatusOnlyIfNeeded(struct EventStruct *event, bool param1, uint32_t key
bool SourceNeedsStatusUpdate(EventValueSource::Enum eventSource);
void SendStatus(struct EventStruct *event, const __FlashStringHelper * status);
void SendStatus(struct EventStruct *event, const String& status);
#if FEATURE_MQTT
+2
View File
@@ -1,5 +1,7 @@
#include "../Helpers/Convert.h"
/*********************************************************************************************\
Convert bearing in degree to bearing string
\*********************************************************************************************/
+5 -5
View File
@@ -308,20 +308,20 @@ String getValue(LabelType::Enum label) {
case LabelType::WIFI_CONNECTION: break;
case LabelType::WIFI_RSSI: return String(WiFi.RSSI());
case LabelType::IP_CONFIG: return useStaticIP() ? getLabel(LabelType::IP_CONFIG_STATIC) : getLabel(
LabelType::IP_CONFIG_DYNAMIC);
case LabelType::IP_CONFIG: return String(useStaticIP() ? getLabel(LabelType::IP_CONFIG_STATIC) : getLabel(
LabelType::IP_CONFIG_DYNAMIC));
case LabelType::IP_CONFIG_STATIC: break;
case LabelType::IP_CONFIG_DYNAMIC: break;
case LabelType::IP_ADDRESS: return NetworkLocalIP().toString();
case LabelType::IP_SUBNET: return NetworkSubnetMask().toString();
case LabelType::IP_ADDRESS_SUBNET: return String(getValue(LabelType::IP_ADDRESS) + F(" / ") + getValue(LabelType::IP_SUBNET));
case LabelType::IP_ADDRESS_SUBNET: return getValue(LabelType::IP_ADDRESS) + F(" / ") + getValue(LabelType::IP_SUBNET);
case LabelType::GATEWAY: return NetworkGatewayIP().toString();
case LabelType::CLIENT_IP: return formatIP(web_server.client().remoteIP());
#if FEATURE_MDNS
case LabelType::M_DNS: return String(NetworkGetHostname()) + F(".local");
case LabelType::M_DNS: return NetworkGetHostname() + F(".local");
#endif // if FEATURE_MDNS
case LabelType::DNS: return String(getValue(LabelType::DNS_1) + F(" / ") + getValue(LabelType::DNS_2));
case LabelType::DNS: return getValue(LabelType::DNS_1) + F(" / ") + getValue(LabelType::DNS_2);
case LabelType::DNS_1: return NetworkDnsIP(0).toString();
case LabelType::DNS_2: return NetworkDnsIP(1).toString();
case LabelType::ALLOWED_IP_RANGE: return describeAllowedIPrange();
+2 -1
View File
@@ -1,10 +1,11 @@
#include "../PluginStructs/P012_data_struct.h"
#ifdef USES_P012
// Needed also here for PlatformIO's library finder as the .h file
// is in a directory which is excluded in the src_filter
#include <LiquidCrystal_I2C.h>
#ifdef USES_P012
P012_data_struct::P012_data_struct(uint8_t addr,
uint8_t lcd_size,
+1 -1
View File
@@ -1,11 +1,11 @@
#include "../PluginStructs/P057_data_struct.h"
#ifdef USES_P057
// Needed also here for PlatformIO's library finder as the .h file
// is in a directory which is excluded in the src_filter
# include <HT16K33.h>
#ifdef USES_P057
P057_data_struct::P057_data_struct(uint8_t i2c_addr) : i2cAddress(i2c_addr) {
ledMatrix.Init(i2cAddress);
+2 -1
View File
@@ -1,11 +1,12 @@
#include "../PluginStructs/P058_data_struct.h"
#ifdef USES_P058
// Needed also here for PlatformIO's library finder as the .h file
// is in a directory which is excluded in the src_filter
# include <HT16K33.h>
#ifdef USES_P058
P058_data_struct::P058_data_struct(uint8_t i2c_addr) {
keyPad.Init(i2c_addr);
+2 -2
View File
@@ -1,11 +1,11 @@
#include "../PluginStructs/P064_data_struct.h"
#ifdef USES_P064
// Needed also here for PlatformIO's library finder as the .h file
// is in a directory which is excluded in the src_filter
#include <SparkFun_APDS9960.h> // Lib is modified to work with ESP
#ifdef USES_P064
P064_data_struct::P064_data_struct() {}
+1 -3
View File
@@ -1,13 +1,11 @@
#include "../PluginStructs/P083_data_struct.h"
#ifdef USES_P083
// Needed also here for PlatformIO's library finder as the .h file
// is in a directory which is excluded in the src_filter
#include <Adafruit_SGP30.h>
#ifdef USES_P083
P083_data_struct::P083_data_struct() {
initialized = sgp.begin();
init_time = millis();