75 lines
1.4 KiB
C++
75 lines
1.4 KiB
C++
#include "WiFlyHQ.h"
|
|
#include "ArdOSCForWiFlyHQ.h"
|
|
|
|
const char mySSID[] = "hangar_nau3";
|
|
const char myPassword[] = "m1cr0fug4s";
|
|
const char *IP = "172.26.0.255";
|
|
//const char *IP = "192.168.1.125";
|
|
|
|
const uint16_t outPort = 8000;
|
|
const uint16_t localPort = 9000;
|
|
|
|
WiFly wifly;
|
|
OSCClient client(&wifly);
|
|
//create new osc message
|
|
OSCMessage global_mes;
|
|
//some variables to send...
|
|
int v3=10;
|
|
float v4=10.0;
|
|
char str1[]="simple send 1!";
|
|
|
|
int v1=0;
|
|
float v2=0.0;
|
|
|
|
|
|
void ini_wifly()
|
|
{
|
|
char buf[32];
|
|
wifly.begin(&Serial);
|
|
|
|
if (!wifly.isAssociated()) {
|
|
/* Setup for UDP packets, sent automatically */
|
|
wifly.setIpProtocol(WIFLY_PROTOCOL_UDP);
|
|
wifly.setHost(IP, outPort); // Send UDP packet to this server and port
|
|
wifly.setPort(localPort); // listen in this local port
|
|
/* Setup the WiFly to connect to a wifi network */
|
|
wifly.setSSID(mySSID);
|
|
wifly.setPassphrase(myPassword);
|
|
//wifly.setKey(mykey); // modo WEP
|
|
wifly.enableDHCP();
|
|
wifly.join();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void setup()
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
ini_wifly();
|
|
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
//note that the destination adress is set by setting the remote host of the wifly!
|
|
global_mes.beginMessage("/glove/send1");
|
|
global_mes.addArgInt32(v1);
|
|
global_mes.addArgFloat(v2);
|
|
global_mes.addArgString(str1);
|
|
|
|
client.send(&global_mes);
|
|
|
|
global_mes.flush(); //object data clear
|
|
|
|
v1++;
|
|
v2 += 0.1;
|
|
|
|
delay(50);
|
|
|
|
}
|
|
|
|
|