support OSC-string

Dependents:   OSCtoCVConverter

Fork of OSC by Toby Harris

Revision:
4:601f6a1141fb
Parent:
3:f4118f0bc1ab
Child:
5:5d585d5107da
--- a/mbedOSC.h	Sun Jan 03 00:13:22 2016 +0000
+++ b/mbedOSC.h	Sat Jan 09 10:54:31 2016 +0000
@@ -3,23 +3,23 @@
  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
-
+ 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License version 2.1 as published by the Free Software Foundation.
  Open Sound Control  http://opensoundcontrol.org/
 */
-
+ 
 #pragma O3
 #pragma Otime
-
+ 
 #ifndef mbedOSC_h
 #define mbedOSC_h
-
+ 
 #include "mbed.h"
 #include "EthernetNetIf.h"
 #include "UDPSocket.h"
-
+ 
 // setup IP of destination (computer):
 #define DEFAULT_SEND_PORT 12000
 //Host sendHost(IpAddr(10, 0, 0, 1), DEFAULT_SEND_PORT, NULL); // Send Port
@@ -27,15 +27,15 @@
 #define DEFAULT_RECEIVE_PORT 57130
 //Host recHost(IpAddr(10, 0, 0, 1), DEFAULT_RECEIVE_PORT, NULL);  // Receive Port
 //UDPSocket udpRec,udpSend;
-
-
+ 
+ 
 #define MAX_ADDRESS    2
 #define MAX_ARG        4
-
+ 
 #define TYPE_INT    1
 #define TYPE_FLOAT  2
-
-
+ 
+ 
 /** Container class for OSC messages (receiving or sending)
  @note mbedOSC version 0.1 Specification (similar to Recotana's OSCClass library)
  Example of an OSC message: "/mbed/test1, if 50 32.4"
@@ -71,7 +71,7 @@
     public:
         /** Create a container for an OSC message to be received or sent */
         OSCMessage();
-
+ 
         /** Return the IpAddr object */   
         const IpAddr&  getIp();
         /** Return the port */
@@ -95,14 +95,14 @@
  Example: In the case "/ard/test", getTopAddress() = "/ard" (WITH the slash "/") 
  */        
         char        *getTopAddress();    //return address[0] :"/ard"
-
+ 
 /**
  Gets the "SubAddress" string of the OSC message (this is just the address with index 1)
  @return pointer of the SubAddress string (char *), i.e. address[1]
  Example: in the case "/ard/test", getSubAddress() = "/test" (WITH the slash "/") 
  */
         char        *getSubAddress();    //return address[1] :"/test"
-
+ 
 /**
  Gets the number of the OSC message address
  @return number of the OSC message address (byte)
@@ -121,7 +121,7 @@
  */
         char         getTypeTag(uint8_t _index);    //_index=0 ->'i'
                                                     //_index=1 ->'f'
-
+ 
 /**
  Gets the number of the OSC message args
  @return number of the args (byte)
@@ -140,7 +140,7 @@
  Note: When a index is bigger than the number of the args, it is set to the number of the args
  */
         int          getArgInt(uint8_t _index);        //_index=0 -> 123
-
+ 
 /**
  Get the args of the OSC message with a float value
  @param[in] _index The index of the args
@@ -149,7 +149,7 @@
  attention: arg declared as float, but return value cast as "double"
  attention: When index is bigger than the number of the args, it is set to the number of the args
  */
-        double       getArgFloat(uint8_t _index);    //_index=1 -> 54.21
+        float       getArgFloat(uint8_t _index);    //_index=1 -> 54.21
     
     
 /**
@@ -158,7 +158,7 @@
  Example: if the complete address string is "/ard/test", we set the topaddress as follows: char top[]="/ard" (allocation done here!), then setTopAddress(top)
  */
         void setTopAddress(char *_address);        //set address[0]
