mirror of https://github.com/ARMmbed/mbed-os.git
Get the pal event handler from pal gattclient
parent
b628285254
commit
03b747a6f6
|
@ -601,8 +601,27 @@ public:
|
||||||
_transaction_timeout_cb = cb;
|
_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:
|
protected:
|
||||||
GattClient() { }
|
GattClient() : _event_handler(NULL) { }
|
||||||
|
|
||||||
virtual ~GattClient() { }
|
virtual ~GattClient() { }
|
||||||
|
|
||||||
|
@ -640,6 +659,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
EventHandler* _event_handler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback called when the client receive a message from the server.
|
* Callback called when the client receive a message from the server.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -107,6 +107,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual generic::GenericGattClient &getGattClient();
|
virtual generic::GenericGattClient &getGattClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PAL Gatt Client.
|
||||||
|
*
|
||||||
|
* @return PAL Gatt Client.
|
||||||
|
*/
|
||||||
|
pal::AttClientToGattClientAdapter &BLE::getPalGattClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BLEInstanceBase::getSecurityManager
|
* @see BLEInstanceBase::getSecurityManager
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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) {
|
if (event->hdr.status == ATT_SUCCESS && event->hdr.event == ATT_MTU_UPDATE_IND) {
|
||||||
ble::vendor::cordio::BLE& ble = ble::vendor::cordio::BLE::deviceInstance();
|
ble::vendor::cordio::BLE& ble = ble::vendor::cordio::BLE::deviceInstance();
|
||||||
ble::pal::GattClient::EventHandler &handler = ble.getGattClient();
|
ble::pal::GattClient::EventHandler *handler = ble.getPalGattClient().get_event_handler();
|
||||||
handler.on_att_mtu_change(event->hdr.param, event->mtu);
|
if (handler) {
|
||||||
|
handler->on_att_mtu_change(event->hdr.param, event->mtu);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// all handlers are stored in a static array
|
// all handlers are stored in a static array
|
||||||
static const event_handler_t handlers[] = {
|
static const event_handler_t handlers[] = {
|
||||||
|
|
|
@ -199,13 +199,19 @@ const GattServer& BLE::getGattServer() const
|
||||||
}
|
}
|
||||||
|
|
||||||
generic::GenericGattClient& BLE::getGattClient()
|
generic::GenericGattClient& BLE::getGattClient()
|
||||||
|
{
|
||||||
|
static generic::GenericGattClient gatt_client(&getPalGattClient());
|
||||||
|
|
||||||
|
return gatt_client;
|
||||||
|
}
|
||||||
|
|
||||||
|
pal::AttClientToGattClientAdapter& BLE::getPalGattClient()
|
||||||
{
|
{
|
||||||
static pal::AttClientToGattClientAdapter pal_client(
|
static pal::AttClientToGattClientAdapter pal_client(
|
||||||
pal::vendor::cordio::CordioAttClient::get_client()
|
pal::vendor::cordio::CordioAttClient::get_client()
|
||||||
);
|
);
|
||||||
static generic::GenericGattClient client(&pal_client);
|
|
||||||
|
|
||||||
return client;
|
return pal_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityManager& BLE::getSecurityManager()
|
SecurityManager& BLE::getSecurityManager()
|
||||||
|
|
Loading…
Reference in New Issue