-
Notifications
You must be signed in to change notification settings - Fork 8
/
OSCServer.cpp
78 lines (53 loc) · 1.55 KB
/
OSCServer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
ArdOSC 2.1 - OSC Library for Arduino.
-------- Lisence -----------------------------------------------------------
ArdOSC
The MIT License
Copyright (c) 2009 - 2011 recotana( http://recotana.com ) All right reserved
*/
#include <stdlib.h>
#include "OSCcommon/OSCServer.h"
OSCServer::OSCServer(WiFly* wiFly) :
wiFly(wiFly)
{
}
OSCServer::~OSCServer(void)
{
}
int OSCServer::availableCheck(
int timeOut //adjust the timeout to your Baudrate for best performance.
)
{
if( wiFly->available() == 0 )
{
return -1;
}
//Serial.println("building osc message");delay(40);
OSCMessage rcvMes;
//get max receive data
//Serial.println("reading data from wifly...");delay(10);
wiFly->readBufTimeout(_rcvData, kMaxRecieveData,timeOut);
//Serial.println(_rcvData);
//clear input buffer
//Serial.println("flushing remaining data from wifly...");delay(10);
wiFly->flushRx(1);
//decode message
//Serial.println("fdecoding osc message...");delay(10);
if( _decoder.decode(&rcvMes, (uint8_t*)_rcvData) < 0 )
{
return -1;
}
//Serial.println("Adress:");
//Serial.println(rcvMes.getOSCAddress());
//Serial.println("matching to routing table...");delay(10);
_adrMatch.paternComp(&rcvMes);
return 1;
}
void OSCServer::addCallback(char *_adr , Pattern::AdrFunc _func )
{
_adrMatch.addOscAddress(_adr, _func);
}
void OSCServer::addOscMessageSink(OscMessageSink* sink )
{
_adrMatch.addOscMessageSink(sink);
}