I am using SDK15.2 with NRF52840-DK.
I want to use BLE5 long range Advertising features on NRF52840. and scan the advertisement on another side with a long distance seperated
I change something based on the ble_app_att_mtu_throughput example.
On the peripheral side, I change the advertising_data_set() as belows:
- change the type to BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED
- change .primary_phy and .secondary_phy to BLE_GAP_PHY_CODED
static void advertising_data_set(void)
{
ret_code_t ret;
ble_gap_adv_params_t const adv_params =
{
.properties =
{
.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED,
},
.p_peer_addr = NULL,
.filter_policy = BLE_GAP_ADV_FP_ANY,
.interval = 50, //ADV_INTERVAL,
.duration = 0,
.primary_phy = BLE_GAP_PHY_CODED,// BLE_GAP_PHY_1MBPS, // Must be changed to connect in long range. (BLE_GAP_PHY_CODED)
.secondary_phy = BLE_GAP_PHY_CODED,
};
ble_advdata_t const adv_data =
{
.name_type = BLE_ADVDATA_FULL_NAME,
.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE,
.include_appearance = false,
};
ret = ble_advdata_encode(&adv_data, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
APP_ERROR_CHECK(ret);
ret = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
APP_ERROR_CHECK(ret);
}
On the Central side, I change the scan as belows:
static void scan_init(void)
{
ret_code_t err_code;
m_scan.scan_params.extended = 1;
m_scan.scan_params.active = 1;
m_scan.scan_params.interval = 20;
m_scan.scan_params.window = 20;
m_scan.scan_params.scan_phys = BLE_GAP_PHY_CODED ;
m_scan.scan_params.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL;
m_scan.scan_params.timeout = 0;
err_code = nrf_ble_scan_init(&m_scan, NULL, scan_evt_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_ble_scan_filter_set(&m_scan,
SCAN_NAME_FILTER, m_target_periph_name);
APP_ERROR_CHECK(err_code);
err_code = nrf_ble_scan_filters_enable(&m_scan,
NRF_BLE_SCAN_NAME_FILTER,
false);
APP_ERROR_CHECK(err_code);
}
Problem:
The problem is that I receive nothing on the central side.
If I change the the advertising setting as:
.primary_phy = BLE_GAP_PHY_1MBPS,
.secondary_phy = BLE_GAP_PHY_CODED,.
Then the connection can be built. but the received distance is not x4 length as what I expected by using PHY_CODED.
I check the rssi are the same at the same distance.
Is there any thing wrong on me setting? which side?
I just need to have a long range beacon which can be scanned on the other side for a long distance.
Thank you.