maix.network.wifi

maix.network.wifi module

You can use maix.network.wifi to access this module with MaixPy
This module is generated from MaixPy and MaixCDK

1. Module#

No module

2. Enum#

3. Variable#

4. Function#

4.1. list_devices#

def list_devices() -> list[str]

List WiFi interfaces

item description
return WiFi interface list, string type

C++ defination code:

std::vector<std::string> list_devices()

5. Class#

5.1. AP_Info#

WiFi AP info

C++ defination code:

class AP_Info

5.1.1. ssid#

WiFi AP info SSID

item description
type var
static False
readonly False

C++ defination code:

std::vector<uint8_t> ssid

5.1.2. bssid#

WiFi AP info BSSID

item description
type var
static False
readonly False

C++ defination code:

std::string bssid

5.1.3. security#

WiFi AP info security

item description
type var
static False
readonly False

C++ defination code:

std::string security

5.1.4. channel#

WiFi AP info channel

item description
type var
static False
readonly False

C++ defination code:

int channel

5.1.5. frequency#

WiFi AP info frequency

item description
type var
static False
readonly False

C++ defination code:

int frequency

5.1.6. rssi#

WiFi AP info rssi

item description
type var
static False
readonly False

C++ defination code:

int rssi

5.1.7. ssid_str#

def ssid_str(self) -> str

WiFi AP info ssid_str

item description
type func
static False

C++ defination code:

std::string ssid_str()

5.2. Wifi#

Wifi class

C++ defination code:

class Wifi

5.2.1. __init__#

def __init__(self, iface: str = 'wlan0') -> None

Wifi class

item description
type func
param iface: wifi interface name, default is wlan0
static False

C++ defination code:

Wifi(std::string iface = "wlan0")

5.2.2. get_ip#

def get_ip(self) -> str

Get current WiFi ip

item description
type func
return ip, string type, if network not connected, will return empty string.
static False

C++ defination code:

std::string get_ip()

5.2.3. get_mac#

def get_mac(self) -> str

Get current WiFi MAC address

item description
type func
return ip, string type.
static False

C++ defination code:

std::string get_mac()

5.2.4. get_ssid#

def get_ssid(self, from_cache: bool = True) -> str

Get current WiFi SSID

item description
type func
param from_cache: if true, will not read config from file, direct use ssid in cache.
attention, first time call this method will auto matically read config from file, and if call connect method will set cache.
return SSID, string type.
static False

C++ defination code:

std::string get_ssid(bool from_cache = true)

5.2.5. get_gateway#

def get_gateway(self) -> str

Get current WiFi ip

item description
type func
return ip, string type, if network not connected, will return empty string.
static False

C++ defination code:

std::string get_gateway()

5.2.6. start_scan#

def start_scan(self) -> maix.err.Err

WiFi start scan AP info around in background.

item description
type func
return If success, return err.Err.ERR_NONE, else means failed.
static False

C++ defination code:

err::Err start_scan()

5.2.7. get_scan_result#

def get_scan_result(self) -> list[AP_Info]

Get WiFi scan AP info.

item description
type func
return wifi.AP_Info list.
static False

C++ defination code:

std::vector<network::wifi::AP_Info> get_scan_result()

5.2.8. stop_scan#

def stop_scan(self) -> None

Stop WiFi scan AP info.

item description
type func
static False

C++ defination code:

void stop_scan()

5.2.9. connect#

def connect(self, ssid: str, password: str, wait: bool = True, timeout: int = 60) -> maix.err.Err

Connect to WiFi AP.

item description
type func
param ssid: SSID of AP
password: password of AP, if no password, leave it empty.
wait: wait for got IP or failed or timeout.
timeout: connect timeout internal, unit second.
return If success, return err.Err.ERR_NONE, else means failed.
static False

C++ defination code:

err::Err connect(const std::string &ssid, const std::string &password, bool wait = true, int timeout = 60)

5.2.10. disconnect#

def disconnect(self) -> maix.err.Err

Disconnect from WiFi AP.

item description
type func
return If success, return err.Err.ERR_NONE, else means failed.
static False

C++ defination code:

err::Err disconnect()

5.2.11. is_connected#

def is_connected(self) -> bool

See if WiFi is connected to AP.

item description
type func
return If connected return true, else false.
static False

C++ defination code:

bool is_connected()

5.2.12. start_ap#

def start_ap(self, ssid: str, password: str, mode: str = 'g', channel: int = 0, ip: str = '192.168.66.1', netmask: str = '255.255.255.0', hidden: bool = False) -> maix.err.Err

Start WiFi AP.

item description
type func
param ssid: SSID of AP.
password: password of AP, if no password, leave it empty.
ip: ip address of hostap, default empty string means auto generated one according to hardware.
netmask: netmask, default 255.255.255.0, now only support 255.255.255.0 .
mode: WiFi mode, default g(IEEE 802.11g (2.4 GHz)), a = IEEE 802.11a (5 GHz), b = IEEE 802.11b (2.4 GHz).
channel: WiFi channel number, 0 means auto select. MaixCAM not support auto, will default channel 1.
hidden: hidden SSID or not.
return If success, return err.Err.ERR_NONE, else means failed.
static False

C++ defination code:

err::Err start_ap(const std::string &ssid, const std::string &password,
                          std::string mode = "g", int channel = 0,
                          const std::string &ip = "192.168.66.1", const std::string &netmask = "255.255.255.0",
                          bool hidden = false)

5.2.13. stop_ap#

def stop_ap(self) -> maix.err.Err

Stop WiFi AP.

item description
type func
return If success, return err.Err.ERR_NONE, else means failed.
static False

C++ defination code:

err::Err stop_ap()

5.2.14. is_ap_mode#

def is_ap_mode(self) -> bool

Whether WiFi is AP mode

item description
type func
return True if AP mode now, or False.
static False

C++ defination code:

bool is_ap_mode()