mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-02-15 00:53:07 +01:00
HTTP request for PageNavigation
This commit is contained in:
25
lib/obp60task/NetworkClient.h
Normal file
25
lib/obp60task/NetworkClient.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include <ArduinoJson.h>
|
||||
#include <WiFi.h>
|
||||
#include <HTTPClient.h>
|
||||
|
||||
#define DEBUG false // Debug flag for NetworkClient for more live information
|
||||
#define READLIMIT 200000 // HTTP read limit in byte for gzip content (can be adjusted)
|
||||
#define NETWORKTIMEOUT 8000 // 8s Network timeout
|
||||
|
||||
class NetworkClient {
|
||||
public:
|
||||
NetworkClient(size_t reserveSize = 0);
|
||||
|
||||
bool fetchAndDecompressJson(const String& url);
|
||||
JsonDocument& json();
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
DynamicJsonDocument _doc;
|
||||
bool _valid;
|
||||
|
||||
int skipGzipHeader(const uint8_t* data, size_t len);
|
||||
bool httpGetGzip(const String& url, uint8_t*& outData, size_t& outLen);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user