reuse http client
This commit is contained in:
parent
398b6fc512
commit
bc4880d59c
2 changed files with 6 additions and 9 deletions
|
@ -5,7 +5,8 @@
|
|||
#include <Arduino.h>
|
||||
#include "secrets.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <HTTPClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
Settings settings;
|
||||
|
||||
#ifdef WIFI
|
||||
|
@ -21,7 +22,6 @@
|
|||
#include <AsyncTCP.h>
|
||||
#include "ESPAsyncWebServer.h"
|
||||
#include "SPIFFS.h"
|
||||
#include <ArduinoJson.h>
|
||||
#include <AsyncJson.h>
|
||||
#ifdef WEB_SERIAL_DEBUG
|
||||
#include <WebSerial.h>
|
||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -7,6 +7,7 @@ const unsigned long displayDelay = 1000; // Delay in milliseconds after which th
|
|||
const unsigned long wifiRebootTimeout = 20000; // Delay before reboot after disconnect
|
||||
unsigned int bitCount = 0; // Variable to keep track of the bit count
|
||||
unsigned int maxReaderWaitTime = 9000; // Variable to timeout reader after too long of no data.
|
||||
HTTPClient http;
|
||||
|
||||
#ifdef LOCAL_ACL
|
||||
void localAcl(String cardID) {
|
||||
|
@ -168,18 +169,11 @@ void handleData1Interrupt() {
|
|||
}
|
||||
|
||||
#ifdef TINANCE2_BACKEND
|
||||
#include <HTTPClient.h>
|
||||
|
||||
|
||||
// Function to send the authentication request to the endpoint
|
||||
#include <ArduinoJson.h> // Include the ArduinoJson library
|
||||
|
||||
class Tinance2HttpClient {
|
||||
public:
|
||||
Tinance2HttpClient() {}
|
||||
|
||||
std::pair<String, int> sendHttpRequest(String url, String method, String payload) {
|
||||
HTTPClient http;
|
||||
|
||||
if (!http.begin(url)) {
|
||||
#ifdef SERIAL_DEBUG
|
||||
|
@ -360,6 +354,9 @@ void handleData1Interrupt() {
|
|||
|
||||
|
||||
void setup() {
|
||||
// allow reuse (if server supports it)
|
||||
http.setReuse(true);
|
||||
|
||||
#if defined SERIAL_DEBUG || defined SERIAL_ACL
|
||||
Serial.begin(9600);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue