Skip to content

Commit

Permalink
Make RDM6300 on software serial configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
matjack1 committed Sep 21, 2024
1 parent 3a6c37e commit 69ba0b3
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 35 deletions.
6 changes: 4 additions & 2 deletions src/config.esp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ bool ICACHE_FLASH_ATTR loadConfiguration(Config &config)
rfidss = hardware["sspin"];
setupPN532Reader(rfidss);
}
else if (config.readertype > READER_PN532)
// RDM6300 can be configured alongside the other readers
if (config.readertype > READER_PN532)
{
setupRDM6300Reader();
int rmd6300TxPin = hardware["rdm6300pin"];
setupRDM6300Reader(rmd6300TxPin);
}

if (network.containsKey("fallbackmode"))
Expand Down
1 change: 0 additions & 1 deletion src/magicnumbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#define RDM6300_BAUDRATE 9600
#define RDM6300_READ_TIMEOUT 20
#define RDM6300_RX_PIN 4

// hardware defines

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MFRC522 mfrc522 = MFRC522();
PN532 pn532;
WIEGAND wg;
RFID_Reader RFIDr;
SoftwareSerial *rdm6300_sw_serial = NULL;
SoftwareSerial *rdm6300SwSerial = NULL;

// relay specific variables
bool activateRelay[MAX_NUM_RELAYS] = {false, false, false, false};
Expand Down
15 changes: 8 additions & 7 deletions src/rfid.esp
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ void pn532Read()
*/
void genericRead()
{
while (rdm6300_sw_serial->available() > 0)
while (rdm6300SwSerial->available() > 0)
{
RFIDr.rfidSerial(rdm6300_sw_serial->read());
char read = rdm6300SwSerial->read();
RFIDr.rfidSerial(read);
}
if (RFIDr.Available())
{
Expand Down Expand Up @@ -682,9 +683,9 @@ void ICACHE_FLASH_ATTR setupPN532Reader(int rfidss)
} while (false);
}

void ICACHE_FLASH_ATTR setupRDM6300Reader()
void ICACHE_FLASH_ATTR setupRDM6300Reader(int rmd6300TxPin)
{
rdm6300_sw_serial = new SoftwareSerial(RDM6300_RX_PIN, -1);
rdm6300_sw_serial->begin(RDM6300_BAUDRATE);
rdm6300_sw_serial->setTimeout(RDM6300_READ_TIMEOUT);
}
rdm6300SwSerial = new SoftwareSerial(rmd6300TxPin, -1);
rdm6300SwSerial->begin(RDM6300_BAUDRATE);
rdm6300SwSerial->setTimeout(RDM6300_READ_TIMEOUT);
}
18 changes: 9 additions & 9 deletions src/webh/esprfid.htm.gz.h

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/webh/esprfid.js.gz.h

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/websrc/esprfid.htm
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,25 @@ <h6 class="text-muted">Please refer the <a href="https://github.com/esprfid/esp-
</span>
</div>
</div>
<div class="" id="rdm6300" style="display:none">
<div class="row form-group">
<label class="col-xs-3">RDM6300 TX pin<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign" aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right" data-content="Choose which ESP pin is connected to RDM6300 TX pin"></i></label>
<span class="col-xs-9 col-md-5">
<select class="form-control input-sm" id="rdm6300pin">
<option value="0">GPIO-0</option>
<option value="1">GPIO-1</option>
<option value="2">GPIO-2</option>
<option selected="selected" value="4">GPIO-4</option>
<option value="5">GPIO-5</option>
<option value="12">GPIO-12</option>
<option value="13">GPIO-13</option>
<option value="14">GPIO-14</option>
<option value="15">GPIO-15</option>
<option value="16">GPIO-16</option>
</select>
</span>
</div>
</div>
<div class="" id="mfrc522Form" style="display:none">
<div class="row form-group">
<label class="col-xs-3">SPI SS<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign" aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right" data-content="Choose which ESP port is connected to RFID Hardware SDA pin"></i></label>
Expand Down
28 changes: 25 additions & 3 deletions src/websrc/js/esprfid.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var config = {
"readertype": 1,
"wgd0pin": 4,
"wgd1pin": 5,
"rdm6300pin": 4,
"sspin": 0,
"rfidgain": 32,
"wifipin": 255,
Expand Down Expand Up @@ -149,21 +150,40 @@ function syncBrowserTime() {

function handleReader() {
var rType = parseInt(document.getElementById("readertype").value);
if (rType === 0 || rType === 4) {
if (rType === 0) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "block";
document.getElementById("rc522gain").style.display = "block";
} else if (rType === 1 || rType === 5) {
document.getElementById("rdm6300").style.display = "none";
} else if (rType === 1) {
document.getElementById("wiegandForm").style.display = "block";
document.getElementById("mfrc522Form").style.display = "none";
} else if (rType === 2 || rType === 6) {
document.getElementById("rdm6300").style.display = "none";
} else if (rType === 2) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "block";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "none";
} else if (rType === 3) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "none";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "block";
} else if (rType === 4) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "block";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "block";
} else if (rType === 5) {
document.getElementById("wiegandForm").style.display = "block";
document.getElementById("mfrc522Form").style.display = "none";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "block";
} else if (rType === 6) {
document.getElementById("wiegandForm").style.display = "none";
document.getElementById("mfrc522Form").style.display = "block";
document.getElementById("rc522gain").style.display = "none";
document.getElementById("rdm6300").style.display = "block";
}
}

Expand Down Expand Up @@ -197,6 +217,7 @@ function listhardware() {
document.getElementById("readertype").value = config.hardware.readertype;
document.getElementById("wg0pin").value = config.hardware.wgd0pin;
document.getElementById("wg1pin").value = config.hardware.wgd1pin;
document.getElementById("rdm6300pin").value = config.hardware.rdm6300pin;
document.getElementById("gpioss").value = config.hardware.sspin;
document.getElementById("gain").value = config.hardware.rfidgain;
document.getElementById("gpiorly").value = config.hardware.rpin;
Expand Down Expand Up @@ -249,6 +270,7 @@ function savehardware() {
config.hardware.readertype = parseInt(document.getElementById("readertype").value);
config.hardware.wgd0pin = parseInt(document.getElementById("wg0pin").value);
config.hardware.wgd1pin = parseInt(document.getElementById("wg1pin").value);
config.hardware.rdm6300pin = parseInt(document.getElementById("rdm6300pin").value);
config.hardware.useridstoragemode = document.getElementById("useridstoragemode").value;
config.hardware.requirepincodeafterrfid = document.getElementById("requirepincodeafterrfid").checked;
config.hardware.allowpincodeonly = document.getElementById("allowpincodeonly").checked;
Expand Down

0 comments on commit 69ba0b3

Please sign in to comment.