mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2026-01-29 09:40:10 +01:00
[BREAKING] Refactor NimBLEAddress - use NimBLE core representation.
This simplifies the NimBLEAddress code by directly using the NimBLE core `ble_addr_t` type to hold the address and allows using NimBLE core functions and macros to replace code in some methods. * `getNative()` replaced with `getBase()` and now returns a pointer to `const ble_addr_t` instead of a pointer to the address value. * Adds `isNrpa()` method to test if an address is random non-resolvable. * Adds `isStatic()` method to test if an address is random static. * Adds `isPublic()` method to test if an address is a public address. * Adds `isNull()` methods to test if an address is NULL. * Adds `getValue()` method which returns a read-only pointer to the address value. * Adds `reverseByteOrder()` method which will reverse the byte order of the address value. * `equals()` method and == operator will now also test if the address types are the same. * Code cleanup.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <algorithm>
|
||||
|
||||
#define NIMBLE_SERVER_GET_PEER_NAME_ON_CONNECT_CB 0
|
||||
#define NIMBLE_SERVER_GET_PEER_NAME_ON_AUTH_CB 1
|
||||
@@ -324,12 +325,8 @@ NimBLEConnInfo NimBLEServer::getPeerInfo(size_t index) {
|
||||
* @param [in] address The address of the peer.
|
||||
*/
|
||||
NimBLEConnInfo NimBLEServer::getPeerInfo(const NimBLEAddress& address) {
|
||||
ble_addr_t peerAddr;
|
||||
memcpy(&peerAddr.val, address.getNative(),6);
|
||||
peerAddr.type = address.getType();
|
||||
|
||||
NimBLEConnInfo peerInfo;
|
||||
int rc = ble_gap_conn_find_by_addr(&peerAddr, &peerInfo.m_desc);
|
||||
int rc = ble_gap_conn_find_by_addr(address.getBase(), &peerInfo.m_desc);
|
||||
if (rc != 0) {
|
||||
NIMBLE_LOGE(LOG_TAG, "Peer info not found");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user