nrf52840 capture security level negotiation

I am using a nrf52840 dongle. I have my own device which has BLE and I am connecting to an app in mobile phone our bluetooth. My goal is to check for the security level what my device has and when it's getting connected with app I was trying to find if there is any security negotiation. To check this I am using the nrf52840 dongle for bluetooth sniffing so that I can check for the security negotiation. 

Based on this link I followed all the steps https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-6-bluetooth-le-sniffer/topic/nrf-sniffer-for-bluetooth-le/

I have flashed firmware 4.1.1 version. 

I get the PDU type as 0x08 

In documentation there is nothing referencing to Packet ID 0x08. It says security level error and CRC is bad wanted to understand more on this.

Also how to check for security level negotiation which packet should I look for specifically? Also with the firmware version 4.1.1 can I get to know the security negotiation?

  • Hi, 
    Please send the whole sniffer trace. 
    I would suggest to follow the exercises in the academy course. Exercise 3 would walk you through inspecting a pairing process. 
    When a packet has CRC failure the content of the packet is not reliable and should be ignored unless you know that it's actually correct. 

  • Could you please share the link to that Exercise 3

  • #include <stdint.h>
    #include <string.h>
    #include "nordic_common.h"
    #include "nrf.h"
    #include "ble.h"
    #include "ble_hci.h"
    #include "ble_srv_common.h"
    #include "ble_advdata.h"
    #include "ble_advertising.h"
    #include "ble_conn_params.h"
    #include "nrf_sdh.h"
    #include "nrf_sdh_ble.h"
    #include "app_timer.h"
    #include "bsp_btn_ble.h"
    #include "nrf_ble_gatt.h"
    #include "nrf_ble_qwr.h"
    #include "app_util_platform.h"
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    #include "app_error.h"
    
    #define APP_BLE_CONN_CFG_TAG            1
    #define APP_BLE_OBSERVER_PRIO           3
    
    NRF_BLE_GATT_DEF(m_gatt);
    NRF_BLE_QWR_DEF(m_qwr);
    
    static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID;
    
    void get_security_level(uint16_t conn_handle)
    {
        ret_code_t err_code;
        ble_gap_conn_sec_t conn_sec;
    
        err_code = sd_ble_gap_conn_sec_get(conn_handle, &conn_sec);
        if (err_code == NRF_SUCCESS)
        {
            NRF_LOG_INFO("Security Mode: %d, Security Level: %d",
                         conn_sec.sec_mode.sm, conn_sec.sec_mode.lv);
        }
        else
        {
            NRF_LOG_ERROR("Failed to get security level, error code: %d", err_code);
        }
    }
    
    static void on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
    {
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                NRF_LOG_INFO("Connected");
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                get_security_level(m_conn_handle);
                break;
    
            case BLE_GAP_EVT_DISCONNECTED:
                NRF_LOG_INFO("Disconnected");
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
                break;
    
            default:
                break;
        }
    }
    
    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        on_ble_evt(p_ble_evt, p_context);
    }
    
    static void ble_stack_init(void)
    {
        ret_code_t err_code;
    
        err_code = nrf_sdh_enable_request();
        APP_ERROR_CHECK(err_code);
    
        uint32_t ram_start = 0;
        err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_sdh_ble_enable(&ram_start);
        APP_ERROR_CHECK(err_code);
    
        NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
    }
    
    int main(void)
    {
        ret_code_t err_code;
    
        err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
    
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        ble_stack_init();
    
        while (true)
        {
            NRF_LOG_FLUSH();
            __WFE();
        }
    }


    Also I have a firmware code with me in which I have integrated the nrf5 17 version SDK but I am facing quite a few issues when I build I get the following issues,

    error: undefined symbol __app_ram_start__ referenced by symbol nrf_sdh_ble_app_ram_start_get (section .text.nrf_sdh_ble_app_ram_start_get in file nrf_sdh_ble.o)
    error: undefined symbol __start_log_const_data referenced by symbol nrf_sdh_ble_default_cfg_set (section .text.nrf_sdh_ble_default_cfg_set in file nrf_sdh_ble.o)
    error: undefined symbol __start_log_dynamic_data referenced by symbol module_idx_get (section .text.module_idx_get in file nrf_log_frontend.o)
    error: undefined symbol __start_sdh_req_observers referenced by symbol sdh_req_observers (section .rodata.sdh_req_observers in file nrf_sdh.o)
    error: undefined symbol __start_sdh_stack_observers referenced by symbol sdh_stack_observers (section .rodata.sdh_stack_observers in file nrf_sdh.o)
    error: undefined symbol __start_sdh_state_observers referenced by symbol sdh_state_observers (section .rodata.sdh_state_observers in file nrf_sdh.o)
    error: undefined symbol __stop_log_const_data referenced by symbol nrf_log_init (section .text.nrf_log_init in file nrf_log_frontend.o)
    error: undefined symbol __stop_sdh_req_observers referenced by symbol sdh_req_observers (section .rodata.sdh_req_observers in file nrf_sdh.o)
    error: undefined symbol __stop_sdh_stack_observers referenced by symbol sdh_stack_observers (section .rodata.sdh_stack_observers in file nrf_sdh.o)
    error: undefined symbol __stop_sdh_state_observers referenced by symbol sdh_state_observers (section .rodata.sdh_state_observers in file nrf_sdh.o)
    error: undefined symbol app_error_handler referenced by symbol uart_init (section .text.uart_init in file nrf_log_backend_uart.o)
    error: undefined symbol nrfx_uart_init referenced by symbol nrf_drv_uart_init (section .text.nrf_drv_uart_init in file nrf_drv_uart.o)
    error: undefined symbol nrfx_uart_tx referenced by symbol nrf_drv_uart_tx (section .text.nrf_drv_uart_tx in file nrf_log_backend_uart.o)
    error: undefined symbol nrfx_uart_uninit referenced by symbol nrf_drv_uart_uninit (section .text.nrf_drv_uart_uninit in file nrf_log_backend_uart.o)
    error: undefined symbol nrfx_uarte_init referenced by symbol nrf_drv_uart_init (section .text.nrf_drv_uart_init in file nrf_drv_uart.o)
    error: undefined symbol nrfx_uarte_tx referenced by symbol nrf_drv_uart_tx (section .text.nrf_drv_uart_tx in file nrf_log_backend_uart.o)
    error: undefined symbol nrfx_uarte_uninit referenced by symbol nrf_drv_uart_uninit (section .text.nrf_drv_uart_uninit in file nrf_log_backend_uart.o)


    Could you please let me know how to resolve these issues

  • Hi, 
    Please create a new ticket for this. Please provide more information on how you integrate the code and from which example you copy it from. It seems that you are missing some config and include folder. But please create a new ticket. 

Related