eric7.MicroPython.Devices.RP2040Devices
Module implementing the device interface class for RP2040 based boards
(e.g. Raspberry Pi Pico).
Global Attributes
Classes
| RP2040Device | Class implementing the device for RP2040 based boards. | 
Functions
| createDevice | Function to instantiate a MicroPython device object. | 
RP2040Device
    Class implementing the device for RP2040 based boards.
Derived from
BaseDevice
Class Attributes
Class Methods
Methods
| RP2040Device | Constructor | 
| __activateBootloader | Private slot to switch the board into 'bootloader' mode. | 
| __createRP2040Menu | Private method to create the RP2040 submenu. | 
| __firmwareVersionResponse | Private slot handling the response of the latest version request. | 
| __flashPython | Private slot to flash a MicroPython firmware to the device. | 
| __resetCountry | Private slot to reset the country of the connected ESP32 device. | 
| __resetDevice | Private slot to reset the connected device. | 
| __setCountry | Private slot to configure the country of the connected RP2040 device. | 
| __showFirmwareVersions | Private slot to show the firmware version of the connected device and the available firmware version. | 
| _getSetTimeCode | Protected method to get the device code to set the time. | 
| activateBluetoothInterface | Public method to activate the Bluetooth interface. | 
| addDeviceMenuEntries | Public method to add device specific entries to the given menu. | 
| addDeviceWifiEntries | Public method to add device specific entries to the given menu. | 
| canRunScript | Public method to determine, if a script can be executed. | 
| canStartFileManager | Public method to determine, if a File Manager can be started. | 
| canStartPlotter | Public method to determine, if a Plotter can be started. | 
| canStartRepl | Public method to determine, if a REPL can be started. | 
| checkInternet | Public method to check, if the internet can be reached. | 
| checkInternetViaLan | Public method to check, if the internet can be reached (LAN variant). | 
| connectToLan | Public method to connect the connected device to the LAN. | 
| connectWifi | Public method to connect a device to a WiFi network. | 
| deactivateBluetoothInterface | Public method to deactivate the Bluetooth interface. | 
| deactivateEthernet | Public method to deactivate the Ethernet interface of the connected device. | 
| deactivateInterface | Public method to deactivate a given WiFi interface of the connected device. | 
| deviceName | Public method to get the name of the device. | 
| disableWebrepl | Public method to write the given WebREPL password to the connected device and modify the start script to start the WebREPL server. | 
| disconnectFromLan | Public method  to disconnect from the LAN. | 
| disconnectWifi | Public method to disconnect a device from the WiFi network. | 
| enableWebrepl | Public method to write the given WebREPL password to the connected device and modify the start script to start the WebREPL server. | 
| forceInterrupt | Public method to determine the need for an interrupt when opening the serial connection. | 
| getBluetoothStatus | Public method to get Bluetooth status data of the connected board. | 
| getConnectedClients | Public method to get a list of connected clients. | 
| getDeviceScan | Public method to perform a Bluetooth device scan. | 
| getDocumentationUrl | Public method to get the device documentation URL. | 
| getDownloadMenuEntries | Public method to retrieve the entries for the downloads menu. | 
| getEthernetStatus | Public method to get Ethernet status data of the connected board. | 
| getWifiData | Public method to get data related to the current WiFi status. | 
| hasBluetooth | Public method to check the availability of Bluetooth. | 
| hasEthernet | Public method to check the availability of Ethernet. | 
| hasFlashMenuEntry | Public method to check, if the device has its own flash menu entry. | 
| hasNetworkTime | Public method to check the availability of network time functions. | 
| hasWifi | Public method to check the availability of WiFi. | 
| hasWifiCountry | Public method to check, if the device has support to set the WiFi country. | 
| isLanConnected | Public method to check the LAN connection status. | 
| isWifiApConnected | Public method to check the WiFi connection status as access point. | 
| isWifiClientConnected | Public method to check the WiFi connection status as client. | 
| removeCredentials | Public method to remove the saved credentials from the connected device. | 
| removeLanAutoConnect | Public method to remove the saved IPv4 parameters from the connected device. | 
| runScript | Public method to run the given Python script. | 
| scanNetworks | Public method to scan for available WiFi networks. | 
| setButtons | Public method to enable the supported action buttons. | 
| setNetworkTime | Public method to set the time to the network time retrieved from an NTP server. | 
| startAccessPoint | Public method to start the access point interface. | 
| stopAccessPoint | Public method to stop the access point interface. | 
| writeCredentials | Public method to write the given credentials to the connected device and modify the start script to connect automatically. | 
| writeLanAutoConnect | Public method to generate a script and associated configuration to connect the device to the LAN during boot time. | 
Static Methods
RP2040Device (Constructor)
RP2040Device(microPythonWidget, deviceType, parent=None)
        Constructor
