void getRate(String value) {
if (dataBuffer.startsWith(value)) {
String rate = dataBuffer.substring(value.length(), dataBuffer.indexOf("<", value.length()));
long currentRate = rate.toInt();
Serial.println(currentRate);
}
}
It's only possible to get the numbers as a String object - but if possible i do not want to use the String object anymore due to a horrible lack of memory...
Should be able to simply use: long data = client.parseInt();
It returns a long in reality.
EDIT: Running your input in my test sketch shows it can parse a number that long ('scuse the pun).
I've just finished a patch for parseInt/Float which improves its behavior and hopefully will be available in 1.6.6. You can read about it here: https://github.com/arduino/Arduino/pull/3337
Whats the best way to parse a Long from an ASCII data stream?
You start with an empty long to accumulate the number in and knowing the largest value you intend to allow to be entered, because between transmission errors and humans it's best to expect errors.
Then you do a repeated action for every digit you get that won't give you an out of bounds value.
accumulator variable *= 10;
add the new digit which is the text value - '0';
And you keep going as long as digits arrive and your entry stays within your bounds.
For bounds with longs I like to limit entries to 9 digits. That way the first can be 0-9 and no overflow.
Possible values are +/- over 2 billion so 999,999,999 is safe.
Note that when reading serial, this method gives you the answer where other functions just start to work. This is the code equivalent to how you write numbers on paper, not something exotic.
There's more when you're ready, start reading about state machines.
Since it's a machine talking to a machine (and error handling is done above) - i don't need to validate this much - it's also a non-critical application where a buffer overflow or a soft-reset isn't nice - but not fatal at all.