void convert_hex(char *str, uint8_t *bytes, int maxlen) { int slen = strlen(str); int bytelen = maxlen; int rpos, wpos = 0; for(rpos = 0; rpos < bytelen; rpos++) { sscanf(&str[rpos*2], "%02hhx", &bytes[wpos++]); } }