esp-nimble-cpp  1.4.1
NimBLEConnInfo.h
1 #ifndef NIMBLECONNINFO_H_
2 #define NIMBLECONNINFO_H_
3 
4 #include "NimBLEAddress.h"
5 
10 friend class NimBLEServer;
11 friend class NimBLEClient;
12  ble_gap_conn_desc m_desc;
13  NimBLEConnInfo() { m_desc = {}; }
14  NimBLEConnInfo(ble_gap_conn_desc desc) { m_desc = desc; }
15 public:
17  NimBLEAddress getAddress() { return NimBLEAddress(m_desc.peer_ota_addr); }
18 
20  NimBLEAddress getIdAddress() { return NimBLEAddress(m_desc.peer_id_addr); }
21 
23  uint16_t getConnHandle() { return m_desc.conn_handle; }
24 
26  uint16_t getConnInterval() { return m_desc.conn_itvl; }
27 
29  uint16_t getConnTimeout() { return m_desc.supervision_timeout; }
30 
32  uint16_t getConnLatency() { return m_desc.conn_latency; }
33 
35  uint16_t getMTU() { return ble_att_mtu(m_desc.conn_handle); }
36 
38  bool isMaster() { return (m_desc.role == BLE_GAP_ROLE_MASTER); }
39 
41  bool isSlave() { return (m_desc.role == BLE_GAP_ROLE_SLAVE); }
42 
44  bool isBonded() { return (m_desc.sec_state.bonded == 1); }
45 
47  bool isEncrypted() { return (m_desc.sec_state.encrypted == 1); }
48 
50  bool isAuthenticated() { return (m_desc.sec_state.authenticated == 1); }
51 
53  uint8_t getSecKeySize() { return m_desc.sec_state.key_size; }
54 };
55 #endif
A BLE device address.
Definition: NimBLEAddress.h:39
A model of a BLE client.
Definition: NimBLEClient.h:39
Connection information.
Definition: NimBLEConnInfo.h:9
uint16_t getConnLatency()
Gets the allowable latency for this connection (unit = number of intervals)
Definition: NimBLEConnInfo.h:32
uint8_t getSecKeySize()
Gets the key size used to encrypt the connection.
Definition: NimBLEConnInfo.h:53
bool isMaster()
Check if we are in the master role in this connection.
Definition: NimBLEConnInfo.h:38
bool isAuthenticated()
Check if the the connection has been authenticated.
Definition: NimBLEConnInfo.h:50
uint16_t getConnHandle()
Gets the connection handle of the connected peer.
Definition: NimBLEConnInfo.h:23
NimBLEAddress getIdAddress()
Gets the ID address of the connected peer.
Definition: NimBLEConnInfo.h:20
uint16_t getConnTimeout()
Gets the supervision timeout for this connection (in 10ms units)
Definition: NimBLEConnInfo.h:29
bool isEncrypted()
Check if the connection in encrypted.
Definition: NimBLEConnInfo.h:47
uint16_t getMTU()
Gets the maximum transmission unit size for this connection (in bytes)
Definition: NimBLEConnInfo.h:35
uint16_t getConnInterval()
Gets the connection interval for this connection (in 1.25ms units)
Definition: NimBLEConnInfo.h:26
bool isSlave()
Check if we are in the slave role in this connection.
Definition: NimBLEConnInfo.h:41
NimBLEAddress getAddress()
Gets the over-the-air address of the connected peer.
Definition: NimBLEConnInfo.h:17
bool isBonded()
Check if we are connected to a bonded peer.
Definition: NimBLEConnInfo.h:44
The model of a BLE server.
Definition: NimBLEServer.h:46