- microPythonWidget (MicroPythonWidget)
- 
reference to the main MicroPython widget
- deviceType (str)
- 
device type assigned to this device interface
- parent (QObject)
- 
reference to the parent object
RP2040Device.__activateBootloader
__activateBootloader()
        Private slot to switch the board into 'bootloader' mode.
RP2040Device.__createRP2040Menu
__createRP2040Menu()
        Private method to create the RP2040 submenu.
RP2040Device.__firmwareVersionResponse
__firmwareVersionResponse(reply)
        Private slot handling the response of the latest version request.
- reply (QNetworkReply)
- 
reference to the reply object
RP2040Device.__flashPython
__flashPython()
        Private slot to flash a MicroPython firmware to the device.
RP2040Device.__resetCountry
__resetCountry()
        Private slot to reset the country of the connected ESP32 device.
        The country is the two-letter ISO 3166-1 Alpha-2 country code. This method
        resets it to the default code 'XX' representing the "worldwide" region.
RP2040Device.__resetDevice
__resetDevice()
        Private slot to reset the connected device.
RP2040Device.__setCountry
__setCountry()
        Private slot to configure the country of the connected RP2040 device.
        The country is the two-letter ISO 3166-1 Alpha-2 country code.
RP2040Device.__showFirmwareVersions
__showFirmwareVersions()
        Private slot to show the firmware version of the connected device and the
        available firmware version.
RP2040Device._getSetTimeCode
_getSetTimeCode()
        Protected method to get the device code to set the time.
        Note: This method must be implemented in the various device specific
        subclasses.
- Return:
- 
code to be executed on the connected device to set the time
- Return Type:
- 
str
RP2040Device.activateBluetoothInterface
activateBluetoothInterface()
        Public method to activate the Bluetooth interface.
- Return:
- 
flag indicating the new state of the Bluetooth interface
- Return Type:
- 
bool
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.addDeviceMenuEntries
addDeviceMenuEntries(menu)
        Public method to add device specific entries to the given menu.
- menu (QMenu)
- 
reference to the context menu
RP2040Device.addDeviceWifiEntries
addDeviceWifiEntries(menu)
        Public method to add device specific entries to the given menu.
- menu (QMenu)
- 
reference to the context menu
RP2040Device.canRunScript
canRunScript()
        Public method to determine, if a script can be executed.
- Return:
- 
tuple containing a flag indicating it is safe to start a
            Plotter and a reason why it cannot.
- Return Type:
- 
tuple of (bool, str)
RP2040Device.canStartFileManager
canStartFileManager()
        Public method to determine, if a File Manager can be started.
- Return:
- 
tuple containing a flag indicating it is safe to start a
            File Manager and a reason why it cannot.
- Return Type:
- 
tuple of (bool, str)
RP2040Device.canStartPlotter
canStartPlotter()
        Public method to determine, if a Plotter can be started.
- Return:
- 
tuple containing a flag indicating it is safe to start a
            Plotter and a reason why it cannot.
- Return Type:
- 
tuple of (bool, str)
RP2040Device.canStartRepl
canStartRepl()
        Public method to determine, if a REPL can be started.
- Return:
- 
tuple containing a flag indicating it is safe to start a REPL
            and a reason why it cannot.
- Return Type:
- 
tuple of (bool, str)
RP2040Device.checkInternet
checkInternet()
        Public method to check, if the internet can be reached.
- Return:
- 
tuple containing a flag indicating reachability and an error string
- Return Type:
- 
tuple of (bool, str)
RP2040Device.checkInternetViaLan
checkInternetViaLan()
        Public method to check, if the internet can be reached (LAN variant).
- Return:
- 
tuple containing a flag indicating reachability and an error string
- Return Type:
- 
tuple of (bool, str)
RP2040Device.connectToLan
connectToLan(config, hostname)
        Public method to connect the connected device to the LAN.
