This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840-DK - Long Range ,data rate 125Kbps

Hi

Please advise when I can find firmware for nRF52840-DK which can send advertising packets or any data packets at data rate 125Kbps and +8dBm output power

I have two nRF52840-DK one will be Central and the other is the Peripheral , the goal is range test .

Please advise.

Thanks

Parents Reply Children
  • Hi,

    It seem that now it work and when connection established both LED 1 are constant blink.

    How I can find in the code the power level and how you configure the data rate (125Kbps) in the code.

    Thanks

  • Hi, 

    You can find the code changes in the diff file included in the zip file. The output power is changed from its default value to +8dBm by the call to sd_ble_gap_tx_power_set() in ble_advertising_start, and the PHY is changed in advertising_init.

    diff --git a/examples/ble_central/ble_app_uart_c/main.c b/examples/ble_central/ble_app_uart_c/main.c
    index 5c6ffd5..c53297b 100644
    --- a/examples/ble_central/ble_app_uart_c/main.c
    +++ b/examples/ble_central/ble_app_uart_c/main.c
    @@ -116,6 +116,10 @@ static void scan_start(void)
     
         ret = bsp_indication_set(BSP_INDICATE_SCANNING);
         APP_ERROR_CHECK(ret);
    +
    +    //Optional: Change output power
    +    ret = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_SCAN_INIT, 0, 8);
    +    APP_ERROR_CHECK(ret);
     }
     
     
    @@ -164,13 +168,25 @@ static void scan_evt_handler(scan_evt_t const * p_scan_evt)
      */
     static void scan_init(void)
     {
    -    ret_code_t          err_code;
    -    nrf_ble_scan_init_t init_scan;
    +    ret_code_t            err_code;
    +    nrf_ble_scan_init_t   init_scan;
    +    ble_gap_scan_params_t scan_params;
    +
    +    memset(&scan_params, 0, sizeof(ble_gap_scan_params_t));
    +
    +    scan_params.active        = 1;
    +    scan_params.interval      = NRF_BLE_SCAN_SCAN_INTERVAL;
    +    scan_params.window        = NRF_BLE_SCAN_SCAN_WINDOW;
    +    scan_params.timeout       = NRF_BLE_SCAN_SCAN_DURATION;
    +    scan_params.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL;
    +    scan_params.scan_phys     = BLE_GAP_PHY_CODED;
    +    scan_params.extended      = true;
     
         memset(&init_scan, 0, sizeof(init_scan));
     
         init_scan.connect_if_match = true;
         init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;
    +    init_scan.p_scan_param     = &scan_params;
     
         err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
         APP_ERROR_CHECK(err_code);
    diff --git a/examples/ble_central/ble_app_uart_c/pca10056/s140/config/sdk_config.h b/examples/ble_central/ble_app_uart_c/pca10056/s140/config/sdk_config.h
    index bb9c621..8ff8018 100644
    --- a/examples/ble_central/ble_app_uart_c/pca10056/s140/config/sdk_config.h
    +++ b/examples/ble_central/ble_app_uart_c/pca10056/s140/config/sdk_config.h
    @@ -127,7 +127,7 @@
     #endif
     // <o> NRF_BLE_SCAN_BUFFER - Data length for an advertising set. 
     #ifndef NRF_BLE_SCAN_BUFFER
    -#define NRF_BLE_SCAN_BUFFER 31
    +#define NRF_BLE_SCAN_BUFFER 255
     #endif
     
     // <o> NRF_BLE_SCAN_NAME_MAX_LEN - Maximum size for the name to search in the advertisement report. 
    @@ -184,7 +184,7 @@
     // <255=> BLE_GAP_PHY_NOT_SET 
     
     #ifndef NRF_BLE_SCAN_SCAN_PHY
    -#define NRF_BLE_SCAN_SCAN_PHY 1
    +#define NRF_BLE_SCAN_SCAN_PHY 4
     #endif
     
     // <e> NRF_BLE_SCAN_FILTER_ENABLE - Enabling filters for the Scanning Module.
    @@ -12394,7 +12394,7 @@
     // <i> Requested BLE GAP data length to be negotiated.
     
     #ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
    -#define NRF_SDH_BLE_GAP_DATA_LENGTH 251
    +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27
     #endif
     
     // <o> NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. 
    @@ -12423,7 +12423,7 @@
     
     // <o> NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. 
     #ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
    -#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
    +#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23
     #endif
     
     // <o> NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. 
    diff --git a/examples/ble_peripheral/ble_app_uart/main.c b/examples/ble_peripheral/ble_app_uart/main.c
    index 4d40d21..a42a8c7 100644
    --- a/examples/ble_peripheral/ble_app_uart/main.c
    +++ b/examples/ble_peripheral/ble_app_uart/main.c
    @@ -616,12 +616,15 @@ static void advertising_init(void)
         init.advdata.include_appearance = false;
         init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
     
    -    init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    -    init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    -
    -    init.config.ble_adv_fast_enabled  = true;
    -    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    -    init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
    +    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    +    init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    +
    +    init.config.ble_adv_fast_enabled      = true;
    +    init.config.ble_adv_fast_interval     = APP_ADV_INTERVAL;
    +    init.config.ble_adv_fast_timeout      = APP_ADV_DURATION;
    +    init.config.ble_adv_primary_phy       = BLE_GAP_PHY_CODED;
    +    init.config.ble_adv_secondary_phy     = BLE_GAP_PHY_CODED;
    +    init.config.ble_adv_extended_enabled  = true;
         init.evt_handler = on_adv_evt;
     
         err_code = ble_advertising_init(&m_advertising, &init);
    @@ -687,6 +690,10 @@ static void advertising_start(void)
     {
         uint32_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
         APP_ERROR_CHECK(err_code);
    +
    +    //Optional: Change output power
    +    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, 8);
    +    APP_ERROR_CHECK(err_code);
     }
     
     

  • Hi,

    Unfortunately I`m not software expert so I need to verify ,if I want to change the power i need to do it by changing the number "8" below? 

    + err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, 8);

    Do you know if this firmware (8dBm,125Kbps you offer is fit to achieve the best range between the boards? 

    Thanks

  • Hi,

    Yes, it will set the output power to +8dBm.  I can't think of any other SW changes that would improve range. 

Related