15 #ifndef COMPONENTS_NIMBLESECURITY_H_
16 #define COMPONENTS_NIMBLESECURITY_H_
17 #include "sdkconfig.h"
18 #if defined(CONFIG_BT_ENABLED)
20 #include "host/ble_gap.h"
28 #define ESP_LE_AUTH_NO_BOND 0x00
29 #define ESP_LE_AUTH_BOND 0x01
30 #define ESP_LE_AUTH_REQ_MITM (1 << 2)
31 #define ESP_LE_AUTH_REQ_BOND_MITM (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_MITM)
32 #define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3)
33 #define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY)
34 #define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY)
35 #define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND)
37 #define ESP_IO_CAP_OUT 0
38 #define ESP_IO_CAP_IO 1
39 #define ESP_IO_CAP_IN 2
40 #define ESP_IO_CAP_NONE 3
41 #define ESP_IO_CAP_KBDISP 4
44 #define ESP_BLE_ENC_KEY_MASK (1 << 0)
46 #define ESP_BLE_ID_KEY_MASK (1 << 1)
48 #define ESP_BLE_CSR_KEY_MASK (1 << 2)
50 #define ESP_BLE_LINK_KEY_MASK (1 << 3)
52 typedef uint8_t esp_ble_auth_req_t;
53 typedef uint8_t esp_ble_io_cap_t;
Callbacks to handle GAP events related to authorization. Deprecated - provided for backward compatibi...
Definition: NimBLESecurity.h:88
virtual uint32_t onPassKeyRequest()=0
Its request from peer device to input authentication pin code displayed on peer device....
virtual void onAuthenticationComplete(ble_gap_conn_desc *)=0
Provides us information when authentication process is completed.
virtual bool onConfirmPIN(uint32_t pin)=0
Called when using numeric comparison for authentication.
virtual bool onSecurityRequest()=0
Here we can make decision if we want to let negotiate authorization with peer device or not.
virtual void onPassKeyNotify(uint32_t pass_key)=0
Provide us 6-digits code to perform authentication. It requires that our device is capable to display...
A class to handle BLE security operations. Deprecated - provided for backward compatibility only.
Definition: NimBLESecurity.h:61
void setStaticPIN(uint32_t pin)
Sets a static PIN used to authenticate/encrypt the connection.
Definition: NimBLESecurity.cpp:105
void setCapability(esp_ble_io_cap_t iocap)
Set our device IO capability to let end user perform authorization either by displaying or entering g...
Definition: NimBLESecurity.cpp:58
void setAuthenticationMode(esp_ble_auth_req_t auth_req)
Set requested authentication mode.
Definition: NimBLESecurity.cpp:40
void setRespEncryptionKey(uint8_t resp_key)
Sets the keys we will accept during encryption.
Definition: NimBLESecurity.cpp:86
void setKeySize(uint8_t key_size=16)
Definition: NimBLESecurity.cpp:94
void setInitEncryptionKey(uint8_t init_key)
Sets the keys we will distibute during encryption.
Definition: NimBLESecurity.cpp:72