Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

how to keep connecting after reset or power-up cycle nrf52840?

Good morning nordic team,

I use BLE app HID Keyboard with softdevice 7.2.0, nRF5 SDK 17.1.0 and for the hardware I use nrf52840's SoC. The connecting and disconnecting well works. My issue rises when I reset the SoC with reset pin or a power-up cycle because battery depleted. The master (smartphone or computer) is connected always and in my application i lauch advertising_start() with the parameter "erase_bonds"! I think that I make the wrong things !

Maybe before deleting the links using the advertising_start(erase_bond) function, I need to know if I'm paired with a master and if there's a connection attempt ?

1) I would like to know how to reconnect me because the smartphone try to reconnect ?


2) Do you have a tutorial for best understand the process of adverting, pairing, connecting, reconnnecting, unpair for BLE because it's a misunderstanding of the BLE software stack !

below the main() function:

/**@brief Function for application main entry.
*/
int main(void)
{
bool erase_bonds;

// Initialize.
#ifdef AT_DBG
uart_init();
#endif
gestion_cmd_init();

log_init();
timers_init();
buttons_leds_init(&erase_bonds);
power_management_init();
ble_stack_init();
scheduler_init();
gap_params_init();
gatt_init();
advertising_init();
services_init();
sensor_simulator_init();
conn_params_init();
buffer_init();
peer_manager_init();

// Start execution.
send_trame_asyn(ASYN_MODULE_STATUS, LEN_STRING_STATUS_RADIO_MODULE, str_event_RST_RADIO_MODULE);
strncpy((char *)&value_status_ble, RST_RADIO_MODULE, 1);
transmission_send_trame_asyn();

NRF_LOG_INFO("HID Keyboard example started.");
timers_start();
advertising_start(erase_bonds);

// Enter main loop.
for (;;)
{
idle_state_handle();
}
}

Thanks for help

alexandre

Parents Reply Children
  • Hi,

    alexandre trilles said:

    I don't see the log with J-Link RTT logger V7.80C.

    Do I have an extra special configuration ?

    Make sure that NRF_LOG_BACKEND_RTT_ENABLED in sdk_config.h is set to 1

    I see in your RTT viewer window that you lost connection. In that case, try to connect again:

  • Dear Sigurd,

    I find how to enable RTT, it's OK. I do several tests. 

    I manage to connect to 8 masters (smartphones or PC) and the peer_id value goes from 0 to 7. It's OK,  I'd like to know how to prevent connection to the 9 masters? The idea is that automatically,  this ninth device becomes the peer_id = 0 ?

    in the function "whitelist_set" I can see the nnumbers of peers --> peer_id_count. But I don't find one function for prohibit the connection request ?

    static void whitelist_set(pm_peer_id_list_skip_t skip)
    {
    pm_peer_id_t peer_ids[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
    uint32_t peer_id_count = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;

    ret_code_t err_code = pm_peer_id_list(peer_ids, &peer_id_count, PM_PEER_ID_INVALID, skip);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_INFO("\tm_whitelist_peer_cnt %d, MAX_PEERS_WLIST %d",
    peer_id_count + 1,
    BLE_GAP_WHITELIST_ADDR_MAX_COUNT);

    err_code = pm_whitelist_set(peer_ids, peer_id_count);
    APP_ERROR_CHECK(err_code);
    }

    Can you tell me where to look ?

    Thanks

    Alexandre

  • Dear Sigurd,

    I would like used the pin "P1.01" for NRF LOG BACKEND UART, because P0.06 (TX) and P0.08(RX) are used to communicate with a external MCU.

    I find in the sdk_config.h the #define NRF_LOG_BACKEND_UART_TX_PIN 6 but not information how to changed port 0 to port 1 in  the sdk_config.h ? could you indicate me where look for ? 

    thanks 

    Alexandre

  • Dear Sigurd,

    I find how to used the pin1.01, I have just to change in the skd_config.h 

    #define NRF_LOG_BACKEND_UART_TX_PIN 33

    UART pins are configured in the "nrfx_uarte.c" function, which uses the "apply_config(p_instance, p_config)" function.

    but I couldn't find how to connected only 8 masters and especially forbid the ninth master ?

    I repeat idea: My application HID Keyboard BLE connecte to 8 masters (computer or smartphone) the peer_id increase to 0 to 7 and if a ninth master want to pair then I erase bond. But before erase bond I want to forbid ninth's pairing!

    thanks for help

    Alexandre

Related