Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a75434fe7b | ||
|
|
020558ed4d | ||
|
|
39a82d03bc | ||
|
|
41ecb5dbc6 |
@@ -245,17 +245,25 @@ class BTMinerAPI(BaseMinerAPI):
|
|||||||
try:
|
try:
|
||||||
data = await self._send_bytes(enc_command, timeout)
|
data = await self._send_bytes(enc_command, timeout)
|
||||||
except (asyncio.CancelledError, asyncio.TimeoutError) as e:
|
except (asyncio.CancelledError, asyncio.TimeoutError) as e:
|
||||||
if command["cmd"] in ["reboot", "restart", "power_on"]:
|
if command["cmd"] in ["reboot", "restart_btminer", "power_on", "power_off"]:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"{self} - (reboot/restart/power_on) - Whatsminers currently break this. "
|
f"{self} - (reboot/restart_btminer/power_on/power_off) - Whatsminers currently break this. "
|
||||||
f"Ignoring exception. Command probably worked."
|
f"Ignoring exception. Command probably worked."
|
||||||
)
|
)
|
||||||
# FAKING IT HERE
|
# FAKING IT HERE
|
||||||
data = b'{"STATUS": "S", "When": 1670966423, "Code": 131, "Msg": "API command OK", "Description": "Reboot/restart/power_on"}'
|
data = (
|
||||||
|
b'{"STATUS": "S", "When": 1670966423, "Code": 131, "Msg": "API command OK", "Description": "'
|
||||||
|
+ command["cmd"].encode("utf-8")
|
||||||
|
+ b'"}'
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
|
if ignore_errors:
|
||||||
|
return {}
|
||||||
raise APIError("No data was returned from the API.")
|
raise APIError("No data was returned from the API.")
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
|
if ignore_errors:
|
||||||
|
return {}
|
||||||
raise APIError("No data was returned from the API.")
|
raise APIError("No data was returned from the API.")
|
||||||
data = self._load_api_data(data)
|
data = self._load_api_data(data)
|
||||||
|
|
||||||
|
|||||||
@@ -172,3 +172,53 @@ class BMMinerX19(BMMiner):
|
|||||||
return round(ideal_rate, 2)
|
return round(ideal_rate, 2)
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
async def set_static_ip(
|
||||||
|
self,
|
||||||
|
ip: str,
|
||||||
|
dns: str,
|
||||||
|
gateway: str,
|
||||||
|
subnet_mask: str = "255.255.255.0",
|
||||||
|
hostname: str = None,
|
||||||
|
):
|
||||||
|
if not hostname:
|
||||||
|
hostname = await self.get_hostname()
|
||||||
|
payload = {
|
||||||
|
"ipAddress": ip,
|
||||||
|
"ipDns": dns,
|
||||||
|
"ipGateway": gateway,
|
||||||
|
"ipHost": hostname,
|
||||||
|
"ipPro": 2, # static
|
||||||
|
"ipSub": subnet_mask,
|
||||||
|
}
|
||||||
|
await self.send_web_command("set_network_conf", params=payload)
|
||||||
|
|
||||||
|
async def set_dhcp(self, hostname: str = None):
|
||||||
|
if not hostname:
|
||||||
|
hostname = await self.get_hostname()
|
||||||
|
payload = {
|
||||||
|
"ipAddress": "",
|
||||||
|
"ipDns": "",
|
||||||
|
"ipGateway": "",
|
||||||
|
"ipHost": hostname,
|
||||||
|
"ipPro": 1, # DHCP
|
||||||
|
"ipSub": "",
|
||||||
|
}
|
||||||
|
await self.send_web_command("set_network_conf", params=payload)
|
||||||
|
|
||||||
|
async def set_hostname(self, hostname: str):
|
||||||
|
cfg = await self.send_web_command("get_network_info")
|
||||||
|
dns = cfg["conf_dnsservers"]
|
||||||
|
gateway = cfg["conf_gateway"]
|
||||||
|
ip = cfg["conf_ipaddress"]
|
||||||
|
subnet_mask = cfg["conf_netmask"]
|
||||||
|
protocol = 1 if cfg["conf_nettype"] == "DHCP" else 2
|
||||||
|
payload = {
|
||||||
|
"ipAddress": ip,
|
||||||
|
"ipDns": dns,
|
||||||
|
"ipGateway": gateway,
|
||||||
|
"ipHost": hostname,
|
||||||
|
"ipPro": protocol,
|
||||||
|
"ipSub": subnet_mask,
|
||||||
|
}
|
||||||
|
await self.send_web_command("set_network_conf", params=payload)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pyasic"
|
name = "pyasic"
|
||||||
version = "0.27.3"
|
version = "0.27.5"
|
||||||
description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH."
|
description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH."
|
||||||
authors = ["UpstreamData <brett@upstreamdata.ca>"]
|
authors = ["UpstreamData <brett@upstreamdata.ca>"]
|
||||||
repository = "https://github.com/UpstreamData/pyasic"
|
repository = "https://github.com/UpstreamData/pyasic"
|
||||||
|
|||||||
Reference in New Issue
Block a user