File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,17 @@ void BLESecurity::setKeySize(uint8_t key_size) {
61
61
esp_ble_gap_set_security_param (ESP_BLE_SM_MAX_KEY_SIZE, &m_keySize, sizeof (uint8_t ));
62
62
} // setKeySize
63
63
64
+ /* *
65
+ * Setup for static PIN connection, call it first and then call setAuthenticationMode eventually to change it
66
+ */
67
+ void BLESecurity::setStaticPIN (uint32_t pin){
68
+ uint32_t passkey = pin;
69
+ esp_ble_gap_set_security_param (ESP_BLE_SM_SET_STATIC_PASSKEY, &passkey, sizeof (uint32_t ));
70
+ setCapability (ESP_IO_CAP_OUT);
71
+ setKeySize ();
72
+ setAuthenticationMode (ESP_LE_AUTH_REQ_SC_ONLY);
73
+ setInitEncryptionKey (ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK);
74
+ }
64
75
65
76
/* *
66
77
* @brief Debug function to display what keys are exchanged by peers
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class BLESecurity {
21
21
void setInitEncryptionKey (uint8_t init_key);
22
22
void setRespEncryptionKey (uint8_t resp_key);
23
23
void setKeySize (uint8_t key_size = 16 );
24
+ void setStaticPIN (uint32_t pin);
24
25
static char * esp_key_type_to_str (esp_ble_key_type_t key_type);
25
26
26
27
private:
You can’t perform that action at this time.
0 commit comments