Problems (#1) - wiimote discovering problem (#2) - Message List

wiimote discovering problem

Both wmgui and wmimput can't discover my wiimote automatically; in order to make they work i have to provide wiimote bluetooth adres as argument to both commands.

Is it a know issue? Or do you need more information to figure out the problem?

Thank you in advance. Valdar.

  • Message #3

    I know that several people have had to do exactly as you describe, but I don't know the cause. It just occurred to me that it may be a different device name - run 'hcitool scan' with your wiimote in discoverable mode, and post the output here.

    • Message #5

      [root@nathan valdar]# hcitool scan Scanning ...

      00:19:1D:93:AC:5B Nintendo RVL-CNT-01

      • Message #6

        No problem there.

        Post the result of 'hcitool inq 00:19:1D:93:AC:5B'

        If your class matches mine (0x002504), I'm blaming it on BlueZ.

        • Message #7

          [root@nathan valdar]# hcitool inq 00:19:1D:93:AC:5B Inquiring ...

          00:19:1D:93:AC:5B clock offset: 0x140a class: 0x002504

          • Message #8

            Yup - blaming it on BlueZ.

            The only other thing I can think of is if you have two bluetooth interfaces, and libwiimote is checking the wrong one.

            I'm working on a lswm utility - I can put a debug mode in it that lists all bluetooth devices rather than just wiimotes, which may shed some light on the issue.

            • Message #12

              I have the same problem ... wmgui works as long as I set the address

              I made a small connection program in C as I was looking through the api spec and whenever I try the connect function, it always fails with "Error opening control channel".

              The wmdemo app fails in the same manner and, after seeing this post, I am at least able to determine that wmgui can talk to my wiimote.

              "hcitool scan" yeilds : 00:19:1D:C2:E6:C4 Nintendo RVL-CNT-01

              and "hcitool inq 00:19:1D:C2:E6:C4" yeilds: Inquiring ...

              00:19:1D:C2:E6:C4 clock offset: 0x0564 class: 0x002504

              I'm running Ubuntu 6.10 Edgy on my Thinkpad T-43, using the built in bluetooth adapter.

              Any help would be appreciated as I plan to use the libwiimote c api in my thesis project.

              • Message #19

                oh... Interesting: a thesis project based on cwiid! Can i ask you what type of thesis? Because i'would like to implement a gesture recognition plug-in for one of my exams (machine learning).

                Best regards.

                • Message #22

                  I wouldn't say my thesis is based on cwiid ... but I do want to utilize a useful, hackable package like the wiimote on a free, useful, hackable OS aka Linux.

                  Well, my thesis is basically a wearable computer running an algorithmic realtime agent that interacts/accompanies my midi guitar input. I'm hacking my wiimote into the midi guitar so I can shake it, use gestures, etc as well as hack another wiimote into a glove so, for example, I can scratch wavetable waveforms in realtime.

                  Of course, I could do all this using a microcontroller + bluetooth module + accelerometer .... but a wiimote has all of these in one package that is cheaper then buying all of the above.

                  If anyone comes up with a good gesture recognition system, I'd be interested as I'm more focused on building my music/performance algorithms right now.

                  • Message #23

                    Great! I'm interesting in wiimote+MIDI because i plan (with one friend) to write an application that convert wiimote gestures an command in MIDI command with jack support. If your thesis' will be open-source I would like to try your code.

                    • Message #24

                      ... but before I do anything, I have to be able to connect to the wiimote through libwiimote :P

                      As of right now it always fails with "Error opening control channel." And I print out the bluetooth address I'm using just to make sure it's the right one :(

                      • Message #25

                        but if you use wminput 00:19:1D:C2:E6:C4 doesn't it work?

                        • Message #27

                          yeah, I just tried that and it works.

                      • Message #26

                        I misunderstood - from your previous message, I thought you had to specify the address, but it was otherwise working fine.

                        First step: make sure the wiimote isn't connected to something else, like a Wii.

                        • Message #28

                          No Wii's here.

                          Well, what dosen't work is specifying the address in my test C code:

                          /**** BEGIN ****/

                          #include <stdio.h>

                          #include "wiimote.h"

                          void callback(int id, int mesg_count, union wiimote_mesg* mesg[]) {

                          if(mesg_count > 0)

                          printf("recieved mesg\n");

                          }

                          int main() {

                          wiimote_t *wi_mote; bdaddr_t *wi_addr;

                          wi_addr = strtoba("00:19:1D:C2:E6:C4"); printf("Wiimote addr : %s\n", batostr(wi_addr));

                          if((wi_mote = wiimote_connect(*wi_addr, &callback, NULL)) == NULL)

                          printf("Connection Error\n");

                          return 0;

                          }

                          /**** End ****/

                          I always get the "Error opening control channel" error when wiimote_connect fails. It's just a very simple test to get started and mabey I'm missing something in the api?

                          • Message #29

                            (some of the linebreaks didn't make it into the post above :P)

                            Ok, another note:

                            $ ./wmdemo 00:19:1D:C2:E6:C4

                            Put Wiimote in discoverable mode now (press 1+2)... 0:Error opening control channel Unable to connect to wiimote

                            and

                            $ ./wmdemo

                            Put Wiimote in discoverable mode now (press 1+2)... -1:Error reading device name 0:Unable to find wiimote Unable to connect to wiimote

                            • Message #34

                              hmmmm...do you have more than one bluetooth interface, by chance? Your code looks good, I'm leaning towards a hardware or bluez problem (which would include a bad bluez invocation on my part).

                              • Message #47

                                I'd just like to say that neither wminput nor wmgui automatically find my Wiimotes either. My PC only has the one bluetooth interface, also; a USB dongle which happens to include an unused IR module.

                                • Message #48

                                  Can you post the output of 'lswm -al' (as noted above, download the svn sources for lswm)?

                                  • Message #76

                                    ok, using the latest svn ...

                                    $ lswm -al Put Bluetooth devices in discoverable mode now... 00:19:1D:C2:E6:C4 0x002504 Nintendo RVL-CNT-01

                                    I also now get some compile errors when I try my example code from before:

                                    Line 224 in wimote.h : "uint8_t class[3];"

                                    More Info:

                                    /usr/include/wiimote.h:224: error: expected identifier before ‘[’ token /usr/include/wiimote.h:224: error: expected unqualified-id before ‘[’ token :: === Build finished: 2 errors, 0 warnings ===

                                    • Message #77

                                      I'm at a loss, and I can't reproduce the error. Is anyone who can reproduce the error willing to dig into the wiimote library to figure out what's going on? I can provide guidance over email, phone, IM (IM preferred).

                                      Concerning the compile error, are you using a C++ compiler? class is a reserved word in C++, I changed it to btclass, it's checked into svn.

                          • Message #38

                            I have try your example code:

                            [valdar@nathan cwiid]$ gcc -I/usr/include/ -c example.c
                            [valdar@nathan cwiid]$ gcc -lwiimote -oexample example.o
                            [valdar@nathan cwiid]$ ./example
                            Wiimote addr : 00:19:1D:93:AC:5B
                            Error opening control channel
                            Connection Error
                            

                            and wmdemo (in 2 quick execution follow one another with wiimote in discover mode since the first command):

                            [valdar@nathan wmdemo]$ ./wmdemo 00:19:1D:93:AC:5B
                            Put Wiimote in discoverable mode now (press 1+2)...
                            0:Unable to find wiimote
                            Unable to connect to wiimote
                            [valdar@nathan wmdemo]$ ./wmdemo 00:19:1D:93:AC:5B
                            Put Wiimote in discoverable mode now (press 1+2)...
                            0:Error opening control channel
                            Unable to connect to wiimote
                            

                            while wminput:

                            [valdar@nathan wmdemo]$ wminput 00:19:1D:93:AC:5B
                            Put Wiimote in discoverable mode now (press 1+2)...
                            Ready.
                            

                            Why with wminput it works and with those 2 simple programs doesn't? I think that this is the main point of the problem.

                            This is my lsusb:

                            [valdar@nathan cwiid]$ lsusb
                            Bus 002 Device 005: ID 1131:1001 Integrated System Solution Corp. KY-BT100 Bluetooth Adapter
                            .
                            .
                            .
                            

                            and this my bluez-lib version:

                            [valdar@nathan ~]$ pacman -Q bluez-libs
                            bluez-libs 3.7
                            

                            I hope this is useful.

                          • Message #40

                            Ok - after going through the BlueZ code, it looks like the batostr and strtoba functions leave out a baswap call, so use ba2str and str2ba instead. (according to the BlueZ dev list, this is the desired behavior, although no explanation is given).

                            I've also changed the wiimote_connect prototype slightly so that it takes a pointer to bdaddr_t, this is more in-line with all of the BlueZ functions, and more efficient anyway. And I've corrected the comment in wmdemo that may have led you to use batostr in the first place.

                            The following revision of your code works for me (that is, it exits without printing an error):

                            #include <stdio.h>
                            #include "wiimote.h"
                            void callback(int id, int mesg_count, union wiimote_mesg* mesg[]) {
                                if(mesg_count > 0)
                                    printf("recieved mesg\n");
                            }
                            int main() {
                                wiimote_t *wi_mote;
                                bdaddr_t wi_addr;
                                char str_addr[18];
                                str2ba("00:19:1D:6F:7D:1E", &wi_addr);
                                ba2str(&wi_addr, str_addr);
                                printf("Wiimote addr : %s\n", str_addr);
                                if((wi_mote = wiimote_connect(&wi_addr, &callback, NULL)) == NULL)
                                    printf("Connection Error\n");
                                return 0;
                            }
                            

                            If you're still having problems, post the output of 'lswm -al' (you'll need to download the svn source for the lswm utility).

                            • Message #97

                              I've tried the latest svn and still the same error .. it must be something in my bluez.

                              #include <iostream>
                              #include <stdio.h>
                              #include <cwiid.h>
                              using namespace std;
                              void callback(int id, int mesg_count, union cwiid_mesg* mesg[])
                              {
                                  if(mesg_count > 0)
                                      printf("recieved mesg\n");
                              }
                              int main() {
                                  wiimote *wi_mote;
                                  bdaddr_t *wi_addr;
                                  char str_addr[18];
                                  str2ba("00:19:1D:6F:7D:1E", wi_addr);
                                  ba2str(wi_addr, str_addr);
                                  printf("Wiimote addr : %s\n", str_addr);
                                  if((wi_mote = cwiid_connect(wi_addr, &callback, NULL)) == NULL)
                                      printf("Connection Error\n");
                                  return 0;
                              }
                              

                              once again: $ lswm -al Put Bluetooth devices in discoverable mode now... 00:19:1D:C2:E6:C4 0x002504 Nintendo RVL-CNT-01

                              • Message #98

                                Add

                                printf("%s\n", strerror());
                                

                                right after the error in cwiid/libcwiid/connect.c, post the output.

                                Do you have L2Cap protocol enabled in your kernel?

                                • Message #99

                                  I do indeed have L2cap:

                                  $ lsmod | grep l2cap
                                  l2cap                  26112  5 rfcomm
                                  bluetooth              57444  7 rfcomm,l2cap,hci_usb
                                  

                                  I'm using a stock Ubuntu kernel.

                                  • Message #106

                                    Did you try the strerror() part? That'll tell us why the connect call is failing.

  • Message #94

    discussion moved to #31

Subscriptions