support OSC-string

Dependents:   OSCtoCVConverter

Fork of OSC by Toby Harris

Committer:
tobyspark
Date:
Sun Apr 15 15:50:42 2012 +0000
Revision:
0:fdea65150534
Child:
1:63b72e393989
mbedOSC__spk as program to OSC as library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tobyspark 0:fdea65150534 1 /*
tobyspark 0:fdea65150534 2 mbedOSC.cpp
tobyspark 0:fdea65150534 3 */
tobyspark 0:fdea65150534 4
tobyspark 0:fdea65150534 5 #include "mbed.h"
tobyspark 0:fdea65150534 6 #include "mbedOSC.h"
tobyspark 0:fdea65150534 7 #include "stdarg.h"
tobyspark 0:fdea65150534 8
tobyspark 0:fdea65150534 9 OSCMessage::OSCMessage() {
tobyspark 0:fdea65150534 10 // Initialize host address and port by default (as if this where the receiver message):
tobyspark 0:fdea65150534 11 // host=new Host(IpAddr(10, 0, 0, 1), DEFAULT_RECEIVE_PORT, NULL);
tobyspark 0:fdea65150534 12 }
tobyspark 0:fdea65150534 13
tobyspark 0:fdea65150534 14 void OSCMessage::setPort(uint16_t _port){
tobyspark 0:fdea65150534 15 host.setPort(_port);
tobyspark 0:fdea65150534 16 }
tobyspark 0:fdea65150534 17
tobyspark 0:fdea65150534 18
tobyspark 0:fdea65150534 19 void OSCMessage::setIp(uint8_t *_ip){
tobyspark 0:fdea65150534 20 host.setIp(IpAddr(_ip[0], _ip[1], _ip[2], _ip[3]));
tobyspark 0:fdea65150534 21 }
tobyspark 0:fdea65150534 22
tobyspark 0:fdea65150534 23
tobyspark 0:fdea65150534 24
tobyspark 0:fdea65150534 25 void OSCMessage::setIp( uint8_t _ip1,
tobyspark 0:fdea65150534 26 uint8_t _ip2,
tobyspark 0:fdea65150534 27 uint8_t _ip3,
tobyspark 0:fdea65150534 28 uint8_t _ip4 ){
tobyspark 0:fdea65150534 29
tobyspark 0:fdea65150534 30 host.setIp(IpAddr(_ip1, _ip2, _ip3, _ip4));
tobyspark 0:fdea65150534 31 }
tobyspark 0:fdea65150534 32
tobyspark 0:fdea65150534 33 const IpAddr& OSCMessage::getIp(){
tobyspark 0:fdea65150534 34 return host.getIp();
tobyspark 0:fdea65150534 35 }
tobyspark 0:fdea65150534 36
tobyspark 0:fdea65150534 37
tobyspark 0:fdea65150534 38 const int& OSCMessage::getPort(){
tobyspark 0:fdea65150534 39 return host.getPort();
tobyspark 0:fdea65150534 40 }
tobyspark 0:fdea65150534 41
tobyspark 0:fdea65150534 42
tobyspark 0:fdea65150534 43
tobyspark 0:fdea65150534 44 uint8_t OSCMessage::getAddressNum(){
tobyspark 0:fdea65150534 45
tobyspark 0:fdea65150534 46 return addressNum;
tobyspark 0:fdea65150534 47 }
tobyspark 0:fdea65150534 48
tobyspark 0:fdea65150534 49
tobyspark 0:fdea65150534 50 uint8_t OSCMessage::getArgNum(){
tobyspark 0:fdea65150534 51
tobyspark 0:fdea65150534 52 return argNum;
tobyspark 0:fdea65150534 53 }
tobyspark 0:fdea65150534 54
tobyspark 0:fdea65150534 55
tobyspark 0:fdea65150534 56
tobyspark 0:fdea65150534 57 char * OSCMessage::getAddress(uint8_t _index){
tobyspark 0:fdea65150534 58 if(_index>MAX_ADDRESS) _index=MAX_ADDRESS-1;
tobyspark 0:fdea65150534 59 return address[_index];
tobyspark 0:fdea65150534 60
tobyspark 0:fdea65150534 61 }
tobyspark 0:fdea65150534 62
tobyspark 0:fdea65150534 63
tobyspark 0:fdea65150534 64
tobyspark 0:fdea65150534 65 char * OSCMessage::getTopAddress(){
tobyspark 0:fdea65150534 66
tobyspark 0:fdea65150534 67 return getAddress(0);
tobyspark 0:fdea65150534 68
tobyspark 0:fdea65150534 69 }
tobyspark 0:fdea65150534 70
tobyspark 0:fdea65150534 71
tobyspark 0:fdea65150534 72 char * OSCMessage::getSubAddress(){
tobyspark 0:fdea65150534 73
tobyspark 0:fdea65150534 74 return getAddress(1);
tobyspark 0:fdea65150534 75
tobyspark 0:fdea65150534 76 }
tobyspark 0:fdea65150534 77
tobyspark 0:fdea65150534 78
tobyspark 0:fdea65150534 79 char OSCMessage::getTypeTag(uint8_t _index){
tobyspark 0:fdea65150534 80 if(_index>MAX_ARG) _index=MAX_ARG-1;
tobyspark 0:fdea65150534 81 return typeTag[_index];
tobyspark 0:fdea65150534 82 }
tobyspark 0:fdea65150534 83
tobyspark 0:fdea65150534 84
tobyspark 0:fdea65150534 85 int32_t OSCMessage::getArgInt(uint8_t _index){
tobyspark 0:fdea65150534 86 int32_t *value;
tobyspark 0:fdea65150534 87 if(_index > argNum) _index=argNum;
tobyspark 0:fdea65150534 88 value = (int32_t *)arg[_index]; // cast to int32_t
tobyspark 0:fdea65150534 89 return *value;
tobyspark 0:fdea65150534 90 }
tobyspark 0:fdea65150534 91
tobyspark 0:fdea65150534 92
tobyspark 0:fdea65150534 93 double OSCMessage::getArgFloat(uint8_t _index){
tobyspark 0:fdea65150534 94 double *value;
tobyspark 0:fdea65150534 95 if(_index > argNum) _index=argNum;
tobyspark 0:fdea65150534 96 value = (double *)arg[_index];
tobyspark 0:fdea65150534 97 return *value;
tobyspark 0:fdea65150534 98 }
tobyspark 0:fdea65150534 99
tobyspark 0:fdea65150534 100
tobyspark 0:fdea65150534 101 void OSCMessage::setTopAddress(char *_address){
tobyspark 0:fdea65150534 102 address[0]=_address;
tobyspark 0:fdea65150534 103 address[1]=0;
tobyspark 0:fdea65150534 104 addressNum=1; // Note: this "erases" the subaddress! (is this a good idea?)
tobyspark 0:fdea65150534 105 }
tobyspark 0:fdea65150534 106
tobyspark 0:fdea65150534 107
tobyspark 0:fdea65150534 108 void OSCMessage::setSubAddress(char *_address){
tobyspark 0:fdea65150534 109 address[1]=_address;
tobyspark 0:fdea65150534 110 addressNum=2; // Note: this assumes the top address was already set!
tobyspark 0:fdea65150534 111 }
tobyspark 0:fdea65150534 112
tobyspark 0:fdea65150534 113
tobyspark 0:fdea65150534 114
tobyspark 0:fdea65150534 115 void OSCMessage::setAddress(char *_topAddress,char *_subAddress){
tobyspark 0:fdea65150534 116 setTopAddress(_topAddress);
tobyspark 0:fdea65150534 117 setSubAddress(_subAddress);
tobyspark 0:fdea65150534 118 addressNum=2; // (unnecessary...)
tobyspark 0:fdea65150534 119 }
tobyspark 0:fdea65150534 120
tobyspark 0:fdea65150534 121
tobyspark 0:fdea65150534 122 void OSCMessage::setAddress(uint8_t _index, char *_address){
tobyspark 0:fdea65150534 123 if(_index>MAX_ADDRESS) _index=MAX_ADDRESS-1;
tobyspark 0:fdea65150534 124 address[_index]=_address;
tobyspark 0:fdea65150534 125 addressNum=_index+1;
tobyspark 0:fdea65150534 126 }
tobyspark 0:fdea65150534 127
tobyspark 0:fdea65150534 128
tobyspark 0:fdea65150534 129
tobyspark 0:fdea65150534 130 void OSCMessage::setArgs(char *types,...){
tobyspark 0:fdea65150534 131
tobyspark 0:fdea65150534 132 va_list argList;
tobyspark 0:fdea65150534 133
tobyspark 0:fdea65150534 134 argNum = strlen(types);
tobyspark 0:fdea65150534 135 if(argNum>MAX_ARG) argNum=MAX_ARG-1;
tobyspark 0:fdea65150534 136
tobyspark 0:fdea65150534 137 va_start( argList, types );
tobyspark 0:fdea65150534 138 for(uint8_t i=0 ; i < argNum ; i++){
tobyspark 0:fdea65150534 139
tobyspark 0:fdea65150534 140 typeTag[i]=types[i];
tobyspark 0:fdea65150534 141
tobyspark 0:fdea65150534 142 switch(types[i]) {
tobyspark 0:fdea65150534 143 case 'i':
tobyspark 0:fdea65150534 144 arg[i]=(uint32_t *)va_arg(argList, uint32_t *);
tobyspark 0:fdea65150534 145 break;
tobyspark 0:fdea65150534 146 case 'f':
tobyspark 0:fdea65150534 147 arg[i]=va_arg(argList, double *);
tobyspark 0:fdea65150534 148 break;
tobyspark 0:fdea65150534 149 }
tobyspark 0:fdea65150534 150
tobyspark 0:fdea65150534 151 }
tobyspark 0:fdea65150534 152
tobyspark 0:fdea65150534 153 }
tobyspark 0:fdea65150534 154
tobyspark 0:fdea65150534 155 // ================================================================================================================================================
tobyspark 0:fdea65150534 156 // ==================================== OSCClass for sending and receiving OSC messages using UDP protocol =======================================
tobyspark 0:fdea65150534 157 // ================================================================================================================================================
tobyspark 0:fdea65150534 158 //The class define an object wrapping the UDP functions to send and receive OSC messages
tobyspark 0:fdea65150534 159
tobyspark 0:fdea65150534 160 OSCClass::OSCClass(){
tobyspark 0:fdea65150534 161 udpRec.setOnEvent(this, &OSCClass::onUDPSocketEvent);
tobyspark 0:fdea65150534 162 newMessage=false;
tobyspark 0:fdea65150534 163 }
tobyspark 0:fdea65150534 164
tobyspark 0:fdea65150534 165 OSCClass::OSCClass(OSCMessage *_mes){
tobyspark 0:fdea65150534 166 udpRec.setOnEvent(this, &OSCClass::onUDPSocketEvent);
tobyspark 0:fdea65150534 167 receiverMessage = _mes; // note: receiverMessage MUST be a pointer to the message, because we will modify things in it
tobyspark 0:fdea65150534 168 newMessage=false;
tobyspark 0:fdea65150534 169 }
tobyspark 0:fdea65150534 170
tobyspark 0:fdea65150534 171 void OSCClass::begin()
tobyspark 0:fdea65150534 172 {
tobyspark 0:fdea65150534 173 // setup receiver udp socket:
tobyspark 0:fdea65150534 174 udpRec.bind(receiverMessage->host);
tobyspark 0:fdea65150534 175 }
tobyspark 0:fdea65150534 176
tobyspark 0:fdea65150534 177
tobyspark 0:fdea65150534 178 void OSCClass::begin(uint16_t _recievePort)
tobyspark 0:fdea65150534 179 {
tobyspark 0:fdea65150534 180 receiverMessage->host.setPort(_recievePort);
tobyspark 0:fdea65150534 181 // setup receiver udp socket:
tobyspark 0:fdea65150534 182 udpRec.bind(receiverMessage->host);
tobyspark 0:fdea65150534 183 }
tobyspark 0:fdea65150534 184
tobyspark 0:fdea65150534 185
tobyspark 0:fdea65150534 186 void OSCClass::setReceiveMessage(OSCMessage *_mes){
tobyspark 0:fdea65150534 187 receiverMessage = _mes;
tobyspark 0:fdea65150534 188 }
tobyspark 0:fdea65150534 189
tobyspark 0:fdea65150534 190 void OSCClass::onUDPSocketEvent(UDPSocketEvent e)
tobyspark 0:fdea65150534 191 {
tobyspark 0:fdea65150534 192 switch(e)
tobyspark 0:fdea65150534 193 {
tobyspark 0:fdea65150534 194 case UDPSOCKET_READABLE: //The only event for now
tobyspark 0:fdea65150534 195 //char buf[256] = {0};
tobyspark 0:fdea65150534 196 Host auxhost;
tobyspark 0:fdea65150534 197 buflength = udpRec.recvfrom( rcvBuff, 256, &auxhost ); // QUESTION: auxhost should be equal to the receiver host I guess...
tobyspark 0:fdea65150534 198 if ( buflength > 0 ) {
tobyspark 0:fdea65150534 199 //printf("\r\nFrom %d.%d.%d.%d:\r\n", host.getIp()[0], host.getIp()[1], host.getIp()[2], host.getIp()[3]);
tobyspark 0:fdea65150534 200 decodePacket(receiverMessage); // convert to OSC message, and save it in receiverMessage
tobyspark 0:fdea65150534 201 newMessage=true;
tobyspark 0:fdea65150534 202
tobyspark 0:fdea65150534 203 messageReceivedCallback.call();
tobyspark 0:fdea65150534 204 }
tobyspark 0:fdea65150534 205 break;
tobyspark 0:fdea65150534 206 }
tobyspark 0:fdea65150534 207 }
tobyspark 0:fdea65150534 208
tobyspark 0:fdea65150534 209 /*
tobyspark 0:fdea65150534 210 Decode UDP packet and save it in the OSCMessage structure
tobyspark 0:fdea65150534 211 */
tobyspark 0:fdea65150534 212 void OSCClass::decodePacket( OSCMessage *_mes) {
tobyspark 0:fdea65150534 213
tobyspark 0:fdea65150534 214 //uint16_t lenBuff;
tobyspark 0:fdea65150534 215 uint8_t d;
tobyspark 0:fdea65150534 216 uint8_t messagePos=0;
tobyspark 0:fdea65150534 217 uint8_t adrCount=0;
tobyspark 0:fdea65150534 218 uint8_t adrMesPos=0;
tobyspark 0:fdea65150534 219 uint8_t packetCount=0;
tobyspark 0:fdea65150534 220 uint8_t packetPos=4;
tobyspark 0:fdea65150534 221
tobyspark 0:fdea65150534 222
tobyspark 0:fdea65150534 223 //W5100.writeSn(socketNo, SnIR, SnIR::RECV);
tobyspark 0:fdea65150534 224 //lenBuff=recvfrom(socketNo, rcvBuff, 1, receiverMessage->ip, &receiverMessage->port);
tobyspark 0:fdea65150534 225
tobyspark 0:fdea65150534 226 receiverMessage->address[0]=tempAddress[0];
tobyspark 0:fdea65150534 227
tobyspark 0:fdea65150534 228 //(1) address process start =========================================
tobyspark 0:fdea65150534 229 do{
tobyspark 0:fdea65150534 230 d=rcvBuff[messagePos];
tobyspark 0:fdea65150534 231
tobyspark 0:fdea65150534 232
tobyspark 0:fdea65150534 233 if( (d=='/') && (messagePos>0) ){
tobyspark 0:fdea65150534 234
tobyspark 0:fdea65150534 235 if(adrCount<MAX_ADDRESS){
tobyspark 0:fdea65150534 236 tempAddress[adrCount][adrMesPos]=0;
tobyspark 0:fdea65150534 237
tobyspark 0:fdea65150534 238 adrCount++;
tobyspark 0:fdea65150534 239 adrMesPos=0;
tobyspark 0:fdea65150534 240
tobyspark 0:fdea65150534 241 receiverMessage->address[adrCount]=tempAddress[adrCount];
tobyspark 0:fdea65150534 242 }
tobyspark 0:fdea65150534 243
tobyspark 0:fdea65150534 244 }
tobyspark 0:fdea65150534 245
tobyspark 0:fdea65150534 246 if(adrCount<MAX_ADDRESS){
tobyspark 0:fdea65150534 247 //Added this in to remove the slashes out of final output
tobyspark 0:fdea65150534 248 if(d!='/'){
tobyspark 0:fdea65150534 249 tempAddress[adrCount][adrMesPos]=d;
tobyspark 0:fdea65150534 250
tobyspark 0:fdea65150534 251 if(packetCount>3) {
tobyspark 0:fdea65150534 252 packetCount=0;
tobyspark 0:fdea65150534 253 packetPos+=4;
tobyspark 0:fdea65150534 254 }
tobyspark 0:fdea65150534 255
tobyspark 0:fdea65150534 256 adrMesPos++;
tobyspark 0:fdea65150534 257 }
tobyspark 0:fdea65150534 258 }
tobyspark 0:fdea65150534 259 messagePos++;
tobyspark 0:fdea65150534 260 packetCount++;
tobyspark 0:fdea65150534 261
tobyspark 0:fdea65150534 262 }while(d!=0);
tobyspark 0:fdea65150534 263
tobyspark 0:fdea65150534 264
tobyspark 0:fdea65150534 265 if(adrCount<MAX_ADDRESS) adrCount++;
tobyspark 0:fdea65150534 266 receiverMessage->addressNum=adrCount;
tobyspark 0:fdea65150534 267
tobyspark 0:fdea65150534 268 messagePos=packetPos;
tobyspark 0:fdea65150534 269
tobyspark 0:fdea65150534 270 //(2) type tag process starts =========================================
tobyspark 0:fdea65150534 271 packetCount=0;
tobyspark 0:fdea65150534 272 packetPos+=4;
tobyspark 0:fdea65150534 273
tobyspark 0:fdea65150534 274 uint8_t typeTagPos=0;
tobyspark 0:fdea65150534 275 uint8_t tempArgNum=0;
tobyspark 0:fdea65150534 276
tobyspark 0:fdea65150534 277 while(rcvBuff[messagePos]!=0 ){
tobyspark 0:fdea65150534 278
tobyspark 0:fdea65150534 279 if(rcvBuff[messagePos] != ',') {
tobyspark 0:fdea65150534 280
tobyspark 0:fdea65150534 281 if(typeTagPos<MAX_ARG){
tobyspark 0:fdea65150534 282 receiverMessage->typeTag[tempArgNum]=rcvBuff[messagePos];
tobyspark 0:fdea65150534 283 tempArgNum++;
tobyspark 0:fdea65150534 284 }
tobyspark 0:fdea65150534 285 typeTagPos++;
tobyspark 0:fdea65150534 286
tobyspark 0:fdea65150534 287 }
tobyspark 0:fdea65150534 288
tobyspark 0:fdea65150534 289 packetCount++;
tobyspark 0:fdea65150534 290
tobyspark 0:fdea65150534 291 if(packetCount>3) {
tobyspark 0:fdea65150534 292 packetCount=0;
tobyspark 0:fdea65150534 293 packetPos+=4;
tobyspark 0:fdea65150534 294 }
tobyspark 0:fdea65150534 295
tobyspark 0:fdea65150534 296 messagePos++;
tobyspark 0:fdea65150534 297 }
tobyspark 0:fdea65150534 298
tobyspark 0:fdea65150534 299 receiverMessage->argNum=tempArgNum;
tobyspark 0:fdea65150534 300
tobyspark 0:fdea65150534 301 messagePos=packetPos;
tobyspark 0:fdea65150534 302
tobyspark 0:fdea65150534 303 //(3) tempArg process starts =========================================
tobyspark 0:fdea65150534 304 for(int i=0;i<tempArgNum;i++){
tobyspark 0:fdea65150534 305
tobyspark 0:fdea65150534 306 adrMesPos=3;
tobyspark 0:fdea65150534 307
tobyspark 0:fdea65150534 308 receiverMessage->arg[i]=tempArg[i];
tobyspark 0:fdea65150534 309
tobyspark 0:fdea65150534 310 for(int j=0;j<4;j++){
tobyspark 0:fdea65150534 311
tobyspark 0:fdea65150534 312 tempArg[i][adrMesPos]=rcvBuff[messagePos];
tobyspark 0:fdea65150534 313
tobyspark 0:fdea65150534 314 messagePos++;
tobyspark 0:fdea65150534 315 adrMesPos--;
tobyspark 0:fdea65150534 316 }
tobyspark 0:fdea65150534 317
tobyspark 0:fdea65150534 318 }
tobyspark 0:fdea65150534 319
tobyspark 0:fdea65150534 320
tobyspark 0:fdea65150534 321 }
tobyspark 0:fdea65150534 322
tobyspark 0:fdea65150534 323
tobyspark 0:fdea65150534 324
tobyspark 0:fdea65150534 325 OSCMessage * OSCClass::getMessage(){
tobyspark 0:fdea65150534 326 newMessage=false; // this indicate the user READ the message
tobyspark 0:fdea65150534 327 return receiverMessage;
tobyspark 0:fdea65150534 328 }
tobyspark 0:fdea65150534 329
tobyspark 0:fdea65150534 330
tobyspark 0:fdea65150534 331 void OSCClass::sendOsc( OSCMessage *_mes )
tobyspark 0:fdea65150534 332 {
tobyspark 0:fdea65150534 333 uint8_t lengthEnd;
tobyspark 0:fdea65150534 334 uint8_t lengthStart;
tobyspark 0:fdea65150534 335 char buff[128];
tobyspark 0:fdea65150534 336
tobyspark 0:fdea65150534 337 sendContainer = _mes;
tobyspark 0:fdea65150534 338
tobyspark 0:fdea65150534 339 //&#12496;&#12483;&#12501;&#12449;&#21021;&#26399;&#20516;
tobyspark 0:fdea65150534 340 buff[0]=0;
tobyspark 0:fdea65150534 341
tobyspark 0:fdea65150534 342 //1) Add name spaces:
tobyspark 0:fdea65150534 343 for(int i=0;i<sendContainer->addressNum;i++){
tobyspark 0:fdea65150534 344
tobyspark 0:fdea65150534 345 strcat(buff,sendContainer->address[i]); // note: an address is for instance: "/test" (including the "/")
tobyspark 0:fdea65150534 346
tobyspark 0:fdea65150534 347 }
tobyspark 0:fdea65150534 348
tobyspark 0:fdea65150534 349 // pad with 0s to align in multiples of 4:
tobyspark 0:fdea65150534 350 lengthStart=strlen(buff);
tobyspark 0:fdea65150534 351 lengthEnd=lengthStart+(4-(lengthStart%4));
tobyspark 0:fdea65150534 352 for(int i=lengthStart ; i<lengthEnd; i++){
tobyspark 0:fdea65150534 353 buff[i]=0;
tobyspark 0:fdea65150534 354 }
tobyspark 0:fdea65150534 355
tobyspark 0:fdea65150534 356 lengthStart=lengthEnd;
tobyspark 0:fdea65150534 357
tobyspark 0:fdea65150534 358 //2) Add TypeTag:
tobyspark 0:fdea65150534 359 buff[lengthEnd++]=','; // Note: type tag is for instance: ",if"
tobyspark 0:fdea65150534 360 for(int i=0;i<sendContainer->argNum;i++){
tobyspark 0:fdea65150534 361 buff[lengthEnd++]=sendContainer->typeTag[i];
tobyspark 0:fdea65150534 362 }
tobyspark 0:fdea65150534 363
tobyspark 0:fdea65150534 364 // pad with 0s to align in multiples of 4:
tobyspark 0:fdea65150534 365 lengthStart=lengthEnd;
tobyspark 0:fdea65150534 366 lengthEnd=lengthStart+(4-(lengthStart%4));
tobyspark 0:fdea65150534 367 for(int i=lengthStart ; i<lengthEnd; i++){
tobyspark 0:fdea65150534 368 buff[i]=0;
tobyspark 0:fdea65150534 369 }
tobyspark 0:fdea65150534 370
tobyspark 0:fdea65150534 371 //3) add argument values (Note: here only big endian):
tobyspark 0:fdea65150534 372 uint8_t *v;
tobyspark 0:fdea65150534 373 for(int i=0;i<sendContainer->argNum;i++){
tobyspark 0:fdea65150534 374 uint8_t valuePos=3;
tobyspark 0:fdea65150534 375 v=(uint8_t *)sendContainer->arg[i];
tobyspark 0:fdea65150534 376
tobyspark 0:fdea65150534 377 buff[lengthEnd++]=v[valuePos--];
tobyspark 0:fdea65150534 378 buff[lengthEnd++]=v[valuePos--];
tobyspark 0:fdea65150534 379 buff[lengthEnd++]=v[valuePos--];
tobyspark 0:fdea65150534 380 buff[lengthEnd++]=v[valuePos];
tobyspark 0:fdea65150534 381
tobyspark 0:fdea65150534 382 }
tobyspark 0:fdea65150534 383
tobyspark 0:fdea65150534 384 //4) Send udp packet:
tobyspark 0:fdea65150534 385 //sendto( socketNo, (uint8_t *)buff, lengthEnd, sendContainer->ip, sendContainer->port );
tobyspark 0:fdea65150534 386 udpSend.sendto(buff , lengthEnd, &(sendContainer->host));
tobyspark 0:fdea65150534 387 }
tobyspark 0:fdea65150534 388
tobyspark 0:fdea65150534 389
tobyspark 0:fdea65150534 390 /*
tobyspark 0:fdea65150534 391 flush a receive buffer
tobyspark 0:fdea65150534 392 void OSCClass::flush() {
tobyspark 0:fdea65150534 393 while ( available() ){}
tobyspark 0:fdea65150534 394 }
tobyspark 0:fdea65150534 395 */
tobyspark 0:fdea65150534 396
tobyspark 0:fdea65150534 397
tobyspark 0:fdea65150534 398 void OSCClass::stop() {
tobyspark 0:fdea65150534 399 //close( socketNo );
tobyspark 0:fdea65150534 400 udpSend.resetOnEvent(); // disables callback
tobyspark 0:fdea65150534 401 }
tobyspark 0:fdea65150534 402
tobyspark 0:fdea65150534 403