Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: OSCMessage.cpp
- Revision:
- 10:936c3afce828
- Parent:
- 9:e4528f622bcc
- Child:
- 12:f2c792ac1aca
--- a/OSCMessage.cpp Tue Dec 04 02:16:19 2018 +0100 +++ b/OSCMessage.cpp Tue Dec 04 19:58:14 2018 +0100 @@ -178,11 +178,7 @@ int copyBytes = bufferSize < datum->bytes? bufferSize : datum->bytes; return datum->getString(buffer, copyBytes); } else { - #ifndef ESPxx - return (int)NULL; - #else return -1; - #endif } } @@ -193,15 +189,11 @@ int copyBytes = bufferSize < datum->bytes? bufferSize : datum->bytes; return datum->getString(buffer, copyBytes, offset, size); } else { - #ifndef ESPxx - return (int)NULL; - #else return -1; - #endif } } -/* + int OSCMessage::getBlob(int position, uint8_t * buffer){ OSCData * datum = getOSCData(position); if (!hasError()){ @@ -255,7 +247,7 @@ } } -*/ + char OSCMessage::getType(int position){ OSCData * datum = getOSCData(position); if (!hasError()){ @@ -461,7 +453,7 @@ SENDING =============================================================================*/ -OSCMessage& OSCMessage::send(UDPSocket &p){ +OSCMessage& OSCMessage::send(UDPSocket &p, const char *host, uint16_t port){ char buff[128]; uint8_t lengthEnd; @@ -525,17 +517,24 @@ for (int i = 0; i < dataCount; i++){ OSCData * datum = getOSCData(i); - /* if ((datum->type == 's') || (datum->type == 'b')){ - p.write(datum->data.b, datum->bytes); + if ((datum->type == 's') || (datum->type == 'b')){ + for(int i = 0; i < datum->bytes; i++){ + buff[lengthEnd++]=datum->data.b[i]; + } + + int dataPad = padSize(datum->bytes); while(dataPad--){ - p.write(nullChar); + buff[lengthEnd++]=nullChar; } } else if (datum->type == 'd'){ double d = BigEndian(datum->data.d); //TODO uint8_t * ptr = (uint8_t *) &d; - p.write(ptr, 8); - } else if (datum->type == 't'){ + for(int i = 0; i < 8; i++){ + buff[lengthEnd++]=ptr[i]; + } + + } /* else if (datum->type == 't'){ osctime_t time = datum->data.time; uint32_t d = BigEndian(time.seconds); uint8_t * ptr = (uint8_t *) &d; @@ -544,7 +543,7 @@ ptr = (uint8_t *) &d; p.write(ptr, 4); - } else */ if (datum->type == 'T' || datum->type == 'F') + } */ else if (datum->type == 'T' || datum->type == 'F') { } else { // float or int uint32_t i = BigEndian(datum->data.i); @@ -556,7 +555,7 @@ // p.write(ptr, datum->bytes); } } - p.sendto("192.168.2.200", 8000, buff, lengthEnd); + p.sendto(host, port, buff, lengthEnd); return *this; } @@ -662,7 +661,7 @@ decodeState = DATA_PADDING; } break; - /* case 'b': + case 'b': if (incomingBufferSize > 4){ //compute the expected blob size union { @@ -678,7 +677,7 @@ } } - break; */ + break; } //break out of the for loop once we've selected the first invalid message break;