- config (str or tuple of (str, str, str, str))
- 
configuration for the connection (either the string 'dhcp'
            for a dynamic address or a tuple of four strings with the IPv4 parameters.
- hostname (str)
- 
host name of the device
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.connectWifi
connectWifi(ssid, password, hostname)
        Public method to connect a device to a WiFi network.
- ssid (str)
- 
name (SSID) of the WiFi network
- password (str)
- 
password needed to connect
- hostname (str)
- 
host name of the device
- Return:
- 
tuple containing the connection status and an error string
- Return Type:
- 
tuple of (bool, str)
RP2040Device.deactivateBluetoothInterface
deactivateBluetoothInterface()
        Public method to deactivate the Bluetooth interface.
- Return:
- 
flag indicating the new state of the Bluetooth interface
- Return Type:
- 
bool
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.deactivateEthernet
deactivateEthernet()
        Public method to deactivate the Ethernet interface of the connected device.
- Return:
- 
tuple containg a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.deactivateInterface
deactivateInterface(interface)
        Public method to deactivate a given WiFi interface of the connected device.
- interface (str)
- 
designation of the interface to be deactivated (one of 'AP'
            or 'STA')
- Return:
- 
tuple containg a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
- Raises ValueError:
- 
raised to indicate a wrong value for the interface type
RP2040Device.deviceName
deviceName()
        Public method to get the name of the device.
- Return:
- 
name of the device
- Return Type:
- 
str
RP2040Device.disableWebrepl
disableWebrepl()
        Public method to write the given WebREPL password to the connected device and
        modify the start script to start the WebREPL server.
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.disconnectFromLan
disconnectFromLan()
        Public method  to disconnect from the LAN.
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.disconnectWifi
disconnectWifi()
        Public method to disconnect a device from the WiFi network.
- Return:
- 
tuple containing a flag indicating success and an error string
- Return Type:
- 
tuple of (bool, str)
RP2040Device.enableWebrepl
enableWebrepl(password)
        Public method to write the given WebREPL password to the connected device and
        modify the start script to start the WebREPL server.
- password (str)
- 
password needed to authenticate
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.forceInterrupt
forceInterrupt()
        Public method to determine the need for an interrupt when opening the
        serial connection.
- Return:
- 
flag indicating an interrupt is needed
- Return Type:
- 
bool
RP2040Device.getBluetoothStatus
getBluetoothStatus()
        Public method to get Bluetooth status data of the connected board.
- Return:
- 
list of tuples containing the translated status data label and
            the associated value
- Return Type:
- 
list of tuples of (str, str)
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.getConnectedClients
getConnectedClients()
        Public method to get a list of connected clients.
- Return:
- 
a tuple containing a list of tuples containing the client MAC-Address
            and the RSSI (if supported and available) and an error message
- Return Type:
- 
tuple of ([(bytes, int)], str)
RP2040Device.getDeviceScan
getDeviceScan(timeout=10)
        Public method to perform a Bluetooth device scan.
- timeout (int (optional))
- 
duration of the device scan in seconds (defaults
            to 10)
- Return:
- 
tuple containing a dictionary with the scan results and
            an error string
- Return Type:
- 
tuple of (dict, str)
RP2040Device.getDocumentationUrl
getDocumentationUrl()
        Public method to get the device documentation URL.
- Return:
- 
documentation URL of the device
- Return Type:
- 
str
RP2040Device.getDownloadMenuEntries
getDownloadMenuEntries()
        Public method to retrieve the entries for the downloads menu.
- Return:
- 
list of tuples with menu text and URL to be opened for each
            entry
- Return Type:
- 
list of tuple of (str, str)
RP2040Device.getEthernetStatus
getEthernetStatus()
        Public method to get Ethernet status data of the connected board.
- Return:
- 
list of tuples containing the translated status data label and
            the associated value
- Return Type:
- 
list of tuples of (str, str)
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.getWifiData
getWifiData()
        Public method to get data related to the current WiFi status.
- Return:
- 
tuple of three dictionaries containing the WiFi status data
            for the WiFi client, access point and overall data
- Return Type:
- 
tuple of (dict, dict, dict)
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.hasBluetooth
hasBluetooth()
        Public method to check the availability of Bluetooth.
- Return:
- 
flag indicating the availability of Bluetooth
- Return Type:
- 
bool
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.hasEthernet
hasEthernet()
        Public method to check the availability of Ethernet.
- Return:
- 
tuple containing a flag indicating the availability of Ethernet
            and the Ethernet type (picowiz)
- Return Type:
- 
tuple of (bool, str)
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.hasFlashMenuEntry
hasFlashMenuEntry()
        Public method to check, if the device has its own flash menu entry.
- Return:
- 
flag indicating a specific flash menu entry
- Return Type:
- 
bool
RP2040Device.hasNetworkTime
hasNetworkTime()
        Public method to check the availability of network time functions.
- Return:
- 
flag indicating the availability of network time functions
- Return Type:
- 
bool
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.hasWifi
hasWifi()
        Public method to check the availability of WiFi.
- Return:
- 
tuple containing a flag indicating the availability of WiFi
            and the WiFi type (picow or picowireless)
- Return Type:
- 
tuple of (bool, str)
- Raises OSError:
- 
raised to indicate an issue with the device
RP2040Device.hasWifiCountry
hasWifiCountry()
        Public method to check, if the device has support to set the WiFi country.
- Return:
- 
flag indicating the support of WiFi country
- Return Type:
- 
bool
RP2040Device.isLanConnected
isLanConnected()
        Public method to check the LAN connection status.
- Return:
- 
flag indicating that the device is connected to the LAN
- Return Type:
- 
bool
RP2040Device.isWifiApConnected
isWifiApConnected()
        Public method to check the WiFi connection status as access point.
- Return:
- 
flag indicating the WiFi connection status
- Return Type:
- 
bool
RP2040Device.isWifiClientConnected
isWifiClientConnected()
        Public method to check the WiFi connection status as client.
- Return:
- 
flag indicating the WiFi connection status
- Return Type:
- 
bool
RP2040Device.removeCredentials
removeCredentials()
        Public method to remove the saved credentials from the connected device.
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.removeLanAutoConnect
removeLanAutoConnect()
        Public method to remove the saved IPv4 parameters from the connected device.
        Note: This disables the LAN auto-connect feature.
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.runScript
runScript(script)
        Public method to run the given Python script.
- script (str)
- 
script to be executed
RP2040Device.scanNetworks
scanNetworks()
        Public method to scan for available WiFi networks.
- Return:
- 
tuple containing the list of available networks as a tuple of 'Name',
            'MAC-Address', 'channel', 'RSSI' and 'security' and an error string
- Return Type:
- 
tuple of (list of tuple of (str, str, int, int, str), str)
RP2040Device.setButtons
setButtons()
        Public method to enable the supported action buttons.
RP2040Device.setNetworkTime
setNetworkTime(server="pool.ntp.org", tzOffset=0, timeout=10)
        Public method to set the time to the network time retrieved from an
        NTP server.
- server (str (optional))
- 
name of the NTP server to get the network time from
            (defaults to "0.pool.ntp.org")
- tzOffset (int (optional))
- 
offset with respect to UTC (defaults to 0)
- timeout (int)
- 
maximum time to wait for a server response in seconds
            (defaults to 10)
- Return:
- 
tuple containing a flag indicating success and an error string
- Return Type:
- 
tuple of (bool, str)
RP2040Device.startAccessPoint
startAccessPoint(ssid, security=None, password=None, hostname=None, ifconfig=None, )
        Public method to start the access point interface.
- ssid (str)
- 
SSID of the access point
- security (int (optional))
- 
security method (defaults to None)
- password (str (optional))
- 
password (defaults to None)
- hostname (str (optional))
- 
host name of the device (defaults to None)
- ifconfig (tuple of (str, str, str, str))
- 
IPv4 configuration for the access point if not default
            (IPv4 address, netmask, gateway address, DNS server address)
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.stopAccessPoint
stopAccessPoint()
        Public method to stop the access point interface.
- Return:
- 
tuple containg a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.writeCredentials
writeCredentials(ssid, password, hostname, country)
        Public method to write the given credentials to the connected device and modify
        the start script to connect automatically.
- ssid (str)
- 
SSID of the network to connect to
- password (str)
- 
password needed to authenticate
- hostname (str)
- 
host name of the device
- country (str)
- 
WiFi country code
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
RP2040Device.writeLanAutoConnect
writeLanAutoConnect(config, hostname)
        Public method to generate a script and associated configuration to connect the
        device to the LAN during boot time.
- config (str or tuple of (str, str, str, str))
- 
configuration for the connection (either the string 'dhcp'
            for a dynamic address or a tuple of four strings with the IPv4 parameters.
- hostname (str)
- 
host name of the device
- Return:
- 
tuple containing a flag indicating success and an error message
- Return Type:
- 
tuple of (bool, str)
createDevice
createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber)
    Function to instantiate a MicroPython device object.
- microPythonWidget (MicroPythonWidget)
- 
reference to the main MicroPython widget
- deviceType (str)
- 
device type assigned to this device interface
- vid (int)
- 
vendor ID
- pid (int)
- 
product ID
- boardName (str)
- 
name of the board
- serialNumber (str)
- 
serial number of the board
- Return:
- 
reference to the instantiated device object
- Return Type:
- 
RP2040Device