Skip to content

Commit 5a6a85d

Browse files
fl4ph2zero
authored andcommitted
Clarify NimBLEAddress(uint8_t[6], type) byte order in docstring
The constructor calls std::reverse_copy on its input, expecting bytes in MSB-first order (Bluedroid's esp_bd_addr_t layout). The previous docstring said "compatibility with bluedroid esp library using native ESP representation," which is correct but ambiguous if the reader doesn't already know the conventions of both stacks. Callers reaching for this constructor with LSB-first bytes (e.g. as they'd come out of NimBLE's own ble_addr_t.val) silently end up with a reversed address — the radio uses val[] directly for HCI commands, so GAP connects target a fictional peer and time out as BLE_HS_ETIMEOUT with no diagnostic. Documentation-only change; behaviour is unchanged. Points readers to NimBLEAddress(ble_addr_t) for LSB-first wire bytes and to NimBLEAddress(const uint64_t&, uint8_t) for hex literals. Refs #423
1 parent 368dff9 commit 5a6a85d

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/NimBLEAddress.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,19 @@ NimBLEAddress::NimBLEAddress(const std::string& addr, uint8_t type) {
9797
} // NimBLEAddress
9898

9999
/**
100-
* @brief Constructor for compatibility with bluedroid esp library using native ESP representation.
101-
* @param [in] address A uint8_t[6] or esp_bd_addr_t containing the address.
100+
* @brief Constructor accepting a 6-byte MSB-first BLE address (Bluedroid `esp_bd_addr_t` layout).
101+
* @details The input bytes are stored internally in LSB-first wire
102+
* order (NimBLE's `ble_addr_t.val` layout), so this constructor
103+
* **reverses** the input. If you already have LSB-first wire bytes —
104+
* e.g. straight out of a NimBLE callback's `ble_addr_t` — use the
105+
* `NimBLEAddress(ble_addr_t)` constructor instead (it stores them
106+
* as-is). If you have the address as a hex integer (e.g.
107+
* `0xa4c1385def16` for `"a4:c1:38:5d:ef:16"`), use
108+
* `NimBLEAddress(const uint64_t&, uint8_t)`.
109+
* @param [in] address Six bytes in MSB-first order
110+
* (`{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}` for
111+
* `"aa:bb:cc:dd:ee:ff"`). Compatible with
112+
* Bluedroid's `esp_bd_addr_t`.
102113
* @param [in] type The type of the address should be one of:
103114
* * BLE_ADDR_PUBLIC (0)
104115
* * BLE_ADDR_RANDOM (1)

0 commit comments

Comments
 (0)