2020-03-30 01:44:20 +02:00
|
|
|
/*
|
|
|
|
* NimBLEAddress.h
|
|
|
|
*
|
|
|
|
* Created: on Jan 24 2020
|
|
|
|
* Author H2zero
|
2020-05-14 06:03:56 +02:00
|
|
|
*
|
2020-03-30 01:44:20 +02:00
|
|
|
* Originally:
|
|
|
|
*
|
|
|
|
* BLEAddress.h
|
|
|
|
*
|
|
|
|
* Created on: Jul 2, 2017
|
|
|
|
* Author: kolban
|
|
|
|
*/
|
|
|
|
|
2024-07-05 03:17:13 +02:00
|
|
|
#ifndef NIMBLE_CPP_ADDRESS_H_
|
|
|
|
#define NIMBLE_CPP_ADDRESS_H_
|
2021-09-07 05:14:43 +02:00
|
|
|
#include "nimconfig.h"
|
2020-03-30 01:44:20 +02:00
|
|
|
#if defined(CONFIG_BT_ENABLED)
|
|
|
|
|
2024-07-05 03:17:13 +02:00
|
|
|
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
|
|
|
# include "nimble/ble.h"
|
|
|
|
# else
|
|
|
|
# include "nimble/nimble/include/nimble/ble.h"
|
|
|
|
# endif
|
2021-09-07 05:14:43 +02:00
|
|
|
|
2020-03-30 01:44:20 +02:00
|
|
|
/**** FIX COMPILATION ****/
|
2024-07-05 03:17:13 +02:00
|
|
|
# undef min
|
|
|
|
# undef max
|
2020-03-30 01:44:20 +02:00
|
|
|
/**************************/
|
|
|
|
|
2024-07-05 03:17:13 +02:00
|
|
|
# include <string>
|
2020-03-30 01:44:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief A %BLE device address.
|
|
|
|
*
|
|
|
|
* Every %BLE device has a unique address which can be used to identify it and form connections.
|
|
|
|
*/
|
2024-07-05 03:17:13 +02:00
|
|
|
class NimBLEAddress : private ble_addr_t {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Create a blank address, i.e. 00:00:00:00:00:00, type 0.
|
|
|
|
*/
|
|
|
|
NimBLEAddress() = default;
|
|
|
|
NimBLEAddress(const ble_addr_t address);
|
|
|
|
NimBLEAddress(const uint8_t address[BLE_DEV_ADDR_LEN], uint8_t type = BLE_ADDR_PUBLIC);
|
|
|
|
NimBLEAddress(const std::string& stringAddress, uint8_t type = BLE_ADDR_PUBLIC);
|
|
|
|
NimBLEAddress(const uint64_t& address, uint8_t type = BLE_ADDR_PUBLIC);
|
2020-05-10 15:21:46 +02:00
|
|
|
|
2024-07-05 03:17:13 +02:00
|
|
|
bool isRpa() const;
|
|
|
|
bool isNrpa() const;
|
|
|
|
bool isStatic() const;
|
|
|
|
bool isPublic() const;
|
|
|
|
bool isNull() const;
|
|
|
|
bool equals(const NimBLEAddress& otherAddress) const;
|
|
|
|
const ble_addr_t* getBase() const;
|
|
|
|
std::string toString() const;
|
|
|
|
uint8_t getType() const;
|
|
|
|
const uint8_t* getVal() const;
|
|
|
|
const NimBLEAddress& reverseByteOrder();
|
|
|
|
bool operator==(const NimBLEAddress& rhs) const;
|
|
|
|
bool operator!=(const NimBLEAddress& rhs) const;
|
|
|
|
operator std::string() const;
|
|
|
|
operator uint64_t() const;
|
2020-03-30 01:44:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CONFIG_BT_ENABLED */
|
2024-07-05 03:17:13 +02:00
|
|
|
#endif /* NIMBLE_CPP_ADDRESS_H_ */
|