Hello, this is my first time posting here,
I have a few questions regarding the Java bluetooth communication.
What I am trying to do is that I have a PIC controller that is the client and a PC that have bluetooth adapter in it as server.
I have the PIC automatically connected to the PC when ever it turned on and I was able to get it to connect.
I have the PIC keep sending a string "TESTING" to the PC in a while loop.
i tried reading it in while loop and exit it when it received a "$EXIT" string from the pic
Java Code:
        
InputStream inStream=connection.openInputStream();
BufferedReader bReader=new BufferedReader(new InputStreamReader(inStream));
int n = 0;
while(n == 0){
String lineRead=bReader.readLine();
System.out.println(lineRead);
if(lineRead.compareTo("$EXIT") == 0){
n = 1;
}
}
What I'm getting is that it's sometimes get the "TESTING" string, but sometimes I don't get them. I'm just wondering if this is the best way to do this or is there any other way of doing this?
I'm also pretty confuse on how to take in a console input to be sent to the PIC while also listening to the PIC at the same time.
Thank you very much