forked from recotana/ArdOSC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OSCDecoder.cpp
66 lines (37 loc) · 1.49 KB
/
OSCDecoder.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
/*
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 <string.h>
#include "OSCcommon/OSCcommon.h"
#include "OSCcommon/OSCDecoder.h"
#include "OSCcommon/OSCArg.h"
int16_t OSCDecoder::decode( OSCMessage::OSCMessage *_newMes , const uint8_t *_binData ){
const uint8_t *packStartPtr = _binData;
_newMes->beginMessage( (char*)packStartPtr );
packStartPtr += _newMes->_oscAdrAlignmentSize;
char *tmpTag = (char*)(packStartPtr+1);
uint8_t argsNum = strlen(tmpTag);
uint16_t typeTagAlignSize = CULC_ALIGNMENT(argsNum+1);
packStartPtr += typeTagAlignSize;
for (uint8_t i=0 ; i< argsNum ; i++) {
switch ( tmpTag[i] ) {
case kTagInt32:
packStartPtr += _newMes->setArgData( kTagInt32 , (void*)packStartPtr , 4 , false );
break;
case kTagFloat:
packStartPtr += _newMes->setArgData( kTagFloat , (void*)packStartPtr , 4 , false );
break;
case kTagString:
packStartPtr += _newMes->setArgData( kTagString , (void*)packStartPtr , strlen((char*)packStartPtr) , true );
break;
default:
break;
}
}
return 1;
}