Sans Pareil Technologies, Inc.

Key To Your Business

We have been developing custom libraries for Arduino. We have borrowed heavily from Poco while implementing our own libraries (some of which are thin wrappers around native Arduino and Poco classes).


The following sketch is used to test the library.

    1: #include <SPI.h>
    2: #include <Ethernet.h>
    3: #include <WiFi.h>
    4:
    5: #include <StandardCplusplus.h>
    6: #include <iostream>
    7:
    8: #include <SHttpClient.h>
    9: #include <DateTime.h>
   10: #include <UUID.h>
   11:
   12: #include <tut.hpp>
   13:
   14: namespace std
   15: {
   16:   ohserialstream cerr(Serial);
   17:   ohserialstream cout(Serial);
   18: }
   19:
   20: // A proper unique mac address is critical to having a stable UUID generated
   21: // for events published to Sidecar service.  Please use the MAC address
   22: // printed on the sticker on the sheild
   23: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
   24:
   25: // Set the static IP address to use if the DHCP fails to assign
   26: IPAddress ip( 192, 168, 0, 177 );
   27:
   28:
   29: // Invoke this in setup if you are using ethernet shield for networking
   30: void initEthernet()
   31: {
   32:   if ( Ethernet.begin( mac ) == 0 )
   33:   {
   34:     std::cout << F( "Failed to configure Ethernet using DHCP" ) << std::endl;
   35:     Ethernet.begin( mac, ip );
   36:   }
   37:
   38:   // give the Ethernet shield a second to initialize:
   39:   std::cout << F( "Connecting to network..." ) << std::endl;
   40:   delay( 1000 );
   41:
   42:   // Initialise network API to use Ethernet
   43:   spt::net::initNetworkType( spt::net::Ethernet );
   44: }
   45:
   46:
   47: void initUUID()
   48: {
   49:   // Initialise UUID engine
   50:   // If using WiFi, the WiFi api provides a way to look up current MAC
   51:   // address.  That would be better to get proper UUID values.
   52:   spt::UUID::init( mac );
   53: }
   54:
   55:
   56: // Invoke this in setup if you are using ethernet shield for networking
   57: void initWiFi()
   58: {
   59:   // Perform normal WiFi setup
   60:
   61:   // Initialise network API to use WiFi
   62:   spt::net::initNetworkType( spt::net::WiFi );
   63: }
   64:
   65:
   66: int freeRam()
   67: {
   68:   extern int __heap_start, *__brkval;
   69:   int v;
   70:   return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
   71: }
   72:
   73:
   74: void setup()
   75: {
   76:   Serial.begin( 57600 );
   77:
   78:   initEthernet();
   79:   initUUID();
   80:
   81:   std::cout << F( "Running unit test suite" ) << std::endl;
   82:   delay( 1000 );
   83:   tut::runTests();
   84: }
   85:
   86: void loop()
   87: {
   88:   std::cout << F( "Current time: " ) << spt::net::DateTime::singleton() << std::endl;
   89:   std::cout << F( "Time based uuid: " ) << spt::UUID::create() << std::endl;
   90:   std::cout << F( "Free SRAM: " ) << freeRam() << std::endl;
   91:   delay( 60000 );
   92: }