Skip to content

Commit dc31e93

Browse files
committed
fix(bt): SSP is now included by default
1 parent 18b1db0 commit dc31e93

File tree

4 files changed

+0
-32
lines changed

4 files changed

+0
-32
lines changed

libraries/BluetoothSerial/examples/SerialToSerialBT_Legacy/SerialToSerialBT_Legacy.ino

-7
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
#error Serial Port Profile for Bluetooth is not available or not enabled. It is only available for the ESP32 chip.
1818
#endif
1919

20-
// Check Simple Secure Pairing
21-
#if defined(CONFIG_BT_SSP_ENABLED)
22-
#warning Legacy Pairing is disabled (CONFIG_BT_SSP_ENABLED is enabled. Disable it in menuconfig).
23-
void setup() {}
24-
void loop() {}
25-
#else
2620
const char *deviceName = "ESP32_Legacy_example";
2721

2822
BluetoothSerial SerialBT;
@@ -62,4 +56,3 @@ void loop() {
6256
delay(1); // Feed the watchdog
6357
}
6458
}
65-
#endif

libraries/BluetoothSerial/examples/SerialToSerialBT_SSP/SerialToSerialBT_SSP.ino

-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
#error Serial Port Profile for Bluetooth is not available or not enabled. It is only available for the ESP32 chip.
2323
#endif
2424

25-
// Check Simple Secure Pairing
26-
#if !defined(CONFIG_BT_SSP_ENABLED)
27-
#error Simple Secure Pairing for Bluetooth is not available or not enabled.
28-
#endif
29-
3025
const char *deviceName = "ESP32_SSP_example";
3126

3227
// The following lines defines the method of pairing

libraries/BluetoothSerial/src/BluetoothSerial.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ static esp_bd_addr_t _peer_bd_addr;
7171
static char _remote_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1];
7272
static bool _isRemoteAddressSet;
7373
static bool _isMaster;
74-
#ifdef CONFIG_BT_SSP_ENABLED
7574
static bool _enableSSP;
7675
static bool _IO_CAP_INPUT;
7776
static bool _IO_CAP_OUTPUT;
78-
#endif
7977
esp_bt_pin_code_t _pin_code = {0};
8078
uint8_t _pin_code_len = 0; // Number of valid Bytes in the esp_bt_pin_code_t array
8179
static esp_spp_sec_t _sec_mask;
@@ -538,7 +536,6 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
538536
esp_bt_gap_pin_reply(param->pin_req.bda, true, _pin_code_len, _pin_code);
539537
}
540538
break;
541-
#ifdef CONFIG_BT_SSP_ENABLED
542539
case ESP_BT_GAP_CFM_REQ_EVT: // Enum 6 - Security Simple Pairing User Confirmation request.
543540
log_i("ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %d", param->cfm_req.num_val);
544541
if (confirm_request_callback) {
@@ -549,13 +546,10 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
549546
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, false);
550547
}
551548
break;
552-
#endif
553549

554550
case ESP_BT_GAP_KEY_NOTIF_EVT: // Enum 7 - Security Simple Pairing Passkey Notification
555551
log_i("ESP_BT_GAP_KEY_NOTIF_EVT passkey:%d", param->key_notif.passkey);
556552
break;
557-
558-
#ifdef CONFIG_BT_SSP_ENABLED
559553
case ESP_BT_GAP_KEY_REQ_EVT: // Enum 8 - Security Simple Pairing Passkey request
560554
log_i("ESP_BT_GAP_KEY_REQ_EVT Please enter passkey!");
561555
if (key_request_callback) {
@@ -566,7 +560,6 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
566560
esp_bt_gap_ssp_confirm_reply(param->cfm_req.bda, false);
567561
}
568562
break;
569-
#endif
570563

