Making changes in "Server Setup" for "nRF52840 Dongle" in "nRF Connect for Desktop Bluetooth Low Energy" doesn't save changes to dongle.

The "nRF52840 Dongle" defaults to a max length of 20 in all of the "General Access" characteristics and I'm trying to change that to a higher number. I change it to 60 for each of the characteristics, save each characteristic and then apply the changes to the device. Reload the dongle and the values are back to 20. I tried creating a new service and once again, the new service not saved.

I'm trying to get the dongle to transmit and receive more then just 20 bytes at a time.

Any idea of how to do this?

Parents
  • Hi, 

    You can save the setup and load it when you need. See Configuring server setup

    Regards,
    Amanda H.

  • Yep, I've done that but that's not the problem. The changes don't seem to be getting saved to the dongle. Even though I changed the max data length to 60, the BLE code in my 52840 still reports 20 when making a connection to the dongle.

    Also, see the attached screen shot above.

    //
    // BLE connected callback
    //
    static void connected_cb(struct bt_conn *conn, uint8_t err)
    {
        char addr[BT_ADDR_LE_STR_LEN];
    
        if (err)
        {
            LOG_DBG("Connection failed (err %u)", err);
            return;
        }
    
        bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
        current_conn = bt_conn_ref(conn);
    
        LOG_INF("Connected %s; Max data length: %u", addr, bt_nus_get_mtu(current_conn));
    }

  • Hi, 

    From your screenshot, you are setting the max length of a characteristic to 60. This is not the same as setting the data length of a connection. And in the code snippet, it looks like the MTU is logged, not the data length. To set the Data Length or MTU in the nRF Connect BLE app, see this screenshot:

    -Amanda H.

  • If I am to set the MTU prior to pairing, then how do I accomplish this within python using your pc-ble-driver-py Python package? I wrote a Python tool using your pc-ble-driver-py v0.17.0 to pull test data through BLE but I'm limited to 20 byte packets. The real goal is to not be limited to 20 byte packets. Thought I had to set the dongle for this. Connecting to the the BLE via your Android app nRT Toolbox is not limited to 20 byte packets, more like 60 byte packets.

    I set the default MTU to 250 but yet I'm limited to 20 byte packets.

    Line 46: self.adapter.default_mtu = 250

    Below is the relevant code that directly connects to your Python package. Any ideas?

    # Hard code the conn_ic_id because this is the only one we will use
    # and the pc_ble_driver_py Python library checks the value
    from pc_ble_driver_py import config
    config.__conn_ic_id__ = 'NRF52'
    
    from pc_ble_driver_py.observers import *
    from pc_ble_driver_py.ble_adapter import BLEAdapter
    from pc_ble_driver_py.ble_driver import (
            BLEDriver,
            BLEAdvData,
            BLEEvtID,
            BLEEnableParams,
            BLEGapTimeoutSrc,
            BLEUUID,
            BLEGapScanParams,
            BLEConfigCommon,
            BLEConfig,
            BLEConfigConnGatt,
            BLEConfigConnGap
        )
    import time, logging
    
    class NordicBleDriver(BLEDriverObserver, BLEAdapterObserver):
        def __init__(self, comport=None, notificationCallback=None, connectCallback=None, disconnectCallback=None, timeoutCallback=None):
            super(NordicBleDriver, self).__init__()
            self.comport = comport
            self.adapter = None
            self.scanCapture = []
            self.active_conn = {}
            self.notificationCallback = notificationCallback
            self.connectCallback = connectCallback
            self.disconnectCallback = disconnectCallback
            self.timeoutCallback = timeoutCallback
    
        def open(self, comport=None, conn_count=1):
            '''
            Open the connection to the comport
            '''
            if comport:
                self.comport = comport
    
            driver = BLEDriver( serial_port=self.comport, auto_flash=False, baud_rate=1000000, log_severity_level="info")
            self.adapter = BLEAdapter(driver)
            self.adapter.observer_register(self)
            self.adapter.driver.observer_register(self)
            self.adapter.default_mtu = 250
            self.adapter.driver.open()
            gatt_cfg = BLEConfigConnGatt()
            gatt_cfg.att_mtu = self.adapter.default_mtu
            gatt_cfg.tag = 1
            self.adapter.driver.ble_cfg_set(BLEConfig.conn_gatt, gatt_cfg)
            gap_cfg = BLEConfigConnGap()
            gap_cfg.conn_count = conn_count
            self.adapter.driver.ble_cfg_set(BLEConfig.conn_gap, gap_cfg)
            self.adapter.driver.ble_enable()
    
        def close(self):
            '''
            Close the connection to the comport
            '''
            self.adapter.driver.close()
            self.adapter = None
    
        def scan(self, blocking = True, scan_duration = 5):
            '''
            Scan for other BLE devices
            '''
            self.scanCapture = []
            params = BLEGapScanParams(interval_ms=200, window_ms=150, timeout_s=scan_duration)
            self.adapter.driver.ble_gap_scan_start(scan_params=params)
            if blocking:
                time.sleep(scan_duration)
    
        def advertise(self):
            '''
            Advertise this BLE
            '''
            adv_data = BLEAdvData(complete_local_name="nordic_ble_driver_py")
            self.adapter.driver.ble_gap_adv_data_set(adv_data)
            self.adapter.driver.ble_gap_adv_start()
    
        def connect(self, peer_addr, blocking = True):
            '''
            Connect to a peer address
            '''
            self.adapter.connect(peer_addr, tag=1)
            if blocking:
                while(self.adapter.conn_in_progress):
                    time.sleep(0.5)
    
        def disconnect(self, conn_handle):
            '''
            Disconnect from peer address
            '''
            self.adapter.disconnect(conn_handle)
    
        def disconnectAll(self):
            '''
            Disconnect from peer address
            '''
            keys = self.active_conn.copy().keys()
            for x in keys:
                self.adapter.disconnect(x)
    
        def discoverServices(self, conn_handle):
            '''
            Discover the services
            '''
            try:
                self.adapter.service_discovery(conn_handle)
            except Exception as e:
                logging.info(str(e))
    
        def enableNotification(self, conn_handle, uuid):
            '''
            Enable the notifications
            '''
            try:
                self.adapter.enable_notification(conn_handle, uuid)
            except Exception as e:
                logging.info(str(e))
    
        def write(self, conn_handle, uuid, data):
            '''
            Write data to device
            '''
            try:
                self.adapter.write_req(conn_handle, uuid, data)
            except Exception as e:
                logging.info(str(e))
    
        def getUUID(self, conn_handle, serviceUUID, charUUID):
            '''
            Get the UUID of the value
            '''
            if conn_handle != None:
                for s in self.adapter.db_conns[conn_handle].services:
                    if s.uuid.value == serviceUUID:
                        for c in s.chars:
                            if c.uuid.value == charUUID:
                                return c.uuid
            return None
    
        def addToList(self, name, peer_addr):
            '''
            Add connect to list keeping out the duplicates
            '''
            found = False
            for x in self.scanCapture:
                if x['name'] == name and get_addr_str(x['peer_addr']) == get_addr_str(peer_addr):
                    found = True
                    break
    
            if not found:
                self.scanCapture.append({'name': name, 'peer_addr': peer_addr})
    
        def on_gap_evt_adv_report(self, ble_driver, conn_handle, peer_addr, rssi, adv_type, adv_data):
            '''
            Observer call back during a scan
            '''
    
            if BLEAdvData.Types.complete_local_name in adv_data.records:
                self.addToList(bytes(adv_data.records[BLEAdvData.Types.complete_local_name]), peer_addr)
    
            elif BLEAdvData.Types.short_local_name in adv_data.records:
                self.addToList(bytes(adv_data.records[BLEAdvData.Types.short_local_name]), peer_addr)
    
        def on_notification(self, ble_adapter, conn_handle, uuid, data):
            '''
            On notification message handler
            '''
            if self.notificationCallback:
                # Send a copy so as to not get over written
                self.notificationCallback(ble_adapter, conn_handle, uuid, data.copy())
            else:
                logging.info("Connection: {}, {} = {}".format(conn_handle, uuid, data))
    
        def on_gap_evt_connected(self, ble_driver, conn_handle, peer_addr, role, conn_params):
            '''
            On connected message handler
            '''
            # Find the advertised name
            addr = peer_addr.addr
            adv_name = ''
            for x in self.scanCapture:
                if addr == x['peer_addr'].addr:
                    adv_name = x['name']
                    break
    
            self.active_conn[conn_handle] = {'adv_name': adv_name.decode(), 'peer_addr': peer_addr.addr}
            if self.connectCallback:
                self.connectCallback(ble_driver, conn_handle, adv_name.decode(), peer_addr, role, conn_params)
            else:
                logging.info("New connection: {}".format(conn_handle))
    
        def on_gap_evt_disconnected(self, ble_driver, conn_handle, reason):
            '''
            On disconnected message handler
            '''
            if conn_handle in self.active_conn:
                del self.active_conn[conn_handle]
    
            if self.disconnectCallback:
                self.disconnectCallback(ble_driver, conn_handle, reason)
            else:
                logging.info("Disconnected: {} {}".format(conn_handle, reason))
    
        def on_gap_evt_timeout(self, ble_driver, conn_handle, src):
            '''
            On disconnected message handler
            '''
    
            if self.timeoutCallback:
                self.timeoutCallback(ble_driver, conn_handle, src)
            else:
                logging.info("timeout: {} {}".format(conn_handle, src))
    
        def get_addr_str(self, peer_addr):
            return get_addr_str(peer_addr)
    

