Bluetooth.getPin() returns null instead of byte[]

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: roger, 99jonathan, imaqine

Bluetooth.getPin() returns null instead of byte[]

Postby ciborro » Wed Feb 06, 2013 6:08 pm

Hello,

I have some problems with pairing devices in lejos.
I can't add device for example, but on original firmware everything work's fine.

Some time ago I wrote really simple application to adding/deleting devices in lejos. It worked fine.

Now I'm trying to write better simple application for managing Bluetooth in lejos.
I recognize that function Bluetooth.getPin() don't work properly.

It returns null instead of byte[]. I enclose code example.

Code: Select all
public void ShowPIN()
    {
        byte[] pin = Bluetooth.getPin();
        if(pin == null)
        {
            LCD.clear();
            LCD.drawString("PIN unavliable!", 0, 1);
            LCD.drawString("Press any key...", 0, 2);
            Button.waitForAnyPress();
            return;
        }
        LCD.clear();
        LCD.drawString("Current PIN is:", 0, 0);

        LCD.drawInt(pin[0], 0, 2);
        LCD.drawInt(pin[1], 2, 2);
        LCD.drawInt(pin[2], 4, 2);
        LCD.drawInt(pin[3], 6, 2);
       
        Button.waitForAnyPress();
    }


Greetings.
Przemek.
ciborro
New User
 
Posts: 5
Joined: Tue Dec 20, 2011 11:00 am

Re: Bluetooth.getPin() returns null instead of byte[]

Postby gloomyandy » Wed Feb 06, 2013 10:15 pm

The pin data is not loaded until the Bluetooth code is actually used. You may need to force this, try making a call to Bluetooth.checkDevice before you call getPin...

What problems are you having with pairing? Is there a reason why you can't use the leJOS menu to do the pair operation?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3012
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff