You obviously have some configuration / oscillator issues, but at least you can get it working with SPBRG = 25. This just means that you are using a 4MHz clock, or your PIC thinks its a 4MHz clock anyways.
The UART will sometimes generate some startup "codes", but normally only 1 or 2, usually to do with the PC hardware, or the 232 module.
Did you do a complete restart of the PC before trying to connect / receive, maybe it's a buffer issue?
The reason I was getting the correct response is because I set the code up for 8MHz operation, not 4, but when I changed to code from SPBRG=51 to 25, it calculated the correct code for 4MHz operation, and worked as it should at 4MHz.
As for the AT commands, I presume that when you issue an AT command to the bluetooth module it is like talking to a modem? So you will receive either:
1) OK
or
2) ERROR
Being a bluetooth module you may recieve some extra information, like a code or something, you will need to look up your spec.
You might create a few "expected" responses of OK and ERROR if the above information was correct, and send the AT command out to the modem, and then wait to recieve, this could be terminated with a CR / LF or CRLF, 0x0A + 0x0D, you may have to send the CRLF also, once the recieve has completed you can do a string compare against the result and the possibilities (OK, ERROR) if one meets, then do the required action.
For example:
Code:
if(!strcmp(inpBuff, m_OK_Response))
{
//OK Received
}
elseif(!strcmp(inpBuff, m_ERROR_Response))
{
//ERROR Received
}
else
{
//Unexpected Response
}
Where m_ERROR_Response and m_OK_Response would be your own defined static variables.
And inpBuff would be your received UART buffer.
If your response returns a code as well as the response such as "ERROR 200", you can do an indexed array compare to just get the first, in this case, 5 characters of the buffer to compare against. Or you can make a function to split the "words" ERROR and 200, so you have an Array length of 2, index 0 = "ERROR", index 1 = "200", index 0 will always be the "command"
Hope this makes sense?
Wilksey