Skip to content

Commit

Permalink
Renamed config vars to config_* (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackcoffeexbt authored Oct 30, 2023
1 parent 32c10f3 commit e39f4e9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
12 changes: 6 additions & 6 deletions installer/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ export const addressesAndFiles = [
export const configPath = "elements.json";
export const elements = [
{
name: "ssid",
name: "config_ssid",
value: "",
label: "WiFi SSID",
type: "text",
},
{
name: "password",
name: "config_wifi_password",
value: "",
label: "WiFi Password",
type: "text",
},
{
name: "relay",
value: "",
name: "config_relay",
value: "nos.lol",
label: "Nostr Relay URL",
type: "text",
},
{
name: "pubkey",
name: "config_pubkey",
value: "",
label: "Nostr Public Key in hex",
label: "The Public Key in Hex to Watch for Zaps",
type: "text",
},
];
68 changes: 34 additions & 34 deletions nostrZapLamp/nostrZapLamp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

String version = "0.0.1";

String ssid = "null"; // 'String ssid = "ssid";' / 'String ssid = "null";'
String wifiPassword = "null"; // 'String wifiPassword = "password";' / 'String wifiPassword = "null";'
String npubHex = "null";
String relaysString = "null";
String config_ssid = "null"; // 'String config_ssid = "config_ssid";' / 'String config_ssid = "null";'
String config_wifi_password = "null"; // 'String config_wifi_password = "password";' / 'String config_wifi_password = "null";'
String config_pubkey = "null";
String config_relay = "null";

///////////////////////////////////////////////////////////////////////////////////
// END of variables //
Expand Down Expand Up @@ -184,11 +184,11 @@ void createZapEventRequest() {
eventRequestOptions->kinds_count = sizeof(kinds) / sizeof(kinds[0]);

// // Populate #p
Serial.println("npubHexString is |" + npubHex + "|");
if(npubHex != "") {
Serial.println("npubHexString is |" + config_pubkey + "|");
if(config_pubkey != "") {
Serial.println("npub is specified");
String* pubkeys = new String[1]; // Allocate memory dynamically
pubkeys[0] = npubHex;
pubkeys[0] = config_pubkey;
eventRequestOptions->p = pubkeys;
eventRequestOptions->p_count = 1;
}
Expand All @@ -212,7 +212,7 @@ void connectToNostrRelays() {

// split relays by comma into vector
std::vector<String> relays;
String relayStringCopy = relaysString;
String relayStringCopy = config_relay;
int commaIndex = relayStringCopy.indexOf(",");
while (commaIndex != -1) {
relays.push_back(relayStringCopy.substring(0, commaIndex));
Expand Down Expand Up @@ -634,12 +634,12 @@ void setup() {

readFiles(); // get the saved details and store in global variables

if(triggerConfig == true || ssid == "" || ssid == "null") {
if(triggerConfig == true || config_ssid == "" || config_ssid == "null") {
Serial.println("Launch serial config");
configOverSerialPort();
}
else {
WiFi.begin(ssid.c_str(), wifiPassword.c_str());
WiFi.begin(config_ssid.c_str(), config_wifi_password.c_str());
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
Expand Down Expand Up @@ -706,50 +706,50 @@ void readFiles()
Serial.println(error.c_str());
return;
}
if(ssid == "null"){ // check ssid is not set above
ssid = getJsonValue(doc, "ssid");
if(config_ssid == "null"){ // check config_ssid is not set above
config_ssid = getJsonValue(doc, "config_ssid");
Serial.println("");
Serial.println("ssid used from memory");
Serial.println("SSID: " + ssid);
Serial.println("config_ssid used from memory");
Serial.println("config_ssid: " + config_ssid);
}
else{
Serial.println("");
Serial.println("ssid hardcoded");
Serial.println("SSID: " + ssid);
Serial.println("config_ssid hardcoded");
Serial.println("config_ssid: " + config_ssid);
}
if(wifiPassword == "null"){ // check wifiPassword is not set above
wifiPassword = getJsonValue(doc, "wifipassword");
if(config_wifi_password == "null"){ // check config_wifi_password is not set above
config_wifi_password = getJsonValue(doc, "config_wifi_password");
Serial.println("");
Serial.println("ssid password used from memory");
Serial.println("SSID password: " + wifiPassword);
Serial.println("config_wifi_password used from memory");
Serial.println("config_wifi_password: " + config_wifi_password);
}
else{
Serial.println("");
Serial.println("ssid password hardcoded");
Serial.println("SSID password: " + wifiPassword);
Serial.println("config_wifi_password hardcoded");
Serial.println("config_wifi_password: " + config_wifi_password);
}
if(npubHex == "null"){ // check nPubHex
npubHex = getJsonValue(doc, "npubHex");
if(config_pubkey == "null"){ // check nPubHex
config_pubkey = getJsonValue(doc, "config_pubkey");
Serial.println("");
Serial.println("npubHex used from memory");
Serial.println("npubHex: " + npubHex);
Serial.println("config_pubkey used from memory");
Serial.println("config_pubkey: " + config_pubkey);
}
else{
Serial.println("");
Serial.println("npubHex hardcoded");
Serial.println("npubHex: " + npubHex);
Serial.println("config_pubkey hardcoded");
Serial.println("config_pubkey: " + config_pubkey);
}

if(relaysString == "null"){ // check relays
relaysString = getJsonValue(doc, "relays");
if(config_relay == "null"){ // check relays
config_relay = getJsonValue(doc, "config_relay");
Serial.println("");
Serial.println("relays used from memory");
Serial.println("relays: " + relaysString);
Serial.println("config_relays used from memory");
Serial.println("config_relays: " + config_relay);
}
else{
Serial.println("");
Serial.println("relays hardcoded");
Serial.println("relays: " + relaysString);
Serial.println("config_relays hardcoded");
Serial.println("config_relays: " + config_relay);
}
}
paramFile.close();
Expand Down

0 comments on commit e39f4e9

Please sign in to comment.