Bluetooth connection to Wii wireless remote


I’ve got a little time now to tinker somewhat. Does anyone have a starting point to begin using a Bluetooth dongle on the FEZ Dominio? I rewritten the USB mouse interface example to test communication with the dongle. I get a response of:

Data = 15 4 0 1 0 0 0 0 0 0 0 0 0 0 0 0

Here is the code:

using System;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.USBHost;
using GHIElectronics.NETMF.System;

namespace BlueTooth
    public class Program
        static USBH_RawDevice bluetooth;
        static USBH_RawDevice.Pipe bluetoothPipe; // needed to read the bluetooth data
        static Thread bluetoothThread; // polls the bluetooth for data

        public static void Main()
            // Subscribe to USBH event.
            USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;

            // Sleep forever

        static void DeviceConnectedEvent(USBH_Device device)
            Debug.Print("BlueTooth connected");
           bluetooth = new USBH_RawDevice(device);

            // Get descriptors
            USB_Descriptors.ConfigurationDescriptor cd = bluetooth.GetConfigurationDescriptors(0);
            // communication endpoint
            USB_Descriptors.EndpointDescriptor bluetoothEP = null;

            // look for HID class
            for (int i = 0; i < cd.interfaces.Length; i++)
                // look for input interrupt Endpoint
                for (int ep = 0; ep < cd.interfaces[i].endpoints.Length; ep++)
                    // is it interrupt Endpoint?
                    if (cd.interfaces[i].endpoints[ep].bmAttributes == 0x03)
                        // set configuration
                        bluetooth.SendSetupTransfer(0x00, 0x09, cd.bConfigurationValue, 0x00);

                        bluetoothEP = cd.interfaces[i].endpoints[ep];   // get endpoint
                        bluetoothPipe = bluetooth.OpenPipe(bluetoothEP);        // open pipe
                        bluetoothPipe.TransferTimeout = 0;              // recommended for interrupt transfers

                        bluetoothThread = new Thread(BlueToothThread);      // create the polling thread
                        bluetoothThread.Priority = ThreadPriority.Highest;  // we should read as fast as possible


     static void BlueToothThread()
            int count,i;
            string btdatastring = "";
            // Maximum data is wMaxPacketSize
            byte[] bluetoothData = new byte[bluetoothPipe.PipeEndpoint.wMaxPacketSize];

            // Read every bInterval
            while (true)

                count = bluetoothPipe.TransferData(bluetoothData, 0, bluetoothData.Length);

                btdatastring = "Data = ";
                for(i=0; i<bluetoothData.Length;i++)     
                        btdatastring = btdatastring +((sbyte)(bluetoothData[i]) + " ");

Any help would be greatly appreciated!

From previous experience, operation with a bluetooth dongle is not an easy task. Yes you can successfully communicate with the bluetooth dongle but you have to implement the whole bluetooth stack to get to the point to run a SSP or OPP profiles for instance.

Actually we have Bluetooth stack ready and we were to add it to our NETMF device but we noticed that it is not very needed by our partners. Also easy Serial-to-Bluetooth modules are available like this one:

All I’m looking for is some simple commands such as search for devices, connect, send/receive data. I take it it’s not that simple.

Any chance I can get to try the stack you have to make things a bit more freakin’ easy? :slight_smile:

Making a stack is at LEAST 6 months of work…porting our stack is at least a month of work and the stack is not free. If you are just having fun, I highly recommend not o go this route. If you are looking fro commercial use and have thousands to spend on this needs then contact GHI directly please.

So I should disregard what Josef said about having a stack available but not added to the NETMF?

I’m trying to work with a Cambridge Silicon Radio chip based dongle. Does anyone know if that takes simple AT commands I’ve read some take? Chips says 41(8orB)14.

Joe said it is available but didn’t say it is free :slight_smile:

No there is no AT commands at all. Bluetooth is much more complicated than you have in mind. We are talking about thousands of lines of code to do any simple thing on bluetooth. This is why 99% of users use modules with SPP profile (like the module we offer). when you use a module with SPP then the complete bluetooth stack is implemented right into the module + it has SPP profile which is Serial Port Profile. AT commands become available AFTER you implemented few layers of the bluetoot stack. See this image

Ohh…I was under the impression the chip inside the dongle had been programmed to accept these commands already. So I need to look for dongles with SPP specified? Would this be one that has that:

I will try to save your the time. :wink: 99.9% of USB Bluetooth dongle depend on a standard Windows Bluetooth driver which in its role implement the Bluetooth stack and the profiles such as SPP.

Usually Bluetooth modules with SPP profiles are made specially for embedded systems and they come with UART interface like the one I pointed to before.

how would you setup a bluetooth listener? how would you pick a device to connect to, such as the wii controller (as mentioned in the title)? this thread seems to be discussing using a USB bluetooth module instead. the brochure for the tinyclr bluetooth only shows creating a connection to send strings only, is COM3 the name of the com port on the fez or the computer?

I think the current Bluetooth board only support connecting to a PC where the PC establishes the connection to the module

hmm, that just ground my headtracking using the wii controller and the fez domino idea to a halt, i guess ill have to use a pc for now. i was pretty sure that the fez with bluetooth could at least listen to the wii but ill have to do some more reading on how the bluetooth establishes the connection… anybody tried anything like this with the bluetooth module?

You have to use a full bluetooth module not one that is spp. Which means writing a command stack and so on. I have not done so on a FEZ I have done it on a arm7 of course not for a wii though.

I just purchased the BT interface (at the nice sale price, BTW 8) and was happy with how easy it was to use. The documentation is sparse, however. I would love to see a spec from the manufacturer. This combined with an IR receiver and I may never throw an old remote away again!

More importantly, I’d like to cast another vote for a full BT stack on the FEZ boards. The hardware is cheap, but then we don’t have a team of developers at Microsoft writing drivers for us…

If the very low power BT standard is ever ratified I think there will be a surge in interest both commercially and for hobbyists. On the other hand, maybe the Zigbee folks have already saturated this niche and BT VLP devices will never really take hold.