Android Question Bluetooth Question

wlcebtg

Member
Licensed User
Longtime User
I have a nBlue Bluetooth radio connected to a MSP430G2553 which I’m trying to communicate with. The command is composed of ASCII characters “put 12 100&CR” and the response from the nBlue Radio is “LFCR”OK”LFCR” or (0a0d”OK”0a0d). I have tried a couple of examples from the website “Serial Library” one which essentially connects to the radio with a virtual serial port. It connects to the radio without any problems and I can toggle bits on my board without any issues only if I comment out the code during the poling sub that tries to read back the OK response. I’ve also used the code that is recommended to replace the first one I tried http://www.b4x.com/forum/basi...ndroid-bluetooth-bluetoothadmin-tutorial.html they both seem to have the same problem when it try to read the radios response. I pretty comfortable with my setup I have a C# and Labview program that communicates with the board I can send commands and receive the appropriate response. Both the Labview and C# programs are simple terminal emulators. My experience with basic4android is about week now I just can’t seem to get the read response to work. Does someone out there have a simple Bluetooth emulator program in basic4android I could try? Thanks for the help I know there is an answer out there.
 

KitCarlson

Active Member
Licensed User
Longtime User
I will try to help, but have much uncertainty when reading your post. The use of commas, and carriage returns may help us separate your thoughts.

The Google Play store has several BT terminal apps, but only a some worked for me. I think I used one called Blueterm, to verify my BT hardware.

The B4A BT chat example, with minor changes involving connect insecure, and non prefix mode for async streams works too. Incoming data is not polled, but is received via newdata sub. There are posts on this. Erel has also posted a tutorial for async streams text mode, it may save effort in your application.
 
Upvote 0

wlcebtg

Member
Licensed User
Longtime User
Thanks for the response Kit I made some progress understanding why the serial poling stops working. I’m starting to feel more comfortable with the IDE and was able to set some break points, logging activity and single step through the code. When I send my string “put 12 100&CR(0x0D) it detects that the data is ready to read back in the poling sub. The data I expect to receive back from the radio is “CRLF”OK”CRLF” best I can tell since I use the TextReader1.ReadLine the first pass it captures the first CR and waits for the poling to start again. Second pass through the sub it captures LF”OK”CR and moves on, on the third pass through only the LF remains and it waits for forever expecting a CR return to happen of course it never will. I’m happy since now I know the radio is responding correctly I just need to find a way around the remaining LF. I remembered when I was testing out our boards with C# I had to switch to ReadAll to make it work for the same reason.

Also played around with the AStream example but for the life of me I couldn’t figure out how to append a carriage return to the example. Our board will not respond to commands unless it sees a CR to terminate the command. So much to learn so little time.
 
Upvote 0

wlcebtg

Member
Licensed User
Longtime User
The search function in the upper right corner is helpful in finding many solutions. I searched carriage return and found this helpful post: http://www.b4x.com/android/forum/threads/astream-carriage-return.12101/#post-67872

I was able to finally get the AStream example working just had to append the CR in the right place. Thanks for helping me out with my questions I’m slowly beginning to catch on. Really like the software and having a lot of fun using it. Vacation over back to work this morning.
 
Upvote 0
Top