#if !defined(MQTTETHERNET_H)
#define MQTTETHERNET_H
#include <mbed.h>
#include "MQTT_mbed.h"
#include "MQTTSocket.h"
#include "WIZnetInterface.h"

class MQTTEthernet : public MQTTSocket
{
public:    
    MQTTEthernet(uint8_t* MAC, const char* IP, const char*MASK, const char* GW, SPI* spi, PinName cs, PinName reset): eth(spi, cs, reset)
    {
        wait(1);
        this->createSocket();
        eth.init(MAC,IP,MASK,GW);
        eth.connect();
    }
    
    MQTTEthernet(uint8_t* MAC, SPI* spi, PinName cs, PinName reset): eth(spi, cs, reset)
	{
		wait(1);
		this->createSocket();
		eth.init(MAC);
		eth.connect();
	}

    WIZnetInterface& getEth()
    {
        return eth;
    }
    
    void reconnect()
    {
        eth.connect();  // nothing I've tried actually works to reconnect 
    }
    
private:
    WIZnetInterface eth;
    
};

#endif
