 Copyright (c) Nicholas Tyrrell, Bournemouth University
 Code inspired by http://www.eclipse.org/paho/clients/c/embedded/
 */
+
+#define MQTTCLIENT_QOS2 1
 
 #include <SPI.h>
 #include <Ethernet2.h>

		digitalWrite(leds[1], HIGH);
		//set current state to caution
		currentRoomState = CAUTION;
		returnCode = publishToBroker("state", "caution");
	}
	//else if active button pressed
	else if (newRoomState == ACTIVE) {

	returnCode = ipstack.connect(host, port);
	//if IP connection successful
	if (returnCode == 1) {
		//dynamically set the room's state for will message topic
		char willTopicBuffer[100];
		strcpy(willTopicBuffer, mainTopic);
		strcat(willTopicBuffer, "/");
		strcat(willTopicBuffer, room);
		strcat(willTopicBuffer, "/state");

		//initialise MQTT connection data
		MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
		data.willFlag = 1;
		data.MQTTVersion = 4;
		data.clientID.cstring = (char*)"sensor-1";
		data.will.topicName.cstring = (char*)willTopicBuffer;
		data.will.qos = 2;
		data.will.retained = 1;
		data.will.message.cstring = (char*)"error";
		//connect to MQTT broker
		returnCode = mqttClient.connect(data);
		//if MQTT connection successful