Reply
  • If I am to set the MTU prior to pairing, then how do I accomplish this within python using your pc-ble-driver-py Python package? I wrote a Python tool using your pc-ble-driver-py v0.17.0 to pull test data through BLE but I'm limited to 20 byte packets. The real goal is to not be limited to 20 byte packets. Thought I had to set the dongle for this. Connecting to the the BLE via your Android app nRT Toolbox is not limited to 20 byte packets, more like 60 byte packets.

    I set the default MTU to 250 but yet I'm limited to 20 byte packets.

    Line 46: self.adapter.default_mtu = 250

    Below is the relevant code that directly connects to your Python package. Any ideas?

    # Hard code the conn_ic_id because this is the only one we will use
    # and the pc_ble_driver_py Python library checks the value
    from pc_ble_driver_py import config
    config.__conn_ic_id__ = 'NRF52'
    
    from pc_ble_driver_py.observers import *
    from pc_ble_driver_py.ble_adapter import BLEAdapter
    from pc_ble_driver_py.ble_driver import (
            BLEDriver,
            BLEAdvData,
            BLEEvtID,
            BLEEnableParams,
            BLEGapTimeoutSrc,
            BLEUUID,
            BLEGapScanParams,
            BLEConfigCommon,
            BLEConfig,
            BLEConfigConnGatt,
            BLEConfigConnGap
        )
    import time, logging
    
    class NordicBleDriver(BLEDriverObserver, BLEAdapterObserver):
        def __init__(self, comport=None, notificationCallback=None, connectCallback=None, disconnectCallback=None, timeoutCallback=None):
            super(NordicBleDriver, self).__init__()
            self.comport = comport
            self.adapter = None
            self.scanCapture = []
            self.active_conn = {}
            self.notificationCallback = notificationCallback
            self.connectCallback = connectCallback
            self.disconnectCallback = disconnectCallback
            self.timeoutCallback = timeoutCallback
    
        def open(self, comport=None, conn_count=1):
            '''
            Open the connection to the comport
            '''
            if comport:
                self.comport = comport
    
            driver = BLEDriver( serial_port=self.comport, auto_flash=False, baud_rate=1000000, log_severity_level="info")
            self.adapter = BLEAdapter(driver)
            self.adapter.observer_register(self)
            self.adapter.driver.observer_register(self)
            self.adapter.default_mtu = 250
            self.adapter.driver.open()
            gatt_cfg = BLEConfigConnGatt()
            gatt_cfg.att_mtu = self.adapter.default_mtu
            gatt_cfg.tag = 1
            self.adapter.driver.ble_cfg_set(BLEConfig.conn_gatt, gatt_cfg)
            gap_cfg = BLEConfigConnGap()
            gap_cfg.conn_count = conn_count
            self.adapter.driver.ble_cfg_set(BLEConfig.conn_gap, gap_cfg)
            self.adapter.driver.ble_enable()
    
        def close(self):
            '''
            Close the connection to the comport
            '''
            self.adapter.driver.close()
            self.adapter = None
    
        def scan(self, blocking = True, scan_duration = 5):
            '''
            Scan for other BLE devices
            '''
            self.scanCapture = []
            params = BLEGapScanParams(interval_ms=200, window_ms=150, timeout_s=scan_duration)
            self.adapter.driver.ble_gap_scan_start(scan_params=params)
            if blocking:
                time.sleep(scan_duration)
    
        def advertise(self):
            '''
            Advertise this BLE
            '''
            adv_data = BLEAdvData(complete_local_name="nordic_ble_driver_py")
            self.adapter.driver.ble_gap_adv_data_set(adv_data)
            self.adapter.driver.ble_gap_adv_start()
    
        def connect(self, peer_addr, blocking = True):
            '''
            Connect to a peer address
            '''
            self.adapter.connect(peer_addr, tag=1)
            if blocking:
                while(self.adapter.conn_in_progress):
                    time.sleep(0.5)
    
        def disconnect(self, conn_handle):
            '''
            Disconnect from peer address
            '''
            self.adapter.disconnect(conn_handle)
    
        def disconnectAll(self):
            '''
            Disconnect from peer address
            '''
            keys = self.active_conn.copy().keys()
            for x in keys:
                self.adapter.disconnect(x)
    
        def discoverServices(self, conn_handle):
            '''
            Discover the services
            '''
            try:
                self.adapter.service_discovery(conn_handle)
            except Exception as e:
                logging.info(str(e))
    
        def enableNotification(self, conn_handle, uuid):
            '''
            Enable the notifications
            '''
            try:
                self.adapter.enable_notification(conn_handle, uuid)
            except Exception as e:
                logging.info(str(e))
    
        def write(self, conn_handle, uuid, data):
            '''
            Write data to device
            '''
            try:
                self.adapter.write_req(conn_handle, uuid, data)
            except Exception as e:
                logging.info(str(e))
    
        def getUUID(self, conn_handle, serviceUUID, charUUID):
            '''
            Get the UUID of the value
            '''
            if conn_handle != None:
                for s in self.adapter.db_conns[conn_handle].services:
                    if s.uuid.value == serviceUUID:
                        for c in s.chars:
                            if c.uuid.value == charUUID:
                                return c.uuid
            return None
    
        def addToList(self, name, peer_addr):
            '''
            Add connect to list keeping out the duplicates
            '''
            found = False
            for x in self.scanCapture:
                if x['name'] == name and get_addr_str(x['peer_addr']) == get_addr_str(peer_addr):
                    found = True
                    break
    
            if not found:
                self.scanCapture.append({'name': name, 'peer_addr': peer_addr})
    
        def on_gap_evt_adv_report(self, ble_driver, conn_handle, peer_addr, rssi, adv_type, adv_data):
            '''
            Observer call back during a scan
            '''
    
            if BLEAdvData.Types.complete_local_name in adv_data.records:
                self.addToList(bytes(adv_data.records[BLEAdvData.Types.complete_local_name]), peer_addr)
    
            elif BLEAdvData.Types.short_local_name in adv_data.records:
                self.addToList(bytes(adv_data.records[BLEAdvData.Types.short_local_name]), peer_addr)
    
        def on_notification(self, ble_adapter, conn_handle, uuid, data):
            '''
            On notification message handler
            '''
            if self.notificationCallback:
                # Send a copy so as to not get over written
                self.notificationCallback(ble_adapter, conn_handle, uuid, data.copy())
            else:
                logging.info("Connection: {}, {} = {}".format(conn_handle, uuid, data))
    
        def on_gap_evt_connected(self, ble_driver, conn_handle, peer_addr, role, conn_params):
            '''
            On connected message handler
            '''
            # Find the advertised name
            addr = peer_addr.addr
            adv_name = ''
            for x in self.scanCapture:
                if addr == x['peer_addr'].addr:
                    adv_name = x['name']
                    break
    
            self.active_conn[conn_handle] = {'adv_name': adv_name.decode(), 'peer_addr': peer_addr.addr}
            if self.connectCallback:
                self.connectCallback(ble_driver, conn_handle, adv_name.decode(), peer_addr, role, conn_params)
            else:
                logging.info("New connection: {}".format(conn_handle))
    
        def on_gap_evt_disconnected(self, ble_driver, conn_handle, reason):
            '''
            On disconnected message handler
            '''
            if conn_handle in self.active_conn:
                del self.active_conn[conn_handle]
    
            if self.disconnectCallback:
                self.disconnectCallback(ble_driver, conn_handle, reason)
            else:
                logging.info("Disconnected: {} {}".format(conn_handle, reason))
    
        def on_gap_evt_timeout(self, ble_driver, conn_handle, src):
            '''
            On disconnected message handler
            '''
    
            if self.timeoutCallback:
                self.timeoutCallback(ble_driver, conn_handle, src)
            else:
                logging.info("timeout: {} {}".format(conn_handle, src))
    
        def get_addr_str(self, peer_addr):
            return get_addr_str(peer_addr)
    

Children
Related