@@ -3,6 +3,7 @@ server.on("/api/tx/bin", [](){
33 int api_txdelayus = txdelayus ;
44 int api_txdelayms = txdelayms ;
55 int prettify = 0 ;
6+ int api_wait = 100000 ;
67 if (server .hasArg ("binary" )) {
78 api_binary = (server .arg ("binary" ));
89 }
@@ -12,11 +13,14 @@ server.on("/api/tx/bin", [](){
1213 if (server .hasArg ("interval" )) {
1314 api_txdelayms = (server .arg ("interval" ).toInt ());
1415 }
16+ if (server .hasArg ("wait" )) {
17+ api_wait = (server .arg ("wait" ).toInt ());
18+ }
1519 if (server .hasArg ("prettify" )) {
1620 prettify = 1 ;
1721 }
1822
19- const size_t bufferSize = JSON_ARRAY_SIZE (4 ) + JSON_OBJECT_SIZE (4 );
23+ const size_t bufferSize = JSON_ARRAY_SIZE (4 ) + JSON_OBJECT_SIZE (5 );
2024 DynamicJsonBuffer jsonAPIbuffer (bufferSize );
2125 JsonObject & apitxbin = jsonAPIbuffer .createObject ();
2226
@@ -29,9 +33,15 @@ server.on("/api/tx/bin", [](){
2933 apitxbinary ["Binary" ]= api_binary ;
3034 apitxbinary ["Wiegand Data Pulse Width" ]= String ()+ api_txdelayus + "us" ;
3135 apitxbinary ["Wiegand Data Interval" ]= String ()+ api_txdelayms + "ms" ;
36+ apitxbinary ["Delay Between Packets" ]= String ()+ api_wait + "us" ;
3237
3338 if (api_binary == "" ) {
34- server .send (200 , "application/json" , F ("Binary to tx not specified." ));
39+ server .send (200 , "text/html" , F (
40+ "Binary to tx not specified.<br>"
41+ "<small>Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_ms]&wait=[delay_us_between_packets]</small><br>"
42+ "<small>Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)</small><br>"
43+ "<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>"
44+ ));
3545 }
3646 else {
3747 String API_Response = "" ;
@@ -43,7 +53,7 @@ server.on("/api/tx/bin", [](){
4353 }
4454 server .send (200 , "application/json" , API_Response );
4555 delay (50 );
46- apiTX (api_binary ,api_txdelayus ,api_txdelayms );
56+ apiTX (api_binary ,api_txdelayus ,api_txdelayms , api_wait );
4757 }
4858 jsonAPIbuffer .clear ();
4959});
@@ -66,7 +76,9 @@ server.on("/api/help", [](){
6676 "<small>Usage: [server]/api/listlogs</small><br>"
6777 "<br>"
6878 "<b><a href=\"/api/tx/bin?binary=0001&pulsewidth=40&interval=2&prettify=1\">/api/tx/bin</a></b><br>"
69- "<small>Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_ms]</small><br>"
79+ "<small>Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_ms]&wait=[delay_us_between_packets]</small><br>"
80+ "<small>Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)</small><br>"
81+ "<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>"
7082 "<br>"
7183 "<b>Universal Arguments</b><br>"
7284 "<small>Prettify: [api-url]?[args]<u>&prettify=1</u></small><br>"
0 commit comments