Sending or receiving data from Wiimote using chrome.hid and using Windows 7 default HID driver not working

and thanks for taking the time to read this.

Concept

Connect wiimote to windows (or mac) using default HID driver and service (since BT L2CAP is not yet supported in chrome.bluetoothSocket). I do not want to send and receive data from the device; buttons, gyroscope, IR camera, etc.

My setup (relevant parts)

  • Macbook pro (installed by Yosemite)
  • Chrome Canary (version 41.0.2246.0 canary (64-bit)) running in verbose logging mode
  • Windows 7 via bootcamp
  • Wiimote (Nintendo RVL-CNT-01)

Code for sending data to the device

var _wiimote = this;
var bytes = new Uint8Array(21);

var reportId = 0x11;
bytes[0] = 0x10;

chrome.hid.send(_wiimote.connectionId, reportId, bytes.buffer, function() {
  if (chrome.runtime.lastError) {
    console.log(chrome.runtime.lastError.message);
    console.log(chrome.runtime.lastError);
  }
  console.log("Wiimote send data");

  chrome.hid.receive(_wiimote.connectionId, function(reportId, data) {
      if (chrome.runtime.lastError) {
        console.log(chrome.runtime.lastError.message);
        console.log(chrome.runtime.lastError);
        return;
      }

      console.log("done receiving.");
      console.log("received:" + data.byteLength);
    });
});

      

Expected behavior?

Start the first LED and stop the blinking that starts when connecting, but not pairing, with the device.

Actual behavior?

The console shows "Wiimote transfer data", but the LEDs do not respond to the submitted report.

So this code doesn't do much, but according to the wiibrew documentation (see below). It has to send to wiimote to light the first LED. This goes for any output report I send to the device. It reacts when I use wrong report IDs or different byte lengths then it fails.

Next there will be a receiving part, if I have to send anything (really any data) in reportId 0x15 to wiimote, it should send me an informational report. I've tried polling for posts like this:

Code for receiving data from the device

var _wiimote = this;

var pollForInput = function() {
  chrome.hid.receive(_wiimote.connectionId, function(reportId, data) {
    console.log("receiving something",reportId);

    if (_wiimote.pollReceive) {
      setTimeout(pollForInput, 0);
    }
  });
};

      

Expected behavior?

After sending 0x00 to reportId 0x15, I should receive an informational report from the wiimote device.

Actual behavior?

I never got anything in the console output indicating communication with the device.

Resources used

+3


source to share





All Articles