I now get a green light in PWR, and a fast blinking light in Status on the BT Shield…
I then tried parring the devices from my computer, with the default 1234 password, and it installs 2 new BT COM ports (COM4 and COM5)…
@ Gus - yeah thats done. Tx to d0 and Rx to d1…
But still not able to type in teraterm. Or putty for that matter…
Any ideas? Or maybe a shield that would work better/more used?
Ohh yes. Really thinking about buying a new fez…
Not sure wich though…
I don’t have direct experience with HC05, but they’re simple.
First up, you need to tell us how you have established that you have comms to the BT module. Have you been able to issue commands to it and receive responses from it? This is purely in the Netmf space - if you can’t get any kind of response from the device, you’re probably suffering from uart dyslexia and need to connect TX/RX the other way around.
Then, once you establish that you can talk to the module, then you can get it paired to a PC. Then, you should be able to type from the terminal connected to the LOWEST COM port on your PC and then have it appear on the UART on your Fez.
@ Brett - That helped alot, i got contact via the Panda and im able to send AT commands and det responds…
Ive set it up as a slave, and paired it with the PC.
Still cant seem to get a connection through TeraTerm or Putty where im able to send commands…
But i tried writing a simple console program that would send a string and on the panda i should read and write it in debug…
But as soon as i run the console app, i get connected, and it sends, but in panda debug i get:
Recieved Data:
#### Exception System.Exception - CLR_E_WRONG_TYPE (3) ####
#### Message:
#### System.Text.UTF8Encoding::GetChars [IP: 0000] ####
#### FEZ_Panda_II_Application2.Program::BTport_DataReceived [IP: 0034] ####
#### System.IO.Ports.SerialPort::DataEventHandler [IP: 0012] ####
A first chance exception of type 'System.Exception' occurred in mscorlib.dll
An unhandled exception of type 'System.Exception' occurred in mscorlib.dll
This is the reader on the Panda:
static SerialPort BTport;
public static void Main()
{
// Blink board LED
OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);
BTport = new SerialPort("COM1", 38400, Parity.None, 8, StopBits.One);
BTport.Handshake = Handshake.None;
BTport.Open();
BTport.DataReceived += new SerialDataReceivedEventHandler(BTport_DataReceived);
//startSlave();
Thread.Sleep(-1);
}
public static void BTport_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
// Check if Chars are received
if (e.EventType == SerialData.Chars)
{
// Create new buffer
byte[] ReadBuffer = new byte[BTport.BytesToRead];
// Read bytes from buffer
BTport.Read(ReadBuffer, 0, ReadBuffer.Length);
// Encode to string
Debug.Print("Recieved Data:");
Debug.Print(new String(Encoding.UTF8.GetChars(ReadBuffer)));
}
}
Baud rate on BT is some kind of “ignoreable” setting. I say that because it’s mostly about the baud rate that you need to talk to the BT module at each end (so on the PC, to your BT module on motherboard or USB module; for the Fez end, it’s the baud rate the module needs to accept commands), it’s more a function of the signal strength that dictates the actual rate you can get bits between the two end points.
Hi,
did you compare the contents of your byte[] Array DataToSend of your sender with the byte[] Array ReadBuffer you received with the debugger or only the encoded strings?
Regards
Roland
Hi,
I`d try to discard the contents of the input buffer of your BT module (in Main). Perhaps there is some junk in it, which you get with the first read. Or try to send a second message, perhaps the second is o.k.
Roland
I just tried:
BTport.DiscardInBuffer();
BTport.Flush();
just after i open the port.
Still same message i get…
And when i then tried sending a second message, somthing really weird happend.
It reacts like it received 2 messages, and posting 1 half of the garbled data in one, and then the other half in the other…
I’dont know. Perhaps check the sent and received data in hex or binary to see whether thera are any correlations. Doublecheck the serial port parameters or play around for some hours. I’m off for today.
Roland
I found the error!
I guess it was stupid just to expect the default settings in the manual for the bluetooth shield would be right.
Cause i just testede with an AT command to check the baudrate, and it was only 9600
Changed it code, and all works perfect