diff --git a/bitcoinSwitch/100_config.ino b/bitcoinSwitch/100_config.ino index 9fa20f9..009f1c7 100644 --- a/bitcoinSwitch/100_config.ino +++ b/bitcoinSwitch/100_config.ino @@ -2,6 +2,7 @@ #define BOOTUP_TIMEOUT 2 // seconds #define CONFIG_FILE "/elements.json" +#define LED_PIN 2 // On board LED pin esp32-dev // uncomment if you dont want to use the configuration file // #define HARDCODED @@ -17,6 +18,7 @@ #ifdef HARDCODED void setupConfig(){ + ledPin = LED_PIN; Serial.println("Setting hardcoded values..."); config_ssid = CONFIG_SSID; Serial.println("SSID: " + config_ssid); diff --git a/bitcoinSwitch/bitcoinSwitch.ino b/bitcoinSwitch/bitcoinSwitch.ino index d48778b..f584df9 100644 --- a/bitcoinSwitch/bitcoinSwitch.ino +++ b/bitcoinSwitch/bitcoinSwitch.ino @@ -9,7 +9,8 @@ int config_threshold_amount; int config_threshold_pin; int config_threshold_time; -String apiUrl = "/api/v1/ws/"; +int ledPin; + WebSocketsClient webSocket; @@ -23,8 +24,6 @@ void setup() { setupConfig(); setupWifi(); - pinMode(2, OUTPUT); // To blink on board LED - if (config_device_string == "") { Serial.println("No device string configured!"); printTFT("No device string!", 21, 95); @@ -45,8 +44,8 @@ void setup() { if (config_threshold_amount != 0) { // Use in threshold mode Serial.println("Using THRESHOLD mode"); - Serial.println("Connecting to websocket: " + host + apiUrl + config_threshold_inkey); - webSocket.beginSSL(host, 443, apiUrl + config_threshold_inkey); + Serial.println("Connecting to websocket: " + host + apiPath + config_threshold_inkey); + webSocket.beginSSL(host, 443, apiPath + config_threshold_inkey); } else { // Use in normal mode Serial.println("Using NORMAL mode"); Serial.println("Connecting to websocket: " + host + apiPath); @@ -84,7 +83,7 @@ void executePayment(uint8_t *payload) { } Serial.println("[WebSocket] received pin: " + String(pin) + ", duration: " + String(time)); - if (config_threshold_amount != 0) { + if (config_threshold_amount > 0) { // If in threshold mode we check the "balance" pushed by the // websocket and use the pin/time preset // executeThreshold(); @@ -93,9 +92,13 @@ void executePayment(uint8_t *payload) { // the magic happens here pinMode(pin, OUTPUT); + pinMode(ledPin, OUTPUT); + digitalWrite(pin, HIGH); + digitalWrite(ledPin, HIGH); delay(time); digitalWrite(pin, LOW); + digitalWrite(ledPin, LOW); printHome(true, true, false);