Print Function Result

Hello,
I want to understand why I cannot print the text from the function Ethernet.hardwareStatus() in the way attempted below.

Sure, i can do it using the if statement below, but what is the reason why i cannot simply output the result from this function in the same way as Ethernet.localIP() for instance? Of course, I don’t actually need to do it this way, but Im looking for the fundamental reason behind why I seem unable to do this, as i’m clearly missing something… Many thanks.

#include <Ethernet.h>
#include <SPI.h>

EthernetServer server(80);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(192, 168, 0, 68);

//EthernetClient client;

char status = Ethernet.hardwareStatus;

void setup() {


// Start Ehternet
 Ethernet.begin(mac,ip);
 server.begin();
// Start Serial Port
 Serial.begin(9600);
 Serial.println("Setup...");
 Serial.println("ip is: ");
 Serial.println(Ethernet.localIP());
 Serial.println("DNS is: ");
 Serial.println(Ethernet.dnsServerIP());

//everthing works fine to this point.

//I cannot obtain the value from Ethernet.hardwareStatus() using the lines below.
 
 Serial.println("Ethernet Hardward Status is: ");
 Serial.println(Ethernet.hardwareStatus());
 Serial.println(status); 

//"EthernetW5100" seems to be only detected through use of the if statement.

if (Ethernet.hardwareStatus() == EthernetW5100) {
   Serial.println("W5100 Ethernet controller detected.");
   
  }

What happens when you try ?
What does the function return ?

Ethernet.hardwareStatus() returns a number that represents the status, not a string telling you what it is.

it returns either'

Ethernet Hardward Status is:
1

W5100 Ethernet controller detected.

hardwareStatus returns the type EthernetHardwareStatus

because the method is declared as:

static EthernetHardwareStatus hardwareStatus();

and EthernetHardwareStatus is just an enumeration:

enum EthernetHardwareStatus {
EthernetNoHardware,
EthernetW5100,
EthernetW5200,
EthernetW5500
};

so you will get "numbers" 0 .. 3 ... no text.

See: Ethernet/Ethernet.h at master · arduino-libraries/Ethernet · GitHub

I see, thankyou.

This doesn't do what you think it does:

char status = Ethernet.hardwareStatus;

What you intended was probably:

char status = Ethernet.hardwareStatus();

I'm not sure that would actually work though as you're calling it before Ethernet.begin. Try it and see.