Skip to content

Commit e2a8b97

Browse files
committed
Work on retry logic
still not working though arduino-libraries/ArduinoHttpClient#110
1 parent 3667929 commit e2a8b97

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Fusion_volume_control.ino

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ int status = WL_IDLE_STATUS;
2929
int count = 0;
3030

3131
void setUpSubscription() {
32+
Serial.println("Setting up subscription");
33+
3234
client.begin("/signalk/v1/stream?subscribe=none");
3335

3436
while (!client.connected()) {
37+
printDots();
38+
delay(500);
3539
; // wait to connect
3640
}
3741

42+
Serial.println("connected");
3843
client.beginMessage(TYPE_TEXT);
3944
client.print("{\"context\":\"vessels.self\",\"subscribe\": [{\"path\": \"entertainment.device.fusion1.output.*\"}]}");
4045
client.endMessage();
@@ -48,9 +53,14 @@ void setup() {
4853
while ( status != WL_CONNECTED) {
4954
Serial.print("Attempting to connect to Network named: ");
5055
Serial.println(ssid); // print the network name (SSID);
56+
Serial.print(". Password: ");
57+
Serial.println(pass);
5158

5259
// Connect to WPA/WPA2 network:
5360
status = WiFi.begin(ssid, pass);
61+
if (status != WL_CONNECTED) {
62+
delay(1000); // wait a bit and try again
63+
}
5464
}
5565

5666
// print the SSID of the network you're attached to:
@@ -61,8 +71,6 @@ void setup() {
6171
IPAddress ip = WiFi.localIP();
6272
Serial.print("IP Address: ");
6373
Serial.println(ip);
64-
65-
Serial.println("starting WebSocket client");
6674

6775
}
6876

@@ -93,8 +101,7 @@ void printVolumeUpdates(String message) {
93101
int volume = updates_0["values"][0]["value"]; // 10
94102

95103
Serial.println();
96-
Serial.print("path: ");
97-
104+
98105
char* completePath = const_cast<char*>(path);
99106

100107
MatchState ms;
@@ -119,15 +126,14 @@ static void printDots() {
119126
count = 0;
120127
} else {
121128
Serial.print(".");
129+
count = count + 1;
122130
}
123131
}
124132

125133

126134
void loop() {
127135
setUpSubscription();
128136
while (client.connected()) {
129-
// increment count for next message
130-
count++;
131137

132138
// check if a message is available to be received
133139
int messageSize = client.parseMessage();

arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#define SECRET_SSID "DGWR"
2-
#define SECRET_PASS ""
2+
#define SECRET_PASS "gg99love"

0 commit comments

Comments
 (0)