hi there
I'm working with a bluegiga wt32 bluetooth adapter at the moment. I never worked with a serial interface so naturally, I do have some questions. generally, it works quite well, but there seem to be some problems with the serial buffer (or so I guess).
Initially I sent the serial commands just like this:
Code: [Select]
Serial.println("INQUIRY 1");
The problem with this was that somehow, when I read out the serial buffer, this command was sent/read out repeatedly.
I then modified the code like this:
Code: [Select]
Serial.println("INQUIRY 1");
delay(500);
Serial.flush();
This works better, but not in every case. And even more, I don't know why it works. If I for example remove the delay, I have the same problems again. Also, I was once told that delay should not be used...
Also, I don't know why it works with Serial.flush(). Doesn't this command delete the serial buffer? Shouldn't I then not be able to read what I have printed before?
Any help with this is appreciated...
By the way, I read out the serial buffer like this:
I'm working with a bluegiga wt32 bluetooth adapter at the moment. I never worked with a serial interface so naturally, I do have some questions. generally, it works quite well, but there seem to be some problems with the serial buffer (or so I guess).
Initially I sent the serial commands just like this:
Code: [Select]
Serial.println("INQUIRY 1");
The problem with this was that somehow, when I read out the serial buffer, this command was sent/read out repeatedly.
I then modified the code like this:
Code: [Select]
Serial.println("INQUIRY 1");
delay(500);
Serial.flush();
This works better, but not in every case. And even more, I don't know why it works. If I for example remove the delay, I have the same problems again. Also, I was once told that delay should not be used...
Also, I don't know why it works with Serial.flush(). Doesn't this command delete the serial buffer? Shouldn't I then not be able to read what I have printed before?
Any help with this is appreciated...
By the way, I read out the serial buffer like this:
[code]
while(Serial.available() > 0){
message_part = Serial.read();
message[message_part_count] = message_part;
message_part_count++;
if (message_part == char(10)){ // only send out message if it's complete (with line feed)
Serial.print(message);
delay(500);
Serial.flush();
reset_message();
} // end if
} // end while
[/code] 



