Im trying to interface with a portable speaker, i got in contact with the manufacturer and they sent me a list off commands i can use to interface with it.
Im not really sure how the commands work, i know i have to send the data over the UART but the commands are a little strange, are they packets of HEX (4 bytes of hexadecimal)?
I would be really grateful if anybody could shine some light on this!
Some Commands:
BE 00 00 00 0c EB BE 00 00 00 12 EB BE 70 00 00 06 EB BE 00 00 00 21 EB BE 00 00 00 22 EB
UNI-T:
Thanks!
How would i go about receiving a commands with identical structure?
My guess would be:
void loop()
{
static chr buffer[MaximumCommandSize];
static int index = 0;
if (Serial.available())
{
char c = Serial.read();
buffer[index++] = c;
if (c == 0xBE) // Start of command
{
index = 0;
buffer[index++] = c;
}
else if (c == 0xEB && buffer[0] == 0xBE) // End of command
{
processCommand(buffer);
index = 0;
}
else if (index >= MaximumCommandSize)
{
index = 0; // Command too long
}
}
}