Hexapod build Serial

Hi.

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 '}'

const char startMarker = '\[';          const char endMarker = '\]';

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.

Regards Antony.

You may want to re-read your post, you have used [ { ( . Which is correct?

The HTML of this forum mangles code meant for a computer. Re-write that using the <code> button.

Guessing...

const char startMarker = '['; // only ONE character between single quotes

If you need the escape character...

const char escChar= '\';

Hi.

That's just it I have no idea.

This is plain Text from his instructions.
Regards Antony.

What is, and how does it identify what you need versus what you get?

I think you are mixing "single-quote" (') with back-tick(`)... and are using the single-quote where you need the back-tick.

My single-quote is "under" my (unshifted) double-quote key.
My back-tick is "under" my (unshifted) tilde key.

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 looked at the code and do not see any of {[( the ACTION_FORWARD is just the single char F which in code is 'F' but you only send F.

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.

Yes.

They are also trying to fit two characters into a char... (if compiler allows, only last char is used)

const char startMarker = '\[';

So I hope they read the comment part of this...

const char startMarker = '['; // only ONE character between single quotes

If they don't understand that a char is 1 char, 8 bits then there is NO hope.

I looked at the Github link... and...

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

Use a HM-10 for iOS

Thank you for all the Info... Looking into it Now.
Thanks :grinning_face:
Regards Antony

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.