forked from Akcelerometry_drgania_WMT/PI_mikrokontroler
Dodanie Captive Portal z logarytmami
This commit is contained in:
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
ADXL345FreshSPI() = default;
|
||||
|
||||
// --- Init (SPI only) ---
|
||||
// --- Init (SPI) ---
|
||||
// Uwaga: ADXL345 wymaga SPI MODE3, zegar ≤ ~5 MHz.
|
||||
bool begin(SPIClass *spi, uint8_t csPin, uint32_t clockHz = 5000000);
|
||||
|
||||
|
||||
19
include/APIClient.h
Normal file
19
include/APIClient.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef APICLIENT_H
|
||||
#define APICLIENT_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <FS.h>
|
||||
#include <SD.h>
|
||||
#include "Config.h"
|
||||
#include "Watchdog.h"
|
||||
|
||||
class APIClient {
|
||||
public:
|
||||
APIClient();
|
||||
|
||||
bool uploadMeasurement(const String& filePath);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -60,10 +60,6 @@ public:
|
||||
void setCursor(int16_t x, int16_t y);
|
||||
void showAccel(float a, float b, float c);
|
||||
void displayOnOffM(bool measure, String myDir, String myFile);
|
||||
|
||||
// Metoda sterująca ikoną SSL (dodana do klasy)
|
||||
void setSSLStatus(bool active);
|
||||
|
||||
void initMeasure(
|
||||
bool measure, // czy pomiar ciągły?
|
||||
bool run, // czy uruchomiony?
|
||||
@@ -78,9 +74,20 @@ public:
|
||||
private:
|
||||
LiquidCrystal_I2C *_lcd;
|
||||
RTC_DS3231 &rtc_;
|
||||
uint8_t _address;
|
||||
uint8_t _columns;
|
||||
uint8_t _rows;
|
||||
uint8_t _address;
|
||||
|
||||
// Poprzednie
|
||||
uint16_t oyear;
|
||||
uint8_t omonth;
|
||||
uint8_t oday;
|
||||
uint8_t ohour;
|
||||
uint8_t omin;
|
||||
uint8_t osec;
|
||||
float ospace;
|
||||
uint8_t oadxlcnt;
|
||||
bool omode;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -17,8 +17,6 @@ static constexpr uint32_t SPI_HZ = 5000000; // 5 MHz (MODE3)
|
||||
static constexpr float ODR_HZ = 3200.0f; // maks. ODR
|
||||
// Zakres ustawiany w main.cpp przez ADXL345FastSPI::begin(..., RANGE_2G, ...)
|
||||
|
||||
//extern Display display;
|
||||
|
||||
struct FileInfo {
|
||||
String path; // np. "/3/00000057.wmt"
|
||||
uint64_t size; // bajty
|
||||
@@ -31,7 +29,7 @@ struct SpaceInfo {
|
||||
};
|
||||
|
||||
class DataCapture {
|
||||
// --- Nagłówek pliku WMT (jak w oryginale) ---
|
||||
// --- Nagłówek pliku WMT ---
|
||||
struct FileHeader {
|
||||
char magic[3]; // "WMT"
|
||||
uint16_t version; // 1
|
||||
@@ -42,7 +40,7 @@ class DataCapture {
|
||||
} __attribute__((packed));
|
||||
|
||||
public:
|
||||
// --- Rekord próbki (jak w oryginale) ---
|
||||
// --- Rekord próbki ---
|
||||
struct Sample {
|
||||
uint32_t offset; // µs od startu akwizycji (wspólny dla ramki)
|
||||
uint8_t sensor_id; // 0..3
|
||||
@@ -105,8 +103,6 @@ private:
|
||||
return ispress;
|
||||
} // szybkidigitalRead : czy BTN stop???
|
||||
|
||||
|
||||
// Helpers (zachowane z Twojej wersji)
|
||||
public:
|
||||
bool isAllDigits(const char *s);
|
||||
uint32_t toUint(const char *s);
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
#include <ESPmDNS.h>
|
||||
#include <DNSServer.h>
|
||||
#elif defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <DNSServer.h>
|
||||
#endif
|
||||
|
||||
#include <DNSServer.h> // Dodano dla Captive Portal
|
||||
//#include <Pinout.h>
|
||||
//#include <IPAddress.h>
|
||||
//#include <WiFiUdp.h>
|
||||
@@ -28,11 +27,6 @@
|
||||
#include <functional>
|
||||
// OTA
|
||||
|
||||
#include "Display.h" // Dodano dla obsługi komunikatów na LCD
|
||||
|
||||
extern Config config; // Deklaracja zewnętrznej struktury config
|
||||
extern ConfigManager configManager; // Deklaracja zewnętrznego managera (to naprawi błąd)
|
||||
|
||||
class WiFiManager {
|
||||
public:
|
||||
WiFiManager();
|
||||
@@ -50,11 +44,11 @@ class WiFiManager {
|
||||
int rssiToPercent(int rssi); // rssi na procenty
|
||||
int8_t getRSSI();
|
||||
|
||||
/**
|
||||
* NOWA METODA: Portal konfiguracyjny (Captive Portal)
|
||||
* Uruchamiany automatycznie przy braku połączenia.
|
||||
*/
|
||||
void startConfigPortal(Display &display);
|
||||
void handleClient();
|
||||
void startCaptivePortal();
|
||||
void handleRoot();
|
||||
void handleSave();
|
||||
void handleNotFound();
|
||||
|
||||
/**
|
||||
* Aktualizacja systemu przez internet z adresu config.updateUrl.
|
||||
@@ -75,18 +69,10 @@ class WiFiManager {
|
||||
|
||||
private:
|
||||
bool isAccessPoint = false;
|
||||
|
||||
// Obiekty serwerów dla Portalu (ESP32/ESP8266)
|
||||
#ifdef ESP32
|
||||
bool captivePortalActive = false;
|
||||
WebServer server{80};
|
||||
#elif defined(ESP8266)
|
||||
ESP8266WebServer server{80};
|
||||
#endif
|
||||
DNSServer dnsServer;
|
||||
void handleRoot();
|
||||
void handleSave();
|
||||
int expectedCaptchaAnswer = 0;
|
||||
};
|
||||
|
||||
extern WiFiManager wifi;
|
||||
|
||||
#endif // WIFIMANAGER_H
|
||||
#endif // WIFIMANAGER_H
|
||||
|
||||
@@ -24,7 +24,7 @@ class Settings {
|
||||
// bool is1and3();
|
||||
|
||||
bool isBtnReset();
|
||||
|
||||
bool isSetClock();
|
||||
bool readBtnUp() { return digitalRead(BTN_UP) == LOW; }
|
||||
bool readBtnOk() { return digitalRead(BTN_OK) == LOW; }
|
||||
bool readBtnDown() { return digitalRead(BTN_DOWN) == LOW; }
|
||||
|
||||
31
include/UploadManager.h
Normal file
31
include/UploadManager.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef UPLOADMANAGER_H
|
||||
#define UPLOADMANAGER_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <FS.h>
|
||||
#include <SD.h>
|
||||
#include "APIClient.h"
|
||||
#include "RTClib.h"
|
||||
#include "Measure.h"
|
||||
|
||||
class UploadManager {
|
||||
public:
|
||||
UploadManager(APIClient& client, RTC_DS3231& rtc, DataCapture& capture);
|
||||
|
||||
// Call this to upload a specific file immediately
|
||||
void uploadFile(const String& filePath);
|
||||
|
||||
// Call this in the background when WiFi is connected
|
||||
void processPendingUploads();
|
||||
|
||||
private:
|
||||
APIClient& apiClient;
|
||||
RTC_DS3231& rtc_;
|
||||
DataCapture& capture_;
|
||||
|
||||
bool isAlreadyUploaded(const String& filePath);
|
||||
void appendLog(const String& filePath, const String& status);
|
||||
String getCurrentTimestamp();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define VERSION "1.3.2"
|
||||
#define VERSION "1.3.4.1"
|
||||
|
||||
// 1: graphical 128x64, 2: LCD I2C Text 4x20
|
||||
#define LCD_TYPE 2
|
||||
|
||||
Reference in New Issue
Block a user