NimBLE-Arduino 2.3.2
Loading...
Searching...
No Matches
NimBLEAddress.h
1/*
2 * Copyright 2020-2025 Ryan Powell <ryan@nable-embedded.io> and
3 * esp-nimble-cpp, NimBLE-Arduino contributors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NIMBLE_CPP_ADDRESS_H_
19#define NIMBLE_CPP_ADDRESS_H_
20
21#include "nimconfig.h"
22#if CONFIG_BT_ENABLED
23
24# if defined(CONFIG_NIMBLE_CPP_IDF)
25# include "nimble/ble.h"
26# else
27# include "nimble/nimble/include/nimble/ble.h"
28# endif
29
30/**** FIX COMPILATION ****/
31# undef min
32# undef max
33/**************************/
34
35# include <string>
36
42class NimBLEAddress : private ble_addr_t {
43 public:
47 NimBLEAddress() = default;
48 NimBLEAddress(const ble_addr_t address);
49 NimBLEAddress(const uint8_t address[BLE_DEV_ADDR_LEN], uint8_t type);
50 NimBLEAddress(const std::string& stringAddress, uint8_t type);
51 NimBLEAddress(const uint64_t& address, uint8_t type);
52
53 bool isRpa() const;
54 bool isNrpa() const;
55 bool isStatic() const;
56 bool isPublic() const;
57 bool isNull() const;
58 bool equals(const NimBLEAddress& otherAddress) const;
59 const ble_addr_t* getBase() const;
60 std::string toString() const;
61 uint8_t getType() const;
62 const uint8_t* getVal() const;
64 bool operator==(const NimBLEAddress& rhs) const;
65 bool operator!=(const NimBLEAddress& rhs) const;
66 operator std::string() const;
67 operator uint64_t() const;
68};
69
70#endif // CONFIG_BT_ENABLED
71#endif // NIMBLE_CPP_ADDRESS_H_
A BLE device address.
Definition NimBLEAddress.h:42
const NimBLEAddress & reverseByteOrder()
Reverse the byte order of the address.
Definition NimBLEAddress.cpp:194
uint8_t getType() const
Get the address type.
Definition NimBLEAddress.cpp:129
const uint8_t * getVal() const
Get the address value.
Definition NimBLEAddress.cpp:137
const ble_addr_t * getBase() const
Get the NimBLE base struct of the address.
Definition NimBLEAddress.cpp:121
bool isStatic() const
Determine if this address is a Static Address.
Definition NimBLEAddress.cpp:161
bool isPublic() const
Determine if this address is a Public Address.
Definition NimBLEAddress.cpp:169
bool equals(const NimBLEAddress &otherAddress) const
Determine if this address equals another.
Definition NimBLEAddress.cpp:113
bool operator==(const NimBLEAddress &rhs) const
Convenience operator to check if this address is equal to another.
Definition NimBLEAddress.cpp:202
bool isRpa() const
Determine if this address is a Resolvable Private Address.
Definition NimBLEAddress.cpp:145
bool isNrpa() const
Determine if this address is a Non-Resolvable Private Address.
Definition NimBLEAddress.cpp:153
bool isNull() const
Determine if this address is a NULL Address.
Definition NimBLEAddress.cpp:177
std::string toString() const
Convert a BLE address to a string.
Definition NimBLEAddress.cpp:186
NimBLEAddress()=default
Create a blank address, i.e. 00:00:00:00:00:00, type 0.
bool operator!=(const NimBLEAddress &rhs) const
Convenience operator to check if this address is not equal to another.
Definition NimBLEAddress.cpp:213