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

Intermittent Failed to ble_cfg_set. Error code: NRF_ERROR_SOFTDEVICE_NOT_ENABLED at connection open

Hi,

We are having problems with nRF52840 dongle.

Intermittently pc-ble-driver-py throws the error in the subject when trying to open interface to nRF52840 dongle. After the error the dongle always fails to open with NRF_ERROR_TIMEOUT until it is reflashed or power cycled. The error has happened with many dongles and occurs quite rarely.

Environment:

Host OS: Ubuntu 20.04 with 5.4.0-67-generic kernel

Dongle FW: connectivity_4.1.1_usb_with_s132_5.1.0.hex

pc-ble-driver-py==0.14.2

Any help available?

  • Hi,

    Which call returns NRF_ERROR_TIMEOUT, and what happens leading up to that point?

    Can you share code, at least leading up to the error, for potentially reproducing?

    The examples typically lack checks on the return value from various calls, are you checking/logging return values from all pc-ble-driver API calls?

    Do you have any log output from the application, and/or USB trace from the communication between application and Dongle?

    Regards,
    Terje

  • Hi,

    Thanks for the reply.

    from pc_ble_driver_py import config
    config.__conn_ic_id__ = 'NRF52'  # this line causes pylint trouble....
    from pc_ble_driver_py.ble_driver import BLEDriver, BLEAdvData, BLEGapAddr, BLEConfigConnGatts, BLEConfigConnGattc, \
        BLEConfigConnGap
    from pc_ble_driver_py.ble_driver import BLEGapSecStatus, BLEGapSecParams, BLEGapIOCaps, BLEGapSecKDist
    from pc_ble_driver_py.ble_driver import BLEUUIDBase, BLEUUID, BLEConfig, BLEConfigConnGatt
    from pc_ble_driver_py.ble_driver import BLEGapConnParams, BLEGapScanParams, BLEGapTimeoutSrc
    from pc_ble_driver_py.ble_adapter import BLEAdapter
    from pc_ble_driver_py.exceptions import NordicSemiException
    # pylint: enable-all
    
    
    class BleInterface(BLEDriverObserver, BLEAdapterObserver):
    
        NRF52_VID = int("1915", 16)
        NRF52_PID = int("C00A", 16)
    
        # NRF51_VID = int("1366", 16)
        # NRF51_PID = int("1015", 16)
    
        # pylint: disable=super-init-not-called
        def __init__(self, port, logger=get_null_logger()):
            """
            NRF52 Ble interface object
            :param port:
            :type port: str
            :param logger: Logger instance
            :type logger: Logger
            """
            self.logger = logger
            self._serial_port = port
            driver = BLEDriver(serial_port=port, baud_rate=115200)
            self.adapter = BLEAdapter(driver)
            self.adapter.observer_register(self)
            self.adapter.driver.observer_register(self)
            self._scanning = False
            self._devices = BleDeviceList(device_class=self._device_class)
            self._devices.set_logger(self.logger)
    
        def open(self, **kwargs):
            """
            Open NRF52 connection
            :param kwargs: config_conn_gatt:BLEConfigConnGatt
            :return: None
            """
            assert self.adapter, 'adapter does not exists'
            self.logger.debug(f'opening BLE interface (serial_port: {self._serial_port})')
            self.adapter.driver.open()
            config_conn_gatt = kwargs.get('config_conn_gatt')
    
            if config_conn_gatt:
                gatt_cfg_defaults = BLEConfigConnGatt()
                gatt_cfg_defaults.att_mtu = config_conn_gatt.get('att_mtu')
                gatt_cfg_defaults.tag = config_conn_gatt.get('tag')
                err = self.adapter.driver.ble_cfg_set(BLEConfig.conn_gatt, gatt_cfg_defaults)
                assert err is None, f'BLE config set failed with error: {err}'
    
            self.adapter.driver.ble_enable()


    self.adapter.driver.open() is the line that raises NRF_ERROR_TIMEOUT. BleInterface is initialized and then open is called. Those are the steps leading to the problem.
    No helpful log or USB trace is available without extra effort.

    We have created workaround based on nrfutil where on open failure dongle is reset by putting it to bootloader mode and bringing it back to normal mode.
    This seems to help, but is not optimal of course.

    Br,
    -Juho
  • Hi,

    have you solved your problem, or is it still unsolved? 

    Best regards,
    Kaja

  • Hey,

    The issue is not blocking anymore due to the dongle restart. It is not solved though.

    Br,

    -Juho

  • Hi,

    okay, I'm glad is not blocking anymore! Terje is out of office, could you create a new case, with your problem, if you want help with it, so that you get an engineer assigned to your case? 

    Best regards,
    Kaja

Related