and thanks for taking the time to read this.

Concept

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

My setup (relevant parts)

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

Code to send data to 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?

Light up the first LED and stop the blinking that starts when connection, but not pairing, the device.

Actual behavior?

The console shows "Wiimote send data" but the LEDs do not react on the sent report.

So this code doesn't do much, but according to the documentation on wiibrew(see resources below). It should send to the wiimote to light up the first LED. This goes for any output report I'm sending to the device. It does react when I use wrong reportIds or different byte lengths, then it fails.

Next up would be the receiving part, if I were to send anything (really any data) to reportId 0x15 on the wiimote, it should send me an information report. I've tried polling for messages like this:

Code to receive 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 the reportId 0x15 I should receive an information report from the wiimote device.

Actual behavior?

I've never received anything in the console output indicating communication from the device.

Resources used

0

There are 0 answers