scanTagID.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
scanTagID.concat(String(mfrc522.uid.uidByte[i], HEX));
As far as i can see. 'scanTagID' is the name of a String, where the value of 'mfrc522.uid.uidByte[i]' (eg the 'i'th element in the array) gets added in HEX format, with an extra '0;' in front if it is less than 0x10 (16)
did the internet break?
scanTagID.concat //String concatenate
mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " " //ternary operator either "0" or " " character will be added to scanTagID String
String(mfrc522.uid.uidByte[i], HEX) //expresses the value of 'mfrc522.uid.uidByte[i]' as in hexadecimal format (to be added to scanTagID String)
the argument uses the ternary operator resulting in one of two values (strings)
in this case it looks like the 2 arguments are passed to the function. don't know how the function handles HEX
what exactly do you search for ??
as 'String' always does, by converting an integer (of any bit length) into a Hexadecimal representation (rather than the decimal default)
so HEX is not a 2nd argument to concat()
Most likely a String variable, scanTagID, was created and then the variable was converted into a String buffer by the use of scanTagID.reserve(withsomenumberofbuffersize).
A String on a MCU without an OS to do house cleaning chores will cause memory holes to be created but by using a String buffer memory holes can be prevented; such as an ESP32 which has an OS that does house cleaning chores.
To use the String buffer, information placed into the buffer is done by using String.concat(). scanTagID="" clears the String buffer.
Once a String buffer is created do not use StringBuffer="my desired string" to put info into a String buffer. If StringBuffer="my desired string" is used then the String buffer can be bypassed and memory holes are created.
correct. concat() only takes 1 argument, being another 'String' and adds that onto the 'scanTagID' String. Note the double '))' at the end of the line.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.