16进制转字符串
String hexToAscii( String hex )
{
uint16_t len = hex.length();
String ascii = "";
for ( uint16_t i = 0; i < len; i += 2 )
ascii += (char)strtol( hex.substring( i, i+2 ).c_str(), NULL, 16 );
return ascii;
}
//houyawei
10转16进制
String tohex(int n) {
if (n == 0) {
return "00";
}
String result = "";
char _16[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
const int radix = 16;
while (n) {
int i = n % radix;
result = _16[i] + result;
n /= radix;
}
if (result.length() < 2) {
result = '0' + result;
}
return result;
}//houyawei
-------------2021.11.23houyawei