File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 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) {
6161esp_ble_gap_set_security_param (ESP_BLE_SM_MAX_KEY_SIZE, &m_keySize, sizeof (uint8_t ));
6262} // setKeySize
6363
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+ }
6475
6576/* *
6677 * @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 {
2121void setInitEncryptionKey (uint8_t init_key);
2222void setRespEncryptionKey (uint8_t resp_key);
2323void setKeySize (uint8_t key_size = 16 );
24+ void setStaticPIN (uint32_t pin);
2425static char * esp_key_type_to_str (esp_ble_key_type_t key_type);
2526
2627private:
You can’t perform that action at this time.
0 commit comments