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

Stop ble_app_uart connection with ble_app_uart_c

I am using: \examples\ble_peripheral\ble_app_uart  and  \examples\ble_central\ble_app_uart_c  .

In Nordic infocenter it says: The application scans peripheral devices and connects to a device that advertises with the NUS UUID in its advertisement report.

The questions are: 

1- Is this type of connection similar to a pairing where a key exchange occurs and connection is encrypted between peripheral and central?

2- How can I modify \examples\ble_peripheral\ble_app_uart code to drop the connection and reconnect periodically (for power saving) .

Parents
  • Hello,

    1. Pairing is a procedure that's performed after a connection is established to secure the connection. But pairing is not supported by the NUS example which means the link will always be unencrypted. The SDK examples that support BLE security include the Peer Manager module.

    2. You can use the low-power Timer library to trigger periodic events to start connectable advertising and/or terminate a connection.

    Softdevice function to terminate a connection:

                err_code = sd_ble_gap_disconnect(conn_handle,
                                                 BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);

    Required change in advertising_init() to prevent the advertising module from automatically re-starting connectable advertising on disconnect:

    /**@brief Function for initializing the Advertising functionality.
     */
    static void advertising_init(void)
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        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;
        /* Don't restart advertising on discoonect */
        init.config.ble_adv_on_disconnect_disabled = true; 
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

  • Thanks Vidar. Is there any example that implements peer manager modules? 

    if NUS does not work with encryption and peer manager, how do I trans/receive data after encryption implementation? Which SDK modules I can use to communicate data between my two devices after connection encryption? 

Reply Children
Related