Short of a proper regex I’m looking for an easy/simple way to check that my comma delimited data before I dump it into my device:
I’m not sure if I am seeing a problem with sscanf() or I’m just off in my template, sending a string like this:
some name,02134,1,
int setDevice(String command)
{
char newSettings[256] = "";
strncpy(newSettings, command.c_str(), sizeof(newSettings));
if(sscanf(newSettings, "%20[^,]%d,%d,") == 3)
{
sscanf(newSettings, "%20[^,]%d,%d,", userSpecificData.name, &userSpecificData.zip, &userSpecificData.power);
EEPROM.put(0, userSpecificData);
return 1;
}
return 0;
}
but it is always returning zero… Any C++ wisdom out there?