Skip to content

Improve StandardFirmataEthernet logging #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions examples/StandardFirmataEthernet/StandardFirmataEthernet.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved.
Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved.
Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.
Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
Copyright (C) 2009-2017 Jeff Hoefs. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -20,7 +20,7 @@

See file LICENSE.txt for further informations on licensing terms.

Last updated October 16th, 2016
Last updated August 13th, 2017
*/

/*
Expand Down Expand Up @@ -832,6 +832,17 @@ void systemResetCallback()
isResetting = false;
}

void printEthernetStatus()
{
DEBUG_PRINT("Local IP Address: ");
IPAddress ip = Ethernet.localIP();
DEBUG_PRINTLN(ip);
#ifdef remote_ip
DEBUG_PRINT("Connecting to server at: ");
DEBUG_PRINTLN(remote_ip);
#endif
}

/*
* StandardFirmataEthernet communicates with Ethernet shields over SPI. Therefore all
* SPI pins must be set to IGNORE. Otherwise Firmata would break SPI communication.
Expand Down Expand Up @@ -868,15 +879,14 @@ void initTransport()
#ifdef local_ip
Ethernet.begin((uint8_t *)mac, local_ip); //start ethernet
#else
Ethernet.begin((uint8_t *)mac); //start ethernet using dhcp
DEBUG_PRINTLN("Local IP will be requested from DHCP...");
//start ethernet using dhcp
if (Ethernet.begin((uint8_t *)mac) == 0) {
DEBUG_PRINTLN("Failed to configure Ethernet using DHCP");
}
#endif
#endif

DEBUG_PRINTLN("connecting...");

DEBUG_PRINT("IP Address: ");
IPAddress ip = Ethernet.localIP();
DEBUG_PRINTLN(ip);
printEthernetStatus();
}

void initFirmata()
Expand All @@ -895,7 +905,7 @@ void initFirmata()

// start up Network Firmata:
Firmata.begin(stream);
systemResetCallback(); // reset to default config
systemResetCallback(); // Initialize default configuration
}

void setup()
Expand Down
4 changes: 2 additions & 2 deletions utility/EthernetClientStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ EthernetClientStream::maintain()
connected = host ? client.connect(host, port) : client.connect(ip, port);
if (!connected) {
time_connect = millis();
DEBUG_PRINTLN("connection failed. attempting to reconnect...");
DEBUG_PRINTLN("Connection failed. Attempting to reconnect...");
} else {
DEBUG_PRINTLN("connected");
DEBUG_PRINTLN("Connected");
}
}
return connected;
Expand Down
1 change: 1 addition & 0 deletions utility/EthernetServerStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ bool EthernetServerStream::connect_client()
if ( !newClient ) return false;
client = newClient;
connected = true;
DEBUG_PRINTLN("Connected");
return true;
}

Expand Down