[quote=“Stephen”]Hi, I want to send commands from my android device to Sparki using sparki_myro. What are the commands and the string format required to send to Sparki. Please advise.
Thank you very much.[/quote]
That’s great! When you get the code done, please share with us.
The broad logical sequence will go like this for your program:
- Wait for the sync character (which is ASCII character 22) – you can find an ASCII table here: http://www.asciitable.com/
- Send the command code, the terminator character (ASCII 23), and any arguments, each followed by the terminator character
- If there is a return value, read those back.
All arguments and return values are sent as characters. So, if you sent the value 3.1415 – it gets sent as the characters 3.1415 and not some sort of floating point value.
So, to give the command to beep at frequency 440Hz for 2 seconds, you would send:
b [TERM] 440 [TERM] 2000 [TERM]
Where [TERM] is ASCII character 23. Each of the numbers would be sent as the bytes for 4, 4, 0 and then 2,0,0,0
If you wanted to, say, read the line sensors, you would send:
m [TERM]
and then from your Bluetooth port, you will read the values from all of the line sensors, which would be something like this:
400 [TERM] 0 [TERM] 25 [TERM] 4354 [TERM] 123 [TERM]
and that would be the sensors from left to right.
The commands can be found in the sparki_myro.ino file (https://github.com/radarjd/sparki_learning/blob/master/sparkiduino/sparki_myro/sparki_myro.ino). That file lists the character which is the command code, and tells what arguments the sparki is expecting. The section is commented with COMMAND CHARACTER CODES.
At present, the status light turns on when the Sparki is receiving or processing a command. If you need to debug things, you can undefine the NO_DEBUGS by commenting out what is presently line 34. The problem is that the debugs take up a lot of space, and so usually when I’m debugging, I have to play with particular areas.
Let me know if I can be of additional help. I’ve never done in Android programming, so I’m not sure I can assist much with that, but I can help on the Sparki side.
