The DICE_Ethernet is basically the https://www.arduino.cc/en/Reference/Ethernet library but with minor adaptation for the dice-ETH architecture. It also simplifies the begin()
function by creating an MAC address automatically from the devices serial number so that it is made sure to be an unique number in the network (see examples in the IDE and below).
The HTTP_Client class EthernetHTTPClient
simplifies http requests via the ethernet interface.
to use the library
#include "DICE_Ethernet.h"
this automatically creates the global objectEthernet
that can be used for the further ethernet operations.
Example
#include "DICE_Ethernet.h"
EthernetHTTPClient myClient;
void setup()
{
while(!Serial);
Serial.println("EthernetHTTPClient Example");
if(Ethernet.begin() == 0)
{
Serial.println("Could not init ethernet");
while(1){ yield(); };
}
int iResponse = myClient.httpGET("di-ce.de", "/downloads/dice-ascii-logo.txt");
if( iResponse <= 0)
Serial.println("Error: "+String(iResponse));
else
{
while(myClient.connected() || myClient.available())
{
while(myClient.available() > 0)
{
if( Serial.availableForWrite())
{
char c = myClient.read();
Serial.write(c);
}
yield();
}
yield();
}
}
Serial.println("\n- disconnected from server -");
myClient.stop();
}
void loop()
{ }
Further information
https://www.arduino.cc/en/Reference/Ethernet – the compatible base library
Arduino – EthernetIPAddress
HTTP_Client Class – providing EthernetHTTPClient
that simplifies http tasks