Getting a UDP msg, i convert the char into a string to search for some specific characters in the msg.
In this example im looking for the "capital letter L" because i need the next piece of information after
that capital L. which is an interger.
So the incoming UDP msg could look like this S0L1E0T1
I want to split them up, OR lookup the letter i need, so i can find the correct number.
int size = udp.parsePacket();
if (size > 0) {
do
{
char* msg = (char*)malloc(size+1);
int len = udp.read(msg,size+1);
msg[len]=0;
String inputMsg = String(msg); // switching to string mode
for (unsigned int i=0;i < inputMsg.length(); i++) // running through the string
{
if(inputMsg.at(i) == "L") // looking for L
{
Serial.print("Found one : "); // Do stuff if L is found
Serial.println(inputMsg.at(i);
doStuff();
}
}
Serial.print("received: '");
Serial.print(msg);
free(msg);
}
However, im running into issues using the .at because clearly it's not supported,
but I'm coming from visual studio where i would #include to help me out here.
Not sure if char is able to work in this way, but it's fine anyway running on a mega and
have plenty of memory to spare.
Any ideas, also open for alternative solutions to find the number after a letter like that.