There are two DKs, one works as a slave while the other works as a master. When these two peripherals are connected via Bluetooth, they exchange each other's parameters via the exchange function and I want to make their phy both 2M.
Some functions are as follow.
static void exchange_func(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
{
if (!err) {
m_nus_max_send_len = bt_nus_get_mtu(conn);
LOG_INF("ATT MTU size updated to %d bytes", m_nus_max_send_len + 3);
LOG_INF("MTU exchange done");
#if CONFIG_BT_USER_DATA_LEN_UPDATE
err = bt_conn_le_data_len_update(conn, BT_LE_DATA_LEN_PARAM_MAX);
if (err) {
LOG_ERR("Failed to update data length (error %u)", err);
}
#endif
} else {
LOG_WRN("MTU exchange failed (err %" PRIu8 ")", err);
}
}
static void data_len_updated(struct bt_conn *conn, struct bt_conn_le_data_len_info *info)
{
int err;
LOG_INF("Data length updated. RX length: %d, TX length: %d", info->rx_max_len,
info->tx_max_len);
err = bt_conn_le_phy_update(conn, BT_CONN_LE_PHY_PARAM_2M);
if (err) {
LOG_ERR("bt_conn_le_phy_update() returned %d", err);
}
}
static void phy_updated(struct bt_conn *conn, struct bt_conn_le_phy_info *param)
{
LOG_INF("PHY updated. RX PHY: %d, TX PHY: %d", param->rx_phy, param->tx_phy);
}
BT_CONN_CB_DEFINE(conn_callbacks) = {
.connected = connected,
.disconnected = disconnected,
.security_changed = security_changed,
#if CONFIG_BT_USER_DATA_LEN_UPDATE
.le_data_len_updated = data_len_updated,
#endif
.le_phy_updated = phy_updated,
};
When these two boards are connected, the transmission rate between them is 500~600kbps. However, when the slave is directly connected to the mobile phone, the transmission rate is 500kbps(1Mbps) when the phy is 1M(2M).Therefore, I don't think I have successfully changed the phy of the master to 2M, though I did get a 2M phy from the read phy function in my mobile app--"nRF Connect".

And I can't seem to modify the phy directly in the prj.conf. This is my prj.conf of the DK that works as a master.
# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# Enable the BLE stack with GATT Client configuration
CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_DEVICE_NAME="Nordic_Central"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_MAX_CONN=2
CONFIG_BT_MAX_PAIRED=2
CONFIG_BT_SMP=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_GATT_CLIENT=y
# Enable the BLE modules from NCS
CONFIG_BT_NUS=y
CONFIG_BT_NUS_CLIENT=y
CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1
CONFIG_BT_GATT_DM=y
CONFIG_HEAP_MEM_POOL_SIZE=2048
# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
# Share address between scanner and advertisor
CONFIG_BT_SCAN_WITH_IDENTITY=y
# CONFIG_BT_EXT_ADV=y
# Enable DK LED and Buttons library
CONFIG_DK_LIBRARY=y
# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_ASSERT=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_BUF_ACL_TX_SIZE=251