- AutoPtr
- RefCountedObject
- Base64Encoder
- Base64Decoder
- Checksum
- HttpRequest
- HttpClient
- DateTime
- UUID
- DigestEngine
- MD5Engine
- SHA1Engine
- HMACEngine
The following sketch is used to test the library.
#include <SPI.h>
#include <Ethernet.h>
#include <WiFi.h>
#include <StandardCplusplus.h>
#include <iostream>
#include <SHttpClient.h>
#include <DateTime.h>
#include <UUID.h>
#include <tut.hpp>
namespace std
{
ohserialstream cerr(Serial);
ohserialstream cout(Serial);
}
// A proper unique mac address is critical to having a stable UUID generated
// for events published to Sidecar service. Please use the MAC address
// printed on the sticker on the sheild
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip( 192, 168, 0, 177 );
// Invoke this in setup if you are using ethernet shield for networking
void initEthernet()
{
if ( Ethernet.begin( mac ) == 0 )
{
std::cout << F( "Failed to configure Ethernet using DHCP" ) << std::endl;
Ethernet.begin( mac, ip );
}
// give the Ethernet shield a second to initialize:
std::cout << F( "Connecting to network..." ) << std::endl;
delay( 1000 );
// Initialise network API to use Ethernet
spt::net::initNetworkType( spt::net::Ethernet );
}
void initUUID()
{
// Initialise UUID engine
// If using WiFi, the WiFi api provides a way to look up current MAC
// address. That would be better to get proper UUID values.
spt::UUID::init( mac );
}
// Invoke this in setup if you are using ethernet shield for networking
void initWiFi()
{
// Perform normal WiFi setup
// Initialise network API to use WiFi
spt::net::initNetworkType( spt::net::WiFi );
}
int freeRam()
{
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
void setup()
{
Serial.begin( 57600 );
initEthernet();
initUUID();
std::cout << F( "Running unit test suite" ) << std::endl;
delay( 1000 );
tut::runTests();
}
void loop()
{
std::cout << F( "Current time: " ) << spt::net::DateTime::singleton() << std::endl;
std::cout << F( "Time based uuid: " ) << spt::UUID::create() << std::endl;
std::cout << F( "Free SRAM: " ) << freeRam() << std::endl;
delay( 60000 );
}