feature: add static IP configuration for whatsminers.
This commit is contained in:
@@ -550,6 +550,23 @@ class BTMinerAPI(BaseMinerAPI):
|
||||
self.pwd = new_pwd
|
||||
return data
|
||||
|
||||
async def net_config(
|
||||
self,
|
||||
ip: str = None,
|
||||
mask: str = None,
|
||||
gate: str = None,
|
||||
dns: str = None,
|
||||
host: str = None,
|
||||
dhcp: bool = True,
|
||||
):
|
||||
if dhcp:
|
||||
return await self.send_privileged_command("net_config", param="dhcp")
|
||||
if None in [ip, mask, gate, dns, host]:
|
||||
raise APIError("Incorrect parameters.")
|
||||
return await self.send_privileged_command(
|
||||
"net_config", ip=ip, mask=mask, gate=gate, dns=dns, host=host
|
||||
)
|
||||
|
||||
async def set_target_freq(self, percent: int) -> dict:
|
||||
"""Update the target frequency.
|
||||
|
||||
|
||||
@@ -548,3 +548,25 @@ class BTMiner(BaseMiner):
|
||||
pass
|
||||
|
||||
return self.light if self.light else False
|
||||
|
||||
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()
|
||||
await self.api.net_config(
|
||||
ip=ip, mask=subnet_mask, dns=dns, gate=gateway, host=hostname, dhcp=False
|
||||
)
|
||||
|
||||
async def set_dhcp(self, hostname: str = None):
|
||||
if hostname:
|
||||
await self.set_hostname(hostname)
|
||||
await self.api.net_config()
|
||||
|
||||
async def set_hostname(self, hostname: str):
|
||||
await self.api.set_hostname(hostname)
|
||||
|
||||
Reference in New Issue
Block a user