Main Site Documentation

Bluetooth module issue with FEZ Hydra


I am using a FEZ Hydra mainboard and I am trying to set up the bluetooth module, but I get following exception during deployment:

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Hardware.ChipworkX.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Documents and Settings\11gdandrea\My Documents\My_Projects\GHI_Projects\repo\test\ChipworkX Application1\ChipworkX Application1\bin\Debug\le\ChipworkX Application.exe’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).
#### Exception Gadgeteer.Socket+InvalidSocketException - 0x00000000 (1) ####
#### Message: Module Bluetooth cannot be used with invalid socket number 5
#### Gadgeteer.Socket::GetSocket [IP: 00c7] ####
#### Gadgeteer.Modules.GHIElectronics.Bluetooth::.ctor [IP: 000b] ####
#### ChipworkX_Application1.Program::Main [IP: 0005] ####
A first chance exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll
An unhandled exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll

Additional information: Module Bluetooth cannot be used with invalid socket number 5

I declare the bluetooth module as following:

Gadgeteer.Modules.GHIElectronics.Bluetooth bt = new Gadgeteer.Modules.GHIElectronics.Bluetooth(5);

The same happens with the sockets 4,6,7.

On the project I include following modules:

  • Gadgeteer
  • GHIelectronics.netmf.hardware.chipworks
  • gtm.ghielectronics.bluetooth
  • mscorlib

Do you know what the problem is?
Is there a project example which shows how to use the Bluetooth module?


PS: I just updated to the newest firmware version.


you say you use Hydra, but the log shows this:

so I’d say you should create a new project, not include ChipworkX dependencies, and see if that changes things?

I don’t have any Gadgeteer experience to know whether Socket 5 is a valid socket for a serial device (that I assume the Bluetooth module is) but to me the CwX information above stands out as something unexpected.


Do you have the module connected in the designer, as well as declaring your own instance of it on the same socket?


Hi, thanks for fast feedback.
what do you mean with “connected in the designer”?
And how is declared the module instance, based on the used socket?


Do you know what kind of project you created when you started? Was it Gadgeteer? If so, the designer is a feature of Visual Studio for Gadgeteer development that allows a developer to quick place modules on a virtual “workspace” and graphically connect them. Once they are connected, all of the code to declare and initialize a module is done for you. You can find this code in the Program.Generated.cs file. You will not want to modify this code, as it can be overwritten by the designer.

I received this error if I connect the module in the designer and declare it myself, so this may be where you want to look first.


so we’re saying that the fact that we’re talking about a Hydra here but ChipworkX was added may not result in an error (I assume that by Gus not agreeing :))? That certainly isn’t necessary and could lead to confusion, so I wouldn’t be doing it - even if it turns out it isn’t going to break things.


Hi Steve, thanks for the precious feedback.
Now I can connect to the Bluetooth module and communicate with it; I could set it in slave inquiry mode and connect with a Bluetooth device.

The problem is that the Bluetooth module wrapper is quite primitive; it only allows the uart connection with the chip, but does not provide a real API, which can be used to pair, connect and send data over Bluetooth.
Do you know if there is such a wrapper-project already available?


There is a very long thread about improving drivers for Bluetooth and xbee. The drivers ate open source do maybe you can contribute if interested.