Skip to content

Commit

Permalink
feat(ble_gatt_server): add preprocessor guards (#175)
Browse files Browse the repository at this point in the history
* Add preprocessor guards around BleGattServerCallbacks so that the component can be required and included, but optionally disabled if no BLE is needed / used.
  • Loading branch information
finger563 authored Mar 8, 2024
1 parent 240a48a commit 8dbf40f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#if CONFIG_BT_NIMBLE_ENABLED || defined(_DOXYGEN_)

#include "NimBLEDevice.h"

namespace espp {
Expand All @@ -22,3 +24,5 @@ class BleGattServerCallbacks : public NimBLEServerCallbacks {
BleGattServer *server_{nullptr};
};
} // namespace espp

#endif // CONFIG_BT_NIMBLE_ENABLED || defined(_DOXYGEN_)
4 changes: 4 additions & 0 deletions components/ble_gatt_server/src/ble_gatt_server_callbacks.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "ble_gatt_server_callbacks.hpp"
#include "ble_gatt_server.hpp"

#if CONFIG_BT_NIMBLE_ENABLED || defined(_DOXYGEN_)

void espp::BleGattServerCallbacks::onConnect(NimBLEServer *server, NimBLEConnInfo &conn_info) {
if (server_ && server_->callbacks_.connect_callback) {
server_->callbacks_.connect_callback(conn_info);
Expand Down Expand Up @@ -33,3 +35,5 @@ bool espp::BleGattServerCallbacks::onConfirmPIN(uint32_t pass_key) {
return pass_key == NimBLEDevice::getSecurityPasskey();
}
}

#endif // CONFIG_BT_NIMBLE_ENABLED || defined(_DOXYGEN_)

0 comments on commit 8dbf40f

Please sign in to comment.