pfodParser  3.61.0
The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections
HexConversionUtils.h File Reference

Go to the source code of this file.

Functions

int isAllHex (const char *str)
 hexConversionUtils for Arduino More...
 
unsigned int asciiToHex (const char *str, unsigned char *result, unsigned int maxHexLen)
 Converts pairs of hex digits (upper or lower case) to bytes i.e. More...
 
int hexToAscii (const unsigned char *hex, unsigned int hexLen, char *str, unsigned int maxStrLen)
 Converts bytes to hex digits and adds terminating null i.e. More...
 

Function Documentation

◆ asciiToHex()

unsigned int asciiToHex ( const char *  str,
unsigned char *  result,
unsigned int  maxHexLen 
)

Converts pairs of hex digits (upper or lower case) to bytes i.e.

"0f" -> (byte)15, as does "0F" "ff" -> (byte)255, as does "FF"

str is null terminated hex chars (converted as pairs) result is where the converted bytes are stored maxHexLen is max number of bytes that can be stored

returns number of bytes actually stored

◆ hexToAscii()

int hexToAscii ( const unsigned char *  hex,
unsigned int  hexLen,
char *  str,
unsigned int  maxStrLen 
)

Converts bytes to hex digits and adds terminating null i.e.

(byte)15 -> '0' 'F' '\0'

hex pointer to bytes to be converted to hex digits hexLen is the number of bytes to convert to hex, str pointer to where the result is to be stored maxStrLen is space available in string (including terminating null)

◆ isAllHex()

int isAllHex ( const char *  str)

hexConversionUtils for Arduino

isAllHex str is null terminated chars (bytes) result 1 if all chars are hex, else 0