bluetil/addr: fix byte ordering in addr_from_str()
This commit is contained in:
parent
b7b5791930
commit
7f7993f1d6
@ -73,6 +73,9 @@ void bluetil_addr_print(const uint8_t *addr);
|
|||||||
/**
|
/**
|
||||||
* @brief Parse a BLE address from the given string
|
* @brief Parse a BLE address from the given string
|
||||||
*
|
*
|
||||||
|
* @note The address is expected most significant byte first and is written
|
||||||
|
* to @p addr in network byte order
|
||||||
|
*
|
||||||
* @param[out] addr buffer to write the BLE address, *must* be able to hold
|
* @param[out] addr buffer to write the BLE address, *must* be able to hold
|
||||||
* @ref BLE_ADDR_LEN bytes
|
* @ref BLE_ADDR_LEN bytes
|
||||||
* @param[in] addr_str address string, must be at least of length
|
* @param[in] addr_str address string, must be at least of length
|
||||||
|
|||||||
@ -78,12 +78,12 @@ uint8_t *bluetil_addr_from_str(uint8_t *addr, const char *addr_str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned pos = BLE_ADDR_LEN;
|
unsigned pos = 0;
|
||||||
for (unsigned i = 0; i < (BLUETIL_ADDR_STRLEN - 1); i += 3) {
|
for (unsigned i = 0; i < (BLUETIL_ADDR_STRLEN - 1); i += 3) {
|
||||||
if (!_is_hex_char(addr_str[i]) || !_is_hex_char(addr_str[i + 1])) {
|
if (!_is_hex_char(addr_str[i]) || !_is_hex_char(addr_str[i + 1])) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
addr[--pos] = fmt_hex_byte(addr_str + i);
|
addr[pos++] = fmt_hex_byte(addr_str + i);
|
||||||
}
|
}
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user