I have built this monster The Github
I am trying to get my IPhone to talk to a Arduino Mega via Bluetooth(HC06).
Reading the Information provided by the author Jakob Leander. I will post it below.
const char ACTION_FORWARD = 'F'; // Walk forward
const char ACTION_BACKWARD = 'B'; // Walk backward
The commands must be wrapped by [] to reduce risk of corrupted commands
'(F#)' = Walk Forward '(B#)' = Walk Backward
Read bluetooth command from the HC-06 one character at a time Identify a command starting with '{' and ending with '}'
So the question is from my App what format should I be sending. Examples :- [F#] or [F#] or ['F'#] or another ?? for the forward movement.
Please ask if you need anymore code or information.
Not understanding you at all. If you are saying you don;t understand some set of instructions, post the link to those instrauctions so we can read what you read.
I think the user is trying to "protect" the "device" against data not intended to move the device by wrapping the "move" character in brackets. That is to say... F is just a character to be discarded or used elsewhere but will not move the device, but [F] means "move forward" to the device. And again with [B] The brackets acting like an esape character... so the sender is actually sending three characters (if not made into an array of three characters).
Ok, that makes some sense. In that case I would use an 'escape' char that is not 'normal input' Maybe a char array of acceptable chars/commands, and/or a char array of 'escape' chars.
The real secret to this is the handling of the input stream. I still remember as a fledgling programmer back in the 60's being given a similar task. I thin that is where I lost most of my hair. Of course today the 'str...' builtin functions do all the heavy lifting.
I don't normally give solutions and won't here, but my clue is
Set up two tasks to handle the input, one a raw get next char and the other the 'smart' string based parser. By task I just mean the normal 'doing many things at once using millis()' See the tutorials section if you dont know about that, there are many tutorials for that kind of pseudo-tasking.
2nd hint, you need at least 3 (assuming command is 1 and a start and end esc char) raw chars buffered before processing. I would think about 6 or even 9. Use a time frame to decide if input is done.
The first thing I saw was the commands in Github already are wrapped.... so, the original code is being un-wrapped to wrap it again with brackets? (the .ino has all the commands as single characters that get stuffed in the wrappers)
'(H#)' = Home
'(S#)' = Sleep
'(F#)' = Walk Forward
'(B#)' = Walk Backward
'(L#)' = Rotate Left
'(R#)' = Rotate Right
The second thing I saw was this show stopper:
It does not work on IoS devices as HC06 module is not compatible with IoS.
Compared to Post #1:
I am trying to get my IPhone to talk to a Arduino Mega via Bluetooth(HC06).
And show-stopper #3 is the need for a paid application...
I have used a paid 3-party component to handle low-level bluetooth communication
Hi.
And a BIG thank you. Sonofcy and xfpd for your inputs.
Its sorted out the issues That I had.
I have the iPhone talking to a HM-10 Sending and receiving.
And I have a Android tablet talking to a HC-06 Sending and receiving.
Now I can progress forward with my build.
Again a BIG thank YOU.
Regards Antony.