Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a75434fe7b | ||
|
|
020558ed4d | ||
|
|
39a82d03bc | ||
|
|
41ecb5dbc6 | ||
|
|
2d057ca9f6 | ||
|
|
b71b23d2a0 | ||
|
|
b32649435d | ||
|
|
c0096126df |
@@ -245,17 +245,25 @@ class BTMinerAPI(BaseMinerAPI):
|
||||
try:
|
||||
data = await self._send_bytes(enc_command, timeout)
|
||||
except (asyncio.CancelledError, asyncio.TimeoutError) as e:
|
||||
if command["cmd"] in ["reboot", "restart"]:
|
||||
if command["cmd"] in ["reboot", "restart_btminer", "power_on", "power_off"]:
|
||||
logging.info(
|
||||
f"{self} - (reboot/restart) - Whatsminers currently break this. "
|
||||
f"{self} - (reboot/restart_btminer/power_on/power_off) - Whatsminers currently break this. "
|
||||
f"Ignoring exception. Command probably worked."
|
||||
)
|
||||
# FAKING IT HERE
|
||||
data = b'{"STATUS": "S", "When": 1670966423, "Code": 131, "Msg": "API command OK", "Description": "Reboot"}'
|
||||
data = (
|
||||
b'{"STATUS": "S", "When": 1670966423, "Code": 131, "Msg": "API command OK", "Description": "'
|
||||
+ command["cmd"].encode("utf-8")
|
||||
+ b'"}'
|
||||
)
|
||||
else:
|
||||
if ignore_errors:
|
||||
return {}
|
||||
raise APIError("No data was returned from the API.")
|
||||
|
||||
if not data:
|
||||
if ignore_errors:
|
||||
return {}
|
||||
raise APIError("No data was returned from the API.")
|
||||
data = self._load_api_data(data)
|
||||
|
||||
|
||||
@@ -543,7 +543,7 @@ class BTMiner(BaseMiner):
|
||||
|
||||
if api_get_miner_info:
|
||||
try:
|
||||
self.light = api_get_miner_info["Msg"]["ledstat"] == "auto"
|
||||
self.light = not (api_get_miner_info["Msg"]["ledstat"] == "auto")
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -172,3 +172,53 @@ class BMMinerX19(BMMiner):
|
||||
return round(ideal_rate, 2)
|
||||
except (KeyError, IndexError):
|
||||
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]
|
||||
name = "pyasic"
|
||||
version = "0.27.1"
|
||||
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."
|
||||
authors = ["UpstreamData <brett@upstreamdata.ca>"]
|
||||
repository = "https://github.com/UpstreamData/pyasic"
|
||||
|
||||
Reference in New Issue
Block a user