Unsuccessful at connecting to brick using Android 2.0 Droid

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

Unsuccessful at connecting to brick using Android 2.0 Droid

Postby charles12 » Sat Feb 20, 2010 1:40 am

I'm unable to successfully pair my Motorola Droid running Android 2.0 with a brick running leJOS. Attempting to search and pair with the Droid from the brick doesn't work either. Has anyone ever successfully paired the Droid with a brick running leJOS 0.8.5?
charles12
New User
 
Posts: 1
Joined: Sat Feb 20, 2010 1:28 am

Re: Unsuccessful at connecting to brick using Android 2.0 Dr

Postby Shawn » Sat Mar 06, 2010 12:29 am

charles12 wrote:Has anyone ever successfully paired the Droid with a brick running leJOS 0.8.5?


I don't think that has been done.

What has been done is pairing Droid with a SVN version of leJOS using bluecove.

Originally, bluecove was needed for Android 1.6 and bluetooth wasn't available yet. My handset can't update so this is what I did.
http://github.com/Shawn-in-Tokyo/leJOS-Droid

People have used it succesfully on Droid. To get rid of the additional bluecove library and use the native 2.0 bluetooth, someone will have to try using NXTCommBluez.

To do that, you'll likely have to modify NXTCommFactory and set it up to load NXTCommBluez if the system is >1.6 .

That advice above is to make a connection via the standard leJOS methods.

You may be able to do so directly, but I have not heard of anyone having success doing so.

By the way, the SVN version is just needed to allow a nxj.cache file to be written to the sdcard. Regular leJOS connections will require this file but if you persist to try to make a direct connection (maybe using the Android samples), then you may not need SVN code.

Curiously, have you debugged your attempt. I wonder what your output is?
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

yeah....this is bad

Postby SpikeT » Mon Mar 22, 2010 4:48 am

I'm still wondering why it is so hard for droid OS to come up with a solution for their Bluetooth failure. It only works with just very few Bluetooth profiles and protocols. Maybe the Android itself wasn't completed yet.
SpikeT
New User
 
Posts: 19
Joined: Tue Sep 22, 2009 3:44 am

Re: yeah....this is bad

Postby Shawn » Tue Mar 23, 2010 8:52 am

SpikeT wrote:I'm still wondering why it is so hard for droid OS to come up with a solution for their Bluetooth failure. It only works with just very few Bluetooth profiles and protocols. Maybe the Android itself wasn't completed yet.


It wasn't complete at 1.6.

The phones built for 1.0 - 1.6 have proprietary code (not google's) which can not be updated to 2.0. The linux community can try to effectively duplicate that code or Google's partners can relent.

Anyway, it's a legal issue for handsets before 2.0.

If 2.0 handsets don't work, well I guess one factor is that the linux community can really neither test nor commit to proprietary code.

Android is not linux. It is linux on a handset that has proprietary restrictions.

Hardware makers don't want to open their stuff. Competitive advantage.
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby SpikeT » Tue Mar 23, 2010 8:03 pm

Thanks for clear thing out, but for me
who escaped from Blackberry because
it couldn't handle simple file transfer over
Bluetooth (I had a pearl)
and have to face it again with G1 is 2X suck.

I heard for BB they don't allow that because
security concern, but I think they just want to
get more money for their data plan.....that's all.
SpikeT
New User
 
Posts: 19
Joined: Tue Sep 22, 2009 3:44 am

Re: Unsuccessful at connecting to brick using Android 2.0 Dr

Postby scarface » Wed Mar 31, 2010 7:39 pm

charles12 wrote: Has anyone ever successfully paired the Droid with a brick running leJOS 0.8.5?


Hi,

I paired my Motorola Milestone running Android 2.0 with the NXT running lejos 0.85 in order to control the NXT using the accelerometer. It worked fine.

NXT code fragment:
Code: Select all
BTConnection btc = Bluetooth.waitForConnection(0, NXTConnection.RAW);
DataInputStream dis = btc.openDataInputStream();
DataOutputStream dos = btc.openDataOutputStream();
...
leftSpeed = dis.readInt();
rightSpeed = dis.readInt();
...


Android code fragment:
Code: Select all
         BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
         Set<BluetoothDevice> bondedDevices = btAdapter.getBondedDevices();
         
         for (BluetoothDevice bluetoothDevice : bondedDevices)
         {
            if (bluetoothDevice.getName().equals("NXT")) {
               nxtDevice = bluetoothDevice;
            }
         }
         
         if (nxtDevice == null)
         {
            tStatus.setText("No paired NXT device found");
            return;
         }
         
         try {
            nxtBTsocket = nxtDevice.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
            nxtBTsocket.connect();
            nxtDos = new DataOutputStream(nxtBTsocket.getOutputStream());
            tStatus.setText("Successfully connected to NXT");
         } catch (IOException e) {
            tStatus.setText("Connection to NXT failed");
            ...
         }       
        ...

scarface
New User
 
Posts: 2
Joined: Wed Mar 31, 2010 7:16 pm
Location: Berlin

Postby jawora » Wed Apr 28, 2010 9:15 pm

Code: Select all
 nxtBTsocket = nxtDevice.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));


