Skip to content

Commit cf3ede0

Browse files
committed
BLE: GattServer PIMPL
1 parent 2b48d48 commit cf3ede0

File tree

4 files changed

+343
-247
lines changed

4 files changed

+343
-247
lines changed

connectivity/FEATURE_BLE/include/ble/GattServer.h

Lines changed: 27 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ namespace ble {
9595
* the nature of the server initiated is not relevant.
9696
*/
9797
#if !defined(DOXYGEN_ONLY)
98+
namespace impl {
99+
class GattServer;
100+
}
101+
98102
namespace interface {
99103
#endif // !defined(DOXYGEN_ONLY)
100104
class GattServer {
@@ -415,7 +419,10 @@ class GattServer {
415419
* function.
416420
*/
417421
template <typename T>
418-
void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count));
422+
void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count))
423+
{
424+
onDataSent({objPtr, memberPtr});
425+
}
419426

420427
/**
421428
* Access the callchain of data sent event handlers.
@@ -448,7 +455,10 @@ class GattServer {
448455
void onDataWritten(
449456
T *objPtr,
450457
void (T::*memberPtr)(const GattWriteCallbackParams *context)
451-
);
458+
)
459+
{
460+
onDataWritten({objPtr, memberPtr});
461+
}
452462

453463
/**
454464
* Access the callchain of data written event handlers.
@@ -495,7 +505,10 @@ class GattServer {
495505
ble_error_t onDataRead(
496506
T *objPtr,
497507
void (T::*memberPtr)(const GattReadCallbackParams *context)
498-
);
508+
)
509+
{
510+
onDataRead({objPtr, memberPtr});
511+
}
499512

500513
/**
501514
* Access the callchain of data read event handlers.
@@ -537,7 +550,10 @@ class GattServer {
537550
* function.
538551
*/
539552
template <typename T>
540-
void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *));
553+
void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *))
554+
{
555+
onShutdown({objPtr, memberPtr});
556+
}
541557

542558
/**
543559
* Access the callchain of shutdown event handlers.
@@ -578,72 +594,8 @@ class GattServer {
578594
*/
579595
void onConfirmationReceived(EventCallback_t callback);
580596

581-
/* Entry points for the underlying stack to report events back to the user. */
582-
protected:
583-
/**
584-
* Helper function that notifies all registered handlers of an occurrence
585-
* of a data written event.
586-
*
587-
* @attention Vendor implementation must invoke this function after one of
588-
* the GattServer attributes has been written.
589-
*
590-
* @param[in] params The data written parameters passed to the registered
591-
* handlers.
592-
*/
593-
void handleDataWrittenEvent(const GattWriteCallbackParams *params);
594-
595-
/**
596-
* Helper function that notifies all registered handlers of an occurrence
597-
* of a data read event.
598-
*
599-
* @attention Vendor implementation must invoke this function after one of
600-
* the GattServer attributes has been read.
601-
*
602-
* @param[in] params The data read parameters passed to the registered
603-
* handlers.
604-
*/
605-
void handleDataReadEvent(const GattReadCallbackParams *params);
606-
607-
/**
608-
* Helper function that notifies the registered handler of an occurrence
609-
* of updates enabled, updates disabled or confirmation received events.
610-
*
611-
* @attention Vendor implementation must invoke this function when a client
612-
* subscribes to characteristic updates, unsubscribes from characteristic
613-
* updates or a notification confirmation has been received.
614-
*
615-
* @param[in] type The type of event that occurred.
616-
* @param[in] attributeHandle The handle of the attribute concerned by the
617-
* event.
618-
*/
619-
void handleEvent(
620-
GattServerEvents::gattEvent_e type,
621-
GattAttribute::Handle_t attributeHandle
622-
);
623-
624-
/**
625-
* Helper function that notifies all registered handlers of an occurrence
626-
* of a data sent event.
627-
*
628-
* @attention Vendor implementation must invoke this function after the
629-
* emission of a notification or an indication.
630-
*
631-
* @param[in] count Number of packets sent.
632-
*/
633-
void handleDataSentEvent(unsigned count);
634-
635-
/**
636-
* Get preferred connection paramters.
637-
*
638-
*/
639-
Gap::PreferredConnectionParams_t getPreferredConnectionParams();
640-
641-
/**
642-
* Set preferred connection parameters.
643-
*
644-
* @param[in] params Preferred connection parameter values to set.
645-
*/
646-
void setPreferredConnectionParams(const Gap::PreferredConnectionParams_t& params);
597+
private:
598+
impl::GattServer *impl;
647599
};
648600

649601
/**
@@ -655,13 +607,16 @@ class GattServer {
655607
#if !defined(DOXYGEN_ONLY)
656608
} // namespace interface
657609
#endif // !defined(DOXYGEN_ONLY)
610+
611+
using ble::interface::GattServer;
612+
658613
} // ble
659614

660615
/* This includes the concrete class implementation, to provide a an alternative API implementation
661616
* disable ble-api-implementation and place your header in a path with the same structure */
662-
#include "ble/internal/GattServerImpl.h"
617+
//#include "ble/internal/GattServerImpl.h"
663618

664619
/** @deprecated Use the namespaced ble::GattServer instead of the global GattServer. */
665-
using ble::GattServer;
620+
using ble::interface::GattServer;
666621

667622
#endif /* ifndef MBED_GATT_SERVER_H__ */

0 commit comments

Comments
 (0)