restore old keys in SPIFFS
This commit is contained in:
parent
89287f43c9
commit
0f65433875
@ -90,12 +90,12 @@ After programming, you will only need to setup your Wifi and BTC address.
|
||||
1. Create a file named "config.json" in your card's root, containing the the following structure. Adjust the settings to your needs:
|
||||
{
|
||||
"SSID": "myWifiSSID",
|
||||
"PW": "myWifiPassword",
|
||||
"WifiPW": "myWifiPassword",
|
||||
"PoolUrl": "public-pool.io",
|
||||
"PoolPort": 21496,
|
||||
"BtcWallet": "walletID",
|
||||
"Timezone": 2,
|
||||
"saveStats": false
|
||||
"SaveStats": false
|
||||
}
|
||||
1. Insert the SD card.
|
||||
1. Hold down the "reset configurations" button as described below to reset the configurations and/or boot without settings in your nvmemory.
|
||||
|
@ -29,11 +29,11 @@ bool nvMemory::saveConfig(TSettings* Settings)
|
||||
|
||||
// Create a JSON document
|
||||
StaticJsonDocument<512> json;
|
||||
json[JSON_KEY_POOLURL] = Settings->PoolAddress;
|
||||
json[JSON_KEY_POOLPORT] = Settings->PoolPort;
|
||||
json[JSON_KEY_WALLETID] = Settings->BtcWallet;
|
||||
json[JSON_KEY_TIMEZONE] = Settings->Timezone;
|
||||
json[JSON_KEY_STATS2NV] = Settings->saveStats;
|
||||
json[JSON_SPIFFS_KEY_POOLURL] = Settings->PoolAddress;
|
||||
json[JSON_SPIFFS_KEY_POOLPORT] = Settings->PoolPort;
|
||||
json[JSON_SPIFFS_KEY_WALLETID] = Settings->BtcWallet;
|
||||
json[JSON_SPIFFS_KEY_TIMEZONE] = Settings->Timezone;
|
||||
json[JSON_SPIFFS_KEY_STATS2NV] = Settings->saveStats;
|
||||
|
||||
// Open config file
|
||||
File configFile = SPIFFS.open(JSON_CONFIG_FILE, "w");
|
||||
@ -84,14 +84,14 @@ bool nvMemory::loadConfig(TSettings* Settings)
|
||||
Serial.print('\n');
|
||||
if (!error)
|
||||
{
|
||||
Settings->PoolAddress = json[JSON_KEY_POOLURL] | Settings->PoolAddress;
|
||||
strcpy(Settings->BtcWallet, json[JSON_KEY_WALLETID] | Settings->BtcWallet);
|
||||
if (json.containsKey(JSON_KEY_POOLPORT))
|
||||
Settings->PoolPort = json[JSON_KEY_POOLPORT].as<int>();
|
||||
if (json.containsKey(JSON_KEY_TIMEZONE))
|
||||
Settings->Timezone = json[JSON_KEY_TIMEZONE].as<int>();
|
||||
if (json.containsKey(JSON_KEY_STATS2NV))
|
||||
Settings->saveStats = json[JSON_KEY_STATS2NV].as<bool>();
|
||||
Settings->PoolAddress = json[JSON_SPIFFS_KEY_POOLURL] | Settings->PoolAddress;
|
||||
strcpy(Settings->BtcWallet, json[JSON_SPIFFS_KEY_WALLETID] | Settings->BtcWallet);
|
||||
if (json.containsKey(JSON_SPIFFS_KEY_POOLPORT))
|
||||
Settings->PoolPort = json[JSON_SPIFFS_KEY_POOLPORT].as<int>();
|
||||
if (json.containsKey(JSON_SPIFFS_KEY_TIMEZONE))
|
||||
Settings->Timezone = json[JSON_SPIFFS_KEY_TIMEZONE].as<int>();
|
||||
if (json.containsKey(JSON_SPIFFS_KEY_STATS2NV))
|
||||
Settings->saveStats = json[JSON_SPIFFS_KEY_STATS2NV].as<bool>();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// config files
|
||||
|
||||
// default settings
|
||||
#define DEFAULT_SSID "NerdMinerAP"
|
||||
#define DEFAULT_WIFIPW "MineYourCoins"
|
||||
#define DEFAULT_POOLURL "public-pool.io"
|
||||
@ -11,16 +14,26 @@
|
||||
#define DEFAULT_TIMEZONE 2
|
||||
#define DEFAULT_SAVESTATS false
|
||||
|
||||
// JSON config file
|
||||
// JSON config files
|
||||
#define JSON_CONFIG_FILE "/config.json"
|
||||
|
||||
// JSON config file SD card (for user interaction, readme.md)
|
||||
#define JSON_KEY_SSID "SSID"
|
||||
#define JSON_KEY_PASW "PW"
|
||||
#define JSON_KEY_PASW "WifiPW"
|
||||
#define JSON_KEY_POOLURL "PoolUrl"
|
||||
#define JSON_KEY_WALLETID "BtcWallet"
|
||||
#define JSON_KEY_POOLPORT "PoolPort"
|
||||
#define JSON_KEY_TIMEZONE "Timezone"
|
||||
#define JSON_KEY_STATS2NV "saveStats"
|
||||
#define JSON_KEY_STATS2NV "SaveStats"
|
||||
|
||||
// JSON config file SPIFFS (different for backward compatibility with existing devices)
|
||||
#define JSON_SPIFFS_KEY_POOLURL "poolString"
|
||||
#define JSON_SPIFFS_KEY_POOLPORT "portNumber"
|
||||
#define JSON_SPIFFS_KEY_WALLETID "btcString"
|
||||
#define JSON_SPIFFS_KEY_TIMEZONE "gmtZone"
|
||||
#define JSON_SPIFFS_KEY_STATS2NV "saveStatsToNVS"
|
||||
|
||||
// settings
|
||||
struct TSettings
|
||||
{
|
||||
String WifiSSID{ DEFAULT_SSID };
|
||||
|
Loading…
Reference in New Issue
Block a user