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? 

  • 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。

  •  

    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

  • Edvin said:

    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 please elaborate. Did you change any parameters before the call that fails, or is it called with the exact same parameters? Try to print them out in the log if you are not sure. 

  • hi 

    I want to ask a question: are the documents released by your mesh SDK correct?My project has been sent to you. You can debug it. I'm also looking for the reason. I'm saying it again:

    err_ code = sd_ ble_ opt_ set(BLE_ COMMON_ OPT_ PA_ LNA, &ble_ Pa_ lna_ opts);

    err_ code =0x00,

    err_ code=mesh_ Pa_ lna_ gpiote_ enable(&m_ Pa_ lna_ params);

    err_ code = 0x07.

    It's mesh_ Pa_ lna_ gpiote_ Enable call problem.

    I mean, there's something wrong with the PA / LNA documents you released.

  • I want to make sure one thing: mesh_ Pa_ lna_ gpiote_ Enable, whether it only supports port P0 and does not support port P1.

Reply Children
  • zhao.yangyang said:
    are the documents released by your mesh SDK correct?

     I assume it is. Was there something specific you had in mind?

     

    zhao.yangyang said:
    My project has been sent to you.

     I know that you sent me the project, but you didn't answer my questions. Unfortunately, we are very short staffed here in Norway due to summer holidays, which is why I want you to test yourself. I can try to run your project later when I have decreased my queue a bit. Sorry for the inconvenience, but I hope that you understand that if I need to spend a lot of time on one ticket, then there are several other tickets that will not be answered.

    Best regards,

    Edvin

  • It looks like your suspicion is correct. The reason your call to mesh_pa_lna_gpiote_enable() returns NRF_ERROR_INVALID_PARAMS is because your .lna_cfg.gpio_pin and .pa_cfg.gpio_pin are too high, and the checks:

    (p_params->lna_cfg.gpio_pin >= ARRAY_SIZE(NRF_GPIO->PIN_CNF)) ||
    (p_params->pa_cfg.gpio_pin >= ARRAY_SIZE(NRF_GPIO->PIN_CNF)))

    in mesh_pa_lna_gpiote_enable() will fail.

    This parameter, mesh_pa_lna_gpiote_params_t doesn't take port number. Perhaps you can try to add it:

    typedef struct
    {
         uint8_t enable :1;      /**< Enable toggling for this amplifier */
         uint8_t active_high :1; /**< Set the pin to be active high */
         uint8_t gpio_pin :6;    /**< The GPIO pin to toggle for this amplifier */
         uint8_t port_number;    /**< The port number for the GPIO */
    } ble_pa_lna_cfg_t;

    Then set your m_pa_lna_params accordingly:

    static mesh_pa_lna_gpiote_params_t m_pa_lna_params = {
            .lna_cfg = {
                .enable = 1,
                .active_high = 1,
                .gpio_pin = 3,
                .port_number = 1
            },
            .pa_cfg = {
                .enable = 1,
                .active_high = 1,
                .gpio_pin = 5,
                .port_number = 1
            },
            .ppi_ch_id_set = 0,
            .ppi_ch_id_clr = 1,
            .gpiote_ch_id = 0
        };

    And finally, in your pin_init:

    static void pin_init(const ble_pa_lna_cfg_t * p_cfg)
    {
        NRF_MESH_ASSERT(p_cfg->port_number == 0 || p_cfg->port_number == 1);
        NRF_GPIO_Type * port;
        if (p_cfg->port_number == 0)
        {
            port = NRF_P0;
        }
        else if (p_cfg->port_number == 1)
        {
            port = NRF_P1;
        }
        if (p_cfg->enable)
        {
            port->PIN_CNF[p_cfg->gpio_pin] =
                ((uint32_t) GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos) |
                ((uint32_t) GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) |
                ((uint32_t) GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
                ((uint32_t) GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) |
                ((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
            port->DIRSET = (GPIO_DIRSET_PIN0_Output << (GPIO_DIRSET_PIN0_Pos + p_cfg->gpio_pin));
            pin_clear(p_cfg);
        }
    }

    Does that work?

  • 1. It doesn't work.Now the call call returns return = 0; however, according to the phenomenon of the RSSI value of NRF connect, it has no effect.

    2.I have annotated out this condition. It has an effect. But I'm not sure it's right.

    // (p_params->lna_cfg.gpio_pin >= ARRAY_SIZE(NRF_GPIO->PIN_CNF)) ||
    //(p_params->pa_cfg.gpio_pin >= ARRAY_SIZE(NRF_GPIO->PIN_CNF)))

  • zhao.yangyang said:

    2.I have annotated out this condition. It has an effect. But I'm not sure it's right.

    // (p_params->lna_cfg.gpio_pin >= ARRAY_SIZE(NRF_GPIO->PIN_CNF)) ||
    //(p_params->pa_cfg.gpio_pin >= ARRAY_SIZE(NRF_GPIO->PIN_CNF)))

     That will only disable the check that would return the error. If the input parameters is still wrong, and you disable this check, you don't know what sort of behaviour you can expect. You start writing to registers unintentionally. I would not recommend that. 

    Did you double check the pin numbers I suggested? I believe they may be off by one. In the above suggestion, if you want to use pin. It originally said pin 34 and pin 36. I guess that would translate to P1.02 and P1.04, not P1.03 and P1.05, as I wrote (I forgot the 0-indexing). 

    You say that it doesn't work. Have you tried to use any of the pins from P0? Does it work then?

  • I've tried. Neither P1.02/P1.04 nor  P1.03/P1.05 works. I need your help. The PA pin of our hardware design is P1.02/P1.04, please provide a correct method. By the way, don't forget that in mesh project, PA's enabling needs to call three interfaces, and there is also a non open source protocol stack. Please, we need to make products. I'm looking forward to your reply. If P1 does not support PA settings, you can directly say no, we can adjust the next step.

Related