NXT pair with Epuck

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

NXT pair with Epuck

Postby A.Soriano » Tue Apr 12, 2011 7:35 am

Hello!
I'm trying pair the nxt with an Epuck. With RobotC there isn't any problem but with LejOS the problem is when, in the menu of NXT, I do "Bluetooth->Search and Pair" NXT finds the epuck and I try to pair them but NXT needs a confirmation from the other device to pair correctly and from the epuck i can't send this confirmation. Is there any way to pair the NXT with LeJOS without the confirmation? Like in RobotC.
Thanks,
regards!
A.Soriano
New User
 
Posts: 15
Joined: Fri Apr 08, 2011 10:14 am

Re: NXT pair with Epuck

Postby gloomyandy » Tue Apr 12, 2011 9:00 am

Are you sure you are using the correct pin number? You may need to use some sort of default pin for this device (like 0000 or 1234)... You may also find it easier to do the pairing pragmatically using the connect methods that allow you to specify the pin...
http://lejos.sourceforge.net/nxt/nxj/ap ... nt,%20byte[]%29
Note that you will almost certainly need to use RAW mode when talking to this device...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4177
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: NXT pair with Epuck

Postby A.Soriano » Tue Apr 12, 2011 12:13 pm

Thanks for your answer.

I tried it and I managed to connect with another NXT which was running robot C firmware. But when I tried the same on another NXT running lejos was impossible and I was neither able to connect to the e-puck bluetooth module. In this last case is not a problem of a wrong pin or mac since using hyperterminal from windows i can connect to the e-puck (working as a slave) and get the data that is sending.

Here's the code I used:

Code: Select all
byte[] pin=new byte[4];
      try {
         pin="1234".getBytes("ASCII"); //also tried with "UTF-8"
      } catch (UnsupportedEncodingException e) {
         // TODO Auto-generated catch block
         //e.printStackTrace();
      }      
      
      boolean band = true;
      BTConnection btc = null;
      while(band){
              //NXTGUI  0016530773f6 //robot C
         //ip4        001653089da5 //leJOS
         //EPUCK    1000e86cd7fb
         
         btc = Bluetooth.connect("0016530773f6",NXTConnection.RAW,pin);
         //btc = Bluetooth.connect("001653089da5",NXTConnection.LCP,pin);
         //btc = Bluetooth.connect("0016530773f6",NXTConnection.PACKET,pin);
      
         if (btc == null) {
            System.out.println("No such device");
             Button.waitForPress();
         }
         else{
            band=false;
         }
      }
      
      System.out.println("Connected!");


Any other advice/suggestions?

Regards
A.Soriano
New User
 
Posts: 15
Joined: Fri Apr 08, 2011 10:14 am

Re: NXT pair with Epuck

Postby gloomyandy » Tue Apr 12, 2011 1:17 pm

No real idea sorry. I've never had any problem with connecting to Bluetooth devices that support the correct profiles (which this must if you can connect from another NXT). It's very hard to try and work out what is going on without access to the device... A couple of things to try....
1. Make suer you delete the device from the list of known devices in the menu before you run your program.
2. What happens if you search for the device from the leJOS menu? Does it show up? What address etc. is displayed?
3. Try pairing with the device from RobotC (or the Lego firmware), then flash the leJOS firmware to the same NXT and try connecting again (without setting a pin or pairing), it should reuse the data that was set by RobotC

Good luck

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4177
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff