forked from esprfid/esp-rfid
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See changelog.
- Loading branch information
Showing
14 changed files
with
581 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"ssid":"SMC", | ||
"pswd":"333555555", | ||
"sspin":15, | ||
"rstpin":0, | ||
"rfidgain":32 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
var websock; | ||
|
||
function start() { | ||
websock = new WebSocket('ws:https://' + window.location.hostname + '/ws'); | ||
websock.onopen = function(evt) { | ||
console.log('ESP WebSock Open'); | ||
websock.send('{"command":"getconf"}'); | ||
websock.send('{"command":"picclist"}'); | ||
}; | ||
websock.onclose = function(evt) { | ||
console.log('ESP WebSock Close'); | ||
}; | ||
websock.onerror = function(evt) { | ||
console.log(evt); | ||
}; | ||
websock.onmessage = function(evt) { | ||
console.log(evt.data); | ||
obj = JSON.parse(evt.data); | ||
if (obj.command == "ssidlist") { | ||
listSSID(obj); | ||
} else if (obj.command == "configfile") { | ||
listCONF(obj); | ||
} else if (obj.command == "piccscan") { | ||
listSCAN(obj); | ||
} else if (obj.command == "picclist") { | ||
listknownPICC(obj); | ||
} | ||
}; | ||
} | ||
|
||
function listCONF(obj) { | ||
console.log(obj); | ||
document.getElementById('inputtohide').value = obj.ssid; | ||
document.getElementById('wifipass').value = obj.pswd; | ||
document.getElementById('gpioss').value = obj.sspin; | ||
document.getElementById('gpiorst').value = obj.rstpin; | ||
document.getElementById('gain').value = obj.rfidgain; | ||
} | ||
|
||
function listSSID(obj) { | ||
var select = document.getElementById('ssid'); | ||
for (var i = 0; i < obj.ssid.length; i++) { | ||
var x = obj.ssid[i]; | ||
var opt = document.createElement('option'); | ||
opt.value = x; | ||
opt.innerHTML = x; | ||
select.appendChild(opt); | ||
} | ||
document.getElementById('scanb').innerHTML = 'Re-Scan'; | ||
} | ||
|
||
function scanWifi() { | ||
websock.send('{"command":"scan"}'); | ||
document.getElementById('scanb').innerHTML = '...'; | ||
document.getElementById('inputtohide').style.display = 'none'; | ||
var node = document.getElementById('ssid'); | ||
node.style.display = 'inline'; | ||
while (node.hasChildNodes()) { | ||
node.removeChild(node.lastChild); | ||
} | ||
} | ||
|
||
function saveConf() { | ||
var ssid; | ||
if (document.getElementById('inputtohide').style.display == 'none') { | ||
var b = document.getElementById('ssid'); | ||
ssid = b.options[b.selectedIndex].value; | ||
} else { | ||
ssid = document.getElementById('inputtohide').value; | ||
} | ||
var datatosend = {}; | ||
datatosend.command = "configfile"; | ||
datatosend.ssid = ssid; | ||
datatosend.pswd = document.getElementById('wifipass').value; | ||
datatosend.sspin = document.getElementById('gpioss').value; | ||
datatosend.rstpin = document.getElementById('gpiorst').value; | ||
datatosend.rfidgain = document.getElementById('gain').value; | ||
console.log(JSON.stringify(datatosend)); | ||
websock.send(JSON.stringify(datatosend)); | ||
} | ||
|
||
function listSCAN(obj) { | ||
var epochTime = obj.epoch; | ||
var isKnown = obj.known; | ||
var uid = obj.uid; | ||
var uidUP = obj.uid.toUpperCase(); | ||
var type = obj.type.toUpperCase(); | ||
var ref = document.getElementById('picctype'); | ||
|
||
ref.innerHTML = "UID: " + uidUP + " Type: " + type + " "; | ||
|
||
var btn = document.createElement('button'); | ||
|
||
if (isKnown == 1) { | ||
|
||
btn.id = uid; | ||
btn.classList.add("btn", "btn-danger", "btn-xs"); | ||
btn.onclick = function() { | ||
del(this); | ||
}; | ||
btn.textContent = "Remove"; | ||
ref.appendChild(btn); | ||
|
||
} else { | ||
|
||
btn.id = uid; | ||
btn.classList.add("btn", "btn-success", "btn-xs"); | ||
btn.onclick = function() { | ||
add(this); | ||
}; | ||
btn.textContent = "Add"; | ||
|
||
ref.appendChild(btn); | ||
} | ||
} | ||
|
||
function add(e) { | ||
var x = confirm('This will add ' + e.id + ' to database. Are you sure?'); | ||
if (x) { | ||
var jsontosend = '{"uid":"' + e.id + '","command":"add"}'; | ||
websock.send(jsontosend); | ||
} | ||
} | ||
|
||
function del(e) { | ||
var x = confirm('This will remove ' + e.id + ' from database. Are you sure?'); | ||
if (x) { | ||
var jsontosend = '{"uid":"' + e.id + '","command":"remove"}'; | ||
websock.send(jsontosend); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
function listknownPICC(obj) { | ||
var table = document.getElementById("knowntable").getElementsByTagName('tbody')[0]; | ||
|
||
for (var i = 0; i < obj.piccs.length; i++) { | ||
var x = obj.piccs[i]; | ||
x = x.substring(3); | ||
var upper = x.toUpperCase(); | ||
var row = table.insertRow(table.rows[0]); | ||
row.className = 'success'; | ||
var cell1 = row.insertCell(0); | ||
cell1.value = upper; | ||
cell1.innerHTML = upper; | ||
var cell2 = row.insertCell(1); | ||
var inp = document.createElement('input'); | ||
inp.classList.add("input-sm"); | ||
cell2.appendChild(inp); | ||
var cell3 = row.insertCell(2); | ||
var btn = document.createElement('button'); | ||
btn.onclick = function() {del(this);}; | ||
btn.id = x; | ||
btn.classList.add("btn", "btn-danger", "btn-xs"); | ||
btn.textContent = "X"; | ||
cell3.appendChild(btn); | ||
|
||
|
||
|
||
} | ||
console.log(obj); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content=""> | ||
<meta name="author" content=""> | ||
<link rel="icon" href="/favicon.ico"> | ||
<title>ESP RFID Websocket Demo</title> | ||
<!-- Bootstrap core CSS --> | ||
<link href="/bootstrap.css" rel="stylesheet"> | ||
<script src="/auth/rfid.js" type="text/javascript" charset="utf-8"></script> | ||
</head> | ||
<body onload="javascript:start();"> | ||
<div class="container"> | ||
<div class="header clearfix"> | ||
<nav> | ||
<ul class="nav nav-pills pull-right"> | ||
<li role="presentation"><a href="#">Logs</a> </li> | ||
<li role="presentation" class="active"><a href="/auth/settings.htm">Settings</a> </li> | ||
</ul> | ||
</nav> | ||
<h3 class="text-muted">ESP RFID</h3> | ||
</div> | ||
<div class="jumbotron"> | ||
<div class="alert alert-warning"> <strong>Warning!</strong> Saving settings will cause your ESP to reboot. </div> | ||
<div class="row"> | ||
<div class="col-sm-6 col-sm-push-6"> | ||
<fieldset> | ||
<legend>Wi-Fi Client Settings</legend> | ||
<p style="font-size:12px;" class="text-muted">Type your Wi-Fi Network's SSID or Scan for nerby Wireless Networks to join.</p> | ||
<div class="row form-group"> | ||
<label class="col-xs-3">SSID</label> | ||
<span class="col-xs-9"> | ||
<input class="form-control input-sm" style="display:inline;max-width:150px" id="inputtohide" type="text" name="ap_ssid"/> | ||
<select class="form-control input-sm" style="display:none;max-width:150px" id="ssid"></select> | ||
<button id="scanb" type="button" class="btn btn-info btn-xs" onclick="scanWifi()">Scan</button> | ||
</span> | ||
</div> | ||
<div class="row form-group"> | ||
<label class="col-xs-3">Password</label> | ||
<span class="col-xs-9"> | ||
<input id="wifipass" style="max-width:150px" class="form-control input-sm" type="text" name="ap_passwd"> | ||
</span> | ||
</div> | ||
</fieldset> | ||
<br> | ||
</div> | ||
<div class="col-sm-6 col-sm-pull-6"> | ||
<fieldset> | ||
<legend>MFRC522 Hardware Settings</legend> | ||
<p style="font-size:12px;" class="text-muted">Please refer the <a href="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/omersiar/esp-rfid">documentation</a> for pin configuration.</p> | ||
<div class="row form-group"> | ||
<label class="col-xs-3">RST/Reset</label> | ||
<span class="col-xs-9"> | ||
<select class="form-control input-sm" style="max-width:185px" id="gpiorst"> | ||
<option selected="selected" value="0">GPIO-0</option> | ||
<option value="2">GPIO-2</option> | ||
<option value="4">GPIO-4</option> | ||
<option value="5">GPIO-5</option> | ||
<option value="15">GPIO-15</option> | ||
<option value="16">GPIO-16</option> | ||
</select> | ||
</span> | ||
</div> | ||
<div class="row form-group"> | ||
<label class="col-xs-3">SPI SS</label> | ||
<span class="col-xs-9"> | ||
<select class="form-control input-sm" style="max-width:185px" id="gpioss"> | ||
<option value="0">GPIO-0</option> | ||
<option value="2">GPIO-2</option> | ||
<option value="4">GPIO-4</option> | ||
<option value="5">GPIO-5</option> | ||
<option selected="selected" value="15">GPIO-15</option> | ||
<option value="16">GPIO-16</option> | ||
</select> | ||
</span> | ||
</div> | ||
<div class="row form-group"> | ||
<label class="col-xs-3">Antenna Gain</label> | ||
<span class="col-xs-9"> | ||
<select class="form-control input-sm" style="max-width:185px" id="gain"> | ||
<option value="112">Max (48 db)</option> | ||
<option value="96">43 db</option> | ||
<option value="48">38 db</option> | ||
<option selected="selected" value="32">Avg (33 db)</option> | ||
<option value="16">23 db</option> | ||
<option value="0">Min (18 db)</option> | ||
</select> | ||
</span> | ||
</div> | ||
</fieldset> | ||
</div> | ||
</div> | ||
<div><button onclick="saveConf()" class="btn btn-success btn-md pull-right">Save & Reboot</button> | ||
</div> | ||
<br> | ||
</div> | ||
<div class="jumbotron"> | ||
<div class="row"> | ||
<div class="col-sm-6 col-sm-push-6"><legend>Scan a PICC for details.</legend> | ||
<div id="picctype" class="well well-lg" style="width:100%;"> | ||
|
||
|
||
</div> | ||
</div> | ||
<div class="col-sm-6 col-sm-pull-6"> | ||
<legend>Known PICCs</legend> | ||
<div class="panel panel-default table-responsive"> | ||
<table id="knowntable" class="table table-hover table-striped"> | ||
<thead class="thead-default"> | ||
<tr> | ||
<th>UID</th> | ||
<th>User</th> | ||
<th>Remove</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<br><br> | ||
</div> | ||
</div> | ||
<hr> | ||
<footer> | ||
<p>© 2017 OSB Inc.</p> | ||
</footer> | ||
</div> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.