Sending OSC data?


Last Updated:

  1. TobiTobsen

    TobiTobsen New Member This Topic's Starter

    Joined:
    Jul 1, 2010
    Messages:
    3
    Likes Received:
    0
    Hey!
    I'm happy to be a new member in this community!

    I'm testing a few things and I'm trying to send OSC data (via UDP) by using a java library.
    When I'm using the Android emulator, how does he connect to the network? Or what settings do I have to do to send and receive the data?
    What I did is to allow the software to use network by writing this to the AndroidManifest.xml:
    <uses-permission android:name="android.permission.INTERNET" />

    Here is some easy code, trying to send data to IP 192.168.60.11 and port 3333


    Code (Text):
    1.  
    2. package com.example.helloandroid;
    3.  
    4. import com.illposed.osc.OSCMessage;
    5. import android.app.Activity;
    6. import android.os.Bundle;
    7. import android.widget.TextView;
    8.  
    9. public class HelloAndroid extends Activity {
    10.     /** Called when the activity is first created. */
    11.     @Override
    12.     public void onCreate(Bundle savedInstanceState) {
    13.         super.onCreate(savedInstanceState);
    14.        
    15.         TextView tv = new TextView (this);
    16.         tv.setText("Hello Android");
    17.        
    18.         setContentView(tv);
    19.        
    20.         /*
    21.          * Preparing OSC data
    22.          */
    23.         OSCInterface oscInterface = new OSCInterface("192.168.60.11", 3333);
    24.        
    25.         Object [] data = new Object [2];
    26.         data[0] = (int)111;
    27.         data[1] = (int) 222;
    28.        
    29.         String oscAdd = "/data";
    30.        
    31.         /*
    32.          * Sending data
    33.          */
    34.         System.out.println("Sending OSC DATA");
    35.         oscInterface.sendSingleMessage(new OSCMessage(oscAdd ,data));
    36.            
    37.     }
    38. }
    39.  
    40.  

    And my OSCInterface

    Code (Text):
    1.  
    2.  
    3. package com.example.helloandroid;
    4.  
    5. import java.io.IOException;
    6. import java.net.InetAddress;
    7. import java.net.SocketException;
    8. import java.net.UnknownHostException;
    9. import com.illposed.osc.OSCMessage;
    10. import com.illposed.osc.OSCPortOut;
    11.  
    12.  
    13. /**
    14.  * Dies Klasse stellt die OSC Schnittstelle nach au
     

    Advertisement

Share This Page

Loading...