Skip to content

Commit

Permalink
Work on retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mshulman committed Jul 25, 2021
1 parent 3667929 commit e2a8b97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions Fusion_volume_control.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ int status = WL_IDLE_STATUS;
int count = 0;

void setUpSubscription() {
Serial.println("Setting up subscription");

client.begin("/signalk/v1/stream?subscribe=none");

while (!client.connected()) {
printDots();
delay(500);
; // wait to connect
}

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

// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
if (status != WL_CONNECTED) {
delay(1000); // wait a bit and try again
}
}

// print the SSID of the network you're attached to:
Expand All @@ -61,8 +71,6 @@ void setup() {
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);

Serial.println("starting WebSocket client");

}

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

Serial.println();
Serial.print("path: ");


char* completePath = const_cast<char*>(path);

MatchState ms;
Expand All @@ -119,15 +126,14 @@ static void printDots() {
count = 0;
} else {
Serial.print(".");
count = count + 1;
}
}


void loop() {
setUpSubscription();
while (client.connected()) {
// increment count for next message
count++;

// check if a message is available to be received
int messageSize = client.parseMessage();
Expand Down
2 changes: 1 addition & 1 deletion arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#define SECRET_SSID "DGWR"
#define SECRET_PASS ""
#define SECRET_PASS "gg99love"

0 comments on commit e2a8b97

Please sign in to comment.