Thank you John! That works perfectly.
Without the 'hh' specifiers it's going to treat your data pointer as 'unsigned int' pointers and store each value as two bytes.
I obviously am searching with the wrong terminology, but what do I need to search for or where can I find out about the "specifiers" or "format" as J-M-L referred to it?
J-M-L, I have read many times and seen at least a couple of your things on staying away from the String class (and I would like to), and I have tried, but I keep running into the same hiccup. Unfortunately you code won't work in my deal because your code is starting off with a "char" not a "string". Unfortunately I am reading the MAC Address from an SD Card, so it comes in as a String, so I am stuck having to try to convert that. Is there another way that your method works starting with a string?
Another question for you J-M-L, I have seen it in several samples, and am trying to fully understand how your code does it, but have not been able to determine what it means or does, *. Where can I find out about that, or can you explain it?
char* endPtr;
while (*endPtr)
What does the * do or mean?
Here is the latest trial code that works:
byte myMac[6];
String val = "8d:75:92:6a:40:e6";
void setup() {
Serial.begin(9600);
sscanf(val.c_str(), "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
&myMac[0], &myMac[1], &myMac[2], &myMac[3], &myMac[4], &myMac[5]);
Serial.print(myMac[0],HEX);
Serial.print(":");
Serial.print(myMac[1], HEX);
Serial.print(":");
Serial.print(myMac[2], HEX);
Serial.print(":");
Serial.print(myMac[3], HEX);
Serial.print(":");
Serial.print(myMac[4], HEX);
Serial.print(":");
Serial.print(myMac[5], HEX);
}