Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into feature/taskvalueset_by_name

This commit is contained in:
Ton Huisman
2021-01-09 11:59:10 +01:00
3 changed files with 42 additions and 11 deletions
+11 -2
View File
@@ -26,13 +26,22 @@ Description
The Wiegand plugin reads the Wiegand protocol, either the 26 or 34 bit variant, transmitted over a 2-wire serial connection. The RFID reader or keypad has to be connected to two GPIO pins on the ESP module. The plugin uses an interrupt routine to decode the bitstream. A RFID reader will send a message containing the unique RFID Tag ID. A keypad will send the input after pressing the #, or another configured, confirmation key.
Data is transmitted in hexadecimal format.
For numeric keypads an option is provided to transform the hex value into a decimal representation, so that when entering value 1234# (# is the confirmation key here), not the result 4660 (0x1234) is made available, but actually 1234. This for easier processing/validating of the entered value. Any input of A-F is replaced by 0 when this option is enabled! It should not be enabled when using a RFID reader, as the Tag ID won't be correct.
Data is transmitted in hexadecimal format. (See below for an option to transform to decimal when using a decimal numeric keypad.)
The value is placed in the Tag variable (this name can be changed).
.. image:: P008_Settings.png
**Present hex as decimal value** (Disabled by default) For decimal numeric keypads this option is provided to transform the hex value into a decimal representation, so that when entering value 1234# (# is the confirmation key here), not the result 4660 (0x1234) is made available, but actually 1234. This for easier processing/validating of the entered value. Any input of A-F is replaced by 0 when this option is enabled! It should not be enabled when using a RFID reader, as the Tag ID won't be correct!
**Automatic Tag removal** (Enabled by default) after scanning a tag, it can be automatically removed (reset).
**Automatic Tag removal after** (Default 500 mSec) The timeout in milli seconds (range 250 - 60000) after which the last Tag will be automatically removed, if that option is enabled.
**Value to set on Tag removal** (Default 0) Set a value to the Tag when the previous tag is removed. (Range 0 to 2147483647 as larger values are difficult to store in settings.)
**Event on Tag removal** (Disabled by default) When enabled sends the removed Tag value as an event and to all enabled controllers.
Supported hardware
------------------
Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 26 KiB

+31 -9
View File
@@ -106,13 +106,15 @@ boolean Plugin_008(byte function, struct EventStruct *event, String& string)
case PLUGIN_TIMER_IN:
{
if (Plugin_008_init) {
// Reset card id on timeout
UserVar[event->BaseVarIndex] = 0;
UserVar[event->BaseVarIndex + 1] = 0;
addLog(LOG_LEVEL_INFO, F("RFID : Removed Tag"));
if (Plugin_008_init && PCONFIG(2) == 0) { // PCONFIG(2) check uses inversed logic!
// Reset card id on timeout
UserVar[event->BaseVarIndex] = PCONFIG_LONG(0) & 0xFFFF;
UserVar[event->BaseVarIndex + 1] = (PCONFIG_LONG(0) >> 16) & 0xFFFF;
addLog(LOG_LEVEL_INFO, F("RFID : Removed Tag"));
if (PCONFIG(3) == 1) {
sendData(event);
success = true;
}
success = true;
}
break;
}
@@ -185,7 +187,9 @@ boolean Plugin_008(byte function, struct EventStruct *event, String& string)
Plugin_008_timeoutCount = 0;
if (new_key) sendData(event);
Scheduler.setPluginTaskTimer(500, event->TaskIndex, event->Par1);
uint32_t resetTimer = PCONFIG_LONG(1);
if (resetTimer < 500) resetTimer = 500;
Scheduler.setPluginTaskTimer(resetTimer, event->TaskIndex, event->Par1);
// String info = "";
// uint64_t invalue = 0x1234;
@@ -213,14 +217,32 @@ boolean Plugin_008(byte function, struct EventStruct *event, String& string)
bool presentHexToDec = PCONFIG(1) == 1;
addFormCheckBox(F("Present hex as decimal value"), F("p008_hexasdec"), presentHexToDec);
addFormNote(F("Useful only for numeric keypad input!"));
bool autoTagRemoval = PCONFIG(2) == 0; // Inverted state!
addFormCheckBox(F("Automatic Tag removal"), F("p008_autotagremoval"), autoTagRemoval);
if (PCONFIG_LONG(1) == 0) PCONFIG_LONG(1) = 500; // Defaulty 500 mSec (was hardcoded value)
addFormNumericBox(F("Automatic Tag removal after"),F("p008_removaltimeout"), PCONFIG_LONG(1), 250, 60000); // 0.25 to 60 seconds
addUnit(F("mSec."));
addFormNumericBox(F("Value to set on Tag removal"),F("p008_removalvalue"), PCONFIG_LONG(0), 0, 2147483647); // Max allowed is int = 0x7FFFFFFF ...
bool eventOnRemoval = PCONFIG(3) == 1; // Normal state!
addFormCheckBox(F("Event on Tag removal"), F("p008_sendreset"), eventOnRemoval);
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
PCONFIG(0) = getFormItemInt(F("p008_type"));
PCONFIG(1) = isFormItemChecked(F("p008_hexasdec")) ? 1 : 0;
PCONFIG(0) = getFormItemInt(F("p008_type"));
PCONFIG(1) = isFormItemChecked(F("p008_hexasdec")) ? 1 : 0;
PCONFIG(2) = isFormItemChecked(F("p008_autotagremoval")) ? 0 : 1; // Inverted logic!
PCONFIG(3) = isFormItemChecked(F("p008_sendreset")) ? 1 : 0;
PCONFIG_LONG(0) = getFormItemInt(F("p008_removalvalue"));
PCONFIG_LONG(1) = getFormItemInt(F("p008_removaltimeout"));
success = true;
break;
}