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

how to enable pa/lna about mesh on nrf5_SDK_for_Mesh_v4.1.0_src ?

HI ,

   

1.
'''
    ble_stack_init();
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &ble_pa_lna_opts);
    APP_ERROR_CHECK(err_code);

#if MESH_FEATURE_GATT_ENABLED
    gap_params_init();
    conn_params_init();
#endif

    mesh_init();
    mesh_pa_lna_gpiote_enable(&m_pa_lna_params);
```

2.
```
static void provisioning_sd_ble_opt_cb()
{
    uint32_t err_code;
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &ble_pa_lna_opts);
    APP_ERROR_CHECK(err_code);
}

static void start(void)
{
    rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);

    if (!m_device_provisioned)
    {
        static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
        mesh_provisionee_start_params_t prov_start_params =
        {
            .p_static_data    = static_auth_data,
            .prov_sd_ble_opt_set_cb = provisioning_sd_ble_opt_cb,
            .prov_complete_cb = provisioning_complete_cb,
            .prov_device_identification_start_cb = device_identification_start_cb,
            .prov_device_identification_stop_cb = NULL,
            .prov_abort_cb = provisioning_aborted_cb,
            .p_device_uri = EX_URI_LS_SERVER
        };
        ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
    }
    else
    {
        unicast_address_print();
    }

    mesh_app_uuid_print(nrf_mesh_configure_device_uuid_get());

    ERROR_CHECK(mesh_stack_start());

    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);

    hal_led_mask_set(LEDS_MASK, LED_MASK_STATE_OFF);
    hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_START);
}
````

I set PA / LNA in the following way. I found that when the device is connected, it will be disconnected and will no longer be connected. How to set PA / LNA correctly?During the development process, I found that Nordic mesh was particularly unstable. We were developing products and were very worried.

Parents
  • Hi,

    I found that when the device is connected, it will be disconnected and will no longer be connected.

    Could you give me more details? Do you get any error codes when debugging?

    Which example are you using from the SDK? Have you made any other modifications other than for the PA/LNA?

    Are you using a custom board or a DK? Which device are you using?

    I recommend you take a look at the documentation for the PA/LNA Module in Mesh.

    During the development process, I found that Nordic mesh was particularly unstable.

    Could you elaborate on what you mean by unstable? 

Reply
  • Hi,

    I found that when the device is connected, it will be disconnected and will no longer be connected.

    Could you give me more details? Do you get any error codes when debugging?

    Which example are you using from the SDK? Have you made any other modifications other than for the PA/LNA?

    Are you using a custom board or a DK? Which device are you using?

    I recommend you take a look at the documentation for the PA/LNA Module in Mesh.

    During the development process, I found that Nordic mesh was particularly unstable.

    Could you elaborate on what you mean by unstable? 

Children
  • hi,I set PA / LNA as follows:(pa=P1.04
    ···
    
    #include "mesh_pa_lna.h"
    
    static mesh_pa_lna_gpiote_params_t m_pa_lna_params = {
    
    .lna_cfg = {
    
    .enable = 1,
    
    .active_high = 1,
    
    .gpio_pin = 34
    
    },
    
    .pa_cfg = {
    
    .enable = 1,
    
    .active_high = 1,
    
    .gpio_pin = 36
    
    },
    
    .ppi_ch_id_set = 0,
    
    .ppi_ch_id_clr = 1,
    
    .gpiote_ch_id = 0
    
    };
    
    static ble_opt_t ble_pa_lna_opts = {
    
    .common_opt = {
    
    .pa_lna = {
    
    .pa_cfg = {
    
    .enable = 1,
    
    .active_high = 1,
    
    .gpio_pin = 36
    
    },
    
    .lna_cfg = {
    
    .enable = 1,
    
    .active_high = 1,
    
    .gpio_pin = 34
    
    },
    
    .ppi_ch_id_set = 0,
    
    .ppi_ch_id_clr = 1,
    
    .gpiote_ch_id = 0
    
    }
    
    }
    
    };
    
    //
    
    
    
    //
    static void initialize(void)
    {
    __LOG_INIT(LOG_SRC_APP | LOG_SRC_FRIEND, LOG_LEVEL_DBG1, LOG_CALLBACK_DEFAULT);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- BLE Mesh Light Switch Server Demo -----\n");
    
    uint32_t err_code;
    
    ERROR_CHECK(app_timer_init());
    hal_leds_init();
    
    #if BUTTON_BOARD
    ERROR_CHECK(hal_buttons_init(button_event_handler));
    #endif
    
    
    ble_stack_init();
    
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &ble_pa_lna_opts);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "ble_pa_lna ret: %d\n",err_code);
    APP_ERROR_CHECK(err_code);
    
    #if MESH_FEATURE_GATT_ENABLED
    gap_params_init();
    conn_params_init();
    #endif
    
    
    mesh_init();
    err_code=mesh_pa_lna_gpiote_enable(&m_pa_lna_params);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "mesh_pa_lna ret: %d\n",err_code);
    APP_ERROR_CHECK(err_code);
    }
    
    
    static void provisioning_sd_ble_opt_cb()
    {
    uint32_t err_code;
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &ble_pa_lna_opts);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "provision pa_lna_set ret: %d\n",err_code);
    APP_ERROR_CHECK(err_code);
    }
    
    static void start(void)
    {
    rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
    
    if (!m_device_provisioned)
    {
    static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
    mesh_provisionee_start_params_t prov_start_params =
    {
    .p_static_data = static_auth_data,
    .prov_sd_ble_opt_set_cb = provisioning_sd_ble_opt_cb,//NULL,
    .prov_complete_cb = provisioning_complete_cb,
    .prov_device_identification_start_cb = device_identification_start_cb,
    .prov_device_identification_stop_cb = NULL,
    .prov_abort_cb = provisioning_aborted_cb,
    .p_device_uri = EX_URI_LS_SERVER
    };
    ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
    }
    else
    {
    unicast_address_print();
    }
    
    mesh_app_uuid_print(nrf_mesh_configure_device_uuid_get());
    
    ERROR_CHECK(mesh_stack_start());
    
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
    
    hal_led_mask_set(LEDS_MASK, LED_MASK_STATE_OFF);
    hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_START);
    }
    
    //
    ,lna=P1.02 on ours 52840 hw),
    but the err_code=mesh_pa_lna_gpiote_enable(&m_pa_lna_params); return err_code=7, Obviously not。

  • Hello,

    Mttrinh is currently out of office, so I'll handle this ticket for you.

    We are currently very low staffed due to summer holidays, so I have not tried to replicate the issue you are seeing. Your call to sd_ble_opt_set() returns 0x07, which means NRF_ERROR_INVALID_PARAM, so you are using some sort of invalid combination. Have you tried to debug to check that your ble_pa_lna_opts are set correctly (as you think they are supposed to be set)? I am not sure about your initialization of it. 

    Do`you use the same configuration the first time you set it ("ble_pa_lna ret: 0") or do you change the parameters between the two calls?

    BR,

    Edvin

  • hello,

    I used the same configuration for the two calls, as shown below

    # PA/LNA module

    The nRF5 SDK for Mesh provides a PA/LNA module with APIs for interfacing the external Front End Modules
    (FEMs) to increase the range of Bluetooth Low Energy communication.

    The FEMs are controlled by the enable signals that turn on a power amplifier (PA) or
    a low noise amplifier (LNA) (see the following figure). To ensure sufficient ramp-up time,
    these signals must be activated some time before the start of the radio transmission or reception.

    @anchor pa-lna-Figure1
    ![Interfacing PA/LNA with an nRF52 device](images/pa-lna-block-dia.svg "Interfacing PA/LNA with an nRF52 device")

    The Mesh PA/LNA module enables users to control such external components using GPIOs
    that are synchronized to the radio operation. The PA/LNA module drives the chosen GPIO pins
    according to the chosen polarity (Active High/Active Low).

    See the following section for an example of how to use the PA/LNA module.
    You can find more information about the available APIs
    in the [PA/LNA API documentation](@ref MESH_PA_LNA).

    The Mesh PA/LNA module works with all the [fully compatible configurations based on nRF52 devices](@ref compatibility_list).

    ---

    ## Adding PA/LNA support to the application @anchor pa-lna_adding_support

    This section describes how to add PA/LNA support to the `light_switch/server` example.
    For more information about this example, see @ref md_examples_light_switch_README
    and @ref md_examples_light_switch_server_README.

    To add the PA/LNA support, complete the steps in the following subsections:
    - [Selecting GPIO pins and PPI channels](@ref pa-lna_adding_support_pins_channels)
    - [Editing the main.c file](@ref pa-lna_adding_support_main)
    - [Running the example and observing the results](@ref pa-lna_adding_support_running)

    ### Selecting GPIO pins and PPI channels @anchor pa-lna_adding_support_pins_channels

    Complete the following steps:

    -# Select the unused GPIO pins that can be used by the PA/LNA module.
    - For this example, use GPIO 25 for controlling the LNA and GPIO 24 for controlling the PA.
    - Also, assume that the control signals required by the external hardware module are Active High.
    The Mesh PA/LNA module uses the PPI and GPIOTE hardware modules to generate these signals.
    To read more about these modules in nRF52832, see the following documents: @link_52832_PPI and @link_52832_GPIOTE .
    -# Select the unused PPI channels 0 and 1, and the GPIOTE channel 0.

    ### Editing the main.c file @anchor pa-lna_adding_support_main

    Make the following changes in `light_switch/server/src/main.c`:

    -# Include the required module header file: `mesh_pa_lna.h`
    -# Create a static global variable of type @ref mesh_pa_lna_gpiote_params_t and initialize it
    with the selected values:
    ```
    static mesh_pa_lna_gpiote_params_t m_pa_lna_params = {
    .lna_cfg = {
    .enable = 1,
    .active_high = 1,
    .gpio_pin = 25
    },
    .pa_cfg = {
    .enable = 1,
    .active_high = 1,
    .gpio_pin = 24
    },
    .ppi_ch_id_set = 0,
    .ppi_ch_id_clr = 1,
    .gpiote_ch_id = 0
    };
    ```
    -# Enable the PA/LNA module by calling @ref mesh_pa_lna_gpiote_enable() after the call to
    `mesh_init()`:

    mesh_pa_lna_gpiote_enable(&m_pa_lna_params);
    -# Enable the PA/LNA module in the BLE stack by completing the following steps:
    -# Create a static global variable of type @link_ble_opt_t.
    You can use the same GPIO pins and the same PPI and GPIO channels as for
    Mesh PA/LNA configuration:
    ```
    static ble_opt_t ble_pa_lna_opts = {
    .common_opt = {
    .pa_lna = {
    .pa_cfg = {
    .enable = 1,
    .active_high = 1,
    .gpio_pin = 24
    },
    .lna_cfg = {
    .enable = 1,
    .active_high = 1,
    .gpio_pin = 25
    },
    .ppi_ch_id_set = 0,
    .ppi_ch_id_clr = 1,
    .gpiote_ch_id = 0
    }
    }
    };
    ```
    -# Call @link_sd_ble_opt_set function before the call to `mesh_init()`:
    ```
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &ble_pa_lna_opts);
    APP_ERROR_CHECK(err_code);
    ```
    -# If @ref MESH_PROVISIONEE is used, implement @ref mesh_provisionee_start_params_t.prov_sd_ble_opt_set_cb
    callback and call @link_sd_ble_opt_set in the callback:
    ```
    static void provisioning_sd_ble_opt_cb()
    {
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &ble_pa_lna_opts);
    APP_ERROR_CHECK(err_code);
    }

    ...

    static void start(void)
    {
    rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);

    if (!m_device_provisioned)
    {
    static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
    mesh_provisionee_start_params_t prov_start_params =
    {
    .p_static_data = static_auth_data,
    .prov_sd_ble_opt_set_cb = provisioning_sd_ble_opt_cb,
    .prov_complete_cb = provisioning_complete_cb,
    .prov_device_identification_start_cb = device_identification_start_cb,
    .prov_device_identification_stop_cb = NULL,
    .prov_abort_cb = provisioning_aborted_cb,
    .p_device_uri = EX_URI_LS_SERVER
    };
    ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
    }

    ...
    }
    ```
    This is required to restore the PA/LNA configuration in the BLE stack after it is
    restarted during the provisioning when [PB GATT feature](@ref MESH_FEATURE_PB_GATT_ENABLED)
    is enabled.


    ### Running the example and observing the results @anchor pa-lna_adding_support_running

    Complete the following steps:

    -# Build the example by following the instructions in @ref md_doc_getting_started_how_to_build.
    -# Run the example by following the instructions in @ref md_doc_getting_started_how_to_build
    for [commands required to program a device using `nrfjprog`](@ref how_to_run_examples_nrfjprog).

    If you connect a logic analyzer to the GPIO pins 25 and 24, you will see them toggling.

    The unprovisioned device sends the unprovisioned node beacons every
    two seconds (@ref NRF_MESH_PROV_BEARER_ADV_UNPROV_BEACON_INTERVAL_MS) and scans for
    the incoming provisioning invite for the rest of the time.

    ![GPIO waveforms after enabling PA/LNA module](images/pa-lna-waveform.png "GPIO waveforms after enabling PA/LNA module")

    You will see brief Active High pulses on the GPIO pin 24, which is used for the PA control.
    Similarly, the GPIO pin 25 (used for the LNA control) is almost always ON,
    except for the time when the radio switches to the next advertising channel for scanning
    or for sending advertisements.

  •  

    Edvin said:

    Your call to sd_ble_opt_set() returns 0x07, which means NRF_ERROR_INVALID_PARAM, so you are using some sort of invalid combination. Have you tried to debug to check that your ble_pa_lna_opts are set correctly (as you think they are supposed to be set)? I am not sure about your initialization of it. 

    Do`you use the same configuration the first time you set it ("ble_pa_lna ret: 0") or do you change the parameters between the two calls?

     

    Can you zip the project folders so that I can unzip them in an unmodified SDK and reproduce what you are seeing? I am sorry, but we are very low on staffing, so I can't take time to configure and tweak the examples myself.

    Please try to unzip your projects in an unmodified SDK and make sure that they are compiling and the issue is recreated before uploading them here. 

    BR,

    Edvin

  • hi,Attached is my project. In addition to PA, I have another question about my user-defined data. At present, only 25 bytes can be accessed. We want to achieve 256 bytes, but there is an error due to incorrect partition.light_switch_flash.rar

Related