Skip to content

Commit 0651617

Browse files
Improve StandardFirmataEthernet logging
1 parent b7af0a4 commit 0651617

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

examples/StandardFirmataEthernet/StandardFirmataEthernet.ino

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved.
1212
Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved.
1313
Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.
14-
Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
14+
Copyright (C) 2009-2017 Jeff Hoefs. All rights reserved.
1515
1616
This library is free software; you can redistribute it and/or
1717
modify it under the terms of the GNU Lesser General Public
@@ -20,7 +20,7 @@
2020
2121
See file LICENSE.txt for further informations on licensing terms.
2222
23-
Last updated October 16th, 2016
23+
Last updated August 13th, 2017
2424
*/
2525

2626
/*
@@ -832,6 +832,17 @@ void systemResetCallback()
832832
isResetting = false;
833833
}
834834

835+
void printEthernetStatus()
836+
{
837+
DEBUG_PRINT("Local IP Address: ");
838+
IPAddress ip = Ethernet.localIP();
839+
DEBUG_PRINTLN(ip);
840+
#ifdef remote_ip
841+
DEBUG_PRINT("Connecting to server at: ");
842+
DEBUG_PRINTLN(remote_ip);
843+
#endif
844+
}
845+
835846
/*
836847
* StandardFirmataEthernet communicates with Ethernet shields over SPI. Therefore all
837848
* SPI pins must be set to IGNORE. Otherwise Firmata would break SPI communication.
@@ -868,15 +879,14 @@ void initTransport()
868879
#ifdef local_ip
869880
Ethernet.begin((uint8_t *)mac, local_ip); //start ethernet
870881
#else
871-
Ethernet.begin((uint8_t *)mac); //start ethernet using dhcp
882+
DEBUG_PRINTLN("Local IP will be requested from DHCP...");
883+
//start ethernet using dhcp
884+
if (Ethernet.begin((uint8_t *)mac) == 0) {
885+
DEBUG_PRINTLN("Failed to configure Ethernet using DHCP");
886+
}
872887
#endif
873888
#endif
874-
875-
DEBUG_PRINTLN("connecting...");
876-
877-
DEBUG_PRINT("IP Address: ");
878-
IPAddress ip = Ethernet.localIP();
879-
DEBUG_PRINTLN(ip);
889+
printEthernetStatus();
880890
}
881891

882892
void initFirmata()
@@ -895,7 +905,7 @@ void initFirmata()
895905

896906
// start up Network Firmata:
897907
Firmata.begin(stream);
898-
systemResetCallback(); // reset to default config
908+
systemResetCallback(); // Initialize default configuration
899909
}
900910

901911
void setup()

utility/EthernetClientStream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ EthernetClientStream::maintain()
130130
connected = host ? client.connect(host, port) : client.connect(ip, port);
131131
if (!connected) {
132132
time_connect = millis();
133-
DEBUG_PRINTLN("connection failed. attempting to reconnect...");
133+
DEBUG_PRINTLN("Connection failed. Attempting to reconnect...");
134134
} else {
135-
DEBUG_PRINTLN("connected");
135+
DEBUG_PRINTLN("Connected");
136136
}
137137
}
138138
return connected;

utility/EthernetServerStream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ bool EthernetServerStream::connect_client()
7373
if ( !newClient ) return false;
7474
client = newClient;
7575
connected = true;
76+
DEBUG_PRINTLN("Connected");
7677
return true;
7778
}
7879

0 commit comments

Comments
 (0)