Get the pal event handler from pal gattclient

pull/9537/head
paul-szczepanek-arm 2019-02-05 12:14:47 +00:00
parent b628285254
commit 03b747a6f6
4 changed files with 41 additions and 5 deletions

View File

@ -601,8 +601,27 @@ public:
_transaction_timeout_cb = cb;
}
/**
* Sets the event handler that us called by the PAL porters to notify the stack of events
* which will in turn be passed onto the user application when appropriate.
*
* @param event_handler The new event handler interface implementation.
*/
void set_event_handler(EventHandler* event_handler) {
_event_handler = event_handler;
}
/**
* Get the currently registered event handler.
*
* @return Currently registered event handler. NULL if no event handler is present.
*/
EventHandler* get_event_handler() {
return _event_handler;
}
protected:
GattClient() { }
GattClient() : _event_handler(NULL) { }
virtual ~GattClient() { }
@ -640,6 +659,8 @@ protected:
}
private:
EventHandler* _event_handler;
/**
* Callback called when the client receive a message from the server.
*/

View File

@ -107,6 +107,13 @@ public:
*/
virtual generic::GenericGattClient &getGattClient();
/**
* Get the PAL Gatt Client.
*
* @return PAL Gatt Client.
*/
pal::AttClientToGattClientAdapter &BLE::getPalGattClient();
/**
* @see BLEInstanceBase::getSecurityManager
*/

View File

@ -26,8 +26,10 @@ void CordioAttClient::att_client_handler(const attEvt_t* event)
{
if (event->hdr.status == ATT_SUCCESS && event->hdr.event == ATT_MTU_UPDATE_IND) {
ble::vendor::cordio::BLE& ble = ble::vendor::cordio::BLE::deviceInstance();
ble::pal::GattClient::EventHandler &handler = ble.getGattClient();
handler.on_att_mtu_change(event->hdr.param, event->mtu);
ble::pal::GattClient::EventHandler *handler = ble.getPalGattClient().get_event_handler();
if (handler) {
handler->on_att_mtu_change(event->hdr.param, event->mtu);
}
} else {
// all handlers are stored in a static array
static const event_handler_t handlers[] = {

View File

@ -199,13 +199,19 @@ const GattServer& BLE::getGattServer() const
}
generic::GenericGattClient& BLE::getGattClient()
{
static generic::GenericGattClient gatt_client(&getPalGattClient());
return gatt_client;
}
pal::AttClientToGattClientAdapter& BLE::getPalGattClient()
{
static pal::AttClientToGattClientAdapter pal_client(
pal::vendor::cordio::CordioAttClient::get_client()
);
static generic::GenericGattClient client(&pal_client);
return client;
return pal_client;
}
SecurityManager& BLE::getSecurityManager()