Fatal error while adding 2Mbps PHY

Board: nRF52810

SoftDevice: s112

SDK version: 17.0.2

I'm trying to enable 2Mbps data rate. So I've added init.config.ble_adv_primary_phy   = BLE_GAP_PHY_2MBPS; in the advertising_init() function. But I'm getting fatal error in advertising_start() function. 

How can I solve this issue and achieve 2 mbps data rate.

Thanks in advance.

Parents Reply Children
  • Thanks.

    Maybe you could also upload the ble_advertising_start() function?
    That was the function I was looking for. Sorry for the confusion.

    Br,
    Joakim

  • Hi,

    No worries.

    This is my ble_advertising_start() function

    uint32_t ble_advertising_start(ble_advertising_t * const p_advertising,
                                   ble_adv_mode_t            advertising_mode)
    {
        uint32_t ret;
    
        if (p_advertising->initialized == false)
        {
            return NRF_ERROR_INVALID_STATE;
        }
    
        p_advertising->adv_mode_current = advertising_mode;
    
        memset(&p_advertising->peer_address, 0, sizeof(p_advertising->peer_address));
    
        if (  ((p_advertising->adv_modes_config.ble_adv_directed_high_duty_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED_HIGH_DUTY))
            ||((p_advertising->adv_modes_config.ble_adv_directed_enabled)           && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED_HIGH_DUTY))
            ||((p_advertising->adv_modes_config.ble_adv_directed_enabled)           && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED))
           )
        {
            if (p_advertising->evt_handler != NULL)
            {
                p_advertising->peer_addr_reply_expected = true;
                p_advertising->evt_handler(BLE_ADV_EVT_PEER_ADDR_REQUEST);
            }
            else
            {
                p_advertising->peer_addr_reply_expected = false;
            }
        }
    
        p_advertising->adv_mode_current = adv_mode_next_avail_get(p_advertising, advertising_mode);
    
        // Fetch the whitelist.
        if ((p_advertising->evt_handler != NULL) &&
            (p_advertising->adv_mode_current == BLE_ADV_MODE_FAST || p_advertising->adv_mode_current == BLE_ADV_MODE_SLOW) &&
            (p_advertising->adv_modes_config.ble_adv_whitelist_enabled) &&
            (!p_advertising->whitelist_temporarily_disabled))
        {
            p_advertising->whitelist_in_use         = false;
            p_advertising->whitelist_reply_expected = true;
            p_advertising->evt_handler(BLE_ADV_EVT_WHITELIST_REQUEST);
        }
        else
        {
            p_advertising->whitelist_reply_expected = false;
        }
    
        // Initialize advertising parameters with default values.
        memset(&p_advertising->adv_params, 0, sizeof(p_advertising->adv_params));
    
        p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
    
        // Use 1MBIT as primary phy if no phy was selected.
        if (phy_is_valid(&p_advertising->adv_modes_config.ble_adv_primary_phy))
        {
            p_advertising->adv_params.primary_phy = p_advertising->adv_modes_config.ble_adv_primary_phy;
        }
        else
        {
            p_advertising->adv_params.primary_phy = BLE_GAP_PHY_1MBPS;
        }
    
        if (p_advertising->adv_modes_config.ble_adv_extended_enabled)
        {
            // Use 1MBIT as secondary phy if no phy was selected.
            if (phy_is_valid(&p_advertising->adv_modes_config.ble_adv_secondary_phy))
            {
                p_advertising->adv_params.secondary_phy = p_advertising->adv_modes_config.ble_adv_secondary_phy;
            }
            else
            {
                p_advertising->adv_params.secondary_phy = BLE_GAP_PHY_1MBPS;
            }
        }
        p_advertising->adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
    
        // Set advertising parameters and events according to selected advertising mode.
        switch (p_advertising->adv_mode_current)
        {
            case BLE_ADV_MODE_DIRECTED_HIGH_DUTY:
                ret = set_adv_mode_directed_high_duty(p_advertising, &p_advertising->adv_params);
                break;
    
            case BLE_ADV_MODE_DIRECTED:
                ret = set_adv_mode_directed(p_advertising, &p_advertising->adv_params);
                break;
    
            case BLE_ADV_MODE_FAST:
                ret = set_adv_mode_fast(p_advertising, &p_advertising->adv_params);
                break;
    
            case BLE_ADV_MODE_SLOW:
                ret = set_adv_mode_slow(p_advertising, &p_advertising->adv_params);
                break;
    
            case BLE_ADV_MODE_IDLE:
                p_advertising->adv_evt = BLE_ADV_EVT_IDLE;
                break;
    
            default:
                break;
        }
    
        if (p_advertising->adv_mode_current != BLE_ADV_MODE_IDLE)
        {
    
            ret = sd_ble_gap_adv_set_configure(&p_advertising->adv_handle, p_advertising->p_adv_data, &p_advertising->adv_params);
            if (ret != NRF_SUCCESS)
            {
                return ret;
            }
            ret = sd_ble_gap_adv_start(p_advertising->adv_handle, p_advertising->conn_cfg_tag);
    
            if (ret != NRF_SUCCESS)
            {
                return ret;
            }
        }
    
        if (p_advertising->evt_handler != NULL)
        {
            p_advertising->evt_handler(p_advertising->adv_evt);
        }
    
        return NRF_SUCCESS;
    }
    

  • Hi,

    Thanks for sharing. But I still can't understand why I'm getting fatal error.

    I have few questions.

    By enabling 2Mbps PHY, where will the transfer speed increase, In an advertisement or in data transfer?

    Is there any example in the SDK with 2Mbps enabled in it?

    TIA.

  • I think you are getting the error because you are trying to advertise on 2mbps.

    Maybe you can try to advertise on 1mbps and when the connection is established, you can request a phy update and change to 2mbps for the connection.

    Br,
    Joakim

Related