Skip to content

Commit 108d690

Browse files
route ble events to gap
1 parent c452d8f commit 108d690

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

features/FEATURE_BLE/ble/pal/PalGap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ struct Gap {
4848
* @copydoc Gap::EventHandler::onAttMtuChanged
4949
*/
5050
virtual void on_att_mtu_changed(
51-
Handle_t connection_handle,
51+
connection_handle_t connection_handle,
5252
uint16_t att_mtu_size
5353
) = 0;
5454

5555
/**
5656
* @copydoc Gap::EventHandler::onPacketPaylodSizeChanged
5757
*/
5858
virtual void on_packet_paylod_size_changed(
59-
Handle_t connection_handle,
59+
connection_handle_t connection_handle,
6060
uint16_t tx_size,
6161
uint16_t rx_size
6262
) = 0;

features/FEATURE_BLE/source/generic/GenericGap.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,9 @@ void GenericGap::on_att_mtu_changed(
865865
uint16_t att_mtu_size
866866
)
867867
{
868-
onAttMtuChanged(connectionHandle, attMtuSize);
868+
if (_eventHandler) {
869+
_eventHandler->onAttMtuChanged(connection_handle, att_mtu_size);
870+
}
869871
}
870872

871873
void GenericGap::on_packet_paylod_size_changed(
@@ -874,7 +876,9 @@ void GenericGap::on_packet_paylod_size_changed(
874876
uint16_t rx_size
875877
)
876878
{
877-
onPacketPaylodSizeChanged(connectionHandle, txSize, rxSize);
879+
if (_eventHandler) {
880+
_eventHandler->onPacketPaylodSizeChanged(connection_handle, tx_size, rx_size);
881+
}
878882
}
879883

880884
void GenericGap::on_phy_update_complete(

features/FEATURE_BLE/targets/TARGET_CORDIO/CordioPalAttClient.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "ble/pal/SimpleAttServerMessage.h"
2323
#include "att_api.h"
2424
#include "att_defs.h"
25+
#include "ble/pal/PalGap.h"
26+
#include "CordioPalGap.h"
2527

2628
namespace ble {
2729
namespace pal {
@@ -318,11 +320,20 @@ class CordioAttClient : public ::ble::pal::AttClient {
318320
*/
319321
static void att_client_handler(const attEvt_t* event)
320322
{
323+
if (event->hdr.status == ATT_SUCCESS && event->hdr.event == ATT_MTU_UPDATE_IND) {
324+
ble::pal::Gap::EventHandler *handler;
325+
handler = ble::pal::vendor::cordio::Gap::get_gap().get_event_handler();
326+
if (handler) {
327+
handler->on_att_mtu_changed(event->hdr.param, event->mtu);
328+
}
329+
return;
330+
}
331+
321332
// all handlers are stored in a static array
322333
static const event_handler_t handlers[] = {
323334
&timeout_event_handler,
324335
&event_handler<ErrorResponseConverter>,
325-
&event_handler<ExchangeMtuResponseConverter>,
336+
//&event_handler<ExchangeMtuResponseConverter>,
326337
&event_handler<FindInformationResponseConverter>,
327338
&event_handler<FindByTypeValueResponseConverter>,
328339
&event_handler<ReadByTypeResponseConverter>,

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,20 @@ void BLE::processEvents()
286286

287287
void BLE::device_manager_cb(dmEvt_t* dm_event)
288288
{
289+
if (dm_event->hdr.status == HCI_SUCCESS && dm_event->hdr.event == DM_CONN_DATA_LEN_CHANGE_IND) {
290+
// this event can only happen after a connection has been established therefore gap is present
291+
ble::pal::Gap::EventHandler *handler;
292+
handler = ble::pal::vendor::cordio::Gap::get_gap().get_event_handler();
293+
if (handler) {
294+
handler->on_packet_paylod_size_changed(
295+
dm_event->hdr.param,
296+
dm_event->dataLenChange.maxTxOctets,
297+
dm_event->dataLenChange.maxRxOctets
298+
);
299+
}
300+
return;
301+
}
302+
289303
BLE::deviceInstance().stack_handler(0, &dm_event->hdr);
290304
}
291305

0 commit comments

Comments
 (0)