Skip to content

Commit cdd5c9f

Browse files
fix nrf52 mtu
1 parent 193092f commit cdd5c9f

File tree

1 file changed

+13
-9
lines changed
  • features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/btle

1 file changed

+13
-9
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/btle/btle.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,12 @@ void btle_handler(const ble_evt_t *p_ble_evt)
400400
p_ble_evt->evt.gatts_evt.params.exchange_mtu_request;
401401

402402
nRF5xGattServer &gatt_server = (nRF5xGattServer&) ble.getGattServer();
403-
gatt_server.getEventHandler()->onAttMtuChange(
404-
connection,
405-
std::min(NRF_SDH_BLE_GATT_MAX_MTU_SIZE, (int)(update.client_rx_mtu))
406-
);
403+
if (gatt_server.getEventHandler()) {
404+
gatt_server.getEventHandler()->onAttMtuChange(
405+
connection,
406+
std::min(NRF_SDH_BLE_GATT_MAX_MTU_SIZE, (int)(update.client_rx_mtu))
407+
);
408+
}
407409
}
408410
break;
409411
}
@@ -415,11 +417,13 @@ void btle_handler(const ble_evt_t *p_ble_evt)
415417
const ble_gattc_evt_exchange_mtu_rsp_t &update =
416418
p_ble_evt->evt.gattc_evt.params.exchange_mtu_rsp;
417419

418-
nRF5xGattServer &gatt_client = (nRF5xGattClient&) ble.getGattClient();
419-
gatt_client.getEventHandler()->onAttMtuChange(
420-
connection,
421-
std::min(NRF_SDH_BLE_GATT_MAX_MTU_SIZE, (int)(update.server_rx_mtu))
422-
);
420+
nRF5xGattClient &gatt_client = (nRF5xGattClient&) ble.getGattClient();
421+
if (gatt_client.get_event_handler()) {
422+
gatt_client.get_event_handler()->on_att_mtu_change(
423+
connection,
424+
std::min(NRF_SDH_BLE_GATT_MAX_MTU_SIZE, (int)(update.server_rx_mtu))
425+
);
426+
}
423427
}
424428
break;
425429
}

0 commit comments

Comments
 (0)