In your code you use the constructor of the Bluetooth class with only one parameter (9). So the baudrate of spider UART always stays on the baudrate of 38.400 to communicate with the BT-Module. You then with bluetooth.SetDeviceBaud(115200) you set the Baudrate of the BT-Module to 115200. After this thy can no longer communicate. You should use the second constructor of the class as Brett suggested.
e.g. bluetooth = new Bluetooth(9, 38400);
this form of the constructor changes the baudrate of the spider UART too.
But you must hit the last baudrate you successfully sent to the BT-Module, otherwise the BT-does not understand the command and will not change its baudrate.
// Your code
void ProgramStarted()
{
bluetooth = new Bluetooth(9);
bluetooth.SetDeviceName("rawr");
bluetooth.SetDeviceBaud(115200);
//From the Bluetooth Class of Brett
public Bluetooth(int socketNumber)
{
// This finds the Socket instance from the user-specified socket number.
// This will generate user-friendly error messages if the socket is invalid.
// If there is more than one socket on this module, then instead of "null" for the last parameter,
// put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
Socket socket = Socket.GetSocket(socketNumber, true, this, null);
this.reset = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this);
this.statusInt = new GTI.InterruptInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingAndFallingEdge, this);
this.serialPort = new GTI.Serial(socket, 38400, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.One, 8, GTI.Serial.HardwareFlowControl.NotRequired, this);
//this.statusInt.Interrupt += new GTI.InterruptInput.InterruptEventHandler(statusInt_Interrupt);
this.serialPort.ReadTimeout = Timeout.Infinite;
this.serialPort.Open();
Thread.Sleep(5);
this.reset.Write(true);
readerThread = new Thread(new ThreadStart(runReaderThread));
readerThread.Start();
Thread.Sleep(500);
}
// Note: A constructor summary is auto-generated by the doc builder.
/// <summary></summary>
/// <param name="socketNumber">The socket that this module is plugged in to.</param>
/// <param name="baud">The baud rate to communicate with the module with.</param>
public Bluetooth(int socketNumber, long baud)
{
// This finds the Socket instance from the user-specified socket number.
// This will generate user-friendly error messages if the socket is invalid.
// If there is more than one socket on this module, then instead of "null" for the last parameter,
// put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
Socket socket = Socket.GetSocket(socketNumber, true, this, null);
this.reset = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this);
this.statusInt = new GTI.InterruptInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingAndFallingEdge, this);
this.serialPort = new GTI.Serial(socket, 38400, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.One, 8, GTI.Serial.HardwareFlowControl.NotRequired, this);
//this.statusInt.Interrupt += new GTI.InterruptInput.InterruptEventHandler(statusInt_Interrupt);
this.serialPort.ReadTimeout = Timeout.Infinite;
this.serialPort.Open();
Thread.Sleep(5);
this.reset.Write(true);
// Poundy added:
Thread.Sleep(5);
this.SetDeviceBaud(baud);
this.serialPort.Flush();
this.serialPort.Close();
this.serialPort.BaudRate = (int)baud;
this.serialPort.Open();
// Poundy
readerThread = new Thread(new ThreadStart(runReaderThread));
readerThread.Start();
Thread.Sleep(500);
}