esp-nimble-cpp  1.4.0
NimBLEAddress.h
1 /*
2  * NimBLEAddress.h
3  *
4  * Created: on Jan 24 2020
5  * Author H2zero
6  *
7  * Originally:
8  *
9  * BLEAddress.h
10  *
11  * Created on: Jul 2, 2017
12  * Author: kolban
13  */
14 
15 #ifndef COMPONENTS_NIMBLEADDRESS_H_
16 #define COMPONENTS_NIMBLEADDRESS_H_
17 #include "nimconfig.h"
18 #if defined(CONFIG_BT_ENABLED)
19 
20 #if defined(CONFIG_NIMBLE_CPP_IDF)
21 #include "nimble/ble.h"
22 #else
23 #include "nimble/nimble/include/nimble/ble.h"
24 #endif
25 
26 /**** FIX COMPILATION ****/
27 #undef min
28 #undef max
29 /**************************/
30 
31 #include <string>
32 #include <algorithm>
33 
40 public:
41  NimBLEAddress();
42  NimBLEAddress(ble_addr_t address);
43  NimBLEAddress(uint8_t address[6], uint8_t type = BLE_ADDR_PUBLIC);
44  NimBLEAddress(const std::string &stringAddress, uint8_t type = BLE_ADDR_PUBLIC);
45  NimBLEAddress(const uint64_t &address, uint8_t type = BLE_ADDR_PUBLIC);
46  bool equals(const NimBLEAddress &otherAddress) const;
47  const uint8_t* getNative() const;
48  std::string toString() const;
49  uint8_t getType() const;
50 
51  bool operator ==(const NimBLEAddress & rhs) const;
52  bool operator !=(const NimBLEAddress & rhs) const;
53  operator std::string() const;
54  operator uint64_t() const;
55 
56 private:
57  uint8_t m_address[6];
58  uint8_t m_addrType;
59 };
60 
61 #endif /* CONFIG_BT_ENABLED */
62 #endif /* COMPONENTS_NIMBLEADDRESS_H_ */
A BLE device address.
Definition: NimBLEAddress.h:39
uint8_t getType() const
Get the address type.
Definition: NimBLEAddress.cpp:136
NimBLEAddress()
Create a blank address, i.e. 00:00:00:00:00:00, type 0.
Definition: NimBLEAddress.cpp:43
bool equals(const NimBLEAddress &otherAddress) const
Determine if this address equals another.
Definition: NimBLEAddress.cpp:118
bool operator==(const NimBLEAddress &rhs) const
Convenience operator to check if this address is equal to another.
Definition: NimBLEAddress.cpp:161
std::string toString() const
Convert a BLE address to a string.
Definition: NimBLEAddress.cpp:153
const uint8_t * getNative() const
Get the native representation of the address.
Definition: NimBLEAddress.cpp:127
bool operator!=(const NimBLEAddress &rhs) const
Convenience operator to check if this address is not equal to another.
Definition: NimBLEAddress.cpp:169