-
+ 
 /**
  Set SubAddress string of the OSC Message
  @param[in] _address A string pointer for the SubAddress String (char *)
@@ -166,7 +166,7 @@
  Attention: we should call first setTopAddress, and then setSubAddress. The order is important. This does not seems like a good idea...
  */
         void setSubAddress(char *_address);        //set address[1]
-
+ 
 /**
  Set the complete Address string of the OSC Message (top and sub addresses)
  @param[in] _topAddress, _subAddress The string pointers to top and sub addresses (char *)
@@ -175,7 +175,7 @@
  */
         void setAddress(char *_topAddress,     
                         char *_subAddress);
-
+ 
 /**
  Set address string using index (here 0 or 1)
  Example: "/ard/test", char adr[]="/ard", setAddress(0,adr), char adr2[]="/test", setAddress(1,adr)
@@ -183,14 +183,14 @@
         void setAddress(uint8_t _index,        //set 0,address[0]
                         char *_address);    
                                             //set 1,address[1]
-
+ 
 /**
  Set IP Address of the OSC Message (for SENDING messages - for receiving this will be done when receiving something ) 
  @param[in] _ip Pointer of IP Address array (byte *)
  Example: IP=192.168.0.99, then we have to do: ip[]={192,168,0,1}, then setIp(ip)
  */    
         void setIp( uint8_t *_ip );    //set ip
-
+ 
 /**
  Set IP Address to the OSC Message container (not through pointer)
  Example: IP=192.168.0.99 => setIp(192,168,0,99)
@@ -199,7 +199,7 @@
                    uint8_t _ip2,    //      168,
                    uint8_t _ip3,    //    0,
                    uint8_t _ip4);    //    100)
-
+ 
         /*
          Set PortNo for the OSC Message
          @param[in] _port PortNo (unsigned int)
@@ -247,13 +247,13 @@
         friend class OSCClass;
     
 };
-
-
-
+ 
+ 
+ 
 /* ====================================  OSCClass for sending and receiving OSC messages using UDP protocol ===================================== */
-
+ 
 #include "UDPSocket.h"
-
+ 
 /** Wraps the UDP functions to send and receive OSC messages */
 class OSCClass {
     
@@ -272,7 +272,7 @@
     void onUDPSocketEvent(UDPSocketEvent e);
     
     void decodePacket( OSCMessage *_mes); // makes OSC message from packet
-
+ 
 public:
     
     friend class UDPSocket;
@@ -290,13 +290,13 @@
  This initializes the OSC communication object with default receiving port (DEFAULT_REC_PORT) 
  */
     void begin();
-
+ 
 /**
  Initialize an OSC object with arbitrary listening port
  @param[in] _recievePort The listening ("receiving") Port No (unsigned int)
  */
     void begin(uint16_t _recievePort);
-
+ 
 /**
  Stop OSC communication (in fact, only the receiver - the server side)
  */
@@ -306,13 +306,13 @@
  Returns whether there is new OSC data in the receiver message container.
  */
     bool newMessage;
-
+ 
 /**
  Set a OSC receive message container
  @param[in] _mes Pointer to the OSC receive message container (OSCMessage *)
  */
     void setReceiveMessage( OSCMessage *_mes ); //set receive OSCmessage container (note: the message has a "host" object from which we get the upd packets)
-
+ 
 /**
  Get the received OSC message (note: this is another way to access the message directly from the OSCClass object).
  The advantage is that we will signal that we read the message, and will be able to query if a NEW message arrived
@@ -325,7 +325,7 @@
  @param[in] _mes Pointer to the OSC message container (OSCMessage *)
  */
     void sendOsc( OSCMessage *_mes ); //set&send OSCmessage (note: it will be sent to the host defined in the message container)
-
+ 
 /**
  A function pointer to be set by host program that will be called on receipt of an OSC message
  @code
@@ -334,8 +334,8 @@
  */
     FunctionPointer messageReceivedCallback;
     
-
+ 
     
 };
-
-#endif
+ 
+#endif
\ No newline at end of file