substring not working

Hello,

I'm trying to compare a received string by UDP, but substring returns nothing. I've tried this in a smaller sketch such the example UDPSendReceiveString, and it works.

Is it because of memory lack? How could I do it then?

if(String(packetBuffer).substring(0,6)=="config")

Thanks!

Welcome to the Forum. Please read Nick Gammon's two posts at the top of this Forum for guidelines on posting here. Having done that, post your code using the code tags. That will help us help you. Also, you will likely find that most of us here do not think the String class is a good way to process textual data in C. Most of us prefer char arrays.

Edit: shame on me, my fault. I will post something later, I'm working on it ;)

I think we'd rather see the code that doesn't work. If your code runs, then there's no problem for us to fix. Obviously, there are some issues somewhere. For example, why define the data[] array in setup() if you don't use it?

Yes, I don't use right now some variables, but I will.

I fixed the problem. It gets, reads and applies the configuration correctly by UDP. But, I got a memory problem. The configuration is 452 bytes long, and the sketch doesn't work properly.

Solved.

Substring takes "LOT" of RAM, 286bytes, so I changed it for a loop, and passed all strings to flash with "F()".

Now it works :)