Hi,
I learning about C++ on the run. I am a retired Pascal programmer and last used C when K&R got to about revision 0.0.3. :) OK, well maybe not that far back but a looong ways back. I am building a home auto system with Arduinos (too many jerks on the Arduino forums - so here I am)
I am sending and receiving data in the following 50-char-wide String
String myData = "wwxxyyzz:data-in-here-then--right-padded to 50..."
ww = 10 to 99 as the station ID sending the string
xx = 10 to 99 as the station ID to receive the the string
yy = 10 to 99 as the type of Sensor sending the string
zz = 10 to 99 as the number of devices on that Sensor sending the string
I didn't want to mess with numbers below 10 as they may be
interpreted as octal, not that it really matters but 89 of anything
is more than enough.
psesudo code...
idSend = copy bytes 1&2 then convert to int to use in switch(idSend)
idRecv = copy bytes 3&4 then convert to int to use in switch(idRecv)
idSens = copy bytes 5&6 then convert to int to use in switch(idSens)
idCntr = copy bytes 7&8 then convert to int to use in switch(idCntr)
1 2 3 4 5 6 7 8 9
|
switch(idSend)
{ case 10:
switch(idSens)
{ case 10:
// do something
break;
}
break;
}
| |
This is really simple in Pascal, but I am struggling with it in Arduino's C++
I have looked at charAt etc but not making much headway.
Some help here would be appreciated.