@@ -99,9 +99,11 @@ uint16_t BLEDevice::m_localMTU = 23;
99
99
switch (event) {
100
100
case ESP_GATTS_CONNECT_EVT: {
101
101
BLEDevice::m_localMTU = 23 ;
102
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
102
103
if (BLEDevice::m_securityLevel){
103
104
esp_ble_set_encryption (param->connect .remote_bda , BLEDevice::m_securityLevel);
104
105
}
106
+ #endif // CONFIG_BLE_SMP_ENABLE
105
107
break ;
106
108
} // ESP_GATTS_CONNECT_EVT
107
109
@@ -148,9 +150,11 @@ uint16_t BLEDevice::m_localMTU = 23;
148
150
ESP_LOGE (LOG_TAG, " esp_ble_gattc_send_mtu_req: rc=%d %s" , errRc, GeneralUtils::errorToString (errRc));
149
151
}
150
152
}
153
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
151
154
if (BLEDevice::m_securityLevel){
152
155
esp_ble_set_encryption (param->connect .remote_bda , BLEDevice::m_securityLevel);
153
156
}
157
+ #endif // CONFIG_BLE_SMP_ENABLE
154
158
break ;
155
159
} // ESP_GATTC_CONNECT_EVT
156
160
@@ -190,16 +194,20 @@ uint16_t BLEDevice::m_localMTU = 23;
190
194
break ;
191
195
case ESP_GAP_BLE_NC_REQ_EVT:
192
196
ESP_LOGI (LOG_TAG, " ESP_GAP_BLE_NC_REQ_EVT" );
197
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
193
198
if (BLEDevice::m_securityCallbacks!=nullptr ){
194
199
esp_ble_confirm_reply (param->ble_security .ble_req .bd_addr , BLEDevice::m_securityCallbacks->onConfirmPIN (param->ble_security .key_notif .passkey ));
195
200
}
201
+ #endif // CONFIG_BLE_SMP_ENABLE
196
202
break ;
197
203
case ESP_GAP_BLE_PASSKEY_REQ_EVT: /* passkey request event */
198
204
ESP_LOGI (LOG_TAG, " ESP_GAP_BLE_PASSKEY_REQ_EVT: " );
199
205
// esp_log_buffer_hex(LOG_TAG, m_remote_bda, sizeof(m_remote_bda));
206
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
200
207
if (BLEDevice::m_securityCallbacks!=nullptr ){
201
208
esp_ble_passkey_reply (param->ble_security .ble_req .bd_addr , true , BLEDevice::m_securityCallbacks->onPassKeyRequest ());
202
209
}
210
+ #endif // CONFIG_BLE_SMP_ENABLE
203
211
break ;
204
212
/*
205
213
* TODO should we add white/black list comparison?
@@ -208,32 +216,42 @@ uint16_t BLEDevice::m_localMTU = 23;
208
216
/* send the positive(true) security response to the peer device to accept the security request.
209
217
If not accept the security request, should sent the security response with negative(false) accept value*/
210
218
ESP_LOGI (LOG_TAG, " ESP_GAP_BLE_SEC_REQ_EVT" );
219
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
211
220
if (BLEDevice::m_securityCallbacks!=nullptr ){
212
221
esp_ble_gap_security_rsp (param->ble_security .ble_req .bd_addr , BLEDevice::m_securityCallbacks->onSecurityRequest ());
213
222
}
214
223
else {
215
224
esp_ble_gap_security_rsp (param->ble_security .ble_req .bd_addr , true );
216
225
}
226
+ #endif // CONFIG_BLE_SMP_ENABLE
217
227
break ;
218
228
/*
219
229
*
220
230
*/
221
231
case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: // /the app will receive this evt when the IO has Output capability and the peer device IO has Input capability.
222
232
// /show the passkey number to the user to input it in the peer deivce.
223
233
ESP_LOGI (LOG_TAG, " ESP_GAP_BLE_PASSKEY_NOTIF_EVT" );
234
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
224
235
if (BLEDevice::m_securityCallbacks!=nullptr ){
225
236
ESP_LOGI (LOG_TAG, " passKey = %d" , param->ble_security .key_notif .passkey );
226
237
BLEDevice::m_securityCallbacks->onPassKeyNotify (param->ble_security .key_notif .passkey );
227
238
}
239
+ #endif // CONFIG_BLE_SMP_ENABLE
228
240
break ;
229
241
case ESP_GAP_BLE_KEY_EVT:
230
242
// shows the ble key type info share with peer device to the user.
243
+ ESP_LOGI (LOG_TAG, " ESP_GAP_BLE_KEY_EVT" );
244
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
231
245
ESP_LOGI (LOG_TAG, " key type = %s" , BLESecurity::esp_key_type_to_str (param->ble_security .ble_key .key_type ));
246
+ #endif // CONFIG_BLE_SMP_ENABLE
232
247
break ;
233
248
case ESP_GAP_BLE_AUTH_CMPL_EVT:
249
+ ESP_LOGI (LOG_TAG, " ESP_GAP_BLE_AUTH_CMPL_EVT" );
250
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
234
251
if (BLEDevice::m_securityCallbacks!=nullptr ){
235
252
BLEDevice::m_securityCallbacks->onAuthenticationComplete (param->ble_security .auth_cmpl );
236
253
}
254
+ #endif // CONFIG_BLE_SMP_ENABLE
237
255
break ;
238
256
default : {
239
257
break ;
@@ -382,12 +400,14 @@ uint16_t BLEDevice::m_localMTU = 23;
382
400
return ;
383
401
};
384
402
403
+ #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
385
404
esp_ble_io_cap_t iocap = ESP_IO_CAP_NONE;
386
405
errRc = ::esp_ble_gap_set_security_param (ESP_BLE_SM_IOCAP_MODE, &iocap, sizeof (uint8_t ));
387
406
if (errRc != ESP_OK) {
388
407
ESP_LOGE (LOG_TAG, " esp_ble_gap_set_security_param: rc=%d %s" , errRc, GeneralUtils::errorToString (errRc));
389
408
return ;
390
409
};
410
+ #endif // CONFIG_BLE_SMP_ENABLE
391
411
}
392
412
vTaskDelay (200 /portTICK_PERIOD_MS); // Delay for 200 msecs as a workaround to an apparent Arduino environment issue.
393
413
} // init
0 commit comments