diff --git a/sys/include/net/bluetil/addr.h b/sys/include/net/bluetil/addr.h index 205000b056..2d998863b8 100644 --- a/sys/include/net/bluetil/addr.h +++ b/sys/include/net/bluetil/addr.h @@ -73,6 +73,9 @@ void bluetil_addr_print(const uint8_t *addr); /** * @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 * @ref BLE_ADDR_LEN bytes * @param[in] addr_str address string, must be at least of length diff --git a/sys/net/ble/bluetil/bluetil_addr/bluetil_addr.c b/sys/net/ble/bluetil/bluetil_addr/bluetil_addr.c index ba4b56d74d..e8b6489a1c 100644 --- a/sys/net/ble/bluetil/bluetil_addr/bluetil_addr.c +++ b/sys/net/ble/bluetil/bluetil_addr/bluetil_addr.c @@ -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) { if (!_is_hex_char(addr_str[i]) || !_is_hex_char(addr_str[i + 1])) { return NULL; } - addr[--pos] = fmt_hex_byte(addr_str + i); + addr[pos++] = fmt_hex_byte(addr_str + i); } return addr; }