RN-42 Bluetooth Communication Guidance
Adam_Karlstedt
Posts: 1
I would like to preemptively apologize for my ignorance in this matter, especially given the vast knowledge that is in these forums; however, I have only fairly recently became acquainted with Bluetooth communication and am having difficulties figuring out the syntax for utilizing sent and received information for my module. I am currently connecting the RN-42 to my phone and am using a Bluetooth terminal that allows me send ASCII and hex data as well as see a response. I have been successful with commencing command mode and executing the "D" get command, along with a few other basic commands and going into "fast-data mode," so I know that the communication is working the way it should. All that I am trying to do is 1.) Establish a variable on my BoE Bot 2.) Get my phone to change that variable to a specified one and 3.) Have my BoE recognize the change and go to a corresponding subroutine based on the variable. My simple question is: How would I get my phone to change the variable, and would I need to have special integration that into my main DO-LOOP to anticipate the change. I'm sorry if my wording is confusing, and if nothing else I would love any sample code I could be directed to. My end game is a phone-controlled BoE Bot.
Comments
http://forums.parallax.com/discussion/146786/rn-42-bluetooth-module-and-boe-bot-tutorial
Protean Logic may still be selling their serial input buffer. Check with them. It would solve this problem. With one of these, your main DO-LOOP could quickly check for waiting characters and only try to read them if there's something available. You'd type some kind of lead-in character like a "?" followed by a value like "523" followed by a space or carriage return using your phone and the Stamp could read the value using a SERIN statement which would discard the terminating space or return. Instead of a "?", you could type a letter and your Stamp program could use the letter to select from a list of subroutines to execute using an ON <char> -"A" GOSUB ... statement where <char> is the received character value.