modded version CNMAT/OSC https://github.com/CNMAT/OSC
Fork of osc-cnmat by
Diff: OSCBundle.cpp
- Revision:
- 4:107c23eb31b6
- Parent:
- 3:f58c63b78853
diff -r f58c63b78853 -r 107c23eb31b6 OSCBundle.cpp --- a/OSCBundle.cpp Sat May 17 12:42:29 2014 +0000 +++ b/OSCBundle.cpp Sat Feb 13 11:29:14 2016 +0000 @@ -214,10 +214,51 @@ } }*/ +int OSCBundle::send(uint8_t * bundleBuffer){ + int i, j; + //don't send a bundle with errors + if (hasError()){ + return -1; + } + //write the bundle header + static uint8_t header[] = {'#', 'b', 'u', 'n', 'd', 'l', 'e', 0}; + + int idx = 0; + //p.write(header, 8); + for (i = 0; i < 8; i++){ + bundleBuffer[idx++] = header[i]; + } + //write the timetag + uint64_t t64 = BigEndian(timetag); + uint8_t * tptr = (uint8_t *) &t64; + //p.write(tptr, 8); + for (i = 0; i < 8; i++){ + bundleBuffer[idx++] = tptr[i]; + } + //send the messages + for (i = 0; i < numMessages; i++){ + OSCMessage * msg = getOSCMessage(i); + int msgSize = msg->bytes(); + //turn the message size into a pointer + uint32_t s32 = BigEndian((uint32_t) msgSize); + uint8_t * sptr = (uint8_t *) &s32; + //write the messsage size + //p.write(sptr, 4); + for (j = 0; j < 4; j++){ + bundleBuffer[idx++] = sptr[j]; + } + //msg->send(p); + msg->bundleOffset = idx; + idx = msg->send(bundleBuffer); + } + + return idx; +} + /*============================================================================= FILLING =============================================================================*/ - +/* void OSCBundle::fill(uint8_t incomingByte){ decode(incomingByte); } @@ -226,6 +267,10 @@ while (length--){ decode(*incomingBytes++); } + +*/ +void OSCBundle::fill(uint8_t incomingByte){ + decode(incomingByte); } /*=============================================================================