Nordic Developer Academy BLE NUS Example with Pairing and Bonding: various problems

Hi Support Team,

I am encountering various problems with the Developer Academy example found here:

https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-4-bluetooth-le-data-exchange/topic/blefund-lesson-4-exercise-3/

1. Unable to debug without GATT errors

To overcome this issue I used logging but:

2. Logging is not working. None of the LOG directives is working

The cause why I need this is:

3. I set CONFIG_BT_NUS_SECURITY_ENABLED=y but nothing happend - security is not working

Could you tell me at least how to get the security in the example working?

Also logging is needed

Many thanks in advance.

Regards, Andreas

Parents
  • Could you tell me at least how to get the security in the example working?

    For guidance setting up security (pairing and bonding), I would recommend checking out Lesson 5 – Security in Bluetooth LE communication.

    If you have specific questions as you work through these excercises, feel free to reach out, and we'll be happy to assist further.

  • Hi Helsing,

    I have indeed also done the lesson 5.

    The security implementation is already in the course example and can be activated by setting CONFIG_BT_NUS_SECURITY_ENABLED=y

    Code-Snipped - already within the code:

    #ifdef CONFIG_BT_NUS_SECURITY_ENABLED
    static void security_changed(struct bt_conn *conn, bt_security_t level, enum bt_security_err 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("Security changed: %s level %u", addr, level);
    	}
    	else
    	{
    		LOG_WRN("Security failed: %s level %u err %d", addr, level, err);
    	}
    }
    #endif

    So I set this parameter and the security implementation is not working.

    Could you advise me how to make it work?

    Many thanks so far.

    Regards, Andreas

  • Thank you for the feedback. I will get back to you tomorrow.

  • Andreas Schurz said:

    The security implementation is already in the course example and can be activated by setting CONFIG_BT_NUS_SECURITY_ENABLED=y

    Code-Snipped - already within the code:

    One trick is to add a warning in your project, withing the ifdef for the kconfig that you are intending to use. That way the string you enter next to #warning will be printed when you build the code, only if that kconfig is active. See an example below:

    #ifdef CONFIG_BT_NUS_SECURITY_ENABLED
    #warning "Verifying that BT_NUS_SECURITY_ENABLED is enabled."
    static void security_changed(struct bt_conn *conn, bt_security_t level, enum bt_security_err 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("Security changed: %s level %u", addr, level);
    	} else {
    		LOG_WRN("Security failed: %s level %u err %d", addr, level, err);
    	}
    }
    #endif

  • Warning comes up then for me

    D:/bt-fund/lesson4/blefund_less4_exer3_solution/src/main.c:357:2: warning: #warning "Verifying that BT_NUS_SECURITY_ENABLED is enabled." [-Wcpp]
      357 | #warning "Verifying that BT_NUS_SECURITY_ENABLED is enabled."

Reply Children
No Data
Related