Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update network.pyi a bit #296

Merged
merged 8 commits into from
Jul 23, 2024
93 changes: 91 additions & 2 deletions typehints/micropython/network.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ network configuration.

Descriptions taken from:
https://raw.githubusercontent.com/micropython/micropython/master/docs/library/network.rst.
https://github.com/Josverl/micropython-stubs/blob/main/stubs/micropython-v1_19_1-esp32-GENERIC/network.py
****************************************

.. module:: network
Expand Down Expand Up @@ -49,6 +50,59 @@ from typing import Protocol, Callable, overload, Any, ClassVar, Final

import pyb

@overload
def country() -> str:
"""
Get the two-letter ISO 3166-1 Alpha-2 country code to be used for
radio compliance.

The default code ``"XX"`` represents the "worldwide" region.
"""

@overload
def country(code: str) -> None:
"""
Set the two-letter ISO 3166-1 Alpha-2 country code to be used for
radio compliance.

The default code ``"XX"`` represents the "worldwide" region.
"""

@overload
def hostname() -> str:
"""Get the hostname that will identify this device on the network. It will
be used by all interfaces.

This hostname is used for:
* Sending to the DHCP server in the client request. (If using DHCP)
* Broadcasting via mDNS. (If enabled)

The default hostname is typically the name of the board.
"""

@overload
def hostname(name: str) -> None:
"""Set the hostname that will identify this device on the network. It will
be used by all interfaces.

This hostname is used for:
* Sending to the DHCP server in the client request. (If using DHCP)
* Broadcasting via mDNS. (If enabled)

A change in hostname is typically only applied during connection. For DHCP
this is because the hostname is part of the DHCP client request, and the
implementation of mDNS in most ports only initialises the hostname once
during connection. For this reason, you must set the hostname before
activating/connecting your network interfaces.

The length of the hostname is limited to 32 characters.
:term:`MicroPython ports <MicroPython port>` may choose to set a lower
limit for memory reasons. If the given name does not fit, a `ValueError`
is raised.

The default hostname is typically the name of the board.
"""

MODE_11B: Final[int] = ...
"""IEEE 802.11b"""

Expand All @@ -57,8 +111,43 @@ MODE_11G: Final[int] = ...

MODE_11N: Final[int] = ...
"""IEEE 802.11n"""

STA_IF: int = 0
"""station interface"""

AP_IF: int = 1
"""access point interface"""

STAT_IDLE: int = 0
"""no connection and no activity"""

STAT_CONNECTING: int = 1
"""connecting in progress"""

STAT_WRONG_PASSWORD: int = 2
"""failed due to incorrect password"""

STAT_NO_AP_FOUND: int = 3
"""failed because no access point replied"""

STAT_CONNECT_FAIL: int = 4
"""failed due to other problems"""

STAT_GOT_IP: int = 5
"""connection successful"""

AUTH_OPEN: int = 0

AUTH_WEP:int = 1

AUTH_WPA_PSK: int = 2

AUTH_WPA2_PSK: int = 3

AUTH_WPA_WPA2_PSK: int = 4

@overload
def phy_mode(self) -> int:
def phy_mode() -> int:
"""
Get or set the PHY mode.

Expand All @@ -74,7 +163,7 @@ def phy_mode(self) -> int:
"""

@overload
def phy_mode(self, mode: int, /) -> None:
def phy_mode(mode: int, /) -> None:
"""
Get or set the PHY mode.

Expand Down
Loading