what I want to do is, if I use send.setOnClickListener(new OnClickListener) to send stringdata1 + stringdata1 over the DatagramSocket to an Arduino Board, but I donīt know how to convert the two Strings and send them
please help me
thanks in Advance
////////////////////////////////////////////////////////////
Code 1
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////send.setOnClickListener(new OnClickListener() { public void onClick(View v) { SendSlcValue.setintData(); SendSlcValue.updateArduinoValues(); ;
Code 2
////////////////////////////////////////////////////////////
public class SendSlcValue { static DatagramSocket socket; static byte data[]; static { data = new byte[700]; try { socket = new DatagramSocket(); } catch (SocketException e1) { e1.printStackTrace(); } } public static void updateArduinoValues() { Thread t = new Thread(new Runnable() { @Override public void run() { try { InetAddress serverIP = InetAddress .getByName("255.255.255.255"); DatagramPacket out = new DatagramPacket(data, data.length, serverIP, 50025); socket.send(out); } catch (IOException e) { e.printStackTrace(); } } }); t.start(); } public static void setintData(byte val_onoff) { String stringdata1 = "0020 0020"; byte[] byteData1 = stringdata1.getBytes(); String stringdata2 = "0000 0071 0000 000c 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0040 0040 0020 0020 0020 0020 0020 0020 0040 0020 0020 0040 0020 0ca0"; byte[] byteData2 = stringdata2.getBytes();