Skip to content

Commit

Permalink
Added hardcoded
Browse files Browse the repository at this point in the history
  • Loading branch information
arcbtc committed Feb 18, 2024
1 parent 69c0344 commit 92c99ad
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 205 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ arduino-cli config --additional-urls https://raw.githubusercontent.com/espressif
arduino-cli core update-index
arduino-cli core install esp32:esp32
arduino-cli upgrade
arduino-cli lib install WebSockets ArduinoJson AutoConnect Base64 Keypad PageBuilder uBitcoin
arduino-cli lib install ArduinoJson Base64 Keypad uBitcoin
arduino-cli compile \
--build-property "build.partitions=min_spiffs" \
--build-property "upload.maximum_size=1966080" \
Expand Down
163 changes: 162 additions & 1 deletion lnpos/100_config.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void executeConfig() {
key_val = "";
getKeypad(false, true, false, false);
if (key_val == "*"){
getParams();
readFiles();
unConfirmed = false;
return;
}
Expand Down Expand Up @@ -90,3 +90,164 @@ KeyValue extractKeyValue(String s) {
String value = s.substring(spacePos + 1, s.length());
return {key, value};
}

void readFiles()
{
File paramFile = FlashFS.open(PARAM_FILE, "r");
if (paramFile)
{
if(!hardcoded){
StaticJsonDocument<2500> doc;
DeserializationError error = deserializeJson(doc, paramFile.readString());
if(error){
Serial.print("deserializeJson() failed: ");
Serial.println(error.c_str());
return;
}
lnurlPoS = getJsonValue(doc, "config_lnurlpos");
lnurlATM = getJsonValue(doc, "config_lnurlatm");
masterKey = getJsonValue(doc, "config_masterkey");
lnbitsServer = getJsonValue(doc, "config_server");
invoice = getJsonValue(doc, "config_invoice");
lncurrency = getJsonValue(doc, "config_lncurrency");
lnurlATMMS = getJsonValue(doc, "config_lnurlatmms");
lnurlATMPin = getJsonValue(doc, "config_lnurlatmpin");
decimalplaces = getJsonValue(doc, "config_decimalplaces");
ssid = getJsonValue(doc, "config_wifi_ssid");
password = getJsonValue(doc, "config_wifi_password");
}

////////LNURL PoS string/////////
if(lnurlPoS != "null" || lnurlPoS != ""){
baseURLPoS = getValue(lnurlPoS, ',', 0);
secretPoS = getValue(lnurlPoS, ',', 1);
currencyPoS = getValue(lnurlPoS, ',', 2);
Serial.println("");
Serial.println("lnurlPoS used");
Serial.println("lnurlPoS: " + lnurlPoS);
if (secretPoS != "")
{
menuItemCheck[1] = 1;
}
}
else{
Serial.println("lnurlPoS not set");
}

////////LNURL ATM string/////////
if(lnurlATM != "null" || lnurlATM != ""){
baseURLATM = getValue(lnurlATM, ',', 0);
secretATM = getValue(lnurlATM, ',', 1);
currencyATM = getValue(lnurlATM, ',', 2);
Serial.println("");
Serial.println("lnurlPoS: " + lnurlPoS);
if (secretATM != "")
{
menuItemCheck[3] = 1;
}
}
else{
Serial.println("lnurlATM not set");
}

//////////MasterKey/////////
if(masterKey != "null" || masterKey != ""){
Serial.println("");
Serial.println("masterKey used from memory");
Serial.println("masterKey: " + masterKey);
if (masterKey != "")
{
menuItemCheck[2] = 1;
}
}
else{
Serial.println("MasterKey not set");
}

//////////Lnbits Server/////////
if(lnbitsServer != "null" || lnbitsServer != ""){
Serial.println("");
Serial.println("lnbitsServer used from memory");
Serial.println("lnbitsServer: " + lnbitsServer);
}
else{
Serial.println("lnbitsServer not set");
}

/////////LNbits Server///////
if(invoice != "null" || invoice != ""){
Serial.println("");
Serial.println("invoice key used from memory");
Serial.println("invoice key: " + invoice);
if (invoice != "")
{
menuItemCheck[0] = 1;
}
}
else{
Serial.println("invoice key not set");
}

/////////PoS Currency///////
if(lncurrency != "null" || lncurrency != ""){
Serial.println("");
Serial.println("PoS currency used from memory");
Serial.println("PoS currency: " + lncurrency);
}
else{
Serial.println("Pos currency not set");
}

/////////mempool.space server///////
if(lnurlATMMS != "null" || lnurlATMMS != ""){
Serial.println("");
Serial.println("mempool.space server used from memory");
Serial.println("mempool.space server: " + lnurlATMMS);
}
else{
Serial.println("mempool.space server not set");
}

/////////mATM/Settings pin///////
if(lnurlATMPin != "null" || lnurlATMPin != ""){
Serial.println("");
Serial.println("ATM/settings security pin used from memory");
Serial.println("ATM/settings security pin: " + lnurlATMPin);
}
else{
lnurlATMPin = "878787";
Serial.println("ATM/Settings security pin not set using default");
}

/////////no. FIAT decimal places///////
if(decimalplaces != "null" || decimalplaces != ""){
Serial.println("");
Serial.println("no. fiat decimal places used from memory");
Serial.println("no. fiat decimal places: " + decimalplaces);
}
else{
Serial.println("no. fiat decimal places not set");
}

/////////WiFi SSID///////
if(ssid != "null" || ssid != ""){
Serial.println("");
Serial.println("WiFi SSID used from memory");
Serial.println("WiFi SSID: " + ssid);
}
else{
Serial.println("WiFi SSID not set");
}

/////////WiFi password///////
if(decimalplaces != "null" || decimalplaces != ""){
Serial.println("");
Serial.println("WiFi password used from memory");
Serial.println("WiFi password: " + password);
}
else{
Serial.println("WiFi password not set");
}
}
paramFile.close();
}
Loading

0 comments on commit 92c99ad

Please sign in to comment.