WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Deconnection and connection

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> WiiremoteJ
View previous topic :: View next topic  
Author Message
dju



Joined: 15 Mar 2008
Posts: 14

Digg It
PostPosted: Thu May 22, 2008 4:33 pm    Post subject: Deconnection and connection

Hello,

I have some problem with reconnection after a disconnection (in the same execution of my code).

I use WiiRemoteJ 1.3, Linux Mandriva 2008, Avetana, BlueZ.

Here is the code to connect my wiimote:
Code:
try {
            // Search for wiimotes
            WiiRemoteJ.findRemotes(new WiiRemoteDiscoveryListener() {
               // Inner class that allows to handle wiimote discovery

               @Override
               public void findFinished(int numberFound) {
                  // Only one wiimote is expected for calibration
                  if (numberFound != 1) {
                     changeState(FRConnectWiimote.CONNECT_FAILED);
                  }
               }

               @Override
               public void wiiRemoteDiscovered(WiiRemoteDiscoveredEvent evt) {
                  // Create new Wiicam, without calibration for the moment
                  wiiCam = new WiiCam(evt.getWiiRemote());
                                                // Listen wiimote for disconnection
                                                wiiCam.getRemote().addWiiRemoteListener(new WiiRemoteAdapter() {

                                                    @Override
                                                    public void disconnected() {
                                                        changeState(FRConnectWiimote.WIIMOTE_DISCONNECTED);
                                                    }
                                                });
                  // Only one wiimote is expected, so we stop searching
                  WiiRemoteJ.stopFind();
                  changeState(FRConnectWiimote.CONNECTED);
               }

            });
         } catch (IllegalStateException ex) {
            changeState(FRConnectWiimote.CONNECT_FAILED);
            Logger.getLogger(FRConnectWiimote.class.getName()).log(
                  Level.SEVERE, null, ex);
         }


It works fine, but, if I disconnect the wiimote (by pushing power button or removing batteries), and then I try to reconnect any wiimote, wiiRemoteDiscovered() is called, but this exception happens :
Code:
2008-05-22 11:58:44 wiiremotej.WiiRemoteDiscoverer deviceDiscovered
GRAVE: Error discovering device.
java.lang.NullPointerException: Connection is null.
        at javax.bluetooth.RemoteDevice.getRemoteDevice(RemoteDevice.java:247)
        at wiiremotej.WiiRemote.equals(WiiRemote.java:2063)
        at java.util.Vector.indexOf(Vector.java:361)
        at java.util.Vector.indexOf(Vector.java:335)
        at java.util.Vector.removeElement(Vector.java:594)
        at java.util.Vector.remove(Vector.java:745)
        at wiiremotej.WiiRemoteDiscoverer.deviceDiscovered(WiiRemoteDiscoverer.java:66)
        at javax.bluetooth.DiscoveryAgent.deviceDiscovered(DiscoveryAgent.java:284)
        at de.avetana.bluetooth.stack.BlueZ.hciInquiry(Native Method)
        at javax.bluetooth.DiscoveryAgent$1.run(DiscoveryAgent.java:208)
        at edu.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
        at java.lang.Thread.run(Thread.java:619)


I don't think that I need to do something special when WiiRemoteAdapter.disconnect() is called, but can you confirm it.
Or maybe it's a bug from avetana or WRJ.
Can you help me?

Thanks Smile
Juju
Back to top
View user's profile Send private message
Cha0s
Site Admin


Joined: 17 Jan 2007
Posts: 495

Digg It
PostPosted: Thu May 22, 2008 5:12 pm    Post subject:

That's a bug. I believe it is fixed in the next version, which I will try to get out soon (this weekend maybe?). Don't hold your breath, though, as a I have another big project I'm working on, and it has to take priority unfortunately.
_________________
Cha0s
Back to top
View user's profile Send private message
dju



Joined: 15 Mar 2008
Posts: 14

Digg It
PostPosted: Fri May 23, 2008 12:58 pm    Post subject:

Thanks Choas !

It's not so bad because WiiRemote returned by wiiRemoteDiscovered() works fine, but it's not clean.

Ju
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> WiiremoteJ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group