An Open Sound Control library for the mbed, created to be compatible with Recotana's OSCClass library (http://recotana.com) for the Arduino with Ethernet shield. It also uses parts of the OSC Transceiver(Sender/Receiver) code by xshige written by: Alvaro Cassinelli, October 2011 tweaked by: Toby Harris / *spark audio-visual, March 2012

Dependencies:   NetServices mbed

Committer:
tobyspark
Date:
Sun Apr 15 12:59:19 2012 +0000
Revision:
5:247b80b139d3
Parent:
4:f365c577b3c6
Child:
6:bdcd499c3ed4
doxygen updates (need to publish to see result, gah!)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tobyspark 2:acfd0090c8e7 1 /* mbed OSC Library
tobyspark 2:acfd0090c8e7 2 This is an Open Sound Control library for the mbed, created to be compatible with Recotana's OSCClass library (http://recotana.com) for the
tobyspark 0:49cdaebd52d5 3 Arduino with Ethernet shield. I have also used parts of the OSC Transceiver(Sender/Receiver) code by xshige
tobyspark 0:49cdaebd52d5 4 written by: Alvaro Cassinelli, 7.10.2011
tobyspark 0:49cdaebd52d5 5 tweaked by: Toby Harris / *spark audio-visual, 13.4.2012
tobyspark 0:49cdaebd52d5 6
tobyspark 0:49cdaebd52d5 7 This library is free software; you can redistribute it and/or
tobyspark 0:49cdaebd52d5 8 modify it under the terms of the GNU Lesser General Public
tobyspark 0:49cdaebd52d5 9 License version 2.1 as published by the Free Software Foundation.
tobyspark 0:49cdaebd52d5 10 Open Sound Control http://opensoundcontrol.org/
tobyspark 0:49cdaebd52d5 11
tobyspark 0:49cdaebd52d5 12 mbedOSC version 0.1 Specification (similar to Recotana's OSCClass library)
tobyspark 0:49cdaebd52d5 13
tobyspark 0:49cdaebd52d5 14 ********
tobyspark 0:49cdaebd52d5 15 Address : max 2
tobyspark 0:49cdaebd52d5 16 "/ard"
tobyspark 0:49cdaebd52d5 17 "/ard/output" --address[0]="/ard" :max 15character
tobyspark 0:49cdaebd52d5 18 --address[1]="/output" :max 15character
tobyspark 0:49cdaebd52d5 19
tobyspark 0:49cdaebd52d5 20 *******
tobyspark 0:49cdaebd52d5 21 TypeTag : max 2
tobyspark 0:49cdaebd52d5 22
tobyspark 0:49cdaebd52d5 23 "i" - long or unsigned long
tobyspark 0:49cdaebd52d5 24 "f" - double
tobyspark 0:49cdaebd52d5 25
tobyspark 0:49cdaebd52d5 26 *******
tobyspark 0:49cdaebd52d5 27 arg : max 2
tobyspark 0:49cdaebd52d5 28
tobyspark 0:49cdaebd52d5 29 *******
tobyspark 0:49cdaebd52d5 30 Example of an OSC message: "/mbed/test1, if 50 32.4" (Note: this is not the byte string
tobyspark 0:49cdaebd52d5 31 sent as UDP packet - there are no spaces, and arguments are in binary, BIG ENDIAN)
tobyspark 0:49cdaebd52d5 32 */
tobyspark 0:49cdaebd52d5 33
tobyspark 0:49cdaebd52d5 34 #ifndef mbedOSC_h
tobyspark 0:49cdaebd52d5 35 #define mbedOSC_h
tobyspark 0:49cdaebd52d5 36
tobyspark 0:49cdaebd52d5 37 #include "mbed.h"
tobyspark 0:49cdaebd52d5 38 #include "EthernetNetIf.h"
tobyspark 0:49cdaebd52d5 39 #include "UDPSocket.h"
tobyspark 0:49cdaebd52d5 40
tobyspark 0:49cdaebd52d5 41 // setup IP of destination (computer):
tobyspark 0:49cdaebd52d5 42 #define DEFAULT_SEND_PORT 12000
tobyspark 0:49cdaebd52d5 43 //Host sendHost(IpAddr(10, 0, 0, 1), DEFAULT_SEND_PORT, NULL); // Send Port
tobyspark 0:49cdaebd52d5 44 // set IP of origin of UDP packets - the mbed acts as a SERVER here, and needs to bind the socket to the "client" (the computer)
tobyspark 0:49cdaebd52d5 45 #define DEFAULT_RECEIVE_PORT 57130
tobyspark 0:49cdaebd52d5 46 //Host recHost(IpAddr(10, 0, 0, 1), DEFAULT_RECEIVE_PORT, NULL); // Receive Port
tobyspark 0:49cdaebd52d5 47 //UDPSocket udpRec,udpSend;
tobyspark 0:49cdaebd52d5 48
tobyspark 0:49cdaebd52d5 49
tobyspark 0:49cdaebd52d5 50 #define MAX_ADDRESS 2
tobyspark 0:49cdaebd52d5 51 #define MAX_ARG 2
tobyspark 0:49cdaebd52d5 52
tobyspark 0:49cdaebd52d5 53 #define TYPE_INT 1
tobyspark 0:49cdaebd52d5 54 #define TYPE_FLOAT 2
tobyspark 0:49cdaebd52d5 55
tobyspark 0:49cdaebd52d5 56
tobyspark 3:2b56849146d8 57 /** Container class for OSC messages (receiving or sending) */
tobyspark 0:49cdaebd52d5 58 class OSCMessage{
tobyspark 0:49cdaebd52d5 59
tobyspark 0:49cdaebd52d5 60 private:
tobyspark 0:49cdaebd52d5 61
tobyspark 0:49cdaebd52d5 62 char *address[MAX_ADDRESS]; // these are strings (as char*)
tobyspark 0:49cdaebd52d5 63 uint8_t addressNum; // current number of addresses in the message (ex: "/ard/test" --> the number of the addresses is 2)
tobyspark 0:49cdaebd52d5 64
tobyspark 0:49cdaebd52d5 65 char typeTag[MAX_ARG];
tobyspark 0:49cdaebd52d5 66
tobyspark 0:49cdaebd52d5 67 void *arg[MAX_ARG];
tobyspark 0:49cdaebd52d5 68 uint8_t argNum;
tobyspark 0:49cdaebd52d5 69
tobyspark 0:49cdaebd52d5 70 // Information about the connection:
tobyspark 0:49cdaebd52d5 71 //uint8_t ip[4];
tobyspark 0:49cdaebd52d5 72 //uint16_t port;
tobyspark 0:49cdaebd52d5 73 Host host;
tobyspark 0:49cdaebd52d5 74
tobyspark 0:49cdaebd52d5 75 public:
tobyspark 3:2b56849146d8 76 /** Create a container for an OSC message to be received or sent */
tobyspark 0:49cdaebd52d5 77 OSCMessage();
tobyspark 1:ab7dc9550de6 78
tobyspark 1:ab7dc9550de6 79 /** Return the IpAddr object */
tobyspark 1:ab7dc9550de6 80 const IpAddr& getIp();
tobyspark 1:ab7dc9550de6 81 /** Return the port */
tobyspark 1:ab7dc9550de6 82 const int& getPort();
tobyspark 0:49cdaebd52d5 83
tobyspark 2:acfd0090c8e7 84 /** Gets the address string of the OSC message
tobyspark 2:acfd0090c8e7 85 *
tobyspark 5:247b80b139d3 86 * @param [in] _index is the index of the address string (byte)
tobyspark 2:acfd0090c8e7 87 * return pointer of the address string (char *)
tobyspark 2:acfd0090c8e7 88 * @note ex. "/ard/test"<br>
tobyspark 2:acfd0090c8e7 89 * getAddress(0) = "/ard"<br>
tobyspark 2:acfd0090c8e7 90 * getAddress(1) = "/test"
tobyspark 2:acfd0090c8e7 91 * @attention It is maximum number of the addresses is 2<br>
tobyspark 2:acfd0090c8e7 92 * In this case "/ard/test1/test2"<br>
tobyspark 2:acfd0090c8e7 93 * ignore it after "/test2"
tobyspark 1:ab7dc9550de6 94 */
tobyspark 0:49cdaebd52d5 95 char *getAddress(uint8_t _index); //retturn address
tobyspark 1:ab7dc9550de6 96
tobyspark 2:acfd0090c8e7 97 /** Gets the TopAddress string of the OSC message (this is just the address with index 0)
tobyspark 3:2b56849146d8 98
tobyspark 1:ab7dc9550de6 99 param[in] None
tobyspark 1:ab7dc9550de6 100 return pointer of the TopAddress string (char *), i.e. address[0]
tobyspark 1:ab7dc9550de6 101 Example: In the case "/ard/test", getTopAddress() = "/ard" (WITH the slash "/")
tobyspark 1:ab7dc9550de6 102 *//*
tobyspark 1:ab7dc9550de6 103 Gets the TopAddress string of the OSC message (this is just the address with index 0)
tobyspark 1:ab7dc9550de6 104 param[in] None
tobyspark 1:ab7dc9550de6 105 return pointer of the TopAddress string (char *), i.e. address[0]
tobyspark 1:ab7dc9550de6 106 Example: In the case "/ard/test", getTopAddress() = "/ard" (WITH the slash "/")
tobyspark 1:ab7dc9550de6 107 */
tobyspark 0:49cdaebd52d5 108 char *getTopAddress(); //return address[0] :"/ard"
tobyspark 1:ab7dc9550de6 109
tobyspark 2:acfd0090c8e7 110 /**
tobyspark 1:ab7dc9550de6 111 Gets the "SubAddress" string of the OSC message (this is just the address with index 1)
tobyspark 1:ab7dc9550de6 112 param[in] None
tobyspark 1:ab7dc9550de6 113 return pointer of the SubAddress string (char *), i.e. address[1]
tobyspark 1:ab7dc9550de6 114 Example: in the case "/ard/test", getSubAddress() = "/test" (WITH the slash "/")
tobyspark 1:ab7dc9550de6 115 */
tobyspark 0:49cdaebd52d5 116 char *getSubAddress(); //return address[1] :"/test"
tobyspark 1:ab7dc9550de6 117
tobyspark 2:acfd0090c8e7 118 /**
tobyspark 1:ab7dc9550de6 119 Gets the number of the OSC message address
tobyspark 1:ab7dc9550de6 120 param[in] None
tobyspark 1:ab7dc9550de6 121 return number of the OSC message address (byte)
tobyspark 1:ab7dc9550de6 122 Examples: "/ard" --> the number of the addresses is 1
tobyspark 1:ab7dc9550de6 123 "/ard/test" --> the number of the addresses is 2
tobyspark 1:ab7dc9550de6 124 Attention: the maximum number of addresses is 2 (MAX_ADDRESS)
tobyspark 1:ab7dc9550de6 125 */
tobyspark 0:49cdaebd52d5 126 uint8_t getAddressNum(); //return 2
tobyspark 0:49cdaebd52d5 127
tobyspark 2:acfd0090c8e7 128 /**
tobyspark 1:ab7dc9550de6 129 Gets the TypeTag string (with index) of the OSC message
tobyspark 1:ab7dc9550de6 130 param[in] <--_index is the index of the TypeTag string (byte)
tobyspark 1:ab7dc9550de6 131 return: TypeTag char (char)
tobyspark 1:ab7dc9550de6 132 Example: in the case of a total typetag string equal to "if", getTypeTag(0) = 'i' and getTypeTag(1) = 'f'
tobyspark 1:ab7dc9550de6 133 Attention: MAX_ARG is maximum number of the args, if the index argument is larger, it will be constrained to this max.
tobyspark 1:ab7dc9550de6 134 */
tobyspark 0:49cdaebd52d5 135 char getTypeTag(uint8_t _index); //_index=0 ->'i'
tobyspark 0:49cdaebd52d5 136 //_index=1 ->'f'
tobyspark 0:49cdaebd52d5 137
tobyspark 2:acfd0090c8e7 138 /**
tobyspark 1:ab7dc9550de6 139 Gets the number of the OSC message args
tobyspark 1:ab7dc9550de6 140 param[in] None
tobyspark 1:ab7dc9550de6 141 return number of the args (byte)
tobyspark 1:ab7dc9550de6 142 Example: "i" 123 --> number of the OSC message args is 1
tobyspark 1:ab7dc9550de6 143 "if" 123 54.24 --> number of the OSC message args is 2
tobyspark 1:ab7dc9550de6 144 Attention: the maximum number of args is 2 (MAX_ARG)
tobyspark 1:ab7dc9550de6 145 */
tobyspark 0:49cdaebd52d5 146 uint8_t getArgNum(); //return 2
tobyspark 0:49cdaebd52d5 147
tobyspark 2:acfd0090c8e7 148 /**
tobyspark 1:ab7dc9550de6 149 Get the args of the OSC message with an integer value
tobyspark 1:ab7dc9550de6 150 param[in] <--_index is (an int, or uint8_t), corresponding to the index of the args (byte)
tobyspark 1:ab7dc9550de6 151 return: integer value (long, or int32_t)
tobyspark 1:ab7dc9550de6 152 Example: in the case "if" 123 54.24, getArgInt(0) = 123
tobyspark 1:ab7dc9550de6 153 Noe: "i" is integer, but the return type is "long"
tobyspark 1:ab7dc9550de6 154 Note: When a index is bigger than the number of the args, it is set to the number of the args
tobyspark 1:ab7dc9550de6 155 */
tobyspark 0:49cdaebd52d5 156 int32_t getArgInt(uint8_t _index); //_index=0 -> 123
tobyspark 1:ab7dc9550de6 157
tobyspark 2:acfd0090c8e7 158 /**
tobyspark 1:ab7dc9550de6 159 Get the args of the OSC message with a float value
tobyspark 1:ab7dc9550de6 160 param[in] <--_index is the index of the args
tobyspark 1:ab7dc9550de6 161 return: float value (double)
tobyspark 1:ab7dc9550de6 162 note: In this case "if" 123 54.24, getArgFloat(1) = 54.24
tobyspark 1:ab7dc9550de6 163 attention: arg declared as float, but return value cast as "double"
tobyspark 1:ab7dc9550de6 164 attention: When index is bigger than the number of the args, it is set to the number of the args
tobyspark 1:ab7dc9550de6 165 */
tobyspark 0:49cdaebd52d5 166 double getArgFloat(uint8_t _index); //_index=1 -> 54.21
tobyspark 0:49cdaebd52d5 167
tobyspark 0:49cdaebd52d5 168
tobyspark 2:acfd0090c8e7 169 /**
tobyspark 1:ab7dc9550de6 170 Set TopAddress string of OSC Message
tobyspark 5:247b80b139d3 171 param[in] _address is a string pointer for the TopAddress String (char *). NOTE: is this a good idea? why not pass as const, and do allocation here?
tobyspark 1:ab7dc9550de6 172 return: None
tobyspark 1:ab7dc9550de6 173 Example: if the complete address string is "/ard/test", we set the topaddress as follows: char top[]="/ard" (allocation done here!), then setTopAddress(top)
tobyspark 1:ab7dc9550de6 174 */
tobyspark 0:49cdaebd52d5 175 void setTopAddress(char *_address); //set address[0]
tobyspark 1:ab7dc9550de6 176
tobyspark 2:acfd0090c8e7 177 /**
tobyspark 1:ab7dc9550de6 178 Set SubAddress string of the OSC Message
tobyspark 5:247b80b139d3 179 param[in] _address is a string pointer for the SubAddress String (char *)
tobyspark 1:ab7dc9550de6 180 return: None
tobyspark 1:ab7dc9550de6 181 Example: if the complete address string is "/ard/test", we set the subaddress as follows: char sub[]="/test" (allocation done here!), then setSubAddress(sub)
tobyspark 1:ab7dc9550de6 182 Attention: we should call first setTopAddress, and then setSubAddress. The order is important. This does not seems like a good idea...
tobyspark 1:ab7dc9550de6 183 */
tobyspark 0:49cdaebd52d5 184 void setSubAddress(char *_address); //set address[1]
tobyspark 1:ab7dc9550de6 185
tobyspark 2:acfd0090c8e7 186 /**
tobyspark 1:ab7dc9550de6 187 Set the complete Address string of the OSC Message (top and sub addresses)
tobyspark 5:247b80b139d3 188 param[in] _topAddress and _subAddress are the string pointers to top and sub addresses (char *)
tobyspark 1:ab7dc9550de6 189 return: None
tobyspark 1:ab7dc9550de6 190 Example: in the case "/ard/test", we need to do: char top[]="/ard", char sub[]="/test", and then setAddress(top,sub)
tobyspark 1:ab7dc9550de6 191 Reminder: in this implementation, the maximum number of addresses is MAX_ADDRESS=2
tobyspark 1:ab7dc9550de6 192 */
tobyspark 0:49cdaebd52d5 193 void setAddress(char *_topAddress,
tobyspark 0:49cdaebd52d5 194 char *_subAddress);
tobyspark 1:ab7dc9550de6 195
tobyspark 2:acfd0090c8e7 196 /**
tobyspark 1:ab7dc9550de6 197 Set address string using index (here 0 or 1)
tobyspark 1:ab7dc9550de6 198 Example: "/ard/test", char adr[]="/ard", setAddress(0,adr), char adr2[]="/test", setAddress(1,adr)
tobyspark 1:ab7dc9550de6 199 */
tobyspark 0:49cdaebd52d5 200 void setAddress(uint8_t _index, //set 0,address[0]
tobyspark 0:49cdaebd52d5 201 char *_address);
tobyspark 0:49cdaebd52d5 202 //set 1,address[1]
tobyspark 1:ab7dc9550de6 203
tobyspark 2:acfd0090c8e7 204 /**
tobyspark 1:ab7dc9550de6 205 Set IP Address of the OSC Message (for SENDING messages - for receiving this will be done when receiving something )
tobyspark 5:247b80b139d3 206 param[in] _ip pointer of IP Address array (byte *)
tobyspark 1:ab7dc9550de6 207 Example: IP=192.168.0.99, then we have to do: ip[]={192,168,0,1}, then setIp(ip)
tobyspark 1:ab7dc9550de6 208 */
tobyspark 0:49cdaebd52d5 209 void setIp( uint8_t *_ip ); //set ip
tobyspark 1:ab7dc9550de6 210
tobyspark 4:f365c577b3c6 211 /**
tobyspark 1:ab7dc9550de6 212 Set IP Address to the OSC Message container (not through pointer)
tobyspark 1:ab7dc9550de6 213 Example: IP=192.168.0.99 => setIp(192,168,0,99)
tobyspark 1:ab7dc9550de6 214 */
tobyspark 0:49cdaebd52d5 215 void setIp(uint8_t _ip1, //set(192,
tobyspark 0:49cdaebd52d5 216 uint8_t _ip2, // 168,
tobyspark 0:49cdaebd52d5 217 uint8_t _ip3, // 0,
tobyspark 0:49cdaebd52d5 218 uint8_t _ip4); // 100)
tobyspark 1:ab7dc9550de6 219
tobyspark 1:ab7dc9550de6 220 /*
tobyspark 1:ab7dc9550de6 221 Set PortNo for the OSC Message
tobyspark 1:ab7dc9550de6 222 @param[in] _port PortNo (unsigned int)
tobyspark 1:ab7dc9550de6 223 @return None
tobyspark 1:ab7dc9550de6 224 */
tobyspark 0:49cdaebd52d5 225 void setPort( uint16_t _port );
tobyspark 0:49cdaebd52d5 226
tobyspark 4:f365c577b3c6 227 /**
tobyspark 1:ab7dc9550de6 228 Set TypeTag and args to the OSC Message container
tobyspark 1:ab7dc9550de6 229 @param[in] types TypeTag string "i"(integer) or"f"(float) (char *)
tobyspark 1:ab7dc9550de6 230 @param[in] ... Pointer of the Args(variable argument) ..
tobyspark 1:ab7dc9550de6 231 @return None
tobyspark 1:ab7dc9550de6 232 @Example:
tobyspark 1:ab7dc9550de6 233 (1) integer 123: (NOTE: integers are LONG)
tobyspark 1:ab7dc9550de6 234 long v1=123; sendMes.setArgs("i",&v1)
tobyspark 1:ab7dc9550de6 235 (2)integer:123 and float:52.14
tobyspark 1:ab7dc9550de6 236 long v1=123; double v2=52.14; sendMes.setArgs("if",&v1,&v2)
tobyspark 1:ab7dc9550de6 237 Attention: in this implementation, the maximum number of the args is 2
tobyspark 1:ab7dc9550de6 238 (if setArgs("iff",&v1,&v2,&v3), data is ignored after &v3)
tobyspark 1:ab7dc9550de6 239 */
tobyspark 0:49cdaebd52d5 240 void setArgs( char *types , ... ); //set ("if",&v1,&v2)
tobyspark 0:49cdaebd52d5 241
tobyspark 0:49cdaebd52d5 242 friend class OSCClass;
tobyspark 0:49cdaebd52d5 243
tobyspark 0:49cdaebd52d5 244 };
tobyspark 0:49cdaebd52d5 245
tobyspark 0:49cdaebd52d5 246
tobyspark 0:49cdaebd52d5 247
tobyspark 0:49cdaebd52d5 248 /* ==================================== OSCClass for sending and receiving OSC messages using UDP protocol ===================================== */
tobyspark 0:49cdaebd52d5 249
tobyspark 0:49cdaebd52d5 250 #include "UDPSocket.h"
tobyspark 0:49cdaebd52d5 251
tobyspark 3:2b56849146d8 252 /** Wraps the UDP functions to send and receive OSC messages */
tobyspark 0:49cdaebd52d5 253 class OSCClass {
tobyspark 0:49cdaebd52d5 254
tobyspark 0:49cdaebd52d5 255 private:
tobyspark 0:49cdaebd52d5 256
tobyspark 0:49cdaebd52d5 257 UDPSocket udpRec,udpSend;
tobyspark 0:49cdaebd52d5 258 char rcvBuff[256]; // raw buffer for UDP packets (udpRec.recvfrom( buf, 256, &host ) ))
tobyspark 0:49cdaebd52d5 259 int buflength;
tobyspark 0:49cdaebd52d5 260
tobyspark 0:49cdaebd52d5 261 OSCMessage *receiverMessage;
tobyspark 0:49cdaebd52d5 262 OSCMessage *sendContainer;
tobyspark 0:49cdaebd52d5 263
tobyspark 0:49cdaebd52d5 264 char tempAddress[MAX_ADDRESS][16];
tobyspark 0:49cdaebd52d5 265 uint8_t tempArg[MAX_ARG][4];
tobyspark 0:49cdaebd52d5 266
tobyspark 0:49cdaebd52d5 267 void decodePacket( OSCMessage *_mes); // makes OSC message from packet
tobyspark 0:49cdaebd52d5 268
tobyspark 0:49cdaebd52d5 269 public:
tobyspark 0:49cdaebd52d5 270
tobyspark 3:2b56849146d8 271 /** Create an object to send and receive OSC messages */
tobyspark 0:49cdaebd52d5 272 OSCClass();
tobyspark 1:ab7dc9550de6 273
tobyspark 4:f365c577b3c6 274 /**
tobyspark 1:ab7dc9550de6 275 This sets "binds" the received message to the receiver container of the communication object
tobyspark 1:ab7dc9550de6 276 @param[in]<--_mes is a pointer to the "receiveing" OSC message (OSCMessage *)
tobyspark 1:ab7dc9550de6 277 */
tobyspark 0:49cdaebd52d5 278 OSCClass(OSCMessage *_mes); // set the receiver message container
tobyspark 1:ab7dc9550de6 279
tobyspark 4:f365c577b3c6 280 /**
tobyspark 1:ab7dc9550de6 281 Ignore: See messageReceivedCallback instead. This is called by the UDPSocket... and should be a protected function and we friend UDPSocket?
tobyspark 1:ab7dc9550de6 282 */
tobyspark 0:49cdaebd52d5 283 void onUDPSocketEvent(UDPSocketEvent e);
tobyspark 0:49cdaebd52d5 284
tobyspark 4:f365c577b3c6 285 /**
tobyspark 1:ab7dc9550de6 286 This initializes the OSC communication object with default receiving port (DEFAULT_REC_PORT)
tobyspark 1:ab7dc9550de6 287 param[in]: None
tobyspark 1:ab7dc9550de6 288 return: None
tobyspark 1:ab7dc9550de6 289 */
tobyspark 0:49cdaebd52d5 290 void begin();
tobyspark 1:ab7dc9550de6 291
tobyspark 4:f365c577b3c6 292 /**
tobyspark 1:ab7dc9550de6 293 Initialize an OSC object with arbitrary listening port
tobyspark 5:247b80b139d3 294 param[in] _recievePort, is the listening ("receiving") Port No (unsigned int)
tobyspark 1:ab7dc9550de6 295 return: None
tobyspark 1:ab7dc9550de6 296 */
tobyspark 0:49cdaebd52d5 297 void begin(uint16_t _recievePort);
tobyspark 1:ab7dc9550de6 298
tobyspark 4:f365c577b3c6 299 /**
tobyspark 1:ab7dc9550de6 300 Stop OSC communication (in fact, only the receiver - the server side)
tobyspark 1:ab7dc9550de6 301 */
tobyspark 0:49cdaebd52d5 302 void stop();
tobyspark 0:49cdaebd52d5 303
tobyspark 0:49cdaebd52d5 304 //new OSC data in the receiver message container:
tobyspark 0:49cdaebd52d5 305 bool newMessage;
tobyspark 0:49cdaebd52d5 306
tobyspark 4:f365c577b3c6 307 /**
tobyspark 1:ab7dc9550de6 308 Set a OSC receive message container
tobyspark 1:ab7dc9550de6 309 param[in] _mes Pointer to the OSC receive message container (OSCMessage *)
tobyspark 1:ab7dc9550de6 310 return None
tobyspark 1:ab7dc9550de6 311 */
tobyspark 0:49cdaebd52d5 312 void setReceiveMessage( OSCMessage *_mes ); //set receive OSCmessage container (note: the message has a "host" object from which we get the upd packets)
tobyspark 1:ab7dc9550de6 313
tobyspark 4:f365c577b3c6 314 /**
tobyspark 1:ab7dc9550de6 315 Get the received OSC message (note: this is another way to access the message directly from the OSCClass object).
tobyspark 1:ab7dc9550de6 316 The advantage is that we will signal that we read the message, and will be able to query if a NEW message arrived
tobyspark 1:ab7dc9550de6 317 (Alternatively, one could have a function pointer to pass to the OSC object, that will be called each time a new packet is received: TO DO)
tobyspark 1:ab7dc9550de6 318 */
tobyspark 0:49cdaebd52d5 319 OSCMessage *getMessage(); //return received OSCmessage
tobyspark 0:49cdaebd52d5 320
tobyspark 0:49cdaebd52d5 321 //buffer clear
tobyspark 0:49cdaebd52d5 322 //void flush();
tobyspark 0:49cdaebd52d5 323
tobyspark 4:f365c577b3c6 324 /**
tobyspark 1:ab7dc9550de6 325 Send an OSC Message (message contain the host ip and port where the message data has to be sent)
tobyspark 1:ab7dc9550de6 326 param[in] _mes Pointer to the OSC message container (OSCMessage *)
tobyspark 1:ab7dc9550de6 327 return None
tobyspark 1:ab7dc9550de6 328 */
tobyspark 0:49cdaebd52d5 329 void sendOsc( OSCMessage *_mes ); //set&send OSCmessage (note: it will be sent to the host defined in the message container)
tobyspark 0:49cdaebd52d5 330
tobyspark 0:49cdaebd52d5 331 //to be set by host program, will be called on receipt of an OSC message
tobyspark 0:49cdaebd52d5 332 FunctionPointer messageReceivedCallback;
tobyspark 0:49cdaebd52d5 333 };
tobyspark 0:49cdaebd52d5 334
tobyspark 0:49cdaebd52d5 335 #endif