Skip to content

Commit fd54e5e

Browse files
author
Donatien Garnier
committed
Handle required BLE5 softdevice commands
1 parent 7f18938 commit fd54e5e

File tree

1 file changed

+47
-0
lines changed
  • features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source/btle

1 file changed

+47
-0
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source/btle/btle.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,53 @@ static void btle_handler(ble_evt_t *p_ble_evt)
369369
break;
370370
}
371371

372+
373+
#if (NRF_SD_BLE_API_VERSION >= 5)
374+
#ifndef S140
375+
// Handle PHY upgrade request
376+
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
377+
{
378+
ble_gap_phys_t const phys =
379+
{
380+
/* rx_phys */ BLE_GAP_PHY_AUTO,
381+
/* tx_phys */ BLE_GAP_PHY_AUTO,
382+
};
383+
ASSERT_STATUS_RET_VOID( sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys) );
384+
break;
385+
}
386+
#endif
387+
388+
// Handle Data length negotiation request
389+
case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
390+
{
391+
ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
392+
uint8_t const data_length_peer =
393+
p_gap_evt->params.data_length_update_request.peer_params.max_tx_octets;
394+
395+
const uint8_t max_data_length = NRF_SDH_BLE_GATT_MAX_MTU_SIZE + 4 /* L2CAP header size */;
396+
397+
uint8_t const data_length = MIN(max_data_length, data_length_peer);
398+
399+
ble_gap_data_length_params_t const dlp =
400+
{
401+
/* max_rx_octets */ data_length,
402+
/* max_tx_octets */ data_length
403+
};
404+
405+
ASSERT_STATUS_RET_VOID(sd_ble_gap_data_length_update(p_gap_evt->conn_handle, &dlp, NULL));
406+
break;
407+
}
408+
409+
// Handle MTU exchange request
410+
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
411+
{
412+
// Respond with the server MTU
413+
uint16_t conn_handle = p_ble_evt->evt.gatts_evt.conn_handle;
414+
ASSERT_STATUS_RET_VOID(sd_ble_gatts_exchange_mtu_reply(conn_handle, NRF_SDH_BLE_GATT_MAX_MTU_SIZE));
415+
break;
416+
}
417+
#endif
418+
372419
case BLE_GAP_EVT_PASSKEY_DISPLAY:
373420
securityManager.processPasskeyDisplayEvent(p_ble_evt->evt.gap_evt.conn_handle, p_ble_evt->evt.gap_evt.params.passkey_display.passkey);
374421
break;

0 commit comments

Comments
 (0)