15#ifndef COMPONENTS_NIMBLESECURITY_H_
16#define COMPONENTS_NIMBLESECURITY_H_
19#if defined(CONFIG_BT_ENABLED)
21#if defined(CONFIG_NIMBLE_CPP_IDF)
22#include "host/ble_gap.h"
24#include "nimble/nimble/host/include/host/ble_gap.h"
34#define ESP_LE_AUTH_NO_BOND 0x00
35#define ESP_LE_AUTH_BOND 0x01
36#define ESP_LE_AUTH_REQ_MITM (1 << 2)
37#define ESP_LE_AUTH_REQ_BOND_MITM (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_MITM)
38#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3)
39#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY)
40#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY)
41#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND)
43#define ESP_IO_CAP_OUT 0
44#define ESP_IO_CAP_IO 1
45#define ESP_IO_CAP_IN 2
46#define ESP_IO_CAP_NONE 3
47#define ESP_IO_CAP_KBDISP 4
50#define ESP_BLE_ENC_KEY_MASK (1 << 0)
52#define ESP_BLE_ID_KEY_MASK (1 << 1)
54#define ESP_BLE_CSR_KEY_MASK (1 << 2)
56#define ESP_BLE_LINK_KEY_MASK (1 << 3)
58typedef uint8_t esp_ble_auth_req_t;
59typedef uint8_t esp_ble_io_cap_t;
Callbacks to handle GAP events related to authorization. Deprecated - provided for backward compatibi...
Definition: NimBLESecurity.h:94
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:67
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 distribute during encryption.
Definition: NimBLESecurity.cpp:72