mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[Log] Prevent generating logs if loglevel not enabled
Done till plugin 50.
This commit is contained in:
+2
-1
@@ -152,7 +152,8 @@ bool do_process_c001_delay_queue(int controller_number, const C001_queue_element
|
||||
String request = create_http_request_auth(controller_number, element.controller_idx, ControllerSettings, F("GET"), element.txt);
|
||||
|
||||
# ifndef BUILD_NO_DEBUG
|
||||
addLog(LOG_LEVEL_DEBUG, element.txt);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG))
|
||||
addLog(LOG_LEVEL_DEBUG, element.txt);
|
||||
# endif // ifndef BUILD_NO_DEBUG
|
||||
return send_via_http(controller_number, client, request, ControllerSettings.MustCheckReply);
|
||||
}
|
||||
|
||||
+5
-3
@@ -185,9 +185,11 @@ bool CPlugin_002(CPlugin::Function function, struct EventStruct *event, String&
|
||||
{
|
||||
String json = serializeDomoticzJson(event);
|
||||
# ifndef BUILD_NO_DEBUG
|
||||
String log = F("MQTT : ");
|
||||
log += json;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("MQTT : ");
|
||||
log += json;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
# endif // ifndef BUILD_NO_DEBUG
|
||||
|
||||
String pubname = CPlugin_002_pubname;
|
||||
|
||||
+2
-1
@@ -99,7 +99,8 @@ bool CPlugin_008(CPlugin::Function function, struct EventStruct *event, String&
|
||||
parseSingleControllerVariable(element.txt[x], event, x, true);
|
||||
element.txt[x].replace(F("%value%"), formattedValue);
|
||||
# ifndef BUILD_NO_DEBUG
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, element.txt[x]);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE))
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, element.txt[x]);
|
||||
# endif // ifndef BUILD_NO_DEBUG
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -90,7 +90,8 @@ bool CPlugin_010(CPlugin::Function function, struct EventStruct *event, String&
|
||||
element.txt[x] = tmppubname;
|
||||
parseSingleControllerVariable(element.txt[x], event, x, false);
|
||||
element.txt[x].replace(F("%value%"), formattedValue);
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, element.txt[x]);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE))
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, element.txt[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-6
@@ -334,19 +334,25 @@ void ReplaceTokenByValue(String& s, struct EventStruct *event, bool sendBinary)
|
||||
// write?db=testdb&type=%1%%vname1%%/1%%2%;%vname2%%/2%%3%;%vname3%%/3%%4%;%vname4%%/4%&value=%1%%val1%%/1%%2%;%val2%%/2%%3%;%val3%%/3%%4%;%val4%%/4%
|
||||
// %1%%vname1%,Standort=%tskname% Wert=%val1%%/1%%2%%LF%%vname2%,Standort=%tskname% Wert=%val2%%/2%%3%%LF%%vname3%,Standort=%tskname%
|
||||
// Wert=%val3%%/3%%4%%LF%%vname4%,Standort=%tskname% Wert=%val4%%/4%
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, F("HTTP before parsing: "));
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, s);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE)) {
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, F("HTTP before parsing: "));
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, s);
|
||||
}
|
||||
const byte valueCount = getValueCountForTask(event->TaskIndex);
|
||||
|
||||
DeleteNotNeededValues(s, valueCount);
|
||||
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, F("HTTP after parsing: "));
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, s);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE)) {
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, F("HTTP after parsing: "));
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, s);
|
||||
}
|
||||
|
||||
parseControllerVariables(s, event, !sendBinary);
|
||||
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, F("HTTP after replacements: "));
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, s);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE)) {
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, F("HTTP after replacements: "));
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, s);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ifdef USES_C011
|
||||
|
||||
+2
-1
@@ -70,7 +70,8 @@ bool CPlugin_012(CPlugin::Function function, struct EventStruct *event, String&
|
||||
element.txt[x] += event->idx + x;
|
||||
element.txt[x] += F("?value=");
|
||||
element.txt[x] += formattedValue;
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, element.txt[x]);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE))
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, element.txt[x]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+35
-25
@@ -193,25 +193,29 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String&
|
||||
valueFullName += valueName;
|
||||
String vPinNumberStr = valueName.substring(1, 4);
|
||||
int vPinNumber = vPinNumberStr.toInt();
|
||||
String log = F(C015_LOG_PREFIX);
|
||||
log += Blynk.connected() ? F("(online): ") : F("(offline): ");
|
||||
|
||||
if ((vPinNumber > 0) && (vPinNumber < 256)) {
|
||||
log += F("send ");
|
||||
log += valueFullName;
|
||||
log += F(" = ");
|
||||
log += formattedValue;
|
||||
log += F(" to blynk pin v");
|
||||
log += vPinNumber;
|
||||
}
|
||||
else {
|
||||
if (!(vPinNumber > 0) && (vPinNumber < 256)) {
|
||||
vPinNumber = -1;
|
||||
log += F("error got vPin number for ");
|
||||
log += valueFullName;
|
||||
log += F(", got not valid value: ");
|
||||
log += vPinNumberStr;
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F(C015_LOG_PREFIX);
|
||||
log += Blynk.connected() ? F("(online): ") : F("(offline): ");
|
||||
|
||||
if ((vPinNumber > 0) && (vPinNumber < 256)) {
|
||||
log += F("send ");
|
||||
log += valueFullName;
|
||||
log += F(" = ");
|
||||
log += formattedValue;
|
||||
log += F(" to blynk pin v");
|
||||
log += vPinNumber;
|
||||
} else {
|
||||
log += F("error got vPin number for ");
|
||||
log += valueFullName;
|
||||
log += F(", got not valid value: ");
|
||||
log += vPinNumberStr;
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
element.vPin[x] = vPinNumber;
|
||||
element.txt[x] = formattedValue;
|
||||
}
|
||||
@@ -286,11 +290,15 @@ boolean Blynk_keep_connection_c015(int controllerIndex, ControllerSettingsStruct
|
||||
LoadCustomControllerSettings(controllerIndex, (byte *)&thumbprint, sizeof(thumbprint));
|
||||
|
||||
if (strlen(thumbprint) != 59) {
|
||||
addLog(LOG_LEVEL_INFO, C015_LOG_PREFIX "Saved thumprint value is not correct:");
|
||||
addLog(LOG_LEVEL_INFO, thumbprint);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, F(C015_LOG_PREFIX "Saved thumprint value is not correct:"));
|
||||
addLog(LOG_LEVEL_INFO, thumbprint);
|
||||
}
|
||||
strcpy(thumbprint, CPLUGIN_015_DEFAULT_THUMBPRINT);
|
||||
addLog(LOG_LEVEL_INFO, C015_LOG_PREFIX "using default one:");
|
||||
addLog(LOG_LEVEL_INFO, thumbprint);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, F(C015_LOG_PREFIX "using default one:"));
|
||||
addLog(LOG_LEVEL_INFO, thumbprint);
|
||||
}
|
||||
}
|
||||
# endif // ifdef CPLUGIN_015_SSL
|
||||
|
||||
@@ -390,12 +398,14 @@ String Command_Blynk_Set_c015(struct EventStruct *event, const char *Line) {
|
||||
return err;
|
||||
}
|
||||
|
||||
String log = F(C015_LOG_PREFIX "(online): send blynk pin v");
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F(C015_LOG_PREFIX "(online): send blynk pin v");
|
||||
|
||||
log += vPin;
|
||||
log += F(" = ");
|
||||
log += data;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
log += vPin;
|
||||
log += F(" = ");
|
||||
log += data;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
|
||||
Blynk.virtualWrite(vPin, data);
|
||||
return return_command_success();
|
||||
|
||||
+19
-15
@@ -325,16 +325,18 @@ struct C018_data_struct {
|
||||
private:
|
||||
|
||||
void C018_logError(const String& command) const {
|
||||
String error = myLora->peekLastError();
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String error = myLora->peekLastError();
|
||||
|
||||
// String error = myLora->getLastError();
|
||||
// String error = myLora->getLastError();
|
||||
|
||||
if (error.length() > 0) {
|
||||
String log = F("RN2483: ");
|
||||
log += command;
|
||||
log += ": ";
|
||||
log += error;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (error.length() > 0) {
|
||||
String log = F("RN2483: ");
|
||||
log += command;
|
||||
log += ": ";
|
||||
log += error;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -869,14 +871,16 @@ bool C018_init(struct EventStruct *event) {
|
||||
}
|
||||
|
||||
if (customConfig->joinmethod == C018_USE_OTAA) {
|
||||
String log = F("OTAA: AppEUI: ");
|
||||
log += AppEUI;
|
||||
log += F(" AppKey: ");
|
||||
log += AppKey;
|
||||
log += F(" DevEUI: ");
|
||||
log += customConfig->DeviceEUI;
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("OTAA: AppEUI: ");
|
||||
log += AppEUI;
|
||||
log += F(" AppKey: ");
|
||||
log += AppKey;
|
||||
log += F(" DevEUI: ");
|
||||
log += customConfig->DeviceEUI;
|
||||
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
|
||||
if (!C018_data->initOTAA(AppEUI, AppKey, customConfig->DeviceEUI)) {
|
||||
return false;
|
||||
|
||||
+20
-11
@@ -96,9 +96,11 @@ boolean NPlugin_001_send(const NotificationSettingsStruct& notificationsettings,
|
||||
WiFiClient client;
|
||||
client.setTimeout(CONTROLLER_CLIENTTIMEOUT_DFLT);
|
||||
String aHost = notificationsettings.Server;
|
||||
addLog(LOG_LEVEL_DEBUG, String(F("EMAIL: Connecting to ")) + aHost + notificationsettings.Port);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG))
|
||||
addLog(LOG_LEVEL_DEBUG, String(F("EMAIL: Connecting to ")) + aHost + notificationsettings.Port);
|
||||
if (!connectClient(client, aHost.c_str(), notificationsettings.Port, CONTROLLER_CLIENTTIMEOUT_DFLT)) {
|
||||
addLog(LOG_LEVEL_ERROR, String(F("EMAIL: Error connecting to ")) + aHost + notificationsettings.Port);
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR))
|
||||
addLog(LOG_LEVEL_ERROR, String(F("EMAIL: Error connecting to ")) + aHost + notificationsettings.Port);
|
||||
myStatus = false;
|
||||
}else {
|
||||
String mailheader = F(
|
||||
@@ -154,7 +156,8 @@ boolean NPlugin_001_send(const NotificationSettingsStruct& notificationsettings,
|
||||
while (nextAddressAvailable) {
|
||||
String mailFound = F("Email: To ");
|
||||
mailFound += emailTo;
|
||||
addLog(LOG_LEVEL_INFO, mailFound);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO))
|
||||
addLog(LOG_LEVEL_INFO, mailFound);
|
||||
if (!NPlugin_001_MTA(client, String(F("RCPT TO:<")) + emailTo + ">", F("250 "))) break;
|
||||
++i;
|
||||
nextAddressAvailable = getNextMailAddress(notificationsettings.Receiver, emailTo, i);
|
||||
@@ -173,9 +176,11 @@ boolean NPlugin_001_send(const NotificationSettingsStruct& notificationsettings,
|
||||
if (myStatus == true) {
|
||||
addLog(LOG_LEVEL_INFO, F("EMAIL: Connection Closed Successfully"));
|
||||
}else {
|
||||
String log = F("EMAIL: Connection Closed With Error. Used header: ");
|
||||
log += mailheader;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
String log = F("EMAIL: Connection Closed With Error. Used header: ");
|
||||
log += mailheader;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
}
|
||||
}
|
||||
return myStatus;
|
||||
@@ -202,7 +207,8 @@ boolean NPlugin_001_Auth(WiFiClient& client, const String& user, const String& p
|
||||
|
||||
boolean NPlugin_001_MTA(WiFiClient& client, const String& aStr, const String &aWaitForPattern)
|
||||
{
|
||||
addLog(LOG_LEVEL_DEBUG, aStr);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG))
|
||||
addLog(LOG_LEVEL_DEBUG, aStr);
|
||||
|
||||
if (aStr.length()) client.println(aStr);
|
||||
|
||||
@@ -211,9 +217,11 @@ boolean NPlugin_001_MTA(WiFiClient& client, const String& aStr, const String &aW
|
||||
backgroundtasks();
|
||||
while (true) {
|
||||
if (timeOutReached(timer)) {
|
||||
String log = F("NPlugin_001_MTA: timeout. ");
|
||||
log += aStr;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
String log = F("NPlugin_001_MTA: timeout. ");
|
||||
log += aStr;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -223,7 +231,8 @@ boolean NPlugin_001_MTA(WiFiClient& client, const String& aStr, const String &aW
|
||||
String line;
|
||||
safeReadStringUntil(client, line, '\n');
|
||||
|
||||
addLog(LOG_LEVEL_DEBUG, line);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG))
|
||||
addLog(LOG_LEVEL_DEBUG, line);
|
||||
|
||||
if (line.indexOf(aWaitForPattern) >= 0) {
|
||||
return true;
|
||||
|
||||
@@ -65,9 +65,11 @@ boolean Plugin_007(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
Wire.read(); // Read older value first (stored in chip)
|
||||
UserVar[event->BaseVarIndex] = (float)Wire.read(); // now read actual value and store into Nodo var
|
||||
String log = F("PCF : Analog value: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("PCF : Analog value: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
+5
-3
@@ -144,9 +144,11 @@ boolean Plugin_008(byte function, struct EventStruct *event, String& string)
|
||||
Plugin_008_timeoutCount++;
|
||||
if (Plugin_008_timeoutCount > 5)
|
||||
{
|
||||
String log = F("RFID : reset bits: ");
|
||||
log += Plugin_008_bitCount;
|
||||
addLog(LOG_LEVEL_INFO, log );
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("RFID : reset bits: ");
|
||||
log += Plugin_008_bitCount;
|
||||
addLog(LOG_LEVEL_INFO, log );
|
||||
}
|
||||
// reset after ~5 sec
|
||||
Plugin_008_keyBuffer = 0;
|
||||
Plugin_008_bitCount = 0;
|
||||
|
||||
+5
-1
@@ -203,7 +203,11 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
|
||||
// read and store current state to prevent switching at boot time
|
||||
// "state" could be -1, 0 or 1
|
||||
newStatus.state = GPIO_MCP_Read(CONFIG_PORT);
|
||||
addLog(LOG_LEVEL_INFO,"MCP INIT="+String(newStatus.state));
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("MCP INIT=");
|
||||
log += newStatus.state;
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
}
|
||||
newStatus.output = newStatus.state;
|
||||
(newStatus.state == -1) ? newStatus.mode = PIN_MODE_OFFLINE : newStatus.mode = PIN_MODE_INPUT_PULLUP; // @giig1967g: if it is in the
|
||||
// device list we assume it's
|
||||
|
||||
@@ -123,13 +123,15 @@ boolean Plugin_010(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
if (lux != -1) {
|
||||
UserVar[event->BaseVarIndex] = lux;
|
||||
String log = F("BH1750 Address: 0x");
|
||||
log += String(address, HEX);
|
||||
log += F(" Mode: 0x");
|
||||
log += String(mode);
|
||||
log += F(" : Light intensity: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("BH1750 Address: 0x");
|
||||
log += String(address, HEX);
|
||||
log += F(" Mode: 0x");
|
||||
log += String(mode);
|
||||
log += F(" : Light intensity: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
+47
-40
@@ -170,43 +170,48 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
P_013_sensordefs[event->TaskIndex] =
|
||||
std::shared_ptr<NewPingESP8266> (new NewPingESP8266(Plugin_013_TRIG_Pin, Plugin_013_IRQ_Pin, max_distance_cm));
|
||||
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" TrigPin: ");
|
||||
log += Plugin_013_TRIG_Pin;
|
||||
log += F(" IRQ_Pin: ");
|
||||
log += Plugin_013_IRQ_Pin;
|
||||
log += F(" max dist ");
|
||||
log += (measuringUnit == UNIT_CM) ? F("[cm]: ") : F("[inch]: ");
|
||||
log += max_distance;
|
||||
log += F(" max echo: ");
|
||||
log += P_013_sensordefs[event->TaskIndex]->getMaxEchoTime();
|
||||
log += F(" Filter: ");
|
||||
if (filterType == FILTER_NONE)
|
||||
log += F("none");
|
||||
else
|
||||
if (filterType == FILTER_MEDIAN) {
|
||||
log += F("Median size: ");
|
||||
log += filterSize;
|
||||
}
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" TrigPin: ");
|
||||
log += Plugin_013_TRIG_Pin;
|
||||
log += F(" IRQ_Pin: ");
|
||||
log += Plugin_013_IRQ_Pin;
|
||||
log += F(" max dist ");
|
||||
log += (measuringUnit == UNIT_CM) ? F("[cm]: ") : F("[inch]: ");
|
||||
log += max_distance;
|
||||
log += F(" max echo: ");
|
||||
log += P_013_sensordefs[event->TaskIndex]->getMaxEchoTime();
|
||||
log += F(" Filter: ");
|
||||
if (filterType == FILTER_NONE)
|
||||
log += F("none");
|
||||
else
|
||||
log += F("invalid!");
|
||||
log += F(" nr_tasks: ");
|
||||
log += P_013_sensordefs.size();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (filterType == FILTER_MEDIAN) {
|
||||
log += F("Median size: ");
|
||||
log += filterSize;
|
||||
}
|
||||
else
|
||||
log += F("invalid!");
|
||||
log += F(" nr_tasks: ");
|
||||
log += P_013_sensordefs.size();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
|
||||
unsigned long tmpmillis = millis();
|
||||
unsigned long tmpmicros = micros();
|
||||
delay(100);
|
||||
long millispassed = timePassedSince(tmpmillis);
|
||||
long microspassed = usecPassedSince(tmpmicros);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
// FIXME TD-er: What kind of nonsense code is this?
|
||||
unsigned long tmpmillis = millis();
|
||||
unsigned long tmpmicros = micros();
|
||||
delay(100);
|
||||
long millispassed = timePassedSince(tmpmillis);
|
||||
long microspassed = usecPassedSince(tmpmicros);
|
||||
|
||||
log = F("ULTRASONIC : micros() test: ");
|
||||
log += millispassed;
|
||||
log += F(" msec, ");
|
||||
log += microspassed;
|
||||
log += F(" usec, ");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
String log = F("ULTRASONIC : micros() test: ");
|
||||
log += millispassed;
|
||||
log += F(" msec, ");
|
||||
log += microspassed;
|
||||
log += F(" usec, ");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
|
||||
success = true;
|
||||
break;
|
||||
@@ -262,11 +267,13 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
state = 1;
|
||||
if (state != switchstate[event->TaskIndex])
|
||||
{
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" state: ");
|
||||
log += state;
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" state: ");
|
||||
log += state;
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
}
|
||||
switchstate[event->TaskIndex] = state;
|
||||
UserVar[event->BaseVarIndex] = state;
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SWITCH;
|
||||
@@ -314,7 +321,7 @@ float Plugin_013_read(taskIndex_t taskIndex)
|
||||
echoTime = (P_013_sensordefs[taskIndex])->ping_median(filterSize, max_distance_cm);
|
||||
break;
|
||||
default:
|
||||
addLog(LOG_LEVEL_INFO, F("invalid Filter Type setting!"));
|
||||
addLog(LOG_LEVEL_ERROR, F("invalid Filter Type setting!"));
|
||||
}
|
||||
|
||||
if (measuringUnit == UNIT_CM)
|
||||
|
||||
@@ -152,7 +152,7 @@ struct P014_data_struct : public PluginTaskData_base {
|
||||
{
|
||||
// Still waiting for data
|
||||
// Should be handled in the loop()
|
||||
addLog(LOG_LEVEL_INFO, F("SI7021 : Read Error !"));
|
||||
addLog(LOG_LEVEL_ERROR, F("SI7021 : Read Error !"));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ struct P014_data_struct : public PluginTaskData_base {
|
||||
|
||||
// Check CRC of data received
|
||||
if (checkCRC(raw, checksum) != 0) {
|
||||
addLog(LOG_LEVEL_INFO, F("SI7021 : checksum error!"));
|
||||
addLog(LOG_LEVEL_ERROR, F("SI7021 : checksum error!"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+40
-17
@@ -172,8 +172,10 @@ boolean Plugin_016(byte function, struct EventStruct *event, String &string)
|
||||
if (irReceiver == 0 && irPin != -1)
|
||||
{
|
||||
|
||||
addLog(LOG_LEVEL_INFO, F("INIT: IR RX"));
|
||||
addLog(LOG_LEVEL_INFO, String(F("IR lib Version: ")) + _IRREMOTEESP8266_VERSION_);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, F("INIT: IR RX"));
|
||||
addLog(LOG_LEVEL_INFO, F("IR lib Version: " _IRREMOTEESP8266_VERSION_));
|
||||
}
|
||||
irReceiver = new IRrecv(irPin, kCaptureBufferSize, P016_TIMEOUT, true);
|
||||
irReceiver->setUnknownThreshold(kMinUnknownSize); // Ignore messages with less than minimum on or off pulses.
|
||||
irReceiver->enableIRIn(); // Start the receiver
|
||||
@@ -405,10 +407,14 @@ boolean Plugin_016(byte function, struct EventStruct *event, String &string)
|
||||
output += F("\",\"bits\":");
|
||||
output += uint64ToString(results.bits);
|
||||
output += '}';
|
||||
String Log = F("IRSEND,\'");
|
||||
Log += output;
|
||||
Log += "\'";
|
||||
addLog(LOG_LEVEL_INFO, Log); //JSON representation of the command
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String Log;
|
||||
Log.reserve(10 + output.length());
|
||||
Log = F("IRSEND,\'");
|
||||
Log += output;
|
||||
Log += '\'';
|
||||
addLog(LOG_LEVEL_INFO, Log); //JSON representation of the command
|
||||
}
|
||||
event->String2 = output;
|
||||
|
||||
// Check if this is a code we have a command for or we have to add
|
||||
@@ -475,8 +481,16 @@ boolean Plugin_016(byte function, struct EventStruct *event, String &string)
|
||||
state.clock = -1;
|
||||
|
||||
String description = IRAcUtils::resultAcToString(&results);
|
||||
if (description != "")
|
||||
addLog(LOG_LEVEL_INFO, String(F("AC State: ")) + description); // If we got a human-readable description of the message, display it.
|
||||
if (description != "") {
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
// If we got a human-readable description of the message, display it.
|
||||
String log;
|
||||
log.reserve(10 + description.length());
|
||||
log = F("AC State: ");
|
||||
log += description;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
}
|
||||
if (IRac::isProtocolSupported(results.decode_type)) //Check If there is a replayable AC state and show the JSON command that can be send
|
||||
{
|
||||
IRAcUtils::decodeToState(&results, &state);
|
||||
@@ -517,7 +531,15 @@ boolean Plugin_016(byte function, struct EventStruct *event, String &string)
|
||||
output="";
|
||||
serializeJson(doc, output);
|
||||
event->String2 = output;
|
||||
addLog(LOG_LEVEL_INFO, String(F("IRSENDAC,'")) + output+ '\''); //Show the command that the user can put to replay the AC state with P035
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
//Show the command that the user can put to replay the AC state with P035
|
||||
String log;
|
||||
log.reserve(12 + output.length());
|
||||
log = F("IRSENDAC,'");
|
||||
log += output;
|
||||
log += '\'';
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
}
|
||||
#endif // P016_P035_Extended_AC
|
||||
if (P016_SEND_IR_TO_CONTROLLER) sendData(event);
|
||||
@@ -674,14 +696,15 @@ boolean displayRawToReadableB32Hex(String &outputStr, decode_results results)
|
||||
iOut = storeB32Hex(out, iOut, tmOut[d++]);
|
||||
|
||||
out[iOut] = 0;
|
||||
String line = F("IRSEND,RAW2,");
|
||||
line += out;
|
||||
line += F(",38,");
|
||||
line += uint64ToString(div[0], 10);
|
||||
line += ',';
|
||||
line += uint64ToString(div[1], 10);
|
||||
addLog(LOG_LEVEL_INFO, line);
|
||||
outputStr = line;
|
||||
|
||||
outputStr.reserve(32 + iOut);
|
||||
outputStr = F("IRSEND,RAW2,");
|
||||
outputStr += out;
|
||||
outputStr += F(",38,");
|
||||
outputStr += uint64ToString(div[0], 10);
|
||||
outputStr += ',';
|
||||
outputStr += uint64ToString(div[1], 10);
|
||||
addLog(LOG_LEVEL_INFO, outputStr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+19
-13
@@ -158,9 +158,11 @@ boolean Plugin_017(byte function, struct EventStruct *event, String& string)
|
||||
if (error == 1)
|
||||
{
|
||||
errorCount++;
|
||||
String log = F("PN532: Read error: ");
|
||||
log += errorCount;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
String log = F("PN532: Read error: ");
|
||||
log += errorCount;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
}
|
||||
else {
|
||||
errorCount = 0;
|
||||
@@ -221,9 +223,11 @@ boolean Plugin_017_Init(int8_t resetPin)
|
||||
{
|
||||
if (resetPin != -1)
|
||||
{
|
||||
String log = F("PN532: Reset on pin: ");
|
||||
log += resetPin;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("PN532: Reset on pin: ");
|
||||
log += resetPin;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
pinMode(resetPin, OUTPUT);
|
||||
digitalWrite(resetPin, LOW);
|
||||
delay(100);
|
||||
@@ -239,13 +243,15 @@ boolean Plugin_017_Init(int8_t resetPin)
|
||||
uint32_t versiondata = getFirmwareVersion();
|
||||
|
||||
if (versiondata) {
|
||||
String log = F("PN532: Found chip PN5");
|
||||
log += String((versiondata >> 24) & 0xFF, HEX);
|
||||
log += F(" FW: ");
|
||||
log += String((versiondata >> 16) & 0xFF, HEX);
|
||||
log += '.';
|
||||
log += String((versiondata >> 8) & 0xFF, HEX);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("PN532: Found chip PN5");
|
||||
log += String((versiondata >> 24) & 0xFF, HEX);
|
||||
log += F(" FW: ");
|
||||
log += String((versiondata >> 16) & 0xFF, HEX);
|
||||
log += '.';
|
||||
log += String((versiondata >> 8) & 0xFF, HEX);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
+5
-3
@@ -84,9 +84,11 @@ boolean Plugin_018(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
interrupts();
|
||||
UserVar[event->BaseVarIndex] = (float)value;
|
||||
String log = F("GPY : Dust value: ");
|
||||
log += value;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("GPY : Dust value: ");
|
||||
log += value;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
+5
-3
@@ -133,9 +133,11 @@ boolean Plugin_021(byte function, struct EventStruct *event, String& string)
|
||||
state = 0;
|
||||
if (state != switchstate[event->TaskIndex])
|
||||
{
|
||||
String log = F("LEVEL: State ");
|
||||
log += state;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("LEVEL: State ");
|
||||
log += state;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
switchstate[event->TaskIndex] = state;
|
||||
digitalWrite(CONFIG_PIN1,state);
|
||||
UserVar[event->BaseVarIndex] = state;
|
||||
|
||||
+11
-3
@@ -208,6 +208,8 @@ boolean Plugin_022(byte function, struct EventStruct *event, String& string)
|
||||
if ((command == F("pcapwm")) || (instanceCommand && (command == F("pwm"))))
|
||||
{
|
||||
success = true;
|
||||
|
||||
// "log" is also sent along with the SendStatusOnlyIfNeeded
|
||||
log = F("PCA 0x");
|
||||
log += String(address, HEX);
|
||||
log += F(": PWM ");
|
||||
@@ -236,17 +238,23 @@ boolean Plugin_022(byte function, struct EventStruct *event, String& string)
|
||||
newStatus.state = event->Par2;
|
||||
savePortStatus(key, newStatus);
|
||||
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
|
||||
// SendStatus(event, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_022, event->Par1, log, 0));
|
||||
SendStatusOnlyIfNeeded(event, SEARCH_PIN_STATE, key, log, 0);
|
||||
}
|
||||
else {
|
||||
addLog(LOG_LEVEL_ERROR, log + F(" the pwm value ") + String(event->Par2) + F(" is invalid value."));
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
addLog(LOG_LEVEL_ERROR, log + F(" the pwm value ") + String(event->Par2) + F(" is invalid value."));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
addLog(LOG_LEVEL_ERROR, log + F(" is invalid value."));
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
addLog(LOG_LEVEL_ERROR, log + F(" is invalid value."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-6
@@ -165,9 +165,13 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
if (nullptr != P025_data) {
|
||||
const int16_t value = P025_data->read();
|
||||
String log = F("ADS1115 : Analog value: ");
|
||||
UserVar[event->BaseVarIndex] = (float)value;
|
||||
log += value;
|
||||
|
||||
String log;
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
log = F("ADS1115 : Analog value: ");
|
||||
log += value;
|
||||
}
|
||||
|
||||
if (PCONFIG(3)) // Calibration?
|
||||
{
|
||||
@@ -180,15 +184,18 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
float normalized = (float)(value - adc1) / (float)(adc2 - adc1);
|
||||
UserVar[event->BaseVarIndex] = normalized * (out2 - out1) + out1;
|
||||
|
||||
log += ' ';
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
log += ' ';
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TEST log += F(" @0x");
|
||||
// TEST log += String(config, 16);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -162,7 +162,9 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("SYS : ");
|
||||
String log;
|
||||
log.reserve(7 * (P026_NR_OUTPUT_VALUES + 1));
|
||||
log = F("SYS : ");
|
||||
|
||||
for (int i = 0; i < P026_NR_OUTPUT_VALUES; ++i) {
|
||||
if (i != 0) {
|
||||
|
||||
+43
-23
@@ -102,32 +102,40 @@ boolean Plugin_027(byte function, struct EventStruct *event, String& string)
|
||||
static_cast<P027_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr != P027_data) {
|
||||
String log = F("INA219 0x");
|
||||
log += String(i2caddr, HEX);
|
||||
log += F(" setting Range to: ");
|
||||
const bool mustLog = loglevelActiveFor(LOG_LEVEL_INFO);
|
||||
String log;
|
||||
if (mustLog) {
|
||||
log = F("INA219 0x");
|
||||
log += String(i2caddr, HEX);
|
||||
log += F(" setting Range to: ");
|
||||
}
|
||||
|
||||
switch (PCONFIG(0))
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
log += F("32V, 2A");
|
||||
if (mustLog)
|
||||
log += F("32V, 2A");
|
||||
P027_data->setCalibration_32V_2A();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
log += F("32V, 1A");
|
||||
if (mustLog)
|
||||
log += F("32V, 1A");
|
||||
P027_data->setCalibration_32V_1A();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
log += F("16V, 400mA");
|
||||
if (mustLog)
|
||||
log += F("16V, 400mA");
|
||||
P027_data->setCalibration_16V_400mA();
|
||||
break;
|
||||
}
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (mustLog)
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
@@ -151,8 +159,12 @@ boolean Plugin_027(byte function, struct EventStruct *event, String& string)
|
||||
UserVar[event->BaseVarIndex + 1] = current;
|
||||
UserVar[event->BaseVarIndex + 2] = power;
|
||||
|
||||
String log = F("INA219 0x");
|
||||
log += String(P027_I2C_ADDR, HEX);
|
||||
const bool mustLog = loglevelActiveFor(LOG_LEVEL_INFO);
|
||||
String log;
|
||||
if (mustLog) {
|
||||
log = F("INA219 0x");
|
||||
log += String(P027_I2C_ADDR, HEX);
|
||||
}
|
||||
|
||||
// for backward compability we allow the user to select if only one measurement should be returned
|
||||
// or all 3 measurement at once
|
||||
@@ -162,24 +174,30 @@ boolean Plugin_027(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SINGLE;
|
||||
UserVar[event->BaseVarIndex] = voltage;
|
||||
log += F(": Voltage: ");
|
||||
log += voltage;
|
||||
if (mustLog) {
|
||||
log += F(": Voltage: ");
|
||||
log += voltage;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SINGLE;
|
||||
UserVar[event->BaseVarIndex] = current;
|
||||
log += F(" Current: ");
|
||||
log += current;
|
||||
if (mustLog) {
|
||||
log += F(" Current: ");
|
||||
log += current;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SINGLE;
|
||||
UserVar[event->BaseVarIndex] = power;
|
||||
log += F(" Power: ");
|
||||
log += power;
|
||||
if (mustLog) {
|
||||
log += F(" Power: ");
|
||||
log += power;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
@@ -188,17 +206,19 @@ boolean Plugin_027(byte function, struct EventStruct *event, String& string)
|
||||
UserVar[event->BaseVarIndex] = voltage;
|
||||
UserVar[event->BaseVarIndex + 1] = current;
|
||||
UserVar[event->BaseVarIndex + 2] = power;
|
||||
log += F(": Voltage: ");
|
||||
log += voltage;
|
||||
log += F(" Current: ");
|
||||
log += current;
|
||||
log += F(" Power: ");
|
||||
log += power;
|
||||
if (mustLog) {
|
||||
log += F(": Voltage: ");
|
||||
log += voltage;
|
||||
log += F(" Current: ");
|
||||
log += current;
|
||||
log += F(" Power: ");
|
||||
log += power;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (mustLog)
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
+11
-9
@@ -368,15 +368,17 @@ boolean Plugin_031(byte function, struct EventStruct *event, String& string)
|
||||
P031_data->startMeasurement();
|
||||
} else if (P031_data->hasError()) {
|
||||
// Log error
|
||||
switch (P031_data->state) {
|
||||
case P031_COMMAND_NO_ACK:
|
||||
addLog(LOG_LEVEL_ERROR, F("SHT1X : Sensor did not ACK command"));
|
||||
break;
|
||||
case P031_NO_DATA:
|
||||
addLog(LOG_LEVEL_ERROR, F("SHT1X : Data not ready"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
switch (P031_data->state) {
|
||||
case P031_COMMAND_NO_ACK:
|
||||
addLog(LOG_LEVEL_ERROR, F("SHT1X : Sensor did not ACK command"));
|
||||
break;
|
||||
case P031_NO_DATA:
|
||||
addLog(LOG_LEVEL_ERROR, F("SHT1X : Data not ready"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
P031_data->state = P031_IDLE;
|
||||
}
|
||||
|
||||
+13
-7
@@ -101,9 +101,11 @@ boolean Plugin_035(byte function, struct EventStruct *event, String &command)
|
||||
int irPin = CONFIG_PIN1;
|
||||
if (Plugin_035_irSender == 0 && irPin != -1)
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO, F("INIT: IR TX"));
|
||||
addLog(LOG_LEVEL_INFO, String(F("IR lib Version: ")) + _IRREMOTEESP8266_VERSION_);
|
||||
addLog(LOG_LEVEL_INFO, String(F("Supported Protocols by IRSEND: ")) + listProtocols());
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, F("INIT: IR TX"));
|
||||
addLog(LOG_LEVEL_INFO, F("IR lib Version: " _IRREMOTEESP8266_VERSION_));
|
||||
addLog(LOG_LEVEL_INFO, String(F("Supported Protocols by IRSEND: ")) + listProtocols());
|
||||
}
|
||||
Plugin_035_irSender = new IRsend(irPin);
|
||||
Plugin_035_irSender->begin(); // Start the sender
|
||||
}
|
||||
@@ -117,8 +119,10 @@ boolean Plugin_035(byte function, struct EventStruct *event, String &command)
|
||||
#ifdef P016_P035_Extended_AC
|
||||
if (Plugin_035_commonAc == nullptr && irPin != -1)
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO, F("INIT AC: IR TX"));
|
||||
addLog(LOG_LEVEL_INFO, String(F("Supported Protocols by IRSENDAC: ")) + listACProtocols());
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, F("INIT AC: IR TX"));
|
||||
addLog(LOG_LEVEL_INFO, String(F("Supported Protocols by IRSENDAC: ")) + listACProtocols());
|
||||
}
|
||||
Plugin_035_commonAc = new (std::nothrow) IRac(irPin);
|
||||
}
|
||||
if (Plugin_035_commonAc != nullptr && irPin == -1)
|
||||
@@ -209,14 +213,16 @@ bool handle_AC_IRremote(const String &irData) {
|
||||
DeserializationError error = deserializeJson(doc, irData); // Deserialize the JSON document
|
||||
if (error) // Test if parsing succeeds.
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO, String(F("IRTX: Deserialize Json failed: ")) + error.c_str());
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO))
|
||||
addLog(LOG_LEVEL_INFO, String(F("IRTX: Deserialize Json failed: ")) + error.c_str());
|
||||
return false; //do not continue with sending the signal.
|
||||
}
|
||||
String sprotocol = doc[F("protocol")];
|
||||
st.protocol = strToDecodeType(sprotocol.c_str());
|
||||
if (!IRac::isProtocolSupported(st.protocol)) //Check if we support the protocol
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO, String(F("IRTX: Protocol not supported:")) + sprotocol);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO))
|
||||
addLog(LOG_LEVEL_INFO, String(F("IRTX: Protocol not supported:")) + sprotocol);
|
||||
return false; //do not continue with sending of the signal.
|
||||
}
|
||||
|
||||
|
||||
@@ -163,14 +163,18 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string)
|
||||
// FIXME TD-er: It may be useful to generate events with string values.
|
||||
float floatPayload;
|
||||
if (!string2float(event->String2, floatPayload)) {
|
||||
String log = F("IMPT : Bad Import MQTT Command ");
|
||||
log += event->String1;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
log = F("ERR : Illegal Payload ");
|
||||
log += event->String2;
|
||||
log += ' ';
|
||||
log += getTaskDeviceName(event->TaskIndex);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
String log = F("IMPT : Bad Import MQTT Command ");
|
||||
log += event->String1;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("ERR : Illegal Payload ");
|
||||
log += event->String2;
|
||||
log += ' ';
|
||||
log += getTaskDeviceName(event->TaskIndex);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
@@ -245,8 +249,8 @@ bool MQTTSubscribe_037(struct EventStruct *event)
|
||||
String log = F("IMPT : Error subscribing to ");
|
||||
log += subscribeTo;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-16
@@ -277,9 +277,14 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
|
||||
SetPixelsBlack();
|
||||
Candle_pixels->setBrightness(Candle_bright);
|
||||
Candle_pixels->begin();
|
||||
String log = F("CAND : Init WS2812 Pin : ");
|
||||
log += CONFIG_PIN1;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("CAND : Init WS2812 Pin : ");
|
||||
log += CONFIG_PIN1;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
success = true;
|
||||
@@ -408,9 +413,13 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
|
||||
if (val_Type.toInt() > -1 && val_Type.toInt() < 8) {
|
||||
PCONFIG(4) = val_Type.toInt(); // Type
|
||||
Candle_type = (SimType)PCONFIG(4);
|
||||
String log = F("CAND : CMD - Type : ");
|
||||
log += val_Type;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("CAND : CMD - Type : ");
|
||||
log += val_Type;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,9 +427,13 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
|
||||
if (val_Bright.toInt() > -1 && val_Bright.toInt() < 256) {
|
||||
PCONFIG(3) = val_Bright.toInt(); // Brightness
|
||||
Candle_bright = PCONFIG(3);
|
||||
String log = F("CAND : CMD - Bright : ");
|
||||
log += val_Bright;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("CAND : CMD - Bright : ");
|
||||
log += val_Bright;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,17 +453,23 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
|
||||
PCONFIG(5) = 1;
|
||||
Candle_color = (ColorType)PCONFIG(5); // ColorType (ColorSelected)
|
||||
|
||||
String log = F("CAND : CMD - R ");
|
||||
log += r;
|
||||
log += F(" G ");
|
||||
log += g;
|
||||
log += F(" B ");
|
||||
log += b;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("CAND : CMD - R ");
|
||||
log += r;
|
||||
log += F(" G ");
|
||||
log += g;
|
||||
log += F(" B ");
|
||||
log += b;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
PCONFIG(5) = 0;
|
||||
Candle_color = (ColorType)PCONFIG(5); // ColorType (ColorDefault)
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
addLog(LOG_LEVEL_DEBUG, F("CAND : CMD - Color : DEFAULT"));
|
||||
#endif
|
||||
}
|
||||
|
||||
//SaveTaskSettings(event->TaskIndex);
|
||||
|
||||
@@ -118,9 +118,11 @@ boolean Plugin_043(byte function, struct EventStruct *event, String& string)
|
||||
pinMode(CONFIG_PIN1, OUTPUT);
|
||||
digitalWrite(CONFIG_PIN1, state);
|
||||
UserVar[event->BaseVarIndex] = state;
|
||||
String log = F("TCLK : State ");
|
||||
log += state;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("TCLK : State ");
|
||||
log += state;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
sendData(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,10 +127,14 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
task->blinkLED();
|
||||
if (P044_BAUDRATE == 115200) {
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
addLog(LOG_LEVEL_DEBUG, F("P1 : DSMR version 4 meter, CRC on"));
|
||||
#endif
|
||||
task->CRCcheck = true;
|
||||
} else {
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
addLog(LOG_LEVEL_DEBUG, F("P1 : DSMR version 4 meter, CRC off"));
|
||||
#endif
|
||||
task->CRCcheck = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,9 @@ boolean Plugin_047(byte function, struct EventStruct *event, String& string)
|
||||
// wake sensor
|
||||
Plugin_047_getVersion(P047_I2C_ADDR);
|
||||
delayBackground(20);
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
addLog(LOG_LEVEL_DEBUG, F("SoilMoisture->wake"));
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t sensorVersion = 0;
|
||||
@@ -149,8 +151,10 @@ boolean Plugin_047(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
// check if we want to change the sensor address
|
||||
if (P047_CHANGE_ADDR) {
|
||||
addLog(LOG_LEVEL_INFO, String(F("SoilMoisture: Change Address: 0x")) + String(P047_I2C_ADDR, HEX) + String(F("->0x")) +
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, String(F("SoilMoisture: Change Address: 0x")) + String(P047_I2C_ADDR, HEX) + String(F("->0x")) +
|
||||
String(P047_NEW_ADDR, HEX));
|
||||
}
|
||||
|
||||
if (Plugin_047_setAddress(P047_I2C_ADDR, P047_NEW_ADDR)) {
|
||||
P047_I2C_ADDR = P047_NEW_ADDR;
|
||||
@@ -179,28 +183,32 @@ boolean Plugin_047(byte function, struct EventStruct *event, String& string)
|
||||
UserVar[event->BaseVarIndex + 1] = moisture;
|
||||
UserVar[event->BaseVarIndex + 2] = light;
|
||||
|
||||
String log = F("SoilMoisture: Address: 0x");
|
||||
log += String(P047_I2C_ADDR, HEX);
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("SoilMoisture: Address: 0x");
|
||||
log += String(P047_I2C_ADDR, HEX);
|
||||
|
||||
if (P047_CHECK_VERSION) {
|
||||
log += F(" Version: 0x");
|
||||
log += String(sensorVersion, HEX);
|
||||
if (P047_CHECK_VERSION) {
|
||||
log += F(" Version: 0x");
|
||||
log += String(sensorVersion, HEX);
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
log = F("SoilMoisture: Temperature: ");
|
||||
log += temperature;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
log = F("SoilMoisture: Moisture: ");
|
||||
log += moisture;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
log = F("SoilMoisture: Light: ");
|
||||
log += light;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
log = F("SoilMoisture: Temperature: ");
|
||||
log += temperature;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
log = F("SoilMoisture: Moisture: ");
|
||||
log += moisture;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
log = F("SoilMoisture: Light: ");
|
||||
log += light;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
if (P047_SENSOR_SLEEP) {
|
||||
// send sensor to sleep
|
||||
I2C_write8(P047_I2C_ADDR, SOILMOISTURESENSOR_SLEEP);
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
addLog(LOG_LEVEL_DEBUG, F("SoilMoisture->sleep"));
|
||||
#endif
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
|
||||
@@ -128,9 +128,13 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) {
|
||||
|
||||
// Create the motor shield object with the default I2C address
|
||||
AFMS = Adafruit_MotorShield(Plugin_048_MotorShield_address);
|
||||
String log = F("MotorShield: Address: 0x");
|
||||
log += String(Plugin_048_MotorShield_address, HEX);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("MotorShield: Address: 0x");
|
||||
log += String(Plugin_048_MotorShield_address, HEX);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (param1.equalsIgnoreCase(F("DCMotor"))) {
|
||||
if (param2_is_int && (p2_int > 0) && (p2_int < 5))
|
||||
@@ -206,6 +210,7 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) {
|
||||
myStepper = AFMS.getStepper(Plugin_048_MotorStepsPerRevolution, p2_int);
|
||||
myStepper->setSpeed(Plugin_048_StepperSpeed);
|
||||
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE)) {
|
||||
String log = F("MotorShield: StepsPerRevolution: ");
|
||||
log += String(Plugin_048_MotorStepsPerRevolution);
|
||||
@@ -213,6 +218,7 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) {
|
||||
log += String(Plugin_048_StepperSpeed);
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (param3.equalsIgnoreCase(F("Forward")))
|
||||
{
|
||||
|
||||
+20
-13
@@ -570,18 +570,23 @@ boolean Plugin_049(byte function, struct EventStruct *event, String& string)
|
||||
float u = 0;
|
||||
|
||||
if (P049_data->read_ppm(ppm, temp, s, u)) {
|
||||
String log = F("MHZ19: ");
|
||||
const bool mustLog = loglevelActiveFor(LOG_LEVEL_INFO);
|
||||
String log;
|
||||
if (mustLog)
|
||||
log = F("MHZ19: ");
|
||||
|
||||
// During (and only ever at) sensor boot, 'u' is reported as 15000
|
||||
// We log but don't process readings during that time
|
||||
if (approximatelyEqual(u, 15000)) {
|
||||
log += F("Bootup detected! ");
|
||||
if (mustLog)
|
||||
log += F("Bootup detected! ");
|
||||
|
||||
if (P049_data->ABC_Disable) {
|
||||
// After bootup of the sensor the ABC will be enabled.
|
||||
// Thus only actively disable after bootup.
|
||||
P049_data->ABC_MustApply = true;
|
||||
log += F("Will disable ABC when bootup complete. ");
|
||||
if (mustLog)
|
||||
log += F("Will disable ABC when bootup complete. ");
|
||||
}
|
||||
success = false;
|
||||
|
||||
@@ -614,16 +619,18 @@ boolean Plugin_049(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
}
|
||||
|
||||
// Log values in all cases
|
||||
log += F("PPM value: ");
|
||||
log += ppm;
|
||||
log += F(" Temp/S/U values: ");
|
||||
log += temp;
|
||||
log += '/';
|
||||
log += s;
|
||||
log += '/';
|
||||
log += u;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (mustLog) {
|
||||
// Log values in all cases
|
||||
log += F("PPM value: ");
|
||||
log += ppm;
|
||||
log += F(" Temp/S/U values: ");
|
||||
log += temp;
|
||||
log += '/';
|
||||
log += s;
|
||||
log += '/';
|
||||
log += u;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
break;
|
||||
|
||||
// #ifdef ENABLE_DETECTION_RANGE_COMMANDS
|
||||
|
||||
+22
-20
@@ -334,27 +334,29 @@ boolean Plugin_050(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
UserVar[event->BaseVarIndex + 3] = value4;
|
||||
|
||||
String log = F("TCS34725: ");
|
||||
switch (PCONFIG(3)) {
|
||||
case 0:
|
||||
case 1:
|
||||
log += F("Color Temp (K): ");
|
||||
break;
|
||||
case 2:
|
||||
log += F("Lux : ");
|
||||
break;
|
||||
case 3:
|
||||
log += F("Clear : ");
|
||||
break;
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("TCS34725: ");
|
||||
switch (PCONFIG(3)) {
|
||||
case 0:
|
||||
case 1:
|
||||
log += F("Color Temp (K): ");
|
||||
break;
|
||||
case 2:
|
||||
log += F("Lux : ");
|
||||
break;
|
||||
case 3:
|
||||
log += F("Clear : ");
|
||||
break;
|
||||
}
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 3);
|
||||
log += F(" R: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
log += F(" G: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 1);
|
||||
log += F(" B: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 2);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 3);
|
||||
log += F(" R: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
log += F(" G: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 1);
|
||||
log += F(" B: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 2);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
#ifdef P050_OPTION_RGB_EVENTS
|
||||
// First RGB events
|
||||
|
||||
Reference in New Issue
Block a user