title: Interfacing Android Nexus One with Arduino + BlueSmirf
body: <p>I'm a bit new to all of this, so bear with me - I'd really appreciate your help.  </p>
  
  <p>I am trying to link the Android Nexus One with an arduino (Duemilanove) that is connected to a BlueSmirf.  I have a program that is simply outputting the string "Hello Bluetooth" to whatever device the BlueSmirf is connected to.  Here is the Arduino program:</p>
  
  <p>void setup(){
    Serial.begin(115200);
    int i;
  }</p>
  
  <p>void loop(){Serial.print("Hello Bluetooth!");
  delay(1000);
  }</p>
  
  <p>One my computer BT terminal I can see the message and connect no problem.  The trouble is with my android code.  I can connect to the device with android, but when I look at the log it is not displaying "Hello Bluetooth".  Here is the debug log:</p>
  
  <p><br>04-09 16:27:49.022: ERROR/BTArduino(17288): FireFly-2583 connected
  <br>04-09 16:27:49.022: ERROR/BTArduino(17288): STARTING TO CONNECT THE SOCKET
  <br>04-09 16:27:55.705: ERROR/BTArduino(17288): Received: 16
  <br>04-09 16:27:56.702: ERROR/BTArduino(17288): Received: 1
  <br>04-09 16:27:56.712: ERROR/BTArduino(17288): Received: 15
  <br>04-09 16:27:57.702: ERROR/BTArduino(17288): Received: 1
  <br>04-09 16:27:57.702: ERROR/BTArduino(17288): Received: 15
  <br>04-09 16:27:58.704: ERROR/BTArduino(17288): Received: 1
  <br>04-09 16:27:58.704: ERROR/BTArduino(17288): Received: 15</p>
  
  <p>ect...</p>
  
  <p>Here is the code, I'm trying to put only the relative code but if you need more please let me know:</p>
  
  <pre><code>private class ConnectThread extends Thread {
      private final BluetoothSocket mySocket;
      private final BluetoothDevice myDevice;
  
      public ConnectThread(BluetoothDevice device) {
          myDevice = device;
          BluetoothSocket tmp = null;
          try {
              tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
          } catch (IOException e) {
              Log.e(TAG, "CONNECTION IN THREAD DIDNT WORK");
          }
          mySocket = tmp;
      }
      public void run() {
          Log.e(TAG, "STARTING TO CONNECT THE SOCKET");
          InputStream inStream = null;
          boolean run = false;
          //...More Connection code here...
  </code></pre>
  
  <p>The more relative code is here:</p>
  
  <pre><code>        byte[] buffer = new byte[1024];
          int bytes;
  
          // handle Connection
          try {
              inStream = mySocket.getInputStream();
              while (run) {
                  try {
                      bytes = inStream.read(buffer);
                      Log.e(TAG, "Received: " + bytes);
                  } catch (IOException e3) {
                      Log.e(TAG, "disconnected");
                  }
              }
  </code></pre>
  
  <p>I am reading bytes = inStream.read(buffer).  I know bytes is an integer, so I tried sending integers over bluetooth because "bytes" was an integer but it still didn't make sense.  </p>
  
  <p>It almost appears that is sending incorrect baud rate.  Could this be true?</p>
  
  <p>Any help would be appreciated.  Thank you very much.</p>