amarino, sending data from arduino to android

Helllo, I've played a little with the amarino library and so far im able to send values from android to arduino succesfully. Now i want to send some sensor reading from arduino to the android device.

I've wrote this code in android in order to get the values

public class ArduinoReceiver extends BroadcastReceiver 
    {

        @Override
        public void onReceive(Context context, Intent intent) 
        {
            String data = null;
            int[] var= new int[10];


            final String address = intent.getStringExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS);


            final int dataType = intent.getIntExtra(AmarinoIntent.EXTRA_DATA_TYPE, -1);


            if (dataType == AmarinoIntent.STRING_EXTRA)
            {
                data = intent.getStringExtra(AmarinoIntent.EXTRA_DATA);

                testview = (TextView)findViewById(R.id.result);
              testview.setText(data);
              
                Scanner s = null;
                try 
                {
                    s = new Scanner(data);
                    s.useDelimiter(",\\s*");
                    
                    int i=1;
                    while (s.hasNext()) 
                    {
                        if (s.hasNextInt()) 
                        {
                          var[i]= s.nextInt();
                            
                        } 
                        else 
                        {
                          s.next();
                            
                        }   
                        i++;
                    }
                } 
                finally 
                {
                    s.close();
                    testview = (TextView)findViewById(R.id.textView1);
                  testview.setText(Integer.toString(var[1]));
                  testview = (TextView)findViewById(R.id.textView2);
                  testview.setText(Integer.toString(var[2]));
                  testview = (TextView)findViewById(R.id.textView3);
                  testview.setText(Integer.toString(var[3]));
                  testview = (TextView)findViewById(R.id.textView4);
                  testview.setText(Integer.toString(var[4]));
                  testview = (TextView)findViewById(R.id.textView5);
                  testview.setText(Integer.toString(var[5]));
                  
                }

            }
        }
    }

and something like this in the arduino side :

startFlag = 18; ack = 19;

Serial.print(startFlag); Serial.print(var[0]); Serial.print(','); Serial.print(var[1]); Serial.print(','); Serial.print(var[2]); Serial.print(','); Serial.print(var[3]); Serial.print(','); Serial.print(var[4]); Serial.print(','); Serial.print(ack);

the problem is that i get only the ack value on the phone. =\ can anyone help me?

I’ve wrote this code in android in order to get the values

and something like this in the arduino side :

startFlag = 18;
ack = 19;

Serial.print(startFlag);
Serial.print(var[0]);
Serial.print(’,’);
Serial.print(var[1]);
Serial.print(’,’);
Serial.print(var[2]);
Serial.print(’,’);
Serial.print(var[3]);
Serial.print(’,’);
Serial.print(var[4]);
Serial.print(’,’);
Serial.print(ack);

“Something like this”? Try posting your EXACT code.

ok im posting the full code again…
android code

package nik.com;


import java.util.Scanner;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.TextView;
import at.abraxas.amarino.Amarino;
import at.abraxas.amarino.AmarinoIntent;

public class Am_test extends Activity {
    /** Called when the activity is first created. */
	
	private static final String DEVICE_ADDRESS =  "00:06:66:42:1F:C8";
	
	private ArduinoReceiver arduinoReceiver = new ArduinoReceiver();
	
	TextView testview;
	String num;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
	@Override
	protected void onStart() {
		super.onStart();
		// in order to receive broadcasted intents we need to register our receiver
		registerReceiver(arduinoReceiver, new IntentFilter(AmarinoIntent.ACTION_RECEIVED));
		
		// this is how you tell Amarino to connect to a specific BT device from within your own code
		Amarino.connect(this, DEVICE_ADDRESS);
	}
	
	@Override
	protected void onStop() {
		super.onStop();
		
		// if you connect in onStart() you must not forget to disconnect when your app is closed
		Amarino.disconnect(this, DEVICE_ADDRESS);
		
		// do never forget to unregister a registered receiver
		unregisterReceiver(arduinoReceiver);
	}
	
	public class ArduinoReceiver extends BroadcastReceiver 
	{

		@Override
		public void onReceive(Context context, Intent intent) 
		{
			String data = null;
			int[] var= new int[10];
			

			final String address = intent.getStringExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS);
			

			final int dataType = intent.getIntExtra(AmarinoIntent.EXTRA_DATA_TYPE, -1);
			

			if (dataType == AmarinoIntent.STRING_EXTRA)
			{
				data = intent.getStringExtra(AmarinoIntent.EXTRA_DATA);
				
				testview = (TextView)findViewById(R.id.result);
	    		testview.setText(data);
	    		
	            Scanner s = null;
	            try 
	            {
	                s = new Scanner(data);
	                s.useDelimiter(",\\s*");
	                
	                int i=1;
	                while (s.hasNext()) 
	                {
	                    if (s.hasNextInt()) 
	                    {
	                    	var[i]= s.nextInt();
	                        
	                    } 
	                    else 
	                    {
	                    	s.next();
	                        
	                    }   
	                    i++;
	                }
	            } 
	            finally 
	            {
	                s.close();
	                testview = (TextView)findViewById(R.id.textView1);
		    		testview.setText(Integer.toString(var[1]));
		    		testview = (TextView)findViewById(R.id.textView2);
		    		testview.setText(Integer.toString(var[2]));
		    		testview = (TextView)findViewById(R.id.textView3);
		    		testview.setText(Integer.toString(var[3]));
		    		testview = (TextView)findViewById(R.id.textView4);
		    		testview.setText(Integer.toString(var[4]));
		    		testview = (TextView)findViewById(R.id.textView5);
		    		testview.setText(Integer.toString(var[5]));
		    		
	            }

			}
		}
	}
}

arduino code

#include <MeetAndroid.h>

MeetAndroid meetAndroid;


void setup()  
{

  Serial.begin(57600); 
  
  meetAndroid.send("1");
  meetAndroid.send(",");
  meetAndroid.send("2");
  meetAndroid.send(",");
  meetAndroid.send("3");
  meetAndroid.send(",");
  meetAndroid.send("4");
  meetAndroid.send(",");
  meetAndroid.send("5");
  
}

void loop()
{}

Im getting the following values on the android side

5
5
0
0
0
0

I've never heard of the MeetAndroid class, so it is hard to say what its send might be doing. Do you have a link to this library?

Here is what i found in the cpp file:

void MeetAndroid::send(char c ){
    Serial.print(startFlag);
    Serial.print(c);
    Serial.print(ack);
}

startFlag = 18; ack = 19;

and here is the link of amarino http://www.amarino-toolkit.net/

Any progress on this? I am trying to do something similar.

What are you using? How much and where can I buy? http://arduino.cc/forum/index.php/topic,71496.0.html

I tried and I found the solution, just use this code in Arduino:

#include <MeetAndroid.h>

MeetAndroid meetAndroid;


void setup()  
{

  Serial.begin(115200); //or (57600); according your bluetooth module
  
  delay(3000);
  
  meetAndroid.send("1,2,3,4,5");
    
}

void loop()
{}

There is good alternative! Just use ArduinoCommander (https://market.android.com/details?id=name.antonsmirnov.android.arduinocommander) on Android and StandardFirmata sketch on the board.

if i want to work on sending data to android serially what is the code that i should delete it??