571564
case ESP_BT_GAP_READ_RSSI_DELTA_EVT: // Enum 9 - Read rssi event
572565
log_i("ESP_BT_GAP_READ_RSSI_DELTA_EVT Read rssi event");
@@ -707,7 +700,6 @@ static bool _init_bt(const char *deviceName, bt_mode mode) {
707700
log_i("device name set");
708701
esp_bt_dev_set_device_name(deviceName);
709702

710-
#ifdef CONFIG_BT_SSP_ENABLED
711703
if (_enableSSP) {
712704
log_i("Simple Secure Pairing");
713705
esp_bt_sp_param_t param_type = ESP_BT_SP_IOCAP_MODE;
@@ -723,7 +715,6 @@ static bool _init_bt(const char *deviceName, bt_mode mode) {
723715
}
724716
esp_bt_gap_set_security_param(param_type, &iocap, sizeof(uint8_t));
725717
}
726-
#endif
727718

728719
// the default BTA_DM_COD_LOUDSPEAKER does not work with the macOS BT stack
729720
esp_bt_cod_t cod;
@@ -894,7 +885,6 @@ void BluetoothSerial::memrelease() {
894885
esp_bt_mem_release(ESP_BT_MODE_BTDM);
895886
}
896887

897-
#ifdef CONFIG_BT_SSP_ENABLED
898888
void BluetoothSerial::onConfirmRequest(ConfirmRequestCb cb) {
899889
confirm_request_callback = cb;
900890
}
@@ -906,7 +896,6 @@ void BluetoothSerial::onKeyRequest(KeyRequestCb cb) {
906896
void BluetoothSerial::respondPasskey(uint32_t passkey) {
907897
esp_bt_gap_ssp_passkey_reply(current_bd_addr, true, passkey);
908898
}
909-
#endif
910899

911900
void BluetoothSerial::onAuthComplete(AuthCompleteCb cb) {
912901
auth_complete_callback = cb;
@@ -921,7 +910,6 @@ esp_err_t BluetoothSerial::register_callback(esp_spp_cb_t callback) {
921910
return ESP_OK;
922911
}
923912

924-
#ifdef CONFIG_BT_SSP_ENABLED
925913
// Enable Simple Secure Pairing (using generated PIN)
926914
// This must be called before calling begin, otherwise has no effect!
927915
void BluetoothSerial::enableSSP() {
@@ -957,8 +945,6 @@ void BluetoothSerial::disableSSP() {
957945
_enableSSP = false;
958946
}
959947

960-
#else
961-
962948
bool BluetoothSerial::setPin(const char *pin, uint8_t pin_code_len) {
963949
if (pin_code_len == 0 || pin_code_len > 16) {
964950
log_e("PIN code must be 1-16 Bytes long! Called with length %d", pin_code_len);
@@ -968,7 +954,6 @@ bool BluetoothSerial::setPin(const char *pin, uint8_t pin_code_len) {
968954
memcpy(_pin_code, pin, pin_code_len);
969955
return (esp_bt_gap_set_pin(ESP_BT_PIN_TYPE_FIXED, _pin_code_len, _pin_code) == ESP_OK);
970956
}
971-
#endif
972957

973958
bool BluetoothSerial::connect(String remoteName) {
974959
bool retval = false;

libraries/BluetoothSerial/src/BluetoothSerial.h

-5
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,16 @@ class BluetoothSerial : public Stream {
5656
void onData(BluetoothSerialDataCb cb);
5757
esp_err_t register_callback(esp_spp_cb_t callback);
5858

59-
#ifdef CONFIG_BT_SSP_ENABLED
6059
void onConfirmRequest(ConfirmRequestCb cb);
6160
void onKeyRequest(KeyRequestCb cb);
6261
void respondPasskey(uint32_t passkey);
63-
#endif
6462
void onAuthComplete(AuthCompleteCb cb);
6563
void confirmReply(boolean confirm);
6664

67-
#ifdef CONFIG_BT_SSP_ENABLED
6865
void enableSSP();
6966
void enableSSP(bool inputCapability, bool outputCapability);
7067
void disableSSP();
71-
#else
7268
bool setPin(const char *pin, uint8_t pin_code_len);
73-
#endif
7469
bool connect(String remoteName);
7570
bool connect(
7671
uint8_t remoteAddress[], int channel = 0, esp_spp_sec_t sec_mask = (ESP_SPP_SEC_ENCRYPT | ESP_SPP_SEC_AUTHENTICATE),

0 commit comments

Comments
 (0)