Looking for a little advice. I HAD it working as intended. Press a button (1), turn on the mainboard led. Press another buttin (2) turn the LED off. Worked great. I changed the baud rate with bt.SetDeviceBaud(115200) and it freaked out. When I compile and push to the device, this appears in the output window:
[quote]Using mainboard GHI Electronics FEZHydra version 1.2
Reader Thread
SwUêó3¢Äó
3¢Äó
3¢Äó
Sc)bý
3¢Äó
ý
)©)1LJü
Program Started
Client Mode
Enter Pairing Mode
)©)1LJ¬
)©)1L*J,(*.)
The thread ‘’ (0x3) has exited with code 0 (0x0).[/quote]
I’ve tried to set it back to 9600 manually, but nothing changes. Same garbage in.
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.Seeed;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp5
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
/*******************************************************************************************
Modules added in the Program.gadgeteer designer view are used by typing
their name followed by a period, e.g. button. or camera.
Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
button.ButtonPressed +=<tab><tab>
If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
timer.Tick +=<tab><tab>
timer.Start();
*******************************************************************************************/
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
bt.SetDeviceName("Name");
bt.SetPinCode("0000");
bt.SetDeviceBaud(9600);
LCD.SimpleGraphics.AutoRedraw = true;
oled.SimpleGraphics.AutoRedraw = true;
oled.SimpleGraphics.DisplayText("Bluetooth Enabled", Resources.GetFont(Resources.FontResources.small), GT.Color.Red, 10, 10);
Debug.Print("Program Started");
bt.DebugPrintEnabled = true;
bt.BluetoothStateChanged += new Bluetooth.BluetoothStateChangedHandler(bt_BluetoothStateChanged);
Bluetooth.Client client;
client = bt.ClientMode;
client.EnterPairingMode();
LCD.SimpleGraphics.DisplayText("Bluetooth Waiting for Connection...", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Blue, 20, 20);
LCD.SetBacklight(true);
bt.DataReceived += new Bluetooth.DataReceivedHandler(bt_DataReceived);
}
void bt_DataReceived(Bluetooth sender, string data)
{
LCD.SimpleGraphics.Clear();
if (data == "1")
{
Mainboard.SetDebugLED(true);
//oled.SimpleGraphics.Clear();
//oled.SimpleGraphics.DisplayText("LED ON", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Green, 10, 20);
}
if (data == "2")
{
Mainboard.SetDebugLED(false);
//oled.SimpleGraphics.Clear();
// oled.SimpleGraphics.DisplayText("LED OFF", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Green, 10, 20);
}
LCD.SimpleGraphics.DisplayText("Recieved: " + data, Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Blue, 10, 10);
}
void bt_BluetoothStateChanged(Bluetooth sender, Bluetooth.BluetoothState btState)
{
LCD.SimpleGraphics.Clear();
oled.SimpleGraphics.Clear();
LCD.SimpleGraphics.DisplayText("State: " + btState, Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Blue, 40, 40);
oled.SimpleGraphics.DisplayText("State: " + btState, Resources.GetFont(Resources.FontResources.small), GT.Color.Blue, 10, 10);
if (sender.IsConnected)
{
oled.SimpleGraphics.DisplayText("Connected!", Resources.GetFont(Resources.FontResources.small), GT.Color.Green, 10, 20);
}
else
{
oled.SimpleGraphics.DisplayText("Not Connected", Resources.GetFont(Resources.FontResources.small), GT.Color.Red, 10, 20);
}
}
}
}
Anyone have an idea why I can’t get good data back into or out of my Bluetooth module? I am running 4.2.