Skip to content

Commit

Permalink
remove deprecated NimBLESecurityCallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishanth Samala committed Oct 29, 2020
1 parent 5ae78ac commit fecd97a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
8 changes: 1 addition & 7 deletions main/include/hal/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

static const char* BLE_TAG = "ble";

class BluetoothLE : public LifecycleBase, public TouchListener, public NimBLEServerCallbacks, public NimBLESecurityCallbacks {
class BluetoothLE : public LifecycleBase, public TouchListener, public NimBLEServerCallbacks {
NimBLEAdvertising *advertising;
NimBLEAdvertisementData advertisementData;
TaskHandle_t bleTaskHandle;
Expand All @@ -43,13 +43,7 @@ class BluetoothLE : public LifecycleBase, public TouchListener, public NimBLESer
void onConnect(NimBLEServer *server) { }
void onConnect(NimBLEServer *server, ble_gap_conn_desc *desc);
void onDisconnect(NimBLEServer *server);

// NimBLESecurityCallbacks
uint32_t onPassKeyRequest() { return 123456; }
void onPassKeyNotify(uint32_t passkey) { ESP_LOGD(BLE_TAG, "Passkey notification: %d", passkey); }
bool onSecurityRequest() { return publicAdvertising; }
void onAuthenticationComplete(ble_gap_conn_desc *conn);
bool onConfirmPIN(uint32_t pin) { ESP_LOGD(BLE_TAG, "On confirm PIN called"); return publicAdvertising && pin == NimBLEDevice::getSecurityPasskey(); }

// TouchListener
void onTouchEvent(std::vector<TouchType> *touches);
Expand Down
3 changes: 0 additions & 3 deletions main/src/hal/ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void BluetoothLE::startServer(void *params) {

NimBLEDevice::init("");
NimBLEDevice::setSecurityAuth(false, true, true);
NimBLEDevice::setSecurityCallbacks(ble);
NimBLEDevice::setSecurityInitKey(BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID);
NimBLEDevice::setSecurityRespKey(BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID);
NimBLEDevice::setMTU(512);
Expand All @@ -58,8 +57,6 @@ NimBLEService* BluetoothLE::createService(std::string uuid) {

void BluetoothLE::onAuthenticationComplete(ble_gap_conn_desc *conn) {
ESP_LOGD(BLE_TAG, "Authentication Complete - bonded: %s authenticated: %s", conn->sec_state.bonded ? "yes" : "no", conn->sec_state.authenticated ? "yes" : "no");
if (!conn->sec_state.bonded)
server->disconnect(conn->conn_handle);
}

void BluetoothLE::startAdvertising() {
Expand Down

0 comments on commit fecd97a

Please sign in to comment.