 unsigned int buttonThresCounter[MAX_NUMBER_OF_BUTTONS];
 int buttonsAllocated=0;
 int frame = 0;
-WiFiUDP udp;
-IPAddress serverIP;
-
-
-void init_header() {
-  int pos = 0;
-  for(int i=0; i<4; i++) {
-    message[pos] = MAGIC[i];
-    pos += 1;
-  }
-  long version = htonl(PROTOCOL_VERSION);
-  for(int i=0; i<4; i++) {
-    message[pos] = ((char *)&version)[i];
-    pos += 1;
-  }
-  int protocol_type = htons(1); //TODO: read or define 1 elsewhere
-  for(int i=0; i<2; i++) {
-    message[pos] = ((char *)&protocol_type)[i];
-    pos += 1;
-  }
-  for(int i=0; i<4; i++) {
-    message[pos] = random(256);
-    pos += 1;
-  }
-  // TODO: check ID construction
-  byte CLIENT_ID[4] = {0,0,0,2}; // button id is 2
-  for(int i=0; i<4; i++) {
-    message[pos] = CLIENT_ID[i];
-    pos += 1;
-  }
-}
+Libni_Sender *libni_sender;
 
 void initButton( int buttonIndex, unsigned char code, int pin, bool pullup ) {
   buttonCode[ buttonIndex ] = code;

#include <ESP8266WiFi.h>
#include <lwip/ip.h> // for endian conversion htons, htonl, ...
#include <WiFiUdp.h>

const char* ssid     = "iotempire";
const char* password = "internetofthings";

const char * DESTINATION_HOST = "192.168.23.175";
int DESTINATION_PORT = 19877;

const char *MAGIC = "LBNI"; // magic identifier for Game Network Controller
const int PROTOCOL_VERSION = 1;
const int NUMBER_OF_BUTTONS = 256;
const int NUMBER_OF_BUTTON_BYTES = (NUMBER_OF_BUTTONS + 7)/8;
const int NUMBER_OF_AXIS = 16;
const int NUMBER_OF_AXIS_BYTES = NUMBER_OF_AXIS * 2;
const int MAX_BUFFER_SIZE = 128;
const int BUFFER_HEADER_SIZE = 16;
byte message[MAX_BUFFER_SIZE];
const int MAX_NUMBER_OF_BUTTONS = 16;
const int BUTTON_THRES = 16; // how many times has an on be counted to assume this button is on
//const int STATUS_LED = 2;

    //Serial.println("LOW");
  }

  delay(5); // or yield();
}
