diff --git a/features/FEATURE_BLE/ble/pal/SigningEventMonitor.h b/features/FEATURE_BLE/ble/pal/SigningEventMonitor.h index bc6392c8be..5a299c68e3 100644 --- a/features/FEATURE_BLE/ble/pal/SigningEventMonitor.h +++ b/features/FEATURE_BLE/ble/pal/SigningEventMonitor.h @@ -17,55 +17,79 @@ #ifndef MBED_BLE_SIGNING_EVENT_MONITOR #define MBED_BLE_SIGNING_EVENT_MONITOR +#include "ble/common/StaticInterface.h" #include "ble/BLETypes.h" namespace ble { namespace pal { +/** + * Implemented by classes that are reacting to signing events. + */ +template +class SigningMonitorEventHandler : public StaticInterface { + + using StaticInterface::impl; + +public: + /** + * Set new signed write peer counter. + * + * @param[in] connection connection handle + * @param[in] sign_coutner counter received from peer + */ + void on_signed_write_received( + connection_handle_t connection, + uint32_t sign_coutner + ) { + impl()->on_signed_write_received_( + connection, + sign_coutner + ); + } + + /** + * Indicate that signed data was rejected due to verification failure. This could + * be due to an invalid CSRK key. + * + * @param[in] connection connection handle + */ + void on_signed_write_verification_failure( + connection_handle_t connection + ) { + impl()->on_signed_write_verification_failure(connection); + } + + /** + * Notify a new signed write cmd was executed. + */ + void on_signed_write() { + impl()->on_signed_write_(); + } +}; + + + /** * Implemented by classes that need to be notified of signing events. * Notification is done by calling functions in the passed in event handler */ +template class SigningEventMonitor { + Impl* impl() { + return static_cast(this); + } + public: - /** - * Implemented by classes that are reacting to signing events. - */ - class EventHandler { - public: - /** - * Set new signed write peer counter. - * - * @param[in] connection connection handle - * @param[in] sign_coutner counter received from peer - */ - virtual void on_signed_write_received( - connection_handle_t connection, - uint32_t sign_coutner - ) = 0; - - /** - * Indicate that signed data was rejected due to verification failure. This could - * be due to an invalid CSRK key. - * - * @param[in] connection connection handle - */ - virtual void on_signed_write_verification_failure( - connection_handle_t connection - ) = 0; - - /** - * Notify a new signed write cmd was executed. - */ - virtual void on_signed_write() = 0; - }; - /** * Register a handler for singing events to be used internally and serviced first. * * @param[in] signing_event_handler Event handler being registered. */ - virtual void set_signing_event_handler(EventHandler *signing_event_handler) = 0; + void set_signing_event_handler(EventHandler *signing_event_handler) + { + impl()->set_signing_event_handler_(signing_event_handler); + } }; } // namespace pal