diff --git a/pyasic/miners/backends/auradine.py b/pyasic/miners/backends/auradine.py index b472855c..0001efdc 100644 --- a/pyasic/miners/backends/auradine.py +++ b/pyasic/miners/backends/auradine.py @@ -193,6 +193,40 @@ class Auradine(StockFirmware): for key in conf.keys(): await self.web.send_command(command=key, **conf[key]) + async def upgrade_firmware(self, *, url: str = None, version: str = "latest", keep_settings: bool = False, **kwargs) -> bool: + """ + Upgrade the firmware of the Auradine device. + + Args: + url (str): The URL to download the firmware from. + version (str): The version of the firmware to upgrade to. + keep_settings (bool): Whether to keep the current settings during the upgrade. + + Returns: + bool: True if the firmware upgrade was successful, False otherwise. + """ + try: + logging.info("Starting firmware upgrade process.") + + if not url and not version: + raise ValueError("Either URL or version must be provided for firmware upgrade.") + + if url: + result = await self.web.firmware_upgrade(url=url) + else: + result = await self.web.firmware_upgrade(version=version) + + if result.get("STATUS", [{}])[0].get("STATUS") == "S": + logging.info("Firmware upgrade process completed successfully.") + return True + else: + logging.error(f"Firmware upgrade failed: {result.get('error', 'Unknown error')}") + return False + + except Exception as e: + logging.error(f"An error occurred during the firmware upgrade process: {str(e)}") + return False + ################################################## ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## diff --git a/pyasic/miners/backends/bfgminer.py b/pyasic/miners/backends/bfgminer.py index dda132ea..c3855d57 100644 --- a/pyasic/miners/backends/bfgminer.py +++ b/pyasic/miners/backends/bfgminer.py @@ -228,4 +228,4 @@ class BFGMiner(StockFirmware): expected_rate, HashUnit.SHA256.from_str(rate_unit) ).into(self.algo.unit.default) except LookupError: - pass + pass \ No newline at end of file diff --git a/pyasic/miners/base.py b/pyasic/miners/base.py index c0fd96fa..eb690821 100644 --- a/pyasic/miners/base.py +++ b/pyasic/miners/base.py @@ -560,5 +560,18 @@ class BaseMiner(MinerProtocol): if self._ssh_cls is not None: self.ssh = self._ssh_cls(ip) + async def upgrade_firmware(self, *, file: str = None, url: str = None, version: str = None, keep_settings: bool = True) -> bool: + """Upgrade the firmware of the miner. + + Parameters: + file (str, optional): The file path to the firmware to upgrade from. Must be a valid file path if provided. + url (str, optional): The URL to download the firmware from. Must be a valid URL if provided. + version (str, optional): The version of the firmware to upgrade to. If None, the version will be inferred from the file or URL. + keep_settings (bool, optional): Whether to keep the current settings during the upgrade. Defaults to True. + + Returns: + A boolean value of the success of the firmware upgrade. + """ + return False AnyMiner = TypeVar("AnyMiner", bound=BaseMiner) diff --git a/pyasic/miners/device/firmware.py b/pyasic/miners/device/firmware.py index efd2b974..d75fa82b 100644 --- a/pyasic/miners/device/firmware.py +++ b/pyasic/miners/device/firmware.py @@ -43,4 +43,4 @@ class LuxOSFirmware(BaseMiner): class MaraFirmware(BaseMiner): - firmware = MinerFirmware.MARATHON + firmware = MinerFirmware.MARATHON \ No newline at end of file