Hi,
I’m pretty new to Gadgeteer. I bought a FEZ Cerberus starter Kit and a bluetooth module.
I’m trying to get it to connect to my PC, my phone or my MS surface but none of it seems to work. I’m using the sample code from the GHI website.
I tried the official driver (GTM.GHIElectronics.Bluetooth 4.2.101.0) as well as the driver from RoSchmi.
With the official driver I got an System.ArgumentOutOfRangeException so I switched to RoSchmi’s driver.
Here’s the code that I’m using.
public partial class Program
{
Bluetooth bluetooth;
void ProgramStarted()
{
bluetooth = new Bluetooth(2);
bluetooth.SetDeviceName("Gadgeteer");
bluetooth.BluetoothStateChanged += new Bluetooth.BluetoothStateChangedHandler(bluetooth_BluetoothStateChanged);
bluetooth.DataReceived += new Bluetooth.DataReceivedHandler(bluetooth_DataReceived);
joystick.JoystickPressed += joystick_JoystickPressed;
}
void bluetooth_BluetoothStateChanged(Bluetooth sender, Bluetooth.BluetoothState btState)
{
Debug.Print(btState.ToString());
}
void bluetooth_DataReceived(Bluetooth sender, string data)
{
Debug.Print(data);
//sender.ClientMode.SendLine(data); //echoes the data back to the device.
}
void joystick_JoystickPressed(GTM.GHIElectronics.Joystick sender, GTM.GHIElectronics.Joystick.JoystickState state)
{
if (!bluetooth.IsConnected)
{
bluetooth.ClientMode.EnterPairingMode();
}
}
}
The initial output is:
Using mainboard GHI Electronics FEZCerberus version 1.1
Message from Class Bluetooth 1: Baudrate set to 38400
Message from Class Bluetooth: Try to set BT-Module baudrate to: 38400
Message from Class Bluetooth: Could connect to BT-Module with baudrate 38400 in 16.6816 msec
OK
WORK:SLAVER
0
+BTSTATE:0
1
+BTSTATE:1
3
+BTSTATE:3
Der Thread ‘’ (0x3) hat mit Code 0 (0x0) geendet.
CONNECT:FAIL
1
+BTSTATE:1
Then I press the joystick and the output is
Enter Pairing Mode
+INQ=1
OK
2
+BTSTATE:2
And the red and blue LEDs are flashing.
I then try to connect to the module from one of my devices (PC, Phone, Surface). I don’t use a PIN.
The PC will show the Gadgeteer as connected for a few seconds but the module is still flashing red and blue and it’s not getting into connected mode.
When I try to send something from the PC to the module, the module does not receive it and the code on the PC just hangs.
I updated the FEZ Cerberus with FEZ Config to 4.2.6.1.
Is there anything that I miss?
Any help is much appreciated.
Thanks,
Sebastian