bug: fix a bug with older M20 units not identifying version correctly.
This commit is contained in:
@@ -240,7 +240,6 @@ class BTMinerAPI(BaseMinerAPI):
|
|||||||
command = {"cmd": command, **kwargs}
|
command = {"cmd": command, **kwargs}
|
||||||
|
|
||||||
token_data = await self.get_token()
|
token_data = await self.get_token()
|
||||||
print(token_data)
|
|
||||||
enc_command = create_privileged_cmd(token_data, command)
|
enc_command = create_privileged_cmd(token_data, command)
|
||||||
|
|
||||||
logging.debug(f"{self} - (Send Privileged Command) - Sending")
|
logging.debug(f"{self} - (Send Privileged Command) - Sending")
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ class BTMiner(BaseMiner):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
async def get_version(
|
async def get_version(
|
||||||
self, api_version: dict = None
|
self, api_version: dict = None, api_summary: dict = None
|
||||||
) -> Tuple[Optional[str], Optional[str]]:
|
) -> Tuple[Optional[str], Optional[str]]:
|
||||||
# check if version is cached
|
# check if version is cached
|
||||||
miner_version = namedtuple("MinerVersion", "api_ver fw_ver")
|
miner_version = namedtuple("MinerVersion", "api_ver fw_ver")
|
||||||
@@ -240,11 +240,31 @@ class BTMiner(BaseMiner):
|
|||||||
if api_version:
|
if api_version:
|
||||||
if "Code" in api_version.keys():
|
if "Code" in api_version.keys():
|
||||||
if api_version["Code"] == 131:
|
if api_version["Code"] == 131:
|
||||||
self.api_ver = api_version["Msg"]["api_ver"].replace(
|
try:
|
||||||
"whatsminer v", ""
|
api_ver = api_version["Msg"]
|
||||||
)
|
if not isinstance(api_ver, str):
|
||||||
self.fw_ver = api_version["Msg"]["fw_ver"]
|
api_ver = api_ver["api_ver"]
|
||||||
self.api.api_ver = self.api_ver
|
self.api_ver = api_ver.replace(
|
||||||
|
"whatsminer v", ""
|
||||||
|
)
|
||||||
|
self.fw_ver = api_version["Msg"]["fw_ver"]
|
||||||
|
except (KeyError, TypeError):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.api.api_ver = self.api_ver
|
||||||
|
return miner_version(self.api_ver, self.fw_ver)
|
||||||
|
|
||||||
|
if not api_summary:
|
||||||
|
try:
|
||||||
|
api_summary = await self.api.summary()
|
||||||
|
except APIError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if api_summary:
|
||||||
|
try:
|
||||||
|
self.fw_ver = api_summary["SUMMARY"][0]["Firmware Version"].replace("'", "")
|
||||||
|
except (KeyError, IndexError):
|
||||||
|
pass
|
||||||
|
|
||||||
return miner_version(self.api_ver, self.fw_ver)
|
return miner_version(self.api_ver, self.fw_ver)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user