Optional aGate address on the API (home-LAN direct connect)
AgateClient takes address= default; attach_local accepts address/host/gateway_ip per call with join control. An explicit address skips the SoftAP radio join by default (join=True forces it). derive_hotspot_credentials and join_device_hotspot accept a gateway_ip override. battery/power host defaults now use DEVICE_GATEWAY_IP. Verified live at 192.168.1.142:9000.
This commit is contained in:
1 parent
eda78dd7d1
commit
b60b32830f
4 files changed
+74
-24
No files matched your search
@@ -65,7 +65,8 @@ class HotspotJoinError(RuntimeError):
|
||||
"""A join was issued but the association never verified in time."""
|
||||
|
||||
|
||||
def derive_hotspot_credentials(sn: str) -> "HotspotProfile":
|
||||
def derive_hotspot_credentials(sn: str,
|
||||
gateway_ip: Optional[str] = None) -> "HotspotProfile":
|
||||
"""``getDeviceApSsid`` / ``getDeviceApDefaultPwd``.
|
||||
|
||||
Offline fallback: for a *20-character* SN the SSID is ``"AP_" + sn[11:]``
|
||||
@@ -74,6 +75,9 @@ def derive_hotspot_credentials(sn: str) -> "HotspotProfile":
|
||||
|
||||
The authoritative values come from the live device
|
||||
(``/terminal/getHotSpotInfo`` + ``/terminal/getHosSpotPassword``).
|
||||
|
||||
``gateway_ip`` overrides the default SoftAP gateway (``10.100.1.1``) —
|
||||
e.g. when the aGate is reached on its home-LAN address instead.
|
||||
"""
|
||||
if len(sn) == VALID_SN_LENGTH:
|
||||
ssid = "AP_" + sn[11:]
|
||||
@@ -83,7 +87,8 @@ def derive_hotspot_credentials(sn: str) -> "HotspotProfile":
|
||||
len(sn), VALID_SN_LENGTH)
|
||||
ssid = "AP_" + sn
|
||||
password = FALLBACK_PASSWORD
|
||||
return HotspotProfile(ssid=ssid, password=password)
|
||||
return HotspotProfile(ssid=ssid, password=password,
|
||||
gateway_ip=gateway_ip or DEVICE_GATEWAY_IP)
|
||||
|
||||
|
||||
class WifiBackend(ABC):
|
||||
@@ -308,9 +313,14 @@ class WifiManager:
|
||||
# -- device hotspot ------------------------------------------------------
|
||||
def join_device_hotspot(self, sn: str, *, verify: bool = True,
|
||||
settle_timeout: float = 30.0,
|
||||
poll_interval: float = 1.0) -> HotspotProfile:
|
||||
"""Derive the profile from the SN, join, and verify the association."""
|
||||
profile = derive_hotspot_credentials(sn)
|
||||
poll_interval: float = 1.0,
|
||||
gateway_ip: Optional[str] = None) -> HotspotProfile:
|
||||
"""Derive the profile from the SN, join, and verify the association.
|
||||
|
||||
``gateway_ip`` overrides the device address recorded on the
|
||||
profile (default ``10.100.1.1``) without changing the radio join.
|
||||
"""
|
||||
profile = derive_hotspot_credentials(sn, gateway_ip=gateway_ip)
|
||||
return self._join(profile, verify=verify,
|
||||
settle_timeout=settle_timeout,
|
||||
poll_interval=poll_interval)
|
||||
|
||||
Reference in new issue
Block a user