I have just one question - where did you get the NXT UUID to paste into this method? Is it standard for NXT brick or do I have to read it somewhere? I tried this method and it didn't work.

//edit
I'm a dumbass and forgot to call connect(). Everything works fine. Thank you very much for posting the solution. But still, where did you get the UUID from?
jawora
New User
 
Posts: 2
Joined: Wed Apr 28, 2010 9:14 pm

Postby scarface » Fri Apr 30, 2010 6:23 am

jawora wrote:Where did you get the UUID from?


The NXT brick supports the Bluetooth Serial Port Profile (SPP) (see for instance http://www.docstoc.com/docs/20929335/LEGO-MINDSTORMS-NXT-Hardware-Developer-Kit/).
Each bluetooth profile has a well know UUID, so that you have to use the UUID associated with the SPP.

Links:
An overview of the BT Profiles
http://www.bluetooth.com/English/Technology/Works/Pages/Profiles_Overview.aspx

Well known UUIDs for BT Profiles
http://forum.btframework.com/index.php?topic=172.0
scarface
New User
 
Posts: 2
Joined: Wed Mar 31, 2010 7:16 pm
Location: Berlin

Postby jawora » Fri Apr 30, 2010 10:26 am

Now I get it. Thanks.
jawora
New User
 
Posts: 2
Joined: Wed Apr 28, 2010 9:14 pm

Connection with LeJOS 0.85

Postby esmetaman » Sat May 08, 2010 9:19 pm

Hi,

I tested a original solution from shawn to connect from Nexus one to NXT brick with leJOS.
http://www.youtube.com/watch?v=7HDEMxQpc_s

If you like, I can send you the example.

Cheers
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://www.iloveneutrinos.com/
User avatar
esmetaman
Advanced Member
 
Posts: 290
Joined: Wed Sep 13, 2006 12:16 am
Location: Madrid, Spain

Re: Connection with LeJOS 0.85

Postby n3cr0 » Tue Jun 01, 2010 9:15 am

esmetaman wrote:Hi,

I tested a original solution from shawn to connect from Nexus one to NXT brick with leJOS.
http://www.youtube.com/watch?v=7HDEMxQpc_s

If you like, I can send you the example.

Cheers


Hi esmetaman,

can you please send me this sample?

thanks!
n3cr0
New User
 
Posts: 1
Joined: Tue Jun 01, 2010 9:09 am

Re: Connection with LeJOS 0.85

Postby kimerajamm » Sat Jun 19, 2010 7:48 am

esmetaman wrote:Hi,

I tested a original solution from shawn to connect from Nexus one to NXT brick with leJOS.
http://www.youtube.com/watch?v=7HDEMxQpc_s

If you like, I can send you the example.

Cheers

send me too, thank :oops: :oops: :oops:
kimerajamm
 

Re: Unsuccessful at connecting to brick using Android 2.0 Dr

Postby ghoelzl » Tue Jun 22, 2010 8:57 am

I implemented the code in "NXTControl", an application to control the robot via the orientation sensor of the phone. There is also an Action-Button for doing other things than moving around. A video, instructions and source code can be found at http://sites.google.com/site/ghoelzl/nxtcontrolv2.
ghoelzl
New User
 
Posts: 1
Joined: Tue Jun 22, 2010 8:47 am

Re: Unsuccessful at connecting to brick using Android 2.0 Dr

Postby Shawn » Sat Jul 03, 2010 12:37 am

ghoelzl wrote:I implemented the code in "NXTControl", an application to control the robot via the orientation sensor of the phone. There is also an Action-Button for doing other things than moving around. A video, instructions and source code can be found at http://sites.google.com/site/ghoelzl/nxtcontrolv2.


Hey ghooelzl,

Really nice stuff there. Thanks for posting it.

It seems to work with Android 1.6 as well provided one uses backported bluetooth http://code.google.com/p/backport-android-bluetooth

The only issue I see now is that it disconnects whenever the phone orientation is changed. --> i.e I/WindowManager( 3282): onOrientationChanged,

I have modified your code slightly so will have to go back and look if there is a difference causing this, but have you even seen that problem and know what to do about it?

UPDATE:

Code: Select all
<activity android:name=".NXTControlAndroid"
                  android:label="@string/app_name"
                  android:screenOrientation="portrait">


I added android:screenOrientation="portrait" on all the actitivies in the Manifest file, and it seemed to resolve the issue .

Notes: it may not be necessary to add it to the bluetooth activities, but I went overboard. I'm really in the know on this.


Shawn
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 2 guests

cron
more stuff