Skip to content

Commit fbd7c84

Browse files
committed
fix: blink led again
1 parent 4261dac commit fbd7c84

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

bitcoinSwitch/100_config.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#define BOOTUP_TIMEOUT 2 // seconds
44
#define CONFIG_FILE "/elements.json"
5+
#define LED_PIN 2 // On board LED pin esp32-dev
56

67
// uncomment if you dont want to use the configuration file
78
// #define HARDCODED
@@ -17,6 +18,7 @@
1718

1819
#ifdef HARDCODED
1920
void setupConfig(){
21+
ledPin = LED_PIN;
2022
Serial.println("Setting hardcoded values...");
2123
config_ssid = CONFIG_SSID;
2224
Serial.println("SSID: " + config_ssid);

bitcoinSwitch/bitcoinSwitch.ino

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ int config_threshold_amount;
99
int config_threshold_pin;
1010
int config_threshold_time;
1111

12-
String apiUrl = "/api/v1/ws/";
12+
int ledPin;
13+
1314

1415
// length of switch device id
1516
// 7dhdyJ9bbZNWNVPiFSdmb5
@@ -30,8 +31,6 @@ void setup() {
3031
setupConfig();
3132
setupWifi();
3233

33-
pinMode(2, OUTPUT); // To blink on board LED
34-
3534
if (config_device_string == "") {
3635
Serial.println("No device string configured!");
3736
printTFT("No device string!", 21, 95);
@@ -52,8 +51,8 @@ void setup() {
5251

5352
if (config_threshold_amount != 0) { // Use in threshold mode
5453
Serial.println("Using THRESHOLD mode");
55-
Serial.println("Connecting to websocket: " + host + apiUrl + config_threshold_inkey);
56-
webSocket.beginSSL(host, 443, apiUrl + config_threshold_inkey);
54+
Serial.println("Connecting to websocket: " + host + apiPath + config_threshold_inkey);
55+
webSocket.beginSSL(host, 443, apiPath + config_threshold_inkey);
5756
} else { // Use in normal mode
5857
Serial.println("Using NORMAL mode");
5958
Serial.println("Connecting to websocket: " + host + apiPath);
@@ -91,7 +90,7 @@ void executePayment(uint8_t *payload) {
9190
}
9291
Serial.println("[WebSocket] received pin: " + String(pin) + ", duration: " + String(time));
9392

94-
if (config_threshold_amount != 0) {
93+
if (config_threshold_amount > 0) {
9594
// If in threshold mode we check the "balance" pushed by the
9695
// websocket and use the pin/time preset
9796
// executeThreshold();
@@ -100,9 +99,13 @@ void executePayment(uint8_t *payload) {
10099

101100
// the magic happens here
102101
pinMode(pin, OUTPUT);
102+
pinMode(ledPin, OUTPUT);
103+
103104
digitalWrite(pin, HIGH);
105+
digitalWrite(ledPin, HIGH);
104106
delay(time);
105107
digitalWrite(pin, LOW);
108+
digitalWrite(ledPin, LOW);
106109

107110
printHome(true, true, false);
108111

0 commit comments

Comments
 (0)