#include <SPI.h>
#include <Ethernet.h>

#include <ArdOSC.h>

byte myMac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte myIp[]  = { 10, 0, 1, 32 };
int  serverPort  = 10000;
int destPort=12000;

int ledPin =  9;


OSCServer server;

void setup(){ 

  Serial.begin(19200);

  Ethernet.begin(myMac ,myIp); 
  server.begin(serverPort);

  //set callback function
  server.addCallback("/Secondary/Up/",&func1);

  pinMode(ledPin, OUTPUT);  
  

}

void loop(){
  
  if(server.aviableCheck()>0){
    //    Serial.println("alive! "); 
  }


}


void func1(OSCMessage *_mes){

  byte *sourceIp = _mes->getIpAddress();
  
  //get 1st argument(int32)
 int I = _mes->getArgInt32(0);

 Serial.println(I);
 
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
  delay(100);
}



