Skip to content

Commit

Permalink
API 1.0.3
Browse files Browse the repository at this point in the history
* Add the ability to TX multiple "packets"
  * NOTE: Processing multiple packets is limited by the devices RAM
  • Loading branch information
exploitagency committed Mar 24, 2018
1 parent 2458b33 commit c17c795
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
9 changes: 7 additions & 2 deletions Source Code/esprfidtool/api.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
void apiTX(String apiBIN, int apitxdelayus, int apitxdelayms) {
void apiTX(String apiBIN, int apitxdelayus, int apitxdelayms, int wait) {
wg.pause();
digitalWrite(DATA0, HIGH);
pinMode(DATA0,OUTPUT);
Expand All @@ -15,7 +15,12 @@ void apiTX(String apiBIN, int apitxdelayus, int apitxdelayms) {
delayMicroseconds(apitxdelayus);
digitalWrite(DATA1, HIGH);
}
delay(apitxdelayms);
if (apiBIN.charAt(i) == ',') {
delayMicroseconds(wait);
}
else {
delay(apitxdelayms);
}
}
yield();
apiBIN="";
Expand Down
20 changes: 16 additions & 4 deletions Source Code/esprfidtool/api_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ server.on("/api/tx/bin", [](){
int api_txdelayus=txdelayus;
int api_txdelayms=txdelayms;
int prettify=0;
int api_wait=100000;
if (server.hasArg("binary")) {
api_binary=(server.arg("binary"));
}
Expand All @@ -12,11 +13,14 @@ server.on("/api/tx/bin", [](){
if (server.hasArg("interval")) {
api_txdelayms=(server.arg("interval").toInt());
}
if (server.hasArg("wait")) {
api_wait=(server.arg("wait").toInt());
}
if (server.hasArg("prettify")) {
prettify=1;
}

const size_t bufferSize = JSON_ARRAY_SIZE(4) + JSON_OBJECT_SIZE(4);
const size_t bufferSize = JSON_ARRAY_SIZE(4) + JSON_OBJECT_SIZE(5);
DynamicJsonBuffer jsonAPIbuffer(bufferSize);
JsonObject& apitxbin = jsonAPIbuffer.createObject();

Expand All @@ -29,9 +33,15 @@ server.on("/api/tx/bin", [](){
apitxbinary["Binary"]=api_binary;
apitxbinary["Wiegand Data Pulse Width"]=String()+api_txdelayus+"us";
apitxbinary["Wiegand Data Interval"]=String()+api_txdelayms+"ms";
apitxbinary["Delay Between Packets"]=String()+api_wait+"us";

if (api_binary=="") {
server.send(200, "application/json", F("Binary to tx not specified."));
server.send(200, "text/html", F(
"Binary to tx not specified.<br>"
"<small>Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_ms]&wait=[delay_us_between_packets]</small><br>"
"<small>Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)</small><br>"
"<small>Example to TX Pin Code 1337# waiting 100,000us between packets(keypresses): /api/tx/bin?binary=11100001,11000011,11000011,10000111,01001011&wait=100000&prettify=1</small><br>"
));
}
else {
String API_Response="";
Expand All @@ -43,7 +53,7 @@ server.on("/api/tx/bin", [](){
}
server.send(200, "application/json", API_Response);
delay(50);
apiTX(api_binary,api_txdelayus,api_txdelayms);
apiTX(api_binary,api_txdelayus,api_txdelayms,api_wait);
}
jsonAPIbuffer.clear();
});
Expand All @@ -66,7 +76,9 @@ server.on("/api/help", [](){
"<small>Usage: [server]/api/listlogs</small><br>"
"<br>"
"<b><a href=\"/api/tx/bin?binary=0001&pulsewidth=40&interval=2&prettify=1\">/api/tx/bin</a></b><br>"
"<small>Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_ms]</small><br>"
"<small>Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_ms]&wait=[delay_us_between_packets]</small><br>"
"<small>Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)</small><br>"
"<small>Example to TX Pin Code 1337# waiting 100,000us between packets(keypresses): /api/tx/bin?binary=11100001,11000011,11000011,10000111,01001011&wait=100000&prettify=1</small><br>"
"<br>"
"<b>Universal Arguments</b><br>"
"<small>Prettify: [api-url]?[args]<u>&prettify=1</u></small><br>"
Expand Down
2 changes: 1 addition & 1 deletion Source Code/esprfidtool/version.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
String version = "1.2.0";
String APIversion = "1.0.2";
String APIversion = "1.0.3";

0 comments on commit c17c795

Please sign in to comment.