forked from Akcelerometry_drgania_WMT/PI_mikrokontroler
Wgranie zmian do repozytorium
This commit is contained in:
71
releases/v1.4.2.2/include/Config.h
Normal file
71
releases/v1.4.2.2/include/Config.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include <Logger.h>
|
||||
#include <Arduino.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
#define EEPROM_SIZE 1024
|
||||
//constexpr size_t EEPROM_SIZE = sizeof(Config) + 32; // z lekkim zapasem
|
||||
|
||||
extern bool isRebootRequired;
|
||||
extern bool isClearLog;
|
||||
extern bool connected;
|
||||
extern long countConnect;
|
||||
extern long countDisconnect;
|
||||
extern String act_rssi_percent;
|
||||
extern int8_t rssi;
|
||||
extern String actDate;
|
||||
extern String actTime;
|
||||
|
||||
struct Config {
|
||||
bool connect; // czy łączyć z Internetem?
|
||||
bool measure; // true - pomiary ciągłe, false - nie rób nic (tryb konfiguracji)
|
||||
char ip[16];
|
||||
char subnet[16];
|
||||
char gateway[16];
|
||||
char dns[16];
|
||||
char ssid[32];
|
||||
char ntp[50];
|
||||
char password[32];
|
||||
char hostname[32];
|
||||
char place[100]; // miejsce instalacji
|
||||
bool dhcp; // czy włączyć DHCP?
|
||||
char user[10]; // użytkownik konfiguracji
|
||||
char pass[20]; // hasło użytkownika konfiguracji
|
||||
char updateUrl[150]; // adres pliku aktualizacji
|
||||
char restURL[150]; // adres Rest API
|
||||
int restPort; // Port systemu Api na serwerze
|
||||
char restUser[30]; // login RestAPI
|
||||
char restPass[50]; // hasło RestAPi
|
||||
uint8_t apiKey[32]; // Klucz API KEY
|
||||
uint16_t pause; // Pomiar co sekund
|
||||
uint8_t duration; // Czas pomiaru w sekundach 1-25
|
||||
char S0[12]; // nazwy czujników 1-8
|
||||
char S1[12];
|
||||
char S2[12];
|
||||
char S3[12];
|
||||
char S4[12];
|
||||
char S5[12];
|
||||
char S6[12];
|
||||
char S7[12];
|
||||
};
|
||||
|
||||
// Global config declaration
|
||||
extern Config config;
|
||||
|
||||
class ConfigManager {
|
||||
public:
|
||||
ConfigManager();
|
||||
void begin(); // EEPROM initialization
|
||||
void readConfig(); // Odczyt konfiguracji z EEPROM
|
||||
void saveConfig(); // Zapis konfiguracji do EEPROM
|
||||
void resetToDefaults(); // Reset do ustawień domyślnych
|
||||
void showConfig();
|
||||
void generateApiKey(uint8_t *buf, size_t len);
|
||||
|
||||
private:
|
||||
bool isEEPROMEmpty();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user