NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
NimBLEAddress.h
1/*
2 * Copyright 2020-2024 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#include "nimconfig.h"
21#if defined(CONFIG_BT_ENABLED)
22
23# if defined(CONFIG_NIMBLE_CPP_IDF)
24# include "nimble/ble.h"
25# else
26# include "nimble/nimble/include/nimble/ble.h"
27# endif
28
29/**** FIX COMPILATION ****/
30# undef min
31# undef max
32/**************************/
33
34# include <string>
35
41class NimBLEAddress : private ble_addr_t {
42 public:
46 NimBLEAddress() = default;
47 NimBLEAddress(const ble_addr_t address);
48 NimBLEAddress(const uint8_t address[BLE_DEV_ADDR_LEN], uint8_t type);
49 NimBLEAddress(const std::string& stringAddress, uint8_t type);
50 NimBLEAddress(const uint64_t& address, uint8_t type);
51
52 bool isRpa() const;
53 bool isNrpa() const;
54 bool isStatic() const;
55 bool isPublic() const;
56 bool isNull() const;
57 bool equals(const NimBLEAddress& otherAddress) const;
58 const ble_addr_t* getBase() const;
59 std::string toString() const;
60 uint8_t getType() const;
61 const uint8_t* getVal() const;
63 bool operator==(const NimBLEAddress& rhs) const;
64 bool operator!=(const NimBLEAddress& rhs) const;
65 operator std::string() const;
66 operator uint64_t() const;
67};
68
69#endif /* CONFIG_BT_ENABLED */
70#endif /* NIMBLE_CPP_ADDRESS_H_ */
A BLE device address.
Definition NimBLEAddress.h:41
const NimBLEAddress & reverseByteOrder()
Reverse the byte order of the address.
Definition NimBLEAddress.cpp:183
uint8_t getType() const
Get the address type.
Definition NimBLEAddress.cpp:118
const uint8_t * getVal() const
Get the address value.
Definition NimBLEAddress.cpp:126
const ble_addr_t * getBase() const
Get the NimBLE base struct of the address.
Definition NimBLEAddress.cpp:110
bool isStatic() const
Determine if this address is a Static Address.
Definition NimBLEAddress.cpp:150
bool isPublic() const
Determine if this address is a Public Address.
Definition NimBLEAddress.cpp:158
bool equals(const NimBLEAddress &otherAddress) const
Determine if this address equals another.
Definition NimBLEAddress.cpp:102
bool operator==(const NimBLEAddress &rhs) const
Convenience operator to check if this address is equal to another.
Definition NimBLEAddress.cpp:191
bool isRpa() const
Determine if this address is a Resolvable Private Address.
Definition NimBLEAddress.cpp:134
bool isNrpa() const
Determine if this address is a Non-Resolvable Private Address.
Definition NimBLEAddress.cpp:142
bool isNull() const
Determine if this address is a NULL Address.
Definition NimBLEAddress.cpp:166
std::string toString() const
Convert a BLE address to a string.
Definition NimBLEAddress.cpp:175
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:202