|
26 | 26 |
|
27 | 27 | #include "ble/GapEvents.h"
|
28 | 28 | #include "nRF5xn.h"
|
| 29 | +#include <algorithm> |
29 | 30 |
|
30 | 31 | #ifdef S110
|
31 | 32 | #define IS_LEGACY_DEVICE_MANAGER_ENABLED 1
|
@@ -368,15 +369,55 @@ void btle_handler(const ble_evt_t *p_ble_evt)
|
368 | 369 |
|
369 | 370 | ASSERT_STATUS_RET_VOID(sd_ble_gap_data_length_update(p_gap_evt->conn_handle, &dlp, NULL));
|
370 | 371 | break;
|
| 372 | + // Handle Data length negotiation result |
| 373 | + case BLE_GAP_EVT_DATA_LENGTH_UPDATE: { |
| 374 | + /* inform user application */ |
| 375 | + if (gap._eventHandler) { |
| 376 | + Gap::Handle_t connection = p_ble_evt->evt.gap_evt.conn_handle; |
| 377 | + const ble_gap_evt_data_length_update_t &update = |
| 378 | + p_ble_evt->evt.gap_evt.params.data_length_update; |
| 379 | + |
| 380 | + gap._eventHandler->onPacketPayloadSizeChanged( |
| 381 | + connection, |
| 382 | + update.effective_params.max_tx_octets, |
| 383 | + update.effective_params.max_rx_octets |
| 384 | + ); |
| 385 | + } |
| 386 | + break; |
371 | 387 | }
|
372 | 388 |
|
373 |
| - // Handle MTU exchange request |
374 |
| - case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: |
375 |
| - { |
376 |
| - // Respond with the server MTU |
377 |
| - uint16_t conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; |
| 389 | + case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: { |
| 390 | + /* Respond with the server MTU */ |
| 391 | + uint16_t conn_handle = p_ble_evt->evt.gatts_evt.conn_handle; |
378 | 392 | ASSERT_STATUS_RET_VOID(sd_ble_gatts_exchange_mtu_reply(conn_handle, NRF_SDH_BLE_GATT_MAX_MTU_SIZE));
|
379 |
| - break; |
| 393 | + |
| 394 | + /* inform user application */ |
| 395 | + if (gap._eventHandler) { |
| 396 | + Gap::Handle_t connection = p_ble_evt->evt.gap_evt.conn_handle; |
| 397 | + const ble_gatts_evt_exchange_mtu_request_t &update = |
| 398 | + p_ble_evt->evt.gatts_evt.params.exchange_mtu_request; |
| 399 | + |
| 400 | + gap._eventHandler->onAttMtuChanged( |
| 401 | + connection, |
| 402 | + std::min(NRF_SDH_BLE_GATT_MAX_MTU_SIZE, (int)(update.client_rx_mtu)) |
| 403 | + ); |
| 404 | + } |
| 405 | + break; |
| 406 | + } |
| 407 | + |
| 408 | + case BLE_GATTC_EVT_EXCHANGE_MTU_RSP: { |
| 409 | + /* inform user application */ |
| 410 | + if (gap._eventHandler) { |
| 411 | + Gap::Handle_t connection = p_ble_evt->evt.gap_evt.conn_handle; |
| 412 | + const ble_gattc_evt_exchange_mtu_rsp_t &update = |
| 413 | + p_ble_evt->evt.gattc_evt.params.exchange_mtu_rsp; |
| 414 | + |
| 415 | + gap._eventHandler->onAttMtuChanged( |
| 416 | + connection, |
| 417 | + std::min(NRF_SDH_BLE_GATT_MAX_MTU_SIZE, (int)(update.server_rx_mtu)) |
| 418 | + ); |
| 419 | + } |
| 420 | + break; |
380 | 421 | }
|
381 | 422 | #endif
|
382 | 423 | case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: {
|
|
0 commit comments