diff --git a/connectivity/FEATURE_BLE/source/cordio/include/ble/internal/PalSigningMonitorImpl.h b/connectivity/FEATURE_BLE/source/cordio/include/ble/internal/PalSigningMonitorImpl.h deleted file mode 100644 index 14fc56156d..0000000000 --- a/connectivity/FEATURE_BLE/source/cordio/include/ble/internal/PalSigningMonitorImpl.h +++ /dev/null @@ -1,33 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2020 ARM Limited - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef IMPL_PAL_SIGNING_MONITOR_H_ -#define IMPL_PAL_SIGNING_MONITOR_H_ - -#include "source/pal/PalSigningMonitor.h" - -namespace ble { - -class PalSigningMonitor : public interface::PalSigningMonitor { -public: - void set_signing_event_handler(PalSigningMonitorEventHandler *handler); -}; - -} // ble - -#endif // CORDIO_PAL_SIGNING_MONITOR_H_ diff --git a/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp index 9a527bf35d..ff7de0f9d3 100644 --- a/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp @@ -267,7 +267,20 @@ PalGattClient &BLEInstanceBase::getPalGattClient() ble::impl::SecurityManager &BLEInstanceBase::getSecurityManagerImpl() { - static PalSigningMonitor signing_event_monitor; + // Creation of a proxy monitor to let the security manager register to + // the gatt client and gatt server. + static struct : PalSigningMonitor { + void set_signing_event_handler(PalSigningMonitorEventHandler *handler) + { +#if BLE_FEATURE_GATT_CLIENT + BLEInstanceBase::deviceInstance().getGattClientImpl().set_signing_event_handler(handler); +#endif // BLE_FEATURE_GATT_CLIENT +#if BLE_FEATURE_GATT_SERVER + BLEInstanceBase::deviceInstance().getGattServerImpl().set_signing_event_handler(handler); +#endif // BLE_FEATURE_GATT_SERVER + } + } signing_event_monitor; + static ble::impl::SecurityManager m_instance( ble::impl::PalSecurityManager::get_security_manager(), getGapImpl(), diff --git a/connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.h index ee818194bf..91bc50e1a5 100644 --- a/connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.h @@ -211,7 +211,7 @@ private: void set_signing_event_handler( PalSigningMonitorEventHandler *signing_event_handler - ); + ) override; EventHandler *getEventHandler(); diff --git a/connectivity/FEATURE_BLE/source/cordio/source/PalSigningMonitorImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/PalSigningMonitorImpl.cpp deleted file mode 100644 index f38af7bf19..0000000000 --- a/connectivity/FEATURE_BLE/source/cordio/source/PalSigningMonitorImpl.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2020 ARM Limited - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "source/pal/PalSigningMonitor.h" -#include "source/BLEInstanceBase.h" - -namespace ble { - -void PalSigningMonitor::set_signing_event_handler(PalSigningMonitorEventHandler *handler) -{ -#if BLE_FEATURE_GATT_CLIENT - BLEInstanceBase::deviceInstance().getGattClientImpl().set_signing_event_handler(handler); -#endif // BLE_FEATURE_GATT_CLIENT -#if BLE_FEATURE_GATT_SERVER - BLEInstanceBase::deviceInstance().getGattServerImpl().set_signing_event_handler(handler); -#endif // BLE_FEATURE_GATT_SERVER -} - -} diff --git a/connectivity/FEATURE_BLE/source/generic/GattClientImpl.h b/connectivity/FEATURE_BLE/source/generic/GattClientImpl.h index c4f059d284..11d4a018b2 100644 --- a/connectivity/FEATURE_BLE/source/generic/GattClientImpl.h +++ b/connectivity/FEATURE_BLE/source/generic/GattClientImpl.h @@ -167,7 +167,7 @@ private: /** * @see ble::PalSigningMonitor::set_signing_event_handler */ - void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler); + void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler) override; /** * @see PalGattClient::EventHandler::on_att_mtu_change diff --git a/connectivity/FEATURE_BLE/source/pal/PalSigningMonitor.h b/connectivity/FEATURE_BLE/source/pal/PalSigningMonitor.h index 19ced89d2a..e4836be169 100644 --- a/connectivity/FEATURE_BLE/source/pal/PalSigningMonitor.h +++ b/connectivity/FEATURE_BLE/source/pal/PalSigningMonitor.h @@ -58,7 +58,6 @@ public: }; }; -namespace interface { /** * Implemented by classes that need to be notified of signing events. * Notification is done by calling functions in the passed in event handler @@ -70,14 +69,9 @@ public: * * @param[in] signing_event_handler Event handler being registered. */ - void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler); + virtual void set_signing_event_handler(PalSigningMonitorEventHandler *signing_event_handler) = 0; }; -} // namespace interface } // namespace ble -/* This includes the concrete class implementation, to provide a an alternative BLE PAL implementation - * disable Cordio and place your header in a path with the same structure */ -#include "ble/internal/PalSigningMonitorImpl.h" - #endif /* MBED_BLE_SIGNING_EVENT_MONITOR */