Cleaned up Settings strings

This commit is contained in:
Stefan Kremser 2019-05-17 11:39:05 +02:00
parent e703486543
commit 04c0f6c67c
2 changed files with 23 additions and 45 deletions

View File

@ -186,11 +186,10 @@ void Settings::save(bool force) {
String buf = getJsonStr();
if (writeFile(SETTINGS_PATH, buf)) {
prnt(S_SETTINGS_SAVED);
prntln(SETTINGS_PATH);
} else {
prnt(F("ERROR: saving "));
prntln(SETTINGS_PATH);
prnt(S_ERROR_SAVING);
}
prntln(SETTINGS_PATH);
}
}
@ -204,8 +203,7 @@ void Settings::print() {
settingsJson.replace(",", "\r\n");
prntln(S_SETTINGS_HEADER);
Serial.println(settingsJson);
// printf("%s\r\n", settingsJson.c_str());
prntln(settingsJson);
}
/*

View File

@ -1,30 +1,34 @@
#ifndef Settings_h
#define Settings_h
#include <Arduino.h> // String
// Load and save JSON files
#include <ArduinoJSON.h>
#include <FS.h>
// ====== Includes ====== //
// Libraries
#include <Arduino.h> // Arduino String, Serial
#include <FS.h> // SPIFFS
// Local files
#include "A_config.h" // Default Settings
#include "language.h" // Debug strings
#include "language.h" // prnt and prntln
// ====== Constants ====== //
#define SETTINGS_PATH "/settings.json"
extern void checkFile(String path, String data);
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
// ====== External Functions ===== //
extern bool writeFile(String path, String& buf);
extern void saveJSONFile(String path, JsonObject& root);
extern String macToStr(uint8_t* mac);
extern void getRandomMac(uint8_t* mac);
extern bool strToMac(String macStr, uint8_t* mac);
extern void setWifiChannel(uint8_t ch);
extern String fixUtf8(String str);
extern void copyWebFiles(bool force);
extern bool macValid(uint8_t* mac);
extern String bytesToStr(uint8_t* b, uint32_t size);
// ====== Strings ===== //
const char S_OK[] PROGMEM = "OK";
const char S_INVALID_HASH[] PROGMEM = "Invalid Hash - reseted to default";
const char S_SETTINGS_LOADED[] PROGMEM = "Loading settings...";
const char S_SETTINGS_RESETED[] PROGMEM = "Settings reseted";
const char S_SETTINGS_SAVED[] PROGMEM = "Settings saved in ";
const char S_ERROR_SAVING[] PROGMEM = "ERROR: saving ";
const char S_SETTINGS_HEADER[] PROGMEM = "[========== Settings ==========]";
const char S_CHANGED_SETTING[] PROGMEM = "Changed setting ";
// ===== JSON Strings ====== //
const char S_JSON_TRUE[] PROGMEM = "true";
const char S_JSON_FALSE[] PROGMEM = "true";
@ -65,28 +69,6 @@ const char S_JSON_LEDENABLED[] PROGMEM = "led";
const char S_JSON_DISPLAYINTERFACE[] PROGMEM = "display";
const char S_JSON_DISPLAY_TIMEOUT[] PROGMEM = "displayTimeout";
// ============
const char S_OK[] PROGMEM = "OK";
const char S_INVALID_HASH[] PROGMEM = "Invalid Hash - reseted to default";
const char S_SETTINGS[] PROGMEM = "settings";
const char S_FORCEPACKETS[] PROGMEM = "forcepackets";
const char S_AUTOSAVETIME[] PROGMEM = "autosavetime";
const char S_VERSION[] PROGMEM = "version";
const char S_MAC[] PROGMEM = "mac";
const char S_SETTINGS_LOADED[] PROGMEM = "Loading settings...";
const char S_SETTINGS_RESETED[] PROGMEM = "Settings reseted";
const char S_SETTINGS_SAVED[] PROGMEM = "Settings saved in ";
const char S_SETTINGS_HEADER[] PROGMEM = "[========== Settings ==========]";
const char S_ERROR_VERSION[] PROGMEM = "Sorry, you can't change the version number";
const char S_ERROR_NOT_FOUND[] PROGMEM = "ERROR: No setting found for ";
const char S_CHANGED_SETTING[] PROGMEM = "Changed setting ";
const char S_CHANNEL_CHANGE[] PROGMEM = "Switched to Channel ";
const char S_CHANNEL_ERROR[] PROGMEM = "ERROR: Channel must be between 1 and 14";
const char S_ERROR_SSID_LEN[] PROGMEM = "ERROR: SSID must be between 1 and 32 characters";
const char S_ERROR_PASSWORD_LEN[] PROGMEM = "ERROR: Password must be between 8 and 32 characters";
const char S_RANDOM[] PROGMEM = "random";
// ===== VERSION ===== //
typedef struct version_t {
uint8_t major = DEAUTHER_VERSION_MAJOR;
@ -188,6 +170,7 @@ typedef struct settings_hash_t {
uint8_t hash[20];
} settings_hash_t;
// ===== SETTINGS ===== //
class Settings {
private:
settings_t data;
@ -205,9 +188,6 @@ class Settings {
void reset();
void print();
// void set(const char* str, String value);
// String get(const char* str);
const version_t& getVersion();
const autosave_settings_t& getAutosaveSettings();
const attack_settings_t & getAttackSettings();