 #include <JsonParser.h>
 #include <SPI.h>
 #include <Ethernet.h>
+#include <EthernetUdp.h>
 #include <PubSubClient.h>
 #include <VirtualWire.h>
 #include <x10.h>

  return client.publish(getString(STR_GATEWAY_RAM), (uint8_t*)mem, strlen(mem), true);
}

//Return size of PROGMEM variable
// byte size(prog_uchar *var) {
//   return sizeof(var)-1;

const char STR_L1_STATUS[] PROGMEM = "home/light/1/status";
const char STR_L1_BRIGHTNESS[] PROGMEM = "home/light/1/status/brightness";

const char STR_X10_STATUS[] PROGMEM = "home/x10/status";
const char STR_RFSWITCH_STATUS[] PROGMEM = "home/rfswitch/status/raw";

//PROGMEM Subscription topics. Automatically subscribe to all of them at the start
#define STR_TOPICS_SIZE 3  //Needs to reflect the actual number of topics needed
prog_char P_STR_SUB_L_1[] PROGMEM = {"home/light/+/action/#"};
prog_char P_STR_SUB_X10[] PROGMEM = {"home/x10/action/#"};
prog_char P_STR_SUB_RFSWITCH[] PROGMEM = {"home/rfswitch/action"};

//Holds all the subscriptions.
PROGMEM const char *string_topics[] = {P_STR_SUB_L_1, P_STR_SUB_X10, P_STR_SUB_RFSWITCH };


//House Codes Topics
prog_char topic_house[] PROGMEM = {"ABCDEFGHIJKLMNOP"};
//House Code Constants
PROGMEM prog_uint8_t constant_house[] = {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P};

//Unit Code Constant
PROGMEM prog_uint8_t constant_unit[] = {UNIT_1, UNIT_2, UNIT_3, UNIT_4, UNIT_5, UNIT_6, UNIT_7, UNIT_8, UNIT_9, UNIT_10, UNIT_11, UNIT_12, UNIT_13, UNIT_14, UNIT_15, UNIT_16};

//Command Codes
prog_char CMD_1[] PROGMEM = {"ALL_LIGHTS_ON"};
prog_char CMD_2[] PROGMEM = {"ALL_UNITS_OFF"};
prog_char CMD_3[] PROGMEM = {"ON"};
prog_char CMD_4[] PROGMEM = {"OFF"};
prog_char CMD_5[] PROGMEM = {"DIM"};
prog_char CMD_6[] PROGMEM = {"BRIGHT"};
prog_char CMD_7[] PROGMEM = {"ALL_LIGHTS_OFF"};
prog_char CMD_8[] PROGMEM = {"EXTENDED_CODE"};
prog_char CMD_9[] PROGMEM = {"HAIL_REQUEST"};
prog_char CMD_10[] PROGMEM = {"HAIL_ACKNOWLEDGE"};
prog_char CMD_11[] PROGMEM = {"PRE_SET_DIM"};
prog_char CMD_12[] PROGMEM = {"EXTENDED_DATA"};
prog_char CMD_13[] PROGMEM = {"STATUS_ON"};
prog_char CMD_14[] PROGMEM = {"STATUS_OFF"};
prog_char CMD_15[] PROGMEM = {"STATUS_REQUEST"};

//Array of Command Codes
PROGMEM const char *topic_command[] = {CMD_1,CMD_2,CMD_3,CMD_4,CMD_5,CMD_6,CMD_7,CMD_8,CMD_9,CMD_10,CMD_11,CMD_12,CMD_13,CMD_14,CMD_15};
//Command Code constants
PROGMEM prog_uint8_t constant_command[] = {ALL_LIGHTS_ON,ALL_UNITS_OFF,ON,OFF,DIM,BRIGHT,ALL_LIGHTS_OFF,EXTENDED_CODE,HAIL_REQUEST,HAIL_ACKNOWLEDGE,PRE_SET_DIM,EXTENDED_DATA,STATUS_ON,STATUS_OFF,STATUS_REQUEST};

//The section in the MQTT topic array that the specific X10 codes are
#define X10_HOUSE_N   3
#define X10_UNIT_N    X10_HOUSE_N + 1
#define X10_CMD_N     X10_UNIT_N + 1


//Hardcoded network address
byte mac[]    = { 0x00, 0x00, 0x10, 0x66, 0x66, 0x66 };
byte server[] = { 192, 168, 0, 175 };
byte ip[]     = { 192, 168, 0, 20 };
