[NUS, Bluetooth] bt_conn

Hello,

I am programming BLE with the nRF52840-DK. [Toolchain Manager: v1.3.0, IDE: Visual Studio Code (VSCode), SDK: ncs v2.6.0, window11 pro]

I am using NUS to work with Bluetooth. I am programming new code by looking at the examples peripheral_uart and central_uart. I have a question about the variable bt_conn (in 'conn_internal.h') that exists in the examples peripheral_uart and central_uart

  1. Is the bt_conn (in 'conn_internal.h') variable the information of the currently connected Bluetooth device, or is it the information of the Bluetooth device that holds this code? (
  2. The code below is the callback function code for connected in peripheral_uart. At this time, info.role is output as peripheral. I am confused whether the function bt_conn_get_info(conn, &info) puts the information of the Bluetooth device connected to conn into info or if it puts the Bluetooth information of conn into info."
    static void connected(struct bt_conn *conn, uint8_t err){
    	char addr[BT_ADDR_LE_STR_LEN];
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    	if (err) {
    		LOG_INF("connected - connected: Connection failed (err %u)", err);
    		return;
    	}
    	LOG_INF("connected - Connected %s", addr);
    	current_conn = bt_conn_ref(conn);
    	struct bt_conn_info info = {0};
    	err = bt_conn_get_info(conn, &info);
    	LOG_INF("connected - bt_conn_get_info >>> err:%d", err);
    	LOG_INF("connected - Connected as %s", info.role == BT_CONN_ROLE_CENTRAL ? "central" : "peripheral");
    	LOG_INF("connected - Conn. interval is %u units", info.le.interval);
    }
    
    static struct bt_conn_cb conn_callbacks = {
    	.connected    = connected,
    	.disconnected = disconnected,
    	.security_changed = security_changed,
    	.le_param_updated = le_param_updated,
    	.le_data_len_updated = le_data_length_updated,
    	.le_phy_updated =  le_phy_updated,
    };
    
Related